コード例 #1
0
ファイル: Site.php プロジェクト: TristanMouchet/Clap
 public function close($msg = '')
 {
     global $_SITE;
     $this->closing = true;
     if ($msg != '') {
         echo $msg;
     }
     if (Clap::isClassLoaded('Clap_Database')) {
         $exec = Clap_Database::$exec;
         $time = Clap_Database::$time;
         $SqlTime = str_pad(round(array_sum($time), 3), 5, '0') . 's';
         foreach ($time as &$t) {
             if ($t != 0) {
                 $t = str_pad(round($t, 4), 6, '0');
             }
         }
         $SQLDatas = $exec['connect'] . ' connexion' . ($exec['connect'] > 1 ? 's' : '') . ' (' . $time['connect'] . 's), ' . $exec['parse'] . '/' . $exec['request'] . ' quer' . ($exec['request'] > 1 ? 'ies' : 'y') . ' (formating : ' . $time['parse'] . 's, requesting : ' . $time['request'] . 's)';
     } else {
         $SQLDatas = 'No database connexion has been loaded on this page';
         $SqlTime = '0.000s';
     }
     if (Clap::isClassLoaded('Clap_Template')) {
         $exec = Clap_Template::$exec;
         $time = Clap_Template::$time == 0 ? 0 : str_pad(round(Clap_Template::$time, 3), 5, '0');
         $TwigTime = $time . 's';
     } else {
         $TwigTime = '0.000s';
     }
     $TotalTime = str_pad(round(microtime(true) - $_SITE['EXEC-TIME'], 3), 5, '0');
     $ClapTime = str_pad(round($TotalTime - $TwigTime - $SqlTime, 3), 5, '0');
     // Write debug datas at the end of HTML source :
     if (!$this->redirecting && !$this->ajax && pathinfo($this->page, PATHINFO_EXTENSION) == 'php') {
         echo "\n\n<!-- \n\n" . " URL : \"" . $this->getUrl() . "\",\n\n" . " BaseUrl : \"" . $this->getSiteUrl() . "\", \n\n" . " Route : \"" . $this->getRoutePage() . "\", \n\n" . ($this->getRoutePage() != $this->getPage() ? " Redirection : \"" . $this->getPage() . "\", \n\n" : '') . " Language : \"" . $this->Lang->getCode() . "\", \n\n" . " Cache : " . ($this->Cache->isActive() ? 'Enabled' : 'Disabled') . ", \n\n" . " Config : \"" . $this->Config->getConfigFile() . "\", \n\n" . " SQL : " . $SQLDatas . ", \n\n" . " Execution : Twig (" . $TwigTime . "), SQL (" . $SqlTime . "), Framework (" . $ClapTime . "s) >> Total (" . $TotalTime . "s) \n\n" . "-->\n";
     }
     // On redirect, some services have to close early :
     if ($this->redirecting) {
         Clap::getService('Session')->close();
         $this->Cache->save();
         if ($this->redirectCode != false) {
             header('Location: ' . $this->redirectUrl, $this->redirectCode);
         } else {
             header('Location: ' . $this->redirectUrl);
         }
     }
     // Send Contents & Headers to browser :
     if (!headers_sent() && ob_get_level() > 0) {
         while (ob_get_level() > 1) {
             ob_end_flush();
         }
         $content = ob_get_contents();
         ob_clean();
         echo $content;
         header('Content-length: ' . ob_get_length());
         ob_flush();
         flush();
         ob_end_flush();
     }
     exit;
     // Classes are destructed after the content have been flushed.
 }