示例#1
0
 /**
  * Dump a variable
  *
  * @param mixed $var    variable which will be dumped
  * @param bool  $inline force inline display if true, otherwise will attempt to
  *                      use debug.log event
  *
  * @return void
  */
 public static function dump($var, $inline = false)
 {
     $events = \Xoops::getInstance()->events();
     $eventName = 'debug.log';
     if (!$inline && $events->hasListeners($eventName)) {
         $events->triggerEvent($eventName, $var);
         //\Kint::dump(func_get_arg(0));
     } else {
         $config = array('skin' => array('selected' => 'modern'), 'css' => array('url' => \XoopsBaseConfig::get('url') . '/modules/xmf/css/krumo/'), 'display' => array('show_version' => false, 'show_call_info' => false, 'sort_arrays' => false));
         \krumo::setConfig($config);
         $msg = \krumo::dump($var);
         echo $msg;
     }
 }
示例#2
0
文件: Debug.php 项目: nvarney/dwa
 public static function info()
 {
     // disable in production, except from PJ HQ ip address
     if (isset($_GET['debug']) && strtolower($_GET['debug']) != "false") {
         // debug block w/ execution time and router info
         echo PHP_EOL . '<div style="font-family: monospace; font-size: 13px; width: 80%; margin: 20px auto;"><b style="color: #008800;">DEBUG INFO</b><br/>' . PHP_EOL;
         echo '<b>Routed Controller/Method:</b> ' . Router::$controller . '/' . Router::$method . '<br/>' . PHP_EOL;
         echo '<b>Execution Time:</b> ' . EXECUTION_TIME . ' sec' . PHP_EOL;
         // show mysql query history
         echo DB::instance()->query_history() . PHP_EOL;
         // show included files
         krumo::includes(FALSE) . PHP_EOL;
         echo '<br/></div>' . PHP_EOL;
         // disable krumo in production
     } elseif (IN_PRODUCTION) {
         // disable krumo output
         krumo::disable();
     }
 }
示例#3
0
    /**
     * Render a dump for an object
     *
     * @param mixed $data
     * @param string $name
     * @access private
     * @static
     */
    function _object(&$data, $name)
    {
        ?>
<li class="krumo-child">

	<div class="krumo-element<?php 
        echo count($data) > 0 ? ' krumo-expand' : '';
        ?>
"
		<?php 
        if (count($data) > 0) {
            ?>
 onClick="krumo.toggle(this);"<?php 
        }
        ?>
		onMouseOver="krumo.over(this);"
		onMouseOut="krumo.out(this);">

			<a class="krumo-name"><?php 
        echo $name;
        ?>
</a>
			(<em class="krumo-type">Object</em>) 
			<strong class="krumo-class"><?php 
        echo get_class($data);
        ?>
</strong>
	</div>

	<?php 
        if (count($data)) {
            krumo::_vars($data);
        }
        ?>
</li>
<?php 
    }
示例#4
0
 /**
  * Dump information about a variable
  *
  * @param mixed $data,...
  * @access public
  * @static
  */
 public static function dump($data, $second = '')
 {
     if (Krumo::is_cli()) {
         print_r($data);
         exit;
     }
     static $setheader = null;
     if (empty($setheader) && ($setheader = 1)) {
         try {
             @header("Content-type: text/html; charset=utf-8");
         } catch (Exception $e) {
         }
     }
     // If we're capturing call dump() with just data and capture the output
     if ($second === KRUMO_RETURN) {
         ob_start();
         Krumo::dump($data);
         $str = ob_get_clean();
         return $str;
         // If we were given expand all, set the global variable
     } elseif ($second === KRUMO_EXPAND_ALL) {
         self::$expand_all = true;
         Krumo::dump($data);
         return true;
     }
     $clearObjectRecursionProtection = false;
     if (self::$objectRecursionProtection === NULL) {
         self::$objectRecursionProtection = array();
         $clearObjectRecursionProtection = true;
     }
     // disabled
     if (!Krumo::_debug()) {
         return false;
     }
     // more arguments
     if (func_num_args() > 1) {
         $_ = func_get_args();
         foreach ($_ as $d) {
             Krumo::dump($d);
         }
         return;
     }
     // find caller
     $_ = debug_backtrace();
     while ($d = array_pop($_)) {
         $callback = self::$lineNumberTestCallback;
         $function = strToLower($d['function']);
         if (in_array($function, array("krumo", "k", "kd")) || strToLower(@$d['class']) == 'krumo' || is_callable($callback) && $callback($d)) {
             break;
         }
     }
     $showVersion = Krumo::_config('display', 'show_version', TRUE);
     $showCallInfo = Krumo::_config('display', 'show_call_info', TRUE);
     $krumoUrl = 'https://github.com/oodle/krumo';
     //////////////////////
     // Start HTML header//
     //////////////////////
     print "<div class=\"krumo-root\">\n";
     print "\t<ul class=\"krumo-node krumo-first\">\n";
     // The actual item itself
     ob_start();
     print Krumo::_dump($data);
     print str_replace(ROOT, '~', ob_get_clean());
     if ($showVersion || $showCallInfo) {
         print "\t\t<li class=\"krumo-footnote\" onDblClick=\"toggle_expand_all();\">\n";
         if ($showCallInfo && isset($d['file']) && $d['file']) {
             print "<span class=\"krumo-call\" style=\"white-space:nowrap;\">";
             print "Called from <strong><code>" . str_replace(ROOT, '~', $d['file']) . "</code></strong>, ";
             print "line <strong><code>" . $d['line'] . "</code></strong></span>";
             print "<span class=\"krumo-call\"> { Time: " . number_format(microtime(true) - LARAVEL_START, 3) . 's }</span>';
         }
         if ($showVersion && 0) {
             $version = krumo::version();
             print "<span class=\"krumo-version\" style=\"white-space:nowrap;\">\n";
             print "<strong class=\"krumo-version-number\">Krumo version {$version}</strong> | <a href=\"{$krumoUrl}\" target=\"_blank\">{$krumoUrl}</a>\n";
             print "</span>\n";
         }
         print "</li>";
     }
     print "</ul></div>\n";
     print "<!-- Krumo - HTML -->\n\n";
     // Output the CSS and JavaScript AFTER the HTML
     krumo::_css();
     ////////////////////
     // End HTML header//
     ////////////////////
     // flee the hive
     $_recursion_marker = Krumo::_marker();
     if ($hive =& Krumo::_hive($dummy)) {
         foreach ($hive as $i => $bee) {
             if (is_object($bee)) {
                 if (($hash = spl_object_hash($bee)) && isset(self::$objectRecursionProtection[$hash])) {
                     unset(self::$objectRecursionProtection[$hash]);
                 }
             } elseif (isset($hive[$i]->{$_recursion_marker})) {
                 unset($hive[$i][$_recursion_marker]);
             }
         }
     }
     if ($clearObjectRecursionProtection) {
         self::$objectRecursionProtection = NULL;
     }
     // End of dump()
 }
示例#5
0
 /**
  * Dump information about a variable
  *
  * @param mixed $data,...
  * @access public
  * @static
  * @return bool
  */
 public static function dump($data, $second = '')
 {
     if (static::isCli()) {
         $args = func_get_args();
         krumo::cli_dump($args);
         return true;
     }
     // If we're capturing call dump() with just data and capture the output
     if ($second === KRUMO_RETURN) {
         ob_start();
         static::dump($data);
         $str = ob_get_clean();
         return $str;
         // If we were given expand all, set the global variable
     } elseif ($second === KRUMO_EXPAND_ALL) {
         static::$expand_all = true;
         static::dump($data);
         return true;
     } elseif ($second === KRUMO_NO_SORT) {
         self::$sort = false;
         Krumo::dump($data);
         return true;
     } elseif ($second === KRUMO_SORT) {
         self::$sort = true;
         Krumo::dump($data);
         return true;
     }
     $clearObjectRecursionProtection = false;
     if (static::$objectRecursionProtection === null) {
         static::$objectRecursionProtection = array();
         $clearObjectRecursionProtection = true;
     }
     // disabled
     if (!static::_debug()) {
         return false;
     }
     // more arguments
     if (func_num_args() > 1) {
         $_ = func_get_args();
         $result = true;
         foreach ($_ as $d) {
             $result = $result && static::dump($d);
         }
         return $result;
     }
     // find caller
     $_ = debug_backtrace();
     while ($d = array_pop($_)) {
         $callback = static::$lineNumberTestCallback;
         $function = strToLower($d['function']);
         if (in_array($function, array("krumo", "k", "kd")) || strToLower(@$d['class']) == 'krumo' || is_callable($callback) && call_user_func($callback, $d)) {
             break;
         }
     }
     $showVersion = static::_config('display', 'show_version', true);
     $showCallInfo = static::_config('display', 'show_call_info', true);
     $krumoUrl = 'https://github.com/mmucklo/krumo';
     //////////////////////
     // Start HTML header//
     //////////////////////
     print "<div class=\"krumo-root\">\n";
     print "\t<ul class=\"krumo-node krumo-first\">\n";
     // The actual item itself
     static::_dump($data);
     if ($showVersion || $showCallInfo) {
         print "\t\t<li class=\"krumo-footnote\" onDblClick=\"toggle_expand_all();\">\n";
         if ($showCallInfo && isset($d['file']) && $d['file']) {
             print "<span class=\"krumo-call\" style=\"white-space:nowrap;\">";
             print "Called from <strong><code>" . $d['file'] . "</code></strong>, ";
             print "line <strong><code>" . $d['line'] . "</code></strong></span>";
         }
         if ($showVersion) {
             $version = static::version();
             print "<span class=\"krumo-version\" style=\"white-space:nowrap;\">\n";
             print "<strong class=\"krumo-version-number\">Krumo version {$version}</strong> | <a href=\"{$krumoUrl}\" target=\"_blank\">{$krumoUrl}</a>\n";
             print "</span>\n";
         }
         print "</li>";
     }
     print "</ul></div>\n";
     print "<!-- Krumo - HTML -->\n\n";
     // Output the CSS and JavaScript AFTER the HTML
     static::_css();
     ////////////////////
     // End HTML header//
     ////////////////////
     // flee the hive
     $_recursion_marker = static::_marker();
     if ($hive =& static::_hive($dummy)) {
         foreach ($hive as $i => $bee) {
             if (is_object($bee)) {
                 if (($hash = spl_object_hash($bee)) && isset(static::$objectRecursionProtection[$hash])) {
                     unset(static::$objectRecursionProtection[$hash]);
                 }
             } elseif (isset($hive[$i]->{$_recursion_marker})) {
                 unset($hive[$i][$_recursion_marker]);
             }
         }
     }
     if ($clearObjectRecursionProtection) {
         static::$objectRecursionProtection = null;
     }
     return true;
 }
 /**
  * Render a dump for a string value
  *
  * @param mixed $data
  * @param string $name
  * @access private
  * @static
  */
 private static function _string($data, $name)
 {
     $collapsed = krumo::_isCollapsed(self::$_level, 1);
     if ($collapsed) {
         $collapse_style = 'style="display: none;"';
     } else {
         $collapse_style = '';
     }
     // extra
     $_extra = false;
     $_ = $data;
     // Get the truncate length from the config, or default to 100
     $truncate_length = krumo::_config('display', 'truncate_length', 100);
     if (strLen($data) > $truncate_length) {
         $_ = substr($data, 0, $truncate_length - 3) . '...';
         $_extra = true;
     }
     $expand_class = '';
     if ($_extra) {
         $expand_class = 'krumo-expand';
     }
     print "<li class=\"krumo-child\">";
     print "<div class=\"krumo-element {$expand_class}\" ";
     if ($_extra) {
         print " onClick=\"krumo.toggle(this);\" ";
     }
     print "onMouseOver=\"krumo.over(this);\" onMouseOut=\"krumo.out(this);\">\n";
     print "<a class=\"krumo-name\">{$name}</a> ";
     print "(<em class=\"krumo-type\">String, <strong class=\"krumo-string-length\">" . strlen($data) . " characters</strong></em>) ";
     print "<strong class=\"krumo-string\">" . htmlSpecialChars($_) . "</strong>";
     // callback
     if (is_callable($data)) {
         print "<span class=\"krumo-callback\"> | ";
         print "(<em class=\"krumo-type\">Callback</em>) <strong class=\"krumo-string\">" . htmlSpecialChars($_) . "()</strong></span>";
     }
     print "</div>";
     if ($_extra) {
         print "<div class=\"krumo-nest\" {$collapse_style}>";
         print "<ul class=\"krumo-node\">";
         print "<li class=\"krumo-child\"> <div class=\"krumo-preview\">" . htmlSpecialChars($data) . "</div></li>";
         print "</ul></div>";
     }
     print "</li>";
 }
示例#7
0
    /**
     * Render a dump for an object
     *
     * @param mixed $data
     * @param string $name
     * @access private
     * @static
     */
    private static function _object(&$data, $name)
    {
        $childCount = count($data);
        $collapsed = krumo::_isCollapsed(self::$_level, count($data));
        $elementClasses = $childCount > 0 ? $collapsed ? ' krumo-expand' : ' krumo-expand krumo-opened' : '';
        ?>
<li class="krumo-child">
	<div class="krumo-element<?php 
        echo $elementClasses;
        ?>
"
		<?php 
        if ($childCount > 0) {
            ?>
 onClick="krumo.toggle(this);"<?php 
        }
        ?>
		onMouseOver="krumo.over(this);"
		onMouseOut="krumo.out(this);">

			<a class="krumo-name"><?php 
        echo $name;
        ?>
</a>
			(<em class="krumo-type">Object</em>) 
			<strong class="krumo-class"><?php 
        echo get_class($data);
        ?>
</strong>
	</div>

	<?php 
        if (count($data)) {
            krumo::_vars($data);
        }
        ?>
</li>
<?php 
    }
示例#8
0
 /**
  * Disable Krumo
  *
  * @return boolean
  * @access public
  * @static
  */
 public static function disable()
 {
     return false === krumo::_debug(false);
 }
示例#9
0
 /**
  * Will return the content generated by the KRUMO plugin. We use the KRUMO to automatically dump the variables generat @ run-time,
  * when an error occured to help the develper quickly debug some of it's variables. This helps him skip some var_dump () actions
  * just to check the content of a variable, which we can do with just a mouse-click in the echoed browser error-screen;
  *
  * @return S Catched Krumo contented, parsed by the KRUMO plugin, for error/variable dumping
  * @author Catalin Z. Alexandru <*****@*****.**>
  * @copyright Under the terms of the GNU General Public License v3
  * @version $Id: 08_ERR.php 313 2009-10-09 13:27:52Z catalin.zamfir $
  * @since Version 1.0
  * @access private
  * @static
  * @final
  */
 private static final function getKrumoContent()
 {
     // Determine if we can KRUMO, only if the ERR has passed;
     // If _GET instanceof A, means that the our URL parser has loaded;
     if (isset($_GET)) {
         if ($_GET instanceof A) {
             // Execute the KRUMO Framework PLUGIN;
             // Wished we could've made an object out of Krumo, but we will call it statically ...
             krumo::get();
             krumo::post();
             krumo::session();
             krumo::cookie();
             krumo::headers();
             krumo::includes();
             krumo::server();
             krumo::env();
             krumo::conf();
             krumo::extensions();
             krumo::interfaces();
             krumo::path();
             // Get its content;
             $catchedKrumoContent = self::getContentFromOutputStream();
             // Save it, and then clean the stream again;
             self::discardOutputStream(new B(TRUE));
             // Yey! It's over!
             return $catchedKrumoContent;
         }
     }
 }
示例#10
0
 /**
  * Dumps a var with PEAR::Var_Dump.
  *
  * @param mixed $var The variable to dump
  * @param string $title An optional title
  *
  * @return void
  */
 public static function varDump($var, $title = '')
 {
     echo $title ? '<h3><tt>' . $title . '</tt></h3>' : '';
     $debug_type = JComponentHelper::getParams('com_easycreator')->get('ecr_debug_type', 'easy');
     if ($debug_type == 'krumo') {
         ecrLoadHelper('krumo_0_2.krumo');
         krumo::dump($var);
         return;
     }
     include_once 'Var_Dump.php';
     if (class_exists('Var_Dump')) {
         Var_Dump::displayInit(array('display_mode' => 'HTML4_Table'), array('show_caption' => FALSE, 'bordercolor' => '#ccc', 'bordersize' => '2', 'captioncolor' => 'black', 'cellpadding' => '8', 'cellspacing' => '5', 'color1' => '#000', 'color2' => '#000', 'before_num_key' => '<span style="color: #fff; font-weight: bold;">', 'after_num_key' => '</span>', 'before_str_key' => '<span style="color: #5450cc; font-weight: bold;">', 'after_str_key' => '</span>', 'before_value' => '<span style="color: #5450cc;">', 'after_value' => '</span>'));
         Var_Dump::display($var);
     } else {
         echo '<pre>' . print_r($var, true) . '</pre>';
     }
 }
示例#11
0
    krumo($_GET);

    echo '$_POST';
    krumo($_POST); 

    // print all the included(or required) files 
    krumo::includes();
 
    // print all the included functions 
    krumo::functions();
 
    // print all the declared classes 
    krumo::classes();
 
    // print all the defined constants 
    krumo::defines();     
}

// shopping_cart
if (isset($_SESSION['new_products_id_in_cart'])) {
    unset($_SESSION['new_products_id_in_cart']);
}
if (isset($_SESSION['error_cart_msg'])) {
    unset($_SESSION['error_cart_msg']);
}
  
// close session (store variables)
oos_session_close();


if (OOS_LOG_SQL == '1') {
示例#12
0
 /**
  * A more ajax and user friendly way to var_dump.
  * Use instead of pr()
  *
  * @param mixed $var
  * @param bool $useFireCakeOutsideViews
  */
 static function krumo($var, $options = array())
 {
     $options = array('fireCake' => true, 'debug' => true);
     if ($options['debug'] && !Configure::read()) {
         return;
     }
     if ($options['fireCake'] && empty(Sl::getInstance()->view) && class_exists('FireCake')) {
         return FireCake::fb($var);
     }
     // force Pheme to keep the whitespace and line breaks
     echo "<!--{!preserveWhitespace}-->";
     App::import('vendor', 'krumo', array('file' => 'krumo/class.krumo.php'));
     return krumo::dump($var);
 }
示例#13
0
 /**
  * Render a dump for a string value
  *
  * @param mixed $data
  * @param string $name
  * @access private
  * @static
  */
 private static function _string($data, $name)
 {
     $collapsed = Krumo::_isCollapsed(self::$_level, 1);
     if ($collapsed) {
         $collapse_style = 'style="display: none;"';
     } else {
         $collapse_style = '';
     }
     // extra
     $_ = $data;
     // Get the truncate length from the config, or default to 100
     $truncate_length = Krumo::_config('display', 'truncate_length', 100);
     $display_cr = Krumo::_config('display', 'carriage_returns', true);
     if (strlen($data) > $truncate_length) {
         $_ = substr($data, 0, $truncate_length - 1);
         $_extra = true;
     } else {
         $_extra = false;
     }
     $icon = '';
     // Check to see if the line has any carriage returns
     if (preg_match("/\n|\r/", $data)) {
         $slash_n = substr_count($data, "\n");
         $slash_r = substr_count($data, "\r");
         $title .= "Note: String contains ";
         if ($slash_n) {
             $title .= "{$slash_n} " . krumo::plural($slash_n, "new line");
         }
         if ($slash_n && $slash_r) {
             $title .= " and ";
         }
         if ($slash_r) {
             $title .= "{$slash_r} " . krumo::plural($slash_r, "carriage return");
         }
         $icon = Krumo::get_icon("information", $title);
         // We flag this as extra so the dropdown can show the correctly formatted version
         $_extra = true;
     }
     $_ = htmlentities($_);
     // Convert all the \r or \n to visible paragraph markers
     if ($display_cr) {
         $_ = preg_replace("/(\\r\\n|\\n|\\r)/", "<strong class=\"krumo-carrage-return\"> &para; </strong>", $_);
     } else {
         $_ = nl2br($_);
     }
     $expand_class = '';
     if ($_extra) {
         $expand_class = 'krumo-expand';
     }
     print "<li class=\"krumo-child\">";
     print "<div class=\"krumo-element {$expand_class}\" ";
     if ($_extra) {
         print " onClick=\"krumo.toggle(this);\" ";
     }
     print "onMouseOver=\"krumo.over(this);\" onMouseOut=\"krumo.out(this);\">\n";
     print "<a class=\"krumo-name\">{$name}</a> ";
     print "<em class=\"krumo-type\">String(<strong class=\"krumo-string-length\">" . strlen($data) . "</strong>)</em> {$icon}";
     print Krumo::get_separator() . " <strong class=\"krumo-string\">" . $_;
     // This has to go AFTER the htmlspecialchars
     if (strlen($data) > $truncate_length) {
         print "&hellip;";
     }
     print "</strong>";
     $ut = Krumo::is_datetime($name, $data);
     if ($ut) {
         print " ~ <strong class=\"krumo-datetime\">{$ut}</strong>";
     }
     // callback
     if (is_callable($data)) {
         print "<span class=\"krumo-callback\"> | ";
         print "(<em class=\"krumo-type\">Callback</em>) <strong class=\"krumo-string\">" . htmlSpecialChars($_) . "()</strong></span>";
     }
     print "</div>";
     if ($_extra) {
         $data = htmlentities($data);
         $data = nl2br($data);
         print "<div class=\"krumo-nest\" {$collapse_style}>";
         print "<ul class=\"krumo-node\">";
         print "<li class=\"krumo-child\"> <div class=\"krumo-preview\">" . $data . "</div></li>";
         print "</ul></div>";
     }
     print "</li>";
 }