Пример #1
0
function db1($x, $lv = 3, $die = 0)
{
    static $t, $i;
    $i++;
    if (!$t) {
        echo "<link rel=stylesheet href='http://x24.fr/!c/syntax.css'><script src='http://x24.fr/!c/syntax.js'></script>";
        $t = 1;
    }
    #if(!is_array($x))$x=[$x];
    #@ob_start();var_debug($x);$x=ob_get_clean();
    $x = var_debug($x);
    #\Doctrine\Common\Util\Debug::dump($x, $lv)
    echo "<pre class=pre id='predb{$i}'>" . $x . "</pre>";
    $_ENV['js'][] = "var x=document.getElementById('predb{$i}');window.onload=x.innerHTML=syntaxHighlight(x.innerHTML);";
    if ($die) {
        die;
    }
}
Пример #2
0
 static function d($debug, $cond = 1, $dies = 0, $file = 0)
 {
     #returns single instance from static context to be used as an object : Debug::d($debug);
     if (!$cond) {
         return;
     }
     #@ob_start();\Doctrine\Common\Util\Debug::dump($debug,4);$$debug=ob_get_clean();return pr1($debug);#doctrine way
     $obj = self::i();
     init();
     $bt = debug_backtrace();
     if (count($bt) > 2) {
         array_shift($bt);
     }
     $call = array_shift($bt);
     $call = $call['file'] . ':' . $call['line'];
     #$tmp=explode('/',$call['file']);if(count($tmp)<2)$tmp=explode('\\',$call['file']);#nunows
     $debug = cleanRecursion($debug);
     cleanNullOrMaxDepthArrays($debug);
     if ($file) {
         file_put_contents($file, serialize(compact('call', 'debug')));
     }
     #Keep a Memo
     if (0) {
         #***
         $xt = (array) end($debug);
         $y = [];
         $y = array_keys($xt);
         $split = str_split($y[1]);
         foreach ($split as &$v) {
             $v .= '§' . ord($v);
         }
         unset($v);
         pr1(['line' => __LINE__, 'aborted', $split, isset($xt[PRIV . 'factetape'])] + $y, 1);
         #enfants,statut,data,*factetape ( public from proposition );
     }
     #isSerializable, now !
     #$debug=var_debug($debug);
     if (isset($_SERVER['HTTP_X_REQUESTED_WITH'])) {
         #AJAX
         if ($dies) {
             $debug = JSON_encode(compact('call', 'debug'));
             cleanOut($debug, 1);
             die($debug);
         }
         #return new JSON_response
         return compact('call', 'debug');
         #return new JSON_response
         #return json_encode($debug);
     }
     if (!isset($_SERVER['HTTP_HOST'])) {
         $debug = print_r(compact('call', 'debug'), 1);
         die(CleanOut($debug));
     }
     #Failsafe for first debug ( recursivity issues ) toggles advanced display -> is now flattened
     $debug = var_debug($debug);
     $debug = print_r(compact('call', 'debug'), 1);
     CleanOut($debug);
     /* know that #client referers to first client level
     $x = preg_replace("~\n[ ]+(bool|int)\(([a-z]*[0-9]*)\)~", "\\2", $x);
     $x = preg_replace("~\n[ ]+string\([0-9]+\)~", "", $x);
     #$x=preg_replace("~\n    bool(false)~","0",$x);
     $x = preg_replace("~\n[ ]+([^\n]+\n[ ]+null|\[[^\n]+\] => null)~i", "", $x);
     $x = preg_replace("~\(([0-9]+)\) {\n[ ]+\.\.\.\n[ ]+}~", "(\\1)...", $x);
     */
     if ($dies < 0) {
         file_put_contents(ini_get('error_log'), print_r($debug, 1));
         return;
     }
     header('Content-Type: text/html; charset=utf-8', 1);
     echo "<link rel=stylesheet href='//ben/codes/debug.css'><script src='//ben/codes/debug.js' type='text/javascript'></script>";
     #
     if ($dies) {
         die(pr1($debug));
     }
     return pr1($debug);
 }