Beispiel #1
0
    echo $sql . "\n";
    $q->QUERY_SQL($sql, $bd);
    if (!$q->ok) {
        echo "{$sql} \n{$q->mysql_error}\n";
    }
    if ($user_id == 0) {
        CreateRoundCubeUser($bd, $num, $val, '127.0.0.1');
        $user_id = GetidFromUser($bd, $num);
    }
    if ($user_id == 0) {
        continue;
    }
    $identity_id = GetidentityFromuser_id($bd, $user_id);
    if ($identity_id == 0) {
        CreateRoundCubeIdentity($bd, $user_id, $num, $val);
        $identity_id = GetidentityFromuser_id($bd, $user_id);
    }
    if ($identity_id == 0) {
        continue;
    }
    $count = $count + 1;
    UpdateRoundCubeIdentity($bd, $identity_id, $val);
}
echo "\n\nsuccess " . $count . " user(s) updated\n";
function GetidFromUser($bd, $uid)
{
    $sql = "SELECT user_id FROM users where username='******'";
    $q = new mysql();
    $results = $q->QUERY_SQL($sql, $bd);
    while ($ligne = @mysql_fetch_array($results, MYSQL_ASSOC)) {
        $userid[] = $ligne["user_id"];
Beispiel #2
0
function popuplate_db($database = null)
{
    $q = new roundcube();
    if ($database == null) {
        $database = $q->database;
    }
    if (isset($GLOBALS["Populated{$database}"])) {
        return;
    }
    $GLOBALS["Populated{$database}"] = true;
    $users = $GLOBALS["LDAP_USERS"];
    $unix = new unix();
    $mailhost = $unix->hostname_g();
    $count = 0;
    while (list($num, $val) = each($users)) {
        usleep(400000);
        $user_id = GetidFromUser($database, $num);
        if ($GLOBALS["OUTPUT"]) {
            echo "Starting......: " . date("H:i:s") . " [INIT]: user \"{$num}\" {$val} user_id={$user_id}\n";
        }
        $sql = "UPDATE identities SET `email`='{$val}', `reply-to`='{$val}' WHERE name='{$num}';";
        echo $sql . "\n";
        $q->QUERY_SQL($sql);
        if (!$q->ok) {
            echo "{$sql} \n{$q->mysql_error}\n";
        }
        if ($user_id == 0) {
            CreateRoundCubeUser($database, $num, $val, '127.0.0.1');
            $user_id = GetidFromUser($database, $num);
        }
        if ($user_id == 0) {
            continue;
        }
        $identity_id = GetidentityFromuser_id($database, $user_id);
        if ($identity_id == 0) {
            CreateRoundCubeIdentity($database, $user_id, $num, $val);
            $identity_id = GetidentityFromuser_id($database, $user_id);
        }
        if ($identity_id == 0) {
            continue;
        }
        $count = $count + 1;
        UpdateRoundCubeIdentity($database, $identity_id, $val);
    }
    echo "\n\nsuccess " . $count . " user(s) updated\n";
}