leaving march with a bang

This commit is contained in:
flash 2016-03-31 22:03:25 +02:00
parent daf21c8873
commit b6f341d550
69 changed files with 421 additions and 357 deletions

8
.gitignore vendored
View file

@ -1,6 +1,3 @@
.idea/
.vs/
errors.log
BingSiteAuth.xml
google*.html
/config/config.ini
@ -8,11 +5,6 @@ google*.html
!/cache/.sakura
/vendor
[Tt]humbs.db
ehthumbs.db
Desktop.ini
$RECYCLE.BIN/
.DS_Store
*.phpproj
*.user
*.sln
composer.lock

47
libraries/ActiveUser.php Normal file
View file

@ -0,0 +1,47 @@
<?php
/**
* Holds information about the currently active session
*
* @package Sakura
*/
namespace Sakura;
use Sakura\Perms\Site;
/**
* Information about the current active user and session.
*
* @package Sakura
* @author Julian van de Groep <me@flash.moe>
*/
class ActiveUser
{
public static $user = null;
public static $session = null;
public static function init($userId, $sessionId)
{
// Create a session object
self::$session = new Session($userId, $sessionId);
// Create a user object
$user = User::construct($userId);
// Check if the session exists and check if the user is activated
if (self::$session->validate() > 0
&& !$user->permission(Site::DEACTIVATED)) {
// Assign the user object
self::$user = $user;
// Update last online
DB::table('users')
->where('user_id', self::$user->id)
->update([
'user_last_online' => time(),
]);
} else {
self::$user = User::construct(0);
}
}
}

View file

@ -9,11 +9,11 @@ namespace Sakura\BBcodeDefinitions;
use JBBCode\CodeDefinition;
use JBBCode\ElementNode;
use Sakura\ActiveUser;
use Sakura\Forum\Forum;
use Sakura\Forum\Post;
use Sakura\Perms\Forum as ForumPerms;
use Sakura\Router;
use Sakura\User;
/**
* Quote BBcode for JBBCode.
@ -43,8 +43,6 @@ class Quote extends CodeDefinition
*/
public function asHtml(ElementNode $el)
{
global $currentUser;
$attr = $el->getAttribute()['quote'];
if (substr($attr, 0, 1) === '#') {
@ -53,7 +51,7 @@ class Quote extends CodeDefinition
$forum = new Forum($post->forum);
if ($post->id !== 0
&& $forum->permission(ForumPerms::VIEW, $currentUser->id)) {
&& $forum->permission(ForumPerms::VIEW, ActiveUser::$user->id)) {
$postLink = Router::route('forums.post', $post->id);
$content = "<blockquote><div class='quotee'><a href='{$postLink}' style='color: inherit;'>"

View file

@ -8,6 +8,7 @@
namespace Sakura\Controllers;
use Sakura\ActionCode;
use Sakura\ActiveUser;
use Sakura\Config;
use Sakura\DB;
use Sakura\Hashing;
@ -52,10 +53,9 @@ class AuthController extends Controller
*/
public function logout()
{
// Check if user is logged in
$check = Users::checkLogin();
if (!$check || !isset($_REQUEST['s']) || $_REQUEST['s'] != session_id()) {
if (!ActiveUser::$session->validate()
|| !isset($_REQUEST['s'])
|| $_REQUEST['s'] != session_id()) {
$message = 'Something happened! This probably happened because you went here without being logged in.';
$redirect = (isset($_REQUEST['redirect']) ? $_REQUEST['redirect'] : Router::route('main.index'));
@ -65,7 +65,7 @@ class AuthController extends Controller
}
// Destroy the active session
(new Session($check[0], $check[1]))->destroy();
ActiveUser::$session->destroy();
// Return true indicating a successful logout
$message = 'Goodbye!';

View file

@ -7,6 +7,7 @@
namespace Sakura\Controllers;
use Sakura\ActiveUser;
use Sakura\Comment;
use Sakura\Config;
use Sakura\Perms\Site;
@ -21,8 +22,6 @@ class CommentsController extends Controller
{
public function post($category = '', $reply = 0)
{
global $currentUser;
$session = $_POST['session'] ?? '';
// Check if the user can comment
@ -32,7 +31,7 @@ class CommentsController extends Controller
}
// Check if the user can comment
if (!$currentUser->permission(Site::CREATE_COMMENTS)) {
if (!ActiveUser::$user->permission(Site::CREATE_COMMENTS)) {
$error = "You aren't allowed to make comments!";
return $this->json(compact('error'));
}
@ -57,7 +56,7 @@ class CommentsController extends Controller
$comment->category = $category;
$comment->time = time();
$comment->reply = (int) $reply;
$comment->user = (int) $currentUser->id;
$comment->user = (int) ActiveUser::$user->id;
$comment->text = $text;
$comment->save();
@ -67,10 +66,8 @@ class CommentsController extends Controller
public function delete($id = 0)
{
global $currentUser;
// Check if the user can delete comments
if (!$currentUser->permission(Site::DELETE_COMMENTS)) {
if (!ActiveUser::$user->permission(Site::DELETE_COMMENTS)) {
$error = "You aren't allowed to delete comments!";
return $this->json(compact('error'));
}
@ -82,7 +79,7 @@ class CommentsController extends Controller
return $this->json(compact('error'));
}
if ($currentUser->id !== $comment->user) {
if (ActiveUser::$user->id !== $comment->user) {
$error = "You aren't allowed to delete the comments of other people!";
return $this->json(compact('error'));
}
@ -96,13 +93,11 @@ class CommentsController extends Controller
public function vote($id = 0)
{
global $currentUser;
$vote = $_REQUEST['vote'] ?? 0;
$vote = $vote != 0;
// Check if the user can delete comments
if (!$currentUser->permission(Site::VOTE_COMMENTS)) {
if (!ActiveUser::$user->permission(Site::VOTE_COMMENTS)) {
$error = "You aren't allowed to vote on comments!";
return $this->json(compact('error'));
}
@ -114,7 +109,7 @@ class CommentsController extends Controller
return $this->json(compact('error'));
}
$comment->vote($currentUser->id, $vote);
$comment->vote(ActiveUser::$user->id, $vote);
$upvotes = $comment->upvotes;
$downvotes = $comment->downvotes;

View file

@ -7,6 +7,7 @@
namespace Sakura\Controllers;
use Sakura\ActiveUser;
use Sakura\Config;
use Sakura\DB;
use Sakura\Forum\Forum;
@ -33,8 +34,6 @@ class ForumController extends Controller
*/
public function index()
{
global $currentUser;
// Get the most active threads
$activeThreadsIds = DB::table('posts')
->groupBy('topic_id')
@ -51,7 +50,7 @@ class ForumController extends Controller
$forum = new Forum($thread->forum);
// Check if we have permission to view it
if (!$forum->permission(ForumPerms::VIEW, $currentUser->id)) {
if (!$forum->permission(ForumPerms::VIEW, ActiveUser::$user->id)) {
$fetch = DB::table('posts')
->groupBy('topic_id')
->orderByRaw('COUNT(*) DESC')
@ -83,7 +82,7 @@ class ForumController extends Controller
$forum = new Forum($post->forum);
// Check if we have permission to view it
if (!$forum->permission(ForumPerms::VIEW, $currentUser->id)) {
if (!$forum->permission(ForumPerms::VIEW, ActiveUser::$user->id)) {
$fetch = DB::table('posts')
->orderBy('post_id', 'desc')
->skip(11 + $_n)
@ -126,8 +125,6 @@ class ForumController extends Controller
*/
public function forum($id = 0)
{
global $currentUser;
// Get the forum
$forum = new Forum($id);
@ -151,7 +148,7 @@ class ForumController extends Controller
}
// Check if the user has access to the forum
if (!$forum->permission(ForumPerms::VIEW, $currentUser->id)) {
if (!$forum->permission(ForumPerms::VIEW, ActiveUser::$user->id)) {
// Set render data
Template::vars([
'page' => [
@ -194,8 +191,6 @@ class ForumController extends Controller
*/
public function markForumRead($id = 0)
{
global $currentUser;
// Check if the session id was supplied
if (!isset($_GET['s']) || $_GET['s'] != session_id()) {
// Set render data
@ -228,7 +223,7 @@ class ForumController extends Controller
}
// Check if the user has access to the forum
if (!$forum->permission(ForumPerms::VIEW, $currentUser->id)) {
if (!$forum->permission(ForumPerms::VIEW, ActiveUser::$user->id)) {
// Set render data
Template::vars([
'page' => [
@ -242,7 +237,7 @@ class ForumController extends Controller
}
// Run the function
$forum->trackUpdateAll($currentUser->id);
$forum->trackUpdateAll(ActiveUser::$user->id);
// Set render data
Template::vars([
@ -263,8 +258,6 @@ class ForumController extends Controller
*/
public function thread($id = 0)
{
global $currentUser;
// Attempt to get the thread
$thread = new Thread($id);
@ -272,7 +265,7 @@ class ForumController extends Controller
$forum = new Forum($thread->forum);
// Check if the forum exists
if ($thread->id == 0 || !$forum->permission(ForumPerms::VIEW, $currentUser->id)) {
if ($thread->id == 0 || !$forum->permission(ForumPerms::VIEW, ActiveUser::$user->id)) {
// Set render data
Template::vars([
'page' => [
@ -286,7 +279,7 @@ class ForumController extends Controller
}
// Update the tracking status
$thread->trackUpdate($currentUser->id);
$thread->trackUpdate(ActiveUser::$user->id);
// Update views
$thread->viewsUpdate();
@ -305,8 +298,6 @@ class ForumController extends Controller
*/
public function threadModerate($id = 0)
{
global $currentUser;
// Attempt to get the thread
$thread = new Thread($id);
@ -319,7 +310,7 @@ class ForumController extends Controller
// Check if the forum exists
if ($thread->id == 0
|| !$forum->permission(ForumPerms::VIEW, $currentUser->id)
|| !$forum->permission(ForumPerms::VIEW, ActiveUser::$user->id)
|| !isset($_POST['session'])
|| $_POST['session'] != session_id()) {
$message = 'This thread doesn\'t exist or you don\'t have access to it!';
@ -332,7 +323,7 @@ class ForumController extends Controller
switch ($action) {
case 'sticky':
// Check permission
if (!$forum->permission(ForumPerms::STICKY, $currentUser->id)) {
if (!$forum->permission(ForumPerms::STICKY, ActiveUser::$user->id)) {
$message = "You're not allowed to do this!";
break;
}
@ -343,12 +334,14 @@ class ForumController extends Controller
$thread->update();
// Add page variable stuff
$message = $thread->type ? 'Changed the thread to sticky!' : 'Reverted the thread back to normal!';
$message = $thread->type
? 'Changed the thread to sticky!'
: 'Reverted the thread back to normal!';
break;
case 'announce':
// Check permission
if (!$forum->permission(ForumPerms::ANNOUNCEMENT, $currentUser->id)) {
if (!$forum->permission(ForumPerms::ANNOUNCEMENT, ActiveUser::$user->id)) {
$message = "You're not allowed to do this!";
break;
}
@ -359,12 +352,14 @@ class ForumController extends Controller
$thread->update();
// Add page variable stuff
$message = $thread->type ? 'Changed the thread to into an announcement!' : 'Reverted the thread back to normal!';
$message = $thread->type
? 'Changed the thread to into an announcement!'
: 'Reverted the thread back to normal!';
break;
case 'lock':
// Check permission
if (!$forum->permission(ForumPerms::LOCK, $currentUser->id)) {
if (!$forum->permission(ForumPerms::LOCK, ActiveUser::$user->id)) {
$message = "You're not allowed to do this!";
break;
}
@ -385,7 +380,7 @@ class ForumController extends Controller
// Check if we're operating from the trash
if ($thread->forum == $trash) {
// Check permission
if (!$forum->permission(ForumPerms::DELETE_ANY, $currentUser->id)) {
if (!$forum->permission(ForumPerms::DELETE_ANY, ActiveUser::$user->id)) {
$message = "You're not allowed to do this!";
break;
}
@ -401,7 +396,7 @@ class ForumController extends Controller
$redirect = Router::route('forums.forum', $trash);
} else {
// Check permission
if (!$forum->permission(ForumPerms::MOVE, $currentUser->id)) {
if (!$forum->permission(ForumPerms::MOVE, ActiveUser::$user->id)) {
$message = "You're not allowed to do this!";
break;
}
@ -442,8 +437,6 @@ class ForumController extends Controller
*/
public function post($id = 0)
{
global $currentUser;
// Attempt to get the post
$post = new Post($id);
@ -456,7 +449,7 @@ class ForumController extends Controller
// Check if the forum exists
if ($post->id == 0
|| $thread->id == 0
|| !$forum->permission(ForumPerms::VIEW, $currentUser->id)) {
|| !$forum->permission(ForumPerms::VIEW, ActiveUser::$user->id)) {
$message = "This post doesn't exist or you don't have access to it!";
$redirect = Router::route('forums.index');
@ -492,8 +485,6 @@ class ForumController extends Controller
*/
public function postRaw($id = 0)
{
global $currentUser;
// Attempt to get the post
$post = new Post($id);
@ -506,7 +497,7 @@ class ForumController extends Controller
// Check if the forum exists
if ($post->id == 0
|| $thread->id == 0
|| !$forum->permission(ForumPerms::VIEW, $currentUser->id)) {
|| !$forum->permission(ForumPerms::VIEW, ActiveUser::$user->id)) {
return "";
}
@ -520,8 +511,6 @@ class ForumController extends Controller
*/
public function threadReply($id = 0)
{
global $currentUser;
$text = isset($_POST['text']) ? $_POST['text'] : null;
// Attempt to get the forum
@ -533,7 +522,7 @@ class ForumController extends Controller
// Check if the thread exists
if ($thread->id == 0
|| $forum->type !== 0
|| !$forum->permission(ForumPerms::VIEW, $currentUser->id)) {
|| !$forum->permission(ForumPerms::VIEW, ActiveUser::$user->id)) {
$message = "This post doesn't exist or you don't have access to it!";
$redirect = Router::route('forums.index');
@ -543,10 +532,10 @@ class ForumController extends Controller
}
// Check if the thread exists
if (!$forum->permission(ForumPerms::REPLY, $currentUser->id)
if (!$forum->permission(ForumPerms::REPLY, ActiveUser::$user->id)
|| (
$thread->status === 1
&& !$forum->permission(ForumPerms::LOCK, $currentUser->id)
&& !$forum->permission(ForumPerms::LOCK, ActiveUser::$user->id)
)) {
$message = "You are not allowed to post in this thread!";
$redirect = Router::route('forums.thread', $thread->id);
@ -592,7 +581,7 @@ class ForumController extends Controller
$post = Post::create(
"Re: {$thread->title}",
$text,
$currentUser,
ActiveUser::$user,
$thread->id,
$forum->id
);
@ -611,8 +600,6 @@ class ForumController extends Controller
*/
public function createThread($id = 0)
{
global $currentUser;
$title = isset($_POST['title']) ? $_POST['title'] : null;
$text = isset($_POST['text']) ? $_POST['text'] : null;
@ -622,9 +609,9 @@ class ForumController extends Controller
// Check if the forum exists
if ($forum->id === 0
|| $forum->type !== 0
|| !$forum->permission(ForumPerms::VIEW, $currentUser->id)
|| !$forum->permission(ForumPerms::REPLY, $currentUser->id)
|| !$forum->permission(ForumPerms::CREATE_THREADS, $currentUser->id)) {
|| !$forum->permission(ForumPerms::VIEW, ActiveUser::$user->id)
|| !$forum->permission(ForumPerms::REPLY, ActiveUser::$user->id)
|| !$forum->permission(ForumPerms::CREATE_THREADS, ActiveUser::$user->id)) {
$message = "This forum doesn't exist or you don't have access to it!";
$redirect = Router::route('forums.index');
@ -685,7 +672,7 @@ class ForumController extends Controller
$post = Post::create(
$title,
$text,
$currentUser,
ActiveUser::$user,
0,
$forum->id
);
@ -709,8 +696,6 @@ class ForumController extends Controller
*/
public function editPost($id = 0)
{
global $currentUser;
$title = isset($_POST['title']) ? $_POST['title'] : null;
$text = isset($_POST['text']) ? $_POST['text'] : null;
@ -726,15 +711,15 @@ class ForumController extends Controller
// Check permissions
$noAccess = $post->id == 0
|| $thread->id == 0
|| !$forum->permission(ForumPerms::VIEW, $currentUser->id);
|| !$forum->permission(ForumPerms::VIEW, ActiveUser::$user->id);
$noEdit = (
$post->poster->id === $currentUser->id
? !$currentUser->permission(ForumPerms::EDIT_OWN, Perms::FORUM)
: !$forum->permission(ForumPerms::EDIT_ANY, $currentUser->id)
$post->poster->id === ActiveUser::$user->id
? !ActiveUser::$user->permission(ForumPerms::EDIT_OWN, Perms::FORUM)
: !$forum->permission(ForumPerms::EDIT_ANY, ActiveUser::$user->id)
) || (
$thread->status === 1
&& !$forum->permission(ForumPerms::LOCK, $currentUser->id)
&& !$forum->permission(ForumPerms::LOCK, ActiveUser::$user->id)
);
// Check if the forum exists
@ -814,7 +799,7 @@ class ForumController extends Controller
$post->text = $text;
$post->editTime = time();
$post->editReason = '';
$post->editUser = $currentUser;
$post->editUser = ActiveUser::$user;
$post = $post->update();
// Go to the post
@ -831,8 +816,6 @@ class ForumController extends Controller
*/
public function deletePost($id = 0)
{
global $currentUser;
$action = isset($_POST['yes']) && isset($_POST['sessionid'])
? $_POST['sessionid'] === session_id()
: null;
@ -849,15 +832,15 @@ class ForumController extends Controller
// Check permissions
$noAccess = $post->id == 0
|| $thread->id == 0
|| !$forum->permission(ForumPerms::VIEW, $currentUser->id);
|| !$forum->permission(ForumPerms::VIEW, ActiveUser::$user->id);
$noDelete = (
$post->poster->id === $currentUser->id
? !$currentUser->permission(ForumPerms::DELETE_OWN, Perms::FORUM)
: !$forum->permission(ForumPerms::DELETE_ANY, $currentUser->id)
$post->poster->id === ActiveUser::$user->id
? !ActiveUser::$user->permission(ForumPerms::DELETE_OWN, Perms::FORUM)
: !$forum->permission(ForumPerms::DELETE_ANY, ActiveUser::$user->id)
) || (
$thread->status === 1
&& !$forum->permission(ForumPerms::LOCK, $currentUser->id)
&& !$forum->permission(ForumPerms::LOCK, ActiveUser::$user->id)
);
// Check if the forum exists

View file

@ -7,6 +7,7 @@
namespace Sakura\Controllers;
use Sakura\ActiveUser;
use Sakura\Notification;
use Sakura\Perms\Site;
use Sakura\Router;
@ -37,7 +38,7 @@ class FriendsController extends Controller
public function add($id = 0)
{
global $currentUser;
$user = ActiveUser::$user;
$session = $_POST['session'] ?? '';
@ -50,31 +51,31 @@ class FriendsController extends Controller
$friend = User::construct($id);
if ($friend->permission(Site::DEACTIVATED)
|| $currentUser->permission(Site::DEACTIVATED)) {
|| $user->permission(Site::DEACTIVATED)) {
$error = "The user you tried to add does not exist!";
return $this->json(compact('error'));
}
if ($friend->id === $currentUser->id) {
if ($friend->id === $user->id) {
$error = "You can't be friends with yourself, stop trying to bend reality!";
return $this->json(compact('error'));
}
if ($currentUser->isFriends($friend->id)) {
if ($user->isFriends($friend->id)) {
$error = "You are already friends with this person!";
return $this->json(compact('error'));
}
// Add friend
$currentUser->addFriend($friend->id);
$user->addFriend($friend->id);
$level = $currentUser->isFriends($friend->id);
$level = $user->isFriends($friend->id);
$mutual = $level === 2;
$alertTitle = $mutual
? "{$currentUser->username} accepted your friend request!"
: "{$currentUser->username} added you as a friend!";
? "{$user->username} accepted your friend request!"
: "{$user->username} added you as a friend!";
$alertText = $mutual
? ""
@ -82,7 +83,7 @@ class FriendsController extends Controller
$this->addNotification(
$friend,
$currentUser,
$user,
$alertTitle,
$alertText
);
@ -96,7 +97,7 @@ class FriendsController extends Controller
public function remove($id = 0)
{
global $currentUser;
$user = ActiveUser::$user;
$session = $_POST['session'] ?? '';
@ -109,26 +110,26 @@ class FriendsController extends Controller
$friend = User::construct($id);
if ($friend->permission(Site::DEACTIVATED)
|| $currentUser->permission(Site::DEACTIVATED)) {
|| $user->permission(Site::DEACTIVATED)) {
$error = "The user you tried to remove does not exist!";
return $this->json(compact('error'));
}
if (!$currentUser->isFriends($friend->id)) {
if (!$user->isFriends($friend->id)) {
$error = "You aren't even friends with that person!";
return $this->json(compact('error'));
}
// Add friend
$currentUser->removeFriend($friend->id);
$user->removeFriend($friend->id);
$level = $currentUser->isFriends($friend->id);
$level = $user->isFriends($friend->id);
$alertTitle = "{$currentUser->username} removed you from their friends!";
$alertTitle = "{$user->username} removed you from their friends!";
$this->addNotification(
$friend,
$currentUser,
$user,
$alertTitle
);

View file

@ -7,9 +7,9 @@
namespace Sakura\Controllers;
use Sakura\ActiveUser;
use Sakura\Notification;
use Sakura\Perms\Site;
use Sakura\User;
/**
* Notification stuff.
@ -26,10 +26,7 @@ class NotificationsController extends Controller
*/
public function notifications()
{
// TODO: add friend on/offline messages
global $currentUser;
return $this->json($currentUser->notifications());
return $this->json(ActiveUser::$user->notifications());
}
/**
@ -41,10 +38,8 @@ class NotificationsController extends Controller
*/
public function mark($id = 0)
{
global $currentUser;
// Check permission
if ($currentUser->permission(Site::DEACTIVATED)) {
if (ActiveUser::$user->permission(Site::DEACTIVATED)) {
return '0';
}
@ -52,7 +47,7 @@ class NotificationsController extends Controller
$alert = new Notification($id);
// Verify that the currently authed user is the one this alert is for
if ($alert->user !== $currentUser->id) {
if ($alert->user !== ActiveUser::$user->id) {
return '0';
}

View file

@ -8,6 +8,7 @@
namespace Sakura\Controllers;
use Exception;
use Sakura\ActiveUser;
use Sakura\Config;
use Sakura\Payments;
use Sakura\Perms\Site;
@ -42,8 +43,6 @@ class PremiumController extends Controller
*/
public function index()
{
global $currentUser;
$price = Config::get('premium_price_per_month');
$amountLimit = Config::get('premium_amount_max');
@ -59,16 +58,14 @@ class PremiumController extends Controller
*/
public function purchase()
{
global $currentUser;
// Get values from post
$session = isset($_POST['session']) ? $_POST['session'] : '';
$months = isset($_POST['months']) ? $_POST['months'] : 0;
// Check if the session is valid
if ($session !== session_id()
|| $currentUser->permission(Site::DEACTIVATED)
|| !$currentUser->permission(Site::OBTAIN_PREMIUM)) {
|| ActiveUser::$user->permission(Site::DEACTIVATED)
|| !ActiveUser::$user->permission(Site::OBTAIN_PREMIUM)) {
$message = "You are not allowed to get premium!";
$redirect = Router::route('premium.index');
@ -138,8 +135,6 @@ class PremiumController extends Controller
*/
public function handle()
{
global $currentUser;
$success = isset($_GET['success']);
$payment = isset($_GET['paymentId']) ? $_GET['paymentId'] : null;
$payer = isset($_GET['PayerID']) ? $_GET['PayerID'] : null;
@ -168,7 +163,7 @@ class PremiumController extends Controller
$pricePerMonth = Config::get('premium_price_per_month');
$currentUser->addPremium(self::PERIOD_PER_PAYMENT * $months);
ActiveUser::$user->addPremium(self::PERIOD_PER_PAYMENT * $months);
return header("Location: {$successRoute}");
}

View file

@ -7,7 +7,10 @@
namespace Sakura\Controllers\Settings;
use Sakura\ActiveUser;
use Sakura\Controllers\Controller as BaseController;
use Sakura\Perms\Site;
use Sakura\Router;
use Sakura\Urls;
/**
@ -33,4 +36,74 @@ class Controller extends BaseController
return header("Location: {$url}");
}
public function navigation()
{
$nav = [];
// General
$nav["General"]["Home"] = Router::route('settings.general.home');
if (ActiveUser::$user->permission(Site::ALTER_PROFILE)) {
$nav["General"]["Profile"] = Router::route('settings.general.profile');
}
$nav["General"]["Options"] = Router::route('settings.general.options');
// Friends
if (ActiveUser::$user->permission(Site::MANAGE_FRIENDS)) {
$nav["Friends"]["Listing"] = Router::route('settings.friends.listing');
$nav["Friends"]["Requests"] = Router::route('settings.friends.requests');
}
// Groups
// Notifications
$nav["Notifications"]["History"] = Router::route('settings.notifications.history');
// Appearance
if (ActiveUser::$user->permission(Site::CHANGE_AVATAR)) {
$nav["Appearance"]["Avatar"] = Router::route('settings.appearance.avatar');
}
if (ActiveUser::$user->permission(Site::CHANGE_BACKGROUND)) {
$nav["Appearance"]["Background"] = Router::route('settings.appearance.background');
}
if (ActiveUser::$user->permission(Site::CHANGE_HEADER)) {
$nav["Appearance"]["Header"] = Router::route('settings.appearance.header');
}
if ((
ActiveUser::$user->page
&& ActiveUser::$user->permission(Site::CHANGE_USERPAGE)
) || ActiveUser::$user->permission(Site::CREATE_USERPAGE)) {
$nav["Appearance"]["Userpage"] = Router::route('settings.appearance.userpage');
}
if (ActiveUser::$user->permission(Site::CHANGE_SIGNATURE)) {
$nav["Appearance"]["Signature"] = Router::route('settings.appearance.signature');
}
// Account
if (ActiveUser::$user->permission(Site::CHANGE_EMAIL)) {
$nav["Account"]["E-mail address"] = Router::route('settings.account.email');
}
if (ActiveUser::$user->permission(Site::CHANGE_USERNAME)) {
$nav["Account"]["Username"] = Router::route('settings.account.username');
}
if (ActiveUser::$user->permission(Site::CHANGE_USERTITLE)) {
$nav["Account"]["Title"] = Router::route('settings.account.title');
}
if (ActiveUser::$user->permission(Site::CHANGE_PASSWORD)) {
$nav["Account"]["Password"] = Router::route('settings.account.password');
}
if (ActiveUser::$user->permission(Site::ALTER_RANKS)) {
$nav["Account"]["Ranks"] = Router::route('settings.account.ranks');
}
// Advanced
if (ActiveUser::$user->permission(Site::MANAGE_SESSIONS)) {
$nav["Advanced"]["Sessions"] = Router::route('settings.advanced.sessions');
}
if (ActiveUser::$user->permission(Site::DEACTIVATE_ACCOUNT)) {
$nav["Advanced"]["Deactivate"] = Router::route('settings.advanced.deactivate');
}
return $nav;
}
}

View file

@ -7,6 +7,10 @@
namespace Sakura\Controllers\Settings;
use Sakura\ActiveUser;
use Sakura\Perms\Site;
use Sakura\Template;
/**
* General settings.
*
@ -17,7 +21,14 @@ class GeneralController extends Controller
{
public function home()
{
return $this->go('general.home');
ActiveUser::class;
Site::class;
$navigation = $this->navigation();
Template::vars(compact('navigation'));
return Template::render('settings/general/home');
}
public function profile()

View file

@ -7,6 +7,7 @@
namespace Sakura\Controllers;
use Sakura\ActiveUser;
use Sakura\Config;
use Sakura\DB;
use Sakura\Perms\Site;
@ -33,8 +34,6 @@ class UserController extends Controller
*/
public function profile($id = 0)
{
global $currentUser;
// Get the user's context
$profile = User::construct($id);
@ -74,10 +73,8 @@ class UserController extends Controller
*/
public function members($rank = null)
{
global $currentUser;
// Check permission
if (!$currentUser->permission(Site::VIEW_MEMBERLIST)) {
if (!ActiveUser::$user->permission(Site::VIEW_MEMBERLIST)) {
return Template::render('global/restricted');
}

View file

@ -37,14 +37,14 @@ class Session
*/
public function __construct($userId, $sessionId = null)
{
// Set the supposed session data
$this->userId = $userId;
$this->sessionId = $sessionId;
// Check if a PHP session was already started and if not start one
if (session_status() != PHP_SESSION_ACTIVE) {
session_start();
}
// Set the supposed session data
$this->userId = $userId;
$this->sessionId = $sessionId;
}
/**
@ -63,9 +63,8 @@ class Session
unset($this->sessionId);
// Destroy the session
if (session_status() == PHP_SESSION_ACTIVE) {
session_destroy();
}
session_regenerate_id(true);
session_destroy();
}
/**

View file

@ -10,6 +10,7 @@ namespace Sakura;
use Twig_Environment;
use Twig_Extension_StringLoader;
use Twig_Loader_Filesystem;
use Twig_SimpleFilter;
use Twig_SimpleFunction;
/**
@ -87,7 +88,16 @@ class Template
return Router::route($name, $args);
}));
// Add config function
self::$template->addFunction(new Twig_SimpleFunction('config', function ($name) {
return Config::get($name);
}));
// Method of getting the currently active session id
self::$template->addFunction(new Twig_SimpleFunction('session_id', 'session_id'));
// json_decode filter (why doesn't this exist to begin with?)
self::$template->addFilter(new Twig_SimpleFilter('json_decode', 'json_decode'));
}
/**

View file

@ -816,7 +816,7 @@ class User
}
// Check if we have additional options as well
if ($field->field_additional != null) {
if (!empty($field->field_additional)) {
// Decode the json of the additional stuff
$additional = json_decode($field->field_additional, true);

View file

@ -18,68 +18,6 @@ use Sakura\Router;
*/
class Users
{
/**
* Check if a user is logged in
*
* @param int $uid The user ID.
* @param string $sid The session ID.
*
* @return array|bool Either false or the ID and session in an array.
*/
public static function checkLogin($uid = null, $sid = null)
{
// Assign $uid and $sid
$uid = $uid ? $uid : (isset($_COOKIE[Config::get('cookie_prefix') . 'id'])
? $_COOKIE[Config::get('cookie_prefix') . 'id']
: 0);
$sid = $sid ? $sid : (isset($_COOKIE[Config::get('cookie_prefix') . 'session'])
? $_COOKIE[Config::get('cookie_prefix') . 'session']
: 0);
// Get session
$session = new Session($uid, $sid);
// Validate the session
$sessionValid = $session->validate();
// Get user object
$user = User::construct($uid);
// Check if the session exists and check if the user is activated
if ($sessionValid == 0 || $user->permission(Site::DEACTIVATED)) {
return false;
}
// Extend the cookie times if the remember flag is set
if ($sessionValid == 2) {
// User ID cookie
setcookie(
Config::get('cookie_prefix') . 'id',
$uid,
time() + 604800,
Config::get('cookie_path')
);
// Session ID cookie
setcookie(
Config::get('cookie_prefix') . 'session',
$sid,
time() + 604800,
Config::get('cookie_path')
);
}
// Update last online
DB::table('users')
->where('user_id', $uid)
->update([
'user_last_online' => time(),
]);
// If everything went through return true
return [$uid, $sid];
}
/**
* Send password forgot e-mail
*

View file

@ -8,12 +8,13 @@ namespace Sakura;
use Sakura\Perms\Site;
// Legacy support!!!!!!!!!
$renderData = [];
// Include components
require_once str_replace(basename(__DIR__), '', dirname(__FILE__)) . 'sakura.php';
// Legacy support!!!!!!!!!
$renderData = [];
$currentUser = ActiveUser::$user;
if (isset($_POST['submit']) && isset($_POST['submit'])) {
$continue = true;
@ -21,10 +22,10 @@ if (isset($_POST['submit']) && isset($_POST['submit'])) {
$redirect = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : $urls->format('SETTINGS_INDEX');
// Check if the user is logged in
if (!Users::checkLogin() || !$continue) {
if (!ActiveUser::$user->id || !$continue) {
$renderData['page'] = [
'redirect' => '/authenticate',
'redirect' => '/login',
'message' => 'You must be logged in to edit your settings.',
'success' => 0,
@ -780,7 +781,7 @@ if (isset($_POST['submit']) && isset($_POST['submit'])) {
exit;
}
if (Users::checkLogin()) {
if (ActiveUser::$user->id) {
// Settings page list
$pages = [
'general' => [
@ -1051,7 +1052,7 @@ if (Users::checkLogin()) {
}
// Set templates directory
$renderData['templates'] = 'settings';
$renderData['templates'] = 'old-settings';
// Render data
$renderData['current'] = $category . '.' . $mode;

View file

@ -8,9 +8,7 @@ namespace Sakura;
// Check if logged out
Router::filter('logoutCheck', function () {
global $currentUser;
if ($currentUser->id !== 0) {
if (ActiveUser::$user->id !== 0) {
$message = "You must be logged out to do that!";
Template::vars(['page' => compact('message')]);
@ -21,9 +19,8 @@ Router::filter('logoutCheck', function () {
// Check if logged in
Router::filter('loginCheck', function () {
global $currentUser;
if ($currentUser->id === 0) {
if (ActiveUser::$user->id === 0
|| ActiveUser::$user->permission(Perms\Site::DEACTIVATED)) {
$message = "You must be logged in to do that!";
Template::vars(['page' => compact('message')]);

View file

@ -8,7 +8,7 @@
namespace Sakura;
// Define Sakura version
define('SAKURA_VERSION', 20160330);
define('SAKURA_VERSION', 20160331);
// Define Sakura Path
define('ROOT', __DIR__ . '/');
@ -73,13 +73,20 @@ $capsule->setAsGlobal();
if (Config::get('no_cron_service')) {
// If not do an "asynchronous" call to the cron.php script
if (Config::get('no_cron_last') < (time() - Config::get('no_cron_interval'))) {
$phpDir = PHP_BINDIR;
$cronPath = ROOT . 'cron.php';
// Check OS
if (substr(strtolower(PHP_OS), 0, 3) == 'win') {
pclose(popen('start /B ' . PHP_BINDIR . '\php.exe ' . addslashes(ROOT . 'cron.php'), 'r'));
$cronPath = addslashes($cronPath);
pclose(popen("start /B {$phpDir}\php.exe {$cronPath}", 'r'));
} else {
pclose(popen(PHP_BINDIR . '/php ' . ROOT . 'cron.php > /dev/null 2>/dev/null &', 'r'));
pclose(popen("{$phpDir}/php {$cronPath} > /dev/null 2>/dev/null &", 'r'));
}
unset($phpDir, $cronPath);
// Update last execution time
Config::set('no_cron_last', time());
}
@ -94,11 +101,11 @@ Router::init();
// Include routes file
include_once ROOT . 'routes.php';
// Auth check
$authCheck = Users::checkLogin();
// Create a user object for the current logged in user
$currentUser = User::construct($authCheck[0]);
// Initialise the current session
ActiveUser::init(
intval($_COOKIE[Config::get('cookie_prefix') . 'id'] ?? 0),
$_COOKIE[Config::get('cookie_prefix') . 'session'] ?? ''
);
// Create the Urls object
$urls = new Urls();
@ -121,50 +128,18 @@ if (!defined('SAKURA_NO_TPL')) {
'showChangelog' => Config::local('dev', 'show_changelog'),
],
'cookie' => [
'prefix' => Config::get('cookie_prefix'),
'domain' => Config::get('cookie_domain'),
'path' => Config::get('cookie_path'),
],
'contentPath' => Config::get('content_path'),
'resources' => Config::get('content_path') . '/data/' . $templateName,
'charset' => Config::get('charset'),
'siteName' => Config::get('sitename'),
'siteLogo' => Config::get('sitelogo'),
'siteDesc' => Config::get('sitedesc'),
'siteTags' => json_decode(Config::get('sitetags'), true),
'dateFormat' => 'r',
'currentPage' => (isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : null),
'referrer' => (isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : null),
'onlineTimeout' => Config::get('max_online_time'),
'announcementImage' => Config::get('header_announcement_image'),
'announcementLink' => Config::get('header_announcement_link'),
'trashForumId' => Config::get('forum_trash_id'),
'recaptchaPublic' => Config::get('recaptcha_public'),
'recaptchaEnabled' => Config::get('recaptcha'),
'disableRegistration' => Config::get('disable_registration'),
'lockAuth' => Config::get('lock_authentication'),
'requireActivation' => Config::get('require_activation'),
'minPwdEntropy' => Config::get('min_entropy'),
'minUsernameLength' => Config::get('username_min_length'),
'maxUsernameLength' => Config::get('username_max_length'),
'forumTitleMaxLength' => Config::get('forum_title_max'),
'forumTitleMinLength' => Config::get('forum_title_min'),
'forumTextMaxLength' => Config::get('forum_text_max'),
'forumTextMinLength' => Config::get('forum_text_min'),
'currentPage' => $_SERVER['REQUEST_URI'] ?? null,
'referrer' => $_SERVER['HTTP_REFERER'] ?? null,
],
'session' => array_merge([
'checkLogin' => $authCheck,
'sessionId' => $authCheck[1],
'checkLogin' => ActiveUser::$user->id && !ActiveUser::$user->permission(Perms\Site::DEACTIVATED),
'sessionId' => ActiveUser::$session->sessionId,
], $_SESSION),
'user' => $currentUser,
'user' => ActiveUser::$user,
'urls' => $urls,
'get' => $_GET,

View file

@ -1,4 +1,4 @@
{% if not (viewPost and postExists) %}<h3 class="miotitle" id="{{ newsPost.id }}">{{ post.title }} by <a href="{{ urls.format('USER_PROFILE', [post.poster.id]) }}" style="text-decoration: none !important; color: {{ post.poster.colour }} !important;">{{ post.poster.username }}</a> - {{ post.date|date(sakura.dateFormat) }}<span class="permalink"><a href="{{ urls.format('SITE_NEWS') }}#{{ newsPost.id }}" title="Permalink">#</a> <a href="{{ urls.format('SITE_NEWS_POST', [post.id]) }}" title="Direct Link">@</a></span></h3>{% endif %}
{% if not (viewPost and postExists) %}<h3 class="miotitle" id="{{ newsPost.id }}">{{ post.title }} by <a href="{{ urls.format('USER_PROFILE', [post.poster.id]) }}" style="text-decoration: none !important; color: {{ post.poster.colour }} !important;">{{ post.poster.username }}</a> - {{ post.date|date(config('date_format')) }}<span class="permalink"><a href="{{ urls.format('SITE_NEWS') }}#{{ newsPost.id }}" title="Permalink">#</a> <a href="{{ urls.format('SITE_NEWS_POST', [post.id]) }}" title="Direct Link">@</a></span></h3>{% endif %}
<div class="postcontent">
{{ post.content_parsed|raw }}
</div>

View file

@ -2,10 +2,10 @@
<html>
<head>
<!-- META -->
<meta charset="{{ sakura.charset }}" />
<meta charset="{{ config('charset') }}" />
<title>{{ page.title }}</title>
<meta name="description" content="{{ sakura.sitedesc }}" />
<meta name="keywords" content="{{ sakura.sitetags }}" />
<meta name="description" content="{{ config('sitedesc') }}" />
<meta name="keywords" content="{{ config('sitetags')|json_decode|join(', ') }}" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" />
{% if page.redirect %}
<meta http-equiv="refresh" content="3; URL={{ page.redirect }}" />
@ -21,6 +21,6 @@
<a href="/register">Register</a>
</div>
<a href="//{{ sakura.urls.main }}/">
<img class="logo" src="/content/pixel.png" alt="{{ sakura.sitename }}" />
<img class="logo" src="/content/pixel.png" alt="{{ config('sitename') }}" />
</a>
<br />

View file

@ -2,7 +2,7 @@
<div class="news-header">
<a class="news-title floatLeft" href="{{ urls.format('SITE_NEWS_POST', [post.news_id]) }}">{{ post.news_title }}</a>
<div class="news-details floatRight">
<div>{{ post.news_timestamp|date(sakura.dateFormat) }}</div>
<div>{{ post.news_timestamp|date(config('date_format')) }}</div>
<div>Posted by <a class="username" style="color: {{ post.news_poster.colour }};" href="{{ urls.format('USER_PROFILE', [post.news_poster.id]) }}">{{ post.news_poster.username }}</a>{% if not (viewPost and postExists) %} / <a class="default" href="{{ urls.format('SITE_NEWS_POST', [post.news_id]) }}#comments">{{ post.news_comments.count }} comment{% if post.news_comments.count != 1 %}s{% endif %}</a>{% endif %}</div>
</div>
<div class="clear"></div>

View file

@ -25,7 +25,7 @@
<div>
{% if forum.lastPost.id %}
<a href="{{ urls.format('FORUM_THREAD', [forum.lastPost.thread]) }}" class="default">{{ forum.lastPost.subject|slice(0, 25) }}{% if forum.lastPost.subject|length > 25 %}...{% endif %}</a><br />
<span title="{{ forum.lastPost.time|date(sakura.dateFormat) }}">{{ forum.lastPost.timeElapsed }}</span> by {% if forum.lastPost.poster.id %}<a href="{{ urls.format('USER_PROFILE', [forum.lastPost.poster.id]) }}" class="default" style="color: {{ forum.lastPost.poster.colour }}; text-shadow: 0 0 5px {% if forum.lastPost.poster.colour != 'inherit' %}{{ forum.lastPost.poster.colour }}{% else %}#222{% endif %};">{{ forum.lastPost.poster.username }}</a>{% else %}[deleted user]{% endif %} <a href="{{ urls.format('FORUM_POST', [forum.lastPost.id]) }}#p{{ forum.lastPost.id }}" class="default fa fa-tag"></a>
<span title="{{ forum.lastPost.time|date(config('date_format')) }}">{{ forum.lastPost.timeElapsed }}</span> by {% if forum.lastPost.poster.id %}<a href="{{ urls.format('USER_PROFILE', [forum.lastPost.poster.id]) }}" class="default" style="color: {{ forum.lastPost.poster.colour }}; text-shadow: 0 0 5px {% if forum.lastPost.poster.colour != 'inherit' %}{{ forum.lastPost.poster.colour }}{% else %}#222{% endif %};">{{ forum.lastPost.poster.username }}</a>{% else %}[deleted user]{% endif %} <a href="{{ urls.format('FORUM_POST', [forum.lastPost.id]) }}#p{{ forum.lastPost.id }}" class="default fa fa-tag"></a>
{% else %}
There are no posts in this forum.
{% endif %}

View file

@ -2,10 +2,10 @@
<html>
<head>
<!-- META -->
<meta charset="{{ sakura.charset }}" />
<title>{% block title %}{{ sakura.siteName }}{% endblock %}</title>
<meta name="description" content="{{ sakura.siteDesc }}" />
<meta name="keywords" content="{{ sakura.siteTags|join(', ') }}" />
<meta charset="{{ config('charset') }}" />
<title>{% block title %}{{ config('sitename') }}{% endblock %}</title>
<meta name="description" content="{{ config('sitedesc') }}" />
<meta name="keywords" content="{{ config('sitetags')|json_decode|join(', ') }}" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" />
<meta name="msapplication-TileColor" content="#9475b2" />
<meta name="msapplication-TileImage" content="/content/images/icons/ms-icon-144x144.png" />
@ -32,7 +32,7 @@
<link rel="stylesheet" type="text/css" href="{{ sakura.resources }}/css/misaki.css" />
{{ block('css') }}
<!-- JS -->
<script type="text/javascript" src="{{ sakura.contentPath }}/scripts/sakura.js"></script>
<script type="text/javascript" src="{{ config('content_path') }}/scripts/sakura.js"></script>
<script type="text/javascript" src="{{ sakura.resources }}/js/misaki.js"></script>
<script type="text/javascript">
@ -42,19 +42,19 @@
"cookie": {
"prefix": "{{ sakura.cookie.prefix }}",
"domain": "{{ sakura.cookie.domain }}",
"path": "{{ sakura.cookie.path }}"
"domain": "{{ config('cookie_domain') }}",
"path": "{{ config('cookie_prefix') }}"
},
"siteName": "{{ sakura.siteName }}",
"content": "{{ sakura.contentPath }}",
"siteName": "{{ config('sitename') }}",
"content": "{{ config('content_path') }}",
"resources": "{{ sakura.resources }}",
"recaptchaEnabled": "{{ sakura.recaptchaEnabled }}",
"recaptchaEnabled": "{{ config('recaptcha') }}",
"minUserLen": {{ sakura.minUsernameLength }},
"maxUserLen": {{ sakura.maxUsernameLength }},
"minPwdEntropy": {{ sakura.minPwdEntropy }},
"minUserLen": {{ config('username_min_length') }},
"maxUserLen": {{ config('username_max_length') }},
"minPwdEntropy": {{ config('min_entropy') }},
"checkLogin": {% if session.checkLogin %}true{% else %}false{% endif %}
};
@ -112,13 +112,13 @@
</ul>
{% endif %}
</li>
<li><a href="{% if session.checkLogin %}{{ urls.format('USER_PROFILE', [user.id]) }}{% else %}{{ urls.format('SITE_LOGIN') }}{% endif %}"><img src="{{ sakura.contentPath }}/pixel.png" alt="{{ user.username }}" style="background-image: url('{{ urls.format('IMAGE_AVATAR', [user.id]) }}');" class="nav-avatar" /></a></li>
<li><a href="{% if session.checkLogin %}{{ urls.format('USER_PROFILE', [user.id]) }}{% else %}{{ urls.format('SITE_LOGIN') }}{% endif %}"><img src="{{ config('content_path') }}/pixel.png" alt="{{ user.username }}" style="background-image: url('{{ urls.format('IMAGE_AVATAR', [user.id]) }}');" class="nav-avatar" /></a></li>
</ul>
</div>
{% if sakura.siteLogo or sakura.announcementImage %}
<div id="banner" style="background: url('{% if sakura.announcementImage %}{{ sakura.announcementImage }}{% else %}{{ sakura.siteLogo }}{% endif %}');">
<a href="{% if sakura.announcementImage and sakura.announcementLink %}{{ sakura.announcementLink }}{% else %}{{ urls.format('SITE_HOME') }}{% endif %}"></a>
{% if config('sitelogo') or config('header_announcement_image') %}
<div id="banner" style="background: url('{% if config('header_announcement_image') %}{{ config('header_announcement_image') }}{% else %}{{ config('sitelogo') }}{% endif %}');">
<a href="{% if config('header_announcement_image') and config('header_announcement_link') %}{{ config('header_announcement_link') }}{% else %}{{ urls.format('SITE_HOME') }}{% endif %}"></a>
</div>
{% endif %}

View file

@ -49,7 +49,7 @@
<div id="userAvatar" style="background-image: url('{{ urls.format('IMAGE_AVATAR', [profile.id]) }}');">{{ profile.username }}'s Avatar</div>
<div class="userData">
<div class="headerLeft">
<div class="profileUsername" style="color: {{ profile.colour }};"{% if profile.getUsernameHistory %} title="Known as {{ profile.getUsernameHistory[0]['username_old'] }} before {{ profile.getUsernameHistory[0]['change_time']|date(sakura.dateFormat) }}."{% endif %}>
<div class="profileUsername" style="color: {{ profile.colour }};"{% if profile.getUsernameHistory %} title="Known as {{ profile.getUsernameHistory[0]['username_old'] }} before {{ profile.getUsernameHistory[0]['change_time']|date(config('date_format')) }}."{% endif %}>
{% if profileHidden %}Unknown user{% else %}{{ profile.username }}{% endif %}
</div>
<div class="profileUserTitle">
@ -58,8 +58,8 @@
</div>
<div class="headerRight">
{% if not profileHidden %}
<div>Joined <span title="{{ profile.dates.joined|date(sakura.dateFormat) }}">{{ profile.elapsed.joined }}</span></div>
<div>{% if profile.dates.lastOnline < 1 %}User hasn't logged in yet.{% else %}Last Active <span title="{{ profile.dates.lastOnline|date(sakura.dateFormat) }}">{{ profile.elapsed.lastOnline }}</span>{% endif %}</div>
<div>Joined <span title="{{ profile.dates.joined|date(config('date_format')) }}">{{ profile.elapsed.joined }}</span></div>
<div>{% if profile.dates.lastOnline < 1 %}User hasn't logged in yet.{% else %}Last Active <span title="{{ profile.dates.lastOnline|date(config('date_format')) }}">{{ profile.elapsed.lastOnline }}</span>{% endif %}</div>
{% endif %}
</div>
</div>

View file

@ -3,7 +3,7 @@
{% block title %}Login{% endblock %}
{% block content %}
{% if sakura.lockAuth %}
{% if config('require_activation') %}
<h1 class="stylised" style="line-height: 1.8em; text-align: center;">Logging in is disabled for security checkups! Try again later.</h1>
{% else %}
<div class="loginPage">

View file

@ -3,7 +3,7 @@
{% block title %}Reactivate account{% endblock %}
{% block content %}
{% if sakura.lockAuth %}
{% if config('require_activation') %}
<h1 class="stylised" style="line-height: 1.8em; text-align: center;">Reactivation is disabled for security checkups! Try again later.</h1>
{% else %}
<div class="loginPage">

View file

@ -3,7 +3,7 @@
{% block title %}Register{% endblock %}
{% block content %}
{% if sakura.lockAuth or sakura.disableRegistration %}
{% if config('require_activation') or config('disable_registration') %}
<div class="loginPage">
<div class="registerForm" id="registerWarn" style="display: block;">
<div class="centreAlign">
@ -39,7 +39,7 @@
<div class="centreAlign">
<input class="inputStyling" type="password" id="registerPassword" name="password" onkeyup="registerVarCheck(this.id, 'password');" placeholder="Using special characters is recommended" />
</div>
{% if sakura.recaptchaEnabled %}
{% if config('recaptcha') %}
<div class="leftAlign">
<label for="recaptcha_response_field">Verification:</label>
</div>

View file

@ -3,7 +3,7 @@
{% block title %}Reset Password{% endblock %}
{% block content %}
{% if sakura.lockAuth %}
{% if config('require_activation') %}
<h1 class="stylised" style="line-height: 1.8em; text-align: center;">Resetting password is disabled because of security checkups!</h1>
{% else %}
<div class="loginPage">

View file

@ -1,10 +1,10 @@
<script src="https://www.google.com/recaptcha/api.js" async defer></script>
<div class="g-recaptcha" data-sitekey="{{ sakura.recaptchaPublic }}" style="margin: auto; display: inline-block;"></div>
<div class="g-recaptcha" data-sitekey="{{ config('recaptcha_public') }}" style="margin: auto; display: inline-block;"></div>
<noscript>
<div style="width: 302px; height: 352px; margin: auto; display: inline-block;">
<div style="width: 302px; height: 352px; position: relative;">
<div style="width: 302px; height: 352px; position: absolute;">
<iframe src="https://www.google.com/recaptcha/api/fallback?k={{ sakura.recaptchaPublic }}" frameborder="0" scrolling="no" style="width: 302px; height:352px; border-style: none;"></iframe>
<iframe src="https://www.google.com/recaptcha/api/fallback?k={{ config('recaptcha_public') }}" frameborder="0" scrolling="no" style="width: 302px; height:352px; border-style: none;"></iframe>
</div>
<div style="width: 250px; height: 80px; position: absolute; border-style: none; bottom: 21px; left: 25px; margin: 0; padding: 0; right: 25px;">
<textarea id="g-recaptcha-response" name="g-recaptcha-response" class="g-recaptcha-response" style="width: 250px; height: 80px; border: 1px solid #c1c1c1; margin: 0; padding: 0; resize: none;" value=""></textarea>

View file

@ -1,17 +1,17 @@
<div id="indexPanel">
{% if session.checkLogin %}
<div class="user-container" style="background-image: url({{ route('user.header', user.id) }});">
<div class="default-avatar-setting user-container-avatar" style="background-image: url({{ route('file.avatar', user.id) }}); box-shadow: 0 0 5px {{ user.colour }};"><a href="{{ urls.format('SETTING_MODE', ['friends', 'requests']) }}" class="clean" style="display: block; height: 100%; width: 100%;"></a></div>
<div class="default-avatar-setting user-container-avatar" style="background-image: url({{ route('file.avatar', user.id) }}); box-shadow: 0 0 5px {{ user.colour }};"><a href="{{ route('settings.appearance.avatar') }}" class="clean" style="display: block; height: 100%; width: 100%;"></a></div>
<div class="user-container-info">
<a href="{{ route('user.profile', user.id) }}" class="clean"><h1 style="color: {{ user.colour }}; text-shadow: 0 0 7px {% if user.colour != 'inherit' %}{{ user.colour }}{% else %}#222{% endif %}; padding: 0 0 2px;">{{ user.username }}</h1></a>
{% set friendRequests = user.friends(-1, true)|length %}
{% if friendRequests %}
<a class="default" href="{{ urls.format('SETTING_MODE', ['friends', 'requests']) }}" title="Pending friend requests">{{ friendRequests }} new friend requests</a>
<a class="default" href="{{ route('settings.friends.requests') }}" title="Pending friend requests">{{ friendRequests }} new friend requests</a>
{% endif %}
</div>
</div>
{% else %}
{% if sakura.lockAuth %}
{% if config('require_activation') %}
<div class="head">Whoops!</div>
You caught the site at the wrong moment! Right now registration <i>and</i> logging in is disabled for unspecified reasons. Sorry for the inconvenience but please try again later!
<div class="indexSidePanelLinks">
@ -32,13 +32,13 @@
it has been <b>{{ stats.lastRegDate }} day{{ stats.lastRegDate == 1 ? '' : 's' }}</b> since the last user registered and the forum has <b>{{ stats.topicCount }} thread{% if stats.topicCount != 1 %}s{% endif %}</b> and <b>{{ stats.postCount }} post{% if stats.postCount != 1 %}s{% endif %}</b>.
<div class="head">Online Users</div>
{% if stats.onlineUsers %}
All active users in the past {{ sakura.onlineTimeout / 60 }} minute{% if sakura.onlineTimeout != 60 %}s{% endif %}
All active users in the past {{ config('max_online_time') / 60 }} minute{% if config('max_online_time') != 60 %}s{% endif %}
<table class="panelTable">
{% for amount,onlineUser in stats.onlineUsers %}
<tr><td style="text-align: left;"><a href="{{ route('user.profile', onlineUser.id) }}" style="font-weight: bold; color: {{ onlineUser.colour }};" class="default">{{ onlineUser.username }}</a></td><td style="text-align: right;"><time>{{ onlineUser.lastOnline|date(sakura.dateFormat) }}</time></td></tr>
<tr><td style="text-align: left;"><a href="{{ route('user.profile', onlineUser.id) }}" style="font-weight: bold; color: {{ onlineUser.colour }};" class="default">{{ onlineUser.username }}</a></td><td style="text-align: right;"><time datetime="{{ onlineUser.lastOnline|date('r') }}">{{ onlineUser.lastOnline|date(config('date_format')) }}</time></td></tr>
{% endfor %}
</table>
{% else %}
There were no online users in the past {{ sakura.onlineTimeout / 60 }} minute{% if sakura.onlineTimeout != 60 %}s{% endif %}.
There were no online users in the past {{ config('max_online_time') / 60 }} minute{% if config('max_online_time') != 60 %}s{% endif %}.
{% endif %}
</div>

View file

@ -12,6 +12,6 @@
</div>
<div class="clear"></div>
<div class="news-post-time">
Posted <time>{{ post.time|date(sakura.dateFormat) }}</time>
Posted <time datetime="{{ post.time|date('r') }}">{{ post.time|date(config('date_format')) }}</time>
{% if newsHideCommentCount is not defined %}<a class="default" href="{{ route('news.post', post.id) }}#comments">{{ post.commentCount }} comment{% if post.commentCount != 1 %}s{% endif %}</a>{% endif %}
</div>

View file

@ -6,7 +6,7 @@
<div>{{ category.title }}</div>
{% for mname,mode in category.modes %}
{% if mode.access and mode.menu %}
<a href="{{ urls.format(templates == 'settings' ? 'SETTING_MODE' : 'MANAGE_MODE', [catname, mname]) }}">{{ mode.title }}</a>
<a href="{{ urls.format('SETTING_MODE', [catname, mname]) }}">{{ mode.title }}</a>
{% endif %}
{% endfor %}
{% endfor %}

View file

@ -24,7 +24,7 @@
<div>
{% if forum.lastPost.id %}
<a href="{{ route('forums.thread', forum.lastPost.thread) }}" class="default">{{ forum.lastPost.subject|slice(0, 30) }}{% if forum.lastPost.subject|length > 30 %}...{% endif %}</a><br />
<time>{{ forum.lastPost.time|date(sakura.dateFormat) }}</time> by {% if forum.lastPost.poster.id %}<a href="{{ route('user.profile', forum.lastPost.poster.id) }}" class="default" style="color: {{ forum.lastPost.poster.colour }}; text-shadow: 0 0 5px {% if forumlastPost.poster.colour != 'inherit' %}{{ forum.lastPost.poster.colour }}{% else %}#222{% endif %};">{{ forum.lastPost.poster.username }}</a>{% else %}[deleted user]{% endif %} <a href="{{ route('forums.post', forum.lastPost.id) }}" class="default fa fa-tag"></a>
<time datetime="{{ forum.lastPost.time|date('r') }}">{{ forum.lastPost.time|date(config('date_format')) }}</time> by {% if forum.lastPost.poster.id %}<a href="{{ route('user.profile', forum.lastPost.poster.id) }}" class="default" style="color: {{ forum.lastPost.poster.colour }}; text-shadow: 0 0 5px {% if forumlastPost.poster.colour != 'inherit' %}{{ forum.lastPost.poster.colour }}{% else %}#222{% endif %};">{{ forum.lastPost.poster.username }}</a>{% else %}[deleted user]{% endif %} <a href="{{ route('forums.post', forum.lastPost.id) }}" class="default fa fa-tag"></a>
{% else %}
There are no posts in this forum.<br />&nbsp;
{% endif %}

View file

@ -37,10 +37,10 @@
</div>
<script type="text/javascript">
var titleMax = {{ sakura.forumTitleMaxLength }},
titleMin = {{ sakura.forumTitleMinLength }},
textMax = {{ sakura.forumTextMaxLength }},
textMin = {{ sakura.forumTextMinLength }},
var titleMax = {{ config('forum_title_max') }},
titleMin = {{ config('forum_title_min') }},
textMax = {{ config('forum_text_max') }},
textMin = {{ config('forum_text_min') }},
preview = document.getElementById('postingPreview'),
pTitle = document.getElementById('postingTitle'),
pTitleCont = document.getElementById('postingTitleContainer'),

View file

@ -22,6 +22,6 @@
{% else %}
[deleted user]
{% endif %} <a href="{{ route('forums.post', thread.lastPost.id) }}" class="default fa fa-tag"></a><br />
<time>{{ thread.lastPost.time|date(sakura.dateFormat) }}</time>
<time datetime="{{ thread.lastPost.time|date('r') }}">{{ thread.lastPost.time|date(config('date_format')) }}</time>
</td>
</tr>

View file

@ -19,7 +19,7 @@
<td style="text-align: left; border-bottom: 1px solid #9475b2;">
<a href="{{ route('forums.thread', _t.id) }}" class="default">{{ _t.title }}</a>
</td>
<td class="rightAlign" style="border-bottom: 1px solid #9475b2;"><time>{{ _t.lastPost.time|date(sakura.dateFormat) }}</time></td>
<td class="rightAlign" style="border-bottom: 1px solid #9475b2;"><time datetime="{{ _t.lastPost.time|date('r') }}">{{ _t.lastPost.time|date(config('date_format')) }}</time></td>
</tr>
{% endfor %}
</table>
@ -38,7 +38,7 @@
by
<a href="{{ route('user.profile', _p.poster.id) }}" class="default"><span style="color: {{ _p.poster.colour }};">{{ _p.poster.username }}</span></a>
</td>
<td class="rightAlign" style="border-bottom: 1px solid #9475b2;"><time>{{ _p.time|date(sakura.dateFormat) }}</time></td>
<td class="rightAlign" style="border-bottom: 1px solid #9475b2;"><time datetime="{{ _p.time|date('r') }}">{{ _p.time|date(config('date_format')) }}</time></td>
</tr>
{% endfor %}
</table>
@ -50,8 +50,8 @@
<div class="user-container" style="background-image: url({{ route('user.header', activePoster.id) }});">
<div class="default-avatar-setting user-container-avatar" style="background-image: url({{ route('file.avatar', activePoster.id) }}); box-shadow: 0 0 5px #{% if activePoster.isOnline %}484{% else %}844{% endif %};"></div>
<div class="user-container-info">
<h1 style="color: {{ activePoster.colour }}; text-shadow: 0 0 7px {% if activePoster.colour != 'inherit' %}{{ activePoster.colour }}{% else %}#222{% endif %}; padding: 0 0 2px;" {% if activePoster.getUsernameHistory %} title="Known as {{ activePoster.getUsernameHistory[0].username_old }} before {{ activePoster.getUsernameHistory[0].change_time|date(sakura.dateFormat) }}." {% endif %}>{{ activePoster.username }}</h1>
{% if activePoster.isPremium %}<img src="{{ sakura.contentPath }}/images/tenshi.png" alt="Tenshi" style="vertical-align: middle;" /> {% endif %}<img src="{{ sakura.contentPath }}/images/flags/{{ activePoster.country|lower }}.png" alt="{{ activePoster.country }}" style="vertical-align: middle;" title="{{ activePoster.country(true) }}" /> <span style="font-size: .8em;">{{ activePoster.title }}</span>
<h1 style="color: {{ activePoster.colour }}; text-shadow: 0 0 7px {% if activePoster.colour != 'inherit' %}{{ activePoster.colour }}{% else %}#222{% endif %}; padding: 0 0 2px;" {% if activePoster.getUsernameHistory %} title="Known as {{ activePoster.getUsernameHistory[0].username_old }} before {{ activePoster.getUsernameHistory[0].change_time|date(config('date_format')) }}." {% endif %}>{{ activePoster.username }}</h1>
{% if activePoster.isPremium %}<img src="{{ config('content_path') }}/images/tenshi.png" alt="Tenshi" style="vertical-align: middle;" /> {% endif %}<img src="{{ config('content_path') }}/images/flags/{{ activePoster.country|lower }}.png" alt="{{ activePoster.country }}" style="vertical-align: middle;" title="{{ activePoster.country(true) }}" /> <span style="font-size: .8em;">{{ activePoster.title }}</span>
</div>
</div>
</a>

View file

@ -38,13 +38,13 @@
{% set forumRestore = true %}
{% endif %}
{% if thread.forum != sakura.trashForumId %}
{% if thread.forum != config('forum_trash_id') %}
{% set forumTrash = true %}
{% endif %}
{% endif %}
{% if forum.permission(constant('Sakura\\Perms\\Forum::DELETE_ANY'), user.id) %}
{% if thread.forum == sakura.trashForumId %}
{% if thread.forum == config('forum_trash_id') %}
{% set forumPrune = true %}
{% endif %}
{% endif %}
@ -56,11 +56,11 @@
{% endif %}
{% block css %}
<link rel="stylesheet" href="{{ sakura.contentPath }}/libraries/highlight.css" />
<link rel="stylesheet" href="{{ config('content_path') }}/libraries/highlight.css" />
{% endblock %}
{% block js %}
<script src="{{ sakura.contentPath }}/libraries/highlight.js"></script>
<script src="{{ config('content_path') }}/libraries/highlight.js"></script>
<script type="text/javascript">
hljs.initHighlightingOnLoad();
</script>
@ -86,7 +86,7 @@
{% endif %}
<div class="userdata">
<div class="usertitle">{{ post.poster.title }}</div>
<img src="{{ sakura.contentPath }}/images/tenshi.png" alt="Tenshi"{% if not post.poster.isPremium %} style="opacity: 0;"{% endif %} /> <img src="{{ sakura.contentPath }}/images/flags/{{ post.poster.country|lower }}.png" alt="{{ post.poster.country(true) }}" />{% if post.poster.id == (thread.posts|first).poster.id %} <img src="{{ sakura.contentPath }}/images/op.png" alt="OP" title="Original Poster" />{% endif %}
<img src="{{ config('content_path') }}/images/tenshi.png" alt="Tenshi"{% if not post.poster.isPremium %} style="opacity: 0;"{% endif %} /> <img src="{{ config('content_path') }}/images/flags/{{ post.poster.country|lower }}.png" alt="{{ post.poster.country(true) }}" />{% if post.poster.id == (thread.posts|first).poster.id %} <img src="{{ config('content_path') }}/images/op.png" alt="OP" title="Original Poster" />{% endif %}
{% if session.checkLogin %}
<div class="actions">
{% if (user.id == post.poster.id and forum.permission(constant('Sakura\\Perms\\Forum::EDIT_OWN'), user.id)) or forum.permission(constant('Sakura\\Perms\\Forum::EDIT_ANY'), user.id) %}
@ -111,7 +111,7 @@
<a href="#p{{ post.id }}" class="clean">{{ post.subject|slice(0, 50) }}{% if post.subject|length > 50 %}...{% endif %}</a>
</div>
<div class="date">
<a href="{{ route('forums.post', post.id) }}" class="clean">#{{ post.id }} - <time>{{ post.time|date(sakura.dateFormat) }}</time></a>
<a href="{{ route('forums.post', post.id) }}" class="clean">#{{ post.id }} - <time datetime="{{ post.time|date('r') }}">{{ post.time|date(config('date_format')) }}</time></a>
</div>
<div class="clear"></div>
</div>
@ -139,7 +139,7 @@
<img src="{{ route('file.avatar', user.id) }}" alt="{{ user.username }}" class="avatar" style="box-shadow: 0 3px 7px #484;" />
<div class="userdata">
<div class="usertitle">{{ user.title }}</div>
<img src="{{ sakura.contentPath }}/images/tenshi.png" alt="Tenshi"{% if not user.isPremium %} style="opacity: 0;"{% endif %} /> <img src="{{ sakura.contentPath }}/images/flags/{{ user.country|lower }}.png" alt="{{ user.country(true) }}" />{% if user.id == (thread.posts|first).poster.id %} <img src="{{ sakura.contentPath }}/images/op.png" alt="OP" title="Original Poster" />{% endif %}
<img src="{{ config('content_path') }}/images/tenshi.png" alt="Tenshi"{% if not user.isPremium %} style="opacity: 0;"{% endif %} /> <img src="{{ config('content_path') }}/images/flags/{{ user.country|lower }}.png" alt="{{ user.country(true) }}" />{% if user.id == (thread.posts|first).poster.id %} <img src="{{ config('content_path') }}/images/op.png" alt="OP" title="Original Poster" />{% endif %}
</div>
</td>
<td class="post-content">

View file

@ -2,10 +2,10 @@
<html>
<head>
<!-- META -->
<meta charset="{{ sakura.charset }}" />
<title>{% block title %}{{ sakura.siteName }}{% endblock %}</title>
<meta name="description" content="{{ sakura.siteDesc }}" />
<meta name="keywords" content="{{ sakura.siteTags|join(', ') }}" />
<meta charset="{{ config('charset') }}" />
<title>{% block title %}{{ config('sitename') }}{% endblock %}</title>
<meta name="description" content="{{ config('sitedesc') }}" />
<meta name="keywords" content="{{ config('sitetags')|json_decode|join(', ') }}" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" />
<meta name="msapplication-TileColor" content="#9475b2" />
<meta name="msapplication-TileImage" content="/content/images/icons/ms-icon-144x144.png" />
@ -38,31 +38,30 @@
<link rel="stylesheet" type="text/css" href="{{ sakura.resources }}/css/yuuno.css" />
{{ block('css') }}
<!-- JS -->
<script type="text/javascript" src="{{ sakura.contentPath }}/scripts/sakura.js"></script>
<script type="text/javascript" src="{{ config('content_path') }}/scripts/sakura.js"></script>
<script type="text/javascript" src="{{ sakura.resources }}/js/yuuno.js"></script>
<script type="text/javascript">
// Create an object so we can access certain settings from remote JavaScript files
var sakuraVars = {
"cookie": {
"prefix": "{{ sakura.cookie.prefix }}",
"domain": "{{ sakura.cookie.domain }}",
"path": "{{ sakura.cookie.path }}"
"prefix": "{{ config('cookie_prefix') }}",
"path": "{{ config('cookie_path') }}"
},
"siteName": "{{ sakura.siteName }}",
"content": "{{ sakura.contentPath }}",
"siteName": "{{ config('sitename') }}",
"content": "{{ config('content_path') }}",
"resources": "{{ sakura.resources }}",
"recaptchaEnabled": "{{ sakura.recaptchaEnabled }}",
"recaptchaEnabled": "{{ config('recaptcha') }}",
"minUserLen": {{ sakura.minUsernameLength }},
"maxUserLen": {{ sakura.maxUsernameLength }},
"minPwdEntropy": {{ sakura.minPwdEntropy }},
"minUserLen": {{ config('username_min_length') }},
"maxUserLen": {{ config('username_max_length') }},
"minPwdEntropy": {{ config('min_entropy') }},
"checkLogin": {{ session.checkLogin ? 'true' : 'false' }}
};
// Set cookie prefix and path
Sakura.cookiePrefix = "{{ sakura.cookie.prefix }}";
Sakura.cookiePath = "{{ sakura.cookie.path }}";
Sakura.cookiePrefix = "{{ config('cookie_prefix') }}";
Sakura.cookiePath = "{{ config('cookie_path') }}";
// Error reporter
window.onerror = function(msg, url, line, col, error) {
@ -79,7 +78,7 @@
<div id="container">
<span id="top"></span>
<div class="header" id="header">
<a class="logo" href="{{ route('main.index') }}">{% if sakura.siteLogo %}<img src="{{ sakura.siteLogo }}" alt="{{ sakura.siteName }}" />{% else %}{{ sakura.siteName }}{% endif %}</a>
<a class="logo" href="{{ route('main.index') }}">{% if config('sitelogo') %}<img src="{{ config('sitelogo') }}" alt="{{ config('sitename') }}" />{% else %}{{ config('sitename') }}{% endif %}</a>
<div class="menu fa">
<div class="menu-nav" id="navMenuSite">
<!-- Navigation menu, displayed on left side of the bar. -->
@ -104,7 +103,7 @@
<a class="menu-item fa-cogs" href="{{ route('settings.index') }}" title="Settings"></a>
<a class="menu-item fa-sign-out" href="{{ route('auth.logout') }}?s={{ session_id() }}" title="Logout" id="headerLogoutLink"></a>
{% else %}
{% if sakura.lockAuth %}
{% if config('require_activation') %}
<div class="menu-item fa-lock" style="padding-left: 10px; padding-right: 10px;" title="Authentication is locked"></div>
{% else %}
<a class="menu-item fa-magic" href="{{ route('auth.register') }}" title="Register"></a>
@ -161,10 +160,10 @@
</div>
</noscript>
{% if sakura.announcementImage %}
<div class="headerAnnouncement" style="background-image: url('{{ sakura.announcementImage }}');">
{% if sakura.announcementLink %}
<a href="{{ sakura.announcementLink }}" class="clean"></a>
{% if config('header_announcement_image') %}
<div class="headerAnnouncement" style="background-image: url('{{ config('header_announcement_image') }}');">
{% if config('header_announcement_link') %}
<a href="{{ config('header_announcement_link') }}" class="clean"></a>
{% endif %}
</div>
{% endif %}
@ -209,8 +208,9 @@
// Iterate over them
for (var timeElem in timeElems) {
console.log(timeElems[timeElem].dateTime);
// Attempt to parse it
var parsed = Date.parse(timeElems[timeElem].innerText);
var parsed = Date.parse(timeElems[timeElem].dateTime);
// If it can be parsed do DOM edits
if (!isNaN(parsed)) {

View file

@ -18,8 +18,8 @@
<br />
<h2>Additional information</h2>
<ul style="margin-left: 30px;">
<li>You were banned on {{ ban.issued|date(sakura.dateFormat) }}.</li>
<li>{% if ban.expires %}This ban expires on {{ ban.expires|date(sakura.dateFormat) }}.{% else %}<b>You are permanently banned.</b>{% endif %}</li>
<li>You were banned on {{ ban.issued|date(config('date_format')) }}.</li>
<li>{% if ban.expires %}This ban expires on {{ ban.expires|date(config('date_format')) }}.{% else %}<b>You are permanently banned.</b>{% endif %}</li>
{% if ban.expires %}
<li>You were banned by <a href="{{ route('user.profile', ban.issuer.id) }}" class="default">{{ ban.issuer.username }}</a>.</li>
{% endif %}

View file

@ -5,11 +5,11 @@
<input type="hidden" name="timestamp" value="{{ date().timestamp }}" />
<input type="hidden" name="mode" value="username" />
<h1 class="stylised" style="text-align: center; margin-top: 10px;{% if not eligible %} color: #c44;{% endif %}">You are {% if not eligible %}not {% endif %}eligible for a name change.</h1>
<h3 style="text-align: center;">{% if user.getUsernameHistory %}Your last name change was <time>{{ user.getUsernameHistory[0]['change_time']|date(sakura.dateFormat) }}</time>.{% else %}This is your first username change.{% endif %}</h3>
<h3 style="text-align: center;">{% if user.getUsernameHistory %}Your last name change was <time datetime="{{ user.getUsernameHistory[0]['change_time']|date('r') }}">{{ user.getUsernameHistory[0]['change_time']|date(config('date_format')) }}</time>.{% else %}This is your first username change.{% endif %}</h3>
{% if eligible %}
<div class="profile-field">
<div><h2>Username</h2></div>
<div><input type="text" name="username" placeholder="Enter your new username (at least {{ sakura.minUsernameLength }} and at most {{ sakura.maxUsernameLength }} characters!)" class="inputStyling" /></div>
<div><input type="text" name="username" placeholder="Enter your new username (at least {{ config('username_min_length') }} and at most {{ config('username_max_length') }} characters!)" class="inputStyling" /></div>
</div>
<div class="profile-save">
<input type="submit" value="Save" name="submit" class="inputStyling" />

View file

@ -15,7 +15,7 @@
{{ s.user_agent }}
</td>
<td>
{{ s.session_start|date(sakura.dateFormat) }}
{{ s.session_start|date(config('date_format')) }}
</td>
<td style="width: 90px;">
<form method="post" action="{{ sakura.currentPage }}">

View file

@ -12,7 +12,7 @@
<tr>
<td><a href="/u/{{ message.data.from.user.id }}" class="default" style="font-weight: 700; color: {{ message.data.from.user.colour }};">{{ message.data.from.user.username }}</a></td>
<td><a href="/messages/read/{{ message.id }}" class="default">{{ message.subject }}</a></td>
<td>{{ message.time|date(sakura.dateFormat) }}</td>
<td>{{ message.time|date(config('date_format')) }}</td>
</tr>
{% endfor %}
</tbody>

View file

@ -32,7 +32,7 @@
</div>
</div>
<div class="notif-hist-time">
<time>{{ alert.time|date(sakura.dateFormat) }}</time>
<time datetime="{{ alert.time|date('r') }}">{{ alert.time|date(config('date_format')) }}</time>
</div>
</div>
<div class="clear"></div>

View file

@ -6,6 +6,6 @@
<div class="content standalone" style="text-align: center;">
<h1 class="stylised" style="margin: 1em auto;">Thank you for your contribution!</h1>
<h1 class="fa fa-heart stylised" style="font-size: 20em;"></h1>
<h3>Your Tenshi will expire on {{ user.isPremium|date(sakura.dateFormat) }}.</h3>
<h3>Your Tenshi will expire on {{ user.isPremium|date(config('date_format')) }}.</h3>
</div>
{% endblock %}

View file

@ -1,6 +1,6 @@
{% extends 'global/master.twig' %}
{% block title %}Support {{ sakura.siteName }}{% endblock %}
{% block title %}Support {{ config('sitename') }}{% endblock %}
{% set persistentPremium = user.permission(constant('Sakura\\Perms\\Site::STATIC_PREMIUM')) %}
@ -12,7 +12,7 @@
</div>
{% endif %}
<div class="content support">
<div class="head">Support {{ sakura.siteName }}</div>
<div class="head">Support {{ config('sitename') }}</div>
<div style="font-size: .9em; margin-bottom: 10px;">
<p>In order to keep the site, its services and improvements on it going I need money but I'm not that big of a fan of asking for money without giving anything special in return thus Tenshi exists. Tenshi is the name for our supporter rank which gives you access to an extra set of features (which are listed further down on this page). With your help we can keep adding new stuff, get new hardware and keep the site awesome!</p>
</div>
@ -21,7 +21,7 @@
Your current Tenshi tag
</div>
<div style="margin-bottom: 10px;">
<h3>{% if persistentPremium %}Your rank has persistent Tenshi.{% else %}Your Tenshi tag is valid till {{ user.premiumInfo.expire|date(sakura.dateFormat) }}.{% endif %}</h3>
<h3>{% if persistentPremium %}Your rank has persistent Tenshi.{% else %}Your Tenshi tag is valid till {{ user.premiumInfo.expire|date(config('date_format')) }}.{% endif %}</h3>
<progress value="{{ persistentPremium ? 100 : (100 - (((date().timestamp - user.premiumInfo.start) / (user.premiumInfo.expire - user.premiumInfo.start)) * 100)) }}" max="100" style="width: 100%"></progress>
</div>
{% endif %}

View file

@ -0,0 +1,25 @@
{% extends 'settings/general/master.twig' %}
{% set mode = 'Home' %}
{% block description %}
<p>Welcome to the Settings Panel! From here you can monitor, view and update your profile and preferences.</p>
{% endblock %}
{% block settingsContent %}
<div style="margin: 5px;">
<h1 class="stylised">Common Tasks</h1>
<h2>Profile</h2>
<ul>
<li><a href="{{ route('settings.appearance.avatar') }}" class="default">Change Avatar</a></li>
<li><a href="{{ route('settings.appearance.userpage') }}" class="default">Change Userpage</a></li>
<li><a href="{{ route('settings.appearance.signature') }}" class="default">Change Signature</a></li>
<li><a href="{{ route('settings.general.profile') }}" class="default">Change Profile Details</a></li>
</ul>
<h2>Account</h2>
<ul>
<li><a href="{{ route('settings.advanced.sessions') }}" class="default">Manage Active Sessions</a></li>
<li><a href="{{ route('settings.account.password') }}" class="default">Change Password</a></li>
</ul>
</div>
{% endblock %}

View file

@ -0,0 +1,3 @@
{% extends 'settings/master.twig' %}
{% set category = 'General' %}

View file

@ -0,0 +1,29 @@
{% extends 'global/master.twig' %}
{% set title = category ~ ' / ' ~ mode %}
{% block title %}{{ title }}{% endblock %}
{% block content %}
<div class="content settings messages">
<div class="content-right content-column">
<div class="head">
Navigation
</div>
<div class="right-menu-nav">
{% for name,links in navigation %}
<div>{{ name }}</div>
{% for name,link in links %}
<a href="{{ link }}">{{ name }}</a>
{% endfor %}
{% endfor %}
</div>
</div>
<div class="content-left content-column">
<div class="head">{{ title }}</div>
<div class="settings-explanation">{{ block('description') }}</div>
{{ block('settingsContent') }}
</div>
<div class="clear"></div>
</div>
{% endblock %}

View file

@ -80,16 +80,16 @@
<a href="{{ route('user.profile', user.id) }}" class="default" style="font-weight: bold; color: {{ user.colour }}; text-shadow: 0 0 5px {{ user.colour }};">{{ user.username }}</a>
</td>
<td>
<time>{{ user.registered|date(sakura.dateFormat) }}</time>
<time datetime="{{ user.registered|date('r') }}">{{ user.registered|date(config('date_format')) }}</time>
</td>
<td>
{% if user.lastOnline == 0 %}<i>Never logged in.</i>{% else %}<time>{{ user.lastOnline|date(sakura.dateFormat) }}</time>{% endif %}
{% if user.lastOnline == 0 %}<i>Never logged in.</i>{% else %}<time datetime="{{ user.lastOnline|date('r') }}">{{ user.lastOnline|date(config('date_format')) }}</time>{% endif %}
</td>
<td>
{{ user.title }}
</td>
<td>
<img src="{{ sakura.contentPath }}/images/flags/{{ user.country|lower }}.png" alt="{% if user.country|lower == 'xx' %}?{% else %}{{ user.country(true) }}{% endif %}" title="{% if user.country|lower == 'xx' %}Unknown{% else %}{{ user.country(true) }}{% endif %}" />
<img src="{{ config('content_path') }}/images/flags/{{ user.country|lower }}.png" alt="{% if user.country|lower == 'xx' %}?{% else %}{{ user.country(true) }}{% endif %}" title="{% if user.country|lower == 'xx' %}Unknown{% else %}{{ user.country(true) }}{% endif %}" />
</td>
</tr>
</tbody>
@ -99,7 +99,7 @@
{% for user in users[currPage] %}
<a href="{{ route('user.profile', user.id) }}">{# These comment tags are here to prevent the link extending too far
#}<div class="userBox" id="u{{ user.id }}">{#
#}<img src="{{ sakura.contentPath }}/pixel.png" alt="{{ user.username }}" style="background: url('{{ route('file.avatar', user.id) }}') no-repeat center / contain;" />{#
#}<img src="{{ config('content_path') }}/pixel.png" alt="{{ user.username }}" style="background: url('{{ route('file.avatar', user.id) }}') no-repeat center / contain;" />{#
#}<span class="userBoxUserName" style="color: {{ user.colour }};">{#
#}{{ user.username }}{#
#}</span>{#

View file

@ -80,16 +80,16 @@
<div class="new-profile-info">
<div class="default-avatar-setting new-profile-avatar" style="background-image: url({{ route('file.avatar', profile.id) }}); box-shadow: 0 0 5px #{% if profile.isOnline %}484{% else %}844{% endif %};"></div>
<div class="new-profile-username">
<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 %}<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;" title="{{ profile.country(true) }}" /> <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(config('date_format')) }}." {% endif %}>{{ profile.username }}</h1>
{% if profile.isPremium %}<img src="{{ config('content_path') }}/images/tenshi.png" alt="Tenshi" style="vertical-align: middle;" /> {% endif %}<img src="{{ config('content_path') }}/images/flags/{{ profile.country|lower }}.png" alt="{{ profile.country }}" style="vertical-align: middle;" title="{{ profile.country(true) }}" /> <span style="font-size: .8em;">{{ profile.title }}</span>
</div>
<div class="new-profile-dates">
<b>Joined</b> <time>{{ profile.registered|date(sakura.dateFormat) }}</time>
<b>Joined</b> <time datetime="{{ profile.registered|date('r') }}">{{ profile.registered|date(config('date_format')) }}</time>
<br />
{% if profile.lastOnline < 1 %}
<b>{{ profile.username }} hasn't logged in yet.</b>
{% else %}
<b>Last online</b> <time>{{ profile.lastOnline|date(sakura.dateFormat) }}</time>
<b>Last online</b> <time datetime="{{ profile.lastOnline|date('r') }}">{{ profile.lastOnline|date(config('date_format')) }}</time>
{% endif %}
{% 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>&nbsp;
@ -111,7 +111,7 @@
{% if session.checkLogin %}
<div class="new-profile-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>
<a class="fa fa-pencil-square-o" title="Edit your profile" href="{{ route('settings.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="javascript:void(0);" onclick="{% if user.isFriends(profile.id) == 0 %}addFriend({{ profile.id }}){% else %}removeFriend({{ profile.id }}){% endif %}"></a>