protected function _initialize() { get_naps_bot() !== false && die(''); //不让蜘蛛抓取 // 获取当前用户ID $uid = is_login(); if ($uid) { defined('UID') or define('UID', $uid); } else { $login = A('Public'); $uid = $login->autologin(); $uid > 0 ? define('UID', $uid) : redirect(U('Public/login')); } defined('IS_ADMIN') or UID == 1 ? define('IS_ADMIN', true) : define('IS_ADMIN', false); //先读取缓存配置 $config = F('DB_CONFIG_DATA'); if (!$config || APP_DEBUG) { $config = api('Config/lists'); F('DB_CONFIG_DATA', $config); } C($config); //添加配置 if (!defined('MAIN_IFRAME')) { if (I('mainmenu') == 'true') { define('MAIN_IFRAME', 'true'); C('SHOW_PAGE_TRACE', false); } else { define('MAIN_IFRAME', 'false'); } } $this->assign('MAIN_IFRAME', MAIN_IFRAME); //定义数据表前缀 defined('__DB_PREFIX__') or define('__DB_PREFIX__', C('DB_PREFIX')); //主题默认为空 C('DEFAULT_THEME', ''); //检查访问权限 import('Ainiku.Auth'); $this->auth = new \Ainiku\Auth(); if (!$this->auth->check()) { $this->error('啊哦,没有此权限,请联系管理员!', U(session('uinfo')['admin_index'])); } $this->addForward(); //设置全局的模板变量 $this->assign('meta_title', '首页'); $this->assign('uinfo', session('uinfo')); //防止重复请求,如果是主框架请求就只输出个目录菜单 $this->getMainNav(); // if (MAIN_IFRAME == 'true' || (CONTROLLER_NAME == 'Index' && ACTION_NAME == 'index')) { // //取主导航 // $this->getMainNav(); // $this->display(CONTROLLER_NAME . '/' . ACTION_NAME); // die(); // } }
protected function _initialize() { get_naps_bot() !== false && die(''); //不让蜘蛛抓取 // 获取当前用户ID $uid = is_login(); if ($uid) { defined('UID') or define('UID', $uid); } else { $login = A('Public'); $uid = $login->autologin(); $uid > 0 ? define('UID', $uid) : redirect(U('Public/login')); } // 记录当前列表页的cookie $forward = cookie('__forward__'); if (!IS_AJAX && !IS_POST) { if (count($forward) >= 2) { array_shift($forward); } isset($_SERVER['HTTP_REFERER']) ? $forward[] = $_SERVER['HTTP_REFERER'] : ''; cookie('__forward__', $forward); } defined('__PAGEURL__') || define('__PAGEURL__', $forward[0]); $this->meta_title = '首页'; //先读取缓存配置 $config = F('DB_CONFIG_DATA'); if (!$config || APP_DEBUG) { $config = api('Config/lists'); F('DB_CONFIG_DATA', $config); } C($config); //添加配置 if (I('get.mainmenu') == 'true') { C('SHOW_PAGE_TRACE', false); } defined('__DB_PREFIX__') or define('__DB_PREFIX__', C('DB_PREFIX')); //主题默认为空 C('DEFAULT_THEME', ''); $this->assign('uinfo', session('uinfo')); $this->uinfo = session('uinfo'); //取主导航 $this->assign('ADMIN_MENU', C('ADMIN_MENU')); }
function robots_log($post_ID) { $bd_submit_log_enabled = get_option('bd_submit_log_enabled'); if (!$bd_submit_log_enabled) { return; } $searchbot = get_naps_bot(); if ($searchbot) { $tlc_thispage = addslashes($_SERVER['HTTP_USER_AGENT']); $url = $_SERVER['HTTP_REFERER']; $submit_file = dirname(__FILE__) . '/submit_log.txt'; $robots_file = dirname(__FILE__) . '/robots_log.txt'; $time = nowtime(); $PR = home_url() . $_SERVER['REQUEST_URI']; if (date('Y-m-d', filemtime($robots_file)) != date('Y-m-d')) { file_put_contents($submit_file, ''); $handle = fopen($robots_file, "w"); } else { $handle = fopen($robots_file, "a"); } fwrite($handle, "{$time}|{$searchbot}|{$PR}||"); fclose($handle); } }
function addSeokeywordlog() { $searchbot = get_naps_bot(); //判断是不是蜘蛛 $url = $_SERVER['HTTP_REFERER']; //来源网站 //下面判断如果是来自百度的用户或是你网站内部的链接 if ($searchbot || ($url != '' and strpos($url, 'baidu.com') !== false) || strpos($url, '你网站的域名')) { //符合的要求的链接可以进入你的网站 } else { //不符合的话就显示提示信息 die; } }
return false; } function nowtime() { $date = date("Y-m-d.G:i:s"); return $date; } function create_Dir($path) { if (!file_exists($path)) { create_Dir(dirname($path)); mkdir($path, 0777); } } //获取二级域名 $host = $_SERVER["HTTP_HOST"]; $array_temp = explode(".", $host); $len = count($array_temp); $domain = $array_temp[$len - 2] . '.' . $array_temp[$len - 1]; $searchbot = get_naps_bot(); if ($searchbot != false) { $tlc_thispage = addslashes($_SERVER['HTTP_USER_AGENT']); $url = $host . $_SERVER["REQUEST_URI"]; $file = "/var/seo/tk001/" . date("Y-m-d") . "/" . $domain . '.txt'; create_Dir(dirname($file)); $time = nowtime(); $data = fopen($file, "a"); fwrite($data, "Time:{$time}\trobot:{$searchbot}\tURL:{$url}\t\n"); //AGENT:$tlc_thispage\n"); fclose($data); }