init.php
<?php // 初始化 // error_reporting(0); define("ROOT", dirname(__FILE__)); define("INC_PATH", ROOT."/inc"); include_once(INC_PATH."/php-inc/src/core.php"); include_once(INC_PATH."/php-inc/src/util.php"); include_once(ROOT."/common.php"); timer::add(); if(get_magic_quotes_gpc()) { $_GET = stripslashes_deep($_GET); $_POST = stripslashes_deep($_POST); $_COOKIE = stripslashes_deep($_COOKIE); } $_REQUEST = array_merge($_GET, $_POST, $_COOKIE); date_default_timezone_set("Asia/Shanghai"); define("PUBLIC_PATH", ROOT); config::set(include(ROOT."/config.php")); mysql::add_db(config::get("db")); template::$path = config::get("template_path"); template::$cache_path = config::get("template_cache_path"); file_cache::$path = config::get("file_cache_path"); file_log::$path = config::get("file_log_path"); file_log::$mode = config::get("file_log_mode"); define("BASE_URL", config::get("base_url")); session_start(); $mid = isset($_SESSION["mid"]) ? $_SESSION["mid"] : 0; template::assign("mid", $mid); if(is_post()) { $p_token = P("_token"); $c_token = isset($_COOKIE["_token"]) ? $_COOKIE["_token"] : ""; setcookie("_token", "", time()-3600, "/"); if($p_token != $c_token || !$c_token) { if(is_ajax()) { return_json(0, "非法请求"); } else { alert("非法请求", get_root_url()); } } } define("UID", 1);