mirror of
https://github.com/slawkens/myaac.git
synced 2025-04-27 09:49:22 +02:00
Fix #51 in 0.7 branch
This commit is contained in:
parent
c37f593eda
commit
6bc14fb44f
@ -376,6 +376,33 @@ class Validator
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Validate guild nick
|
||||||
|
* Nick lenght must be 3-40 chars
|
||||||
|
*
|
||||||
|
* @param string $name Name to check
|
||||||
|
* @return bool Is name valid?
|
||||||
|
*/
|
||||||
|
public static function guildNick($name)
|
||||||
|
{
|
||||||
|
if(empty($name)) {
|
||||||
|
self::$lastError = 'Please enter guild nick.';
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(strspn($name, "qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM0123456789- ") != strlen($name)) {
|
||||||
|
self::$lastError = 'Invalid guild nick format.';
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!preg_match("/[A-z ]{3,40}/", $name)) {
|
||||||
|
self::$lastError = 'Invalid guild nick format.';
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Validate rank name
|
* Validate rank name
|
||||||
* Rank lenght must be 1-32 chars
|
* Rank lenght must be 1-32 chars
|
||||||
|
@ -32,6 +32,12 @@ if(!$new_nick) {
|
|||||||
$player = new OTS_Player();
|
$player = new OTS_Player();
|
||||||
$player->find($name);
|
$player->find($name);
|
||||||
$player_from_account = false;
|
$player_from_account = false;
|
||||||
|
|
||||||
|
if(!Validator::guildNick($new_nick)) {
|
||||||
|
echo Validator::getLastError();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if(strlen($new_nick) <= 40)
|
if(strlen($new_nick) <= 40)
|
||||||
{
|
{
|
||||||
if($player->isLoaded())
|
if($player->isLoaded())
|
||||||
|
Loading…
x
Reference in New Issue
Block a user