From 9d8f398d9f436258c3fb5b68b1ebecd818f7087c Mon Sep 17 00:00:00 2001 From: Lee <42119604+Leesneaks@users.noreply.github.com> Date: Tue, 9 Mar 2021 23:42:21 +0000 Subject: [PATCH] update validator name check -added character_name_npc_check to config.php -added npc name check to validator --- config.php | 1 + system/libs/validator.php | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/config.php b/config.php index 2c815136..58ef4b46 100644 --- a/config.php +++ b/config.php @@ -171,6 +171,7 @@ $config = array( // This is the minimum and the maximum length that a player can create a character. It is highly recommend the maximum length to be 21. 'character_name_min_length' => 4, 'character_name_max_length' => 21, + 'character_name_npc_check' => true, // list of towns // if you use TFS 1.3 with support for 'towns' table in database, then you can ignore this - it will be configured automatically (from MySQL database - Table - towns) diff --git a/system/libs/validator.php b/system/libs/validator.php index 06ea63f7..450c2573 100644 --- a/system/libs/validator.php +++ b/system/libs/validator.php @@ -221,6 +221,16 @@ class Validator return false; } + $npcCheck = config('character_name_npc_check'); + if ($npcCheck) { + require LIBS . 'npc.php'; + NPCS::load(); + if(NPCS::$npcs && in_array(strtolower($name), NPCS::$npcs)) { + self::$lastError = "Invalid name format. Do not use NPC Names"; + return false; + } + } + return true; } @@ -334,6 +344,16 @@ class Validator } } + $npcCheck = config('character_name_npc_check'); + if ($npcCheck) { + require LIBS . 'npc.php'; + NPCS::load(); + if(NPCS::$npcs && in_array($name_lower, NPCS::$npcs)) { + self::$lastError = "Invalid name format. Do not use NPC Names"; + return false; + } + } + if(strspn($name, "qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM- '") != $name_length) { self::$lastError = 'This name contains invalid letters, words or format. Please use only a-Z, - , \' and space.'; return false;