From 9fb540daf890645d26f1cd38d7e4f02327e93f98 Mon Sep 17 00:00:00 2001 From: flashwave Date: Fri, 22 Jan 2016 21:07:44 +0100 Subject: [PATCH] r20160122.1 --- composer.json | 3 ++- libraries/Comments.php | 9 +-------- libraries/Console/Application.php | 23 +++++++++++++++++++++++ libraries/Forum/Post.php | 1 - libraries/News.php | 9 +-------- libraries/User.php | 6 ++++++ libraries/Users.php | 7 ++++++- public/content/data/yuuno/css/yuuno.css | 2 -- public/members.php | 2 +- sakura.php | 8 ++++++++ templates/yuuno/global/master.twig | 18 ------------------ templates/yuuno/main/profile.twig | 2 +- 12 files changed, 49 insertions(+), 41 deletions(-) create mode 100644 libraries/Console/Application.php diff --git a/composer.json b/composer.json index 50841d0..c6a9271 100644 --- a/composer.json +++ b/composer.json @@ -6,6 +6,7 @@ "twig/twig": "*", "phpmailer/phpmailer": "*", "paypal/rest-api-sdk-php": "*", - "jbbcode/jbbcode": "^1.3" + "jbbcode/jbbcode": "*", + "corneltek/cliframework": "*" } } diff --git a/libraries/Comments.php b/libraries/Comments.php index cae965c..35a6dc2 100644 --- a/libraries/Comments.php +++ b/libraries/Comments.php @@ -12,7 +12,6 @@ namespace Sakura; class Comments { public $comments = []; // Array containing comments - private $commenters = []; // Array containing User objects public $category; // Comment category public $count = 0; // Amount of comments @@ -45,14 +44,8 @@ class Comments // Sort comments foreach ($comments as $comment) { - // Check if we already have an object for this user - if (!array_key_exists($comment['comment_poster'], $this->commenters)) { - // Create new object - $this->commenters[$comment['comment_poster']] = User::construct($comment['comment_poster']); - } - // Attach the poster - $comment['comment_poster'] = $this->commenters[$comment['comment_poster']]; + $comment['comment_poster'] = User::construct($comment['comment_poster']); $comment['comment_text'] = Utils::parseEmotes(Utils::cleanString($comment['comment_text'])); // Get likes and dislikes diff --git a/libraries/Console/Application.php b/libraries/Console/Application.php new file mode 100644 index 0000000..20f25f0 --- /dev/null +++ b/libraries/Console/Application.php @@ -0,0 +1,23 @@ + $this->id, 'topic_id' => $thread->id, 'forum_id' => $thread->forum, 'poster_id' => $this->poster->id, diff --git a/libraries/News.php b/libraries/News.php index c33c687..53fdc11 100644 --- a/libraries/News.php +++ b/libraries/News.php @@ -12,7 +12,6 @@ namespace Sakura; class News { public $posts = []; // Posts array - private $posters = []; // Posters array (so we don't create a new user object every time) // Initialise the news object public function __construct($category) @@ -23,14 +22,8 @@ class News // Attach poster data foreach ($posts as $post) { - // Check if we already have an object for this user - if (!array_key_exists($post['user_id'], $this->posters)) { - // Create new object - $this->posters[$post['user_id']] = User::construct($post['user_id']); - } - // Attach the poster - $post['news_poster'] = $this->posters[$post['user_id']]; + $post['news_poster'] = User::construct($post['user_id']); // Load comments $post['news_comments'] = $this->comments = new Comments('news-' . $category . '-' . $post['news_id']); diff --git a/libraries/User.php b/libraries/User.php index 9f1d2cf..7d32110 100644 --- a/libraries/User.php +++ b/libraries/User.php @@ -173,6 +173,12 @@ class User $this->permissions = new Perms(Perms::SITE); } + // Update + public function update() + { + // placeholder + } + // Get user birthday public function birthday($age = false) { diff --git a/libraries/Users.php b/libraries/Users.php index 7a552e7..080f568 100644 --- a/libraries/Users.php +++ b/libraries/Users.php @@ -704,7 +704,7 @@ class Users } // Get all users - public static function getAllUsers($includeInactive = true, $includeAbyss = false) + public static function getAllUsers($includeInactive = true, $includeRestricted = false) { // Execute query $getUsers = Database::fetch('users', true); @@ -721,6 +721,11 @@ class Users continue; } + // Skip if inactive and not include restricted users + if (!$includeRestricted && $user->permission(Site::RESTRICTED)) { + continue; + } + $users[$user->id] = $user; } diff --git a/public/content/data/yuuno/css/yuuno.css b/public/content/data/yuuno/css/yuuno.css index 522c110..8b18084 100644 --- a/public/content/data/yuuno/css/yuuno.css +++ b/public/content/data/yuuno/css/yuuno.css @@ -239,7 +239,6 @@ a.default:active { .content-column { position: relative; - min-height: 600px; } .content-left { @@ -1930,7 +1929,6 @@ textarea.inputStyling { width: 100%; border-spacing: 0; margin-top: 2px; - word-break: break-all; } .forum .topicList thead, diff --git a/public/members.php b/public/members.php index fc03e5f..06f440d 100644 --- a/public/members.php +++ b/public/members.php @@ -25,7 +25,7 @@ if (Users::checkLogin()) { && $_GET['rank'] && array_key_exists($_GET['rank'], $_MEMBERLIST_RANKS) ? $_GET['rank'] : 0 )), - 'users' => ($_MEMBERLIST_ACTIVE && !$_MEMBERLIST_NFOUND ? Users::getUsersInRank($_MEMBERLIST_ACTIVE) : Users::getAllUsers()), + 'users' => ($_MEMBERLIST_ACTIVE ? Users::getUsersInRank($_MEMBERLIST_ACTIVE) : Users::getAllUsers(false)), 'membersPerPage' => Config::get('members_per_page'), ]; diff --git a/sakura.php b/sakura.php index 881f6e9..02df199 100644 --- a/sakura.php +++ b/sakura.php @@ -54,6 +54,7 @@ require_once ROOT . 'libraries/User.php'; require_once ROOT . 'libraries/Users.php'; require_once ROOT . 'libraries/Utils.php'; require_once ROOT . 'libraries/Whois.php'; +require_once ROOT . 'libraries/Console/Application.php'; require_once ROOT . 'libraries/Forum/Forum.php'; require_once ROOT . 'libraries/Forum/Post.php'; require_once ROOT . 'libraries/Forum/Thread.php'; @@ -84,6 +85,13 @@ Config::initDB(); // Assign servers file to whois class Whois::setServers(ROOT . Config::local('data', 'whoisservers')); +// Check if we're using console +if (php_sapi_name() === 'cli') { + $console = new Console\Application; + $console->run($argv); + exit; +} + // Check if we the system has a cron service if (Config::get('no_cron_service')) { // If not do an "asynchronous" call to the cron.php script diff --git a/templates/yuuno/global/master.twig b/templates/yuuno/global/master.twig index cbc6213..ce89746 100644 --- a/templates/yuuno/global/master.twig +++ b/templates/yuuno/global/master.twig @@ -60,24 +60,6 @@ // Space for things that need to happen onload window.addEventListener("load", function() { - - // Check if we can use SSL - if (window.location.protocol.toLowerCase() === "http:") { - // Build check string - var sslCheckDest = 'https://' + window.location.host + sakuraVars.content + '/pixel.png'; - - // Create a new image - var sslCheck = new Image(); - - // Add an onload - sslCheck.onload = function() { - window.location.assign(window.location.href.toLowerCase().replace('http://', 'https://')); - } - - // Set the source - sslCheck.src = sslCheckDest; - } - {% if session.checkLogin %} // Convert href to object in logout link prepareAjaxLink('headerLogoutLink', 'submitPost', ', true, "Logging out..."'); diff --git a/templates/yuuno/main/profile.twig b/templates/yuuno/main/profile.twig index c187800..4bc0ac2 100644 --- a/templates/yuuno/main/profile.twig +++ b/templates/yuuno/main/profile.twig @@ -30,7 +30,7 @@ {% if profile.mainRankId > 1 and profile.checkBan|length < 1 %} {{ profile.title }}

{{ profile.username }}

- {% if profile.isPremium[0] %}Tenshi {% endif %}{{ profile.country.short }} {{ profile.country.long }} + {% if profile.isPremium[0] %}Tenshi {% endif %}{{ profile.country }} {{ profile.country(true) }} {% if session.checkLogin %}
{% if user.id == profile.id %}