Re: Download tracker/counter

From: Date: Fri, 23 Mar 2007 19:29:46 +0000
Subject: Re: Download tracker/counter
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-251218@lists.php.net to get a copy of this message
Robert Wolfe wrote: [snip]
1)      Allow the downloads of said files.
readfile() is your friend here, although you will need to search around for the right HTTP headers to send as well.
2)      Count the number of time a file has been downloaded.
You could either look into creating a serialized array and writing/reading from that file - although you may have concurrency issues with this, or you could look into writing the counts into a database table (SQLlite, mySQL - you have a number of options here. There are *lots* of net tutorials for this.
3)      Record the IP addresses of the machines that download the files.
http://uk3.php.net/manual/en/reserved.variables.php#reserved.variables.server REMOTE_ADDR is the one you need. HTH, Mikey

« previous php.general (#251218) next »