PHP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingPHP Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old December 15th, 2003, 06:45 PM
velocityX velocityX is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jun 2003
Posts: 72 velocityX User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 11 m 36 sec
Reputation Power: 6
Send a message via AIM to velocityX
PHP download.php check referer

does anyone know the code to check the referer in a download.php?

Reply With Quote
  #2  
Old December 15th, 2003, 07:12 PM
Mike_r Mike_r is offline
ExoCrew
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Dec 2003
Posts: 68 Mike_r User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
I have taken the following code directly from http://php.exocrew.com/?view=scripts (FormMail)

$referer_c = "1";
$referer = array("mysite.com","www.mysite.com");
$fail = "http://somesite.com/fail.html";

if($referer_c=="1") {
if(!isset($_REQUEST['grant'])) { // Check if user hasn't given a value for grant using url

while(list($key,$val)=each($referer)) {
if(strstr($_SERVER['HTTP_REFERER'],$val)) {
$grant = 'true';
} // End giving grant a value
} // End while
} // End if grant

if($grant!='true') {
header("Location: $fail");
exit;
}
}

But it cant be trusted as some browsers doesn't set the REFERER. I would rather prefer setting a cookie at the place where users gets the link to download the file, and then at download.php verify that the cookie exists.

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingPHP Development > PHP download.php check referer


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway
Stay green...Green IT