Re: download counter?



"lorento" <laurente1234@xxxxxxxxx> píse v diskusním príspevku news:1170907412.690300.77580@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
I think you can make simple php application for count the download,
like:
when people click http://host/download.php?file=xyz.zip, the
download.php will increase the counter and the people will forwarded
into file xyz.zip

these are not the code but the algorithm:
1. create mysql table
create table counter (filename varchar(100), counter int);
insert into counter values ('xyz.zip', 0);
2. create download.php file:
//increase the counter table
update counter set counter = counter + 1 where filename like
'$_GET[file]'
//forward to file
header ("location: xyz.zip");

Better then redirecting is to read file in php script, send to browser and write to sql table after a file is complete send.

1. open file
2. read file and send to browser until EOF
3. increase counter in DB

This avoid a situation when user cancel download.
--

Petr Vileta, Czech republic
(My server rejects all messages from Yahoo and Hotmail. Send me your mail from another non-spammer site please.)



.