diff -r e3d7322305bf -r 5e1f1e916419 punbb/include/functions.php
--- a/punbb/include/functions.php Sun Sep 02 11:00:57 2007 -0400
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,1097 +0,0 @@
-started)
- $session->start();
-
- if($session->user_logged_in)
- {
- $result = $pun_db->query(
- 'SELECT eu.*, u.*, eu.real_name AS realname, g.*, eu.user_level AS g_id, o.logged, o.idle
- FROM '.$pun_db->prefix.'users AS u
- LEFT JOIN '.table_prefix.'users AS eu
- ON eu.user_id=u.id
- INNER JOIN '.$pun_db->prefix.'groups AS g
- ON u.group_id=g.g_id
- LEFT JOIN '.$pun_db->prefix.'online AS o
- ON o.user_id=u.id
- WHERE u.id='.intval($session->user_id))
- or error('Unable to fetch user information', __FILE__, __LINE__, $pun_db->error());
- $pun_user = $pun_db->fetch_assoc($result);
- // Set a default language if the user selected language no longer exists
- if (!@file_exists(PUN_ROOT.'lang/'.$pun_user['language']))
- $pun_user['language'] = $pun_config['o_default_lang'];
-
- // Set a default style if the user selected style no longer exists
- // if (!@file_exists(PUN_ROOT.'style/'.$pun_user['style'].'.css'))
- // $pun_user['style'] = $pun_config['o_default_style'];
-
- if (!$pun_user['disp_topics'])
- $pun_user['disp_topics'] = $pun_config['o_disp_topics_default'];
- if (!$pun_user['disp_posts'])
- $pun_user['disp_posts'] = $pun_config['o_disp_posts_default'];
-
- if ($pun_user['save_pass'] == '0')
- $expire = 0;
-
- // Define this if you want this visit to affect the online list and the users last visit data
- if (!defined('PUN_QUIET_VISIT'))
- {
- // Update the online list
- if (!$pun_user['logged'])
- $pun_db->query('INSERT INTO '.$pun_db->prefix.'online (user_id, ident, logged) VALUES('.$pun_user['id'].', \''.$pun_db->escape($pun_user['username']).'\', '.$now.')') or error('Unable to insert into online list', __FILE__, __LINE__, $pun_db->error());
- else
- {
- // Special case: We've timed out, but no other user has browsed the forums since we timed out
- if ($pun_user['logged'] < ($now-$pun_config['o_timeout_visit']))
- {
- $pun_db->query('UPDATE '.$pun_db->prefix.'users SET last_visit='.$pun_user['logged'].' WHERE id='.$pun_user['id']) or error('Unable to update user visit data', __FILE__, __LINE__, $pun_db->error());
- $pun_user['last_visit'] = $pun_user['logged'];
- }
-
- $idle_sql = ($pun_user['idle'] == '1') ? ', idle=0' : '';
- $pun_db->query('UPDATE '.$pun_db->prefix.'online SET logged='.$now.$idle_sql.' WHERE user_id='.$pun_user['id']) or error('Unable to update online list', __FILE__, __LINE__, $pun_db->error());
- }
- }
-
- $pun_user['is_guest'] = false;
- }
- else
- {
- set_default_user();
- }
-}
-
-
-//
-// Fill $pun_user with default values (for guests)
-//
-function set_default_user()
-{
- global $pun_db, $pun_user, $pun_config;
-
- $remote_addr = get_remote_address();
-
- // Fetch guest user
- $result = $pun_db->query('SELECT u.*, g.*, o.logged FROM '.$pun_db->prefix.'users AS u INNER JOIN '.$pun_db->prefix.'groups AS g ON u.group_id=g.g_id LEFT JOIN '.$pun_db->prefix.'online AS o ON o.ident=\''.$remote_addr.'\' WHERE u.id=1') or error('Unable to fetch guest information', __FILE__, __LINE__, $pun_db->error());
- if (!$pun_db->num_rows($result))
- exit('Unable to fetch guest information. The table \''.$pun_db->prefix.'users\' must contain an entry with id = 1 that represents anonymous users.');
-
- $pun_user = $pun_db->fetch_assoc($result);
-
- // Update online list
- if (!$pun_user['logged'])
- $pun_db->query('INSERT INTO '.$pun_db->prefix.'online (user_id, ident, logged) VALUES(1, \''.$pun_db->escape($remote_addr).'\', '.time().')') or error('Unable to insert into online list', __FILE__, __LINE__, $pun_db->error());
- else
- $pun_db->query('UPDATE '.$pun_db->prefix.'online SET logged='.time().' WHERE ident=\''.$pun_db->escape($remote_addr).'\'') or error('Unable to update online list', __FILE__, __LINE__, $pun_db->error());
-
- $pun_user['disp_topics'] = $pun_config['o_disp_topics_default'];
- $pun_user['disp_posts'] = $pun_config['o_disp_posts_default'];
- $pun_user['timezone'] = $pun_config['o_server_timezone'];
- $pun_user['language'] = $pun_config['o_default_lang'];
- $pun_user['style'] = $pun_config['o_default_style'];
- $pun_user['is_guest'] = true;
-}
-
-
-//
-// Set a cookie, PunBB style!
-//
-function pun_setcookie($user_id, $password_hash, $expire)
-{
- global $cookie_name, $cookie_path, $cookie_domain, $cookie_secure, $cookie_seed;
-
- // Enable sending of a P3P header by removing // from the following line (try this if login is failing in IE6)
-// @header('P3P: CP="CUR ADM"');
-
- if (version_compare(PHP_VERSION, '5.2.0', '>='))
- setcookie($cookie_name, serialize(array($user_id, md5($cookie_seed.$password_hash))), $expire, $cookie_path, $cookie_domain, $cookie_secure, true);
- else
- setcookie($cookie_name, serialize(array($user_id, md5($cookie_seed.$password_hash))), $expire, $cookie_path.'; HttpOnly', $cookie_domain, $cookie_secure);
-}
-
-
-//
-// Check whether the connecting user is banned (and delete any expired bans while we're at it)
-//
-function check_bans()
-{
- global $pun_db, $pun_config, $lang_common, $pun_user, $pun_bans;
-
- // Admins aren't affected
- if ($pun_user['g_id'] == PUN_ADMIN || !$pun_bans)
- return;
-
- // Add a dot at the end of the IP address to prevent banned address 192.168.0.5 from matching e.g. 192.168.0.50
- $user_ip = get_remote_address().'.';
- $bans_altered = false;
-
- foreach ($pun_bans as $cur_ban)
- {
- // Has this ban expired?
- if ($cur_ban['expire'] != '' && $cur_ban['expire'] <= time())
- {
- $pun_db->query('DELETE FROM '.$pun_db->prefix.'bans WHERE id='.$cur_ban['id']) or error('Unable to delete expired ban', __FILE__, __LINE__, $pun_db->error());
- $bans_altered = true;
- continue;
- }
-
- if ($cur_ban['username'] != '' && !strcasecmp($pun_user['username'], $cur_ban['username']))
- {
- $pun_db->query('DELETE FROM '.$pun_db->prefix.'online WHERE ident=\''.$pun_db->escape($pun_user['username']).'\'') or error('Unable to delete from online list', __FILE__, __LINE__, $pun_db->error());
- message($lang_common['Ban message'].' '.(($cur_ban['expire'] != '') ? $lang_common['Ban message 2'].' '.strtolower(format_time($cur_ban['expire'], true)).'. ' : '').(($cur_ban['message'] != '') ? $lang_common['Ban message 3'].'
').$lang_common['Ban message 4'].' '.$pun_config['o_admin_email'].'.', true);
- }
- }
- }
- }
-
- // If we removed any expired bans during our run-through, we need to regenerate the bans cache
- if ($bans_altered)
- {
- require_once PUN_ROOT.'include/cache.php';
- generate_bans_cache();
- }
-}
-
-
-//
-// Update "Users online"
-//
-function update_users_online()
-{
- global $pun_db, $pun_config, $pun_user;
-
- $now = time();
-
- // Fetch all online list entries that are older than "o_timeout_online"
- $result = $pun_db->query('SELECT * FROM '.$pun_db->prefix.'online WHERE logged<'.($now-$pun_config['o_timeout_online'])) or error('Unable to fetch old entries from online list', __FILE__, __LINE__, $pun_db->error());
- while ($cur_user = $pun_db->fetch_assoc($result))
- {
- // If the entry is a guest, delete it
- if ($cur_user['user_id'] == '1')
- $pun_db->query('DELETE FROM '.$pun_db->prefix.'online WHERE ident=\''.$pun_db->escape($cur_user['ident']).'\'') or error('Unable to delete from online list', __FILE__, __LINE__, $pun_db->error());
- else
- {
- // If the entry is older than "o_timeout_visit", update last_visit for the user in question, then delete him/her from the online list
- if ($cur_user['logged'] < ($now-$pun_config['o_timeout_visit']))
- {
- $pun_db->query('UPDATE '.$pun_db->prefix.'users SET last_visit='.$cur_user['logged'].' WHERE id='.$cur_user['user_id']) or error('Unable to update user visit data', __FILE__, __LINE__, $pun_db->error());
- $pun_db->query('DELETE FROM '.$pun_db->prefix.'online WHERE user_id='.$cur_user['user_id']) or error('Unable to delete from online list', __FILE__, __LINE__, $pun_db->error());
- }
- else if ($cur_user['idle'] == '0')
- $pun_db->query('UPDATE '.$pun_db->prefix.'online SET idle=1 WHERE user_id='.$cur_user['user_id']) or error('Unable to insert into online list', __FILE__, __LINE__, $pun_db->error());
- }
- }
-}
-
-//
-// Generate the "navigator" that appears at the top of every page
-//
-function generate_navlinks()
-{
- global $pun_config, $lang_common, $pun_user;
- global $db, $session, $paths, $template, $plugins; // Common objects
-
- // Index and Userlist should always be displayed
- $links[] = '
'.$lang_common['Logout'].'';
- }
- }
-
- // Are there any additional navlinks we should insert into the array before imploding it?
- if ($pun_config['o_additional_navlinks'] != '')
- {
- if (preg_match_all('#([0-9]+)\s*=\s*(.*?)\n#s', $pun_config['o_additional_navlinks']."\n", $extra_links))
- {
- // Insert any additional links into the $links array (at the correct index)
- for ($i = 0; $i < count($extra_links[1]); ++$i)
- array_splice($links, $extra_links[1][$i], 0, array('
'."\n\t\t\t\t", $links).''."\n\t\t\t".'';
-}
-
-
-//
-// Display the profile navigation menu
-//
-function generate_profile_menu($page = '')
-{
- global $lang_profile, $pun_config, $pun_user, $id, $lang_common;
-
-?>
-
-
-
-
-
-
-
>
-
>
-
>
-
>
-
>
-
>
-
>
-
-
-
-
-query('SELECT COUNT(id), SUM(num_replies) FROM '.$pun_db->prefix.'topics WHERE moved_to IS NULL AND forum_id='.$forum_id) or error('Unable to fetch forum topic count', __FILE__, __LINE__, $pun_db->error());
- list($num_topics, $num_posts) = $pun_db->fetch_row($result);
-
- $num_posts = $num_posts + $num_topics; // $num_posts is only the sum of all replies (we have to add the topic posts)
-
- $result = $pun_db->query('SELECT last_post, last_post_id, last_poster FROM '.$pun_db->prefix.'topics WHERE forum_id='.$forum_id.' AND moved_to IS NULL ORDER BY last_post DESC LIMIT 1') or error('Unable to fetch last_post/last_post_id/last_poster', __FILE__, __LINE__, $pun_db->error());
- if ($pun_db->num_rows($result)) // There are topics in the forum
- {
- list($last_post, $last_post_id, $last_poster) = $pun_db->fetch_row($result);
-
- $pun_db->query('UPDATE '.$pun_db->prefix.'forums SET num_topics='.$num_topics.', num_posts='.$num_posts.', last_post='.$last_post.', last_post_id='.$last_post_id.', last_poster=\''.$pun_db->escape($last_poster).'\' WHERE id='.$forum_id) or error('Unable to update last_post/last_post_id/last_poster', __FILE__, __LINE__, $pun_db->error());
- }
- else // There are no topics
- $pun_db->query('UPDATE '.$pun_db->prefix.'forums SET num_topics=0, num_posts=0, last_post=NULL, last_post_id=NULL, last_poster=NULL WHERE id='.$forum_id) or error('Unable to update last_post/last_post_id/last_poster', __FILE__, __LINE__, $pun_db->error());
-}
-
-
-//
-// Delete a topic and all of it's posts
-//
-function delete_topic($topic_id)
-{
- global $pun_db;
-
- // Delete the topic and any redirect topics
- $pun_db->query('DELETE FROM '.$pun_db->prefix.'topics WHERE id='.$topic_id.' OR moved_to='.$topic_id) or error('Unable to delete topic', __FILE__, __LINE__, $pun_db->error());
-
- // Create a list of the post ID's in this topic
- $post_ids = '';
- $result = $pun_db->query('SELECT id FROM '.$pun_db->prefix.'posts WHERE topic_id='.$topic_id) or error('Unable to fetch posts', __FILE__, __LINE__, $pun_db->error());
- while ($row = $pun_db->fetch_row($result))
- $post_ids .= ($post_ids != '') ? ','.$row[0] : $row[0];
-
- // Make sure we have a list of post ID's
- if ($post_ids != '')
- {
- strip_search_index($post_ids);
-
- // Delete posts in topic
- $pun_db->query('DELETE FROM '.$pun_db->prefix.'posts WHERE topic_id='.$topic_id) or error('Unable to delete posts', __FILE__, __LINE__, $pun_db->error());
- }
-
- // Delete any subscriptions for this topic
- $pun_db->query('DELETE FROM '.$pun_db->prefix.'subscriptions WHERE topic_id='.$topic_id) or error('Unable to delete subscriptions', __FILE__, __LINE__, $pun_db->error());
-}
-
-
-//
-// Delete a single post
-//
-function delete_post($post_id, $topic_id)
-{
- global $pun_db;
-
- $result = $pun_db->query('SELECT id, poster, posted FROM '.$pun_db->prefix.'posts WHERE topic_id='.$topic_id.' ORDER BY id DESC LIMIT 2') or error('Unable to fetch post info', __FILE__, __LINE__, $pun_db->error());
- list($last_id, ,) = $pun_db->fetch_row($result);
- list($second_last_id, $second_poster, $second_posted) = $pun_db->fetch_row($result);
-
- // Delete the post
- $pun_db->query('DELETE FROM '.$pun_db->prefix.'posts WHERE id='.$post_id) or error('Unable to delete post', __FILE__, __LINE__, $pun_db->error());
-
- strip_search_index($post_id);
-
- // Count number of replies in the topic
- $result = $pun_db->query('SELECT COUNT(id) FROM '.$pun_db->prefix.'posts WHERE topic_id='.$topic_id) or error('Unable to fetch post count for topic', __FILE__, __LINE__, $pun_db->error());
- $num_replies = $pun_db->result($result, 0) - 1;
-
- // If the message we deleted is the most recent in the topic (at the end of the topic)
- if ($last_id == $post_id)
- {
- // If there is a $second_last_id there is more than 1 reply to the topic
- if (!empty($second_last_id))
- $pun_db->query('UPDATE '.$pun_db->prefix.'topics SET last_post='.$second_posted.', last_post_id='.$second_last_id.', last_poster=\''.$pun_db->escape($second_poster).'\', num_replies='.$num_replies.' WHERE id='.$topic_id) or error('Unable to update topic', __FILE__, __LINE__, $pun_db->error());
- else
- // We deleted the only reply, so now last_post/last_post_id/last_poster is posted/id/poster from the topic itself
- $pun_db->query('UPDATE '.$pun_db->prefix.'topics SET last_post=posted, last_post_id=id, last_poster=poster, num_replies='.$num_replies.' WHERE id='.$topic_id) or error('Unable to update topic', __FILE__, __LINE__, $pun_db->error());
- }
- else
- // Otherwise we just decrement the reply counter
- $pun_db->query('UPDATE '.$pun_db->prefix.'topics SET num_replies='.$num_replies.' WHERE id='.$topic_id) or error('Unable to update topic', __FILE__, __LINE__, $pun_db->error());
-}
-
-
-//
-// Replace censored words in $text
-//
-function censor_words($text)
-{
- global $pun_db;
- static $search_for, $replace_with;
-
- // If not already built in a previous call, build an array of censor words and their replacement text
- if (!isset($search_for))
- {
- $result = $pun_db->query('SELECT search_for, replace_with FROM '.$pun_db->prefix.'censoring') or error('Unable to fetch censor word list', __FILE__, __LINE__, $pun_db->error());
- $num_words = $pun_db->num_rows($result);
-
- $search_for = array();
- for ($i = 0; $i < $num_words; ++$i)
- {
- list($search_for[$i], $replace_with[$i]) = $pun_db->fetch_row($result);
- $search_for[$i] = '/\b('.str_replace('\*', '\w*?', preg_quote($search_for[$i], '/')).')\b/i';
- }
- }
-
- if (!empty($search_for))
- $text = substr(preg_replace($search_for, $replace_with, ' '.$text.' '), 1, -1);
-
- return $text;
-}
-
-
-//
-// Determines the correct title for $user
-// $user must contain the elements 'username', 'title', 'posts', 'g_id' and 'g_user_title'
-//
-function get_title($user)
-{
- global $pun_db, $pun_config, $pun_bans, $lang_common;
- static $ban_list, $pun_ranks;
-
- // If not already built in a previous call, build an array of lowercase banned usernames
- if (empty($ban_list))
- {
- $ban_list = array();
-
- foreach ($pun_bans as $cur_ban)
- $ban_list[] = strtolower($cur_ban['username']);
- }
-
- // If not already loaded in a previous call, load the cached ranks
- if ($pun_config['o_ranks'] == '1' && empty($pun_ranks))
- {
- @include PUN_ROOT.'cache/cache_ranks.php';
- if (!defined('PUN_RANKS_LOADED'))
- {
- require_once PUN_ROOT.'include/cache.php';
- generate_ranks_cache();
- require PUN_ROOT.'cache/cache_ranks.php';
- }
- }
-
- // If the user has a custom title
- if ($user['title'] != '')
- $user_title = pun_htmlspecialchars($user['title']);
- // If the user is banned
- else if (in_array(strtolower($user['username']), $ban_list))
- $user_title = $lang_common['Banned'];
- // If the user group has a default user title
- else if ($user['g_user_title'] != '')
- $user_title = pun_htmlspecialchars($user['g_user_title']);
- // If the user is a guest
- else if ($user['g_id'] == PUN_GUEST)
- $user_title = $lang_common['Guest'];
- else
- {
- // Are there any ranks?
- if ($pun_config['o_ranks'] == '1' && !empty($pun_ranks))
- {
- @reset($pun_ranks);
- while (list(, $cur_rank) = @each($pun_ranks))
- {
- if (intval($user['num_posts']) >= $cur_rank['min_posts'])
- $user_title = pun_htmlspecialchars($cur_rank['rank']);
- }
- }
-
- // If the user didn't "reach" any rank (or if ranks are disabled), we assign the default
- if (!isset($user_title))
- $user_title = $lang_common['Member'];
- }
-
- return $user_title;
-}
-
-
-//
-// Generate a string with numbered links (for multipage scripts)
-//
-function pun_paginate($num_pages, $cur_page, $link_to)
-{
- $pages = array();
- $link_to_all = false;
-
- // If $cur_page == -1, we link to all pages (used in viewforum.php)
- if ($cur_page == -1)
- {
- $cur_page = 1;
- $link_to_all = true;
- }
-
- if ($num_pages <= 1)
- $pages = array('1');
- else
- {
- if ($cur_page > 3)
- {
- $pages[] = '1';
-
- if ($cur_page != 4)
- $pages[] = '…';
- }
-
- // Don't ask me how the following works. It just does, OK? :-)
- for ($current = $cur_page - 2, $stop = $cur_page + 3; $current < $stop; ++$current)
- {
- if ($current < 1 || $current > $num_pages)
- continue;
- else if ($current != $cur_page || $link_to_all)
- $pages[] = ''.$current.'';
- else
- $pages[] = ''.$current.'';
- }
-
- if ($cur_page <= ($num_pages-3))
- {
- if ($cur_page != ($num_pages-3))
- $pages[] = '…';
-
- $pages[] = ''.$num_pages.'';
- }
- }
-
- return implode(' ', $pages);
-}
-
-
-//
-// Display a message
-//
-function message($message, $no_back_link = false)
-{
- global $pun_db, $lang_common, $pun_config, $pun_start, $tpl_main;
-
- if (!defined('PUN_HEADER'))
- {
- global $pun_user;
-
- $page_title = pun_htmlspecialchars($pun_config['o_board_title']).' / '.$lang_common['Info'];
- require PUN_ROOT.'header.php';
- }
-
-?>
-
-
-
-
-
-
-
-
-
-
-', '"'), array('<', '>', '"'), $str);
-
- return $str;
-}
-
-
-//
-// Equivalent to strlen(), but counts [0-9]+ as one character (for unicode)
-//
-function pun_strlen($str)
-{
- return strlen(preg_replace('/([0-9]+);/', '!', $str));
-}
-
-
-//
-// Convert \r\n and \r to \n
-//
-function pun_linebreaks($str)
-{
- return str_replace("\r", "\n", str_replace("\r\n", "\n", $str));
-}
-
-
-//
-// A more aggressive version of trim()
-//
-function pun_trim($str)
-{
- global $lang_common;
-
- if (strpos($lang_common['lang_encoding'], '8859') !== false)
- {
- $fishy_chars = array(chr(0x81), chr(0x8D), chr(0x8F), chr(0x90), chr(0x9D), chr(0xA0));
- return trim(str_replace($fishy_chars, ' ', $str));
- }
- else
- return trim($str);
-}
-
-
-//
-// Display a message when board is in maintenance mode
-//
-function maintenance_message()
-{
- global $pun_db, $pun_config, $lang_common, $pun_user;
-
- // Deal with newlines, tabs and multiple spaces
- $pattern = array("\t", ' ', ' ');
- $replace = array(' ', ' ', ' ');
- $message = str_replace($pattern, $replace, $pun_config['o_maintenance_message']);
-
-
- // Load the maintenance template
- $tpl_maint = trim(file_get_contents(PUN_ROOT.'include/template/maintenance.tpl'));
-
-
- // START SUBST -
- while (preg_match('##', $tpl_maint, $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 maintenance.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_maint = str_replace($cur_include[0], $tpl_temp, $tpl_maint);
- ob_end_clean();
- }
- // END SUBST -
-
-
- // START SUBST -
- $tpl_maint = str_replace('', $lang_common['lang_direction'], $tpl_maint);
- // END SUBST -
-
-
- // START SUBST -
- $tpl_maint = str_replace('', $lang_common['lang_encoding'], $tpl_maint);
- // END SUBST -
-
-
- // START SUBST -
- ob_start();
-
-?>
-
-
-', $tpl_temp, $tpl_maint);
- ob_end_clean();
- // END SUBST -
-
-
- // START SUBST -
- $tpl_maint = str_replace('', $lang_common['Maintenance'], $tpl_maint);
- // END SUBST -
-
-
- // START SUBST -
- $tpl_maint = str_replace('', $message, $tpl_maint);
- // END SUBST -
-
-
- // End the transaction
- $pun_db->end_transaction();
-
-
- // Close the db connection (and free up any result data)
- $pun_db->close();
-
- exit($tpl_maint);
-}
-
-
-//
-// Display $message and redirect user to $destination_url
-//
-function pun_redirect($destination_url, $message)
-{
- global $pun_db, $pun_config, $lang_common, $pun_user;
-
- if ($destination_url == '')
- $destination_url = 'index.php';
-
- if ( preg_match('/^admin_([a-z0-9_]+?)\.php$/i', $destination_url, $match) )
- {
- $module = capitalize_first_letter($match[1]);
- $destination_url = makeUrlNS('Special', 'Forum/Admin_' . $module);
- }
-
- // 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 -
- while (preg_match('##', $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 -
-
-
- // START SUBST -
- $tpl_redir = str_replace('', $lang_common['lang_direction'], $tpl_redir);
- // END SUBST -
-
-
- // START SUBST -
- $tpl_redir = str_replace('', $lang_common['lang_encoding'], $tpl_redir);
- // END SUBST -
-
-
- // START SUBST -
- ob_start();
-
-?>
-" />
-
-
-', $tpl_temp, $tpl_redir);
- ob_end_clean();
- // END SUBST -
-
-
- // START SUBST -
- $tpl_redir = str_replace('', $lang_common['Redirecting'], $tpl_redir);
- // END SUBST -
-
-
- // START SUBST -
- $tpl_temp = $message.'
'.''.$lang_common['Click redirect'].'';
- $tpl_redir = str_replace('', $tpl_temp, $tpl_redir);
- // END SUBST -
-
-
- // START SUBST -
- ob_start();
-
- // End the transaction
- $pun_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('', $tpl_temp, $tpl_redir);
- ob_end_clean();
- // END SUBST -
-
-
- // Close the db connection (and free up any result data)
- $pun_db->close();
-
- exit($tpl_redir);
-}
-
-
-//
-// Display a simple error message
-//
-function error($message, $file, $line, $db_error = false)
-{
- global $pun_config;
-
- // Set a default title if the script failed before $pun_config could be populated
- if (empty($pun_config))
- $pun_config['o_board_title'] = 'PunBB';
-
- // Empty output buffer and stop buffering
- @ob_end_clean();
-
- // "Restart" output buffering if we are using ob_gzhandler (since the gzip header is already sent)
- if (!empty($pun_config['o_gzip']) && extension_loaded('zlib') && (strpos($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip') !== false || strpos($_SERVER['HTTP_ACCEPT_ENCODING'], 'deflate') !== false))
- ob_start('ob_gzhandler');
-
-?>
-
-
-
-
- / Error
-
-
-
-
-