Пример #1
0
        // Calculate script generation time
        $time_diff = forum_microtime() - $forum_start;
        $query_time_total = $time_percent_db = 0.0;
        $saved_queries = $forum_db->get_saved_queries();
        if (count($saved_queries) > 0) {
            foreach ($saved_queries as $cur_query) {
                $query_time_total += $cur_query[1];
            }
            if ($query_time_total > 0 && $time_diff > 0) {
                $time_percent_db = $query_time_total / $time_diff * 100;
            }
        }
        echo '<p id="querytime" class="quiet">' . sprintf($lang_common['Querytime'], forum_number_format($time_diff, 3), forum_number_format(100 - $time_percent_db, 0), forum_number_format($time_percent_db, 0), forum_number_format($forum_db->get_num_queries())) . '</p>' . "\n";
    }
    if (defined('FORUM_SHOW_QUERIES')) {
        echo get_saved_queries();
    }
    ($hook = get_hook('ft_debug_end')) ? eval($hook) : null;
    $tpl_temp = forum_trim(ob_get_contents());
    $tpl_main = str_replace('<!-- forum_debug -->', $tpl_temp, $tpl_main);
    ob_end_clean();
}
// END SUBST - <!-- forum_debug -->
// START SUBST - <!-- forum_javascript -->
$forum_javascript_commonjs_urls = '
	if (typeof PUNBB === \'undefined\' || !PUNBB) {
		var PUNBB = {};
	}

	PUNBB.env = {
		base_url: "' . forum_htmlencode($base_url) . '/",
function redirect($destination_url, $message)
{
    global $forum_db, $forum_config, $lang_common, $forum_user, $base_url, $forum_loader;
    define('FORUM_PAGE', 'redirect');
    ($hook = get_hook('fn_redirect_start')) ? eval($hook) : null;
    // Prefix with base_url (unless it's there already)
    if (strpos($destination_url, 'http://') !== 0 && strpos($destination_url, 'https://') !== 0 && strpos($destination_url, '/') !== 0) {
        $destination_url = $base_url . '/' . $destination_url;
    }
    // Do a little spring cleaning
    $destination_url = preg_replace('/([\\r\\n])|(%0[ad])|(;[\\s]*data[\\s]*:)/i', '', $destination_url);
    // If the delay is 0 seconds, we might as well skip the redirect all together
    if ($forum_config['o_redirect_delay'] == '0') {
        header('Location: ' . str_replace('&amp;', '&', $destination_url));
    }
    // Send no-cache headers
    header('Expires: Thu, 21 Jul 1977 07:30:00 GMT');
    // When yours truly first set eyes on this world! :)
    header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
    header('Cache-Control: post-check=0, pre-check=0', false);
    header('Pragma: no-cache');
    // For HTTP/1.0 compability
    // Send the Content-type header in case the web server is setup to send something else
    header('Content-type: text/html; charset=utf-8');
    // Load the redirect template
    if (file_exists(FORUM_ROOT . 'style/' . $forum_user['style'] . '/redirect.tpl')) {
        $tpl_path = FORUM_ROOT . 'style/' . $forum_user['style'] . '/redirect.tpl';
    } else {
        $tpl_path = FORUM_ROOT . 'include/template/redirect.tpl';
    }
    ($hook = get_hook('fn_redirect_pre_template_loaded')) ? eval($hook) : null;
    $tpl_redir = forum_trim(file_get_contents($tpl_path));
    ($hook = get_hook('fn_redirect_template_loaded')) ? eval($hook) : null;
    // START SUBST - <!-- forum_local -->
    $tpl_redir = str_replace('<!-- forum_local -->', 'xml:lang="' . $lang_common['lang_identifier'] . '" lang="' . $lang_common['lang_identifier'] . '" dir="' . $lang_common['lang_direction'] . '"', $tpl_redir);
    // END SUBST - <!-- forum_local -->
    // START SUBST - <!-- forum_head -->
    $forum_head['refresh'] = '<meta http-equiv="refresh" content="' . $forum_config['o_redirect_delay'] . ';URL=' . str_replace(array('<', '>', '"'), array('&lt;', '&gt;', '&quot;'), $destination_url) . '" />';
    $forum_head['title'] = '<title>' . $lang_common['Redirecting'] . $lang_common['Title separator'] . forum_htmlencode($forum_config['o_board_title']) . '</title>';
    ob_start();
    // Include stylesheets
    require FORUM_ROOT . 'style/' . $forum_user['style'] . '/' . $forum_user['style'] . '.php';
    $head_temp = forum_trim(ob_get_contents());
    $num_temp = 0;
    foreach (explode("\n", $head_temp) as $style_temp) {
        $forum_head['style' . $num_temp++] = $style_temp;
    }
    ob_end_clean();
    ($hook = get_hook('fn_redirect_head')) ? eval($hook) : null;
    $tmp_head = implode("\n", $forum_head) . $forum_loader->render_css();
    $tpl_redir = str_replace('<!-- forum_head -->', $tmp_head, $tpl_redir);
    unset($forum_head, $tmp_head);
    // END SUBST - <!-- forum_head -->
    // START SUBST - <!-- forum_redir_main -->
    ob_start();
    ?>
<div id="brd-main" class="main basic">

	<div class="main-head">
		<h1 class="hn"><span><?php 
    echo $message . $lang_common['Redirecting'];
    ?>
</span></h1>
	</div>

	<div class="main-content main-message">
		<p><?php 
    printf($lang_common['Forwarding info'], $forum_config['o_redirect_delay'], intval($forum_config['o_redirect_delay']) == 1 ? $lang_common['second'] : $lang_common['seconds']);
    ?>
<span> <a href="<?php 
    echo $destination_url;
    ?>
"><?php 
    echo $lang_common['Click redirect'];
    ?>
</a></span></p>
	</div>

</div>
<?php 
    $tpl_temp = "\t" . forum_trim(ob_get_contents());
    $tpl_redir = str_replace('<!-- forum_redir_main -->', $tpl_temp, $tpl_redir);
    ob_end_clean();
    // END SUBST - <!-- forum_redir_main -->
    // START SUBST - <!-- forum_debug -->
    if (defined('FORUM_SHOW_QUERIES')) {
        $tpl_redir = str_replace('<!-- forum_debug -->', get_saved_queries(), $tpl_redir);
    }
    // End the transaction
    $forum_db->end_transaction();
    // END SUBST - <!-- forum_debug -->
    // START SUBST - <!-- forum_include "*" -->
    while (preg_match('#<!-- ?forum_include "([^/\\\\]*?)" ?-->#', $tpl_redir, $cur_include)) {
        if (!file_exists(FORUM_ROOT . 'include/user/' . $cur_include[1])) {
            error('Unable to process user include &lt;!-- forum_include "' . forum_htmlencode($cur_include[1]) . '" --&gt; from template redirect.tpl.<br />There is no such file in folder /include/user/.');
        }
        ob_start();
        include FORUM_ROOT . 'include/user/' . $cur_include[1];
        $tpl_temp = ob_get_contents();
        $tpl_redir = str_replace($cur_include[0], $tpl_temp, $tpl_redir);
        ob_end_clean();
    }
    // END SUBST - <!-- forum_include "*" -->
    // Close the db connection (and free up any result data)
    $forum_db->close();
    exit($tpl_redir);
}