Newsgroups: php.general,php.internals Path: news.php.net Xref: news.php.net php.general:325712 php.internals:95483 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 4806 invoked from network); 28 Aug 2016 03:22:11 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 28 Aug 2016 03:22:11 -0000 Authentication-Results: pb1.pair.com smtp.mail=rene.veerman.netherlands@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=rene.veerman.netherlands@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.220.182 as permitted sender) X-PHP-List-Original-Sender: rene.veerman.netherlands@gmail.com X-Host-Fingerprint: 209.85.220.182 mail-qk0-f182.google.com Received: from [209.85.220.182] ([209.85.220.182:33379] helo=mail-qk0-f182.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id CB/67-34481-2E852C75 for ; Sat, 27 Aug 2016 23:22:10 -0400 Received: by mail-qk0-f182.google.com with SMTP id z190so110865690qkc.0; Sat, 27 Aug 2016 20:22:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to; bh=N33FYoQwGvXy7oRMlMtIKRmGSUDX55d+HfGCakhbaY0=; b=vKMCF3h2N6gBcvBLCPE9dVDE6hBEsLjcV7JyEaN4OTPY+2kp9KmJ7tItmw3v6kTODf XYm8V85OXSTSRY0LEqHSgUOeR8b7+BEw22mA/NRwUX5cIhP9PH8/H75eTlYYyIPEBuYw hDJEJoMYdb3LqVf1ZTNfVkkzkHeKJODqtQaM8iVD+GBTu9PF/Z/xhayG1Z0kUVPsYKob mN/FuBRp3ZXkqKOx+MDJcDT9ks7jiFDWjiapHTBtZ/gdTpU4DmvMbIF9HeKq7xwcM9EX bVpVzQuIACsrVkMEqElVRUTXj3eT5gOwgyR+pkF+ISIKc/CWGqexw4TFJBq8+6qUTW2Z 5Jwg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to; bh=N33FYoQwGvXy7oRMlMtIKRmGSUDX55d+HfGCakhbaY0=; b=Atb6NIqkyvKHXuxfGnMwKunF731uFcQEtmNAPfi4oHvv6P/m05FzmnDonl1tFu38GT AoJERmIjdkXF0muIwuSu3O8OvrNvw11daVycQeZmm80feSCwqYpeweikN34B71L7MWaP yH696vyZoo5a/Miuuvb0YszoCHBgYSuvdOgSMEPHZIoxwKL+2TvMBYvZ8SoCRxwW6U12 0P6GBRkkJj7XnDlEMxAerq7blopwf5y7itFNoLZHKNqicy4a6YcKBcJGYEQaemdiNxn2 PmLU+VypaPdK6ne+/SMxkHyb/AYuJDzy2K7nh4XwMWp16oSRlT2EA9sL7DS50xWPxlp9 7zhw== X-Gm-Message-State: AE9vXwNlJT2GhrP8SVjUST/MmD/WRY8T9yx2WaFq0X/umC5SMJgmP7leayznsz0EPXhW0gBarY4AYexFBfvnDw== X-Received: by 10.55.158.16 with SMTP id h16mr11914224qke.32.1472354527313; Sat, 27 Aug 2016 20:22:07 -0700 (PDT) MIME-Version: 1.0 Received: by 10.200.52.68 with HTTP; Sat, 27 Aug 2016 20:21:46 -0700 (PDT) In-Reply-To: References: Date: Sun, 28 Aug 2016 05:21:46 +0200 Message-ID: To: php-general@lists.php.net, Internals Content-Type: multipart/alternative; boundary=001a114d318e958365053b19408b Subject: Re: feature-request : html + css logging in apache logs (example for the rest of the unix community too) From: rene.veerman.netherlands@gmail.com (Rene Veerman) --001a114d318e958365053b19408b Content-Type: text/plain; charset=UTF-8 all are donated to public domain : __FILE__==='functions__internalErrorHandling.php'; 0) ob_end_flush(); ob_start(); var_dump ($errMsgOrArray); $errMsg = ob_get_clean(); } else if ( is_string($errMsgOrArray) || is_int($errMsgOrArray) || is_float($errMsgOrArray) ) { $errMsg = '' . $errMsgOrArray; } else if ( is_bool($errMsgOrArray) ) { $errMsg = ( $errMsgOrArray ? 'TRUE' : 'FALSE' ); } //echo 't1200'; //echo '
'; var_dump (debug_backtrace()); echo '
'; in badResult() instead trigger_error ($errMsg, $errCode); } function woBasicErrorHandler ($errno, $errstr, $errfile, $errline, $errcontext) { //echo 'woBasicErrorHandler.main:start'; $stacktrace = debug_backtrace(); $errType = wo_php_errorType_humanReadable($errno); $errSeverity = 'woErrorSeverity__error'; if (stripos($errType, 'warning')!==false) $errSeverity = 'woErrorSeverity__warning'; if (stripos($errType, 'notice')!==false) $errSeverity = 'woErrorSeverity__notice'; if (stripos($errType, 'user')!==false) $errSeverity .= ' woErrorSeverity__user'; if (stripos($errType, 'parse')!==false) $errSeverity .= ' woErrorSeverity__parse'; if (stripos($errType, 'core')!==false) $errSeverity .= ' woErrorSeverity__core'; if (stripos($errType, 'compile')!==false) $errSeverity .= ' woErrorSeverity__compile'; $html = '

webappObfuscator error

' .'

'.$errType.' : '.$errstr.'

' .woBasicErrorHandler__prettyStacktrace ($stacktrace) .'
'; echo $html; //reportStatus (1, $html); // RV : where the F is that function?? die(); /* echo '

dfo error

'.errorType_humanReadable($errno).' : '.$errstr.'
stacktrace:

';
var_dump ($stacktrace);
echo '
';*/ } function woBasicErrorHandler__prettyStacktrace ($st) { global $errorsBasepath; $r = '
' .'All filenames are under : '.$errorsBasepath.'
'; foreach ($st as $stackNumber => $stackData) { if (array_key_exists('file', $stackData)) { $relPath = '...'.str_replace($errorsBasepath, '', $stackData['file']); } else { $relPath = '.../'; }; if (array_key_exists('line', $stackData)) { $line = '(line '.$stackData['line'].')'; } else { $line = ''; } $file = '__FILE__ : '.$relPath.' '; $function = ''.$stackData['function'].'( ' .( array_key_exists('args',$stackData) ? woBasicErrorHandler__prettyStacktrace__arguments ($stackData['args']) : '' ) .' )'; //if ($stackNumber > 0) { // ignore the call to saBasicErrorHandler() itself $r .= '
' .$file.' ' .$line.' calls ' .$function .'
'; //} }; $r .= '
'; return $r; } function woBasicErrorHandler__prettyStacktrace__arguments ($args) { $r = ''; foreach ($args as $argIdx => $arg) { if (is_array($arg)) { $r .= ''.htmlentities(json_encode($arg)).''; } elseif (is_object($arg)) { $r .= ''.htmlentities(json_encode($arg)).''; } else { $r .= ''.htmlentities($arg).''; } $r .= ', '; } $r .= ''; return $r; } function wo_php_json_last_error_humanReadable ($errNo) { // taken from http://php.net/manual/en/function.json-last-error.php // on 2015 July 9th, valid for php version up to 5.5.0 $errorTypes = array ( JSON_ERROR_NONE => array ( 'errorCode' => 'JSON_ERROR_NONE', 'msg' => 'No error has occurred' ), JSON_ERROR_DEPTH => array ( 'errorCode' => 'JSON_ERROR_DEPTH', 'msg' => 'The maximum stack depth has been exceeded' ), JSON_ERROR_STATE_MISMATCH => array ( 'errorCode' => 'JSON_ERROR_STATE_MISMATCH', 'msg' => 'Invalid or malformed JSON' ), JSON_ERROR_CTRL_CHAR => array ( 'errorCode' => 'JSON_ERROR_CTRL_CHAR', 'msg' => 'Control character error, possibly incorrectly encoded' ), JSON_ERROR_SYNTAX => array ( 'errorCode' => 'JSON_ERROR_SYNTAX', 'msg' => 'Syntax error' ), JSON_ERROR_UTF8 => array ( 'errorCode' => 'JSON_ERROR_UTF8', 'msg' => 'Malformed UTF-8 characters, possibly incorrectly encoded' )/*, JSON_ERROR_RECURSION => array ( 'errorCode' => 'JSON_ERROR_RECURSION', 'msg' => 'One or more recursive references in the value to be encoded' ), JSON_ERROR_INF_OR_NAN => array ( 'errorCode' => 'JSON_ERROR_INF_OR_NAN', 'msg' => 'One or more NAN or INF values in the value to be encoded' ), JSON_ERROR_UNSUPPORTED_TYPE => array ( 'errorCode' => 'JSON_ERROR_UNSUPPORTED_TYPE', 'msg' => 'A value of a type that cannot be encoded was given' )*/ ); if ($errNo===0) { $r = $errorTypes[0]; } else { $r = array_key_exists ($errNo, $errorTypes) ? $errorTypes[$errNo] : array ( 'errorCode' => 'ERROR_UNKNOWN_ERROR', 'msg' => 'json_last_error() returned a code that is unknown to fucntions__basicErrorHandling.php::wo_php_json_last_error_humanReadable()' ); }; return $r; } function wo_php_errorType_humanReadable ($errNo) { if (phpversion() < '4.0.0') { $errorTypes = array ( 1 => 'Error', 2 => 'Warning', 4 => 'Parsing Error', 8 => 'Notice', 2047 => 'E_ALL' ); } elseif (phpversion() < '5.0.0') { $errorTypes = array ( 1 => 'Error', 2 => 'Warning', 4 => 'Parsing Error', 8 => 'Notice', 16 => 'Core Error', 32 => 'Core Warning', 64 => 'Compile Error', 128 => 'Compile Warning', 256 => 'User Error', 512 => 'User Warning', 1024=> 'User Notice', 2047=> 'E_ALL' ); } elseif (phpversion() < '5.2.0') { $errorTypes = array ( 1 => 'Error', 2 => 'Warning', 4 => 'Parsing Error', 8 => 'Notice', 16 => 'Core Error', 32 => 'Core Warning', 64 => 'Compile Error', 128 => 'Compile Warning', 256 => 'User Error', 512 => 'User Warning', 1024=> 'User Notice', 2048=> 'Strict', 2047=> 'E_ALL' ); } elseif (phpversion() < '5.3.0') { $errorTypes = array ( 1 => 'Error', 2 => 'Warning', 4 => 'Parsing Error', 8 => 'Notice', 16 => 'Core Error', 32 => 'Core Warning', 64 => 'Compile Error', 128 => 'Compile Warning', 256 => 'User Error', 512 => 'User Warning', 1024=> 'User Notice', 2048=> 'Strict', 4096=> 'Recoverable', 6143=> 'E_ALL' ); } elseif (phpversion() >= '5.3.0' && phpversion() < '6.0.0') { $errorTypes = array ( 1 => 'Error', 2 => 'Warning', 4 => 'Parsing Error', 8 => 'Notice', 16 => 'Core Error', 32 => 'Core Warning', 64 => 'Compile Error', 128 => 'Compile Warning', 256 => 'User Error', 512 => 'User Warning', 1024=> 'User Notice', 2048=> 'Strict', 4096=> 'Recoverable', 8192=> 'Depracated', 16384=> 'User-level Depracated', 30719=> 'E_ALL' ); } elseif (phpversion() >= '6.0.0') { $errorTypes = array ( 1 => 'Error', 2 => 'Warning', 4 => 'Parsing Error', 8 => 'Notice', 16 => 'Core Error', 32 => 'Core Warning', 64 => 'Compile Error', 128 => 'Compile Warning', 256 => 'User Error', 512 => 'User Warning', 1024=> 'User Notice', 2048=> 'Strict', 4096=> 'Recoverable', 8192=> 'Depracated', 16384=> 'User-level Depracated', 32767=> 'E_ALL' ); } return $errorTypes[$errNo]; } ?> __FILE__==='functions__internalErrorHandling.php'; $errMeta); }; //$errMeta = filterArgs($errMeta, $filterSettings); $e = array ( 'isMetaForFunc' => true, 'phpErrorClass' => $errNo, 'phpErrorType' => wo_php_errorType_humanReadable ($errNo), 'error' => $errMeta, ); $traceData = debug_backtrace(); $e['backtrace'] = $traceData;//phpFilterBacktraceData($traceData,$filterSettings); $e['globals'] = getGlobals(); //var_dump ($e); /*if (function_exists('saError')) { echo 'error handler === saError()'; saError ($errNo, $errMeta); // http://seductiveapps.com } else*/if (function_exists('woError')) { echo 'error handler === woError()'; woError ($errNo, $errMeta); } else { echo 'functions__internalErrorHandling.php::no error handler specified, var_dump-ing.
';
 var_dump ($e);
 echo '
'; } return $e; } function getGlobals() { $r = array ( '$_GET' => $_GET, '$_POST' => $_POST, '$_COOKIE' => $_COOKIE ); return $r; } function good($r) { return ( is_array($r) && array_key_exists('result',$r) ); } //function &result(&$r) { function &result(&$r) { return $r['result']; } function &resultArray (&$r) { $r2 = array(); foreach ($r as $k => $v) { $r2[$k] = result($v); } return $r2; } function &goodResult(&$r) { $r2 = array ( 'isMetaForFunc' => true, 'result' => &$r ); return $r2; } ?> __FILE__==='errorHandling_css_forLightBackgrounds.css' .woError { border : 2px solid red; border-radius : 5px; padding : 5px; background : yellow; color : red; } .woStacktrace { font-size : 90%; font-weight : bold; } .woStacktrace__basePath { color : purple; } .woStacktrace__item { } .woStacktrace__file { color : navy; } .woStacktrace__function { color : #002300; } .woStacktrace__line { color : blue; } .woStacktrace__args { color : navy; font-weight : normal; } .woStacktrace__arg { color : blue; } .woStacktrace__argSeperator { color : purple; background : white; font-weight : bold; font-size : 100%; } __FILE__==='errorHandling_css_forDarkOrSemitransparentBackgrounds.css' .woError { border : 2px solid red; border-radius : 5px; padding : 5px; background : yellow; color : red; opacity : 0.767 } .woStacktrace { font-size : 90%; font-weight : bold; } .woStacktrace__basePath { color : purple; } .woStacktrace__item { } .woStacktrace__file { color : navy; } .woStacktrace__function { color : #002300; } .woStacktrace__line { color : blue; } .woStacktrace__args { color : navy; font-weight : normal; } .woStacktrace__arg { color : blue; } .woStacktrace__argSeperator { color : purple; background : white; font-weight : bold; font-size : 100%; } On Sun, Aug 28, 2016 at 5:16 AM, Rene Veerman < rene.veerman.netherlands@gmail.com> wrote: > nothing's better than cut-n-pasting, i knooow :) > > so in the next few messages i'll include my own PHP handlers.. it's 4 > files, which i'll just post as ordinary text.. dunno and dont wanna test if > attaching works to the entire list architecture (web caches and stuff).. > > On Sun, Aug 28, 2016 at 5:07 AM, Rene Veerman gmail.com> wrote: > >> Hi. >> >> Once again, thanks for keeping PHP free to use and so widely and easily >> installed.. >> >> I have another feature request (sent earlier tonight).. >> >> I quite often, much more than i like, *need* a stacktrace and *proper* >> variable listings for each function called in PHP when it barfs out nothing >> more than an apache error log entry.. >> And can we please show such entries in the browser *as well as the apache >> log*? Or if nothing else, *just* in the browser? >> >> Rather than going "all the way" and making variable contents (which can >> grow quite large) collapsable and shit *right away*, you could simply add >> the right and

class="" names and supply a CSS file. I use it in >> all error handling that does make it to set_error_handler(myHandler), and >> that really is what makes things like my obfuscator (also posted about to >> the php-general@lists.php.net earlier tonight) possible. >> And taking things that far allows guys like me to provide you with a >> collapsable large-JSON-decoding viewer addon for such logfiles later (rest >> assured that that'll get done once you do this for me).. i call it >> jsonViewer and i should have it back up at http://seductiveapps.com/tools >> /json (or /jsonViewer) once the obfuscator is fully done in a few weeks, >> at most.. >> >> if you want me to build (and opensource) things like that true-obfuscator >> and my JSON scalable database architecture using just apache2+ and php5+, >> it would really cut my development time in more than half if you could add >> "all of this" (it's deadsimple and a few hours work imo) to the next >> versions of PHP (and please make it the default, you can include sample CSS >> or read in a CSS file that you set in php.ini (comment on how to do this in >> the logfile html please)).. >> >> see https://github.com/seductiveapps/folderDB/blob/master/todo. >> platform.txt for all relevant updates concerning these developments >> mentioned here.. >> >> Thanks in advance for considering and likely adopting the 2 small changes >> i need in the next versions of PHP.. I run ubuntu btw.. I'll be checking >> the php.net pages for your future updates.. >> >> If anyone can gimme a duration-to-completion for each of my requests of >> tonight, that'd be awesome. I'll take a "wild guess", or any serious >> objections that i might be able to sway out of the way.. >> >> > --001a114d318e958365053b19408b--