• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Force first letter do be capital - Gesior guilds.php

Dankoo

Active Member
Joined
Sep 4, 2010
Messages
1,007
Reaction score
27
Hello,

I would like to know how to set an "protection" on Gesior's guild system so it won't allow players to create guild names with first letter as lower case

Here's my script (in media fire cause it overwhelms characters limitation):

guilds.php

There's this name check function on config-and-functions.php, but I don't know if it's neither bad coded, or not inserted in guilds.php script (the function is present in guilds.php, but I don't know if it's working as it should):

PHP:
function check_guild_name($name) {
    $temp = strspn("$name", "qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM0123456789- ");
    if ($temp != strlen($name)) {
        return false;
    } else {
        $ok = "/[a-zA-Z ]{1,60}/";
        return (preg_match($ok, $name))? true: false;
    }
}
 
PHP:
function check_guild_name($s) {
	return strlen($s) < 30 && ctype_upper($s[0]) && !preg_match('/[^a-zA-Z ]/', $s);
}
 
That's great Cyk, but is there a way to improve a little bit this function, by adding protection like:

I'm being able to create guild with names like: CyKoTiTan

Capital letter besides first one should be a invalid name too, no? And if the guild has a compost name (two words), the first letters of each word must be capital

Thanks a lot for your support so far, the code by itself right now is already great, just some checks to make it even better

See ya

PS: I've been thinking, something like


PHP:
function check_guild_name($s) {
    return strlen($s) < 30 && ctype_upper($s[0]) && ctype_lower($s[SOMETHING BESIDES 0]) && !preg_match('/[^a-zA-Z ]/', $s);
}

I've tried like this but didn't work: ctype_lower !==($s[0])

:3
 
Last edited:
i already made some checks like you mentioned for createaccount, but the quickest solution would be to change
PHP:
		$new_guild->setName($guild_name);
to
PHP:
		$new_guild->setName(ucfirst(strtolower($guild_name)));
 
Ok Cyk, just one little problem left

With this code, when I create a composite name (two words), the second word's first letter get lower cased as well

Example: Cyko Titan -> Cyko titan
 
if you want both words to start in capital letters change ucfirst to ucwords (in the line from my last post)
 
Back
Top