<?php


// Value for the new status column in the domains table for the existant domains:
// if the correspondent user.status=0 then domains.status=0
// otherwise domains.status=1
// (had to to this with php because MySQL < 4 won't let update using multiple tables :(

$query = "SELECT id,status FROM users";
$result = mysql_query($query) or die("ERROR (Getting User ids): $query");
$activeUsers = array();
$pendingUsers = array();
while (list($id, $status) = mysql_fetch_row($result)) {
    if ($status == '0') $pendingUsers[] = $id;
    else $activeUsers[] = $id;
}

$activeUsers = implode(',', $activeUsers);
$pendingUsers = implode(',', $pendingUsers);
if ($activeUsers) {
    $query = "UPDATE domains SET status='1' WHERE customerID IN($activeUsers)";
    $result = mysql_query($query) or die("ERROR (updating active users): $query");
}
if ($pendingUsers) {
    $query = "UPDATE domains SET status='0' WHERE customerID IN($pendingUsers)";
    $result = mysql_query($query) or die("ERROR (updating active users): $query");
}

?>
