equal
deleted
inserted
replaced
212 $row = $db->fetchrow(); |
212 $row = $db->fetchrow(); |
213 if ( $row['username'] == 'Anonymous' ) |
213 if ( $row['username'] == 'Anonymous' ) |
214 return true; |
214 return true; |
215 // Find the first unused user ID |
215 // Find the first unused user ID |
216 $used = Array(); |
216 $used = Array(); |
217 $q = $db->sql_query('SELECT user_id FROM '.table_prefix.'users'); |
217 $q = $db->sql_query('SELECT user_id FROM '.table_prefix.'users;'); |
218 if ( !$q ) |
218 if ( !$q ) |
219 $db->_die(); |
219 $db->_die(); |
220 $c = false; |
220 $notfirst = false; |
221 while ( $row = $db->fetchrow() ) |
221 while ( $row = $db->fetchrow() ) |
222 { |
222 { |
223 $i = intval($row['user_id']); |
223 $i = intval($row['user_id']); |
224 $used[$i] = true; |
224 $used[$i] = true; |
225 if ( !isset($used[$i - 1]) && $c ) |
225 if ( !isset($used[$i - 1]) && $notfirst ) |
226 { |
226 { |
227 $id = $i - 1; |
227 $id = $i - 1; |
228 break; |
228 break; |
229 } |
229 } |
230 $c = true; |
230 $notfirst = true; |
231 } |
231 } |
232 if ( !isset($id) ) |
232 if ( !isset($id) ) |
233 $id = $i + 1; |
233 $id = $i + 1; |
|
234 if ( $id == 0 ) |
|
235 $id = 2; |
234 $db->free_result(); |
236 $db->free_result(); |
235 |
237 |
236 $q = $db->sql_query('UPDATE '.table_prefix.'users SET user_id=' . $id . ' WHERE user_id=1;'); |
238 $q = $db->sql_query('UPDATE '.table_prefix.'users SET user_id=' . $id . ' WHERE user_id=1;'); |
237 if(!$q) |
239 if(!$q) |
238 $db->_die(); |
240 $db->_die(); |
371 } |
373 } |
372 |
374 |
373 function u_1_0_RC3_make_users_extra() |
375 function u_1_0_RC3_make_users_extra() |
374 { |
376 { |
375 global $db; |
377 global $db; |
376 $q = $db->sql_query('SELECT user_id FROM '.table_prefix.'users WHERE user_id > 1;'); |
378 $q = $db->sql_query('SELECT user_id FROM '.table_prefix.'users WHERE user_id > 0;'); |
377 if ( !$q ) |
379 if ( !$q ) |
378 $db->_die(); |
380 $db->_die(); |
379 |
381 |
380 $ids = array(); |
382 $ids = array(); |
381 while ( $row = $db->fetchrow() ) |
383 while ( $row = $db->fetchrow() ) |
382 { |
384 { |
383 $ids[] = intval($row['user_id']); |
385 $ids[] = intval($row['user_id']); |
384 } |
386 } |
385 |
387 |
386 $ids = '(' . implode('),(', $ids) . ')'; |
388 $ids = '(' . implode('),(', $ids) . ')'; |
|
389 if ( $ids == '' ) |
|
390 return false; |
387 $sql = "INSERT INTO " . table_prefix . "users_extra(user_id) VALUES$ids;"; |
391 $sql = "INSERT INTO " . table_prefix . "users_extra(user_id) VALUES$ids;"; |
388 |
392 |
389 if ( !$db->sql_query($sql) ) |
393 if ( !$db->sql_query($sql) ) |
390 $db->_die(); |
394 $db->_die(); |
391 } |
395 } |