Re: File Downloads

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

 



Yes the users will have gone through a registration and login to get to the downloads.
The files will be served from MySQL and output to HTML of Flash.

Karl


On May 28, 2010, at 6:27 PM, Systems wrote:

While DB logging is definitely the way to do it, I would suggest not to rely
on ip logging as authentication mechanism for following reasons:
Most end-users are on a dynamic IP.
One IP can/will serve multiple users (any large institution with wireless (Universities, Hospitals etc.) will have hundreds or thousands of people
surfing with one public IP - which is the IP you're logging)

Is there any reason not to log them in by personalized means? (such as
email/username)

-----Original Message-----
From: Karl DeSaulniers [mailto:karl@xxxxxxxxxxxxxxx]
Sent: Friday, May 28, 2010 6:39 PM
To: php-db@xxxxxxxxxxxxx
Subject: Re:  File Downloads

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



Karl DeSaulniers
Design Drumm
http://designdrumm.com


--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



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

  Powered by Linux