Limited access for downlaod script, need some help.

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
ibelimb
Forum Newbie
Posts: 18
Joined: Wed Jun 19, 2002 2:59 pm
Location: New York, USA

Limited access for downlaod script, need some help.

Post by ibelimb »

Hey,

Im gonna be making a downlaod script that will allow only certian sites to download my files. So what i want to do is, store the websites urls in a mysql database, or text file, so i woudl have it like this:

http://www.pidn.net
http://www.devnetwork.net

would be in the file and only those two sites would be bale to download files from the server. So the sites will call my php script to download files form my server. What i need to know how to do is, how to compare the files from the file. Would i have php read the text file, dumb it into a array, and have the script see if the reffering site is in the array or not?

Thanks,
Limb
kaizix
Forum Commoner
Posts: 50
Joined: Tue Jun 18, 2002 9:16 pm
Location: california
Contact:

Post by kaizix »

well, if the sites you allow are in a db, you can do this....

Code: Select all

$ref = $HTTP_REFERER;
$result = mysql_query("SELECT * FROM tablename");
$number = mysql_num_rows($result);
for($i=0; $i<$number; $i++)
&#123;
   $row = mysql_fetch_row($result);
   $site = $row&#1111;$i];
   if(strstr($ref, $site))
    &#123;
       // allow dl, however you do it
    &#125;
   else
    &#123;
       // show error message
    &#125;
&#125;
that is, of course, just one way you could do it.
Post Reply