コード例 #1
0
ファイル: functions.php プロジェクト: jammarmalade/jamphp
function checkrobot($useragent = '')
{
    static $kw_spiders = array('bot', 'crawl', 'spider', 'slurp', 'sohu-search', 'lycos', 'robozilla');
    static $kw_browsers = array('msie', 'netscape', 'opera', 'konqueror', 'mozilla');
    $useragent = strtolower(empty($useragent) ? $_SERVER['HTTP_USER_AGENT'] : $useragent);
    if (strpos($useragent, 'http://') === false && astrpos($useragent, $kw_browsers)) {
        return false;
    }
    if (astrpos($useragent, $kw_spiders)) {
        return true;
    }
    return false;
}
コード例 #2
0
ファイル: functions.php プロジェクト: jammarmalade/blog
function checkmobile()
{
    global $_B;
    $mobile = array();
    static $touchbrowser_list = array('iphone', 'android', 'phone', 'mobile', 'wap', 'netfront', 'java', 'opera mobi', 'opera mini', 'ucweb', 'windows ce', 'symbian', 'series', 'webos', 'sony', 'blackberry', 'dopod', 'nokia', 'samsung', 'palmsource', 'xda', 'pieplus', 'meizu', 'midp', 'cldc', 'motorola', 'foma', 'docomo', 'up.browser', 'up.link', 'blazer', 'helio', 'hosin', 'huawei', 'novarra', 'coolpad', 'webos', 'techfaith', 'palmsource', 'alcatel', 'amoi', 'ktouch', 'nexian', 'ericsson', 'philips', 'sagem', 'wellcom', 'bunjalloo', 'maui', 'smartphone', 'iemobile', 'spice', 'bird', 'zte-', 'longcos', 'pantech', 'gionee', 'portalmmm', 'jig browser', 'hiptop', 'benq', 'haier', '^lct', '320x320', '240x320', '176x220');
    static $mobilebrowser_list = array('windows phone');
    static $wmlbrowser_list = array('cect', 'compal', 'ctl', 'lg', 'nec', 'tcl', 'alcatel', 'ericsson', 'bird', 'daxian', 'dbtel', 'eastcom', 'pantech', 'dopod', 'philips', 'haier', 'konka', 'kejian', 'lenovo', 'benq', 'mot', 'soutec', 'nokia', 'sagem', 'sgh', 'sed', 'capitel', 'panasonic', 'sonyericsson', 'sharp', 'amoi', 'panda', 'zte');
    $pad_list = array('ipad');
    $useragent = strtolower($_SERVER['HTTP_USER_AGENT']);
    if (astrpos($useragent, $pad_list)) {
        return false;
    }
    if ($v = astrpos($useragent, $mobilebrowser_list)) {
        $_B['mobile'] = $v;
        return '1';
    }
    if ($v = astrpos($useragent, $touchbrowser_list)) {
        $_B['mobile'] = $v;
        return '2';
    }
    if ($v = astrpos($useragent, $wmlbrowser_list)) {
        $_B['mobile'] = $v;
        return '3';
    }
    $brower = array('mozilla', 'chrome', 'safari', 'opera', 'm3gate', 'winwap', 'openwave', 'myop');
    if ($v = astrpos($useragent, $brower)) {
        $_B['agent'] = $v;
    }
    $_B['mobile'] = 'unknown';
}