public function _render()
 {
     if ($this->viewname) {
         if ($this->viewname === 'empty') {
             return '';
         }
         $viewfile = $this->viewname;
     } else {
         $v = get_class($this);
         $v = preg_replace('/^controller_/', '', $v);
         $viewfile = "{$v}/index.tpl";
     }
     if (!file_exists($this->view->template_dir . "/" . $viewfile)) {
         throw new HTTPNotFound("view \"" . $viewfile . "\" not found");
     }
     if ($this->autoRender) {
         $content_type = $this->content_type;
         if (preg_match('@^text/@', $content_type) && !preg_match('/charset=/i', $content_type)) {
             $content_type .= '; charset=UTF-8';
         }
         header("Content-type: " . $content_type);
         if (empty($_SERVER['buffer_rendering'])) {
             header("X-DB-Stats: " . lib::dbstats());
             header("X-Runtime: " . lib::runtime());
             $this->view->display($viewfile);
         } else {
             ob_start();
             $this->view->display($viewfile);
             header("X-DB-Stats: " . lib::dbstats());
             header("X-Runtime: " . lib::runtime());
             ob_end_flush();
         }
     } else {
         return $this->view->fetch($viewfile);
     }
 }
Exemplo n.º 2
0
 public static function debugbox()
 {
     if (!lib::client_is_internal_host()) {
         return '';
     }
     if (lib::$debugboxshown) {
         return '';
     }
     $box = "<div id='debugbox' style='clear: both; margin-top: 8em; margin-bottom: 2em; padding: 4em 0.5em 0px 0.5em;'>";
     $box .= "<table width='100%' border='1' rules='all' cellpadding='4'>\n";
     $_SERVER['runtime'] = lib::runtime();
     $box .= lib::trow('execution time', $_SERVER['runtime']);
     $dbstats = lib::dbstats();
     $box .= lib::trow('database', $dbstats);
     if (isset($_SESSION)) {
         ob_start();
         print_r($_SESSION);
         $msg = ob_get_contents();
         ob_end_clean();
         $msg = preg_replace('/(^Array\\n\\(|\\n\\)$)/', '', $msg);
         $box .= lib::trow('session', "<pre style='margin: 0px; padding: 0px;'>{$msg}</pre>");
     }
     global $__RECMSG;
     if ($__RECMSG) {
         $msg = '<dl style="padding-left: 2em; margin-left: -20px;">';
         foreach ($__RECMSG as $k) {
             $msg .= $k;
         }
         $msg .= '</dl>';
         $box .= lib::trow('messages', $msg);
     } else {
         $box .= lib::trow('messages', "(none)");
     }
     $box .= '</table></div>';
     lib::$debugboxshown = true;
     return $box;
 }