Created
March 22, 2012 03:41
-
-
Save girvan/2155465 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
//input可以是單一字串,或是array | |
function must_referer($src){ | |
$src_arr=Array(); | |
if(empty($_SERVER['HTTP_REFERER'])) //一定要有referer url | |
exit; | |
$src_arr=(is_array($src))?$src:Array($src); | |
foreach($src_arr as $url) | |
if(strpos($_SERVER['HTTP_REFERER'],$url)===0) //一定要match到,而且是第一個字元就要match到 | |
return; //有match到,就結束這個function | |
exit; //都沒有match到,將整支程式結束掉 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment