Re: [PHP-DB] File Downloads
[email protected] (Karl DeSaulniers)
| Newsgroups | php.db |
|---|---|
| Message-ID | <[email protected]> |
Nice breakdown. Thank you. Maybe set up a table that list all the files that user downloads successfully then revert their ability to download ones they already have? Its not that I necessarily am hell-bent on preventing one user from downloading a file again, I just want to set it up so the results they have to download from are -1 less every completed download. Hens the one they just downloaded is not there anymore. Thanks for your help. Karl On May 28, 2010, at 7:05 PM, Systems wrote: > In that case log by login var instead. > 1. Create a table that holds the link of the audio file > 2. create a join table between the user table and the audio table > 3. whenever someone logs in, set the join > 4. in your audio link display page set the link to display only if > count(id_user) of join is <150 or username Is logged in join table > (so the > 150 first authenticated users can retrieve the file more than once...) > > Good luck > Eli > > -----Original Message----- > From: Karl DeSaulniers [mailto:[email protected]] > Sent: Friday, May 28, 2010 7:40 PM > To: [email protected] > Subject: Re: [PHP-DB] File Downloads > > This is for a small project of limited edition audio or pictures or > scripts, > etc. > Hens, "I'd like" to limit each user in the allotted 150 to be able to > download (whatever it is) only once. > But up to 150 users can get in on it kind of thing. > > Karl > > On May 28, 2010, at 6:36 PM, Karl DeSaulniers wrote: > >> 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:[email protected]] >>> Sent: Friday, May 28, 2010 6:39 PM >>> To: [email protected] >>> Subject: Re: [PHP-DB] 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 >> > > Karl DeSaulniers > Design Drumm > http://designdrumm.com > > > -- > PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: > http://www.php.net/unsub.php > > > -- > PHP Database Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > Karl DeSaulniers Design Drumm http://designdrumm.com