From d55ae7e936db9daede48f891a53c844a6941add2 Mon Sep 17 00:00:00 2001 From: flashwave Date: Sat, 27 Feb 2016 17:46:16 +0100 Subject: [PATCH] r20160227 --- libraries/Controllers/Auth.php | 24 --- libraries/Controllers/AuthController.php | 178 ++++++++++++++++++ .../{Files.php => FileController.php} | 2 +- .../{Forums.php => ForumController.php} | 2 +- .../{Meta.php => MetaController.php} | 2 +- .../{Premium.php => PremiumController.php} | 2 +- .../{User.php => UserController.php} | 33 +++- libraries/Router.php | 11 +- libraries/Template.php | 6 + libraries/Users.php | 124 ------------ public/authenticate.php | 49 +---- public/robots.txt | 2 + routes.php | 160 ++-------------- sakura.php | 16 +- templates/yuuno/elements/comment.twig | 2 +- templates/yuuno/elements/comments.twig | 2 +- templates/yuuno/elements/indexPanel.twig | 17 +- templates/yuuno/elements/newsPost.twig | 8 +- templates/yuuno/forum/forum.twig | 4 +- templates/yuuno/forum/forumEntry.twig | 2 +- templates/yuuno/global/master.twig | 114 +++-------- templates/yuuno/main/authenticate.twig | 29 --- templates/yuuno/main/banned.twig | 3 +- templates/yuuno/main/infopage.twig | 2 +- templates/yuuno/main/login.twig | 65 ++++--- templates/yuuno/main/memberlist.twig | 28 +-- templates/yuuno/main/profile.twig | 8 +- templates/yuuno/main/support.twig | 4 +- templates/yuuno/main/supporttracker.twig | 4 +- templates/yuuno/profile/friends.twig | 6 +- 30 files changed, 358 insertions(+), 551 deletions(-) delete mode 100644 libraries/Controllers/Auth.php create mode 100644 libraries/Controllers/AuthController.php rename libraries/Controllers/{Files.php => FileController.php} (99%) rename libraries/Controllers/{Forums.php => ForumController.php} (98%) rename libraries/Controllers/{Meta.php => MetaController.php} (99%) rename libraries/Controllers/{Premium.php => PremiumController.php} (99%) rename libraries/Controllers/{User.php => UserController.php} (82%) create mode 100644 public/robots.txt diff --git a/libraries/Controllers/Auth.php b/libraries/Controllers/Auth.php deleted file mode 100644 index d270d29..0000000 --- a/libraries/Controllers/Auth.php +++ /dev/null @@ -1,24 +0,0 @@ - - */ -class Auth extends Controller -{ - public function login() - { - return Template::render('main/login'); - } -} diff --git a/libraries/Controllers/AuthController.php b/libraries/Controllers/AuthController.php new file mode 100644 index 0000000..182c58a --- /dev/null +++ b/libraries/Controllers/AuthController.php @@ -0,0 +1,178 @@ + + */ +class AuthController extends Controller +{ + protected function touchRateLimit($user, $mode = 0) + { + DB::table('login_attempts') + ->insert([ + 'attempt_success' => $mode, + 'attempt_timestamp' => time(), + 'attempt_ip' => Net::pton(Net::IP()), + 'user_id' => $user, + ]); + } + + public function logout() + { + // Check if user is logged in + $check = Users::checkLogin(); + + if (!$check || !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')); + + Template::vars(['page' => ['success' => 0, 'redirect' => $redirect, 'message' => $message]]); + + return Template::render('global/information'); + } + + // Destroy the active session + (new Session($check[0], $check[1]))->destroy(); + + // Return true indicating a successful logout + $message = 'Goodbye!'; + $redirect = Router::route('auth.login'); + + Template::vars(['page' => ['success' => 1, 'redirect' => $redirect, 'message' => $message]]); + + return Template::render('global/information'); + } + + public function loginGet() + { + return Template::render('main/login'); + } + + public function loginPost() + { + // Preliminarily set login to failed + $success = 0; + $redirect = Router::route('auth.login'); + + // Check if authentication is disallowed + if (Config::get('lock_authentication')) { + $message = 'Logging in is disabled for security checkups! Try again later.'; + Template::vars(['page' => ['success' => $success, 'redirect' => $redirect, 'message' => $message]]); + return Template::render('global/information'); + } + + // Get request variables + $username = isset($_REQUEST['username']) ? $_REQUEST['username'] : null; + $password = isset($_REQUEST['password']) ? $_REQUEST['password'] : null; + $remember = isset($_REQUEST['remember']); + + // Check if we haven't hit the rate limit + $rates = DB::table('login_attempts') + ->where('attempt_ip', Net::pton(Net::IP())) + ->where('attempt_timestamp', '>', time() - 1800) + ->where('attempt_success', '0') + ->count(); + + if ($rates > 4) { + $message = 'Your have hit the login rate limit, try again later.'; + Template::vars(['page' => ['success' => $success, 'redirect' => $redirect, 'message' => $message]]); + return Template::render('global/information'); + } + + // Get account data + $user = User::construct(Utils::cleanString($username, true, true)); + + // Check if the user that's trying to log in actually exists + if ($user->id === 0) { + $this->touchRateLimit($user->id); + $message = 'The user you tried to log into does not exist.'; + Template::vars(['page' => ['success' => $success, 'redirect' => $redirect, 'message' => $message]]); + return Template::render('global/information'); + } + + // Validate password + switch ($user->passwordAlgo) { + // Disabled + case 'disabled': + $this->touchRateLimit($user->id); + $message = 'Logging into this account is disabled.'; + Template::vars(['page' => ['success' => $success, 'redirect' => $redirect, 'message' => $message]]); + return Template::render('global/information'); + + // Default hashing method + default: + if (!Hashing::validatePassword($password, [ + $user->passwordAlgo, + $user->passwordIter, + $user->passwordSalt, + $user->passwordHash, + ])) { + $this->touchRateLimit($user->id); + $message = 'The password you entered was invalid.'; + Template::vars(['page' => ['success' => $success, 'redirect' => $redirect, 'message' => $message]]); + return Template::render('global/information'); + } + } + + // Check if the user has the required privs to log in + if ($user->permission(Site::DEACTIVATED)) { + $this->touchRateLimit($user->id); + $message = 'Your account does not have the required permissions to log in.'; + Template::vars(['page' => ['success' => $success, 'redirect' => $redirect, 'message' => $message]]); + return Template::render('global/information'); + } + + // Create a new session + $session = new Session($user->id); + + // Generate a session key + $sessionKey = $session->create($remember); + + // User ID cookie + setcookie( + Config::get('cookie_prefix') . 'id', + $user->id, + time() + 604800, + Config::get('cookie_path') + ); + + // Session ID cookie + setcookie( + Config::get('cookie_prefix') . 'session', + $sessionKey, + time() + 604800, + Config::get('cookie_path') + ); + + $this->touchRateLimit($user->id, 1); + + $success = 1; + $redirect = $user->lastOnline ? (isset($_REQUEST['redirect']) ? $_REQUEST['redirect'] : Router::route('main.index')) : Router::route('main.infopage', 'welcome'); + $message = 'Welcome' . ($user->lastOnline ? ' back' : '') . '!'; + + Template::vars(['page' => ['success' => $success, 'redirect' => $redirect, 'message' => $message]]); + + return Template::render('global/information'); + } +} diff --git a/libraries/Controllers/Files.php b/libraries/Controllers/FileController.php similarity index 99% rename from libraries/Controllers/Files.php rename to libraries/Controllers/FileController.php index 3be83f8..f5bb5be 100644 --- a/libraries/Controllers/Files.php +++ b/libraries/Controllers/FileController.php @@ -18,7 +18,7 @@ use Sakura\Perms\Site; * @package Sakura * @author Julian van de Groep */ -class Files extends Controller +class FileController extends Controller { private function serveImage($data, $mime, $name) { diff --git a/libraries/Controllers/Forums.php b/libraries/Controllers/ForumController.php similarity index 98% rename from libraries/Controllers/Forums.php rename to libraries/Controllers/ForumController.php index 7850798..e16fdee 100644 --- a/libraries/Controllers/Forums.php +++ b/libraries/Controllers/ForumController.php @@ -23,7 +23,7 @@ use Sakura\Utils; * @package Sakura * @author Julian van de Groep */ -class Forums extends Controller +class ForumController extends Controller { /** * Serves the forum index. diff --git a/libraries/Controllers/Meta.php b/libraries/Controllers/MetaController.php similarity index 99% rename from libraries/Controllers/Meta.php rename to libraries/Controllers/MetaController.php index 4da8bca..02e1a65 100644 --- a/libraries/Controllers/Meta.php +++ b/libraries/Controllers/MetaController.php @@ -22,7 +22,7 @@ use Sakura\Utils; * @package Sakura * @author Julian van de Groep */ -class Meta extends Controller +class MetaController extends Controller { /** * Serves the site index. diff --git a/libraries/Controllers/Premium.php b/libraries/Controllers/PremiumController.php similarity index 99% rename from libraries/Controllers/Premium.php rename to libraries/Controllers/PremiumController.php index c05cc18..6a1a87b 100644 --- a/libraries/Controllers/Premium.php +++ b/libraries/Controllers/PremiumController.php @@ -22,7 +22,7 @@ use Sakura\Perms\Site; * @package Sakura * @author Julian van de Groep */ -class Premium extends Controller +class PremiumController extends Controller { public function index() { diff --git a/libraries/Controllers/User.php b/libraries/Controllers/UserController.php similarity index 82% rename from libraries/Controllers/User.php rename to libraries/Controllers/UserController.php index 6ab8024..f6b529f 100644 --- a/libraries/Controllers/User.php +++ b/libraries/Controllers/UserController.php @@ -21,7 +21,7 @@ use Sakura\Utils; * @package Sakura * @author Julian van de Groep */ -class User extends Controller +class UserController extends Controller { /** * Display the profile of a user. @@ -99,7 +99,7 @@ class User extends Controller * * @return bool|string The memberlist. */ - public function members($rank = 0) + public function members($rank = null) { global $currentUser; @@ -108,14 +108,31 @@ class User extends Controller return Template::render('global/restricted'); } + // Get all ranks + + // Execute query + $getRanks = DB::table('ranks') + ->get(['rank_id']); + + // Define variable + $ranks = []; + + // Add the empty rank + $ranks[0] = Rank::construct(0); + + // Reorder shit + foreach ($getRanks as $sortRank) { + $ranks[$sortRank->rank_id] = Rank::construct($sortRank->rank_id); + } + + // Get the active rank + $rank = array_key_exists($rank, $ranks) ? $rank : ($rank ? 0 : 2); + // Set parse variables Template::vars([ - 'memberlist' => [ - 'ranks' => ($_MEMBERLIST_RANKS = \Sakura\Users::getAllRanks()), - 'active' => ($_MEMBERLIST_ACTIVE = (array_key_exists($rank, $_MEMBERLIST_RANKS) ? $rank : 2)), - 'users' => Rank::construct($_MEMBERLIST_ACTIVE)->users(), - 'membersPerPage' => Config::get('members_per_page'), - ] + 'ranks' => $ranks, + 'rank' => $rank, + 'membersPerPage' => Config::get('members_per_page'), ]); // Render the template diff --git a/libraries/Router.php b/libraries/Router.php index 8850090..6376dab 100644 --- a/libraries/Router.php +++ b/libraries/Router.php @@ -118,9 +118,16 @@ class Router * * @return string The generated URI. */ - public static function url($name, $args = null) + public static function route($name, $args = null) { - return self::$router->route($name, $args); + // Array-ify the arguments + if ($args !== null && !is_array($args)) { + $temp = $args; + $args = []; + $args[] = $temp; + } + + return self::$basePath . self::$router->route($name, $args); } /** diff --git a/libraries/Template.php b/libraries/Template.php index c2bb7a9..9b59465 100644 --- a/libraries/Template.php +++ b/libraries/Template.php @@ -10,6 +10,7 @@ namespace Sakura; use Twig_Environment; use Twig_Extension_StringLoader; use Twig_Loader_Filesystem; +use Twig_SimpleFunction; /** * Sakura wrapper for Twig. @@ -98,6 +99,11 @@ class Template // Load String template loader self::$template->addExtension(new Twig_Extension_StringLoader()); + + // Add route function + self::$template->addFunction(new Twig_SimpleFunction('route', function ($name, $args = null) { + return Router::route($name, $args); + })); } /** diff --git a/libraries/Users.php b/libraries/Users.php index 9edd8d1..c30ffcf 100644 --- a/libraries/Users.php +++ b/libraries/Users.php @@ -98,130 +98,6 @@ class Users return [$uid, $sid]; } - /** - * Log in to an account. - * - * @param string $username The username. - * @param string $password The password. - * @param bool $remember Stay logged in "forever"? - * @param bool $cookies Set cookies? - * - * @return array Return the status. - */ - public static function login($username, $password, $remember = false, $cookies = true) - { - // Check if authentication is disallowed - if (Config::get('lock_authentication')) { - return [0, 'AUTH_LOCKED']; - } - - // Check if we haven't hit the rate limit - $rates = DBv2::prepare('SELECT * FROM `{prefix}login_attempts` WHERE `attempt_ip` = :ip AND `attempt_timestamp` > :time AND `attempt_success` = 0'); - $rates->execute([ - 'ip' => Net::pton(Net::IP()), - 'time' => time() - 1800, - ]); - $rates = $rates->fetchAll(\PDO::FETCH_ASSOC); - - if (count($rates) > 4) { - return [0, 'RATE_LIMIT']; - } - - // Check if the user that's trying to log in actually exists - if (!$uid = self::userExists($username, false)) { - return [0, 'USER_NOT_EXIST']; - } - - // Get account data - $user = User::construct($uid); - - // Validate password - switch ($user->passwordAlgo) { - // Disabled - case 'disabled': - return [0, 'NO_LOGIN']; - - // Default hashing method - default: - if (!Hashing::validatePassword($password, [ - $user->passwordAlgo, - $user->passwordIter, - $user->passwordSalt, - $user->passwordHash, - ])) { - return [0, 'INCORRECT_PASSWORD', $user->id, $user->passwordChan]; - } - } - - // Check if the user has the required privs to log in - if ($user->permission(Site::DEACTIVATED)) { - return [0, 'NOT_ALLOWED', $user->id]; - } - - // Create a new session - $session = new Session($user->id); - - // Generate a session key - $sessionKey = $session->create($remember); - - // Set cookies - if ($cookies) { - // User ID cookie - setcookie( - Config::get('cookie_prefix') . 'id', - $user->id, - time() + 604800, - Config::get('cookie_path') - ); - - // Session ID cookie - setcookie( - Config::get('cookie_prefix') . 'session', - $sessionKey, - time() + 604800, - Config::get('cookie_path') - ); - } - - // Successful login! (also has a thing for the legacy password system) - return [1, 'LOGIN_SUCCESS', $user->id]; - } - - /** - * Logout - * - * @return bool Was the logout successful? - */ - public static function logout() - { - // Check if user is logged in - if (!$check = self::checkLogin()) { - return false; - } - - // Destroy the active session - (new Session($check[0], $check[1]))->destroy(); - - // Unset User ID - setcookie( - Config::get('cookie_prefix') . 'id', - 0, - time() - 60, - Config::get('cookie_path') - ); - - // Unset Session ID - setcookie( - Config::get('cookie_prefix') . 'session', - '', - time() - 60, - Config::get('cookie_path') - ); - - // Return true indicating a successful logout - return true; - } - /** * Register a new account. * diff --git a/public/authenticate.php b/public/authenticate.php index ffc613a..a209172 100644 --- a/public/authenticate.php +++ b/public/authenticate.php @@ -65,16 +65,11 @@ if (isset($_REQUEST['mode'])) { if ($continue) { switch ($_REQUEST['mode']) { case 'logout': - // Attempt logout - $logout = Users::logout(); - - // Add page specific data + // Add page specific things $renderData['page'] = [ - - 'redirect' => ($logout ? $_REQUEST['redirect'] : $urls->format('SITE_LOGIN')), - 'message' => $logout ? 'You are now logged out.' : 'An unknown error occurred.', - 'success' => $logout ? 1 : 0, - + 'redirect' => Router::route('main.index'), + 'message' => 'Wrong logout page.', + 'success' => 0, ]; break; @@ -165,41 +160,11 @@ if (isset($_REQUEST['mode'])) { // Login processing case 'login': - // Attempt login - $login = Users::login($_REQUEST['username'], $_REQUEST['password'], isset($_REQUEST['remember'])); - - // Array containing "human understandable" messages - $messages = [ - - 'AUTH_LOCKED' => 'Authentication is currently not allowed, try again later.', - 'USER_NOT_EXIST' => 'The user you tried to log into does not exist.', - 'INCORRECT_PASSWORD' => 'The password you entered was invalid.', - 'NOT_ALLOWED' => 'Your account does not have the required permissions to log in.', - 'NO_LOGIN' => 'Logging into this account is disabled.', - 'RATE_LIMIT' => 'Your IP has hit the login rate limit, try again later.', - 'LOGIN_SUCCESS' => 'Login successful!', - - ]; - - // Check if we're not RATE_LIMIT - if ($login[1] != 'RATE_LIMIT') { - // Add to database - DBv2::prepare('INSERT INTO `{prefix}login_attempts` (`attempt_success`, `attempt_timestamp`, `attempt_ip`, `user_id`) VALUES (:succ, :time, :ip, :user)') - ->execute([ - 'succ' => $login[0], - 'time' => time(), - 'ip' => Net::pton(Net::IP()), - 'user' => isset($login[2]) ? $login[2] : 0, - ]); - } - // Add page specific things $renderData['page'] = [ - - 'redirect' => $login[0] ? (User::construct($login[2])->lastOnline ? $_REQUEST['redirect'] : $urls->format('INFO_PAGE', ['welcome'])) : $urls->format('SITE_LOGIN'), - 'message' => $messages[$login[1]], - 'success' => $login[0], - + 'redirect' => Router::route('auth.login'), + 'message' => 'Wrong login page.', + 'success' => 0, ]; break; diff --git a/public/robots.txt b/public/robots.txt new file mode 100644 index 0000000..d346249 --- /dev/null +++ b/public/robots.txt @@ -0,0 +1,2 @@ +User-agent: * +Disallow: /api/ diff --git a/routes.php b/routes.php index aeb7b0a..2527cb5 100644 --- a/routes.php +++ b/routes.php @@ -7,38 +7,40 @@ namespace Sakura; // Meta pages -Router::get('/', 'Meta@index', 'main.index'); -Router::get('/faq', 'Meta@faq', 'main.faq'); -Router::get('/search', 'Meta@search', 'main.search'); -Router::get('/p/{id}', 'Meta@infoPage', 'main.infopage'); +Router::get('/', 'MetaController@index', 'main.index'); +Router::get('/faq', 'MetaController@faq', 'main.faq'); +Router::get('/search', 'MetaController@search', 'main.search'); +Router::get('/p/{id}', 'MetaController@infoPage', 'main.infopage'); // Auth -Router::get('/login', 'Auth@login', 'auth.login'); +Router::get('/login', 'AuthController@loginGet', 'auth.login'); +Router::post('/login', 'AuthController@loginPost', 'auth.login'); +Router::get('/logout', 'AuthController@logout', 'auth.logout'); // News -Router::get('/news', 'Meta@news', 'news.index'); -Router::get('/news/{category}', 'Meta@news', 'news.category'); -Router::get('/news/{category}/{id}', 'Meta@news', 'news.post'); +Router::get('/news', 'MetaController@news', 'news.index'); +Router::get('/news/{category}', 'MetaController@news', 'news.category'); +Router::get('/news/{category}/{id}', 'MetaController@news', 'news.post'); // Forum -Router::get('/forum', 'Forums@index', 'forums.index'); -Router::get('/forum/{id}', 'Forums@forum', 'forums.forum'); +Router::get('/forum', 'ForumController@index', 'forums.index'); +Router::get('/forum/{id}', 'ForumController@forum', 'forums.forum'); // Members -Router::get('/members', 'User@members', 'members.index'); -Router::get('/members/{rank}', 'User@members', 'members.rank'); +Router::get('/members', 'UserController@members', 'members.index'); +Router::get('/members/{rank}', 'UserController@members', 'members.rank'); // User -Router::get('/u/{id}', 'User@profile', 'user.profile'); -Router::get('/u/{id}/header', 'Files@header', 'user.header'); +Router::get('/u/{id}', 'UserController@profile', 'user.profile'); +Router::get('/u/{id}/header', 'FileController@header', 'user.header'); // Files -Router::get('/a/{id}', 'Files@avatar', 'file.avatar'); -Router::get('/bg/{id}', 'Files@background', 'file.background'); +Router::get('/a/{id}', 'FileController@avatar', 'file.avatar'); +Router::get('/bg/{id}', 'FileController@background', 'file.background'); // Premium -Router::get('/support', 'Premium@index', 'premium.index'); -Router::get('/support/tracker', 'Premium@tracker', 'premium.tracker'); +Router::get('/support', 'PremiumController@index', 'premium.index'); +Router::get('/support/tracker', 'PremiumController@tracker', 'premium.tracker'); // Management /* @@ -71,125 +73,3 @@ Router::get('/support/tracker', 'Premium@tracker', 'premium.tracker'); * - Management * - Errors */ - -// Redirections -Router::any('/index.php', function () { - // Info pages - if (isset($_REQUEST['p'])) { - header('Location: /p/' . $_REQUEST['p']); - return; - } - - // Forum index - if (isset($_REQUEST['forum']) && $_REQUEST['forum']) { - header('Location: /forum'); - return; - } - - // Site index - header('Location: /'); -}); - -Router::any('/news.php', function () { - // Category + post - if (isset($_REQUEST['cat']) && isset($_REQUEST['id'])) { - header('Location: /news/' . $_REQUEST['cat'] . '/'. $_REQUEST['id']); - return; - } - - // Category - if (isset($_REQUEST['cat'])) { - header('Location: /news/' . $_REQUEST['cat']); - return; - } - - // Post in the main category - if (isset($_REQUEST['id'])) { - header('Location: /news/' . $_REQUEST['id']); - return; - } - - // All posts in main category - 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('/support.php', function () { - if (isset($_GET['tracker'])) { - header('Location: /support/tracker'); - return; - } - - header('Location: /support'); -}); - -Router::any('/imageserve.php', function () { - // Category + post - if (isset($_REQUEST['u']) && isset($_REQUEST['m'])) { - switch ($_REQUEST['m']) { - case 'avatar': - header('Location: /a/' . $_REQUEST['u']); - return; - case 'background': - header('Location: /bg/' . $_REQUEST['u']); - return; - case 'header': - header('Location: /u/' . $_REQUEST['u'] . '/header'); - return; - } - } - - header('Location: /bg/0'); -}); - -Router::any('/faq.php', function () { - header('Location: /faq'); -}); - -Router::any('/search.php', function () { - header('Location: /search'); -}); diff --git a/sakura.php b/sakura.php index 1c3a8f9..8eb2152 100644 --- a/sakura.php +++ b/sakura.php @@ -8,9 +8,7 @@ namespace Sakura; // Define Sakura version -define('SAKURA_VERSION', '20160219'); -define('SAKURA_VLABEL', 'Amethyst'); -define('SAKURA_COLOUR', '#9966CC'); +define('SAKURA_VERSION', '20160227'); // Define Sakura Path define('ROOT', __DIR__ . '/'); @@ -27,14 +25,17 @@ mb_internal_encoding('utf-8'); // Stop the execution if the PHP Version is older than 5.5.0 if (version_compare(phpversion(), '5.5.0', '<')) { - die('Sakura requires at least PHP 5.5.0, please upgrade to a newer PHP version.'); + throw new \Exception('Sakura requires at least PHP 5.5.0, please upgrade to a newer PHP version.'); } -// Include third-party libraries -if (!@include_once ROOT . 'vendor/autoload.php') { - die('Autoloader not found, did you run composer?'); +// Check if the composer autoloader exists +if (!file_exists(ROOT . 'vendor/autoload.php')) { + throw new \Exception('Autoloader not found, did you run composer?'); } +// Require composer libraries +require_once ROOT . 'vendor/autoload.php'; + // Setup the autoloader spl_autoload_register(function ($className) { // Replace \ with / @@ -187,6 +188,7 @@ if (!defined('SAKURA_NO_TPL')) { 'get' => $_GET, 'post' => $_POST, + 'server' => $_SERVER, ]); // Add the default render data diff --git a/templates/yuuno/elements/comment.twig b/templates/yuuno/elements/comment.twig index 6c5a304..a518cac 100644 --- a/templates/yuuno/elements/comment.twig +++ b/templates/yuuno/elements/comment.twig @@ -1,6 +1,6 @@
  • - {{ comment.comment_poster.username }} + {{ comment.comment_poster.username }}
    diff --git a/templates/yuuno/elements/comments.twig b/templates/yuuno/elements/comments.twig index 1ade73b..1d3786b 100644 --- a/templates/yuuno/elements/comments.twig +++ b/templates/yuuno/elements/comments.twig @@ -7,7 +7,7 @@
    -
    +
    diff --git a/templates/yuuno/elements/indexPanel.twig b/templates/yuuno/elements/indexPanel.twig index 740b6bd..1aaef0b 100644 --- a/templates/yuuno/elements/indexPanel.twig +++ b/templates/yuuno/elements/indexPanel.twig @@ -1,7 +1,7 @@
    {% if session.checkLogin %}
    Hi, {{ user.username }}!
    - {{ user.username }} + {{ user.username }}
    diff --git a/templates/yuuno/elements/newsPost.twig b/templates/yuuno/elements/newsPost.twig index 725a20c..0caae65 100644 --- a/templates/yuuno/elements/newsPost.twig +++ b/templates/yuuno/elements/newsPost.twig @@ -1,8 +1,8 @@ -{% if not (viewPost and postExists) %}{{ post.news_title }}{% endif %} +{% if not (viewPost and postExists) %}{{ post.news_title }}{% endif %}
    - Posted {% if not (viewPost and postExists) %} {{ post.news_comments.count }} comment{% if post.news_comments.count != 1 %}s{% endif %}{% endif %} + Posted {% if not (viewPost and postExists) %} {{ post.news_comments.count }} comment{% if post.news_comments.count != 1 %}s{% endif %}{% endif %}
    diff --git a/templates/yuuno/forum/forum.twig b/templates/yuuno/forum/forum.twig index fa168f7..fd609d4 100644 --- a/templates/yuuno/forum/forum.twig +++ b/templates/yuuno/forum/forum.twig @@ -4,7 +4,7 @@ {% if forum.type == 1 %} {% if forum.forums|length and forum.permission(constant('Sakura\\Perms\\Forum::VIEW'), user.id) %}
    - {% if forum.type != 1 %}Subforums{% else %}{{ forum.name }}{% endif %} + {% if forum.type != 1 %}Subforums{% else %}{{ forum.name }}{% endif %}
    {% for forum in forum.forums %} {% include 'forum/forumEntry.twig' %} @@ -19,7 +19,7 @@ {% set threads = forum.threads|batch(25) %} {% set paginationPages = threads %} - {% set paginationUrl %}{{ urls.format('FORUM_SUB', [forum.id]) }}{% endset %} + {% set paginationUrl %}{{ route('forums.forum', forum.id) }}{% endset %} {% include 'forum/forumBtns.twig' %} {% if forum.threads %} diff --git a/templates/yuuno/forum/forumEntry.twig b/templates/yuuno/forum/forumEntry.twig index 93b1f8f..7a8e15b 100644 --- a/templates/yuuno/forum/forumEntry.twig +++ b/templates/yuuno/forum/forumEntry.twig @@ -2,7 +2,7 @@
    - +
    {{ forum.description }} {% if forum.forums|length %} diff --git a/templates/yuuno/global/master.twig b/templates/yuuno/global/master.twig index 63ac67b..8825512 100644 --- a/templates/yuuno/global/master.twig +++ b/templates/yuuno/global/master.twig @@ -73,36 +73,36 @@
    + {% endif %} {% endblock %} {% block content %} @@ -65,7 +67,7 @@ There are a few possible reasons for this:
    • They changed their username.
    • -
    • They may have been abyss'd.
    • +
    • They may have been restricted.
    • You made a typo.
    • They never existed.
    @@ -74,9 +76,9 @@ {% else %}
    -
    +
    -
    +

    {{ profile.username }}

    {% if profile.isPremium[0] %}Tenshi {% endif %}{{ profile.country }} {{ profile.title }} diff --git a/templates/yuuno/main/support.twig b/templates/yuuno/main/support.twig index 666aec3..3cc55a6 100644 --- a/templates/yuuno/main/support.twig +++ b/templates/yuuno/main/support.twig @@ -13,7 +13,7 @@
    Support {{ sakura.siteName }}

    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!

    -

    Ever wonder what happens on the financial side of things? View the donation tracker!

    +

    Ever wonder what happens on the financial side of things? View the donation tracker!

    {% if page.current[0] %}
    @@ -109,7 +109,7 @@ {% endif %}
    {% if session.checkLogin and user.permission(constant('Sakura\\Perms\\Site::OBTAIN_PREMIUM')) %} - + diff --git a/templates/yuuno/main/supporttracker.twig b/templates/yuuno/main/supporttracker.twig index f646baf..592a738 100644 --- a/templates/yuuno/main/supporttracker.twig +++ b/templates/yuuno/main/supporttracker.twig @@ -3,7 +3,7 @@ {% block title %}Donation Tracker{% endblock %} {% set paginationPages = tracker.table|batch(20) %} -{% set paginationUrl %}{{ urls.format('SITE_DONATE_TRACK') }}{% endset %} +{% set paginationUrl %}{{ route('premium.tracker') }}{% endset %} {% block css %}