Example #1
0
 public static function obExit($header = null, $do_footer = null, $from_index = false, $from_fatal_error = false)
 {
     global $context, $modSettings;
     static $header_done = false, $footer_done = false, $level = 0, $has_fatal_error = false;
     // Attempt to prevent a recursive loop.
     ++$level;
     if ($level > 1 && !$from_fatal_error && !$has_fatal_error) {
         exit;
     }
     if ($from_fatal_error) {
         $has_fatal_error = true;
     }
     // Clear out the stat cache.
     trackStats();
     // If we have mail to send, send it.
     if (!empty($context['flush_mail'])) {
         AddMailQueue(true);
     }
     $do_header = $header === null ? !$header_done : $header;
     if ($do_footer === null) {
         $do_footer = $do_header;
     }
     // Has the template/header been done yet?
     if ($do_header) {
         // Was the page title set last minute? Also update the HTML safe one.
         if (!empty($context['page_title']) && empty($context['page_title_html_safe'])) {
             $context['page_title_html_safe'] = $context['forum_name_html_safe'] . ' - ' . commonAPI::htmlspecialchars(un_htmlspecialchars($context['page_title']));
         }
         // Start up the session URL fixer.
         ob_start('ob_sessrewrite');
         HookAPI::integrateOB();
         //if(!empty($modSettings['simplesef_enable']))
         //	ob_start('SimpleSEF::ob_simplesef');
         // Display the screen in the logical order.
         self::template_header();
         $header_done = true;
     }
     if ($do_footer) {
         if (WIRELESS && !isset($context['sub_template'])) {
             fatal_lang_error('wireless_error_notyet', false);
         }
         self::Display();
         // Just so we don't get caught in an endless loop of errors from the footer...
         if (!$footer_done) {
             $footer_done = true;
             // (since this is just debugging... it's okay that it's after </html>.)
             if (!isset($_REQUEST['xml'])) {
                 db_debug_junk();
             }
         }
     }
     // Remember this URL in case someone doesn't like sending HTTP_REFERER.
     if (strpos($_SERVER['REQUEST_URL'], 'action=dlattach') === false && strpos($_SERVER['REQUEST_URL'], 'action=viewsmfile') === false) {
         $_SESSION['old_url'] = $_SERVER['REQUEST_URL'];
     }
     // For session check verfication.... don't switch browsers...
     $_SESSION['USER_AGENT'] = $_SERVER['HTTP_USER_AGENT'];
     // Hand off the output to the portal, etc. we're integrated with.
     HookAPI::callHook('integrate_exit', array($do_footer));
     if (!empty($modSettings['simplesef_enable'])) {
         SimpleSEF::fixXMLOutput($do_footer);
     }
     // Don't exit if we're coming from index.php; that will pass through normally.
     if (!$from_index) {
         exit;
     }
 }