Index: trunk/extensions/AntiSpoof/AntiSpoof.i18n.php |
— | — | @@ -9,8 +9,12 @@ |
10 | 10 | |
11 | 11 | $messages['en'] = array( |
12 | 12 | 'antispoof-desc' => 'Blocks the creation of accounts with mixed-script, confusing and similar usernames', |
13 | | - 'antispoof-name-conflict' => 'The name "$1" is too similar to the existing account "$2". |
| 13 | + 'antispoof-name-conflict' => 'The name "$1" is too similar to existing accounts: "$2". |
14 | 14 | Please choose another name.', |
| 15 | + 'antispoof-name-conflict2' => '$1 $2', |
| 16 | + 'antispoof-name-conflict3' => '$1 $2 $3', |
| 17 | + 'antispoof-name-conflict4' => '$1 $2 $3 $4', |
| 18 | + 'antispoof-name-conflict5' => '$1 $2 $3 $4 $5', |
15 | 19 | 'antispoof-name-illegal' => 'The name "$1" is not allowed to prevent confusing or spoofed usernames: $2. |
16 | 20 | Please choose another name.', |
17 | 21 | 'antispoof-badtype' => 'Bad data type', |
Index: trunk/extensions/AntiSpoof/AntiSpoof.php |
— | — | @@ -85,9 +85,33 @@ |
86 | 86 | if( $conflict === false ) { |
87 | 87 | wfDebugLog( 'antispoof', "{$mode}PASS new account '$name' [$normalized]" ); |
88 | 88 | } else { |
89 | | - wfDebugLog( 'antispoof', "{$mode}CONFLICT new account '$name' [$normalized] spoofs '$conflict'" ); |
| 89 | + wfDebugLog( 'antispoof', "{$mode}CONFLICT new account '$name' [$normalized] spoofs: '" . implode( ', ', $conflict ) . "'" ); |
90 | 90 | if( $active ) { |
91 | | - $message = wfMsg( 'antispoof-name-conflict', $name, $conflict ); |
| 91 | + $numConflicts = count( $conflict ); |
| 92 | + switch ( $numConflicts ) { |
| 93 | + case 1: |
| 94 | + $message = wfMsg( 'antispoof-name-conflict', $name, $conflict['0'] ); |
| 95 | + break; |
| 96 | + case 2: |
| 97 | + $message = wfMsg( 'antispoof-name-conflict', $name, |
| 98 | + wfMsg( 'antispoof-name-conflict2', $conflict['0'], $conflict['1'] ) ); |
| 99 | + break; |
| 100 | + case 3: |
| 101 | + $message = wfMsg( 'antispoof-name-conflict', $name, |
| 102 | + wfMsg( 'antispoof-name-conflict3', $conflict['0'], $conflict['1'], $conflict['2'] ) ); |
| 103 | + break; |
| 104 | + case 4: |
| 105 | + $message = wfMsg( 'antispoof-name-conflict', $name, |
| 106 | + wfMsg( 'antispoof-name-conflict4', $conflict['0'], $conflict['1'], |
| 107 | + $conflict['2'], $conflict['3'] ) ); |
| 108 | + break; |
| 109 | + case 5: |
| 110 | + $message = wfMsg( 'antispoof-name-conflict', $name, |
| 111 | + wfMsg( 'antispoof-name-conflict5', $conflict['0'], $conflict['1'], $conflict['2'], |
| 112 | + $conflict['3'], $conflict['4'] ) ); |
| 113 | + break; |
| 114 | + } |
| 115 | + |
92 | 116 | return false; |
93 | 117 | } |
94 | 118 | } |
Index: trunk/extensions/AntiSpoof/SpoofUser.php |
— | — | @@ -39,7 +39,7 @@ |
40 | 40 | /** |
41 | 41 | * Does the username pass Unicode legality and script-mixing checks? |
42 | 42 | * |
43 | | - * @return mixed false if no conflict, or string with conflicting username |
| 43 | + * @return mixed false if no conflict, or array with up to five conflicting usernames |
44 | 44 | */ |
45 | 45 | public function getConflict() { |
46 | 46 | if( $this->isLegal() ) { |
— | — | @@ -47,17 +47,26 @@ |
48 | 48 | |
49 | 49 | // Join against the user table to ensure that we skip stray |
50 | 50 | // entries left after an account is renamed or otherwise munged. |
51 | | - $row = $dbr->selectRow( |
| 51 | + $spoofedUsers = $dbr->select( |
52 | 52 | array( 'spoofuser', 'user' ), |
53 | 53 | array( 'user_name' ), |
54 | 54 | array( |
55 | 55 | 'su_normalized' => $this->mNormalized, |
56 | 56 | 'su_name=user_name', |
57 | 57 | ), |
58 | | - __METHOD__ ); |
| 58 | + __METHOD__, |
| 59 | + array( |
| 60 | + 'LIMIT' => 5 |
| 61 | + ) ); |
59 | 62 | |
60 | | - if( $row ) { |
61 | | - return $row->user_name; |
| 63 | + $spoofs = array(); |
| 64 | + |
| 65 | + while( $row = $dbr->fetchObject( $spoofedUsers ) ) { |
| 66 | + array_push( $spoofs, $row->user_name ); |
| 67 | + } |
| 68 | + |
| 69 | + if( count( $spoofs ) > 0 ) { |
| 70 | + return $spoofs; |
62 | 71 | } else { |
63 | 72 | return false; |
64 | 73 | } |