mirror of
https://github.com/slawkens/myaac.git
synced 2025-05-03 04:39:20 +02:00
Create character blocked words (by @gpedro), just moved to settings
This commit is contained in:
parent
d7e6545156
commit
191137282b
@ -246,14 +246,9 @@ class Validator
|
|||||||
global $db, $config;
|
global $db, $config;
|
||||||
|
|
||||||
$name_lower = strtolower($name);
|
$name_lower = strtolower($name);
|
||||||
$custom_first_words_blocked = [];
|
|
||||||
if (isset($config['character_name_blocked']['prefix']) && $config['character_name_blocked']['prefix']) {
|
|
||||||
$custom_first_words_blocked = $config['character_name_blocked']['prefix'];
|
|
||||||
}
|
|
||||||
|
|
||||||
$first_words_blocked = array_merge($custom_first_words_blocked, array('admin ', 'administrator ', 'gm ', 'cm ', 'god ','tutor ', "'", '-'));
|
$first_words_blocked = array_merge(["'", '-'], setting('core.create_character_name_blocked_prefix'));
|
||||||
foreach($first_words_blocked as $word)
|
foreach($first_words_blocked as $word) {
|
||||||
{
|
|
||||||
if($word == substr($name_lower, 0, strlen($word))) {
|
if($word == substr($name_lower, 0, strlen($word))) {
|
||||||
self::$lastError = 'Your name contains blocked words.';
|
self::$lastError = 'Your name contains blocked words.';
|
||||||
return false;
|
return false;
|
||||||
@ -275,8 +270,7 @@ class Validator
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(preg_match('/ {2,}/', $name))
|
if(preg_match('/ {2,}/', $name)) {
|
||||||
{
|
|
||||||
self::$lastError = 'Invalid character name format. Use only A-Z and numbers 0-9 and no double spaces.';
|
self::$lastError = 'Invalid character name format. Use only A-Z and numbers 0-9 and no double spaces.';
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -286,26 +280,16 @@ class Validator
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$custom_names_blocked = [];
|
$names_blocked = setting('core.create_character_name_blocked_names');
|
||||||
if (isset($config['character_name_blocked']['names']) && $config['character_name_blocked']['names']) {
|
foreach($names_blocked as $word) {
|
||||||
$custom_names_blocked = $config['character_name_blocked']['names'];
|
|
||||||
}
|
|
||||||
$names_blocked = array_merge($custom_names_blocked, array('admin', 'administrator', 'gm', 'cm', 'god', 'tutor'));
|
|
||||||
foreach($names_blocked as $word)
|
|
||||||
{
|
|
||||||
if($word == $name_lower) {
|
if($word == $name_lower) {
|
||||||
self::$lastError = 'Your name contains blocked words.';
|
self::$lastError = 'Your name contains blocked words.';
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$custom_words_blocked = [];
|
$words_blocked = array_merge(['--', "''","' ", " '", '- ', ' -', "-'", "'-"], setting('core.create_character_name_blocked_words'));
|
||||||
if (isset($config['character_name_blocked']['words']) && $config['character_name_blocked']['words']) {
|
foreach($words_blocked as $word) {
|
||||||
$custom_words_blocked = $config['character_name_blocked']['words'];
|
|
||||||
}
|
|
||||||
$words_blocked = array_merge($custom_words_blocked, array('admin', 'administrator', 'gamemaster', 'game master', 'game-master', "game'master", '--', "''","' ", " '", '- ', ' -', "-'", "'-", 'fuck', 'sux', 'suck', 'noob', 'tutor'));
|
|
||||||
foreach($words_blocked as $word)
|
|
||||||
{
|
|
||||||
if(!(strpos($name_lower, $word) === false)) {
|
if(!(strpos($name_lower, $word) === false)) {
|
||||||
self::$lastError = 'Your name contains illegal words.';
|
self::$lastError = 'Your name contains illegal words.';
|
||||||
return false;
|
return false;
|
||||||
@ -348,14 +332,6 @@ class Validator
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(isset($config['npc']))
|
|
||||||
{
|
|
||||||
if(in_array($name_lower, $config['npc'])) {
|
|
||||||
self::$lastError = 'Your name cannot contains NPC name.';
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$npcCheck = config('character_name_npc_check');
|
$npcCheck = config('character_name_npc_check');
|
||||||
if ($npcCheck) {
|
if ($npcCheck) {
|
||||||
require_once LIBS . 'npc.php';
|
require_once LIBS . 'npc.php';
|
||||||
|
@ -616,6 +616,43 @@ Sent by MyAAC,<br/>
|
|||||||
'desc' => 'should country of user be automatically recognized by his IP? This makes an external API call to http://ipinfo.io',
|
'desc' => 'should country of user be automatically recognized by his IP? This makes an external API call to http://ipinfo.io',
|
||||||
'default' => true,
|
'default' => true,
|
||||||
],
|
],
|
||||||
|
'create_character' => [
|
||||||
|
'type' => 'section',
|
||||||
|
'title' => 'Create Character',
|
||||||
|
],
|
||||||
|
'create_character_name_blocked_prefix' => [
|
||||||
|
'name' => 'Create Character Blocked Prefix',
|
||||||
|
'type' => 'textarea',
|
||||||
|
'desc' => 'Space after is important!',
|
||||||
|
'default' => 'admin ,administrator ,gm ,cm ,god ,tutor',
|
||||||
|
'callbacks' => [
|
||||||
|
'get' => function ($value) {
|
||||||
|
return explode(',', $value);
|
||||||
|
},
|
||||||
|
],
|
||||||
|
],
|
||||||
|
'create_character_name_blocked_names' => [
|
||||||
|
'name' => 'Create Character Blocked Names',
|
||||||
|
'type' => 'textarea',
|
||||||
|
'desc' => 'Separated by comma (,)',
|
||||||
|
'default' => 'admin,administrator,gm,cm,god,tutor',
|
||||||
|
'callbacks' => [
|
||||||
|
'get' => function ($value) {
|
||||||
|
return array_map('trim', explode(',', $value));
|
||||||
|
},
|
||||||
|
],
|
||||||
|
],
|
||||||
|
'create_character_name_blocked_words' => [
|
||||||
|
'name' => 'Create Character Blocked Words',
|
||||||
|
'type' => 'textarea',
|
||||||
|
'desc' => 'Separated by comma (,)',
|
||||||
|
'default' => "admin,administrator,gamemaster,game master,game-master,game'master,fuck,sux,suck,noob,tutor",
|
||||||
|
'callbacks' => [
|
||||||
|
'get' => function ($value) {
|
||||||
|
return array_map('trim', explode(',', $value));
|
||||||
|
},
|
||||||
|
],
|
||||||
|
],
|
||||||
'account_mail_confirmed_reward' => [
|
'account_mail_confirmed_reward' => [
|
||||||
'type' => 'section',
|
'type' => 'section',
|
||||||
'title' => 'Reward Users for confirming their E-Mails. Works only with Account Mail Verify enabled',
|
'title' => 'Reward Users for confirming their E-Mails. Works only with Account Mail Verify enabled',
|
||||||
|
Loading…
x
Reference in New Issue
Block a user