From c2221a25e6d0673ec5dde4a24d091a0f8dce8418 Mon Sep 17 00:00:00 2001 From: conory Date: Thu, 17 Jan 2019 18:26:46 +0900 Subject: [PATCH] =?UTF-8?q?=EC=BA=90=EC=8B=9C=EA=B0=80=20=EC=97=86?= =?UTF-8?q?=EB=8A=94=20=EC=83=81=ED=99=A9=EC=97=90=EC=84=9C=20DB=20?= =?UTF-8?q?=EC=97=B0=EA=B2=B0=20=EC=97=90=EB=9F=AC=EC=8B=9C=20DB=20?= =?UTF-8?q?=EC=97=90=EB=9F=AC=20=EB=A9=94=EC=84=B8=EC=A7=80=20=EB=8C=80?= =?UTF-8?q?=EC=8B=A0=20php=20=EC=B9=98=EB=AA=85=EC=A0=81=20=EC=97=90?= =?UTF-8?q?=EB=9F=AC=EA=B0=80=20=EB=82=98=EC=98=A4=EB=8A=94=20=EB=AC=B8?= =?UTF-8?q?=EC=A0=9C=20=EC=88=98=EC=A0=95=20(=EB=9D=BC=EC=9D=B4=EB=AF=B9?= =?UTF-8?q?=EC=8A=A4=20=EC=98=A4=EB=A5=98=20=ED=99=94=EB=A9=B4=20=EC=B6=9C?= =?UTF-8?q?=EB=A0=A5=EC=8B=9C=EC=97=90=EB=8F=84=20DB=20=EC=97=B0=EA=B2=B0?= =?UTF-8?q?=EC=9D=B4=20=EC=82=AC=EC=9A=A9=EB=90=98=EB=AF=80=EB=A1=9C=20Deb?= =?UTF-8?q?ug::displayErrorScreen()=20=ED=95=A8=EC=88=98=EB=A5=BC=20?= =?UTF-8?q?=EA=B1=B0=EC=B9=98=EB=A9=B4=20=EC=B9=98=EB=AA=85=EC=A0=81=20?= =?UTF-8?q?=EC=97=90=EB=9F=AC=EA=B0=80=20=EB=B0=9C=EC=83=9D=EB=90=98?= =?UTF-8?q?=EA=B8=B0=EC=97=90=20Exception=EB=A1=9C=20=EC=B2=98=EB=A6=AC?= =?UTF-8?q?=ED=95=98=EC=A7=80=20=EC=95=8A=EC=95=98=EC=9D=8C)=20=EB=9D=BC?= =?UTF-8?q?=EC=9D=B4=EB=AF=B9=EC=8A=A4=EA=B0=80=20=EC=84=A4=EC=B9=98?= =?UTF-8?q?=EB=90=98=EC=A7=80=20=EC=95=8A=EC=9D=80=20=EC=83=81=ED=83=9C?= =?UTF-8?q?=EC=97=90=EC=84=9C=EB=8A=94=20"=EC=97=90=EB=9F=AC=20=EB=A1=9C?= =?UTF-8?q?=EA=B7=B8=EB=A1=9C=20=ED=99=95=EC=9D=B8=ED=95=98=EB=9D=BC?= =?UTF-8?q?=EB=8A=94=20=EB=A9=94=EC=84=B8=EC=A7=80"=20=EC=97=86=EC=9D=B4?= =?UTF-8?q?=20=EC=97=90=EB=9F=AC=EA=B0=80=20=EB=B0=94=EB=A1=9C=20=EC=B6=9C?= =?UTF-8?q?=EB=A0=A5=EB=90=98=EB=8F=84=EB=A1=9D=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- classes/db/DB.class.php | 6 ++++-- classes/db/DBMysql.class.php | 8 ++++---- common/framework/debug.php | 35 +++++++++++++++++++++++------------ 3 files changed, 31 insertions(+), 18 deletions(-) diff --git a/classes/db/DB.class.php b/classes/db/DB.class.php index 2d0a3e6af..244f73f1d 100644 --- a/classes/db/DB.class.php +++ b/classes/db/DB.class.php @@ -122,7 +122,8 @@ class DB } if(!$db_type && Context::isInstalled()) { - return new BaseObject(-1, 'msg_db_not_setted'); + Rhymix\Framework\Debug::displayError(lang('msg_db_not_setted')); + exit; } if(!strncmp($db_type, 'mysql', 5)) { @@ -139,7 +140,8 @@ class DB $class_file = RX_BASEDIR . "classes/db/$class_name.class.php"; if(!file_exists($class_file)) { - return new BaseObject(-1, 'msg_db_not_setted'); + Rhymix\Framework\Debug::displayError(sprintf('DB type "%s" is not supported.', $db_type)); + exit; } // get a singletone instance of the database driver class diff --git a/classes/db/DBMysql.class.php b/classes/db/DBMysql.class.php index 626ef95be..ac6a978a6 100644 --- a/classes/db/DBMysql.class.php +++ b/classes/db/DBMysql.class.php @@ -73,16 +73,16 @@ class DBMySQL extends DB // Check connection error if($mysqli->connect_errno) { - $this->setError($mysqli->connect_errno, $mysqli->connect_error); - return; + Rhymix\Framework\Debug::displayError(sprintf('DB ERROR %d : %s', $mysqli->connect_errno, $mysqli->connect_error)); + exit; } // Check DB version $this->db_version = $mysqli->server_info; if (version_compare($this->db_version, '5.0.7', '<')) { - $this->setError(-1, 'Rhymix requires MySQL 5.0.7 or later. Current MySQL version is ' . $this->db_version); - return; + Rhymix\Framework\Debug::displayError('Rhymix requires MySQL 5.0.7 or later. Current MySQL version is ' . $this->db_version); + exit; } // Set DB charset diff --git a/common/framework/debug.php b/common/framework/debug.php index b908c85ba..f9ce31076 100644 --- a/common/framework/debug.php +++ b/common/framework/debug.php @@ -650,7 +650,7 @@ class Debug } // Localize the error message. - $display_error_message = ini_get('display_errors') || Session::isAdmin(); + $display_error_message = ini_get('display_errors') || !\Context::isInstalled() || Session::isAdmin(); $message = $display_error_message ? $message : lang('msg_server_error_see_log'); if ($message === 'msg_server_error_see_log') { @@ -664,17 +664,28 @@ class Debug } catch (\Error $e) { - header('HTTP/1.1 500 Internal Server Error'); - if ($_SERVER['REQUEST_METHOD'] === 'GET' || !isset($_SERVER['HTTP_X_REQUESTED_WITH'])) - { - header('Content-Type: text/html; charset=UTF-8'); - echo sprintf('%s%s', escape($title, false), escape($message, false)); - } - else - { - header('Content-Type: application/json; charset=UTF-8'); - echo json_encode(array('error' => -1, 'message' => escape($message, false)), \JSON_UNESCAPED_UNICODE); - } + self::displayError($message); + } + } + + /** + * Display a default error. + * + * @param string $message + * @return void + */ + public static function displayError($message) + { + header('HTTP/1.1 500 Internal Server Error'); + if ($_SERVER['REQUEST_METHOD'] === 'GET' || !isset($_SERVER['HTTP_X_REQUESTED_WITH'])) + { + header('Content-Type: text/html; charset=UTF-8'); + echo sprintf('Server Error%s', escape($message, false)); + } + else + { + header('Content-Type: application/json; charset=UTF-8'); + echo json_encode(array('error' => -1, 'message' => escape($message, false)), \JSON_UNESCAPED_UNICODE); } }