Welcome to Geeklog, Anonymous Wednesday, May 01 2024 @ 08:22 pm EDT

Geeklog Forums

usernames and the badword filter


Status: Banned

machinari

Forum User
Full Member
Registered: 03/22/04
Posts: 1512
Looking at the new user list today brings to mind a feature request or perhaps a bug report, not sure which just yet, but the badwords filter doesn't seem to be applied there.
 Quote

Status: offline

jetshack

Forum User
Full Member
Registered: 06/29/04
Posts: 122
Location:Texas
that's weird because on one of the sites i'm running it does catch usernames... I had a user whose last name was *censored*son and it was censored.

edit: Well aren't I a dumb *censored* for not realizing that *censored* would be censored?

edit 2: thinking more on this... it's happening on the site that blaine created the custom reg script for... wonder if that's why it's catching the names?
 Quote

Status: offline

Dirk

Site Admin
Admin
Registered: 01/12/02
Posts: 13073
Location:Stuttgart, Germany
Well, what exactly do you have in mind? Censoring the username whenever it's displayed?

It's easy to apply the bad word filter (check the frontpage now), but that doesn't sound like a viable solution.

I guess what you're really after is a way to prevent people from even signing up with such a username in the first place.

bye, Dirk
 Quote

Status: Banned

machinari

Forum User
Full Member
Registered: 03/22/04
Posts: 1512
here is an edited version of the createuser() in users.php...it does just that, Dirk. Using the bad word filter it prevents those usernames from registering. It returns the invalid username message.
Text Formatted Code
function createuser($username,$email)
{
    global $_CONF, $_TABLES, $LANG01, $LANG04;

    $username = trim ($username);
    $email = trim ($email);

    if (COM_isEmail ($email) && !empty ($username)) {

        //********** added this bit ********************
        if( $_CONF['censormode'] != 0 )
        {
            if( is_array( $_CONF['censorlist'] ))
            {
                switch( $_CONF['censormode'])
                {
                    case 1: # Exact match
                        $RegExPrefix = '(s*)';
                        $RegExSuffix = '(W*)';
                        break;

                    case 2: # Word beginning
                        $RegExPrefix = '(s*)';
                        $RegExSuffix = '(w*)';
                        break;

                    case 3: # Word fragment
                        $RegExPrefix   = '(w*)';
                        $RegExSuffix   = '(w*)';
                        break;
                }

                for( $i = 0; $i < count( $_CONF['censorlist']); $i++ )
                {
                    if(eregi( $RegExPrefix . $_CONF['censorlist'][$i] . $RegExSuffix, $username ))
                    {
                        $msg = $LANG01[32]; // invalid username
                        $retval .= COM_siteHeader ('menu');
                        if ($_CONF['custom_registration'] && function_exists(custom_userform)) {
                            $retval .= custom_userform ($msg);
                        } else {
                            $retval .= newuserform ($msg);
                        }
                        $retval .= COM_siteFooter();

                        return $retval;
                    }
                }
            }
        }
        //***************************************

        $ucount = DB_count ($_TABLES['users'], 'username',
                            addslashes ($username));
        $ecount = DB_count ($_TABLES['users'], 'email', addslashes ($email));

        if ($ucount == 0 AND $ecount == 0) {
            $uid = USER_createAccount ($username, $email);

            $queueUser = USER_isQueued ($uid);
            if ($queueUser) {
                $msg = 48;
            } else {
                emailpassword ($username, 1);
                $msg = 1;
            }
            if (isset ($_CONF['notification']) &&
                    in_array ('user', $_CONF['notification'])) {
                sendNotification ($username, $email, $uid, $queueUser);
            }

            return COM_refresh($_CONF['site_url'] . '/index.php?msg=' . $msg);
        } else {
            $retval .= COM_siteHeader ('Menu');
            if ($_CONF['custom_registration'] &&
                    function_exists ('custom_userform')) {
                $retval .= custom_userform ($LANG04[19]);
            } else {
                $retval .= newuserform ($LANG04[19]);
            }
            $retval .= COM_siteFooter ();
        }
    } else {
        if (empty ($username)) {
            $msg = $LANG01[32]; // invalid username
        } else {
            $msg = $LANG04[18]; // invalid email address
        }
        $retval .= COM_siteHeader ('menu');
        if ($_CONF['custom_registration'] && function_exists(custom_userform)) {
            $retval .= custom_userform ($msg);
        } else {
            $retval .= newuserform ($msg);
        }
        $retval .= COM_siteFooter();
    }


 

I took some of COM_checkWords() and applied it to the username.
 Quote

All times are EDT. The time is now 08:22 pm.

  • Normal Topic
  • Sticky Topic
  • Locked Topic
  • New Post
  • Sticky Topic W/ New Post
  • Locked Topic W/ New Post
  •  View Anonymous Posts
  •  Able to post
  •  Filtered HTML Allowed
  •  Censored Content