diff --git a/_sakura/changelog.json b/_sakura/changelog.json index 32a8c7d..a507ee4 100644 --- a/_sakura/changelog.json +++ b/_sakura/changelog.json @@ -8,7 +8,8 @@ "builds": [ - "20150427" + "20150427", + "20150427.1" ] @@ -672,6 +673,35 @@ "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." + } + ] } diff --git a/_sakura/components/SockChat.php b/_sakura/components/SockChat.php new file mode 100644 index 0000000..4be539f --- /dev/null +++ b/_sakura/components/SockChat.php @@ -0,0 +1,12 @@ + 0, 'birthday' => '', 'country' => 'EU', - 'profile_data' => '' + 'profile_data' => '[]' ]; // Empty rank template @@ -127,7 +127,7 @@ class Users { } // 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']; // Create a new session @@ -247,7 +247,7 @@ class Users { 'lastdate' => 0, 'lastunamechange' => time(), 'country' => Main::getCountryCode(), - 'profile_data' => '' + 'profile_data' => '[]' ]); // Get userid of the new user @@ -296,7 +296,7 @@ class Users { return [0, 'USER_NOT_EXIST']; // 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']; // Generate the verification key @@ -338,7 +338,7 @@ class Users { $user = Users::getUser(Session::$userId); // 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']; // Check if the account is disabled @@ -447,7 +447,7 @@ class Users { return [0, 'USER_NOT_EXIST']; // 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']; // Send activation e-mail @@ -465,14 +465,14 @@ class Users { $user = Database::fetch('users', false, ['id' => [$uid, '=']]); // 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; // Generate activation key $activate = ($customKey ? $customKey : Main::newActionCode('ACTIVATE', $uid, [ 'user' => [ - 'rank_main' => 1, - 'ranks' => json_encode([1]) + 'rank_main' => 2, + 'ranks' => json_encode([2]) ] ])); @@ -509,7 +509,7 @@ class Users { return [0, 'USER_NOT_EXIST']; // 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']; // Set default values for activation @@ -560,14 +560,14 @@ class Users { return [0, 'USER_NOT_EXIST']; // Check if user is already deactivated - if(!$user['rank_main']) + if(self::checkIfUserHasRanks([0, 1], $user, true)) return [0, 'USER_ALREADY_DEACTIVE']; // Deactivate the account Database::update('users', [ [ - 'rank_main' => 1, - 'ranks' => json_encode([1]) + 'rank_main' => 2, + 'ranks' => json_encode([2]) ], [ '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 public static function userExists($user, $id = true) { diff --git a/_sakura/config/config.example.php b/_sakura/config/config.example.php index 4939615..6c79db5 100644 --- a/_sakura/config/config.example.php +++ b/_sakura/config/config.example.php @@ -14,6 +14,7 @@ $sakuraConf['db']['database'] = 'sakura'; // Database name $sakuraConf['db']['prefix'] = 'sakura_'; // Table Prefix // URLs (for modularity) +$sakuraConf['urls'] = array(); $sakuraConf['urls']['main'] = 'flashii.net'; // Main site url $sakuraConf['urls']['api'] = 'api.flashii.net'; // API 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 // Errata +$sakuraConf['etc'] = array(); $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']['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 diff --git a/_sakura/templates/yuuno/global/footer.tpl b/_sakura/templates/yuuno/global/footer.tpl index 28eacf6..0868a50 100644 --- a/_sakura/templates/yuuno/global/footer.tpl +++ b/_sakura/templates/yuuno/global/footer.tpl @@ -2,7 +2,7 @@