banning soon

This commit is contained in:
flash 2015-07-30 03:12:53 +02:00
parent 2f642f7f85
commit ef21a94914
15 changed files with 171 additions and 77 deletions

View file

@ -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."
}
]
}

View file

@ -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'
];
}
}
}

View file

@ -36,8 +36,12 @@ class Main {
self::$_MANAGE_MODE = defined('SAKURA_MANAGE');
// Templating engine
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'));

View file

@ -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;
}
}

View file

@ -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,25 +34,31 @@ 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')) {
// Set base page rendering data
$renderData = [
'sakura' => [
@ -82,7 +88,8 @@ $renderData = [
'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')
'disqus_api_key' => Configuration::getConfig('disqus_api_key'),
'date_format' => Configuration::getConfig('date_format')
],
@ -111,4 +118,28 @@ $renderData = [
]
];
];
// 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;
}
}

View file

@ -25,8 +25,7 @@
<div class="head">Stats</div>
We have <b>{{ stats.userCount }}</b>,
<b><a href="//{{ sakura.urls.main }}/u/{{ stats.newestUser.id }}" class="default">{{ stats.newestUser.username }}</a></b> is the newest user,
it has been <b>{{ stats.lastRegDate }}</b> since the last user registered,
there's <b>{{ stats.chatOnline }}</b> in chat right now and the forum has <b>{{ stats.topicCount }}</b> and <b>{{ stats.postCount }}</b>.
it has been <b>{{ stats.lastRegDate }}</b> since the last user registered and the forum has <b>{{ stats.topicCount }}</b> and <b>{{ stats.postCount }}</b>.
<div class="head">Online Users</div>
{% if stats.onlineUsers %}
All active users in the past 5 minutes:<br />

View file

@ -0,0 +1,22 @@
{% include 'global/header.tpl' %}
<div class="content">
<div class="content-column news banned">
<div style="padding: 20px;">
<h1>You are banned!</h1>
<h3>The following reason was supplied:</h3>
<p>
{{ ban.reason }}
</p>
<br />
<h2>Additional information</h2>
<ul style="margin-left: 30px;">
<li>You were banned on {{ ban.issued|date(sakura.date_format) }}.</li>
<li>{% if ban.expires %}This ban expires on {{ ban.expire|date(sakura.date_format) }}.{% else %}<b>You are permanently banned.</b>{% endif %}</li>
{% if ban.expires %}
<li>You were banned by <a href="/u/{{ ban.issuer.id }}" class="default">{{ ban.issuer.username }}</a>.</li>
{% endif %}
</ul>
</div>
</div>
</div>
{% include 'global/footer.tpl' %}

View file

@ -13,10 +13,8 @@
</div>
<script type="text/javascript" src="{{ sakura.resources }}/js/ybabstat.js"></script>
<script type="text/javascript">
/* * * CONFIGURATION VARIABLES: EDIT BEFORE PASTING INTO YOUR WEBPAGE * * */
var disqus_shortname = 'flashii';
/* * * DO NOT EDIT BELOW THIS LINE * * */
(function () {
var s = document.createElement('script');
s.async = true;

View file

@ -6,6 +6,9 @@
// Declare Namespace
namespace Sakura;
// Define that this page won't require templating
define('SAKURA_NO_TPL', true);
// Include components
require_once str_replace(basename(__DIR__), '', dirname(__FILE__)) .'_sakura/sakura.php';

View file

@ -6,7 +6,7 @@
/*
* Import fonts
*/
@import url('//maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css'); /* Font Awesome */
@import url('//maxcdn.bootstrapcdn.com/font-awesome/4.4.0/css/font-awesome.min.css'); /* Font Awesome */
@import url('/fonts/springsteel-light/font.css'); /* Springsteel Light */
@import url('/fonts/exo2-0-italic/font.css'); /* Exo 2.0 Italic */
@import url('/fonts/exo2-0-light/font.css'); /* Exo 2.0 Light */

View file

@ -7,7 +7,7 @@
@charset "utf-8";
/* Import Font Awesome */
@import url('//maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css');
@import url('//maxcdn.bootstrapcdn.com/font-awesome/4.4.0/css/font-awesome.min.css');
/* Import Segoe UI */
@import url('/fonts/segoeui/font.css');
@ -1777,3 +1777,16 @@ textarea.inputStyling {
.forum .buttonRow .rightSide {
float: right;
}
/*
* Ban page styling
*/
.banned p {
background: #B19DDD;
border: 1px solid #9475B2;
font-size: 13px;
line-height: 19px;
overflow: auto;
padding: 6px 10px;
border-radius: 3px;
}

View file

@ -80,7 +80,7 @@ if(isset($_REQUEST['mode'])) {
$renderData['page'] = [
'title' => 'Logout',
'redirect' => ($logout ? $_REQUEST['redirect'] : '/authenticate'),
'message' => $logout ? 'You are now logged out.' : 'Logout failed.',
'message' => $logout ? 'You are now logged out.' : 'An unknown error occurred.',
'success' => $logout ? 1 : 0
];

View file

@ -6,6 +6,9 @@
// Declare Namespace
namespace Sakura;
// Define that this page won't require templating
define('SAKURA_NO_TPL', true);
// Include components
require_once str_replace(basename(__DIR__), '', dirname(__FILE__)) .'_sakura/sakura.php';

View file

@ -13,7 +13,7 @@ require_once str_replace(basename(__DIR__), '', dirname(__FILE__)) .'_sakura/sak
$forumMode = isset($_GET['forums']) ? ($_GET['forums'] == true) : false;
// Add page specific things
$renderData['newsPosts'] = ($forumMode ? null : Main::getNewsPosts(3));
$renderData['newsPosts'] = ($forumMode ? null : Main::getNewsPosts(Configuration::getConfig('front_page_news_posts')));
$renderData['page'] = [
'title' => ($forumMode ? 'Forum Listing' : Configuration::getConfig('sitename')),
@ -30,7 +30,6 @@ $renderData['stats'] = [
'userCount' => ($_INDEX_USER_COUNT = count($_INDEX_USERS = Users::getAllUsers(false))) .' user'. ($_INDEX_USER_COUNT == 1 ? '' : 's'),
'newestUser' => ($_INDEX_NEWEST_USER = max($_INDEX_USERS)),
'lastRegDate' => ($_INDEX_LAST_REGDATE = date_diff(date_create(date('Y-m-d', $_INDEX_NEWEST_USER['regdate'])), date_create(date('Y-m-d')))->format('%a')) .' day'. ($_INDEX_LAST_REGDATE == 1 ? '' : 's'),
'chatOnline' => ($_INDEX_CHAT_ONLINE = count(SockChat::getOnlineUsers())) .' user'. ($_INDEX_CHAT_ONLINE == 1 ? '' : 's'),
'onlineUsers' => Users::checkAllOnline(),
'topicCount' => ($_TOPICS = count(Database::fetch('topics'))) .' topic'. ($_TOPICS != 1 ? 's' : ''),
'postCount' => ($_POSTS = count(Database::fetch('posts'))) .' post'. ($_POSTS != 1 ? 's' : '')

View file

@ -6,6 +6,13 @@
// Declare Namespace
namespace Sakura;
// If this we're requesting notifications this page won't require templating
if(isset($_REQUEST['request-notifications']) && $_REQUEST['request-notifications']) {
define('SAKURA_NO_TPL', true);
}
// Include components
require_once str_replace(basename(__DIR__), '', dirname(__FILE__)) .'_sakura/sakura.php';