From 3368fbd058f1a9159261e834292550b15dc27928 Mon Sep 17 00:00:00 2001 From: slawkens Date: Sat, 6 Jun 2020 19:37:05 +0200 Subject: [PATCH] New config: account_mail_block_plus_sign Block emails with '+' signs like test+box@gmail.com (help protect against spamming accounts) --- config.php | 1 + system/libs/validator.php | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/config.php b/config.php index c00cbe16..aa4eb098 100644 --- a/config.php +++ b/config.php @@ -94,6 +94,7 @@ $config = array( 'account_create_character_create' => true, // allow directly to create character on create account page? 'account_mail_verify' => false, // force users to confirm their email addresses when registering account 'account_mail_unique' => true, // email addresses cannot be duplicated? (one account = one email) + 'account_mail_block_plus_sign' => true, // block email with '+' signs like test+box@gmail.com (help protect against spamming accounts) 'account_premium_days' => 0, // default premium days on new account 'account_premium_points' => 0, // default premium points on new account 'account_welcome_mail' => true, // send welcome email when user registers diff --git a/system/libs/validator.php b/system/libs/validator.php index 02bbb506..ff082be6 100644 --- a/system/libs/validator.php +++ b/system/libs/validator.php @@ -117,6 +117,14 @@ class Validator return false; } + if(config('account_mail_block_plus_sign')) { + $explode = explode('@', $email); + if(isset($explode[0]) && (strpos($explode[0],'+') !== false)) { + self::$lastError = 'Please do not use plus (+) sign in your e-mail.'; + return false; + } + } + if(!preg_match('/^(?:[\w\!\#\$\%\&\'\*\+\-\/\=\?\^\`\{\|\}\~]+\.)*[\w\!\#\$\%\&\'\*\+\-\/\=\?\^\`\{\|\}\~]+@(?:(?:(?:[a-zA-Z0-9_](?:[A-z0-9_\-](?!\.)){0,61}[a-zA-Z0-9_]?\.)+[a-zA-Z0-9_](?:[a-zA-Z0-9_\-](?!$)){0,61}[a-zA-Z0-9_]?)|(?:\[(?:(?:[01]?\d{1,2}|2[0-4]\d|25[0-5])\.){3}(?:[01]?\d{1,2}|2[0-4]\d|25[0-5])\]))$/', $email)) { self::$lastError = 'Invalid e-mail format.'; return false;