示例#1
0
function checkBrowser()
{
    $brower_type = getBrowser();
    if ($brower_type == 'ie') {
        $brower_version = getBrowserVer();
        if ($brower_version >= 11) {
            return true;
        }
    }
    if ($brower_type == 'chrome') {
        $brower_version = getBrowserVer();
        if ($brower_version >= 42) {
            return true;
        }
    }
    if ($brower_type == 'spartan') {
        return true;
    }
    return false;
}
示例#2
0
    if (preg_match('/MSIE\\s(\\d+)\\..*/i', $agent, $regs)) {
        return $regs[1];
    } elseif (preg_match('/FireFox\\/(\\d+)\\..*/i', $agent, $regs)) {
        return $regs[1];
    } elseif (preg_match('/Opera[\\s|\\/](\\d+)\\..*/i', $agent, $regs)) {
        return $regs[1];
    } elseif (preg_match('/Chrome\\/(\\d+)\\..*/i', $agent, $regs)) {
        return $regs[1];
    } elseif (strpos($agent, 'Chrome') == false && preg_match('/Safari\\/(\\d+)\\..*$/i', $agent, $regs)) {
        return $regs[1];
    } else {
        return 'unknow';
    }
}
$browser = getBrowser();
$version = getBrowserVer();
$timeline = time();
//var_dump($_SERVER) ;
$host = 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF'] . '?' . $_SERVER['QUERY_STRING'];
$ip = $_SERVER["REMOTE_ADDR"];
if ($ip == '::1') {
    $ip = '42.224.200.104';
} elseif (substr($ip, 0, 3) == '192') {
    $ip = '42.224.200.104';
}
$content = file_get_contents("http://api.map.baidu.com/location/ip?ak=XtagQAxjHG8uQeT9nhGYHHlf&ip={$ip}&coor=bd09ll");
$json = json_decode($content);
$location = $json->{'content'}->{'address'};
//按层级关系提取address数据
$sql = "insert into visitors(ip,location,host,browser,version,timeline) values('{$ip}','{$location}','{$host}','{$browser}','{$version}','{$timecur}')";
$res = $pdo->exec($sql);