Visited(); // 統計関数を呼び出します (公開ページ上で行うことが望ましい)
//访问量
訪問した関数(){
$now_time = time();
$referer_url = $_SERVER['HTTP_REFERER']; //出身の页面地址
$from_spider = $keywords = '';
if(!empty($referer_url)){
if(strstr($referer_url,'www.baidu.com')){
$referer_url =explode("&",$referer_url);
foreach($referer_url as $val){
if(strstr($val,'wd=')){
$keywords =explode("wd=",$val);
$keywords = $keywords[1];
}
}
$from_spider = '百度';
$keywords = urldecode($keywords);
}elseif(strstr($referer_url,'www.google')){
$referer_url =explode("&",$referer_url);
foreach($referer_url as $val){
if(strstr($val,'q=')){
$keywords =explode("q=",$val);
$keywords = $keywords[1];
}
}
$from_spider = '谷歌';
$keywords = urldecode($keywords);
}
}
//只判断百度和谷歌的、その他の原理一样
$theData = 配列(
'access_time' => $今、
'access_date' => date("Y-m-d",$now_time),
「access_url」 => $_SERVER['REQUEST_URI']、
'referer_url' => $_SERVER['HTTP_REFERER']、
「キーワード」 => $キーワード、
'ip_address' => $_SERVER['REMOTE_ADDR']、
'from_spider' => $from_spider、
);
$sql = "統計 (access_time,access_date,access_url,referer_url,keywords,ip_address,from_spider) 値 ('".$theData['access_time']."','".$theData['access_date']) に挿入します。" ','".$theData['access_url']."','".$theData['referer_url']."','".$theData['keywords']."','".$theData[ 'ip_address']."','".$theData['from_spider']."')";
$sql をエコーします。終了;mysql_query($sql);
}
|