This repository has been archived on 2024-06-26. You can view files and clone it, but cannot push or open issues or pull requests.
sakura/public/index.php

79 lines
2.2 KiB
PHP
Raw Normal View History

2015-04-01 17:05:55 +00:00
<?php
/*
* Sakura Main Index
*/
// Declare Namespace
namespace Sakura;
// Include components
require_once str_replace(basename(__DIR__), '', dirname(__FILE__)) . '_sakura/sakura.php';
2015-06-29 00:36:37 +00:00
// Info pages
if (isset($_GET['p'])) {
// Set default variables
$renderData['page'] = [
'content' => Main::mdParse("# Unable to load the requested info page.\r\n\r\nCheck the URL and try again."),
];
// Set page id
$pageId = isset($_GET['p']) ? strtolower($_GET['p']) : '';
// Get info page data from the database
if ($ipData = Main::loadInfoPage($pageId)) {
// Assign new proper variable
$renderData['page'] = [
'id' => $pageId,
'title' => $ipData['page_title'],
'content' => Main::mdParse($ipData['page_content']),
];
}
// Print page contents
print Templates::render('main/infopage.tpl', $renderData);
exit;
}
2015-06-27 11:03:11 +00:00
// Are we in forum mode?
$forumMode = isset($_GET['forum']) ? ($_GET['forum'] == true) : false;
2015-06-27 11:03:11 +00:00
$renderData['news'] = ($forumMode ? null : (new News(Configuration::getConfig('site_news_category'))));
$renderData['newsCount'] = Configuration::getConfig('front_page_news_posts');
2015-06-27 19:29:37 +00:00
2015-04-01 17:05:55 +00:00
$renderData['page'] = [
'friend_req' => Users::getPendingFriends(),
2015-06-27 19:29:37 +00:00
];
$renderData['board'] = [
'forums' => ($forumMode ? Forum::getForumList() : null),
2015-06-29 00:36:37 +00:00
'viewforum' => false,
'viewtopic' => false,
2015-04-01 17:05:55 +00:00
];
2015-06-27 19:29:37 +00:00
2015-04-02 14:03:58 +00:00
$renderData['stats'] = [
'userCount' => Database::count('users', ['password_algo' => ['nologin', '!='], 'rank_main' => ['1', '!=']])[0],
'newestUser' => ($_INDEX_NEWEST_USER = new User(Users::getNewestUserId())),
2015-09-14 21:41:43 +00:00
'lastRegDate' => ($_INDEX_LAST_REGDATE = date_diff(
date_create(
date(
'Y-m-d',
$_INDEX_NEWEST_USER->data['user_registered']
2015-09-14 21:41:43 +00:00
)
),
date_create(
date('Y-m-d')
)
)->format('%a')) . ' day' . ($_INDEX_LAST_REGDATE == 1 ? '' : 's'),
'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
// Print page contents
print Templates::render(($forumMode ? 'forum' : 'main') . '/index.tpl', $renderData);