Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Option to prevent registration spam #250

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions config/application.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
'RequireEmailConfirm' => false, // Require e-mail confirmation during registration.
'RequireChangeConfirm' => false, // Require confirmation when changing e-mail addresses.
'EmailConfirmExpire' => 48, // E-mail confirmations expire hours. Unconfirmed accounts will expire after this period of time.
'AntiRegesterationSpam' => false, // Work only when 'RequireEmailConfirm' is active , if the ip have an unconfirmed account , it would privent the user from registering new account.
sader1992 marked this conversation as resolved.
Show resolved Hide resolved
'PincodeEnabled' => true, // Whether or not the pincode system is enabled in your server. (Check your char_athena.conf file. Enabled by default.)
'MailerFromAddress' => 'noreply@localhost', // The e-mail address displayed in the From field.
'MailerFromName' => 'MailerName', // The name displayed with the From e-mail address.
Expand Down
1 change: 1 addition & 0 deletions lang/en_us.php
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,7 @@
'InvalidSecurityCode' => 'Please enter the security code correctly.',
'InvalidPassword' => 'Your password contains invalid characters.',
'InvalidBirthdate' => 'Invalid birthdate input.',
'AntiRegesterationSpam' => 'Anti Registeration Spam System is Active , Contact the Admin to Complete your registeration.',
sader1992 marked this conversation as resolved.
Show resolved Hide resolved
'CriticalRegisterError' => 'Something bad happened. Report to an administrator ASAP.',
// - account/edit
'AccountEditTitle' => 'Modify Account',
Expand Down
15 changes: 13 additions & 2 deletions lib/Flux/LoginServer.php
Original file line number Diff line number Diff line change
Expand Up @@ -189,14 +189,25 @@ public function register($username, $password, $confirmPassword, $email,$email2,
throw new Flux_RegisterError('E-mail address is already in use', Flux_RegisterError::EMAIL_ADDRESS_IN_USE);
}
}

if (Flux::config('RequireEmailConfirm') && Flux::config('AntiRegesterationSpam')) {
$sql = "SELECT state FROM {$this->loginDatabase}.login WHERE last_ip = ? And state = 5 LIMIT 1";
$sth = $this->connection->getStatement($sql);
$sth->execute(array($_SERVER['REMOTE_ADDR']));

$res = $sth->fetch();
if ($res) {
throw new Flux_RegisterError('Anti Regesteration Spam System Detect a Spam', Flux_RegisterError::ANTI_REGESTERATION_SPAM);
sader1992 marked this conversation as resolved.
Show resolved Hide resolved
}
}

if ($this->config->getUseMD5()) {
$password = Flux::hashPassword($password);
}

$sql = "INSERT INTO {$this->loginDatabase}.login (userid, user_pass, email, sex, group_id, birthdate) VALUES (?, ?, ?, ?, ?, ?)";
$sql = "INSERT INTO {$this->loginDatabase}.login (userid, user_pass, email, sex, group_id, birthdate, last_ip) VALUES (?, ?, ?, ?, ?, ?, ?)";
$sth = $this->connection->getStatement($sql);
$res = $sth->execute(array($username, $password, $email, $gender, (int)$this->config->getGroupID(), date('Y-m-d', $birthdatestamp)));
$res = $sth->execute(array($username, $password, $email, $gender, (int)$this->config->getGroupID(), date('Y-m-d', $birthdatestamp), $_SERVER['REMOTE_ADDR']));

if ($res) {
$idsth = $this->connection->getStatement("SELECT LAST_INSERT_ID() AS account_id");
Expand Down
1 change: 1 addition & 0 deletions lib/Flux/RegisterError.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,6 @@ class Flux_RegisterError extends Flux_Error {
const INVALID_PASSWORD = 18;
const INVALID_BIRTHDATE = 19;
const INVALID_EMAIL_CONF = 20;
const ANTI_REGESTERATION_SPAM= 21;
}
?>
3 changes: 3 additions & 0 deletions modules/account/create.php
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,9 @@
case Flux_RegisterError::INVALID_BIRTHDATE:
$errorMessage = Flux::message('InvalidBirthdate');
break;
case Flux_RegisterError::ANTI_REGESTERATION_SPAM:
$errorMessage = Flux::message('AntiRegesterationSpam');
break;
default:
$errorMessage = Flux::message('CriticalRegisterError');
break;
Expand Down