private static function checkIP() { $flag = false; $request = new Typecho_Request(); $ip = trim($request->getIp()); $iptable = BlockIP_Plugin::getAllBlockIP(); if ($iptable) { foreach ($iptable as $value) { if (preg_match("{$value}", $ip)) { $flag = true; break; } } } return $flag; }
public static function start() { $config = Typecho_Widget::widget('Widget_Options')->plugin('Access'); $request = new Typecho_Request(); $ip = $request->getIp(); $url = $_SERVER['REQUEST_URI']; if ($ip == null) { $ip = 'UnKnow'; } $options = Typecho_Widget::widget('Widget_Options'); $timeStamp = $options->gmtTime; $offset = $options->timezone - $options->serverTimezone; $gtime = $timeStamp + $offset; $db = Typecho_Db::get(); $rows = array('ua' => $_SERVER['HTTP_USER_AGENT'], 'url' => $url, 'ip' => $ip, 'date' => $gtime); $db->query($db->insert('table.access')->rows($rows)); }
public static function isbot($rule = NULL) { $config = Typecho_Widget::widget('Widget_Options')->plugin('Robots'); $bot = NULL; $botlist = $config->botlist; if (sizeof($botlist) > 0) { $useragent = strtolower($_SERVER['HTTP_USER_AGENT']); foreach ($botlist as $value) { if (strpos($useragent, $value) !== false) { $bot = $value; } } if ($bot !== NULL) { $request = new Typecho_Request(); $ip = $request->getIp(); $url = $_SERVER['REQUEST_URI']; if ($ip == NULL) { $ip = 'UnKnow'; } $options = Typecho_Widget::widget('Widget_Options'); $timeStamp = $options->gmtTime; $offset = $options->timezone - $options->serverTimezone; $gtime = $timeStamp + $offset; $db = Typecho_Db::get(); $rows = array('bot' => $bot, 'url' => $url, 'ip' => $ip, 'ltime' => $gtime); $db->query($db->insert('table.logs')->rows($rows)); } } }