A few urgent bug fixes.

This commit is contained in:
flash 2015-04-27 15:13:52 +00:00
parent 4039201e7a
commit 5e13f91f3f
9 changed files with 98 additions and 21 deletions

View file

@ -8,7 +8,8 @@
"builds": [ "builds": [
"20150427" "20150427",
"20150427.1"
] ]
@ -672,6 +673,35 @@
"change": "Fix chat redirect." "change": "Fix chat redirect."
} }
],
"20150427.1": [
{
"type": "FIX",
"change": "Fixed bug in registration process causing a PDO Exception."
},
{
"type": "FIX",
"change": "Fixed bug in rank checking (e.g. system saying that you're activated and deactivated at the same time)."
},
{
"type": "FIX",
"change": "Fixed the enter substitute not working on some forms."
},
{
"type": "FIX",
"change": "Fixed activation system assigning incorrect rank after clicking the link."
},
{
"type": "FIX",
"change": "Fixed off-site account links being displayed to guests."
},
{
"type": "FIX",
"change": "Fixed /u/[username] not working."
}
] ]
} }

View file

@ -0,0 +1,12 @@
<?php
/*
* Sock Chat extensions
*/
namespace Sakura;
class SockChat {
}

View file

@ -33,7 +33,7 @@ class Users {
'lastunamechange' => 0, 'lastunamechange' => 0,
'birthday' => '', 'birthday' => '',
'country' => 'EU', 'country' => 'EU',
'profile_data' => '' 'profile_data' => '[]'
]; ];
// Empty rank template // Empty rank template
@ -127,7 +127,7 @@ class Users {
} }
// Check if the user is deactivated // Check if the user is deactivated
if(in_array(1, json_decode($userData['ranks'], true)) || in_array(0, json_decode($userData['ranks'], true)) || $userData['rank_main'] < 2) if(self::checkIfUserHasRanks([0, 1], $user, true))
return [0, 'DEACTIVATED']; return [0, 'DEACTIVATED'];
// Create a new session // Create a new session
@ -247,7 +247,7 @@ class Users {
'lastdate' => 0, 'lastdate' => 0,
'lastunamechange' => time(), 'lastunamechange' => time(),
'country' => Main::getCountryCode(), 'country' => Main::getCountryCode(),
'profile_data' => '' 'profile_data' => '[]'
]); ]);
// Get userid of the new user // Get userid of the new user
@ -296,7 +296,7 @@ class Users {
return [0, 'USER_NOT_EXIST']; return [0, 'USER_NOT_EXIST'];
// Check if the user is deactivated // Check if the user is deactivated
if(in_array(1, json_decode($user['ranks'], true)) || in_array(0, json_decode($user['ranks'], true)) || $user['rank_main'] < 2) if(self::checkIfUserHasRanks([0, 1], $user, true))
return [0, 'DEACTIVATED']; return [0, 'DEACTIVATED'];
// Generate the verification key // Generate the verification key
@ -338,7 +338,7 @@ class Users {
$user = Users::getUser(Session::$userId); $user = Users::getUser(Session::$userId);
// Check if the user is deactivated // Check if the user is deactivated
if(in_array(1, json_decode($user['ranks'], true)) || in_array(0, json_decode($user['ranks'], true)) || $user['rank_main'] < 2) if(self::checkIfUserHasRanks([0, 1], $user, true))
return [0, 'DEACTIVATED']; return [0, 'DEACTIVATED'];
// Check if the account is disabled // Check if the account is disabled
@ -447,7 +447,7 @@ class Users {
return [0, 'USER_NOT_EXIST']; return [0, 'USER_NOT_EXIST'];
// Check if a user is activated // Check if a user is activated
if(!in_array(1, json_decode($user['ranks'], true)) || !in_array(0, json_decode($user['ranks'], true)) || $user['rank_main'] > 1) if(!self::checkIfUserHasRanks([0, 1], $user, true))
return [0, 'USER_ALREADY_ACTIVE']; return [0, 'USER_ALREADY_ACTIVE'];
// Send activation e-mail // Send activation e-mail
@ -465,14 +465,14 @@ class Users {
$user = Database::fetch('users', false, ['id' => [$uid, '=']]); $user = Database::fetch('users', false, ['id' => [$uid, '=']]);
// User is already activated or doesn't even exist // User is already activated or doesn't even exist
if(count($user) < 2 || (!in_array(1, json_decode($user['ranks'], true)) || !in_array(0, json_decode($user['ranks'], true))) || $user['rank_main'] > 1) if(count($user) < 2 || !self::checkIfUserHasRanks([0, 1], $user, true))
return false; return false;
// Generate activation key // Generate activation key
$activate = ($customKey ? $customKey : Main::newActionCode('ACTIVATE', $uid, [ $activate = ($customKey ? $customKey : Main::newActionCode('ACTIVATE', $uid, [
'user' => [ 'user' => [
'rank_main' => 1, 'rank_main' => 2,
'ranks' => json_encode([1]) 'ranks' => json_encode([2])
] ]
])); ]));
@ -509,7 +509,7 @@ class Users {
return [0, 'USER_NOT_EXIST']; return [0, 'USER_NOT_EXIST'];
// Check if user is already activated // Check if user is already activated
if(!in_array(1, json_decode($user['ranks'], true)) || !in_array(0, json_decode($user['ranks'], true)) || $user['rank_main'] > 1) if(!self::checkIfUserHasRanks([0, 1], $user, true))
return [0, 'USER_ALREADY_ACTIVE']; return [0, 'USER_ALREADY_ACTIVE'];
// Set default values for activation // Set default values for activation
@ -560,14 +560,14 @@ class Users {
return [0, 'USER_NOT_EXIST']; return [0, 'USER_NOT_EXIST'];
// Check if user is already deactivated // Check if user is already deactivated
if(!$user['rank_main']) if(self::checkIfUserHasRanks([0, 1], $user, true))
return [0, 'USER_ALREADY_DEACTIVE']; return [0, 'USER_ALREADY_DEACTIVE'];
// Deactivate the account // Deactivate the account
Database::update('users', [ Database::update('users', [
[ [
'rank_main' => 1, 'rank_main' => 2,
'ranks' => json_encode([1]) 'ranks' => json_encode([2])
], ],
[ [
'id' => [$uid, '='] 'id' => [$uid, '=']
@ -640,6 +640,30 @@ class Users {
} }
// Check if a user has these ranks
public static function checkIfUserHasRanks($ranks, $userid, $userIdIsUserData = false) {
// Get the specified user
$user = $userIdIsUserData ? $userid : self::getUser($userid);
// Check if the main rank is the specified rank
if(in_array($user['rank_main'], $ranks))
return true;
// If not go over all ranks and check if the user has them
foreach($ranks as $rank) {
// We check if $rank is in $user['ranks'] and if yes return true
if(in_array($rank, $user['ranks']))
return true;
}
// If all fails return false
return false;
}
// Check if a user exists // Check if a user exists
public static function userExists($user, $id = true) { public static function userExists($user, $id = true) {

View file

@ -14,6 +14,7 @@ $sakuraConf['db']['database'] = 'sakura'; // Database name
$sakuraConf['db']['prefix'] = 'sakura_'; // Table Prefix $sakuraConf['db']['prefix'] = 'sakura_'; // Table Prefix
// URLs (for modularity) // URLs (for modularity)
$sakuraConf['urls'] = array();
$sakuraConf['urls']['main'] = 'flashii.net'; // Main site url $sakuraConf['urls']['main'] = 'flashii.net'; // Main site url
$sakuraConf['urls']['api'] = 'api.flashii.net'; // API url $sakuraConf['urls']['api'] = 'api.flashii.net'; // API url
$sakuraConf['urls']['content'] = 'cdn.flashii.net'; // Content directory url $sakuraConf['urls']['content'] = 'cdn.flashii.net'; // Content directory url
@ -21,6 +22,12 @@ $sakuraConf['urls']['chat'] = 'chat.flashii.net'; // Chat url
$sakuraConf['urls']['manage'] = 'manage.flashii.net'; // Moderator panel url $sakuraConf['urls']['manage'] = 'manage.flashii.net'; // Moderator panel url
// Errata // Errata
$sakuraConf['etc'] = array();
$sakuraConf['etc']['cfhosts'] = ROOT .'_sakura/config/cloudflare.hosts'; // Cloudflare IP subnets file $sakuraConf['etc']['cfhosts'] = ROOT .'_sakura/config/cloudflare.hosts'; // Cloudflare IP subnets file
$sakuraConf['etc']['whoisservers'] = ROOT .'_sakura/config/whois.json'; // JSON with Whois servers $sakuraConf['etc']['whoisservers'] = ROOT .'_sakura/config/whois.json'; // JSON with Whois servers
$sakuraConf['etc']['iso3166'] = ROOT .'_sakura/config/iso3166.json'; // JSON with country codes $sakuraConf['etc']['iso3166'] = ROOT .'_sakura/config/iso3166.json'; // JSON with country codes
// Sock Chat extensions
$sakuraConf['sock'] = array();
$sakuraConf['sock']['enable'] = true; // Ability to disable the extension in case you're using Sakura without Sock Chat, mind that this extension only works when using the same database
$sakuraConf['sock']['sqlpref'] = 'sock_'; // Sock Chat table prefixes

View file

@ -2,7 +2,7 @@
</div> </div>
<div class="footer"> <div class="footer">
<div class="ftsections"> <div class="ftsections">
<div class="copycentre">Copyright &copy; 2013-2015 <a href="//flash.moe/" target="_blank">Flashwave</a>, <a href="//{{ sakura.urls.main }}/credits">et al</a></div> <div class="copycentre">Copyright &copy; 2013-2015 <a href="//flash.moe/" target="_blank">Flashwave</a>, <a href="//{{ sakura.urls.main }}/credits">et al</a>.</div>
<ul class="ftsection"> <ul class="ftsection">
<li class="fthead">General</li> <li class="fthead">General</li>
<li><a href="//{{ sakura.urls.main }}/" title="Flashii Frontpage">Home</a></li> <li><a href="//{{ sakura.urls.main }}/" title="Flashii Frontpage">Home</a></li>

View file

@ -91,12 +91,12 @@
var form = document.getElementById(i); var form = document.getElementById(i);
var submit = form.querySelector('[type="submit"]'); var submit = form.querySelector('[type="submit"]');
form.setAttribute('onkeydown', 'formEnterCatch(event, \''+ submit.id +'\');');
submit.setAttribute('href', 'javascript:void(0);'); submit.setAttribute('href', 'javascript:void(0);');
submit.setAttribute('onclick', 'submitPost(\''+ i +'\', true, \''+ forms[i] +'\');'); submit.setAttribute('onclick', 'submitPost(\''+ i +'\', true, \''+ forms[i] +'\');');
submit.setAttribute('type', 'button'); submit.setAttribute('type', 'button');
form.setAttribute('onkeydown', 'formEnterCatch(event, \''+ submit.id +'\');');
var createInput = document.createElement('input'); var createInput = document.createElement('input');
createInput.setAttribute('name', 'ajax'); createInput.setAttribute('name', 'ajax');
createInput.setAttribute('value', 'true'); createInput.setAttribute('value', 'true');

View file

@ -55,7 +55,7 @@
<input class="inputStyling" type="text" id="forgotEmail" name="email" /> <input class="inputStyling" type="text" id="forgotEmail" name="email" />
</div> </div>
<div class="centreAlign"> <div class="centreAlign">
<input class="inputStyling" type="submit" name="submit" value="Request Password" /> <input class="inputStyling" type="submit" name="submit" value="Request Password" id="requestPassBtn" />
</div> </div>
<div class="subLinks centreAlign"> <div class="subLinks centreAlign">
If you lost access to the e-mail address you registered with then there's not much we can do, it's your own responsibility to keep track of it and attaching a working one to your account. If you lost access to the e-mail address you registered with then there's not much we can do, it's your own responsibility to keep track of it and attaching a working one to your account.
@ -130,7 +130,7 @@
<input class="inputStyling" name="tos" type="checkbox" class="ignore-css" id="registerToS" /><label for="registerToS">I agree to the <a class="default" href="/r/terms" target="_blank">Terms of Service</a>. <input class="inputStyling" name="tos" type="checkbox" class="ignore-css" id="registerToS" /><label for="registerToS">I agree to the <a class="default" href="/r/terms" target="_blank">Terms of Service</a>.
</div> </div>
<div class="centreAlign"> <div class="centreAlign">
<input class="inputStyling" type="submit" name="submit" value="Register" /> <input class="inputStyling" type="submit" name="submit" value="Register" id="registerAccBtn" />
</div> </div>
</form> </form>
{% if auth.blockRegister.do %} {% if auth.blockRegister.do %}
@ -179,7 +179,7 @@
<input class="inputStyling" type="text" id="activeEmail" name="email" /> <input class="inputStyling" type="text" id="activeEmail" name="email" />
</div> </div>
<div class="centreAlign"> <div class="centreAlign">
<input class="inputStyling" type="submit" name="submit" value="Request Activation" /> <input class="inputStyling" type="submit" name="submit" value="Request Activation" id="requestActiveBtn" />
</div> </div>
<div class="subLinks centreAlign"> <div class="subLinks centreAlign">
Read the footnote on the Lost Password form. Read the footnote on the Lost Password form.

View file

@ -23,6 +23,7 @@
<b>Last Seen on</b> {{ profile.user.lastdate|date("l Y-m-d H:i T") }} <b>Last Seen on</b> {{ profile.user.lastdate|date("l Y-m-d H:i T") }}
{% if profile.data is not null %} {% if profile.data is not null %}
<hr class="default" /> <hr class="default" />
{% if user.loggedin %}
<table style="width: 100%;"> <table style="width: 100%;">
{% for name,field in profile.data %} {% for name,field in profile.data %}
<tr> <tr>
@ -45,6 +46,9 @@
</tr> </tr>
{% endfor %} {% endfor %}
</table> </table>
{% else %}
<b>Log in to view the full profile!</b>
{% endif %}
{% endif %} {% endif %}
<hr class="default" /> <hr class="default" />
<b>Account Standing</b> <b>Account Standing</b>

View file

@ -26,7 +26,7 @@ if(isset($_GET['u'])) {
$renderData['profile'] = [ $renderData['profile'] = [
'notset' => false, 'notset' => false,
'user' => ($_PROFILE_USER_DATA = Users::getUser($_GET['u'])), 'user' => ($_PROFILE_USER_DATA = Users::getUser(($_USER_USERNAME_ID = Users::userExists($_GET['u'], false)) ? $_USER_USERNAME_ID : $_GET['u'])),
'rank' => ($_PROFILE_RANK_DATA = Users::getRank($_PROFILE_USER_DATA['rank_main'])), 'rank' => ($_PROFILE_RANK_DATA = Users::getRank($_PROFILE_USER_DATA['rank_main'])),
'colour' => ($_PROFILE_USER_DATA['name_colour'] == null ? $_PROFILE_RANK_DATA['colour'] : $_PROFILE_USER_DATA['name_colour']), 'colour' => ($_PROFILE_USER_DATA['name_colour'] == null ? $_PROFILE_RANK_DATA['colour'] : $_PROFILE_USER_DATA['name_colour']),
'ranktitle' => ($_PROFILE_USER_DATA['usertitle'] == null ? $_PROFILE_RANK_DATA['title'] : $_PROFILE_USER_DATA['usertitle']), 'ranktitle' => ($_PROFILE_USER_DATA['usertitle'] == null ? $_PROFILE_RANK_DATA['title'] : $_PROFILE_USER_DATA['usertitle']),