r20151024

Signed-off-by: Flashwave <me@flash.moe>
This commit is contained in:
Pachira 2015-10-24 10:55:45 +02:00
parent 0c77fa438e
commit e3b7b8cc87
10 changed files with 102 additions and 37 deletions

View file

@ -264,12 +264,6 @@ class Forum
'elapsed' => Main::timeElapsed($post['post_time']),
'is_op' => ($post['poster_id'] == $firstPost['poster_id'] ? '1' : '0'),
'parsed_post' => self::parseMarkUp($post['post_text'], $post['post_parse'], $post['post_emotes']),
'signature' => empty($_POSTER['userData']['signature']) ?
'' :
self::parseMarkUp(
$_POSTER['userData']['signature']['text'],
$_POSTER['userData']['signature']['mode']
),
]);
// Just in case

View file

@ -0,0 +1,15 @@
<?php
/*
* Extension manager
*/
namespace Sakura;
/**
* Class Trick
* @package Sakura
*/
class Trick
{
}

View file

@ -461,7 +461,7 @@ class User
}
// Get all warnings issued to the user
// Get a user's userpage
public function userPage()
{
@ -476,6 +476,22 @@ class User
}
// Get a user's signature
public function signature()
{
return isset($this->data['user_data']['signature']) ?
Main::bbParse(
Main::parseEmotes(
base64_decode(
$this->data['user_data']['signature']
)
)
) :
null;
}
// Get username change history
public function getUsernameHistory()
{

View file

@ -15,8 +15,8 @@ class Users
// Empty user template
public static $emptyUser = [
'user_id' => 0,
'username' => 'Sakura User',
'username_clean' => 'sakura user',
'username' => 'User',
'username_clean' => 'user',
'password_hash' => '',
'password_salt' => '',
'password_algo' => 'nologin',
@ -29,7 +29,7 @@ class Users
'user_colour' => '',
'register_ip' => '127.0.0.1',
'last_ip' => '127.0.0.1',
'user_title' => 'Internal fallback account',
'user_title' => '',
'user_registered' => 0,
'user_last_online' => 0,
'user_birthday' => '',
@ -40,11 +40,12 @@ class Users
// Empty rank template
public static $emptyRank = [
'rank_id' => 0,
'rank_name' => 'Sakura Rank',
'rank_name' => 'Rank',
'rank_hierarchy' => 0,
'rank_multiple' => null,
'rank_hidden' => 1,
'rank_colour' => '#444',
'rank_description' => 'A hardcoded dummy rank for fallback.',
'rank_description' => '',
'rank_title' => '',
];

View file

@ -8,7 +8,7 @@
namespace Sakura;
// Define Sakura version
define('SAKURA_VERSION', '20151022');
define('SAKURA_VERSION', '20151024');
define('SAKURA_VLABEL', 'Eminence');
define('SAKURA_COLOUR', '#6C3082');
define('SAKURA_STABLE', false);
@ -47,6 +47,7 @@ require_once ROOT . '_sakura/components/Manage.php';
require_once ROOT . '_sakura/components/Bans.php';
require_once ROOT . '_sakura/components/Whois.php';
require_once ROOT . '_sakura/components/Payments.php';
require_once ROOT . '_sakura/components/Trick.php';
// Include database extensions
foreach (glob(ROOT . '_sakura/components/database/*.php') as $driver) {

View file

@ -49,10 +49,10 @@
<div class="post-text markdown">
{{ post.parsed_post|raw }}
</div>
{% if post.post_signature and post.signature %}
{% if post.user.signature and post.post_signature %}
<div class="clear"></div>
<div class="signature">
{{ post.signature|raw }}
{{ post.user.signature|raw }}
</div>
{% endif %}
</td>

View file

@ -0,0 +1,15 @@
<form enctype="multipart/form-data" method="post" action="{{ sakura.currentPage }}" id="signatureEditorForm">
<input type="hidden" name="sessid" value="{{ php.sessionid }}" />
<input type="hidden" name="timestamp" value="{{ php.time }}" />
<input type="hidden" name="mode" value="signature" />
<div><textarea name="signature" id="signatureEditor" class="inputStyling" style="width: calc(100% - 12px); height: 400px;">{{ signature }}</textarea></div>
<div class="profile-save">
<input type="submit" value="Save" name="submit" class="inputStyling" />
<input type="reset" value="Reset" name="reset" class="inputStyling" />
</div>
</form>
<script type="text/javascript">
window.addEventListener('load', function() {
prepareAjaxForm('signatureEditorForm', 'Updating signature...');
});
</script>

View file

@ -1973,11 +1973,11 @@ textarea.inputStyling {
.forum.viewtopic .posts .post-content .signature {
border-top: 1px solid #B19EED;
margin-top: 16px;
padding-top: 4px;
padding-top: 2px;
margin-top: 20px;
display: block;
min-width: 300px;
max-height: 180px;
width: 100%;
max-height: 200px;
overflow: auto;
}

View file

@ -36,7 +36,7 @@ if ($mode != 'f') {
$topic = Forum::getTopic($topicId, true);
// Prompt an error if the topic doesn't exist
if(!$topic) {
if (!$topic) {
// Add page specific things
$renderData['page'] = [
'redirect' => (isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : $urls->format('FORUM_INDEX')),
@ -56,7 +56,7 @@ if ($mode != 'f') {
// Add subject to render data
$posting['text'] = '[quote]' . $post['post_text'] . '[/quote]';
// Post editing
// Post editing
} elseif ($mode == 'p' && isset($_GET['edit']) && $_GET['edit'] == $_GET['p'] && array_key_exists($_GET['p'], $topic['posts'])) {
// Checks
if ($topic['posts'][$_GET['p']]['poster_id'] != $currentUser->data['user_id']) {
@ -78,9 +78,9 @@ if ($mode != 'f') {
$posting = array_merge($posting, [
'subject' => $post['post_subject'],
'text' => $post['post_text'],
'id' => $post['post_id']
'id' => $post['post_id'],
]);
// Post deletion
// Post deletion
} elseif ($mode == 'p' && isset($_GET['delete']) && $_GET['delete'] == $_GET['p'] && array_key_exists($_GET['p'], $topic['posts'])) {
// Checks
if ($topic['posts'][$_GET['p']]['poster_id'] != $currentUser->data['user_id']) {
@ -123,9 +123,9 @@ if ($mode != 'f') {
// Render information page
print Templates::render('global/information.tpl', $renderData);
exit;
// Return to previous page
// Return to previous page
} else {
header('Location: '. $urls->format('FORUM_POST', [$_POST['post_id']]));
header('Location: ' . $urls->format('FORUM_POST', [$_POST['post_id']]));
exit;
}
}
@ -134,8 +134,8 @@ if ($mode != 'f') {
$renderData = array_merge($renderData, [
'message' => 'Are you sure you want to delete your reply to ' . $topic['topic']['topic_title'] . '?',
'conditions' => [
'post_id' => $topic['posts'][$_GET['p']]['post_id']
]
'post_id' => $topic['posts'][$_GET['p']]['post_id'],
],
]);
// Render confirmation form
@ -144,7 +144,7 @@ if ($mode != 'f') {
}
// Add subject to render data
if(!isset($posting['subject'])) {
if (!isset($posting['subject'])) {
$posting['subject'] = 'Re: ' . $topic['topic']['topic_title'];
}
}
@ -152,7 +152,7 @@ if ($mode != 'f') {
// Check if a post is being made
if (isset($_POST['post'])) {
// Set post mode
switch($_POST['parseMode']) {
switch ($_POST['parseMode']) {
// BBcode
case '1':
$parse = '1';
@ -167,7 +167,7 @@ if (isset($_POST['post'])) {
}
// Attempt to make the post
$makePost = Forum::createPost($currentUser->data['user_id'], $_POST['subject'], $_POST['text'], $forumId, $topicId, $parse);
$makePost = Forum::createPost($currentUser->data['user_id'], $_POST['subject'], $_POST['text'], $forumId, $topicId, $parse, 1, 1);
// Add page specific things
$renderData['page'] = [
@ -178,12 +178,12 @@ if (isset($_POST['post'])) {
// Print page contents or if the AJAX request is set only display the render data
print isset($_REQUEST['ajax']) ?
(
$renderData['page']['message'] . '|' .
$renderData['page']['success'] . '|' .
$renderData['page']['redirect']
) :
Templates::render('global/information.tpl', $renderData);
(
$renderData['page']['message'] . '|' .
$renderData['page']['success'] . '|' .
$renderData['page']['redirect']
) :
Templates::render('global/information.tpl', $renderData);
exit;
}

View file

@ -948,6 +948,24 @@ if (isset($_REQUEST['request-notifications']) && $_REQUEST['request-notification
];
break;
// Signature
case 'signature':
// Base64 encode the signature
$signature = base64_encode($_POST['signature']);
// Update database
Users::updateUserDataField($currentUser->data['user_id'], ['signature' => $signature]);
// Set render data
$renderData['page'] = [
'redirect' => $redirect,
'message' => 'Your signature has been updated!',
'success' => 1,
];
break;
// Fallback
default:
// Set render data
@ -1465,11 +1483,16 @@ if (Users::checkLogin()) {
];
break;
// Profile
// User page
case 'appearance.userpage':
$renderData['userPage'] = isset($currentUser->data['user_data']['userPage']) ? base64_decode($currentUser->data['user_data']['userPage']) : '';
break;
// Signature
case 'appearance.signature':
$renderData['signature'] = isset($currentUser->data['user_data']['signature']) ? base64_decode($currentUser->data['user_data']['signature']) : '';
break;
// Username changing
case 'account.username':
$renderData['difference'] = $currentUser->getUsernameHistory() ? Main::timeElapsed($currentUser->getUsernameHistory()[0]['change_time']) : 0;