Beispiel #1
0
function debug_var_dump($var, $maxlevel = 2, $level = 0)
{
    debug_printr(debug_var_dump_helper($var, $maxlevel, $level));
}
 /**
  * Create the code for the debugbar and returns it..
  *
  * @return string
  */
 function getDebugCode()
 {
     global $PIVOTX, $version, $codename, $timetaken;
     // The debugbar will not work on IE6 or IE7.. Check for those browsers and return a notice.
     if (preg_match('|MSIE ([0-9].[0-9]{1,2})|', $_SERVER['HTTP_USER_AGENT'], $browserversion)) {
         if ($browserversion[1] < 8) {
             return "<!-- The PivotX debug bar is not supported on IE6 or IE7. -->";
         }
     }
     $debugcode = "";
     $debugversion = strip_tags($version . ($codename != "" ? ": " . $codename : ""));
     list($dummy, $host) = explode("://", $PIVOTX['paths']['canonical_host']);
     $path = $PIVOTX['paths']['pivotx_url'];
     // Build the text for 'Modifiers'
     $modifiers = array();
     $modifiers[] = "<strong>Modifiers:</strong>";
     // Note: 'Modifiers' left untranslated. I don't think we should translate this.
     foreach ($this->modifier as $key => $value) {
         $modifiers[] = sprintf('%-8s => %s', $key, getDefault($value, "<em>(empty)</em>"));
     }
     // Add the templates to template_log, but skip the first one (since it's always 'maintemplate')
     $smarty_debug_info = array_slice($PIVOTX['template']->_smarty_debug_info, 1);
     foreach ($smarty_debug_info as $template) {
         if (strpos($template['filename'], "db:") === false) {
             $GLOBALS['template_log'][] = "- " . $template['filename'];
         }
     }
     $modifiers[] = "\n<strong>" . __("Templates") . ":</strong>";
     $modifiers[] = "Main: " . $this->maintemplate;
     if (!empty($GLOBALS['template_log'])) {
         $modifiers[] = implode("\n", $GLOBALS['template_log']);
     }
     $str = __("Note: '%s' is enabled, which affects the performance of this site.");
     $str = preg_replace("/^([^:]*)/i", "<strong>\$1</strong>", $str);
     if ($PIVOTX['config']->get('smarty_force_compile')) {
         $modifiers['notes'] .= "\n" . wordwrap(sprintf($str, __('Force compile templates')), 80);
     }
     if ($PIVOTX['config']->get('no_cached_include')) {
         $modifiers['notes'] .= "\n" . wordwrap(sprintf($str, __('Disallow cached includes')), 80);
     }
     $str = __("Note: '%s' is enabled.");
     $str = preg_replace("/^([^:]*)/i", "<strong>\$1</strong>", $str);
     if ($PIVOTX['config']->get('minify_frontend')) {
         $modifiers['notes'] .= "\n" . wordwrap(sprintf($str, __('Minify Frontend')), 80);
     }
     if ($PIVOTX['config']->get('smarty_cache')) {
         $modifiers['notes'] .= "\n" . wordwrap(sprintf($str, __('Use output caching')), 80);
     }
     // Add the paths to the modifiers tab.
     $modifiers['paths'] = "\n<strong>" . __("Paths") . ":</strong> (\$PIVOTX['paths']['<em>pathname</em>'])";
     foreach ($PIVOTX['paths'] as $key => $value) {
         $modifiers['paths'] .= sprintf("\n%-16s => %s", $key, $value);
     }
     // Set the correct classes, if we want the bar at the bottom..
     if ($PIVOTX['config']->get("debug_bottom")) {
         $boxclass = " pxdb-box-bottom";
         $barclass = "class='pxdb-bar-bottom'";
     } else {
         $boxclass = "";
         $barclass = "";
     }
     // Build the text for the server tab.
     $server_log = array();
     $server_log = $this->getDebugCodeServerHelper('$_GET', $_GET, $server_log, 13);
     $server_log = $this->getDebugCodeServerHelper('$_POST', $_POST, $server_log, 13);
     $server_log = $this->getDebugCodeServerHelper('$_REQUEST', $_REQUEST, $server_log, 13);
     $server_log = $this->getDebugCodeServerHelper('$_FILES', $_FILES, $server_log, 13);
     $server_log = $this->getDebugCodeServerHelper('$_SERVER', $_SERVER, $server_log, 21);
     $server_log = $this->getDebugCodeServerHelper('$_COOKIE', $_COOKIE, $server_log, 13);
     $server_log = $this->getDebugCodeServerHelper('$_SESSION', $_SESSION, $server_log, 13);
     $debugcode .= sprintf("<script type=\"text/javascript\">!window.jQuery && document.write('<script src=\"%s\"><\\/script>')</script>", $PIVOTX['paths']['jquery_url']);
     $debugcode .= sprintf("<script type=\"text/javascript\" src=\"%stemplates_internal/assets/debugbar.js\"></script>", $path);
     $debugcode .= sprintf("<link rel=\"stylesheet\" type=\"text/css\" href=\"%stemplates_internal/assets/debugbar.css\" />", $path);
     $debugcode .= sprintf("        <div id=\"pxdb-bar\" %s>\n            <div id=\"pxdb-bar-logo\"><img src=\"%stemplates_internal/assets/m_pivotx.png\" width=\"90\" height=\"18\" alt=\"PivotX\" /></div>\n            <div id=\"pxdb-bar-version\">v %s</div>\n            <div class=\"pxdb-bar-section\" id=\"pxdb-bar-timetaken\">%s sec.</div>\n            <div class=\"pxdb-bar-divider\">|</div>\n            <div class=\"pxdb-bar-section\" id=\"pxdb-bar-modifiers\"><a href=\"#\">Modifiers</a></div>\n            <div class=\"pxdb-bar-divider\">|</div>\n            <div class=\"pxdb-bar-section\" id=\"pxdb-bar-log\"><a href=\"#\">Debug log</a></div>\n            <div class=\"pxdb-bar-divider\">|</div>", $barclass, $path, $debugversion, timeTaken('int'));
     if ($PIVOTX['db']->db_type == "sql") {
         $debugcode .= sprintf("        <div class=\"pxdb-bar-section\" id=\"pxdb-bar-queries\"><a href=\"#\">%s Queries</a> (%s sec.)</div>\n                <div class=\"pxdb-bar-divider\">|</div>", $timetaken['query_count'], $timetaken['sql']);
     }
     $debugcode .= sprintf("        <div class=\"pxdb-bar-section\" id=\"pxdb-bar-server\"><a href=\"#\">%s</a></div>\n                <div class=\"pxdb-bar-divider\">|</div>\n                <div class=\"pxdb-bar-section\" id=\"pxdb-bar-open\">&nbsp;</div>\n                <div class=\"pxdb-bar-section\" id=\"pxdb-bar-close\">&nbsp;</div>\n            </div>", $host);
     $debugcode .= sprintf("<div id=\"pxdb-box-modifiers\" class=\"pxdb-box%s\">\n            <pre>\n%s\n            </pre>\n            </div>", $boxclass, implode("\n", $modifiers));
     // If $query_log is filled, output the executed queries..
     if (count($GLOBALS['query_log']) > 0) {
         sort($GLOBALS['query_log']);
         $debugcode .= sprintf("<div id=\"pxdb-box-queries\" class=\"pxdb-box%s\">\n                <pre>\n%s\n                </pre>\n                </div>", $boxclass, implode("\n", $GLOBALS['query_log']));
         // perhaps also log to file
         if ($PIVOTX['config']->get('log_queries') && $PIVOTX['config']->get('debug_logfile')) {
             debug_printr($GLOBALS['query_log']);
         }
     }
     if (empty($GLOBALS['debug_log'])) {
         $GLOBALS['debug_log'] = "<div class='timetaken'>" . __("No debug output.") . "</div>";
     }
     $GLOBALS['debug_log'] .= sprintf("\n\n <a href=\"%s#bottom\" onclick=\"void(debugwin = window.open('%s#bottom', 'debugwin', 'status=yes, scrollbars=yes, resizable=yes, width=700, height=300')); return false;\">%s</a>", $PIVOTX['paths']['pivotx_url'] . "modules/module_debug.php", $PIVOTX['paths']['pivotx_url'] . "modules/module_debug.php", __("View debug logs"));
     // If $debug_log is filled, output it here..
     $debugcode .= sprintf("<div id=\"pxdb-box-log\" class=\"pxdb-box%s\">\n%s\n            </div>", $boxclass, nl2br($GLOBALS['debug_log']));
     // If $server_log is filled, output it here..
     $debugcode .= sprintf("<div id=\"pxdb-box-server\" class=\"pxdb-box%s\">\n                <pre>\n%s\n                </pre>\n                </div>", $boxclass, implode("\n", $server_log));
     /*
     
                 if ($PIVOTX['config']->get('debug_cachestats')) {
                     debug_printr($PIVOTX['cache']->stats());
                 }
     */
     return $debugcode;
 }