Re: File Downloads

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On May 28, 2010, at 4:49 PM, Michael Stowe wrote:

For that you would probably need to setup a databased system in which (best scenario) they would need to register prior to downloading or (not so secure) capture their IP address and prevent that IP from downloading it again (example below).

Since you are already using the php script to detect the download, you could simply add (assuming MySQL) a Mysql query such as:

$result = mysql_query('select dt.downloads, ip.ip_address from downloads_table dt RIGHT JOIN downloads_ip ip ON ip.track_id = "% your track id%" AND ip.ip_address = "'.$_SERVER ['REMOTE_ADDRESS'].'" where dt.track_id = "%your track id%"');
$results = mysql_fetch_array($result);

if(($results['downloads'] <= 150) && (empty($results ['ip_address']))) {

mysql_query('INSERT INTO downloads_ip (track_id,ip_address) VALUES ("%track_id%","'.$_SERVER['REMOTE_ADDRESS'].'")'); // insert IP into downloads_ip table mysql_query('UPDATE downloads_table SET downloads = downloads + 1 WHERE track_id = "%track_id%" LIMIT 1'); // update the count of the downloads
// do download here

} elseif (!empty($results['ip_address'])) {
echo 'you have already downloaded this track...';

} else {
echo 'this track is no longer available for download';
}


(note I haven't checked the code, but it should give you a quick example of how you can keep track of this)

Hope this helps, and if you have any questions just let me know.

Take care,
Mike :o)



"My command is this: Love each other as I
have loved you."                         John 15:12

-----------------------


Oh my.. thank you for that.



Karl DeSaulniers
Design Drumm
http://designdrumm.com


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux