Пример #1
0
        $frm->addmessage("A change was made to the display name configuration of \n             Phorum. This requires some updates in the database.\n             Click \"Continue\" to start the updates.");
    }
    $frm->hidden("module", "update_display_names");
    $frm->hidden("step", "1");
    $frm->show();
} else {
    // The number of users to process in a single batch.
    $batchsize = 100;
    // Quickly show an empty update progress screen.
    if ($step == 1) {
        $batch = -1;
    } else {
        // Find the update batch that we have to run.
        $batch = empty($_REQUEST["batch"]) ? 0 : $_REQUEST["batch"];
        // Retrieve users for this batch.
        $res = phorum_db_user_get_all($batch * $batchsize, $batchsize);
        // Handle batch.
        $updated = 0;
        while ($user = phorum_db_fetch_row($res, DB_RETURN_ASSOC)) {
            $updated++;
            // We save an empty user, to make sure that the display name in the
            // database is up-to-date. This will already run needed updates in
            // case the display name changed ...
            phorum_api_user_save(array("user_id" => $user["user_id"]));
            // ... but still we run the name updates here, so inconsitencies
            // are flattened out.
            $user = phorum_api_user_get($user["user_id"]);
            phorum_db_user_display_name_updates(array("user_id" => $user["user_id"], "display_name" => $user["display_name"]));
        }
        if ($updated == 0) {
            $frm = new PhorumInputForm("", "post", "Finish");
Пример #2
0
if ('cli' != php_sapi_name()) {
    echo "This script cannot be run from a browser.";
    return;
}
define("PHORUM_ADMIN", 1);
define('phorum_page', 'rebuild_real_names');
chdir(dirname(__FILE__) . "/..");
require_once './common.php';
// Make sure that the output is not buffered.
phorum_ob_clean();
if (!ini_get('safe_mode')) {
    set_time_limit(0);
    ini_set("memory_limit", "64M");
}
$count_total = phorum_db_user_count();
$res = phorum_db_user_get_all();
print "\nRebuilding display name information ...\n";
$size = strlen($count_total);
$count = 0;
while ($user = phorum_db_fetch_row($res, DB_RETURN_ASSOC)) {
    // We save an empty user, to make sure that the display name in the
    // database is up-to-date. This will already run needed updates in
    // case the display name changed ...
    phorum_api_user_save(array("user_id" => $user["user_id"]));
    // ... but still we run the name updates here, so inconsistencies
    // are flattened out.
    $user = phorum_api_user_get($user["user_id"]);
    phorum_db_user_display_name_updates(array("user_id" => $user["user_id"], "display_name" => $user["display_name"]));
    $count++;
    $perc = floor($count / $count_total * 100);
    $barlen = floor(20 * ($perc / 100));