Changed die() to trigger_error()

E_USER_ERROR will always be displayed.
Changed die() to trigger_error(error, E_USER_ERROR).
This commit is contained in:
TimZ99 2018-07-04 21:41:38 +02:00
parent a96e1e5a2e
commit 3023c83226
No known key found for this signature in database
GPG Key ID: 4D8268DC68E8339D
5 changed files with 15 additions and 17 deletions

View File

@ -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, <a href=\"install.php\">click here</a>.", 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, <a href=\"install.php\">click here</a>.", 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, <a href="install.php">please click here</a> to update your database to the latest version.');
trigger_error("Your database is for an older version and requires an upgrade, <a href=\"install.php\">please click here</a> to update your database to the latest version.", E_USER_ERROR);
}
}

View File

@ -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)

View File

@ -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'])) {

View File

@ -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);
}
}

View File

@ -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');
}