コード例 #1
0
echo "Get user list....\n";
$ldap = new clladp();
$users = $ldap->Hash_GetALLUsers();
echo count($users) . " user(s) to scan\n";
$q = new mysql();
while (list($num, $val) = each($users)) {
    $user_id = GetidFromUser($bd, $num);
    echo " 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, $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);
コード例 #2
0
ファイル: exec.roundcube.php プロジェクト: BillTheBest/1.6.x
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";
}