1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
| public function is_bot() { $data['robotspage'] = $_SERVER['REQUEST_URI'] ? $_SERVER['REQUEST_URI'] : ''; $data['oldurl'] = $_SERVER['HTTP_REFERER'] ? $_SERVER['HTTP_REFERER'] : '直接访问'; import('ORG.Net.IpLocation'); $Ip = new IpLocation('UTFWry.dat'); $data['robotsip'] = get_client_ip(); $useragent = addslashes(strtolower($_SERVER['HTTP_USER_AGENT'])); if (strpos($useragent, 'googlebot') !== false) { $bot = 'Google'; } elseif (strpos($useragent, 'mediapartners-google') !== false) { $bot = 'Google Adsense'; } elseif (strpos($useragent, 'baiduspider') !== false) { $bot = 'Baidu'; } elseif (strpos($useragent, 'sogou spider') !== false) { $bot = 'Sogou'; } elseif (strpos($useragent, 'sogou web') !== false) { $bot = 'Sogou web'; } elseif (strpos($useragent, 'sosospider') !== false) { $bot = 'SOSO'; } elseif (strpos($useragent, 'yahoo') !== false) { $bot = 'Yahoo'; } elseif (strpos($useragent, 'msn') !== false) { $bot = 'MSN'; } elseif (strpos($useragent, 'msnbot') !== false) { $bot = 'msnbot'; } elseif (strpos($useragent, 'sohu') !== false) { $bot = 'Sohu'; } elseif (strpos($useragent, 'yodaoBot') !== false) { $bot = 'Yodao'; } elseif (strpos($useragent, 'twiceler') !== false) { $bot = 'Twiceler'; } elseif (strpos($useragent, 'ia_archiver') !== false) { $bot = 'Alexa_'; } elseif (strpos($useragent, 'iaarchiver') !== false) { $bot = 'Alexa'; } elseif (strpos($useragent, 'slurp') !== false) { $bot = '雅虎'; } elseif (strpos($useragent, 'bot') !== false) { $bot = '未知'.$useragent; } $data['robotsname'] = $bot; $data['robotsarea'] = serialize($Ip->getlocation($data['robotsip'])); $data['create_time'] = time(); if (isset($bot)) { $Jrobot = D("Robot"); $lastInsId = $Jrobot->add($data); }
|