Block Certain Nicknames

Is there a way to ban certain words from being used as nicknames? ie, Admin, Administrator, Owner, Webmaster, swearwords, etc. There was a post about a year ago regarding this issue, but I tried the solution and no luck. It looks like the registration process is done through AJAX (perhaps only since v6) and is a little too complex for me to figure out myself... Thanks.
Quote · 22 Jul 2008

This is a good idea for another reason.  Since the usernames also form the url, you could use such a blocking feature to make sure people don't take the name of a directory that already exists.  So for example if someone picked the username "tools" for some reason, but you already had a directory called mysite/tools maybe something like this would help.  Unless it already exists?  If you have installed Dolphin in the root, and someone picks a username with the same name as one of your directories what happens?

Rob

Quote · 23 Jul 2008

Dolphin sorta kinda has something built in that we can use for this.. if you go in admin and then "builders" and "fields builder" you will see the join form builder. Click on "nickname" and then at the top of that box click on "advanced".. you will see this:

 

return ( preg_match( '/^[a-zA-Z0-9_-]+$/', $arg0 ) and !file_exists( $dir['root'] . $arg0 ) );

 

This is what Dolphin uses to check that a nickname is only numbers and letters and that it isn't a root directory... if we add this:

 

and !strstr($arg0,"rumproast")

 

then it will also check for the word in quotes... so you end up with this:

 

return ( preg_match( '/^[a-zA-Z0-9_-]+$/', $arg0 ) and !file_exists( $dir['root'] . $arg0 ) and !strstr($arg0,"rumproast"));

 

Now I know that box is going to get messy when you add about 20 or 30 of those conditional statements but this is an easy way to do it without changing any Dolphin code :-)  Oh and don't forget to leave that );  at the end after you add your statements.

 

Mike

http://www.makeasocialnetwork.com

BoonEx Certified Host: Zarconia.net - Fully Supported Shared and Dedicated for Dolphin
Quote · 23 Jul 2008

Wow that worked great thanks alot!

I used this

return ( preg_match( '/^[a-zA-Z0-9]+$/', $arg0 ) and !file_exists( $dir['root'] . $arg0 ) and !strstr($arg0,"-") and !strstr($arg0,"admin")and !strstr($arg0,"administrator") and !strstr($arg0,"_") and !strstr($arg0,"Owner") and !strstr($arg0,"fuck") and !strstr($arg0,"cunt") and !strstr($arg0,"webmaster") and !strstr($arg0,"guest"));

I wanted to get rid of _ and - as well.  :)

Quote · 23 Jul 2008

You're welcome :-)

BoonEx Certified Host: Zarconia.net - Fully Supported Shared and Dedicated for Dolphin
Quote · 24 Jul 2008

Hey mscott,

Any idea if wildcards would work too? Such as and !strstr($arg0,"*badword") or and !strstr($arg0,".*badword") or something maybe /* or/* so it would prevent anything with the particular word in it like:
youbadword or badwordyou.

hey jaminunit,

Interesting choice of words. I am thinking you will probably come up with a few more.

DialMe.com - Your One and Only Source For Boonex Dolphin Tutorials and Resources
Quote · 24 Jul 2008

Thank you Mike :-)

This is a really useful post :-)

Life is a fatal disease, sexually transmissible - Virginity is carcinogenic! Ask here for vaccine.
Quote · 24 Jul 2008

So how would you do it to prevent a username of all numbers since this
will not work as mentioned in another thread?
i.e. 123456789

Quote · 25 Jul 2008

Dear all, i'd like that user could put in the nickname the following caracters:

éèòàùì and more. Where can I add it?

I tried to add here: return ( preg_match( '/^[a-zA-Z0-9_-]+$/', $arg0 ) and !file_exists( $dir['root'] . $arg0 ) );

but it didnt work.

Thanks a lot

Quote · 26 Jul 2008

Thanks Mike!!

Quote · 4 Aug 2008

cool.. that sorted it :)

Quote · 13 Aug 2008

Okay - here is a little function I wrote to use in dolphin - first - open utils.inc.php, goto the bottom and right before the last ?> add this function:

function lookUpByArray($l_arr, $sCheck){
foreach ($l_arr as &$value) {$value = '/\b('.str_replace('\*', '\w*?', preg_quote($value, '/')).')\b/i';}
unset ($value); $foundit=false;
if (!empty($l_arr)){
foreach ($l_arr as $value) {if (preg_match($value, $sCheck)){$foundit=true; break;}}
}
return $foundit;
}

Now, goto profiles.inc.php - around line 260 - find function conf_nick($nick, $ID = 0 ) and right before:

if ( $ID )

Add this:

$badNicks = Array('*fuck*','shit','bitch');
if (lookUpByArray($badNicks, $nick)){return false;}

Explanation of $badNicks array - you can use the * for any wildcards  -example:

fuck* will match fuckit fucker fuckstick, but not itfuck

and *fuck matches ifuck itfuck wefuck, but not fucker

So *fuck* covers all bases.  You can add as many words as you like - just remember, always end the array without the comma - 'xxxx','xxxx','xxxx',) is wrong ('xxxx','xxxx','xxxx') is correct.

Enjoy :)

As always, simple and sweet - php is the instrument, I'm the artist :)

Chris

www.convictionscommunity.com

Quote · 27 Aug 2008

This must also be applied for the above filter to work:

Okay - goto admin panel, field builder, click NickName, advanced - replace this:

return ( preg_match( '/^[a-zA-Z0-9_-]+$/', $arg0 ) and !file_exists( $dir['root'] . $arg0 ) );

with

return ( preg_match( '/^[a-zA-Z0-9_-]+$/', $arg0 ) && conf_nick($arg0) );

Quote · 27 Aug 2008

Topher, That works great except when you want to change the membership status of the person.

When you go to save, it shows the NICKNAME as being already used and you would have to change it.

If you delete all those changes that you recomended, it will save just fine.

Maybe there is a way for that not to happen?

Quote · 8 Sep 2008

I am having the same problem, I cannot upgrade memberships. Any solutions?

Topher, That works great except when you want to change the membership status of the person.

When you go to save, it shows the NICKNAME as being already used and you would have to change it.

If you delete all those changes that you recomended, it will save just fine.

Maybe there is a way for that not to happen?

There are none so blind as those that will not see.
Quote · 8 Sep 2008

Yes, it appears the reason is because on resave it evals the checksum.  What is the name of the php file (in your url) when this error occurs.  I have an idea :)

Chris

Quote · 8 Sep 2008

pedit.php?ID=35

Regards,

Stuart

I am having the same problem, I cannot upgrade memberships. Any solutions?

Topher, That works great except when you want to change the membership status of the person.

When you go to save, it shows the NICKNAME as being already used and you would have to change it.

If you delete all those changes that you recomended, it will save just fine.

Maybe there is a way for that not to happen?

There are none so blind as those that will not see.
Quote · 8 Sep 2008

Hello Topher, is there a fix for this error?

Regards,

Stuart

I am having the same problem, I cannot upgrade memberships. Any solutions?

Topher, That works great except when you want to change the membership status of the person.

When you go to save, it shows the NICKNAME as being already used and you would have to change it.

If you delete all those changes that you recomended, it will save just fine.

Maybe there is a way for that not to happen?

Yes - I think this will work - try it and report :)

Inside of the conf_nick function - add this: (before any other part of the function).

global $logged; if ($logged['admin']){return true;}

Quote · 8 Sep 2008

Hello Topher, is there a fix for this error?

Regards,

Stuart

I am having the same problem, I cannot upgrade memberships. Any solutions?

Topher, That works great except when you want to change the membership status of the person.

When you go to save, it shows the NICKNAME as being already used and you would have to change it.

If you delete all those changes that you recomended, it will save just fine.

Maybe there is a way for that not to happen?

Yes - I think this will work - try it and report :)

Inside of the conf_nick function - add this: (before any other part of the function).

global $logged; if ($logged['admin']){return true;}

I am not sure exactly where to paste code. I had an error with (utils.inc.php):

/* Added badnick function (also in profiles.inc.php) */
function lookUpByArray($l_arr, $sCheck)
global $logged; if ($logged['admin']){return true;}{
foreach ($l_arr as &$value) {$value = '/\b('.str_replace('\*', '\w*?', preg_quote($value, '/')).')\b/i';}
unset ($value); $foundit=false;
if (!empty($l_arr)){
foreach ($l_arr as $value) {if (preg_match($value, $sCheck)){$foundit=true; break;}}
}
return $foundit;
}

/* End of badnick function */

There are none so blind as those that will not see.
Quote · 9 Sep 2008

Wrong function :)

In profiles.inc.php change:

function conf_nick($nick, $ID = 0 )
{
global $exist_arr;

to:

function conf_nick($nick, $ID = 0 )
{
global $exist_arr, $logged; if ($logged['admin']){return true;}

That should work - let me know.

Quote · 9 Sep 2008

Nice one! works like a dream!!

Many thanks

Stuart

Wrong function :)

In profiles.inc.php change:

function conf_nick($nick, $ID = 0 )
{
global $exist_arr;

to:

function conf_nick($nick, $ID = 0 )
{
global $exist_arr, $logged; if ($logged['admin']){return true;}

That should work - let me know.

There are none so blind as those that will not see.
Quote · 9 Sep 2008

GREAT! !  Laughing

Quote · 9 Sep 2008
 
 
Below is the legacy version of the Boonex site, maintained for Dolphin.Pro 7.x support.
The new Dolphin solution is powered by UNA Community Management System.