Example #1
0
function remoteVPSAction($vps_node, $vps_name, $action)
{
    $soap_client = connectToVPSServer($vps_node);
    if ($soap_client === false) {
        echo "<font color=\"red\">" . _("Could not connect to VPS server!") . "</font>";
        return;
    }
    switch ($action) {
        case "start_vps":
            $r = $soap_client->call("startVPS", array("vpsname" => "xen" . $vps_name), "", "", "");
            break;
        case "destroy_vps":
            $r = $soap_client->call("destroyVPS", array("vpsname" => "xen" . $vps_name), "", "", "");
            break;
        case "shutdown_vps":
            $r = $soap_client->call("shutdownVPS", array("vpsname" => "xen" . $vps_name), "", "", "");
            break;
        case "kill_vps_disk":
            $r = $soap_client->call("killVPS", array("vpsname" => $vps_name), "", "", "");
            break;
        default:
            break;
    }
    $err = $soap_client->getError();
    if (!$err) {
        //    echo "Result: ".print_r($r);
    } else {
        echo "Error: " . $err;
    }
}
Example #2
0
function validateWaitingUser($waiting_login_id)
{
    global $conf_administrative_site;
    global $conf_use_ssl;
    global $pro_mysql_admin_table;
    global $pro_mysql_client_table;
    global $pro_mysql_new_admin_table;
    global $pro_mysql_product_table;
    global $pro_mysql_vps_ip_table;
    global $pro_mysql_vps_server_table;
    global $pro_mysql_completedorders_table;
    global $pro_mysql_domain_table;
    global $dtcshared_path;
    global $txt_userwaiting_account_activated_subject;
    global $txt_userwaiting_account_activated_text_header;
    global $conf_site_root_host_path;
    global $conf_demo_version;
    global $conf_use_ssl;
    global $conf_webmaster_email_addr;
    global $conf_this_server_country_code;
    global $conf_message_subject_header;
    global $console;
    //get affiliate cookie
    if (isset($_COOKIE["affiliate"]) && isMailbox($affiliatename)) {
        $affiliatename = $_COOKIE["affiliate"];
    }
    if (isset($affiliatename)) {
        //Step 1: validate that the affiliatename exists
        $q = "SELECT * FROM {$pro_mysql_admin_table} WHERE adm_login='******';";
        $r = mysql_query($q) or die("Cannot execute query \"{$q}\" ! line: " . __LINE__ . " file: " . __FILE__ . " sql said: " . mysql_error());
        if (mysql_num_rows($r) != 1) {
            unset($affiliatename);
        }
        // at this point, we should have an affiliatename
    }
    // Get the informations from the user waiting table
    $q = "SELECT * FROM {$pro_mysql_new_admin_table} WHERE id='{$waiting_login_id}';";
    //	$q = "SELECT * FROM $pro_mysql_new_admin_table WHERE reqadm_login='******';";
    $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("I can't find username with id {$waiting_login_id} in the userwaiting table line: " . __LINE__ . " file: " . __FILE__ . "!");
    }
    $a = mysql_fetch_array($r);
    $waiting_login = $a["reqadm_login"];
    $last_used_lang = $a["last_used_lang"];
    // Check if there is a user by that name
    $q = "SELECT * FROM {$pro_mysql_admin_table} WHERE adm_login='******';";
    $r = mysql_query($q) or die("Cannot execute query \"{$q}\" ! line: " . __LINE__ . " file: " . __FILE__ . " sql said: " . mysql_error());
    $n = mysql_num_rows($r);
    if ($a["add_service"] == "yes") {
        if ($n != 1) {
            die("There is no user with name {$waiting_login} in database: I can't add a service to it line: " . __LINE__ . " file: " . __FILE__ . "!");
        }
        $existing_admin = mysql_fetch_array($r);
        $cid = $existing_admin["id_client"];
        $vps_root_pass = $existing_admin["adm_pass"];
    } else {
        if ($n != 0) {
            die("There is already a user with name {$waiting_login} in database: I can't add another one line: " . __LINE__ . " file: " . __FILE__ . "!");
        }
        $vps_root_pass = $a["reqadm_pass"];
    }
    // Calculate user's path with default path
    $newadmin_path = $conf_site_root_host_path . "/" . $waiting_login;
    // Create admin's directory
    if ($conf_demo_version == "no" && $a["add_service"] != "yes") {
        $oldumask = umask(0);
        if (!file_exists($newadmin_path)) {
            mkdir("{$newadmin_path}", 0750);
            $console .= "mkdir {$newadmin_path};<br>";
        }
    }
    // Get the informations from the product table
    $q2 = "SELECT * FROM {$pro_mysql_product_table} WHERE id='" . $a["product_id"] . "'";
    $r2 = mysql_query($q2) or die("Cannot execute query \"{$q2}\" ! line: " . __LINE__ . " file: " . __FILE__ . " sql said: " . mysql_error());
    $n2 = mysql_num_rows($r2);
    if ($n2 != 1) {
        die("I can't find the product in the table line: " . __LINE__ . " file: " . __FILE__ . "!");
    }
    $a2 = mysql_fetch_array($r2);
    // Add customer's info to production table
    if ($a["add_service"] != "yes") {
        $adm_query = "INSERT INTO {$pro_mysql_client_table}\n(id,is_company,company_name,vat_num,familyname,christname,addr1,addr2,addr3,\ncity,zipcode,state,country,phone,fax,email,\ndisk_quota_mb,bw_quota_per_month_gb,\nspecial_note) VALUES ('','" . $a["iscomp"] . "',\n'" . addslashes($a["comp_name"]) . "','" . addslashes($a["vat_num"]) . "','" . addslashes($a["family_name"]) . "','" . addslashes($a["first_name"]) . "',\n'" . addslashes($a["addr1"]) . "','" . addslashes($a["addr2"]) . "','" . addslashes($a["addr3"]) . "','" . addslashes($a["city"]) . "',\n'" . addslashes($a["zipcode"]) . "','" . addslashes($a["state"]) . "','" . addslashes($a["country"]) . "','" . addslashes($a["phone"]) . "',\n'" . addslashes($a["fax"]) . "','" . addslashes($a["email"]) . "','" . $a2["quota_disk"] . "','" . $a2["bandwidth"] / 1024 . "',\n'" . addslashes($a["restricted_ftp_path"]) . "','" . addslashes($a["allow_dns_and_mx_change"]) . "',\n'" . addslashes($a["ftp_login_flag"]) . "','" . addslashes($a["allow_mailing_list_edit"]) . "','" . addslashes($a["allow_subdomain_edit"]) . "',\n'" . addslashes($a["custom_notes"]) . "');";
        $r = mysql_query($adm_query) or die("Cannot execute query \"{$adm_query}\" ! line: " . __LINE__ . " file: " . __FILE__ . " sql said: " . mysql_error());
        $cid = mysql_insert_id();
    }
    // Add user in database
    $expires = calculateExpirationDate(date("Y-m-d"), $a2["period"]);
    if ($a2["heb_type"] == "vps") {
        $admtbl_added1 = ",expire,prod_id";
        $admtbl_added2 = ",'0000-00-00','0'";
    } else {
        if ($a2["heb_type"] == "server") {
            $admtbl_added1 = ",expire,prod_id";
            $admtbl_added2 = ",'0000-00-00','0'";
        } else {
            $admtbl_added1 = ",expire,prod_id";
            $admtbl_added2 = ",'{$expires}','" . $a2["id"] . "'";
            $admtbl_added3 = ", expire='{$expires}', prod_id='" . $a2["id"] . "' ";
        }
    }
    if ($a["add_service"] != "yes") {
        $adm_query = "INSERT INTO {$pro_mysql_admin_table}\n(adm_login        ,adm_pass              ,last_used_lang   ,path            ,id_client,bandwidth_per_month_mb,quota,nbrdb,allow_add_domain,max_domain,restricted_ftp_path,allow_dns_and_mx_change,ftp_login_flag,allow_mailing_list_edit,allow_subdomain_edit,max_email{$admtbl_added1}) VALUES\n('{$waiting_login}','" . $a["reqadm_pass"] . "','{$last_used_lang}','{$newadmin_path}','{$cid}','" . $a2["bandwidth"] . "','" . $a2["quota_disk"] . "','" . $a2["nbr_database"] . "','" . $a2["allow_add_domain"] . "','" . $a2["max_domain"] . "',\n'" . $a2["restricted_ftp_path"] . "','" . $a2["allow_dns_and_mx_change"] . "','" . $a2["ftp_login_flag"] . "','" . $a2["allow_mailing_list_edit"] . "','" . $a2["allow_subdomain_edit"] . "','" . $a2["nbr_email"] . "'{$admtbl_added2});";
        mysql_query($adm_query) or die("Cannot execute query \"{$adm_query}\" ! line: " . __LINE__ . " file: " . __FILE__ . " sql said: " . mysql_error());
    } else {
        if ($a2["heb_type"] == "shared") {
            $adm_query = "UPDATE {$pro_mysql_admin_table}\n\t\t\tSET bandwidth_per_month_mb='" . $a2["bandwidth"] . "', quota='" . $a2["quota_disk"] . "', nbrdb='" . $a2["nbr_database"] . "',\n\t\t\tallow_add_domain='" . $a2["allow_add_domain"] . "', max_domain='" . $a2["max_domain"] . "', restricted_ftp_path='" . $a2["restricted_ftp_path"] . "',\n\t\t\tallow_dns_and_mx_change='" . $a2["allow_dns_and_mx_change"] . "', ftp_login_flag='" . $a2["ftp_login_flag"] . "', allow_mailing_list_edit='" . $a2["allow_mailing_list_edit"] . "',\n\t\t\tallow_subdomain_edit='" . $a2["allow_subdomain_edit"] . "', max_email='" . $a2["nbr_email"] . "' {$admtbl_added3}\n\t\t\tWHERE adm_login='******';";
            mysql_query($adm_query) or die("Cannot execute query \"{$adm_query}\" ! line: " . __LINE__ . " file: " . __FILE__ . " sql said: " . mysql_error());
        }
    }
    if ($a2["heb_type"] == "vps") {
        $vps_xen_name = addVPSToUser($waiting_login, $a["vps_location"], $a2["id"], $a["vps_os"]);
        $soap_client = connectToVPSServer($a["vps_location"]);
        if ($soap_client == false) {
            echo "Could not connect to the VPS server for doing the setup: please contact the administrator!";
        } else {
            $image_type = "lvm";
            if (isVPSNodeLVMEnabled($a["vps_location"]) == "no") {
                $image_type = "vbd";
            }
            $r = $soap_client->call("setupLVMDisks", array("vpsname" => $vps_xen_name, "hddsize" => $a2["quota_disk"], "swapsize" => $a2["memory_size"], "imagetype" => $image_type), "", "", "");
            $qvps = "SELECT * FROM {$pro_mysql_vps_ip_table} WHERE vps_server_hostname='" . $a["vps_location"] . "' AND vps_xen_name='{$vps_xen_name}' LIMIT 1;";
            $rvps = mysql_query($qvps) or die("Cannot execute query \"{$qvps}\" line " . __LINE__ . " file: " . __FILE__ . " sql said: " . mysql_error());
            $nvps = mysql_num_rows($rvps);
            if ($nvps != 1) {
                echo "Cannot find VPS IP: wont be able to setup the os, please get in touch with the administrator!";
            } else {
                $avps = mysql_fetch_array($rvps);
                $r = $soap_client->call("reinstallVPSos", array("vpsname" => $vps_xen_name, "ostype" => $a["vps_os"], "hddsize" => $a2["quota_disk"], "ramsize" => $a2["memory_size"], "ipaddr" => $avps["ip_addr"], "password" => $vps_root_pass), "", "", "");
                $qcountry = "SELECT * FROM {$pro_mysql_vps_server_table} WHERE hostname='" . $a["vps_location"] . "';";
                $rcountry = mysql_query($qcountry) or die("Cannot execute query \"{$qcountry}\" line " . __LINE__ . " file: " . __FILE__ . " sql said: " . mysql_error());
                $ncountry = mysql_num_rows($rcountry);
                if ($ncountry != 1) {
                    echo "Cannot find VPS server country!";
                    $country = 'US';
                } else {
                    $acountry = mysql_fetch_array($rcountry);
                    $country = $acountry["country_code"];
                }
            }
        }
        // Read the (customizable) registration message to send
        $txt_welcome_message = readCustomizedMessage("registration_msg/vps_open", $waiting_login);
    } else {
        if ($a2["heb_type"] == "server") {
            // As there is currently no dedicated server provision system, we just do this:
            $country = $conf_this_server_country_code;
            addDedicatedToUser($waiting_login, $a["domain_name"], $a2["id"]);
            // Read the (customizable) registration message to send
            $txt_welcome_message = readCustomizedMessage("registration_msg/dedicated_open", $waiting_login);
        } else {
            $country = $conf_this_server_country_code;
            addDomainToUser($waiting_login, $a["reqadm_pass"], $a["domain_name"]);
            // Read the (customizable) registration message to send
            $txt_welcome_message = readCustomizedMessage("registration_msg/shared_open", $waiting_login);
            $q = "UPDATE {$pro_mysql_domain_table} SET max_email='" . $a2["nbr_email"] . "',quota='" . $a2["quota_disk"] . "' WHERE name='" . $a["domain_name"] . "';";
            $r = mysql_query($q) or die("Cannot execute query \"{$q}\" ! line: " . __LINE__ . " file: " . __FILE__ . " sql said: " . mysql_error());
        }
    }
    // Send a mail to user with how to login and use interface.
    $txt_userwaiting_account_activated_subject = "{$conf_message_subject_header} Account {$waiting_login} has been activated!";
    // Manage the signature of all registration messages
    $signature = readCustomizedMessage("signature", $waiting_login);
    $msg_2_send = str_replace("%%%SIGNATURE%%%", $signature, $txt_welcome_message);
    // Manage the login info part of the message
    if ($conf_use_ssl == "yes") {
        $surl = "s";
    } else {
        $surl = "";
    }
    $dtc_login_info = "URL: http{$surl}://{$conf_administrative_site}/dtc/\nLogin: {$waiting_login}\nPassword: "******"reqadm_pass"];
    $msg_2_send = str_replace("%%%DTC_LOGIN_INFO%%%", $dtc_login_info, $msg_2_send);
    // Manage the header of the messages
    $head = readCustomizedMessage("messages_header", $waiting_login);
    $msg_2_send = $head . "\n" . $msg_2_send;
    $headers = "From: " . $conf_webmaster_email_addr;
    mail($a["email"], $txt_userwaiting_account_activated_subject, $msg_2_send, $headers);
    // Now add a command to the user so we keep tracks of payments
    $q = "INSERT INTO {$pro_mysql_completedorders_table} (id,id_client,domain_name,quantity,date,product_id,payment_id,country_code,last_expiry_date)\n\tVALUES ('','{$cid}','" . $a["domain_name"] . "','1','" . date("Y-m-d") . "','" . $a["product_id"] . "','" . $a["paiement_id"] . "','{$country}','" . date("Y-d-m") . "');";
    mysql_query($q) or die("Cannot execute query \"{$q}\" ! line: " . __LINE__ . " file: " . __FILE__ . " sql said: " . mysql_error());
    if (isset($affiliatename)) {
        // Step 2) retrieve the kickback from the products table
        $kickback = $a2["affiliate_kickback"];
        $orderid = mysql_insert_id();
        if ($kickback) {
            // Step 3) if a kickback exists, store it in the affiliate transaction table
            $kickback = 1.0 + $kickback - 1.0;
            //cast to float.  I hate PHP.
            $xxs = "INSERT INTO affiliate_payments (adm_login,order_id,kickback) VALUES('{$affiliatename}',{$orderid},{$kickback});";
            mysql_query($q) or die("Cannot execute query \"{$q}\" ! line: " . __LINE__ . " file: " . __FILE__ . " sql said: " . mysql_error());
        }
    }
    // Finaly delete the user from the userwaiting table
    $q = "DELETE FROM {$pro_mysql_new_admin_table} WHERE id='{$waiting_login_id}';";
    mysql_query($q) or die("Cannot execute query \"{$q}\" ! line: " . __LINE__ . " file: " . __FILE__ . " sql said: " . mysql_error());
}
Example #3
0
// get_install_log.php?adm_login=$adm_login&adm_pass=$adm_pass&vps_node=$vps_node&vps_name=$vps_name
$panel_type = "admin";
require_once "../shared/autoSQLconfig.php";
require_once "{$dtcshared_path}/dtc_lib.php";
$vps_name = $_REQUEST["vps_name"];
$vps_node = $_REQUEST["vps_node"];
if (!isRandomNum($vps_name)) {
    die("Not a vps number...");
}
if (!isHostname($vps_node)) {
    die("Not a vps name...");
}
if (checkVPSAdmin($adm_login, $adm_pass, $vps_node, $vps_name) == false) {
    die("Login, pass, vps number or node name incorrect: access not granted!");
}
$soap_client = connectToVPSServer($vps_node);
if ($soap_client != false) {
    // getVPSInstallLog(vpsname,numlines)
    $r = $soap_client->call("getVPSInstallLog", array("vpsname" => $vps_name, "numlines" => "0"), "", "", "");
    $err = $soap_client->getError();
    if ($err) {
        die("Could not get VPS install log. Error: " . $err);
    }
    // prepare to send JSON
    header('Content-type: application/json');
    // disable cookies (so script works for privacy conscious users too)
    ini_set('session.use_cookies', false);
    // start ongoing or new session
    if (isset($_GET["PHPSESSID"])) {
        session_id($_GET["PHPSESSID"]);
    } else {
    $a = mysql_fetch_array($r);
    $q = "UPDATE {$pro_mysql_vps_ip_table} SET available='no' WHERE vps_xen_name='" . $a["vps_xen_name"] . "' AND vps_server_hostname='" . $a["vps_server_hostname"] . "';";
    $r = mysql_query($q) or die("Cannot execute query \"{$q}\" line " . __LINE__ . " file " . __FILE__ . " sql said: " . mysql_error());
    $q = "SELECT * FROM {$pro_mysql_product_table} WHERE id='" . $_REQUEST["product_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 IP address you want to add line " . __LINE__ . " file " . __FILE__);
    }
    $prod = mysql_fetch_array($r);
    $exp_date = calculateExpirationDate(date("Y-m-d"), $prod["period"]);
    $q = "INSERT INTO {$pro_mysql_vps_table} (id,owner,vps_server_hostname,vps_xen_name,start_date,expire_date,hddsize,ramsize,bandwidth_per_month_gb,product_id)\n\tVALUES('','{$adm_login}','" . $a["vps_server_hostname"] . "','" . $a["vps_xen_name"] . "','" . date("Y-m-d") . "','{$exp_date}','" . $prod["quota_disk"] . "','" . $prod["memory_size"] . "','" . $prod["bandwidth"] . "','" . $_REQUEST["product_id"] . "');";
    $r = mysql_query($q) or die("Cannot execute query \"{$q}\" line " . __LINE__ . " file " . __FILE__ . " sql said: " . mysql_error());
    // Setup the physical VPS (do the lvcreate remotly)
    if ($_REQUEST["physical_setup"] == "yes") {
        $soap_client = connectToVPSServer($a["vps_server_hostname"]);
        if ($soap_client == false) {
            echo "Could not connect to the VPS server for doing the setup: please contact the administrator!";
        } else {
            $image_type = "lvm";
            if (isVPSNodeLVMEnabled($a["vps_server_hostname"]) == "no") {
                $image_type = "vbd";
            }
            $r = $soap_client->call("setupLVMDisks", array("vpsname" => $a["vps_xen_name"], "hddsize" => $prod["quota_disk"], "swapsize" => $prod["memory_size"], "imagetype" => $image_type), "", "", "");
        }
    }
}
// Import of domain config
if (isset($_REQUEST["action"]) && $_REQUEST["action"] == "import_domain") {
    $adm_path = getAdminPath($adm_login);
    $uploaded_file = basename($_FILES['domain_import_file']['name']);
Example #5
0
    $_SESSION['vps_node'] = $_REQUEST["vps_node"];
    $delay = 0;
} else {
    $delay = 2;
}
require_once "../shared/autoSQLconfig.php";
require_once "../shared/dtc_lib.php";
$errorset = false;
function terminate($errString)
{
    global $errorset;
    $_SESSION['lastlog'] = $errString;
    $_SESSION['callSID'] = '';
    $errorset = true;
}
$soap_client = connectToVPSServer($_SESSION['vps_node']);
if ($soap_client != false) {
    $err = $soap_client->getError();
    if ($err) {
        terminate("Could not get VPS install log. Error: " . $err);
    } else {
        sleep($delay);
        // delay AJAX refresh 2 seconds - FIXME change to what you want
        $vps_remote_info = getVPSInfo($_SESSION['vps_node'], $_SESSION['vps_name'], $soap_client);
        if ($vps_remote_info != "mkos") {
            $_SESSION['callSID'] = '';
        }
        // install finished, set termination signal
        $_SESSION['lastlog'] = $soap_client->call("getVPSInstallLog", array("vpsname" => $_SESSION['vps_name'], "numlines" => "20"), "", "", "");
        // get last 20 log lines
    }
Example #6
0
 }
 $vps_query = "SELECT * FROM {$pro_mysql_vps_server_table};";
 if (($vps_servers_result = mysql_query($vps_query)) === FALSE) {
     fwrite($log_fp, date("Y-m-d H:i:s") . " " . mysql_error() . "\n");
     continue;
 }
 //die("Cannot query $query !!!".mysql_error());
 $vps_servers_num_rows = mysql_num_rows($vps_servers_result);
 for ($i = 0; $i < $vps_servers_num_rows; $i++) {
     // sleep 5 seconds between every soap call, we don't want to kill the soap servers
     // sleep (5);
     $all_recs = array();
     $vps_servers_row = mysql_fetch_array($vps_servers_result);
     $vps_server = $vps_servers_row['hostname'];
     fwrite($log_fp, date("Y-m-d H:i:s") . " Fetching stats from server {$i}/{$vps_servers_num_rows}: {$vps_server}...\n");
     $soap_client = connectToVPSServer($vps_server);
     $r = $soap_client->call("getCollectedPerformanceData", array("count" => 64), "", "", "");
     $err = $soap_client->getError();
     if ($err) {
         fwrite($log_fp, date("Y-m-d H:i:s") . " " . $err);
         continue;
     }
     //
     // Save collected datas in /var/lib/dtc/dtc-xenservers-rrds
     //
     // Create the folder if it doesn't exists
     if (!file_exists("/var/lib/dtc/dtc-xenservers-rrds/{$vps_server}")) {
         mkdir("/var/lib/dtc/dtc-xenservers-rrds/{$vps_server}", 0755);
     }
     if (!is_array($r)) {
         fwrite($log_fp, date("Y-m-d H:i:s") . " No data in this fetch!\n");
Example #7
0
function drawAdminTools_VPSMonitor($admin, $vps)
{
    global $vps_name;
    global $vps_node;
    global $adm_login;
    global $adm_pass;
    global $rub;
    global $addrlink;
    global $vps_soap_err;
    global $pro_mysql_product_table;
    global $pro_mysql_vps_ip_table;
    global $pro_mysql_vps_stats_table;
    global $secpayconf_currency_letters;
    global $panel_type;
    $reinstall_os = 1;
    get_secpay_conf();
    $out = "";
    $checker = checkVPSAdmin($adm_login, $adm_pass, $vps_node, $vps_name);
    if ($checker != true) {
        return _("Credential not correct: can't display in file ") . __FILE__ . " line " . __LINE__;
    }
    $vps_out = "";
    $vps_out_net_stats = "";
    $vps_out_hdd_stats = "";
    $vps_out_swap_stats = "";
    $vps_out_cpu_stats = "";
    // Calculate last month
    $cur_year = date("Y");
    $cur_month = date("m");
    $last_month = $cur_month - 1;
    if ($last_month == 0) {
        $last_month_year = $cur_year - 1;
        $last_month = 12;
    } else {
        $last_month_year = $cur_year;
    }
    $tow_month_ago = $last_month - 1;
    if ($tow_month_ago == 0) {
        $tow_month_ago = 12;
        $tow_month_ago_year = $last_month_year - 1;
    } else {
        $tow_month_ago_year = $last_month_year;
    }
    $q = "SELECT * FROM {$pro_mysql_vps_stats_table} WHERE vps_server_hostname='{$vps_node}' AND vps_xen_name='xen{$vps_name}'\n\tAND year='{$tow_month_ago_year}' AND month='{$tow_month_ago}';";
    $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) {
        $a = mysql_fetch_array($r);
        $net_total = $a["network_in_count"] + $a["network_out_count"];
        $vps_out_net_stats .= _("2 months ago: ") . smartByte($net_total) . "<br>";
        $vps_out_cpu_stats .= _("2 months ago: ") . $a["cpu_usage"] . _(" CPU seconds") . "<br>";
        $vps_out_swap_stats .= _("2 months ago: ") . smartByte($a["swapio_count"]) . "<br>";
        $vps_out_hdd_stats .= _("2 months ago: ") . smartByte($a["diskio_count"]) . "<br>";
    }
    $q = "SELECT * FROM {$pro_mysql_vps_stats_table} WHERE vps_server_hostname='{$vps_node}' AND vps_xen_name='xen{$vps_name}'\n\tAND year='{$last_month_year}' AND month='{$last_month}';";
    $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) {
        $a = mysql_fetch_array($r);
        $net_total = $a["network_in_count"] + $a["network_out_count"];
        $vps_out_net_stats .= _("Last month: ") . smartByte($net_total) . "<br>";
        $vps_out_cpu_stats .= _("Last month: ") . $a["cpu_usage"] . _(" CPU seconds") . "<br>";
        $vps_out_swap_stats .= _("Last month: ") . smartByte($a["swapio_count"]) . "<br>";
        $vps_out_hdd_stats .= _("Last month: ") . smartByte($a["diskio_count"]) . "<br>";
    }
    $q = "SELECT * FROM {$pro_mysql_vps_stats_table} WHERE vps_server_hostname='{$vps_node}' AND vps_xen_name='xen{$vps_name}'\n\tAND year='{$cur_year}' AND month='{$cur_month}';";
    $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) {
        $a = mysql_fetch_array($r);
        $net_total = $a["network_in_count"] + $a["network_out_count"];
        $vps_out_net_stats .= _("This month: ") . smartByte($net_total);
        $vps_out_cpu_stats .= _("This month: ") . $a["cpu_usage"] . _(" CPU seconds");
        $vps_out_swap_stats .= _("This month: ") . smartByte($a["swapio_count"]);
        $vps_out_hdd_stats .= _("This month: ") . smartByte($a["diskio_count"]);
    }
    // Display the stats of the VPS
    $vps_stat_out = "";
    $vps_stat_out .= "<table cellspacing=\"2\" cellpaddig=\"2\" border=\"0\">";
    $vps_stat_out .= "<tr><td>" . _("Network:") . "<br>";
    $vps_stat_out .= "<img width=\"120\" height=\"48\" src=\"vps_stats_network.php?adm_login={$adm_login}&adm_pass={$adm_pass}&vps_node={$vps_node}&vps_name={$vps_name}\"></td>";
    $vps_stat_out .= "<td>" . _("CPU Time:") . "<br>";
    $vps_stat_out .= "<img width=\"120\" height=\"48\" src=\"vps_stats_cpu.php?adm_login={$adm_login}&adm_pass={$adm_pass}&vps_node={$vps_node}&vps_name={$vps_name}\"></td></tr>";
    $vps_stat_out .= "<tr><td>" . $vps_out_net_stats . "</td><td>{$vps_out_cpu_stats}</td></tr>";
    $vps_stat_out .= "<tr><td>" . _("Swap I/O:") . "<br>";
    $vps_stat_out .= "<img width=\"120\" height=\"48\" src=\"vps_stats_swap.php?adm_login={$adm_login}&adm_pass={$adm_pass}&vps_node={$vps_node}&vps_name={$vps_name}\"></td>";
    $vps_stat_out .= "<td>" . _("HDD I/O:") . "<br>";
    $vps_stat_out .= "<img width=\"120\" height=\"48\" src=\"vps_stats_hdd.php?adm_login={$adm_login}&adm_pass={$adm_pass}&vps_node={$vps_node}&vps_name={$vps_name}\"></td></tr>";
    $vps_stat_out .= "<tr><td>" . $vps_out_swap_stats . "</td><td>" . $vps_out_hdd_stats . "</td></tr></table>";
    // VPS (remote SOAP) Status
    $soap_client = connectToVPSServer($vps_node);
    if ($soap_client != false) {
        $vps_remote_info = getVPSInfo($vps_node, $vps_name, $soap_client);
        if ($vps_remote_info == false) {
            if (strstr($vps_soap_err, _("Method getVPSState failed"))) {
                $vps_out .= _("Could not get remote status (Method getVPSState() failed). Maybe the VPS is not running?") . "<br><br>";
            } else {
                if (strstr($vps_soap_err, _("couldn't connect to host"))) {
                    $vps_out .= _("Could not get remote status: could not connect to the SOAP server (HTTP error).") . "<br><br>";
                } else {
                    $vps_out .= _("Could not get remote status. Unkown error: ") . "{$vps_soap_err}<br><br>";
                }
            }
        } else {
            if ($vps_remote_info == "fsck") {
                $vps_out .= _("Checking filesystem...") . "<br><br>";
            } else {
                if ($vps_remote_info == "mkos") {
                    $vps_out .= _("Reinstalling operating system...") . "<br><br>";
                } else {
                    if (isset($vps_remote_info["id"])) {
                        $vps_out .= _("VM id: ") . $vps_remote_info["id"] . "<br>";
                    }
                    if (isset($vps_remote_info["name"])) {
                        $vps_out .= _("Name: ") . $vps_remote_info["name"] . "<br>";
                    }
                    if (isset($vps_remote_info["memory"])) {
                        $vps_out .= _("Memory: ") . $vps_remote_info["memory"] . "<br>";
                    }
                    if (isset($vps_remote_info["maxmem"])) {
                        $vps_out .= _("Max memory: ") . $vps_remote_info["maxmem"] . "<br>";
                    } else {
                        $vps_out .= _("Maxmem: cannot fetch (maybe boot in progress?)") . "<br>";
                    }
                    if (isset($vps_remote_info["cpu"])) {
                        $vps_out .= _("Number of CPU: ") . $vps_remote_info["cpu"] . "<br>";
                    } else {
                        $vps_out .= _("Number of CPU: cannot fetch (maybe boot in progress?)") . "<br>";
                    }
                    if (isset($vps_remote_info["state"])) {
                        $vps_out .= _("VPS State: ") . $vps_remote_info["state"] . "<br>";
                    } else {
                        $vps_out .= _("State: cannot fetch (maybe boot in progress?)") . "<br>";
                    }
                    if ($vps_remote_info["xen_type"] == 2 && isset($vps_remote_info["up_time"])) {
                        $uptime = substr($vps_remote_info["up_time"], 0, strpos($vps_remote_info["up_time"], "."));
                        $uptime_s = $uptime % 60;
                        $uptime_m = round($uptime / 60) % 60;
                        $uptime_h = round($uptime / 3600) % 24;
                        $uptime_j = round($uptime / 86400);
                        if ($uptime_s > 1) {
                            $upt_s_s = "s";
                        } else {
                            $upt_s_s = "";
                        }
                        if ($uptime_m > 1) {
                            $upt_s_m = "s";
                        } else {
                            $upt_s_m = "";
                        }
                        if ($uptime_h > 1) {
                            $upt_s_h = "s";
                        } else {
                            $upt_s_h = "";
                        }
                        if ($uptime_j > 1) {
                            $upt_s_j = "s";
                        } else {
                            $upt_s_j = "";
                        }
                        $vps_out .= _("Up time: ") . "{$uptime_j} day{$upt_s_j} {$uptime_h} hour{$upt_s_h} {$uptime_m} minute{$upt_s_m} {$uptime_s} seconde{$upt_s_s}<br>";
                        $vps_out .= _("Last boot date: ") . date("Y-m-d H:i:s", substr($vps_remote_info["start_time"], 0, strlen($vps_remote_info["start_time"]) - 2)) . "<br>";
                    }
                    $vps_out .= "<br>";
                }
            }
        }
    } else {
        $vps_out .= _("Could not connect to the VPS SOAP Server.");
    }
    $frm_start = "<form action=\"?\">\n<input type=\"hidden\" name=\"adm_login\" value=\"{$adm_login}\">\n<input type=\"hidden\" name=\"adm_pass\" value=\"{$adm_pass}\">\n<input type=\"hidden\" name=\"addrlink\" value=\"{$addrlink}\">";
    // The ip address(es)
    $out .= "<br><h3>" . _("IP address(es) of your VPS:") . "</h3>";
    $vps_ips = $vps["ip_addr"];
    $n = sizeof($vps_ips);
    if ($n > 1) {
        $out .= _("IP addresses: ");
    } else {
        $out .= _("IP address: ");
    }
    for ($i = 0; $i < $n; $i++) {
        if ($i != 0) {
            $out .= ", ";
        }
        $out .= $vps_ips[$i];
    }
    $out .= "<br><br>";
    // VPS status
    $out .= $vps_stat_out;
    $out .= "<h3>" . _("Current VPS status:") . "</h3><br>";
    $out .= $vps_out;
    // VPS Monitoring
    $out .= "<br><h3>" . _("Service monitoring:") . "</h3><br>";
    $frm_start = dtcFormTableAttrs() . "<form action=\"?\">\n<input type=\"hidden\" name=\"adm_login\" value=\"{$adm_login}\">\n<input type=\"hidden\" name=\"adm_pass\" value=\"{$adm_pass}\">\n<input type=\"hidden\" name=\"addrlink\" value=\"{$addrlink}\">";
    $out .= $frm_start . "\n<input type=\"hidden\" name=\"action\" value=\"set_vps_monitoring_values\">\n";
    if ($vps["monitor_ping"] == "yes") {
        $monitor_ping = " checked ";
    } else {
        $monitor_ping = " ";
    }
    if ($vps["monitor_ssh"] == "yes") {
        $monitor_ssh = " checked ";
    } else {
        $monitor_ssh = " ";
    }
    if ($vps["monitor_http"] == "yes") {
        $monitor_http = " checked ";
    } else {
        $monitor_http = " ";
    }
    if ($vps["monitor_smtp"] == "yes") {
        $monitor_smtp = " checked ";
    } else {
        $monitor_smtp = " ";
    }
    if ($vps["monitor_pop3"] == "yes") {
        $monitor_pop3 = " checked ";
    } else {
        $monitor_pop3 = " ";
    }
    if ($vps["monitor_imap4"] == "yes") {
        $monitor_imap4 = " checked ";
    } else {
        $monitor_imap4 = " ";
    }
    if ($vps["monitor_ftp"] == "yes") {
        $monitor_ftp = " checked ";
    } else {
        $monitor_ftp = " ";
    }
    $out .= dtcFormLineDraw(_("VPS monitoring alerts email address: "), "<input type=\"text\" name=\"email_addr\" value=\"" . $vps["monitoring_email"] . "\">", 1);
    $out .= dtcFormLineDraw(_("Ping: "), "<input type=\"checkbox\" name=\"monitor_ping\" value=\"yes\" {$monitor_ping}>", 0);
    $out .= dtcFormLineDraw(_("SSH: "), "<input type=\"checkbox\" name=\"monitor_ssh\" value=\"yes\" {$monitor_ssh}>", 1);
    $out .= dtcFormLineDraw(_("HTTP: "), "<input type=\"checkbox\" name=\"monitor_http\" value=\"yes\" {$monitor_http}>", 0);
    $out .= dtcFormLineDraw(_("SMTP: "), "<input type=\"checkbox\" name=\"monitor_smtp\" value=\"yes\" {$monitor_smtp}>", 1);
    $out .= dtcFormLineDraw(_("POP3: "), "<input type=\"checkbox\" name=\"monitor_pop3\" value=\"yes\" {$monitor_pop3}>", 0);
    $out .= dtcFormLineDraw(_("IMAP4: "), "<input type=\"checkbox\" name=\"monitor_imap4\" value=\"yes\" {$monitor_imap4}>", 1);
    $out .= dtcFormLineDraw(_("FTP: "), "<input type=\"checkbox\" name=\"monitor_ftp\" value=\"yes\" {$monitor_ftp}>", 0);
    $out .= dtcFormLineDraw("", dtcApplyButton(), 1);
    $out .= "</form></table>";
    return $out;
}
Example #8
0
function drawAdminTools_VPSInstallation($admin, $vps)
{
    global $vps_name;
    global $vps_node;
    global $adm_login;
    global $adm_pass;
    global $rub;
    global $addrlink;
    global $vps_soap_err;
    global $pro_mysql_product_table;
    global $pro_mysql_vps_ip_table;
    global $pro_mysql_vps_stats_table;
    global $secpayconf_currency_letters;
    global $panel_type;
    global $submit_err;
    $reinstall_os = 1;
    get_secpay_conf();
    $out = "<font color=\"red\">{$submit_err} {$vps_soap_err}</font>";
    $checker = checkVPSAdmin($adm_login, $adm_pass, $vps_node, $vps_name);
    if ($checker != true) {
        return _("Credential not correct: can't display in file ") . __FILE__ . " line " . __LINE__;
    }
    $vps_out = "";
    // Calculate last month dates
    $cur_year = date("Y");
    $cur_month = date("m");
    $last_month = $cur_month - 1;
    if ($last_month == 0) {
        $last_month_year = $cur_year - 1;
        $last_month = 12;
    } else {
        $last_month_year = $cur_year;
    }
    $tow_month_ago = $last_month - 1;
    if ($tow_month_ago == 0) {
        $tow_month_ago = 12;
        $tow_month_ago_year = $last_month_year - 1;
    } else {
        $tow_month_ago_year = $last_month_year;
    }
    // Check if the VPS has expired or not
    $ar = explode("-", $vps["expire_date"]);
    if (date("Y") > $ar[0] || date("Y") == $ar[0] && date("m") > $ar[1] || date("Y") == $ar[0] && date("m") == $ar[1] && date("d") > $ar[2]) {
        $expired = "yes";
    } else {
        $expired = "no";
    }
    // VPS (remote SOAP) Status
    $soap_client = connectToVPSServer($vps_node);
    if ($soap_client != false) {
        $vps_remote_info = getVPSInfo($vps_node, $vps_name, $soap_client);
        if ($vps_remote_info == false) {
            if (strstr($vps_soap_err, _("Method getVPSState failed"))) {
                $vps_out .= _("Could not get remote status (Method getVPSState() failed). Maybe the VPS is not running?") . "<br><br>";
            } else {
                if (strstr($vps_soap_err, _("couldn't connect to host"))) {
                    $vps_out .= _("Could not get remote status: could not connect to the SOAP server (HTTP error).") . "<br><br>";
                } else {
                    $vps_out .= _("Could not get remote status. Unkown error: ") . "{$vps_soap_err}<br><br>";
                }
            }
        } else {
            if ($vps_remote_info == "fsck") {
                $vps_out .= _("Checking filesystem...") . "<br><br>";
            } else {
                if ($vps_remote_info == "mkos") {
                    $vps_out .= _("Reinstalling operating system...") . "<br><br>";
                } else {
                    if (isset($vps_remote_info["id"])) {
                        $vps_out .= _("VM id: ") . $vps_remote_info["id"] . "<br>";
                    }
                    if (isset($vps_remote_info["name"])) {
                        $vps_out .= _("Name: ") . $vps_remote_info["name"] . "<br>";
                    }
                    if (isset($vps_remote_info["memory"])) {
                        $vps_out .= _("Memory: ") . $vps_remote_info["memory"] . "<br>";
                    }
                    if (isset($vps_remote_info["maxmem"])) {
                        $vps_out .= _("Max memory: ") . $vps_remote_info["maxmem"] . "<br>";
                    } else {
                        $vps_out .= _("Maxmem: cannot fetch (maybe boot in progress?)") . "<br>";
                    }
                    if (isset($vps_remote_info["cpu"])) {
                        $vps_out .= _("Number of CPU: ") . $vps_remote_info["cpu"] . "<br>";
                    } else {
                        $vps_out .= _("Number of CPU: cannot fetch (maybe boot in progress?)") . "<br>";
                    }
                    if (isset($vps_remote_info["state"])) {
                        $vps_out .= _("VPS State: ") . $vps_remote_info["state"] . "<br>";
                    } else {
                        $vps_out .= _("State: cannot fetch (maybe boot in progress?)") . "<br>";
                    }
                    if ($vps_remote_info["xen_type"] == 2 && isset($vps_remote_info["up_time"])) {
                        $uptime = substr($vps_remote_info["up_time"], 0, strpos($vps_remote_info["up_time"], "."));
                        $uptime_s = $uptime % 60;
                        $uptime_m = round($uptime / 60) % 60;
                        $uptime_h = round($uptime / 3600) % 24;
                        $uptime_j = round($uptime / 86400);
                        if ($uptime_s > 1) {
                            $upt_s_s = "s";
                        } else {
                            $upt_s_s = "";
                        }
                        if ($uptime_m > 1) {
                            $upt_s_m = "s";
                        } else {
                            $upt_s_m = "";
                        }
                        if ($uptime_h > 1) {
                            $upt_s_h = "s";
                        } else {
                            $upt_s_h = "";
                        }
                        if ($uptime_j > 1) {
                            $upt_s_j = "s";
                        } else {
                            $upt_s_j = "";
                        }
                        $vps_out .= _("Up time: ") . "{$uptime_j} day{$upt_s_j} {$uptime_h} hour{$upt_s_h} {$uptime_m} minute{$upt_s_m} {$uptime_s} seconde{$upt_s_s}<br>";
                        $vps_out .= _("Last boot date: ") . date("Y-m-d H:i:s", substr($vps_remote_info["start_time"], 0, strlen($vps_remote_info["start_time"]) - 2)) . "<br>";
                    }
                    $vps_out .= "<br>";
                }
            }
        }
    } else {
        $vps_out .= _("Could not connect to the VPS SOAP Server.");
    }
    $frm_start = "<form action=\"?\">\n<input type=\"hidden\" name=\"adm_login\" value=\"{$adm_login}\">\n<input type=\"hidden\" name=\"adm_pass\" value=\"{$adm_pass}\">\n<input type=\"hidden\" name=\"addrlink\" value=\"{$addrlink}\">";
    // The ip address(es)
    $vps_ips = $vps["ip_addr"];
    $n = sizeof($vps_ips);
    if ($n > 1) {
        $ip_title = _("IP addresses: ");
    } else {
        $ip_title = _("IP address: ");
    }
    $out .= "<br><h3>" . $ip_title . "</h3>";
    $out .= dtcFormTableAttrs();
    for ($i = 0; $i < $n; $i++) {
        if ($i % 2) {
            $alt_color = 0;
        } else {
            $alt_color = 1;
        }
        $q = "SELECT * FROM {$pro_mysql_vps_ip_table} WHERE ip_addr='" . $vps_ips[$i] . "';";
        $r = mysql_query($q) or die("Cannot query {$q} line " . __LINE__ . " file " . __FILE__ . " sql said: " . mysql_error());
        $n2 = mysql_num_rows($r);
        if ($n2 != 1) {
            $out .= _("Error line " . __LINE__ . " file " . __FILE__);
        } else {
            $a = mysql_fetch_array($r);
            $out .= dtcFormLineDraw($vps_ips[$i], "{$frm_start}<input type=\"hidden\" name=\"action\" value=\"set_ip_reverse_dns\">\n\t<input type=\"hidden\" name=\"ip_addr\" value=\"" . $vps_ips[$i] . "\">\n\t<input type=\"text\" name=\"rdns\" value=\"" . $a["rdns_addr"] . "\">\n</td><td><div class=\"input_btn_container\" onMouseOver=\"this.className='input_btn_container-hover';\"\nonMouseOut=\"this.className='input_btn_container';\">\n <div class=\"input_btn_left\"></div>\n <div class=\"input_btn_mid\"><input class=\"input_btn\" type=\"submit\" value=\"" . _("Change RDNS") . "\"></div>\n <div class=\"input_btn_right\"></div>\n</div></form>", $alt_color);
        }
    }
    $out .= "</table><br><br>";
    // VPS status
    $out .= "<h3>" . _("Current VPS status:") . "</h3><br>";
    $out .= $vps_out;
    // Start / stop VPS
    $out .= "<h3>" . _("Start and stop of your VPS:") . "</h3><br>";
    if ($vps_remote_info == "fsck") {
        $out .= _("Please wait until file system check is finished first.") . "<br><br>";
    } else {
        if ($vps_remote_info == "mkos") {
            $out .= _("Please wait until operating system reinstallation has completed.") . "<br><br>";
            $reinstall_os = 1;
        } else {
            if ($vps_remote_info == true) {
                $out .= $frm_start . "<input type=\"hidden\" name=\"action\" value=\"shutdown_vps\">\n" . submitButtonStart() . _("Gracefully shutdown (xm shutdown)") . submitButtonEnd() . "\n</form><br><br>";
                $out .= $frm_start . "<input type=\"hidden\" name=\"action\" value=\"destroy_vps\">\n" . submitButtonStart() . _("Immediate kill (xm destroy)") . submitButtonEnd() . "\n</form><br><br>";
                $out .= _("To do a file system check or an operating system reinstallation, you need to shutdown or destroy your server first.") . "<br><br>";
            } else {
                if ($expired == "yes") {
                    $out .= _("You cannot start your VPS if it has expired. Please renew it if you want the boot up (xm start) button to appear here.");
                } else {
                    $out .= $frm_start . "<input type=\"hidden\" name=\"action\" value=\"start_vps\">" . submitButtonStart() . _("Boot up (xm start)") . submitButtonEnd() . "<br><br></form>";
                }
                // FSCK
                $out .= "<h3>" . _("File-system check:") . "</h3><br>";
                $out .= $frm_start . "<input type=\"hidden\" name=\"action\" value=\"fsck_vps\">" . submitButtonStart() . _("File system check (fsck)") . submitButtonEnd() . "\n<br><br></form>";
                // OS reinstall
                $out .= "<h3>" . _("Reinstall operating system:") . "</h3><br>";
                $out .= _("Currently installed operating system: ") . $vps["operatingsystem"] . "<br>";
                $deb_selected = " ";
                $debdtc_selected = " ";
                $cent_selected = " ";
                $gen_selected = " ";
                $bsd_selected = " ";
                $xenhvm_selected = " ";
                switch ($vps["operatingsystem"]) {
                    case "debian":
                        $deb_selected = " selected ";
                        break;
                    case "debian-dtc":
                        $debdtc_selected = " selected ";
                        break;
                    case "centos":
                        $cent_selected = " selected ";
                        break;
                    case "netbsd":
                        $bsd_selected = " selected ";
                        break;
                    case "xenhvm":
                        $xenhvm_selected = " selected ";
                        break;
                    default:
                        break;
                }
                // Operating system selection popup and reinstallation button
                $out .= $frm_start . "<table><tr><td>" . _("Operating system:") . " </td><td><select name=\"os_type\">\n<option value=\"debian\" {$deb_selected}>Debian (" . _("network install with debootstrap") . ")</option>\n<option value=\"debian-dtc\" {$debdtc_selected}>Debian with DTC panel (" . _("network install with debootstrap") . ")</option>\n<option value=\"centos\" {$cent_selected}>CentOS (" . _("network install with yum") . ")</option>\n<option value=\"netbsd\" {$bsd_selected}>NetBSD (" . _("network setup with install kernel") . ")</option>\n<option value=\"xenhvm\" {$xenhvm_selected}>Xen HVM (" . _("boot on your own .iso image") . ")</option>";
                $installable_os = getInstallableOS($soap_client);
                $nbr_os = sizeof($installable_os);
                for ($i = 0; $i < $nbr_os; $i++) {
                    $os_name = $installable_os[$i];
                    if ($vps["operatingsystem"] == $os_name) {
                        $selected = " selected ";
                    } else {
                        $selected = "";
                    }
                    $out .= "<option value=\"{$os_name}\" {$selected}>{$os_name} (" . _("operating system image") . ")</option>";
                }
                $installable_app = getInstallableAPP($soap_client);
                $nbr_app = sizeof($installable_app);
                for ($i = 0; $i < $nbr_app; $i++) {
                    $app_name = $installable_app[$i];
                    if ($vps["operatingsystem"] == $os_name) {
                        $selected = " selected ";
                    } else {
                        $selected = "";
                    }
                    $out .= "<option value=\"{$app_name}\" {$selected}>{$app_name} (" . _("applicance builder") . ")</option>";
                }
                $out .= "</select></td></tr>\n<tr><td>" . "VPS root password:"******" </td><td><input type=\"password\" name=\"root_password\"><input type=\"hidden\" name=\"action\" value=\"reinstall_os\"></td></tr>\n<tr><td></td><td>" . submitButtonStart() . _("Reinstall operating system") . submitButtonEnd() . "\n</td></tr></table></form>";
                //		}
                // BSD kernel change popup
                if ($vps["operatingsystem"] == "netbsd") {
                    if ($vps["bsdkernel"] == "install") {
                        $normal_selected = " ";
                        $install_selected = " selected ";
                    } else {
                        $normal_selected = " selected ";
                        $install_selected = " ";
                    }
                    $out .= $frm_start . "<select name=\"bsdkernel\">\n    <option value=\"normal\" {$normal_selected}>Normal</option>\n    <option value=\"install\" {$install_selected}>Install</option>\n    </select><input type=\"hidden\" name=\"action\" value=\"change_bsd_kernel_type\">\n    " . submitButtonStart() . _("Change NetBSD kernel") . submitButtonEnd() . "\n    </form>";
                }
                if ($vps["operatingsystem"] == "xenhvm") {
                    $vps_xenhvm_iso = getVPSIso($vps_node, $vps_name, $soap_client);
                    $out .= "<br><br>" . _("To upload .iso files so they appear below and you can boot on them, you can upload them using ftp, ") . "xen{$vps_name}@{$vps_node}" . _(" using the password of your physical console.") . "<br><br>";
                    $boot_device_selector = "<select name=\"xenhvm_iso\">\n<option value=\"hdd\">" . _("Boot on hard drive") . "</option>";
                    $n_iso = sizeof($vps_xenhvm_iso);
                    if (is_array($vps_xenhvm_iso)) {
                        for ($i = 0; $i < $n_iso; $i++) {
                            $iso = $vps_xenhvm_iso[$i];
                            if ($vps["howtoboot"] == $iso) {
                                $selected = " selected ";
                            } else {
                                $selected = " ";
                            }
                            $boot_device_selector .= "<option value=\"" . htmlspecialchars($iso) . "\" {$selected}>" . htmlspecialchars($iso) . "</option>";
                        }
                    }
                    $boot_device_selector .= "</select>";
                    if ($vps["vncpassword"] == "no_vnc") {
                        $vncons_act_yes_selected = " ";
                        $vncons_act_no_selected = " checked ";
                    } else {
                        $vncons_act_yes_selected = " ";
                        $vncons_act_no_selected = " checked ";
                    }
                    $out .= dtcFormTableAttrs();
                    $out .= dtcFormLineDraw($frm_start . _("Boot device: "), "<input type=\"hidden\" name=\"action\" value=\"change_xenhvm_boot_iso\">" . $boot_device_selector, 1);
                    $out .= dtcFormLineDraw(_("VNC console password: "******"<input type=\"text\" name=\"vnc_console_pass\" value=\"\">", 0);
                    $out .= dtcFormLineDraw(_("VNC console activation: "), "<input type=\"radio\" name=\"vnc_console_activate\" value=\"yes\" {$vncons_act_yes_selected}>" . _("yes") . " <input type=\"radio\" name=\"vnc_console_activate\" value=\"no\" {$vncons_act_no_selected}>" . _("no"), 1);
                    $out .= dtcFormLineDraw("", submitButtonStart() . _("Write parameters") . submitButtonEnd(), 0);
                    $out .= "</table></form>";
                }
            }
        }
    }
    $out .= "<br><br>";
    // SSH Physical console password changing
    $out .= "<h3>" . _("Physical console last display and ssh access:") . "</h3><br>";
    $out .= "Once your VPS is installed, ssh to the physical console to use it for the first time." . "<br><br>";
    $out .= dtcFormTableAttrs();
    $out .= dtcFormLineDraw($frm_start . "<input type=\"hidden\" name=\"action\" value=\"change_xm_console_ssh_passwd\">" . _("New SSH password: "******"<input size=\"40\" type=\"text\" name=\"new_password\" value=\"\"></td><td>" . submitButtonStart() . _("Ok") . submitButtonEnd() . "</form>", 1);
    $out .= dtcFormLineDraw($frm_start . "<input type=\"hidden\" name=\"action\" value=\"change_xm_console_ssh_key\">" . _("New SSH key: "), "<input size=\"40\" type=\"text\" name=\"new_key\" value=\"\"></td><td>" . submitButtonStart() . _("Ok") . submitButtonEnd() . "</form>", 0);
    $out .= "</table>";
    $out .= "<br><br>" . _("To access to your console, first enter a ssh password or key above, and then ssh to:") . "<br>xen" . $vps_name . "@" . $vps_node . "<br><br>";
    $out .= "<br>" . _("You should then install sshd in your VPS and use the physical console only for debugging purposes.");
    $out .= "<br>" . helpLink("PmWiki/Setup-A-VPS-Once-DTC-Xen-Installed-It");
    /* FIXME probably don't need any of this stuff'
    
    	if($reinstall_os == 1){
    		if($panel_type == "admin"){
    			$path_url = "/dtcadmin";
    		}else{
    			$path_url = "/dtc";
    		}
    		$ajax_url = "https://".$_SERVER["SERVER_NAME"].$path_url."/xanjaxPushlet.php?";
    		$ajax_auth = "adm_login="******"&adm_pass="******"&vps_node=".$vps_node."&vps_name=".$vps_name;
    		$r = "";
    	}else{
    		$r = $soap_client->call("getVPSInstallLog",array("vpsname" => $vps_name,"numlines" => "20"),"","","");
    		$err = $soap_client->getError();
    		if($err){
    			$r = _("Could not get VPS install log. Error: ").$err._(" maybe there are no logs yet?");
    		}
    		// print_r($r);
    		$r = str_replace("\n\n","\n",$r);
    	}
    */
    // tested AJAX stuff starts here
    $out .= "<script language=\"javascript\" src=\"xanjaxXHR.js\"></script>";
    $out .= "<h3>" . _("Installation log (last 20 lines):") . "</h3><br>";
    $out .= "<table cellspacing=\"0\" cellpadding=\"0\" border=\"1\">\n<tr><td bgcolor=\"black\"><font color=\"white\">{$vps_node}:{$vps_name}</font></td>\n<tr><td bgcolor=\"black\"><font color=\"white\"><pre id=\"reinstall_os_log\" class=\"reinstall_os_log\"><font color=\"red\">dtc-xen</font>@<font color=\"blue\">{$vps_node}</font>&gt;_ #<br>...</pre></font></td>\n</table>";
    $out .= "\n\t\t<script type=\"text/javascript\">\n\t\t\txanGet(logPushlet,\"logPushlet.php?vps_node=" . $vps_node . "&vps_name=" . $vps_name . "\");\n\t\t</script>";
    return $out;
}