Esempio n. 1
0
 static function dump(&$source)
 {
     self::$depth = 0;
     self::drawStyles();
     //$s = microtime(true);
     //self::$objects = array();
     self::$calls++;
     echo '<div class="dumphper">';
     self::_dump($source);
     echo '</div>';
     //echo round(microtime(true) - $s,6)*1000 . 's';
 }
 function d()
 {
     static $bSetStyle = True;
     static $bExit = True;
     if (!class_exists('Dumphper', False)) {
         define('DPHP_USE_ACCESSIBLE', version_compare(PHP_VERSION, '5.3.0') >= 0);
         $Path = defined('USEFULFUNCTIONS_VENDORS') ? USEFULFUNCTIONS_VENDORS : dirname(__FILE__) . '/../vendors';
         require $Path . '/class.dumphper.php';
         Dumphper::$escape_keys = false;
         Dumphper::$max_showw_depth = 8;
         Dumphper::$encoding = 'utf-8';
     }
     $Args = func_get_args();
     if (count($Args) == 0 && $bExit) {
         $bExit = False;
     }
     if (PHP_SAPI != 'cli') {
         if (!headers_sent()) {
             if (defined('CP1251')) {
                 header('Content-Type: text/html; charset=windows-1251');
             } else {
                 header('Content-Type: text/html; charset=utf-8');
             }
         }
         if ($bSetStyle) {
             $bSetStyle = False;
             echo "<style type='text/css'>.dumphper span{font-size:14px !important;font-family:'Arial' !important;}</style>\n";
         }
         if (defined('CP1251')) {
             echo '<pre style="font-size:14px">';
             $Count = 0;
             foreach ($Args as $A) {
                 $String = VarDump($A);
                 $String = preg_replace("/\\=\\>\n +/s", '=> ', $String);
                 echo str_repeat("*", ++$Count) . ' ';
                 echo $String;
             }
             die;
         }
         //var_dump($Args);
         foreach ($Args as $A) {
             //var_dump($A);die;
             if (is_string($A) && defined('CP1251')) {
                 $A = mb_convert_encoding($A, 'utf-8', 'windows-1251');
             }
             Dumphper::dump($A);
         }
     } else {
         $i = 1;
         ob_start();
         foreach ($Args as $A) {
             echo str_repeat('*', $i++) . ' ';
             var_dump($A);
         }
         $String = ob_get_contents();
         @ob_end_clean();
         $Encoding = 'cp866';
         if (class_exists('Gdn', FALSE)) {
             $Encoding = Gdn::Config('Plugins.UsefulFunctions.Console.MessageEnconding');
         }
         $String = preg_replace("/\\=\\>\n +/s", '=> ', $String);
         if ($Encoding && $Encoding != 'utf-8') {
             $String = mb_convert_encoding($String, $Encoding, 'utf-8');
         }
         echo $String;
     }
     if (class_exists('Gdn', FALSE)) {
         if (method_exists('Gdn', 'Database')) {
             $Database = Gdn::Database();
             if ($Database != Null) {
                 $Database->CloseConnection();
             }
         }
     }
     if ($bExit) {
         exit;
     }
 }