fix wrong language-string in settings/180.dkim.php, implemented Settings::Add() for updates later (much better than a manual query etc.), added new php-errorhandler so we can display php errors/warnings/notices (whatever is activated) in a nicer way
Signed-off-by: Michael Kaufmann (d00p) <d00p@froxlor.org>
This commit is contained in:
@@ -81,7 +81,7 @@ return array(
|
|||||||
'dkim_keylength' => array(
|
'dkim_keylength' => array(
|
||||||
'label' => array(
|
'label' => array(
|
||||||
'title' => $lng['dkim']['dkim_keylength']['title'],
|
'title' => $lng['dkim']['dkim_keylength']['title'],
|
||||||
'description' => sprintf($lng['dkim_keylength']['label']['description'], Settings::Get('dkim.dkim_prefix'))
|
'description' => sprintf($lng['dkim']['dkim_keylength']['description'], Settings::Get('dkim.dkim_prefix'))
|
||||||
),
|
),
|
||||||
'settinggroup' => 'dkim',
|
'settinggroup' => 'dkim',
|
||||||
'varname' => 'dkim_keylength',
|
'varname' => 'dkim_keylength',
|
||||||
|
|||||||
@@ -79,9 +79,9 @@ class Settings {
|
|||||||
*/
|
*/
|
||||||
private function _readSettings() {
|
private function _readSettings() {
|
||||||
$result_stmt = Database::query("
|
$result_stmt = Database::query("
|
||||||
SELECT `settingid`, `settinggroup`, `varname`, `value`
|
SELECT `settingid`, `settinggroup`, `varname`, `value`
|
||||||
FROM `" . TABLE_PANEL_SETTINGS . "`
|
FROM `" . TABLE_PANEL_SETTINGS . "`
|
||||||
");
|
");
|
||||||
self::$_data = array();
|
self::$_data = array();
|
||||||
while ($row = $result_stmt->fetch(PDO::FETCH_ASSOC)) {
|
while ($row = $result_stmt->fetch(PDO::FETCH_ASSOC)) {
|
||||||
self::$_data[$row['settinggroup']][$row['varname']] = $row['value'];
|
self::$_data[$row['settinggroup']][$row['varname']] = $row['value'];
|
||||||
@@ -136,6 +136,9 @@ class Settings {
|
|||||||
if (Settings::Get($setting) !== null) {
|
if (Settings::Get($setting) !== null) {
|
||||||
// set new value in array
|
// set new value in array
|
||||||
$sstr = explode(".", $setting);
|
$sstr = explode(".", $setting);
|
||||||
|
if (!isset($sstr[1])) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
self::$_data[$sstr[0]][$sstr[1]] = $value;
|
self::$_data[$sstr[0]][$sstr[1]] = $value;
|
||||||
// should we store to db instantly?
|
// should we store to db instantly?
|
||||||
if ($instant_save) {
|
if ($instant_save) {
|
||||||
@@ -151,6 +154,41 @@ class Settings {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* add a new setting to the database (mainly used in updater)
|
||||||
|
*
|
||||||
|
* @param string $setting a group and a varname separated by a dot (group.varname)
|
||||||
|
* @param string $value
|
||||||
|
*
|
||||||
|
* @return boolean
|
||||||
|
*/
|
||||||
|
public function pAddNew($setting = null, $value = null) {
|
||||||
|
|
||||||
|
// first check if it doesn't exist
|
||||||
|
if (Settings::Get($setting) === null) {
|
||||||
|
// validate parameter
|
||||||
|
$sstr = explode(".", $setting);
|
||||||
|
if (!isset($sstr[1])) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
// prepare statement
|
||||||
|
$ins_stmt = Database::prepare("
|
||||||
|
INSERT INTO `".TABLE_PANEL_SETTINGS."` SET
|
||||||
|
`settinggroup` = :group,
|
||||||
|
`varname` = :varname,
|
||||||
|
`value` = :value
|
||||||
|
");
|
||||||
|
$ins_data = array(
|
||||||
|
'settinggroup' => $sstr[0],
|
||||||
|
'varname' => $sstr[1],
|
||||||
|
'value' => $value
|
||||||
|
);
|
||||||
|
Database::pexecute($ins_stmt, $ins_data);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Store all un-saved changes to the database and
|
* Store all un-saved changes to the database and
|
||||||
* re-read in all settings
|
* re-read in all settings
|
||||||
|
|||||||
37
lib/functions/froxlor/function.phpErrHandler.php
Normal file
37
lib/functions/froxlor/function.phpErrHandler.php
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* froxlor php error handler
|
||||||
|
*
|
||||||
|
* @param int $errno
|
||||||
|
* @param string $errstr
|
||||||
|
* @param string $errfile
|
||||||
|
* @param int $errline
|
||||||
|
* @param array $errcontext
|
||||||
|
*
|
||||||
|
* @return void|boolean
|
||||||
|
*/
|
||||||
|
function phpErrHandler($errno, $errstr, $errfile, $errline, array $errcontext) {
|
||||||
|
|
||||||
|
if (!(error_reporting() & $errno)) {
|
||||||
|
// This error code is not included in error_reporting
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!isset($_SERVER['SHELL']) || (isset($_SERVER['SHELL']) && $_SERVER['SHELL'] == '')) {
|
||||||
|
global $theme;
|
||||||
|
// if we're not on the shell, output a nicer error-message
|
||||||
|
$err_hint = file_get_contents(FROXLOR_INSTALL_DIR.'/templates/'.$theme.'/misc/phperrornice.tpl');
|
||||||
|
// replace values
|
||||||
|
$err_hint = str_replace("<TEXT>", '#'.$errno.' '.$errstr, $err_hint);
|
||||||
|
$err_hint = str_replace("<DEBUG>", $errfile.':'.$errline, $err_hint);
|
||||||
|
|
||||||
|
// show
|
||||||
|
echo $err_hint;
|
||||||
|
// return true to ignore php standard error-handler
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// of on shell, use the php standard error-handler
|
||||||
|
return false;
|
||||||
|
}
|
||||||
@@ -106,6 +106,7 @@ if (!isset($sql)
|
|||||||
* Includes the Functions
|
* Includes the Functions
|
||||||
*/
|
*/
|
||||||
require FROXLOR_INSTALL_DIR.'/lib/functions.php';
|
require FROXLOR_INSTALL_DIR.'/lib/functions.php';
|
||||||
|
@set_error_handler('phpErrHandler');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Includes the MySQL-Tabledefinitions etc.
|
* Includes the MySQL-Tabledefinitions etc.
|
||||||
@@ -121,7 +122,7 @@ $idna_convert = new idna_convert_wrapper();
|
|||||||
* disable magic_quotes_runtime if enabled
|
* disable magic_quotes_runtime if enabled
|
||||||
*/
|
*/
|
||||||
if (get_magic_quotes_runtime()) {
|
if (get_magic_quotes_runtime()) {
|
||||||
//Deactivate
|
// deactivate
|
||||||
set_magic_quotes_runtime(false);
|
set_magic_quotes_runtime(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
9
templates/Froxlor/misc/phperrornice.tpl
Normal file
9
templates/Froxlor/misc/phperrornice.tpl
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
<div class="messagewrapperfull">
|
||||||
|
<div class="warningcontainer bradius">
|
||||||
|
<div class="warningtitle">PHP warning/error</div>
|
||||||
|
<div class="warning">
|
||||||
|
<p><TEXT></p>
|
||||||
|
<pre style="overflow:auto;"><DEBUG></pre>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
11
templates/Sparkle/misc/phperrornice.tpl
vendored
Normal file
11
templates/Sparkle/misc/phperrornice.tpl
vendored
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
<div class="messagewrapperfull">
|
||||||
|
<div class="warningcontainer bradius">
|
||||||
|
<div class="warningtitle">PHP warning/error</div>
|
||||||
|
<div class="warning">
|
||||||
|
<p><TEXT></p>
|
||||||
|
<p> </p>
|
||||||
|
<pre style="overflow:auto;"><DEBUG></pre>
|
||||||
|
<p> </p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
Reference in New Issue
Block a user