From ef21a949142c45f26b6baea0851d999b7ebd79f4 Mon Sep 17 00:00:00 2001 From: flashwave Date: Thu, 30 Jul 2015 03:12:53 +0200 Subject: [PATCH] banning soon --- _sakura/changelog.json | 16 ++- _sakura/components/Bans.php | 15 ++ _sakura/components/Main.php | 6 +- _sakura/components/SockChat.php | 14 -- _sakura/sakura.php | 135 +++++++++++------- .../templates/yuuno/elements/indexPanel.tpl | 3 +- _sakura/templates/yuuno/errors/banned.tpl | 22 +++ _sakura/templates/yuuno/main/index.tpl | 2 - api/api.php | 3 + content/data/misaki/css/misaki.css | 2 +- content/data/yuuno/css/yuuno.css | 15 +- main/authenticate.php | 2 +- main/imageserve.php | 3 + main/index.php | 3 +- main/settings.php | 7 + 15 files changed, 171 insertions(+), 77 deletions(-) create mode 100644 _sakura/templates/yuuno/errors/banned.tpl diff --git a/_sakura/changelog.json b/_sakura/changelog.json index 76b1396..a40579f 100644 --- a/_sakura/changelog.json +++ b/_sakura/changelog.json @@ -34,7 +34,8 @@ "20150705", "20150706", "20150707", - "20150725" + "20150725", + "20150728" ] @@ -1521,6 +1522,19 @@ "change": "Make the error in getConfig return the value that can't be found." } + ], + + "20150728": [ + + { + "type": "UPD", + "change": "Made the amount of news posts loaded on the frontpage configurable." + }, + { + "type": "REM", + "change": "(Temporarily) removed chat online user count." + } + ] } diff --git a/_sakura/components/Bans.php b/_sakura/components/Bans.php index 7e76549..be9e47e 100644 --- a/_sakura/components/Bans.php +++ b/_sakura/components/Bans.php @@ -7,4 +7,19 @@ namespace Sakura; class Bans { + // Check if a user is banned + public static function checkBan($id) { + + if($id == 1) { + return [ + 'user' => 1, + 'issuer' => 2, + 'issued' => 246, + 'expires' => time(), + 'reason' => 'meow' + ]; + } + + } + } diff --git a/_sakura/components/Main.php b/_sakura/components/Main.php index b7d5991..3f3c642 100644 --- a/_sakura/components/Main.php +++ b/_sakura/components/Main.php @@ -36,7 +36,11 @@ class Main { self::$_MANAGE_MODE = defined('SAKURA_MANAGE'); // Templating engine - Templates::init(self::$_MANAGE_MODE ? Configuration::getConfig('manage_style') : Configuration::getConfig('site_style')); + if(!defined('SAKURA_NO_TPL')) { + + Templates::init(self::$_MANAGE_MODE ? Configuration::getConfig('manage_style') : Configuration::getConfig('site_style')); + + } // Assign servers file to whois class Whois::setServers(ROOT .'_sakura/'. Configuration::getLocalConfig('data', 'whoisservers')); diff --git a/_sakura/components/SockChat.php b/_sakura/components/SockChat.php index 7bf7c6c..61629f0 100644 --- a/_sakura/components/SockChat.php +++ b/_sakura/components/SockChat.php @@ -125,18 +125,4 @@ class SockChat { } - // Get online users - public static function getOnlineUsers() { - - // If the sock chat extensions are disabled return an empty array - if(!Configuration::getLocalConfig('sockchat', 'enabled')) - return []; - - // Get contents of the table - $sockUsers = Database::fetch('online_users', true, null, null, null, null, false, '*', Configuration::getLocalConfig('sockchat', 'prefix')); - - return $sockUsers; - - } - } diff --git a/_sakura/sakura.php b/_sakura/sakura.php index d5b6175..f2a003f 100644 --- a/_sakura/sakura.php +++ b/_sakura/sakura.php @@ -8,7 +8,7 @@ namespace Sakura; // Define Sakura version -define('SAKURA_VERSION', '20150707'); +define('SAKURA_VERSION', '20150728'); define('SAKURA_VLABEL', 'Eminence'); define('SAKURA_STABLE', false); define('SAKURA_COLOUR', '#6C3082'); @@ -34,81 +34,112 @@ require_once ROOT .'_sakura/components/Sessions.php'; require_once ROOT .'_sakura/components/Users.php'; require_once ROOT .'_sakura/components/Forum.php'; require_once ROOT .'_sakura/components/Manage.php'; +require_once ROOT .'_sakura/components/Bans.php'; require_once ROOT .'_sakura/components/Whois.php'; require_once ROOT .'_sakura/components/Payments.php'; require_once ROOT .'_sakura/components/SockChat.php'; // Include database extensions -foreach(glob(ROOT .'_sakura/components/database/*.php') as $driver) - require_once($driver); +foreach(glob(ROOT .'_sakura/components/database/*.php') as $driver) { + + require_once $driver; + +} // Set Error handler set_error_handler(array('Sakura\Main', 'errorHandler')); -// Initialise Flashii Class +// Initialise Main Class Main::init(ROOT .'_sakura/config/config.ini'); // Start output buffering ob_start(Configuration::getConfig('use_gzip') ? 'ob_gzhandler' : null); -// Set base page rendering data -$renderData = [ +if(!defined('SAKURA_NO_TPL')) { - 'sakura' => [ + // Set base page rendering data + $renderData = [ - 'version' => SAKURA_VERSION, - 'vlabel' => SAKURA_VLABEL, - 'vcolour' => SAKURA_COLOUR, - 'stable' => SAKURA_STABLE, - 'urls' => Configuration::getLocalConfig('urls'), - 'charset' => Configuration::getConfig('charset'), - 'currentpage' => '//'. $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI'], - 'recaptcha_public' => Configuration::getConfig('recaptcha_public'), - 'recaptcha_enable' => Configuration::getConfig('recaptcha'), - 'resources' => '//'. Configuration::getLocalConfig('urls')['content'] .'/data/'. strtolower(Templates::$_TPL), - 'disableregister' => Configuration::getConfig('disable_registration'), - 'locksite' => Configuration::getConfig('lock_site'), - 'locksitereason' => Configuration::getConfig('lock_site_reason'), - 'lockauth' => Configuration::getConfig('lock_authentication'), - 'requireregcodes' => Configuration::getConfig('require_registration_code'), - 'requireactiveate' => Configuration::getConfig('require_activation'), - 'sitename' => Configuration::getConfig('sitename'), - 'sitedesc' => Configuration::getConfig('sitedesc'), - 'sitetags' => implode(", ", json_decode(Configuration::getConfig('sitetags'), true)), - 'cookieprefix' => Configuration::getConfig('cookie_prefix'), - 'cookiedomain' => Configuration::getConfig('cookie_domain'), - 'cookiepath' => Configuration::getConfig('cookie_path'), - 'minpwdentropy' => Configuration::getConfig('min_entropy'), - 'minusernamelength' => Configuration::getConfig('username_min_length'), - 'maxusernamelength' => Configuration::getConfig('username_max_length'), - 'disqus_shortname' => Configuration::getConfig('disqus_shortname'), - 'disqus_api_key' => Configuration::getConfig('disqus_api_key') + 'sakura' => [ - ], + 'version' => SAKURA_VERSION, + 'vlabel' => SAKURA_VLABEL, + 'vcolour' => SAKURA_COLOUR, + 'stable' => SAKURA_STABLE, + 'urls' => Configuration::getLocalConfig('urls'), + 'charset' => Configuration::getConfig('charset'), + 'currentpage' => '//'. $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI'], + 'recaptcha_public' => Configuration::getConfig('recaptcha_public'), + 'recaptcha_enable' => Configuration::getConfig('recaptcha'), + 'resources' => '//'. Configuration::getLocalConfig('urls')['content'] .'/data/'. strtolower(Templates::$_TPL), + 'disableregister' => Configuration::getConfig('disable_registration'), + 'locksite' => Configuration::getConfig('lock_site'), + 'locksitereason' => Configuration::getConfig('lock_site_reason'), + 'lockauth' => Configuration::getConfig('lock_authentication'), + 'requireregcodes' => Configuration::getConfig('require_registration_code'), + 'requireactiveate' => Configuration::getConfig('require_activation'), + 'sitename' => Configuration::getConfig('sitename'), + 'sitedesc' => Configuration::getConfig('sitedesc'), + 'sitetags' => implode(", ", json_decode(Configuration::getConfig('sitetags'), true)), + 'cookieprefix' => Configuration::getConfig('cookie_prefix'), + 'cookiedomain' => Configuration::getConfig('cookie_domain'), + 'cookiepath' => Configuration::getConfig('cookie_path'), + 'minpwdentropy' => Configuration::getConfig('min_entropy'), + 'minusernamelength' => Configuration::getConfig('username_min_length'), + 'maxusernamelength' => Configuration::getConfig('username_max_length'), + 'disqus_shortname' => Configuration::getConfig('disqus_shortname'), + 'disqus_api_key' => Configuration::getConfig('disqus_api_key'), + 'date_format' => Configuration::getConfig('date_format') - 'perms' => [ + ], - 'canGetPremium' => Permissions::check('SITE', 'OBTAIN_PREMIUM', Session::$userId, 1), - 'canUseForums' => Permissions::check('FORUM', 'USE_FORUM', Session::$userId, 1) + 'perms' => [ - ], + 'canGetPremium' => Permissions::check('SITE', 'OBTAIN_PREMIUM', Session::$userId, 1), + 'canUseForums' => Permissions::check('FORUM', 'USE_FORUM', Session::$userId, 1) - 'php' => [ + ], - 'sessionid' => \session_id(), - 'time' => \time(), - 'self' => $_SERVER['PHP_SELF'] + 'php' => [ - ], + 'sessionid' => \session_id(), + 'time' => \time(), + 'self' => $_SERVER['PHP_SELF'] - 'user' => [ + ], - 'checklogin' => Users::checkLogin(), - 'session' => Session::$sessionId, - 'data' => ($_init_udata = Users::getUser(Session::$userId)), - 'rank' => ($_init_rdata = Users::getRank($_init_udata['rank_main'])), - 'colour' => ($_init_udata['name_colour'] == null ? $_init_rdata['colour'] : $_init_udata['name_colour']) + 'user' => [ - ] + 'checklogin' => Users::checkLogin(), + 'session' => Session::$sessionId, + 'data' => ($_init_udata = Users::getUser(Session::$userId)), + 'rank' => ($_init_rdata = Users::getRank($_init_udata['rank_main'])), + 'colour' => ($_init_udata['name_colour'] == null ? $_init_rdata['colour'] : $_init_udata['name_colour']) -]; + ] + + ]; + + // Ban checking + if(Users::checkLogin() && $ban = Bans::checkBan(Session::$userId)) { + + // Additional render data + $renderData = array_merge($renderData, [ + 'ban' => [ + 'reason' => $ban['reason'], + 'issued' => $ban['issued'], + 'expires' => $ban['expires'], + 'issuer' => Users::getUser($ban['issuer']) + ], + 'page' => [ + 'title' => 'You are banned!' + ] + ]); + + //Users::logout(); + print Templates::render('errors/banned.tpl', $renderData); + exit; + + } + +} diff --git a/_sakura/templates/yuuno/elements/indexPanel.tpl b/_sakura/templates/yuuno/elements/indexPanel.tpl index 081b525..b80a40d 100644 --- a/_sakura/templates/yuuno/elements/indexPanel.tpl +++ b/_sakura/templates/yuuno/elements/indexPanel.tpl @@ -25,8 +25,7 @@
Stats
We have {{ stats.userCount }}, {{ stats.newestUser.username }} is the newest user, -it has been {{ stats.lastRegDate }} since the last user registered, -there's {{ stats.chatOnline }} in chat right now and the forum has {{ stats.topicCount }} and {{ stats.postCount }}. +it has been {{ stats.lastRegDate }} since the last user registered and the forum has {{ stats.topicCount }} and {{ stats.postCount }}.
Online Users
{% if stats.onlineUsers %} All active users in the past 5 minutes:
diff --git a/_sakura/templates/yuuno/errors/banned.tpl b/_sakura/templates/yuuno/errors/banned.tpl new file mode 100644 index 0000000..ce8de41 --- /dev/null +++ b/_sakura/templates/yuuno/errors/banned.tpl @@ -0,0 +1,22 @@ +{% include 'global/header.tpl' %} +
+
+
+

You are banned!

+

The following reason was supplied:

+

+ {{ ban.reason }} +

+
+

Additional information

+
    +
  • You were banned on {{ ban.issued|date(sakura.date_format) }}.
  • +
  • {% if ban.expires %}This ban expires on {{ ban.expire|date(sakura.date_format) }}.{% else %}You are permanently banned.{% endif %}
  • + {% if ban.expires %} +
  • You were banned by {{ ban.issuer.username }}.
  • + {% endif %} +
+
+
+
+{% include 'global/footer.tpl' %} diff --git a/_sakura/templates/yuuno/main/index.tpl b/_sakura/templates/yuuno/main/index.tpl index 581073d..6a391ad 100644 --- a/_sakura/templates/yuuno/main/index.tpl +++ b/_sakura/templates/yuuno/main/index.tpl @@ -13,10 +13,8 @@