Exemplo n.º 1
0
 public static function display()
 {
     if (!self::isActive()) {
         return false;
     }
     $data_time = time();
     $debugger_id = !empty(self::$debugger_cookie) ? self::$debugger_cookie : substr(Session::getId(), 0, 8);
     $ch_p = array_values(self::$checkpoints);
     $included_templates = array();
     $depth = array();
     $d = 0;
     foreach (Registry::get('view')->template_objects as $k => $v) {
         if (count(explode('#', $k)) == 1) {
             continue;
         }
         list(, $tpl) = explode('#', $k);
         if (!empty($v->parent)) {
             if (property_exists($v->parent, 'template_resource')) {
                 if (empty($depth[$v->parent->template_resource])) {
                     $depth[$v->parent->template_resource] = ++$d;
                 }
                 $included_templates[] = array('filename' => $tpl, 'depth' => $depth[$v->parent->template_resource]);
             }
         }
     }
     $assigned_vars = Registry::get('view')->tpl_vars;
     ksort($assigned_vars);
     $exclude_vars = array('_REQUEST', 'config', 'settings', 'runtime', 'demo_password', 'demo_username', 'empty', 'ldelim', 'rdelim');
     foreach ($assigned_vars as $name => $value_obj) {
         if (in_array($name, $exclude_vars)) {
             unset($assigned_vars[$name]);
         } else {
             $assigned_vars[$name] = $value_obj->value;
         }
     }
     self::$totals['time_page'] = $ch_p[count($ch_p) - 1]['time'] - $ch_p[0]['time'];
     self::$totals['memory_page'] = ($ch_p[count($ch_p) - 1]['memory'] - $ch_p[0]['memory']) / 1024;
     self::$totals['count_queries'] = count(self::$queries);
     self::$totals['count_tpls'] = count($included_templates);
     $runtime = fn_foreach_recursive(Registry::get('runtime'), '.');
     foreach ($runtime as $key => $value) {
         if (in_array(gettype($value), array('object', 'resource'))) {
             $runtime[$key] = gettype($value);
         }
     }
     $data = array('request' => array('request' => $_REQUEST, 'server' => $_SERVER, 'cookie' => $_COOKIE), 'config' => array('runtime' => $runtime), 'sql' => array('totals' => array('count' => self::$totals['count_queries'], 'rcount' => 0, 'time' => self::$totals['time_queries']), 'queries' => self::$queries), 'backtraces' => self::$backtraces, 'logging' => self::$checkpoints, 'templates' => array('tpls' => $included_templates, 'vars' => $assigned_vars), 'totals' => self::$totals);
     $datas = Registry::get('debugger.data');
     $datas = is_array($datas) ? $datas : array();
     foreach (array_keys($datas) as $id) {
         foreach (array_keys($datas[$id]) as $time) {
             if ($time < time() - self::EXPIRE_DEBUGGER) {
                 unset($datas[$id][$time]);
             }
         }
         if (empty($datas[$id])) {
             unset($datas[$id]);
         }
     }
     $datas[$debugger_id][$data_time] = $data;
     Registry::set('debugger.data', $datas);
     Registry::get('view')->assign('debugger_id', $debugger_id);
     Registry::get('view')->assign('debugger_hash', $data_time);
     Registry::get('view')->assign('totals', self::$totals);
     Registry::get('view')->display('views/debugger/debugger.tpl');
     return true;
 }
Exemplo n.º 2
0
/**
 * Convert multi-level array to single-level array
 *
 * @param array $item Multi-level array
 * @param string $delimiter Delimiter name
 * @return array Single-level array
 */
function fn_foreach_recursive($item, $delimiter, $name = '', $arr = array())
{
    if (is_array($item)) {
        foreach ($item as $key => $value) {
            $new_key = $name === '' ? $key : $name . $delimiter . $key;
            $arr = fn_foreach_recursive($value, $delimiter, $new_key, $arr);
        }
    } else {
        $arr[$name] = $item;
    }
    return $arr;
}
    function content_55dc83c80a39d3_28756302($_smarty_tpl)
    {
        ?>
<div class="deb-tab-content" id="DebugToolbarTabConfigContent">
    <div class="deb-sub-tab">
        <ul>
            <li class="active"><a data-sub-tab-id="DebugToolbarSubTabConfigConfig">Config</a></li>
            <li><a data-sub-tab-id="DebugToolbarSubTabConfigSettings">Settings</a></li>
            <li><a data-sub-tab-id="DebugToolbarSubTabConfigRuntime">Runtime</a></li>
        </ul>
    </div>

    <div class="deb-sub-tab-content" id="DebugToolbarSubTabConfigConfig">
        <table class="deb-table">
            <caption>Config</caption>
            <?php 
        $_smarty_tpl->tpl_vars["value"] = new Smarty_Variable();
        $_smarty_tpl->tpl_vars["value"]->_loop = false;
        $_smarty_tpl->tpl_vars["name"] = new Smarty_Variable();
        $_from = fn_foreach_recursive($_smarty_tpl->tpl_vars['config']->value, ".");
        if (!is_array($_from) && !is_object($_from)) {
            settype($_from, 'array');
        }
        foreach ($_from as $_smarty_tpl->tpl_vars["value"]->key => $_smarty_tpl->tpl_vars["value"]->value) {
            $_smarty_tpl->tpl_vars["value"]->_loop = true;
            $_smarty_tpl->tpl_vars["name"]->value = $_smarty_tpl->tpl_vars["value"]->key;
            ?>
                <tr>
                    <td width="200px"><?php 
            echo htmlspecialchars($_smarty_tpl->tpl_vars['name']->value, ENT_QUOTES, 'UTF-8');
            ?>
</td>
                    <td>
                        <?php 
            if (gettype($_smarty_tpl->tpl_vars['value']->value) == 'boolean') {
                ?>
                            <pre><code class="php"><?php 
                if ($_smarty_tpl->tpl_vars['value']->value) {
                    ?>
true<?php 
                } else {
                    ?>
false<?php 
                }
                ?>
</code></pre>
                        <?php 
            } elseif (gettype($_smarty_tpl->tpl_vars['value']->value) == 'NULL') {
                ?>
                            <pre><code class="php">null</code></pre>
                        <?php 
            } elseif (gettype($_smarty_tpl->tpl_vars['value']->value) == 'object') {
                ?>
                            <pre><code class="php"><span class="pseudo">Object</span></code></pre>
                        <?php 
            } elseif (gettype($_smarty_tpl->tpl_vars['value']->value) == 'resource') {
                ?>
                            <pre><code class="php"><span class="pseudo">Resource</span></code></pre>
                        <?php 
            } else {
                ?>
                            <?php 
                echo htmlspecialchars(strval($_smarty_tpl->tpl_vars['value']->value), ENT_QUOTES, 'UTF-8');
                ?>

                        <?php 
            }
            ?>
                    </td>
                </tr>
            <?php 
        }
        ?>
        </table>
    </div>

    <div class="deb-sub-tab-content" id="DebugToolbarSubTabConfigSettings">
        <table class="deb-table">
            <caption>Settings</caption>
            <?php 
        $_smarty_tpl->tpl_vars["value"] = new Smarty_Variable();
        $_smarty_tpl->tpl_vars["value"]->_loop = false;
        $_smarty_tpl->tpl_vars["name"] = new Smarty_Variable();
        $_from = fn_foreach_recursive($_smarty_tpl->tpl_vars['settings']->value, ".");
        if (!is_array($_from) && !is_object($_from)) {
            settype($_from, 'array');
        }
        foreach ($_from as $_smarty_tpl->tpl_vars["value"]->key => $_smarty_tpl->tpl_vars["value"]->value) {
            $_smarty_tpl->tpl_vars["value"]->_loop = true;
            $_smarty_tpl->tpl_vars["name"]->value = $_smarty_tpl->tpl_vars["value"]->key;
            ?>
                <tr>
                    <td width="200px"><?php 
            echo htmlspecialchars($_smarty_tpl->tpl_vars['name']->value, ENT_QUOTES, 'UTF-8');
            ?>
</td>
                    <td>
                        <?php 
            if (gettype($_smarty_tpl->tpl_vars['value']->value) == 'boolean') {
                ?>
                            <pre><code class="php"><?php 
                if ($_smarty_tpl->tpl_vars['value']->value) {
                    ?>
true<?php 
                } else {
                    ?>
false<?php 
                }
                ?>
</code></pre>
                        <?php 
            } elseif (gettype($_smarty_tpl->tpl_vars['value']->value) == 'NULL') {
                ?>
                            <pre><code class="php">null</code></pre>
                        <?php 
            } elseif (gettype($_smarty_tpl->tpl_vars['value']->value) == 'object') {
                ?>
                            <pre><code class="php"><span class="pseudo">Object</span></code></pre>
                        <?php 
            } elseif (gettype($_smarty_tpl->tpl_vars['value']->value) == 'resource') {
                ?>
                            <pre><code class="php"><span class="pseudo">Resource</span></code></pre>
                        <?php 
            } else {
                ?>
                            <?php 
                echo htmlspecialchars(strval($_smarty_tpl->tpl_vars['value']->value), ENT_QUOTES, 'UTF-8');
                ?>

                        <?php 
            }
            ?>
                    </td>
                </tr>
            <?php 
        }
        ?>
        </table>
    </div>
    
    <div class="deb-sub-tab-content" id="DebugToolbarSubTabConfigRuntime">
        <table class="deb-table">
            <caption>Runtime</caption>
            <?php 
        $_smarty_tpl->tpl_vars["value"] = new Smarty_Variable();
        $_smarty_tpl->tpl_vars["value"]->_loop = false;
        $_smarty_tpl->tpl_vars["name"] = new Smarty_Variable();
        $_from = fn_foreach_recursive($_smarty_tpl->tpl_vars['data']->value['runtime'], ".");
        if (!is_array($_from) && !is_object($_from)) {
            settype($_from, 'array');
        }
        foreach ($_from as $_smarty_tpl->tpl_vars["value"]->key => $_smarty_tpl->tpl_vars["value"]->value) {
            $_smarty_tpl->tpl_vars["value"]->_loop = true;
            $_smarty_tpl->tpl_vars["name"]->value = $_smarty_tpl->tpl_vars["value"]->key;
            ?>
                <tr>
                    <td width="200px"><?php 
            echo htmlspecialchars($_smarty_tpl->tpl_vars['name']->value, ENT_QUOTES, 'UTF-8');
            ?>
</td>
                    <td>
                        <?php 
            if (gettype($_smarty_tpl->tpl_vars['value']->value) == 'boolean') {
                ?>
                            <pre><code class="php"><?php 
                if ($_smarty_tpl->tpl_vars['value']->value) {
                    ?>
true<?php 
                } else {
                    ?>
false<?php 
                }
                ?>
</code></pre>
                        <?php 
            } elseif (gettype($_smarty_tpl->tpl_vars['value']->value) == 'NULL') {
                ?>
                            <pre><code class="php">null</code></pre>
                        <?php 
            } elseif (gettype($_smarty_tpl->tpl_vars['value']->value) == 'object' || $_smarty_tpl->tpl_vars['value']->value === 'object') {
                ?>
                            <pre><code class="php"><span class="pseudo">Object</span></code></pre>
                        <?php 
            } elseif (gettype($_smarty_tpl->tpl_vars['value']->value) == 'resource' || $_smarty_tpl->tpl_vars['value']->value === 'resource') {
                ?>
                            <pre><code class="php"><span class="pseudo">Resource</span></code></pre>
                        <?php 
            } else {
                ?>
                            <?php 
                echo htmlspecialchars(strval($_smarty_tpl->tpl_vars['value']->value), ENT_QUOTES, 'UTF-8');
                ?>

                        <?php 
            }
            ?>
                    </td>
                </tr>
            <?php 
        }
        ?>
        </table>
    </div>
<!--DebugToolbarTabConfigContent--></div><?php 
    }