|
Posted by Kimmo Laine on 09/02/05 18:49
"Ben Xia" <ben@jetcom.com> kirjoitti
viestissδ:05_Re.10522$884.867453@news20.bellglobal.com...
> Hello all:
>
> I want to know how many successful downloads from website, is there some
> PHP script can do this?
>
> Let's say I have file "abc.zip" people can download, The system is
> Apache+linux+php+mysql, how I can know exact how many successfully
> downloads and the download time.
>
> I know it can be done by weblog statistic, but I want to know is there
> some way in php can do it so I can save in database and view real time
> result.
>
> any help will be appreciate.
>
Make a file called download.php:
<?php
if(file_exists($file=$_REQUEST['file'])) {
header("Content-type: application/force-download");
header("Content-Length: ".filesize($file));
header("Content-Disposition: attachment; filename=$file");
readfile($file);
file_put_contents('counter.log', file_get_contents('counter.log')+1);
} else {
header("HTTP/1.0 404 Not Found");
}
?>
And make a downloadlink <a href="download.php?file=abc.zip">download</a>
Although this counts only attempted downloads, not succesful ones.
--
SETI @ Home - Donate your cpu's idle time to science.
Further reading at <http://setiweb.ssl.berkeley.edu/>
Kimmo Laine eternal.erectionN0@5P4Mgmail.com
[Back to original message]
|