/*
SMF Archive Version: 1.1
http://www.smfhacks.com
By:vbgamer45
1.1 just normal archive not tied into SMF SEO yet wait for 1.2
Install: Just upload archive.php to your forum's main directory
License: The footer links must remain. If you want to remove them you need to talk to me.
************************
archive.php - Generates a search engine friendly version of the forum.
************************
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!
*/
include 'SSI.php';
$board = 0;
$topic = 0;
//Max topics to show per page in a forum
$maxtopics = 20;
//Max posts to show per page in a topic
$maxposts = 15;
//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, $user_info;
$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 AND $user_info[query_see_board]", __FILE__, __LINE__);
$row = mysql_fetch_assoc($request);
if (mysql_num_rows($request) == 0)
die('The topic or board you are looking for appears to be either missing or off limits to you');
mysql_free_result($request);
archive_header($row['name'],$boardurl . '/index.php?board=' . $boardid . '.' . $start);
//Show board Menu Parent List
echo '
';
$request2 = db_query("
SELECT
m.subject, t.ID_TOPIC, t.numReplies
FROM {$db_prefix}messages AS m, {$db_prefix}topics AS t
WHERE m.ID_BOARD = $boardid AND m.ID_MSG = t.ID_FIRST_MSG
ORDER BY t.ID_LAST_MSG DESC
LIMIT $start,$maxtopics", __FILE__, __LINE__);
$i = 0;
while($row2 = mysql_fetch_assoc($request2))
{
$i++;
echo $i . '. ' . $row2['subject'] . ' (' . $row2['numReplies'] . ' replies) ';
}
echo '
';
archive_footer();
}
function archive_topic($topicid)
{
global $boardurl, $db_prefix, $maxposts, $user_info, $mbname;
$topicid = addslashes($topicid);
$start = (int) $_REQUEST['start'];
$request = db_query("
SELECT
m.subject, t.numReplies, b.name, b.ID_BOARD, m.ID_BOARD
FROM {$db_prefix}messages AS m, {$db_prefix}topics AS t,
{$db_prefix}boards AS b
WHERE b.ID_BOARD = m.ID_BOARD AND t.ID_TOPIC = $topicid AND m.ID_MSG = t.ID_FIRST_MSG AND $user_info[query_see_board]", __FILE__, __LINE__);
$row = mysql_fetch_assoc($request);
if (mysql_num_rows($request) == 0)
die('The topic or board you are looking for appears to be either missing or off limits to you');
archive_header($row['subject'],$boardurl . '/index.php?topic=' . $topicid . '.' . $start);
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 '