SHARE
TWEET

dump.php

jessicakennedy1028 Sep 9th, 2018 26 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2.     function dump(&$var, $autohide = TRUE, $collaspe = TRUE) {
  3.         $format = array('N'=>"\n", 'T'=>"\t", 'BR'=>"<br />", 'BRN'=>"<br />\n");
  4.         $css  = ".content-wrapper {font-family:Verdana,Arial;font-size:12px;list-style:none;margin:0;padding:0;outline:0;text-decoration:none;box-sizing:border-box!important;-webkit-box-sizing:border-box!important;-moz-box-sizing:border-box!important;-ms-box-sizing:border-box!important}";
  5.         $css .= ".dumpnotify{-webkit-border-radius:5px;-moz-border-radius:3px;border-radius:3px;border:1px solid #000;width:480px;margin:15px}";
  6.         $css .= "div.dumpnotify .content-wrapper,div.dumpnotify .header-wrapper{padding:10px;max-width:480px;-moz-box-shadow:inset 0 2px 0 -1px rgba(255,255,255,.2);-webkit-box-shadow:inset 0 2px 0 -1px rgba(255,255,255,.2);box-shadow:inset 0 2px 0 -1px rgba(255,255,255,.2)}";
  7.         $css .= "div.dumpnotify .header-wrapper{width:100%;display:table;padding-left:20px;padding-right:20px;border-bottom:1px solid #000;background:#464646;background:-moz-linear-gradient(top,#464646 0,#3f3f3f 50%,#3f3f3f 51%,#3d3d3d 100%);background:-webkit-gradient(linear,left top,left bottom,color-stop(0,#464646),color-stop(50%,#3f3f3f),color-stop(51%,#3f3f3f),color-stop(100%,#3d3d3d));background:-webkit-linear-gradient(top,#464646 0,#3f3f3f 50%,#3f3f3f 51%,#3d3d3d 100%);background:-o-linear-gradient(top,#464646 0,#3f3f3f 50%,#3f3f3f 51%,#3d3d3d 100%);background:-ms-linear-gradient(top,#464646 0,#3f3f3f 50%,#3f3f3f 51%,#3d3d3d 100%);background:linear-gradient(to bottom,#464646 0,#3f3f3f 50%,#3f3f3f 51%,#3d3d3d 100%);filter:progid:DXImageTransform.Microsoft.gradient( startColorstr='#464646', endColorstr='#3d3d3d', GradientType=0 )}";
  8.         $css .= "div.dumpnotify .header-wrapper .title{font-family:Verdana;font-size:18px;font-weight:100;color:#e6e6e6;float:left}div.notify .header-wrapper .notifications{font-family:verdana;font-size:13px;padding-left:30px;padding-top:2px;padding-bottom:2px;color:#e6e6e6;float:right}";
  9.         $css .= "div.dumpnotify .content-wrapper{display:table;padding-left:15px;background-color:#84413B;width:100%}div.notify .content-wrapper .number{font-family:Helvetica;float:right;font-size:30pt;color:#fff;font-weight:500;background:#773d3d;padding:25px 15px;margin:10px;-webkit-border-radius:5px;-moz-border-radius:5px;border-radius:5px;-moz-box-shadow:inset 0 1px 0 0 rgba(0,0,0,.3),inset 0 -1px 0 0 rgba(255,255,255,.3);-webkit-box-shadow:inset 0 1px 0 0 rgba(0,0,0,.3),inset 0 -1px 0 0 rgba(255,255,255,.3);box-shadow:inset 0 1px 0 0 rgba(0,0,0,.3),inset 0 -1px 0 0 rgba(255,255,255,.3)}";
  10.         $css .= ".fa-user{color:#fff!important;font-size:4em;display:inline-block}.floatleft{float:left;padding:11px 6px;text-shadow:0 1px 1px #000;font-size:1em;color:#fff}.pdtop{padding-top:5px;line-height:18px}";
  11.         $css .= ".toggle-box{display:none}.toggle-box+label{cursor:pointer;display:block;font-weight:700;line-height:16px;margin-top:5px;margin-bottom:5px}";
  12.         $css .= ".toggle-box+label+div{display:none;margin-bottom:10px}.toggle-box+label::after{color:#FFF;font-weight:700;font-size: 12px;content:'...}'}";
  13.         $css .= ".toggle-box:checked+label+div{display:block;-webkit-animation:fadein 2s;-moz-animation:fadein 2s;-ms-animation:fadein 2s;-o-animation:fadein 2s;animation:fadein 2s}";
  14.         $css .= ".toggle-box+label:before{background-color:#4F5150;-webkit-border-radius:10px;-moz-border-radius:10px;border-radius:10px;color:#FFF;content:\"+\";display:inline-block;font-weight:700;height:15px;line-height:15px;margin-right:5px;text-align:center;width:15px}";
  15.         $css .= ".toggle-box:checked+label:before{content:\"-\"}.toggle-box:checked+label:after{content:\"    \"}.maindiv{display:block;background:#000;color:#FFF;font-family:Verdana;font-size:10px;line-height:13px;padding:5px 5px 5px 20px}";
  16.         $css .= ".version{color:#FFF;font-family:Verdana;font-size:8px;line-height:10px;margin:0 0 10px;padding:5px}";
  17.         $css .= "@keyframes fadein{from{opacity:0}to{opacity:1}}@-moz-keyframes fadein{from{opacity:0}to{opacity:1}}@-webkit-keyframes fadein{from{opacity:0}to{opacity:1}}@-ms-keyframes fadein{from{opacity:0}to{opacity:1}}@-o-keyframes fadein{from{opacity:0}to{opacity:1}}";
  18.         $css .= ".dumpicon{display: block;z-index:999999;position:static;}";
  19.  
  20.         if ($autohide) {
  21.             $css .= ".diagdumpbox {text-align: left; position: fixed; top: 5px; left: 5px; width: 32px; height: 32px; z-index: 999999;}.diagdumpbutton {cursor: pointer;transition: all 0.3s ease-out;}";
  22.             $css .= ".diagdumpoverlay {position: absolute;z-index: 9999;top: 0;bottom: 0;left: 0;right: 0;transition: opacity 500ms;visibility: hidden;opacity: 0;}.diagdumpoverlay:target {visibility: visible;opacity: 1;}";
  23.             $css .= ".diagdumppopup {margin: 70px auto;padding: 20px;background: #fff;border-radius: 5px;width: 43%;position: relative;transition: all 5s ease-in-out;-webkit-box-shadow: 0px 0px 12px 6px #444;-moz-box-shadow: 0px 0px 12px 6px #444;box-shadow: 0px 0px 12px 6px #444;}";
  24.             $css .= ".diagdumppopup h2 {margin-top: 0;color: #333;font-family: Tahoma, Arial, sans-serif;}.diagdumppopup .close {position: absolute;top: 15px;right: 15px;transition: all 200ms;font-size: 25px;font-weight: bold;text-decoration: none;color: #333;background: #FFF;border: 1px solid black;border-radius: 25px;height: 27px;width: 27px;text-align: center;}.diagdumppopup .close:hover {color: #773d3d;}";
  25.             $css .= ".diagdumppopup .content {max-height: 30%;overflow: auto;}@media screen and (max-width: 700px){.diagdumpbox{width: 70%;}.diagdumppopup{width: 70%;}}";
  26.         }
  27.  
  28.         $output = $format['T'].'<style type="text/css">'.$format['N'].$css.$format['N'].$format['T'].'</style>'.$format['N'];
  29.         $arrayCount = number_format(count($var, COUNT_RECURSIVE));
  30.         $size = (function_exists('mb_strlen') ? mb_strlen(serialize($var), '8bit') : strlen(serialize($var)));
  31.         $scope = false;
  32.         $dumpver = "2.3.1";
  33.         $prefix = 'unique';
  34.         $suffix = 'value';
  35.         $vals = ($scope ? $scope : $GLOBALS);
  36.         $collaspe = ($collaspe == TRUE ? TRUE : FALSE);
  37.         $old = $var;
  38.         $var = $new = $prefix.rand().$suffix;
  39.         $vname = FALSE;
  40.         $unit = array('b','kb','mb','gb','tb','pb');
  41.         $memusage = @round(memory_get_usage(TRUE)/pow(1024,($i=floor(log(memory_get_usage(TRUE),1024)))),2).' '.$unit[$i];
  42.         $memory_limit = @round((ini_get('memory_limit')*1000000)/pow(1024,($i=floor(log((ini_get('memory_limit')*1000000),1024)))),2).' '.$unit[$i];
  43.         $file_paths = debug_backtrace();
  44.  
  45.         foreach($vals as $key => $val) if($val === $new) $vname = $key;
  46.         $var = $old;
  47.         foreach($file_paths AS $file_path) {
  48.             $fileCalled = basename($file_path['file']);
  49.             $fileLineCalled = $file_path['line'];
  50.         }
  51.         if ($autohide) {
  52.             $output .= '<div class="diagdumpbox">';
  53.             $output .= '<a class="diagdumpbutton" href="#diagdumppopup1"><img width="32" height="32" alt="dump" class="dumpicon" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAHeElEQVRYR71Xe0yTVxQ/LdYqL+VZ5WF4zYwlxMSSiA+CmUDARRLCH6CRDaxamEAV8tE1sNlNcdT4tahoeYS4zRpAl7BkMUqmzkzUfzT4QqNMBQOiKIpCKw+hy++OS5C1GP1jN7lpv/vdc+7vnPM7555PQh8xTCZTLhFhRk2IP7Lb7ebCwsLyD1Un+VAB7BdFsS0/P/+zWbNmMfHx8XE6cOBAV2FhYfCH6psRwKFDh9y3bds2OF2pwWBo12g0EU+ePKHR0VFatGgR7d+//2lxcfGC6Xud6eD7nAIwmUw7XV1d9TabTb9jx47vIWA0GucSUdLIyIhYUFAQ+vTpU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5ErkJggg==" /></a>';
  54.             $output .= '</div>';
  55.             $output .= '<div id="diagdumppopup1" class="diagdumpoverlay">';
  56.             $output .= '<div class="diagdumppopup">';
  57.         }
  58.         $info  = '<div class="dumpnotify"><div class="header-wrapper"><span class="title">Dump Information Panel<span class="version">ver '.$dumpver.'</span></span><span class="notifications">Number of Elements</span>'.($autohide ? '<a class="close" href="#">&times;</a>' : '').'</div>';
  59.         $info .= '<div class="content-wrapper"><div class="floatleft pdtop">';
  60.         $info .= 'Total Array Size: <strong>'.@round($size/pow(1024,($i=floor(log($size,1024)))),2).' '.$unit[$i].'</strong>'.$format['BRN'];
  61.         $info .= 'Memory Usage: <strong>'.$memusage.'</strong>'.$format['BRN'];
  62.         $info .= 'Total Memory: <strong>'.$memory_limit.'</strong>'.$format['BRN'];
  63.         $info .= 'Function Called: <strong>'.$fileCalled.'</strong><span style="font-size: 9px;"> (line :'.$fileLineCalled.')</span>'.$format['BRN'];
  64.         $info .= 'Script\'s Current inode: <strong>'.getmyinode().'</strong>'.$format['BRN'];
  65.         $info .= 'File\'s Last Modified: <strong>'.date("M d Y H:i:s", getlastmod()).'</strong>'.$format['BRN'];
  66.         $info .= '</div>';
  67.         $info .= '<div>';
  68.         $info .= '<span class="number">'.$arrayCount.'</span>';
  69.         $info .= '</div>';
  70.         $info .= '</div>';
  71.         $output .= $format['T']."".$info."".$format['N'];
  72.         $output .= $format['T']."<div class='maindiv'>".$format['N'];
  73.         $output .= do_dump($var, '$'.$vname, NULL, 20, NULL, $collaspe);
  74.         $output .= "</div></div>";
  75.         if ($autohide) {
  76.             $output .= "</div></div>";
  77.         }
  78.         return $output;
  79.     }
  80.     function do_dump(&$var, $var_name = NULL, $indent = NULL, $divpad = 20, $reference = NULL, $collaspe) {
  81.         $format = array('N'=>"\n", 'T'=>"\t", 'BR'=>"<br />", 'BRN'=>"<br />\n");
  82.         $reference = $reference.$var_name;
  83.         $keyvar = 'the_do_dump_recursion_protection_scheme';
  84.         $keyname = 'referenced_object_name';
  85.  
  86.         if (is_array($var) && isset($var[$keyvar])) {
  87.             $real_var = &$var[$keyvar];
  88.             $real_name = &$var[$keyname];
  89.             $type = ucfirst(gettype($real_var));
  90.             $output .= $format['T'].$format['T'].$format['T']."$indent$var_name <span style='color:#a2a2a2; font-size: 9px;'>$type</span> = <span style='color:#e87800;'>&$real_name</span>".$format['N'];
  91.         } else {
  92.             $var = array($keyvar => $var, $keyname => $reference);
  93.             $avar = &$var[$keyvar];
  94.             $type = ucfirst(gettype($avar));
  95.             if($type == "String") {
  96.                 $type_color = "<span style='color:green'>";
  97.             }
  98.             elseif($type == "Integer") {
  99.                 $type_color = "<span style='color:red'>";
  100.             }
  101.             elseif($type == "Double") {
  102.                 $type_color = "<span style='color:#0099c5'>";
  103.                 $type = "Float";
  104.             }
  105.             elseif($type == "Boolean") {
  106.                 $type_color = "<span style='color:#92008d'>";
  107.             }
  108.             elseif($type == "NULL") {
  109.                 $type_color = "<span style='color:black'>";
  110.             }
  111.             if (is_array($avar)) {
  112.                 $count = count($avar);
  113.                 $uuid = uniqid();
  114.                 $output = ("&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;".$var_name ? $format['T'].$format['T'].($collaspe == TRUE ? "<input class='toggle-box' id=\"$uuid\" type='checkbox' />".$format['N'].$format['T'].$format['T']."<label for=\"$uuid\">".$format['N'] : "").$format['T'].$format['T'].$format['T']."$var_name => " : "")."<span style='color:#a2a2a2; font-size: 9px;'>$type ($count) </span><span style='color: #FFF; font-size: 12px;font-weight: 700'> {</span>".($collaspe == TRUE ? "</label>" : "").$format['N'];
  115.                 $keys = array_keys($avar);
  116.                 $output .= $format['T'].$format['T'].'<div style="padding-left: '.$divpad.'px">'.$format['N'];
  117.                 foreach($keys as $name) {
  118.                     $value = &$avar[$name];
  119.                     $divpad = 20;
  120.                     $output .= do_dump($value, "['$name']", $indent, $divpad, $reference, $collaspe);
  121.                 }
  122.                 $output .= '<span style="color: #FFF;font-weight: 700">}</span>'.$format['N'];
  123.                 $output .= '</div>'.$format['N'];
  124.             }
  125.             elseif(is_object($avar)) {
  126.                 $output = $format['T'].$format['T'].$format['T']."$indent&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$var_name <span style='color:#a2a2a2; font-size: 9px;'>$type</span>".$format['N'].$format['T'].$format['T'].$format['T']."$indent(".$format['N'];
  127.                 $divpad = $divpad + 20;
  128.                 foreach($avar as $name=>$value) {
  129.                     $output .= do_dump($value, "$name", $indent, $divpad, $reference, $collaspe);
  130.                 }
  131.                 $output .= "$indent)".$format['N'];
  132.             }
  133.             elseif(is_int($avar)) {
  134.                 $output = $format['T'].$format['T'].$format['T'].$indent."&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$var_name = <span style='color:#a2a2a2; font-size: 9px;'>$type(".strlen($avar).")</span> $type_color$avar</span>".$format['BRN'];
  135.             }
  136.             elseif(is_string($avar)) {
  137.                 $output = $format['T'].$format['T'].$format['T'].$indent."&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$var_name = <span style='color:#a2a2a2; font-size: 9px;'>$type(".strlen($avar).")</span> $type_color\"$avar\"</span>".$format['BRN'];
  138.             }
  139.             elseif(is_float($avar)) {
  140.                 $output = $format['T'].$format['T'].$format['T'].$indent."&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$var_name = <span style='color:#a2a2a2; font-size: 9px;'>$type(".strlen($avar).")</span> $type_color$avar</span>".$format['BRN'];
  141.             }
  142.             elseif(is_bool($avar)) {
  143.                 $output = $format['T'].$format['T'].$format['T'].$indent."&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$var_name = <span style='color:#a2a2a2; font-size: 9px;'>$type(".strlen($avar).")</span> $type_color".($avar == 1 ? "TRUE":"FALSE")."</span>".$format['BRN'];
  144.             }
  145.             elseif(is_null($avar)) {
  146.                 $output = $format['T'].$format['T'].$format['T'].$indent."&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$var_name = <span style='color:#a2a2a2; font-size: 9px;'>$type(".strlen($avar).")</span> {$type_color}NULL</span>".$format['BRN'];
  147.             }
  148.             else {
  149.                 $output = $format['T'].$format['T'].$format['T'].$indent."&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$var_name = <span style='color:#a2a2a2; font-size: 9px;'>$type(".strlen($avar).")</span> $avar".$format['BRN'];
  150.             }
  151.             $var = $var[$keyvar];
  152.         }
  153.         return $output;
  154.     }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top