jon31
04-27-2006, 04:18 PM
Hey guys,
Is it possible to track the download of someone on my server? I want to find out if the person has completed the download or not. The files are usually 300+ MB.
Any ideas, or is it impossible?
Thanks,
Jon
Domainitor
04-27-2006, 04:24 PM
Depends on the server (software). If it's on a *nix platform and you're using FTP, the bytes downloaded'll be in the ftp transfer logs. If you're using a web server to front-end their client, the bytes downloaded will be in the web server's logs. Just about every server (program) logs what it's doing.... I'll bet the info's there somewhere.
jon31
04-27-2006, 04:27 PM
It's on a linux server running Apache. It's being served from a website via a download link. Good point about the log files. I'll just have to figure out which one, and how to parse it to get the downloading information.
Thanks for the tip.
SimonDurkee
04-27-2006, 08:57 PM
Be careful, most log files will show the total bytes of the file even if it wasn't completely downloaded. You'll want to test this first.
RWJDCom
04-27-2006, 09:27 PM
You could write a php script to monitor if the downloaded file has hit the last byte of the file thats being set to the user downloading the file and log it to like a database or a flat text file.
If you need something like this written for you let me know, i've already got something like this in one of my scripts.
Saeven
04-27-2006, 11:19 PM
You could write a script that opens a file descriptor in PHP for example, that flags a database when it starts and stops.
Example:
mysql_query( /* insert a stamp and identifier into the database */, DB );
$f = '/path/to/your/';
$n = 'file.zip';
header( "Content-type: application/octet-stream" );
header( "Content-Disposition: attachment; filename=\"$n\"" );
header( "Content-length:". filesize( $f.$n ) );
$fp = fopen( $f.$n , "rb" );
fpassthru( $fp );
fclose( $fp );
mysql_query( /* delete stamp previously inserted into the database */, DB );
HTH
Alex
RWJDCom
04-27-2006, 11:48 PM
Yup, that's exactly what i do with my script.
Xenatino
04-28-2006, 07:56 AM
What happens then if someone uses a Download Accelerator or Resume program? Wont it display twice?
mikey1090
04-28-2006, 10:12 AM
here is how i would go about it...
<a href=download.php?downloadid=1>Download a file here</a>
then in php
if ($downloadid==1) {
$result=mysql_query("UPDATE table SET download_file1=download_file1+1");
//that will track that someone has downloaded the file
Header("Location :link_to_the_file.exe");
//that will send the user to download that they requested
}
its simple really, when they click the link it updates the mysql table to +1 for that file, then redirects the page to the file they wanted to download
Domainitor
04-28-2006, 10:26 AM
...most log files will show the total bytes of the file even if it wasn't completely downloaded.
Can you give a few examples? I've never seen a mainstream Linux app lie in it's logs.
...it updates the mysql table to +1 for that file, then redirects...
The OP wants to track completion of the download.