.: Downloader :.
  Author: Albert
  Download: Complete Downloader V3.0 [ 20-11-2005 ] 11.4 kB     Globals OFF compat.
You came directly to this page. Links to Pondok: | Main Page | PHP Scripts |

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:

confirm.php?get=filetodownload&pname=shortdescription

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:

set_time_limit(0); //run unlimited time

$fileName = 'myFiles.zip';
$fileLocation = '/mypathtodownloads/hiddenDownloads/';

/* In kB/s */
$speed = 10; #THIS IS THE SPEED IN KB

header('Cache-control: private');
header('Content-Description: File Transfer');
header('Content-Type: application/force-download');
header('Content-Length: ' . filesize($fileLocation . $fileName));
header('Content-Disposition: attachment; filename=' . $fileName);

if (!$file = fopen($fileLocation . $fileName, 'rb')) {
exit;
}

while (!feof($file)) {
echo fread($file, $speed * 1024 * 8); #read speed in Kb x 8 bits
flush(); #do not wait send it now
sleep(1); #snorr 1 second
}

@fclose($file);


It is already incorporated in the downloader script.
You like this script?
Rate it now!

 

Number of ratings: 124
Rating: 3.9


Please use the forum for any questions!
This page has 1 comments. View/Add Comments.


Copyright AB Webservices 2002-2008 Last modified on: 20-11-2005 09:21:32
Page generated with php in: 0.090 seconds.This page has been viewed 25,709 times since June 2003.