the forum actually works somehow

This commit is contained in:
flash 2016-07-31 03:32:37 +02:00
parent e34ee69ba4
commit b555608f11
49 changed files with 629 additions and 414 deletions

View file

@ -177,8 +177,8 @@ class AuthController extends Controller
$redirect = $user->lastOnline
? (isset($_REQUEST['redirect'])
? $_REQUEST['redirect']
: Router::route('main.index'))
: Router::route('main.infopage', 'welcome');
: route('main.index'))
: route('info.welcome');
$message = 'Welcome' . ($user->lastOnline ? ' back' : '') . '!';

View file

@ -0,0 +1,27 @@
<?php
/**
* Hold the controller for chat related pages.
*
* @package Sakura
*/
namespace Sakura\Controllers;
/**
* Chat related controller.
*
* @package Sakura
* @author Julian van de Groep <me@flash.moe>
*/
class ChatController extends Controller
{
public function redirect()
{
return;
}
public function settings()
{
return;
}
}

View file

@ -34,13 +34,9 @@ class Controller
}
}
public function json($object)
public function json($object, $operators = JSON_FORCE_OBJECT | JSON_NUMERIC_CHECK | JSON_BIGINT_AS_STRING)
{
header('Content-Type: application/json; charset=utf-8');
return json_encode(
$object,
JSON_FORCE_OBJECT | JSON_NUMERIC_CHECK | JSON_BIGINT_AS_STRING
);
return json_encode($object, $operators);
}
}

View file

@ -0,0 +1,20 @@
<?php
/**
* Holds the base controller for forums.
*
* @package Sakura
*/
namespace Sakura\Controllers\Forum;
use Sakura\Controllers\Controller as BaseController;
/**
* Base forum controller (which other controllers should extend on).
*
* @package Sakura
* @author Julian van de Groep <me@flash.moe>
*/
class Controller extends BaseController
{
}

View file

@ -0,0 +1,309 @@
<?php
/**
* Holds the controller for topic.
*
* @package Sakura
*/
namespace Sakura\Controllers\Forum;
use Sakura\ActiveUser;
use Sakura\Forum\Forum;
use Sakura\Forum\Topic;
use Sakura\Perms\Forum as ForumPerms;
use Sakura\Template;
/**
* Topic controller.
*
* @package Sakura
* @author Julian van de Groep <me@flash.moe>
*/
class TopicController extends Controller
{
public function view($id = 0)
{
// Attempt to get the topic
$topic = new Topic($id);
// And attempt to get the forum
$forum = new Forum($topic->forum);
// Check if the forum exists
if ($topic->id === 0 || !$forum->permission(ForumPerms::VIEW, ActiveUser::$user->id)) {
// Set render data
Template::vars([
'message' => "This topic doesn't exist or you don't have access to it!",
'redirect' => route('forums.index'),
]);
// Print page contents
return Template::render('global/information');
}
// Update the tracking status
$topic->trackUpdate(ActiveUser::$user->id);
// Update views
$topic->viewsUpdate();
// Set parse variables
Template::vars(compact('forum', 'topic'));
// Print page contents
return Template::render('forum/topic');
}
private function modBase($id)
{
$topic = new Topic($id);
$forum = new Forum($topic->forum);
if ($topic->id !== 0 || $forum->permission(ForumPerms::VIEW, ActiveUser::$user->id) || session_check()) {
return compact('topic', 'forum');
}
return false;
}
public function sticky($id)
{
$modBase = $this->modBase($id);
$redirect = route('forums.index');
$message = "This forum doesn't exist or you don't have access to it.";
if ($modBase !== false) {
extract($modBase);
$redirect = route('forums.topic', $topic->id);
if ($forum->permission(ForumPerms::STICKY, ActiveUser::$user->id)) {
$topic->type = $topic->type !== 1 ? 1 : 0;
$topic->update();
$message = $topic->type
? 'Changed the topic to sticky!' : 'Reverted the topic back to normal!';
} else {
$message = "You aren't allowed to sticky topics!";
}
}
return view('global/information', compact('message', 'redirect'));
}
public function announce($id)
{
$modBase = $this->modBase($id);
$redirect = route('forums.index');
$message = "This forum doesn't exist or you don't have access to it.";
if ($modBase !== false) {
extract($modBase);
$redirect = route('forums.topic', $topic->id);
if ($forum->permission(ForumPerms::ANNOUNCEMENT, ActiveUser::$user->id)) {
$topic->type = $topic->type !== 2 ? 2 : 0;
$topic->update();
$message = $topic->type
? 'Changed the topic to an announcement!' : 'Reverted the topic back to normal!';
} else {
$message = "You aren't allowed to announce topics!";
}
}
return view('global/information', compact('message', 'redirect'));
}
public function lock($id)
{
$modBase = $this->modBase($id);
$redirect = route('forums.index');
$message = "This forum doesn't exist or you don't have access to it.";
if ($modBase !== false) {
extract($modBase);
$redirect = route('forums.topic', $topic->id);
if ($forum->permission(ForumPerms::LOCK, ActiveUser::$user->id)) {
$topic->status = $topic->status !== 1 ? 1 : 0;
$topic->update();
$message = ($topic->status ? 'Locked' : 'Unlocked') . ' the topic!';
} else {
$message = "You aren't allowed to lock topics!";
}
}
return view('global/information', compact('message', 'redirect'));
}
public function delete($id)
{
$modBase = $this->modBase($id);
$redirect = route('forums.index');
$message = "This forum doesn't exist or you don't have access to it.";
if ($modBase !== false) {
extract($modBase);
$trash = config('forum.trash');
// Check if we're operating from the trash
if ($topic->forum === $trash) {
if ($forum->permission(ForumPerms::DELETE_ANY, ActiveUser::$user->id)) {
$topic->delete();
$message = "Deleted the topic!";
$redirect = route('forums.forum', $trash);
} else {
$message = "You aren't allowed to delete topics!";
}
} else {
$redirect = route('forums.topic', $topic->id);
if ($forum->permission(ForumPerms::MOVE, ActiveUser::$user->id)) {
$topic->move($trash);
$message = "Moved the topic to the trash!";
} else {
$message = "You're not allowed to do this!";
}
}
}
return view('global/information', compact('message', 'redirect'));
}
public function restore($id)
{
$modBase = $this->modBase($id);
$redirect = route('forums.index');
$message = "This forum doesn't exist or you don't have access to it.";
if ($modBase !== false) {
extract($modBase);
$redirect = route('forums.topic', $topic->id);
if ($forum->permission(ForumPerms::MOVE, ActiveUser::$user->id)) {
if ($topic->oldForum) {
$topic->move($topic->oldForum, false);
$message = "Moved the topic back to it's old location!";
} else {
$message = "This topic has never been moved!";
}
} else {
$message = "You aren't allowed to move threads!";
}
}
return view('global/information', compact('message', 'redirect'));
}
public function move($id)
{
$modBase = $this->modBase($id);
$redirect = route('forums.index');
$message = "This forum doesn't exist or you don't have access to it.";
if ($modBase !== false) {
extract($modBase);
$redirect = route('forums.topic', $topic->id);
if ($forum->permission(ForumPerms::MOVE, ActiveUser::$user->id)) {
$dest_forum = new Forum($_REQUEST['forum_id'] ?? 0);
if ($dest_forum->id === 0
|| $dest_forum->permission(ForumPerms::VIEW, ActiveUser::$user->id)) {
$topic->move($dest_forum->id);
$message = "Moved to the topic to {$dest_forum->name}!";
} else {
$message = "The destination forum doesn't exist or you don't have access to it.";
}
} else {
$message = "You aren't allowed to move threads!";
}
}
return view('global/information', compact('message', 'redirect'));
}
public function reply($id = 0)
{
$text = $_POST['text'] ?? null;
// Attempt to get the forum
$topic = new Topic($id);
// And attempt to get the forum
$forum = new Forum($topic->forum);
// Check if the topic exists
if ($topic->id === 0
|| $forum->type !== 0
|| !$forum->permission(ForumPerms::VIEW, ActiveUser::$user->id)) {
$message = "This post doesn't exist or you don't have access to it!";
$redirect = route('forums.index');
Template::vars(compact('message', 'redirect'));
return Template::render('global/information');
}
// Check if the topic exists
if (!$forum->permission(ForumPerms::REPLY, ActiveUser::$user->id)
|| (
$topic->status === 1
&& !$forum->permission(ForumPerms::LOCK, ActiveUser::$user->id)
)) {
$message = "You are not allowed to post in this topic!";
$redirect = route('forums.topic', $topic->id);
Template::vars(compact('message', 'redirect'));
return Template::render('global/information');
}
// Length
$length = strlen($text);
$minLen = config('forum.min_post_length');
$maxLen = config('forum.max_post_length');
$tooShort = $length < $minLen;
$tooLong = $length > $maxLen;
// Check requirments
if ($tooShort
|| $tooLong) {
$route = Router::route('forums.topic', $topic->id);
$message = "Your post is " . (
$tooShort
? "too short, add some more text! Make it at least {$minLen}."
: "too long, you're gonna have to cut a little! Keep it under {$maxLen}."
);
$redirect = "{$route}#reply";
Template::vars(compact('message', 'redirect'));
if (!isset($_SESSION['replyText'])) {
$_SESSION['replyText'] = [];
}
$_SESSION['replyText']["t{$topic->id}"] = $text;
return Template::render('global/information');
}
unset($_SESSION['replyText']["t{$topic->id}"]);
// Create the post
$post = Post::create(
"Re: {$topic->title}",
$text,
ActiveUser::$user,
$topic->id,
$forum->id
);
// Go to the post
$postLink = route('forums.post', $post->id);
// Head to the post
return header("Location: {$postLink}");
}
}

View file

@ -255,182 +255,6 @@ class ForumController extends Controller
return Template::render('global/information');
}
/**
* View a topic.
*
* @return string
*/
public function topic($id = 0)
{
// Attempt to get the topic
$topic = new Topic($id);
// And attempt to get the forum
$forum = new Forum($topic->forum);
// Check if the forum exists
if ($topic->id == 0 || !$forum->permission(ForumPerms::VIEW, ActiveUser::$user->id)) {
// Set render data
Template::vars([
'page' => [
'message' => 'This topic doesn\'t exist or you don\'t have access to it!',
'redirect' => Router::route('forums.index'),
],
]);
// Print page contents
return Template::render('global/information');
}
// Update the tracking status
$topic->trackUpdate(ActiveUser::$user->id);
// Update views
$topic->viewsUpdate();
// Set parse variables
Template::vars(compact('forum', 'topic'));
// Print page contents
return Template::render('forum/topic');
}
/**
* Moderate a topic.
*
* @return string
*/
public function topicModerate($id = 0)
{
// Attempt to get the topic
$topic = new Topic($id);
// And attempt to get the forum
$forum = new Forum($topic->forum);
// Default stuff
$message = 'Unknown moderation action.';
$redirect = Router::route('forums.topic', $topic->id);
// Check if the forum exists
if ($topic->id == 0
|| !$forum->permission(ForumPerms::VIEW, ActiveUser::$user->id)
|| !isset($_POST['session'])
|| $_POST['session'] != session_id()) {
$message = 'This topic doesn\'t exist or you don\'t have access to it!';
$redirect = Router::route('forums.index');
} else {
// Take the action
$action = isset($_POST['action']) ? $_POST['action'] : null;
// Switch
switch ($action) {
case 'sticky':
// Check permission
if (!$forum->permission(ForumPerms::STICKY, ActiveUser::$user->id)) {
$message = "You're not allowed to do this!";
break;
}
// Update the type
$topic->type = $topic->type !== 1 ? 1 : 0;
$topic->update();
// Add page variable stuff
$message = $topic->type
? 'Changed the topic to sticky!'
: 'Reverted the topic back to normal!';
break;
case 'announce':
// Check permission
if (!$forum->permission(ForumPerms::ANNOUNCEMENT, ActiveUser::$user->id)) {
$message = "You're not allowed to do this!";
break;
}
// Update the type
$topic->type = $topic->type !== 2 ? 2 : 0;
$topic->update();
// Add page variable stuff
$message = $topic->type
? 'Changed the topic to into an announcement!'
: 'Reverted the topic back to normal!';
break;
case 'lock':
// Check permission
if (!$forum->permission(ForumPerms::LOCK, ActiveUser::$user->id)) {
$message = "You're not allowed to do this!";
break;
}
// Update the status
$topic->status = $topic->status !== 1 ? 1 : 0;
$topic->update();
// Add page variable stuff
$message = ($topic->status ? 'Locked' : 'Unlocked') . ' the topic!';
break;
case 'delete':
// Get the id of the trash forum
$trash = config('forum.trash');
// Check if we're operating from the trash
if ($topic->forum == $trash) {
// Check permission
if (!$forum->permission(ForumPerms::DELETE_ANY, ActiveUser::$user->id)) {
$message = "You're not allowed to do this!";
break;
}
// Delete the topic
$topic->delete();
// Set message
$message = "Deleted the topic!";
$redirect = Router::route('forums.forum', $trash);
} else {
// Check permission
if (!$forum->permission(ForumPerms::MOVE, ActiveUser::$user->id)) {
$message = "You're not allowed to do this!";
break;
}
// Move the topic
$topic->move($trash);
// Trashed!
$message = "Moved the topic to the trash!";
}
break;
case 'restore':
// Check if this topic has record of being in a previous forum
if ($topic->oldForum) {
// Move the topic back
$topic->move($topic->oldForum, false);
$message = "Moved the topic back to it's old location!";
} else {
$message = "This topic has never been moved!";
}
break;
}
}
// Set the variables
Template::vars(compact('message', 'redirect'));
// Print page contents
return Template::render('global/information');
}
/**
* Redirect to the position of a post in a topic.
*
@ -505,95 +329,6 @@ class ForumController extends Controller
return $post->text;
}
/**
* Reply to a topic.
*
* @return string
*/
public function topicReply($id = 0)
{
$text = isset($_POST['text']) ? $_POST['text'] : null;
// Attempt to get the forum
$topic = new Topic($id);
// And attempt to get the forum
$forum = new Forum($topic->forum);
// Check if the topic exists
if ($topic->id == 0
|| $forum->type !== 0
|| !$forum->permission(ForumPerms::VIEW, ActiveUser::$user->id)) {
$message = "This post doesn't exist or you don't have access to it!";
$redirect = Router::route('forums.index');
Template::vars(compact('message', 'redirect'));
return Template::render('global/information');
}
// Check if the topic exists
if (!$forum->permission(ForumPerms::REPLY, ActiveUser::$user->id)
|| (
$topic->status === 1
&& !$forum->permission(ForumPerms::LOCK, ActiveUser::$user->id)
)) {
$message = "You are not allowed to post in this topic!";
$redirect = Router::route('forums.topic', $topic->id);
Template::vars(compact('message', 'redirect'));
return Template::render('global/information');
}
// Length
$length = strlen($text);
$minLen = config('forum.min_post_length');
$maxLen = config('forum.max_post_length');
$tooShort = $length < $minLen;
$tooLong = $length > $maxLen;
// Check requirments
if ($tooShort
|| $tooLong) {
$route = Router::route('forums.topic', $topic->id);
$message = "Your post is " . (
$tooShort
? "too short, add some more text!"
: "too long, you're gonna have to cut a little!"
);
$redirect = "{$route}#reply";
Template::vars(compact('message', 'redirect'));
if (!isset($_SESSION['replyText'])) {
$_SESSION['replyText'] = [];
}
$_SESSION['replyText']["t{$topic->id}"] = $text;
return Template::render('global/information');
}
unset($_SESSION['replyText']["t{$topic->id}"]);
// Create the post
$post = Post::create(
"Re: {$topic->title}",
$text,
ActiveUser::$user,
$topic->id,
$forum->id
);
// Go to the post
$postLink = Router::route('forums.post', $post->id);
// Head to the post
return header("Location: {$postLink}");
}
/**
* Create a topic.
*

View file

@ -0,0 +1,44 @@
<?php
/**
* Hold the controller for informational pages.
*
* @package Sakura
*/
namespace Sakura\Controllers;
/**
* Informational controller.
*
* @package Sakura
* @author Julian van de Groep <me@flash.moe>
*/
class InfoController extends Controller
{
public function terms()
{
return view('info/terms');
}
public function privacy()
{
return view('info/privacy');
}
public function contact()
{
$contact = config('contact');
return view('info/contact', compact('contact'));
}
public function rules()
{
return view('info/rules');
}
public function welcome()
{
return view('info/welcome');
}
}

View file

@ -108,47 +108,6 @@ class MetaController extends Controller
return Template::render('meta/faq');
}
/**
* Handles the info pages.
* Deprecate this!!
*
* @param string $id The page ID from the database.
*
* @return mixed HTML for the info page.
*/
public function infoPage($id = null)
{
// Set default variables
Template::vars([
'page' => [
'content' => '<h1>Unable to load the requested info page.</h1><p>Check the URL and try again.</p>',
],
]);
// Set page id
$id = strtolower($id);
// Get the page from the database
$ipData = DB::table('infopages')
->where('page_shorthand', $id)
->get();
// Get info page data from the database
if ($ipData) {
// Assign new proper variable
Template::vars([
'page' => [
'id' => $id,
'title' => $ipData[0]->page_title,
'content' => $ipData[0]->page_content,
],
]);
}
// Return the compiled page
return Template::render('meta/infopage');
}
/**
* Search page
*

View file

@ -113,7 +113,7 @@ class Forum
*
* @param int $forumId The ID of the forum that should be constructed.
*/
public function __construct($forumId = 0)
public function __construct(int $forumId = 0)
{
// Get the row from the database
$forumRow = DB::table('forums')
@ -126,15 +126,15 @@ class Forum
// Populate the variables
if ($forumRow) {
$forumRow = $forumRow[0];
$this->id = $forumRow->forum_id;
$this->order = $forumRow->forum_order;
$this->id = intval($forumRow->forum_id);
$this->order = intval($forumRow->forum_order);
$this->name = $forumRow->forum_name;
$this->description = $forumRow->forum_desc;
$this->link = $forumRow->forum_link;
$this->category = $forumRow->forum_category;
$this->type = $forumRow->forum_type;
$this->category = intval($forumRow->forum_category);
$this->type = intval($forumRow->forum_type);
$this->icon = $forumRow->forum_icon;
} elseif ($forumId != 0) {
} elseif ($forumId !== 0) {
$this->id = -1;
}
}

View file

@ -120,14 +120,14 @@ class Post
// Assign data if a row was returned
if ($postRow) {
$postRow = $postRow[0];
$this->id = $postRow->post_id;
$this->topic = $postRow->topic_id;
$this->forum = $postRow->forum_id;
$this->id = intval($postRow->post_id);
$this->topic = intval($postRow->topic_id);
$this->forum = intval($postRow->forum_id);
$this->poster = User::construct($postRow->poster_id);
$this->time = $postRow->post_time;
$this->time = intval($postRow->post_time);
$this->subject = $postRow->post_subject;
$this->text = $postRow->post_text;
$this->editTime = $postRow->post_edit_time;
$this->editTime = intval($postRow->post_edit_time);
$this->editReason = $postRow->post_edit_reason;
$this->editUser = User::construct($postRow->post_edit_user);

View file

@ -135,17 +135,17 @@ class Topic
// Assign data if a row was returned
if ($topicRow) {
$topicRow = $topicRow[0];
$this->id = $topicRow->topic_id;
$this->forum = $topicRow->forum_id;
$this->hidden = (bool) $topicRow->topic_hidden;
$this->id = intval($topicRow->topic_id);
$this->forum = intval($topicRow->forum_id);
$this->hidden = boolval($topicRow->topic_hidden);
$this->title = $topicRow->topic_title;
$this->time = $topicRow->topic_time;
$this->timeLimit = $topicRow->topic_time_limit;
$this->views = $topicRow->topic_views;
$this->status = $topicRow->topic_status;
$this->statusChange = $topicRow->topic_status_change;
$this->type = $topicRow->topic_type;
$this->oldForum = $topicRow->topic_old_forum;
$this->time = intval($topicRow->topic_time);
$this->timeLimit = intval($topicRow->topic_time_limit);
$this->views = intval($topicRow->topic_views);
$this->status = intval($topicRow->topic_status);
$this->statusChange = intval($topicRow->topic_status_change);
$this->type = intval($topicRow->topic_type);
$this->oldForum = intval($topicRow->topic_old_forum);
}
}

View file

@ -190,3 +190,11 @@ trash = 4
[comments]
min_length = 500
min_length = 1
; Content for the contact page, the variables function like a normal associative array
[contact]
mail['Administrator'] = sakura@localghost
twit['smugwave'] = Sakura's main developer
repo['Sakura'] = https://github.com/flashwave/sakura

View file

@ -268,7 +268,9 @@ class BaseTables extends Migration
->unsigned()
->default(0);
$table->string('post_edit_reason', 255);
$table->string('post_edit_reason', 255)
->nullable()
->default(null);
$table->integer('post_edit_user')
->unsigned()
@ -559,6 +561,7 @@ class BaseTables extends Migration
$schema->drop('comment_votes');
$schema->drop('comments');
$schema->drop('emoticons');
$schema->drop('error_log');
$schema->drop('faq');
$schema->drop('forum_permissions');
$schema->drop('forums');

View file

@ -4,7 +4,7 @@
*/
/* Import bbcode specific style */
@import('bbcode');
@import "bbcode";
/*
* Animation Keyframes
@ -1915,7 +1915,8 @@ a.default:active {
input[type="submit"].inputStyling,
input[type="button"].inputStyling,
input[type="reset"].inputStyling,
button.inputStyling {
button.inputStyling,
a.button {
padding: 3px 10px;
cursor: pointer;
border: 0;
@ -1933,7 +1934,8 @@ button.inputStyling {
input[type="submit"].inputStyling.small,
input[type="button"].inputStyling.small,
input[type="reset"].inputStyling.small,
button.inputStyling.small {
button.inputStyling.small,
a.button.small {
padding: 0 4px 1px;
margin: -2px 0 0;
font-size: 16px;
@ -1944,7 +1946,8 @@ button.inputStyling.small {
input[type="submit"].inputStyling:hover,
input[type="button"].inputStyling:hover,
input[type="reset"].inputStyling:hover,
button.inputStyling:hover {
button.inputStyling:hover,
a.button:hover {
box-shadow: inset #222 0 0 3px;
text-shadow: #F1F1F1 0 0 5px;
}
@ -1952,7 +1955,8 @@ button.inputStyling:hover {
input[type="submit"].inputStyling:active,
input[type="button"].inputStyling:active,
input[type="reset"].inputStyling:active,
button.inputStyling:active {
button.inputStyling:active,
a.button:active {
box-shadow: inset #222 0 0 5px;
text-shadow: #F1F1F1 0 0 3px;
transition: text-shadow .2s, box-shadow .2s;
@ -1961,7 +1965,8 @@ button.inputStyling:active {
input[type="submit"][disabled=disabled].inputStyling,
input[type="button"][disabled=disabled].inputStyling,
input[type="reset"][disabled=disabled].inputStyling,
button[disabled=disabled].inputStyling {
button[disabled=disabled].inputStyling,
a.button[disabled=disabled] {
background: linear-gradient(180deg, #858585 0%, #858585 50%, #787878 50%) #858585 !important;
box-shadow: inset #222 0 0 1px !important;
text-shadow: #888 0 0 2px !important;

View file

@ -1,6 +1,6 @@
{% extends 'global/master.twig' %}
{% block title %}Login{% endblock %}
{% set title = 'Login' %}
{% block content %}
<div class="loginPage">

View file

@ -1,6 +1,6 @@
{% extends 'global/master.twig' %}
{% block title %}Reactivate account{% endblock %}
{% set title = 'Reactivate account' %}
{% block content %}
<div class="loginPage">

View file

@ -1,6 +1,6 @@
{% extends 'global/master.twig' %}
{% block title %}Register{% endblock %}
{% set title = 'Register' %}
{% block content %}
{% if config('user.disable_registration') %}
@ -40,7 +40,7 @@
<input class="inputStyling" type="password" id="registerPassword" name="password" onkeyup="registerVarCheck(this.id, 'password');" placeholder="Using special characters is recommended">
</div>
<div class="subLinks centreAlign">
<input class="inputStyling" name="tos" type="checkbox" id="registerToS"><label for="registerToS">I agree to the <a class="default" href="{{ route('main.infopage', 'terms') }}" target="_blank">Terms of Service</a>.
<input class="inputStyling" name="tos" type="checkbox" id="registerToS"><label for="registerToS">I agree to the <a class="default" href="{{ route('info.terms') }}" target="_blank">Terms of Service</a>.
</div>
<div class="centreAlign">
<input class="inputStyling" type="submit" name="submit" value="Register" id="registerAccBtn">

View file

@ -1,6 +1,6 @@
{% extends 'global/master.twig' %}
{% block title %}Reset Password{% endblock %}
{% set title = 'Reset Password' %}
{% block content %}
<div class="loginPage">
@ -39,7 +39,7 @@
<button class="inputStyling">Request Change</button>
</div>
<div class="subLinks centreAlign">
<a href="{{ route('main.infopage', 'contact') }}" class="default">Contact us</a> if you lost access to your e-mail address!
<a href="{{ route('info.contact') }}" class="default">Contact us</a> if you lost access to your e-mail address!
</div>
{% endif %}
</form>

View file

@ -24,7 +24,7 @@
<div>
{% if forum.lastPost.id %}
<a href="{{ route('forums.topic', forum.lastPost.topic) }}" class="default">{{ forum.lastPost.subject|slice(0, 30) }}{% if forum.lastPost.subject|length > 30 %}...{% endif %}</a><br>
<time datetime="{{ forum.lastPost.time|date('r') }}">{{ forum.lastPost.time|date(config('date_format')) }}</time> by {% if forum.lastPost.poster.id %}<a href="{{ route('user.profile', forum.lastPost.poster.id) }}" class="default" style="color: {{ forum.lastPost.poster.colour }}; text-shadow: 0 0 5px {% if forumlastPost.poster.colour != 'inherit' %}{{ forum.lastPost.poster.colour }}{% else %}#222{% endif %};">{{ forum.lastPost.poster.username }}</a>{% else %}[deleted user]{% endif %} <a href="{{ route('forums.post', forum.lastPost.id) }}" class="default fa fa-tag"></a>
<time datetime="{{ forum.lastPost.time|date('r') }}">{{ forum.lastPost.time|date('D Y-m-d H:i:s T') }}</time> by {% if forum.lastPost.poster.id %}<a href="{{ route('user.profile', forum.lastPost.poster.id) }}" class="default" style="color: {{ forum.lastPost.poster.colour }}; text-shadow: 0 0 5px {% if forumlastPost.poster.colour != 'inherit' %}{{ forum.lastPost.poster.colour }}{% else %}#222{% endif %};">{{ forum.lastPost.poster.username }}</a>{% else %}[deleted user]{% endif %} <a href="{{ route('forums.post', forum.lastPost.id) }}" class="default fa fa-tag"></a>
{% else %}
There are no posts in this forum.<br>&nbsp;
{% endif %}

View file

@ -1,18 +1,15 @@
<form method="post" action="{{ route('forums.topic.mod', topic.id) }}" style="display: inline-block;">
<input type="hidden" name="session" value="{{ session_id() }}">
{% if forumSticky is defined %}
<button class="forumbtn" title="{{ forumSticky ? 'Unsticky' : 'Sticky' }}" name="action" value="sticky"><span class="fa fa-{{ forumSticky ? 'remove' : 'thumb-tack' }}"></span></button>
{% endif %}
{% if forumAnnounce is defined %}
<button class="forumbtn" title="{{ forumAnnounce ? 'Unannounce' : 'Announce' }}" name="action" value="announce"><span class="fa fa-{{ forumAnnounce ? 'remove' : 'bullhorn' }}"></span></button>
{% endif %}
{% if forumLock is defined %}
<button class="forumbtn" title="{{ forumLock ? 'Unlock' : 'Lock' }}" name="action" value="lock"><span class="fa fa-{{ forumLock ? 'unlock' : 'lock' }}"></span></button>
{% endif %}
{% if forumRestore is defined %}
<button class="forumbtn" title="Restore" name="action" value="restore"><span class="fa fa-history"></span></button>
{% endif %}
{% if forumTrash is defined or forumPrune is defined %}
<button class="forumbtn" title="{{ forumPrune ? 'Prune' : 'Trash' }}" name="action" value="delete"><span class="fa fa-{{ forumPrune ? 'bomb' : 'trash' }}"></span></button>
{% endif %}
</form>
{% if forumSticky is defined %}
<a class="forumbtn" title="{{ forumSticky ? 'Unsticky' : 'Sticky' }}" href="{{ route('forums.topic.sticky', topic.id) }}?session={{ session_id() }}"><span class="fa fa-{{ forumSticky ? 'remove' : 'thumb-tack' }}"></span></a>
{% endif %}
{% if forumAnnounce is defined %}
<a class="forumbtn" title="{{ forumAnnounce ? 'Unannounce' : 'Announce' }}" href="{{ route('forums.topic.announce', topic.id) }}?session={{ session_id() }}"><span class="fa fa-{{ forumAnnounce ? 'remove' : 'bullhorn' }}"></span></a>
{% endif %}
{% if forumLock is defined %}
<a class="forumbtn" title="{{ forumLock ? 'Unlock' : 'Lock' }}" href="{{ route('forums.topic.lock', topic.id) }}?session={{ session_id() }}"><span class="fa fa-{{ forumLock ? 'unlock' : 'lock' }}"></span></a>
{% endif %}
{% if forumRestore is defined %}
<a class="forumbtn" title="Restore" href="{{ route('forums.topic.restore', topic.id) }}?session={{ session_id() }}"><span class="fa fa-history"></span></a>
{% endif %}
{% if forumTrash is defined or forumPrune is defined %}
<a class="forumbtn" title="{{ forumPrune ? 'Prune' : 'Trash' }}" href="{{ route('forums.topic.delete', topic.id) }}?session={{ session_id() }}"><span class="fa fa-{{ forumPrune ? 'bomb' : 'trash' }}"></span></a>
{% endif %}

View file

@ -37,10 +37,10 @@
</div>
<script type="text/javascript">
var titleMax = {{ config('forum_title_max') }},
titleMin = {{ config('forum_title_min') }},
textMax = {{ config('forum_text_max') }},
textMin = {{ config('forum_text_min') }},
var titleMax = {{ config('forum.max_title_length') }},
titleMin = {{ config('forum.min_title_length') }},
textMax = {{ config('forum.max_post_length') }},
textMin = {{ config('forum.min_post_length') }},
preview = document.getElementById('postingPreview'),
pTitle = document.getElementById('postingTitle'),
pTitleCont = document.getElementById('postingTitleContainer'),

View file

@ -6,8 +6,6 @@
{% set forumNewLink %}{{ route('forums.new', forum.id) }}{% endset %}
{% set forumMarkRead %}{{ route('forums.mark', forum.id) }}?s={{ session_id() }}{% endset %}
{% block title %}{{ title }}{% endblock %}
{% block content %}
<div class="content homepage forum viewforum">
<div class="content-column">

View file

@ -2,8 +2,6 @@
{% set title = 'Forums' %}
{% block title %}{{ title }}{% endblock %}
{% block content %}
<div class="content homepage forum">
<div class="content-right content-column">

View file

@ -2,7 +2,7 @@
{% set forumBackLink %}{{ route('forums.forum', forum.id) }}{% endset %}
{% block title %}{% if topic is defined %}{{ topic.title }}{% else %}Creating topic in {{ forum.name }}{% endif %}{% endblock %}
{% set title %}{% if topic is defined %}{{ topic.title }}{% else %}Creating topic in {{ forum.name }}{% endif %}{% endset %}
{% if topic is defined %}
{% if forum.permission(constant('Sakura\\Perms\\Forum::REPLY'), user.id)
@ -38,13 +38,13 @@
{% set forumRestore = true %}
{% endif %}
{% if topic.forum != config('forum_trash_id') %}
{% if topic.forum != config('forum.trash') %}
{% set forumTrash = true %}
{% endif %}
{% endif %}
{% if forum.permission(constant('Sakura\\Perms\\Forum::DELETE_ANY'), user.id) %}
{% if topic.forum == config('forum_trash_id') %}
{% if topic.forum == config('forum.trash') %}
{% set forumPrune = true %}
{% endif %}
{% endif %}

View file

@ -1,6 +1,6 @@
{% extends 'global/master.twig' %}
{% block title %}Confirmation{% endblock %}
{% set title = 'Confirmation' %}
{% block content %}
<div class="content standalone">

View file

@ -1,6 +1,6 @@
{% extends 'global/master.twig' %}
{% block title %}Information{% endblock %}
{% set title = 'Information' %}
{% block content %}
<div class="content standalone">

View file

@ -114,7 +114,7 @@
{% if user.permission(constant('Sakura\\Perms\\Site::RESTRICTED')) %}
<div class="headerNotify" style="background: repeating-linear-gradient(-45deg, #B33, #B33 10px, #B00 10px, #B00 20px); color: #FFF; border: 1px solid #C00; box-shadow: 0 0 3px #C00;">
<h1>Your account is currently in <span style="font-weight: 700 !important;">restricted mode</span>!</h1>
<div>A staff member has set your account to restricted mode most likely due to violation of the rules. While restricted you won't be able to use most public features of the site. If you think this is a mistake please <a href="{{ route('main.infopage', 'contact') }}" style="color: inherit;">get in touch with one of our staff members</a>.</div>
<div>A staff member has set your account to restricted mode most likely due to violation of the rules. While restricted you won't be able to use most public features of the site. If you think this is a mistake please <a href="{{ route('info.contact') }}" style="color: inherit;">get in touch with one of our staff members</a>.</div>
</div>
{% endif %}
@ -141,7 +141,7 @@
<li><a href="{{ route('main.index') }}">Home</a></li>
<li><a href="{{ route('news.category') }}">News</a></li>
<li><a href="{{ route('main.search') }}">Search</a></li>
<li><a href="{{ route('main.infopage', 'contact') }}">Contact</a></li>
<li><a href="{{ route('info.contact') }}">Contact</a></li>
<li><a href="https://sakura.flash.moe" target="_blank">Changelog</a></li>
<li><a href="{{ route('premium.index') }}">Support us</a></li>
</ul>
@ -156,9 +156,9 @@
<ul class="ftsection">
<li class="fthead">Information</li>
<li><a href="{{ route('main.faq') }}">FAQ</a></li>
<li><a href="{{ route('main.infopage', 'rules') }}">Rules</a></li>
<li><a href="{{ route('info.rules') }}">Rules</a></li>
<li><a href="//fiistat.us" target="_blank">Server Status</a></li>
<li><a href="{{ route('main.infopage', 'terms') }}">Terms of Service</a></li>
<li><a href="{{ route('info.terms') }}">Terms of Service</a></li>
</ul>
</div>
</div>

View file

@ -3,7 +3,7 @@
<head>
<meta charset="utf-8">
<title>Cannot find page</title>
<link rel="stylesheet" type="text/css" href="/css/error.css">
<link rel="stylesheet" type="text/css" href="/error.css">
</head>
<body>
<div id="wrap">

View file

@ -1,6 +1,6 @@
{% extends 'global/master.twig' %}
{% block title %}Restricted{% endblock %}
{% set title = 'Restricted' %}
{% block content %}
<div class="content standalone">

View file

@ -0,0 +1,26 @@
{% extends 'info/master.twig' %}
{% set title = 'Contact' %}
{% block info %}
<h1>Contact</h1>
<p>Need to contact us? Here's a few ways to do so! We try to respond as soon as possible.</p>
<h3>E-mail</h3>
<ul>
{% for user, email in contact.mail %}
<li>{{ user }} - <a href="mailto:{{ email }}">{{ email }}</a></li>
{% endfor %}
</ul>
<h3>Twitter</h3>
<ul>
{% for handle, comment in contact.twit %}
<li>@<a href="https://twitter.com/{{ handle }}">{{ handle }}</a> - {{ comment }}</li>
{% endfor %}
</ul>
<h3>Repositories</h3>
<ul>
{% for link, name in contact.repo %}
<li><a href="{{ link }}">{{ link }}</a> - {{ name }}</li>
{% endfor %}
</ul>
{% endblock %}

View file

@ -0,0 +1,9 @@
{% extends 'global/master.twig' %}
{% block content %}
<div class="content standalone bbcode">
<div>
{{ block('info') }}
</div>
</div>
{% endblock %}

View file

@ -0,0 +1,8 @@
{% extends 'info/master.twig' %}
{% set title = 'Privacy Policy' %}
{% block info %}
<h1>Privacy Policy</h1>
<p>test</p>
{% endblock %}

View file

@ -0,0 +1,7 @@
{% extends 'info/master.twig' %}
{% set title = 'Rules' %}
{% block info %}
<p><img src="http://i.imgur.com/C1MBw2u.png"></p>
{% endblock %}

View file

@ -0,0 +1,8 @@
{% extends 'info/master.twig' %}
{% set title = 'Terms of Service' %}
{% block info %}
<h1>Terms of Service</h1>
<p>test</p>
{% endblock %}

View file

@ -0,0 +1,9 @@
{% extends 'info/master.twig' %}
{% set title = 'Welcome!' %}
{% block info %}
<h1>Welcome to {{ config('general.name') }}!</h1>
<p>Hey, thank you for registering!</p>
<p>Be sure to familiarise your with the <a href="{{ route('info.rules') }}">rules</a> and to <a href="{{ route('forums.index') }}">introduce</a> yourself on the forum!</p>
{% endblock %}

View file

@ -1,6 +1,6 @@
{% extends 'global/master.twig' %}
{% block title %}You are banned!{% endblock %}
{% set title = 'You are banned!' %}
{% block content %}
<div class="content">

View file

@ -1,6 +1,6 @@
{% extends 'global/master.twig' %}
{% block title %}Frequently Asked Questions{% endblock %}
{% set title = 'Frequently Asked Questions' %}
{% block content %}
<div class="content settings">

View file

@ -1,11 +0,0 @@
{% extends 'global/master.twig' %}
{% block title %}{% if page.title %}{{ page.title }}{% else %}Not found!{% endif %}{% endblock %}
{% block content %}
<div class="content standalone bbcode">
<div>
{{ include(template_from_string(page.content|raw)) }}
</div>
</div>
{% endblock %}

View file

@ -1,6 +1,6 @@
{% extends 'global/master.twig' %}
{% block title %}Search{% endblock %}
{% set title = 'Search' %}
{% block content %}
<div class="content" style="background: #FFF;">

View file

@ -1,6 +1,6 @@
{% extends 'global/master.twig' %}
{% block title %}{{ page.category }} / {{ page.mode }}{% endblock %}
{% set title %}{{ page.category }} / {{ page.mode }}{% endset %}
{% block content %}
<div class="content settings messages">

View file

@ -1,6 +1,6 @@
{% extends 'global/master.twig' %}
{% block title %}News{% endblock %}
{% set title = 'News' %}
{% block css %}
<style type="text/css">

View file

@ -1,6 +1,6 @@
{% extends 'global/master.twig' %}
{% block title %}{{ post.title }}{% endblock %}
{% set title = post.title %}
{% set commentsCategory = 'news-' ~ post.category ~ '-' ~ post.id %}
{% set comments = post.comments %}

View file

@ -1,6 +1,6 @@
{% extends 'global/master.twig' %}
{% block title %}Purchase complete!{% endblock %}
{% set title = 'Purchase complete!' %}
{% block content %}
<div class="content standalone" style="text-align: center;">

View file

@ -1,6 +1,6 @@
{% extends 'global/master.twig' %}
{% block title %}Support {{ config('general.name') }}{% endblock %}
{% set title %}Support {{ config('general.name') }}{% endset %}
{% set persistentPremium = user.permission(constant('Sakura\\Perms\\Site::STATIC_PREMIUM')) %}

View file

@ -2,8 +2,6 @@
{% set title = category ~ ' / ' ~ mode %}
{% block title %}{{ title }}{% endblock %}
{% block content %}
<div class="content settings messages">
<div class="content-right content-column">

View file

@ -20,7 +20,7 @@
{% set paginationPages = users %}
{% set paginationUrl %}{% if rank %}{{ route('members.rank', rank) }}{% else %}{{ route('members.index') }}{% endif %}{% endset %}
{% block title %}{{ rankTitle }}{% endblock %}
{% set title = rankTitle %}
{% block content %}
<div class="headerNotify" style="margin-bottom: 1px;">

View file

@ -6,7 +6,7 @@
{% set profileView = noUserpage and profileView == 'index' ? 'comments' : profileView %}
{% block title %}{% if profileHidden %}User not found!{% else %}Profile of {{ profile.username }}{% endif %}{% endblock %}
{% set title %}{% if profileHidden %}User not found!{% else %}Profile of {{ profile.username }}{% endif %}{% endset %}
{% block js %}
{% if not profileHidden %}

View file

@ -44,7 +44,6 @@ Router::group(['before' => 'maintenance'], function () {
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');
// Auth
Router::group(['before' => 'logoutCheck'], function () {
@ -62,6 +61,49 @@ Router::group(['before' => 'maintenance'], function () {
Router::get('/logout', 'AuthController@logout', 'auth.logout');
});
// Link compatibility layer, prolly remove this in like a year
Router::get('/r/{id}', function ($id) {
header("Location: /p/{$id}");
});
Router::get('/p/{id}', function ($id) {
$resolve = [
'terms' => 'info.terms',
'contact' => 'info.contact',
'rules' => 'info.rules',
'welcome' => 'info.welcome',
//'profileapi' => 'api.manage.index',
'chat' => 'chat.redirect',
//'irc' => 'chat.irc',
'feedback' => 'forums.index',
//'mcp' => 'manage.index',
//'mcptest' => 'manage.index',
//'report' => 'report.something',
//'osu' => 'eventual link to flashii team',
//'filehost' => '???',
//'fhscript' => '???',
//'fhmanager' => '???',
'everlastingness' => 'https://i.flash.moe/18661469927746.txt',
'fuckingdone' => 'https://i.flash.moe/18671469927761.txt',
];
if (!array_key_exists($id, $resolve)) {
throw new \Phroute\Phroute\Exception\HttpRouteNotFoundException();
}
$link = $resolve[$id];
header("Location: " . (substr($link, 0, 4) === 'http' ? $link : route($link)));
});
// Info
Router::group(['prefix' => 'info'], function () {
Router::get('/terms', 'InfoController@terms', 'info.terms');
Router::get('/privacy', 'InfoController@privacy', 'info.privacy');
Router::get('/contact', 'InfoController@contact', 'info.contact');
Router::get('/rules', 'InfoController@rules', 'info.rules');
Router::get('/welcome', 'InfoController@welcome', 'info.welcome');
});
// News
Router::group(['prefix' => 'news'], function () {
Router::get('/{category:c}?', 'NewsController@category', 'news.category');
@ -70,7 +112,8 @@ Router::group(['before' => 'maintenance'], function () {
// Chat
Router::group(['prefix' => 'chat'], function () {
Router::get('/redirect', 'ChatController@category', 'chat.redirect');
Router::get('/redirect', 'ChatController@redirect', 'chat.redirect');
Router::get('/settings', 'ChatController@settings', 'chat.settings');
});
// Forum
@ -88,9 +131,14 @@ Router::group(['before' => 'maintenance'], function () {
// Topic
Router::group(['prefix' => 'topic'], function () {
Router::get('/{id:i}', 'ForumController@topic', 'forums.topic');
Router::post('/{id:i}/mod', 'ForumController@topicModerate', 'forums.topic.mod');
Router::post('/{id:i}/reply', 'ForumController@topicReply', 'forums.topic.reply');
Router::get('/{id:i}', 'Forum.TopicController@view', 'forums.topic');
Router::get('/{id:i}/sticky', 'Forum.TopicController@sticky', 'forums.topic.sticky');
Router::get('/{id:i}/announce', 'Forum.TopicController@announce', 'forums.topic.announce');
Router::get('/{id:i}/lock', 'Forum.TopicController@lock', 'forums.topic.lock');
Router::get('/{id:i}/delete', 'Forum.TopicController@delete', 'forums.topic.delete');
Router::get('/{id:i}/restore', 'Forum.TopicController@restore', 'forums.topic.restore');
Router::get('/{id:i}/move', 'Forum.TopicController@move', 'forums.topic.move');
Router::post('/{id:i}/reply', 'Forum.TopicController@reply', 'forums.topic.reply');
});
// Forum

View file

@ -6,6 +6,7 @@
use Sakura\Config;
use Sakura\Net;
use Sakura\Router;
use Sakura\Template;
// Sort of alias for Config::get
function config($value)
@ -27,6 +28,19 @@ function route($name, $args = null)
return Router::route($name, $args);
}
// Checking if a parameter is equal to session_id()
function session_check($param = 'session')
{
return isset($_REQUEST[$param]) && $_REQUEST[$param] === session_id();
}
// Alias for Template::vars and Template::render
function view($name, $vars = [])
{
Template::vars($vars);
return Template::render($name);
}
function clean_string($string, $lower = false, $noSpecial = false, $replaceSpecial = '')
{
// Run common sanitisation function over string