From 5cce6c3e82fec9fdc51bba24e3a55bc036859ace Mon Sep 17 00:00:00 2001 From: flashwave Date: Thu, 10 Dec 2015 21:55:51 +0100 Subject: [PATCH] r20151210 Signed-off-by: Flashwave --- libraries/Forum/Forum.php | 126 +++++++++++++---------- libraries/Forum/Thread.php | 44 ++++++-- libraries/Main.php | 13 --- libraries/Template.php | 5 +- public/404.php | 2 +- public/authenticate.php | 8 +- public/faq.php | 2 +- public/group.php | 2 +- public/index.php | 4 +- public/manage.php | 2 +- public/members.php | 4 +- public/news.php | 2 +- public/posting.php | 14 +-- public/profile.php | 2 +- public/report.php | 2 +- public/search.php | 2 +- public/settings.php | 149 ++-------------------------- public/support.php | 6 +- public/viewforum.php | 8 +- public/viewtopic.php | 4 +- sakura.php | 31 +++--- templates/misaki/global/master.tpl | 1 + templates/yuuno/forum/viewtopic.tpl | 2 +- 23 files changed, 166 insertions(+), 269 deletions(-) diff --git a/libraries/Forum/Forum.php b/libraries/Forum/Forum.php index b654d13..d3e3805 100644 --- a/libraries/Forum/Forum.php +++ b/libraries/Forum/Forum.php @@ -21,10 +21,10 @@ class Forum public $category = 0; public $type = 0; public $icon = ""; - public $firstPost = null; - public $lastPost = null; - public $forums = []; - public $threads = []; + private $_firstPost = null; + private $_lastPost = null; + private $_forums = []; + private $_threads = []; // Constructor public function __construct($forumId = 0) @@ -44,32 +44,27 @@ class Forum } elseif ($forumId != 0) { $this->id = -1; } - - // Populate the forums array - $this->forums = $this->getForums(); - - // and the threads array - $this->threads = $this->getThreads(); - - // and the first post - $this->firstPost = $this->getFirstPost(); - - // and finally the last post - $this->lastPost = $this->getLastPost(); } // Subforums - public function getForums() + public function forums() { - // Get all rows with the category id set to the forum id - $forumRows = Database::fetch('forums', true, ['forum_category' => [$this->id, '=']]); + // Check if _forums is populated + if (!count($this->_forums)) { + // Get all rows with the category id set to the forum id + $forumRows = Database::fetch('forums', true, ['forum_category' => [$this->id, '=']]); - // Create a storage array - $forums = []; + // Create a storage array + $forums = []; - // Create new objects for each forum - foreach ($forumRows as $forum) { - $forums[$forum['forum_id']] = new Forum($forum['forum_id']); + // Create new objects for each forum + foreach ($forumRows as $forum) { + $forums[$forum['forum_id']] = new Forum($forum['forum_id']); + } + + $this->_forums = $forums; + } else { + $forums = $this->_forums; } // Return the forum objects @@ -77,22 +72,29 @@ class Forum } // Threads - public function getThreads() + public function threads() { - // Get all rows with the forum id for this forum - $announcements = Database::fetch('topics', true, ['forum_id' => [$this->id, '='], 'topic_type' => ['2', '=']], ['topic_last_reply', true]); - $sticky = Database::fetch('topics', true, ['forum_id' => [$this->id, '='], 'topic_type' => ['1', '=']], ['topic_last_reply', true]); - $regular = Database::fetch('topics', true, ['forum_id' => [$this->id, '='], 'topic_type' => ['0', '=']], ['topic_last_reply', true]); + // Check if _threads is populated + if (!count($this->_threads)) { + // Get all rows with the forum id for this forum + $announcements = Database::fetch('topics', true, ['forum_id' => [$this->id, '='], 'topic_type' => ['2', '=']], ['topic_last_reply', true]); + $sticky = Database::fetch('topics', true, ['forum_id' => [$this->id, '='], 'topic_type' => ['1', '=']], ['topic_last_reply', true]); + $regular = Database::fetch('topics', true, ['forum_id' => [$this->id, '='], 'topic_type' => ['0', '=']], ['topic_last_reply', true]); - // Combine them into one array - $threadRows = array_merge($announcements, $sticky, $regular); + // Combine them into one array + $threadRows = array_merge($announcements, $sticky, $regular); - // Create a storage array - $threads = []; + // Create a storage array + $threads = []; - // Create new objects for each thread - foreach ($threadRows as $thread) { - $threads[$thread['topic_id']] = new Thread($thread['topic_id']); + // Create new objects for each thread + foreach ($threadRows as $thread) { + $threads[$thread['topic_id']] = new Thread($thread['topic_id']); + } + + $this->_threads = $threads; + } else { + $threads = $this->_threads; } // Return the thread objects @@ -100,29 +102,45 @@ class Forum } // First post - public function getFirstPost() + public function firstPost() { - // Get the row - $firstPost = Database::fetch('posts', false, ['forum_id' => [$this->id, '=']], ['post_id'], [1]); + // Check if _firstPost is set + if ($this->_firstPost === null) { + // Get the row + $firstPost = Database::fetch('posts', false, ['forum_id' => [$this->id, '=']], ['post_id'], [1]); - // Create the post object - $post = new Post(empty($firstPost) ? 0 : $firstPost['post_id']); + // Create the post object + $post = new Post(empty($firstPost) ? 0 : $firstPost['post_id']); - // Return the post object - return $post; + // Assign it to a "cache" variable + $this->_firstPost = $post; + + // Return the post object + return $post; + } else { + return $this->_firstPost; + } } // Last post - public function getLastPost() + public function lastPost() { - // Get the row - $lastPost = Database::fetch('posts', false, ['forum_id' => [$this->id, '=']], ['post_id', true], [1]); + // Check if _lastPost is set + if ($this->_lastPost === null) { + // Get the row + $lastPost = Database::fetch('posts', false, ['forum_id' => [$this->id, '=']], ['post_id', true], [1]); - // Create the post object - $post = new Post(empty($lastPost) ? 0 : $lastPost['post_id']); + // Create the post object + $post = new Post(empty($lastPost) ? 0 : $lastPost['post_id']); + + // Assign it to a "cache" variable + $this->_lastPost = $post; - // Return the post object - return $post; + // Return the post object + return $post; + } else { + return $this->_lastPost; + } } // Thread count @@ -146,14 +164,14 @@ class Forum } // Check forums - foreach ($this->forums as $forum) { + foreach ($this->forums() as $forum) { if ($forum->unread($user)) { return true; } } // Check each thread - foreach ($this->threads as $thread) { + foreach ($this->threads() as $thread) { if ($thread->unread($user)) { return true; } @@ -167,13 +185,13 @@ class Forum public function trackUpdateAll($user) { // Iterate over every forum - foreach ($this->forums as $forum) { + foreach ($this->forums() as $forum) { // Update every forum $forum->trackUpdateAll($user); } // Iterate over every thread - foreach ($this->threads as $thread) { + foreach ($this->threads() as $thread) { // Update every thread $thread->trackUpdate($user); } diff --git a/libraries/Forum/Thread.php b/libraries/Forum/Thread.php index cb7a5b1..9fc20b7 100644 --- a/libraries/Forum/Thread.php +++ b/libraries/Forum/Thread.php @@ -26,6 +26,8 @@ class Thread public $statusChange = 0; public $type = 0; private $_posts = []; + private $_firstPost = null; + private $_lastPost = null; // Constructor public function __construct($threadId) @@ -53,7 +55,6 @@ class Thread { // Check if _posts is something if (!count($this->_posts)) { - // Get all rows with the thread id $postRows = Database::fetch('posts', true, ['topic_id' => [$this->id, '=']]); @@ -77,13 +78,43 @@ class Thread // Get the opening post public function firstPost() { - return $this->posts() ? array_values($this->_posts)[0] : (new Post(0)); + // Check if the cache var is set + if ($this->_firstPost !== null) { + return $this->_firstPost; + } + + // Get the row from the database + $post = Database::fetch('posts', false, ['topic_id' => [$this->id, '=']], ['post_id'], [1]); + + // Create the post class + $post = new Post($post ? $post['post_id'] : 0); + + // Assign it to the cache var + $this->_firstPost = $post; + + // Return + return $post; } // Get the last reply public function lastPost() { - return $this->posts() ? end($this->_posts) : (new Post(0)); + // Check if the cache var is set + if ($this->_lastPost !== null) { + return $this->_firstPost; + } + + // Get the row from the database + $post = Database::fetch('posts', false, ['topic_id' => [$this->id, '=']], ['post_id', true], [1]); + + // Create the post class + $post = new Post($post ? $post['post_id'] : 0); + + // Assign it to the cache var + $this->_lastPost = $post; + + // Return + return $post; } // Reply count @@ -108,18 +139,13 @@ class Thread public function unread($user) { // Attempt to get track row from the database - $track = Database::fetch('topics_track', false, ['user_id' => [$user, '='], 'topic_id' => [$this->id, '=']]); + $track = Database::fetch('topics_track', false, ['user_id' => [$user, '='], 'topic_id' => [$this->id, '='], 'mark_time' => [$this->lastPost()->time, '>']]); // If nothing was returned it's obvious that the status is unread if (!$track) { return true; } - // Check if the last time the user has been here is less than the creation timestamp of the latest post - if ($track['mark_time'] < $this->lastPost()->time) { - return true; - } - // Else just return false meaning everything is read return false; } diff --git a/libraries/Main.php b/libraries/Main.php index 07ed4e4..f9f952f 100644 --- a/libraries/Main.php +++ b/libraries/Main.php @@ -14,19 +14,6 @@ use PHPMailer; */ class Main { - // Constructor - public static function init($config) - { - // Configuration Management and local configuration - Config::init($config); - - // Database - Database::init(Config::local('database', 'driver')); - - // "Dynamic" Configuration - Config::initDB(); - } - // Parse markdown public static function mdParse($text, $escape = false) { diff --git a/libraries/Template.php b/libraries/Template.php index 0c521c4..45a13fc 100644 --- a/libraries/Template.php +++ b/libraries/Template.php @@ -20,6 +20,7 @@ class Template private $template; private $templateName; private $templateOptions; + protected $templateFileExtension = ".tpl"; // Initialise templating engine and data public function __construct() @@ -80,9 +81,9 @@ class Template public function render($file) { try { - return $this->template->render($file, $this->vars); + return $this->template->render($file . $this->templateFileExtension, $this->vars); } catch (\Exception $e) { - trigger_error($e->getMessage(), E_USER_ERROR); + return trigger_error($e->getMessage(), E_USER_ERROR); } } } diff --git a/public/404.php b/public/404.php index 998d76a..858aa2d 100644 --- a/public/404.php +++ b/public/404.php @@ -22,4 +22,4 @@ $template->setTemplate($templateName); $template->setVariables($renderData); // Print page contents -echo $template->render('global/notfound.tpl'); +echo $template->render('global/notfound'); diff --git a/public/authenticate.php b/public/authenticate.php index 2f10e95..7b1007c 100644 --- a/public/authenticate.php +++ b/public/authenticate.php @@ -296,7 +296,7 @@ if (isset($_REQUEST['mode'])) { $renderData['page']['redirect']; } else { $template->setVariables($renderData); - echo $template->render('global/information.tpl'); + echo $template->render('global/information'); } exit; } @@ -324,7 +324,7 @@ if (Users::checkLogin()) { ]; $template->setVariables($renderData); - echo $template->render('global/information.tpl'); + echo $template->render('global/information'); exit; } @@ -348,10 +348,10 @@ if (isset($_REQUEST['pw']) && $_REQUEST['pw']) { } $template->setVariables($renderData); - echo $template->render('main/forgotpassword.tpl'); + echo $template->render('main/forgotpassword'); exit; } // Print page contents $template->setVariables($renderData); -echo $template->render('main/authenticate.tpl'); +echo $template->render('main/authenticate'); diff --git a/public/faq.php b/public/faq.php index 9f9ec64..eb9a4cf 100644 --- a/public/faq.php +++ b/public/faq.php @@ -27,4 +27,4 @@ $template->setTemplate($templateName); $template->setVariables($renderData); // Print page contents -echo $template->render('main/faq.tpl'); +echo $template->render('main/faq'); diff --git a/public/group.php b/public/group.php index 200512b..8e11dc2 100644 --- a/public/group.php +++ b/public/group.php @@ -19,4 +19,4 @@ $template->setTemplate($templateName); $template->setVariables($renderData); // Print page contents -echo $template->render('group/index.tpl'); +echo $template->render('group/index'); diff --git a/public/index.php b/public/index.php index 83f5348..cb3a7e0 100644 --- a/public/index.php +++ b/public/index.php @@ -39,7 +39,7 @@ if (isset($_GET['p'])) { $template->setVariables($renderData); // Print page contents - echo $template->render('main/infopage.tpl'); + echo $template->render('main/infopage'); exit; } @@ -75,4 +75,4 @@ $renderData['stats'] = [ $template->setVariables($renderData); // Print page contents -echo $template->render(($forumMode ? 'forum' : 'main') . '/index.tpl'); +echo $template->render(($forumMode ? 'forum' : 'main') . '/index'); diff --git a/public/manage.php b/public/manage.php index 64ff12d..f70e15b 100644 --- a/public/manage.php +++ b/public/manage.php @@ -86,4 +86,4 @@ $template->setTemplate($templateName); $template->setVariables($renderData); // Print page contents -echo $template->render('pages/' . $category . '/' . $mode . '.tpl'); +echo $template->render('pages/' . $category . '/' . $mode); diff --git a/public/members.php b/public/members.php index 792926e..b138dac 100644 --- a/public/members.php +++ b/public/members.php @@ -45,11 +45,11 @@ if (Users::checkLogin()) { $template->setVariables($renderData); // Print page contents - echo $template->render('main/memberlist.tpl'); + echo $template->render('main/memberlist'); } else { // Set parse variables $template->setVariables($renderData); // Print page contents - echo $template->render('global/restricted.tpl'); + echo $template->render('global/restricted'); } diff --git a/public/news.php b/public/news.php index 7c38c3b..60cc748 100644 --- a/public/news.php +++ b/public/news.php @@ -135,4 +135,4 @@ $template->setTemplate($templateName); $template->setVariables($renderData); // Print page contents -echo $template->render('main/news.tpl'); +echo $template->render('main/news'); diff --git a/public/posting.php b/public/posting.php index 47d8e11..b685487 100644 --- a/public/posting.php +++ b/public/posting.php @@ -52,7 +52,7 @@ if ($mode != 'f') { $template->setVariables($renderData); // Print page contents - echo $template->render('global/information.tpl'); + echo $template->render('global/information'); exit; } @@ -78,7 +78,7 @@ if ($mode != 'f') { $template->setVariables($renderData); // Print page contents - echo $template->render('global/information.tpl'); + echo $template->render('global/information'); exit; } @@ -105,7 +105,7 @@ if ($mode != 'f') { $template->setVariables($renderData); // Print page contents - echo $template->render('global/information.tpl'); + echo $template->render('global/information'); exit; } @@ -138,7 +138,7 @@ if ($mode != 'f') { $template->setVariables($renderData); // Print page contents - echo $template->render('global/information.tpl'); + echo $template->render('global/information'); exit; // Return to previous page } else { @@ -159,7 +159,7 @@ if ($mode != 'f') { $template->setVariables($renderData); // Print page contents - echo $template->render('global/confirm.tpl'); + echo $template->render('global/confirm'); exit; } @@ -191,7 +191,7 @@ if (isset($_POST['post'])) { $template->setVariables($renderData); // Print page contents - echo $template->render('global/information.tpl'); + echo $template->render('global/information'); } exit; } @@ -205,4 +205,4 @@ $renderData = array_merge($renderData, [ $template->setVariables($renderData); // Print page contents -echo $template->render('forum/posting.tpl'); +echo $template->render('forum/posting'); diff --git a/public/profile.php b/public/profile.php index 5845e1e..7e095af 100644 --- a/public/profile.php +++ b/public/profile.php @@ -35,4 +35,4 @@ $renderData['profileView'] = isset($_GET['view']) && in_array($_GET['view'], $vi $template->setVariables($renderData); // Print page contents -echo $template->render('main/profile.tpl'); +echo $template->render('main/profile'); diff --git a/public/report.php b/public/report.php index 91b070e..bf895ef 100644 --- a/public/report.php +++ b/public/report.php @@ -19,4 +19,4 @@ $template->setTemplate($templateName); $template->setVariables($renderData); // Print page contents -echo $template->render('main/report.tpl'); +echo $template->render('main/report'); diff --git a/public/search.php b/public/search.php index 4a7dc5a..8bf305f 100644 --- a/public/search.php +++ b/public/search.php @@ -24,4 +24,4 @@ $template->setTemplate($templateName); $template->setVariables($renderData); // Print page contents -echo $template->render('main/search.tpl'); +echo $template->render('main/search'); diff --git a/public/settings.php b/public/settings.php index cc747a9..b3d53f3 100644 --- a/public/settings.php +++ b/public/settings.php @@ -276,7 +276,7 @@ if (isset($_REQUEST['request-notifications']) && $_REQUEST['request-notification $template->setVariables($renderData); // Print page contents - echo $template->render('global/information.tpl'); + echo $template->render('global/information'); } exit; } elseif (isset($_REQUEST['friend-action']) && $_REQUEST['friend-action'] && Users::checkLogin()) { @@ -405,7 +405,7 @@ if (isset($_REQUEST['request-notifications']) && $_REQUEST['request-notification $template->setVariables($renderData); // Print page contents - echo $template->render('global/information.tpl'); + echo $template->render('global/information'); } exit; } elseif (isset($_POST['submit']) && isset($_POST['submit'])) { @@ -1036,7 +1036,7 @@ if (isset($_REQUEST['request-notifications']) && $_REQUEST['request-notification $template->setVariables($renderData); // Print page contents - echo $template->render('global/information.tpl'); + echo $template->render('global/information'); } exit; } @@ -1044,15 +1044,10 @@ if (isset($_REQUEST['request-notifications']) && $_REQUEST['request-notification if (Users::checkLogin()) { // Settings page list $pages = [ - 'general' => [ - 'title' => 'General', - 'modes' => [ - 'home' => [ - 'title' => 'Home', 'description' => [ @@ -1062,317 +1057,200 @@ if (Users::checkLogin()) { ], 'access' => !$currentUser->checkPermission('SITE', 'DEACTIVATED'), 'menu' => true, - ], 'profile' => [ - 'title' => 'Edit Profile', 'description' => [ - 'These are the external account links etc. on your profile, shouldn\'t need any additional explanation for this one.', - ], 'access' => $currentUser->checkPermission('SITE', 'ALTER_PROFILE'), 'menu' => true, - ], 'options' => [ - 'title' => 'Site Options', 'description' => [ - 'These are a few personalisation options for the site while you\'re logged in.', - ], 'access' => !$currentUser->checkPermission('SITE', 'DEACTIVATED'), 'menu' => true, - - ], /*, - 'groups' => [ - - 'title' => 'Groups', - 'description' => [ - - '{{ user.colour }}' - + ], ], - 'access' => $currentUser->checkPermission('SITE', 'JOIN_GROUPS'), - 'menu' => true - - ]*/ - - ], - ], 'friends' => [ - 'title' => 'Friends', - 'modes' => [ - 'listing' => [ - 'title' => 'Listing', 'description' => [ - 'Manage your friends.', - ], 'access' => $currentUser->checkPermission('SITE', 'MANAGE_FRIENDS'), 'menu' => true, - ], 'requests' => [ - 'title' => 'Requests', 'description' => [ - 'Handle friend requests.', - ], 'access' => $currentUser->checkPermission('SITE', 'MANAGE_FRIENDS'), 'menu' => true, - ], - ], - ], 'messages' => [ - 'title' => 'Messages', - 'modes' => [ - 'inbox' => [ - 'title' => 'Inbox', 'description' => [ - 'The list of messages you\'ve received.', - ], 'access' => $currentUser->checkPermission('SITE', 'USE_MESSAGES'), 'menu' => true, - ], 'sent' => [ - 'title' => 'Sent', 'description' => [ - 'The list of messages you\'ve sent to other users.', - ], 'access' => $currentUser->checkPermission('SITE', 'USE_MESSAGES'), 'menu' => true, - ], 'compose' => [ - 'title' => 'Compose', 'description' => [ - 'Write a new message.', - ], 'access' => $currentUser->checkPermission('SITE', 'SEND_MESSAGES'), 'menu' => true, - ], 'read' => [ - 'title' => 'Read', 'description' => [ - 'Read a message.', - ], 'access' => $currentUser->checkPermission('SITE', 'USE_MESSAGES'), 'menu' => false, - ], - ], - ], 'notifications' => [ - 'title' => 'Notifications', - 'modes' => [ - 'history' => [ - 'title' => 'History', 'description' => [ - 'The history of notifications that have been sent to you in the last month.', - ], 'access' => !$currentUser->checkPermission('SITE', 'DEACTIVATED'), 'menu' => true, - ], - ], - ], 'appearance' => [ - 'title' => 'Appearance', - 'modes' => [ - 'avatar' => [ - 'title' => 'Avatar', 'description' => [ - 'Your avatar which is displayed all over the site and on your profile.', 'Maximum image size is {{ avatar.max_width }}x{{ avatar.max_height }}, minimum image size is {{ avatar.min_width }}x{{ avatar.min_height }}, maximum file size is {{ avatar.max_size_view }}.', - ], 'access' => $currentUser->checkPermission('SITE', 'CHANGE_AVATAR'), 'menu' => true, - ], 'background' => [ - 'title' => 'Background', 'description' => [ - 'The background that is displayed on your profile.', 'Maximum image size is {{ background.max_width }}x{{ background.max_height }}, minimum image size is {{ background.min_width }}x{{ background.min_height }}, maximum file size is {{ background.max_size_view }}.', - ], 'access' => ( isset($currentUser->userData()['profileBackground']) && $currentUser->checkPermission('SITE', 'CHANGE_BACKGROUND') ) || $currentUser->checkPermission('SITE', 'CREATE_BACKGROUND'), 'menu' => true, - ], 'userpage' => [ - 'title' => 'Userpage', 'description' => [ - 'The custom text that is displayed on your profile.', - ], 'access' => ( isset($currentUser->userData()['userPage']) && $currentUser->checkPermission('SITE', 'CHANGE_USERPAGE') ) || $currentUser->checkPermission('SITE', 'CREATE_USERPAGE'), 'menu' => true, - ], 'signature' => [ - 'title' => 'Signature', 'description' => [ - 'This signature is displayed at the end of all your posts (unless you choose not to show it).', - ], 'access' => $currentUser->checkPermission('SITE', 'CHANGE_SIGNATURE'), 'menu' => true, - ], - ], - ], 'account' => [ - 'title' => 'Account', - 'modes' => [ - 'email' => [ - 'title' => 'E-mail Address', 'description' => [ - 'You e-mail address is used for password recovery and stuff like that, we won\'t spam you ;).', - ], 'access' => $currentUser->checkPermission('SITE', 'CHANGE_EMAIL'), 'menu' => true, - ], 'username' => [ - 'title' => 'Username', 'description' => [ - 'Probably the biggest part of your identity on a site.', 'You can only change this once every 30 days so choose wisely.', - ], 'access' => $currentUser->checkPermission('SITE', 'CHANGE_USERNAME'), 'menu' => true, - ], 'usertitle' => [ - 'title' => 'Usertitle', 'description' => [ - 'That little piece of text displayed under your username on your profile.', - ], 'access' => $currentUser->checkPermission('SITE', 'CHANGE_USERTITLE'), 'menu' => true, - ], 'password' => [ - 'title' => 'Password', 'description' => [ - 'Used to authenticate with the site and certain related services.', - ], 'access' => $currentUser->checkPermission('SITE', 'CHANGE_PASSWORD'), 'menu' => true, - ], 'ranks' => [ - 'title' => 'Ranks', 'description' => [ - 'Manage what ranks you\'re in and what is set as your main rank. Your main rank is highlighted. You get the permissions of all of the ranks you\'re in combined.', - ], 'access' => $currentUser->checkPermission('SITE', 'ALTER_RANKS'), 'menu' => true, - ], - ], - ], 'advanced' => [ - 'title' => 'Advanced', - 'modes' => [ - 'sessions' => [ - 'title' => 'Sessions', 'description' => [ - 'Session keys are a way of identifying yourself with the system without keeping your password in memory.', 'If someone finds one of your session keys they could possibly compromise your account, @@ -1380,43 +1258,30 @@ if (Users::checkLogin()) { selected session.', 'If you get logged out after clicking one you\'ve most likely killed your current session, to make it easier to avoid this from happening your current session is highlighted.', - ], 'access' => $currentUser->checkPermission('SITE', 'MANAGE_SESSIONS'), 'menu' => true, - ], 'registrationkeys' => [ - 'title' => 'Registration Keys', 'description' => [ - 'Sometimes we activate the registration key system which means that users can only register using your "referer" keys,this means we can keep unwanted people from registering.', 'Each user can generate 5 of these keys, bans and deactivates render these keys useless.', - ], 'access' => $currentUser->checkPermission('SITE', 'CREATE_REGKEYS'), 'menu' => true, - ], 'deactivate' => [ - 'title' => 'Deactivate Account', 'description' => [ - 'You can deactivate your account here if you want to leave :(.', - ], 'access' => $currentUser->checkPermission('SITE', 'DEACTIVATE_ACCOUNT'), 'menu' => true, - ], - ], - ], - ]; // Current settings page @@ -1444,7 +1309,7 @@ if (Users::checkLogin()) { $template->setVariables($renderData); // Print page contents - echo $template->render('global/notfound.tpl'); + echo $template->render('global/notfound'); exit; } @@ -1534,11 +1399,11 @@ if (Users::checkLogin()) { $template->setVariables($renderData); // Print page contents - echo $template->render('main/settings.tpl'); + echo $template->render('main/settings'); } else { // If not allowed print the restricted page $template->setVariables($renderData); // Print page contents - echo $template->render('global/restricted.tpl'); + echo $template->render('global/restricted'); } diff --git a/public/support.php b/public/support.php index 6a3693e..8e3e23c 100644 --- a/public/support.php +++ b/public/support.php @@ -127,7 +127,7 @@ if (isset($_REQUEST['mode']) $template->setVariables($renderData); // Print page contents - echo $template->render('main/premiumcomplete.tpl'); + echo $template->render('main/premiumcomplete'); break; default: @@ -148,7 +148,7 @@ if (isset($_GET['tracker'])) { $template->setVariables($renderData); // Print page contents - echo $template->render('main/supporttracker.tpl'); + echo $template->render('main/supporttracker'); exit; } @@ -166,4 +166,4 @@ $renderData['page'] = [ $template->setVariables($renderData); // Print page contents -echo $template->render('main/support.tpl'); +echo $template->render('main/support'); diff --git a/public/viewforum.php b/public/viewforum.php index f4101b9..39edc34 100644 --- a/public/viewforum.php +++ b/public/viewforum.php @@ -30,7 +30,7 @@ if ($forum->id < 0) { $template->setVariables($renderData); // Print page contents - echo $template->render('global/information.tpl'); + echo $template->render('global/information'); exit; } @@ -47,7 +47,7 @@ if ($forum->type === 2) { $template->setVariables($renderData); // Print page contents - echo $template->render('global/information.tpl'); + echo $template->render('global/information'); exit; } @@ -67,7 +67,7 @@ if (isset($_GET['read']) && $_GET['read'] && isset($_GET['session']) && $_GET['s $template->setVariables($renderData); // Print page contents - echo $template->render('global/information.tpl'); + echo $template->render('global/information'); exit; } @@ -83,4 +83,4 @@ $renderData['forum'] = $forum; $template->setVariables($renderData); // Print page contents -echo $template->render('forum/viewforum.tpl'); +echo $template->render('forum/viewforum'); diff --git a/public/viewtopic.php b/public/viewtopic.php index 787ffad..e1a1e2e 100644 --- a/public/viewtopic.php +++ b/public/viewtopic.php @@ -36,7 +36,7 @@ if (!$thread) { $template->setVariables($renderData); // Print page contents - echo $template->render('global/information.tpl'); + echo $template->render('global/information'); exit; } @@ -56,4 +56,4 @@ $renderData = array_merge($renderData, [ $template->setVariables($renderData); // Print page contents -echo $template->render('forum/viewtopic.tpl'); +echo $template->render('forum/viewtopic'); diff --git a/sakura.php b/sakura.php index cd94f52..7758a46 100644 --- a/sakura.php +++ b/sakura.php @@ -8,7 +8,7 @@ namespace Sakura; // Define Sakura version -define('SAKURA_VERSION', '20151209'); +define('SAKURA_VERSION', '20151210'); define('SAKURA_VLABEL', 'Eminence'); define('SAKURA_COLOUR', '#6C3082'); @@ -23,12 +23,12 @@ mb_internal_encoding('utf-8'); // Stop the execution if the PHP Version is older than 5.4.0 if (version_compare(phpversion(), '5.4.0', '<')) { - die('

Sakura requires at least PHP 5.4.0, please upgrade to a newer PHP version.

'); + die('Sakura requires at least PHP 5.4.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?

'); + die('Autoloader not found, did you run composer?'); } // Include components @@ -66,12 +66,18 @@ foreach (glob(ROOT . 'libraries/DBWrapper/*.php') as $driver) { // Set Error handler set_error_handler(['Sakura\Main', 'errorHandler']); -// Initialise Main Class -Main::init(ROOT . 'config/config.ini'); +// Load the local configuration +Config::init(ROOT . 'config/config.ini'); // Change error reporting according to the dev configuration error_reporting(Config::local('dev', 'enable') ? -1 : 0); +// Make the database connection +Database::init(Config::local('database', 'driver')); + +// Load the configuration stored in the database +Config::initDB(); + // Assign servers file to whois class Whois::setServers(ROOT . Config::local('data', 'whoisservers')); @@ -87,14 +93,7 @@ if (Config::get('no_cron_service')) { } // Update last execution time - Database::update('config', [ - [ - 'config_value' => time(), - ], - [ - 'config_name' => ['no_cron_last', '='], - ], - ]); + Database::update('config', [['config_value' => time()], ['config_name' => ['no_cron_last', '=']]]); } } @@ -205,12 +204,12 @@ if (!defined('SAKURA_NO_TPL')) { $template->setVariables($renderData); // Print page contents - echo $template->render('global/information.tpl'); + echo $template->render('global/information'); exit; } // Ban checking - if ($authCheck && !in_array($_SERVER['PHP_SELF'], ['/authenticate.php']) && $ban = Bans::checkBan($currentUser->id())) { + if ($authCheck && !in_array($_SERVER['PHP_SELF'], [$urls->format('AUTH_ACTION', [], false)]) && $ban = Bans::checkBan($currentUser->id())) { // Additional render data $renderData = array_merge($renderData, [ 'ban' => [ @@ -231,7 +230,7 @@ if (!defined('SAKURA_NO_TPL')) { $template->setVariables($renderData); // Print page contents - echo $template->render('main/banned.tpl'); + echo $template->render('main/banned'); exit; } } diff --git a/templates/misaki/global/master.tpl b/templates/misaki/global/master.tpl index d2de389..ad9acb7 100644 --- a/templates/misaki/global/master.tpl +++ b/templates/misaki/global/master.tpl @@ -115,6 +115,7 @@
  • {{ user.username }}
  • + {##}
    {% block content %}
    diff --git a/templates/yuuno/forum/viewtopic.tpl b/templates/yuuno/forum/viewtopic.tpl index a846c40..4cac7d1 100644 --- a/templates/yuuno/forum/viewtopic.tpl +++ b/templates/yuuno/forum/viewtopic.tpl @@ -36,7 +36,7 @@ {% block content %}
    -
    {{ forum.name }} / {{ thread.title }}
    + {% include 'forum/forumBtns.tpl' %} {% for post in posts[get.page|default(1) - 1] %}