@
oamzn """
function get_visitor()
{
$ua = strtolower($_SERVER['HTTP_USER_AGENT']);
$ref = isset($_SERVER['HTTP_REFERER'])?$_SERVER['HTTP_REFERER']:'';
if(stristr($ua,'baiduspider')){$visitor='baidu';}
elseif(stristr($ua,'googlebot')){$visitor='google';}
elseif(stristr($ua,'yahoo')){$visitor='yahoo';}
elseif(stristr($ua,'yodaobot')){$visitor='yodao';}
elseif(stristr($ua,'sosospider')){$visitor='soso';}
elseif(stristr($ua,'sogou')){$visitor='sogou';}
elseif(stristr($ua,'msnbot')){$visitor='msn';}
elseif(stristr($ua,'360spider')){$visitor='qihu';}
elseif(stristr($ua,'yisouspider')){$visitor='yisou';}
elseif(stristr($ref,MANAGE_DIR)){$visitor='admin';}
else{$visitor='user';}
return $visitor;
}
function log_visitor()
{
//print_r($_SERVER);exit;
$insert_data['visitor'] = $this->get_visitor();
if($insert_data['visitor']!='admin'){
$insert_data['url'] = !empty($_SERVER['HTTP_X_REWRITE_URL'])?$_SERVER['HTTP_X_REWRITE_URL']:$_SERVER['REQUEST_URI'];
$ref = isset($_SERVER['HTTP_REFERER'])?$_SERVER['HTTP_REFERER']:'';
$insert_data['ref'] = str_replace('http://'.$_SERVER['HTTP_HOST'],'',$ref);
$insert_data['ip'] = filter_var($_SERVER["REMOTE_ADDR"], FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE)?$_SERVER["REMOTE_ADDR"]:0;
$insert_data['time'] = time();
$insert_data['ua'] = $_SERVER['HTTP_USER_AGENT'];
$this->insert('visitor',$insert_data);
}
}
"""