Ejemplo n.º 1
0
Archivo: Subs.php Proyecto: bbon/mjncms
function obExit($header = null, $do_footer = null, $from_index = false)
{
    global $context, $settings, $modSettings, $txt;
    static $header_done = false, $footer_done = false;
    // Clear out the stat cache.
    trackStats();
    $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) {
        // Start up the session URL fixer.
        ob_start('ob_sessrewrite');
        // Just in case we have anything bad already in there...
        if ((isset($_REQUEST['debug']) || isset($_REQUEST['xml']) || WIRELESS && WIRELESS_PROTOCOL == 'wap') && in_array($txt['lang_locale'], array('UTF-8', 'ISO-8859-1'))) {
            ob_start('validate_unicode__recursive');
        }
        if (!empty($settings['output_buffers']) && is_string($settings['output_buffers'])) {
            $buffers = explode(',', $settings['output_buffers']);
        } elseif (!empty($settings['output_buffers'])) {
            $buffers = $settings['output_buffers'];
        } else {
            $buffers = array();
        }
        if (isset($modSettings['integrate_buffer'])) {
            $buffers = array_merge(explode(',', $modSettings['integrate_buffer']), $buffers);
        }
        if (!empty($buffers)) {
            foreach ($buffers as $buffer_function) {
                if (function_exists(trim($buffer_function))) {
                    ob_start(trim($buffer_function));
                }
            }
        }
        // Display the screen in the logical order.
        template_header();
        $header_done = true;
    }
    if ($do_footer) {
        if (WIRELESS && !isset($context['sub_template'])) {
            fatal_lang_error('wireless_error_notyet', false);
        }
        // Just show the footer, then.
        loadSubTemplate(isset($context['sub_template']) ? $context['sub_template'] : 'main');
        // Just so we don't get caught in an endless loop of errors from the footer...
        if (!$footer_done) {
            $footer_done = true;
            template_footer();
            // (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) {
        $_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.
    if (isset($modSettings['integrate_exit'], $context['template_layers']) && in_array('main', $context['template_layers']) && function_exists($modSettings['integrate_exit'])) {
        call_user_func($modSettings['integrate_exit'], $do_footer && !WIRELESS);
    }
    // Don't exit if we're coming from index.php; that will pass through normally.
    if (!$from_index || WIRELESS) {
        exit;
    }
}
Ejemplo n.º 2
0
function obExit($header = null, $do_footer = null, $from_index = false, $from_fatal_error = false)
{
    global $context, $settings, $modSettings, $txt, $smcFunc;
    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'] = $smcFunc['htmlspecialchars'](un_htmlspecialchars($context['page_title']));
        }
        // Start up the session URL fixer.
        ob_start('ob_sessrewrite');
        if (!empty($settings['output_buffers']) && is_string($settings['output_buffers'])) {
            $buffers = explode(',', $settings['output_buffers']);
        } elseif (!empty($settings['output_buffers'])) {
            $buffers = $settings['output_buffers'];
        } else {
            $buffers = array();
        }
        if (isset($modSettings['integrate_buffer'])) {
            $buffers = array_merge(explode(',', $modSettings['integrate_buffer']), $buffers);
        }
        if (!empty($buffers)) {
            foreach ($buffers as $function) {
                $function = trim($function);
                $call = strpos($function, '::') !== false ? explode('::', $function) : $function;
                // Is it valid?
                if (is_callable($call)) {
                    ob_start($call);
                }
            }
        }
        // Display the screen in the logical order.
        template_header();
        $header_done = true;
    }
    if ($do_footer) {
        if (WIRELESS && !isset($context['sub_template'])) {
            fatal_lang_error('wireless_error_notyet', false);
        }
        // Just show the footer, then.
        loadSubTemplate(isset($context['sub_template']) ? $context['sub_template'] : 'main');
        // Anything special to put out?
        if (!empty($context['insert_after_template']) && !isset($_REQUEST['xml'])) {
            echo $context['insert_after_template'];
        }
        // Just so we don't get caught in an endless loop of errors from the footer...
        if (!$footer_done) {
            $footer_done = true;
            template_footer();
            // (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'];
    if (!empty($settings['strict_doctype'])) {
        // The theme author wants to use the STRICT doctype (only God knows why).
        $temp = ob_get_contents();
        if (function_exists('ob_clean')) {
            ob_clean();
        } else {
            ob_end_clean();
            ob_start('ob_sessrewrite');
        }
        echo strtr($temp, array('var smf_iso_case_folding' => 'var target_blank = \'_blank\'; var smf_iso_case_folding', 'target="_blank"' => 'onclick="this.target=target_blank"'));
    }
    // Hand off the output to the portal, etc. we're integrated with.
    call_integration_hook('integrate_exit', array($do_footer && !WIRELESS));
    // Don't exit if we're coming from index.php; that will pass through normally.
    if (!$from_index || WIRELESS) {
        exit;
    }
}
Ejemplo n.º 3
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;
     }
 }