r20160204

This commit is contained in:
Pachira 2016-02-04 21:56:40 +01:00
parent 38ddeb2a52
commit 7bf64954ec
23 changed files with 537 additions and 728 deletions

View file

@ -1,65 +0,0 @@
<?php
/**
* Holds the forum pages controllers.
*
* @package Sakura
*/
namespace Sakura\Controllers;
use Sakura\Config;
use Sakura\Database;
use Sakura\Forum as ForumData;
use Sakura\Perms\Forum as ForumPerms;
use Sakura\Template;
use Sakura\User;
use Sakura\Users;
use Sakura\Utils;
/**
* Forum page controllers.
*
* @package Sakura
* @author Julian van de Groep <me@flash.moe>
*/
class Forum
{
/**
* Serves the forum index.
*
* @return mixed HTML for the forum index.
*/
public static function index()
{
// Get the global renderData
global $renderData;
// Initialise templating engine
$template = new Template();
// Merge index specific stuff with the global render data
$renderData = array_merge(
$renderData,
[
'forum' => (new ForumData\Forum()),
'stats' => [
'userCount' => Database::count('users', ['password_algo' => ['nologin', '!='], 'rank_main' => ['1', '!=']])[0],
'newestUser' => User::construct(Users::getNewestUserId()),
'lastRegData' => date_diff(
date_create(date('Y-m-d', User::construct(Users::getNewestUserId())->registered)),
date_create(date('Y-m-d'))
)->format('%a'),
'topicCount' => Database::count('topics')[0],
'postCount' => Database::count('posts')[0],
'onlineUsers' => Users::checkAllOnline(),
],
]
);
// Set parse variables
$template->setVariables($renderData);
// Return the compiled page
return $template->render('forum/index');
}
}

View file

@ -0,0 +1,134 @@
<?php
/**
* Holds the forum pages controllers.
*
* @package Sakura
*/
namespace Sakura\Controllers;
use Sakura\Config;
use Sakura\Database;
use Sakura\Forum;
use Sakura\Perms\Forum as ForumPerms;
use Sakura\Template;
use Sakura\User;
use Sakura\Users;
use Sakura\Utils;
/**
* Forum page controllers.
*
* @package Sakura
* @author Julian van de Groep <me@flash.moe>
*/
class Forums
{
/**
* Serves the forum index.
*
* @return mixed HTML for the forum index.
*/
public static function index()
{
// Merge index specific stuff with the global render data
Template::vars([
'forum' => (new Forum\Forum()),
'stats' => [
'userCount' => Database::count('users', ['password_algo' => ['nologin', '!='], 'rank_main' => ['1', '!=']])[0],
'newestUser' => User::construct(Users::getNewestUserId()),
'lastRegData' => date_diff(
date_create(date('Y-m-d', User::construct(Users::getNewestUserId())->registered)),
date_create(date('Y-m-d'))
)->format('%a'),
'topicCount' => Database::count('topics')[0],
'postCount' => Database::count('posts')[0],
'onlineUsers' => Users::checkAllOnline(),
],
]);
// Return the compiled page
return Template::render('forum/index');
}
public static function forum($id = 0)
{
global $currentUser;
// Get the forum
$forum = new Forum\Forum($id);
// Redirect forum id 0 to the main page
if ($forum->id === 0) {
header('Location: ' . (new \Sakura\Urls)->format('FORUM_INDEX'));
exit;
}
// Check if the forum exists
if ($forum->id < 0) {
// Set render data
Template::vars([
'page' => [
'message' => 'The forum you tried to access does not exist.',
],
]);
// Print page contents
return Template::render('global/information');
}
// Check if the user has access to the forum
if (!$forum->permission(ForumPerms::VIEW, $currentUser->id)) {
// Set render data
Template::vars([
'page' => [
'message' => 'You do not have access to this forum.',
],
]);
// Print page contents
return Template::render('global/information');
}
// Check if the forum isn't a link
if ($forum->type === 2) {
// Set render data
Template::vars([
'page' => [
'message' => 'The forum you tried to access is a link. You\'re being redirected.',
'redirect' => $forum->link,
]
]);
// Print page contents
return Template::render('global/information');
}
// 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
Template::vars([
'page' => [
'message' => 'All threads have been marked as read.',
'redirect' => (new \Sakura\Urls)->format('FORUM_SUB', [$forum->id]),
]
]);
// Print page contents
return Template::render('global/information');
}
$renderData['forum'] = $forum;
// Set parse variables
Template::vars([
'forum' => $forum,
]);
// Print page contents
return Template::render('forum/viewforum');
}
}

View file

@ -30,37 +30,25 @@ class Meta
*/
public static function index()
{
// Get the global renderData
global $renderData;
// Initialise templating engine
$template = new Template();
// Merge index specific stuff with the global render data
$renderData = array_merge(
$renderData,
[
'news' => new News(Config::get('site_news_category')),
'newsCount' => Config::get('front_page_news_posts'),
'stats' => [
'userCount' => Database::count('users', ['password_algo' => ['nologin', '!='], 'rank_main' => ['1', '!=']])[0],
'newestUser' => User::construct(Users::getNewestUserId()),
'lastRegDate' => date_diff(
date_create(date('Y-m-d', User::construct(Users::getNewestUserId())->registered)),
date_create(date('Y-m-d'))
)->format('%a'),
'topicCount' => Database::count('topics')[0],
'postCount' => Database::count('posts')[0],
'onlineUsers' => Users::checkAllOnline(),
],
]
);
// Set parse variables
$template->setVariables($renderData);
Template::vars([
'news' => new News(Config::get('site_news_category')),
'newsCount' => Config::get('front_page_news_posts'),
'stats' => [
'userCount' => Database::count('users', ['password_algo' => ['nologin', '!='], 'rank_main' => ['1', '!=']])[0],
'newestUser' => User::construct(Users::getNewestUserId()),
'lastRegDate' => date_diff(
date_create(date('Y-m-d', User::construct(Users::getNewestUserId())->registered)),
date_create(date('Y-m-d'))
)->format('%a'),
'topicCount' => Database::count('topics')[0],
'postCount' => Database::count('posts')[0],
'onlineUsers' => Users::checkAllOnline(),
],
]);
// Return the compiled page
return $template->render('main/index');
return Template::render('main/index');
}
/**
@ -70,9 +58,6 @@ class Meta
*/
public static function news()
{
// Get the global renderData
global $renderData;
// Get arguments
$args = func_get_args();
$category = isset($args[0]) && !is_numeric($args[0]) ? $args[0] : Config::get('site_news_category');
@ -83,22 +68,16 @@ class Meta
// Create news object
$news = new News($category);
// Merge the data for this page with the global
$renderData = array_merge($renderData, [
// Set parse variables
Template::vars([
'news' => $news,
'postsPerPage' => Config::get('news_posts_per_page'),
'viewPost' => $post != 0,
'postExists' => $news->postExists($post),
]);
// Initialise templating engine
$template = new Template();
// Set parse variables
$template->setVariables($renderData);
// Print page contents
return $template->render('main/news');
return Template::render('main/news');
}
/**
@ -108,23 +87,16 @@ class Meta
*/
public static function faq()
{
// Get the global renderData
global $renderData;
// Add page specific things
$renderData['page'] = [
'title' => 'Frequently Asked Questions',
'questions' => Utils::getFaqData(),
];
// Initialise templating engine
$template = new Template();
// Set parse variables
$template->setVariables($renderData);
Template::vars([
'page' => [
'title' => 'Frequently Asked Questions',
'questions' => Utils::getFaqData(),
],
]);
// Print page contents
return $template->render('main/faq');
return Template::render('main/faq');
}
/**
@ -136,12 +108,6 @@ class Meta
*/
public static function infoPage($id = null)
{
// Get the global renderData
global $renderData;
// Initialise templating engine
$template = new Template();
// Set default variables
$renderData['page'] = [
'content' => '<h1>Unable to load the requested info page.</h1><p>Check the URL and try again.</p>',
@ -161,10 +127,10 @@ class Meta
}
// Set parse variables
$template->setVariables($renderData);
Template::vars($renderData);
// Return the compiled page
return $template->render('main/infopage');
return Template::render('main/infopage');
}
/**
@ -174,21 +140,14 @@ class Meta
*/
public static function search()
{
// Get the global renderData
global $renderData;
// Add page specific things
$renderData['page'] = [
'title' => 'Search',
];
// Initialise templating engine
$template = new Template();
// Set parse variables
$template->setVariables($renderData);
Template::vars([
'page' => [
'title' => 'Search',
],
]);
// Print page contents
return $template->render('main/search');
return Template::render('main/search');
}
}

View file

@ -0,0 +1,110 @@
<?php
/**
* Holds the user page controllers.
*
* @package Sakura
*/
namespace Sakura\Controllers;
use Sakura\Config;
use Sakura\Database;
use Sakura\Template;
use Sakura\User as UserContext;
use Sakura\Utils;
/**
* Everything that is just for serving user data.
*
* @package Sakura
* @author Julian van de Groep <me@flash.moe>
*/
class User
{
/**
* Display the profile of a user
*
* @param mixed $id The user ID.
*
* @return bool|string The profile page.
*/
public static function profile($id = 0)
{
global $currentUser;
// Get the user's context
$profile = UserContext::construct($id);
// If the user id is zero check if there was a namechange
if ($profile->id == 0) {
// Fetch from username_history
$check = Database::fetch('username_history', false, ['username_old_clean' => [Utils::cleanString(isset($_GET['u']) ? $_GET['u'] : 0, true, true), '=']]);
// Redirect if so
if ($check) {
Template::vars([
'message' => 'The user this profile belongs to changed their username, you are being redirected.',
'redirect' => (new \Sakura\Urls)->format('USER_PROFILE', [$check['user_id']]),
]);
// Print page contents
return Template::render('global/information');
}
}
// Check if we're trying to restrict
if (isset($_GET['restrict']) && $_GET['restrict'] == session_id() && $currentUser->permission(\Sakura\Perms\Manage::CAN_RESTRICT_USERS, \Sakura\Perms::MANAGE)) {
// Check restricted status
$restricted = $profile->permission(\Sakura\Perms\Site::RESTRICTED);
if ($restricted) {
$profile->removeRanks([Config::get('restricted_rank_id')]);
$profile->addRanks([2]);
} else {
$profile->addRanks([Config::get('restricted_rank_id')]);
$profile->removeRanks(array_keys($profile->ranks));
}
Template::vars([
'page' => [
'message' => 'Toggled the restricted status of the user.',
'redirect' => (new \Sakura\Urls)->format('USER_PROFILE', [$profile->id]),
],
]);
// Print page contents
return Template::render('global/information');
}
// Set parse variables
Template::vars([
'profile' => $profile,
]);
// Print page contents
return Template::render('main/profile');
}
public static function members($rank = 0)
{
global $currentUser;
// Check permission
if (!$currentUser->permission(\Sakura\Perms\Site::VIEW_MEMBERLIST)) {
return Template::render('global/restricted');
}
// Set parse variables
Template::vars([
'memberlist' => [
'ranks' => ($_MEMBERLIST_RANKS = \Sakura\Users::getAllRanks()),
'active' => ($_MEMBERLIST_ACTIVE = (array_key_exists($rank, $_MEMBERLIST_RANKS) ? $rank : 0)),
'users' => ($_MEMBERLIST_ACTIVE ? \Sakura\Users::getUsersInRank($_MEMBERLIST_ACTIVE) : \Sakura\Users::getAllUsers(false)),
'membersPerPage' => Config::get('members_per_page'),
]
]);
// Render the template
return Template::render('main/memberlist');
}
}

View file

@ -7,8 +7,10 @@
namespace Sakura;
use Phroute\Phroute\RouteCollector;
use Phroute\Phroute\Dispatcher;
use Phroute\Phroute\Exception\HttpRouteNotFoundException;
use Phroute\Phroute\Exception\HttpMethodNotAllowedException;
use Phroute\Phroute\RouteCollector;
/**
* Sakura Wrapper for Phroute.
@ -108,6 +110,19 @@ class Router
return parse_url($url, PHP_URL_PATH);
}
/**
* Generate the URI of a route using names.
*
* @param string $name The identifier of the route.
* @param string|array $args The route arguments.
*
* @return string The generated URI.
*/
public static function url($name, $args = null)
{
return self::$router->route($name, $args);
}
/**
* Handle requests.
*
@ -127,6 +142,13 @@ class Router
$url = self::parseUrl($url);
// Handle the request
return self::$dispatcher->dispatch($method, $url);
try {
try {
return self::$dispatcher->dispatch($method, $url);
} catch (HttpMethodNotAllowedException $e) {}
} catch (HttpRouteNotFoundException $e) {}
// Default to the not found page
return Template::render('global/notfound');
}
}

View file

@ -24,51 +24,40 @@ class Template
*
* @var array
*/
private $vars = [];
private static $vars = [];
/**
* The templating engine.
*
* @var Twig_Environment
*/
private $template;
private static $template;
/**
* The template name.
*
* @var string
*/
private $templateName;
private static $templateName;
/**
* The template options.
*
* @var array
*/
private $templateOptions;
private static $templateOptions;
/**
* The file extension used by template files
*
* @var string
*/
protected $templateFileExtension = ".twig";
/**
* Constructor.
*/
public function __construct()
{
// Set template to default
$this->setTemplate(Config::get('site_style'));
}
const FILE_EXT = '.twig';
/**
* Set the template name.
*
* @param string $name The name of the template directory.
*/
public function setTemplate($name)
public static function set($name)
{
// Assign config path to a variable so we don't have to type it out twice
$confPath = ROOT . 'templates/' . $name . '/template.ini';
@ -79,22 +68,22 @@ class Template
}
// Parse and store the configuration
$this->templateOptions = parse_ini_file($confPath, true);
self::$templateOptions = parse_ini_file($confPath, true);
// Set variables
$this->templateName = $name;
self::$templateName = $name;
// Reinitialise
$this->initTemplate();
self::init();
}
/**
* Initialise the templating engine.
*/
public function initTemplate()
public static function init()
{
// Initialise Twig Filesystem Loader
$twigLoader = new Twig_Loader_Filesystem(ROOT . 'templates/' . $this->templateName);
$twigLoader = new Twig_Loader_Filesystem(ROOT . 'templates/' . self::$templateName);
// Environment variable
$twigEnv = [];
@ -105,10 +94,10 @@ class Template
}
// And now actually initialise the templating engine
$this->template = new Twig_Environment($twigLoader, $twigEnv);
self::$template = new Twig_Environment($twigLoader, $twigEnv);
// Load String template loader
$this->template->addExtension(new Twig_Extension_StringLoader());
self::$template->addExtension(new Twig_Extension_StringLoader());
}
/**
@ -116,9 +105,9 @@ class Template
*
* @param array $vars The new variables.
*/
public function setVariables($vars)
public static function vars($vars)
{
$this->vars = array_merge($this->vars, $vars);
self::$vars = array_merge(self::$vars, $vars);
}
/**
@ -128,10 +117,10 @@ class Template
*
* @return bool|string An error or the HTML.
*/
public function render($file)
public static function render($file)
{
try {
return $this->template->render($file . $this->templateFileExtension, $this->vars);
return self::$template->render($file . self::FILE_EXT, self::$vars);
} catch (\Exception $e) {
return trigger_error($e->getMessage(), E_USER_ERROR);
}

View file

@ -1,25 +0,0 @@
<?php
/*
* Flashii.net Main Index
*/
// Declare Namespace
namespace Sakura;
// Include components
require_once str_replace(basename(__DIR__), '', dirname(__FILE__)) . 'sakura.php';
// Set 404 header
header('HTTP/1.0 404 Not Found');
// Initialise templating engine
$template = new Template();
// Change templating engine
$template->setTemplate($templateName);
// Set parse variables
$template->setVariables($renderData);
// Print page contents
echo $template->render('global/notfound');

View file

@ -9,12 +9,6 @@ namespace Sakura;
// Include components
require_once str_replace(basename(__DIR__), '', dirname(__FILE__)) . 'sakura.php';
// Initialise templating engine
$template = new Template();
// Change templating engine
$template->setTemplate($templateName);
// Page actions
if (isset($_REQUEST['mode'])) {
// Continue
@ -108,7 +102,6 @@ if (isset($_REQUEST['mode'])) {
// Add page specific things
$renderData['page'] = [
'redirect' => (
$passforget[0] ?
$urls->format('SITE_LOGIN') :
@ -116,7 +109,6 @@ if (isset($_REQUEST['mode'])) {
),
'message' => $messages[$passforget[1]],
'success' => $passforget[0],
];
break;
@ -289,8 +281,8 @@ if (isset($_REQUEST['mode'])) {
$renderData['page']['success'] . '|' .
$renderData['page']['redirect'];
} else {
$template->setVariables($renderData);
echo $template->render('global/information');
Template::vars($renderData);
echo Template::render('global/information');
}
exit;
}
@ -317,8 +309,8 @@ if (Users::checkLogin()) {
];
$template->setVariables($renderData);
echo $template->render('global/information');
Template::vars($renderData);
echo Template::render('global/information');
exit;
}
@ -341,11 +333,11 @@ if (isset($_REQUEST['pw']) && $_REQUEST['pw']) {
$renderData['auth']['forgotKey'] = $_REQUEST['key'];
}
$template->setVariables($renderData);
echo $template->render('main/forgotpassword');
Template::vars($renderData);
echo Template::render('main/forgotpassword');
exit;
}
// Print page contents
$template->setVariables($renderData);
echo $template->render('main/authenticate');
Template::vars($renderData);
echo Template::render('main/authenticate');

View file

@ -15,19 +15,13 @@ define('SAKURA_MANAGE', true);
// Include components
require_once str_replace(basename(__DIR__), '', dirname(__FILE__)) . 'sakura.php';
// Initialise templating engine
$template = new Template();
// Change templating engine
$template->setTemplate($templateName);
// Make sure user has the permissions to view this
if (!$currentUser->permission(Manage::USE_MANAGE, Perms::MANAGE)) {
// Set parse variables
$template->setVariables($renderData);
Template::vars($renderData);
// Print page contents
echo $template->render('global/restricted');
echo Template::render('global/restricted');
exit;
}
@ -268,10 +262,10 @@ if (!$category
header('HTTP/1.0 404 Not Found');
// Set parse variables
$template->setVariables($renderData);
Template::vars($renderData);
// Print page contents
echo $template->render('global/notfound');
echo Template::render('global/notfound');
exit;
}
@ -313,7 +307,7 @@ switch ($category . '.' . $mode) {
}
// Set parse variables
$template->setVariables($renderData);
Template::vars($renderData);
// Print page contents
echo $template->render('main/settings');
echo Template::render('main/settings');

View file

@ -1,43 +0,0 @@
<?php
/*
* Sakura Memberlist
*/
// Declare Namespace
namespace Sakura;
// Include components
require_once str_replace(basename(__DIR__), '', dirname(__FILE__)) . 'sakura.php';
// Initialise templating engine
$template = new Template();
// Change templating engine
$template->setTemplate($templateName);
// CHeck if the user is logged in
if (Users::checkLogin()) {
// Add page specific things
$renderData['memberlist'] = [
'ranks' => ($_MEMBERLIST_RANKS = Users::getAllRanks()),
'active' => ($_MEMBERLIST_ACTIVE = (
isset($_GET['rank'])
&& $_GET['rank']
&& array_key_exists($_GET['rank'], $_MEMBERLIST_RANKS) ? $_GET['rank'] : 0
)),
'users' => ($_MEMBERLIST_ACTIVE ? Users::getUsersInRank($_MEMBERLIST_ACTIVE) : Users::getAllUsers(false)),
'membersPerPage' => Config::get('members_per_page'),
];
// Set parse variables
$template->setVariables($renderData);
// Print page contents
echo $template->render('main/memberlist');
} else {
// Set parse variables
$template->setVariables($renderData);
// Print page contents
echo $template->render('global/restricted');
}

View file

@ -12,12 +12,6 @@ use Sakura\Perms\Forum as ForumPerms;
// Include components
require_once str_replace(basename(__DIR__), '', dirname(__FILE__)) . 'sakura.php';
// Initialise templating engine
$template = new Template();
// Change templating engine
$template->setTemplate($templateName);
// Set location
$topicId = isset($_GET['t']) ?
$_GET['t'] :
@ -48,10 +42,10 @@ if (!$forum->permission(ForumPerms::VIEW, $currentUser->id) || !$forum->permissi
];
// Set parse variables
$template->setVariables($renderData);
Template::vars($renderData);
// Print page contents
echo $template->render('global/information');
echo Template::render('global/information');
exit;
}
@ -64,10 +58,10 @@ if (!isset($thread) && !$forum->permission(ForumPerms::CREATE_THREADS, $currentU
];
// Set parse variables
$template->setVariables($renderData);
Template::vars($renderData);
// Print page contents
echo $template->render('global/information');
echo Template::render('global/information');
exit;
}
@ -92,10 +86,10 @@ if ($mode != 'f') {
];
// Set parse variables
$template->setVariables($renderData);
Template::vars($renderData);
// Print page contents
echo $template->render('global/information');
echo Template::render('global/information');
exit;
}
@ -108,10 +102,10 @@ if ($mode != 'f') {
];
// Set parse variables
$template->setVariables($renderData);
Template::vars($renderData);
// Print page contents
echo $template->render('global/information');
echo Template::render('global/information');
exit;
}
@ -134,10 +128,10 @@ if ($mode != 'f') {
];
// Set parse variables
$template->setVariables($renderData);
Template::vars($renderData);
// Print page contents
echo $template->render('global/information');
echo Template::render('global/information');
exit;
}
// Checks
@ -149,10 +143,10 @@ if ($mode != 'f') {
];
// Set parse variables
$template->setVariables($renderData);
Template::vars($renderData);
// Print page contents
echo $template->render('global/information');
echo Template::render('global/information');
exit;
}
@ -176,10 +170,10 @@ if ($mode != 'f') {
];
// Set parse variables
$template->setVariables($renderData);
Template::vars($renderData);
// Print page contents
echo $template->render('global/information');
echo Template::render('global/information');
exit;
}
@ -192,10 +186,10 @@ if ($mode != 'f') {
];
// Set parse variables
$template->setVariables($renderData);
Template::vars($renderData);
// Print page contents
echo $template->render('global/information');
echo Template::render('global/information');
exit;
}
@ -225,10 +219,10 @@ if ($mode != 'f') {
];
// Set parse variables
$template->setVariables($renderData);
Template::vars($renderData);
// Print page contents
echo $template->render('global/information');
echo Template::render('global/information');
exit;
// Return to previous page
} else {
@ -246,10 +240,10 @@ if ($mode != 'f') {
]);
// Set parse variables
$template->setVariables($renderData);
Template::vars($renderData);
// Print page contents
echo $template->render('global/confirm');
echo Template::render('global/confirm');
exit;
}
@ -296,10 +290,10 @@ if (isset($_POST['post'])) {
$renderData['page']['redirect'];
} else {
// Set parse variables
$template->setVariables($renderData);
Template::vars($renderData);
// Print page contents
echo $template->render('global/information');
echo Template::render('global/information');
}
exit;
}
@ -310,7 +304,7 @@ $renderData = array_merge($renderData, [
]);
// Set parse variables
$template->setVariables($renderData);
Template::vars($renderData);
// Print page contents
echo $template->render('forum/posting');
echo Template::render('forum/posting');

View file

@ -1,86 +0,0 @@
<?php
/*
* Sakura User Profiles
*/
// Declare Namespace
namespace Sakura;
// Include components
require_once str_replace(basename(__DIR__), '', dirname(__FILE__)) . 'sakura.php';
// Initialise templating engine
$template = new Template();
// Change templating engine
$template->setTemplate($templateName);
// Get the user's context
$profile = User::construct(isset($_GET['u']) ? $_GET['u'] : 0);
// Views array
$views = [
'index',
'friends',
//'threads',
//'posts',
'comments',
//'groups',
];
// Assign the object to a renderData variable
$renderData['profile'] = $profile;
$renderData['profileView'] = isset($_GET['view']) && in_array($_GET['view'], $views) ? $_GET['view'] : $views[0];
// If the user id is zero check if there was a namechange
if ($profile->id == 0) {
// Fetch from username_history
$check = Database::fetch('username_history', false, ['username_old_clean' => [Utils::cleanString(isset($_GET['u']) ? $_GET['u'] : 0, true, true), '=']]);
// Redirect if so
if ($check) {
$renderData['page'] = [
'message' => 'The user this profile belongs to changed their username, you are being redirected.',
'redirect' => $urls->format('USER_PROFILE', [$check['user_id']]),
];
// Set parse variables
$template->setVariables($renderData);
// Print page contents
echo $template->render('global/information');
exit;
}
}
// If the user id is zero check if there was a namechange
if (isset($_GET['restrict']) && $_GET['restrict'] == session_id() && $currentUser->permission(Perms\Manage::CAN_RESTRICT_USERS, Perms::MANAGE)) {
// Check restricted status
$restricted = $profile->permission(Perms\Site::RESTRICTED);
if ($restricted) {
$profile->removeRanks([Config::get('restricted_rank_id')]);
$profile->addRanks([2]);
} else {
$profile->addRanks([Config::get('restricted_rank_id')]);
$profile->removeRanks(array_keys($profile->ranks));
}
$renderData['page'] = [
'message' => 'Toggled the restricted status of the user.',
'redirect' => $urls->format('USER_PROFILE', [$profile->id]),
];
// Set parse variables
$template->setVariables($renderData);
// Print page contents
echo $template->render('global/information');
exit;
}
// Set parse variables
$template->setVariables($renderData);
// Print page contents
echo $template->render('main/profile');

View file

@ -1,22 +0,0 @@
<?php
/*
* Sakura Reporting
*/
// Declare Namespace
namespace Sakura;
// Include components
require_once str_replace(basename(__DIR__), '', dirname(__FILE__)) . 'sakura.php';
// Initialise templating engine
$template = new Template();
// Change templating engine
$template->setTemplate($templateName);
// Set parse variables
$template->setVariables($renderData);
// Print page contents
echo $template->render('main/report');

View file

@ -16,14 +16,6 @@ if (isset($_REQUEST['request-notifications']) && $_REQUEST['request-notification
// Include components
require_once str_replace(basename(__DIR__), '', dirname(__FILE__)) . 'sakura.php';
if (!defined('SAKURA_NO_TPL')) {
// Initialise templating engine
$template = new Template();
// Change templating engine
$template->setTemplate($templateName);
}
// Notifications
if (isset($_REQUEST['request-notifications']) && $_REQUEST['request-notifications']) {
// Create the notification container array
@ -275,10 +267,10 @@ if (isset($_REQUEST['request-notifications']) && $_REQUEST['request-notification
$renderData['page']['redirect'];
} else {
// If not allowed print the restricted page
$template->setVariables($renderData);
Template::vars($renderData);
// Print page contents
echo $template->render('global/information');
echo Template::render('global/information');
}
exit;
} elseif (isset($_REQUEST['friend-action']) && $_REQUEST['friend-action'] && Users::checkLogin()) {
@ -404,10 +396,10 @@ if (isset($_REQUEST['request-notifications']) && $_REQUEST['request-notification
$renderData['page']['redirect'];
} else {
// If not allowed print the restricted page
$template->setVariables($renderData);
Template::vars($renderData);
// Print page contents
echo $template->render('global/information');
echo Template::render('global/information');
}
exit;
} elseif (isset($_POST['submit']) && isset($_POST['submit'])) {
@ -1158,10 +1150,10 @@ if (isset($_REQUEST['request-notifications']) && $_REQUEST['request-notification
$renderData['page']['redirect'];
} else {
// If not allowed print the restricted page
$template->setVariables($renderData);
Template::vars($renderData);
// Print page contents
echo $template->render('global/information');
echo Template::render('global/information');
}
exit;
}
@ -1429,10 +1421,10 @@ if (Users::checkLogin()) {
header('HTTP/1.0 404 Not Found');
// Set parse variables
$template->setVariables($renderData);
Template::vars($renderData);
// Print page contents
echo $template->render('global/notfound');
echo Template::render('global/notfound');
exit;
}
@ -1518,14 +1510,14 @@ if (Users::checkLogin()) {
}
// Set parse variables
$template->setVariables($renderData);
Template::vars($renderData);
// Print page contents
echo $template->render('main/settings');
echo Template::render('main/settings');
} else {
// If not allowed print the restricted page
$template->setVariables($renderData);
Template::vars($renderData);
// Print page contents
echo $template->render('global/restricted');
echo Template::render('global/restricted');
}

View file

@ -11,12 +11,6 @@ use Sakura\Perms\Site;
// Include components
require_once str_replace(basename(__DIR__), '', dirname(__FILE__)) . 'sakura.php';
// Initialise templating engine
$template = new Template();
// Change templating engine
$template->setTemplate($templateName);
// Switch between modes (we only allow this to be used by logged in user)
if (isset($_REQUEST['mode'])
&& Users::checkLogin()
@ -126,10 +120,10 @@ if (isset($_REQUEST['mode'])
], $renderData);
// Set parse variables
$template->setVariables($renderData);
Template::vars($renderData);
// Print page contents
echo $template->render('main/premiumcomplete');
echo Template::render('main/premiumcomplete');
break;
default:
@ -147,10 +141,10 @@ if (isset($_GET['tracker'])) {
$renderData['tracker'] = Utils::getPremiumTrackerData();
// Set parse variables
$template->setVariables($renderData);
Template::vars($renderData);
// Print page contents
echo $template->render('main/supporttracker');
echo Template::render('main/supporttracker');
exit;
}
@ -165,7 +159,7 @@ $renderData['page'] = [
];
// Set parse variables
$template->setVariables($renderData);
Template::vars($renderData);
// Print page contents
echo $template->render('main/support');
echo Template::render('main/support');

View file

@ -1,104 +0,0 @@
<?php
/*
* Sakura Forum List Viewer
*/
// Declare Namespace
namespace Sakura;
use Sakura\Perms\Forum as ForumPerms;
// Include components
require_once str_replace(basename(__DIR__), '', dirname(__FILE__)) . 'sakura.php';
// Get the forum's data
$forum = new Forum\Forum(isset($_GET['f']) ? $_GET['f'] : -1);
// Initialise templating engine
$template = new Template();
// Change templating engine
$template->setTemplate($templateName);
// Check if the forum exists
if ($forum->id < 0) {
// Set render data
$renderData['page'] = [
'title' => 'Information',
'message' => 'The forum you tried to access does not exist.',
];
// Set parse variables
$template->setVariables($renderData);
// Print page contents
echo $template->render('global/information');
exit;
}
// Check if the user has access to the forum
if (!$forum->permission(ForumPerms::VIEW, $currentUser->id)) {
// Set render data
$renderData['page'] = [
'title' => 'Information',
'message' => 'You do not have access to this forum.',
];
// Set parse variables
$template->setVariables($renderData);
// Print page contents
echo $template->render('global/information');
exit;
}
// Check if the forum isn't a link
if ($forum->type === 2) {
// Set render data
$renderData['page'] = [
'title' => 'Information',
'message' => 'The forum you tried to access is a link. You\'re being redirected.',
'redirect' => $forum->link,
];
// Set parse variables
$template->setVariables($renderData);
// Print page contents
echo $template->render('global/information');
exit;
}
// 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');
exit;
}
// Redirect forum id 0 to the main page
if ($forum->id === 0) {
header('Location: ' . $urls->format('FORUM_INDEX'));
exit;
}
$renderData['forum'] = $forum;
// Set parse variables
$template->setVariables($renderData);
// Print page contents
echo $template->render('forum/viewforum');

View file

@ -21,12 +21,6 @@ $thread = new Forum\Thread(
// And attempt to get the forum
$forum = new Forum\Forum($thread->forum);
// Initialise templating engine
$template = new Template();
// Change templating engine
$template->setTemplate($templateName);
// Check if the forum exists
if (!$thread) {
// Set render data
@ -36,10 +30,10 @@ if (!$thread) {
];
// Set parse variables
$template->setVariables($renderData);
Template::vars($renderData);
// Print page contents
echo $template->render('global/information');
echo Template::render('global/information');
exit;
}
@ -52,10 +46,10 @@ if (!$forum->permission(ForumPerms::VIEW, $currentUser->id)) {
];
// Set parse variables
$template->setVariables($renderData);
Template::vars($renderData);
// Print page contents
echo $template->render('global/information');
echo Template::render('global/information');
exit;
}
@ -78,10 +72,10 @@ if (isset($_GET['sticky']) && $_GET['sticky'] == session_id() && $forum->permiss
];
// Set parse variables
$template->setVariables($renderData);
Template::vars($renderData);
// Print page contents
echo $template->render('global/information');
echo Template::render('global/information');
exit;
}
@ -103,10 +97,10 @@ if (isset($_GET['announce']) && $_GET['announce'] == session_id() && $forum->per
];
// Set parse variables
$template->setVariables($renderData);
Template::vars($renderData);
// Print page contents
echo $template->render('global/information');
echo Template::render('global/information');
exit;
}
@ -128,10 +122,10 @@ if (isset($_GET['lock']) && $_GET['lock'] == session_id() && $forum->permission(
];
// Set parse variables
$template->setVariables($renderData);
Template::vars($renderData);
// Print page contents
echo $template->render('global/information');
echo Template::render('global/information');
exit;
}
@ -155,10 +149,10 @@ if (isset($_GET['trash']) && $_GET['trash'] == session_id() && $forum->permissio
}
// Set parse variables
$template->setVariables($renderData);
Template::vars($renderData);
// Print page contents
echo $template->render('global/information');
echo Template::render('global/information');
exit;
}
@ -183,10 +177,10 @@ if (isset($_GET['restore']) && $_GET['restore'] == session_id() && $forum->permi
}
// Set parse variables
$template->setVariables($renderData);
Template::vars($renderData);
// Print page contents
echo $template->render('global/information');
echo Template::render('global/information');
exit;
}
@ -210,10 +204,10 @@ if (isset($_GET['prune']) && $_GET['prune'] == session_id() && $forum->permissio
}
// Set parse variables
$template->setVariables($renderData);
Template::vars($renderData);
// Print page contents
echo $template->render('global/information');
echo Template::render('global/information');
exit;
}
@ -230,7 +224,7 @@ $renderData = array_merge($renderData, [
]);
// Set parse variables
$template->setVariables($renderData);
Template::vars($renderData);
// Print page contents
echo $template->render('forum/viewtopic');
echo Template::render('forum/viewtopic');

View file

@ -18,7 +18,15 @@ Router::get('/news/{category}', 'Sakura\Controllers\Meta@news', 'news.category')
Router::get('/news/{category}/{id}', 'Sakura\Controllers\Meta@news', 'news.post');
// Forum
Router::get('/forum', 'Sakura\Controllers\Forum@index', 'forum.index');
Router::get('/forum', 'Sakura\Controllers\Forums@index', 'forums.index');
Router::get('/forum/{id}', 'Sakura\Controllers\Forums@forum', 'forums.forum');
// Members
Router::get('/members', 'Sakura\Controllers\User@members', 'members.all');
Router::get('/members/{rank}', 'Sakura\Controllers\User@members', 'members.rank');
// User
Router::get('/u/{id}', 'Sakura\Controllers\User@profile', 'user.profile');
// Redirections
Router::any('/index.php', function () {
@ -61,6 +69,51 @@ Router::any('/news.php', function () {
header('Location: /news');
});
Router::any('/profile.php', function () {
// Redirect to the profile
if (isset($_REQUEST['u'])) {
header('Location: /u/' . $_REQUEST['u']);
return;
}
// Redirect to index
header('Location: /');
});
Router::any('/members.php', function () {
// Append sort
$append = isset($_REQUEST['sort']) ? '?sort=' . $_REQUEST['sort'] : '';
// Redirect to the profile
if (isset($_REQUEST['rank'])) {
header('Location: /members/' . $_REQUEST['rank'] . $append);
return;
}
// Redirect to index
header('Location: /members/' . $append);
});
Router::any('/viewforum.php', function () {
// Redirect to the profile
if (isset($_REQUEST['f'])) {
$req = [];
foreach ($_REQUEST as $k => $v) {
if ($k == 'f') {
continue;
}
$req[] = $k . '=' . $v;
}
header('Location: /forum/' . $_REQUEST['f'] . ($req ? '?' . implode('&', $req) : ''));
return;
}
// Redirect to index
header('Location: /forum/');
});
Router::any('/faq.php', function () {
header('Location: /faq');
});

View file

@ -8,7 +8,7 @@
namespace Sakura;
// Define Sakura version
define('SAKURA_VERSION', '20160202');
define('SAKURA_VERSION', '20160204');
define('SAKURA_VLABEL', 'Amethyst');
define('SAKURA_COLOUR', '#9966CC');
@ -59,8 +59,9 @@ require_once ROOT . 'libraries/Users.php';
require_once ROOT . 'libraries/Utils.php';
require_once ROOT . 'libraries/Whois.php';
require_once ROOT . 'libraries/Console/Application.php';
require_once ROOT . 'libraries/Controllers/Forum.php';
require_once ROOT . 'libraries/Controllers/Forums.php';
require_once ROOT . 'libraries/Controllers/Meta.php';
require_once ROOT . 'libraries/Controllers/User.php';
require_once ROOT . 'libraries/Forum/Forum.php';
require_once ROOT . 'libraries/Forum/Post.php';
require_once ROOT . 'libraries/Forum/Thread.php';
@ -140,6 +141,9 @@ $templateName =
'misaki' : Config::get('site_style');
if (!defined('SAKURA_NO_TPL')) {
// Start templating engine
Template::set($templateName);
// Set base page rendering data
$renderData = [
'sakura' => [
@ -202,33 +206,27 @@ if (!defined('SAKURA_NO_TPL')) {
'post' => $_POST,
];
// Add the default render data
Template::vars($renderData);
// Site closing
if (Config::get('site_closed')) {
// Additional render data
$renderData = array_merge($renderData, [
// Set parse variables
Template::vars([
'page' => [
'message' => Config::get('site_closed_reason'),
],
]);
// Initialise templating engine
$template = new Template();
// Change templating engine
$template->setTemplate($templateName);
// Set parse variables
$template->setVariables($renderData);
// Print page contents
echo $template->render('global/information');
echo Template::render('global/information');
exit;
}
// Ban checking
if ($authCheck && !in_array($_SERVER['PHP_SELF'], [$urls->format('AUTH_ACTION', [], false)]) && $ban = Bans::checkBan($currentUser->id)) {
// Additional render data
$renderData = array_merge($renderData, [
Template::vars([
'ban' => [
'reason' => $ban['reason'],
'issued' => $ban['issued'],
@ -237,17 +235,8 @@ if (!defined('SAKURA_NO_TPL')) {
],
]);
// Initialise templating engine
$template = new Template();
// Change templating engine
$template->setTemplate($templateName);
// Set parse variables
$template->setVariables($renderData);
// Print page contents
echo $template->render('main/banned');
echo Template::render('main/banned');
exit;
}
}

View file

@ -3,10 +3,13 @@
* mod_rewrite emulator for php's build in server
*/
// Decode and parse the request uri
$uri = urldecode(parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH));
// Check if the file exist in the public directory and if it does serve it.
if ($uri !== '/' && file_exists(__DIR__ . '/public' . $uri)) {
return false;
}
// Otherwise include the router
require_once __DIR__ . '/public/index.php';

View file

@ -4,8 +4,6 @@
{% block title %}{{ title }}{% endblock %}
{% set forumMarkRead %}{{ urls.format('FORUM_MARK_READ', [forum.id, php.sessionid]) }}{% endset %}
{% block content %}
<div class="content homepage forum">
<div class="content-right content-column">
@ -13,7 +11,6 @@
</div>
<div class="content-left content-column">
{% include 'forum/forum.twig' %}
{% include 'forum/forumBtns.twig' %}
</div>
<div class="clear"></div>
</div>

View file

@ -8,6 +8,55 @@
{% block title %}{% if profileHidden %}User not found!{% else %}Profile of {{ profile.username }}{% endif %}{% endblock %}
{% block js %}
<script type="text/javascript">
window.addEventListener('load', function () {
// Check if location.hash is set
if (location.hash) {
var open = location.hash.slice(2);
// Check if the element exists
if (document.getElementById('profile-mode-' + open)) {
profileMode(open);
return;
}
}
var profileUserpage = document.getElementById('profile-mode-userpage');
// Check if the user page has contents
if (profileUserpage.children[0].innerHTML.trim().length) {
profileMode('userpage');
} else {
profileMode('comments');
}
});
// Switch to a different mode
function profileMode(id) {
// Get other active modes and fetch the new element
var current = document.getElementsByClassName('profile-mode-current'),
newMode = document.getElementById('profile-mode-' + id);
// Check if the new mode exists
if (typeof newMode == 'undefined') {
return;
}
// Check if there's any active
if (current) {
// Hide them all
for (i in current) {
current[i].className = 'hidden';
}
}
// Set the new to active
newMode.className = 'profile-mode-current';
}
</script>
{% endblock %}
{% block content %}
{% if profileHidden %}
<div class="content standalone">
@ -22,133 +71,6 @@
</ul>
</div>
</div>
{% elseif get.old %}
<div class="content profile">
<div class="content-right content-column">
<div style="text-align: center;">
<img src="{{ urls.format('IMAGE_AVATAR', [profile.id]) }}" alt="{{ profile.username }}'s Avatar" class="default-avatar-setting" style="box-shadow: 0 3px 7px #{% if profile.isOnline %}484{% else %}844{% endif %};" /><br />
{% if profile.mainRankId > 1 and profile.checkBan|length < 1 %}
<span style="font-size: .8em;">{{ profile.title }}</span>
<h1 style="color: {{ profile.colour }}; text-shadow: 0 0 7px {% if profile.colour != 'inherit' %}{{ profile.colour }}{% else %}#222{% endif %}; padding: 0 0 2px;" {% if profile.getUsernameHistory %} title="Known as {{ profile.getUsernameHistory[0]['username_old'] }} before {{ profile.getUsernameHistory[0]['change_time']|date(sakura.dateFormat) }}." {% endif %}>{{ profile.username }}</h1>
{% if profile.isPremium[0] %}<img src="{{ sakura.contentPath }}/images/tenshi.png" alt="Tenshi" style="vertical-align: middle;" /> {% endif %}<img src="{{ sakura.contentPath }}/images/flags/{{ profile.country|lower }}.png" alt="{{ profile.country }}" style="vertical-align: middle;" /> <span style="font-size: .8em; line-height: 11px;">{{ profile.country(true) }}</span>
{% if session.checkLogin %}
<div class="user-actions">
{% if user.id == profile.id %}
<a class="fa fa-pencil-square-o" title="Edit your profile" href="{{ urls.format('SETTING_MODE', ['general', 'profile']) }}"></a>
{% else %}
{% if user.isFriends(profile.id) != 0 %}<a class="fa fa-{% if user.isFriends(profile.id) == 2 %}heart{% else %}star{% endif %}" title="You are friends"></a>{% endif %}
<a class="fa fa-user-{% if user.isFriends(profile.id) == 0 %}plus{% else %}times{% endif %}" title="{% if user.isFriends(profile.id) == 0 %}Add {{ profile.username }} as a friend{% else %}Remove friend{% endif %}" href="{% if user.isFriends(profile.id) == 0 %}{{ urls.format('FRIEND_ADD', [profile.id, php.sessionid, php.time, sakura.currentPage]) }}{% else %}{{ urls.format('FRIEND_REMOVE', [profile.id, php.sessionid, php.time, sakura.currentPage]) }}{% endif %}" id="profileFriendToggle"></a>
<a class="fa fa-exclamation-circle" title="Report {{ profile.username }}" href="{{ urls.format('USER_REPORT', [profile.id]) }}"></a>
{% endif %}
{% if user.permission(constant('Sakura\\Perms\\Manage::CAN_RESTRICT_USERS'), constant('Sakura\\Perms::MANAGE')) %}
<a class="fa fa-trash" title="Restrict {{ profile.username }}" href="?restrict={{ php.sessionid }}"></a>
{% endif %}
<hr class="default" />
<a class="fa fa-file-text-o" title="View {{ profile.username }}'s user page" href="{{ urls.format('USER_PROFILE', [profile.id]) }}"></a>
{#<a class="fa fa-list" title="View {{ profile.username }}'s threads" href="{{ urls.format('USER_THREADS', [profile.id]) }}"></a>
<a class="fa fa-reply" title="View {{ profile.username }}'s posts" href="{{ urls.format('USER_POSTS', [profile.id]) }}"></a> shh #}
<a class="fa fa-star" title="View {{ profile.username }}'s friends" href="{{ urls.format('USER_FRIENDS', [profile.id]) }}"></a>
{#<a class="fa fa-users" title="View {{ profile.username }}'s groups" href="{{ urls.format('USER_GROUPS', [profile.id]) }}"></a>#}
{% if not noUserpage %}
<a class="fa fa-comments-o" title="View {{ profile.username }}'s profile comments" href="{{ urls.format('USER_COMMENTS', [profile.id]) }}"></a>
{% endif %}
</div>
{% endif %}
<hr class="default" />
<b>Joined</b> <span title="{{ profile.registered|date(sakura.dateFormat) }}">{{ profile.elapsed.joined }}</span>
<br />
{% if profile.lastOnline < 1 %}
<b>{{ profile.username }} hasn't logged in yet.</b>
{% else %}
<b>Last online</b> <span title="{{ profile.lastOnline|date(sakura.dateFormat) }}">{{ profile.elapsed.lastOnline }}</span>
{% endif %}
<br />
<b>{{ profile.username }} has {% if not profile.forumStats.posts %}no{% else %}{{ profile.forumStats.posts }}{% endif %} forum post{% if profile.forumStats.posts != 1 %}s{% endif %}.</b>
{% if profile.birthday != '0000-00-00' and profile.birthday|split('-')[0] > 0 %}
<br /><b>Age</b> <span title="{{ profile.birthday }}">{{ profile.birthday(true) }} years old</span>
{% endif %}
{% if profile.profileFields or user.permission(constant('Sakura\\Perms\\Manage::USE_MANAGE'), constant('Sakura\\Perms::MANAGE')) %}
<hr class="default" />
{% if session.checkLogin %}
<table style="width: 100%;">
{% for name,field in profile.profileFields %}
<tr>
<td style="text-align: left; font-weight: bold;">
{{ field.name }}
</td>
<td style="text-align: right;">
{% if name == 'youtube' %}
<a href="https://youtube.com/{% if field.youtubetype == true %}channel{% else %}user{% endif %}/{{ field.value }}" class="default">{% if field.youtubetype == true %}{{ profile.username }}'s Channel{% else %}{{ field.value }}{% endif %}</a>
{% else %}
{% if field.islink %}
<a href="{{ field.link }}" class="default">
{% endif %}
{{ field.value }}
{% if field.islink %}
</a>
{% endif %}
{% endif %}
</td>
</tr>
{% endfor %}
{% if user.permission(constant('Sakura\\Perms\\Manage::USE_MANAGE'), constant('Sakura\\Perms::MANAGE')) %}
<tr>
<td style="text-align: left; font-weight: bold;">E-mail address</td>
<td style="text-align: right;"><a href="mailto:{{ profile.email }}" class="default">{{ profile.email }}</a></td>
</tr>
<tr>
<td style="text-align: left; font-weight: bold;">Register IP</td>
<td style="text-align: right;">{{ profile.registerIp }}</td>
</tr>
<tr>
<td style="text-align: left; font-weight: bold;">Last IP</td>
<td style="text-align: right;">{{ profile.lastIp }}</td>
</tr>
{% endif %}
</table>
{% else %}
<b>Log in to view the full profile!</b>
{% endif %}
{% endif %}
{% else %}
<h1 style="color: #222; text-shadow: 0 0 7px #888; padding: 0 0 2px;">{{ profile.username }}</h1>
{% endif %}
<hr class="default" />
<b>Account Standing</b>
{% if profile.permission(constant('Sakura\\Perms\\Site::DEACTIVATED')) %}
<h2 style="color: #888; text-shadow: 0 0 7px #888; margin-top: 0;">Deactivated</h2>
{% elseif profile.checkBan %}
<h2 style="color: #222; text-shadow: 0 0 7px #222; margin-top: 0;">Banned</h2>
{% elseif profile.permission(constant('Sakura\\Perms\\Site::RESTRICTED')) %}
<h2 style="color: #800; text-shadow: 0 0 7px #800; margin-top: 0;">Restricted</h2>
{% elseif profile.getWarnings %}
<h2 style="color: #A00; text-shadow: 0 0 7px #A00; margin-top: 0;">Bad</h2>
{% else %}
<h2 style="color: #080; text-shadow: 0 0 7px #080; margin-top: 0;">Good</h2>
{% endif %}
{% if profile.getWarnings %}
<table class="panelTable">
<tr>
<th>Action</th>
<th>Duration</th>
<th>Reason</th>
</tr>
{% for warning in profile.getWarnings %}
<tr class="{{ warning.warning_action_text|lower }}">
<td>{{ warning.warning_action_text }}</td>
<td>{{ warning.warning_length }} minute{% if warning.warning_length != 1 %}s{% endif %}</td>
<td>{{ warning.warning_reason }}</td>
</tr>
{% endfor %}
</table>
{% endif %}
</div>
</div>
<div class="content-left content-column">
{% include 'profile/' ~ profileView ~ '.twig' %}
</div>
<div class="clear"></div>
</div>
{% else %}
<div class="content new-profile">
<div class="new-profile-container">
@ -175,14 +97,14 @@
</div>
<div class="new-profile-interactions">
<div class="new-profile-navigation">
<a class="fa fa-file-text-o" title="View {{ profile.username }}'s user page" href="{{ urls.format('USER_PROFILE', [profile.id]) }}"></a>
{#<a class="fa fa-list" title="View {{ profile.username }}'s threads" href="{{ urls.format('USER_THREADS', [profile.id]) }}"></a>
<a class="fa fa-reply" title="View {{ profile.username }}'s posts" href="{{ urls.format('USER_POSTS', [profile.id]) }}"></a>#}
<a class="fa fa-star" title="View {{ profile.username }}'s friends" href="{{ urls.format('USER_FRIENDS', [profile.id]) }}"></a>
{#<a class="fa fa-users" title="View {{ profile.username }}'s groups" href="{{ urls.format('USER_GROUPS', [profile.id]) }}"></a>#}
{% if not noUserpage %}
<a class="fa fa-comments-o" title="View {{ profile.username }}'s profile comments" href="{{ urls.format('USER_COMMENTS', [profile.id]) }}"></a>
<a class="fa fa-file-text-o" title="View {{ profile.username }}'s user page" href="#_userpage" onclick="profileMode('userpage');"></a>
{% endif %}
{#<a class="fa fa-list" title="View {{ profile.username }}'s threads" href="#_threads" onclick="profileMode('threads');"></a>
<a class="fa fa-reply" title="View {{ profile.username }}'s posts" href="#_posts" onclick="profileMode('posts');"></a>#}
<a class="fa fa-star" title="View {{ profile.username }}'s friends" href="#_friends" onclick="profileMode('friends');"></a>
{#<a class="fa fa-users" title="View {{ profile.username }}'s groups" href="#_groups" onclick="profileMode('groups');"></a>#}
<a class="fa fa-comments-o" title="View {{ profile.username }}'s profile comments" href="#_comments" onclick="profileMode('comments');"></a>
</div>
{% if session.checkLogin %}
<div class="new-profile-actions">
@ -201,8 +123,24 @@
</div>
<div class="new-profile-content">
<div class="new-profile-mode">
<div>
{% include 'profile/' ~ profileView ~ '.twig' %}
<noscript><h1 class="stylised" style="text-align: center;">Please enable Javascript!</h1></noscript>
<div id="profile-mode-userpage" class="hidden">
{% include 'profile/userpage.twig' %}
</div>
<div id="profile-mode-friends" class="hidden">
{% include 'profile/friends.twig' %}
</div>
<div id="profile-mode-groups" class="hidden">
{% include 'profile/groups.twig' %}
</div>
<div id="profile-mode-threads" class="hidden">
{% include 'profile/threads.twig' %}
</div>
<div id="profile-mode-posts" class="hidden">
{% include 'profile/posts.twig' %}
</div>
<div id="profile-mode-comments" class="hidden">
{% include 'profile/comments.twig' %}
</div>
</div>
<div class="new-profile-data">