Example #1
0
}
// ###################### Start update usernames #######################
if ($_REQUEST['do'] == 'updateusernames') {
    if (!vB::getUserContext()->hasAdminPermission('canadminmaintain')) {
        print_cp_no_permission();
    }
    if (empty($vbulletin->GPC['perpage'])) {
        $vbulletin->GPC['perpage'] = 1000;
    }
    echo '<p>' . $vbphrase['updating_usernames'] . '</p>';
    $users = $vbulletin->db->query_read("\n\t\tSELECT *\n\t\tFROM " . TABLE_PREFIX . "user\n\t\tWHERE userid >= " . $vbulletin->GPC['startat'] . "\n\t\tORDER BY userid\n\t\tLIMIT " . $vbulletin->GPC['perpage']);
    $finishat = $vbulletin->GPC['startat'];
    while ($user = $vbulletin->db->fetch_array($users)) {
        $userman = new vB_Datamanager_User($vbulletin, vB_DataManager_Constants::ERRTYPE_SILENT);
        $userman->set_existing($user);
        $userman->update_username($user['userid'], $user['username']);
        unset($userman);
        echo construct_phrase($vbphrase['processing_x'], $user['userid']) . "<br />\n";
        vbflush();
        $finishat = $user['userid'] > $finishat ? $user['userid'] : $finishat;
    }
    $finishat++;
    // move past the last processed user
    if ($checkmore = $vbulletin->db->query_first("SELECT userid FROM " . TABLE_PREFIX . "user WHERE userid >= {$finishat} LIMIT 1")) {
        $args = array();
        parse_str(vB::getCurrentSession()->get('sessionurl'), $args);
        $args['do'] = 'updateusernames';
        $args['startat'] = $finishat;
        $args['pp'] = $vbulletin->GPC['perpage'];
        print_cp_redirect2('misc', $args);
        echo "<p><a href=\"misc.php?" . vB::getCurrentSession()->get('sessionurl') . "do=updateusernames&amp;startat={$finishat}&amp;pp=" . $vbulletin->GPC['perpage'] . "\">" . $vbphrase['click_here_to_continue_processing'] . "</a></p>";