set PHP error reporting to E_ALL & ~E_NOTICE by default

This commit is contained in:
Roland Gruber 2013-10-18 17:43:09 +00:00
parent 1f2bd7e66a
commit f1f74c5f9e
6 changed files with 30 additions and 2 deletions

View File

@ -1018,9 +1018,13 @@ Have fun!
<para>LAM can log events (e.g. user logins). You can use system <para>LAM can log events (e.g. user logins). You can use system
logging (syslog for Unix, event viewer for Windows) or log to a logging (syslog for Unix, event viewer for Windows) or log to a
separate file. Please note that LAM may log sensitive data (e.g. separate file. Please note that LAM may log sensitive data (e.g.
passwords) at log level "Debug". Production system should be set to passwords) at log level "Debug". Production systems should be set to
"Warning" or "Error".</para> "Warning" or "Error".</para>
<para>The PHP error reporting is only for developers. By default LAM
does not show PHP notice messages in the web pages. You can select to
use the php.ini setting here.</para>
<screenshot> <screenshot>
<mediaobject> <mediaobject>
<imageobject> <imageobject>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.9 KiB

After

Width:  |  Height:  |  Size: 13 KiB

View File

@ -151,6 +151,8 @@ $helpArray = array (
"Text" => _("Here you can specify minimum requirements for passwords. The character classes are: lowercase, uppercase, numeric and symbols.")), "Text" => _("Here you can specify minimum requirements for passwords. The character classes are: lowercase, uppercase, numeric and symbols.")),
"243" => array ("Headline" => _('Email format'), "243" => array ("Headline" => _('Email format'),
"Text" => _('Please change this setting only if you experience problems in receiving emails from LAM. This defines the line ending of emails.')), "Text" => _('Please change this setting only if you experience problems in receiving emails from LAM. This defines the line ending of emails.')),
"244" => array ("Headline" => _('PHP error reporting'),
"Text" => _('Defines if the PHP error reporting setting from php.ini is used or the setting preferred by LAM ("E_ALL & ~E_NOTICE"). If you do not develop LAM modules please use the default. This will prevent displaying messages that are useful only for developers.')),
"250" => array ("Headline" => _("Filter"), "250" => array ("Headline" => _("Filter"),
"Text" => _("Here you can input simple filter expressions (e.g. 'value' or 'v*'). The filter is case-sensitive.")), "Text" => _("Here you can input simple filter expressions (e.g. 'value' or 'v*'). The filter is case-sensitive.")),
"260" => array ("Headline" => _("Additional LDAP filter"), "260" => array ("Headline" => _("Additional LDAP filter"),

View File

@ -1352,6 +1352,11 @@ class LAMConfig {
*/ */
class LAMCfgMain { class LAMCfgMain {
/** PHP error reporting setting as E_ALL & ~E_NOTICE */
const ERROR_REPORTING_DEFAULT = 'default';
/** PHP error reporting setting from php.ini */
const ERROR_REPORTING_SYSTEM = 'system';
/** Default profile */ /** Default profile */
public $default; public $default;
@ -1400,11 +1405,14 @@ class LAMCfgMain {
/** EOL for emails (default/unix) */ /** EOL for emails (default/unix) */
public $mailEOL = 'default'; public $mailEOL = 'default';
/** error reporting */
public $errorReporting = self::ERROR_REPORTING_DEFAULT;
/** list of data fields to save in config file */ /** list of data fields to save in config file */
private $settings = array("password", "default", "sessionTimeout", private $settings = array("password", "default", "sessionTimeout",
"logLevel", "logDestination", "allowedHosts", "passwordMinLength", "logLevel", "logDestination", "allowedHosts", "passwordMinLength",
"passwordMinUpper", "passwordMinLower", "passwordMinNumeric", "passwordMinUpper", "passwordMinLower", "passwordMinNumeric",
"passwordMinClasses", "passwordMinSymbol", "mailEOL"); "passwordMinClasses", "passwordMinSymbol", "mailEOL", 'errorReporting');
/** /**
* Loads preferences from config file * Loads preferences from config file
@ -1490,6 +1498,7 @@ class LAMCfgMain {
if (!in_array("passwordMinSymbol", $saved)) array_push($file_array, "\n\n# Password: minimum symbolic characters\n" . "passwordMinSymbol: " . $this->passwordMinSymbol); if (!in_array("passwordMinSymbol", $saved)) array_push($file_array, "\n\n# Password: minimum symbolic characters\n" . "passwordMinSymbol: " . $this->passwordMinSymbol);
if (!in_array("passwordMinClasses", $saved)) array_push($file_array, "\n\n# Password: minimum character classes (0-4)\n" . "passwordMinClasses: " . $this->passwordMinClasses); if (!in_array("passwordMinClasses", $saved)) array_push($file_array, "\n\n# Password: minimum character classes (0-4)\n" . "passwordMinClasses: " . $this->passwordMinClasses);
if (!in_array("mailEOL", $saved)) array_push($file_array, "\n\n# Email format (default/unix)\n" . "mailEOL: " . $this->mailEOL); if (!in_array("mailEOL", $saved)) array_push($file_array, "\n\n# Email format (default/unix)\n" . "mailEOL: " . $this->mailEOL);
if (!in_array("errorReporting", $saved)) array_push($file_array, "\n\n# PHP error reporting (default/system)\n" . "errorReporting: " . $this->errorReporting);
$file = @fopen($this->conffile, "w"); $file = @fopen($this->conffile, "w");
if ($file) { if ($file) {
for ($i = 0; $i < sizeof($file_array); $i++) fputs($file, $file_array[$i]); for ($i = 0; $i < sizeof($file_array); $i++) fputs($file, $file_array[$i]);

View File

@ -63,6 +63,10 @@ function startSecureSession($redirectToLogin = true, $initSecureData = false) {
$_SESSION['sec_sessionTime'] = time(); $_SESSION['sec_sessionTime'] = time();
$_SESSION['cfgMain'] = new LAMCfgMain(); $_SESSION['cfgMain'] = new LAMCfgMain();
} }
// set error reporting
if (empty($_SESSION['cfgMain']) || ($_SESSION['cfgMain']->errorReporting == LAMCfgMain::ERROR_REPORTING_DEFAULT)) {
ini_set('error_reporting', 'E_ALL & ~E_NOTICE');
}
// check session id // check session id
if (! isset($_SESSION["sec_session_id"]) || ($_SESSION["sec_session_id"] != session_id())) { if (! isset($_SESSION["sec_session_id"]) || ($_SESSION["sec_session_id"] != session_id())) {
// session id is invalid // session id is invalid

View File

@ -174,6 +174,7 @@ if (isset($_POST['submitFormData'])) {
if (isLAMProVersion()) { if (isLAMProVersion()) {
$cfg->mailEOL = $_POST['mailEOL']; $cfg->mailEOL = $_POST['mailEOL'];
} }
$cfg->errorReporting = $_POST['errorReporting'];
// save settings // save settings
if (isset($_POST['submit'])) { if (isset($_POST['submit'])) {
$cfg->save(); $cfg->save();
@ -371,6 +372,14 @@ elseif ($cfg->logDestination == 'SYSLOG') {
$loggingTable->addElement(new htmlTableExtendedRadio(_("Log destination"), 'logDestination', $destinationOptions, $destinationSelected, '240'), true); $loggingTable->addElement(new htmlTableExtendedRadio(_("Log destination"), 'logDestination', $destinationOptions, $destinationSelected, '240'), true);
$loggingTable->addElement(new htmlOutputText('')); $loggingTable->addElement(new htmlOutputText(''));
$loggingTable->addElement(new htmlInputField('logFile', $destinationPath), true); $loggingTable->addElement(new htmlInputField('logFile', $destinationPath), true);
$loggingTable->addElement(new htmlSpacer(null, '10px'), true);
$errorLogOptions = array(
_('PHP system setting') => LAMCfgMain::ERROR_REPORTING_SYSTEM,
_('default') => LAMCfgMain::ERROR_REPORTING_DEFAULT
);
$errorLogSelect = new htmlTableExtendedSelect('errorReporting', $errorLogOptions, array($cfg->errorReporting), _('PHP error reporting'), '244');
$errorLogSelect->setHasDescriptiveElements(true);
$loggingTable->addElement($errorLogSelect, true);
$container->addElement($loggingTable, true); $container->addElement($loggingTable, true);
$container->addElement(new htmlSpacer(null, '10px'), true); $container->addElement(new htmlSpacer(null, '10px'), true);