/*
Function list
void archive_board($boardid) - shows a board's topics passed is the ID_BOARD
void archive_topic($topicid) - shows a topic's post passed is the ID_TOPIC
void archive_main() - shows the board index of the archive
//Template functions
void archive_header($title, $url) - shows the header html information for the template. Takes a title of the page and the url to the full version
void archive_footer() - shows the footer html for the archive. Links must remain!
*/
define('SMF', '1');
//Report all the errors
//error_reporting(E_ALL);
error_reporting(E_NONE);
//Get the database and board information
require_once(dirname(__FILE__) . '/Settings.php');
//Max topics to show per page in a forum
$maxtopics = 20;
//Max posts to show per page in a topic
$maxposts = 15;
//Check if board is in maintenance mode
if($maintenance == 2)
die('Board is in maintenance mode. The archive is not open durning this time.');
//Connect to the database
if($db_persist == 0)
$db_connection = @mysql_connect($db_server, $db_user, $db_passwd);
else
$db_connection = @mysql_pconnect($db_server, $db_user, $db_passwd);
//Check if you can connect to the database
if (!$db_connection )
die('Could not connect to the database.');
if(!@mysql_select_db($db_name, $db_connection ))
die('Could not select the database.');
//Take off that wirless warning
define('WIRELESS', false);
//These are mainly here to check for user permissions what boards and topics they can view.
require_once($sourcedir . '/QueryString.php');
require_once($sourcedir . '/Subs.php');
require_once($sourcedir . '/Errors.php');
require_once($sourcedir . '/Load.php');
require_once($sourcedir . '/Security.php');
if (@version_compare(PHP_VERSION, '4.2.3') != 1)
require_once($sourcedir . '/Subs-Compat.php');
reloadSettings();
cleanRequest();
//Load User Setttings
loadUserSettings();
$user_info['smiley_set'] = $modSettings['smiley_sets_default'];
$user_info['groups'] = array_unique($user_info['groups']);
// Just build this here, it makes it easier to change/use.
if ($user_info['is_guest'])
$user_info['query_see_board'] = 'FIND_IN_SET(-1, b.memberGroups)';
// Administrators can see all boards.
elseif ($user_info['is_admin'])
$user_info['query_see_board'] = '1';
// Registered user.... just the groups in $user_info['groups'].
else
$user_info['query_see_board'] = '(FIND_IN_SET(' . implode(', b.memberGroups) OR FIND_IN_SET(', $user_info['groups']) . ', b.memberGroups))';
if(!isset($topic))
loadBoard();
//Load the Current User Permmissions
loadPermissions();
//Check if they have smfseo installed and turned on
//if(@$modSettings['smfseo_enabled'] == 1)
// $smfseo = true;
//else
// $smfseo = false;
$board = 0;
$topic = 0;
//All $context['browser'] code from loadTheme from Load.php
// The following determines the user agent (browser) as best it can.
$context['browser'] = array(
'is_opera' => strpos($_SERVER['HTTP_USER_AGENT'], 'Opera') !== false,
'is_opera6' => strpos($_SERVER['HTTP_USER_AGENT'], 'Opera 6') !== false,
'is_opera7' => strpos($_SERVER['HTTP_USER_AGENT'], 'Opera 7') !== false || strpos($_SERVER['HTTP_USER_AGENT'], 'Opera/7') !== false,
'is_opera8' => strpos($_SERVER['HTTP_USER_AGENT'], 'Opera 8') !== false || strpos($_SERVER['HTTP_USER_AGENT'], 'Opera/8') !== false,
'is_ie4' => strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE 4') !== false && strpos($_SERVER['HTTP_USER_AGENT'], 'WebTV') === false,
'is_safari' => strpos($_SERVER['HTTP_USER_AGENT'], 'Safari') !== false,
'is_mac_ie' => strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE 5.') !== false && strpos($_SERVER['HTTP_USER_AGENT'], 'Mac') !== false,
'is_web_tv' => strpos($_SERVER['HTTP_USER_AGENT'], 'WebTV') !== false,
'is_konqueror' => strpos($_SERVER['HTTP_USER_AGENT'], 'Konqueror') !== false,
'is_firefox' => strpos($_SERVER['HTTP_USER_AGENT'], 'Firefox') !== false,
);
$context['browser']['is_gecko'] = strpos($_SERVER['HTTP_USER_AGENT'], 'Gecko') !== false && !$context['browser']['is_safari'] && !$context['browser']['is_konqueror'];
// Internet Explorer 5 and 6 are often "emulated".
$context['browser']['is_ie7'] = strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE 7') !== false && !$context['browser']['is_opera'] && !$context['browser']['is_gecko'] && !$context['browser']['is_web_tv'];
$context['browser']['is_ie6'] = strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE 6') !== false && !$context['browser']['is_opera'] && !$context['browser']['is_gecko'] && !$context['browser']['is_web_tv'];
$context['browser']['is_ie5.5'] = strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE 5.5') !== false && !$context['browser']['is_opera'] && !$context['browser']['is_gecko'] && !$context['browser']['is_web_tv'];
$context['browser']['is_ie5'] = strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE 5.0') !== false && !$context['browser']['is_opera'] && !$context['browser']['is_gecko'] && !$context['browser']['is_web_tv'];
$context['browser']['is_ie'] = $context['browser']['is_ie4'] || $context['browser']['is_ie5'] || $context['browser']['is_ie5.5'] || $context['browser']['is_ie6'] || $context['browser']['is_ie7'];
$context['browser']['needs_size_fix'] = ($context['browser']['is_ie5'] || $context['browser']['is_ie5.5'] || $context['browser']['is_ie4'] || $context['browser']['is_opera6']) && strpos($_SERVER['HTTP_USER_AGENT'], 'Mac') === false;
//Get the board ID
@$board = (int) $_GET['board'];
//Get the topic ID
@$topic = (int) $_GET['topic'];
if(empty($board) && empty($topic))
{
archive_main();
exit();
}
if(!empty($board))
{
archive_board($board);
exit();
}
if(!empty($topic))
{
archive_topic($topic);
exit();
}
function archive_board($boardid)
{
global $boardurl, $db_prefix, $maxtopics, $mbname;
$boardid = addslashes($boardid);
$start = (int) $_REQUEST['start'];
$request = db_query("SELECT b.name, b.numTopics
FROM {$db_prefix}boards AS b
WHERE b.ID_BOARD = $boardid", __FILE__, __LINE__);
$row = mysql_fetch_assoc($request);
archive_header($row['name'],$boardurl . '/index.php?board=' . $boardid . '.' . $start);
//Show board Menu Parent List
echo '
';
//Get all posts in a topic
$request2 = db_query("SELECT m.subject, m.posterName, m.body, m.posterTime
FROM {$db_prefix}messages AS m
LEFT JOIN {$db_prefix}boards AS b ON(b.ID_BOARD = m.ID_BOARD)
WHERE m.ID_TOPIC = $topicid AND $user_info[query_see_board] ORDER BY m.ID_MSG ASC LIMIT $start,$maxposts", __FILE__, __LINE__);
echo '