Newsgroups: php.general,php.internals Path: news.php.net Xref: news.php.net php.general:325715 php.internals:95486 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 16500 invoked from network); 28 Aug 2016 03:53:55 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 28 Aug 2016 03:53:55 -0000 Authentication-Results: pb1.pair.com smtp.mail=ocramius@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=ocramius@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 74.125.82.45 as permitted sender) X-PHP-List-Original-Sender: ocramius@gmail.com X-Host-Fingerprint: 74.125.82.45 mail-wm0-f45.google.com Received: from [74.125.82.45] ([74.125.82.45:35100] helo=mail-wm0-f45.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 8B/0A-34481-D4062C75 for ; Sat, 27 Aug 2016 23:53:50 -0400 Received: by mail-wm0-f45.google.com with SMTP id f65so37746478wmi.0; Sat, 27 Aug 2016 20:53:49 -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 :cc; bh=/91shRWpb/GaIFBUnF6rX7gNcdg8BwuekVCou0ocU5w=; b=G9Kxse83WJw7ToZ2RGqIuut+/hXrAmx3+EtTsKpaZI9xx4iKuhpPBbr3AIfFDZgtAT tjUZeojF6R3BXbDMgIOQya3gRBRjAWpwgTeMQkd2WeZQHUy/Q+7Z3aaLVXsnRswZifEK cgOE+4FqQ7B170R8rFcRREQoIIWwqNh7RtO5Hpih8ZX9lsMhqYMzv1Md0yvSsRg/vx/P GX4662ReRvCM8DTX3SroOAXuMgh8v5XZRVaxsYWtgMFXoA0X+XZSd+vu+7bOaopSQaOf 5c7UhyBRajB8NTnsb8u4+nXMEQnCWF3jVeag5dWDGBZXqG2daYroACvG0NZWuw8sOVYF GjkA== 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:cc; bh=/91shRWpb/GaIFBUnF6rX7gNcdg8BwuekVCou0ocU5w=; b=OecRTEtWRwbFk5TH/Wp5pDFWXLmzJnGow+IoYnNlmsqCDG4LX+WsQgqtZYt4HUKcpR d370sJ07kryPp4LJw3AOfFo/pRtcglmBbuUxsoEP745W6BCJGAULJO/TSkxv+30KFYGP elc0ZuvvFqx3MPdeQA/eMRXzDR9Ahzdysm1cmtDwPVdeaVQMHjiCKiTAaXmu7U7hZq1L bzJiC7OOpuZ4NuhLDPtEXGyotxSIMSiQGA1GzWMreiKa0pDL8kK4v4FyowRbW7Oh0dG4 aCcxvcJ9Q57yqIhikGaYDWbJiH13x+rFLjK/macLQq/9Rs6VBcS/CeqZvdYdWUJXqS18 CTzA== X-Gm-Message-State: AE9vXwPiFKDtAyvBaWSDgFZWiGSK9jjXHxSPBiNWEF4nMHDcp3o2LPu/e7UBafwxpKiu3WMOqoQP43JmnuDClA== X-Received: by 10.28.27.211 with SMTP id b202mr5083441wmb.12.1472356426873; Sat, 27 Aug 2016 20:53:46 -0700 (PDT) MIME-Version: 1.0 Received: by 10.194.19.229 with HTTP; Sat, 27 Aug 2016 20:53:44 -0700 (PDT) Received: by 10.194.19.229 with HTTP; Sat, 27 Aug 2016 20:53:44 -0700 (PDT) In-Reply-To: References: Date: Sun, 28 Aug 2016 05:53:44 +0200 Message-ID: To: Rene Veerman Cc: PHP Internals List , php-general@lists.php.net Content-Type: multipart/alternative; boundary=001a114b3ab8ce81ac053b19b13e Subject: Re: [PHP-DEV] Re: feature-request : html + css logging in apache logs (example for the rest of the unix community too) From: ocramius@gmail.com (Marco Pivetta) --001a114b3ab8ce81ac053b19b13e Content-Type: text/plain; charset=UTF-8 Are you looking for https://filp.github.io/whoops/ ? On 28 Aug 2016 5:29 a.m., "Rene Veerman" wrote: > eh oops, this would've maybe been easier, and allows me to update these > sources in the future if and when needed.. > > https://github.com/seductiveapps/webappObfuscator/blob/master/ > webappObfuscator-1.0.0/functions__basicErrorHandling.php > https://github.com/seductiveapps/webappObfuscator/blob/master/ > webappObfuscator-1.0.0/1.0.0/functions.php > https://github.com/seductiveapps/webappObfuscator/blob/master/ > webappObfuscator-1.0.0/functions__internalErrorHandling.php > light background css : > https://github.com/seductiveapps/webappObfuscator/blob/master/ > webappObfuscator-1.0.0/webappObfuscator-1.0.0__ajax.css > dark background css : > https://github.com/seductiveapps/webappObfuscator/blob/master/ > webappObfuscator-1.0.0/webappObfuscator-1.0.0.css > > > On Sun, Aug 28, 2016 at 5:21 AM, Rene Veerman < > rene.veerman.netherlands@gmail.com> wrote: > > > all are donated to public domain : > > > > __FILE__==='functions__internalErrorHandling.php'; > > > require_once (dirname(__FILE__).'/1.0.0/functions.php'); > > require_once (dirname(__FILE__).'/functions__basicErrorHandling.php'); > > > > function woError ($errCode, $errMsgOrArray) { > > if (is_array($errMsgOrArray)) { > > > > if (ob_get_length()>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'; > > > > > /*--- > > this is my way of providing quality runtime debugging info > > (to the computerprogram itself, to developers, to end-users) > > and -even more important- creating robust computerprograms that > > can be debugged quickly when they break when they're faced with the > > unexpected. > > a future version of this will email all the *releveant* debug details > > to the developer(s) whenever the unexpected hits the computer program > > using this. > > draft of this extension is detailed in webappObfuscator-1.0.0.php::: > > webappObfuscator::readTokens() > > */ > > > > function badResult ($errNo, $errMeta=null) { > > if ( > > is_string($errNo) > > || is_array($errNo) > > ) { > > $errMeta = $errNo; > > $errNo = E_USER_ERROR; > > $errMeta['additionalError'] = 'badResult called with no $errNo as first > > parameter'; > > }; > > if (is_string($errMeta)) { > > $errMeta = array ('msg'=>$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 > 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 < > >> rene.veerman.netherlands@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.p > >>> latform.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.. > >>> > >>> > >> > > > --001a114b3ab8ce81ac053b19b13e--