数据采集脚本如下:
error_reporting(0);
date_default_timezone_set("PRC");
$environment = get_cfg_var('app_flow_develop') ? get_cfg_var('app_flow_develop') : 3;
define('BASEPATH',dirname(dirname(__FILE__)));
switch($environment){
case 1 :
require BASEPATH . DIRECTORY_SEPARATOR . 'conf' . DIRECTORY_SEPARATOR . 'config.product.php';
break;
case 2 :
require BASEPATH . DIRECTORY_SEPARATOR . 'conf' . DIRECTORY_SEPARATOR . 'config.product.php';
break;
default:
require BASEPATH . DIRECTORY_SEPARATOR . 'conf' . DIRECTORY_SEPARATOR . 'config.develop.php';
break;
}
require BASEPATH . DIRECTORY_SEPARATOR . 'lib' . DIRECTORY_SEPARATOR . 'logger.class.php';
$log_base = new Logger($LOG_BASE . DIRECTORY_SEPARATOR . 'error.log');
//判断后是来着检查站点
if((!isset($_COOKIE['YPTJACCOUNT']) || $_COOKIE['YPTJACCOUNT'] != $_GET['si'])){
exit(0);
}
//无会话记录也不会记录
if(!isset($_COOKIE['YPTJUUID'])){
exit(0);
}
//获取客户端ip
get_request_ip();
//获取客户端请求时间
get_request_time();
//获取客户端的来源于关键词
get_request_su_kd();
//获取客户端请求的url地址分级
get_request_u();
//获取其他一般参数
get_other_params(); //cc : 是否支持写数据到浏览器(cookie,sessionStorage,localStorage,userData)
//ck : 是否支持cookie
//cl : 浏览器颜色位数
//ds : 浏览器分辨率
//fl : flash版本
//ja : 是否支持java
//ln : 浏览器语言
//si : 统计id,站点标示
//su : 来源url,只取了域名
//kd : 关键词
//tt : 站点title
//cf : m点 1,站点0
//uid : 会员id
//pt : 平台
//ocu : 操作系统
//ua : 浏览器类型
//tm : 请求时间
//ip : 请求ip
//u : 站点url
//uuid:唯一用户标识
//basesu:原始su
//baseu:原始u
//basekd:原始关键词
//u1:一级连接
//u2:二级连接
//u3:三级连接
//u4:四级连接 $savelogA = array(
'cc'=>$rq_cc,
'ck'=>$rq_ck,
'cl'=>$rq_cl,
'ds'=>$rq_ds,
'fl'=>$rq_fl,
'ja'=>$rq_ja,
'ln'=>$rq_ln,
'si'=>$rq_si,
'su'=>$rq_su,
'kd'=>$rq_kd,
'tt'=>$rq_tt,
'cf'=>$rq_cf,
'uid'=>$rq_uid,
'pt'=>$rq_pt,
'ocu'=>$rq_ocu,
'ua'=>$rq_ua,
'tm'=>$rq_tm,
'ip'=>$rq_ip,
'u'=>$rq_u,
'uuid'=>$rq_uuid,
'basesu'=>$rq_basesu,
'baseu'=>$rq_baseu,
'basekd'=>$rq_basekd,
'u1'=>$rq_u1,
'u2'=>$rq_u2,
'u3'=>$rq_u3,
'u4'=>$rq_u4
); //查找记录的目录路径
$time = time();
$Ymd = date("Ymd",$time);
$H = date("G",$time);
$i = floor(date("i",$time)/5);
$LOG_PATH = $LOG_BASE . DIRECTORY_SEPARATOR . $Ymd . DIRECTORY_SEPARATOR . $H . DIRECTORY_SEPARATOR . $i; //创建记录的目录文件夹
if(!file_exists($LOG_PATH)){
$mk_re = mkdir($LOG_PATH,0777,true);
if(false === $mk_re){
$log_base -> error('mkdir '.$LOG_PATH. ' false');
}
chmod(dirname(dirname($LOG_PATH)),0777);
chmod(dirname($LOG_PATH),0777);
chmod($LOG_PATH,0777);
}
//随机记录文本
$rand = mt_rand(0,500); //做all.log的判断,如果这个目录合并过,日志追加.after后缀,以防时间不一致
if(file_exists($LOG_PATH .DIRECTORY_SEPARATOR . 'all.log')){
$log_data = new Logger($LOG_PATH .DIRECTORY_SEPARATOR . $rand . '.log.after');
$log_data -> log(implode('~^~',$savelogA),false);
}else{
$log_data = new Logger($LOG_PATH .DIRECTORY_SEPARATOR . $rand . '.log');
$log_data -> log(implode('~^~',$savelogA),false);
}
exit; function get_other_params(){
global $rq_cc,$rq_ck,$rq_cl,$rq_ds,$rq_fl,$rq_ja,$rq_ln,$rq_si,$rq_tt,$rq_cf,$rq_uid,$rq_pt,$rq_ocu,$rq_ua,$rq_uuid;
isset($_GET['cc']) ? $rq_cc = intval($_GET['cc']) : $rq_cc = 0;
isset($_GET['ck']) ? $rq_ck = intval($_GET['ck']) : $rq_ck = 0;
isset($_GET['cl']) && strlen($_GET['cl']) < 10 ? $rq_cl = $_GET['cl'] : $rq_cl = 0;
isset($_GET['ds']) && strlen($_GET['ds']) < 10 ? $rq_ds = $_GET['ds'] : $rq_ds = 0;
isset($_GET['fl']) ? $rq_fl = intval($_GET['fl']) : $rq_fl = 0;
isset($_GET['ja']) ? $rq_ja = intval($_GET['ja']) : $rq_ja = 0;
isset($_GET['ln']) && strlen($_GET['ln']) < 10 ? $rq_ln = $_GET['ln'] : $rq_ln = 0;
isset($_GET['si']) ? $rq_si = $_GET['si'] : $rq_si = 0;
isset($_GET['tt']) ? $rq_tt = $_GET['tt'] : $rq_tt = 0;
isset($_GET['cf']) ? $rq_cf = intval($_GET['cf']) : $rq_cf = 0;
isset($_GET['uid']) ? $rq_uid = intval($_GET['uid']) : $rq_uid = 0;
isset($_GET['pt']) && strlen($_GET['pt']) < 10 ? $rq_pt = $_GET['pt'] : $rq_pt = 0;
isset($_GET['ocu']) && strlen($_GET['ocu']) < 40 ? $rq_ocu = $_GET['ocu'] : $rq_ocu = 0;
isset($_GET['ua']) && strlen($_GET['ua']) < 40 ? $rq_ua = $_GET['ua'] : $rq_ua = 0;
isset($_COOKIE['YPTJUUID']) ? $rq_uuid = $_COOKIE['YPTJUUID'] : $rq_uuid = 0;
} function get_request_u(){
global $rq_u,$rq_u1,$rq_u2,$rq_u3,$rq_u4,$rq_baseu;
$rq_u = $rq_u1 = $rq_u2 = $rq_u3 = $rq_u4 = 0;
$rq_baseu = isset($_GET['u']) ? $_GET['u'] : 0;
if(isset($_GET['u']) && $_GET['u']){
$rq_u = $_GET['u'];
$u = str_replace(array('http://','https://'),'',$_GET['u']);
if($pos = strpos($u,'?')){
$u = substr($u,0,$pos);
}
$u = rtrim($u,'/');
$a = explode('/',$u,4);
isset($a[0]) ? $rq_u1 = $a[0] : false;
isset($a[1]) ? $rq_u2 = "{$rq_u1}/{$a[1]}" : false;
isset($a[2]) ? $rq_u3 = "{$rq_u2}/{$a[2]}" : false;
isset($a[3]) ? $rq_u4 = "{$rq_u3}/{$a[3]}" : false;
$num = "rq_u" . count($a);
$rq_u = $$num;
}
} function get_request_su_kd(){
global $rq_su,$rq_kd,$rq_basesu,$rq_basekd;
$rq_su = $rq_kd = $rq_basekd = 0;
$rq_basesu = isset($_GET['su']) ? $_GET['su'] : 0;
if(isset($_GET['su']) && $parseA = parse_url($_GET['su'])){
$rq_su = $parseA['host'];
if($parseA['query']){
parse_str($parseA['query'],$output);
if( 'www.baidu.com' == $rq_su){
if(isset($output['wd']) && isset($output['ie'])){
if($output['ie'] != 'utf-8'){
$rq_kd = urldecode(iconv($output['ie'],'utf-8',$output['wd']));
}else{
$rq_kd = urldecode($output['wd']);
}
}
}elseif( 'www.sogou.com' == $rq_su){
if(isset($output['query']) && isset($output['ie'])){
if($output['ie'] != 'utf8'){
$rq_kd = urldecode(iconv($output['ie'],'utf-8',$output['query']));
}else{
$rq_kd = urldecode($output['query']);
}
}
}elseif('www.so.com' == $rq_su){
if(isset($output['q']) && isset($output['ie'])){
if($output['ie'] != 'utf-8'){
$rq_kd = urldecode(iconv($output['ie'],'utf-8',$output['q']));
}else{
$rq_kd = urldecode($output['q']);
}
}
}elseif(preg_match('/m\d{1,2}\.baidu\.com/',$rq_su)){
if(isset($output['word'])){
$rq_kd = urldecode($output['word']);
}
}
if(!$rq_kd){
$rq_kd = 0;
$rq_basekd = 0;
}else{
$rq_basekd = $rq_kd;
$rq_kd = base64_encode($rq_kd);
}
}
}
} function get_request_time(){
global $rq_tm;
if(isset($_SERVER['REQUEST_TIME'])){
$rq_tm = $_SERVER['REQUEST_TIME'];
}else{
$rq_tm = time();
}
} function get_request_ip(){
global $rq_ip;
if (getenv("HTTP_CLIENT_IP")){
$rq_ip = getenv("HTTP_CLIENT_IP");
} else if(getenv("HTTP_X_FORWARDED_FOR")){
$rq_ip = getenv("HTTP_X_FORWARDED_FOR");
} else if(getenv("REMOTE_ADDR")){
$rq_ip = getenv("REMOTE_ADDR");
}else {
$rq_ip = "Unknow";
}
}