diff --git a/src/bootstrap.php b/src/bootstrap.php
index 33798305..4c071af8 100644
--- a/src/bootstrap.php
+++ b/src/bootstrap.php
@@ -50,13 +50,11 @@ if(file_exists($path_conf)) {
if(!defined('PSM_DEBUG')) {
define('PSM_DEBUG', false);
}
-if(PSM_DEBUG) {
- error_reporting(E_ALL);
- ini_set('display_errors', 1);
-} else {
- error_reporting(0);
- ini_set('display_errors', 0);
-}
+
+// Debug enabled: report everything
+// Debug disabled: report error only if created manually
+ini_set('display_errors', 1);
+PSM_DEBUG ? error_reporting(E_ALL) : error_reporting(E_USER_ERROR);
// check for a cron allowed ip array
if(!defined('PSM_CRON_ALLOW')) {
@@ -66,7 +64,7 @@ if(!defined('PSM_CRON_ALLOW')) {
$vendor_autoload = PSM_PATH_SRC . '..' . DIRECTORY_SEPARATOR . 'vendor' . DIRECTORY_SEPARATOR . 'autoload.php';
if(!file_exists($vendor_autoload)) {
- die('No dependencies found in vendor dir. Did you install the dependencies? Please run "php composer.phar install".');
+ trigger_error("No dependencies found in vendor dir. Did you install the dependencies? Please run \"php composer.phar install\".", E_USER_ERROR);
}
require_once $vendor_autoload;
@@ -79,22 +77,22 @@ if(!defined('PSM_INSTALL') || !PSM_INSTALL) {
if($db->getDbHost() === null) {
// no config file has been loaded, redirect the user to the install
header('Location: install.php');
- die();
+ trigger_error("Could not load config file. Redirect to install failed, click here.", E_USER_ERROR);
}
// config file has been loaded, check if we have a connection
if(!$db->status()) {
- die('Unable to establish database connection...');
+ trigger_error("Unable to establish database connection...", E_USER_ERROR);
}
// attempt to load configuration from database
if(!psm_load_conf()) {
// unable to load from config table
header('Location: install.php');
- die();
+ trigger_error("Could not load config table. Redirect to install failed, click here.", E_USER_ERROR);
}
// config load OK, make sure database version is up to date
$installer = new \psm\Util\Install\Installer($db);
if($installer->isUpgradeRequired()) {
- die('Your database is for an older version and requires an upgrade, please click here to update your database to the latest version.');
+ trigger_error("Your database is for an older version and requires an upgrade, please click here to update your database to the latest version.", E_USER_ERROR);
}
}
diff --git a/src/includes/functions.inc.php b/src/includes/functions.inc.php
index e98cfeb4..65671cc5 100644
--- a/src/includes/functions.inc.php
+++ b/src/includes/functions.inc.php
@@ -76,8 +76,8 @@ function psm_load_lang($lang) {
// this will also fill in every part that is not translated in other translation files
$default_lang_file = PSM_PATH_LANG . 'en_US.lang.php';
- file_exists($default_lang_file) ? require $default_lang_file : die('English translation needs to be intalled at all time!');
- isset($sm_lang) ? $GLOBALS['sm_lang_default'] = $sm_lang : die('$sm_lang not found in English translation!');
+ file_exists($default_lang_file) ? require $default_lang_file : trigger_error("English translation needs to be intalled at all time!", E_USER_ERROR);
+ isset($sm_lang) ? $GLOBALS['sm_lang_default'] = $sm_lang : trigger_error("\$sm_lang not found in English translation!", E_USER_ERROR);
unset($sm_lang);
// load translation is the selected language is not English (en_US)
diff --git a/src/psm/Module/Config/Controller/ConfigController.php b/src/psm/Module/Config/Controller/ConfigController.php
index 1db33c35..ff910c28 100644
--- a/src/psm/Module/Config/Controller/ConfigController.php
+++ b/src/psm/Module/Config/Controller/ConfigController.php
@@ -206,7 +206,7 @@ class ConfigController extends AbstractController {
if($language_refresh) {
header('Location: ' . psm_build_url(array('mod' => 'config'), true, false));
- die();
+ trigger_error("Redirect failed.", E_USER_ERROR);
}
if(isset($_POST['general_submit'])) {
diff --git a/src/psm/Module/Server/Controller/UpdateController.php b/src/psm/Module/Server/Controller/UpdateController.php
index 63f2c21b..8162d5c6 100644
--- a/src/psm/Module/Server/Controller/UpdateController.php
+++ b/src/psm/Module/Server/Controller/UpdateController.php
@@ -46,7 +46,7 @@ class UpdateController extends AbstractController {
header('Location: ' . psm_build_url(array(
'mod' => 'server_status'
), true, false));
- die();
+ trigger_error("Redirect failed.", E_USER_ERROR);
}
}
diff --git a/src/psm/Module/User/Controller/LoginController.php b/src/psm/Module/User/Controller/LoginController.php
index e2235777..25487c87 100644
--- a/src/psm/Module/User/Controller/LoginController.php
+++ b/src/psm/Module/User/Controller/LoginController.php
@@ -56,7 +56,7 @@ class LoginController extends AbstractController {
if($result) {
// success login, redirect
header('Location: ' . psm_build_url($_SERVER['QUERY_STRING']));
- die();
+ trigger_error("Redirect failed.", E_USER_ERROR);
} else {
$this->addMessage(psm_get_lang('login', 'error_login_incorrect'), 'error');
}