r20150919 and r20150923

Signed-off-by: Flashwave <me@flash.moe>
This commit is contained in:
flash 2015-09-23 22:45:42 +02:00
parent 062f672026
commit 5a1264f329
19 changed files with 283 additions and 146 deletions

View file

@ -2836,6 +2836,43 @@
"user": "Flashwave" "user": "Flashwave"
} }
],
"20150919": [
"eminence",
{
"type": "REM",
"change": "Removed Main::jsonPretty in favour of the built in PHP version.",
"user": "Flashwave"
}
],
"20150923": [
"eminence",
{
"type": "ADD",
"change": "Added a JavaScript error reporter.",
"user": "Flashwave"
},
{
"type": "ADD",
"change": "Redirect a new user to /p/welcome on first login.",
"user": "Flashwave"
},
{
"type": "UPD",
"change": "Changed sakura_sessions to a MEMORY table.",
"user": "Flashwave"
},
{
"type": "ADD",
"change": "Implement username changing.",
"user": "Flashwave"
}
] ]
} }

View file

@ -708,81 +708,6 @@ class Main
} }
// Indent JSON
public static function jsonPretty($json)
{
// Defines
$tab = ' ';
$out = '';
$lvl = 0;
$str = false;
$obj = json_decode($json);
// Validate the object
if ($obj === false) {
return false;
}
// Re-encode the json and get the length
$json = json_encode($obj);
$len = strlen($json);
// Go over the entries
for ($c = 0; $c < $len; $c++) {
// Get the current character
$char = $json[$c];
switch ($char) {
case '[':
case '{':
if ($str) {
$out .= $char;
} else {
$out .= $char . "\r\n" . str_repeat($tab, $lvl + 1);
$lvl++;
}
break;
case ']':
case '}':
if ($str) {
$out .= $char;
} else {
$lvl--;
$out .= "\r\n" . str_repeat($tab, $lvl) . $char;
}
break;
case ',':
if ($str) {
$out .= $char;
} else {
$out .= ",\r\n" . str_repeat($tab, $lvl);
}
break;
case ':':
if ($str) {
$out .= $char;
} else {
$out .= ": ";
}
break;
default:
$out .= $char;
break;
}
}
// Return the indented JSON
return $out;
}
// Time elapsed // Time elapsed
public static function timeElapsed($timestamp, $append = ' ago', $none = 'Just now') public static function timeElapsed($timestamp, $append = ' ago', $none = 'Just now')
{ {

View file

@ -336,4 +336,82 @@ class User
return $warnings; return $warnings;
} }
// Get username change history
public function getUsernameHistory()
{
// Do the database query
$changes = Database::fetch('username_history', true, [
'user_id' => [$this->data['id'], '='],
], ['change_id', true]);
// Return all the warnings
return $changes;
}
// Set a new username
public function setUsername($username)
{
// Create a cleaned version
$username_clean = Main::cleanString($username, true);
// Check if the username is too short
if (strlen($username_clean) < Configuration::getConfig('username_min_length')) {
return [0, 'TOO_SHORT'];
}
// Check if the username is too long
if (strlen($username_clean) > Configuration::getConfig('username_max_length')) {
return [0, 'TOO_LONG'];
}
// Check if this username hasn't been used in the last amount of days set in the config
$getOld = Database::fetch('username_history', false, [
'username_old_clean' => [$username_clean, '='],
'change_time' => [(Configuration::getConfig('old_username_reserve') * 24 * 60 * 60), '>'],
], ['change_id', true]);
// Check if anything was returned
if ($getOld) {
return [0, 'TOO_RECENT', $getOld['change_time']];
}
// Check if the username is already in use
$getInUse = Database::fetch('users', false, [
'username_clean' => [$username_clean, '='],
]);
// Check if anything was returned
if ($getInUse) {
return [0, 'IN_USE', $getInUse['id']];
}
// Insert into username_history table
Database::insert('username_history', [
'change_time' => time(),
'user_id' => $this->data['id'],
'username_new' => $username,
'username_new_clean' => $username_clean,
'username_old' => $this->data['username'],
'username_old_clean' => $this->data['username_clean'],
]);
// Update userrow
Database::update('users', [
[
'username' => $username,
'username_clean' => $username_clean,
],
[
'id' => [$this->data['id'], '='],
],
]);
// Return success
return [1, 'SUCCESS', $username];
}
} }

View file

@ -196,7 +196,7 @@ class Users
} }
// Successful login! (also has a thing for the legacy password system) // Successful login! (also has a thing for the legacy password system)
return [1, 'LOGIN_SUCESS']; return [1, 'LOGIN_SUCCESS', $user['id']];
} }
@ -329,7 +329,6 @@ class Users
'last_ip' => Main::getRemoteIP(), 'last_ip' => Main::getRemoteIP(),
'regdate' => time(), 'regdate' => time(),
'lastdate' => 0, 'lastdate' => 0,
'lastunamechange' => time(),
'country' => Main::getCountryCode(), 'country' => Main::getCountryCode(),
'userData' => '[]', 'userData' => '[]',
]); ]);

View file

@ -8,7 +8,7 @@
namespace Sakura; namespace Sakura;
// Define Sakura version // Define Sakura version
define('SAKURA_VERSION', '20150918'); define('SAKURA_VERSION', '20150923');
define('SAKURA_VLABEL', 'Eminence'); define('SAKURA_VLABEL', 'Eminence');
define('SAKURA_COLOUR', '#6C3082'); define('SAKURA_COLOUR', '#6C3082');
define('SAKURA_STABLE', false); define('SAKURA_STABLE', false);

View file

@ -1,5 +1,5 @@
{% if newsPosts|length > 1 %}<h3 class="miotitle" id="{{ newsPost.id }}">{{ newsPost.title }} by <a href="/u/{{ newsPost.uid }}" style="text-decoration: none !important; color: {{ newsPost.rdata.colour }} !important;">{{ newsPost.udata.username }}</a> - {{ newsPost.date|date("D Y-m-d H:i:s T") }}<span class="permalink"><a href="/news#{{ newsPost.id }}" title="Permalink">#</a> <a href="/news/{{ newsPost.id }}" title="Direct Link">@</a></span></h3>{% endif %} {% if not (viewPost and postExists) %}<h3 class="miotitle" id="{{ newsPost.id }}">{{ post.title }} by <a href="{{ urls.format('USER_PROFILE', [post.poster.data.id]) }}" style="text-decoration: none !important; color: {{ post.poster.colour }} !important;">{{ post.poster.data.username }}</a> - {{ post.date|date(sakura.dateFormat) }}<span class="permalink"><a href="{{ urls.format('SITE_NEWS') }}#{{ newsPost.id }}" title="Permalink">#</a> <a href="{{ urls.format('SITE_NEWS_POST', [post.id]) }}" title="Direct Link">@</a></span></h3>{% endif %}
<div class="postcontent"> <div class="postcontent">
{{ newsPost.parsed|raw }} {{ post.content_parsed|raw }}
</div> </div>
<br /> <br />

View file

@ -12,26 +12,15 @@
{% endif %} {% endif %}
<!-- CSS --> <!-- CSS -->
<link rel="stylesheet" type="text/css" href="{{ sakura.resources }}/css/mio.css" /> <link rel="stylesheet" type="text/css" href="{{ sakura.resources }}/css/mio.css" />
{% if page.style %}
<style type="text/css">
{% for element,properties in page.style %}
{{ element|raw }} {
{% for property,value in properties %}
{{ property|raw }}: {{ value|raw }};
{% endfor %}
}
{% endfor %}
</style>
{% endif %}
<!-- JS --> <!-- JS -->
<script type="text/javascript" src="{{ sakura.resources }}/js/mio.js"></script> <script type="text/javascript" src="{{ sakura.resources }}/js/mio.js"></script>
</head> </head>
<body> <body>
<div class="flashii-bar"> <div class="flashii-bar">
<a href="//{{ sakura.urls.main }}/login"<!-- onclick="flashii_login(true);"-->Login</a> | <a href="javascript:void(0);" onclick="flashii_login(true);">Login</a> |
<a href="//{{ sakura.urls.main }}/register">Register</a> <a href="/register">Register</a>
</div> </div>
<a href="//{{ sakura.urls.main }}/"> <a href="//{{ sakura.urls.main }}/">
<img class="logo" src="//{{ sakura.urls.content }}/pixel.png" alt="{{ sakura.sitename }}" /> <img class="logo" src="/content/pixel.png" alt="{{ sakura.sitename }}" />
</a> </a>
<br /> <br />

View file

@ -5,19 +5,19 @@
Welcome to Flashii! This is a site for a bunch of friends to hang out, nothing special.<br />Anyone is pretty much welcome to register so why not have a go? Welcome to Flashii! This is a site for a bunch of friends to hang out, nothing special.<br />Anyone is pretty much welcome to register so why not have a go?
<br /> <br />
<br /> <br />
<a class="registerbutton" href="//{{ sakura.urls.main }}/register">Register!</a> <a class="registerbutton" href="/register">Register!</a>
<a class="loginbutton" href="//{{ sakura.urls.main }}/login">Login</a> <a class="loginbutton" href="/login">Login</a>
</div> </div>
<div class="mioblog"> <div class="mioblog">
<h3 class="miotitle" style="margin: 0;">Latest News Posts<span class="windowbutton-container" onclick="hidePageSection('latestnewsposts',1);"><img class="minbutton" src="//{{ sakura.urls.content }}/pixel.png" alt="_"></span></h3> <h3 class="miotitle" style="margin: 0;">Latest News Posts<span class="windowbutton-container" onclick="hidePageSection('latestnewsposts',1);"><img class="minbutton" src="/content/pixel.png" alt="_"></span></h3>
<div class="mioboxcontent sub" style="margin: 0;"> <div class="mioboxcontent sub" style="margin: 0;">
{% for newsPost in newsPosts %} {% for post in news.getPosts(0, newsCount) %}
{% include 'elements/newsPost.tpl' %} {% include 'elements/newsPost.tpl' %}
{% endfor %} {% endfor %}
</div> </div>
</div> </div>
<div class="mioblog"> <div class="mioblog">
<h3 class="miotitle" style="margin: 0;">Statistics<span class="windowbutton-container" onclick="hidePageSection('sitestatistics',1);"><img class="minbutton" src="//{{ sakura.urls.content }}/pixel.png" alt="_"></span></h3> <h3 class="miotitle" style="margin: 0;">Statistics<span class="windowbutton-container" onclick="hidePageSection('sitestatistics',1);"><img class="minbutton" src="/content/pixel.png" alt="_"></span></h3>
<div class="mioboxcontent sub" style="margin: 0;"> <div class="mioboxcontent sub" style="margin: 0;">
<table class="miotable" style="text-align:center;"> <table class="miotable" style="text-align:center;">
<tbody> <tbody>

View file

@ -141,6 +141,17 @@
}); });
// Error reporter
window.onerror = function(msg, url, line, col, error) {
notifyUI({
"title": "An error has occurred!",
"text": "There was a problem while executing the JavaScript code for this page: " + msg + ", URL: " + url + ", Line: " + line + ", Column: " + col + ". Please report this to a developer.",
"img": "FONT:fa-warning"
});
}
</script> </script>
{{ block('js') }} {{ block('js') }}
</head> </head>

View file

@ -108,7 +108,7 @@
<input class="inputStyling" type="text" id="registerCode" name="registercode" placeholder="Ask another member for one" /> <input class="inputStyling" type="text" id="registerCode" name="registercode" placeholder="Ask another member for one" />
</div> </div>
{% endif %} {% endif %}
{% if sakura.recaptchaEnable %} {% if sakura.recaptchaEnabled %}
<div class="leftAlign"> <div class="leftAlign">
<label for="recaptcha_response_field">Verification:</label> <label for="recaptcha_response_field">Verification:</label>
</div> </div>

View file

@ -23,7 +23,7 @@
<img src="{{ urls.format('IMAGE_AVATAR', [profile.data.id]) }}" alt="{{ profile.data.username }}'s Avatar" class="default-avatar-setting" style="box-shadow: 0 3px 7px #{% if profile.checkOnline %}484{% else %}844{% endif %};" /><br /> <img src="{{ urls.format('IMAGE_AVATAR', [profile.data.id]) }}" alt="{{ profile.data.username }}'s Avatar" class="default-avatar-setting" style="box-shadow: 0 3px 7px #{% if profile.checkOnline %}484{% else %}844{% endif %};" /><br />
{% if profile.data.rank_main > 1 and profile.checkBan|length < 1 %} {% if profile.data.rank_main > 1 and profile.checkBan|length < 1 %}
<span style="font-size: .8em;">{{ profile.userTitle }}</span> <span style="font-size: .8em;">{{ profile.userTitle }}</span>
<h1 style="color: {{ profile.colour }}; text-shadow: 0 0 7px {% if profile.colour != 'inherit' %}{{ profile.colour }}{% else %}#222{% endif %}; padding: 0 0 2px;">{{ profile.data.username }}</h1> <h1 style="color: {{ profile.colour }}; text-shadow: 0 0 7px {% if profile.colour != 'inherit' %}{{ profile.colour }}{% else %}#222{% endif %}; padding: 0 0 2px;"{% if profile.getUsernameHistory %} title="Known as {{ profile.getUsernameHistory[0]['username_old'] }} before {{ profile.getUsernameHistory[0]['change_time']|date(sakura.dateFormat) }}."{% endif %}>{{ profile.data.username }}</h1>
{% if profile.checkPremium[0] %}<img src="{{ sakura.contentPath }}/images/tenshi.png" alt="Tenshi" /> {% endif %}<img src="{{ sakura.contentPath }}/images/flags/{{ profile.country.short|lower }}.png" alt="{{ profile.country.short }}" /> <span style="font-size: .9em; line-height: 11px;">{{ profile.country.long }}</span> {% if profile.checkPremium[0] %}<img src="{{ sakura.contentPath }}/images/tenshi.png" alt="Tenshi" /> {% endif %}<img src="{{ sakura.contentPath }}/images/flags/{{ profile.country.short|lower }}.png" alt="{{ profile.country.short }}" /> <span style="font-size: .9em; line-height: 11px;">{{ profile.country.long }}</span>
{% if session.checkLogin %} {% if session.checkLogin %}
<div class="user-actions"> <div class="user-actions">

View file

@ -1,19 +1,15 @@
{% set eligible = (php.time - user.data.lastunamechange) > 2592000 %} {% set eligible = user.getUsernameHistory ? (php.time - user.getUsernameHistory()[0].change_time) > 2592000 : true %}
<form enctype="multipart/form-data" method="post" action="{{ sakura.currentPage }}" id="changeUsernameForm"> <form enctype="multipart/form-data" method="post" action="{{ sakura.currentPage }}" id="changeUsernameForm">
<input type="hidden" name="sessid" value="{{ php.sessionid }}" /> <input type="hidden" name="sessid" value="{{ php.sessionid }}" />
<input type="hidden" name="timestamp" value="{{ php.time }}" /> <input type="hidden" name="timestamp" value="{{ php.time }}" />
<input type="hidden" name="mode" value="username" /> <input type="hidden" name="mode" value="username" />
<h1 class="stylised" style="text-align: center; margin-top: 10px;{% if not eligible %} color: #c44;{% endif %}">You are {% if not eligible %}not {% endif %}eligible for a name change.</h1> <h1 class="stylised" style="text-align: center; margin-top: 10px;{% if not eligible %} color: #c44;{% endif %}">You are {% if not eligible %}not {% endif %}eligible for a name change.</h1>
<h3 style="text-align: center;">Your last name change was {{ difference }}.</h3> <h3 style="text-align: center;">{% if user.getUsernameHistory %}Your last name change was {{ difference }}.{% else %}This is your first username change.{% endif %}</h3>
{% if eligible %} {% if eligible %}
<div class="profile-field"> <div class="profile-field">
<div><h2>Username</h2></div> <div><h2>Username</h2></div>
<div><input type="text" name="usernew" placeholder="Enter your new username (Max 20 characters)" class="inputStyling" /></div> <div><input type="text" name="username" placeholder="Enter your new username (at least {{ sakura.minUsernameLength }} and at most {{ sakura.maxUsernameLength }} characters!)" class="inputStyling" /></div>
</div>
<div class="profile-field">
<div><h2>Confirmation</h2></div>
<div><input type="text" name="userver" placeholder="Just to make sure since you'll be stuck with it for 30 days..." class="inputStyling" /></div>
</div> </div>
<div class="profile-save"> <div class="profile-save">
<input type="submit" value="Save" name="submit" class="inputStyling" /> <input type="submit" value="Save" name="submit" class="inputStyling" />

View file

@ -71,4 +71,4 @@ switch (isset($elems[0]) ? $elems[0] : false) {
$return = ['error' => ['NO_API_VERSION']]; $return = ['error' => ['NO_API_VERSION']];
} }
echo isset($_GET['pretty']) ? Main::jsonPretty(json_encode([$return])) : json_encode([$return]); echo json_encode([$return], (isset($_GET['pretty']) ? JSON_PRETTY_PRINT : 0));

View file

@ -5,8 +5,6 @@ SET time_zone = '+00:00';
SET foreign_key_checks = 0; SET foreign_key_checks = 0;
SET sql_mode = 'NO_AUTO_VALUE_ON_ZERO'; SET sql_mode = 'NO_AUTO_VALUE_ON_ZERO';
USE `sakura-development`;
TRUNCATE `sakura_bbcodes`; TRUNCATE `sakura_bbcodes`;
INSERT INTO `sakura_bbcodes` (`id`, `regex`, `replace`, `title`, `description`, `on_posting`) VALUES INSERT INTO `sakura_bbcodes` (`id`, `regex`, `replace`, `title`, `description`, `on_posting`) VALUES
(1, '/\\[b\\](.*?)\\[\\/b\\]/is', '<b>$1</b>', 'Bold', 'Make text bold. Usage: [b]text[/b].', 1), (1, '/\\[b\\](.*?)\\[\\/b\\]/is', '<b>$1</b>', 'Bold', 'Make text bold. Usage: [b]text[/b].', 1),
@ -24,36 +22,36 @@ INSERT INTO `sakura_config` (`config_name`, `config_value`) VALUES
('recaptcha_public', ''), ('recaptcha_public', ''),
('recaptcha_private', ''), ('recaptcha_private', ''),
('charset', 'utf-8'), ('charset', 'utf-8'),
('cookie_prefix', 'sakura_'), ('cookie_prefix', 'fii_'),
('cookie_domain', 'sakura.dev'), ('cookie_domain', 'flashii.test'),
('cookie_path', '/'), ('cookie_path', '/'),
('site_style', 'yuuno'), ('site_style', 'yuuno'),
('manage_style', 'broomcloset'), ('manage_style', 'broomcloset'),
('smtp_server', ''), ('smtp_server', ''),
('smtp_auth', ''), ('smtp_auth', '1'),
('smtp_secure', ''), ('smtp_secure', 'tls'),
('smtp_port', ''), ('smtp_port', ''),
('smtp_username', ''), ('smtp_username', ''),
('smtp_password', ''), ('smtp_password', ''),
('smtp_replyto_mail', ''), ('smtp_replyto_mail', ''),
('smtp_replyto_name', ''), ('smtp_replyto_name', 'Flashwave'),
('smtp_from_email', ''), ('smtp_from_email', ''),
('smtp_from_name', ''), ('smtp_from_name', 'Flashii Noreply'),
('sitename', 'Sakura'), ('sitename', 'Cutting Edgii'),
('recaptcha', '0'), ('recaptcha', '0'),
('require_activation', '0'), ('require_activation', '0'),
('require_registration_code', '0'), ('require_registration_code', '0'),
('disable_registration', '0'), ('disable_registration', '0'),
('max_reg_keys', '5'), ('max_reg_keys', '5'),
('mail_signature', ''), ('mail_signature', 'Team Flashii'),
('lock_authentication', '0'), ('lock_authentication', '0'),
('min_entropy', '1'), ('min_entropy', '1'),
('sitedesc', ''), ('sitedesc', 'Live development environment for the script that powers Flashii.net called Sakura.'),
('sitetags', '[]'), ('sitetags', '[\"Flashii\",\"Media\",\"Flashwave\",\"Circle\",\"Zeniea\",\"MalwareUp\",\"Cybernetics\",\"Saibateku\",\"Community\",\"osu!\",\"osu\"]'),
('username_min_length', '3'), ('username_min_length', '3'),
('username_max_length', '16'), ('username_max_length', '16'),
('lock_site', '0'), ('site_closed', '0'),
('lock_site_reason', ''), ('site_closed_reason', 'meow'),
('use_gzip', '0'), ('use_gzip', '0'),
('enable_tpl_cache', '0'), ('enable_tpl_cache', '0'),
('paypal_client_id', ''), ('paypal_client_id', ''),
@ -71,25 +69,30 @@ INSERT INTO `sakura_config` (`config_name`, `config_value`) VALUES
('avatar_max_height', '512'), ('avatar_max_height', '512'),
('avatar_max_width', '512'), ('avatar_max_width', '512'),
('avatar_max_fsize', '2097152'), ('avatar_max_fsize', '2097152'),
('url_api', 'api.sakura.dev'), ('url_api', 'api.flashii.test'),
('content_path', '/content'), ('content_path', '/content'),
('user_uploads', 'uploads'), ('user_uploads', 'uploads'),
('no_background_img', 'main/content/pixel.png'), ('no_background_img', 'public/content/pixel.png'),
('no_header_img', 'main/content/images/triangles.png'), ('no_header_img', 'public/content/images/triangles.png'),
('pixel_img', 'main/content/pixel.png'), ('pixel_img', 'public/content/pixel.png'),
('background_max_fsize', '5242880'), ('background_max_fsize', '5242880'),
('background_max_width', '2560'), ('background_max_width', '2560'),
('background_max_height', '1440'), ('background_max_height', '1440'),
('background_min_height', '16'), ('background_min_height', '16'),
('background_min_width', '16'), ('background_min_width', '16'),
('max_online_time', '500'), ('max_online_time', '500'),
('no_avatar_img', 'main/content/data/{{ TPL }}/images/no-av.png'), ('no_avatar_img', 'public/content/data/{{ TPL }}/images/no-av.png'),
('deactivated_avatar_img', 'main/content/data/{{ TPL }}/images/deactivated-av.png'), ('deactivated_avatar_img', 'public/content/data/{{ TPL }}/images/deactivated-av.png'),
('banned_avatar_img', 'main/content/data/{{ TPL }}/images/banned-av.png'), ('banned_avatar_img', 'public/content/data/{{ TPL }}/images/banned-av.png'),
('session_check', '2'), ('session_check', '4'),
('url_rewrite', '1'), ('url_rewrite', '1'),
('members_per_page', '30'), ('members_per_page', '30'),
('admin_email', ''); ('admin_email', 'me@flash.moe'),
('site_news_category', 'site-news'),
('no_cron_service', '1'),
('no_cron_interval', '30'),
('no_cron_last', '1443040870'),
('old_username_reserve', '90');
TRUNCATE `sakura_emoticons`; TRUNCATE `sakura_emoticons`;
INSERT INTO `sakura_emoticons` (`emote_string`, `emote_path`) VALUES INSERT INTO `sakura_emoticons` (`emote_string`, `emote_path`) VALUES
@ -132,6 +135,28 @@ INSERT INTO `sakura_emoticons` (`emote_string`, `emote_path`) VALUES
(':what:', '/content/images/emoticons/what.png'), (':what:', '/content/images/emoticons/what.png'),
(':smug:', '/content/images/emoticons/smug.png'); (':smug:', '/content/images/emoticons/smug.png');
TRUNCATE `sakura_forums`;
INSERT INTO `sakura_forums` (`forum_id`, `forum_name`, `forum_desc`, `forum_link`, `forum_category`, `forum_type`, `forum_icon`) VALUES
(1, 'General', 'General category', '', 0, 1, ''),
(2, 'Introductions', 'Help us get to know you better!', '', 1, 0, 'fa-smile-o'),
(3, 'General Discussion', 'Civilised discussions about things that don\'t have their own subforum.', '', 1, 0, 'fa-comments'),
(4, 'BUG SPORTS', 'Post all new BUG SPORTS tutorials here (this is the off topic forum for those who couldn\'t guess).', '', 1, 0, 'fa-bug'),
(5, 'Programming', 'Programming discussion', '', 0, 1, ''),
(6, 'Web Development', 'Talk about the PHPython on Rails.js.', '', 5, 0, 'fa-html5'),
(7, 'General Programming', 'Mostly desktop stuff here.', '', 5, 0, 'fa-code'),
(8, 'Media', 'Media discussion', '', 0, 1, ''),
(9, 'Anime & Manga', 'Your waifu is shit.', '', 8, 0, 'fa-yen'),
(10, 'Video Games', 'Sakura Clicker is the best game ever and you know it.', '', 8, 0, 'fa-gamepad'),
(11, 'osu!', 'Talk about clicking circles like an insane person.', '', 10, 0, 'fa-dot-circle-o'),
(12, 'Feedback', 'Site Feedback', '', 0, 1, ''),
(13, 'Staff', 'Tell us how to do our jobs.', '', 12, 0, 'fa-balance-scale'),
(14, 'Sakura', 'Report bugs or give us feature suggestions about the script Flashii runs on here.', '', 12, 0, 'fa-heartbeat'),
(15, 'Staff', 'Staff discussion', '', 0, 1, ''),
(16, 'Slack', 'A direct link to Slack.', 'https://circlestorm.slack.com/', 15, 2, 'fa-slack'),
(17, 'Office 365', 'A direct link to Office 365.', 'https://login.microsoftonline.com/', 15, 2, 'fa-envelope-o'),
(18, 'General Discussion', 'Discuss Staff Stuff.', '', 15, 0, 'fa-user-secret'),
(19, 'Retarded Palace', 'This is where deleted threads rot.', '', 15, 0, 'fa-trash-o');
TRUNCATE `sakura_optionfields`; TRUNCATE `sakura_optionfields`;
INSERT INTO `sakura_optionfields` (`id`, `name`, `description`, `formtype`, `require_perm`) VALUES INSERT INTO `sakura_optionfields` (`id`, `name`, `description`, `formtype`, `require_perm`) VALUES
('disableProfileParallax', 'Disable Parallaxing', 'This will stop your background from responding to your mouse movement, this will only affect your background.', 'checkbox', 'CHANGE_BACKGROUND'), ('disableProfileParallax', 'Disable Parallaxing', 'This will stop your background from responding to your mouse movement, this will only affect your background.', 'checkbox', 'CHANGE_BACKGROUND'),
@ -149,7 +174,8 @@ INSERT INTO `sakura_permissions` (`rid`, `uid`, `siteperms`, `manageperms`, `for
(7, 0, '0001111111111111111111111100', '01', '1', '000'), (7, 0, '0001111111111111111111111100', '01', '1', '000'),
(8, 0, '0001111111111111111111111100', '00', '1', '000'), (8, 0, '0001111111111111111111111100', '00', '1', '000'),
(9, 0, '0001111111111111111111111100', '00', '1', '000'), (9, 0, '0001111111111111111111111100', '00', '1', '000'),
(10, 0, '0000000011010100101000100010', '00', '0', '000'); (10, 0, '0000000011010100101000100010', '00', '0', '000'),
(11, 0, '0000111111111100111101101100', '00', '1', '000');
TRUNCATE `sakura_profilefields`; TRUNCATE `sakura_profilefields`;
INSERT INTO `sakura_profilefields` (`id`, `name`, `formtype`, `islink`, `linkformat`, `description`, `additional`) VALUES INSERT INTO `sakura_profilefields` (`id`, `name`, `formtype`, `islink`, `linkformat`, `description`, `additional`) VALUES
@ -177,6 +203,7 @@ INSERT INTO `sakura_ranks` (`id`, `name`, `multi`, `hidden`, `colour`, `descript
(7, 'Chat moderator', 1, 0, '#09F', 'Moderators of the chat room.', 'Staff'), (7, 'Chat moderator', 1, 0, '#09F', 'Moderators of the chat room.', 'Staff'),
(8, 'Tenshi', 0, 0, '#EE9400', 'Users that bought premium to help us keep the site and its services alive!', 'Tenshi'), (8, 'Tenshi', 0, 0, '#EE9400', 'Users that bought premium to help us keep the site and its services alive!', 'Tenshi'),
(9, 'Alumnii', 0, 0, '#FF69B4', 'People who have contributed to the community but have moved on or resigned.', 'Alumnii'), (9, 'Alumnii', 0, 0, '#FF69B4', 'People who have contributed to the community but have moved on or resigned.', 'Alumnii'),
(10, 'Restricted', 0, 1, '#333', 'Users that are restricted.', 'Restricted'); (10, 'Restricted', 0, 1, '#333', 'Users that are restricted.', 'Restricted'),
(11, 'Early Supporter', 1, 0, '#0049EE', 'User that donated before the premium system.', 'Early Supporter');
-- 2015-09-06 14:19:12 -- 2015-09-23 20:43:17

View file

@ -55,6 +55,20 @@ CREATE TABLE `sakura_bbcodes` (
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin; ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
DROP TABLE IF EXISTS `sakura_comments`;
CREATE TABLE `sakura_comments` (
`comment_id` bigint(255) unsigned NOT NULL AUTO_INCREMENT COMMENT 'MySQL Generated ID used for sorting.',
`comment_category` varchar(32) COLLATE utf8_bin NOT NULL COMMENT 'Comment category.',
`comment_timestamp` int(11) unsigned NOT NULL COMMENT 'Timestamp of when this comment was posted.',
`comment_poster` bigint(255) unsigned NOT NULL COMMENT 'User ID of the poster.',
`comment_likes` int(11) unsigned NOT NULL DEFAULT '0' COMMENT 'Upvotes of the comments.',
`comment_dislikes` int(11) unsigned NOT NULL DEFAULT '0' COMMENT 'Downvotes of the comments.',
`comment_reply_to` bigint(255) unsigned NOT NULL DEFAULT '0' COMMENT 'ID of the comment this comment is a reply to',
`comment_text` text COLLATE utf8_bin NOT NULL COMMENT 'Content of the comment.',
PRIMARY KEY (`comment_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
DROP TABLE IF EXISTS `sakura_config`; DROP TABLE IF EXISTS `sakura_config`;
CREATE TABLE `sakura_config` ( CREATE TABLE `sakura_config` (
`config_name` varchar(255) COLLATE utf8_bin NOT NULL COMMENT 'Array key for configuration value', `config_name` varchar(255) COLLATE utf8_bin NOT NULL COMMENT 'Array key for configuration value',
@ -73,6 +87,7 @@ DROP TABLE IF EXISTS `sakura_error_log`;
CREATE TABLE `sakura_error_log` ( CREATE TABLE `sakura_error_log` (
`id` varchar(32) COLLATE utf8_bin NOT NULL COMMENT 'An ID that is created when an error occurs.', `id` varchar(32) COLLATE utf8_bin NOT NULL COMMENT 'An ID that is created when an error occurs.',
`timestamp` varchar(128) COLLATE utf8_bin NOT NULL COMMENT 'A datestring from when the error occurred.', `timestamp` varchar(128) COLLATE utf8_bin NOT NULL COMMENT 'A datestring from when the error occurred.',
`revision` int(16) unsigned NOT NULL COMMENT 'Sakura Revision number.',
`error_type` int(16) unsigned NOT NULL COMMENT 'The PHP error type of this error.', `error_type` int(16) unsigned NOT NULL COMMENT 'The PHP error type of this error.',
`error_line` int(32) unsigned NOT NULL COMMENT 'The line that caused this error.', `error_line` int(32) unsigned NOT NULL COMMENT 'The line that caused this error.',
`error_string` varchar(512) COLLATE utf8_bin NOT NULL COMMENT 'PHP''s description of this error.', `error_string` varchar(512) COLLATE utf8_bin NOT NULL COMMENT 'PHP''s description of this error.',
@ -276,7 +291,7 @@ CREATE TABLE `sakura_ranks` (
`hidden` tinyint(1) unsigned NOT NULL DEFAULT '0' COMMENT 'Don''t show any public links to this rank.', `hidden` tinyint(1) unsigned NOT NULL DEFAULT '0' COMMENT 'Don''t show any public links to this rank.',
`colour` varchar(255) COLLATE utf8_bin NOT NULL COMMENT 'Colour used for the username of a member of this rank.', `colour` varchar(255) COLLATE utf8_bin NOT NULL COMMENT 'Colour used for the username of a member of this rank.',
`description` text COLLATE utf8_bin NOT NULL COMMENT 'A description of what a user of this rank can do/is supposed to do.', `description` text COLLATE utf8_bin NOT NULL COMMENT 'A description of what a user of this rank can do/is supposed to do.',
`title` varchar(255) COLLATE utf8_bin NOT NULL COMMENT 'Default user title if user has none set.', `title` varchar(64) COLLATE utf8_bin NOT NULL COMMENT 'Default user title if user has none set.',
PRIMARY KEY (`id`) PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin; ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
@ -318,9 +333,8 @@ CREATE TABLE `sakura_sessions` (
`expire` int(16) unsigned NOT NULL COMMENT 'The timestamp for when this session should end, -1 for permanent. ', `expire` int(16) unsigned NOT NULL COMMENT 'The timestamp for when this session should end, -1 for permanent. ',
`remember` tinyint(1) unsigned NOT NULL DEFAULT '0' COMMENT 'If set to 1 session will be extended each time a page is loaded.', `remember` tinyint(1) unsigned NOT NULL DEFAULT '0' COMMENT 'If set to 1 session will be extended each time a page is loaded.',
PRIMARY KEY (`id`), PRIMARY KEY (`id`),
KEY `userid` (`userid`), KEY `userid` (`userid`)
CONSTRAINT `sakura_sessions_ibfk_1` FOREIGN KEY (`userid`) REFERENCES `sakura_users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE=MEMORY DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
DROP TABLE IF EXISTS `sakura_topics`; DROP TABLE IF EXISTS `sakura_topics`;
@ -342,6 +356,19 @@ CREATE TABLE `sakura_topics` (
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin; ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
DROP TABLE IF EXISTS `sakura_username_history`;
CREATE TABLE `sakura_username_history` (
`change_id` int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT 'Identifier',
`change_time` int(11) unsigned NOT NULL COMMENT 'Timestamp of change',
`user_id` bigint(255) unsigned NOT NULL COMMENT 'User ID',
`username_new` varchar(255) COLLATE utf8_bin NOT NULL COMMENT 'New username',
`username_new_clean` varchar(255) COLLATE utf8_bin NOT NULL COMMENT 'Clean new username',
`username_old` varchar(255) COLLATE utf8_bin NOT NULL COMMENT 'Old username',
`username_old_clean` varchar(255) COLLATE utf8_bin NOT NULL COMMENT 'Clean old username',
PRIMARY KEY (`change_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
DROP TABLE IF EXISTS `sakura_users`; DROP TABLE IF EXISTS `sakura_users`;
CREATE TABLE `sakura_users` ( CREATE TABLE `sakura_users` (
`id` bigint(255) unsigned NOT NULL AUTO_INCREMENT COMMENT 'Automatically generated ID by MySQL for management. ', `id` bigint(255) unsigned NOT NULL AUTO_INCREMENT COMMENT 'Automatically generated ID by MySQL for management. ',
@ -362,8 +389,7 @@ CREATE TABLE `sakura_users` (
`usertitle` varchar(64) COLLATE utf8_bin DEFAULT NULL COMMENT 'Custom user title of the user, when empty reverts to their derault group name.', `usertitle` varchar(64) COLLATE utf8_bin DEFAULT NULL COMMENT 'Custom user title of the user, when empty reverts to their derault group name.',
`regdate` int(11) unsigned NOT NULL DEFAULT '0' COMMENT 'Timestamp of account creation.', `regdate` int(11) unsigned NOT NULL DEFAULT '0' COMMENT 'Timestamp of account creation.',
`lastdate` int(11) unsigned NOT NULL DEFAULT '0' COMMENT 'Last time anything was done on this account.', `lastdate` int(11) unsigned NOT NULL DEFAULT '0' COMMENT 'Last time anything was done on this account.',
`lastunamechange` int(11) unsigned NOT NULL DEFAULT '0' COMMENT 'Last username change.', `birthday` date NOT NULL COMMENT 'Birthdate of the user.',
`birthday` date DEFAULT NOT NULL COMMENT 'Birthdate of the user.',
`country` char(2) COLLATE utf8_bin NOT NULL COMMENT 'Contains ISO 3166 country code of user''s registration location.', `country` char(2) COLLATE utf8_bin NOT NULL COMMENT 'Contains ISO 3166 country code of user''s registration location.',
`userData` text COLLATE utf8_bin COMMENT 'All additional profile data.', `userData` text COLLATE utf8_bin COMMENT 'All additional profile data.',
PRIMARY KEY (`id`), PRIMARY KEY (`id`),
@ -387,4 +413,4 @@ CREATE TABLE `sakura_warnings` (
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin; ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
-- 2015-09-06 14:14:33 -- 2015-09-23 20:45:04

View file

@ -178,14 +178,14 @@ if (isset($_REQUEST['mode'])) {
'INCORRECT_PASSWORD' => 'The password you entered was invalid.', 'INCORRECT_PASSWORD' => 'The password you entered was invalid.',
'NOT_ALLOWED' => 'Your account does not have the required permissions to log in.', 'NOT_ALLOWED' => 'Your account does not have the required permissions to log in.',
'NO_LOGIN' => 'Logging into this account is disabled.', 'NO_LOGIN' => 'Logging into this account is disabled.',
'LOGIN_SUCESS' => 'Login successful!', 'LOGIN_SUCCESS' => 'Login successful!',
]; ];
// Add page specific things // Add page specific things
$renderData['page'] = [ $renderData['page'] = [
'redirect' => $login[0] ? $_REQUEST['redirect'] : $urls->format('SITE_LOGIN'), 'redirect' => $login[0] ? ((new User($login[2]))->data['lastdate'] ? $_REQUEST['redirect'] : $urls->format('INFO_PAGE', ['welcome'])) : $urls->format('SITE_LOGIN'),
'message' => $messages[$login[1]], 'message' => $messages[$login[1]],
'success' => $login[0], 'success' => $login[0],

View file

@ -334,6 +334,17 @@ a.default:active {
padding-bottom: 5px; padding-bottom: 5px;
} }
@media (max-width: 1024px) {
.ajax-busy {
background: rgba(0, 0, 0, .8);
}
.ajax-busy .ajax-inner {
background: transparent;
box-shadow: 0 0 0 transparent;
}
}
.homepage .content-right ul { .homepage .content-right ul {
margin: 10px 0; margin: 10px 0;
margin-left: 30px; margin-left: 30px;

View file

@ -600,7 +600,7 @@ function submitPostHandler(result, busyView, resetCaptchaOnFailure) {
} }
// If request reset the recaptcha on failure // If request reset the recaptcha on failure
if(resetCaptchaOnFailure && result[1] != '1' && sakuraVars.recaptchaEnabled) { if(resetCaptchaOnFailure && result[1] != '1' && sakuraVars.recaptchaEnabled != '0') {
grecaptcha.reset(); grecaptcha.reset();

View file

@ -680,6 +680,44 @@ if (isset($_REQUEST['request-notifications']) && $_REQUEST['request-notification
break; break;
// Username changing
case 'username':
// Check permissions
if (!$currentUser->checkPermission('SITE', 'CHANGE_USERNAME')) {
$renderData['page'] = [
'redirect' => $redirect,
'message' => 'You aren\'t allowed to change your username.',
'success' => 0,
];
break;
}
// Attempt username change
$userNameChange = $currentUser->setUsername(isset($_POST['username']) ? $_POST['username'] : '');
// Messages
$messages = [
'TOO_SHORT' => 'Your new name is too short!',
'TOO_LONG' => 'Your new name is too long!',
'TOO_RECENT' => 'The username you tried to use is reserved, try again later.',
'IN_USE' => 'Someone already has this username!',
'SUCCESS' => 'Successfully changed your username!',
];
// Set render data
$renderData['page'] = [
'redirect' => $redirect,
'message' => $messages[$userNameChange[1]],
'success' => $userNameChange[0],
];
break;
// Userpage // Userpage
/*case 'userpage': /*case 'userpage':
@ -1211,7 +1249,7 @@ if (Users::checkLogin()) {
// Username changing // Username changing
case 'account.username': case 'account.username':
$renderData['difference'] = Main::timeElapsed($currentUser->data['lastunamechange']); $renderData['difference'] = $currentUser->getUsernameHistory() ? Main::timeElapsed($currentUser->getUsernameHistory()[0]['change_time']) : 0;
break; break;
} }