r20151211

Signed-off-by: Flashwave <me@flash.moe>
This commit is contained in:
flash 2015-12-11 21:49:40 +01:00
parent 5cce6c3e82
commit cf33d8a059
17 changed files with 199 additions and 426 deletions

View file

@ -76,7 +76,8 @@ class mysql
PDO::ATTR_EMULATE_PREPARES => false, PDO::ATTR_EMULATE_PREPARES => false,
PDO::ATTR_ERRMODE => PDO::ERRMODE_WARNING, PDO::ATTR_ERRMODE => PDO::ERRMODE_WARNING,
]); ]);
} catch (PDOException $e) { }
catch (PDOException $e) {
// Catch connection errors // Catch connection errors
trigger_error('SQL Driver: ' . $e->getMessage(), E_USER_ERROR); trigger_error('SQL Driver: ' . $e->getMessage(), E_USER_ERROR);
} }

View file

@ -25,6 +25,7 @@ class Forum
private $_lastPost = null; private $_lastPost = null;
private $_forums = []; private $_forums = [];
private $_threads = []; private $_threads = [];
private $_permissions;
// Constructor // Constructor
public function __construct($forumId = 0) public function __construct($forumId = 0)

View file

@ -1,333 +0,0 @@
<?php
/*
* Discussion Board
*/
namespace Sakura\Forum;
use Sakura\Main;
use Sakura\Database;
use Sakura\User;
use Sakura\BBcode;
/**
* Class Forums
* @package Sakura
*/
class Forums
{
// Empty forum template
public static $emptyForum = [
'forum_id' => 0,
'forum_name' => 'Forum',
'forum_desc' => '',
'forum_link' => '',
'forum_category' => 0,
'forum_type' => 1,
'forum_posts' => 0,
'forum_topics' => 0,
];
// Get a forum or category
public static function getForum($id)
{
// Get the forumlist from the database
$forums = Database::fetch('forums');
// Sneak the template in the array
$forums['fb'] = self::$emptyForum;
// Create an array to store the forum once we found it
$forum = [];
// Try to find the requested forum
foreach ($forums as $list) {
// Once found set $forum to $list and break the loop
if ($list['forum_id'] == $id) {
$forum['forum'] = $list;
break;
}
}
// If $forum is still empty after the foreach return false
if (empty($forum)) {
return false;
}
// Create conditions for fetching the forums
$conditions['forum_category'] = [$id, '='];
// If the current category is 0 (the built in fallback) prevent getting categories
if ($id == 0) {
$conditions['forum_type'] = ['1', '!='];
}
// Check if this forum/category has any subforums
$forum['forums'] = Database::fetch('forums', true, $conditions);
// Get the userdata related to last posts
foreach ($forum['forums'] as $key => $sub) {
// Get last post in forum
$lastPost = Database::fetch('posts', false, [
'forum_id' => [$sub['forum_id'], '='],
], ['post_id', true]);
$forum['forums'][$key]['last_poster'] = new User($lastPost['poster_id']);
$forum['forums'][$key]['last_post'] = array_merge(
empty($lastPost) ? [] : $lastPost,
['elapsed' => Main::timeElapsed($lastPost['post_time'])]
);
}
// Lastly grab the topics for this forum
$forum['topics'] = self::getTopics($forum['forum']['forum_id']);
// Return the forum/category
return $forum;
}
// Getting all topics from a forum
public static function getTopics($id)
{
// Get the topics from the database
$topics = Database::fetch('topics', true, [
'forum_id' => [$id, '='],
]);
// Get the userdata related to last posts
foreach ($topics as $key => $topic) {
// Get the reply count
$topics[$key]['reply_count'] = Database::count('posts', [
'topic_id' => [$topic['topic_id'], '='],
])[0];
// Get first post in topics
$firstPost = Database::fetch('posts', false, [
'topic_id' => [$topic['topic_id'], '='],
]);
$topics[$key]['first_poster'] = new User($firstPost['poster_id']);
$topics[$key]['first_post'] = array_merge(
empty($firstPost) ? [] : $firstPost,
['elapsed' => Main::timeElapsed($firstPost['post_time'])]
);
// Get last post in topics
$lastPost = Database::fetch('posts', false, [
'topic_id' => [$topic['topic_id'], '='],
], ['post_id', true]);
$topics[$key]['last_poster'] = new User($lastPost['poster_id']);
$topics[$key]['last_post'] = array_merge(
empty($lastPost) ? [] : $lastPost,
['elapsed' => Main::timeElapsed($lastPost['post_time'])]
);
}
return $topics;
}
// Get posts of a thread
public static function getTopic($id, $ignoreView = false)
{
// Get the topic data from the database
$topicInfo = Database::fetch('topics', false, [
'topic_id' => [$id, '='],
]);
// Check if there actually is anything
if (empty($topicInfo)) {
return false;
}
// Up the view count
if (!$ignoreView) {
// Get the new count
$topicInfo['topic_views'] = $topicInfo['topic_views'] + 1;
// Update the count
Database::update('topics', [
[
'topic_views' => $topicInfo['topic_views'],
],
[
'topic_id' => [$id, '='],
],
]);
}
// Get the posts from the database
$rawPosts = Database::fetch('posts', true, [
'topic_id' => [$id, '='],
]);
// Create storage array
$topic = [];
// Add forum data
$topic['forum'] = self::getForum($topicInfo['forum_id']);
// Store the topic info
$topic['topic'] = $topicInfo;
// Get first post in topics
$firstPost = Database::fetch('posts', false, [
'topic_id' => [$topic['topic']['topic_id'], '='],
]);
$topic['topic']['first_poster'] = new User($firstPost['poster_id']);
$topic['topic']['first_post'] = array_merge(
empty($firstPost) ? [] : $firstPost,
['elapsed' => Main::timeElapsed($firstPost['post_time'])]
);
// Get last post in topics
$lastPost = Database::fetch('posts', false, [
'topic_id' => [$topic['topic']['topic_id'], '='],
], ['post_id', true]);
$topic['topic']['last_poster'] = new User($lastPost['poster_id']);
$topic['topic']['last_post'] = array_merge(
empty($lastPost) ? [] : $lastPost,
['elapsed' => Main::timeElapsed($lastPost['post_time'])]
);
// Create space for posts
$topic['posts'] = [];
// Parse the data of every post
foreach ($rawPosts as $post) {
// Add post and metadata to the global storage array
$topic['posts'][$post['post_id']] = array_merge($post, [
'user' => (new User($post['poster_id'])),
'elapsed' => Main::timeElapsed($post['post_time']),
'is_op' => ($post['poster_id'] == $firstPost['poster_id'] ? '1' : '0'),
'parsed_post' => BBcode::toHTML($post['post_text']),
]);
// Just in case
unset($_POSTER);
}
// Return the compiled topic data
return $topic;
}
// Get a forum ID from a topic ID
public static function getForumIdFromTopicId($id)
{
// Get the topic
$topic = Database::fetch('topics', false, [
'topic_id' => [$id, '='],
]);
// Return false if nothing was returned
if (empty($topic)) {
return false;
}
// Return the forum id
return $topic['forum_id'];
}
// Get a topic ID from a post ID
public static function getTopicIdFromPostId($id)
{
// Get the post
$post = Database::fetch('posts', false, [
'post_id' => [$id, '='],
]);
// Return false if nothing was returned
if (empty($post)) {
return false;
}
// Return the topic id
return $post['topic_id'];
}
// Get forum statistics of a user
public static function getUserStats($uid)
{
// Collect the stats
return [
'posts' => Database::count(
'posts',
['poster_id' => [$uid, '=']]
)[0],
'topics' => count(Database::fetch(
'posts',
true,
['poster_id' => [$uid, '=']],
['post_time'],
null,
['topic_id']
)),
];
}
// Creating a new post
public static function createPost($poster, $title, $text, $forum, $topic = 0, $parse = 0, $signature = 0, $emotes = 0, $type = 0, $status = 0)
{
// Check if we're replying to a thread
$getThread = Database::fetch('topics', false, ['topic_id' => [$topic, '=']]);
// If nothing was returned create a new thread
if (!$getThread) {
// Insert the required data
Database::insert('topics', [
'forum_id' => $forum,
'topic_title' => $title,
'topic_time' => time(),
'topic_status' => $status,
'topic_type' => $type,
]);
// Fetch the last insert
$getThread = Database::fetch('topics', false, [
'topic_id' => [Database::lastInsertID(), '='],
]);
}
// Insert the post
Database::insert('posts', [
'topic_id' => $getThread['topic_id'],
'forum_id' => $getThread['forum_id'],
'poster_id' => $poster,
'post_time' => time(),
'post_signature' => $signature,
'post_subject' => $title,
'post_text' => $text,
]);
// Fetch the last insert
$getPost = Database::fetch('posts', false, [
'post_id' => [Database::lastInsertID(), '='],
]);
// Update the topic with the last details
Database::update('topics', [
[
'topic_last_reply' => time(),
],
[
'topic_id' => [$getPost['topic_id'], '='],
],
]);
// Return success
return [1, 'SUCCESS', $getPost['forum_id'], $getPost['topic_id'], $getPost['post_id']];
}
}

View file

@ -0,0 +1,26 @@
<?php
/*
* Forum specific permissions class
*/
namespace Sakura\Forum;
use Sakura\Database;
/**
* Class Permissions
* @package Sakura
*/
class Permissions
{
// Permissions
const VIEW = 1;
const REPLY = 2;
const CREATE_THREADS = 4;
const EDIT_OWN = 8;
const DELETE_OWN = 16;
const STICKY = 32;
const ANNOUNCEMENT = 64;
const EDIT_ANY = 128;
const DELETE_ANY = 256;
}

View file

@ -59,6 +59,43 @@ class Post
$this->parsed = BBcode::toHTML(htmlentities($this->text)); $this->parsed = BBcode::toHTML(htmlentities($this->text));
} }
// Create a new post
public static function create($subject, $text, User $poster, $thread = 0, $forum = 0)
{
// If no thread is specified create a new one
if ($thread) {
$thread = new Thread($thread);
} else {
$thread = Thread::create($forum, $subject);
}
// Stop if the thread ID is 0
if ($thread->id == 0) {
return null;
}
// Insert the post
Database::insert('posts', [
'topic_id' => $thread->id,
'forum_id' => $thread->forum,
'poster_id' => $poster->id(),
'poster_ip' => Main::getRemoteIP(),
'post_time' => time(),
'post_signature' => '1',
'post_subject' => $subject,
'post_text' => $text,
]);
// Get post id
$id = Database::lastInsertID();
// Update the last post date
$thread->lastUpdate();
// Return the object
return new Post($id);
}
// Time elapsed since creation // Time elapsed since creation
public function timeElapsed() public function timeElapsed()
{ {

View file

@ -1,23 +0,0 @@
<?php
/*
* Posting handler
*/
namespace Sakura\Forum;
use Sakura\Main;
use Sakura\Database;
use Sakura\User;
use Sakura\BBcode;
/**
* Class Posting
* @package Sakura
*/
class Posting
{
// Construct a new post action
public function __construct($forum, $thread = null)
{
}
}

View file

@ -50,6 +50,22 @@ class Thread
} }
} }
// Create a new topic
public static function create($forum, $title, $status = 0, $type = 0)
{
// Create the database entry
Database::insert('topics', [
'forum_id' => $forum,
'topic_title' => $title,
'topic_time' => time(),
'topic_status' => $status,
'topic_type' => $type,
]);
// Return the thread object
return new Thread(Database::lastInsertID());
}
// Posts // Posts
public function posts() public function posts()
{ {
@ -190,4 +206,17 @@ class Thread
], ],
]); ]);
} }
// Update last post timestamp
public function lastUpdate()
{
Database::update('topics', [
[
'topic_last_reply' => time(),
],
[
'topic_id' => [$this->id, '='],
],
]);
}
} }

View file

@ -13,22 +13,17 @@ class Permissions
{ {
// Fallback permission data // Fallback permission data
private static $fallback = [ private static $fallback = [
'rank_id' => 0, 'rank_id' => 0,
'user_id' => 0, 'user_id' => 0,
'permissions_site' => 1, 'permissions_site' => 1,
'permissions_manage' => 0, 'permissions_manage' => 0,
'permissions_forums' => 0, 'permissions_inherit' => 11,
'permissions_inherit' => 111,
]; ];
// Global permissions table // Global permissions table
protected static $permissions = [ protected static $permissions = [
// Site permissions // Site permissions
'SITE' => [ 'SITE' => [
'DEACTIVATED' => 1, // Is a user deactivated 'DEACTIVATED' => 1, // Is a user deactivated
'RESTRICTED' => 2, // Is a user restricted 'RESTRICTED' => 2, // Is a user restricted
'ALTER_PROFILE' => 4, // Can alter their profile data 'ALTER_PROFILE' => 4, // Can alter their profile data
@ -61,29 +56,17 @@ class Permissions
'DELETE_COMMENTS' => 536870912, // User can delete own comments 'DELETE_COMMENTS' => 536870912, // User can delete own comments
'VOTE_COMMENTS' => 1073741824, // User can vote on comments 'VOTE_COMMENTS' => 1073741824, // User can vote on comments
'CHANGE_SIGNATURE' => 2147483648, // User can vote on comments 'CHANGE_SIGNATURE' => 2147483648, // User can vote on comments
],
// Forum permissions
'FORUM' => [
'USE_FORUM' => 1,
], ],
// Site management permissions // Site management permissions
'MANAGE' => [ 'MANAGE' => [
'USE_MANAGE' => 1, 'USE_MANAGE' => 1,
], ],
]; ];
// Checking if a user has the permissions to do a thing // Checking if a user has the permissions to do a thing
public static function check($layer, $action, $operator, $mode = 0) public static function check($layer, $action, $operator, $mode = 0)
{ {
// Check if the permission layer and the permission itself exists // Check if the permission layer and the permission itself exists
if (!array_key_exists($layer, self::$permissions) || !array_key_exists($action, self::$permissions[$layer])) { if (!array_key_exists($layer, self::$permissions) || !array_key_exists($action, self::$permissions[$layer])) {
return false; return false;
@ -108,7 +91,6 @@ class Permissions
// Get permission data of a rank from the database // Get permission data of a rank from the database
public static function getRankPermissions($ranks) public static function getRankPermissions($ranks)
{ {
// Container array // Container array
$getRanks = []; $getRanks = [];
$perms = []; $perms = [];
@ -129,20 +111,14 @@ class Permissions
if (empty($perms)) { if (empty($perms)) {
// Store the data of the current rank in $perms // Store the data of the current rank in $perms
$perms = [ $perms = [
'SITE' => $rank['permissions_site'], 'SITE' => $rank['permissions_site'],
'MANAGE' => $rank['permissions_manage'], 'MANAGE' => $rank['permissions_manage'],
'FORUM' => $rank['permissions_forums'],
]; ];
} else { } else {
// Perform a bitwise OR on the ranks // Perform a bitwise OR on the ranks
$perms = [ $perms = [
'SITE' => $perms['SITE'] | $rank['permissions_site'], 'SITE' => $perms['SITE'] | $rank['permissions_site'],
'MANAGE' => $perms['MANAGE'] | $rank['permissions_manage'], 'MANAGE' => $perms['MANAGE'] | $rank['permissions_manage'],
'FORUM' => $perms['FORUM'] | $rank['permissions_forums'],
]; ];
} }
} }
@ -154,7 +130,6 @@ class Permissions
// Get permission data for a user // Get permission data for a user
public static function getUserPermissions($uid) public static function getUserPermissions($uid)
{ {
// Get user data // Get user data
$user = new User($uid); $user = new User($uid);
@ -182,11 +157,6 @@ class Permissions
$rankPerms['MANAGE'] = $userPerms['permissions_manage']; $rankPerms['MANAGE'] = $userPerms['permissions_manage'];
} }
// Override forum permissions
if (!$inheritance[2]) {
$rankPerms['FORUM'] = $userPerms['permissions_forums'];
}
// Return permissions // Return permissions
return $rankPerms; return $rankPerms;
} }

View file

@ -191,7 +191,20 @@ class User
// Get user's forum statistics // Get user's forum statistics
public function forumStats() public function forumStats()
{ {
return Forum\Forums::getUserStats($this->data['user_id']); return [
'posts' => Database::count(
'posts',
['poster_id' => [$this->id(), '=']]
)[0],
'topics' => count(Database::fetch(
'posts',
true,
['poster_id' => [$this->id(), '=']],
['post_time'],
null,
['topic_id']
)),
];
} }
// Get amount of time since user events using the same format as dates() // Get amount of time since user events using the same format as dates()

View file

@ -156,6 +156,22 @@ a:active {
top: 0; top: 0;
} }
/*
* Logo
*/
#banner {
height: 120px;
width: 1024px;
margin: 0 auto 5px;
box-shadow: 0 2px 6px rgba(0, 0, 0, .75);
}
#banner > a {
display: block;
width: 100%;
height: 100%;
}
/* /*
* Site footer * Site footer
*/ */

View file

@ -640,6 +640,25 @@ a.default:active {
text-align: center; text-align: center;
} }
.headerAnnouncement {
display: block;
margin: 10px auto;
text-align: center;
padding: 2px;
border: 1px solid #9475B2;
box-shadow: 0 0 3px #9475B2;
border-radius: 3px;
max-width: 1024px;
height: 120px;
background: #D3BFFF no-repeat scroll center center;
}
.headerAnnouncement > a {
display: block;
width: 100%;
height: 100%;
}
/* /*
* Site footer styling * Site footer styling
*/ */

View file

@ -20,13 +20,13 @@ $topicId = isset($_GET['t']) ?
$_GET['t'] : $_GET['t'] :
( (
isset($_GET['p']) ? isset($_GET['p']) ?
Forum\Forums::getTopicIdFromPostId($_GET['p']) : (new Forum\Post($_GET['p']))->thread :
0 0
); );
$forumId = isset($_GET['f']) ? $forumId = isset($_GET['f']) ?
$_GET['f'] : $_GET['f'] :
Forum\Forums::getForumIdFromTopicId($topicId); ($thread = new Forum\Thread($topicId))->forum;
$mode = isset($_GET['f']) ? 'f' : (isset($_GET['t']) ? 't' : (isset($_GET['p']) ? 'p' : null)); $mode = isset($_GET['f']) ? 'f' : (isset($_GET['t']) ? 't' : (isset($_GET['p']) ? 'p' : null));
@ -38,10 +38,10 @@ $posting = [
// Check if we're in reply mode // Check if we're in reply mode
if ($mode != 'f') { if ($mode != 'f') {
// Attempt to get the topic // Attempt to get the topic
$thread = Forum\Forums::getTopic($topicId, true); $thread = $thread ? $thread : new Forum\Thread($topicId);
// Prompt an error if the topic doesn't exist // Prompt an error if the topic doesn't exist
if (!$thread) { if (!$thread->id) {
// Add page specific things // Add page specific things
$renderData['page'] = [ $renderData['page'] = [
'redirect' => (isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : $urls->format('FORUM_INDEX')), 'redirect' => (isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : $urls->format('FORUM_INDEX')),
@ -57,17 +57,17 @@ if ($mode != 'f') {
} }
// Check if we're in quote mode // Check if we're in quote mode
if ($mode == 'p' && isset($_GET['quote']) && $_GET['quote'] == $_GET['p'] && array_key_exists($_GET['p'], $thread['posts'])) { if ($mode == 'p' && isset($_GET['quote']) && $_GET['quote'] == $_GET['p'] && array_key_exists($_GET['p'], $thread->posts())) {
// Reassign post for ease // Reassign post for ease
$post = $thread['posts'][$_GET['p']]; $post = $thread->posts()[$_GET['p']];
// Add subject to render data // Add subject to render data
$posting['text'] = '[quote=' . (new User($post['poster_id']))->username() . ']' . BBcode::toEditor($post['post_text']) . '[/quote]'; $posting['text'] = '[quote=' . $post->poster->username() . ']' . BBcode::toEditor($post->text) . '[/quote]';
// Post editing // Post editing
} elseif ($mode == 'p' && isset($_GET['edit']) && $_GET['edit'] == $_GET['p'] && array_key_exists($_GET['p'], $thread['posts'])) { } elseif ($mode == 'p' && isset($_GET['edit']) && $_GET['edit'] == $_GET['p'] && array_key_exists($_GET['p'], $thread->posts())) {
// Checks // Checks
if ($thread['posts'][$_GET['p']]['poster_id'] != $currentUser->id()) { if ($thread->posts()[$_GET['p']]->poster->id() != $currentUser->id()) {
// Add page specific things // Add page specific things
$renderData['page'] = [ $renderData['page'] = [
'redirect' => (isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : $urls->format('FORUM_INDEX')), 'redirect' => (isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : $urls->format('FORUM_INDEX')),
@ -83,18 +83,18 @@ if ($mode != 'f') {
} }
// Reassign post for ease // Reassign post for ease
$post = $thread['posts'][$_GET['p']]; $post = $thread->posts()[$_GET['p']];
// Set variables // Set variables
$posting = array_merge($posting, [ $posting = array_merge($posting, [
'subject' => $post['post_subject'], 'subject' => $post->subject,
'text' => BBcode::toEditor($post['post_text']), 'text' => BBcode::toEditor($post->text),
'id' => $post['post_id'], 'id' => $post->id,
]); ]);
// Post deletion // Post deletion
} elseif ($mode == 'p' && isset($_GET['delete']) && $_GET['delete'] == $_GET['p'] && array_key_exists($_GET['p'], $thread['posts'])) { } elseif ($mode == 'p' && isset($_GET['delete']) && $_GET['delete'] == $_GET['p'] && array_key_exists($_GET['p'], $thread->posts())) {
// Checks // Checks
if ($thread['posts'][$_GET['p']]['poster_id'] != $currentUser->id()) { if ($thread->posts()[$_GET['p']]->poster->id() != $currentUser->id()) {
// Add page specific things // Add page specific things
$renderData['page'] = [ $renderData['page'] = [
'redirect' => (isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : $urls->format('FORUM_INDEX')), 'redirect' => (isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : $urls->format('FORUM_INDEX')),
@ -119,18 +119,18 @@ if ($mode != 'f') {
]); ]);
// Reload the topic // Reload the topic
$thread = Forum\Forums::getTopic($topicId, true); $thread = new Forum\Thread($topicId);
// If there's no more posts left in the topic delete it as well // If there's no more posts left in the topic delete it as well
if (!count($thread['posts'])) { if (!$thread->replyCount()) {
Database::delete('topics', [ Database::delete('topics', [
'topic_id' => [$thread['topic']['topic_id'], '='], 'topic_id' => [$thread->id, '='],
]); ]);
} }
// Add page specific things // Add page specific things
$renderData['page'] = [ $renderData['page'] = [
'redirect' => (count($thread['posts']) ? $urls->format('FORUM_THREAD', [$thread['topic']['topic_id']]) : $urls->format('FORUM_INDEX')), 'redirect' => ($thread->replyCount() ? $urls->format('FORUM_THREAD', [$thread->id]) : $urls->format('FORUM_INDEX')),
'message' => 'Your post has been deleted!', 'message' => 'Your post has been deleted!',
]; ];
@ -149,9 +149,9 @@ if ($mode != 'f') {
// Form mode // Form mode
$renderData = array_merge($renderData, [ $renderData = array_merge($renderData, [
'message' => 'Are you sure you want to delete your reply to ' . $thread['topic']['topic_title'] . '?', 'message' => 'Are you sure you want to delete your reply to ' . $thread->title . '?',
'conditions' => [ 'conditions' => [
'post_id' => $thread['posts'][$_GET['p']]['post_id'], 'post_id' => $thread->posts()[$_GET['p']]->id,
], ],
]); ]);
@ -165,20 +165,20 @@ if ($mode != 'f') {
// Add subject to render data // Add subject to render data
if (!isset($posting['subject'])) { if (!isset($posting['subject'])) {
$posting['subject'] = 'Re: ' . $thread['topic']['topic_title']; $posting['subject'] = 'Re: ' . $thread->title;
} }
} }
// Check if a post is being made // Check if a post is being made
if (isset($_POST['post'])) { if (isset($_POST['post'])) {
// Attempt to make the post // Attempt to make the post
$makePost = Forum\Forums::createPost($currentUser->id(), $_POST['subject'], $_POST['text'], $forumId, $topicId, 1, 1, 1); $post = Forum\Post::create($_POST['subject'], $_POST['text'], $currentUser, $topicId, $forumId);
// Add page specific things // Add page specific things
$renderData['page'] = [ $renderData['page'] = [
'redirect' => $urls->format('FORUM_THREAD', [$makePost[3]]), 'redirect' => $urls->format('FORUM_POST', [$post->id]) . '#p' . $post->id,
'message' => 'Made the post!', 'message' => 'Made the post!',
'success' => $makePost[0], 'success' => 1,
]; ];
// Print page contents or if the AJAX request is set only display the render data // Print page contents or if the AJAX request is set only display the render data

View file

@ -18,7 +18,7 @@ $template->setTemplate($templateName);
// Switch between modes (we only allow this to be used by logged in user) // Switch between modes (we only allow this to be used by logged in user)
if (isset($_REQUEST['mode']) if (isset($_REQUEST['mode'])
&& Users::checkLogin() && Users::checkLogin()
&& Permissions::check('SITE', 'OBTAIN_PREMIUM', $currentUser->id(), 1)) { && $currentUser->checkPermission('SITE', 'OBTAIN_PREMIUM')) {
// Initialise Payments class // Initialise Payments class
if (!Payments::init()) { if (!Payments::init()) {
header('Location: ' . $urls->format('SITE_PREMIUM') . '?fail=true'); header('Location: ' . $urls->format('SITE_PREMIUM') . '?fail=true');

View file

@ -12,7 +12,7 @@ require_once str_replace(basename(__DIR__), '', dirname(__FILE__)) . 'sakura.php
// Attempt to get the thread // Attempt to get the thread
$thread = new Forum\Thread( $thread = new Forum\Thread(
isset($_GET['p']) isset($_GET['p'])
? Forum\Forums::getTopicIdFromPostId($_GET['p']) ? (new Forum\Post($_GET['p']))->thread
: (isset($_GET['t']) ? $_GET['t'] : 0) : (isset($_GET['t']) ? $_GET['t'] : 0)
); );

View file

@ -8,7 +8,7 @@
namespace Sakura; namespace Sakura;
// Define Sakura version // Define Sakura version
define('SAKURA_VERSION', '20151210'); define('SAKURA_VERSION', '20151211');
define('SAKURA_VLABEL', 'Eminence'); define('SAKURA_VLABEL', 'Eminence');
define('SAKURA_COLOUR', '#6C3082'); define('SAKURA_COLOUR', '#6C3082');
@ -54,7 +54,7 @@ require_once ROOT . 'libraries/User.php';
require_once ROOT . 'libraries/Users.php'; require_once ROOT . 'libraries/Users.php';
require_once ROOT . 'libraries/Whois.php'; require_once ROOT . 'libraries/Whois.php';
require_once ROOT . 'libraries/Forum/Forum.php'; require_once ROOT . 'libraries/Forum/Forum.php';
require_once ROOT . 'libraries/Forum/Forums.php'; require_once ROOT . 'libraries/Forum/Permissions.php';
require_once ROOT . 'libraries/Forum/Post.php'; require_once ROOT . 'libraries/Forum/Post.php';
require_once ROOT . 'libraries/Forum/Thread.php'; require_once ROOT . 'libraries/Forum/Thread.php';
@ -154,6 +154,8 @@ if (!defined('SAKURA_NO_TPL')) {
'currentPage' => '//' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'], 'currentPage' => '//' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'],
'referrer' => (isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : null), 'referrer' => (isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : null),
'onlineTimeout' => Config::get('max_online_time'), 'onlineTimeout' => Config::get('max_online_time'),
'announcementImage' => Config::get('header_announcement_image'),
'announcementLink' => Config::get('header_announcement_link'),
'recaptchaPublic' => Config::get('recaptcha_public'), 'recaptchaPublic' => Config::get('recaptcha_public'),
'recaptchaEnabled' => Config::get('recaptcha'), 'recaptchaEnabled' => Config::get('recaptcha'),

View file

@ -82,7 +82,7 @@
{% endif %} {% endif %}
<div id="navigation"> <div id="navigation">
<ul class="site-menu"> <ul class="site-menu">
<li title="Home" class="logo"><a href="{{ urls.format('SITE_HOME') }}" {% if sakura.siteLogo %} style="background-image: url('{{ sakura.siteLogo }}');"{% endif %}></a></li> <li title="Home" class="logo"><a href="{{ urls.format('SITE_HOME') }}"></a></li>
<li title="News"><a href="{{ urls.format('SITE_NEWS') }}" class="fa fa-newspaper-o"></a></li> <li title="News"><a href="{{ urls.format('SITE_NEWS') }}" class="fa fa-newspaper-o"></a></li>
<li title="Chat"><a href="//chat.{{ sakura.urlMain }}/" class="fa fa-commenting"></a></li> <li title="Chat"><a href="//chat.{{ sakura.urlMain }}/" class="fa fa-commenting"></a></li>
<li title="Forums"><a href="{{ urls.format('FORUM_INDEX') }}" class="fa fa-comments"></a></li> <li title="Forums"><a href="{{ urls.format('FORUM_INDEX') }}" class="fa fa-comments"></a></li>
@ -115,7 +115,13 @@
<li><a href="{% if session.checkLogin %}{{ urls.format('USER_PROFILE', [user.id]) }}{% else %}{{ urls.format('SITE_LOGIN') }}{% endif %}"><img src="{{ sakura.contentPath }}/pixel.png" alt="{{ user.username }}" style="background-image: url('{{ urls.format('IMAGE_AVATAR', [user.id]) }}');" class="nav-avatar" /></a></li> <li><a href="{% if session.checkLogin %}{{ urls.format('USER_PROFILE', [user.id]) }}{% else %}{{ urls.format('SITE_LOGIN') }}{% endif %}"><img src="{{ sakura.contentPath }}/pixel.png" alt="{{ user.username }}" style="background-image: url('{{ urls.format('IMAGE_AVATAR', [user.id]) }}');" class="nav-avatar" /></a></li>
</ul> </ul>
</div> </div>
{#<div id="banner" style="height: 120px; width: 1024px; background: url('http://i.flash.moe/headtest.png'); margin: 0 auto 5px; box-shadow: 0 2px 6px rgba(0, 0, 0, .75);"></div>#}
{% if sakura.siteLogo or sakura.announcementImage %}
<div id="banner" style="background: url('{% if sakura.announcementImage %}{{ sakura.announcementImage }}{% else %}{{ sakura.siteLogo }}{% endif %}');">
<a href="{% if sakura.announcementImage and sakura.announcementLink %}{{ sakura.announcementLink }}{% else %}{{ urls.format('SITE_HOME') }}{% endif %}"></a>
</div>
{% endif %}
<div id="content"> <div id="content">
{% block content %} {% block content %}
<div class="platform"> <div class="platform">
@ -128,7 +134,7 @@
<div class="inner"> <div class="inner">
<div class="ft-logo"></div> <div class="ft-logo"></div>
<div class="ft-text"> <div class="ft-text">
<div>Powered by <a href="https://github.com/flashwave/sakura/" target="_blank">Sakura</a>, <a href="http://flash.moe/" target="_blank">Flashwave</a> 2013-2015</div> <div>Powered by <a href="https://github.com/flashwave/sakura/" target="_blank">Sakura</a>, <a href="https://flash.moe/" target="_blank">Flashwave</a> 2013-2015</div>
<div><a href="{{ urls.format('INFO_PAGE', ['terms']) }}">Terms of Service</a> | <a href="{{ urls.format('INFO_PAGE', ['contact']) }}">Contact</a> | <a href="{{ urls.format('SITE_FAQ') }}">FAQ</a> | <a href="{{ urls.format('INFO_PAGE', ['rules']) }}">Rules</a> | <a href="https://sakura.flash.moe/">Changelog</a> | <a href="https://fiistat.us/">Status</a></div> <div><a href="{{ urls.format('INFO_PAGE', ['terms']) }}">Terms of Service</a> | <a href="{{ urls.format('INFO_PAGE', ['contact']) }}">Contact</a> | <a href="{{ urls.format('SITE_FAQ') }}">FAQ</a> | <a href="{{ urls.format('INFO_PAGE', ['rules']) }}">Rules</a> | <a href="https://sakura.flash.moe/">Changelog</a> | <a href="https://fiistat.us/">Status</a></div>
</div> </div>
</div> </div>

View file

@ -222,6 +222,14 @@
</div> </div>
</noscript> </noscript>
{% if sakura.announcementImage %}
<div class="headerAnnouncement" style="background-image: url('{{ sakura.announcementImage }}');">
{% if sakura.announcementLink %}
<a href="{{ sakura.announcementLink }}" class="clean"></a>
{% endif %}
</div>
{% endif %}
{% block content %} {% block content %}
<h1 class="stylised" style="text-align: center; margin: 2em auto;">{{ php.self }} is now printing!</h1> <h1 class="stylised" style="text-align: center; margin: 2em auto;">{{ php.self }} is now printing!</h1>
{% endblock %} {% endblock %}
@ -268,11 +276,12 @@
// Column colours for actions // Column colours for actions
var changelogColours = [ var changelogColours = [
'inherit', // Unknown 'inherit', // Unknown
'#2A2', // Added '#2A2', // Add
'#2AA', // Updated '#2AA', // Update
'#2AA', // Fixed '#2AA', // Fix
'#A22', // Removed '#A22', // Remove
'#62C' // Exported '#62C', // Export
'#C44' // Revert
]; ];
window.addEventListener("load", function() { window.addEventListener("load", function() {