473,790 Members | 2,951 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

download counter?

Hi,

I'm trying to create a download counter for individual files on a web
site and I'm not sure how to do this. Right now I'm using Webalizer
to just read the log files and see how many times the files I'm
interested in were downloaded. The problem is Webalizer breaks it up
by month and I want a running total. I'd also like to see the counts
without having to log in to Webalizer in the first place. Not that
logging in or adding the results is too difficult, but it would be
nice if I could just put a little number on the web site so when I go
to the site I can imediately see the download counts.

The first thing I thought of was accessing the log files via PHP and
reading the data out of there. However because the log files get
broken up, zipped, and a new one started after they reach a certain
size I'm afraid this will be too complicated and may put too much
extra strain on the server if this is done too often.

Also, what's the best way to read log files with PHP anyway?

Any ideas?

Thanks.

->Later.....Spic e

Feb 7 '07
12 2918
It is. The PHP feed works fine. (http://www.thefump.com/cast.php)
But pointing the link tag to a PHP file instead of an audio file
generates a "this feed is not valid" error in iTunes.
->Later.....Spic e

As I said - if the header is correct, it should be OK.

I looked at your link, but I didn't see any php files being pointed to -
just the mp3 files themselves.
Sorry. Here's the code for the feed. It pulls the most recent 5
entries from the database (ignoring future ones that haven't gone live
yet) and formats it. It's based on the code I use to update my Manic
Mondays podcast (http://www.suddendeath.org/cast/feed.xml) which I've
never had a problem with. But those always point directly to the MP3
file.

->Later.....Spic e

<?php

// NOTE: All links point to the site folder, which must be changed
upon launch.

include("functi ons.php");

// Get the 5 most recent fumps.
$today = date("Y-m-d");
$fumpSQL = "SELECT * FROM fumps WHERE date<=CURDATE() ORDER BY date
DESC LIMIT 5";
$allFumps = getDataFromTabl e($fumpSQL);

// Calculate the last build date.
$lastFump = $allFumps[0];
$lastDate = $lastFump["date"]; // YYYY-MM-DD
$timestamp = strtotime($last Date);
$latestBuildDat e = date("D, d M Y", $timestamp);

echo "<?xml version=\"1.0\" ?>\r\n";
echo "<rss xmlns:itunes=\" http://www.itunes.com/DTDs/Podcast-1.0.dtd\"
version=\"2.0\" >\r\n";
echo "<channel>\r\n" ;
echo "<title>The FuMP</title>\r\n";
echo "<link>http ://www.thefump.com </link>\r\n";
echo "<description>T he Funny Music Project!</description>\r\ n";
echo "<lastBuildDate >".$latestBuild Date." 01:00:00 -0500</
lastBuildDate>\ r\n";
echo "<language> en-us</language>\r\n";
echo "<copyright>Cop yright ".date("Y") . " FIDIM Interactive, LLC</
copyright>\r\n" ;
echo "<generator>dir Castv0.4</generator>\r\n" ;
echo "<webMaster>su* ****@fidim.com</webMaster>\r\n" ;
echo "<ttl>60</ttl>\r\n\r\n";

echo "<!--iTunes specific tags-->\r\n";
echo "<itunes:catego ry text=\"Comedy\" />\r\n";
echo "<itunes:catego ry text=\"Movies &amp; Television\">\r \n"; //
NEED TO CONFIRM CATEGORY!
echo "<itunes:catego ry text=\"Music\" />\r\n";
echo "</itunes:category >\r\n\r\n";

echo "<itunes:keywor ds>Sudden Death, Worm Quartet, Luke Ski, Tom
Smith, Rob Balder, Raymond and Scum, fump, comedy, Dr. Demento,
dementia, funny music, funny songs, funny, weird, music</
itunes:keywords >\r\n";
echo "<itunes:subtit le>Funny music from some of todays hottest
dementia acts!</itunes:subtitle >\r\n";
echo "<itunes:summar y>The FuMP is a twice-weekly podcast featuring
new, rare, and unreleased songs by some of the biggest names in funny
music. These artists are regularly featured on The Dr. Demento Show
and routinely perform at science fiction conventions and other places
around the country.</itunes:summary> \r\n";
echo "<itunes:im age href=\"http://www.thefump.com/logo.jpg\" />\r
\n"; // NEED TO CREATE A LOGO GRAPHIC
echo "<itunes:author >FIDIM Interactive, LLC</itunes:author>\ r\n";
echo "<itunes:owner> \r\n";
echo "<itunes:name>T om Rockwell</itunes:name>\r\ n";
echo "<itunes:email> su*****@fidim.c om</itunes:email>\r \n";
echo "</itunes:owner>\r \n\r\n";

foreach ($allFumps as $fump) {

$artist = getData("name", "artists", $fump["artist"]);
$timestamp = strtotime($fump["date"]);
$buildDate = date("D, d M Y", $timestamp);
$link = sprintf("http://www.thefump.com/fumps/%s", $fump["mp3_128"]);
$size = filesize("fumps/".$fump["mp3_128"]);
if ($fump["explicit"] == "1") {
$explicit = "yes";
} else {
$explicit = "no";
}

echo "<item>\r\n ";
echo "<!--iTunes specific tags-->\r\n";
echo "<itunes:author >".$artist." </itunes:author>\ r\n";
echo "<itunes:durati on>".$fump["length"]."</itunes:duration >\r\n";
echo "<itunes:explic it>".$explicit. "</itunes:explicit >\r\n\r\n"; //
NEEDS TO BE YES OR NO

echo "<title>".$ fump["title"]."</title>\r\n";
echo "<link>".$link. "</link>\r\n";
echo "<description>" .$fump["descriptio n"]."</description>\r\ n";
echo "<pubDate>".$bu ildDate." 01:00:00 -0500</pubDate>\r\n";
echo "<enclosure url=\"".$link." \" length=\"".$siz e."\" type=\"audio/
mpeg\"/>\r\n";
echo "</item>\r\n";

}

echo "</channel>\r\n";
echo "</rss>\r\n";

?>

Feb 19 '07 #11
devospice wrote:
>>It is. The PHP feed works fine. (http://www.thefump.com/cast.php)
But pointing the link tag to a PHP file instead of an audio file
generates a "this feed is not valid" error in iTunes.
->Later.....Spic e
As I said - if the header is correct, it should be OK.

I looked at your link, but I didn't see any php files being pointed to -
just the mp3 files themselves.

Sorry. Here's the code for the feed. It pulls the most recent 5
entries from the database (ignoring future ones that haven't gone live
yet) and formats it. It's based on the code I use to update my Manic
Mondays podcast (http://www.suddendeath.org/cast/feed.xml) which I've
never had a problem with. But those always point directly to the MP3
file.

->Later.....Spic e

<?php

// NOTE: All links point to the site folder, which must be changed
upon launch.

include("functi ons.php");

// Get the 5 most recent fumps.
$today = date("Y-m-d");
$fumpSQL = "SELECT * FROM fumps WHERE date<=CURDATE() ORDER BY date
DESC LIMIT 5";
$allFumps = getDataFromTabl e($fumpSQL);

// Calculate the last build date.
$lastFump = $allFumps[0];
$lastDate = $lastFump["date"]; // YYYY-MM-DD
$timestamp = strtotime($last Date);
$latestBuildDat e = date("D, d M Y", $timestamp);

echo "<?xml version=\"1.0\" ?>\r\n";
echo "<rss xmlns:itunes=\" http://www.itunes.com/DTDs/Podcast-1.0.dtd\"
version=\"2.0\" >\r\n";
echo "<channel>\r\n" ;
echo "<title>The FuMP</title>\r\n";
echo "<link>http ://www.thefump.com </link>\r\n";
echo "<description>T he Funny Music Project!</description>\r\ n";
echo "<lastBuildDate >".$latestBuild Date." 01:00:00 -0500</
lastBuildDate>\ r\n";
echo "<language> en-us</language>\r\n";
echo "<copyright>Cop yright ".date("Y") . " FIDIM Interactive, LLC</
copyright>\r\n" ;
echo "<generator>dir Castv0.4</generator>\r\n" ;
echo "<webMaster>su* ****@fidim.com</webMaster>\r\n" ;
echo "<ttl>60</ttl>\r\n\r\n";

echo "<!--iTunes specific tags-->\r\n";
echo "<itunes:catego ry text=\"Comedy\" />\r\n";
echo "<itunes:catego ry text=\"Movies &amp; Television\">\r \n"; //
NEED TO CONFIRM CATEGORY!
echo "<itunes:catego ry text=\"Music\" />\r\n";
echo "</itunes:category >\r\n\r\n";

echo "<itunes:keywor ds>Sudden Death, Worm Quartet, Luke Ski, Tom
Smith, Rob Balder, Raymond and Scum, fump, comedy, Dr. Demento,
dementia, funny music, funny songs, funny, weird, music</
itunes:keywords >\r\n";
echo "<itunes:subtit le>Funny music from some of todays hottest
dementia acts!</itunes:subtitle >\r\n";
echo "<itunes:summar y>The FuMP is a twice-weekly podcast featuring
new, rare, and unreleased songs by some of the biggest names in funny
music. These artists are regularly featured on The Dr. Demento Show
and routinely perform at science fiction conventions and other places
around the country.</itunes:summary> \r\n";
echo "<itunes:im age href=\"http://www.thefump.com/logo.jpg\" />\r
\n"; // NEED TO CREATE A LOGO GRAPHIC
echo "<itunes:author >FIDIM Interactive, LLC</itunes:author>\ r\n";
echo "<itunes:owner> \r\n";
echo "<itunes:name>T om Rockwell</itunes:name>\r\ n";
echo "<itunes:email> su*****@fidim.c om</itunes:email>\r \n";
echo "</itunes:owner>\r \n\r\n";

foreach ($allFumps as $fump) {

$artist = getData("name", "artists", $fump["artist"]);
$timestamp = strtotime($fump["date"]);
$buildDate = date("D, d M Y", $timestamp);
$link = sprintf("http://www.thefump.com/fumps/%s", $fump["mp3_128"]);
$size = filesize("fumps/".$fump["mp3_128"]);
if ($fump["explicit"] == "1") {
$explicit = "yes";
} else {
$explicit = "no";
}

echo "<item>\r\n ";
echo "<!--iTunes specific tags-->\r\n";
echo "<itunes:author >".$artist." </itunes:author>\ r\n";
echo "<itunes:durati on>".$fump["length"]."</itunes:duration >\r\n";
echo "<itunes:explic it>".$explicit. "</itunes:explicit >\r\n\r\n"; //
NEEDS TO BE YES OR NO

echo "<title>".$ fump["title"]."</title>\r\n";
echo "<link>".$link. "</link>\r\n";
echo "<description>" .$fump["descriptio n"]."</description>\r\ n";
echo "<pubDate>".$bu ildDate." 01:00:00 -0500</pubDate>\r\n";
echo "<enclosure url=\"".$link." \" length=\"".$siz e."\" type=\"audio/
mpeg\"/>\r\n";
echo "</item>\r\n";

}

echo "</channel>\r\n";
echo "</rss>\r\n";

?>
OK, I'm not that familiar with the iTunes RSS feeds, but it looks OK.

It looks like iTunes does check the file extension, which is pretty
stupid. But maybe they do.

In this case, you would probably have to use Apache's mod_rewrite to
redirect the download. In your link tag put something like
"/tunes/mytune.mpg". Then have a redirect in your httpd.conf or
..htaccess file to redirect anything from the /tunes directory to your
script, passing the filename as a parameter. This might get you around
the restriction - I don't know what else iTunes might be looking for.

You can get more info on how to use mod_rewrite in alt.apache.conf iguration.

The only other think I could suggest would be that you ask the itunes
support people about it. They might have some answers. Or there might
be another tag you'd could fill in to handle it.
--
=============== ===
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attgl obal.net
=============== ===
Feb 20 '07 #12
In this case, you would probably have to use Apache's mod_rewrite to
redirect the download.
Interesting. I didn't know that could be done. I'll look into it.
Thanks.
The only other think I could suggest would be that you ask the itunes
support people about it. They might have some answers.
Yeah, I'm planning on doing that too. I just have lots of other
things to do first. :)

->Later.....Spic e

Feb 21 '07 #13

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
2426
by: Jim Willsher | last post by:
Hi all, PHP 4.2.2 on RedHat9 I have some files on my website for people to download, and I want to generate the file location "on the fly", so the URL is held in a database. I have a simple PHP script, pasted below. IE users are fine, but Mozilla users actually see the file contents on screen, as garbage, instead of being presented with the "save as" dialog.
4
2984
by: Bernhard | last post by:
I am not sure if php can achieve this, but i guess that my problem shoulb be solved with an server side language. Is there any way i can tell if a visitor of my website has finished a download? For example the visitor clicks on a file download link, and when his download is finished then i want to happen something (for example some download counter or something like that.)
3
20548
by: Michael | last post by:
I am trying to allow a user to view a PDF in a new window. I currently have this working using the following: <a href="./pdf.do?parameter=01121980" target="top"><b>pdf</b></a> The problem with the above solution is the back/forward buttons and all the other browser options. Because of this, I am trying to get the following solution to work: <a href="#" onclick="popUp('./pdf.do?parameter=01121980')"><b>pdf</b></a>
8
5261
by: William Starr Moake | last post by:
I'm trying to script a download counter that will display the total number on the download page without server-side scripting. Below is my very incomplete beginning. It returns no errors, but does nothing: <script language="JavaScript"> function addClicks() { total = "form1.value"; form1.value = (eval(total.value) + (1));
0
1799
by: Marius III | last post by:
Hi there, I am building a File download counter in PHP5. It's working fine but the problem is that its not working with any Download Managers for ex: Free Download Manager / DAP etc. The download manager downloads the actual PHP script file. How can I correct this? Here is my code:
5
1588
by: Mickey | last post by:
Hi all, Is there a way to find out when a user has completed a download? I ask this because I have a current system where users download files, however due to serious bandwidth issues I need to limit the amount of downloads at one time. Ideally, I want to be able to allow a maximum of 5 members to access the download page at one time (with one download per person at one
7
3440
by: mistral | last post by:
I use htaccess to protect directory and granting access to download file only for the authorized users. Just want implement simple PHP file download counter for single file. I need track the number of downloads of this file on my website, IP address and date. Since I have no access to Apache log files, I need some other way, use script that will write a log file. Is there some handy way? M.
3
1846
by: malaysiauser | last post by:
Dear all, Last year I install a download control script in Linux server. its working. This year i'd changed my hosting server to other company. i'd tried install the script. It was installed properly but doesn't work. More about the script; This script will log date, time, ip address, by day, by month, by year and analysis of downloads. It has 4 log files for one module (year, date...) Now the problem is if i create new module, it...
1
47490
KevinADC
by: KevinADC | last post by:
Note: You may skip to the end of the article if all you want is the perl code. Introduction Many websites have a form or a link you can use to download a file. You click a form button or click on a link and after a moment or two a file download dialog box pops-up in your web browser and prompts you for some instructions, such as “open” or “save“. I’m going to show you how to do that using a perl script. What You Need Any recent...
0
10419
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10201
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10147
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9987
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9023
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6770
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5424
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5552
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2910
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.