php 獲取來路[前一頁]頁面分析函數
本文章提供一款功能全面的獲取上一級頁面的函數哦,就是來路函數了。
function getref(&$ref,&$fullref) {
global $err,$conf,$HTTP_GET_VARS,$_GET;
if(isset($_GET['anr'])) $refer=$_GET['anr'];
elseif(isset($HTTP_GET_VARS['anr'])) $refer=$HTTP_GET_VARS['anr'];
else $refer='undefined';
if(empty($refer)) $refer='undefined';
if(!strcmp($refer,'null')) $refer='undefined';
$refer=urldecode($refer);
$refer=modsec($refer);
$refer=txtproc($refer);
//to correct back slashes http://111cn.cnindex
$refer=str_replace("","/",$refer);
//to remove unnecessary points http://111cn.cn.
$refer=preg_replace("//./",'/',$refer);
$refer=preg_replace("/.//",'/',$refer);
$refer=preg_replace("/.*$/",'',$refer);
$refer=preg_replace("/("|')*$/",'',$refer);
//to remove unnecessary duplicates of slashes http://111cn.cn///
$refer=preg_replace("/([^:])(/)+/",'$1/',$refer);
$fullref=$refer;
$refer=preg_replace("/^(https?://)(www.)?/i",'',$refer);
$ref=preg_replace("/[?|&|#|;].*$/i",'',$refer);
$ref=preg_replace("/(/)*$/",'',$ref);
$ref=trim($ref);
$ref=preg_replace("/.*$/",'',$ref);
$ref=preg_replace("/("|')*$/",'',$ref);
$ref=trim($ref);
//check referrer (bad)
if(empty($ref)) $ref='undefined';
//search "." in domain name
if(!preg_match("/^([^./]+.)+([^./])+/i",$ref)) $ref='undefined';
}
}