Go Back   vb.org Archive > vBulletin Modifications > Archive > vB.org Archives > vBulletin 2.x > vBulletin 2.x Beta Releases
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools
Details »»

Version: , by dlst dlst is offline
Developer Last Online: Jan 2004 Show Printable Version Email this Page

Version: 2.2.x Rating:
Released: 12-26-2001 Last Update: Never Installs: 1
Is in Beta Stage  
No support by the author.

Hi all.

I have a client that runs a board that has about 100 members that are his personal friends, and the other 3400 members are just regular users. Lately poeple have been registering with usernames very similar to those of his friends, and his friends are complaining.

He asked me for a way to display a list of usernames that "sound like" or "are similar to" existing users, so that when he moderates user registrations it's easy to make a decision as to allow the new user or not.

Anyway, this VERY simple hack searches the database for existing usernames, and checks to see if they are similar to the username that is being registered. If it finds any, it simply lists them.

The system uses my own combination of metaphone and levenshtein to try to find similar matches.

There are options in the code to limit the number of returned matches, and to set the "tolerance level" of the search. A higher tolerance allows more matches.

Did I mention this was an EXCEEDINGLY simple hack? The only modifications are to admin/user.php.

You need to add two bits of code. The first is around line 1182, when you see the following code:

PHP Code:
$users=$DB_site->query("SELECT userid,username,email FROM user WHERE usergroupid=4 ORDER BY username"); 
Add this AFTER the code above:

PHP Code:
// DLST hack! Show similar usernames when moderating a user signup
  // to speed things up, get an array of all the users in the system here
  
$sim_all_users=$DB_site->query("SELECT username FROM user WHERE usergroupid!=4");
  while (
$sim_all_user=$DB_site->fetch_array($sim_all_users)) {
    
$sim_arr_all_users[] = $sim_all_user[username];
  }
  
// now we have $sim_arr_all_users, an array with all the usernames in the system that a current
  // END 
Then, find the following (a couple lines down, around 1190):

PHP Code:
echo "<td><p>$user[username]</p></td><td><p><a href=\"mailto:$user['email']\">$user['email']</a></p></td><td><p><a href=\"user.php?s=$session[sessionhash]&action=edit&userid=$user[userid]\" target=_blank>View profile</a></p></td></tr>\n"
And add this code AFTER:

PHP Code:
// DLST hack! Show similar usernames when moderating a user signup
        //********************
        // Options for Show Similar Usernames Hack
        
$sim_limit_show 10// maximum number of similar names to show
        
$sim_tolerance 2// how close a match to the username do you want?  The lower it is, the closer 
                            // the usernames must match to show up in list.  Experiment for yourself, but 
                            // this number works best for me.
        // END Options
        //********************
        // $user[username] is the username trying to get registered
        // $sim_message is the list of similar usernames that gets generated
        
$sim_meta1 metaphone$user[username] ); // get the metaphone for the username we are checking
        
reset ($sim_arr_all_users); // reset the array
        
while ( $sim_thiscount $sim_limit_show && list(, $sim_current_user) = each ($sim_arr_all_users) ) {
            
$sim_meta2 metaphone$sim_current_user ); // get the metaphone for the usernames that already exist
            
$sim_score levenshtein$sim_meta1$sim_meta2 ); // generate a score with the lev. method
            
if ( $sim_score <= $sim_tolerance ) { // compare the score to the tolerance (set above)
                
$sim_users_found[] = $sim_current_user// if it's good, add it to the list
                
$sim_thiscount++; // increase the count of matched usernames by one
            
}   
        }
        if ( 
$sim_thiscount ) {
            
$sim_message "A total of $sim_thiscount similar users were found: ";
            foreach (
$sim_users_found as $sim_value) {
                
$sim_message .= "<b>$sim_value</b>, ";
            }
            
$sim_message substr$sim_message0, -); // remove the last comma     
        
} else {
            
$sim_message "No similar usernames were found in the user list.";
        }
        
        
//echo "<tr><td><p>Validate option</p></td><td><p>$user[username]</p></td><td><p>$user["email"]</p></td><td><p>View profile</p></td></tr>\n";
        
echo "<tr class='".getrowbg()."'><td><p></p></td><td colspan=3><p>$sim_message</p></td></tr>\n";
unset(
$sim_meta1$sim_thiscount);
        
// END DLST hack 
And that's it! Moderate a user registration to see it in action.

I'd very much like to get as much feedback as possible for this, so don't hold back! If you have any suggestions, or ways to optimize the code further, also let me know.

-DLST

Show Your Support

  • This modification may not be copied, reproduced or published elsewhere without author's permission.

Comments
  #2  
Old 12-27-2001, 12:21 PM
TheComputerGuy's Avatar
TheComputerGuy TheComputerGuy is offline
 
Join Date: Oct 2001
Location: TX
Posts: 580
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Very good idea, if I do say so. Thanks for the hack
Reply With Quote
  #3  
Old 01-08-2002, 03:14 PM
Jawelin Jawelin is offline
 
Join Date: Nov 2001
Posts: 557
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

GREAT !!!
I'm gonna to install asap!

Just an enhancement: how could I modify the code to search (and to add the same array... ) even for similar emails or identical encrypted passwords ?

Thanks again for you excellent work!
Bye
Reply With Quote
  #4  
Old 01-08-2002, 04:01 PM
Lesane's Avatar
Lesane Lesane is offline
 
Join Date: Oct 2001
Location: The Netherlands
Posts: 1,149
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Great. Thanks. I gonna install this hack later.
Reply With Quote
  #5  
Old 01-08-2002, 04:32 PM
dlst dlst is offline
 
Join Date: Dec 2001
Posts: 35
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

[QUOTE]Originally posted by Jawelin

Just an enhancement: how could I modify the code to search (and to add the same array... ) even for similar emails or identical encrypted passwords ?

Thanks again for you excellent work!
Bye [/B]
Reply With Quote
  #6  
Old 01-08-2002, 04:33 PM
dlst dlst is offline
 
Join Date: Dec 2001
Posts: 35
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

[QUOTE]Originally posted by Jawelin

Just an enhancement: how could I modify the code to search (and to add the same array... ) even for similar emails or identical encrypted passwords ?

Thanks again for you excellent work!
Bye [/B]
Reply With Quote
  #7  
Old 01-08-2002, 04:48 PM
Jawelin Jawelin is offline
 
Join Date: Nov 2001
Posts: 557
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

You're absolutely right about passwords... Just I thought I could be notified of possible duplicates without knowing them (as hashed in 2.2.x) ...
Later, the Admin could evaluate or investigate better tracking those user this way identified...

The other thing, the email: well, my board has about 30 new users a day, but most of them are only 'readers' cause login/pw are necessary even to reach the forums, then I use email verification and admin validation to find potential dupe users.

Till now I always did this way: about once a month, I close the new subscriptions for a day, download the user.csv to excel and sort again and again with small function utilities to find 'probably' matching (at 90%... ) userid, emails, md5(pw), ipaddress, and so on... Most dupe email are similar id on different servers (yahoo, hotmail, etc.) or 'soundex-like' ids on the same one...

Then I always found out about 100-200 potential dupe users (I experimented the most popular sport is, when forgettin pw, re-subscribe again and again... ), and if in doubt contacted them to choose the right one...

As you can see, your great hack seems solving almost my problems...

That's all ... Thanks for support.
Reply With Quote
  #8  
Old 01-08-2002, 07:16 PM
dlst dlst is offline
 
Join Date: Dec 2001
Posts: 35
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Ok, so tell me if I'm hearing you right:

You would like a system that does the following:

1) check the list of users and find similar email usernames (the part that comes before that @domain.com)

2) take that list of similars (call them potential dupes) and check passwords and ip addresses for possible close or match.

3) generate that list of potentials, with links to contact that user about the potential problem.

You would have the following options:

$sim_limit_show - how many duplicates to show (-1 for all)
$sim_tolerance - how close a match do you want?
$sim_checkpass - (T/F) check for similar passwords?
$sim_pass_tolerance - how close a match on passwords?
$sim_checkip - (T/F) check for similar ips?
$sim_ip_tolerance - how close a match on ips?
$sim_orderby - (DATE/ALPHA) how do you want list displayed?

And the code above would have to be it's own section in the admin, which you could run from time to time, without having to take down the registration at all...

Have I got this right? Is this what you are looking for? let me know if I've left out anything.

-dlst
Reply With Quote
  #9  
Old 01-09-2002, 09:55 AM
Jawelin Jawelin is offline
 
Join Date: Nov 2001
Posts: 557
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

[QUOTE]Have I got this right? Is this what you are looking for? let me know if I've left out anything.
Reply With Quote
  #10  
Old 01-16-2002, 12:28 PM
Jawelin Jawelin is offline
 
Join Date: Nov 2001
Posts: 557
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Ehi ?!?

Nobody's there ?
You gave me such an input and now ? Ehehehe
Thanks
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 10:17 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.05827 seconds
  • Memory Usage 2,320KB
  • Queries Executed 23 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (4)bbcode_php
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)modsystem_post
  • (1)navbar
  • (6)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (10)post_thanks_box
  • (10)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (10)post_thanks_postbit_info
  • (9)postbit
  • (10)postbit_onlinestatus
  • (10)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete