|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
PHP download.php check referer
does anyone know the code to check the referer in a download.php?
|
|
#2
|
|||
|
|||
|
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. |
![]() |
| Viewing: Dev Articles Community Forums > Programming > PHP Development > PHP download.php check referer |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|