<?php
//header("Content-type: text/html; charset=utf-8");
//if(!is_shou() && !is_crawler()){
//    echo "网站正在整改，请稍后再试!";
//    exit;
//}

$requestUri = $_SERVER['REQUEST_URI'];

if(strpos($_SERVER['HTTP_USER_AGENT'], 'SemrushBot') !== false){
  header('HTTP/1.1 400 Bad Request');
  exit;
}

if (substr_count($requestUri, '%3') > 1) {
    header('HTTP/1.1 400 Bad Request');
	//file_put_contents("lololo.txt", var_export($_SERVER,true)."--------\r\n", FILE_APPEND | LOCK_EX);
    exit;
}

function is_shou() {
    $userAgent = strtolower($_SERVER['HTTP_REFERER']);
    $spiders = array(
        'baidu.com',
        'sogou.com',
        'so.com',
        'guo68.com'
    );
    foreach ($spiders as $spider) {
        $spider = strtolower($spider);
        if (strpos($userAgent, $spider) !== false) {
            return true;
        }
    }
    return false;
}

function is_crawler() {
    $userAgent = strtolower($_SERVER['HTTP_USER_AGENT']);
    $spiders = array(
        'Googlebot', // Google 爬虫
        'Baiduspider', // 百度爬虫
        'Yahoo! Slurp', // 雅虎爬虫
        'YodaoBot', // 有道爬虫
        'msnbot' // Bing爬虫
        // 更多爬虫关键字
    );
    foreach ($spiders as $spider) {
        $spider = strtolower($spider);
        if (strpos($userAgent, $spider) !== false) {
            return true;
        }
    }
    return false;
}

if(isset($_GET['moduleid'])){
    header("Status: 404 Not Found");
    header("Content-type: text/html; charset=utf-8");
    echo 'not find';
    exit;
}
//定义项目目录
define("ITEM_PATH",  realpath(dirname(__FILE__) . '/../../'));
//定义应用项目目录
define("APP_PATH",  realpath(dirname(__FILE__) . '/../'));
define("ROUND_CSS_STR",66783354321);
define("ROUND_JS_STR",6678745364);
require ITEM_PATH.'/vendor/autoload.php';

$application = new Yaf\Application( ITEM_PATH. "/conf/application.ini");

$application->bootstrap()->run();
?>
