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/main/index.php

27 lines
1,019 B
PHP

<?php
/*
* Sakura Main Index
*/
// Declare Namespace
namespace Sakura;
// Include components
require_once str_replace(basename(__DIR__), '', dirname(__FILE__)) .'_sakura/sakura.php';
// Add page specific things
$renderData['newsPosts'] = Main::getNewsPosts(3);
$renderData['page'] = [
'title' => Configuration::getConfig('sitename'),
'articleCount' => count($renderData['newsPosts'])
];
$renderData['stats'] = [
'userCount' => ($userCount = count($users = Users::getAllUsers(false))) .' user'. ($userCount == 1 ? '' : 's'),
'newestUser' => max($users),
'lastRegDate' => ($lastRegDate = date_diff(date_create(date('Y-m-d', max($users)['regdate'])), date_create(date('Y-m-d')))->format('%a')) .' day'. ($lastRegDate == 1 ? '' : 's'),
'chatOnline' => ($chatOnline = count(SockChat::getOnlineUsers())) .' user'. ($chatOnline == 1 ? '' : 's'),
'onlineUsers' => Users::checkAllOnline()
];
// Print page contents
print Templates::render('main/index.tpl', $renderData);