better-staridc-MNBT
1<?php
2if (defined('SYSTEM_ROOT')) return;
3if (!defined('IN_CRONLITE')) define('IN_CRONLITE', true);
4define('SYSTEM_ROOT', dirname(__FILE__).'/');
5define('ROOT', dirname(SYSTEM_ROOT).'/');
6
7// 生产环境:页面不显示错误,但写入本地错误日志,便于排查问题。
8ini_set('display_errors', '0');
9ini_set('display_startup_errors', '0');
10ini_set('log_errors', '1');
11$runtimeLogDir = ROOT . 'runtime/logs';
12if (!is_dir($runtimeLogDir)) {
13 @mkdir($runtimeLogDir, 0755, true);
14}
15$errorLogPath = getenv('MNBT_ERROR_LOG');
16if (!$errorLogPath) {
17 $errorLogPath = $runtimeLogDir . '/php-error.log';
18}
19ini_set('error_log', $errorLogPath);
20error_reporting(E_ALL);
21
22define('SYS_KEY', 'MNBT');
23define('CC_Defender', 1); //防CC攻击开关(1为session模式)
24date_default_timezone_set("PRC");
25$date = date("Y-m-d H:i:s");
26include_once(SYSTEM_ROOT."function.php");
27$sessionSecure = mnbt_request_is_secure();
28@ini_set('session.use_strict_mode', '1');
29@ini_set('session.cookie_httponly', '1');
30@ini_set('session.cookie_samesite', 'Lax');
31if (PHP_VERSION_ID >= 70300) {
32 session_set_cookie_params(['lifetime' => 0, 'path' => '/', 'secure' => $sessionSecure, 'httponly' => true, 'samesite' => 'Lax']);
33} else {
34 session_set_cookie_params(0, '/; samesite=Lax', '', $sessionSecure, true);
35}
36session_start();
37// 提前初始化 CSRF token 并下发双提交 Cookie,确保即使页面未注入 meta 也能通过 cookie 兜底校验
38mnbt_csrf_token();
39$scriptpath=str_replace('\\','/',$_SERVER['SCRIPT_NAME']);
40$sitepath = substr($scriptpath, 0, strrpos($scriptpath, '/'));
41$siteurl = ($_SERVER['SERVER_PORT'] == '443' ? 'https://' : 'http://').$_SERVER['HTTP_HOST'].$sitepath.'/';
42$docRoot = rtrim(str_replace('\\', '/', isset($_SERVER['DOCUMENT_ROOT']) ? realpath($_SERVER['DOCUMENT_ROOT']) : ''), '/');
43$projFs = rtrim(str_replace('\\', '/', realpath(ROOT)), '/');
44$siteWebRoot = ($docRoot && strpos($projFs, $docRoot) === 0) ? rtrim(substr($projFs, strlen($docRoot)), '/') . '/' : '/';
45$install_url = ($_SERVER['SERVER_PORT'] == '443' ? 'https://' : 'http://') . $_SERVER['HTTP_HOST'] . $siteWebRoot . 'install';
46if(is_file(SYSTEM_ROOT.'360safe/360webscan.php')){//360网站卫士
47require_once(SYSTEM_ROOT.'360safe/360webscan.php');
48}
49if (!is_file(ROOT.'config.php')) {
50 header("Location: " . $install_url);
51 exit();
52}
53require ROOT.'config.php';
54if(!defined('SQLITE') && (!$dbconfig['user']||!$dbconfig['pwd']||!$dbconfig['dbname']))//检测安装
55{
56header("Location: " . $install_url);
57exit();
58}
59//连接数据库
60include_once(SYSTEM_ROOT."db.class.php");
61$DB=new DB($dbconfig['host'],$dbconfig['user'],$dbconfig['pwd'],$dbconfig['dbname'],$dbconfig['port']);
62if(!$DB->get_all_prepare("select * from MN_config where 1"))//检测安装2
63{
64header("Location: " . $install_url);
65exit();
66}
67
68$siteid=1;
69$conf=$DB->get_row_prepare("SELECT * FROM MN_config WHERE id=? limit 1", [$siteid]);//获取系统配置
70$password_hash='!@#%!s!0';
71 include_once(SYSTEM_ROOT."Response.php");
72include_once(SYSTEM_ROOT."function.php");
73include_once(SYSTEM_ROOT."member.php");
74include_once(SYSTEM_ROOT."theme.php");
75include_once(SYSTEM_ROOT."plugin.php");
76include_once(SYSTEM_ROOT."frontend.php");
77require_once(SYSTEM_ROOT."lib/pay.function.php");
78mnbt_plugins_boot();
79?>