2015-05-06 13:42:02 +00:00
|
|
|
<?php
|
|
|
|
/*
|
|
|
|
* Sakura Forum List Viewer
|
|
|
|
*/
|
|
|
|
|
|
|
|
// Declare Namespace
|
|
|
|
namespace Sakura;
|
|
|
|
|
|
|
|
// Include components
|
2015-09-14 20:51:23 +00:00
|
|
|
require_once str_replace(basename(__DIR__), '', dirname(__FILE__)) . '_sakura/sakura.php';
|
2015-06-27 19:29:37 +00:00
|
|
|
|
|
|
|
// Get the forum's data
|
2015-11-17 19:30:34 +00:00
|
|
|
$forum = new Board\Forum(isset($_GET['f']) ? $_GET['f'] : -1);
|
2015-06-27 19:29:37 +00:00
|
|
|
|
2015-11-06 22:30:37 +00:00
|
|
|
// Initialise templating engine
|
|
|
|
$template = new Template();
|
|
|
|
|
|
|
|
// Change templating engine
|
|
|
|
$template->setTemplate($templateName);
|
|
|
|
|
2015-06-27 19:29:37 +00:00
|
|
|
// Check if the forum exists
|
2015-11-21 15:27:37 +00:00
|
|
|
if ($forum->id < 0) {
|
2015-06-27 19:29:37 +00:00
|
|
|
// Set render data
|
|
|
|
$renderData['page'] = [
|
2015-09-14 20:51:23 +00:00
|
|
|
'title' => 'Information',
|
2015-11-21 15:27:37 +00:00
|
|
|
'message' => 'The forum you tried to access does not exist.',
|
2015-06-27 19:29:37 +00:00
|
|
|
];
|
|
|
|
|
2015-11-06 22:30:37 +00:00
|
|
|
// Set parse variables
|
|
|
|
$template->setVariables($renderData);
|
|
|
|
|
|
|
|
// Print page contents
|
|
|
|
echo $template->render('global/information.tpl');
|
2015-06-27 19:29:37 +00:00
|
|
|
exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Check if the forum isn't a link
|
2015-11-15 14:29:26 +00:00
|
|
|
if ($forum->type === 2) {
|
2015-06-27 19:29:37 +00:00
|
|
|
// Set render data
|
|
|
|
$renderData['page'] = [
|
2015-09-14 20:51:23 +00:00
|
|
|
'title' => 'Information',
|
|
|
|
'message' => 'The forum you tried to access is a link. You\'re being redirected.',
|
2015-11-15 14:29:26 +00:00
|
|
|
'redirect' => $forum->link,
|
2015-06-27 19:29:37 +00:00
|
|
|
];
|
|
|
|
|
2015-11-06 22:30:37 +00:00
|
|
|
// Set parse variables
|
|
|
|
$template->setVariables($renderData);
|
|
|
|
|
|
|
|
// Print page contents
|
|
|
|
echo $template->render('global/information.tpl');
|
2015-06-27 19:29:37 +00:00
|
|
|
exit;
|
|
|
|
}
|
|
|
|
|
2015-11-21 15:27:37 +00:00
|
|
|
// Check if we're marking as read
|
|
|
|
if (isset($_GET['read']) && $_GET['read'] && isset($_GET['session']) && $_GET['session'] == session_id()) {
|
|
|
|
// Run the function
|
|
|
|
$forum->trackUpdateAll($currentUser->id());
|
|
|
|
|
|
|
|
// Set render data
|
|
|
|
$renderData['page'] = [
|
|
|
|
'title' => 'Information',
|
|
|
|
'message' => 'All threads have been marked as read.',
|
|
|
|
'redirect' => $urls->format('FORUM_SUB', [$forum->id]),
|
|
|
|
];
|
|
|
|
|
|
|
|
// Set parse variables
|
|
|
|
$template->setVariables($renderData);
|
|
|
|
|
|
|
|
// Print page contents
|
|
|
|
echo $template->render('global/information.tpl');
|
|
|
|
exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Redirect forum id 0 to the main page
|
|
|
|
if ($forum->id === 0) {
|
|
|
|
header('Location: ' . $urls->format('FORUM_INDEX'));
|
|
|
|
exit;
|
|
|
|
}
|
|
|
|
|
2015-11-15 14:29:26 +00:00
|
|
|
$renderData['forum'] = $forum;
|
|
|
|
|
2015-11-06 22:30:37 +00:00
|
|
|
// Set parse variables
|
|
|
|
$template->setVariables($renderData);
|
|
|
|
|
2015-06-27 19:29:37 +00:00
|
|
|
// Print page contents
|
2015-11-06 22:30:37 +00:00
|
|
|
echo $template->render('forum/viewforum.tpl');
|