<?php /*********************************************************************** Copyright (C) 2006-2010 Anders Persson (anders_persson@home.se) OpenLD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. OpenLD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. ************************************************************************/ $queries = defined("OPENLD_SHOW_QUERIES") ? display_saved_queries(2) : ''; $page_generation = defined("OPENLD_DEBUG") ? PAGE_GENERATED_IN . strval(round(microtime_float() - $time_start, 2)) . SECONDS : ''; require OPENLD_ROOT . 'themes/' . $settings['template_path'] . 'header.php'; require OPENLD_ROOT . 'themes/' . $settings['template_path'] . $page; require OPENLD_ROOT . 'themes/' . $settings['template_path'] . 'footer.php';
function redirect($destination_url, $message) { global $db, $pun_config, $lang_common, $pun_user; // Prefix with base_url (unless there's already a valid URI) if (strpos($destination_url, 'http://') !== 0 && strpos($destination_url, 'https://') !== 0 && strpos($destination_url, '/') !== 0) { $destination_url = get_base_url(true) . '/' . $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 ($pun_config['o_redirect_delay'] == '0') { $db->end_transaction(); $db->close(); header('Location: ' . str_replace('&', '&', $destination_url)); exit; } // 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 compatibility // Send the Content-type header in case the web server is setup to send something else header('Content-type: text/html; charset=utf-8'); if (file_exists(PUN_ROOT . 'style/' . $pun_user['style'] . '/redirect.tpl')) { $tpl_file = PUN_ROOT . 'style/' . $pun_user['style'] . '/redirect.tpl'; $tpl_inc_dir = PUN_ROOT . 'style/' . $pun_user['style'] . '/'; } else { $tpl_file = PUN_ROOT . 'include/template/redirect.tpl'; $tpl_inc_dir = PUN_ROOT . 'include/user/'; } $tpl_redir = file_get_contents($tpl_file); // START SUBST - <pun_include "*"> preg_match_all('%<pun_include "([^/\\\\]*?)\\.(php[45]?|inc|html?|txt)">%i', $tpl_redir, $pun_includes, PREG_SET_ORDER); foreach ($pun_includes as $cur_include) { ob_start(); // Allow for overriding user includes, too. if (file_exists($tpl_inc_dir . $cur_include[1] . '.' . $cur_include[2])) { require $tpl_inc_dir . $cur_include[1] . '.' . $cur_include[2]; } else { if (file_exists(PUN_ROOT . 'include/user/' . $cur_include[1] . '.' . $cur_include[2])) { require PUN_ROOT . 'include/user/' . $cur_include[1] . '.' . $cur_include[2]; } else { error(sprintf($lang_common['Pun include error'], htmlspecialchars($cur_include[0]), basename($tpl_file))); } } $tpl_temp = ob_get_contents(); $tpl_redir = str_replace($cur_include[0], $tpl_temp, $tpl_redir); ob_end_clean(); } // END SUBST - <pun_include "*"> // START SUBST - <pun_language> $tpl_redir = str_replace('<pun_language>', $lang_common['lang_identifier'], $tpl_redir); // END SUBST - <pun_language> // START SUBST - <pun_content_direction> $tpl_redir = str_replace('<pun_content_direction>', $lang_common['lang_direction'], $tpl_redir); // END SUBST - <pun_content_direction> // START SUBST - <pun_head> ob_start(); $page_title = array(pun_htmlspecialchars($pun_config['o_board_title']), $lang_common['Redirecting']); ?> <meta http-equiv="refresh" content="<?php echo $pun_config['o_redirect_delay']; ?> ;URL=<?php echo $destination_url; ?> " /> <title><?php echo generate_page_title($page_title); ?> </title> <link rel="stylesheet" type="text/css" href="style/<?php echo $pun_user['style'] . '.css'; ?> " /> <?php $tpl_temp = trim(ob_get_contents()); $tpl_redir = str_replace('<pun_head>', $tpl_temp, $tpl_redir); ob_end_clean(); // END SUBST - <pun_head> // START SUBST - <pun_redir_main> ob_start(); ?> <div class="block"> <h2><?php echo $lang_common['Redirecting']; ?> </h2> <div class="box"> <div class="inbox"> <p><?php echo $message . '<br /><br /><a href="' . $destination_url . '">' . $lang_common['Click redirect'] . '</a>'; ?> </p> </div> </div> </div> <?php $tpl_temp = trim(ob_get_contents()); $tpl_redir = str_replace('<pun_redir_main>', $tpl_temp, $tpl_redir); ob_end_clean(); // END SUBST - <pun_redir_main> // START SUBST - <pun_footer> ob_start(); // End the transaction $db->end_transaction(); // Display executed queries (if enabled) if (defined('PUN_SHOW_QUERIES')) { display_saved_queries(); } $tpl_temp = trim(ob_get_contents()); $tpl_redir = str_replace('<pun_footer>', $tpl_temp, $tpl_redir); ob_end_clean(); // END SUBST - <pun_footer> // Close the db connection (and free up any result data) $db->close(); exit($tpl_redir); }
// Calculate script generation time list($usec, $sec) = explode(' ', microtime()); $time_diff = sprintf('%.3f', (double) $usec + (double) $sec - $pun_start); echo "\t\t\t" . '<p class="conr">[ Generated in ' . $time_diff . ' seconds, ' . $db->get_num_queries() . ' queries executed ]</p>' . "\n"; } ?> <div class="clearer"></div> </div> </div> </div> <?php // End the transaction $db->end_transaction(); // Display executed queries (if enabled) if (defined('PUN_SHOW_QUERIES')) { display_saved_queries(); } $tpl_temp = trim(ob_get_contents()); $tpl_main = str_replace('<pun_footer>', $tpl_temp, $tpl_main); ob_end_clean(); // END SUBST - <pun_footer> // START SUBST - <pun_include "*"> while (preg_match('#<pun_include "([^/\\\\]*?)">#', $tpl_main, $cur_include)) { if (!file_exists(PUN_ROOT . 'include/user/' . $cur_include[1])) { error('Unable to process user include <pun_include "' . htmlspecialchars($cur_include[1]) . '"> from template main.tpl. There is no such file in folder /include/user/'); } ob_start(); include PUN_ROOT . 'include/user/' . $cur_include[1]; $tpl_temp = ob_get_contents(); $tpl_main = str_replace($cur_include[0], $tpl_temp, $tpl_main); ob_end_clean();
if ($panther_config['o_feed_type'] == '2') { $feed = array('type' => 'atom', 'link' => panther_link($panther_url['topic_atom'], array($id)), 'lang' => $lang_common['Atom topic feed']); } } break; } ($hook = get_extensions('footer_feedsr')) ? eval($hook) : null; } // Display debug info (if enabled/defined) if ($panther_config['o_debug_mode'] == '1') { // Calculate script generation time $time_diff = sprintf('%.3f', microtime(true) - $panther_start); $debug_info = sprintf($lang_common['Querytime'], $time_diff, $db->get_num_queries()); if (function_exists('memory_get_usage')) { $debug_info .= ' - ' . sprintf($lang_common['Memory usage'], file_size(memory_get_usage())); if (function_exists('memory_get_peak_usage')) { $debug_info .= ' ' . sprintf($lang_common['Peak usage'], file_size(memory_get_peak_usage())); } } } else { $debug_info = ''; } $queries = $panther_config['o_show_queries'] == '1' ? display_saved_queries() : ''; // End the transaction $db->end_transaction(); $style_path = ($panther_config['o_style_path'] != 'style' ? $panther_config['o_style_path'] : PANTHER_ROOT . $panther_config['o_style_path']) . '/' . $panther_user['style'] . '/templates/'; $tpl = defined('PANTHER_ADMIN_CONSOLE') && (file_exists($style_path . 'admin_footer.tpl') || $panther_user['style'] == $panther_config['o_default_style'] && !file_exists($style_path)) ? 'admin_footer.tpl' : 'footer.tpl'; $tpl = load_template($tpl); echo $tpl->render(array('footer_style' => isset($footer_style) ? $footer_style : '', 'controls' => $controls, 'quickjump' => $quickjump_tpl, 'lang_common' => $lang_common, 'links' => $links, 'panther_config' => $panther_config, 'feed' => $feed, 'debug_info' => $debug_info, 'queries' => $queries)); ob_flush(); exit;
function redirect($destination_url, $message = '', $redirect_code = 302) { global $db, $pun_config, $lang_common, $pun_user; // Prefix with o_base_url (unless there's already a valid URI) if (strpos($destination_url, 'http://') !== 0 && strpos($destination_url, 'https://') !== 0 && strpos($destination_url, 'ftp://') !== 0 && strpos($destination_url, 'ftps://') !== 0 && strpos($destination_url, '/') !== 0) { $destination_url = $pun_config['o_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 (!$pun_config['o_redirect_delay'] || !$message) { header('Location: ' . str_replace('&', '&', $destination_url), true, $redirect_code); exit; } // Load the redirect template $tpl_redir = trim(file_get_contents(PUN_ROOT . 'include/template/redirect.tpl')); // START SUBST - <pun_include "*"> while (preg_match('#<pun_include "([^/\\\\]*?)\\.(php[45]?|inc|html?|txt)">#', $tpl_redir, $cur_include)) { if (!file_exists(PUN_ROOT . 'include/user/' . $cur_include[1] . '.' . $cur_include[2])) { error('Unable to process user include ' . htmlspecialchars($cur_include[0]) . ' from template redirect.tpl. There is no such file in folder /include/user/', __FILE__, __LINE__); } ob_start(); include PUN_ROOT . 'include/user/' . $cur_include[1] . '.' . $cur_include[2]; $tpl_temp = ob_get_contents(); $tpl_redir = str_replace($cur_include[0], $tpl_temp, $tpl_redir); ob_end_clean(); } // END SUBST - <pun_include "*"> // START SUBST - <pun_content_direction> $tpl_redir = str_replace('<pun_content_direction>', $lang_common['lang_direction'], $tpl_redir); // END SUBST - <pun_content_direction> // START SUBST - <pun_head> ob_start(); echo '<meta http-equiv="refresh" content="' . $pun_config['o_redirect_delay'] . '; url=' . str_replace(array('<', '>', '"'), array('<', '>', '"'), $destination_url) . '" /> <title>' . pun_htmlspecialchars($pun_config['o_board_title']) . ' / ' . $lang_common['Redirecting'] . '</title> <link rel="stylesheet" type="text/css" href="style/' . $pun_user['style'] . '.css" />'; $tpl_temp = trim(ob_get_contents()); $tpl_redir = str_replace('<pun_head>', $tpl_temp, $tpl_redir); ob_end_clean(); // END SUBST - <pun_head> // START SUBST - <pun_redir_heading> $tpl_redir = str_replace('<pun_redir_heading>', $lang_common['Redirecting'], $tpl_redir); // END SUBST - <pun_redir_heading> // START SUBST - <pun_redir_text> $tpl_temp = $message . '<br /><br />' . '<a href="' . $destination_url . '">' . $lang_common['Click redirect'] . '</a>'; $tpl_redir = str_replace('<pun_redir_text>', $tpl_temp, $tpl_redir); // END SUBST - <pun_redir_text> // START SUBST - <pun_footer> ob_start(); // Display executed queries (if enabled) if (defined('PUN_SHOW_QUERIES')) { display_saved_queries(); } $tpl_temp = trim(ob_get_contents()); $tpl_redir = str_replace('<pun_footer>', $tpl_temp, $tpl_redir); ob_end_clean(); // END SUBST - <pun_footer> // Close the db connection (and free up any result data) $db->close(); header('Content-Type: text/html; charset=UTF-8'); exit($tpl_redir); }
function redirect($destination_url, $message) { global $db, $pun_config, $lang_common, $pun_user; if ($destination_url == '') { $destination_url = 'index.php'; } // If the delay is 0 seconds, we might as well skip the redirect all together if ($pun_config['o_redirect_delay'] == '0') { header('Location: ' . str_replace('&', '&', $destination_url)); } // Load the redirect template $tpl_redir = trim(file_get_contents(PUN_ROOT . 'include/template/redirect.tpl')); // START SUBST - <pun_content_direction> $tpl_redir = str_replace('<pun_content_direction>', $lang_common['lang_direction'], $tpl_redir); // END SUBST - <pun_content_direction> // START SUBST - <pun_char_encoding> $tpl_redir = str_replace('<pun_char_encoding>', $lang_common['lang_encoding'], $tpl_redir); // END SUBST - <pun_char_encoding> // START SUBST - <pun_head> ob_start(); ?> <meta http-equiv="refresh" content="<?php echo $pun_config['o_redirect_delay']; ?> ;URL=<?php echo str_replace(array('<', '>', '"'), array('<', '>', '"'), $destination_url); ?> " /> <title><?php echo pun_htmlspecialchars($pun_config['o_board_title']) . ' / ' . $lang_common['Redirecting']; ?> </title> <link rel="stylesheet" type="text/css" href="style/<?php echo $pun_user['style'] . '.css'; ?> " /> <?php $tpl_temp = trim(ob_get_contents()); $tpl_redir = str_replace('<pun_head>', $tpl_temp, $tpl_redir); ob_end_clean(); // END SUBST - <pun_head> // START SUBST - <pun_redir_heading> $tpl_redir = str_replace('<pun_redir_heading>', $lang_common['Redirecting'], $tpl_redir); // END SUBST - <pun_redir_heading> // START SUBST - <pun_redir_text> $tpl_temp = $message . '<br /><br />' . '<a href="' . $destination_url . '">' . $lang_common['Click redirect'] . '</a>'; $tpl_redir = str_replace('<pun_redir_text>', $tpl_temp, $tpl_redir); // END SUBST - <pun_redir_text> // START SUBST - <pun_footer> ob_start(); // End the transaction $db->end_transaction(); // Display executed queries (if enabled) if (defined('PUN_SHOW_QUERIES')) { display_saved_queries(); } $tpl_temp = trim(ob_get_contents()); $tpl_redir = str_replace('<pun_footer>', $tpl_temp, $tpl_redir); ob_end_clean(); // END SUBST - <pun_footer> // START SUBST - <pun_include "*"> while (preg_match('#<pun_include "([^/\\\\]*?)">#', $tpl_redir, $cur_include)) { if (!file_exists(PUN_ROOT . 'include/user/' . $cur_include[1])) { error('Unable to process user include <pun_include "' . htmlspecialchars($cur_include[1]) . '"> from template redirect.tpl. There is no such file in folder /include/user/'); } ob_start(); include PUN_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 - <pun_include "*"> // Close the db connection (and free up any result data) $db->close(); exit($tpl_redir); }
function redirect($destination_url, $message) { global $db, $pun_config, $lang_common, $pun_user; // if ($destination_url == '') // $destination_url = 'index.php'; // punbb 1.2.16 update see http://punbb.org/download/hdiff/hdiff-1.2.15_to_1.2.16.html and http://punbb.org/download/changelogs/1.2.15_to_1.2.16.txt // Prefix with o_base_url (unless there's already a valid URI) // if (strpos($destination_url, $pun_config['o_base_url']) !== 0) if (strpos($destination_url, 'http://') !== 0 && strpos($destination_url, 'https://') !== 0 && strpos($destination_url, '/') !== 0) { $destination_url = $pun_config['o_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 ($pun_config['o_redirect_delay'] == '0') { header('Location: ' . str_replace('&', '&', $destination_url)); } // StyleInstaller update // Load the redirect template global $style; if (is_file(PUN_ROOT . 'include/template/' . $style . '/redirect.tpl')) { $tpl_redir = trim(file_get_contents(PUN_ROOT . 'include/template/' . $style . '/redirect.tpl')); } else { $tpl_redir = trim(file_get_contents(PUN_ROOT . 'include/template/redirect.tpl')); } // START SUBST - <pun_include "*"> while (preg_match('#<pun_include "([^/\\\\]*?)\\.(php[45]?|inc|html?|txt)">#', $tpl_redir, $cur_include)) { if (!file_exists(PUN_ROOT . 'include/user/' . $cur_include[1] . '.' . $cur_include[2])) { error('Unable to process user include ' . htmlspecialchars($cur_include[0]) . ' from template redirect.tpl. There is no such file in folder /include/user/'); } ob_start(); include PUN_ROOT . 'include/user/' . $cur_include[1] . '.' . $cur_include[2]; $tpl_temp = ob_get_contents(); $tpl_redir = str_replace($cur_include[0], $tpl_temp, $tpl_redir); ob_end_clean(); } // END SUBST - <pun_include "*"> // Load the redirect template // $tpl_redir = trim(file_get_contents(PUN_ROOT.'include/template/redirect.tpl')); // START SUBST - <pun_content_direction> $tpl_redir = str_replace('<pun_content_direction>', $lang_common['lang_direction'], $tpl_redir); // END SUBST - <pun_content_direction> // START SUBST - <pun_char_encoding> $tpl_redir = str_replace('<pun_char_encoding>', $lang_common['lang_encoding'], $tpl_redir); // END SUBST - <pun_char_encoding> // START SUBST - <pun_head> ob_start(); ?> <meta http-equiv="refresh" content="<?php echo $pun_config['o_redirect_delay']; ?> ;URL=<?php echo str_replace(array('<', '>', '"'), array('<', '>', '"'), $destination_url); ?> " /> <title><?php echo pun_htmlspecialchars($pun_config['o_board_title']) . ' / ' . $lang_common['Redirecting']; ?> </title> <link rel="stylesheet" type="text/css" href="style/<?php echo $pun_user['style'] . '.css'; ?> " /> <?php $tpl_temp = trim(ob_get_contents()); $tpl_redir = str_replace('<pun_head>', $tpl_temp, $tpl_redir); ob_end_clean(); // END SUBST - <pun_head> // START SUBST - <pun_redir_heading> $tpl_redir = str_replace('<pun_redir_heading>', $lang_common['Redirecting'], $tpl_redir); // END SUBST - <pun_redir_heading> // START SUBST - <pun_redir_text> $tpl_temp = $message . '<br /><br />' . '<a href="' . $destination_url . '">' . $lang_common['Click redirect'] . '</a>'; $tpl_redir = str_replace('<pun_redir_text>', $tpl_temp, $tpl_redir); // END SUBST - <pun_redir_text> // START SUBST - <pun_footer> ob_start(); // End the transaction $db->end_transaction(); // Display executed queries (if enabled) if (defined('PUN_SHOW_QUERIES')) { display_saved_queries(); } $tpl_temp = trim(ob_get_contents()); $tpl_redir = str_replace('<pun_footer>', $tpl_temp, $tpl_redir); ob_end_clean(); // END SUBST - <pun_footer> // START SUBST - <pun_include "*"> // while (preg_match('#<pun_include "([^/\\\\]*?)">#', $tpl_redir, $cur_include)) // { // if (!file_exists(PUN_ROOT.'include/user/'.$cur_include[1])) // error('Unable to process user include <pun_include "'.htmlspecialchars($cur_include[1]).'"> from template redirect.tpl. There is no such file in folder /include/user/'); // // ob_start(); // include PUN_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 - <pun_include "*"> // Close the db connection (and free up any result data) $db->close(); exit($tpl_redir); }
function redirect($destination_url, $message) { global $db, $panther_config, $lang_common, $panther_user; // Prefix with base_url (unless there's already a valid URI) if (strpos($destination_url, 'http://') !== 0 && strpos($destination_url, 'https://') !== 0 && strpos($destination_url, '/') !== 0) { $destination_url = get_base_url(true) . '/' . $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 ($panther_config['o_redirect_delay'] == '0') { $db->end_transaction(); header('Location: ' . str_replace('&', '&', $destination_url)); exit; } // 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 compatibility // Send the Content-type header in case the web server is setup to send something else header('Content-type: text/html; charset=utf-8'); $tpl = load_template('redirect.tpl'); echo $tpl->render(array('lang_common' => $lang_common, 'destination_url' => $destination_url, 'message' => $message, 'queries' => $panther_config['o_show_queries'] == '1' ? display_saved_queries() : '', 'panther_config' => $panther_config, 'page_title' => generate_page_title(array($panther_config['o_board_title'], $lang_common['Redirecting'])), 'css_url' => ($panther_config['o_style_dir'] != '' ? $panther_config['o_style_dir'] : get_base_url() . '/style/') . $panther_user['style'])); $db->end_transaction(); exit; }