<?php

// Generate package_server table based on the servers set up for all domains, to avoid that when people go to edit an old domain,
// they wouldn't see anything in the servers dropdown, not even the one already set up for this domain.
$query = "SELECT Plan, serverid FROM domains";
$result = mysql_query($query) or die("ERROR in query: $query");
$package_server = array();
while (list($plan, $serverId) = mysql_fetch_row($result)) {
    $item = array($plan, $serverId);
    if (in_array($item, $package_server)) {
        continue;
    }
    $package_server[] = $item;
}

if ($package_server) {
    foreach ($package_server as $entry) {
        $query = "INSERT INTO package_server (package_id, server_id) VALUES({$entry[0]}, {$entry[1]})";
        mysql_query($query) or die("ERROR in query $query");
    }
}


?>
