This is a complete system for file downloading, counting
and showing the statistics.
It consists of 5 files:
<download_cfg> the
configuration file for all components.
<confirm.php>
shows the file size / file date / number of downloads and checks availability
<download.php>
the actual download and creation of flatfile counters in the counter directory.
<downloadcount.php>
shows all downloaded files and the number of downloads + last download
date
<top10download>
Shows the top 10 or top 5 downloaded files.
<total downloaded files>
Counts total files downloaded + bandwidth used.
You will have to create 2 directories download and filecounter
or what ever name you want to give them.
The filecounter dir will only hold the counter files all named as downloadedfilename.txt,
so if the file test.zip is downloaded the counterfile will be test.zip.txt.
Make sure the filecounter dir is read/write!
The counterfile contains the counter + the short program
discription, separated by ::
To download a file create the following link in the page:
if you create a popup page with confirm, make sure the referer
is passed.
Sample:
<a href='confirm1.php?get=commenter.zip&pname=commenter 1.03' target="nWin"
onclick="javascript:NewWindow('',this.target,650,420,'no','center')">Link
text</a> This gives a real HTTP_REFERER and works perfectly.
NewWindow is a javascript to create a new window.
If all the download files are zip than in the configuration
put the extension as ".zip", dont forget the . (dot). You dont
have to mention the extension of the file to download.
If you have mixed files leave the extension setting as "" and
just mention the file+extension.
Top10download and downloadcounter can be called into any
page with an include().
The front page of Pondok PHP shows top10download configured as top 5.
If you want, open the confirm.php in a popup window, because after download
you will always come back to this screen. If you use a popup window, you
can remove the return button.
Pondok PHP is making use of the same download system.
Version 3 hides the download directory also in FireFox!
FireFox proved to reveal to much.....
Server speed and downloading.
A lot of downloads running together it may drag down the speed of your
server.
If you have hundreds of downloads, think about limiting the download
speed from the server.
(If non commercial)
It can be accomplished by using the header, a sample you find below: