From 30ac85295cb51dd9e7ae2668856ebf30397f34e8 Mon Sep 17 00:00:00 2001 From: printempw Date: Sat, 12 Mar 2016 18:47:42 +0800 Subject: [PATCH] added DEBUG_MODE in config --- config.example.php | 3 +++ includes/Database.class.php | 4 ++-- includes/User.class.php | 3 +-- includes/autoload.inc.php | 3 ++- 4 files changed, 8 insertions(+), 5 deletions(-) diff --git a/config.example.php b/config.example.php index 0ac72c36..39a69e0a 100644 --- a/config.example.php +++ b/config.example.php @@ -17,6 +17,9 @@ define('DB_HOST', 'localhost'); /* 盐,用于 token 加密,修改为任意随机字符串 */ define('SALT', '9tvsh55d*s'); +/* 调试模式,开启后将会显示所有用于错误提示 */ +define('DEBUG_MODE', false); + /* 同一 IP 最大可注册账户数 */ define('REGS_PER_IP', 2); diff --git a/includes/Database.class.php b/includes/Database.class.php index 9c9df1fc..9a1fe0cf 100644 --- a/includes/Database.class.php +++ b/includes/Database.class.php @@ -3,7 +3,7 @@ * @Author: printempw * @Date: 2016-02-02 21:59:06 * @Last Modified by: printempw - * @Last Modified time: 2016-03-12 18:15:55 + * @Last Modified time: 2016-03-12 18:42:21 */ class Database @@ -15,7 +15,7 @@ class Database } public static function checkConfig() { - error_reporting(0); + if (!DEBUG_MODE) error_reporting(0); $conn = new mysqli(DB_HOST, DB_USER, DB_PASSWD, DB_NAME, DB_PORT); if ($conn->connect_error) { Utils::showErrorPage(-1, "Can not connect to mysql, check if database info correct in config.php. ". diff --git a/includes/User.class.php b/includes/User.class.php index bb499d03..983ea976 100644 --- a/includes/User.class.php +++ b/includes/User.class.php @@ -3,7 +3,7 @@ * @Author: printempw * @Date: 2016-01-16 23:01:33 * @Last Modified by: printempw - * @Last Modified time: 2016-03-12 18:33:34 + * @Last Modified time: 2016-03-12 18:46:22 */ class User @@ -107,7 +107,6 @@ class User if ($this->getTexture($type) != "") { $filename = "./textures/".$this->getTexture($type); if (file_exists($filename)) { - header('Content-Type: image/png'); // Cache friendly header('Last-Modified: ' . gmdate('D, d M Y H:i:s', $this->getLastModified()).' GMT'); header('Content-Length: '.filesize($filename)); diff --git a/includes/autoload.inc.php b/includes/autoload.inc.php index 4befd822..9fabcc20 100644 --- a/includes/autoload.inc.php +++ b/includes/autoload.inc.php @@ -3,7 +3,7 @@ * @Author: prpr * @Date: 2016-02-02 21:17:59 * @Last Modified by: printempw - * @Last Modified time: 2016-03-12 18:04:46 + * @Last Modified time: 2016-03-12 18:44:26 */ function __autoload($classname) { @@ -14,3 +14,4 @@ function __autoload($classname) { if (!file_exists($dir.'/config.php')) Utils::showErrorPage(-1, '未找到 `config.php`,请确认配置文件是否存在。'); require "$dir/config.php"; +if (!DEBUG_MODE) error_reporting(0);