Exemplo n.º 1
0
function deleteVPS($id)
{
    global $pro_mysql_vps_table;
    global $pro_mysql_vps_ip_table;
    global $pro_mysql_vps_stats_table;
    global $pro_mysql_cronjob_table;
    $q = "SELECT * FROM {$pro_mysql_vps_table} WHERE id='{$id}';";
    $r = mysql_query($q) or die("Cannot execute query \"{$q}\" line " . __LINE__ . " file " . __FILE__ . " sql said: " . mysql_error());
    $n = mysql_num_rows($r);
    if ($n != 1) {
        die("Didn't find the VPS id you want to delete line " . __LINE__ . " file " . __FILE__);
    }
    $vps = mysql_fetch_array($r);
    $q = "UPDATE {$pro_mysql_vps_ip_table} SET available='yes' WHERE vps_server_hostname='" . $vps["vps_server_hostname"] . "' AND vps_xen_name='" . $vps["vps_xen_name"] . "';";
    $r = mysql_query($q) or die("Cannot execute query \"{$q}\" line " . __LINE__ . " file " . __FILE__ . " sql said: " . mysql_error());
    $q = "DELETE FROM {$pro_mysql_vps_table} WHERE id='" . $_REQUEST["id"] . "';";
    $r = mysql_query($q) or die("Cannot execute query \"{$q}\" line " . __LINE__ . " file " . __FILE__ . " sql said: " . mysql_error());
    $q = "DELETE FROM {$pro_mysql_vps_stats_table} WHERE vps_server_hostname='" . $vps["vps_server_hostname"] . "' AND vps_xen_name='xen" . $vps["vps_xen_name"] . "';";
    $r = mysql_query($q) or die("Cannot execute query \"{$q}\" line " . __LINE__ . " file " . __FILE__ . " sql said: " . mysql_error());
    remoteVPSAction($vps["vps_server_hostname"], $vps["vps_xen_name"], "destroy_vps");
    remoteVPSAction($vps["vps_server_hostname"], $vps["vps_xen_name"], "kill_vps_disk");
    VPS_Server_Subscribe_To_Lists($vps["vps_server_hostname"]);
    $adm_query = "UPDATE {$pro_mysql_cronjob_table} SET gen_nagios='yes' WHERE 1;";
    mysql_query($adm_query);
}
Exemplo n.º 2
0
function DTCdeleteAdmin($adm_to_del)
{
    global $pro_mysql_admin_table;
    global $pro_mysql_domain_table;
    global $pro_mysql_vps_table;
    global $pro_mysql_dedicated_table;
    global $pro_mysql_tik_queries_table;
    global $pro_mysql_cronjob_table;
    global $pro_mysql_ssl_ips_table;
    global $conf_demo_version;
    global $conf_mysql_db;
    if (!isFtpLogin($adm_to_del)) {
        echo "Admin to delete is not in correct format line " . __LINE__ . " file " . __FILE__;
        die;
    }
    $adm_query = "SELECT * FROM {$pro_mysql_admin_table} WHERE adm_login='******'";
    $result = mysql_query($adm_query) or die("Cannot execute query \"{$adm_query}\" !!!");
    $num_rows = mysql_num_rows($result);
    if ($num_rows != 1) {
        die("User not found for deletion of {$adm_to_del} !!!");
    }
    $row_virtual_admin = mysql_fetch_array($result);
    $the_admin_path = $row_virtual_admin["path"];
    // delete the user also mailboxs, ftp accounts, domains and subdomains in database
    $query = "SELECT * FROM {$pro_mysql_domain_table} WHERE owner='{$adm_to_del}';";
    $result = mysql_query($query) or die("Cannot execute query \"{$query}\" !!!");
    $num_rows = mysql_num_rows($result);
    for ($i = 0; $i < $num_rows; $i++) {
        $row = mysql_fetch_array($result);
        //echo "Deleting ".$_REQUEST["delete_admin_user"]." / ".$row_virtual_admin["adm_pass"].$row["name"];
        deleteUserDomain($_REQUEST["delete_admin_user"], $row_virtual_admin["adm_pass"], $row["name"]);
    }
    if ($conf_demo_version == "no") {
        system("rm -rf {$the_admin_path}");
    }
    // Make all SSL vhosts the user registered available again
    $q = "UPDATE {$pro_mysql_ssl_ips_table} SET available='yes' WHERE adm_login='******';";
    $r = mysql_query($q) or die("Cannot execute query {$q} line " . __LINE__ . " file " . __FILE__ . " sql said: " . mysql_error());
    deleteMysqlUserAndDB($adm_to_del);
    // Delete all VPS of the user, and set all its IPs as available
    $q = "SELECT * FROM {$pro_mysql_vps_table} WHERE owner='{$adm_to_del}';";
    $r = mysql_query($q) or die("Cannot execute query \"{$q}\" line " . __LINE__ . " file " . __FILE__ . " sql said: " . mysql_error());
    $n = mysql_num_rows($r);
    for ($i = 0; $i < $n; $i++) {
        $vps = mysql_fetch_array($r);
        $q2 = "UPDATE {$pro_mysql_vps_ip_table} SET available='yes' WHERE vps_server_hostname='" . $vps["vps_server_hostname"] . "' AND vps_xen_name='" . $vps["vps_xen_name"] . "';";
        $r2 = mysql_query($q2) or die("Cannot execute query \"{$q2}\" line " . __LINE__ . " file " . __FILE__ . " sql said: " . mysql_error());
        $q2 = "DELETE FROM {$pro_mysql_vps_stats_table} WHERE vps_server_hostname='" . $vps["vps_server_hostname"] . "' AND vps_xen_name='" . $vps["vps_xen_name"] . "';";
        $r2 = mysql_query($q2) or die("Cannot execute query \"{$q2}\" line " . __LINE__ . " file " . __FILE__ . " sql said: " . mysql_error());
        // Unload (eg: destroy) the VPS directly
        remoteVPSAction($vps["vps_server_hostname"], $vps["vps_xen_name"], "destroy_vps");
        VPS_Server_Subscribe_To_Lists($vps["vps_server_hostname"]);
    }
    $q = "DELETE FROM {$pro_mysql_vps_table} WHERE owner='{$adm_to_del}';";
    $r = mysql_query($q) or die("Cannot execute query \"{$q}\" line " . __LINE__ . " file " . __FILE__ . " sql said: " . mysql_error());
    // Delete all dedicated servers of the admin
    $q = "DELETE FROM {$pro_mysql_dedicated_table} WHERE owner='{$adm_to_del}';";
    $r = mysql_query($q) or die("Cannot execute query \"{$q}\" line " . __LINE__ . " file " . __FILE__ . " sql said: " . mysql_error());
    // Delete all support tickets of the admin
    $q = "DELETE FROM {$pro_mysql_tik_queries_table} WHERE adm_login='******';";
    $r = mysql_query($q) or die("Cannot execute query \"{$q}\" line " . __LINE__ . " file " . __FILE__ . " sql said: " . mysql_error());
    $adm_query = "DELETE FROM {$pro_mysql_admin_table} WHERE adm_login='******'";
    mysql_query($adm_query) or die("Cannot execute query \"{$adm_query}\" !!!");
    // Tell the cron job to activate the changes (in case there was some shared accounts. Todo: check if there is some...)
    $adm_query = "UPDATE {$pro_mysql_cronjob_table} SET qmail_newu='yes',restart_qmail='yes',reload_named='yes',\n\trestart_apache='yes',gen_vhosts='yes',gen_named='yes',gen_qmail='yes',gen_webalizer='yes',gen_backup='yes',gen_ssh='yes',gen_fetchmail='yes' WHERE 1;";
    mysql_query($adm_query);
    triggerDomainListUpdate();
}
Exemplo n.º 3
0
function addVPSToUser($adm_login, $vps_server_hostname, $product_id, $operating_system = "debian")
{
    global $pro_mysql_product_table;
    global $pro_mysql_vps_ip_table;
    global $pro_mysql_vps_table;
    $q = "SELECT * FROM {$pro_mysql_product_table} WHERE id='{$product_id}';";
    $r = mysql_query($q) or die("Cannot query : \"{$q}\" line " . __LINE__ . " file " . __FILE__ . " sql said " . mysql_error());
    $n = mysql_num_rows($r);
    if ($n != 1) {
        die("Cannot find product line " . __LINE__ . " file " . __FILE__);
    }
    $product = mysql_fetch_array($r);
    $q = "SELECT * FROM {$pro_mysql_vps_ip_table} WHERE available='yes' AND vps_server_hostname='{$vps_server_hostname}' LIMIT 1;";
    $r = mysql_query($q) or die("Cannot query : \"{$q}\" line " . __LINE__ . " file " . __FILE__ . " sql said " . mysql_error());
    $n = mysql_num_rows($r);
    if ($n != 1) {
        die("Cannot find available IP and Xen name in {$vps_server_hostname} line " . __LINE__ . " file " . __FILE__);
    }
    $vps_ip = mysql_fetch_array($r);
    $q = "UPDATE {$pro_mysql_vps_ip_table} SET available='no',rdns_addr='mx.xen" . $vps_ip["vps_xen_name"] . "." . $vps_ip["vps_server_hostname"] . "' WHERE vps_xen_name='" . $vps_ip["vps_xen_name"] . "' AND vps_server_hostname='" . $vps_ip["vps_server_hostname"] . "';";
    $r = mysql_query($q) or die("Cannot query : \"{$q}\" line " . __LINE__ . " file " . __FILE__ . " sql said " . mysql_error());
    $exp_date = calculateExpirationDate(date("Y-m-d"), $product["period"]);
    $q = "INSERT INTO {$pro_mysql_vps_table} (id,owner,vps_server_hostname,vps_xen_name,start_date,expire_date,hddsize,ramsize,product_id,bandwidth_per_month_gb,operatingsystem)\n\tVALUES('','{$adm_login}','" . $vps_ip["vps_server_hostname"] . "','" . $vps_ip["vps_xen_name"] . "','" . date("Y-m-d") . "','{$exp_date}','" . $product["quota_disk"] . "','" . $product["memory_size"] . "','{$product_id}','" . $product["bandwidth"] . "','{$operating_system}');";
    $r = mysql_query($q) or die("Cannot query : \"{$q}\" line " . __LINE__ . " file " . __FILE__ . " sql said " . mysql_error());
    updateUsingCron("gen_named='yes',reload_named ='yes'");
    // Subscribe user to the lists of the VPS
    VPS_Server_Subscribe_To_Lists($vps_server_hostname);
    return $vps_ip["vps_xen_name"];
}