Looking @ is_banned_username() and is_banned_email(), it could be quite easy to do.
I've 2 proposals:
- use a special char at the beginning of the mask
- add a checkbox (and a field in mybb_banfilters)
And modification in function should be something like:
/**
* Checks if a username has been disallowed for registration/use.
*
* @param string $username The username
* @param boolean $update_lastuse True if the 'last used' dateline should be updated if a match is found.
* @return boolean True if banned, false if not banned
*/
function is_banned_username($username, $update_lastuse=false)
{
global $db;
$query = $db->simple_select('banfilters', 'filter, fid, regex', "type='2'");
while($banned_username = $db->fetch_array($query))
{
// Make regular expression * match
if ($banned_username['regex']==1)
{
$pattern = "#^" . $banned_username['filter'] . "$#i";
}
else
{
$banned_username['filter'] = str_replace('\*', '(.*)', preg_quote($banned_username['filter'], '#'));
$pattern = "#(^|\b){$banned_username['filter']}($|\b)#i";
}
if(preg_match($pattern, $username))
{
// Updating last use
if($update_lastuse == true)
{
$db->update_query("banfilters", array("lastuse" => TIME_NOW), "fid='{$banned_username['fid']}'");
}
return true;
}
}
// Still here - good username
return false;
}
The creation of $pattern is only because if we need back references, we must not have capture group at the beginning.