示例#1
0
function draw_UpgradeAccount($admin)
{
    global $adm_pass;
    global $adm_login;
    global $addrlink;
    global $pro_mysql_admin_table;
    global $pro_mysql_client_table;
    global $pro_mysql_product_table;
    global $pro_mysql_companies_table;
    global $pro_mysql_pending_renewal_table;
    global $secpayconf_currency_letters;
    if (!isset($secpayconf_currency_letters)) {
        get_secpay_conf();
    }
    $out = "";
    $nowrap = 'style="white-space:nowrap"';
    $frm_start = "<form action=\"" . $_SERVER["PHP_SELF"] . "\">\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}\">\n<input type=\"hidden\" name=\"action\" value=\"upgrade_myaccount\">\n";
    $client = $admin["client"];
    $out .= "<b><u>" . _("Upgrade my account:") . "</u></b><br>";
    if ($admin["info"]["prod_id"] != 0) {
        $out .= "<i><u>" . _("Past account refundal") . "</u></i><br>";
        $out .= _("Your last command expire on the: ") . $admin["info"]["expire"] . ".<br>";
        $out .= _("Today is the: ") . date("Y-m-d") . "<br>";
        $today = mktime(0, 0, 0, date("m"), date("d"), date("Y"));
        $ar = explode("-", $admin["info"]["expire"]);
        $expire = mktime(0, 0, 0, $ar[1], 0, $ar[0]);
        $remaining_seconds = $expire - $today;
        $days_remaining = $remaining_seconds / (60 * 60 * 24);
        $days_outstanding = 0;
        // don't give credit if there are negative days remaining
        if ($days_remaining < 0) {
            $days_outstanding = $days_remaining;
            $days_remaining = 0;
        }
        $q = "SELECT * FROM {$pro_mysql_product_table} WHERE id='" . $admin["info"]["prod_id"] . "';";
        $r = mysql_query($q) or die("Cannot querry: \"{$q}\" !!!" . mysql_error() . " line " . __LINE__ . " in file " . __FILE__);
        $prod = mysql_fetch_array($r);
        $ar = explode("-", $prod["period"]);
        $prod_period = mktime(0, 0, 0, $ar[1] + 1, 1, 1970 + $ar[0]);
        $prod_days = $prod_period / (60 * 60 * 24);
        $price_per_days = $prod["price_dollar"] / $prod_days;
        $refundal = floor($days_remaining * $price_per_days);
        $owing = floor($days_outstanding * $price_per_days);
        $out .= _("Your past account was: ") . $prod["price_dollar"] . " " . $secpayconf_currency_letters . " " . _("for") . " " . smartDate($prod["period"]) . "<br>";
        $out .= _("Refund") . " (" . $days_remaining . _(" days) for upgrading will be: ") . "{$refundal} " . $secpayconf_currency_letters . "<br><br>";
        $out .= _("You have") . " (" . $days_outstanding . _(" days), with ") . "{$owing}" . " " . $secpayconf_currency_letters . _(" remaining to be paid") . "<br>";
    } else {
        $out .= _("You currently don't have a validated account. Please contact customer support.");
        return $out;
    }
    $out .= "<i><u>" . _("Step 1: choose your upgrade") . "</u></i><br>";
    if (!isset($_REQUEST["prod_id"]) || $_REQUEST["prod_id"] == "") {
        $out .= _("Your current account is ") . smartByte($admin["info"]["quota"] * 1024 * 1024) . _(" disk storage and ") . smartByte($admin["info"]["bandwidth_per_month_mb"] * 1024 * 1024) . _(" of data transfer each month.") . "<br><br>" . _("To what capacity would you like to upgrade to?") . "<br>";
        $q = "SELECT * FROM {$pro_mysql_product_table} WHERE (quota_disk > '" . $admin["info"]["quota"] . "' OR bandwidth > '" . $admin["info"]["bandwidth_per_month_mb"] . "' or max_domain>" . $admin["info"]["max_domain"] . ") and heb_type='shared';";
        $r = mysql_query($q) or die("Cannot query \"{$q}\" !" . mysql_error());
        $n = mysql_num_rows($r);
        $out .= "{$frm_start}";
        $out .= "<table border=\"1\" cellspacing=\"0\" cellpadding=\"0\" width=\"100%\" height=\"1\">";
        $out .= "<tr><td></td><td>" . _("Product") . "</td><td>" . _("Storage") . "</td><td>" . _("Bandwidth/month") . "</td>\n\t\t\t<td>" . _("Max. Domains") . "</td><td>" . _("Price") . "</td><td>" . _("Period") . "</td></tr>";
        if ($n > 0) {
            for ($i = 0; $i < $n; $i++) {
                $ro = mysql_fetch_array($r);
                if ($i % 2) {
                    $color = " bgcolor=\"#000000\" ";
                    $fnt1 = "<font color=\"#FFFFFF\"> ";
                    $fnt2 = "</font>";
                } else {
                    $color = "";
                    $fnt1 = "";
                    $fnt2 = "";
                }
                $out .= '<tr><td>' . $fnt1 . '<input type="radio" name="prod_id" value="' . $ro["id"] . '">' . $fnt2 . '</td>';
                $out .= "<td {$color} {$nowrap} >{$fnt1}" . $ro["name"] . $fnt2 . '</td>';
                $out .= "<td {$color} {$nowrap} >{$fnt1}" . smartByte($ro["quota_disk"] * 1024 * 1024) . $fnt2 . '</td>';
                $out .= "<td {$color} {$nowrap} >{$fnt1}" . smartByte($ro["bandwidth"] * 1024 * 1024) . $fnt2 . '</td>';
                $out .= "<td {$color} {$nowrap} >{$fnt1}" . $ro["max_domain"] . $fnt2 . '</td>';
                $out .= "<td {$color} {$nowrap} >{$fnt1}" . $ro["price_dollar"] . $fnt2 . '</td>';
                $out .= "<td {$color} {$nowrap} >{$fnt1}" . smartDate($ro["period"]) . $fnt2 . '</td></tr>';
            }
            $out .= '</table><center><input type="submit" value="' . _("Calculate price") . '"></center></form>';
        } else {
            $out .= '</table><center>' . _("There is no product with greater capacity available, please contact Support service.") . '</center></form>';
        }
        return $out;
    }
    $q = "SELECT * FROM {$pro_mysql_product_table} WHERE id='" . $_REQUEST["prod_id"] . "';";
    $r = mysql_query($q) or die("Cannot query \"{$q}\" !" . mysql_error());
    $n = mysql_num_rows($r);
    if ($n != 1) {
        die("Product not found !!!");
    }
    $ro = mysql_fetch_array($r);
    $q = "SELECT * FROM {$pro_mysql_client_table} WHERE id='" . $admin["info"]["id_client"] . "';";
    $r = mysql_query($q) or die("Cannot query \"{$q}\" !" . mysql_error());
    $n = mysql_num_rows($r);
    if ($n != 1) {
        die("Client not found !!!");
    }
    $rocli = mysql_fetch_array($r);
    $frm_start .= '<input type="hidden" name="prod_id" value="' . $ro["id"] . '">';
    $out .= _("You have selected") . ": " . $ro["name"];
    $out .= " (" . _("Storage") . ": " . smartByte($ro["quota_disk"] * 1024 * 1024);
    $out .= ", " . _("Transfer") . ": " . smartByte($ro["bandwidth"] * 1024 * 1024) . '), ';
    $out .= ", " . _("Max. Domains") . ": " . $ro["max_domain"] . '), ';
    $out .= '$' . $ro["price_dollar"] . ' ' . _("each") . ' ' . smartDate($ro["period"]);
    $out .= "<br><br><i><u>" . _("Step 2: proceed to upgrade") . "</u></i><br>";
    $remaining = $admin["client"]["dollar"];
    $ze_price = $ro["price_dollar"];
    $heber_price = $ze_price - $refundal;
    if (isset($_REQUEST["inner_action"]) && $_REQUEST["inner_action"] == "return_from_paypal_upgrade_account") {
        $ze_refund = isPayIDValidated(addslashes($_REQUEST["pay_id"]));
        if ($ze_refund == 0) {
            $out .= "<font color=\"red\">" . _("The transaction failed, please try again!") . "</font>";
        } else {
            $out .= "<font color=\"green\">" . _("Funds added to your account!") . "</font><br>";
            $q = "UPDATE {$pro_mysql_client_table} SET dollar = dollar+" . $ze_refund . " WHERE id='" . $admin["info"]["id_client"] . "';";
            $r = mysql_query($q) or die("Cannot querry {$q} line " . __LINE__ . " file " . __FILE__ . " sql said " . mysql_error());
            $admin["client"]["dollar"] += $ze_refund;
            $remaining += $ze_refund;
        }
    }
    $out .= _("Remaining on your account") . ": " . $remaining . "{$secpayconf_currency_letters}<br>\n" . _("New account price") . ": " . $ze_price . "{$secpayconf_currency_letters}<br>\n" . _("Past account refundal") . ": " . $refundal . "{$secpayconf_currency_letters}<br>\n" . _("Total price") . ": " . $heber_price . "{$secpayconf_currency_letters}<br>";
    if ($heber_price > $remaining) {
        $to_pay = $heber_price - $remaining;
        $payid = createCreditCardPaiementID($to_pay, $admin["info"]["id_client"], "Account upgrade: " . $ro["name"], "no");
        $return_url = $_SERVER["PHP_SELF"] . "?adm_login={$adm_login}&adm_pass={$adm_pass}" . "&addrlink={$addrlink}&action=upgrade_myaccount&prod_id=9&inner_action=return_from_paypal_upgrade_account&payid={$payid}";
        $service_location = $conf_this_server_country_code;
        $company_invoicing_id = findInvoicingCompany($conf_this_server_country_code, $rocli["country"]);
        $q = "SELECT * FROM {$pro_mysql_companies_table} WHERE id='{$company_invoicing_id}';";
        $r = mysql_query($q) or die("Cannot query \"{$q}\" ! line: " . __LINE__ . " file: " . __FILE__ . " sql said: " . mysql_error());
        if ($n != 1) {
            $form = "Cannot find company invoicing line " . __LINE__ . " file " . __FILE__;
            break;
        }
        $company_invoicing = mysql_fetch_array($r);
        // If VAT is set, use it.
        if ($company_invoicing["vat_rate"] == 0 || $company_invoicing["vat_number"] == "") {
            $vat_rate = 0;
            $use_vat = "no";
        } else {
            // Both companies are in europe, in different countries, and customer as a VAT number,
            // then there is no VAT and the customer shall pay the VAT in it's own country
            // These are the VAT rules in the European Union...
            if ($client["is_company"] == "yes" && $client["vat_num"] != "" && isset($cc_europe[$client["country"]]) && isset($cc_europe[$company_invoicing["country"]]) && $client["country"] != $company_invoicing["country"]) {
                $vat_rate = 0;
                $use_vat = "no";
            } else {
                $use_vat = "yes";
                $vat_rate = $company_invoicing["vat_rate"];
            }
        }
        // Save the values in SQL and process the paynow buttons
        $q = "INSERT INTO {$pro_mysql_pending_renewal_table} (id,adm_login,renew_date,renew_time,product_id,renew_id,heb_type,country_code)\n\t\tVALUES ('','" . $_REQUEST["adm_login"] . "',now(),now(),'" . $ro["id"] . "','" . $rocli["id"] . "','shared-upgrade','{$country}');";
        $r = mysql_query($q) or die("Cannot querry {$q} line " . __LINE__ . " file " . __FILE__ . " sql said " . mysql_error());
        $renew_id = mysql_insert_id();
        $payid = createCreditCardPaiementID($heber_price, $renew_id, "Account upgrade: " . $ro["name"] . " (login: " . $_REQUEST["adm_login"] . ")", "no", $prod_id, $vat_rate);
        $q = "UPDATE {$pro_mysql_pending_renewal_table} SET pay_id='{$payid}' WHERE id='{$renew_id}';";
        $r = mysql_query($q) or die("Cannot querry {$q} line " . __LINE__ . " file " . __FILE__ . " sql said " . mysql_error());
        $payButton = paynowButton($payid, $heber_price, "Account upgrade: " . $ro["name"], $return_url, $vat_rate);
        $out .= "<br>" . _("You currently don't have enough funds on your account. You will be redirected to our payment system. Please click on the button below to pay.") . "<br><br>" . $payButton;
        return $out;
    }
    $after_upgrade_remaining = $remaining - $heber_price;
    $out .= _("After upgrade, you will have") . ": " . $after_upgrade_remaining . " " . $secpayconf_currency_letters . "<br><br>";
    // Check for confirmation
    if (isset($_REQUEST["toreg_confirm_register"]) && $_REQUEST["toreg_confirm_register"] != "yes") {
        $out .= _("You have enough funds on your account to proceed account upgrade. Press the confirm button and your order will be proceeded.") . "<br><br>\n{$frm_start}\n<input type=\"hidden\" name=\"toreg_confirm_register\" value=\"yes\">\n<input type=\"submit\" value=\"" . _("Proceed to account upgrade") . "\">\n</form>";
        return $out;
    }
    return $out;
}
示例#2
0
function drawAdminTools_DomainInfo($admin, $eddomain)
{
    global $adm_login;
    global $adm_pass;
    global $addrlink;
    global $dtcshared_path;
    global $conf_administrative_site;
    global $pro_mysql_domain_table;
    global $pro_mysql_whois_table;
    global $renew_return;
    global $secpayconf_currency_letters;
    $out = "";
    $webname = $eddomain["name"];
    get_secpay_conf();
    // Domain registration API stuffs
    $out .= "<br><h3>" . _("Registration:") . "</h3>";
    if ($eddomain["whois"] == "away") {
        $out .= _("Your domain is not registered here.");
    } else {
        $q = "SELECT * FROM {$pro_mysql_domain_table} WHERE name='{$webname}';";
        $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) {
            $out .= _("Cannot find your domain name registration information in the database.");
        } else {
            $a = mysql_fetch_array($r);
            // Domain renewals
            if (isset($_REQUEST["action"]) && $_REQUEST["action"] == "renew_domain") {
                $out .= dtcFormTableAttrs();
                $out .= dtcFormLineDraw(_("Money on your account: "), $admin["client"]["dollar"] . " {$secpayconf_currency_letters}", 1);
                $tld = find_domain_extension($webname);
                $out .= dtcFormLineDraw(_("Type of extension: "), $tld, 0);
                $out .= dtcFormLineDraw(_("Renewal for how many years: "), $_REQUEST["num_years"], 1);
                $price = find_domain_price($tld);
                if ($price === FALSE) {
                    $out .= dtcFormLineDraw("", "<font color=\"red\">" . _("Price for the domain not found!") . "</font>", 0);
                    $out .= "</table>";
                } else {
                    $price = $_REQUEST["num_years"] * $price;
                    $out .= dtcFormLineDraw(_("Total price: "), $price . " {$secpayconf_currency_letters}", 0);
                    $remaining = $admin["client"]["dollar"] - $price;
                    $out .= dtcFormLineDraw(_("Balance after transaction: "), $remaining . " {$secpayconf_currency_letters}", 1);
                    if ($remaining < 0) {
                        $out .= dtcFormLineDraw("", "<font color=\"red\">" . _("Insufisant balance for the transaction, please go to \"My account\" and add money.") . "</font>", 0);
                        $out .= "</table>";
                    } else {
                        $out .= dtcFormLineDraw("", "<form action=\"" . $_SERVER["PHP_SELF"] . "\"><input type=\"hidden\" name=\"adm_login\" value=\"{$adm_login}\">\n<input type=\"hidden\" name=\"addrlink\" value=\"" . $_REQUEST["addrlink"] . "\">\n<input type=\"hidden\" name=\"edit_domain\" value=\"" . $webname . "\">\n<input type=\"hidden\" name=\"adm_pass\" value=\"{$adm_pass}\">\n<input type=\"hidden\" name=\"action\" value=\"registry_renew_domain\">\n<input type=\"hidden\" name=\"num_years\" value=\"" . $_REQUEST["num_years"] . "\">\n" . submitButtonStart() . _("Renew domain") . submitButtonEnd() . "</form>", 0);
                        $out .= "</table>";
                    }
                }
            } elseif (isset($_REQUEST["action"]) && $_REQUEST["action"] == "registry_renew_domain") {
                $out .= $renew_return["response_text"];
            } else {
                $out .= dtcFormTableAttrs();
                // Domain auth code
                $authcode = registry_get_auth_code($webname);
                if ($authcode === FALSE || $authcode["is_success"] != 1) {
                    $txt = _("Auth code retrival failed.");
                } else {
                    $txt = $authcode["response_text"];
                }
                $frm = "<form action=\"" . $_SERVER["PHP_SELF"] . "\"><input type=\"hidden\" name=\"adm_login\" value=\"{$adm_login}\">\n<input type=\"hidden\" name=\"addrlink\" value=\"" . $_REQUEST["addrlink"] . "\">\n<input type=\"hidden\" name=\"edit_domain\" value=\"" . $_REQUEST["addrlink"] . "\">\n<input type=\"hidden\" name=\"adm_pass\" value=\"{$adm_pass}\">\n<input type=\"hidden\" name=\"action\" value=\"renew_domain\">";
                $out .= dtcFormLineDraw(_("Registrar: ") . $frm, $a["registrar"], 1);
                $out .= dtcFormLineDraw(_("Creation date: "), $a["creation_date"], 0);
                $out .= dtcFormLineDraw(_("Last modification date: "), $a["modification_date"], 1);
                $out .= dtcFormLineDraw(_("Expiration date: "), $a["expiration_date"], 0);
                $out .= dtcFormLineDraw(_("Domain auth code: "), $txt, 1);
                $out .= dtcFormLineDraw("<select name=\"num_years\">\n<option value=\"1\">1</option>\n<option value=\"2\">2</option>\n<option value=\"3\">3</option>\n<option value=\"4\">4</option>\n<option value=\"5\">5</option>\n<option value=\"6\">6</option>\n<option value=\"7\">7</option>\n<option value=\"8\">8</option>\n<option value=\"9\">9</option>\n</select>" . _("year(s)"), submitButtonStart() . _("Renew domain") . submitButtonEnd() . "</form>", 0);
                $out .= "</table>";
            }
            // Domain protection
            if (isset($_REQUEST["action"]) && $_REQUEST["action"] == "change_domain_protection") {
                switch ($_REQUEST["protection"]) {
                    case "unlocked":
                        $sel = "unlocked";
                        break;
                    case "transferprot":
                        $sel = "transferprot";
                        break;
                    default:
                    case "locked":
                        $sel = "locked";
                        break;
                }
                $ret = registry_set_domain_protection($webname, $sel);
                if ($ret != FALSE && $ret["is_success"] == 1) {
                    $q = "UPDATE {$pro_mysql_whois_table} SET protection='{$sel}' WHERE domain_name='{$webname}';";
                    $r = mysql_query($q) or die("Cannot query {$q} line " . __LINE__ . " file " . __FILE__ . "sql said: " . mysql_error());
                    $a["protection"] = $sel;
                }
            }
            $frm = "<form action=\"" . $_SERVER["PHP_SELF"] . "\"><input type=\"hidden\" name=\"adm_login\" value=\"{$adm_login}\">\n<input type=\"hidden\" name=\"addrlink\" value=\"" . $_REQUEST["addrlink"] . "\">\n<input type=\"hidden\" name=\"edit_domain\" value=\"" . $_REQUEST["addrlink"] . "\">\n<input type=\"hidden\" name=\"adm_pass\" value=\"{$adm_pass}\">\n<input type=\"hidden\" name=\"action\" value=\"change_domain_protection\">";
            $out .= dtcFormTableAttrs();
            $unlck_sel = "";
            $trans_sel = "";
            $lockd_sel = "";
            switch ($a["protection"]) {
                case "unlocked":
                    $unlck_sel = " selected ";
                    break;
                case "transferprot":
                    $trans_sel = " selected ";
                    break;
                default:
                case "locked":
                    $lockd_sel = " selected ";
                    break;
            }
            $out .= dtcFormLineDraw(_("Domain protection: ") . $frm, "<select name=\"protection\">\n<option value=\"unlocked\" {$unlck_sel}>" . _("Domain name unlocked") . "</option>\n<option value=\"transferprot\" {$trans_sel}>" . _("Domain name transfer protected") . "</option>\n<option value=\"locked\" {$lockd_sel}>" . _("Domain name protected") . "</option>\n</select>", 1);
            $out .= dtcFormLineDraw("", submitButtonStart() . _("Set protection") . submitButtonEnd(), 0);
            $out .= "</form></table>";
        }
    }
    // End of domain registration API code
    // Retrive domain config
    $quota = $eddomain["quota"];
    $max_email = $eddomain["max_email"];
    $max_ftp = $eddomain["max_ftp"];
    $max_subdomain = $eddomain["max_subdomain"];
    $domain_parking = $eddomain["domain_parking"];
    $domain_parking_type = $eddomain["domain_parking_type"];
    $adm_path = $admin["info"]["path"];
    // Retrive disk usage
    //	$du_string = exec("du -sm $adm_path/$webname --exclude=access.log",$retval);
    //	$du_state = explode("\t",$du_string);
    //	$du = $du_state[0];
    // The upper version might be too slow and give a bad feeling to the user. This one should be a lot better:
    $du_stat = $eddomain["du_stat"];
    $du = $du_stat;
    // Retrive number of mailbox
    if (isset($eddomain["emails"])) {
        $email_nbr = sizeof($eddomain["emails"]);
    } else {
        $email_nbr = 0;
    }
    // Retrive number of ftp account
    if (isset($eddomain["ftps"])) {
        $ftp_nbr = sizeof($eddomain["ftps"]);
    } else {
        $ftp_nbr = 0;
    }
    // Retrive number of ftp account
    $subdomain_nbr = sizeof($eddomain["subdomains"]);
    $total_http_transfer = fetchHTTPInfo($webname);
    $total_ftp_transfer = fetchFTPInfo($webname);
    $total_pop_transfer = fetchPOPInfo($webname);
    $total_imap_transfer = fetchIMAPInfo($webname);
    $total_smtp_transfer = fetchSMTPInfo($webname);
    $total_transfer = smartByte($total_http_transfer + $total_ftp_transfer + $total_smtp_transfer + $total_pop_transfer + $total_imap_transfer);
    $out .= "<br><h3>" . _("Your domain usage and quota:") . "</h3>\n\t" . _("Total transfered bytes this month:") . " {$total_transfer}<br>\n\t" . _("Your area disk usage:") . " " . smartByte($du) . " / {$quota} MBytes<br>\n\t" . _("Mailboxes:") . " {$email_nbr} / {$max_email}<br>\n\t" . _("FTP accounts:") . " {$ftp_nbr} / {$max_ftp}<br>\n\t" . _("Subdomains:") . " {$subdomain_nbr} / {$max_subdomain}<br><br>";
    $out .= "<h3>" . _("Preview URL:") . "</h3>\n\t" . _("Use") . " http(s)://" . $conf_administrative_site . "/www." . $_REQUEST["addrlink"] . " " . _("aliasing") . ":";
    if ($eddomain["gen_unresolved_domain_alias"] == "yes") {
        $radio_yes = " checked";
        $radio_no = "";
    } else {
        $radio_no = " checked";
        $radio_yes = "";
    }
    $out .= "<form action=\"" . $_SERVER["PHP_SELF"] . "\"><input type=\"hidden\" name=\"adm_login\" value=\"{$adm_login}\">\n<input type=\"hidden\" name=\"addrlink\" value=\"" . $_REQUEST["addrlink"] . "\">\n<input type=\"hidden\" name=\"edit_domain\" value=\"" . $_REQUEST["addrlink"] . "\">\n<input type=\"hidden\" name=\"adm_pass\" value=\"{$adm_pass}\">\n<input type=\"radio\" name=\"domain_gen_unresolv_alias\" value=\"yes\"{$radio_yes}>" . _("Yes") . "\n<input type=\"radio\" name=\"domain_gen_unresolv_alias\" value=\"no\"{$radio_no}>" . _("No") . "\n<input type=\"hidden\" name=\"change_unresolv_alias\" value=\"Ok\"><br>" . submitButtonStart() . _("Ok") . submitButtonEnd() . "</form><br><br>";
    $out .= "<h3>" . _("Domain parking:") . "</h3>";
    $out .= _("This domain will be the alias of the following domain (domain parking):");
    $out .= "<form action=\"" . $_SERVER["PHP_SELF"] . "\"><input type=\"hidden\" name=\"adm_login\" value=\"{$adm_login}\">\n<input type=\"hidden\" name=\"addrlink\" value=\"" . $_REQUEST["addrlink"] . "\">\n<input type=\"hidden\" name=\"edit_domain\" value=\"" . $_REQUEST["addrlink"] . "\">\n<input type=\"hidden\" name=\"adm_pass\" value=\"{$adm_pass}\">\n<input type=\"hidden\" name=\"set_domain_parcking\" value=\"Ok\">\n<select name=\"domain_parking_value\">\n<option value=\"no-parking\">" . _("No parking") . "</option>\n";
    $q = "SELECT name FROM {$pro_mysql_domain_table} WHERE owner='{$adm_login}' AND domain_parking='no-parking' AND name NOT LIKE '" . $_REQUEST["addrlink"] . "';";
    $r = mysql_query($q) or die("Cannot query \"{$q}\" line " . __LINE__ . " in file " . __FILE__ . " sql said: " . mysql_error());
    $n = mysql_num_rows($r);
    for ($i = 0; $i < $n; $i++) {
        $a = mysql_fetch_array($r);
        if ($domain_parking == $a["name"]) {
            $checked = " selected ";
        } else {
            $checked = "";
        }
        $out .= "<option value=\"" . $a["name"] . "\"{$checked}>" . $a["name"] . "</option>";
    }
    $out .= "</select><br>";
    $redirect_selected = " ";
    $same_docroot_selected = " ";
    $serveralias_selected = " ";
    switch ($domain_parking_type) {
        case "redirect":
            $redirect_selected = " checked ";
            break;
        case "same_docroot":
            $same_docroot_selected = " checked ";
            break;
        case "serveralias":
            $serveralias_selected = " checked ";
            break;
    }
    $out .= "<input type=\"radio\" name=\"domain_parking_type\" value=\"redirect\" {$redirect_selected}>" . _("Redirection") . " ";
    $out .= "<input type=\"radio\" name=\"domain_parking_type\" value=\"same_docroot\" {$same_docroot_selected}>" . _("Same DocumentRoot") . " ";
    $out .= "<input type=\"radio\" name=\"domain_parking_type\" value=\"serveralias\" {$serveralias_selected}>" . _("ServerAlias") . " ";
    $out .= "<br>" . submitButtonStart() . _("Ok") . submitButtonEnd() . "</form><br><br>";
    $out .= "<h3>" . _("Domain configuration backup:") . "</h3>";
    $out .= "<a href=\"?adm_login={$adm_login}&adm_pass={$adm_pass}&action=export_domain&addrlink=" . $_REQUEST["addrlink"] . "\" target=\"_blank\">" . _("Export this domain to a file") . "</a>";
    $out .= "<br><br>" . helpLink("UserDoc/Domain-General-Config");
    return $out;
}
示例#3
0
function drawAdminTools_DomainStats($admin, $eddomain)
{
    global $pro_mysql_domain_table;
    global $pro_mysql_acc_http_table;
    global $pro_mysql_acc_ftp_table;
    global $pro_mysql_acc_email_table;
    global $adm_login;
    global $adm_pass;
    global $addrlink;
    global $conf_htpasswd_path;
    $out = "";
    //	sum_http($eddomain["name"]);
    $query_http = "SELECT bytes_sent FROM {$pro_mysql_acc_http_table} WHERE domain='" . $eddomain["name"] . "'\n\tAND month='" . date("n") . "' AND year='" . date("Y") . "'";
    $result_http = mysql_query($query_http) or die("Cannot execute query \"{$query_http}\"");
    $num_rows = mysql_num_rows($result_http);
    if ($num_rows > 0) {
        $http_amount = mysql_result($result_http, 0, "bytes_sent");
    } else {
        $http_amount = 0;
    }
    //	sum_ftp($eddomain["name"]);
    $q = "SELECT transfer FROM {$pro_mysql_acc_ftp_table} WHERE sub_domain='" . $eddomain["name"] . "'\n\tAND month='" . date("m") . "' AND year='" . date("Y") . "'";
    $r = mysql_query($q) or die("Cannot execute query \"{$q}\" !" . mysql_error() . " line " . __LINE__ . " file " . __FILE__);
    $num_rows = mysql_num_rows($r);
    if ($num_rows > 0) {
        $ftp_amount = mysql_result($r, 0, "transfer");
    } else {
        $ftp_amount = 0;
    }
    //	sum_email($eddomain["name"]);
    $q = "SELECT smtp_trafic,pop_trafic,imap_trafic FROM {$pro_mysql_acc_email_table} WHERE domain_name='" . $eddomain["name"] . "'\n\tAND month='" . date("m") . "' AND year='" . date("Y") . "'";
    $r = mysql_query($q) or die("Cannot execute query \"{$q}\" !" . mysql_error() . " line " . __LINE__ . " file " . __FILE__);
    $num_rows = mysql_num_rows($r);
    if ($num_rows > 0) {
        $smtp_trafic = mysql_result($r, 0, "smtp_trafic");
        $pop_trafic = mysql_result($r, 0, "pop_trafic");
        $imap_trafic = mysql_result($r, 0, "imap_trafic");
    } else {
        $smtp_trafic = 0;
        $pop_trafic = 0;
        $imap_trafic = 0;
    }
    $out .= "<h3>" . _("Total transfered bytes this month") . "</h3>";
    $out .= "<br>HTTP: " . smartByte($http_amount);
    $out .= "<br>FTP:  " . smartByte($ftp_amount);
    $out .= "<br>SMTP:  " . smartByte($smtp_trafic);
    $out .= "<br>POP3:  " . smartByte($pop_trafic);
    $out .= "<br>IMAP:  " . smartByte($imap_trafic);
    $out .= "<br>Total: " . smartByte($http_amount + $ftp_amount + $pop_trafic + $smtp_trafic + $imap_trafic);
    $out .= "<br><br><h3>" . _("Detailed web statistics (HTTP) of your subdomains:") . "</h3><br>";
    for ($i = 0; $i < sizeof($eddomain["subdomains"]); $i++) {
        if ($i != 0) {
            $out .= " - ";
        }
        $out .= "<a target=\"_blank\" href=\"http://" . $eddomain["subdomains"][$i]["name"] . "." . $eddomain["name"] . "/stats/\">";
        $out .= $eddomain["subdomains"][$i]["name"];
        $out .= "</a>";
    }
    $q = "SELECT stats_login,stats_pass,stats_subdomain FROM {$pro_mysql_domain_table}  WHERE name='" . $eddomain["name"] . "';";
    $r = mysql_query($q) or die("Cannot query \"{$q}\" line " . __LINE__ . " file " . __FILE__ . " sql said " . mysql_error());
    $n = mysql_num_rows($r);
    $a = mysql_fetch_array($r);
    $out .= "<br><br><strong>" . _("Protect your logs and stats folder with a password") . "</strong><br>";
    $out .= "<table>";
    $hidden = "<input type=\"hidden\" name=\"adm_login\" value=\"{$adm_login}\">\n\t\t<input type=\"hidden\" name=\"adm_pass\" value=\"{$adm_pass}\">\n\t\t<input type=\"hidden\" name=\"addrlink\" value=\"" . $addrlink . "\">\n\t\t<input type=\"hidden\" name=\"edit_domain\" value=\"" . $eddomain["name"] . "\">";
    if (empty($a["stats_login"])) {
        $out .= "<tr><td><form action=\"" . $_SERVER["PHP_SELF"] . "\">{$hidden}\n\t\t<input type=\"hidden\" name=\"action\" value=\"add_stats_login\">\n\t\t" . _("Login:") . " <input type=\"text\" name=\"stats_login\" value=\"\"> " . _("Password:") . " \n\t\t<input type=\"text\" name=\"stats_pass\" value=\"\"></td></tr>\n\t\t<tr><td>" . _("Copy to subdomains:") . " <input type=\"checkbox\" name=\"stats_subdomain\" value=\"\"></td></tr>\n\t\t<tr><td><input type=\"submit\" value=\"" . _("Ok") . "\"></form></td></tr>";
    } else {
        $out .= "<tr><td><form action=\"" . $_SERVER["PHP_SELF"] . "\">{$hidden}\n\t\t<input type=\"hidden\" name=\"action\" value=\"modify_stats_login_pass\">\n\t\t" . _("Login:") . " <input type=\"text\" name=\"stats_login\" value=\"" . $a["stats_login"] . "\">\n\t\t" . _("Password:") . " <input type=\"password\" name=\"stats_pass\" value=\"" . $a["stats_pass"] . "\"></td></tr>\n\t\t<tr><td>" . _("Copy to subdomains:") . " <input type=\"checkbox\" name=\"stats_subdomain\" value=\"\" ";
        if ($a["stats_subdomain"] == 'yes') {
            $out .= "checked";
        }
        $out .= "></td></tr>\n\t\t<tr><td><input type=\"submit\" value=\"" . _("Save") . "\"></form>\n\t\t<form action=\"" . $_SERVER["PHP_SELF"] . "\">{$hidden}\n\t\t<input type=\"hidden\" name=\"action\" value=\"del_stats_login\">\n\t\t<input type=\"hidden\" name=\"stats_login\" value=\"" . $a["stats_login"] . "\">\n\t\t<input type=\"hidden\" name=\"stats_pass\" value=\"" . $a["stats_pass"] . "\">\n\t\t<input type=\"hidden\" name=\"stats_subdomain\" value=\" " . $a["stats_subdomain"] . "\">\n\t\t<input type=\"submit\" value=\"" . _("Delete") . "\"></form></td></tr>";
    }
    $out .= "</table>";
    return $out;
}
示例#4
0
function drawAdminTools_MyAccount($admin)
{
    global $PHP_SELF;
    global $adm_login;
    global $adm_pass;
    global $addrlink;
    global $dtcshared_path;
    global $pro_mysql_pay_table;
    global $pro_mysql_client_table;
    global $pro_mysql_ssl_ips_table;
    global $pro_mysql_product_table;
    global $secpayconf_currency_letters;
    global $cc_code_array;
    get_secpay_conf();
    $frm_start = "<form action=\"{$PHP_SELF}\">\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}\">\n";
    $out = "";
    $id_client = $admin["info"]["id_client"];
    $stats = fetchAdminStats($admin);
    if (isset($_REQUEST["action"]) && $id_client != 0 && $_REQUEST["action"] == "upgrade_myaccount") {
        return draw_UpgradeAccount($admin);
    }
    if (isset($_REQUEST["action"]) && $id_client != 0 && $_REQUEST["action"] == "refund_myaccount") {
        if (isset($_REQUEST["inneraction"]) && $_REQUEST["inneraction"] == "return_from_paypal_refund_my_account") {
            $ze_refund = isPayIDValidated(addslashes($_REQUEST["payid"]));
            if ($ze_refund == 0) {
                $out .= "<font color=\"red\">The transaction failed, please try again!</font>";
                return $out;
            } else {
                $out .= "<font color=\"green\">Funds added to your account!</font><br><br>";
                $q = "UPDATE {$pro_mysql_client_table} SET dollar = dollar+" . $ze_refund . " WHERE id='" . $admin["info"]["id_client"] . "';";
                $r = mysql_query($q) or die("Cannot querry {$q} line " . __LINE__ . " file " . __FILE__ . " sql said " . mysql_error());
                $admin["client"]["dollar"] += $ze_refund;
                $out .= "Your account now has \$" . $admin["client"]["dollar"];
                return $out;
            }
        } else {
            $payid = createCreditCardPaiementID(addslashes($_REQUEST["refund_amount"]), $admin["info"]["id_client"], "Refund my account", "no");
            $return_url = $_SERVER["PHP_SELF"] . "?adm_login={$adm_login}&adm_pass={$adm_pass}" . "&addrlink={$addrlink}&action=refund_myaccount&inneraction=return_from_paypal_refund_my_account&payid={$payid}";
            $paybutton = paynowButton($payid, addslashes($_REQUEST["refund_amount"]), "Refund my account", $return_url);
            $out .= "<b><u>Pay \$" . $_REQUEST["refund_amount"] . " on my account:</u></b><br>";
            $out .= " Please click on the button below to pay your acount.<br><br>{$paybutton}";
            return $out;
        }
    }
    if ($id_client != 0) {
        $client = $admin["client"];
    }
    if (isset($admin["data"])) {
        $out .= "<br><h3>" . _("Transfer and disk usage:") . "</h3>";
        // Draw overall this month usage
        // if there is no usage, set to 0
        if (!isset($stats["total_transfer"])) {
            $stats["total_transfer"] = 0;
        }
        $overall = "<br>" . _("Transfer this month:") . smartByte($stats["total_transfer"]);
        if ($id_client != 0) {
            $bw_quota = $admin["info"]["bandwidth_per_month_mb"] * 1024 * 1024;
            $overall .= " / " . smartByte($bw_quota) . "<br>";
            $overall .= drawPercentBar($stats["total_transfer"], $bw_quota);
        }
        $overall .= "<br>" . _("Total disk usage:") . smartByte($stats["total_du"]);
        if ($id_client != 0 && isset($admin["data"])) {
            $du_quota = $admin["info"]["quota"] * 1024 * 1024;
            $overall .= " / " . smartByte($du_quota) . "<br>";
            $overall .= drawPercentBar($stats["total_du"], $du_quota);
        }
        if ($id_client != 0) {
            $out .= '<table><td>' . $overall . '</td><td><img src="bw_per_month.php?cid=' . $id_client . '&adm_login=' . $adm_login . '"></td></tr></table>';
        } else {
            $out .= $overall;
        }
    }
    $out .= "<h3>" . _("Export configuration:") . "</h3>";
    $out .= "<a href=\"?adm_login={$adm_login}&adm_pass={$adm_pass}&action=export_my_account&addrlink=" . $_REQUEST["addrlink"] . "\" target=\"_blank\">" . _("Export all my domains configuration to a file") . "</a>";
    if ($id_client != 0) {
        // If the customer has domains (he could have only a VPS...).
        if (isset($admin["data"])) {
            $out .= "<br><h3>" . _("Your hosting account:") . "</h3>";
            $out .= "<table width=\"100%\" height=\"1\" cellpadding=\"4\" cellspacing=\"0\" border=\"1\">\n<tr>\n\t<td><b>" . _("Storage space") . "</b></td><td><b>" . _("Allowed bandwidth per month") . "</b></td><td><b>" . _("Expiry date") . "</b></td>\n</tr>\n<tr>\n\t<td>" . smartByte($du_quota) . "</td><td>" . smartByte($bw_quota) . "</td><td>" . $admin["info"]["expire"] . "</td>\n</tr>\n</table>";
            if (file_exists($dtcshared_path . "/dtcrm")) {
                $out .= "<br><center>{$frm_start}<input type=\"hidden\" name=\"action\" value=\"upgrade_myaccount\">\n<input type=\"submit\" value=\"" . _("Upgrade my account") . "\">\n</form>";
                $out .= "<form action=\"/dtc/new_account.php\">\n<input type=\"hidden\" name=\"action\" value=\"contract_renewal\">\n<input type=\"hidden\" name=\"renew_type\" value=\"shared\">\n<input type=\"hidden\" name=\"product_id\" value=\"" . $admin["info"]["prod_id"] . "\">\n<input type=\"hidden\" name=\"adm_login\" value=\"{$adm_login}\">\n<input type=\"hidden\" name=\"client_id\" value=\"{$id_client}\">\n<input type=\"submit\" value=\"" . _("Renew my account") . "\">\n</form></center><br>";
            }
            $out .= "<h3>" . _("SSL tokens") . "</h3><br>";
            $q = "SELECT * FROM {$pro_mysql_ssl_ips_table} WHERE adm_login='{$adm_login}' AND available='no';";
            $r = mysql_query($q) or die("Cannot query {$q} line " . __LINE__ . " file " . __FILE__ . " sql said: " . mysql_error());
            $n = mysql_num_rows($r);
            if ($n == 0) {
                $out .= _("You currently don't have any SSL tokens.") . "<br><br>";
            } else {
                $out .= "<table cellspacing=\"0\" cellpadding=\"0\" border=\"1\">";
                $out .= "<tr><td>" . _("IP address") . "</td><td>" . _("Used by") . "</td><td>" . _("Expire") . "</td><td>" . _("Action") . "</td></tr>";
                for ($i = 0; $i < $n; $i++) {
                    $a = mysql_fetch_array($r);
                    $nbr_domains = sizeof($admin["data"]);
                    $used_by = "Not used";
                    for ($j = 0; $j < $nbr_domains; $j++) {
                        $nbr_subdomains = sizeof($admin["data"][$j]["subdomains"]);
                        for ($k = 0; $k < $nbr_subdomains; $k++) {
                            if ($admin["data"][$j]["subdomains"][$k]["ssl_ip"] == $a["ip_addr"]) {
                                $used_by = $admin["data"][$j]["subdomains"][$k]["name"] . "." . $admin["data"][$j]["name"];
                            }
                        }
                    }
                    $q = "SELECT * FROM {$pro_mysql_product_table} WHERE heb_type='ssl';";
                    $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) {
                        $ssl_renew_form = _("No ssl product defined.");
                    } else {
                        $prod = mysql_fetch_array($r);
                        $ssl_renew_form = "<form action=\"/dtc/new_account.php\">\n<input type=\"hidden\" name=\"action\" value=\"contract_renewal\">\n<input type=\"hidden\" name=\"renew_type\" value=\"ssl_renew\">\n<input type=\"hidden\" name=\"ssl_ip_id\" value=\"" . $a["id"] . "\">\n<input type=\"hidden\" name=\"product_id\" value=\"" . $prod["id"] . "\">\n<input type=\"hidden\" name=\"adm_login\" value=\"{$adm_login}\">\n<input type=\"hidden\" name=\"client_id\" value=\"{$id_client}\">\n<input type=\"submit\" value=\"Renew SSL IP\"></form>";
                    }
                    $out .= "<tr><td>" . $a["ip_addr"] . "</td><td>{$used_by}</td><td>" . $a["expire"] . "</td><td>{$ssl_renew_form}</td></tr>";
                }
                $out .= "</table><br><br>";
            }
            $q = "SELECT * FROM {$pro_mysql_ssl_ips_table} WHERE available='yes';";
            $r = mysql_query($q) or die("Cannot query {$q} line " . __LINE__ . " file " . __FILE__ . " sql said: " . mysql_error());
            $n = mysql_num_rows($r);
            if ($n == 0) {
                $out .= _("No SSL token available: contact your administrator to request it.") . "<br><br>";
            } else {
                $q = "SELECT * FROM {$pro_mysql_product_table} WHERE heb_type='ssl';";
                $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) {
                    $out .= _("No ssl product defined.");
                } else {
                    $prod = mysql_fetch_array($r);
                    $out .= "<form action=\"/dtc/new_account.php\">\n<input type=\"hidden\" name=\"action\" value=\"contract_renewal\">\n<input type=\"hidden\" name=\"renew_type\" value=\"ssl\">\n<input type=\"hidden\" name=\"product_id\" value=\"" . $prod["id"] . "\">\n<input type=\"hidden\" name=\"adm_login\" value=\"{$adm_login}\">\n<input type=\"hidden\" name=\"client_id\" value=\"{$id_client}\">\n<input type=\"submit\" value=\"Buy an SSL IP\">\n</form></center><br>";
                }
            }
            $out .= "<h3>" . _("Remaining money on my account:") . "</h3>";
            $out .= dtcFormTableAttrs();
            $out .= dtcFormLineDraw(_("Money remaining: "), $client["dollar"] . " {$secpayconf_currency_letters}", 1);
            $out .= dtcFormLineDraw(_("Refund my account:"), "{$frm_start}<input type=\"hidden\" name=\"action\" value=\"refund_myaccount\">\n<input size=\"8\" type=\"text\" name=\"refund_amount\" value=\"\"> {$secpayconf_currency_letters}", 0);
            $out .= dtcFormLineDraw("", submitButtonStart() . _("Add money") . submitButtonEnd() . "</form>", 1);
            $out .= "</table>";
        }
        $out .= "<h3>" . _("Your address (please tell us if the following is not correct):") . "</h3>";
        if ($client["is_company"] == "yes") {
            $out .= _("Company name:") . $client["company_name"] . "<br>";
            $out .= _("VAT / GST number:") . $client["vat_num"] . "<br>";
        }
        $out .= _("First name:") . $client["christname"] . "<br>";
        $out .= _("Family name:") . $client["familyname"] . "<br>";
        $out .= _("Address:") . $client["addr1"] . "<br>";
        $out .= $client["addr2"] . "<br>";
        $out .= _("Zipcode:") . $client["zipcode"] . "<br>";
        $out .= _("City:") . $client["city"] . "<br>";
        $out .= _("State:") . $client["state"] . "<br>";
        $out .= _("Country:") . $cc_code_array[$client["country"]] . "<br>";
        $out .= _("Phone number:") . $client["phone"] . "<br>";
        $out .= _("Fax:") . $client["fax"] . "<br>";
        $out .= _("Email:") . $client["email"] . "<br>";
        $sql = "SELECT SUM(kickback) as kickbacks FROM affiliate_payments WHERE adm_login = '{$adm_login}' and date_paid IS NULL; ";
        $result = mysql_query($sql);
        $row = mysql_fetch_array($result);
        $afftotal = $row["kickbacks"];
        if ($afftotal) {
            global $pro_mysql_completedorders_table;
            $sql = "SELECT * FROM affiliate_payments INNER JOIN {$pro_mysql_completedorders_table} on (affiliate_payments.order_id = {$pro_mysql_completedorders_table}.id) WHERE adm_login = '{$adm_login}' and date_paid IS NULL; ";
            $result = mysql_query($sql);
            $out .= "" . _("Outstanding payments:") . "<br><table><tr><th>" . _("Date") . "</th><th>" . _("Amount") . "</th></tr>";
            while ($row = mysql_fetch_array($result)) {
                $out .= "<tr><td>{$row['date']}</td><td>{$row['kickback']}</td></tr>";
            }
            $out .= "<tr><td></td><th>{$afftotal}</th></tr>";
            $out .= "</table>";
        }
        $out .= "<h3>" . _("Affiliation") . "</h3>";
        $out .= _("If you want to earn money, all you have to do is place a link on your site, pointing to:") . "<pre>https://{$_SERVER['SERVER_NAME']}/dtc/affiliation.php?affiliate={$adm_login}&amp;return=/hosting-vps.html</pre>" . _("You can customize the <code>return</code> variable to redirect the user to any particular landing page that exists on our Web site (though we recommend the product page as per the example).  Then, when one of your visitors clicks on that link to buy a product from us, he will be redirected to our Web site.  Once he buys, you will automatically be credited a payment depending on the product that your visitor bought.");
    } else {
        $out .= "<br>" . _("You do not have a client account, so there is no money in your account.");
    }
    return $out;
}
示例#5
0
function drawAdminTools_PackageInstaller($domain, $adm_path)
{
    global $adm_login;
    global $adm_pass;
    global $edit_domain;
    global $addrlink;
    global $dtcshared_path;
    global $pro_mysql_subdomain_table;
    global $conf_mysql_db;
    global $conf_user_mysql_type;
    global $conf_user_mysql_host;
    global $conf_user_mysql_root_login;
    global $conf_user_mysql_root_pass;
    global $package_installer_console;
    global $dtcpkg_db_login;
    global $pkg_info;
    $txt = "";
    $dir = $dtcshared_path . "/package-installer";
    if (isset($_REQUEST["action"]) && ($_REQUEST["action"] == "do_install" || $_REQUEST["action"] == "prepareinstall")) {
        $pkg_path = $dir . "/" . $_REQUEST["pkg"];
        $dtc_pkg_info = $pkg_path . "/dtc-pkg-info.php";
        if (!file_exists($dtc_pkg_info)) {
            die("Package {$dtc_pkg_info} not found line " . __LINE__ . " file " . __FILE__);
        }
        include $dtc_pkg_info;
    }
    if (isset($_REQUEST["action"]) && $_REQUEST["action"] == "do_install") {
        $pkg_path = $dir . "/" . $_REQUEST["pkg"];
        $dtc_pkg_install = $pkg_path . "/dtc-pkg-install.php";
        if (file_exists($dtc_pkg_install)) {
            include $dtc_pkg_install;
        }
        // Check if user has enough rights
        checkLoginPassAndDomain($adm_login, $adm_pass, $edit_domain);
        checkSubdomainFormat($_REQUEST["subdomain"]);
        $admin_path = getAdminPath($adm_login);
        $target = "{$admin_path}/{$edit_domain}/subdomains/" . $_REQUEST["subdomain"] . "/html";
        if (!is_dir($target)) {
            die("Destination directory does not exists line " . __LINE__ . " file " . __FILE__);
        }
        // Unpack the distribution package in target folder
        if ($pkg_info["unpack_type"] == "tar.gz") {
            $cmd = "tar -C {$target} -xvzf {$pkg_path}/" . $pkg_info["file"];
            $x = "=> tar -C {$target} -xvzf {$pkg_path}/" . $pkg_info["file"] . "\n";
            exec($cmd, $exec_out, $return_val);
        } else {
            if ($pkg_info["unpack_type"] == "tar.bz2") {
                $cmd = "tar -C {$target} -xvjf {$pkg_path}/" . $pkg_info["file"];
                $x = "=> tar -xvjf " . $pkg_info["file"] . "\n";
                exec($cmd, $exec_out, $return_val);
            } else {
                die("Package methode not supported yet");
            }
        }
        // Rename folder to the destination folder name (eg remove version out of package.X.X.X folder name if exists)
        if (isset($pkg_info["renamedir_to"]) && isset($pkg_info["resulting_dir"]) && $pkg_info["resulting_dir"] != $pkg_info["renamedir_to"]) {
            $cmd = "mv {$target}/" . $pkg_info["resulting_dir"] . " {$target}/" . $pkg_info["renamedir_to"];
            $x .= "=> Moving " . $pkg_info["resulting_dir"] . " to " . $pkg_info["renamedir_to"] . "<br>";
            exec($cmd, $exec_out, $return_val);
        }
        // https://dtc.gpl-host.com/dtc/index.php?adm_login=zigo&adm_pass=toto&addrlink=gpl-host.com/package-installer&action=prepareinstall&pkg=phpbb
        // Move the folder to the requested name dtcpkg_directory=bla
        if ($pkg_info["can_select_directory"] == "yes") {
            if ($_REQUEST["dtcpkg_directory"] == "") {
                $cmd = "mv {$target}/" . $pkg_info["renamedir_to"] . "/* {$target}/";
                $x .= "=> Moving " . $pkg_info["renamedir_to"] . " to folder /<br>";
                exec($cmd, $exec_out, $return_val);
                $realtarget = "{$target}";
            } else {
                $cmd = "mv {$target}/" . $pkg_info["renamedir_to"] . " {$target}/" . $_REQUEST["dtcpkg_directory"];
                $x .= "=> Moving " . $pkg_info["renamedir_to"] . " to " . $_REQUEST["dtcpkg_directory"] . "<br>";
                exec($cmd, $exec_out, $return_val);
                $realtarget = "{$target}/" . $_REQUEST["dtcpkg_directory"];
            }
        }
        if ($conf_user_mysql_type == "distant") {
            $newid = mysql_connect($conf_user_mysql_host, $conf_user_mysql_root_login, $conf_user_mysql_root_pass) or die("Cannot connect to user host");
        }
        // Get the database infos beffore calling the custom package installer
        $q = "SELECT DISTINCT db.Db,db.User FROM mysql.user,mysql.db WHERE user.dtcowner='{$adm_login}' AND db.User=user.User AND db.Db='" . $_REQUEST["database_name"] . "';";
        $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 database line " . __LINE__ . " file " . __FILE__);
        }
        $a = mysql_fetch_array($r);
        $dtcpkg_db_login = $a["User"];
        if ($conf_user_mysql_type == "distant") {
            mysql_close($newid) or die("Cannot disconnect to user database");
            connect2base();
        }
        // Call the package specific installer php script
        $install_ret = do_package_install();
        // reselect the current dtc db in case another have been set
        mysql_select_db($conf_mysql_db);
        if ($install_ret == 0) {
            $package_installer_console .= "Install successful !<br>";
        }
        $nbr_remove = sizeof($pkg_info["remove_folder_path"]);
        if ($nbr_remove > 0) {
            //	print_r($pkg_info["remove_folder_path"]);
            $nbr_remove = sizeof($pkg_info["remove_folder_path"]);
            $package_installer_console .= "Removing install folders...<br>";
            for ($i = 0; $i < $nbr_remove; $i++) {
                $cmd = "rm -r {$realtarget}/" . $pkg_info["remove_folder_path"][$i];
                //	$package_installer_console .= $cmd."<br>";
                exec($cmd, $exec_out, $return_val);
            }
        }
        // Print the results
        $txt .= "<h3>Installation of " . $pkg_info["name"] . ":</h3><br><pre>" . $x . $package_installer_console . "</pre>";
        return $txt;
    }
    if (isset($_REQUEST["action"]) && $_REQUEST["action"] == "prepareinstall") {
        $txt = "<h3>You are about to install " . $pkg_info["name"] . ":</h3><br>\n\t\t<u>Description:</u> " . $pkg_info["long_desc"] . "<br>\n\t\t<u>Version:</u> " . $pkg_info["version"] . "<br><br>";
        $txt .= "<form action=\"" . $_SERVER["PHP_SELF"] . "\">\n\t\t<input type=\"hidden\" name=\"adm_login\" value=\"{$adm_login}\">\n\t\t<input type=\"hidden\" name=\"adm_pass\" value=\"{$adm_pass}\">\n\t\t<input type=\"hidden\" name=\"addrlink\" value=\"{$addrlink}\">";
        if ($pkg_info["need_database"] == "yes") {
            $txt .= "<h3>Choose a database name for setup:</h3><br>";
            if ($conf_user_mysql_type == "distant") {
                $newid = mysql_connect($conf_user_mysql_host, $conf_user_mysql_root_login, $conf_user_mysql_root_pass) or die("Cannot connect to user SQL host");
            }
            mysql_select_db("mysql") or die("Cannot select db: mysql");
            $q = "SELECT db.Db,db.User FROM user,db\n\t\t\tWHERE user.dtcowner='{$adm_login}'\n\t\t\tAND db.User=user.User";
            $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) {
                $txt .= "You don't have any database yet. Please create one using the database tool\n\t\t\t\t(click database in the menu, then create a user and a database for this user).";
                if ($conf_user_mysql_type == "distant") {
                    mysql_close($newid) or die("Cannot disconnect to user database");
                    connect2base();
                }
                mysql_select_db($conf_mysql_db);
                return $txt;
            }
            $txt .= "Database name: <select name=\"database_name\">";
            for ($i = 0; $i < $n; $i++) {
                $a = mysql_fetch_array($r);
                $txt .= "<option value=\"" . $a["Db"] . "\">" . $a["Db"] . " (login: " . $a["User"] . ")" . "</option>";
            }
            $txt .= "</select><br>\n\t\t\t\tDatabase password: <input type=\"password\" name=\"dtcpkg_db_pass\" value=\"\"><br><br>";
            if ($conf_user_mysql_type == "distant") {
                mysql_close($newid) or die("Cannot disconnect to user database");
                connect2base();
            }
            mysql_select_db($conf_mysql_db) or die("Cannot select db: {$conf_mysql_db} line " . __LINE__ . " file " . __FILE__);
        }
        if ($pkg_info["need_admin_email"] == "yes") {
            $txt .= "<h3>Enter email for the admin of this package:</h3><br>";
            $txt .= "Email: <input type=\"text\" name=\"dtcpkg_email\" value=\"\"><br><br>";
        }
        if ($pkg_info["need_admin_login"] == "yes") {
            $txt .= "<h3>Enter login informations for the admin of this package:</h3><br>";
            $txt .= "Login: <input type=\"text\" name=\"dtcpkg_login\" value=\"\"><br>";
            if ($pkg_info["need_admin_pass"] == "yes") {
                $txt .= "Pass: <input type=\"text\" name=\"dtcpkg_pass\" value=\"\"><br>";
            }
            $txt .= "<br>";
        }
        $txt .= "<h3>Choose the subdomain and install :</h3><br>";
        $txt .= "<input type=\"hidden\" name=\"action\" value=\"do_install\">\n\t\t<input type=\"hidden\" name=\"pkg\" value=\"" . $_REQUEST["pkg"] . "\">\n\t\tSubdomain: <select name=\"subdomain\">";
        //		echo "<pre>";
        //		print_r($domain);
        //		echo "</pre>";
        $n = sizeof($domain["subdomains"]);
        for ($i = 0; $i < $n; $i++) {
            $txt .= "<option value=\"" . $domain["subdomains"][$i]["name"] . "\">" . $domain["subdomains"][$i]["name"] . "</option>";
        }
        $txt .= "</select><br><br>";
        if ($pkg_info["can_select_directory"] == "yes") {
            $txt .= "<h3>Enter the directory where you want to install this package:</h3><br>";
            $txt .= "Directory (blank for /): <input type=\"text\" name=\"dtcpkg_directory\" value=\"\"><br><br>";
        }
        $txt .= "<input type=\"submit\" value=\"Install\">";
        $txt .= "</form>";
        return $txt;
    }
    $txt = "<h3>" . _("Choose a package to install") . ":</h3>";
    $txt .= "<table cellspacing=\"0\" cellpadding=\"4\" border=\"1\">";
    $txt .= "<tr><td>" . _("Package name") . "</td><td>" . _("Description") . "</td><td>" . _("Package version") . "</td><td>" . _("Need a database") . "</td><td>" . _("Unpack size") . "</td><td>" . _("Install") . "</td></tr>";
    $packages = array();
    if (is_dir($dir) && ($dh = opendir($dir))) {
        while (($file = readdir($dh)) !== false) {
            if (is_dir($dir . "/" . $file) && $file != "." && $file != "..") {
                $packages[] = $file;
            }
        }
        closedir($dh);
    }
    sort($packages);
    foreach ($packages as $package) {
        if (file_exists($dir . "/" . $package . "/dtc-pkg-info.php")) {
            include $dir . "/" . $package . "/dtc-pkg-info.php";
            $txt .= "<tr><td>" . $pkg_info["name"] . "</td>\n\t\t\t\t<td>" . $pkg_info["short_desc"] . "</td>\n\t\t\t\t<td>" . $pkg_info["version"] . "</td>\n\t\t\t\t<td>" . $pkg_info["need_database"] . "</td>\n\t\t\t\t<td style=\"white-space:nowrap;text-align=right\" nowrap>" . smartByte($pkg_info["unpack_disk_usage"]) . "</td>\n\t\t\t\t<td><a href=\"" . $_SERVER["PHP_SELF"] . "?adm_login={$adm_login}&adm_pass={$adm_pass}&addrlink={$addrlink}&action=prepareinstall&pkg={$package}\">" . _("Install") . "</a></td></tr>";
        }
    }
    $txt .= "</table>";
    return $txt;
}
示例#6
0
function drawAdminMonitor()
{
    global $pro_mysql_client_table;
    global $pro_mysql_admin_table;
    global $conf_mysql_db;
    global $adm_realpass;
    global $adm_pass;
    global $adm_random_pass;
    $out = "";
    // For each clients
    $q = "SELECT * FROM {$pro_mysql_client_table} WHERE 1 ORDER BY familyname,christname";
    $r = mysql_query($q) or die("Cannot query: \"{$q}\" !" . mysql_error() . " line " . __LINE__ . " in file " . __FILE__);
    $nr = mysql_num_rows($r);
    $out .= '<br><table border="1" width="100%" height="1" cellpadding="1" cellspacing="1">';
    $out .= "<tr><td><b>" . _("User") . "</b></td><td><b>" . _("Transfer") . " / " . _("BW Quota") . "</b></td><td><b>" . _("Transfer per month") . "</b></td><td><b>" . _("Disk usage") . " / " . _("Quota") . "</b></td></tr>";
    $total_box_transfer = 0;
    $total_box_hits = 0;
    for ($i = 0; $i < $nr; $i++) {
        $ar = mysql_fetch_array($r);
        $transfer = 0;
        $total_hits = 0;
        $du = 0;
        // make sure we are selecting the correct DB
        // there is a condition where we have lost the link to the main DB
        // this may hide another bug, but at least it will show things to the user
        mysql_select_db($conf_mysql_db);
        // For each of it's admins
        $q2 = "SELECT * FROM {$pro_mysql_admin_table} WHERE id_client='" . $ar["id"] . "';";
        $r2 = mysql_query($q2) or die("Cannot query: \"{$q2}\" !" . mysql_error() . " line " . __LINE__ . " in file " . __FILE__);
        $nr2 = mysql_num_rows($r2);
        $admin = array();
        $admin_stats = array();
        for ($j = 0; $j < $nr2; $j++) {
            $ar2 = mysql_fetch_array($r2);
            $adm_realpass = $ar2["adm_pass"];
            $adm_pass = $ar2["adm_pass"];
            $adm_random_pass = $ar2["adm_pass"];
            $oneadmin = fetchAdmin($ar2["adm_login"], $ar2["adm_pass"]);
            $admin_stats = fetchAdminStats($oneadmin);
            $admin = array_merge($admin, $oneadmin);
            if (isset($admin_stats["total_transfer"])) {
                $transfer += $admin_stats["total_transfer"];
            }
            if (isset($admin_stats["total_du"])) {
                $du += $admin_stats["total_du"];
            }
            if (isset($admin_stats["total_hit"])) {
                $hits = $admin_stats["total_hit"];
                $total_hits += $hits;
            }
        }
        if ($i % 2) {
            $back = " bgcolor=\"#000000\" style=\"white-space:nowrap;color:#FFFFFF\" nowrap";
        } else {
            $back = " style=\"white-space:nowrap;\" nowrap";
        }
        $nbr_row = 0;
        if (!isset($admin["vps"])) {
            $nbr_vps = 0;
        } else {
            $nbr_vps = sizeof($admin["vps"]);
            $nbr_row += $nbr_vps;
        }
        if (isset($admin["data"])) {
            $nbr_row += 1;
        }
        if ($nbr_row > 1) {
            $rowspan_entry = "rowspan=\"{$nbr_row}\"";
        } else {
            $rowspan_entry = "";
        }
        // Admin name
        $out .= "<tr><td{$back} {$rowspan_entry}><u>" . $ar["company_name"] . ":</u><br>\n" . $ar["familyname"] . ", " . $ar["christname"] . "</td>";
        if (isset($admin["data"])) {
            // Transfer this month
            $out .= "<td{$back}>" . drawPercentBar($transfer, $ar["bw_quota_per_month_gb"] * 1024 * 1024 * 1024, "no") . "<br>\n" . smartByte($transfer) . " / " . smartByte($ar["bw_quota_per_month_gb"] * 1024 * 1024 * 1024) . " ({$total_hits} hits)</td>";
            // Per month transfer graph
            $out .= "<td{$back}><img width=\"120\" height=\"48\" src=\"bw_per_month.php?cid=" . $ar["id"] . "\"></td>";
            // Share hosing hard disk space
            $out .= "<td{$back}>" . drawPercentBar($du, $ar["disk_quota_mb"] * 1024 * 1024, "no") . "<br>\n" . smartByte($du) . " / " . smartByte($ar["disk_quota_mb"] * 1024 * 1024) . "</td></tr>";
        }
        for ($j = 0; $j < $nbr_vps; $j++) {
            if (isset($admin["data"]) || $j > 1) {
                $out .= "<tr>";
            }
            $out .= "<td {$back} colspan=\"3\">" . $admin["vps"][$j]["vps_server_hostname"] . ":" . $admin["vps"][$j]["vps_xen_name"];
            $out .= "<table border=\"1\" width=\"100%\" height=\"1\" cellpadding=\"1\" cellspacing=\"1\">";
            $out .= "<tr><td {$back}>" . _("Network") . "</td><td {$back}>" . _("HDD") . "</td><td {$back}>" . _("Swap") . "</td><td {$back}>" . _("CPU") . "</td></tr>";
            $out .= "<tr><td {$back}><img width=\"120\" height=\"48\" src=\"vps_stats_network.php?vps_node=" . $admin["vps"][$j]["vps_server_hostname"] . "&vps_name=" . $admin["vps"][$j]["vps_xen_name"] . "\"></td>\n<td {$back}><img width=\"120\" height=\"48\" src=\"vps_stats_hdd.php?vps_node=" . $admin["vps"][$j]["vps_server_hostname"] . "&vps_name=" . $admin["vps"][$j]["vps_xen_name"] . "\"></td>\n<td {$back}><img width=\"120\" height=\"48\" src=\"vps_stats_swap.php?vps_node=" . $admin["vps"][$j]["vps_server_hostname"] . "&vps_name=" . $admin["vps"][$j]["vps_xen_name"] . "\"></td>\n<td {$back}><img width=\"120\" height=\"48\" src=\"vps_stats_cpu.php?vps_node=" . $admin["vps"][$j]["vps_server_hostname"] . "&vps_name=" . $admin["vps"][$j]["vps_xen_name"] . "\"></td>";
            $out .= "</tr>";
            $out .= "</table>";
            $out .= "</td></tr>";
        }
        $total_box_transfer += $transfer;
        $total_box_hits += $total_hits;
        //fetchAdminStats($admin)
    }
    $out .= "</table>";
    $out .= _("Server accounted transfers this month: ") . smartByte($total_box_transfer) . " ({$total_box_hits} hits)";
    return $out;
}
示例#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;
}
示例#8
0
function drawAdminTools_AdminStats($admin)
{
    global $adm_login;
    global $conf_mysql_db;
    global $pro_mysql_domain_table;
    global $pro_mysql_acc_http_table;
    global $pro_mysql_acc_ftp_table;
    $out = "";
    $nowrap = " style=\"white-space:nowrap\" nowrap";
    $stats = fetchAdminStats($admin);
    // ["domains"][]["name"]
    //              ["du"]
    //              ["ftp"]
    //              ["http"]
    //              ["smtp"]
    //              ["pop"]
    //              ["total_transfer"]
    // ["total_http"]
    // ["total_ftp"]
    // ["total_email"]
    // ["total_transfer"]
    // ["total_du_domains"]
    // ["db"][]["name"]
    //         ["du"]
    // ["total_db_du"]
    // ["total_du"]
    $id_client = $admin["info"]["id_client"];
    // Print the transfer overall total for this month
    $out .= "<h3>" . _("Total transfered bytes this month:") . "</h3>";
    if (!isset($stats["total_http"])) {
        $stats["total_http"] = 0;
    }
    $out .= "<br>HTTP: " . smartByte($stats["total_http"]) . " " . $stats["total_hit"] . " " . _("hits");
    if (!isset($stats["total_ftp"])) {
        $stats["total_ftp"] = 0;
    }
    $out .= "<br>FTP: " . smartByte($stats["total_ftp"]);
    if (!isset($stats["total_email"])) {
        $stats["total_email"] = 0;
    }
    $out .= "<br>Email: " . smartByte($stats["total_email"]);
    if (!isset($stats["total_transfer"])) {
        $stats["total_transfer"] = 0;
    }
    $out .= "<br>Total: " . smartByte($stats["total_transfer"]);
    if ($id_client != 0) {
        $bw_quota = $admin["info"]["bandwidth_per_month_mb"] * 1024 * 1024;
        $out .= " / " . smartByte($bw_quota) . "<br>";
        $out .= drawPercentBar($stats["total_transfer"], $bw_quota);
    }
    // Print disk usage
    $out .= "<br><h3>" . _("Total disk usage:") . "</h3>";
    if (!isset($stats["total_du_domains"])) {
        $stats["total_du_domains"] = 0;
    }
    $out .= "<br>" . _("Domain name files:") . " " . smartByte($stats["total_du_domains"]);
    if (isset($stats["total_du_db"])) {
        $out .= "<br>" . _("Database files:") . " " . smartByte($stats["total_du_db"]);
    } else {
        $out .= "<br>" . _("Database files:") . " " . smartByte(0);
    }
    $out .= "<br>" . _("Total disk usage:") . " " . smartByte($stats["total_du"]);
    if ($id_client != 0) {
        $du_quota = $admin["info"]["quota"] * 1024 * 1024;
        $out .= " / " . smartByte($du_quota) . "<br>";
        $out .= drawPercentBar($stats["total_du"], $du_quota);
    }
    $out .= "<br><br><h3>" . _("Databases disk usage:") . "</h3>";
    $out .= '<br><table border="1" width="100%" height="1" cellpadding="0" cellspacing="1">';
    $out .= "<tr><td{$nowrap} class=\"dtcDatagrid_table_titles\"><b>" . _("Database Name") . "</b></td><td{$nowrap} class=\"dtcDatagrid_table_titles\"><b>" . _("Disk usage") . "</b></tr>";
    if (isset($stats["db"])) {
        $n = sizeof($stats["db"]);
    } else {
        $n = 0;
    }
    for ($i = 0; $i < $n; $i++) {
        if ($i % 2) {
            $bgcolor = "{$nowrap} ";
        } else {
            $bgcolor = "{$nowrap} class=\"alternatecolorline\" ";
        }
        $out .= "<tr>";
        $out .= "<td{$bgcolor}>" . $stats["db"][$i]["name"] . "</td>";
        $out .= "<td{$bgcolor}>" . smartByte($stats["db"][$i]["du"]) . "</td>";
        $out .= "</tr>";
    }
    $out .= '</table>';
    $out .= "<br><br><h3>" . _("Domain name traffic and disk usage:") . "</h3>";
    $out .= '<br><table border="1" width="100%" height="1" cellpadding="0" cellspacing="1">';
    $out .= "<tr><td class=\"dtcDatagrid_table_titles\"><b>" . _("Domain name") . "</b></td><td{$nowrap} class=\"dtcDatagrid_table_titles\"><b>" . _("Disk usage") . "</b></td>\n\t<td class=\"dtcDatagrid_table_titles\"><b>POP3</b></td><td class=\"dtcDatagrid_table_titles\"><b>IMAP</b></td><td class=\"dtcDatagrid_table_titles\"><b>SMTP</b></td><td class=\"dtcDatagrid_table_titles\"><b>FTP</b></td><td class=\"dtcDatagrid_table_titles\"><b>HTTP</b></td>\n\t<td{$nowrap} class=\"dtcDatagrid_table_titles\"><b>HTTP HITS</b></td>\n\t<td{$nowrap} class=\"dtcDatagrid_table_titles\"><b>" . _("Total traffic") . "</b></td></tr>";
    if (isset($stats["domains"])) {
        for ($ad = 0; $ad < sizeof($stats["domains"]); $ad++) {
            if ($ad % 2) {
                $bgcolor = "{$nowrap} ";
            } else {
                $bgcolor = "{$nowrap} class=\"alternatecolorline\" ";
            }
            $out .= "<tr>";
            $out .= "<td{$bgcolor}>" . $stats["domains"][$ad]["name"] . "</td>";
            $out .= "<td{$bgcolor}>" . smartByte($stats["domains"][$ad]["du"]) . "</td>";
            $out .= "<td{$bgcolor}>" . smartByte($stats["domains"][$ad]["pop"]) . "</td>";
            $out .= "<td{$bgcolor}>" . smartByte($stats["domains"][$ad]["imap"]) . "</td>";
            $out .= "<td{$bgcolor}>" . smartByte($stats["domains"][$ad]["smtp"]) . "</td>";
            $out .= "<td{$bgcolor}>" . smartByte($stats["domains"][$ad]["ftp"]) . "</td>";
            $out .= "<td{$bgcolor}>" . smartByte($stats["domains"][$ad]["http"]) . "</td>";
            $out .= "<td{$bgcolor}>" . $stats["domains"][$ad]["hit"] . "</td>";
            $out .= "<td{$bgcolor}>" . smartByte($stats["domains"][$ad]["total_transfer"]) . "</td>";
            $out .= "</tr>";
        }
    }
    $out .= '</table>';
    return $out;
}