Registration and activation works
This commit is contained in:
parent
f4ed101874
commit
69c0dd651b
8 changed files with 405 additions and 119 deletions
|
@ -5,9 +5,20 @@ SET time_zone = '+00:00';
|
|||
SET foreign_key_checks = 0;
|
||||
SET sql_mode = 'NO_AUTO_VALUE_ON_ZERO';
|
||||
|
||||
DROP DATABASE IF EXISTS `flashiidev`;
|
||||
CREATE DATABASE `flashiidev` /*!40100 DEFAULT CHARACTER SET utf8 COLLATE utf8_bin */;
|
||||
USE `flashiidev`;
|
||||
DROP DATABASE IF EXISTS `sakura`;
|
||||
CREATE DATABASE `sakura` /*!40100 DEFAULT CHARACTER SET utf8 COLLATE utf8_bin */;
|
||||
USE `sakura`;
|
||||
|
||||
DROP TABLE IF EXISTS `fii_actioncodes`;
|
||||
CREATE TABLE `fii_actioncodes` (
|
||||
`id` bigint(255) NOT NULL AUTO_INCREMENT COMMENT 'Automatically generated ID by MySQL for management.',
|
||||
`action` varchar(255) COLLATE utf8_bin NOT NULL COMMENT 'Action identifier so the backend knows what to do.',
|
||||
`userid` bigint(255) NOT NULL COMMENT 'ID of the user that would be affected by this action',
|
||||
`actkey` varchar(255) COLLATE utf8_bin NOT NULL COMMENT 'The URL key for using this code.',
|
||||
`instruction` varchar(255) COLLATE utf8_bin NOT NULL COMMENT 'Things the backend should do upon using this code',
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
|
||||
|
||||
|
||||
DROP TABLE IF EXISTS `fii_apikeys`;
|
||||
CREATE TABLE `fii_apikeys` (
|
||||
|
@ -39,6 +50,34 @@ CREATE TABLE `fii_config` (
|
|||
`config_value` varchar(255) COLLATE utf8_bin NOT NULL COMMENT 'The value, obviously.'
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
|
||||
|
||||
TRUNCATE `fii_config`;
|
||||
INSERT INTO `fii_config` (`config_name`, `config_value`) VALUES
|
||||
('recaptcha_public', ''),
|
||||
('recaptcha_private', ''),
|
||||
('charset', 'utf-8'),
|
||||
('cookie_prefix', ''),
|
||||
('cookie_domain', ''),
|
||||
('cookie_path', '/'),
|
||||
('site_style', 'yuuno'),
|
||||
('manage_style', 'Manage'),
|
||||
('allow_registration', '0'),
|
||||
('smtp_server', ''),
|
||||
('smtp_auth', ''),
|
||||
('smtp_secure', ''),
|
||||
('smtp_port', ''),
|
||||
('smtp_username', ''),
|
||||
('smtp_password', ''),
|
||||
('smtp_replyto_mail', ''),
|
||||
('smtp_replyto_name', ''),
|
||||
('smtp_from_email', ''),
|
||||
('smtp_from_name', 'Sakura Noreply'),
|
||||
('sitename', 'Sakura'),
|
||||
('recaptcha', '1'),
|
||||
('require_activation', '1'),
|
||||
('require_registration_code', '0'),
|
||||
('disable_registration', '1'),
|
||||
('max_reg_keys', '5'),
|
||||
('mail_signature', 'Team Flashii');
|
||||
|
||||
DROP TABLE IF EXISTS `fii_infopages`;
|
||||
CREATE TABLE `fii_infopages` (
|
||||
|
@ -83,6 +122,7 @@ CREATE TABLE `fii_profilefields` (
|
|||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=12 DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
|
||||
|
||||
TRUNCATE `fii_profilefields`;
|
||||
INSERT INTO `fii_profilefields` (`id`, `name`, `formtype`, `description`, `additional`) VALUES
|
||||
(1, 'Website', 'url', 'URL to your website', ''),
|
||||
(2, 'Twitter', 'text', 'Your @twitter Username', ''),
|
||||
|
@ -94,8 +134,7 @@ INSERT INTO `fii_profilefields` (`id`, `name`, `formtype`, `description`, `addit
|
|||
(8, 'osu!', 'text', 'Your osu! Username', ''),
|
||||
(9, 'Origin', 'text', 'Your Origin User ID', ''),
|
||||
(10, 'Xbox Live', 'text', 'Your Xbox User ID', ''),
|
||||
(11, 'PSN', 'text', 'Your PSN User ID', '')
|
||||
ON DUPLICATE KEY UPDATE `id` = VALUES(`id`), `name` = VALUES(`name`), `formtype` = VALUES(`formtype`), `description` = VALUES(`description`), `additional` = VALUES(`additional`);
|
||||
(11, 'PSN', 'text', 'Your PSN User ID', '');
|
||||
|
||||
DROP TABLE IF EXISTS `fii_ranks`;
|
||||
CREATE TABLE `fii_ranks` (
|
||||
|
@ -108,6 +147,7 @@ CREATE TABLE `fii_ranks` (
|
|||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=10 DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
|
||||
|
||||
TRUNCATE `fii_ranks`;
|
||||
INSERT INTO `fii_ranks` (`id`, `name`, `multi`, `colour`, `description`, `title`) VALUES
|
||||
(1, 'Deactivated', 0, '#555', 'Users that are yet to be activated or that deactivated their own account.', 'Deactivated'),
|
||||
(2, 'Regular user', 1, 'inherit', 'Regular users with regular permissions.', 'Regular user'),
|
||||
|
@ -117,8 +157,7 @@ INSERT INTO `fii_ranks` (`id`, `name`, `multi`, `colour`, `description`, `title`
|
|||
(6, 'Bot', 1, '#9E8DA7', 'Reserved user accounts for services.', 'Bot'),
|
||||
(7, 'Chat moderator', 1, '#09F', 'Moderators of the chat room.', 'Staff'),
|
||||
(8, 'Tenshi', 0, '#EE9400', 'Users that donated $5.00 or more in order to keep the site and it\'s services alive!', 'Tenshi'),
|
||||
(9, 'Alumnii', 0, '#FF69B4', 'People who have contributed to the community but have moved on or resigned.', 'Alumnii')
|
||||
ON DUPLICATE KEY UPDATE `id` = VALUES(`id`), `name` = VALUES(`name`), `multi` = VALUES(`multi`), `colour` = VALUES(`colour`), `description` = VALUES(`description`), `title` = VALUES(`title`);
|
||||
(9, 'Alumnii', 0, '#FF69B4', 'People who have contributed to the community but have moved on or resigned.', 'Alumnii');
|
||||
|
||||
DROP TABLE IF EXISTS `fii_regcodes`;
|
||||
CREATE TABLE `fii_regcodes` (
|
||||
|
@ -128,7 +167,7 @@ CREATE TABLE `fii_regcodes` (
|
|||
`used_by` bigint(128) unsigned NOT NULL COMMENT 'ID of user who used this code.',
|
||||
`key_used` tinyint(1) unsigned NOT NULL COMMENT 'Boolean for setting this key as used.',
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
|
||||
|
||||
|
||||
DROP TABLE IF EXISTS `fii_sessions`;
|
||||
|
@ -142,7 +181,7 @@ CREATE TABLE `fii_sessions` (
|
|||
`expire` int(64) 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.',
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=18 DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
|
||||
|
||||
|
||||
DROP TABLE IF EXISTS `fii_tenshi`;
|
||||
|
@ -184,7 +223,7 @@ CREATE TABLE `fii_users` (
|
|||
`profile_data` text COLLATE utf8_bin NOT NULL COMMENT 'Modular array containing profile data.',
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE KEY `username_clean` (`username_clean`)
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
|
||||
|
||||
|
||||
DROP TABLE IF EXISTS `fii_warnings`;
|
||||
|
@ -199,4 +238,4 @@ CREATE TABLE `fii_warnings` (
|
|||
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
|
||||
|
||||
|
||||
-- 2015-04-13 10:06:13
|
||||
-- 2015-04-19 12:58:09
|
||||
|
|
|
@ -243,8 +243,8 @@ class Main {
|
|||
// Validate MX records
|
||||
public static function checkMXRecord($email) {
|
||||
|
||||
// Split up the address in two parts (user and domain)
|
||||
list($user, $domain) = split('@', $email);
|
||||
// Get the domain from the e-mail address
|
||||
$domain = substr(strstr($email, '@'), 1);
|
||||
|
||||
// Check the MX record
|
||||
$record = checkdnsrr($domain, 'MX');
|
||||
|
@ -407,4 +407,61 @@ class Main {
|
|||
|
||||
}
|
||||
|
||||
// Create a new action code
|
||||
public static function newActionCode($action, $userid, $instruct) {
|
||||
|
||||
// Make sure the user we're working with exists
|
||||
if(Users::getUser($userid)['id'] == 0)
|
||||
return false;
|
||||
|
||||
// Convert the instruction array to a JSON
|
||||
$instruct = json_encode($instruct);
|
||||
|
||||
// Generate a key
|
||||
$key = sha1(date("r") . time() . $userid . $action . rand(0, 9999));
|
||||
|
||||
// Insert the key into the database
|
||||
Database::insert('actioncodes', [
|
||||
'action' => $action,
|
||||
'userid' => $userid,
|
||||
'actkey' => $key,
|
||||
'instruction' => $instruct
|
||||
]);
|
||||
|
||||
// Return the key
|
||||
return $key;
|
||||
|
||||
}
|
||||
|
||||
// Use an action code
|
||||
public static function useActionCode($action, $key, $uid = 0) {
|
||||
|
||||
// Retrieve the row from the database
|
||||
$keyRow = Database::fetch('actioncodes', false, [
|
||||
'actkey' => [$key, '='],
|
||||
'action' => [$action, '=']
|
||||
]);
|
||||
|
||||
// Check if the code exists
|
||||
if(count($keyRow) <= 1)
|
||||
return [0, 'INVALID_CODE'];
|
||||
|
||||
// Check if the code was intended for the user that's using this code
|
||||
if($keyRow['userid'] != 0) {
|
||||
|
||||
if($keyRow['userid'] != $uid)
|
||||
return [0, 'INVALID_USER'];
|
||||
|
||||
}
|
||||
|
||||
// Remove the key from the database
|
||||
Database::delete('actioncodes', [
|
||||
'id' => [$keyRow['id'], '=']
|
||||
]);
|
||||
|
||||
// Return success
|
||||
return [1, 'SUCCESS', $keyRow['instruction']];
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -191,7 +191,7 @@ class Users {
|
|||
return [0, 'PASS_TOO_LONG'];
|
||||
|
||||
// Passwords do not match
|
||||
if($password != $confirmpassword)
|
||||
if($password != $confirmpass)
|
||||
return [0, 'PASS_NOT_MATCH'];
|
||||
|
||||
// Check if the given email address is formatted properly
|
||||
|
@ -254,7 +254,7 @@ class Users {
|
|||
}
|
||||
|
||||
// Send the activation e-mail and do other required stuff
|
||||
public static function sendActivationMail($uid) {
|
||||
public static function sendActivationMail($uid, $customKey = null) {
|
||||
|
||||
// Get the user data
|
||||
$user = Database::fetch('users', false, ['id' => [$uid, '=']]);
|
||||
|
@ -264,14 +264,18 @@ class Users {
|
|||
return false;
|
||||
|
||||
// Generate activation key
|
||||
// $activate = <interface with the shit for the activationkeys table here>;
|
||||
$activate = 'null';
|
||||
$activate = ($customKey ? $customKey : Main::newActionCode('ACTIVATE', $uid, [
|
||||
'user' => [
|
||||
'rank_main' => 1,
|
||||
'ranks' => json_encode([1])
|
||||
]
|
||||
]));
|
||||
|
||||
// Build the e-mail
|
||||
$message = "Welcome to ". Configuration::getConfig('sitename') ."!\r\n\r\n";
|
||||
$message .= "Please keep this e-mail for your records. Your account intormation is as follows:\r\n\r\n";
|
||||
$message .= "----------------------------\r\n\r\n";
|
||||
$message .= "Username: ". $user['username'] ."\r\n";
|
||||
$message .= "Username: ". $user['username'] ."\r\n\r\n";
|
||||
$message .= "Your profile: http://". Configuration::getLocalConfig('urls', 'main') ."/u/". $user['id'] ."\r\n\r\n";
|
||||
$message .= "----------------------------\r\n\r\n";
|
||||
$message .= "Please visit the following link in order to activate your account:\r\n\r\n";
|
||||
|
@ -289,6 +293,87 @@ class Users {
|
|||
|
||||
}
|
||||
|
||||
// Activating a user
|
||||
public static function activateUser($uid, $requireKey = false, $key = null) {
|
||||
|
||||
// Get the user data
|
||||
$user = Database::fetch('users', false, ['id' => [$uid, '=']]);
|
||||
|
||||
// Check if user exists
|
||||
if(!count($user) > 1)
|
||||
return [0, 'USER_NOT_EXIST'];
|
||||
|
||||
// Check if user is already activated
|
||||
if($user['rank_main'])
|
||||
return [0, 'USER_ALREADY_ACTIVE'];
|
||||
|
||||
// Set default values for activation
|
||||
$rank = 1;
|
||||
$ranks = json_encode([1]);
|
||||
|
||||
// Check if a key is set (there's an option to not set one for user management reasons but you can't really get around this anyway)
|
||||
if($requireKey) {
|
||||
|
||||
// Check the action code
|
||||
$action = Main::useActionCode('ACTIVATE', $key, $uid);
|
||||
|
||||
// Check if we got a negative return
|
||||
if(!$action[0])
|
||||
return [0, $action[1]];
|
||||
|
||||
// Assign the special values
|
||||
$instructionData = json_decode($action[2], true);
|
||||
$rank = $instructionData['user']['rank_main'];
|
||||
$ranks = $instructionData['user']['ranks'];
|
||||
|
||||
}
|
||||
|
||||
// Activate the account
|
||||
Database::update('users', [
|
||||
[
|
||||
'rank_main' => $rank,
|
||||
'ranks' => $ranks
|
||||
],
|
||||
[
|
||||
'id' => [$uid, '=']
|
||||
]
|
||||
]);
|
||||
|
||||
// Return success
|
||||
return [1, 'SUCCESS'];
|
||||
|
||||
}
|
||||
|
||||
// Deactivating a user
|
||||
public static function deactivateUser($uid) {
|
||||
|
||||
// Get the user data
|
||||
$user = Database::fetch('users', false, ['id' => [$uid, '=']]);
|
||||
|
||||
// Check if user exists
|
||||
if(!count($user) > 1)
|
||||
return [0, 'USER_NOT_EXIST'];
|
||||
|
||||
// Check if user is already deactivated
|
||||
if(!$user['rank_main'])
|
||||
return [0, 'USER_ALREADY_DEACTIVE'];
|
||||
|
||||
// Deactivate the account
|
||||
Database::update('users', [
|
||||
[
|
||||
'rank_main' => 0,
|
||||
'ranks' => json_encode([0])
|
||||
],
|
||||
[
|
||||
'id' => [$uid, '=']
|
||||
]
|
||||
]);
|
||||
|
||||
// Return success
|
||||
return [1, 'SUCCESS'];
|
||||
|
||||
}
|
||||
|
||||
// Check if registration code is valid
|
||||
public static function checkRegistrationCode($code) {
|
||||
|
||||
|
@ -412,15 +497,22 @@ class Users {
|
|||
}
|
||||
|
||||
// Get all users
|
||||
public static function getAllUsers() {
|
||||
public static function getAllUsers($includeInactive = true) {
|
||||
|
||||
// Execute query
|
||||
$getUsers = Database::fetch('users', true);
|
||||
|
||||
// Reorder shit
|
||||
foreach($getUsers as $user)
|
||||
foreach($getUsers as $user) {
|
||||
|
||||
// Skip if inactive and not include deactivated users
|
||||
if(!$includeInactive && $user['rank_main'] == 0)
|
||||
continue;
|
||||
|
||||
$users[$user['id']] = $user;
|
||||
|
||||
}
|
||||
|
||||
// and return an array with the users
|
||||
return $users;
|
||||
|
||||
|
|
|
@ -60,6 +60,7 @@
|
|||
</form>
|
||||
</div>
|
||||
</div>
|
||||
<div class="registerCont">
|
||||
<div class="registerForm">
|
||||
<div class="head">
|
||||
Register on Flashii
|
||||
|
@ -84,7 +85,7 @@
|
|||
<label for="registerPassword">Password:</label>
|
||||
</div>
|
||||
<div class="centreAlign">
|
||||
<input class="inputStyling" type="password" id="registerPassword" name="password" placeholder="Must be at least 5 characters." />
|
||||
<input class="inputStyling" type="password" id="registerPassword" name="password" placeholder="Must be at least 8 characters." />
|
||||
</div>
|
||||
<div class="leftAlign">
|
||||
<label for="registerConfirmPassword">Confirm Password:</label>
|
||||
|
@ -133,6 +134,35 @@
|
|||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
<div class="passwordForm">
|
||||
<div class="head">
|
||||
Resend Activation E-mail
|
||||
</div>
|
||||
<form method="post" action="http://{{ sakura.urls.main }}/authenticate">
|
||||
<input type="hidden" name="mode" value="resendactivemail" />
|
||||
<input type="hidden" name="session" value="{{ php.sessionid }}" />
|
||||
<input type="hidden" name="time" value="{{ php.time }}" />
|
||||
<div class="leftAlign">
|
||||
<label for="activeUserName">Username:</label>
|
||||
</div>
|
||||
<div class="centreAlign">
|
||||
<input class="inputStyling" type="text" id="activeUserName" name="username" />
|
||||
</div>
|
||||
<div class="leftAlign">
|
||||
<label for="activeEmail">E-mail:</label>
|
||||
</div>
|
||||
<div class="centreAlign">
|
||||
<input class="inputStyling" type="text" id="activeEmail" name="email" />
|
||||
</div>
|
||||
<div class="centreAlign">
|
||||
<input class="inputStyling" type="submit" name="submit" value="Request Activation" />
|
||||
</div>
|
||||
<div class="subLinks centreAlign">
|
||||
If you lost access to your e-mail address please <a href="/contact" class="default" target="_blank">contact us</a>.
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
<div class="clear"></div>
|
||||
</div>
|
||||
{% include 'global/footer.tpl' %}
|
||||
|
|
|
@ -532,7 +532,7 @@ a.gotop:active {
|
|||
border-radius: 2px;
|
||||
}
|
||||
.content-right .head,
|
||||
.loginPage > .registerForm .head {
|
||||
.loginPage > .registerCont .head {
|
||||
margin: -1px -2px -1px;
|
||||
padding: 4px 5px 5px;
|
||||
font-weight: 700;
|
||||
|
@ -1100,7 +1100,7 @@ textarea.inputStyling {
|
|||
margin: 0 auto;
|
||||
max-width: 825px;
|
||||
}
|
||||
.loginPage > .registerForm,
|
||||
.loginPage > .registerCont > *,
|
||||
.loginPage > .loginCont > * {
|
||||
text-align: center;
|
||||
border: 1px solid #9475B2;
|
||||
|
@ -1113,7 +1113,7 @@ textarea.inputStyling {
|
|||
background: #D3BFFF;
|
||||
}
|
||||
@media (max-width: 430px) {
|
||||
.loginPage > .registerForm,
|
||||
.loginPage > .registerCont > *,
|
||||
.loginPage > .loginCont > * {
|
||||
width: 300px;
|
||||
}
|
||||
|
@ -1121,14 +1121,14 @@ textarea.inputStyling {
|
|||
.loginPage > .loginCont {
|
||||
float: left;
|
||||
}
|
||||
.loginPage > .registerForm {
|
||||
.loginPage > .registerCont {
|
||||
float: right;
|
||||
}
|
||||
@media (max-width: 820px) {
|
||||
.loginPage > .loginCont {
|
||||
float: none;
|
||||
}
|
||||
.loginPage > .registerForm {
|
||||
.loginPage > .registerCont {
|
||||
float: none;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,7 +17,7 @@ Options +FollowSymLinks -Indexes
|
|||
RewriteRule ^feedback?/?$ http://forum.flash.moe/viewforum.php?f=22
|
||||
RewriteRule ^credits?/?$ credits.php
|
||||
RewriteRule ^index?/?$ index.php
|
||||
RewriteRule ^login?/?$|logout?/?$|register?/?$|forgotpassword?/?|authenticate?/?$ authenticate.php
|
||||
RewriteRule ^login?/?$|logout?/?$|activate?/?$|register?/?$|forgotpassword?/?|authenticate?/?$ authenticate.php
|
||||
RewriteRule ^donate?/?$ donate.php
|
||||
RewriteRule ^contact?/?$ contact.php
|
||||
|
||||
|
|
|
@ -11,14 +11,15 @@ require_once str_replace(basename(__DIR__), '', dirname(__FILE__)) .'_sakura/sak
|
|||
|
||||
// Page actions
|
||||
if(
|
||||
isset($_REQUEST['mode']) &&
|
||||
isset($_REQUEST['time']) &&
|
||||
isset($_REQUEST['session'])
|
||||
isset($_REQUEST['mode'])
|
||||
) {
|
||||
|
||||
// Continue
|
||||
$continue = true;
|
||||
|
||||
// Make sure we're not in activate mode since adding a timestamp and accessing the PHP session id is kind of hard when you're in an e-mail client
|
||||
if(!isset($_REQUEST['mode']) || $_REQUEST['mode'] != 'activate') {
|
||||
|
||||
// Compare time and session so we know the link isn't forged
|
||||
if($_REQUEST['time'] < time() - 1000) {
|
||||
|
||||
|
@ -34,7 +35,7 @@ if(
|
|||
}
|
||||
|
||||
// Match session ids for the same reason
|
||||
if($_REQUEST['session'] != session_id()) {
|
||||
if(!isset($_REQUEST['session']) || $_REQUEST['session'] != session_id()) {
|
||||
|
||||
$renderData['page'] = [
|
||||
'title' => 'Action failed',
|
||||
|
@ -47,6 +48,8 @@ if(
|
|||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Login check
|
||||
if(Users::checkLogin()) {
|
||||
|
||||
|
@ -55,7 +58,6 @@ if(
|
|||
|
||||
}
|
||||
|
||||
|
||||
if($continue) {
|
||||
switch($_REQUEST['mode']) {
|
||||
|
||||
|
@ -73,6 +75,35 @@ if(
|
|||
|
||||
break;
|
||||
|
||||
// Activating accounts
|
||||
case 'activate':
|
||||
|
||||
// Attempt activation
|
||||
$activate = Users::activateUser($_REQUEST['u'], true, $_REQUEST['k']);
|
||||
|
||||
// Array containing "human understandable" messages
|
||||
$messages = [
|
||||
'USER_NOT_EXIST' => 'The user you tried to activate does not exist.',
|
||||
'USER_ALREADY_ACTIVE' => 'The user you tried to activate is already active.',
|
||||
'INVALID_CODE' => 'Invalid activation code, if you think this is an error contact the administrator.',
|
||||
'INVALID_USER' => 'The used registration code is not designated for this user.',
|
||||
'SUCCESS' => 'Successfully activated your account, you may now log in.'
|
||||
];
|
||||
|
||||
// Add page specific things
|
||||
$renderData['page'] = [
|
||||
'title' => 'Activate account',
|
||||
'redirect' => '/authenticate',
|
||||
'message' => $messages[$activate[1]]
|
||||
];
|
||||
|
||||
break;
|
||||
|
||||
// Resending the activation e-mail
|
||||
case 'resendactivemail':
|
||||
|
||||
break;
|
||||
|
||||
// Login processing
|
||||
case 'login':
|
||||
|
||||
|
@ -101,11 +132,48 @@ if(
|
|||
// Registration processing
|
||||
case 'register':
|
||||
|
||||
// Attempt registration
|
||||
$register = Users::register(
|
||||
$_REQUEST['username'],
|
||||
$_REQUEST['password'],
|
||||
$_REQUEST['confirmpassword'],
|
||||
$_REQUEST['email'],
|
||||
isset($_REQUEST['tos']),
|
||||
(
|
||||
Configuration::getConfig('recaptcha') ?
|
||||
$_REQUEST['g-recaptcha-response'] :
|
||||
null
|
||||
),
|
||||
(
|
||||
Configuration::getConfig('require_registration_code') ?
|
||||
$_REQUEST['registercode'] :
|
||||
null
|
||||
)
|
||||
);
|
||||
|
||||
// Array containing "human understandable" messages
|
||||
$messages = [
|
||||
'DISABLED' => 'Registration is currently disabled.',
|
||||
'INVALID_REG_KEY' => 'The given registration code was invalid.',
|
||||
'TOS' => 'You are required to agree to the Terms of Service.',
|
||||
'CAPTCHA_FAIL' => 'Captcha verification failed, please try again.',
|
||||
'USER_EXISTS' => 'A user with this username already exists, if you lost your password try using the Lost Password form.',
|
||||
'NAME_TOO_SHORT' => 'Your name must be at least 3 characters long.',
|
||||
'NAME_TOO_LONG' => 'Your name can\'t be longer than 16 characters.',
|
||||
'PASS_TOO_SHORT' => 'Your password is too short, it must be at least 8 characters.',
|
||||
'PASS_TOO_LONG' => 'A password longer than 256 characters? Seriously?',
|
||||
'PASS_NOT_MATCH' => 'Passwords do not match.',
|
||||
'INVALID_EMAIL' => 'Your e-mail address is formatted incorrectly.',
|
||||
'INVALID_MX' => 'No valid MX-Record found on the e-mail address you supplied.',
|
||||
'EMAILSENT' => 'Your registration went through! An activation e-mail has been sent.',
|
||||
'SUCCESS' => 'Your registration went through! Welcome to '. Configuration::getConfig('sitename') .'!'
|
||||
];
|
||||
|
||||
// Add page specific things
|
||||
$renderData['page'] = [
|
||||
'title' => 'Register on Flashii',
|
||||
'redirect' => $_SERVER['PHP_SELF'],
|
||||
'message' => 'what'
|
||||
'redirect' => ($register[0] ? '/' : '/authenticate'),
|
||||
'message' => $messages[$register[1]]
|
||||
];
|
||||
|
||||
break;
|
||||
|
|
|
@ -16,7 +16,7 @@ $renderData['page'] = [
|
|||
'articleCount' => count($renderData['newsPosts'])
|
||||
];
|
||||
$renderData['stats'] = [
|
||||
'userCount' => ($userCount = count($users = Users::getAllUsers())) .' user'. ($userCount == 1 ? '' : 's'),
|
||||
'userCount' => ($userCount = count($users = Users::getAllUsers(false))) .' user'. ($userCount == 1 ? '' : 's'),
|
||||
'newestUser' => max($users),
|
||||
'lastRegDate' => ($lastRegDate = date_diff(date_create(date('Y-m-d', max($users)['regdate'])), date_create(date('Y-m-d')))->format('%a')) .' day'. ($lastRegDate == 1 ? '' : 's'),
|
||||
'chatOnline' => ($chatOnline = 0) .' user'. ($chatOnline == 1 ? '' : 's')
|
||||
|
|
Reference in a new issue