[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Phpgroupware-cvs] [20975] Improvement: Errorhandling - 4512:4565
From: |
Sigurd Nes |
Subject: |
[Phpgroupware-cvs] [20975] Improvement: Errorhandling - 4512:4565 |
Date: |
Fri, 22 Jan 2010 09:46:44 +0000 |
Revision: 20975
http://svn.sv.gnu.org/viewvc/?view=rev&root=phpgroupware&revision=20975
Author: sigurdne
Date: 2010-01-22 09:46:44 +0000 (Fri, 22 Jan 2010)
Log Message:
-----------
Improvement: Errorhandling - 4512:4565
Modified Paths:
--------------
people/sigurdne/modules/phpgwapi/trunk/inc/functions.inc.php
Modified: people/sigurdne/modules/phpgwapi/trunk/inc/functions.inc.php
===================================================================
--- people/sigurdne/modules/phpgwapi/trunk/inc/functions.inc.php
2010-01-22 09:46:02 UTC (rev 20974)
+++ people/sigurdne/modules/phpgwapi/trunk/inc/functions.inc.php
2010-01-22 09:46:44 UTC (rev 20975)
@@ -183,11 +183,48 @@
*/
function phpgw_handle_error($error_level, $error_msg, $error_file,
$error_line, $error_context = array())
{
+
if ( error_reporting() == 0 ) // 0 == @function() so we ignore
it, as the dev requested
{
return true;
}
+/*
+_debug_array($error_level);
+_debug_array($error_msg);
+_debug_array($error_file);
+_debug_array($error_line);
+//_debug_array($bt = debug_backtrace());die();
+*/
+
if(isset($GLOBALS['phpgw_info']['server']['log_levels']['global_level']))
+ {
+ switch
($GLOBALS['phpgw_info']['server']['log_levels']['global_level'])
+ {
+ case 'F': // Fatal
+ case 'E': // Error
+ $error_reporting = E_ERROR |
E_USER_ERROR |E_PARSE;
+ break;
+ case 'W': // Warn
+ case 'I': // Info
+ $error_reporting = E_ERROR |
E_USER_ERROR| E_WARNING | E_USER_WARNING | E_PARSE;
+ break;
+
+ case 'N': // Notice
+ case 'D': // Debug
+ $error_reporting = E_ERROR |
E_USER_ERROR | E_WARNING | E_USER_WARNING | E_NOTICE | E_USER_NOTICE | E_PARSE;
+ break;
+
+ case 'S': // Strict
+ $error_reporting = E_STRICT | E_PARSE;
+ break;
+ }
+
+ if( !(!!($error_reporting & $error_level)))
+ {
+ return true;
+ }
+ }
+
if ( !isset($GLOBALS['phpgw']->log)
|| !is_object($GLOBALS['phpgw']->log) )
{
@@ -242,6 +279,7 @@
echo '<p>' . lang('Notice: %1 in %2 at
line %3', $error_msg, $error_file, $error_line) . "</p>\n";
echo '<pre>' .
phpgw_parse_backtrace($bt) . "</pre>\n";
}
+ break;
case E_STRICT:
$log_args['severity'] = 'S';
$log->strict($log_args);
@@ -252,8 +290,15 @@
// echo '<p>' . lang('Strict: %1 in %2 at
line %3', $error_msg, $error_file, $error_line) . "</p>\n";
// echo '<pre>' .
phpgw_parse_backtrace($bt) . "</pre>\n";
}
+ break;
- //No default, we just ignore it, for now
+ case E_DEPRECATED:
+ case E_USER_DEPRECATED:
+ $log_args['severity'] = 'DP';
+ $log->deprecated_($log_args);
+ echo '<p class="msg">' . lang('deprecated: %1
in %2 at line %3', $error_msg, $error_file, $error_line) . "</p>\n";
+ echo '<pre>' . phpgw_parse_backtrace($bt) .
"</pre>\n";
+ break;
}
}
set_error_handler('phpgw_handle_error');
@@ -266,7 +311,7 @@
function phpgw_handle_exception(Exception $e)
{
$msg = $e->getMessage();
- $help = lang('Please contact your administrator for
assistance');
+ $help = 'Please contact your administrator for assistance';
$trace = $e->getTraceAsString();
echo <<<HTML
<h1>Uncaught Exception: {$msg}</h1>
@@ -316,8 +361,13 @@
/* Load main class */
$GLOBALS['phpgw'] = createObject('phpgwapi.phpgw');
- magic_quotes_runtime(false);
+ if(get_magic_quotes_runtime())
+ {
+ echo '<center><b>The magic_quotes_runtime has to set to Off in
php.ini</b></center>';
+ exit;
+ }
+
// Can't use this yet - errorlog hasn't been created.
// print_debug('sane environment','messageonly','api');
@@ -442,6 +492,35 @@
$GLOBALS['phpgw_info']['server'][$k] = $v;
}
+ if (
isset($GLOBALS['phpgw_info']['server']['log_levels']['global_level']) )
+ {
+ switch
($GLOBALS['phpgw_info']['server']['log_levels']['global_level'])
+ {
+ case 'F': // Fatal
+ case 'E': // Error
+ error_reporting(E_ERROR | E_USER_ERROR
| E_PARSE);
+ break;
+
+ case 'W': // Warn
+ case 'I': // Info
+ error_reporting(E_ERROR | E_USER_ERROR
| E_WARNING | E_USER_WARNING | E_PARSE);
+ break;
+
+ case 'N': // Notice
+ case 'D': // Debug
+ error_reporting(E_ERROR | E_USER_ERROR
| E_WARNING | E_USER_WARNING | E_NOTICE | E_USER_NOTICE | E_PARSE);
+ break;
+
+ case 'S': // Strict
+ error_reporting(E_STRICT | E_PARSE);
+ break;
+
+ case 'DP': // Deprecated
+ error_reporting(E_ERROR | E_USER_ERROR
| E_DEPRECATED | E_USER_DEPRECATED | E_PARSE);
+ break;
+ }
+ }
+
/*
@@ -636,7 +715,7 @@
/********* Optional classes, which can be disabled for
performance increases *********/
while ($phpgw_class_name =
each($GLOBALS['phpgw_info']['flags']))
{
- if (ereg('enable_', $phpgw_class_name[0]))
+ if (preg_match('/enable_/', $phpgw_class_name[0]))
{
$enable_class = str_replace('enable_', '',
$phpgw_class_name[0]);
$enable_class = str_replace('_class', '',
$enable_class);
@@ -663,15 +742,30 @@
{
if (!$GLOBALS['phpgw']->acl->check('run',
PHPGW_ACL_READ, $GLOBALS['phpgw_info']['flags']['currentapp']))
{
- $GLOBALS['phpgw']->common->phpgw_header(true);
-
$GLOBALS['phpgw']->log->write(array('text'=>'W-Permissions, Attempted to access
%1','p1'=>$GLOBALS['phpgw_info']['flags']['currentapp']));
+ $_access = false;
+ if
($GLOBALS['phpgw_info']['flags']['currentapp'] == 'admin' &&
$GLOBALS['phpgw']->acl->get_app_list_for_id('admin', phpgwapi_acl::ADD,
$GLOBALS['phpgw_info']['user']['userid']))
+ {
+ $_access = true;
+ }
- $lang_denied = lang('Access not permitted');
- echo <<<HTML
- <div class="error">$lang_denied</div>
+ if ($GLOBALS['phpgw']->acl->check('admin',
phpgwapi_acl::ADD, $GLOBALS['phpgw_info']['flags']['currentapp']))
+ {
+ $_access = true;
+ }
+ if (!$_access)
+ {
+
$GLOBALS['phpgw']->common->phpgw_header(true);
+
$GLOBALS['phpgw']->log->write(array('text'=>'W-Permissions, Attempted to access
%1','p1'=>$GLOBALS['phpgw_info']['flags']['currentapp']));
+
+ $lang_denied = lang('Access not
permitted');
+ echo <<<HTML
+ <div
class="error">$lang_denied</div>
+
HTML;
- $GLOBALS['phpgw']->common->phpgw_exit(True);
+
$GLOBALS['phpgw']->common->phpgw_exit(True);
+ }
+ unset($_access);
}
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Phpgroupware-cvs] [20975] Improvement: Errorhandling - 4512:4565,
Sigurd Nes <=