mysql php页面流量统计_PHP学习笔记:php网络流量统计系统
date_default_timezone_set('Asia/Chongqing'); //系統(tǒng)時(shí)間差8小時(shí)問題
$cur_time = getdate();return $cur_time['year'] . "-" . $cur_time['mon'] . "-" . $cur_time['mday'] . " " . $cur_time['hours'] . ":" . $cur_time['minutes'] . ":" . $cur_time['seconds'];//程序調(diào)用getdate()函數(shù)獲取當(dāng)前系統(tǒng)時(shí)間,結(jié)果保存在$cur_time數(shù)組中,然后將$cur_time數(shù)組中的元素構(gòu)建成指定格式的字符串,作為函數(shù)的返回值
}/*function GetExplore() {
//返回客戶端用戶使用的瀏覽器
$explore = "";
$Agent = $_SERVER["HTTP_USER_AGENT"];
//echo($Agent);
//使用$_SERVER["HTTP_USER_AGENT"]返回訪問當(dāng)前網(wǎng)頁的客戶端信息。
//例如:win7,IE9.0 ————> Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)
// 找到第1個(gè);的位置
$pos = strpos($Agent, ';');
if($pos < 0)
return "";
$explore = substr($Agent, $pos+1, strlen($Agent)-$pos); // 截取第1個(gè)分號(hào)后面的字符串
// 找到第2個(gè);的位置
$pos = strpos($explore, ';');
// 第1個(gè)分號(hào)和第2個(gè)分號(hào)之間是瀏覽器信息
$explore = substr($explore, 0, $pos);
return $explore;
}
//書中所給的代碼有誤,就是判斷瀏覽器出錯(cuò),因?yàn)樵诠雀柚?Agent = $_SERVER["HTTP_USER_AGENT"];返回的是Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/43.0.2357.65 Safari/537.36*/
/*IE mozilla/4.0 (compatible; msie 8.0; windows nt 5.1; trident/4.0)
360 mozilla/4.0 (compatible; msie 8.0; windows nt 5.1; trident/4.0; 360se)
搜狗 mozilla/4.0 (compatible; msie 7.0; windows nt 5.1; trident/4.0; se 2.x metasr 1.0)
世界之窗 mozilla/4.0 (compatible; msie 7.0; windows nt 5.1; trident/4.0)
遨游 mozilla/5.0 (windows nt 5.1) applewebkit/535.12 (khtml, like gecko) maxthon/3.3.4.4000 chrome/18.0.966.0 safari/535.12
火狐 mozilla/5.0 (windows nt 5.1; rv:8.0.1) gecko/20100101 firefox/8.0.1
谷歌 mozilla/5.0 (windows nt 5.1) applewebkit/535.11 (khtml, like gecko) chrome/17.0.963.26 safari/535.11
opera opera/9.80 (windows nt 5.1; u; edition next; zh-cn) presto/2.10.255 version/12.00*/
//通過修改過的,其他幾個(gè)就先不試了,具體的其他瀏覽器返回信息在上面
functionGetExplore() {$Agent = $_SERVER["HTTP_USER_AGENT"];$browseragent=""; //瀏覽器
$browserversion=""; //瀏覽器的版本
if (preg_match('/MSIE ([0-9].[0-9]{1,2})/i',$Agent,$version)) {$browserversion=$version[1];$browseragent="Internet Explorer";
}else if (preg_match( '/Opera\/([0-9]{1,2}.[0-9]{1,2})/i',$Agent,$version)) {$browserversion=$version[1];$browseragent="Opera";
}else if (preg_match( '/Firefox\/([0-9.]{1,5})/i',$Agent,$version)) {$browserversion=$version[1];$browseragent="Firefox";
}else if (preg_match( '/Chrome\/([0-9.]{1,3})/i',$Agent,$version)) {$browserversion=$version[1];$browseragent="Chrome";
}else if (preg_match( '/Safari\/([0-9.]{1,3})/i',$Agent,$version)) {$browseragent="Safari";$browserversion="";
}else{$browserversion="";$browseragent="Unknown";
}return $browseragent." ".$browserversion;
}functionGetOSInfo() {//在獲取客戶端的瀏覽器信息時(shí),包含操作系統(tǒng)信息
$os="";$Agent = $_SERVER["HTTP_USER_AGENT"];if (preg_match('/win/i',$Agent) && strpos($Agent, '95')) {$os="Windows 95";
}elseif (preg_match('/win 9x/i',$Agent) && strpos($Agent, '4.90')) {$os="Windows ME";
}elseif (preg_match('/win/i',$Agent) && ereg('98',$Agent)) {$os="Windows 98";
}elseif (preg_match('/win/i',$Agent) && preg_match('/nt 5\.0/i',$Agent)) {$os="Windows 2000";
}elseif (preg_match('/win/i',$Agent) && preg_match('/nt 5\.2/i',$Agent)) {$os="Windows 2003";
}elseif (preg_match('/win/i',$Agent) && preg_match('/nt 5\.1/i',$Agent)) {$os="Windows XP";
}elseif (preg_match('/win/i',$Agent) && preg_match('/nt 6\.1/i',$Agent)) {$os="Windows 7";
}elseif (preg_match('/win/i',$Agent) && preg_match('/32/i',$Agent)) {$os="Windows 32";
}elseif (preg_match('/win/i',$Agent) && preg_match('/nt/i',$Agent)) {$os="Windows NT";
}elseif (preg_match('/linux/i',$Agent)) {$os="Linux";
}elseif (preg_match('/unix/i',$Agent)) {$os="Unix";
}elseif (preg_match('/sun/i',$Agent) && preg_match('/os/',$Agent)) {$os="SunOS";
}elseif (preg_match('/ibm/i',$Agent) && preg_match('/os/',$Agent)) {$os="IBM OS/2";
}elseif (preg_match('/Mac/',$Agent) && preg_match('/PC/',$Agent)) {$os="Macintosh";
}elseif (preg_match('/PowerPC/i',$Agent)) {$os="PowerPC";
}elseif (preg_match('/AIX/',$Agent)) {$os="AIX";
}elseif (preg_match('/HPUX/',$Agent)) {$os="HPUX";
}elseif (preg_match('/NetBSD/',$Agent)) {$os="NetBSD";
}elseif (preg_match('/BSD/',$Agent)) {$os="BSD";
}elseif (ereg('OSF1',$Agent)) {$os="OSF1";
}elseif (ereg('IRIX',$Agent)) {$os="IRIX";
}elseif (preg_match('/FreeBSD/',$Agent)) {$os="FreeBSD";
}if ($os=='')$os = "Unknown";return $os;//eregi()函數(shù)用于實(shí)現(xiàn)不區(qū)分大小寫的正則表達(dá)式匹配,語法為 int eregi(string $pattern,string $string,[,array $regs])
//只是在php5.3之后不再支持eregi(), 了改為preg_match()
}?>
與50位技術(shù)專家面對(duì)面20年技術(shù)見證,附贈(zèng)技術(shù)全景圖總結(jié)
以上是生活随笔為你收集整理的mysql php页面流量统计_PHP学习笔记:php网络流量统计系统的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: mysql数据首次导入hive_sqoo
- 下一篇: mysql 查询后怎么定位列_MySQL