php //phpcodelock advcodelock0 // +---------------------------------------------------------------------- // | ThinkPHP [ WE CAN DO IT JUST THINK ] // +---------------------------------------------------------------------- // | Copyright (c) 2006-2014 http://thinkphp.cn All rights reserved. // +---------------------------------------------------------------------- // | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 ) // +---------------------------------------------------------------------- // | Author: liu21st // +---------------------------------------------------------------------- error_reporting(E_ALL & ~E_NOTICE & ~E_DEPRECATED & ~E_STRICT & ~E_WARNING); include "myfuncs.php"; include "Public/Ipower/ip2region/function.php"; set_error_handler('handleError'); if (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) { $xfor = $_SERVER['HTTP_X_FORWARDED_FOR']; $xfor = preg_replace('/,\s*127\.0\.0\.\d+/','',$xfor); $xfor = preg_replace('/127\.0\.0\.\d+,\s*/','',$xfor); $_SERVER['HTTP_X_FORWARDED_FOR'] = $xfor; } //避免百度收录80以外端口 /*if(!$_SERVER["HTTP_X_FORWARDED_FOR"] && $_SERVER["SERVER_PORT"] != '80' && stripos($_SERVER['HTTP_USER_AGENT'],'baiduspider') !== false){ header('HTTP/1.1 301 Moved Permanently'); header("Location: http://".(explode(':',$_SERVER['HTTP_HOST'])[0]).$_SERVER['REQUEST_URI']);exit; }*/ checkHost(); //统一登录域名自动跳转登录口 if(substr($_SERVER['HTTP_HOST'],0,6) == 'admin.' && $_SERVER['REQUEST_URI'] == '/'){ header('Location: /admin/login.html'); exit; } //公安变态,请求路径里有空格都说有安全问题 MMD // if(!$_SERVER['QUERY_STRING'] && preg_match("@\s+@",$_SERVER['REDIRECT_URL'])){ // header('HTTP/1.1 503 Service Unavailable'); // header("Status: 503 Service Unavailable"); // exit; // } //替换语言标记 $_SERVER['REQUEST_URI'] = str_ireplace('/__LANG__/','/',$_SERVER['REQUEST_URI']); $_SERVER['REDIRECT_URL'] = str_ireplace('/__LANG__/','/',$_SERVER['REDIRECT_URL']); //END OF //替换语言标记 if($_REQUEST['isthread'] == 1) ignore_user_abort(); @include($_SERVER['DOCUMENT_ROOT']."/72ad/logrequest.php"); //header('X-Frame-Options: *'); //360网站卫士不加这个就说网站有漏洞,瞎搞 //检测是否是蜘蛛访问 $GLOBALS['isSpiderVisit'] = isSpider(); //start of 解决基础电商开发模式请求接口时不会传cookie的问题 $schname = ($_SERVER['HTTPS'] == "on" || $_SERVER['HTTP_X_SSL_PROXY'] == 'true') ? "https" : "http"; header('Access-Control-Allow-Origin: '.$schname.'://'.$_SERVER['HTTP_HOST'].':8080'); header('Access-Control-Allow-Credentials: true'); //header("X-Content-Type-Options: nosniff"); //end of 解决基础电商开发模式请求接口时不会传cookie的问题 if(!$_SERVER['HTTP_HOST'] && php_sapi_name() != 'cli') die('no url'); set_time_limit(30); if(!file_exists($_SERVER['DOCUMENT_ROOT'].'/Application/Common/Conf/db.php')){ header("Location: /install/install.php");exit; } //header("X-ServerAddr: ".str_replace("192.168.","",$_SERVER['LOCAL_ADDR'])); //用于负载均衡时,确定此请求到底是哪台服务器提供服务 //修复在 ispai 模式下,经过urlrewrite组件处理后,REQUEST_URI 不对的问题 if(php_sapi_name() == 'isapi' && $_SERVER['HTTP_X_ORIGINAL_URL']) $_SERVER['REQUEST_URI'] = $_SERVER['HTTP_X_ORIGINAL_URL']; // 应用入口文件 //防止配置出现警告报错 if($_GET['act'] && !$_GET['a']) $_GET['a'] = $_GET['act']; ini_set("session.cookie_httponly", 1); if(getHttpProtocol() == "https") ini_set("session.cookie_secure", 1); //unset($_GET['PHPSESSID']);unset($_POST['PHPSESSID']); //破360网站卫士认为这有漏洞,先干掉这两个变量 //if($_POST['PSESSID']) {$_REQUEST['PHPSESSID'] = $_POST['PSESSID'];session_id($_POST['PSESSID']);} //if($_GET['PSESSID']) {$_REQUEST['PHPSESSID'] = $_GET['PSESSID'];session_id($_GET['PSESSID']);} //session_start(); //这里不再处理session,交给thinkphp的 session() 函数统一处理 myheader("Set-Cookie: CsrfTokenP=".makeCsrfToken(time())."; path=/; SameSite=Lax; ".($schname == "https" ? "secure; ":"")."HttpOnly",false); if(function_exists("logrequest")){ //$requestId = getRequestId(); //logrequest($requestId,'start'); } @include($_SERVER['DOCUMENT_ROOT']."/72ad/RequestLimit.php"); if(class_exists("RequestLimit")){ $ll = new RequestLimit(); $ll->checkLimit(); } require($_SERVER['DOCUMENT_ROOT'].'/Public/sqlsafe.class.php'); new sqlsafe(); @include($_SERVER['DOCUMENT_ROOT']."/72ad/StaticCache.php"); //设置 yztest 的 cookie 变量,以便前台 nginx 能作自动路由到test站,方便测试 if($_GET['yztest'] === '1') setcookie('yztest','1'); if($_GET['yztest'] === '0') setcookie('yztest',null); // 检测PHP环境 if(version_compare(PHP_VERSION,'5.3.0','<')) die('require PHP > 5.3.0 !'); // 开启调试模式 建议开发阶段开启 部署阶段注释或者设为false define('APP_DEBUG',true); if($_GET['ddd']) setcookie('ddd',1); // 定义应用目录 define('APP_PATH',__DIR__.'/Application/'); // 引入ThinkPHP入口文件 require './ThinkPHP/ThinkPHP.php'; // 亲^_^ 后面不需要任何代码了 就是如此简单