Ejemplo n.º 1
0
function productManager()
{
    global $pro_mysql_product_table;
    global $secpayconf_currency_symbol;
    if (!isset($secpayconf_currency_symbol)) {
        get_secpay_conf();
    }
    $dsc = array("table_name" => $pro_mysql_product_table, "title" => _("Product list editor") . _(" (shared)"), "action" => "hosting_product_list_shared", "forward" => array("rub"), "where_condition" => "heb_type='shared'", "cols" => array("id" => array("type" => "id", "display" => "yes", "legend" => "Id"), "name" => array("type" => "text", "legend" => _("Product name"), "size" => "30"), "period" => array("type" => "text", "help" => _("Period for the product with format YYYY-MM-DD. For example, if you want a product that will last 1 year, 2 months, and 3 days, write 0001-02-03. "), "legend" => _("Period"), "size" => "10"), "price_dollar" => array("type" => "text", "legend" => _("Price"), "size" => "4"), "setup_fee" => array("type" => "text", "legend" => _("Setup fee"), "size" => "4"), "affiliate_kickback" => array("type" => "text", "help" => _("This is the amount of money that you will give back to the affiliate account that made the sell possible."), "legend" => _("Commission") . " " . $secpayconf_currency_symbol, "size" => "4"), "quota_disk" => array("type" => "text", "help" => _("Hard drive space in MBytes."), "legend" => _("Disk"), "size" => "4"), "nbr_email" => array("type" => "text", "legend" => _("Max email"), "size" => "2"), "nbr_database" => array("type" => "text", "legend" => _("Max database"), "size" => "2"), "bandwidth" => array("type" => "text", "legend" => _("Traffic"), "size" => "5"), "allow_add_domain" => array("type" => "popup", "legend" => _("Add domain"), "help" => _("If set to yes, the the admin can add a domain, if set to check, then it will go through moderation, set to no, no domain addition to account is possible by the admin."), "values" => array("check", "no", "yes"), "display_replace" => array(_("check"), _("no"), _("yes"))), "max_domain" => array("type" => "text", "legend" => _("Max domain"), "help" => _("Maximum number of domain a customer can add by himself on his shared account. Setting a value of zero will mean no limit."), "size" => "3"), "allow_dns_and_mx_change" => array("type" => "checkbox", "legend" => _("DNS & MX"), "help" => _("If set to no, users wont be able to edit the DNS and MX pointer of their domains."), "values" => array("yes", "no"), "display_replace" => array(_("Yes"), _("No")), "default" => "no"), "ftp_login_flag" => array("type" => "checkbox", "legend" => _("FTP"), "help" => _("If set to no, users wont be able to add/remove/edit FTP accounts."), "values" => array("yes", "no"), "display_replace" => array(_("Yes"), _("No")), "default" => "yes"), "restricted_ftp_path" => array("type" => "checkbox", "legend" => _("Restricted FTP"), "help" => _("If set to no, users will only be able to create FTP accounts with a path in the html folder of each vhosts."), "values" => array("yes", "no"), "display_replace" => array(_("Yes"), _("No")), "default" => "no"), "allow_mailing_list_edit" => array("type" => "checkbox", "legend" => _("Lists"), "help" => _("If set to no, users wont be able to add/remove/edit mailing lists and mail alias groups."), "values" => array("yes", "no"), "display_replace" => array(_("Yes"), _("No")), "default" => "yes"), "allow_subdomain_edit" => array("type" => "checkbox", "legend" => _("Subdomains"), "help" => _("If set to no, users wont be able to add/remove/edit subdomains."), "values" => array("yes", "no"), "display_replace" => array(_("Yes"), _("No")), "default" => "yes"), "pkg_install_flag" => array("type" => "checkbox", "legend" => _("Subdomains"), "help" => _("If set to no, users wont be able to use the package installer."), "values" => array("yes", "no"), "display_replace" => array(_("Yes"), _("No")), "default" => "yes"), "private" => array("type" => "checkbox", "legend" => _("Private"), "help" => _("If the private flag is set, then this product wont appear in the registration form."), "values" => array("yes", "no"), "display_replace" => array(_("Yes"), _("No")), "default" => "no")));
    $out = dtcDatagrid($dsc);
    // Build the product ID popup
    $qp = "SELECT id,name FROM {$pro_mysql_product_table} WHERE renew_prod_id='0' AND heb_type='vps'";
    $rp = mysql_query($qp) or die("Cannot query \"{$qp}\" !!! line: " . __LINE__ . " file: " . __FILE__ . " sql said: " . mysql_error());
    $np = mysql_num_rows($rp);
    $renew_id_popup = array();
    $renew_id_popup[] = 0;
    $renew_id_replace = array();
    $renew_id_replace[] = _("Not a renewal product");
    for ($j = 0; $j < $np; $j++) {
        $ap = mysql_fetch_array($rp);
        $renew_id_popup[] = $ap["id"];
        if (strlen($ap["name"]) > 20) {
            $renew_id_replace[] = $ap["id"] . ": " . substr($ap["name"], 0, 17) . "...";
        } else {
            $renew_id_replace[] = $ap["id"] . ": " . $ap["name"];
        }
    }
    $dsc = array("table_name" => $pro_mysql_product_table, "title" => _("Product list editor") . _(" (VPS)"), "action" => "hosting_product_list_vps", "forward" => array("rub"), "where_condition" => "heb_type='vps'", "cols" => array("id" => array("type" => "id", "display" => "yes", "legend" => "Id"), "renew_prod_id" => array("type" => "popup", "help" => _("If you set the renewal ID, then this entry will be considered as a renewal product for the matching ID."), "legend" => _("Renewal-ID"), "values" => $renew_id_popup, "display_replace" => $renew_id_replace), "name" => array("type" => "text", "legend" => _("Name"), "size" => "30"), "period" => array("type" => "text", "help" => _("Period for the product with format YYYY-MM-DD. For example, if you want a product that will last 1 year, 2 months, and 3 days, write 0001-02-03. "), "legend" => _("Period"), "size" => "10"), "price_dollar" => array("type" => "text", "legend" => _("Price"), "size" => "4"), "setup_fee" => array("type" => "text", "legend" => _("Setup fee"), "size" => "4"), "affiliate_kickback" => array("type" => "text", "help" => _("This is the amount of money that you will give back to the affiliate account that made the sell possible."), "legend" => _("Commission") . " " . $secpayconf_currency_symbol, "size" => "4"), "quota_disk" => array("type" => "text", "help" => _("Hard drive space in MBytes."), "legend" => _("Disk"), "size" => "4"), "memory_size" => array("type" => "text", "help" => _("Memory size in MBytes."), "legend" => _("RAM"), "size" => "4"), "bandwidth" => array("type" => "text", "help" => _("Bandwidth per month in MBytes."), "legend" => _("Traffic"), "size" => "5"), "private" => array("type" => "checkbox", "legend" => _("Private"), "help" => _("If the private flag is set, then this product wont appear in the registration form."), "values" => array("yes", "no"), "display_replace" => array(_("Yes"), _("No")), "default" => "no")));
    $out .= dtcDatagrid($dsc);
    // Build the product ID popup
    $qp = "SELECT id,name FROM {$pro_mysql_product_table} WHERE renew_prod_id='0' AND heb_type='server'";
    $rp = mysql_query($qp) or die("Cannot query \"{$qp}\" !!! line: " . __LINE__ . " file: " . __FILE__ . " sql said: " . mysql_error());
    $np = mysql_num_rows($rp);
    $renew_id_popup = array();
    $renew_id_popup[] = 0;
    $renew_id_replace = array();
    $renew_id_replace[] = _("Not a renewal product");
    for ($j = 0; $j < $np; $j++) {
        $ap = mysql_fetch_array($rp);
        $renew_id_popup[] = $ap["id"];
        if (strlen($ap["name"]) > 20) {
            $renew_id_replace[] = $ap["id"] . ": " . substr($ap["name"], 0, 17) . "...";
        } else {
            $renew_id_replace[] = $ap["id"] . ": " . $ap["name"];
        }
    }
    $dsc = array("table_name" => $pro_mysql_product_table, "title" => _("Product list editor") . _(" (Dedicated servers)"), "action" => "hosting_product_list_dedicated", "forward" => array("rub"), "where_condition" => "heb_type='server'", "cols" => array("id" => array("type" => "id", "display" => "yes", "legend" => "Id"), "renew_prod_id" => array("type" => "popup", "help" => _("If you set the renewal ID, then this entry will be considered as a renewal product for the matching ID."), "legend" => _("Renewal-ID"), "values" => $renew_id_popup, "display_replace" => $renew_id_replace), "name" => array("type" => "text", "legend" => _("Name"), "size" => "30"), "period" => array("type" => "text", "help" => _("Period for the product with format YYYY-MM-DD. For example, if you want a product that will last 1 year, 2 months, and 3 days, write 0001-02-03. "), "legend" => _("Period"), "size" => "10"), "price_dollar" => array("type" => "text", "legend" => _("Price"), "size" => "4"), "setup_fee" => array("type" => "text", "legend" => _("Setup fee"), "size" => "4"), "affiliate_kickback" => array("type" => "text", "help" => _("This is the amount of money that you will give back to the affiliate account that made the sell possible."), "legend" => _("Commission") . " " . $secpayconf_currency_symbol, "size" => "4"), "quota_disk" => array("type" => "text", "help" => _("Hard drive space in MBytes."), "legend" => _("Disk"), "size" => "4"), "memory_size" => array("type" => "text", "help" => _("Memory size in MBytes."), "legend" => "RAM", "size" => "4"), "bandwidth" => array("type" => "text", "help" => _("Bandwidth per month in GBytes."), "legend" => _("Traffic"), "size" => "5"), "use_radius" => array("type" => "checkbox", "legend" => _("Use Radius"), "help" => _("If the Use Radius flag is set this service is used to check a radius user."), "values" => array("yes", "no"), "display_replace" => array(_("Yes"), _("No")), "default" => "no"), "private" => array("type" => "checkbox", "legend" => _("Private"), "help" => _("If the private flag is set, then this product wont appear in the registration form."), "values" => array("yes", "no"), "display_replace" => array(_("Yes"), _("No")), "default" => "no")));
    $out .= dtcDatagrid($dsc);
    $dsc = array("table_name" => $pro_mysql_product_table, "title" => _("Product list editor") . _(" (SSL IPs)"), "action" => "hosting_product_list_ssl", "forward" => array("rub"), "where_condition" => "heb_type='ssl'", "cols" => array("id" => array("type" => "id", "display" => "yes", "legend" => "Id"), "renew_prod_id" => array("type" => "popup", "legend" => _("Renewal-ID"), "help" => _("There must be ONLY ONE SSL product at any time, with only ONE renewal product."), "values" => $renew_id_popup, "display_replace" => array(_("No-renew"))), "name" => array("type" => "text", "legend" => _("Name"), "size" => "30"), "period" => array("type" => "text", "help" => _("Period for the product with format YYYY-MM-DD. For example, if you want a product that will last 1 year, 2 months, and 3 days, write 0001-02-03. "), "legend" => _("Period"), "size" => "10"), "price_dollar" => array("type" => "text", "legend" => _("Price"), "size" => "4"), "setup_fee" => array("type" => "text", "legend" => _("Setup fee"), "size" => "4"), "affiliate_kickback" => array("type" => "text", "help" => _("This is the amount of money that you will give back to the affiliate account that made the sell possible."), "legend" => _("Commission") . " " . $secpayconf_currency_symbol, "size" => "4"), "private" => array("type" => "checkbox", "legend" => _("Private"), "help" => _("If the private flag is set, then this product wont appear in the registration form."), "values" => array("yes", "no"), "display_replace" => array(_("Yes"), _("No")), "default" => "no")));
    $out .= dtcDatagrid($dsc);
    $out .= helpLink("PmWiki/HostingProductManager");
    return $out;
}
Ejemplo n.º 2
0
function drawRenewalTables()
{
    global $pro_mysql_product_table;
    global $pro_mysql_admin_table;
    global $pro_mysql_ssl_ips_table;
    global $pro_mysql_product_table;
    global $pro_mysql_vps_table;
    global $pro_mysql_dedicated_table;
    global $pro_mysql_ssl_ips_table;
    global $pro_mysql_client_table;
    global $pro_mysql_domain_table;
    global $pro_mysql_completedorders_table;
    global $pro_mysql_pay_table;
    global $pro_mysql_spent_type_table;
    global $pro_mysql_spent_providers_table;
    global $pro_mysql_spent_moneyout_table;
    global $pro_mysql_companies_table;
    global $pro_mysql_spent_bank_table;
    global $pro_mysql_client_table;
    global $pro_mysql_new_admin_table;
    global $secpayconf_currency_letters;
    global $rub;
    global $conf_vps_renewal_shutdown;
    get_secpay_conf();
    if (!isset($_REQUEST["sousrub"]) || $_REQUEST["sousrub"] == "") {
        $sousrub = "renewalreport";
    } else {
        $sousrub = $_REQUEST["sousrub"];
    }
    $out = '<ul class="box_wnb_content_nb">';
    if ($sousrub == "renewalreport") {
        $out .= "<li class=\"box_wnb_content_nb_item_select\"><a href=\"?rub={$rub}\"><img width=\"16\" height=\"16\" src=\"gfx/skin/bwoup/gfx/tabs/p_clientinterface.gif\" align=\"absmiddle\" border=\"0\"> " . _("Renewal report") . "</a></li>";
    } else {
        $out .= "<li class=\"box_wnb_content_nb_item\"><a href=\"?rub={$rub}\"><img width=\"16\" height=\"16\" src=\"gfx/skin/bwoup/gfx/tabs/p_clientinterface.gif\" align=\"absmiddle\" border=\"0\"> " . _("Renewal repport") . "</a></li>";
    }
    $out .= '<li class="box_wnb_content_nb_item_vsep"></li>';
    if ($sousrub == "spent") {
        $out .= "<li class=\"box_wnb_content_nb_item_select\"><a href=\"?rub={$rub}&sousrub=spent\"><img width=\"16\" height=\"16\" src=\"gfx/skin/bwoup/gfx/config-icon/box_wnb_nb_picto-payementgateway.gif\" align=\"absmiddle\" border=\"0\">" . _("Money spent") . "</a></li>";
    } else {
        $out .= "<li class=\"box_wnb_content_nb_item\"><a href=\"?rub={$rub}&sousrub=spent\"><img width=\"16\" height=\"16\" src=\"gfx/skin/bwoup/gfx/config-icon/box_wnb_nb_picto-payementgateway.gif\" align=\"absmiddle\" border=\"0\">" . _("Money spent") . "</a></li>";
    }
    $out .= '<li class="box_wnb_content_nb_item_vsep"></li>';
    if ($sousrub == "bank") {
        $out .= "<li class=\"box_wnb_content_nb_item_select\"><a href=\"?rub={$rub}&sousrub=bank\"><img width=\"16\" height=\"16\" src=\"gfx/skin/bwoup/gfx/config-icon/box_wnb_nb_picto-payementgateway.gif\" align=\"absmiddle\" border=\"0\">" . _("Bank accounts & payments") . "</a></li>";
    } else {
        $out .= "<li class=\"box_wnb_content_nb_item\"><a href=\"?rub={$rub}&sousrub=bank\"><img width=\"16\" height=\"16\" src=\"gfx/skin/bwoup/gfx/config-icon/box_wnb_nb_picto-payementgateway.gif\" align=\"absmiddle\" border=\"0\">" . _("Bank accounts & payments") . "</a></li>";
    }
    $out .= '<li class="box_wnb_content_nb_item_vsep"></li>';
    if ($sousrub == "provideredit") {
        $out .= "<li class=\"box_wnb_content_nb_item_select\"><a href=\"?rub={$rub}&sousrub=provideredit\"><img width=\"16\" height=\"16\" src=\"gfx/skin/bwoup/gfx/tabs/p_admineditor.gif\" align=\"absmiddle\" border=\"0\">" . _("Upstream provider editor") . "</a></li>";
    } else {
        $out .= "<li class=\"box_wnb_content_nb_item\"><a href=\"?rub={$rub}&sousrub=provideredit\"><img width=\"16\" height=\"16\" src=\"gfx/skin/bwoup/gfx/tabs/p_admineditor.gif\" align=\"absmiddle\" border=\"0\">" . _("Upstream provider editor") . "</a></li>";
    }
    $out .= "</ul>";
    switch ($sousrub) {
        case "spent":
            $ret = dateSelector("spent_moneyout", "invoice_date", "date_selector");
            $out .= $ret["text"];
            $where_condition = $ret["where_condition"];
            $q = "SELECT * FROM {$pro_mysql_spent_providers_table} ";
            $r = mysql_query($q) or die("Cannot query {$q} line " . __LINE__ . " file " . __FILE__ . " sql said: " . mysql_error());
            $n = mysql_num_rows($r);
            $prov_popup_id = array();
            $prov_popup_names = array();
            for ($i = 0; $i < $n; $i++) {
                $a = mysql_fetch_array($r);
                $prov_popup_id[] = $a["id"];
                $prov_popup_names[] = $a["quick_name"];
            }
            $q = "SELECT * FROM {$pro_mysql_spent_type_table} ";
            $r = mysql_query($q) or die("Cannot query {$q} line " . __LINE__ . " file " . __FILE__ . " sql said: " . mysql_error());
            $n = mysql_num_rows($r);
            $spent_type_popup_id = array();
            $spent_type_names = array();
            for ($i = 0; $i < $n; $i++) {
                $a = mysql_fetch_array($r);
                $spent_type_popup_id[] = $a["id"];
                $spent_type_names[] = $a["label"];
            }
            $q = "SELECT * FROM {$pro_mysql_companies_table} ";
            $r = mysql_query($q) or die("Cannot query {$q} line " . __LINE__ . " file " . __FILE__ . " sql said: " . mysql_error());
            $n = mysql_num_rows($r);
            $company_paying_popup_id = array();
            $company_paying_names = array();
            for ($i = 0; $i < $n; $i++) {
                $a = mysql_fetch_array($r);
                $company_paying_popup_id[] = $a["id"];
                $company_paying_names[] = $a["name"];
            }
            $q = "SELECT * FROM {$pro_mysql_spent_bank_table} ";
            $r = mysql_query($q) or die("Cannot query {$q} line " . __LINE__ . " file " . __FILE__ . " sql said: " . mysql_error());
            $n = mysql_num_rows($r);
            $bank_popup_id = array();
            $bank_names = array();
            for ($i = 0; $i < $n; $i++) {
                $a = mysql_fetch_array($r);
                $bank_popup_id[] = $a["id"];
                $bank_names[] = $a["acct_name"];
            }
            $dsc = array("title" => _("List of payments done by your hosting company"), "table_name" => $pro_mysql_spent_moneyout_table, "action" => "money_out_editor", "forward" => array("rub", "sousrub"), "print_where_condition" => $where_condition, "order_by" => "invoice_date", "cols" => array("id" => array("type" => "id", "display" => "no", "legend" => "id"), "label" => array("type" => "text", "size" => "10", "legend" => _("Label")), "id_company_spending" => array("legend" => _("Company paying"), "type" => "popup", "values" => $company_paying_popup_id, "display_replace" => $company_paying_names), "id_provider" => array("legend" => _("Company paid"), "type" => "popup", "values" => $prov_popup_id, "display_replace" => $prov_popup_names), "expenditure_type" => array("legend" => _("Expenditure type"), "type" => "popup", "values" => $spent_type_popup_id, "display_replace" => $spent_type_names), "payment_type" => array("legend" => _("Means of payment"), "type" => "popup", "values" => array("none", "credit_card", "wire_transfer", "paypal", "check", "cash"), "display_replace" => array(_("Unknown"), _("Credit card"), _("Wire transfer"), _("Paypal"), _("Check"), _("Cash"))), "payment_total" => array("type" => "text", "size" => 6, "legend" => _("Total cost")), "vat_rate" => array("type" => "text", "size" => 4, "legend" => _("Tax rate")), "vat_total" => array("type" => "text", "size" => 4, "legend" => _("Total tax")), "currency_type" => array("type" => "text", "size" => 4, "legend" => _("Currency")), "bank_acct_id" => array("type" => "popup", "values" => $bank_popup_id, "display_replace" => $bank_names, "legend" => _("Bank account")), "amount" => array("type" => "text", "size" => 6, "legend" => _("Bank amount")), "invoice_date" => array("type" => "text", "size" => 10, "legend" => _("Invoice date")), "paid_date" => array("type" => "text", "size" => 10, "legend" => _("Payment date"))));
            if (isset($_REQUEST["date_selector"])) {
                $dsc["forward"][] = "date_selector";
            }
            $out .= dtcDatagrid($dsc);
            break;
        case "bank":
            $q = "SELECT * FROM {$pro_mysql_companies_table} ";
            $r = mysql_query($q) or die("Cannot query {$q} line " . __LINE__ . " file " . __FILE__ . " sql said: " . mysql_error());
            $n = mysql_num_rows($r);
            $company_paying_popup_id = array();
            $company_paying_names = array();
            for ($i = 0; $i < $n; $i++) {
                $a = mysql_fetch_array($r);
                $company_paying_popup_id[] = $a["id"];
                $company_paying_names[] = $a["name"];
            }
            $dsc = array("title" => _("Bank accounts edition"), "table_name" => $pro_mysql_spent_bank_table, "action" => "bank_account_editor", "forward" => array("rub", "sousrub"), "cols" => array("id" => array("type" => "id", "display" => "no", "legend" => "id"), "acct_name" => array("type" => "text", "legend" => _("Account name")), "id_company" => array("legend" => _("Company"), "type" => "popup", "values" => $company_paying_popup_id, "display_replace" => $company_paying_names), "sort_code" => array("legend" => _("Sort code"), "type" => "text", "size" => "8"), "acct_number" => array("legend" => _("Account number"), "type" => "text"), "swift" => array("legend" => _("SWIFT"), "type" => "text", "size" => "8"), "bank_addr" => array("legend" => _("Bank address"), "type" => "text"), "currency_type" => array("legend" => _("Currency"), "type" => "text", "size" => "4")));
            $out .= dtcDatagrid($dsc);
            // Payment type
            $dsc = array("title" => _("Payment type edition"), "table_name" => $pro_mysql_spent_type_table, "action" => "payment_type_editor", "forward" => array("rub", "sousrub"), "cols" => array("id" => array("type" => "id", "display" => "no", "legend" => "id"), "label" => array("legend" => _("Type of payment"), "type" => "text", "size" => "32")));
            $out .= dtcDatagrid($dsc);
            break;
        case "provideredit":
            $dsc = array("title" => _("Upstream provider list edition"), "table_name" => $pro_mysql_spent_providers_table, "action" => "provider_list_editor", "forward" => array("rub", "sousrub"), "id_fld" => "id", "list_fld_show" => "quick_name", "new_item_title" => _("New upstream provider") . ":", "new_item_link" => _("New upsream provider"), "edit_item_title" => _("Edit upstream provider") . ":", "check_unique" => array("quick_name"), "where_list" => array("always_yes" => "yes"), "cols" => array("id" => array("type" => "id", "display" => "no", "legend" => "id"), "quick_name" => array("type" => "text", "disable_edit" => "yes", "check" => "dtc_login_or_email", "legend" => _("Short name:")), "company_name" => array("legend" => _("Company name:"), "type" => "text"), "is_company" => array("type" => "checkbox", "values" => array("yes", "no"), "default" => "yes", "legend" => _("Is it a company:")), "familyname" => array("legend" => _("First name:"), "type" => "text"), "christname" => array("legend" => _("Familly name:"), "type" => "text"), "addr1" => array("legend" => _("Address:"), "type" => "text"), "addr2" => array("legend" => _("Address (line2):"), "type" => "text"), "addr3" => array("legend" => _("Address (line3):"), "type" => "text"), "city" => array("legend" => _("City:"), "type" => "text"), "zipcode" => array("legend" => _("Zipcode:"), "type" => "text"), "state" => array("legend" => _("State:"), "type" => "text"), "country" => array("legend" => _("Country:"), "type" => "text"), "phone" => array("legend" => _("Phone:"), "type" => "text"), "fax" => array("legend" => _("Fax:"), "type" => "text"), "email" => array("legend" => _("Email:"), "type" => "text"), "special_note" => array("legend" => _("Note:"), "type" => "textarea")));
            $out .= dtcListItemsEdit($dsc);
            break;
        default:
        case "renewalreport":
            // Allow shutdown of expired VPS
            if (isset($_REQUEST["action"])) {
                switch ($_REQUEST["action"]) {
                    case "shutdown_expired_vps":
                        // Perform a clean shutdown
                        remoteVPSAction($_REQUEST["server_hostname"], $_REQUEST["vps_name"], "shutdown_vps");
                        break;
                    case "kill_vps_and_owner":
                        // Do a brutal kill of the running instance
                        deleteVPS($_REQUEST["vps_id"]);
                        remoteVPSAction($_REQUEST["server_hostname"], $_REQUEST["vps_name"], "destroy_vps");
                        remoteVPSAction($_REQUEST["server_hostname"], $_REQUEST["vps_name"], "kill_vps_disk");
                        // Delete the admin
                        $q = "DELETE FROM {$pro_mysql_admin_table} WHERE adm_login='******';";
                        $r = mysql_query($q) or die("Cannot querry {$q} line " . __LINE__ . " file " . __FILE__ . " sql said: " . mysql_error());
                        // And the client
                        $q = "DELETE FROM {$pro_mysql_client_table} WHERE id='" . $_REQUEST["client_id"] . "';";
                        $r = mysql_query($q) or die("Cannot querry {$q} line " . __LINE__ . " file " . __FILE__ . " sql said: " . mysql_error());
                        break;
                    default:
                        break;
                }
            }
            // Display of each month payment list
            if (isset($_REQUEST["date"])) {
                $ret = dateSelector($pro_mysql_pay_table, "date", "date");
                $out .= $ret["text"];
                $where_condition = $ret["where_condition"];
                $q = "SELECT id,name FROM {$pro_mysql_product_table} ";
                $r = mysql_query($q) or die("Cannot querry {$q} line " . __LINE__ . " file " . __FILE__ . " sql said: " . mysql_error());
                $n = mysql_num_rows($r);
                $prod_ids = array();
                $prod_names = array();
                for ($i = 0; $i < $n; $i++) {
                    $a = mysql_fetch_array($r);
                    $prod_ids[] = $a["id"];
                    $prod_names[] = $a["name"];
                }
                $out .= "<h3>" . _("Payements for the period: ") . $_REQUEST["date"] . "</h3>";
                $dsc = array("title" => _("Payment history"), "table_name" => $pro_mysql_pay_table, "action" => "payment_history_list_editor", "forward" => array("rub", "sousrub", "date"), "order_by" => "date", "skip_deletion" => "yes", "skip_creation" => "yes", "print_where_condition" => $where_condition, "cols" => array("id" => array("type" => "id", "display" => "no", "legend" => "id"), "date" => array("type" => "text", "size" => "8", "legend" => _("Date")), "id_client" => array("type" => "forkey", "forkey_type" => "info", "table" => $pro_mysql_client_table, "other_table_fld" => "CONCAT(company_name,': ',familyname,', ',christname)", "other_table_key" => "id", "this_table_field" => "id_client", "link" => "?rub=crm&id=", "bk_table" => $pro_mysql_new_admin_table, "bk_other_table_fld" => "CONCAT(comp_name,': ',family_name,', ',first_name)", "bk_other_table_key" => "id", "bk_this_table_field" => "id_client", "legend" => _("Customer name")), "product_id" => array("type" => "popup", "values" => $prod_ids, "display_replace" => $prod_names, "legend" => _("Product")), "refund_amount" => array("type" => "text", "size" => "8", "legend" => _("Refund amount")), "paiement_cost" => array("type" => "text", "size" => "4", "legend" => _("Gate cost")), "vat_rate" => array("type" => "text", "size" => "4", "legend" => _("VAT rate")), "vat_total" => array("type" => "text", "size" => "4", "legend" => _("VAT total")), "paiement_total" => array("type" => "text", "size" => "6", "legend" => _("Grand total")), "paiement_type" => array("type" => "text", "size" => "6", "legend" => _("Type")), "secpay_site" => array("type" => "text", "size" => "4", "legend" => _("Gate type")), "new_account" => array("type" => "popup", "values" => array("no", "yes"), "display_replace" => array(_("New account"), _("Renewal")), "legend" => _("Is renewal")), "valid" => array("type" => "popup", "values" => array("no", "pending", "yes"), "display_replace" => array(_("No"), _("Pending"), _("Yes")), "legend" => _("Validated")), "pending_reason" => array("type" => "text", "size" => "6", "legend" => _("Pending reason"))));
                $out .= dtcDatagrid($dsc);
                return $out;
                $ret = dateSelector($pro_mysql_completedorders_table, "date", "date");
                // Allow nuke of bad payment (hackers?) to have accounting done correctly
                if (isset($_REQUEST["action"]) && $_REQUEST["action"] == "nuke_payment") {
                    $q = "DELETE FROM {$pro_mysql_completedorders_table} WHERE id='" . $_REQUEST["completedorders_id"] . "';";
                    $r = mysql_query($q) or die("Cannot querry {$q} line " . __LINE__ . " file " . __FILE__ . " sql said: " . mysql_error());
                }
                $r = mysql_query($q) or die("Cannot querry {$q} line " . __LINE__ . " file " . __FILE__ . " sql said: " . mysql_error());
                $n = mysql_num_rows($r);
                if ($n < 1) {
                    $out .= _("No past payments for this period") . "<br>";
                } else {
                    $out .= "<table cellspacing=\"0\" cellpadding=\"2\" border=\"1\">\n\t\t\t\t<tr><td>" . _("Product") . "</td><td>" . _("Client ID") . "</td><td>" . _("Client") . "</td><td>" . _("Service country") . "</td>\n\t\t\t\t<td>" . _("Client country") . "</td>\n\t\t\t\t<td>" . _("VAT collected") . "</td><td>" . _("Period") . "</td><td>" . _("Payment date") . "</td><td>" . _("Total") . "</td><td>" . _("Payment method") . "</td>\n\t\t\t\t<td>" . _("Action") . "</td></tr>";
                    for ($i = 0; $i < $n; $i++) {
                        $a = mysql_fetch_array($r);
                        if ($a["id_client"] == 0) {
                            $client_name = _("No client id");
                            $client_id_txt = _("No client id");
                        } else {
                            $q2 = "SELECT * FROM {$pro_mysql_client_table} WHERE id='" . $a["id_client"] . "';";
                            $r2 = mysql_query($q2) or die("Cannot querry {$q2} line " . __LINE__ . " file " . __FILE__ . " sql said: " . mysql_error());
                            $n2 = mysql_num_rows($r2);
                            if ($n2 != 1) {
                                $client_name = _("N/A");
                                $client_id_txt = _("N/A");
                                $client_country = _("N/A");
                            } else {
                                $a2 = mysql_fetch_array($r2);
                                $client_name = $a2["company_name"] . ":" . $a2["christname"] . ", " . $a2["familyname"];
                                $client_id_txt = $a["id_client"];
                                $client_country = $a2["country"];
                            }
                        }
                        $q2 = "SELECT * FROM {$pro_mysql_product_table} WHERE id='" . $a["product_id"] . "';";
                        $r2 = mysql_query($q2) or die("Cannot querry {$q2} line " . __LINE__ . " file " . __FILE__ . " sql said: " . mysql_error());
                        $n2 = mysql_num_rows($r2);
                        if ($n2 != 1) {
                            $product_txt = _("Product not found");
                        } else {
                            $a2 = mysql_fetch_array($r2);
                            $product_txt = $a2["name"];
                            $product_period_size = $a2["period"];
                        }
                        $q2 = "SELECT * FROM {$pro_mysql_pay_table} WHERE id='" . $a["payment_id"] . "';";
                        $r2 = mysql_query($q2) or die("Cannot querry {$q2} line " . __LINE__ . " file " . __FILE__ . " sql said: " . mysql_error());
                        $n2 = mysql_num_rows($r2);
                        if ($n2 != 1) {
                            $payment_txt = _("Payment not found");
                            $payment_type = _("Payment not found");
                            $vat_collected = _("VAT not found");
                        } else {
                            $a2 = mysql_fetch_array($r2);
                            $payment_txt = $a2["paiement_total"] . " " . $a2["currency"];
                            $payment_type = $a2["paiement_type"];
                            if ($payment_type == "online") {
                                $payment_type .= ": " . $a2["secpay_site"];
                            }
                            $vat_collected = $a2["paiement_total"] * $a2["vat_rate"] / 100;
                        }
                        if ($a["last_expiry_date"] == "0000-00-00") {
                            $last_expiry_date = $a["date"];
                        } else {
                            $last_expiry_date = $a["last_expiry_date"];
                        }
                        if ($payment_type == 'wire') {
                            $pay = _("Wire");
                        } else {
                            if ($payment_type == 'cheque') {
                                $pay = _("cheque");
                            } else {
                                if ($payment_type == 'online: none') {
                                    $pay = _("online: none");
                                } else {
                                    $pay = $payment_type;
                                }
                            }
                        }
                        $new_expiry_date = calculateExpirationDate($last_expiry_date, $product_period_size);
                        $out .= "<tr><td>{$product_txt}</td><td>{$client_id_txt}</td><td>{$client_name}</td><td>" . $a["country_code"] . "</td>\n\t\t\t\t\t<td>{$client_country}</td>\n\t\t\t\t\t<td>{$vat_collected}</td><td>{$last_expiry_date} -> {$new_expiry_date}</td><td>" . $a["date"] . "</td><td>{$payment_txt}</td>\n\t\t\t\t\t<td>{$pay}</td>\n\t\t\t\t\t<td><a href=\"" . $_SERVER["PHP_SELF"] . "?rub={$rub}&date=" . $_REQUEST["date"] . "&action=nuke_payment&completedorders_id=" . $a["id"] . "\">" . _("Delete") . "</a></tr>";
                    }
                    $out .= "</table>";
                }
                return $out;
            }
            // Calculation of recuring totals
            $out .= "<h3>" . _("Total recurring incomes per month:") . "</h3>";
            // Monthly recurring for shared hosting:
            $q = "SELECT {$pro_mysql_product_table}.price_dollar,{$pro_mysql_product_table}.period,{$pro_mysql_product_table}.id\n\t\tFROM {$pro_mysql_product_table},{$pro_mysql_admin_table}\n\t\tWHERE {$pro_mysql_product_table}.id = {$pro_mysql_admin_table}.prod_id\n\t\tAND {$pro_mysql_product_table}.heb_type='shared'\n\t\tAND {$pro_mysql_admin_table}.expire != '0000-00-00'";
            $r = mysql_query($q) or die("Cannot querry {$q} line " . __LINE__ . " file " . __FILE__ . " sql said: " . mysql_error());
            $n = mysql_num_rows($r);
            $total_shared = 0;
            for ($i = 0; $i < $n; $i++) {
                $a = mysql_fetch_array($r);
                $period = $a["period"];
                $price = $a["price_dollar"];
                $id = $a["id"];
                if ($period == '0001-00-00') {
                    $total_shared += $price / 12;
                } else {
                    $papoum = explode('-', $period);
                    $months = $papoum[1];
                    if ($months == 0) {
                        echo "Product {$id} has zero month.<br>";
                    } else {
                        $total_shared += $price / $months;
                    }
                }
            }
            // Calculate how much SSL IPs have been taken
            $q = "SELECT count(id) as num_ssl FROM {$pro_mysql_ssl_ips_table} WHERE available='no'";
            $r = mysql_query($q) or die("Cannot querry {$q} line " . __LINE__ . " file " . __FILE__ . " sql said: " . mysql_error());
            $n = mysql_num_rows($r);
            $total_ssl = 0;
            if ($n != 0) {
                $a = mysql_fetch_array($r);
                $q = "SELECT price_dollar FROM {$pro_mysql_product_table} WHERE heb_type='ssl'";
                $r = mysql_query($q) or die("Cannot querry {$q} line " . __LINE__ . " file " . __FILE__ . " sql said: " . mysql_error());
                $n = mysql_num_rows($r);
                if ($n != 0) {
                    $b = mysql_fetch_array($r);
                    $total_ssl = $a["num_ssl"] * $b["price_dollar"] / 12;
                }
            }
            // Monthly recurring for VPS:
            $q = "SELECT {$pro_mysql_product_table}.price_dollar,{$pro_mysql_product_table}.period,{$pro_mysql_product_table}.id\n\t\tFROM {$pro_mysql_product_table},{$pro_mysql_vps_table}\n\t\tWHERE {$pro_mysql_product_table}.id = {$pro_mysql_vps_table}.product_id";
            $r = mysql_query($q) or die("Cannot querry {$q} line " . __LINE__ . " file " . __FILE__ . " sql said: " . mysql_error());
            $n = mysql_num_rows($r);
            $total_vps = 0;
            for ($i = 0; $i < $n; $i++) {
                $a = mysql_fetch_array($r);
                $period = $a["period"];
                $price = $a["price_dollar"];
                $id = $a["id"];
                if ($period == '0001-00-00') {
                    $total_shared += $price / 12;
                } else {
                    $papoum = explode('-', $period);
                    $months = $papoum[1];
                    if ($months != 0) {
                        $total_vps += $price / $months;
                    } else {
                        echo "Product {$id} has zero month.<br>";
                    }
                }
            }
            // Monthly recurring for dedicated servers:
            $q = "SELECT {$pro_mysql_product_table}.price_dollar,{$pro_mysql_product_table}.period,{$pro_mysql_product_table}.id\n\t\tFROM {$pro_mysql_product_table},{$pro_mysql_dedicated_table}\n\t\tWHERE {$pro_mysql_product_table}.id = {$pro_mysql_dedicated_table}.product_id";
            $r = mysql_query($q) or die("Cannot querry {$q} line " . __LINE__ . " file " . __FILE__ . " sql said: " . mysql_error());
            $n = mysql_num_rows($r);
            $total_dedicated = 0;
            for ($i = 0; $i < $n; $i++) {
                $a = mysql_fetch_array($r);
                $period = $a["period"];
                $price = $a["price_dollar"];
                $id = $a["id"];
                if ($period == '0001-00-00') {
                    $total_shared += $price / 12;
                } else {
                    $papoum = explode('-', $period);
                    $months = $papoum[1];
                    if ($months == 0) {
                        echo _("Dedicated server product ID {$id} has zero for the number of month to renew") . "<br>";
                    } else {
                        $total_dedicated += $price / $months;
                    }
                }
            }
            $p_renewal = "";
            $p_renewal .= _("Shared hosting: ") . round($total_shared, 2) . " {$secpayconf_currency_letters}<br>";
            $p_renewal .= _("SSL IPs renewals: ") . round($total_ssl, 2) . " {$secpayconf_currency_letters}<br>";
            $p_renewal .= _("VPS: ") . round($total_vps, 2) . " {$secpayconf_currency_letters}<br>";
            $p_renewal .= _("Dedicated servers: ") . round($total_dedicated, 2) . " {$secpayconf_currency_letters}<br>";
            $big_total = $total_shared + $total_vps + $total_dedicated + $total_ssl;
            $p_renewal .= "<b>" . _("Total: ") . round($big_total, 2) . " {$secpayconf_currency_letters}</b>";
            // Show a quick history of payments
            $year = date("Y");
            $month = date("m");
            $cur_year = $year - 2;
            $cur_month = $month;
            $p_history = "";
            $p_history .= "<table cellspacing=\"1\" cellpadding=\"1\" border=\"1\">\n\t\t<tr><td>" . _("Period") . "</td><td>" . _("Amount") . "</td><td>" . _("VAT collected") . "</td><td>" . _("Payment gateway cost") . "</td><td>" . _("Profit") . "</td></tr>";
            for ($i = 0; $i < 25; $i++) {
                $q2 = "SELECT {$pro_mysql_pay_table}.paiement_total,{$pro_mysql_pay_table}.vat_rate,{$pro_mysql_pay_table}.paiement_cost\n\t\t\tFROM {$pro_mysql_pay_table},{$pro_mysql_completedorders_table}\n\t\t\tWHERE {$pro_mysql_pay_table}.vat_rate!='0.00'\n\t\t\tAND {$pro_mysql_completedorders_table}.payment_id = {$pro_mysql_pay_table}.id\n\t\t\tAND {$pro_mysql_completedorders_table}.date LIKE '" . $cur_year . "-" . $cur_month . "-%';";
                $r2 = mysql_query($q2) or die("Cannot querry {$q2} line " . __LINE__ . " file " . __FILE__ . " sql said: " . mysql_error());
                $n2 = mysql_num_rows($r2);
                $vat_collected = 0;
                $month_total = 0;
                $cost_total = 0;
                for ($j = 0; $j < $n2; $j++) {
                    $a2 = mysql_fetch_array($r2);
                    $tt = $a2["paiement_total"];
                    $vat = $a2["vat_rate"];
                    $vat_collected += $tt * $vat / 100;
                    $month_total += $tt;
                    $cost_total += $a2["paiement_cost"];
                }
                $q2 = "SELECT sum(paiement_total) as paiement_total, sum(paiement_cost) as paiement_cost FROM {$pro_mysql_completedorders_table},{$pro_mysql_pay_table}\n\t\t\tWHERE {$pro_mysql_completedorders_table}.date LIKE '" . $cur_year . "-" . $cur_month . "%'\n\t\t\tAND {$pro_mysql_completedorders_table}.payment_id = {$pro_mysql_pay_table}.id\n\t\t\tAND {$pro_mysql_pay_table}.vat_rate = '0.00';";
                $r2 = mysql_query($q2) or die("Cannot querry {$q2} line " . __LINE__ . " file " . __FILE__ . " sql said: " . mysql_error());
                $n2 = mysql_num_rows($r2);
                if ($n2 > 0) {
                    $a2 = mysql_fetch_array($r2);
                    $cost_total += $a2["paiement_cost"];
                    $month_total += $a2["paiement_total"];
                    $profit = $month_total - $cost_total - $vat_collected;
                    $p_history .= "<tr><td style=\"text-align:right;\"><a href=\"" . $_SERVER["PHP_SELF"] . "?rub={$rub}&date=" . $cur_year . "-" . $cur_month . "\">" . $cur_year . "-" . $cur_month . "</a></td>\n\t\t\t\t<td style=\"text-align:right;\">" . $month_total . " {$secpayconf_currency_letters}</td>\n\t\t\t\t<td style=\"text-align:right;\">" . round($vat_collected, 2) . " {$secpayconf_currency_letters}</td>\n\t\t\t\t<td style=\"text-align:right;\">" . round($cost_total, 2) . " {$secpayconf_currency_letters}</td>\n\t\t\t\t<td style=\"text-align:right;\">" . round($profit, 2) . " {$secpayconf_currency_letters}</td></tr>";
                }
                $cur_month++;
                if ($cur_month > 12) {
                    $cur_month = 1;
                    $cur_year++;
                }
                if ($cur_month < 10) {
                    $cur_month = "0" . $cur_month;
                }
            }
            $p_history .= "</table>";
            $p_active_prods = "<img src=\"active_prods_graph.php?graph=year\"><br>\n<img src=\"active_prods_graph.php?graph=month\">";
            // Layout the recuring stat and the effective payment statistics
            $out .= "<table cellspacing=\"1\" cellpadding=\"4\" border=\"0\" width=\"100%\">\n\t\t<tr valign=\"top\"><td valign=\"top\" width=\"50%\">{$p_history}</td>\n\t\t<td valign=\"top\">{$p_renewal}</td>\n\t\t<td valign=\"top\">{$p_active_prods}</td></tr></table>";
            $out .= "<h3>" . _("Shared hosting renewals:") . "</h3>";
            $q = "SELECT * FROM {$pro_mysql_admin_table} WHERE expire < '" . date("Y-m-d") . "' AND id_client!='0' AND expire !='0000-00-00' ORDER BY expire;";
            $r = mysql_query($q) or die("Cannot querry {$q} line " . __LINE__ . " file " . __FILE__);
            $n = mysql_num_rows($r);
            if ($n < 1) {
                $out .= _("No shared account expired.") . "<br>";
            } else {
                $out .= "<table cellspacing=\"0\" cellpadding=\"2\" border=\"1\">\n\t\t\t<tr><td>" . _("Login") . "</td><td>" . _("Client") . "</td><td>" . _("Email") . "</td><td>" . _("Expiration date") . "</td></tr>";
                for ($i = 0; $i < $n; $i++) {
                    $a = mysql_fetch_array($r);
                    $q2 = "SELECT * FROM {$pro_mysql_client_table} WHERE id='" . $a["id_client"] . "';";
                    $r2 = mysql_query($q2) or die("Cannot querry {$q2} line " . __LINE__ . " file " . __FILE__ . " sql said: " . mysql_error());
                    $n2 = mysql_num_rows($r2);
                    if ($n2 != 1) {
                        $client_name = _("Client name not found!");
                    } else {
                        $a2 = mysql_fetch_array($r2);
                        $client_name = $a2["company_name"] . ":" . $a2["christname"] . ", " . $a2["familyname"];
                    }
                    $q2 = "SELECT * FROM {$pro_mysql_domain_table} WHERE owner='" . $a["adm_login"] . "';";
                    $r2 = mysql_query($q2) or die("Cannot querry {$q2} line " . __LINE__ . " file " . __FILE__);
                    $n2 = mysql_num_rows($r2);
                    if ($n2 > 0) {
                        $out .= "<tr><td>" . $a["adm_login"] . "</td><td>{$client_name}</td><td>" . $a2["email"] . "</td><td>" . $a["expire"] . "</td></tr>";
                    }
                }
                $out .= "</table>";
            }
            // List of expired expired SSL IPs
            $out .= "<h3>" . _("SSL IPs renewals") . "</h3>";
            $q = "SELECT * FROM {$pro_mysql_ssl_ips_table} WHERE expire < '" . date("Y-m-d") . "' AND available='no' ORDER BY expire";
            $r = mysql_query($q) or die("Cannot querry {$q} line " . __LINE__ . " file " . __FILE__ . " sql said: " . mysql_error());
            $n = mysql_num_rows($r);
            if ($n < 1) {
                $out .= _("No SSL IP expired") . "<br>";
            } else {
                $out .= "<table cellspacing=\"0\" cellpadding=\"2\" border=\"1\">\n\t\t\t<tr><td>" . _("Login") . "</td><td>" . _("Client") . "</td><td>" . _("Email") . "</td><td>" . _("Expiration date") . "</td></tr>";
                for ($i = 0; $i < $n; $i++) {
                    $a = mysql_fetch_array($r);
                    $q2 = "SELECT * FROM {$pro_mysql_admin_table} WHERE adm_login='******';";
                    $r2 = mysql_query($q2) or die("Cannot querry {$q2} line " . __LINE__ . " file " . __FILE__ . " sql said: " . mysql_error());
                    $n2 = mysql_num_rows($r2);
                    if ($n2 != 1) {
                        die("Cannot find admin name " . $a["adm_login"] . " line " . __LINE__ . " file " . __FILE__);
                    } else {
                        $admin = mysql_fetch_array($r2);
                    }
                    $q2 = "SELECT * FROM {$pro_mysql_client_table} WHERE id='" . $admin["id_client"] . "';";
                    $r2 = mysql_query($q2) or die("Cannot querry {$q2} line " . __LINE__ . " file " . __FILE__ . " sql said: " . mysql_error());
                    $n2 = mysql_num_rows($r2);
                    if ($n2 != 1) {
                        $client_name = _("Client name not found!");
                    } else {
                        $a2 = mysql_fetch_array($r2);
                        $client_name = $a2["company_name"] . ":" . $a2["christname"] . ", " . $a2["familyname"];
                    }
                    $out .= "<tr><td>" . $a["adm_login"] . "</td><td>{$client_name}</td><td>" . $a2["email"] . "</td><td>" . $a["expire"] . "</td></tr>";
                }
                $out .= "</table>";
            }
            // List if expired VPS
            $out .= "<h3>" . _("VPS renewals:") . "</h3>";
            $q = "SELECT * FROM {$pro_mysql_vps_table} WHERE expire_date < '" . date("Y-m-d") . "' ORDER BY expire_date";
            $r = mysql_query($q) or die("Cannot querry {$q} line " . __LINE__ . " file " . __FILE__ . " sql said: " . mysql_error());
            $n = mysql_num_rows($r);
            if ($n < 1) {
                $out .= _("No VPS expired") . "<br>";
            } else {
                $out .= "<table cellspacing=\"0\" cellpadding=\"2\" border=\"1\">\n\t\t\t<tr><td>" . _("Login") . "</td><td>" . _("VPS") . "</td>\n\t\t\t<td>" . _("Client") . "</td>\n\t\t\t<td>" . _("Email") . "</td>\n\t\t\t<td>" . _("Expiration date") . "</td>\n\t\t\t<td>" . _("Days of expiration") . "</td>\n\t\t\t<td>" . _("Action") . "</td>\n\t\t\t</tr>";
                for ($i = 0; $i < $n; $i++) {
                    $a = mysql_fetch_array($r);
                    $q2 = "SELECT * FROM {$pro_mysql_admin_table} WHERE adm_login='******';";
                    $r2 = mysql_query($q2) or die("Cannot querry {$q2} line " . __LINE__ . " file " . __FILE__ . " sql said: " . mysql_error());
                    $n2 = mysql_num_rows($r2);
                    if ($n2 != 1) {
                        die("Cannot find admin name " . $a["owner"] . " line " . __LINE__ . " file " . __FILE__);
                    } else {
                        $admin = mysql_fetch_array($r2);
                    }
                    $q2 = "SELECT * FROM {$pro_mysql_client_table} WHERE id='" . $admin["id_client"] . "';";
                    $r2 = mysql_query($q2) or die("Cannot querry {$q2} line " . __LINE__ . " file " . __FILE__ . " sql said: " . mysql_error());
                    $n2 = mysql_num_rows($r2);
                    if ($n2 != 1) {
                        $client_name = _("Client name not found!");
                    } else {
                        $a2 = mysql_fetch_array($r2);
                        $client_name = $a2["company_name"] . ":" . $a2["christname"] . ", " . $a2["familyname"];
                    }
                    $q2 = "SELECT adm_login FROM {$pro_mysql_admin_table} WHERE id_client='" . $admin["id_client"] . "'";
                    $r2 = mysql_query($q2) or die("Cannot querry {$q2} line " . __LINE__ . " file " . __FILE__ . " sql said: " . mysql_error());
                    $n2 = mysql_num_rows($r2);
                    if ($n2 == 1) {
                        $q2 = "SELECT * FROM {$pro_mysql_vps_table} WHERE owner='" . $admin["adm_login"] . "'";
                        $r2 = mysql_query($q2) or die("Cannot querry " . $q2 . " line " . __LINE__ . " file " . __FILE__ . " sql said: " . mysql_error());
                        $n2 = mysql_num_rows($r2);
                        if ($n2 == 1) {
                            $q2 = "SELECT * FROM {$pro_mysql_dedicated_table} WHERE owner='" . $admin["adm_login"] . "'";
                            $r2 = mysql_query($q2) or die("Cannot querry " . $q2 . " line " . __LINE__ . " file " . __FILE__ . " sql said: " . mysql_error());
                            $n2 = mysql_num_rows($r2);
                            if ($n2 == 0) {
                                $q2 = "SELECT * FROM {$pro_mysql_domain_table} WHERE owner='" . $admin["adm_login"] . "'";
                                $r2 = mysql_query($q2) or die("Cannot querry " . $q2 . " line " . __LINE__ . " file " . __FILE__ . " sql said: " . mysql_error());
                                $n2 = mysql_num_rows($r2);
                                if ($n2 == 0) {
                                    $kill_owner_txt = "<a href=\"" . $_SERVER["PHP_SELF"] . "?action=kill_vps_and_owner&adm_login="******"adm_login"] . "&client_id=" . $admin["id_client"] . "&vps_name=" . $a["vps_xen_name"] . "&server_hostname=" . $a["vps_server_hostname"] . "&vps_id=" . $a["id"] . "\">" . _("Kill VPS and owner") . "</a>";
                                } else {
                                    $kill_owner_txt = _("Has some domains");
                                }
                            } else {
                                $kill_owner_txt = _("Has a dedicated");
                            }
                        } else {
                            $kill_owner_txt = _("More than one VPS");
                        }
                    } else {
                        $kill_owner_txt = _("More than one login");
                    }
                    if (numOfDays($a["expire_date"]) >= $conf_vps_renewal_shutdown) {
                        $bgcolor = " bgcolor=\"#FF8888\" ";
                    } else {
                        $bgcolor = " ";
                    }
                    $out .= "<tr><td>" . $a["owner"] . "</td>\n\t\t\t\t<td>" . $a["vps_xen_name"] . ":" . $a["vps_server_hostname"] . "</td>\n\t\t\t\t<td>{$client_name}</td>\n\t\t\t\t<td>" . $a2["email"] . "</td>\n\t\t\t\t<td {$bgcolor}>" . $a["expire_date"] . "</td>\n\t\t\t\t<td {$bgcolor}>" . calculateAge($a["expire_date"], "00:00:00") . "</td>\n\t\t\t\t<td><a href=\"" . $_SERVER["PHP_SELF"] . "?rub={$rub}&action=shutdown_expired_vps&server_hostname=" . $a["vps_server_hostname"] . "&vps_name=" . $a["vps_xen_name"] . "\">" . _("Shutdown") . "</a> - {$kill_owner_txt}</td></tr>";
                }
                $out .= "</table>";
            }
            // List expired dedicated servers
            $out .= "<h3>" . _("Dedicated servers renewals") . "</h3>";
            $q = "SELECT * FROM {$pro_mysql_dedicated_table} WHERE expire_date < '" . date("Y-m-d") . "' ORDER BY expire_date";
            $r = mysql_query($q) or die("Cannot querry {$q} line " . __LINE__ . " file " . __FILE__ . " sql said: " . mysql_error());
            $n = mysql_num_rows($r);
            if ($n < 1) {
                $out .= _("No dedicated server expired") . "<br>";
            } else {
                $out .= "<table cellspacing=\"0\" cellpadding=\"2\" border=\"1\">\n\t\t\t<tr><td>" . _("Login") . "</td><td>" . _("Server") . "</td><td>" . _("Client") . "</td><td>" . _("Email") . "</td><td>" . _("Expiration date") . "</td></tr>";
                for ($i = 0; $i < $n; $i++) {
                    $a = mysql_fetch_array($r);
                    $q2 = "SELECT * FROM {$pro_mysql_admin_table} WHERE adm_login='******';";
                    $r2 = mysql_query($q2) or die("Cannot querry {$q2} line " . __LINE__ . " file " . __FILE__ . " sql said: " . mysql_error());
                    $n2 = mysql_num_rows($r2);
                    if ($n2 != 1) {
                        die("Cannot find admin name " . $a["owner"] . " line " . __LINE__ . " file " . __FILE__);
                    } else {
                        $admin = mysql_fetch_array($r2);
                    }
                    $q2 = "SELECT * FROM {$pro_mysql_client_table} WHERE id='" . $admin["id_client"] . "';";
                    $r2 = mysql_query($q2) or die("Cannot querry {$q2} line " . __LINE__ . " file " . __FILE__ . " sql said: " . mysql_error());
                    $n2 = mysql_num_rows($r2);
                    if ($n2 != 1) {
                        $client_name = _("Client name not found!");
                    } else {
                        $a2 = mysql_fetch_array($r2);
                        $client_name = $a2["company_name"] . ":" . $a2["christname"] . ", " . $a2["familyname"];
                    }
                    $out .= "<tr><td>" . $a["owner"] . "</td><td>" . $a["server_hostname"] . "</td><td>{$client_name}</td><td>" . $a2["email"] . "</td><td>" . $a["expire_date"] . "</td></tr>";
                }
                $out .= "</table>";
            }
            break;
    }
    return $out;
}
Ejemplo n.º 3
0
function drawInvoicingConfig()
{
    global $pro_mysql_companies_table;
    global $pro_mysql_invoicing_table;
    global $cc_code_array;
    $out = "";
    $q = "SELECT * FROM {$pro_mysql_companies_table} WHERE 1;";
    $r = mysql_query($q) or die("Cannot query {$q} line " . __LINE__ . " file " . __FILE__ . " sql said: " . mysql_error());
    $n = mysql_num_rows($r);
    $comp_names = array(_("Please select"));
    $comp_ids = array(0);
    for ($i = 0; $i < $n; $i++) {
        $a = mysql_fetch_array($r);
        $comp_names[] = $a["name"];
        $comp_ids[] = $a["id"];
    }
    $dsc = array("title" => _("Default company invoicing:"), "action" => "default_company_invoicing_editor", "forward" => array("rub", "sousrub"), "cols" => array("default_company_invoicing" => array("legend" => _("Default company invoicing:"), "type" => "popup", "values" => $comp_ids, "display_replace" => $comp_names)));
    $out .= configEditorTemplate($dsc);
    $country_codes = array_keys($cc_code_array);
    $country_fullnames = array_values($cc_code_array);
    $country_codes = array_reverse($country_codes);
    $country_fullnames = array_reverse($country_fullnames);
    $country_codes[] = "00";
    $country_fullnames[] = _("none");
    $country_codes = array_reverse($country_codes);
    $country_fullnames = array_reverse($country_fullnames);
    $dsc = array("table_name" => $pro_mysql_invoicing_table, "title" => _("Customer and service country vs company:"), "action" => "cust_and_serv_country_vs_comp", "forward" => array("rub", "sousrub"), "cols" => array("id" => array("type" => "id", "display" => "no", "legend" => "id"), "service_country_code" => array("type" => "popup", "legend" => _("Service country"), "values" => $country_codes, "display_replace" => $country_fullnames), "customer_country_code" => array("type" => "popup", "legend" => _("Customer country"), "values" => $country_codes, "display_replace" => $country_fullnames), "company_id" => array("type" => "popup", "legend" => _("Company name"), "values" => $comp_ids, "display_replace" => $comp_names)));
    $out .= dtcDatagrid($dsc);
    return $out;
}
Ejemplo n.º 4
0
function drawDomainConfig($admin)
{
    global $rub;
    global $cc_code_array;
    global $pro_mysql_product_table;
    global $pro_mysql_domain_table;
    global $pro_mysql_product_table;
    global $pro_mysql_vps_table;
    global $pro_mysql_dedicated_table;
    global $pro_mysql_subdomain_table;
    global $conf_site_addrs;
    global $conf_use_shared_ssl;
    $site_addrs = explode("|", $conf_site_addrs);
    global $adm_login;
    global $adm_pass;
    $ret = "";
    if (isset($admin["data"])) {
        $domains = $admin["data"];
        $nbr_domain = sizeof($domains);
    } else {
        $nbr_domain = 0;
    }
    // Shared hosting domain configuration
    if ($nbr_domain > 0) {
        if (isset($_REQUEST["action"]) && $_REQUEST["action"] == "change_domain_config_edit") {
            $q = "UPDATE {$pro_mysql_domain_table} SET generate_flag='yes' WHERE name='" . $_REQUEST["name"] . "';";
            $r = mysql_query($q) or die("Cannot query {$q} line " . __LINE__ . " file " . __FILE__ . " sql said: " . mysql_error());
            updateUsingCron("gen_vhosts='yes',restart_apache='yes',gen_named='yes',reload_named ='yes'");
        }
        $dsc = array("table_name" => $pro_mysql_domain_table, "title" => _("Configuration of the domains"), "action" => "change_domain_config", "forward" => array("rub", "adm_login", "adm_pass"), "skip_deletion" => "yes", "skip_creation" => "yes", "where_condition" => "owner='{$adm_login}'", "cols" => array("name" => array("type" => "id", "display" => "yes", "legend" => _("Domain name")), "edithost" => array("type" => "hyperlink", "legend" => _("Vhost"), "text" => _("Customize")), "safe_mode" => array("type" => "checkbox", "help" => _("This will add a new subdomain switch yes/no in the client interface of this domain. Unticking this checkbox is NOT ENOUGH to disable the safe mode. Please go in the subdomains section of this domain name to finish the setup."), "legend" => _("PHP safe_mode"), "values" => array("yes", "no"), "display_replace" => array(_("No"), _("Yes"))), "sbox_protect" => array("type" => "checkbox", "help" => _("This will add a new subdomain switch yes/no in the client interface of this domain. Unticking this checkbox is NOT ENOUGH to disable the sbox CGI-BIN protection. Please go in the subdomains section of this domain name to finish the setup."), "legend" => _("CGI-BIN protection"), "values" => array("yes", "no"), "display_replace" => array(_("No"), _("Yes"))), "quota" => array("type" => "text", "help" => _("Quota disk in MBytes"), "legend" => _("Disk quota"), "size" => "6"), "max_email" => array("type" => "text", "legend" => _("Email max"), "size" => "3"), "max_lists" => array("type" => "text", "legend" => _("Lists max"), "size" => "3"), "max_ftp" => array("type" => "text", "legend" => _("Max FTP"), "size" => "3"), "max_subdomain" => array("type" => "text", "legend" => _("Subdomain max"), "size" => "3"), "max_ssh" => array("type" => "text", "legend" => _("Max SSH"), "size" => "3"), "ip_addr" => array("type" => "popup", "legend" => _("IP address"), "values" => $site_addrs), "backup_ip_addr" => array("type" => "text", "legend" => _("Backup Vhost IP address"), "size" => "14")));
        $ret .= dtcDatagrid($dsc);
        if (isset($_REQUEST["edithost"]) && isHostname($_REQUEST["edithost"])) {
            $ret .= "<h3>" . _("Custom Apache directives for") . " " . $_REQUEST["edithost"] . "</h3>";
            $q = "SELECT subdomain_name FROM {$pro_mysql_subdomain_table} WHERE domain_name='" . $_REQUEST["edithost"] . "';";
            $r = mysql_query($q) or die("Cannot execute query \"{$q}\" ! line: " . __LINE__ . " file: " . __FILE__ . " sql said: " . mysql_error());
            $n = mysql_num_rows($r);
            for ($j = 0; $j < $n; $j++) {
                $a = mysql_fetch_array($r);
                if ($j != 0) {
                    $ret .= " - ";
                }
                $subname = $a["subdomain_name"];
                $ret .= "<a href=\"" . $_SERVER["PHP_SELF"] . "?adm_login={$adm_login}&adm_pass={$adm_pass}&rub={$rub}&edithost=" . $_REQUEST["edithost"] . "&subdomain={$subname}\">{$subname}</a>";
            }
            $ret .= "<br><br>";
            if (isset($_REQUEST["subdomain"]) && isHostname($_REQUEST["subdomain"])) {
                $ret .= "<u>" . _("Subdomain") . ": " . $_REQUEST["subdomain"] . ":</u><br>";
                $ret .= _("Take care: no syntax checkings are done on your custom directives, doing a mistake here could lead to your web server not being able to restart!") . "<br>";
                $q = "SELECT customize_vhost FROM {$pro_mysql_subdomain_table} WHERE subdomain_name='" . $_REQUEST["subdomain"] . "' AND domain_name='" . $_REQUEST["edithost"] . "';";
                $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("Domain name not found line " . __LINE__ . " file " . __FILE__);
                }
                $ze_dom = mysql_fetch_array($r);
                $customization = $ze_dom["customize_vhost"];
                /*$ret .= "<form action=\"".$_SERVER["PHP_SELF"]."\">
                				<input type=\"hidden\" name=\"rub\" value=\"$rub\">
                				<input type=\"hidden\" name=\"adm_login\" value=\"$adm_login\">
                				<input type=\"hidden\" name=\"adm_pass\" value=\"$adm_pass\">
                				<input type=\"hidden\" name=\"edithost\" value=\"".$_REQUEST["edithost"]."\">
                				<input type=\"hidden\" name=\"subdomain\" value=\"".$_REQUEST["subdomain"]."\">
                				<input type=\"hidden\" name=\"action\" value=\"set_vhost_custom_directives\">
                				<textarea cols=\"120\" rows=\"10\" name=\"custom_directives\">$customization</textarea><br>
                <div class=\"input_btn_container\" onMouseOver=\"this.className='input_btn_container-hover';\" onMouseOut=\"this.className='input_btn_container';\">
                 <div class=\"input_btn_left\"></div>
                 <div class=\"input_btn_mid\"><input class=\"input_btn\" type=\"submit\" value=\"Ok\"></div>
                 <div class=\"input_btn_right\"></div>
                </div>
                				</form><br><br><br>";*/
                $cols = array("id" => array("type" => "id", "display" => "no", "legend" => _("ID")), "customize_vhost" => array("type" => "textarea", "help" => _("Custom apache directives. There is *no* syntax checking on this field!"), "cols" => "40", "rows" => "70", "legend" => _("Custom apache directives")), "redirect_url" => array("type" => "text", "help" => _("Redirect URL"), "size" => 50, "legend" => _("Redirect to:")), "php_memory_limit" => array("type" => "text", "help" => _("Maximum memory used by PHP session"), "size" => 3, "legend" => _("PHP memory limit")), "php_max_execution_time" => array("type" => "text", "help" => _("Maximum time a PHP script can execute"), "size" => 3, "legend" => _("Execution time")), "php_upload_max_filesize" => array("type" => "text", "help" => _("Maximum allowed size of uploaded file"), "size" => 2, "legend" => _("Max upload file size")), "php_post_max_size" => array("type" => "text", "help" => _("Maximum allowed size of POST"), "size" => 2, "legend" => _("Max POST file size")), "php_session_auto_start" => array("type" => "checkbox", "help" => _("Auto start of php sessions"), "size" => 2, "legend" => _("Session autostart"), "values" => array("yes", "no"), "display_replace" => array(_("No"), _("Yes"))), "php_allow_url_fopen" => array("type" => "checkbox", "help" => _("Allows to open URLs with PHP's fopen() function."), "size" => 2, "legend" => _("Allow URL fOpen()"), "values" => array("yes", "no"), "display_replace" => array(_("No"), _("Yes"))));
                if ($conf_use_shared_ssl == "yes") {
                    $cols["use_shared_ssl"] = array("type" => "checkbox", "help" => _("Use a shared SSL certificate for this subdomain."), "size" => 2, "legend" => _("SSL"), "values" => array("yes", "no"), "display_replace" => array(_("No"), _("Yes")));
                }
                $dsc = array("table_name" => $pro_mysql_subdomain_table, "title" => _("Configuration of the subdomain"), "action" => "change_domain_config", "forward" => array("subdomain", "edithost", "rub", "adm_login", "adm_pass"), "skip_deletion" => "yes", "skip_creation" => "yes", "where_condition" => "subdomain_name='" . $_REQUEST["subdomain"] . "' AND domain_name='" . $_REQUEST["edithost"] . "'", "cols" => $cols);
                $ret .= dtcDatagrid($dsc);
            }
        }
    }
    // VPS configuration
    if (isset($admin["vps"])) {
        $vpses = $admin["vps"];
        $nbr_vps = sizeof($vpses);
    } else {
        $nbr_vps = 0;
    }
    if ($nbr_vps > 0) {
        $q = "SELECT id,name FROM {$pro_mysql_product_table} WHERE heb_type='vps' AND renew_prod_id='0';";
        $r = mysql_query($q) or die("Cannot query {$q} line " . __LINE__ . " file " . __FILE__ . " sql said: " . mysql_error());
        $n = mysql_num_rows($r);
        $prod_name = array();
        $prod_id = array();
        for ($i = 0; $i < $n; $i++) {
            $a = mysql_fetch_array($r);
            $prod_name[] = $a["name"];
            $prod_id[] = $a["id"];
        }
        $dsc = array("table_name" => $pro_mysql_vps_table, "title" => _("Configuration of the VPSes"), "action" => "change_vps_config", "forward" => array("rub", "adm_login", "adm_pass"), "skip_deletion" => "yes", "skip_creation" => "yes", "where_condition" => "owner='{$adm_login}'", "order_by" => "vps_server_hostname,vps_xen_name", "cols" => array("id" => array("type" => "id", "display" => "no", "legend" => "id"), "vps_server_hostname" => array("type" => "info", "legend" => _("VPS Server")), "vps_xen_name" => array("type" => "info", "legend" => _("VPS Name")), "start_date" => array("type" => "text", "size" => "10", "help" => _("Format: YYYY-MM-DD."), "legend" => _("Registration")), "expire_date" => array("type" => "text", "help" => _("Format: YYYY-MM-DD."), "size" => "10", "legend" => _("Expiration")), "hddsize" => array("type" => "text", "help" => _("Hard drive space in MBytes. You will need to manually do a lvresize on the dom0 of your VPS server to activate the changes."), "size" => "5", "legend" => "HDD"), "ramsize" => array("type" => "text", "help" => _("Memory size in MBytes. You will need to manually change the RAM size in the /etc/xen/xenXX startup configuration file and reboot the VPS to activate the changes."), "size" => "5", "legend" => "RAM"), "bandwidth_per_month_gb" => array("type" => "text", "size" => "5", "help" => _("Bandwidth per month in MBytes."), "legend" => _("Bandwidth")), "product_id" => array("type" => "popup", "legend" => _("Product ID"), "values" => $prod_id, "display_replace" => $prod_name)));
        $ret .= dtcDatagrid($dsc);
    }
    // Dedicated servers configuration
    if (isset($admin["dedicated"])) {
        $servers = $admin["dedicated"];
        $nbr_server = sizeof($servers);
    } else {
        $nbr_server = 0;
    }
    if ($nbr_server > 0) {
        $q = "SELECT id,name FROM {$pro_mysql_product_table} WHERE heb_type='server' AND renew_prod_id='0';";
        $r = mysql_query($q) or die("Cannot query {$q} line " . __LINE__ . " file " . __FILE__ . " sql said: " . mysql_error());
        $n = mysql_num_rows($r);
        $prod_name = array();
        $prod_id = array();
        for ($i = 0; $i < $n; $i++) {
            $a = mysql_fetch_array($r);
            $prod_name[] = $a["name"];
            $prod_id[] = $a["id"];
        }
        $dsc = array("table_name" => $pro_mysql_dedicated_table, "title" => "", "action" => _("Configuration of the dedicated servers"), "forward" => array("rub", "adm_login", "adm_pass"), "skip_deletion" => "yes", "skip_creation" => "yes", "where_condition" => "owner='{$adm_login}'", "cols" => array("id" => array("type" => "id", "display" => "no", "legend" => "id"), "server_hostname" => array("type" => "text", "legend" => _("Server name")), "start_date" => array("type" => "text", "help" => _("Format: YYYY-MM-DD."), "size" => "10", "legend" => _("Registration")), "expire_date" => array("type" => "text", "help" => _("Format: YYYY-MM-DD."), "size" => "10", "legend" => _("Expiration")), "hddsize" => array("type" => "text", "help" => _("Hard drive size in MBytes."), "size" => "5", "legend" => "HDD"), "ramsize" => array("type" => "text", "help" => _("Memory size in MBytes."), "size" => "5", "legend" => "RAM"), "bandwidth_per_month_gb" => array("type" => "text", "help" => _("Bandwidth per month in GBytes."), "size" => "5", "legend" => _("Bandwidth per month")), "country_code" => array("type" => "popup", "legend" => _("Country"), "values" => array_keys($cc_code_array), "display_replace" => array_values($cc_code_array)), "product_id" => array("type" => "popup", "legend" => _("Product"), "values" => $prod_id, "display_replace" => $prod_name)));
        $ret .= dtcDatagrid($dsc);
    }
    return $ret;
}