first few updates in ages

This commit is contained in:
Pachira 2016-04-25 04:01:14 +02:00
parent a435d15339
commit 888b22f14a
24 changed files with 350 additions and 345 deletions

View file

@ -39,6 +39,7 @@ class ActiveUser
->where('user_id', self::$user->id)
->update([
'user_last_online' => time(),
'last_ip' => Net::pton(Net::ip()),
]);
} else {
self::$user = User::construct(0);

View file

@ -36,6 +36,7 @@ class ForumController extends Controller
{
// Get the most active threads
$activeThreadsIds = DB::table('posts')
->where('forum_id', '!=', Config::get('forum_trash_id'))
->groupBy('topic_id')
->orderByRaw('COUNT(*) DESC')
->limit(10)
@ -69,6 +70,7 @@ class ForumController extends Controller
// Get the latest posts
$latestPostsIds = DB::table('posts')
->where('forum_id', '!=', Config::get('forum_trash_id'))
->orderBy('post_id', 'desc')
->limit(10)
->get(['post_id']);
@ -100,6 +102,7 @@ class ForumController extends Controller
// Get the most active poster
$activePosterId = DB::table('posts')
->where('forum_id', '!=', Config::get('forum_trash_id'))
->where('post_time', '>', time() - (24 * 60 * 60))
->groupBy('poster_id')
->orderByRaw('COUNT(*) DESC')

View file

@ -69,15 +69,15 @@ class MetaController extends Controller
'stats' => [
'userCount' => DB::table('users')
->where('password_algo', '!=', 'disabled')
->whereNotIn('rank_main', [1, 10])
->whereNotIn('rank_main', [Config::get('deactive_rank_id'), Config::get('restricted_rank_id')])
->count(),
'newestUser' => $newestUser,
'lastRegDate' => date_diff(
date_create(date('Y-m-d', $newestUser->registered)),
date_create(date('Y-m-d'))
)->format('%a'),
'topicCount' => DB::table('topics')->count(),
'postCount' => DB::table('posts')->count(),
'topicCount' => DB::table('topics')->where('forum_id', '!=', Config::get('forum_trash_id'))->count(),
'postCount' => DB::table('posts')->where('forum_id', '!=', Config::get('forum_trash_id'))->count(),
'onlineUsers' => $onlineUsers,
],
]);

View file

@ -82,8 +82,9 @@ class AdvancedController extends Controller
$sessions = DB::table('sessions')
->where('user_id', ActiveUser::$user->id)
->get();
$active = ActiveUser::$session->sessionId;
Template::vars(compact('sessions'));
Template::vars(compact('sessions', 'active'));
return Template::render('settings/advanced/sessions');
}

18
libraries/Exception.php Normal file
View file

@ -0,0 +1,18 @@
<?php
/**
* Holds the Exception class.
*
* @package Sakura
*/
namespace Sakura;
/**
* Sakura Exception class.
*
* @package Sakura
* @author Julian van de Groep <me@flash.moe>
*/
class Exception extends \Exception
{
}

View file

@ -10,6 +10,7 @@ namespace Sakura\Forum;
use Sakura\BBcode;
use Sakura\Config;
use Sakura\DB;
use Sakura\Exception;
use Sakura\Net;
use Sakura\User;
@ -124,13 +125,20 @@ class Post
$this->thread = $postRow->topic_id;
$this->forum = $postRow->forum_id;
$this->poster = User::construct($postRow->poster_id);
$this->ip = $postRow->poster_ip;
$this->time = $postRow->post_time;
$this->subject = $postRow->post_subject;
$this->text = $postRow->post_text;
$this->editTime = $postRow->post_edit_time;
$this->editReason = $postRow->post_edit_reason;
$this->editUser = User::construct($postRow->post_edit_user);
// Temporary backwards compatible IP storage system
try {
$this->ip = Net::ntop($postRow->poster_ip);
} catch (Exception $e) {
$this->ip = $postRow->poster_ip;
$this->update();
}
}
// Parse the markup
@ -168,7 +176,7 @@ class Post
'topic_id' => $thread->id,
'forum_id' => $thread->forum,
'poster_id' => $poster->id,
'poster_ip' => Net::ip(),
'poster_ip' => Net::pton(Net::ip()),
'post_time' => time(),
'post_subject' => $subject,
'post_text' => $text,
@ -235,6 +243,11 @@ class Post
*/
public function unread($user)
{
// Return false if the user id is less than 1
if ($user < 1) {
return false;
}
// Attempt to get track row from the database
$track = DB::table('topics_track')
->where('user_id', $user)

View file

@ -347,6 +347,11 @@ class Thread
*/
public function unread($user)
{
// Return false if the user id is less than 1
if ($user < 1) {
return false;
}
// Attempt to get track row from the database
$track = DB::table('topics_track')
->where('user_id', $user)

View file

@ -56,7 +56,7 @@ class Net
*
* @param string $ip Printable IP string.
*
* @throws \Exception Thrown if an invalid IP is supplied.
* @throws Exception Thrown if an invalid IP is supplied.
*
* @return string Unpacked IP address.
*/
@ -76,7 +76,7 @@ class Net
}
// Throw an exception if an invalid IP was supplied
throw new \Exception("Invalid IP address supplied.");
throw new Exception("Invalid IP address supplied.");
}
/**
@ -84,7 +84,7 @@ class Net
*
* @param string $bin The unpacked IP.
*
* @throws \Exception Thrown if the unpacked IP is invalid.
* @throws Exception Thrown if the unpacked IP is invalid.
*
* @return string The packed IP.
*/
@ -95,7 +95,7 @@ class Net
// Throw an exception if it's not 4 or 16 bytes
if ($len !== 4 && $len !== 16) {
throw new \Exception("Could not handle this IP type.");
throw new Exception("Could not handle this IP type.");
}
// Finally pack the IP

View file

@ -133,51 +133,8 @@ class Session
return 0;
}
// IP Check
$ipCheck = false; // Forced disabled due to incompatibility with the Net class. -- Config::get('session_check');
// Origin checking
if ($ipCheck) {
// Split both IPs up
$sessionIP = explode('.', $session[0]->user_ip);
$userIP = explode('.', Net::ip());
// Take 1 off the ipCheck variable so it's equal to the array keys
$ipCheck = $ipCheck - 1;
// Check if the user's IP is similar to the session's registered IP
switch ($ipCheck) {
// 000.xxx.xxx.xxx
case 3:
if ($userIP[3] !== $sessionIP[3]) {
return 0;
}
// xxx.000.xxx.xxx
case 2:
case 3:
if ($userIP[2] !== $sessionIP[2]) {
return 0;
}
// xxx.xxx.000.xxx
case 1:
case 2:
case 3:
if ($userIP[1] !== $sessionIP[1]) {
return 0;
}
// xxx.xxx.xxx.000
case 0:
case 1:
case 2:
case 3:
if ($userIP[0] !== $sessionIP[0]) {
return 0;
}
}
}
/* completely removed the code for ip checking because it only worked with IPv4
good thing is i can probably do CIDR based checking */
// If the remember flag is set extend the session time
if ($session[0]->session_remember) {

View file

@ -316,8 +316,6 @@ class User
$this->email = $userRow->email;
$this->mainRankId = $userRow->rank_main;
$this->colour = $userRow->user_colour;
$this->registerIp = Net::ntop($userRow->register_ip);
$this->lastIp = Net::ntop($userRow->last_ip);
$this->title = $userRow->user_title;
$this->registered = $userRow->user_registered;
$this->lastOnline = $userRow->user_last_online;
@ -328,6 +326,31 @@ class User
$this->header = $userRow->user_header;
$this->page = $userRow->user_page;
$this->signature = $userRow->user_signature;
// Temporary backwards compatible IP storage system
try {
$this->registerIp = Net::ntop($userRow->register_ip);
} catch (Exception $e) {
$this->registerIp = $userRow->register_ip;
DB::table('users')
->where('user_id', $this->id)
->update([
'register_ip' => Net::pton($this->registerIp),
]);
}
try {
$this->lastIp = Net::ntop($userRow->last_ip);
} catch (Exception $e) {
$this->lastIp = $userRow->last_ip;
DB::table('users')
->where('user_id', $this->id)
->update([
'last_ip' => Net::pton($this->lastIp),
]);
}
}
// Get all ranks

View file

@ -28,223 +28,239 @@ Router::filter('loginCheck', function () {
}
});
// Meta pages
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');
// Maintenance check
Router::filter('maintenance', function () {
if (Config::get('site_closed')) {
ActiveUser::$session->destroy();
// Auth
Router::group(['before' => 'logoutCheck'], function () {
Router::get('/login', 'AuthController@loginGet', 'auth.login');
Router::post('/login', 'AuthController@loginPost', 'auth.login');
Router::get('/register', 'AuthController@registerGet', 'auth.register');
Router::post('/register', 'AuthController@registerPost', 'auth.register');
Router::get('/resetpassword', 'AuthController@resetPasswordGet', 'auth.resetpassword');
Router::post('/resetpassword', 'AuthController@resetPasswordPost', 'auth.resetpassword');
Router::get('/reactivate', 'AuthController@reactivateGet', 'auth.reactivate');
Router::post('/reactivate', 'AuthController@reactivatePost', 'auth.reactivate');
Router::get('/activate', 'AuthController@activate', 'auth.activate');
});
Router::group(['before' => 'loginCheck'], function () {
Router::get('/logout', 'AuthController@logout', 'auth.logout');
http_response_code(503);
$message = Config::get('site_closed_reason');
Template::vars(compact('message'));
return Template::render('global/maintenance');
}
});
// News
Router::group(['prefix' => 'news'], function () {
Router::get('/{category:c}?', 'NewsController@category', 'news.category');
Router::get('/post/{id:i}', 'NewsController@post', 'news.post');
});
Router::group(['before' => 'maintenance'], function () {
// Meta pages
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');
// Forum
Router::group(['prefix' => 'forum'], function () {
// Post
Router::group(['prefix' => 'post'], function () {
Router::get('/{id:i}', 'ForumController@post', 'forums.post');
Router::group(['before' => 'loginCheck'], function () {
Router::get('/{id:i}/raw', 'ForumController@postRaw', 'forums.post.raw');
Router::get('/{id:i}/delete', 'ForumController@deletePost', 'forums.post.delete');
Router::post('/{id:i}/delete', 'ForumController@deletePost', 'forums.post.delete');
Router::post('/{id:i}/edit', 'ForumController@editPost', 'forums.post.edit');
});
// Auth
Router::group(['before' => 'logoutCheck'], function () {
Router::get('/login', 'AuthController@loginGet', 'auth.login');
Router::post('/login', 'AuthController@loginPost', 'auth.login');
Router::get('/register', 'AuthController@registerGet', 'auth.register');
Router::post('/register', 'AuthController@registerPost', 'auth.register');
Router::get('/resetpassword', 'AuthController@resetPasswordGet', 'auth.resetpassword');
Router::post('/resetpassword', 'AuthController@resetPasswordPost', 'auth.resetpassword');
Router::get('/reactivate', 'AuthController@reactivateGet', 'auth.reactivate');
Router::post('/reactivate', 'AuthController@reactivatePost', 'auth.reactivate');
Router::get('/activate', 'AuthController@activate', 'auth.activate');
});
Router::group(['before' => 'loginCheck'], function () {
Router::get('/logout', 'AuthController@logout', 'auth.logout');
});
// Thread
Router::group(['prefix' => 'thread'], function () {
Router::get('/{id:i}', 'ForumController@thread', 'forums.thread');
Router::post('/{id:i}/mod', 'ForumController@threadModerate', 'forums.thread.mod');
Router::post('/{id:i}/reply', 'ForumController@threadReply', 'forums.thread.reply');
// News
Router::group(['prefix' => 'news'], function () {
Router::get('/{category:c}?', 'NewsController@category', 'news.category');
Router::get('/post/{id:i}', 'NewsController@post', 'news.post');
});
// Forum
Router::get('/', 'ForumController@index', 'forums.index');
Router::get('/{id:i}', 'ForumController@forum', 'forums.forum');
Router::group(['before' => 'loginCheck'], function () {
Router::get('/{id:i}/mark', 'ForumController@markForumRead', 'forums.mark');
Router::get('/{id:i}/new', 'ForumController@createThread', 'forums.new');
Router::post('/{id:i}/new', 'ForumController@createThread', 'forums.new');
Router::group(['prefix' => 'forum'], function () {
// Post
Router::group(['prefix' => 'post'], function () {
Router::get('/{id:i}', 'ForumController@post', 'forums.post');
Router::group(['before' => 'loginCheck'], function () {
Router::get('/{id:i}/raw', 'ForumController@postRaw', 'forums.post.raw');
Router::get('/{id:i}/delete', 'ForumController@deletePost', 'forums.post.delete');
Router::post('/{id:i}/delete', 'ForumController@deletePost', 'forums.post.delete');
Router::post('/{id:i}/edit', 'ForumController@editPost', 'forums.post.edit');
});
});
// Thread
Router::group(['prefix' => 'thread'], function () {
Router::get('/{id:i}', 'ForumController@thread', 'forums.thread');
Router::post('/{id:i}/mod', 'ForumController@threadModerate', 'forums.thread.mod');
Router::post('/{id:i}/reply', 'ForumController@threadReply', 'forums.thread.reply');
});
// Forum
Router::get('/', 'ForumController@index', 'forums.index');
Router::get('/{id:i}', 'ForumController@forum', 'forums.forum');
Router::group(['before' => 'loginCheck'], function () {
Router::get('/{id:i}/mark', 'ForumController@markForumRead', 'forums.mark');
Router::get('/{id:i}/new', 'ForumController@createThread', 'forums.new');
Router::post('/{id:i}/new', 'ForumController@createThread', 'forums.new');
});
});
});
// Members
Router::group(['prefix' => 'members', 'before' => 'loginCheck'], function () {
Router::get('/', 'UserController@members', 'members.index');
Router::get('/{rank:i}', 'UserController@members', 'members.rank');
});
// User
Router::group(['prefix' => 'u'], function () {
Router::get('/{id}', 'UserController@profile', 'user.profile');
Router::get('/{id}/report', 'UserController@report', 'user.report');
Router::get('/{id}/header', 'FileController@header', 'user.header');
});
// Notifications
Router::group(['prefix' => 'notifications'], function () {
Router::get('/', 'NotificationsController@notifications', 'notifications.get');
Router::get('/{id}/mark', 'NotificationsController@mark', 'notifications.mark');
});
// Comments
Router::group(['prefix' => 'comments', 'before' => 'loginCheck'], function () {
Router::post('/{category:c}/post/{reply:i}?', 'CommentsController@post', 'comments.category.post');
Router::post('/{id:i}/delete', 'CommentsController@delete', 'comments.comment.delete');
Router::post('/{id:i}/vote', 'CommentsController@vote', 'comments.comment.vote');
});
// Comments
Router::group(['prefix' => 'friends', 'before' => 'loginCheck'], function () {
Router::post('/{id:i}/add', 'FriendsController@add', 'friends.add');
Router::post('/{id:i}/remove', 'FriendsController@remove', 'friends.remove');
});
// Files
Router::get('/a/{id}', 'FileController@avatar', 'file.avatar');
Router::get('/bg/{id}', 'FileController@background', 'file.background');
// Premium
Router::group(['prefix' => 'support', 'before' => 'loginCheck'], function () {
Router::get('/', 'PremiumController@index', 'premium.index');
Router::get('/handle', 'PremiumController@handle', 'premium.handle');
Router::get('/complete', 'PremiumController@complete', 'premium.complete');
Router::post('/purchase', 'PremiumController@purchase', 'premium.purchase');
});
// Helpers
Router::group(['prefix' => 'helper'], function () {
// BBcode
Router::group(['prefix' => 'bbcode', 'before' => 'loginCheck'], function () {
Router::post('/parse', 'HelperController@bbcodeParse', 'helper.bbcode.parse');
// Members
Router::group(['prefix' => 'members', 'before' => 'loginCheck'], function () {
Router::get('/', 'UserController@members', 'members.index');
Router::get('/{rank:i}', 'UserController@members', 'members.rank');
});
});
// Settings
Router::group(['prefix' => 'settings', 'before' => 'loginCheck'], function () {
Router::get('/', function () {
$route = Router::route('settings.general.home');
return header("Location: {$route}");
}, 'settings.index');
// User
Router::group(['prefix' => 'u'], function () {
Router::get('/{id}', 'UserController@profile', 'user.profile');
Router::get('/{id}/report', 'UserController@report', 'user.report');
Router::get('/{id}/header', 'FileController@header', 'user.header');
});
// General section
Router::group(['prefix' => 'general'], function () {
// Notifications
Router::group(['prefix' => 'notifications'], function () {
Router::get('/', 'NotificationsController@notifications', 'notifications.get');
Router::get('/{id}/mark', 'NotificationsController@mark', 'notifications.mark');
});
// Comments
Router::group(['prefix' => 'comments', 'before' => 'loginCheck'], function () {
Router::post('/{category:c}/post/{reply:i}?', 'CommentsController@post', 'comments.category.post');
Router::post('/{id:i}/delete', 'CommentsController@delete', 'comments.comment.delete');
Router::post('/{id:i}/vote', 'CommentsController@vote', 'comments.comment.vote');
});
// Comments
Router::group(['prefix' => 'friends', 'before' => 'loginCheck'], function () {
Router::post('/{id:i}/add', 'FriendsController@add', 'friends.add');
Router::post('/{id:i}/remove', 'FriendsController@remove', 'friends.remove');
});
// Files
Router::get('/a/{id}', 'FileController@avatar', 'file.avatar');
Router::get('/bg/{id}', 'FileController@background', 'file.background');
// Premium
Router::group(['prefix' => 'support', 'before' => 'loginCheck'], function () {
Router::get('/', 'PremiumController@index', 'premium.index');
Router::get('/handle', 'PremiumController@handle', 'premium.handle');
Router::get('/complete', 'PremiumController@complete', 'premium.complete');
Router::post('/purchase', 'PremiumController@purchase', 'premium.purchase');
});
// Helpers
Router::group(['prefix' => 'helper'], function () {
// BBcode
Router::group(['prefix' => 'bbcode', 'before' => 'loginCheck'], function () {
Router::post('/parse', 'HelperController@bbcodeParse', 'helper.bbcode.parse');
});
});
// Settings
Router::group(['prefix' => 'settings', 'before' => 'loginCheck'], function () {
Router::get('/', function () {
$route = Router::route('settings.general.home');
return header("Location: {$route}");
}, 'settings.index');
// General section
Router::group(['prefix' => 'general'], function () {
Router::get('/', function () {
$route = Router::route('settings.general.home');
return header("Location: {$route}");
});
Router::get('/home', 'Settings.GeneralController@home', 'settings.general.home');
Router::get('/profile', 'Settings.GeneralController@profile', 'settings.general.profile');
Router::post('/profile', 'Settings.GeneralController@profile', 'settings.general.profile');
Router::get('/options', 'Settings.GeneralController@options', 'settings.general.options');
Router::post('/options', 'Settings.GeneralController@options', 'settings.general.options');
});
Router::get('/home', 'Settings.GeneralController@home', 'settings.general.home');
Router::get('/profile', 'Settings.GeneralController@profile', 'settings.general.profile');
Router::post('/profile', 'Settings.GeneralController@profile', 'settings.general.profile');
Router::get('/options', 'Settings.GeneralController@options', 'settings.general.options');
Router::post('/options', 'Settings.GeneralController@options', 'settings.general.options');
});
// Friends section
Router::group(['prefix' => 'friends'], function () {
Router::get('/', function () {
$route = Router::route('settings.friends.listing');
return header("Location: {$route}");
});
// Friends section
Router::group(['prefix' => 'friends'], function () {
Router::get('/', function () {
$route = Router::route('settings.friends.listing');
return header("Location: {$route}");
Router::get('/listing', 'Settings.FriendsController@listing', 'settings.friends.listing');
Router::get('/requests', 'Settings.FriendsController@requests', 'settings.friends.requests');
});
Router::get('/listing', 'Settings.FriendsController@listing', 'settings.friends.listing');
Router::get('/requests', 'Settings.FriendsController@requests', 'settings.friends.requests');
});
// Groups section
Router::group(['prefix' => 'groups'], function () {
Router::get('/', function () {
$route = Router::route('settings.groups.listing');
return header("Location: {$route}");
});
// Groups section
Router::group(['prefix' => 'groups'], function () {
Router::get('/', function () {
$route = Router::route('settings.groups.listing');
return header("Location: {$route}");
Router::get('/listing', 'Settings.GroupsController@listing', 'settings.groups.listing');
Router::get('/invites', 'Settings.GroupsController@invites', 'settings.groups.invites');
});
Router::get('/listing', 'Settings.GroupsController@listing', 'settings.groups.listing');
Router::get('/invites', 'Settings.GroupsController@invites', 'settings.groups.invites');
});
// Notifications section
Router::group(['prefix' => 'notifications'], function () {
Router::get('/', function () {
$route = Router::route('settings.notifications.history');
return header("Location: {$route}");
});
// Notifications section
Router::group(['prefix' => 'notifications'], function () {
Router::get('/', function () {
$route = Router::route('settings.notifications.history');
return header("Location: {$route}");
Router::get('/history', 'Settings.NotificationsController@history', 'settings.notifications.history');
});
Router::get('/history', 'Settings.NotificationsController@history', 'settings.notifications.history');
});
// Appearance section
Router::group(['prefix' => 'appearance'], function () {
Router::get('/', function () {
$route = Router::route('settings.appearance.avatar');
return header("Location: {$route}");
});
// Appearance section
Router::group(['prefix' => 'appearance'], function () {
Router::get('/', function () {
$route = Router::route('settings.appearance.avatar');
return header("Location: {$route}");
Router::get('/avatar', 'Settings.AppearanceController@avatar', 'settings.appearance.avatar');
Router::post('/avatar', 'Settings.AppearanceController@avatar', 'settings.appearance.avatar');
Router::get('/background', 'Settings.AppearanceController@background', 'settings.appearance.background');
Router::post('/background', 'Settings.AppearanceController@background', 'settings.appearance.background');
Router::get('/header', 'Settings.AppearanceController@header', 'settings.appearance.header');
Router::post('/header', 'Settings.AppearanceController@header', 'settings.appearance.header');
Router::get('/userpage', 'Settings.AppearanceController@userpage', 'settings.appearance.userpage');
Router::post('/userpage', 'Settings.AppearanceController@userpage', 'settings.appearance.userpage');
Router::get('/signature', 'Settings.AppearanceController@signature', 'settings.appearance.signature');
Router::post('/signature', 'Settings.AppearanceController@signature', 'settings.appearance.signature');
});
Router::get('/avatar', 'Settings.AppearanceController@avatar', 'settings.appearance.avatar');
Router::post('/avatar', 'Settings.AppearanceController@avatar', 'settings.appearance.avatar');
Router::get('/background', 'Settings.AppearanceController@background', 'settings.appearance.background');
Router::post('/background', 'Settings.AppearanceController@background', 'settings.appearance.background');
Router::get('/header', 'Settings.AppearanceController@header', 'settings.appearance.header');
Router::post('/header', 'Settings.AppearanceController@header', 'settings.appearance.header');
Router::get('/userpage', 'Settings.AppearanceController@userpage', 'settings.appearance.userpage');
Router::post('/userpage', 'Settings.AppearanceController@userpage', 'settings.appearance.userpage');
Router::get('/signature', 'Settings.AppearanceController@signature', 'settings.appearance.signature');
Router::post('/signature', 'Settings.AppearanceController@signature', 'settings.appearance.signature');
});
// Account section
Router::group(['prefix' => 'account'], function () {
Router::get('/', function () {
$route = Router::route('settings.account.email');
return header("Location: {$route}");
});
// Account section
Router::group(['prefix' => 'account'], function () {
Router::get('/', function () {
$route = Router::route('settings.account.email');
return header("Location: {$route}");
Router::get('/email', 'Settings.AccountController@email', 'settings.account.email');
Router::post('/email', 'Settings.AccountController@email', 'settings.account.email');
Router::get('/username', 'Settings.AccountController@username', 'settings.account.username');
Router::post('/username', 'Settings.AccountController@username', 'settings.account.username');
Router::get('/title', 'Settings.AccountController@title', 'settings.account.title');
Router::post('/title', 'Settings.AccountController@title', 'settings.account.title');
Router::get('/password', 'Settings.AccountController@password', 'settings.account.password');
Router::post('/password', 'Settings.AccountController@password', 'settings.account.password');
Router::get('/ranks', 'Settings.AccountController@ranks', 'settings.account.ranks');
Router::post('/ranks', 'Settings.AccountController@ranks', 'settings.account.ranks');
});
Router::get('/email', 'Settings.AccountController@email', 'settings.account.email');
Router::post('/email', 'Settings.AccountController@email', 'settings.account.email');
Router::get('/username', 'Settings.AccountController@username', 'settings.account.username');
Router::post('/username', 'Settings.AccountController@username', 'settings.account.username');
Router::get('/title', 'Settings.AccountController@title', 'settings.account.title');
Router::post('/title', 'Settings.AccountController@title', 'settings.account.title');
Router::get('/password', 'Settings.AccountController@password', 'settings.account.password');
Router::post('/password', 'Settings.AccountController@password', 'settings.account.password');
Router::get('/ranks', 'Settings.AccountController@ranks', 'settings.account.ranks');
Router::post('/ranks', 'Settings.AccountController@ranks', 'settings.account.ranks');
});
// Advanced section
Router::group(['prefix' => 'advanced'], function () {
Router::get('/', function () {
$route = Router::route('settings.advanced.sessions');
return header("Location: {$route}");
});
// Advanced section
Router::group(['prefix' => 'advanced'], function () {
Router::get('/', function () {
$route = Router::route('settings.advanced.sessions');
return header("Location: {$route}");
Router::get('/sessions', 'Settings.AdvancedController@sessions', 'settings.advanced.sessions');
Router::post('/sessions', 'Settings.AdvancedController@sessions', 'settings.advanced.sessions');
Router::get('/deactivate', 'Settings.AdvancedController@deactivate', 'settings.advanced.deactivate');
Router::post('/deactivate', 'Settings.AdvancedController@deactivate', 'settings.advanced.deactivate');
});
Router::get('/sessions', 'Settings.AdvancedController@sessions', 'settings.advanced.sessions');
Router::post('/sessions', 'Settings.AdvancedController@sessions', 'settings.advanced.sessions');
Router::get('/deactivate', 'Settings.AdvancedController@deactivate', 'settings.advanced.deactivate');
Router::post('/deactivate', 'Settings.AdvancedController@deactivate', 'settings.advanced.deactivate');
});
});
// Management
/*
/*
* General
* - Dashboard
* - Info pages (possibly deprecate with wiki)
@ -274,3 +290,4 @@ Router::group(['prefix' => 'settings', 'before' => 'loginCheck'], function () {
* - Management
* - Errors
*/
});

View file

@ -8,7 +8,7 @@
namespace Sakura;
// Define Sakura version
define('SAKURA_VERSION', 20160408);
define('SAKURA_VERSION', 20160425);
// Define Sakura Path
define('ROOT', __DIR__ . '/');
@ -25,12 +25,12 @@ mb_internal_encoding('utf-8');
// Stop the execution if the PHP Version is older than 7.0.0
if (version_compare(phpversion(), '7.0.0', '<')) {
throw new \Exception('Sakura requires at least PHP 7.0.0, please upgrade to a newer PHP version.');
throw new Exception('Sakura requires at least PHP 7.0.0, please upgrade to a newer PHP version.');
}
// Check if the composer autoloader exists
if (!file_exists(ROOT . 'vendor/autoload.php')) {
throw new \Exception('Autoloader not found, did you run composer install?');
throw new Exception('Autoloader not found, did you run composer install?');
}
// Require composer libraries
@ -87,9 +87,10 @@ Router::init();
include_once ROOT . 'routes.php';
// Initialise the current session
$cookiePrefix = Config::get('cookie_prefix');
ActiveUser::init(
intval($_COOKIE[Config::get('cookie_prefix') . 'id'] ?? 0),
$_COOKIE[Config::get('cookie_prefix') . 'session'] ?? ''
intval($_COOKIE["{$cookiePrefix}id"] ?? 0),
$_COOKIE["{$cookiePrefix}session"] ?? ''
);
if (!defined('SAKURA_NO_TPL')) {
@ -98,32 +99,11 @@ if (!defined('SAKURA_NO_TPL')) {
// Set base page rendering data
Template::vars([
'sakura' => [
'currentPage' => $_SERVER['REQUEST_URI'] ?? null,
'referrer' => $_SERVER['HTTP_REFERER'] ?? null,
],
'session' => array_merge([
'sessionId' => ActiveUser::$session->sessionId,
], $_SESSION),
'user' => ActiveUser::$user,
'get' => $_GET,
'user' => ActiveUser::$user,
'post' => $_POST,
'request' => $_REQUEST,
'server' => $_SERVER,
'request' => $_REQUEST,
'session' => $_SESSION,
]);
// Site closing
if (Config::get('site_closed')) {
// Set parse variables
Template::vars([
'message' => Config::get('site_closed_reason'),
]);
// Print page contents
echo Template::render('global/information');
exit;
}
}

View file

@ -108,7 +108,7 @@
<li><a href="{{ urls.format('SETTING_CAT', ['messages']) }}">Private Messages</a></li>
<li><a href="{{ urls.format('SETTINGS_INDEX') }}">User Settings</a></li>
<li><a href="{{ urls.format('MANAGE_INDEX') }}">Site Management</a></li>
<li><a href="{{ urls.format('USER_LOGOUT', [date().timestamp, session_id(), sakura.currentPage]) }}">Logout</a></li>
<li><a href="{{ urls.format('USER_LOGOUT', [date().timestamp, session_id(), server['REQUEST_URI']]) }}">Logout</a></li>
</ul>
{% endif %}
</li>

View file

@ -95,7 +95,7 @@
<li class="edit"><a title="Edit your profile" href="{{ urls.format('SETTING_MODE', ['general', 'profile']) }}">Edit</a></li>
<li class="settings"><a title="Change your settings" href="{{ urls.format('SETTINGS_INDEX') }}">Settings</a></li>
{% else %}
<li class="{% if user.checkFriends(profile.id) == 2 %}mutualFriend{% elseif user.checkFriends(profile.id) == 1 %}pendingFriend{% else %}addFriend{% endif %}"><a href="{% if user.checkFriends(profile.id) == 0 %}{{ urls.format('FRIEND_ADD', [profile.id, session_id(), date().timestamp, sakura.currentPage]) }}{% else %}{{ urls.format('FRIEND_REMOVE', [profile.id, session_id(), date().timestamp, sakura.currentPage]) }}{% endif %}">{% if user.checkFriends(profile.id) == 0 %}Add friend{% else %}Friends{% endif %}</a></li>
<li class="{% if user.checkFriends(profile.id) == 2 %}mutualFriend{% elseif user.checkFriends(profile.id) == 1 %}pendingFriend{% else %}addFriend{% endif %}"><a href="{% if user.checkFriends(profile.id) == 0 %}{{ urls.format('FRIEND_ADD', [profile.id, session_id(), date().timestamp, server['REQUEST_URI']]) }}{% else %}{{ urls.format('FRIEND_REMOVE', [profile.id, session_id(), date().timestamp, server['REQUEST_URI']]) }}{% endif %}">{% if user.checkFriends(profile.id) == 0 %}Add friend{% else %}Friends{% endif %}</a></li>
<li class="report"><a href="{{ route('user.report', profile.id) }}">Report</a></li>
{% endif %}
</ul>

View file

@ -1,4 +1,4 @@
<form enctype="multipart/form-data" method="post" action="{{ sakura.currentPage }}" class="box">
<form enctype="multipart/form-data" method="post" action="{{ server['REQUEST_URI'] }}" class="box">
<input type="hidden" name="sessid" value="{{ session_id() }}" />
<input type="hidden" name="timestamp" value="{{ date().timestamp }}" />
<input type="hidden" name="mode" value="options" />

View file

@ -12,8 +12,7 @@
Login
</div>
<form method="post" action="{{ route('auth.login') }}" id="loginForm">
<input type="hidden" name="redirect" value="{{ sakura.referrer ? sakura.referrer : route('main.index') }}" />
<input type="hidden" name="session" value="{{ session_id() }}" />
<input type="hidden" name="redirect" value="{{ server['HTTP_REFERER'] ? server['HTTP_REFERER'] : route('main.index') }}" />
<div class="leftAlign">
<label for="loginUserName">Username:</label>
</div>
@ -30,7 +29,7 @@
<input class="inputStyling" name="remember" type="checkbox" class="ignore-css" id="loginRemember" /><label for="loginRemember">Remember Me</a>
</div>
<div class="centreAlign">
<button class="inputStyling" id="loginButton"><i class="fa fa-sign-in"></i> Login</button>
<button class="inputStyling" id="loginButton" name="session" value="{{ session_id() }}"><i class="fa fa-sign-in"></i> Login</button>
</div>
<div class="subLinks centreAlign" style="line-height: 1.5em;">
<p><a href="{{ route('auth.register') }}" class="default">I don't have an account yet!</a></p>

View file

@ -10,21 +10,6 @@
{% endif %}
</div>
</div>
{% else %}
{% if config('lock_authentication') %}
<div class="head">Whoops!</div>
You caught the site at the wrong moment! Right now registration <i>and</i> logging in is disabled for unspecified reasons. Sorry for the inconvenience but please try again later!
<div class="indexSidePanelLinks">
<a class="fa fa-lock" href="#" title="Authentication is locked"></a>
</div>
{% else %}
<div class="head">Welcome!</div>
Welcome to Flashii! This is a site for a bunch of friends to hang out, nothing special. Anyone is pretty much welcome to register so why not have a go?
<div class="indexSidePanelLinks">
<a class="fa fa-magic" href="{{ route('auth.register') }}" title="Register" id="indexSidePanelRegister"></a>
<a class="fa fa-sign-in" href="{{ route('auth.login') }}" title="Login" id="indexSidePanelLogin"></a>
</div>
{% endif %}
{% endif %}
<div class="head">Stats</div>
We have <b>{{ stats.userCount }} user{% if stats.userCount != 1 %}s{% endif %}</b>,

View file

@ -8,7 +8,7 @@
<h1>{% block header %}Confirmation{% endblock %}</h1>
<hr class="default" />
{{ message }}
<form method="post" action="{{ sakura.currentPage }}" id="confirmationForm">
<form method="post" action="{{ server['REQUEST_URI'] }}" id="confirmationForm">
<input type="hidden" name="sessionid" value="{{ session_id() }}" />
<input type="hidden" name="timestamp" value="{{ date().timestamp }}" />
{% for key,value in conditions %}

View file

@ -0,0 +1,28 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>Service unavailable</title>
<link rel="stylesheet" type="text/css" href="{{ resource('css/error.css') }}" />
</head>
<body>
<div id="wrap">
<h1>
<img src="{{ resource('images/404-info.gif') }}" />
The page is currently unavailable
</h1>
<p>
The page you are looking for is temporarily unavailable.
</p>
<hr />
<h2>
{{ message }}
</h2>
<h3>
HTTP 503 - Service unavailable
<br />
Internet Explorer
</h3>
</div>
</body>
</html>

View file

@ -111,13 +111,10 @@
{% if profile is defined ? profile.background : (user.permission(constant('Sakura\\Perms\\Site::CHANGE_BACKGROUND')) and user.optionFields.profileBackgroundSiteWide and user.background) %}
<div id="userBackground" style="background-image: url('{{ route('file.background', (profile is defined ? profile : user).id) }}');"></div>
{% endif %}
{% if not user.isActive and sakura.currentPage != route('auth.login') %}
{% if not user.isActive and server['REQUEST_URI'] != route('auth.login') %}
<div class="headerLoginContainer">
<form method="post" action="{{ route('auth.login') }}" id="headerLoginForm">
<input type="hidden" name="redirect" value="{{ sakura.currentPage }}" />
<input type="hidden" name="session" value="{{ session_id() }}" />
<input type="hidden" name="time" value="{{ date().timestamp }}" />
<input type="hidden" name="mode" value="login" />
<input type="hidden" name="redirect" value="{{ server['REQUEST_URI'] }}" />
<div>
<label for="headerLoginUserName">Username:</label>
<input type="text" id="headerLoginUserName" name="username" class="inputStyling" placeholder="Username" />
@ -131,12 +128,9 @@
<label for="headerLoginRemember">Remember me</label>
</div>
<div>
<input type="submit" id="headerLoginButton" name="submit" class="inputStyling small" value="Login" />
<button class="inputStyling small" name="session" value="{{ session_id() }}"><i class="fa fa-sign-in"></i> Login</button>
</div>
</form>
<form method="get" action="{{ route('auth.register') }}">
<button class="inputStyling small">Register</button>
</form>
</div>
{% endif %}
{% if user.permission(constant('Sakura\\Perms\\Site::RESTRICTED')) %}

View file

@ -4,6 +4,15 @@
{% set persistentPremium = user.permission(constant('Sakura\\Perms\\Site::STATIC_PREMIUM')) %}
{% set features = {
"money": "Helping us pay for the bills to survive",
"certificate": "A <span style='font-weight: bold; color: #EE9400'>special</span> name colour to stand out in the crowd",
"magic": "The ability to change your username once a month",
"pencil": "You can set a custom user title",
"lock": "Access to some exclusive forums",
"picture-o": "You get the ability to set a profile background"
} %}
{% block content %}
{% if get.fail %}
<div class="headerNotify">
@ -14,61 +23,28 @@
<div class="content support">
<div class="head">Support {{ config('sitename') }}</div>
<div style="font-size: .9em; margin-bottom: 10px;">
<p>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!</p>
<p>To keep the site and everything surrounding it running I need money to pay the bills, however instead of just having a donate button I decided on adding a premium system to the site which gives you a few extras. The premium rank is indentified on the site by Tenshi. More stuff that literally doesn't exist yet will be added to the list of featuring down the line but in order, the stuff that already exist can be seen further down on this page. With your help we can keep adding new stuff, get new hardware and keep the site awesome!</p>
</div>
{% if user.isPremium %}
<div class="sectionHeader">
Your current Tenshi tag
</div>
<div style="margin-bottom: 10px;">
<h3>{% if persistentPremium %}Your rank has persistent Tenshi.{% else %}Your Tenshi tag is valid till {{ user.premiumInfo.expire|date(config('date_format')) }}.{% endif %}</h3>
<progress value="{{ persistentPremium ? 100 : (100 - (((date().timestamp - user.premiumInfo.start) / (user.premiumInfo.expire - user.premiumInfo.start)) * 100)) }}" max="100" style="width: 100%"></progress>
</div>
<div class="sectionHeader">
Your current Tenshi tag
</div>
<div style="margin-bottom: 10px;">
<h3>{% if persistentPremium %}Your rank has persistent Tenshi.{% else %}Your Tenshi tag is valid till {{ user.premiumInfo.expire|date(config('date_format')) }}.{% endif %}</h3>
<progress value="{{ persistentPremium ? 100 : (100 - (((date().timestamp - user.premiumInfo.start) / (user.premiumInfo.expire - user.premiumInfo.start)) * 100)) }}" max="100" style="width: 100%"></progress>
</div>
{% endif %}
<div class="sectionHeader">
Why should I get Tenshi?
</div>
<div class="featureParent">
<div class="featureBox">
<div class="featureBoxIcon fa fa-money"></div>
<div class="featureBoxDesc">Helping us pay for the bills to survive</div>
<div class="clear"></div>
</div>
<div class="featureBox">
<div class="featureBoxIcon fa fa-certificate"></div>
<div class="featureBoxDesc">A <span style="font-weight: bold; color: #EE9400">special</span> name colour to stand out in the crowd</div>
<div class="clear"></div>
</div>
<div class="featureBox">
<div class="featureBoxIcon fa fa-magic"></div>
<div class="featureBoxDesc">The ability to change your username once a month</div>
<div class="clear"></div>
</div>
<div class="featureBox">
<div class="featureBoxIcon fa fa-pencil"></div>
<div class="featureBoxDesc">You can set a custom user title</div>
<div class="clear"></div>
</div>
<div class="featureBox">
<div class="featureBoxIcon fa fa-archive"></div>
<div class="featureBoxDesc">You'll be able to read the chat logs</div>
<div class="clear"></div>
</div>
<div class="featureBox">
<div class="featureBoxIcon fa fa-eye-slash"></div>
<div class="featureBoxDesc">You can create temporary channels in the chat</div>
<div class="clear"></div>
</div>
<div class="featureBox">
<div class="featureBoxIcon fa fa-users"></div>
<div class="featureBoxDesc">You get to create a user group</div>
<div class="clear"></div>
</div>
<div class="featureBox">
<div class="featureBoxIcon fa fa-picture-o"></div>
<div class="featureBoxDesc">You get the ability to set a profile background</div>
<div class="clear"></div>
</div>
{% for k,v in features %}
<div class="featureBox">
<div class="featureBoxIcon fa fa-{{ k }}"></div>
<div class="featureBoxDesc">{{ v|raw }}</div>
<div class="clear"></div>
</div>
{% endfor %}
<div class="featureBox final">
<div class="featureBoxIcon fa fa-heart"></div>
<div class="featureBoxIcon right fa fa-heart"></div>

View file

@ -15,7 +15,7 @@
<a href="{{ route('members.rank', rank.id) }}" class="clean">{{ rank.name }}</a>
</td>
<td style="width: 90px;">
<form method="post" action="{{ sakura.currentPage }}">
<form method="post" action="{{ route('settings.account.ranks') }}">
<input type="hidden" name="session" value="{{ session_id() }}" />
<input type="hidden" name="rank" value="{{ rank.id }}" />
<button class="inputStyling small" name="mode" value="main">Set as main</button>

View file

@ -18,7 +18,7 @@
</tfoot>
<tbody>
{% for s in sessions %}
<tr {% if s.session_key == session.sessionId %} class="current-session"{% endif %}>
<tr {% if s.session_key == active %} class="current-session"{% endif %}>
<td>
{{ s.user_ip }}
</td>

View file

@ -75,6 +75,11 @@ function get_country_name($code)
return 'Anonymous Proxy';
}
// Catch proxy
if (strtolower($code) === 'a2') {
return 'Satellite Provider';
}
return locale_get_display_region("-{$code}", 'en');
}