mirror of
https://github.com/slawkens/myaac.git
synced 2025-04-26 09:19:22 +02:00
Fixes in create new character nick
+ fixed config.character_name_min/max_length being ignored in change_name.php
This commit is contained in:
parent
4e68838172
commit
d148b71f0f
@ -26,21 +26,13 @@ class CreateCharacter
|
||||
if(empty($name))
|
||||
$errors['name'] = 'Please enter a name for your character!';
|
||||
else if(strlen($name) > $maxLength)
|
||||
$errors['name'] = 'Name is too long. Max. lenght <b>'.$maxLength.'</b> letters.';
|
||||
$errors['name'] = 'Name is too long. Max. length <b>'.$maxLength.'</b> letters.';
|
||||
else if(strlen($name) < $minLength)
|
||||
$errors['name'] = 'Name is too short. Min. lenght <b>'.$minLength.'</b> letters.';
|
||||
elseif(preg_match('/ {2,}/', $name))
|
||||
$errors['name'] = 'Invalid character name format. Use only A-Z and numbers 0-9 and no double spaces.';
|
||||
$errors['name'] = 'Name is too short. Min. length <b>'.$minLength.'</b> letters.';
|
||||
else {
|
||||
if(!admin() && !Validator::newCharacterName($name)) {
|
||||
$errors['name'] = Validator::getLastError();
|
||||
}
|
||||
|
||||
$exist = new OTS_Player();
|
||||
$exist->find($name);
|
||||
if($exist->isLoaded()) {
|
||||
$errors['name'] = 'Character with this name already exist.';
|
||||
}
|
||||
}
|
||||
|
||||
if(empty($sex) && $sex != "0")
|
||||
@ -122,7 +114,7 @@ class CreateCharacter
|
||||
return false;
|
||||
}
|
||||
|
||||
global $db, $twig;
|
||||
global $db;
|
||||
|
||||
if($sex == "0")
|
||||
$char_to_copy->setLookType(136);
|
||||
@ -188,7 +180,7 @@ class CreateCharacter
|
||||
}
|
||||
|
||||
$player->save();
|
||||
$player->setCustomField("created", time());
|
||||
$player->setCustomField('created', time());
|
||||
|
||||
$player = new OTS_Player();
|
||||
$player->find($name);
|
||||
@ -211,6 +203,7 @@ class CreateCharacter
|
||||
foreach($loaded_items_to_copy as $save_item)
|
||||
$db->query("INSERT INTO `player_items` (`player_id` ,`pid` ,`sid` ,`itemtype`, `count`, `attributes`) VALUES ('".$player->getId()."', '".$save_item['pid']."', '".$save_item['sid']."', '".$save_item['itemtype']."', '".$save_item['count']."', '".$save_item['attributes']."');");
|
||||
|
||||
global $twig;
|
||||
$twig->display('success.html.twig', array(
|
||||
'title' => 'Character Created',
|
||||
'description' => 'The character <b>' . $name . '</b> has been created.<br/>
|
||||
|
@ -84,7 +84,7 @@ class Validator
|
||||
self::$lastError = 'Account name is too long (max. 32 chars).';
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
if(preg_match('/ {2,}/', $name))
|
||||
{
|
||||
self::$lastError = 'Invalid account name format. Use only A-Z and numbers 0-9 and no double spaces.';
|
||||
@ -185,13 +185,13 @@ class Validator
|
||||
$length = strlen($name);
|
||||
if($length < 3)
|
||||
{
|
||||
self::$lastError = 'Character name is too short. Min. lenght <b>3</b> characters.';
|
||||
self::$lastError = 'Character name is too short. Min. length <b>3</b> characters.';
|
||||
return false;
|
||||
}
|
||||
|
||||
if($length > 25)
|
||||
{
|
||||
self::$lastError = 'Character name is too long. Max. lenght <b>25</b> characters.';
|
||||
self::$lastError = 'Character name is too long. Max. length <b>25</b> characters.';
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -200,12 +200,13 @@ class Validator
|
||||
self::$lastError = "Invalid name format. Use only A-Z, spaces and '.";
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
if(preg_match('/ {2,}/', $name))
|
||||
{
|
||||
self::$lastError = 'Invalid character name format. Use only A-Z and numbers 0-9 and no double spaces.';
|
||||
return false;
|
||||
}
|
||||
|
||||
if(!preg_match("/[A-z ']/", $name))
|
||||
{
|
||||
self::$lastError = "Invalid name format. Use only A-Z, spaces and '.";
|
||||
@ -228,7 +229,7 @@ class Validator
|
||||
|
||||
$name_lower = strtolower($name);
|
||||
|
||||
$first_words_blocked = array('admin ', 'administrator ', 'gm ', 'cm ', 'god ','tutor ', "'", '-');
|
||||
$first_words_blocked = array('admin ', 'administrator ', 'gm ', 'cm ', 'god ','tutor ');
|
||||
foreach($first_words_blocked as $word)
|
||||
{
|
||||
if($word == substr($name_lower, 0, strlen($word))) {
|
||||
@ -252,6 +253,12 @@ class Validator
|
||||
return false;
|
||||
}
|
||||
|
||||
if(preg_match('/ {2,}/', $name))
|
||||
{
|
||||
self::$lastError = 'Invalid character name format. Use only A-Z and numbers 0-9 and no double spaces.';
|
||||
return false;
|
||||
}
|
||||
|
||||
if(strtolower($config['lua']['serverName']) == $name_lower) {
|
||||
self::$lastError = 'Your name cannot be same as server name.';
|
||||
return false;
|
||||
@ -284,14 +291,6 @@ class Validator
|
||||
}
|
||||
}
|
||||
|
||||
for($i = 0; $i < $name_length; $i++)
|
||||
{
|
||||
if(isset($name_lower[$i - 1]) && $name_lower[$i - 1] == ' ' && isset($name_lower[$i + 1]) && $name_lower[$i + 1] == ' ') {
|
||||
self::$lastError = 'Your name contains too many spaces.';
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
$player = new OTS_Player();
|
||||
$player->find($name);
|
||||
if($player->isLoaded()) {
|
||||
@ -339,13 +338,7 @@ class Validator
|
||||
return false;
|
||||
}
|
||||
|
||||
if($name_length < 3 || $name_length > 28) {
|
||||
self::$lastError = 'Your name cannot be shorter than 3 characters and longer than 28 characters.';
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
if(!preg_match("/[A-z ']{3,28}/", $name)) {
|
||||
if(!preg_match("/[A-z ']/", $name)) {
|
||||
self::$lastError = 'Your name containst illegal characters.';
|
||||
return false;
|
||||
}
|
||||
|
@ -21,19 +21,15 @@ else
|
||||
if($points < $config['account_change_character_name_points'])
|
||||
$errors[] = 'You need ' . $config['account_change_character_name_points'] . ' premium points to change name. You have <b>'.$points.'<b> premium points.';
|
||||
|
||||
$minLength = config('character_name_min_length');
|
||||
$maxLength = config('character_name_max_length');
|
||||
|
||||
if(empty($errors) && empty($name))
|
||||
$errors[] = 'Please enter a new name for your character!';
|
||||
else if(strlen($name) > 25)
|
||||
$errors[] = 'Name is too long. Max. lenght <b>25</b> letters.';
|
||||
else if(strlen($name) < 3)
|
||||
$errors[] = 'Name is too short. Min. lenght <b>3</b> letters.';
|
||||
else {
|
||||
$exist = new OTS_Player();
|
||||
$exist->find($name);
|
||||
if($exist->isLoaded()) {
|
||||
$errors[] = 'Character with this name already exist.';
|
||||
}
|
||||
}
|
||||
else if(strlen($name) > $maxLength)
|
||||
$errors['name'] = 'Name is too long. Max. length <b>'.$maxLength.'</b> letters.';
|
||||
else if(strlen($name) < $minLength)
|
||||
$errors['name'] = 'Name is too short. Min. length <b>'.$minLength.'</b> letters.';
|
||||
|
||||
if(empty($errors))
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user