2015-04-01 17:05:55 +00:00
|
|
|
<?php
|
|
|
|
/*
|
|
|
|
* Sakura Main Index
|
|
|
|
*/
|
|
|
|
|
|
|
|
// Declare Namespace
|
|
|
|
namespace Sakura;
|
|
|
|
|
|
|
|
// Include components
|
2015-12-03 19:40:01 +00:00
|
|
|
require_once str_replace(basename(__DIR__), '', dirname(__FILE__)) . 'sakura.php';
|
2015-06-29 00:36:37 +00:00
|
|
|
|
2015-11-06 22:30:37 +00:00
|
|
|
// Initialise templating engine
|
|
|
|
$template = new Template();
|
|
|
|
|
|
|
|
// Change templating engine
|
|
|
|
$template->setTemplate($templateName);
|
|
|
|
|
2015-09-04 23:49:53 +00:00
|
|
|
// Info pages
|
2015-09-14 20:51:23 +00:00
|
|
|
if (isset($_GET['p'])) {
|
2015-09-04 23:49:53 +00:00
|
|
|
// Set default variables
|
|
|
|
$renderData['page'] = [
|
2016-01-20 23:06:21 +00:00
|
|
|
'content' => '<h1>Unable to load the requested info page.</h1><p>Check the URL and try again.</p>',
|
2015-09-04 23:49:53 +00:00
|
|
|
];
|
|
|
|
|
|
|
|
// Set page id
|
|
|
|
$pageId = isset($_GET['p']) ? strtolower($_GET['p']) : '';
|
|
|
|
|
|
|
|
// Get info page data from the database
|
2016-01-17 01:58:31 +00:00
|
|
|
if ($ipData = Utils::loadInfoPage($pageId)) {
|
2015-09-04 23:49:53 +00:00
|
|
|
// Assign new proper variable
|
|
|
|
$renderData['page'] = [
|
2015-09-14 20:51:23 +00:00
|
|
|
'id' => $pageId,
|
2015-10-10 21:17:50 +00:00
|
|
|
'title' => $ipData['page_title'],
|
2016-01-20 23:06:21 +00:00
|
|
|
'content' => $ipData['page_content'],
|
2015-09-04 23:49:53 +00:00
|
|
|
];
|
|
|
|
}
|
|
|
|
|
2015-11-06 22:30:37 +00:00
|
|
|
// Set parse variables
|
|
|
|
$template->setVariables($renderData);
|
|
|
|
|
2015-09-04 23:49:53 +00:00
|
|
|
// Print page contents
|
2015-12-10 20:55:51 +00:00
|
|
|
echo $template->render('main/infopage');
|
2015-09-04 23:49:53 +00:00
|
|
|
exit;
|
|
|
|
}
|
|
|
|
|
2015-06-27 11:03:11 +00:00
|
|
|
// Are we in forum mode?
|
2015-09-04 23:49:53 +00:00
|
|
|
$forumMode = isset($_GET['forum']) ? ($_GET['forum'] == true) : false;
|
2015-06-27 11:03:11 +00:00
|
|
|
|
2015-12-04 14:19:10 +00:00
|
|
|
$renderData['news'] = ($forumMode ? null : (new News(Config::get('site_news_category'))));
|
2015-09-11 23:31:54 +00:00
|
|
|
|
2015-12-04 14:19:10 +00:00
|
|
|
$renderData['newsCount'] = Config::get('front_page_news_posts');
|
2015-06-27 19:29:37 +00:00
|
|
|
|
2015-11-22 22:10:23 +00:00
|
|
|
$renderData['forum'] = ($forumMode ? (new Forum\Forum()) : null);
|
2015-06-27 19:29:37 +00:00
|
|
|
|
2016-01-20 23:06:21 +00:00
|
|
|
$renderData['latestPosts'] = Database::fetch('posts', true, null, ['post_id', true], [3]);
|
|
|
|
|
2015-04-02 14:03:58 +00:00
|
|
|
$renderData['stats'] = [
|
2015-09-14 20:51:23 +00:00
|
|
|
'userCount' => Database::count('users', ['password_algo' => ['nologin', '!='], 'rank_main' => ['1', '!=']])[0],
|
2015-12-29 01:27:49 +00:00
|
|
|
'newestUser' => ($_INDEX_NEWEST_USER = User::construct(Users::getNewestUserId())),
|
2015-09-14 21:41:43 +00:00
|
|
|
'lastRegDate' => ($_INDEX_LAST_REGDATE = date_diff(
|
|
|
|
date_create(
|
|
|
|
date(
|
|
|
|
'Y-m-d',
|
2016-01-17 01:58:31 +00:00
|
|
|
$_INDEX_NEWEST_USER->registered
|
2015-09-14 21:41:43 +00:00
|
|
|
)
|
|
|
|
),
|
|
|
|
date_create(
|
|
|
|
date('Y-m-d')
|
|
|
|
)
|
|
|
|
)->format('%a')) . ' day' . ($_INDEX_LAST_REGDATE == 1 ? '' : 's'),
|
2015-09-14 20:51:23 +00:00
|
|
|
'topicCount' => Database::count('topics')[0],
|
|
|
|
'postCount' => Database::count('posts')[0],
|
|
|
|
'onlineUsers' => Users::checkAllOnline(),
|
2015-04-02 14:03:58 +00:00
|
|
|
];
|
2015-04-01 17:05:55 +00:00
|
|
|
|
2015-10-31 18:14:54 +00:00
|
|
|
// Set parse variables
|
|
|
|
$template->setVariables($renderData);
|
|
|
|
|
2015-04-01 17:05:55 +00:00
|
|
|
// Print page contents
|
2015-12-10 20:55:51 +00:00
|
|
|
echo $template->render(($forumMode ? 'forum' : 'main') . '/index');
|