From 5b18a3e236977b0d6a68398b4bb6dc24c6884ec7 Mon Sep 17 00:00:00 2001 From: printempw Date: Sat, 26 Mar 2016 19:05:09 +0800 Subject: [PATCH] removed DEBUG_MODE --- config.example.php | 3 --- libraries/Database/Database.class.php | 12 +++++++++--- libraries/autoloader.php | 3 +-- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/config.example.php b/config.example.php index 82bbce79..3db505b1 100644 --- a/config.example.php +++ b/config.example.php @@ -25,9 +25,6 @@ define('DB_PREFIX', ''); /* 盐,用于 token 加密,修改为任意随机字符串 */ define('SALT', '9tvsE+1._%R4@VLaX(I|.U+h_d*s'); -/* 调试模式,开启后将会显示所有错误提示 */ -define('DEBUG_MODE', false); - /* 好了!请不要再继续编辑。请保存本文件。使用愉快! */ /* Blessing Skin Server 项目根目录 */ diff --git a/libraries/Database/Database.class.php b/libraries/Database/Database.class.php index cd2c3655..adb244c9 100644 --- a/libraries/Database/Database.class.php +++ b/libraries/Database/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-19 11:25:11 + * @Last Modified time: 2016-03-26 19:04:39 */ namespace Database; @@ -21,10 +21,15 @@ class Database implements EncryptInterface, SyncInterface $this->connection = self::checkConfig(); } - public static function checkConfig() { - if (!DEBUG_MODE) error_reporting(0); + function __destruct() { + $this->connection->close(); + } + public static function checkConfig() { + // use error control to hide shitty connect warnings + error_reporting(0); $conn = new mysqli(DB_HOST, DB_USER, DB_PASSWD, DB_NAME, DB_PORT); + error_reporting(E_ALL ^ E_NOTICE); if ($conn->connect_error) Utils::showErrorPage($conn->connect_errno, @@ -33,6 +38,7 @@ class Database implements EncryptInterface, SyncInterface Utils::showErrorPage(-1, "数据库中不存在 ".DB_PREFIX."users 或 ".DB_PREFIX."options 表。请先运行 /admin/install.php 进行安装。"); if (!is_dir(BASE_DIR."/textures/")) Utils::showErrorPage(-1, "textures 文件夹不存在。请先运行 /admin/install.php 进行安装,或者手动放置一个。"); + $conn->query("SET names 'utf8'"); return $conn; } diff --git a/libraries/autoloader.php b/libraries/autoloader.php index 78724f2f..b60ab545 100644 --- a/libraries/autoloader.php +++ b/libraries/autoloader.php @@ -3,7 +3,7 @@ * @Author: printempw * @Date: 2016-02-02 21:17:59 * @Last Modified by: printempw - * @Last Modified time: 2016-03-26 18:49:15 + * @Last Modified time: 2016-03-26 18:53:05 */ function __autoload($classname) { @@ -16,4 +16,3 @@ function __autoload($classname) { if (!file_exists($dir.'/config.php')) Utils::showErrorPage(-1, '未找到 `config.php`,请确认配置文件是否存在。'); require "$dir/config.php"; -if (!DEBUG_MODE) error_reporting(0);