Exemple #1
0
function drawPasswordChange()
{
    global $adm_login;
    global $adm_pass;
    global $addrlink;
    global $pro_mysql_admin_table;
    $pass_submit_err = "";
    if (isset($_REQUEST["action"]) && $_REQUEST["action"] == "change_adm_pass") {
        $commit_flag = "yes";
        //Init the commit_flag
        if (!isDTCPassword($_REQUEST["new_pass1"]) || !isDTCPassword($_REQUEST["new_pass2"])) {
            $pass_submit_err .= _("This is not a valid password!") . "<br>\n";
            $commit_flag = "no";
        }
        if ($_REQUEST["new_pass1"] != $_REQUEST["new_pass2"]) {
            $pass_submit_err .= _("Password 1 does not match password 2!") . "<br>\n";
            $commit_flag = "no";
        }
        if ($commit_flag == "yes") {
            $q = "UPDATE {$pro_mysql_admin_table} SET adm_pass='******' WHERE adm_login='******';";
            $r = mysql_query($q) or die("Cannot query {$q} line " . __LINE__ . " file " . __FILE__ . " sql said " . mysql_error());
            $pass_submit_err .= _("Your administrator password has been changed!") . "<br>\n";
        }
    }
    $out = "<h3>" . _("Change your password:"******"</h3><br>\n{$pass_submit_err}\n<form action=\"" . $_SERVER["PHP_SELF"] . "\" method=\"post\">\n" . dtcFormTableAttrs() . "\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=\"change_adm_pass\">\n" . dtcFormLineDraw(_("New password:"******"<input type=\"password\" name=\"new_pass1\" value=\"\">") . dtcFormLineDraw(_("Retype new password:"******"<input type=\"password\" name=\"new_pass2\" value=\"\">", 1) . dtcFromOkDraw() . "</form></table>";
    return $out;
}
function drawNewAdminForm()
{
    global $conf_site_root_host_path;
    global $lang;
    global $pro_mysql_admin_table;
    global $pro_mysql_client_table;
    global $pro_mysql_new_admin_table;
    global $pro_mysql_pending_queries_table;
    global $pro_mysql_pay_table;
    global $pro_mysql_pending_renewal_table;
    global $pro_mysql_product_table;
    global $pro_mysql_vps_table;
    global $pro_mysql_tik_admins_table;
    global $pro_mysql_tik_queries_table;
    global $pro_mysql_tik_cats_table;
    global $pro_mysql_dedicated_table;
    global $secpayconf_currency_letters;
    global $secpayconf_use_maxmind;
    get_secpay_conf();
    $out = "";
    // Resolve support ticket stuff
    if (isset($_REQUEST["subaction"]) && $_REQUEST["subaction"] == "resolv_ticket") {
        $q = "SELECT * FROM {$pro_mysql_tik_queries_table} WHERE id='" . $_REQUEST["tik_id"] . "';";
        $r = mysql_query($q) or die("Cannot query \"{$q}\" ! Line: " . __LINE__ . " in file: " . __FILE__ . " mysql said: " . mysql_error());
        $n = mysql_num_rows($r);
        if ($n != 1) {
            return _("Cannot find ticket!");
        }
        $a = mysql_fetch_array($r);
        $out .= _("Subject: ") . htmlspecialchars(stripslashes($a["subject"])) . "<br>";
        $q2 = "SELECT * FROM {$pro_mysql_tik_cats_table} WHERE id='" . $a["cat_id"] . "';";
        $r2 = mysql_query($q2) or die("Cannot query {$q2} line " . __LINE__ . " file " . __FILE__ . " sql said: " . mysql_error());
        $n2 = mysql_num_rows($r2);
        if ($n2 != 1) {
            $tmp = _("Type not found!");
        } else {
            $a2 = mysql_fetch_array($r2);
            $tmp = $a2["catdescript"] . "<br>";
        }
        $out .= _("Type:") . $tmp;
        $out .= _("First query date: ") . $a["date"] . " " . $a["time"] . "<br>";
        $out .= _("Server hostname related: ") . $a["server_hostname"] . "<br>";
        $out .= _("Admin login: "******"adm_login"] . "<br><br>";
        $out .= "<table cellspacing=\"0\" cellpadding=\"4\" border=\"0\">";
        $next_tikq = $_REQUEST["tik_id"];
        $close_request = "no";
        while ($next_tikq != 0) {
            $q = "SELECT * FROM {$pro_mysql_tik_queries_table} WHERE adm_login='******' AND id='{$next_tikq}';";
            $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 ticket!");
                break;
            }
            $a = mysql_fetch_array($r);
            $last_tik = $next_tikq;
            $next_tikq = $a["reply_id"];
            if ($a["admin_or_user"] == "user") {
                $bg = " bgcolor=\"#AAAAFF\" ";
            } else {
                $bg = " bgcolor=\"#FFFFAA\" ";
            }
            if ($a["admin_or_user"] == "admin") {
                $replied_by = "<br>" . _("Replied by:") . " " . $a["admin_name"];
            } else {
                $replied_by = "";
            }
            $out .= "<tr><td{$bg} valign=\"top\"><i>" . $a["date"] . " " . $a["time"] . "</i>" . $replied_by . "</td><td{$bg}>" . nl2br(htmlspecialchars(stripslashes($a["text"]))) . "</td></tr>";
            if ($a["request_close"] == "yes") {
                $close_request = "yes";
            }
        }
        $out .= "</table>";
        $out .= _("Request to close the ticket: ");
        if ($close_request == "yes") {
            $out .= "<font color=\"#00FF00\">" . _("Yes") . "</font><br>";
        } else {
            $out .= "<font color=\"#FF0000\">" . _("No") . "</font><br>";
        }
        $out .= "<form action=\"" . $_SERVER["PHP_SELF"] . "\" method=\"post\">\n\t\t<input type=\"hidden\" name=\"subaction\" value=\"ticket_reply\">\n\t\t<textarea cols=\"100\" rows=\"10\" wrap=\"physical\" name=\"ticketbody\"></textarea><br>\n\t\t<input type=\"hidden\" name=\"tik_id\" value=\"" . $_REQUEST["tik_id"] . "\">\n\t\t<input type=\"hidden\" name=\"server_hostname\" value=\"" . $a["server_hostname"] . "\">\n\t\t<input type=\"hidden\" name=\"last_tik_id\" value=\"{$last_tik}\">\n\t\t<div class=\"input_btn_container\" onMouseOver=\"this.className='input_btn_container-hover';\" onMouseOut=\"this.className='input_btn_container';\">\n <div class=\"input_btn_left\"></div>\n <div class=\"input_btn_mid\"><input class=\"input_btn\" type=\"submit\" name=\"answer\" value=\"" . _("Send reply") . "\"></div>\n <div class=\"input_btn_right\"></div>\n</div>\n\t\t<div class=\"input_btn_container\" onMouseOver=\"this.className='input_btn_container-hover';\" onMouseOut=\"this.className='input_btn_container';\">\n <div class=\"input_btn_left\"></div>\n <div class=\"input_btn_mid\"><input class=\"input_btn\" type=\"submit\" name=\"answer_close\" value=\"" . _("Send reply and close ticket") . "\"></div>\n <div class=\"input_btn_right\"></div>\n</div>\n\t\t<div class=\"input_btn_container\" onMouseOver=\"this.className='input_btn_container-hover';\" onMouseOut=\"this.className='input_btn_container';\">\n <div class=\"input_btn_left\"></div>\n <div class=\"input_btn_mid\"><input class=\"input_btn\" type=\"submit\" name=\"close\" value=\"" . _("Close without reply") . "\"></div>\n <div class=\"input_btn_right\"></div>\n</div>\n\t\t<div class=\"input_btn_container\" onMouseOver=\"this.className='input_btn_container-hover';\" onMouseOut=\"this.className='input_btn_container';\">\n <div class=\"input_btn_left\"></div>\n <div class=\"input_btn_mid\"><input class=\"input_btn\" type=\"submit\" name=\"delete_thread\" value=\"" . _("Delete thread silently") . "\"></div>\n <div class=\"input_btn_right\"></div>\n</div>\n\t\t</form>";
        return $out;
    }
    // Reply to support ticket stuff
    if (isset($_REQUEST["subaction"]) && $_REQUEST["subaction"] == "ticket_reply") {
        $q = "SELECT * FROM {$pro_mysql_tik_queries_table} WHERE id='" . $_REQUEST["tik_id"] . "';";
        $r = mysql_query($q) or die("Cannot query \"{$q}\" ! Line: " . __LINE__ . " in file: " . __FILE__ . " mysql said: " . mysql_error());
        $n = mysql_num_rows($r);
        if ($n != 1) {
            return _("Cannot find ticket!");
        }
        $a = mysql_fetch_array($r);
        if (isset($_REQUEST["answer"])) {
            $closed = "no";
        } else {
            $closed = "yes";
        }
        $adm_login = $a["adm_login"];
        if (strlen($adm_login) != 0) {
            $q = "SELECT * FROM {$pro_mysql_admin_table} WHERE adm_login='******';";
            $r = mysql_query($q) or die("Cannot query \"{$q}\" ! Line: " . __LINE__ . " in file: " . __FILE__ . " mysql said: " . mysql_error());
            $n = mysql_num_rows($r);
            if ($n != 1) {
                return "Admin {$adm_login} not found line " . __LINE__ . " file " . __FILE__;
            }
            $admin = mysql_fetch_array($r);
            if ($admin["id_client"] == "0") {
                return _("The virtual administrator for which you are trying to manage a support ticket has no client file. Go in the Customer management screen and create a client file for this administrator.");
            }
            $q = "SELECT * FROM {$pro_mysql_client_table} WHERE id='" . $admin["id_client"] . "';";
            $r = mysql_query($q) or die("Cannot query \"{$q}\" ! Line: " . __LINE__ . " in file: " . __FILE__ . " mysql said: " . mysql_error());
            $n = mysql_num_rows($r);
            if ($n != 1) {
                return "Client id for admin {$adm_login} not found line " . __LINE__ . " file " . __FILE__;
            }
            $client = mysql_fetch_array($r);
        } else {
            $adm_login = "";
        }
        if (isset($_REQUEST["delete_thread"])) {
            deleteTicketThread($_REQUEST["tik_id"]);
            $closed = "no";
        }
        if (isset($_REQUEST["answer"]) || isset($_REQUEST["answer_close"])) {
            $qps = "SELECT * FROM {$pro_mysql_tik_admins_table} WHERE pseudo='" . $_SERVER["PHP_AUTH_USER"] . "';";
            $rps = mysql_query($qps) or die("Cannot query {$qps} line " . __LINE__ . " file " . __FILE__ . " sql said: " . mysql_error());
            $nps = mysql_num_rows($rps);
            if ($nps != 1) {
                die("Ticket admin not found line " . __LINE__ . " file " . __FILE__);
            }
            $aps = mysql_fetch_array($rps);
            $pseudo = $aps["pseudo"];
            $q2 = "INSERT INTO {$pro_mysql_tik_queries_table} (id,adm_login,date,time,in_reply_of_id,reply_id,admin_or_user,subject,text,cat_id,initial_ticket,server_hostname,closed,admin_name)\n\t\t\tVALUES ('','" . $a["adm_login"] . "','" . date("Y-m-d") . "','" . date("H:i:s") . "','" . $_REQUEST["last_tik_id"] . "','0','admin','" . mysql_real_escape_string($a["subject"]) . "','" . mysql_real_escape_string($_REQUEST["ticketbody"]) . "','" . $a["cat_id"] . "','no','" . $a["server_hostname"] . "','{$closed}','{$pseudo}');";
            $r2 = mysql_query($q2) or die("Cannot query {$q2} line " . __LINE__ . " file " . __FILE__ . " sql said: " . mysql_error());
            $ins_id = mysql_insert_id();
            $q2 = "UPDATE {$pro_mysql_tik_queries_table} SET reply_id='{$ins_id}' WHERE id='" . $_REQUEST["last_tik_id"] . "';";
            $r2 = mysql_query($q2) or die("Cannot query {$q2} line " . __LINE__ . " file " . __FILE__ . " sql said: " . mysql_error());
            $out .= "Ticket reply sent!<br>";
            if (strlen($adm_login) != 0) {
                mailUserTicketReply($client["email"], $a["hash"], $a["subject"], $_REQUEST["ticketbody"], $closed, $adm_login);
            }
            if (strlen($a["customer_email"]) != 0) {
                mailUserTicketReply($a["customer_email"], $a["hash"], $a["subject"], $_REQUEST["ticketbody"], $closed, $adm_login);
            }
        }
        if ($closed == "yes") {
            $q2 = "UPDATE {$pro_mysql_tik_queries_table} SET closed='yes' WHERE id='" . $_REQUEST["tik_id"] . "';";
            $r2 = mysql_query($q2) or die("Cannot query {$q2} line " . __LINE__ . " file " . __FILE__ . " sql said: " . mysql_error());
        }
        if (isset($_REQUEST["close"])) {
            if (strlen($adm_login) != 0) {
                mailUserTicketReply($client["email"], $a["hash"], "The ticket has been closed (without text reply)", "The ticket has been closed (without text reply)", $closed, $adm_login);
            }
            if (strlen($a["customer_email"]) != 0) {
                mailUserTicketReply($a["customer_email"], $a["hash"], "The ticket has been closed (without text reply)", "The ticket has been closed (without text reply)", $closed, $adm_login);
            }
        }
    }
    // Draw the form for making a new admin
    $add_a_user = "******" . _("Add a new user") . "</h3>\n<form name=\"addnewuser_frm\" action=\"?\" method=\"post\">\n<input type=\"hidden\" name=\"newadminuser\" value=\"Ok\">\n" . dtcFormTableAttrs() . dtcFormLineDraw(_("Login:"******"<input class=\"dtcDatagrid_input_color\" type=\"text\" name=\"newadmin_login\" value=\"\">") . dtcFormLineDraw(_("Password:"******"<input class=\"dtcDatagrid_input_alt_color\" type=\"password\" name=\"newadmin_pass\" value=\"\">" . autoGeneratePassButton("addnewuser_frm", "newadmin_pass"), 0) . dtcFormLineDraw(_("Path:"), "<input class=\"dtcDatagrid_input_color\" type=\"text\" name=\"newadmin_path\" value=\"{$conf_site_root_host_path}\">") . dtcFromOkDraw() . "\n</form>\n</table>\n";
    if ($secpayconf_use_maxmind == "yes") {
        $maxmindsays_th = "<td>" . _("MaxMind says") . "</td>";
    } else {
        $maxmindsays_th = "";
    }
    // Draw the list of users awaiting for an account
    $waiting_new_users = "<h3>" . _("User and domain waiting for addition:") . "</h3>";
    $q = "SELECT * FROM {$pro_mysql_new_admin_table} ORDER BY date,time";
    $r = mysql_query($q) or die("Cannot query \"{$q}\" ! Line: " . __LINE__ . " in file: " . __FILE__ . " mysql said: " . mysql_error());
    $n = mysql_num_rows($r);
    if ($n < 1) {
        $waiting_new_users .= "<b>" . _("No user waiting!") . "</b>";
    } else {
        $waiting_new_users .= "<table width=\"100%\"border=\"1\">\n<tr><td>" . _("Name") . "</td><td>" . _("Login") . "</td><td>" . _("Domain name / VPS server hostname") . "</td><td>" . _("Product") . "</td><td>" . _("Date") . "</td><td>" . _("Bank validated") . "</td>{$maxmindsays_th}<td>" . _("Action") . "</td></tr>";
        for ($i = 0; $i < $n; $i++) {
            $a = mysql_fetch_array($r);
            $waiting_new_users .= "<tr><td style=\"white-space:nowrap\"><u>" . $a["comp_name"] . ":</u><br>";
            $waiting_new_users .= $a["family_name"] . ", " . $a["first_name"] . "</td>";
            $waiting_new_users .= "<td>" . $a["reqadm_login"] . "</td>";
            $prod_id = $a["product_id"];
            $q2 = "SELECT * FROM {$pro_mysql_product_table} WHERE id='{$prod_id}';";
            $r2 = mysql_query($q2) or die("Cannot query \"{$q2}\" ! Line: " . __LINE__ . " in file: " . __FILE__ . " mysql said: " . mysql_error());
            $n2 = mysql_num_rows($r2);
            if ($n2 != 1) {
                $dom_name = _("Cannot find product in db!");
                $prod_name = _("Cannot find product in db!");
            } else {
                $a2 = mysql_fetch_array($r2);
                $prod_name = $a2["name"];
                if ($a2["heb_type"] == "vps") {
                    $dom_name = $a["vps_location"];
                } else {
                    $dom_name = $a["domain_name"];
                }
            }
            $waiting_new_users .= "<td>{$dom_name}</td><td>{$prod_name}</td>";
            $waiting_new_users .= "<td>" . $a["date"] . " " . $a["time"] . "<br>" . calculateAge($a["date"], $a["time"]) . "</td>";
            if ($a["paiement_id"] == 0) {
                $waiting_new_users .= "<td>" . _("No pay ID!") . "</td>";
            } else {
                $q = "SELECT * FROM {$pro_mysql_pay_table} WHERE id='" . $a["paiement_id"] . "';";
                $r2 = mysql_query($q) or die("Cannot select {$q} line: " . __LINE__ . " file: " . __FILE__ . " sql said: " . mysql_error());
                $n2 = mysql_num_rows($r2);
                if ($n2 != 1) {
                    echo "Numrows!=1 in {$q} line: " . __LINE__ . " file: " . __FILE__ . " : problems with sql tables !";
                }
                $a2 = mysql_fetch_array($r2);
                if ($a2["valid"] == "yes") {
                    $waiting_new_users .= "<td><font color=\"green\">" . _("Yes") . "</font></td>";
                } elseif ($a2["valid"] == "pending") {
                    $waiting_new_users .= "<td><font color=\"#FF8800\">" . _("Pending") . ": " . $a2["pending_reason"] . "</font></td>";
                } else {
                    $waiting_new_users .= "<td><font color=\"red\">" . _("No") . "</font></td>";
                }
            }
            if ($secpayconf_use_maxmind == "yes") {
                $waiting_new_users .= "<td><pre style='width: 200px; height: 100px; overflow: scroll;'>" . htmlspecialchars(print_r(unserialize($a["maxmind_output"]), true)) . "</pre></td>";
            }
            $waiting_new_users .= "<td style=\"white-space:nowrap\"><a target=\"_blank\" href=\"/dtcadmin/view_waitingusers.php?reqadm_id=" . $a["id"] . "\">" . _("Edit") . "</a><br/>\n\t\t\t<a href=\"" . $_SERVER["PHP_SELF"] . "?action=valid_waiting_user&reqadm_id=" . $a["id"] . "\">" . _("Add") . "</a><br/>\n\t\t\t<a href=\"" . $_SERVER["PHP_SELF"] . "?action=delete_waiting_user&reqadm_id=" . $a["id"] . "\">" . _("Delete") . "</a></td>";
            $waiting_new_users .= "</tr>";
        }
        $waiting_new_users .= "</table>";
    }
    // Draw the list of domains awaiting to be add to users
    $q = "SELECT * FROM {$pro_mysql_pending_queries_table}";
    $r = mysql_query($q) or die("Cannot query \"{$q}\" ! Line: " . __LINE__ . " in file: " . __FILE__ . " mysql said: " . mysql_error());
    $n = mysql_num_rows($r);
    if ($n < 1) {
        $waiting_new_users .= "<br><b>" . _("No domain waiting!") . "</b><br>";
    } else {
        $waiting_new_users .= "<table border=\"1\">\n\t<tr><td>" . _("Login") . "</td><td>" . _("Domain name") . "</td><td>" . _("Action") . "</td></tr>";
        for ($i = 0; $i < $n; $i++) {
            $a = mysql_fetch_array($r);
            $waiting_new_users .= "<td>" . $a["adm_login"] . "</td>";
            $waiting_new_users .= "<td>" . $a["domain_name"] . "</td>";
            $waiting_new_users .= "<td><a href=\"" . $_SERVER["PHP_SELF"] . "?action=valid_waiting_domain_to_user&reqid=" . $a["id"] . "\">" . _("Add") . "</a>\n- <a href=\"" . $_SERVER["PHP_SELF"] . "?action=delete_waiting_domain_to_user&reqid=" . $a["id"] . "\">" . _("Delete") . "</a></td></tr>";
        }
        $waiting_new_users .= "</table>";
    }
    // Draw the list of pending renewals
    $q = "SELECT * FROM {$pro_mysql_pending_renewal_table} ORDER BY renew_date,renew_time";
    $r = mysql_query($q) or die("Cannot query \"{$q}\" ! Line: " . __LINE__ . " in file: " . __FILE__ . " mysql said: " . mysql_error());
    $n = mysql_num_rows($r);
    if ($n < 1) {
        $waiting_new_users .= "<b>" . _("No pending renewals!") . "</b><br>";
    } else {
        $waiting_new_users .= "<table border=\"1\">\n<tr><td>" . _("Login") . "</td><td>" . _("Product") . "</td><td>" . _("Payment date") . "</td><td>" . _("Bank validated") . "</td><td>" . _("Type") . "</td><td>" . _("Action") . "</td></tr>";
        for ($i = 0; $i < $n; $i++) {
            $a = mysql_fetch_array($r);
            $waiting_new_users .= "<tr><td>" . $a["adm_login"] . "</td>";
            $q2 = "SELECT name,price_dollar,period FROM {$pro_mysql_product_table} WHERE id='" . $a["product_id"] . "';";
            $r2 = mysql_query($q2) or die("Cannot query \"{$q2}\" ! Line: " . __LINE__ . " in file: " . __FILE__ . " mysql said: " . mysql_error());
            $n2 = mysql_num_rows($r2);
            if ($n2 != 1) {
                $prod_name = _("Cannot find product!");
            } else {
                $a2 = mysql_fetch_array($r2);
                $prod_name = $a2["name"] . " (" . $a2["price_dollar"] . " {$secpayconf_currency_letters}: " . $a2["period"] . ")";
            }
            $waiting_new_users .= "<td>{$prod_name}</td>";
            $waiting_new_users .= "<td>" . $a["renew_date"] . " " . $a["renew_time"] . "</td>";
            $q2 = "SELECT * FROM {$pro_mysql_pay_table} WHERE id='" . $a["pay_id"] . "';";
            $r2 = mysql_query($q2) or die("Cannot query \"{$q2}\" ! Line: " . __LINE__ . " in file: " . __FILE__ . " mysql said: " . mysql_error());
            $n2 = mysql_num_rows($r2);
            if ($n2 != 1) {
                $bank = _("Cannot find payment!");
            } else {
                $a2 = mysql_fetch_array($r2);
                switch ($a2["valid"]) {
                    case "yes":
                        $bank = "<font color=\"green\">" . _("Yes") . "</font>";
                        break;
                    default:
                    case "no":
                        $bank = "<font color=\"red\">" . _("No") . "</font>";
                        break;
                    case "pending":
                        $bank = "<font color=\"#FF8800\">" . _("Pending") . ": " . $a2["pending_reason"] . "</font>";
                        break;
                }
            }
            $waiting_new_users .= "<td>{$bank}</td>";
            switch ($a["heb_type"]) {
                case "vps":
                    $q2 = "SELECT * FROM {$pro_mysql_vps_table} WHERE id='" . $a["renew_id"] . "'";
                    $r2 = mysql_query($q2) or die("Cannot query \"{$q2}\" ! Line: " . __LINE__ . " in file: " . __FILE__ . " mysql said: " . mysql_error());
                    if ($n2 != 1) {
                        $heb_type = _("VPS: Cannot find VPS in db!");
                    } else {
                        $a2 = mysql_fetch_array($r2);
                        $heb_type = "VPS: " . $a2["vps_xen_name"] . "@" . $a2["vps_server_hostname"];
                    }
                    break;
                case "shared":
                case "ssl":
                    $heb_type = _("Shared");
                    break;
                case "shared-upgrade":
                    $heb_type = _("Shared Upgrade");
                    break;
                case "ssl":
                    $heb_type = _("SSL Token purchase");
                    break;
                case "ssl_renew":
                    $heb_type = _("SSL Token renewal");
                    break;
                case "server":
                    $q2 = "SELECT * FROM {$pro_mysql_dedicated_table} WHERE id='" . $a["renew_id"] . "'";
                    $r2 = mysql_query($q2) or die("Cannot query \"{$q2}\" ! Line: " . __LINE__ . " in file: " . __FILE__ . " mysql said: " . mysql_error());
                    if ($n2 != 1) {
                        $tmp = _("Cannot find server in db!");
                    } else {
                        $a2 = mysql_fetch_array($r2);
                        $tmp = $a2["server_hostname"];
                    }
                    $heb_type = _("Server:") . $tmp;
                    break;
                default:
                    echo "Renew type " . $a["heb_type"] . " not implemented line " . __LINE__ . " file " . __FILE__;
                    break;
            }
            $waiting_new_users .= "<td>{$heb_type}</td>";
            $waiting_new_users .= "<td style=\"white-space:nowrap\"><a href=\"" . $_SERVER["PHP_SELF"] . "?action=validate_renewal&id=" . $a["id"] . "\">" . _("Validate") . "</a> <a href=\"" . $_SERVER["PHP_SELF"] . "?action=delete_renewal&id=" . $a["id"] . "\">" . _("Del") . "</a></td>";
            $waiting_new_users .= "</tr>";
        }
        $waiting_new_users .= "</table>";
    }
    // Ticket manager: draw all open tickets
    $q = "SELECT * FROM {$pro_mysql_tik_queries_table} WHERE closed='no' AND initial_ticket='yes' ORDER BY `date`,`time`;";
    $r = mysql_query($q) or die("Cannot query \"{$q}\" ! Line: " . __LINE__ . " in file: " . __FILE__ . " mysql said: " . mysql_error());
    $n = mysql_num_rows($r);
    if ($n < 1) {
        $waiting_new_users .= "<b>" . _("No pending support tickets!") . "</b><br>";
    } else {
        $waiting_new_users .= "<table border=\"1\">\n<tr><td>" . _("Login") . "</td><td>" . _("Age") . "</td><td>" . _("Type") . "</td><td>" . _("Subject") . "</td><td>" . _("Last message from") . "</td><td>" . _("Last message age") . "</td></tr>";
        for ($i = 0; $i < $n; $i++) {
            $a = mysql_fetch_array($r);
            if (strlen($a["customer_email"]) != 0) {
                $who = $a["customer_email"];
                if (strlen($a["adm_login"]) != 0) {
                    $who .= " / " . $a["adm_login"];
                }
            } else {
                $who = $a["adm_login"];
            }
            $waiting_new_users .= "<tr><td>{$who}</td>";
            $q2 = "SELECT * FROM {$pro_mysql_tik_cats_table} WHERE id='" . $a["cat_id"] . "'";
            $r2 = mysql_query($q2) or die("Cannot query \"{$q2}\" ! Line: " . __LINE__ . " in file: " . __FILE__ . " mysql said: " . mysql_error());
            $n2 = mysql_num_rows($r2);
            if ($n2 != 1) {
                $cat = _("Type not found!");
            } else {
                $a2 = mysql_fetch_array($r2);
                $cat = $a2["catname"];
            }
            $age = calculateAge($a["date"], $a["time"]);
            $waiting_new_users .= "<td style=\"white-space:nowrap;\">{$age}</td><td>{$cat}</td><td style=\"white-space:nowrap;\"><a href=\"" . $_SERVER["PHP_SELF"] . "?subaction=resolv_ticket&tik_id=" . $a["id"] . "\">" . htmlspecialchars(stripslashes($a["subject"])) . "</a></td>";
            $next_reply_id = $a["reply_id"];
            $last_reply_text = "<font color=\"green\">" . _("Admin") . "</font>";
            $last_message_date = $a["date"];
            $last_message_time = $a["time"];
            $loop_num = 0;
            $last_guy_replied = "user";
            while ($next_reply_id != 0 && $loop_num < 49) {
                $loop_num++;
                $q2 = "SELECT * FROM {$pro_mysql_tik_queries_table} WHERE id='{$next_reply_id}';";
                $r2 = mysql_query($q2) or die("Cannot query \"{$q2}\" ! Line: " . __LINE__ . " in file: " . __FILE__ . " mysql said: " . mysql_error());
                $n2 = mysql_num_rows($r2);
                if ($n2 != 1) {
                    echo "Warning: couldn't find tik query {$next_reply_id} in last reply detection!";
                    break;
                }
                $a3 = mysql_fetch_array($r2);
                $last_message_date = $a3["date"];
                $last_message_time = $a3["time"];
                if ($a3["admin_or_user"] == "user") {
                    $last_guy_replied = "user";
                } else {
                    $last_guy_replied = "admin";
                }
                $next_reply_id = $a3["reply_id"];
                if ($loop_num >= 49) {
                    echo "Warning: loop_num exeeded 50, not displaying last ticket reply from line" . __LINE__ . " file " . __FILE__;
                }
            }
            if ($last_guy_replied == "user") {
                $last_reply_text = "<font color=\"red\">" . _("User") . "</font>";
            }
            $waiting_new_users .= "<td>{$last_reply_text}</td>";
            $age2 = calculateAge($last_message_date, $last_message_time);
            $waiting_new_users .= "<td>" . $age2 . "</td>";
            $waiting_new_users .= "</tr>";
        }
        $waiting_new_users .= "</table>";
    }
    return "<table>\n<tr>\n\t<td valign=\"top\">" . $waiting_new_users . "</td>\n\t</tr><tr>\n\t<td valign=\"top\">" . $add_a_user . "</td>\n</tr></table>";
}
Exemple #3
0
function drawAdminTools_Dedicated($admin, $dedicated_server_hostname)
{
    global $adm_login;
    global $adm_pass;
    global $rub;
    global $addrlink;
    global $pro_mysql_product_table;
    global $pro_mysql_dedicated_table;
    global $pro_mysql_dedicated_ips_table;
    global $secpayconf_currency_letters;
    global $submit_err;
    get_secpay_conf();
    $out = "<font color=\"red\">{$submit_err}</font>";
    // Check owner and fetch!
    checkDedicatedAdmin($adm_login, $adm_pass, $dedicated_server_hostname);
    $q = "SELECT * FROM {$pro_mysql_dedicated_table} WHERE server_hostname='{$dedicated_server_hostname}';";
    $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 .= _("Server not found!");
    }
    $dedicated = mysql_fetch_array($r);
    // Display the current contract
    $q = "SELECT * FROM {$pro_mysql_product_table} WHERE id='" . $dedicated["product_id"] . "';";
    $r = mysql_query($q) or die("Cannot query {$q} line " . __LINE__ . " file " . __FILE__ . " sql said: " . mysql_error());
    $n = mysql_num_rows($r);
    if ($n == 1) {
        $server_prod = mysql_fetch_array($r);
        $contract = $server_prod["name"];
    } else {
        $contact = _("Not found!");
    }
    $out .= "<h3>" . _("Dedicated server contract:") . "</h3><br>{$contract}<br><br>";
    $ar = explode("-", $dedicated["expire_date"]);
    $out .= "<b><u>" . _("Dedicated server expiration dates:") . "</u></b><br>";
    $out .= _("Your dedicated server was first registered on the:") . " " . $dedicated["start_date"] . "<br>";
    if (date("Y") > $ar[0] || date("Y") == $ar[0] && date("m") > $ar[1] || date("Y") == $ar[0] && date("m") == $ar[1] && date("d") > $ar[2]) {
        $out .= "<font color=\"red\">" . _("Your dedicated server has expired on the: ") . $dedicated["expire_date"] . "</font>" . "<br>" . _("Please renew it with one of the following options") . "<br>";
    } else {
        $out .= _("Your dedicated server will expire on the: ") . $dedicated["expire_date"];
    }
    $q = "SELECT * FROM {$pro_mysql_product_table} WHERE renew_prod_id='" . $dedicated["product_id"] . "';";
    $r = mysql_query($q) or die("Cannot query {$q} line " . __LINE__ . " file " . __FILE__ . " sql said: " . mysql_error());
    $n = mysql_num_rows($r);
    for ($i = 0; $i < $n; $i++) {
        $a = mysql_fetch_array($r);
        $out .= "<form action=\"/dtc/new_account.php\">\n\t\t<input type=\"hidden\" name=\"action\" value=\"contract_renewal\">\n\t\t<input type=\"hidden\" name=\"renew_type\" value=\"server\">\n\t\t<input type=\"hidden\" name=\"product_id\" value=\"" . $a["id"] . "\">\n\t\t<input type=\"hidden\" name=\"server_id\" value=\"" . $dedicated["id"] . "\">\n\t\t<input type=\"hidden\" name=\"adm_login\" value=\"{$adm_login}\">\n\t\t<input type=\"submit\" value=\"" . $a["name"] . " (" . $a["price_dollar"] . " {$secpayconf_currency_letters})" . "\">\n\t\t</form>";
    }
    //	$out .= "Dedicated server content!";
    if ($server_prod["use_radius"] == 'yes') {
        $out .= '<BR><BR>Aca editamos Radius<BR><BR>';
    }
    $out .= "<br><br><h3>" . _("IP addresses: ") . "</h3>";
    $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}\">";
    $q = "SELECT * FROM {$pro_mysql_dedicated_ips_table} WHERE dedicated_server_hostname='{$dedicated_server_hostname}'";
    $r = mysql_query($q) or die("Cannot query {$q} line " . __LINE__ . " file " . __FILE__ . " sql said: " . mysql_error());
    $n = mysql_num_rows($r);
    $out .= dtcFormTableAttrs();
    for ($i = 0; $i < $n; $i++) {
        $a = mysql_fetch_array($r);
        if ($i % 2) {
            $alt_color = 0;
        } else {
            $alt_color = 1;
        }
        $out .= dtcFormLineDraw($a["ip_addr"], "{$frm_start}<input type=\"hidden\" name=\"action\" value=\"set_dedicated_ip_rdns\">\n<input type=\"hidden\" name=\"ip_addr\" value=\"" . $a["ip_addr"] . "\">\n<input type=\"text\" name=\"rdns\" value=\"" . $a["rdns_addr"] . "\">\n</td><td><div class=\"input_btn_container\" onMouseOver=\"this.className='input_btn_container-hover';\" onMouseOut=\"this.className='input_btn_container';\">\n<div class=\"input_btn_left\"></div>\n<div class=\"input_btn_mid\"><input class=\"input_btn\" type=\"submit\" value=\"" . _("Change RDNS") . "\"></div>\n<div class=\"input_btn_right\"></div>\n</div></form>", $alt_color);
        /*		if($i > 0){
        			$out .= ", ";
        		}
        		$out .= $a["ip_addr"];*/
    }
    $out .= "</table>";
    return $out;
}
Exemple #4
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;
}
    $text .= dtcFormLineDraw(_("Address (line3): "), "<input class=\"dtcDatagrid_input_alt_color\" size=\"40\" type=\"text\" name=\"addr3\" value=\"" . stripcslashes($b["addr3"]) . "\">", 0);
    $text .= dtcFormLineDraw(_("City: "), "<input class=\"dtcDatagrid_input_color\" size=\"40\" type=\"text\" name=\"city\" value=\"" . stripcslashes($b["city"]) . "\">");
    $text .= dtcFormLineDraw(_("Zipcode: "), "<input class=\"dtcDatagrid_input_alt_color\" size=\"40\" type=\"text\" name=\"zipcode\" value=\"" . stripcslashes($b["zipcode"]) . "\">", 0);
    $text .= dtcFormLineDraw(_("State: "), "<input class=\"dtcDatagrid_input_color\" size=\"40\" type=\"text\" name=\"state\" value=\"" . stripcslashes($b["state"]) . "\">");
    $text .= dtcFormLineDraw(_("Country: "), "<select class=\"dtcDatagrid_input_alt_color\" name=\"country\">" . cc_code_popup($b["country"]) . "</select>", 0);
    $text .= dtcFormLineDraw(_("Phone number: "), "<input class=\"dtcDatagrid_input_color\" size=\"40\" type=\"text\" name=\"phone\" value=\"" . stripcslashes($b["phone"]) . "\">");
    $text .= dtcFormLineDraw(_("Fax: "), "<input class=\"dtcDatagrid_input_alt_color\" size=\"40\" type=\"text\" name=\"fax\" value=\"" . stripcslashes($b["fax"]) . "\">", 0);
    $text .= dtcFormLineDraw(_("Email: "), "<input class=\"dtcDatagrid_input_color\" size=\"40\" type=\"text\" name=\"email\" value=\"" . $b["email"] . "\">");
    $text .= dtcFormLineDraw(_("Notes: "), "<textarea class=\"dtcDatagrid_input_alt_color\" cols=\"40\" rows=\"5\" name=\"custom_notes\">" . stripcslashes($b["custom_notes"]) . "</textarea>", 0);
    $text .= "<input type=\"hidden\" name=\"paiement_id\" value=\"" . $b["paiement_id"] . "\">";
    if ($has_payement == 1) {
        $text .= "<input type=\"hidden\" name=\"secpay_site\" value=\"" . $p["secpay_site"] . "\">";
        $text .= dtcFormLineDraw(_("Payment type: "), "<input class=\"dtcDatagrid_input_color\" size=\"40\" type=\"text\" name=\"paiement_type\" value=\"" . $p["paiement_type"] . "\">");
        $text .= dtcFormLineDraw(_("Payment validated: "), "<input class=\"dtcDatagrid_input_alt_color\" size=\"40\" type=\"text\" name=\"valid\" value=\"" . $p["valid"] . "\">", 0);
        $text .= dtcFormLineDraw(_("Payment site: "), "<input class=\"dtcDatagrid_input_color\" size=\"40\" type=\"text\" name=\"secpay_site\" value=\"" . $p["secpay_site"] . "\">");
        $text .= dtcFormLineDraw(_("Refund amount: "), "<input class=\"dtcDatagrid_input_alt_color\" size=\"40\" type=\"text\" name=\"refund_amount\" value=\"" . $p["refund_amount"] . "\">", 0);
        $text .= dtcFormLineDraw(_("Paiement cost: "), "<input class=\"dtcDatagrid_input_color\" size=\"40\" type=\"text\" name=\"paiement_cost\" value=\"" . $p["paiement_cost"] . "\">");
        $text .= dtcFormLineDraw(_("Paiement total: "), "<input class=\"dtcDatagrid_input_alt_color\" size=\"40\" type=\"text\" name=\"paiement_total\" value=\"" . $p["paiement_total"] . "\">", 0);
        $text .= dtcFormLineDraw(_("Vat rate: "), "<input class=\"dtcDatagrid_input_color\" size=\"40\" type=\"text\" name=\"vat_rate\" value=\"" . $p["vat_rate"] . "\">");
        $text .= dtcFormLineDraw(_("Vat total: "), "<input class=\"dtcDatagrid_input_alt_color\" size=\"40\" type=\"text\" name=\"vat_total\" value=\"" . $p["vat_total"] . "\">", 0);
    } else {
        $text .= dtcFormLineDraw(_("Payment site: "), _("Paiement not found!"));
    }
    $text .= dtcFormLineDraw(_("Shopper IP: "), $b["shopper_ip"]);
    $text .= "<input type=\"hidden\" name=\"shopper_ip\" value=\"" . $b["shopper_ip"] . "\">";
    $text .= "\n<tr><td align=\"right\"></td><td><div class=\"input_btn_container\" onMouseOver=\"this.className='input_btn_container-hover';\" onMouseOut=\"this.className='input_btn_container';\">\n <div class=\"input_btn_left\"></div>\n <div class=\"input_btn_mid\"><input class=\"input_btn\" type=\"submit\" value=\"" . _("Save") . "\"></div>\n <div class=\"input_btn_right\"></div>\n</div></form>";
}
$the_page[] = skin($conf_skin, $text, "User details:");
$pageContent = makeVerticalFrame($the_page);
$anotherFooter = anotherFooter("Footer content<br><br>");
echo anotherPage("admin:", "", "", makePreloads(), $anotherTopBanner, $anotherMenu, $pageContent, $anotherFooter);
Exemple #6
0
function DTCRMeditClients()
{
    global $pro_mysql_client_table;
    if (isset($_REQUEST["id"])) {
        $cid = $_REQUEST["id"];
        // current customer id
    } else {
        return _("Select a customer.");
    }
    $iscomp_yes = "checked";
    $iscomp_no = "";
    if ($cid != 0 && isset($cid) && $cid != "") {
        $query = "SELECT * FROM {$pro_mysql_client_table} WHERE id='" . $_REQUEST["id"] . "';";
        $result = mysql_query($query) or die("Cannot query \"{$query}\" !!!" . mysql_error());
        $num_rows = mysql_num_rows($result);
        if ($num_rows != 1) {
            return "<font color=\"red\">Error : no row by that client ID (" . $_REQUEST["id"] . ") !!!</font>";
        }
        $row = mysql_fetch_array($result);
        $hidden_inputs = "<input type=\"hidden\" name=\"action\" value=\"edit_client\">";
        if ($row["is_company"] == "no") {
            $iscomp_yes = "";
            $iscomp_no = "checked";
        }
    } else {
        $hidden_inputs = "<input type=\"hidden\" name=\"action\" value=\"new_client\">";
        unset($row);
        $row["familyname"] = "";
        $row["christname"] = "";
        $row["company_name"] = "";
        $row["vat_num"] = "";
        $row["addr1"] = "";
        $row["addr2"] = "";
        $row["addr3"] = "";
        $row["city"] = "";
        $row["zipcode"] = "";
        $row["state"] = "";
        $row["country"] = "us";
        $row["phone"] = "+";
        $row["fax"] = "";
        $row["email"] = "";
        $row["special_note"] = "";
        $row["dollar"] = "";
        $row["disk_quota_mb"] = "80";
        $row["bw_quota_per_month_gb"] = "1";
    }
    if (isset($row["special_note"])) {
        $specnot = $row["special_note"];
    } else {
        $specnot = "";
    }
    $text = "<form action=\"" . $_SERVER["PHP_SELF"] . "\">\n<input type=\"hidden\" name=\"rub\" value=\"crm\">\n<input type=\"hidden\" name=\"id\" value=\"{$cid}\">{$hidden_inputs}\n";
    $text .= dtcFormTableAttrs();
    $text .= dtcFormLineDraw(_("Familly name: "), "<input class=\"dtcDatagrid_input_color\" size=\"40\" type=\"text\" name=\"ed_familyname\"value=\"" . stripcslashes($row["familyname"]) . "\">");
    $text .= dtcFormLineDraw(_("First name: "), "<input class=\"dtcDatagrid_input_alt_color\" size=\"40\" type=\"text\" name=\"ed_christname\" value=\"" . stripcslashes($row["christname"]) . "\">", 0);
    $text .= dtcFormLineDraw(_("Is it a company: "), "<input type=\"radio\" name=\"ed_is_company\" value=\"yes\" {$iscomp_yes} > " . _("Yes") . "\n<input type=\"radio\" name=\"ed_is_company\" value=\"no\" {$iscomp_no} > " . _("No"));
    $text .= dtcFormLineDraw(_("Company name: "), "<input class=\"dtcDatagrid_input_alt_color\" size=\"40\" type=\"text\" name=\"ed_company_name\" value=\"" . stripcslashes($row["company_name"]) . "\">", 0);
    $text .= dtcFormLineDraw(_("VAT number: "), "<input class=\"dtcDatagrid_input_color\" size=\"40\" type=\"text\" name=\"ed_vat_num\" value=\"" . stripcslashes($row["vat_num"]) . "\">");
    $text .= dtcFormLineDraw(_("Address (line1): "), "<input class=\"dtcDatagrid_input_alt_color\" size=\"40\" type=\"text\" name=\"ed_addr1\" value=\"" . stripcslashes($row["addr1"]) . "\">", 0);
    $text .= dtcFormLineDraw(_("Address (line2): "), "<input class=\"dtcDatagrid_input_color\" size=\"40\" type=\"text\" name=\"ed_addr2\" value=\"" . stripcslashes($row["addr2"]) . "\">");
    $text .= dtcFormLineDraw(_("Address (line3): "), "<input class=\"dtcDatagrid_input_alt_color\" size=\"40\" type=\"text\" name=\"ed_addr3\" value=\"" . stripcslashes($row["addr3"]) . "\">", 0);
    $text .= dtcFormLineDraw(_("City: "), "<input class=\"dtcDatagrid_input_color\" size=\"40\" type=\"text\" name=\"ed_city\" value=\"" . stripcslashes($row["city"]) . "\">");
    $text .= dtcFormLineDraw(_("Zipcode: "), "<input class=\"dtcDatagrid_input_alt_color\" size=\"40\" type=\"text\" name=\"ed_zipcode\" value=\"" . stripcslashes($row["zipcode"]) . "\">", 0);
    $text .= dtcFormLineDraw(_("State: "), "<input class=\"dtcDatagrid_input_color\" size=\"40\" type=\"text\" name=\"ed_state\" value=\"" . stripcslashes($row["state"]) . "\">");
    $text .= dtcFormLineDraw(_("Country: "), "<select class=\"dtcDatagrid_input_alt_color\" name=\"ed_country\">" . cc_code_popup($row["country"]) . "</select>", 0);
    $text .= dtcFormLineDraw(_("Phone number: "), "<input class=\"dtcDatagrid_input_color\" size=\"40\" type=\"text\" name=\"ed_phone\" value=\"" . stripcslashes($row["phone"]) . "\">");
    $text .= dtcFormLineDraw(_("Fax: "), "<input class=\"dtcDatagrid_input_alt_color\" size=\"40\" type=\"text\" name=\"ed_fax\" value=\"" . stripcslashes($row["fax"]) . "\">", 0);
    $text .= dtcFormLineDraw(_("Email: "), "<input class=\"dtcDatagrid_input_color\" size=\"40\" type=\"text\" name=\"ed_email\" value=\"" . $row["email"] . "\">");
    $text .= dtcFormLineDraw(_("Notes: "), "<textarea class=\"dtcDatagrid_input_alt_color\" cols=\"40\" rows=\"5\" name=\"ed_special_note\">" . stripcslashes($specnot) . "</textarea>", 0);
    $text .= dtcFormLineDraw(_("Money remaining: "), "<input class=\"dtcDatagrid_input_color\" size=\"40\" type=\"text\" name=\"ed_dollar\" value=\"" . $row["dollar"] . "\">");
    $text .= dtcFormLineDraw(_("Quota (MB): "), "<input class=\"dtcDatagrid_input_alt_color\" size=\"40\" type=\"text\" name=\"ed_disk_quota_mb\" value=\"" . $row["disk_quota_mb"] . "\">", 0);
    $text .= dtcFormLineDraw(_("Allowed data transfer (GB): "), "<input class=\"dtcDatagrid_input_color\" size=\"40\" type=\"text\" name=\"ed_bw_quota_per_month_gb\" value=\"" . $row["bw_quota_per_month_gb"] . "\">");
    $text .= "\n<tr><td align=\"right\"></td><td><div class=\"input_btn_container\" onMouseOver=\"this.className='input_btn_container-hover';\" onMouseOut=\"this.className='input_btn_container';\">\n <div class=\"input_btn_left\"></div>\n <div class=\"input_btn_mid\"><input class=\"input_btn\" type=\"submit\" value=\"Save\"></div>\n <div class=\"input_btn_right\"></div>\n</div></form>\n<form><form action=\"" . $_SERVER["PHP_SELF"] . "\">\n<input type=\"hidden\" name=\"rub\" value=\"crm\">\n<input type=\"hidden\" name=\"delete_id\" value=\"{$cid}\">\n<input type=\"hidden\" name=\"action\" value=\"delete_customer_id\">\n<input type=\"hidden\" name=\"del\" value=\"Del\">\n<div class=\"input_btn_container\" onMouseOver=\"this.className='input_btn_container-hover';\" onMouseOut=\"this.className='input_btn_container';\">\n <div class=\"input_btn_left\"></div>\n <div class=\"input_btn_mid\"><input class=\"input_btn\" type=\"submit\" value=\"" . _("Delete client") . "\"></div>\n <div class=\"input_btn_right\"></div>\n</div></td></tr>\n</table>\n</form>";
    return $text;
}
Exemple #7
0
function configEditorTemplate($dsc, $conftype = "config")
{
    global $pro_mysql_config_table;
    global $pro_mysql_secpayconf_table;
    $out = "";
    if ($conftype == "config") {
        $sql_table = $pro_mysql_config_table;
        $prefix = "conf_";
    } else {
        $sql_table = $pro_mysql_secpayconf_table;
        $prefix = "secpayconf_";
    }
    $keys = array_keys($dsc["cols"]);
    $n = sizeof($keys);
    // Do the sql stuff here!
    if (isset($_REQUEST["action"]) && $_REQUEST["action"] == $dsc["action"]) {
        $vals = "";
        for ($i = 0; $i < $n; $i++) {
            if ($i != 0) {
                $vals .= ", ";
            }
            if (!isset($_REQUEST[$keys[$i]])) {
                $_REQUEST[$keys[$i]] = "";
            }
            if (!is_array($_REQUEST[$keys[$i]])) {
                $my_value = $_REQUEST[$keys[$i]];
            } else {
                $my_value = join(",", $_REQUEST[$keys[$i]]);
            }
            $vals .= $keys[$i] . "='" . $my_value . "'";
        }
        $q = "UPDATE {$sql_table} SET {$vals} WHERE 1;";
        $r = mysql_query($q) or die("Cannot query {$q} line " . __LINE__ . " file " . __FILE__ . " mysql said: " . mysql_error());
    }
    if (isset($dsc["edit_callback"])) {
        $dsc["edit_callback"]();
    }
    if ($conftype == "config") {
        getConfig();
    } else {
        get_secpay_conf();
    }
    $out .= "<h3>" . $dsc["title"] . "</h3>";
    if (isset($dsc["desc"])) {
        $out .= $dsc["desc"] . "<br><br>";
    }
    $nbr_forwards = sizeof($dsc["forward"]);
    $fw = "";
    for ($i = 0; $i < $nbr_forwards; $i++) {
        $fw .= "<input type=\"hidden\" name=\"" . $dsc["forward"][$i] . "\" value=\"" . $_REQUEST[$dsc["forward"][$i]] . "\">";
    }
    $out .= dtcFormTableAttrs();
    $out .= "<form action=\"" . $_SERVER["PHP_SELF"] . "\">\n<input type=\"hidden\" name=\"action\" value=\"" . $dsc["action"] . "\">{$fw}";
    for ($i = 0; $i < $n; $i++) {
        $fld = $prefix . $keys[$i];
        global ${$fld};
        if ($i % 2 == 1) {
            $input_class = "dtcDatagrid_input_alt_color";
        } else {
            $input_class = "dtcDatagrid_input_color";
        }
        switch ($dsc["cols"][$keys[$i]]["type"]) {
            case "radio":
                $nb_choices = sizeof($dsc["cols"][$keys[$i]]["values"]);
                $control = "";
                for ($j = 0; $j < $nb_choices; $j++) {
                    if (${$fld} == $dsc["cols"][$keys[$i]]["values"][$j]) {
                        $selected = " checked ";
                    } else {
                        $selected = "";
                    }
                    if (isset($dsc["cols"][$keys[$i]]["display_replace"][$j])) {
                        $text = $dsc["cols"][$keys[$i]]["display_replace"][$j];
                    } else {
                        $text = $dsc["cols"][$keys[$i]]["values"][$j];
                    }
                    $control .= "<input type=\"radio\" name=\"" . $keys[$i] . "\" value=\"" . $dsc["cols"][$keys[$i]]["values"][$j] . "\" {$selected}> {$text}";
                }
                break;
            case "popup":
                $nb_choices = sizeof($dsc["cols"][$keys[$i]]["values"]);
                $control = "";
                for ($j = 0; $j < $nb_choices; $j++) {
                    if (${$fld} == $dsc["cols"][$keys[$i]]["values"][$j]) {
                        $selected = " selected ";
                    } else {
                        $selected = "";
                    }
                    if (isset($dsc["cols"][$keys[$i]]["display_replace"][$j])) {
                        $text = $dsc["cols"][$keys[$i]]["display_replace"][$j];
                    } else {
                        $text = $dsc["cols"][$keys[$i]]["values"][$j];
                    }
                    $control .= "<option value=\"" . $dsc["cols"][$keys[$i]]["values"][$j] . "\" {$selected}>{$text}</option>";
                }
                $control = "<select class=\"{$input_class}\" name=\"" . $keys[$i] . "\">" . $control . "</select>";
                break;
            case "checkboxcomma":
                $nb_choices = sizeof($dsc["cols"][$keys[$i]]["values"]);
                $control = "";
                $arr_values = split(",", ${$fld});
                $cntchk = 0;
                for ($j = 0; $j < $nb_choices; $j++) {
                    if (in_array($dsc["cols"][$keys[$i]]["values"][$j], $arr_values)) {
                        $selected = " checked ";
                    } else {
                        $selected = "";
                    }
                    if (isset($dsc["cols"][$keys[$i]]["display_replace"][$j])) {
                        $text = $dsc["cols"][$keys[$i]]["display_replace"][$j];
                    } else {
                        $text = $dsc["cols"][$keys[$i]]["values"][$j];
                    }
                    $control .= "<input type=\"checkbox\" name=\"" . $keys[$i] . "[]\" value=\"" . $dsc["cols"][$keys[$i]]["values"][$j] . "\" {$selected}> {$text}\n";
                    if ($cntchk > 3) {
                        $control .= "<br />";
                        $cntchk = 0;
                    }
                    $cntchk++;
                }
                break;
            case "textarea":
                if (isset($dsc["cols"][$keys[$i]]["cols"])) {
                    $cols = " cols=\"" . $dsc["cols"][$keys[$i]]["cols"] . "\" ";
                } else {
                    $cols = "";
                }
                if (isset($dsc["cols"][$keys[$i]]["rows"])) {
                    $rows = " rows=\"" . $dsc["cols"][$keys[$i]]["rows"] . "\" ";
                } else {
                    $rows = "";
                }
                $control = "<textarea class=\"{$input_class}\" {$cols} {$rows} name=\"" . $keys[$i] . "\">" . ${$fld} . "</textarea>";
                break;
            case "text":
            default:
                if (isset($dsc["cols"][$keys[$i]]["size"])) {
                    $size = " size=\"" . $dsc["cols"][$keys[$i]]["size"] . "\" ";
                } else {
                    $size = "";
                }
                $control = "<input class=\"{$input_class}\" {$size} type=\"text\" name=\"" . $keys[$i] . "\" value=\"" . ${$fld} . "\">";
                break;
        }
        $out .= dtcFormLineDraw($dsc["cols"][$keys[$i]]["legend"], $control, !($i % 2));
    }
    $out .= dtcFromOkDraw() . "</form></table>";
    return $out;
}
Exemple #8
0
function dtcListItemsEdit($dsc)
{
    global $adm_pass;
    $out = "<h3>" . $dsc["title"] . "</u></b></h3>";
    // Calculate the forwards parameters for links and forms
    $nbr_forwards = sizeof($dsc["forward"]);
    $keys_fw = array_keys($dsc["forward"]);
    $fw = "";
    $fw_link = $_SERVER["PHP_SELF"] . "?";
    for ($i = 0; $i < $nbr_forwards; $i++) {
        if ($dsc["forward"][$i] == "adm_pass") {
            $fw .= "<input type=\"hidden\" name=\"" . $dsc["forward"][$i] . "\" value=\"" . $adm_pass . "\">";
        } else {
            $fw .= "<input type=\"hidden\" name=\"" . $dsc["forward"][$i] . "\" value=\"" . $_REQUEST[$dsc["forward"][$i]] . "\">";
        }
        if ($i != 0) {
            $fw_link .= "&";
        }
        if ($dsc["forward"][$i] == "adm_pass") {
            $fw_link .= $dsc["forward"][$i] . "={$adm_pass}";
        } else {
            $fw_link .= $dsc["forward"][$i] . "=" . $_REQUEST[$dsc["forward"][$i]];
        }
    }
    // Condition to add to each queries
    $where = "WHERE 1";
    if (isset($dsc["order_by"])) {
        $order_by = " ORDER BY " . $dsc["order_by"];
    } else {
        $order_by = "";
    }
    $added_insert_names = "";
    $added_insert_values = "";
    if (isset($dsc["where_list"])) {
        $nbr_where = sizeof($dsc["where_list"]);
        $where_keys = array_keys($dsc["where_list"]);
        for ($i = 0; $i < $nbr_where; $i++) {
            if ($i != 0) {
                $added_insert_names .= ",";
                $added_insert_values .= ",";
            }
            $added_insert_names .= $where_keys[$i];
            $added_insert_values .= "'" . $dsc["where_list"][$where_keys[$i]] . "'";
            $where .= " AND " . $where_keys[$i] . "='" . $dsc["where_list"][$where_keys[$i]] . "'";
        }
        // As there will be other fields, we need that one
        $added_insert_names .= ",";
        $added_insert_values .= ",";
    }
    // Number of fields that we are about to manage here and theire names
    $nbr_fld = sizeof($dsc["cols"]);
    $keys = array_keys($dsc["cols"]);
    // We need the current number of items now to check against the max number for addition
    $q = "SELECT " . $dsc["id_fld"] . "," . $dsc["list_fld_show"] . " FROM " . $dsc["table_name"] . " {$where};";
    $r_item_list = mysql_query($q) or die("Cannot query {$q} in " . __FILE__ . " line " . __LINE__ . " sql said: " . mysql_error());
    $current_num_items = mysql_num_rows($r_item_list);
    // SQL submit stuffs
    if (isset($_REQUEST["action"]) && $_REQUEST["action"] == $dsc["action"] . "_new_item") {
        // Todo: do the fields checkings
        $commit_flag = "yes";
        $commit_err = "";
        for ($i = 0; $i < $nbr_fld; $i++) {
            switch ($dsc["cols"][$keys[$i]]["type"]) {
                case "popup":
                case "radio":
                    $nbr_choices = sizeof($dsc["cols"][$keys[$i]]["values"]);
                    $is_one_of_them = "no";
                    for ($j = 0; $j < $nbr_choices; $j++) {
                        if ($dsc["cols"][$keys[$i]]["values"][$j] == $_REQUEST[$keys[$i]]) {
                            $is_one_of_them = "yes";
                        }
                    }
                    if ($is_one_of_them == "no") {
                        $commit_flag = "no";
                        $commit_err = "the variable " . $keys[$i] . " is not one of the allowed values<br>";
                    }
                    break;
                default:
                    break;
            }
            if (isset($dsc["cols"][$keys[$i]]["check"])) {
                switch ($dsc["cols"][$keys[$i]]["check"]) {
                    case "subdomain":
                        if (!checkSubdomainFormat($_REQUEST[$keys[$i]])) {
                            if (!isset($dsc["cols"][$keys[$i]]["can_be_empty"]) || $dsc["cols"][$keys[$i]]["can_be_empty"] != "yes" || $_REQUEST[$keys[$i]] != "") {
                                $commit_flag = "no";
                                $commit_err .= $keys[$i] . ": not a subdomain<br>";
                            }
                        }
                        break;
                    case "subdomain_or_ip":
                        if (!checkSubdomainFormat($_REQUEST[$keys[$i]]) && !isIP($_REQUEST[$keys[$i]])) {
                            if (!isset($dsc["cols"][$keys[$i]]["can_be_empty"]) || $dsc["cols"][$keys[$i]]["can_be_empty"] != "yes" || $_REQUEST[$keys[$i]] != "") {
                                $commit_flag = "no";
                                $commit_err .= $keys[$i] . ": not a subdomain or IP addresse<br>";
                            }
                        }
                        break;
                    case "ip6":
                        if (!isIP6($_REQUEST[$keys[$i]])) {
                            if (!isset($dsc["cols"][$keys[$i]]["can_be_empty"]) || $dsc["cols"][$keys[$i]]["can_be_empty"] != "yes" || $_REQUEST[$keys[$i]] != "") {
                                if (!isset($dsc["cols"][$keys[$i]]["empty_makes_default"]) || $dsc["cols"][$keys[$i]]["empty_makes_default"] != "yes" || $_REQUEST[$keys[$i]] != "default") {
                                    $commit_flag = "no";
                                    $commit_err .= $keys[$i] . ": not an IPv6 address<br>";
                                }
                            }
                        }
                        break;
                    case "ip_addr":
                        if (!isIP($_REQUEST[$keys[$i]])) {
                            if (!isset($dsc["cols"][$keys[$i]]["can_be_empty"]) || $dsc["cols"][$keys[$i]]["can_be_empty"] != "yes" || $_REQUEST[$keys[$i]] != "") {
                                $commit_flag = "no";
                                $commit_err .= $keys[$i] . ": not an IP address<br>";
                            }
                        }
                        break;
                    case "domain_or_ip":
                        if (!isIP($_REQUEST[$keys[$i]]) && !isHostname($_REQUEST[$keys[$i]])) {
                            if (!isset($dsc["cols"][$keys[$i]]["can_be_empty"]) || $dsc["cols"][$keys[$i]]["can_be_empty"] != "yes" || $_REQUEST[$keys[$i]] != "") {
                                $commit_flag = "no";
                                $commit_err .= $keys[$i] . ": not a domain or IP addresse<br>";
                            }
                        }
                        break;
                    case "dtc_login":
                        if (!isFtpLogin($_REQUEST[$keys[$i]])) {
                            if (!isset($dsc["cols"][$keys[$i]]["can_be_empty"]) || $dsc["cols"][$keys[$i]]["can_be_empty"] != "yes" || $_REQUEST[$keys[$i]] != "") {
                                $commit_flag = "no";
                                $commit_err .= $keys[$i] . ": not a correct login format.<br>";
                            }
                        }
                        break;
                    case "dtc_login_or_email":
                        if (!isFtpLogin($_REQUEST[$keys[$i]]) && !isValidEmail($_REQUEST[$keys[$i]])) {
                            if (!isset($dsc["cols"][$keys[$i]]["can_be_empty"]) || $dsc["cols"][$keys[$i]]["can_be_empty"] != "yes" || $_REQUEST[$keys[$i]] != "") {
                                $commit_flag = "no";
                                $commit_err .= $keys[$i] . ": not a correct login format.<br>";
                            }
                        }
                        break;
                    case "mail_alias_group":
                        $mail_alias_group_raw = trim($_REQUEST[$keys[$i]], "\r\n");
                        $mail_alias_nocr = str_replace("\r", "", $mail_alias_group_raw);
                        $mail_alias_array = split("\n", $mail_alias_nocr);
                        for ($x = 0; $x < count($mail_alias_array); $x++) {
                            if (!isValidEmail($mail_alias_array[$x])) {
                                $commit_flag = "no";
                                $commit_err .= $mail_alias_array[$x] . ": not a valid email format.<br>";
                            }
                        }
                        break;
                    case "dtc_pass":
                        if (!isDTCPassword($_REQUEST[$keys[$i]])) {
                            if (!isset($dsc["cols"][$keys[$i]]["can_be_empty"]) || $dsc["cols"][$keys[$i]]["can_be_empty"] != "yes" || $_REQUEST[$keys[$i]] != "") {
                                $commit_flag = "no";
                                $commit_err .= $keys[$i] . ": not a correct password format<br>";
                            }
                        }
                        break;
                    case "email":
                        if (!isValidEmail($_REQUEST[$keys[$i]])) {
                            if (!isset($dsc["cols"][$keys[$i]]["can_be_empty"]) || $dsc["cols"][$keys[$i]]["can_be_empty"] != "yes" || $_REQUEST[$keys[$i]] != "") {
                                $commit_flag = "no";
                                $commit_err .= $keys[$i] . ": not a correct email format<br>";
                            }
                        }
                        break;
                    case "number":
                        if (!isRandomNum($_REQUEST[$keys[$i]])) {
                            if (!isset($dsc["cols"][$keys[$i]]["can_be_empty"]) || $dsc["cols"][$keys[$i]]["can_be_empty"] != "yes" || $_REQUEST[$keys[$i]] != "") {
                                $commit_flag = "no";
                                $commit_err .= $keys[$i] . ": not a correct number format<br>";
                            }
                        }
                        break;
                    case "max_value_2096":
                        if (!isset($dsc["cols"][$keys[$i]]["can_be_empty"]) || $dsc["cols"][$keys[$i]]["can_be_empty"] != "yes" || $_REQUEST[$keys[$i]] != "") {
                            if (!isRandomNum($_REQUEST[$keys[$i]])) {
                                $commit_flag = "no";
                                $commit_err .= $keys[$i] . ": not a correct number format<br>";
                            }
                            if ($_REQUEST[$keys[$i]] >= 2096) {
                                $commit_flag = "no";
                                $commit_err .= $keys[$i] . ": is greater or equal than the max value 2096<br>";
                            }
                        }
                        break;
                    default:
                        $commit_flag = "no";
                        $commit_err .= $keys[$i] . ": unknown field checking type (" . $dsc["cols"][$keys[$i]]["check"] . ").<br>";
                        break;
                }
            }
        }
        if (isset($dsc["max_item"]) && $current_num_items >= $dsc["max_item"]) {
            $commit_flag = "no";
            $commit_err = "Max number of items reached!";
        }
        if (isset($dsc["check_unique"])) {
            $nbr_unique_check = sizeof($dsc["check_unique"]);
            $where_clause = "";
            for ($i = 0; $i < $nbr_unique_check; $i++) {
                if ($i != 0) {
                    $where_clause .= " AND ";
                }
                if (isset($dsc["cols"][$dsc["check_unique"][$i]]["happen_domain"])) {
                    $where_clause .= $dsc["check_unique"][$i] . "='" . $_REQUEST[$dsc["check_unique"][$i]] . $dsc["cols"][$dsc["check_unique"][$i]]["happen_domain"] . "' ";
                } else {
                    $where_clause .= $dsc["check_unique"][$i] . "='" . $_REQUEST[$dsc["check_unique"][$i]] . "' ";
                }
            }
            if (!isset($dsc["check_unique_use_where_list"]) || $dsc["check_unique_use_where_list"] == "yes") {
                $nbr_where_list_fld = sizeof($dsc["where_list"]);
                $where_list_keys_fld = array_keys($dsc["where_list"]);
                for ($i = 0; $i < $nbr_where_list_fld; $i++) {
                    $where_clause .= " AND " . $where_list_keys_fld[$i] . "='" . $dsc["where_list"][$where_list_keys_fld[$i]] . "'";
                }
            }
            $q = "SELECT * FROM " . $dsc["table_name"] . " WHERE {$where_clause} ";
            $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) {
                $commit_flag = "no";
                $commit_err = $dsc["check_unique_msg"];
            }
        }
        // Build the request
        $fld_names = "";
        $values = "";
        $added_one = "no";
        for ($i = 0; $i < $nbr_fld; $i++) {
            switch ($dsc["cols"][$keys[$i]]["type"]) {
                case "password":
                    if ($added_one == "yes") {
                        $fld_names .= ",";
                        $values .= ",";
                    }
                    $fld_names .= $keys[$i];
                    if (isset($dsc["cols"][$keys[$i]]["empty_makes_sql_null"]) && $dsc["cols"][$keys[$i]]["empty_makes_sql_null"] == "yes" && $_REQUEST[$keys[$i]] == "") {
                        $values .= "NULL";
                    } else {
                        if (isset($dsc["cols"][$keys[$i]]["empty_makes_default"]) && $dsc["cols"][$keys[$i]]["empty_makes_default"] == "yes" && $_REQUEST[$keys[$i]] == "") {
                            $values .= "'default'";
                        } else {
                            if (isset($dsc["cols"][$keys[$i]]["happen_domain"])) {
                                $values .= "'" . addslashes($_REQUEST[$keys[$i]]) . $dsc["cols"][$keys[$i]]["happen_domain"] . "'";
                            } else {
                                $values .= "'" . addslashes($_REQUEST[$keys[$i]]) . "'";
                            }
                            // if the crypt field is set, then we use this as the SQL field to populate the crypted password into
                            if (isset($dsc["cols"][$keys[$i]]["cryptfield"])) {
                                if ($added_one == "yes") {
                                    $fld_names .= ",";
                                    $values .= ",";
                                }
                                $fld_names .= $dsc["cols"][$keys[$i]]["cryptfield"];
                                $values .= "'" . crypt($_REQUEST[$keys[$i]], dtc_makesalt()) . "'";
                            }
                        }
                    }
                    $added_one = "yes";
                    break;
                case "text":
                case "textarea":
                    if ($added_one == "yes") {
                        $fld_names .= ",";
                        $values .= ",";
                    }
                    $fld_names .= $keys[$i];
                    if (isset($dsc["cols"][$keys[$i]]["empty_makes_sql_null"]) && $dsc["cols"][$keys[$i]]["empty_makes_sql_null"] == "yes" && $_REQUEST[$keys[$i]] == "") {
                        $values .= "NULL";
                    } else {
                        if (isset($dsc["cols"][$keys[$i]]["empty_makes_default"]) && $dsc["cols"][$keys[$i]]["empty_makes_default"] == "yes" && $_REQUEST[$keys[$i]] == "") {
                            $values .= "'default'";
                        } else {
                            if (isset($dsc["cols"][$keys[$i]]["happen_domain"])) {
                                $values .= "'" . addslashes($_REQUEST[$keys[$i]]) . $dsc["cols"][$keys[$i]]["happen_domain"] . "'";
                            } else {
                                $values .= "'" . addslashes($_REQUEST[$keys[$i]]) . "'";
                            }
                        }
                    }
                    $added_one = "yes";
                    break;
                case "checkbox":
                    if ($added_one == "yes") {
                        $fld_names .= ",";
                        $values .= ",";
                    }
                    $added_one = "yes";
                    $fld_names .= $keys[$i];
                    if (isset($_REQUEST[$keys[$i]])) {
                        $values .= "'" . $dsc["cols"][$keys[$i]]["values"][0] . "'";
                    } else {
                        $values .= "'" . $dsc["cols"][$keys[$i]]["values"][1] . "'";
                    }
                    break;
                case "popup":
                case "radio":
                    if ($added_one == "yes") {
                        $fld_names .= ",";
                        $values .= ",";
                    }
                    $fld_names .= $keys[$i];
                    $values .= "'" . addslashes($_REQUEST[$keys[$i]]) . "'";
                    $added_one = "yes";
                    break;
            }
        }
        if ($commit_flag == "yes") {
            $q = "INSERT INTO " . $dsc["table_name"] . " ({$added_insert_names} {$fld_names}) VALUES ({$added_insert_values} {$values});";
            $success = "yes";
            $r = mysql_query($q) or $success = "no";
            if ($success == "yes") {
                $insert_id = mysql_insert_id();
                if (isset($dsc["create_item_callback"])) {
                    $out .= $dsc["create_item_callback"]($insert_id);
                }
            } else {
                $out .= "<font color=\"red\">Cannot query {$q} in " . __FILE__ . " line " . __LINE__ . " sql said: " . mysql_error() . "</font>";
            }
        } else {
            $out .= "<font color=\"red\">Could not commit the changes because of an error in field format: <br>{$commit_err}</font><br>";
        }
    } else {
        if (isset($_REQUEST["action"]) && $_REQUEST["action"] == $dsc["action"] . "_save_item") {
            // Todo: do the fields checkings
            $commit_flag = "yes";
            $commit_err = "";
            for ($i = 0; $i < $nbr_fld; $i++) {
                switch ($dsc["cols"][$keys[$i]]["type"]) {
                    case "checkbox":
                        break;
                    case "popup":
                    case "radio":
                    case "checkbox":
                        $nbr_choices = sizeof($dsc["cols"][$keys[$i]]["values"]);
                        $is_one_of_them = "no";
                        for ($j = 0; $j < $nbr_choices; $j++) {
                            if ($dsc["cols"][$keys[$i]]["values"][$j] == $_REQUEST[$keys[$i]]) {
                                $is_one_of_them = "yes";
                            }
                        }
                        if ($is_one_of_them == "no") {
                            $commit_flag = "no";
                            $commit_err = "the variable " . $keys[$i] . " is not one of the allowed values<br>";
                        }
                        break;
                    default:
                        break;
                }
                if (isset($dsc["cols"][$keys[$i]]["check"]) && (!isset($dsc["cols"][$keys[$i]]["disable_edit"]) || $dsc["cols"][$keys[$i]]["disable_edit"] != "yes")) {
                    switch ($dsc["cols"][$keys[$i]]["check"]) {
                        case "subdomain":
                            if (!checkSubdomainFormat($_REQUEST[$keys[$i]])) {
                                if (!isset($dsc["cols"][$keys[$i]]["can_be_empty"]) || $dsc["cols"][$keys[$i]]["can_be_empty"] != "yes" || $_REQUEST[$keys[$i]] != "") {
                                    $commit_flag = "no";
                                    $commit_err .= $keys[$i] . ": not a subdomain<br>";
                                }
                            }
                            break;
                        case "subdomain_or_ip":
                            if (!checkSubdomainFormat($_REQUEST[$keys[$i]]) && !isIP($_REQUEST[$keys[$i]])) {
                                if (!isset($dsc["cols"][$keys[$i]]["can_be_empty"]) || $dsc["cols"][$keys[$i]]["can_be_empty"] != "yes" || $_REQUEST[$keys[$i]] != "") {
                                    $commit_flag = "no";
                                    $commit_err .= $keys[$i] . ": not a subdomain or IP addresse<br>";
                                }
                            }
                            break;
                        case "ip6":
                            if (!isIP6($_REQUEST[$keys[$i]])) {
                                if (!isset($dsc["cols"][$keys[$i]]["can_be_empty"]) || $dsc["cols"][$keys[$i]]["can_be_empty"] != "yes" || $_REQUEST[$keys[$i]] != "") {
                                    if (!isset($dsc["cols"][$keys[$i]]["empty_makes_default"]) || $dsc["cols"][$keys[$i]]["empty_makes_default"] != "yes" || $_REQUEST[$keys[$i]] != "default") {
                                        $commit_flag = "no";
                                        $commit_err .= $keys[$i] . ": not an IPv6 address<br>";
                                    }
                                }
                            }
                            break;
                        case "ip_addr":
                            if (!isIP($_REQUEST[$keys[$i]])) {
                                if (!isset($dsc["cols"][$keys[$i]]["can_be_empty"]) || $dsc["cols"][$keys[$i]]["can_be_empty"] != "yes" || $_REQUEST[$keys[$i]] != "") {
                                    $commit_flag = "no";
                                    $commit_err .= $keys[$i] . ": not an IP address<br>";
                                }
                            }
                            break;
                        case "domain_or_ip":
                            if (!isIP($_REQUEST[$keys[$i]]) && !isHostname($_REQUEST[$keys[$i]])) {
                                if (!isset($dsc["cols"][$keys[$i]]["can_be_empty"]) || $dsc["cols"][$keys[$i]]["can_be_empty"] != "yes" || $_REQUEST[$keys[$i]] != "") {
                                    $commit_flag = "no";
                                    $commit_err .= $keys[$i] . ": not a domain or IP addresse<br>";
                                }
                            }
                            break;
                        case "dtc_login":
                            if (!isFtpLogin($_REQUEST[$keys[$i]])) {
                                if (!isset($dsc["cols"][$keys[$i]]["can_be_empty"]) || $dsc["cols"][$keys[$i]]["can_be_empty"] != "yes" || $_REQUEST[$keys[$i]] != "") {
                                    $commit_flag = "no";
                                    $commit_err .= $keys[$i] . ": not a correct login format.<br>";
                                }
                            }
                            break;
                        case "dtc_login_or_email":
                            if (!isFtpLogin($_REQUEST[$keys[$i]]) && !isValidEmail($_REQUEST[$keys[$i]])) {
                                if (!isset($dsc["cols"][$keys[$i]]["can_be_empty"]) || $dsc["cols"][$keys[$i]]["can_be_empty"] != "yes" || $_REQUEST[$keys[$i]] != "") {
                                    $commit_flag = "no";
                                    $commit_err .= $keys[$i] . ": not a correct login format.<br>";
                                }
                            }
                            break;
                        case "mail_alias_group":
                            $mail_alias_group_raw = trim($_REQUEST[$keys[$i]], "\r\n");
                            $mail_alias_nocr = str_replace("\r", "", $mail_alias_group_raw);
                            $mail_alias_array = split("\n", $mail_alias_nocr);
                            for ($x = 0; $x < count($mail_alias_array); $x++) {
                                if (!isValidEmail($mail_alias_array[$x])) {
                                    $commit_flag = "no";
                                    $commit_err .= $mail_alias_array[$x] . ": not a valid email format.<br>";
                                }
                            }
                            break;
                        case "dtc_pass":
                            if (!isDTCPassword($_REQUEST[$keys[$i]])) {
                                if (!isset($dsc["cols"][$keys[$i]]["can_be_empty"]) || $dsc["cols"][$keys[$i]]["can_be_empty"] != "yes" || $_REQUEST[$keys[$i]] != "") {
                                    $commit_flag = "no";
                                    $commit_err .= $keys[$i] . ": not a correct password format<br>";
                                }
                            }
                            break;
                        case "email":
                            if (!isValidEmail($_REQUEST[$keys[$i]])) {
                                if (!isset($dsc["cols"][$keys[$i]]["can_be_empty"]) || $dsc["cols"][$keys[$i]]["can_be_empty"] != "yes" || $_REQUEST[$keys[$i]] != "") {
                                    $commit_flag = "no";
                                    $commit_err .= $keys[$i] . ": not a correct email format<br>";
                                }
                            }
                            break;
                        case "number":
                            if (!isRandomNum($_REQUEST[$keys[$i]])) {
                                if (!isset($dsc["cols"][$keys[$i]]["can_be_empty"]) || $dsc["cols"][$keys[$i]]["can_be_empty"] != "yes" || $_REQUEST[$keys[$i]] != "") {
                                    $commit_flag = "no";
                                    $commit_err .= $keys[$i] . ": not a correct number format<br>";
                                }
                            }
                            break;
                        case "max_value_2096":
                            if (!isset($dsc["cols"][$keys[$i]]["can_be_empty"]) || $dsc["cols"][$keys[$i]]["can_be_empty"] != "yes" || $_REQUEST[$keys[$i]] != "") {
                                if (!isRandomNum($_REQUEST[$keys[$i]])) {
                                    $commit_flag = "no";
                                    $commit_err .= $keys[$i] . ": not a correct number format<br>";
                                }
                                if ($_REQUEST[$keys[$i]] >= 2096) {
                                    $commit_flag = "no";
                                    $commit_err .= $keys[$i] . ": is greater or equal than the max value 2096<br>";
                                }
                            }
                            break;
                        default:
                            $commit_flag = "no";
                            $commit_err .= $keys[$i] . ": unknown field checking type (" . $dsc["cols"][$keys[$i]]["check"] . ").<br>";
                            break;
                    }
                }
            }
            // Build the request
            $added_one = "no";
            $reqs = "";
            for ($i = 0; $i < $nbr_fld; $i++) {
                switch ($dsc["cols"][$keys[$i]]["type"]) {
                    case "id":
                        $id_fldname = $keys[$i];
                        $id_fld_value = addslashes($_REQUEST[$keys[$i]]);
                        break;
                    case "readonly":
                        break;
                    case "text":
                    case "textarea":
                    case "password":
                        if (!isset($dsc["cols"][$keys[$i]]["disable_edit"]) || $dsc["cols"][$keys[$i]]["disable_edit"] != "yes") {
                            if ($added_one == "yes") {
                                $reqs .= ",";
                            }
                            if (isset($dsc["cols"][$keys[$i]]["happen_domain"])) {
                                $happen = $dsc["cols"][$keys[$i]]["happen_domain"];
                            } else {
                                $happen = "";
                            }
                            if (isset($dsc["cols"][$keys[$i]]["empty_makes_sql_null"]) && $dsc["cols"][$keys[$i]]["empty_makes_sql_null"] == "yes" && $_REQUEST[$keys[$i]] == "") {
                                $reqs .= $keys[$i] . "=NULL";
                            } else {
                                if (isset($dsc["cols"][$keys[$i]]["empty_makes_default"]) && $dsc["cols"][$keys[$i]]["empty_makes_default"] == "yes" && $_REQUEST[$keys[$i]] == "") {
                                    $reqs .= $keys[$i] . "='default'";
                                } else {
                                    $reqs .= $keys[$i] . "='" . addslashes($_REQUEST[$keys[$i]]) . $happen . "'";
                                    // if the crypt field is set, then we use this as the SQL field to populate the crypted password into
                                    if (isset($dsc["cols"][$keys[$i]]["cryptfield"])) {
                                        if ($added_one == "yes") {
                                            $reqs .= ", ";
                                        }
                                        $reqs .= " " . $dsc["cols"][$keys[$i]]["cryptfield"] . "='" . crypt($_REQUEST[$keys[$i]], dtc_makesalt()) . "' ";
                                    }
                                }
                            }
                            $added_one = "yes";
                        }
                        break;
                    case "popup":
                    case "radio":
                        if ($added_one == "yes") {
                            $reqs .= ",";
                        }
                        $reqs .= $keys[$i] . "='" . addslashes($_REQUEST[$keys[$i]]) . "'";
                        $added_one = "yes";
                        break;
                    case "checkbox":
                        if ($added_one == "yes") {
                            $reqs .= ",";
                        }
                        if (isset($_REQUEST[$keys[$i]])) {
                            $reqs .= $keys[$i] . "='" . $dsc["cols"][$keys[$i]]["values"][0] . "'";
                        } else {
                            $reqs .= $keys[$i] . "='" . $dsc["cols"][$keys[$i]]["values"][1] . "'";
                        }
                        break;
                    default:
                        die($dsc["cols"][$keys[$i]]["type"] . ": Not implemented yet line " . __LINE__ . " file " . __FILE__);
                        break;
                }
            }
            if ($commit_flag != "yes") {
                $out .= "<font color=\"red\">Could not commit the changes because of an error in field format: [todo: error desc]<br>{$commit_err}</font>";
            } else {
                if (!isset($id_fldname) || !isset($id_fld_value)) {
                    $out .= "<font color=\"red\">Could not commit the changes because the id is not set!</font>";
                } else {
                    $q = "UPDATE " . $dsc["table_name"] . " SET {$reqs} {$where} AND {$id_fldname}='{$id_fld_value}';";
                    $r = mysql_query($q) or $out .= "<font color=\"red\">Cannot query {$q} in " . __FILE__ . " line " . __LINE__ . " sql said: " . mysql_error() . "</font>";
                    if (isset($dsc["edit_item_callback"])) {
                        $dsc["edit_item_callback"]($id_fld_value);
                    }
                }
            }
        } else {
            if (isset($_REQUEST["action"]) && $_REQUEST["action"] == $dsc["action"] . "_delete_item") {
                for ($i = 0; $i < $nbr_fld; $i++) {
                    if ($dsc["cols"][$keys[$i]]["type"] == "id") {
                        $id_fldname = $keys[$i];
                        $id_fld_value = addslashes($_REQUEST[$keys[$i]]);
                    }
                }
                if (isset($id_fldname) && isset($id_fld_value)) {
                    if (isset($dsc["delete_item_callback"])) {
                        $dsc["delete_item_callback"]($id_fld_value);
                    }
                    $q = "DELETE FROM " . $dsc["table_name"] . " {$where} AND {$id_fldname}='" . $id_fld_value . "';";
                    $r = mysql_query($q) or $out .= "<font color=\"red\">Cannot query {$q} in " . __FILE__ . " line " . __LINE__ . " sql said: " . mysql_error() . "</font>";
                } else {
                    $out .= "<font color=\"red\">Could not commit the deletion because the id field could not be found.</font>";
                }
            }
        }
    }
    // We have to query it again, in case an insert or a delete has occured!
    $q = "SELECT " . $dsc["id_fld"] . "," . $dsc["list_fld_show"] . " FROM " . $dsc["table_name"] . " {$where} {$order_by};";
    $r_item_list = mysql_query($q) or die("Cannot query {$q} in " . __FILE__ . " line " . __LINE__ . " sql said: " . mysql_error());
    $current_num_items = mysql_num_rows($r_item_list);
    if (isset($dsc["max_item"])) {
        if ($current_num_items >= $dsc["max_item"]) {
            $out .= "<font color=\"red\">";
        }
        $out .= $dsc["num_item_txt"] . $current_num_items . "/" . $dsc["max_item"];
        if ($current_num_items >= $dsc["max_item"]) {
            $out .= "</font>";
        }
        $out .= "<br><br>";
    }
    // First display a list of items
    for ($i = 0; $i < $current_num_items; $i++) {
        $a = mysql_fetch_array($r_item_list);
        if ($i != 0) {
            $out .= " - ";
        }
        if (isset($_REQUEST["subaction"]) && $_REQUEST["subaction"] == $dsc["action"] . "_edit_item" && $_REQUEST["item"] == $a[$dsc["id_fld"]]) {
            $out .= $a[$dsc["list_fld_show"]];
        } else {
            $out .= "<a href=\"{$fw_link}&subaction=" . $dsc["action"] . "_edit_item&item=" . $a[$dsc["id_fld"]] . "\">" . $a[$dsc["list_fld_show"]] . "</a>";
        }
    }
    $out .= "<br><br>";
    // Creation of new items
    if (!isset($_REQUEST["subaction"]) || $_REQUEST["subaction"] != $dsc["action"] . "_edit_item") {
        $out .= $dsc["new_item_link"] . "<br><br>";
        $out .= "<h3>" . $dsc["new_item_title"] . "</h3><br>";
        if (isset($dsc["max_item"]) && $current_num_items >= $dsc["max_item"]) {
            $out .= "<font color=\"red\">" . _("Maximum number reached") . "!</font><br>";
        } else {
            $out .= "<form name=\"" . $dsc["action"] . "_new_item_frm\" action=\"" . $_SERVER["PHP_SELF"] . "\">{$fw}\n\t\t\t\t<input type=\"hidden\" name=\"action\" value=\"" . $dsc["action"] . "_new_item\">" . dtcFormTableAttrs();
            for ($i = 0; $i < $nbr_fld; $i++) {
                if (isset($dsc["cols"][$keys[$i]]["help"])) {
                    $help = $dsc["cols"][$keys[$i]]["help"];
                } else {
                    $help = "";
                }
                switch ($dsc["cols"][$keys[$i]]["type"]) {
                    case "id":
                        $out .= "<input type=\"hidden\" name=\"" . $keys[$i] . "\" value=\"\">";
                        break;
                    case "password":
                        $genpass = autoGeneratePassButton($dsc["action"] . "_new_item_frm", $keys[$i]);
                        $ctrl = "<input type=\"password\" name=\"" . $keys[$i] . "\" value=\"\">{$genpass}";
                        $out .= dtcFormLineDraw($dsc["cols"][$keys[$i]]["legend"], $ctrl, $i % 2, $help);
                        break;
                    case "text":
                    case "readonly":
                        if (isset($dsc["cols"][$keys[$i]]["hide_create"]) && $dsc["cols"][$keys[$i]]["hide_create"] == "yes") {
                            break;
                        }
                        if (isset($dsc["cols"][$keys[$i]]["happen_domain"])) {
                            $happen = $dsc["cols"][$keys[$i]]["happen_domain"];
                        } else {
                            $happen = "";
                        }
                        if (isset($dsc["cols"][$keys[$i]]["happen"])) {
                            $happen .= $dsc["cols"][$keys[$i]]["happen"];
                        }
                        if (isset($dsc["cols"][$keys[$i]]["default"])) {
                            $ctrl_value = $dsc["cols"][$keys[$i]]["default"];
                        } else {
                            $ctrl_value = "";
                        }
                        if ($dsc["cols"][$keys[$i]]["type"] == "readonly") {
                            $ctrl = "<input type=\"text\" name=\"" . $keys[$i] . "\" value=\"{$ctrl_value}\" READONLY>{$happen}";
                        } else {
                            $ctrl = "<input type=\"text\" name=\"" . $keys[$i] . "\" value=\"{$ctrl_value}\">{$happen}";
                        }
                        $out .= dtcFormLineDraw($dsc["cols"][$keys[$i]]["legend"], $ctrl, $i % 2, $help);
                        break;
                    case "textarea":
                        if (isset($dsc["cols"][$keys[$i]]["cols"])) {
                            $ctrl_cols = " cols=\"" . $dsc["cols"][$keys[$i]]["cols"] . "\" ";
                        } else {
                            $ctrl_cols = "";
                        }
                        if (isset($dsc["cols"][$keys[$i]]["rows"])) {
                            $ctrl_rows = " rows=\"" . $dsc["cols"][$keys[$i]]["rows"] . "\" ";
                        } else {
                            $ctrl_rows = "";
                        }
                        $ctrl = "<textarea {$ctrl_cols} {$ctrl_rows} name=\"" . $keys[$i] . "\"></textarea>";
                        $out .= dtcFormLineDraw($dsc["cols"][$keys[$i]]["legend"], $ctrl, $i % 2, $help);
                        break;
                    case "radio":
                        $nbr_choices = sizeof($dsc["cols"][$keys[$i]]["values"]);
                        $ctrl = "";
                        for ($x = 0; $x < $nbr_choices; $x++) {
                            if (isset($dsc["cols"][$keys[$i]]["default"])) {
                                if ($dsc["cols"][$keys[$i]]["values"][$x] == $dsc["cols"][$keys[$i]]["default"]) {
                                    $selected = " checked ";
                                } else {
                                    $selected = "";
                                }
                            } else {
                                if ($x == 0) {
                                    $selected = " checked ";
                                } else {
                                    $selected = "";
                                }
                            }
                            if (isset($dsc["cols"][$keys[$i]]["display_replace"][$x])) {
                                $display_val = $dsc["cols"][$keys[$i]]["display_replace"][$x];
                            } else {
                                $display_val = $dsc["cols"][$keys[$i]]["values"][$x];
                            }
                            $ctrl .= "<input type=\"radio\" name=\"" . $keys[$i] . "\" value=\"" . $dsc["cols"][$keys[$i]]["values"][$x] . "\" {$selected}> ";
                            $ctrl .= $display_val;
                        }
                        $out .= dtcFormLineDraw($dsc["cols"][$keys[$i]]["legend"], $ctrl, $i % 2, $help);
                        break;
                    case "checkbox":
                        if (!isset($dsc["cols"][$keys[$i]]["default"])) {
                            $checked = " checked ";
                        } else {
                            $checked = " ";
                        }
                        $ctrl = "<input type=\"checkbox\" name=\"" . $keys[$i] . "\" value=\"yes\" {$checked}>";
                        $out .= dtcFormLineDraw($dsc["cols"][$keys[$i]]["legend"], $ctrl, $i % 2, $help);
                        break;
                    case "popup":
                        $nbr_choices = sizeof($dsc["cols"][$keys[$i]]["values"]);
                        $ctrl = "<select name=\"" . $keys[$i] . "\">";
                        for ($x = 0; $x < $nbr_choices; $x++) {
                            $selected = "";
                            if (isset($dsc["cols"][$keys[$i]]["default"])) {
                                if ($dsc["cols"][$keys[$i]]["values"][$x] == $dsc["cols"][$keys[$i]]["default"]) {
                                    $selected = " selected ";
                                } else {
                                    $selected = "";
                                }
                            }
                            if (isset($dsc["cols"][$keys[$i]]["display_replace"][$x])) {
                                $display_val = $dsc["cols"][$keys[$i]]["display_replace"][$x];
                            } else {
                                $display_val = $dsc["cols"][$keys[$i]]["values"][$x];
                            }
                            $ctrl .= " <option value=\"" . $dsc["cols"][$keys[$i]]["values"][$x] . "\" {$selected}>{$display_val}</option>";
                        }
                        $out .= dtcFormLineDraw($dsc["cols"][$keys[$i]]["legend"], $ctrl, $i % 2, $help);
                        break;
                    default:
                        $ctrl = "Not implemented yet!!!";
                        $out .= dtcFormLineDraw($dsc["cols"][$keys[$i]]["legend"], $ctrl, $i % 2, $help);
                        break;
                }
            }
            $out .= dtcFromOkDraw();
            $out .= "</table></form>";
        }
        // Edition of existing items
    } else {
        $out .= "<a href=\"{$fw_link}&subaction=" . $dsc["action"] . "_new_item\">" . $dsc["new_item_link"] . "</a><br><br>";
        $out .= "<h3>" . $dsc["edit_item_title"] . "</h3><br>";
        $q = "SELECT * FROM " . $dsc["table_name"] . " {$where} AND " . $dsc["id_fld"] . "='" . addslashes($_REQUEST["item"]) . "';";
        $r = mysql_query($q) or die("Cannot query {$q} in " . __FILE__ . " line " . __LINE__ . " sql said: " . mysql_error());
        $n = mysql_num_rows($r);
        if ($n == 1) {
            $a = mysql_fetch_array($r);
            $out .= "<form name=\"" . $dsc["action"] . "_save_item_frm\" action=\"" . $_SERVER["PHP_SELF"] . "\">{$fw}";
            $out .= "<input type=\"hidden\" name=\"action\" value=\"" . $dsc["action"] . "_save_item\">";
            $out .= "<input type=\"hidden\" name=\"subaction\" value=\"" . $dsc["action"] . "_edit_item\">";
            $out .= "<input type=\"hidden\" name=\"item\" value=\"" . $a[$dsc["id_fld"]] . "\">";
            $out .= dtcFormTableAttrs();
            for ($j = 0; $j < $nbr_fld; $j++) {
                $the_fld = $dsc["cols"][$keys[$j]];
                if (isset($dsc["cols"][$keys[$j]]["help"])) {
                    $help = $dsc["cols"][$keys[$j]]["help"];
                } else {
                    $help = "";
                }
                switch ($the_fld["type"]) {
                    case "id":
                        $out .= "<input type=\"hidden\" name=\"" . $keys[$j] . "\" value=\"" . $a[$keys[$j]] . "\">";
                        $id_fldname = $keys[$j];
                        $id_fld_value = $a[$keys[$j]];
                        break;
                    case "textarea":
                        if (isset($dsc["cols"][$keys[$j]]["cols"])) {
                            $ctrl_cols = " cols=\"" . $dsc["cols"][$keys[$j]]["cols"] . "\" ";
                        } else {
                            $ctrl_cols = "";
                        }
                        if (isset($dsc["cols"][$keys[$j]]["rows"])) {
                            $ctrl_rows = " rows=\"" . $dsc["cols"][$keys[$j]]["rows"] . "\" ";
                        } else {
                            $ctrl_rows = "";
                        }
                        $ctrl = "<textarea {$ctrl_cols} {$ctrl_rows} name=\"" . $keys[$j] . "\">" . stripslashes($a[$keys[$j]]) . "</textarea>";
                        $out .= dtcFormLineDraw($dsc["cols"][$keys[$j]]["legend"], $ctrl, $j % 2, $help);
                        break;
                    case "password":
                    case "text":
                    case "readonly":
                        if (isset($dsc["cols"][$keys[$j]]["disable_edit"]) && $dsc["cols"][$keys[$j]]["disable_edit"] == "yes") {
                            $disabled = " disabled ";
                        } else {
                            $disabled = " ";
                        }
                        if (isset($dsc["cols"][$keys[$j]]["size"])) {
                            $size = " size=\"" . $dsc["cols"][$keys[$j]]["size"] . "\" ";
                        } else {
                            $size = "";
                        }
                        if (isset($dsc["cols"][$keys[$j]]["happen_domain"]) && preg_match("/" . $dsc["cols"][$keys[$j]]["happen_domain"] . "\$/", $a[$keys[$j]])) {
                            $input_disp_value = substr($a[$keys[$j]], 0, strlen($a[$keys[$j]]) - strlen($dsc["cols"][$keys[$j]]["happen_domain"]));
                            $happen = $dsc["cols"][$keys[$j]]["happen_domain"];
                        } else {
                            if ($dsc["cols"][$keys[$j]]["type"] != "readonly") {
                                $input_disp_value = $a[$keys[$j]];
                            }
                            $happen = "";
                        }
                        if (isset($dsc["cols"][$keys[$j]]["happen"])) {
                            $happen .= $dsc["cols"][$keys[$j]]["happen"];
                        }
                        if ($the_fld["type"] == "password") {
                            $genpass = autoGeneratePassButton($dsc["action"] . "_save_item_frm", $keys[$j]);
                            $input_disp_type = "password";
                        } else {
                            $genpass = "";
                            $input_disp_type = "text";
                        }
                        // Do this only for readonly
                        if ($dsc["cols"][$keys[$j]]["type"] == "readonly") {
                            $disabled = " READONLY";
                            isset($dsc["cols"][$keys[$j]]["default"]) ? $input_disp_value = $dsc["cols"][$keys[$j]]["default"] : ($input_disp_value = '');
                            isset($dsc["cols"][$keys[$j]]["happen"]) ? $happen = $dsc["cols"][$keys[$j]]["happen"] : ($happen = '');
                        }
                        if (isset($dsc["cols"][$keys[$j]]["callback"])) {
                            $retArray = $dsc["cols"][$keys[$j]]["callback"]($id_fld_value);
                            $input_disp_value = $retArray["value"];
                            $happen = $retArray["happen"];
                        }
                        $ctrl = "<input type=\"{$input_disp_type}\" {$size} name=\"" . $keys[$j] . "\" value=\"" . stripslashes($input_disp_value) . "\" {$disabled}>{$genpass}{$happen}";
                        $out .= dtcFormLineDraw($dsc["cols"][$keys[$j]]["legend"], $ctrl, $j % 2, $help);
                        break;
                    case "radio":
                        $nbr_choices = sizeof($dsc["cols"][$keys[$j]]["values"]);
                        $ctrl = "";
                        for ($x = 0; $x < $nbr_choices; $x++) {
                            if ($dsc["cols"][$keys[$j]]["values"][$x] == $a[$keys[$j]]) {
                                $selected = " checked ";
                            } else {
                                $selected = "";
                            }
                            $ctrl .= " <input type=\"radio\" name=\"" . $keys[$j] . "\" value=\"" . $dsc["cols"][$keys[$j]]["values"][$x] . "\" {$selected}> ";
                            $ctrl .= $dsc["cols"][$keys[$j]]["values"][$x];
                        }
                        $out .= dtcFormLineDraw($dsc["cols"][$keys[$j]]["legend"], $ctrl, $j % 2, $help);
                        break;
                    case "checkbox":
                        if ($dsc["cols"][$keys[$j]]["values"][0] == $a[$keys[$j]]) {
                            $selected = " checked ";
                        } else {
                            $selected = " ";
                        }
                        $ctrl = "<input type=\"checkbox\" name=\"" . $keys[$j] . "\" value=\"yes\" " . $selected . ">";
                        $out .= dtcFormLineDraw($dsc["cols"][$keys[$j]]["legend"], $ctrl, $j % 2, $help);
                        break;
                    case "popup":
                        $nbr_choices = sizeof($dsc["cols"][$keys[$j]]["values"]);
                        $ctrl = "<select name=\"" . $keys[$j] . "\">";
                        for ($x = 0; $x < $nbr_choices; $x++) {
                            if ($dsc["cols"][$keys[$j]]["values"][$x] == $a[$keys[$j]]) {
                                $selected = " selected ";
                            } else {
                                $selected = "";
                            }
                            if (isset($dsc["cols"][$keys[$j]]["display_replace"][$x])) {
                                $display_val = $dsc["cols"][$keys[$j]]["display_replace"][$x];
                            } else {
                                $display_val = $dsc["cols"][$keys[$j]]["values"][$x];
                            }
                            $ctrl .= " <option value=\"" . $dsc["cols"][$keys[$j]]["values"][$x] . "\" {$selected}>{$display_val}</option>";
                        }
                        $out .= dtcFormLineDraw($dsc["cols"][$keys[$j]]["legend"], $ctrl, $j % 2, $help);
                        break;
                    default:
                        $ctrl = "Not implemented yet!!!";
                        $out .= dtcFormLineDraw($dsc["cols"][$keys[$j]]["legend"], $ctrl, $j % 2, $help);
                        break;
                }
            }
            $delete_button = "<form action=\"" . $_SERVER["PHP_SELF"] . "\">{$fw}\n\t\t\t<input type=\"hidden\" name=\"action\" value=\"" . $dsc["action"] . "_delete_item" . "\">\n\t\t\t<input type=\"hidden\" name=\"{$id_fldname}\" value=\"{$id_fld_value}\">\n\t\t\t" . dtcDeleteButton() . "</form>";
            $out .= "<tr><td>&nbsp;</td><td><table cellspacing=\"0\" cellpadding=\"0\" border=\"0\">\n\t\t\t<tr><td>" . dtcApplyButton() . "</form></td><td>{$delete_button}</td></tr></table></td></tr>";
            $out .= "</table>";
        } else {
            $out .= "No item by this number!";
        }
    }
    return $out;
}
Exemple #9
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='******'"></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='******' 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 = '******' 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 = '******' 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;
}
Exemple #10
0
            $q = "SELECT * FROM {$pro_mysql_admin_table},{$pro_mysql_client_table} WHERE {$pro_mysql_client_table}.email='" . $_REQUEST["adm_lost_email"] . "';";
            $r = mysql_query($q) or die("Cannot query {$q} line " . __LINE__ . " file " . __FILE__ . " sql said: " . mysql_error());
            $n = mysql_num_rows($r);
            $recover_txt .= "<br><br>" . _("The following logins have been found to be related to this email address. Click on any of them to send your password to the email address:") . "<br><br>";
            for ($i = 0; $i < $n; $i++) {
                $a = mysql_fetch_array($r);
                $login = $a["adm_login"];
                if ($i != 0) {
                    $recover_txt .= " - ";
                }
                $recover_txt .= "<a href=\"" . $_SERVER["PHP_SELF"] . "?action=recover_lost_pass&adm_lost_login={$login}\">{$login}</a>";
            }
        }
    }
} else {
    $recover_l_txt = dtcFormTableAttrs();
    $recover_l_txt .= "<form action=\"" . $_SERVER["PHP_SELF"] . "\">\n<input type=\"hidden\" name=\"action\" value=\"recover_lost_pass\">";
    $recover_l_txt .= dtcFormLineDraw(_("Login:"******"<input type=\"text\" name=\"adm_lost_login\">", 0);
    $recover_l_txt .= dtcFromOkDraw() . "</table></form>";
    $recover_r_txt = dtcFormTableAttrs();
    $recover_r_txt .= "<form action=\"" . $_SERVER["PHP_SELF"] . "\">\n<input type=\"hidden\" name=\"action\" value=\"recover_lost_pass\">";
    $recover_r_txt .= dtcFormLineDraw(_("Email:"), "<input type=\"text\" name=\"adm_lost_email\">", 0);
    $recover_r_txt .= dtcFromOkDraw() . "</table></form>";
    $recover_txt .= '<table cellpadding="8" border="0"><tr><td>' . $recover_l_txt . "</td><td>" . $recover_r_txt . "</td></table>";
}
$mypage = skin($conf_skin, $recover_txt, _("Client panel:") . " " . _("Recover password"));
if (function_exists("skin_NewAccountPage")) {
    skin_NewAccountPage($mypage);
} else {
    echo anotherPage("Client:", "", "", makePreloads(), $anotherTopBanner, "", $mypage, anotherFooter(""));
}
Exemple #11
0
function drawEditAdmin($admin)
{
    global $pro_mysql_vps_server_table;
    global $pro_mysql_vps_ip_table;
    global $pro_mysql_vps_table;
    global $pro_mysql_product_table;
    global $pro_mysql_dedicated_table;
    global $cc_code_popup;
    global $adm_login;
    global $adm_pass;
    global $rub;
    global $conf_hide_password;
    $info = $admin["info"];
    if (isset($admin["data"])) {
        $data = $admin["data"];
    }
    $adm_cur_pass = $info["adm_pass"];
    $adm_path = $info["path"];
    $adm_max_email = $info["max_email"];
    $adm_max_ftp = $info["max_ftp"];
    $adm_quota = $info["quota"];
    $bandwidth_per_month_mb = $info["bandwidth_per_month_mb"];
    $adm_id_client = $info["id_client"];
    $expire = $info["expire"];
    $prod_id = $info["prod_id"];
    $allow_add_domain = $info["allow_add_domain"];
    $max_domain = $info["max_domain"];
    $restricted_ftp_path = $info["restricted_ftp_path"];
    $allow_dns_and_mx_change = $info["allow_dns_and_mx_change"];
    $allow_mailing_list_edit = $info["allow_mailing_list_edit"];
    $allow_subdomain_edit = $info["allow_subdomain_edit"];
    $resseller_flag = $info["resseller_flag"];
    $ssh_login_flag = $info["ssh_login_flag"];
    $ftp_login_flag = $info["ftp_login_flag"];
    $pkg_install_flag = $info["pkg_install_flag"];
    if ($resseller_flag == "yes") {
        $resflag_yes = " checked='checked' ";
        $resflag_no = "";
    } else {
        $resflag_yes = " ";
        $resflag_no = " checked='checked' ";
    }
    $res_selector = "<input type=\"radio\" name=\"resseller_flag\" value=\"yes\"{$resflag_yes}> " . _("Yes") . "\n\t<input type=\"radio\" name=\"resseller_flag\" value=\"no\"{$resflag_no}> " . _("No") . "</div>";
    if ($ssh_login_flag == "yes") {
        $sshlogin_yes = " checked='checked' ";
        $sshlogin_no = "";
    } else {
        $sshlogin_yes = "";
        $sshlogin_no = " checked='checked' ";
    }
    $sshlog_selector = "<input type=\"radio\" name=\"ssh_login_flag\" value=\"yes\"{$sshlogin_yes}> " . _("Yes") . "\n\t<input type=\"radio\" name=\"ssh_login_flag\" value=\"no\"{$sshlogin_no}> " . _("No");
    if ($ftp_login_flag == "yes") {
        $ftplogin_yes = " checked='checked' ";
        $ftplogin_no = "";
    } else {
        $ftplogin_yes = "";
        $ftplogin_no = " checked='checked' ";
    }
    $ftplog_selector = "<input type=\"radio\" name=\"ftp_login_flag\" value=\"yes\"{$ftplogin_yes}> " . _("Yes") . "\n\t<input type=\"radio\" name=\"ftp_login_flag\" value=\"no\"{$ftplogin_no}> " . _("No");
    if ($pkg_install_flag == "yes") {
        $pkg_install_yes = " checked='checked' ";
        $pkg_install_no = "";
    } else {
        $pkg_install_yes = "";
        $pkg_install_no = " checked='checked' ";
    }
    $pkg_install_selector = "<input type=\"radio\" name=\"pkg_install_flag\" value=\"yes\"{$pkg_install_yes}> " . _("Yes") . "\n\t<input type=\"radio\" name=\"pkg_install_flag\" value=\"no\"{$pkg_install_no}> " . _("No");
    if ($allow_add_domain == "yes") {
        $adyes = "selected='selected'";
    } else {
        $adyes = "";
    }
    if ($allow_add_domain == "check") {
        $adcheck = "selected='selected'";
    } else {
        $adcheck = "";
    }
    if ($allow_add_domain == "no") {
        $adno = "selected='selected'";
    } else {
        $adno = "";
    }
    $aldom_popup = "<select class=\"dtcDatagrid_input_color\" name=\"allow_add_domain\">\n<option value=\"yes\" {$adyes}>" . _("Yes") . "</option>\n<option value=\"check\" {$adcheck}>" . _("Check") . "</option>\n<option value=\"no\" {$adno}>" . _("No") . "</option>\n</select>\n";
    // Restriction of FTP path selection
    if ($restricted_ftp_path == "yes") {
        $restricted_ftp_path_yes = " checked='checked' ";
        $restricted_ftp_path_no = "";
    } else {
        $restricted_ftp_path_yes = "";
        $restricted_ftp_path_no = " checked='checked' ";
    }
    $restricted_ftp_path_selector = "<input type=\"radio\" name=\"restricted_ftp_path\" value=\"yes\"{$restricted_ftp_path_yes}> " . _("Yes") . "\n<input type=\"radio\" name=\"restricted_ftp_path\" value=\"no\"{$restricted_ftp_path_no}> " . _("No");
    // Allowing change of DNS and MX
    if ($allow_dns_and_mx_change == "yes") {
        $allow_dns_and_mx_change_yes = " checked='checked' ";
        $allow_dns_and_mx_change_no = "";
    } else {
        $allow_dns_and_mx_change_yes = "";
        $allow_dns_and_mx_change_no = " checked='checked' ";
    }
    $allow_dns_and_mx_change_selector = "<input type=\"radio\" name=\"allow_dns_and_mx_change\" value=\"yes\"{$allow_dns_and_mx_change_yes}> " . _("Yes") . "\n<input type=\"radio\" name=\"allow_dns_and_mx_change\" value=\"no\"{$allow_dns_and_mx_change_no}> " . _("No");
    // Allow users to edit mailing lists
    if ($allow_mailing_list_edit == "yes") {
        $allow_mailing_list_edit_yes = " checked='checked' ";
        $allow_mailing_list_edit_no = "";
    } else {
        $allow_mailing_list_edit_yes = "";
        $allow_mailing_list_edit_no = " checked='checked' ";
    }
    $allow_mailing_list_edit_selector = "<input type=\"radio\" name=\"allow_mailing_list_edit\" value=\"yes\"{$allow_mailing_list_edit_yes}> " . _("Yes") . "\n<input type=\"radio\" name=\"allow_mailing_list_edit\" value=\"no\"{$allow_mailing_list_edit_no}> " . _("No");
    // Allow users to edit subdomains
    if ($allow_subdomain_edit == "yes") {
        $allow_subdomain_edit_yes = " checked='checked' ";
        $allow_subdomain_edit_no = "";
    } else {
        $allow_subdomain_edit_yes = "";
        $allow_subdomain_edit_no = " checked='checked' ";
    }
    $allow_subdomain_edit_selector = "<input type=\"radio\" name=\"allow_subdomain_edit\" value=\"yes\"{$allow_subdomain_edit_yes}> " . _("Yes") . "\n<input type=\"radio\" name=\"allow_subdomain_edit\" value=\"no\"{$allow_subdomain_edit_no}> " . _("No");
    // Generate the user configuration form
    $user_data = "\n<form name=\"admattrbfrm\" action=\"?\" methode=\"post\">\n<input type=\"hidden\" name=\"rub\" value=\"{$rub}\">\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=\"updateuserinfo\" value=\"Ok\">\n" . dtcFormTableAttrs();
    $genpass = autoGeneratePassButton("admattrbfrm", "changed_pass");
    if ($conf_hide_password == "yes") {
        $ctrl = "<input class=\"dtcDatagrid_input_color\" type=\"password\" name=\"changed_pass\" value=\"{$adm_cur_pass}\">{$genpass}";
    } else {
        $ctrl = "<input class=\"dtcDatagrid_input_color\" type=\"text\" name=\"changed_pass\" value=\"{$adm_cur_pass}\">{$genpass}";
    }
    $user_data .= dtcFormLineDraw(_("Password:"******"SELECT * FROM {$pro_mysql_product_table} WHERE (heb_type='shared' OR heb_type='ssl') AND renew_prod_id='0' ORDER BY id;";
    $r = mysql_query($q) or die("Cannot query {$q} line " . __LINE__ . " file " . __FILE__ . " sql said: " . mysql_error());
    $n = mysql_num_rows($r);
    $prodsid = "";
    $prodsid .= "<select class=\"dtcDatagrid_input_color\" name=\"heb_prod_id\"><option value=\"0\">" . _("No product") . "</option>";
    for ($i = 0; $i < $n; $i++) {
        $a = mysql_fetch_array($r);
        if ($a["id"] == $prod_id) {
            $prodsid_sel = " selected ";
        } else {
            $prodsid_sel = " ";
        }
        $prodsid .= "<option value=\"" . $a["id"] . "\"{$prodsid_sel}>" . $a["id"] . ": " . $a["name"] . "</option>";
    }
    $prodsid .= "</select>";
    $user_data .= dtcFormLineDraw(_("Path:"), "<input class=\"dtcDatagrid_input_alt_color\" type=\"text\" name=\"changed_path\" value=\"{$adm_path}\">", 0);
    $user_data .= dtcFormLineDraw(_("Client ID:"), "<input class=\"dtcDatagrid_input_color\" type=\"text\" name=\"changed_id_client\" value=\"{$adm_id_client}\"><a href=\"?rub=crm&id={$adm_id_client}\">" . _("client") . "</a>");
    $user_data .= dtcFormLineDraw(_("Disk quota (MB):"), "<input class=\"dtcDatagrid_input_alt_color\" type=\"text\" name=\"adm_quota\" value=\"{$adm_quota}\">", 0);
    $user_data .= dtcFormLineDraw(_("Allowed bandwidth per month (MB):"), "<input class=\"dtcDatagrid_input_color\" type=\"text\" name=\"bandwidth_per_month\" value=\"{$bandwidth_per_month_mb}\">");
    $user_data .= dtcFormLineDraw(_("Expiry date:"), "<input class=\"dtcDatagrid_input_alt_color\" type=\"text\" name=\"expire\" value=\"{$expire}\">", 0);
    $user_data .= dtcFormLineDraw(_("Product ID:"), $prodsid);
    $user_data .= dtcFormLineDraw(_("Number of databases:"), "<input class=\"dtcDatagrid_input_alt_color\" type=\"text\" name=\"nbrdb\" value=\"" . $info["nbrdb"] . "\">", 0);
    $user_data .= dtcFormLineDraw(_("Allow to add domains:"), $aldom_popup);
    $user_data .= dtcFormLineDraw(_("Max domain:"), "<input class=\"dtcDatagrid_input_alt_color\" type=\"text\" name=\"max_domain\" value=\"{$max_domain}\">", 0);
    $user_data .= dtcFormLineDraw(_("Grant sub-account addition rights (reseller):"), $res_selector);
    $user_data .= dtcFormLineDraw(_("Allow addition of SSH logins:"), $sshlog_selector, 0);
    $user_data .= dtcFormLineDraw(_("Allow addition of FTP logins:"), $ftplog_selector);
    $user_data .= dtcFormLineDraw(_("Restrict FTP to the html folder:"), $restricted_ftp_path_selector, 0);
    $user_data .= dtcFormLineDraw(_("Allow addition of mailing lists and mail groups:"), $allow_mailing_list_edit_selector);
    $user_data .= dtcFormLineDraw(_("Allow edition of DNS and MX:"), $allow_dns_and_mx_change_selector, 0);
    $user_data .= dtcFormLineDraw(_("Allow edition subdomains:"), $allow_subdomain_edit_selector);
    $user_data .= dtcFormLineDraw(_("Allow the use of the package installer:"), $pkg_install_selector, 0);
    $user_data .= dtcFromOkDraw() . "</table></form>";
    // Generate the admin tool configuration module
    // Deletion of domains :
    $url = "" . $_SERVER["PHP_SELF"] . "?delete_admin_user={$adm_login}&rub={$rub}";
    $confirmed_url = dtcJavascriptConfirmLink(_("Are your sure you want to delete this user? This will erase all his hosted domain names, files, and databases !!!"), $url);
    $domain_conf = "<a href=\"{$confirmed_url}\"><b>" . _("Delete the user") . "</b></a><br><br>";
    if (isset($data)) {
        $domain_conf .= "<h3>" . _("Delete a user domain:") . "</h3><br>";
        $nbr_domain = sizeof($data);
        for ($i = 0; $i < $nbr_domain; $i++) {
            $dom = $data[$i]["name"];
            if ($i != 0) {
                $domain_conf .= " - ";
            }
            $url = "?adm_login={$adm_login}&adm_pass={$adm_pass}&deluserdomain={$dom}&rub={$rub}";
            $js_url = dtcJavascriptConfirmLink(_("Are you sure you want to delete this domain name ? This will erase all hosted files for this domain!!!"), $url);
            $domain_conf .= "<a href=\"{$js_url}\">{$dom}</a>";
        }
        $domain_conf .= "</b><br><br>";
    }
    // Creation of domains :
    $domain_conf .= "<h3>" . _("Add a domain for this user:"******"</h3>";
    $domain_conf .= "<form action=\"?\"><table cellspacing=\"0\" cellpadding=\"0\" border=\"0\">\n<tr><td><input type=\"hidden\" name=\"adm_login\" value=\"{$adm_login}\">\n\t<input type=\"hidden\" name=\"rub\" value=\"{$rub}\">\n\t<input type=\"hidden\" name=\"adm_pass\" value=\"{$adm_pass}\">\n\t<input type=\"text\" name=\"newdomain_name\" value=\"\"></td>\n\t<td><div class=\"input_btn_container\" onMouseOver=\"this.className='input_btn_container-hover';\" onMouseOut=\"this.className='input_btn_container';\">\n <div class=\"input_btn_left\"></div>\n <div class=\"input_btn_mid\"><input class=\"input_btn\" type=\"submit\" name=\"newdomain\" value=\"Ok\"></div>\n <div class=\"input_btn_right\"></div>\n</div></td></tr></table>\n\t</form>";
    $domain_conf .= "<h3>" . _("Import a domain file for this user:"******"<h3></b>\n\t<form action=\"?\" enctype=\"multipart/form-data\" method=\"post\">\n\t<table cellspacing=\"0\" cellpadding=\"0\" border=\"0\">\n\t<tr><td><input type=\"hidden\" name=\"rub\" value=\"{$rub}\">\n\t<input type=\"hidden\" name=\"action\" value=\"import_domain\">\n\t<input type=\"hidden\" name=\"adm_login\" value=\"{$adm_login}\">\n\t<input type=\"hidden\" name=\"adm_pass\" value=\"{$adm_pass}\">\n\t<input type=\"hidden\" name=\"MAX_FILE_SIZE\" value=\"30000000\">\n\t<input type=\"file\" name=\"domain_import_file\" size=\"30\"></td>\n\t<td><div class=\"input_btn_container\" onMouseOver=\"this.className='input_btn_container-hover';\" onMouseOut=\"this.className='input_btn_container';\">\n <div class=\"input_btn_left\"></div>\n <div class=\"input_btn_mid\"><input class=\"input_btn\" type=\"submit\" value=\"" . _("Import") . "\"></div>\n <div class=\"input_btn_right\"></div>\n</div></td></tr></table></form>";
    // Deletion of VPS
    $q = "SELECT * FROM {$pro_mysql_vps_table} WHERE owner='{$adm_login}' ORDER BY vps_server_hostname,vps_xen_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 > 0) {
        $domain_conf .= "<h3>" . _("Delete one of the admin VPS: ") . "</h3><br>";
        for ($i = 0; $i < $n; $i++) {
            $a = mysql_fetch_array($r);
            if ($i > 0) {
                $domain_conf .= " - ";
            }
            $delete_vps_url = dtcJavascriptConfirmLink(_("Are you sure you want to delete this VPS? This will also delete the partitions!"), "?adm_login={$adm_login}&adm_pass={$adm_pass}&rub={$rub}&action=delete_a_vps&id=" . $a["id"]);
            $domain_conf .= "<a href=\"" . $delete_vps_url . "\"><b>" . $a["vps_server_hostname"] . ":" . $a["vps_xen_name"] . "</b></a>";
        }
        $domain_conf .= "<br><br>";
    }
    // Creation of VPS
    $q = "SELECT * 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);
    $num_prods_vps = $n;
    $vps_prods = "";
    for ($i = 0; $i < $n; $i++) {
        $a = mysql_fetch_array($r);
        $vps_prods .= "<option value=\"" . $a["id"] . "\">" . $a["name"] . "</option>";
    }
    $q = "SELECT * FROM {$pro_mysql_vps_ip_table} WHERE available='yes' ORDER BY vps_server_hostname,vps_xen_name;";
    $r = mysql_query($q) or die("Cannot query {$q} line " . __LINE__ . " file " . __FILE__ . " sql said: " . mysql_error());
    $n = mysql_num_rows($r);
    $vps_srvs = "";
    for ($i = 0; $i < $n; $i++) {
        $a = mysql_fetch_array($r);
        $vps_srvs .= "<option value=\"" . $a["ip_addr"] . "\">" . $a["vps_server_hostname"] . ":" . $a["vps_xen_name"] . " (" . $a["ip_addr"] . ")</option>";
    }
    if ($n > 0 && $num_prods_vps > 0) {
        $domain_conf .= "<h3>" . _("Add a VPS for this admin:") . "</h3>\n\t\t<form action=\"?\">\n\t\t<input type=\"hidden\" name=\"rub\" value=\"{$rub}\">\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=\"action\" value=\"add_vps_to_user\">\n\t\t<table border=\"0\">\n\t\t<tr><td style=\"text-align: right; white-space: nowrap;\">" . _("VPS Server hostname: ") . "</td>\n\t\t<td><select name=\"vps_server_ip\">{$vps_srvs}</select></td></tr>\n\t\t<tr><td style=\"text-align: right; white-space: nowrap;\">" . _("Product: ") . "</td>\n\t\t<td><select name=\"product_id\">{$vps_prods}</select></td></tr>\n\t\t<tr><td style=\"text-align: right; white-space: nowrap;\">" . _("Setup physical VPS (LVM): ") . "</td>\n\t\t<td><input type=\"radio\" name=\"physical_setup\" value=\"yes\">" . _("Yes") . "\n\t\t<input type=\"radio\" name=\"physical_setup\" value=\"no\" checked='checked'>" . _("No") . "</td></tr>\n\t\t<tr><td></td><td><div class=\"input_btn_container\" onMouseOver=\"this.className='input_btn_container-hover';\" onMouseOut=\"this.className='input_btn_container';\">\n <div class=\"input_btn_left\"></div>\n <div class=\"input_btn_mid\"><input class=\"input_btn\" type=\"submit\" value=\"Add VPS\"></div>\n <div class=\"input_btn_right\"></div>\n</div></td></tr></table></form>";
    } else {
        $domain_conf .= _("To add a VPS, you need to setup some free IPs VPS in the general config and setup some VPS products.");
    }
    // Deletion of dedicated
    $q = "SELECT * FROM {$pro_mysql_dedicated_table} WHERE owner='{$adm_login}';";
    $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) {
        $domain_conf .= "<br><br><h3>" . _("Delete one of the admin dedicated server:") . "</h3><br>";
        for ($i = 0; $i < $n; $i++) {
            $a = mysql_fetch_array($r);
            if ($i > 0) {
                $domain_conf .= " - ";
            }
            $domain_conf .= "<a href=\"?adm_login={$adm_login}&adm_pass={$adm_pass}&rub={$rub}&action=delete_a_dedicated&id=" . $a["id"] . "\"><b>" . $a["server_hostname"] . "</b></a>";
        }
    }
    // Creation of dedicated servers
    $q = "SELECT * 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);
    $num_prods_vps = $n;
    $server_prods = "";
    for ($i = 0; $i < $n; $i++) {
        $a = mysql_fetch_array($r);
        $server_prods .= "<option value=\"" . $a["id"] . "\">" . $a["name"] . "</option>";
    }
    $domain_conf .= "<br><br><h3>" . _("Add a dedicated server for this admin:") . "</h3>\n\t<form action=\"?\">\n\t<input type=\"hidden\" name=\"rub\" value=\"{$rub}\">\n\t<input type=\"hidden\" name=\"adm_login\" value=\"{$adm_login}\">\n\t<input type=\"hidden\" name=\"adm_pass\" value=\"{$adm_pass}\">\n\t<input type=\"hidden\" name=\"action\" value=\"add_dedicated_to_user\">\n\t<table border=\"0\">\n\t<tr><td style=\"text-align: right; white-space: nowrap;\">" . _("Product: ") . "</td>\n\t\t<td><select name=\"product_id\">{$server_prods}</select></td></tr>\n\t<tr><td style=\"text-align: right; white-space: nowrap;\">" . _("Hostname: ") . "</td>\n\t\t<td><input type=\"text\" name=\"server_hostname\" value=\"\"></td>\n\t<tr><td style=\"text-align: right; white-space: nowrap;\">" . _("Country: ") . "</td>\n\t\t<td><select name=\"country\">{$cc_code_popup}</select></td>\n\t<tr><td></td><td>" . dtcApplyButton() . "</td></tr></table></form>";
    $out = "<font size=\"-1\">\n<table>\n <tr>\n  <td>{$domain_conf}</td><td background=\"gfx/border_2.gif\">&nbsp;</td>\n  <td>{$user_data}</td>\n </tr>\n</table>\n</font>\n";
    return $out;
}
Exemple #12
0
function drawAdminTools_DomainDNS($admin, $eddomain)
{
    global $adm_login;
    global $adm_pass;
    global $addrlink;
    global $conf_generated_file_path;
    // The domain DNS configuration
    $domain_dns_mx_conf_form = "\n<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=\"edit_domain\" value=\"" . $eddomain["name"] . "\">\n<input type=\"hidden\" name=\"addrlink\" value=\"{$addrlink}\">\n<input type=\"hidden\" name=\"new_dns_and_mx_config\" value=\"Ok\">" . dtcFormTableAttrs() . dtcFormLineDraw(_("IP address of the primary DNS server:"), "<input type=\"text\" name=\"new_dns_1\" value=\"" . $eddomain["primary_dns"] . "\">");
    if ($eddomain["other_dns"] != "default") {
        $other_dns = explode("|", $eddomain["other_dns"]);
        $dns2 = $other_dns[0];
        $nbr_other_dns = sizeof($other_dns);
    } else {
        $dns2 = "default";
        $nbr_other_dns = 1;
    }
    $domain_dns_mx_conf_form .= dtcFormLineDraw(_("Other DNS servers:"), "<input type=\"text\" name=\"new_dns_2\" value=\"{$dns2}\">");
    $new_dns_num = 3;
    for ($z = 1; $z < $nbr_other_dns; $z++) {
        if ($z != 1) {
            $domain_dns_mx_conf_form .= "<tr><td></td>";
        }
        $domain_dns_mx_conf_form .= dtcFormLineDraw("", "<input type=\"text\" name=\"new_dns_{$new_dns_num}\" value=\"" . $other_dns[$z] . "\">");
        $new_dns_num += 1;
    }
    $domain_dns_mx_conf_form .= dtcFormLineDraw("", "<input type=\"text\" name=\"new_dns_{$new_dns_num}\" value=\"\">");
    //	$domain_dns_mx_conf_form .= "<tr><td></td><td><input type=\"text\" name=\"new_dns_$new_dns_num\" value=\"\"><br><br></td></tr>";
    // The domain MX configuration
    $domain_dns_mx_conf_form .= dtcFormLineDraw(_("Primary MX address:"), "<input type=\"text\" name=\"new_mx_1\" value=\"" . $eddomain["primary_mx"] . "\">");
    if ($eddomain["other_mx"] == "default" && $eddomain["primary_dns"] == "default") {
        $domain_dns_mx_conf_form .= dtcFormLineDraw(_("Other MX (backup) servers:"), "<input type=\"text\" name=\"new_mx_2\" value=\"\">");
    } else {
        $new_mx_num = 2;
        $other_mx = explode("|", $eddomain["other_mx"]);
        $nbr_other_mx = sizeof($other_mx);
        for ($z = 0; $z < $nbr_other_mx; $z++) {
            if ($z != 0) {
                $domain_dns_mx_conf_form .= dtcFormLineDraw("", "<input type=\"text\" name=\"new_mx_{$new_mx_num}\" value=\"" . $other_mx[$z] . "\">");
            } else {
                $domain_dns_mx_conf_form .= dtcFormLineDraw(_("Other MX (backup) servers:"), "<input type=\"text\" name=\"new_mx_{$new_mx_num}\" value=\"" . $other_mx[$z] . "\">");
            }
            $new_mx_num += 1;
        }
        $domain_dns_mx_conf_form .= dtcFormLineDraw("", "<input type=\"text\" name=\"new_mx_{$new_mx_num}\" value=\"\">");
    }
    $domain_dns_mx_conf_form .= dtcFormLineDraw(_("Domain root TXT record: "), "<input type=\"text\" name=\"txt_root_entry\" value=\"" . $eddomain["txt_root_entry"] . "\">");
    $domain_dns_mx_conf_form .= dtcFormLineDraw(_("Domain root TXT record2: "), "<input type=\"text\" name=\"txt_root_entry2\" value=\"" . $eddomain["txt_root_entry2"] . "\">");
    $domain_dns_mx_conf_form .= dtcFromOkDraw();
    $domain_dns_mx_conf_form .= "</form></table>";
    $zonefile_content = "";
    if ($eddomain["generate_flag"] == "yes") {
        $zonefile_content .= "<font color=\"#FF0000\">" . _("Zone file will be regenerated at next cron job.") . "</font><br>";
    }
    $handle = @fopen($conf_generated_file_path . "/zones/" . $eddomain["name"], "r");
    if ($handle) {
        while (!feof($handle)) {
            $lines[] = fgets($handle, 4096);
        }
        fclose($handle);
        $zonefile_content .= "<pre>";
        foreach ($lines as $line_num => $line) {
            $zonefile_content .= '<b>' . $line_num . '</b>: ' . htmlspecialchars($line);
        }
        $zonefile_content .= "</pre>";
    } else {
        $zonefile_content .= _("Could not load zonefile: permission denied or file not existant?");
    }
    return "<h3>" . _("Configure your domain name:") . "</h3><br><br>" . _("Take care ! Setting a wrong value\nin the following fields can lead to\nyour site services stopping (web or mail).<br>\nPutting something else than \"default\" in the DNS\nfields means that you want your site to be\nhosted elsewhere.<br>\nThe MX parameter determines the address of the mail server\nthat receives all your mail when somebody sends\nyour a message. The value \"default\" means that\nyou want to use the current server.") . "<br>\n\t{$domain_dns_mx_conf_form}<br>\n\t<h3>" . _("Named zonefile:") . "</h3>\n\t{$zonefile_content}";
}
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;
}
function drawAdminTools_VPSInstallation($admin, $vps)
{
    global $vps_name;
    global $vps_node;
    global $adm_login;
    global $adm_pass;
    global $rub;
    global $addrlink;
    global $vps_soap_err;
    global $pro_mysql_product_table;
    global $pro_mysql_vps_ip_table;
    global $pro_mysql_vps_stats_table;
    global $secpayconf_currency_letters;
    global $panel_type;
    global $submit_err;
    $reinstall_os = 1;
    get_secpay_conf();
    $out = "<font color=\"red\">{$submit_err} {$vps_soap_err}</font>";
    $checker = checkVPSAdmin($adm_login, $adm_pass, $vps_node, $vps_name);
    if ($checker != true) {
        return _("Credential not correct: can't display in file ") . __FILE__ . " line " . __LINE__;
    }
    $vps_out = "";
    // Calculate last month dates
    $cur_year = date("Y");
    $cur_month = date("m");
    $last_month = $cur_month - 1;
    if ($last_month == 0) {
        $last_month_year = $cur_year - 1;
        $last_month = 12;
    } else {
        $last_month_year = $cur_year;
    }
    $tow_month_ago = $last_month - 1;
    if ($tow_month_ago == 0) {
        $tow_month_ago = 12;
        $tow_month_ago_year = $last_month_year - 1;
    } else {
        $tow_month_ago_year = $last_month_year;
    }
    // Check if the VPS has expired or not
    $ar = explode("-", $vps["expire_date"]);
    if (date("Y") > $ar[0] || date("Y") == $ar[0] && date("m") > $ar[1] || date("Y") == $ar[0] && date("m") == $ar[1] && date("d") > $ar[2]) {
        $expired = "yes";
    } else {
        $expired = "no";
    }
    // VPS (remote SOAP) Status
    $soap_client = connectToVPSServer($vps_node);
    if ($soap_client != false) {
        $vps_remote_info = getVPSInfo($vps_node, $vps_name, $soap_client);
        if ($vps_remote_info == false) {
            if (strstr($vps_soap_err, _("Method getVPSState failed"))) {
                $vps_out .= _("Could not get remote status (Method getVPSState() failed). Maybe the VPS is not running?") . "<br><br>";
            } else {
                if (strstr($vps_soap_err, _("couldn't connect to host"))) {
                    $vps_out .= _("Could not get remote status: could not connect to the SOAP server (HTTP error).") . "<br><br>";
                } else {
                    $vps_out .= _("Could not get remote status. Unkown error: ") . "{$vps_soap_err}<br><br>";
                }
            }
        } else {
            if ($vps_remote_info == "fsck") {
                $vps_out .= _("Checking filesystem...") . "<br><br>";
            } else {
                if ($vps_remote_info == "mkos") {
                    $vps_out .= _("Reinstalling operating system...") . "<br><br>";
                } else {
                    if (isset($vps_remote_info["id"])) {
                        $vps_out .= _("VM id: ") . $vps_remote_info["id"] . "<br>";
                    }
                    if (isset($vps_remote_info["name"])) {
                        $vps_out .= _("Name: ") . $vps_remote_info["name"] . "<br>";
                    }
                    if (isset($vps_remote_info["memory"])) {
                        $vps_out .= _("Memory: ") . $vps_remote_info["memory"] . "<br>";
                    }
                    if (isset($vps_remote_info["maxmem"])) {
                        $vps_out .= _("Max memory: ") . $vps_remote_info["maxmem"] . "<br>";
                    } else {
                        $vps_out .= _("Maxmem: cannot fetch (maybe boot in progress?)") . "<br>";
                    }
                    if (isset($vps_remote_info["cpu"])) {
                        $vps_out .= _("Number of CPU: ") . $vps_remote_info["cpu"] . "<br>";
                    } else {
                        $vps_out .= _("Number of CPU: cannot fetch (maybe boot in progress?)") . "<br>";
                    }
                    if (isset($vps_remote_info["state"])) {
                        $vps_out .= _("VPS State: ") . $vps_remote_info["state"] . "<br>";
                    } else {
                        $vps_out .= _("State: cannot fetch (maybe boot in progress?)") . "<br>";
                    }
                    if ($vps_remote_info["xen_type"] == 2 && isset($vps_remote_info["up_time"])) {
                        $uptime = substr($vps_remote_info["up_time"], 0, strpos($vps_remote_info["up_time"], "."));
                        $uptime_s = $uptime % 60;
                        $uptime_m = round($uptime / 60) % 60;
                        $uptime_h = round($uptime / 3600) % 24;
                        $uptime_j = round($uptime / 86400);
                        if ($uptime_s > 1) {
                            $upt_s_s = "s";
                        } else {
                            $upt_s_s = "";
                        }
                        if ($uptime_m > 1) {
                            $upt_s_m = "s";
                        } else {
                            $upt_s_m = "";
                        }
                        if ($uptime_h > 1) {
                            $upt_s_h = "s";
                        } else {
                            $upt_s_h = "";
                        }
                        if ($uptime_j > 1) {
                            $upt_s_j = "s";
                        } else {
                            $upt_s_j = "";
                        }
                        $vps_out .= _("Up time: ") . "{$uptime_j} day{$upt_s_j} {$uptime_h} hour{$upt_s_h} {$uptime_m} minute{$upt_s_m} {$uptime_s} seconde{$upt_s_s}<br>";
                        $vps_out .= _("Last boot date: ") . date("Y-m-d H:i:s", substr($vps_remote_info["start_time"], 0, strlen($vps_remote_info["start_time"]) - 2)) . "<br>";
                    }
                    $vps_out .= "<br>";
                }
            }
        }
    } else {
        $vps_out .= _("Could not connect to the VPS SOAP Server.");
    }
    $frm_start = "<form action=\"?\">\n<input type=\"hidden\" name=\"adm_login\" value=\"{$adm_login}\">\n<input type=\"hidden\" name=\"adm_pass\" value=\"{$adm_pass}\">\n<input type=\"hidden\" name=\"addrlink\" value=\"{$addrlink}\">";
    // The ip address(es)
    $vps_ips = $vps["ip_addr"];
    $n = sizeof($vps_ips);
    if ($n > 1) {
        $ip_title = _("IP addresses: ");
    } else {
        $ip_title = _("IP address: ");
    }
    $out .= "<br><h3>" . $ip_title . "</h3>";
    $out .= dtcFormTableAttrs();
    for ($i = 0; $i < $n; $i++) {
        if ($i % 2) {
            $alt_color = 0;
        } else {
            $alt_color = 1;
        }
        $q = "SELECT * FROM {$pro_mysql_vps_ip_table} WHERE ip_addr='" . $vps_ips[$i] . "';";
        $r = mysql_query($q) or die("Cannot query {$q} line " . __LINE__ . " file " . __FILE__ . " sql said: " . mysql_error());
        $n2 = mysql_num_rows($r);
        if ($n2 != 1) {
            $out .= _("Error line " . __LINE__ . " file " . __FILE__);
        } else {
            $a = mysql_fetch_array($r);
            $out .= dtcFormLineDraw($vps_ips[$i], "{$frm_start}<input type=\"hidden\" name=\"action\" value=\"set_ip_reverse_dns\">\n\t<input type=\"hidden\" name=\"ip_addr\" value=\"" . $vps_ips[$i] . "\">\n\t<input type=\"text\" name=\"rdns\" value=\"" . $a["rdns_addr"] . "\">\n</td><td><div class=\"input_btn_container\" onMouseOver=\"this.className='input_btn_container-hover';\"\nonMouseOut=\"this.className='input_btn_container';\">\n <div class=\"input_btn_left\"></div>\n <div class=\"input_btn_mid\"><input class=\"input_btn\" type=\"submit\" value=\"" . _("Change RDNS") . "\"></div>\n <div class=\"input_btn_right\"></div>\n</div></form>", $alt_color);
        }
    }
    $out .= "</table><br><br>";
    // VPS status
    $out .= "<h3>" . _("Current VPS status:") . "</h3><br>";
    $out .= $vps_out;
    // Start / stop VPS
    $out .= "<h3>" . _("Start and stop of your VPS:") . "</h3><br>";
    if ($vps_remote_info == "fsck") {
        $out .= _("Please wait until file system check is finished first.") . "<br><br>";
    } else {
        if ($vps_remote_info == "mkos") {
            $out .= _("Please wait until operating system reinstallation has completed.") . "<br><br>";
            $reinstall_os = 1;
        } else {
            if ($vps_remote_info == true) {
                $out .= $frm_start . "<input type=\"hidden\" name=\"action\" value=\"shutdown_vps\">\n" . submitButtonStart() . _("Gracefully shutdown (xm shutdown)") . submitButtonEnd() . "\n</form><br><br>";
                $out .= $frm_start . "<input type=\"hidden\" name=\"action\" value=\"destroy_vps\">\n" . submitButtonStart() . _("Immediate kill (xm destroy)") . submitButtonEnd() . "\n</form><br><br>";
                $out .= _("To do a file system check or an operating system reinstallation, you need to shutdown or destroy your server first.") . "<br><br>";
            } else {
                if ($expired == "yes") {
                    $out .= _("You cannot start your VPS if it has expired. Please renew it if you want the boot up (xm start) button to appear here.");
                } else {
                    $out .= $frm_start . "<input type=\"hidden\" name=\"action\" value=\"start_vps\">" . submitButtonStart() . _("Boot up (xm start)") . submitButtonEnd() . "<br><br></form>";
                }
                // FSCK
                $out .= "<h3>" . _("File-system check:") . "</h3><br>";
                $out .= $frm_start . "<input type=\"hidden\" name=\"action\" value=\"fsck_vps\">" . submitButtonStart() . _("File system check (fsck)") . submitButtonEnd() . "\n<br><br></form>";
                // OS reinstall
                $out .= "<h3>" . _("Reinstall operating system:") . "</h3><br>";
                $out .= _("Currently installed operating system: ") . $vps["operatingsystem"] . "<br>";
                $deb_selected = " ";
                $debdtc_selected = " ";
                $cent_selected = " ";
                $gen_selected = " ";
                $bsd_selected = " ";
                $xenhvm_selected = " ";
                switch ($vps["operatingsystem"]) {
                    case "debian":
                        $deb_selected = " selected ";
                        break;
                    case "debian-dtc":
                        $debdtc_selected = " selected ";
                        break;
                    case "centos":
                        $cent_selected = " selected ";
                        break;
                    case "netbsd":
                        $bsd_selected = " selected ";
                        break;
                    case "xenhvm":
                        $xenhvm_selected = " selected ";
                        break;
                    default:
                        break;
                }
                // Operating system selection popup and reinstallation button
                $out .= $frm_start . "<table><tr><td>" . _("Operating system:") . " </td><td><select name=\"os_type\">\n<option value=\"debian\" {$deb_selected}>Debian (" . _("network install with debootstrap") . ")</option>\n<option value=\"debian-dtc\" {$debdtc_selected}>Debian with DTC panel (" . _("network install with debootstrap") . ")</option>\n<option value=\"centos\" {$cent_selected}>CentOS (" . _("network install with yum") . ")</option>\n<option value=\"netbsd\" {$bsd_selected}>NetBSD (" . _("network setup with install kernel") . ")</option>\n<option value=\"xenhvm\" {$xenhvm_selected}>Xen HVM (" . _("boot on your own .iso image") . ")</option>";
                $installable_os = getInstallableOS($soap_client);
                $nbr_os = sizeof($installable_os);
                for ($i = 0; $i < $nbr_os; $i++) {
                    $os_name = $installable_os[$i];
                    if ($vps["operatingsystem"] == $os_name) {
                        $selected = " selected ";
                    } else {
                        $selected = "";
                    }
                    $out .= "<option value=\"{$os_name}\" {$selected}>{$os_name} (" . _("operating system image") . ")</option>";
                }
                $installable_app = getInstallableAPP($soap_client);
                $nbr_app = sizeof($installable_app);
                for ($i = 0; $i < $nbr_app; $i++) {
                    $app_name = $installable_app[$i];
                    if ($vps["operatingsystem"] == $os_name) {
                        $selected = " selected ";
                    } else {
                        $selected = "";
                    }
                    $out .= "<option value=\"{$app_name}\" {$selected}>{$app_name} (" . _("applicance builder") . ")</option>";
                }
                $out .= "</select></td></tr>\n<tr><td>" . "VPS root password:"******" </td><td><input type=\"password\" name=\"root_password\"><input type=\"hidden\" name=\"action\" value=\"reinstall_os\"></td></tr>\n<tr><td></td><td>" . submitButtonStart() . _("Reinstall operating system") . submitButtonEnd() . "\n</td></tr></table></form>";
                //		}
                // BSD kernel change popup
                if ($vps["operatingsystem"] == "netbsd") {
                    if ($vps["bsdkernel"] == "install") {
                        $normal_selected = " ";
                        $install_selected = " selected ";
                    } else {
                        $normal_selected = " selected ";
                        $install_selected = " ";
                    }
                    $out .= $frm_start . "<select name=\"bsdkernel\">\n    <option value=\"normal\" {$normal_selected}>Normal</option>\n    <option value=\"install\" {$install_selected}>Install</option>\n    </select><input type=\"hidden\" name=\"action\" value=\"change_bsd_kernel_type\">\n    " . submitButtonStart() . _("Change NetBSD kernel") . submitButtonEnd() . "\n    </form>";
                }
                if ($vps["operatingsystem"] == "xenhvm") {
                    $vps_xenhvm_iso = getVPSIso($vps_node, $vps_name, $soap_client);
                    $out .= "<br><br>" . _("To upload .iso files so they appear below and you can boot on them, you can upload them using ftp, ") . "xen{$vps_name}@{$vps_node}" . _(" using the password of your physical console.") . "<br><br>";
                    $boot_device_selector = "<select name=\"xenhvm_iso\">\n<option value=\"hdd\">" . _("Boot on hard drive") . "</option>";
                    $n_iso = sizeof($vps_xenhvm_iso);
                    if (is_array($vps_xenhvm_iso)) {
                        for ($i = 0; $i < $n_iso; $i++) {
                            $iso = $vps_xenhvm_iso[$i];
                            if ($vps["howtoboot"] == $iso) {
                                $selected = " selected ";
                            } else {
                                $selected = " ";
                            }
                            $boot_device_selector .= "<option value=\"" . htmlspecialchars($iso) . "\" {$selected}>" . htmlspecialchars($iso) . "</option>";
                        }
                    }
                    $boot_device_selector .= "</select>";
                    if ($vps["vncpassword"] == "no_vnc") {
                        $vncons_act_yes_selected = " ";
                        $vncons_act_no_selected = " checked ";
                    } else {
                        $vncons_act_yes_selected = " ";
                        $vncons_act_no_selected = " checked ";
                    }
                    $out .= dtcFormTableAttrs();
                    $out .= dtcFormLineDraw($frm_start . _("Boot device: "), "<input type=\"hidden\" name=\"action\" value=\"change_xenhvm_boot_iso\">" . $boot_device_selector, 1);
                    $out .= dtcFormLineDraw(_("VNC console password: "******"<input type=\"text\" name=\"vnc_console_pass\" value=\"\">", 0);
                    $out .= dtcFormLineDraw(_("VNC console activation: "), "<input type=\"radio\" name=\"vnc_console_activate\" value=\"yes\" {$vncons_act_yes_selected}>" . _("yes") . " <input type=\"radio\" name=\"vnc_console_activate\" value=\"no\" {$vncons_act_no_selected}>" . _("no"), 1);
                    $out .= dtcFormLineDraw("", submitButtonStart() . _("Write parameters") . submitButtonEnd(), 0);
                    $out .= "</table></form>";
                }
            }
        }
    }
    $out .= "<br><br>";
    // SSH Physical console password changing
    $out .= "<h3>" . _("Physical console last display and ssh access:") . "</h3><br>";
    $out .= "Once your VPS is installed, ssh to the physical console to use it for the first time." . "<br><br>";
    $out .= dtcFormTableAttrs();
    $out .= dtcFormLineDraw($frm_start . "<input type=\"hidden\" name=\"action\" value=\"change_xm_console_ssh_passwd\">" . _("New SSH password: "******"<input size=\"40\" type=\"text\" name=\"new_password\" value=\"\"></td><td>" . submitButtonStart() . _("Ok") . submitButtonEnd() . "</form>", 1);
    $out .= dtcFormLineDraw($frm_start . "<input type=\"hidden\" name=\"action\" value=\"change_xm_console_ssh_key\">" . _("New SSH key: "), "<input size=\"40\" type=\"text\" name=\"new_key\" value=\"\"></td><td>" . submitButtonStart() . _("Ok") . submitButtonEnd() . "</form>", 0);
    $out .= "</table>";
    $out .= "<br><br>" . _("To access to your console, first enter a ssh password or key above, and then ssh to:") . "<br>xen" . $vps_name . "@" . $vps_node . "<br><br>";
    $out .= "<br>" . _("You should then install sshd in your VPS and use the physical console only for debugging purposes.");
    $out .= "<br>" . helpLink("PmWiki/Setup-A-VPS-Once-DTC-Xen-Installed-It");
    /* FIXME probably don't need any of this stuff'
    
    	if($reinstall_os == 1){
    		if($panel_type == "admin"){
    			$path_url = "/dtcadmin";
    		}else{
    			$path_url = "/dtc";
    		}
    		$ajax_url = "https://".$_SERVER["SERVER_NAME"].$path_url."/xanjaxPushlet.php?";
    		$ajax_auth = "adm_login="******"&adm_pass="******"&vps_node=".$vps_node."&vps_name=".$vps_name;
    		$r = "";
    	}else{
    		$r = $soap_client->call("getVPSInstallLog",array("vpsname" => $vps_name,"numlines" => "20"),"","","");
    		$err = $soap_client->getError();
    		if($err){
    			$r = _("Could not get VPS install log. Error: ").$err._(" maybe there are no logs yet?");
    		}
    		// print_r($r);
    		$r = str_replace("\n\n","\n",$r);
    	}
    */
    // tested AJAX stuff starts here
    $out .= "<script language=\"javascript\" src=\"xanjaxXHR.js\"></script>";
    $out .= "<h3>" . _("Installation log (last 20 lines):") . "</h3><br>";
    $out .= "<table cellspacing=\"0\" cellpadding=\"0\" border=\"1\">\n<tr><td bgcolor=\"black\"><font color=\"white\">{$vps_node}:{$vps_name}</font></td>\n<tr><td bgcolor=\"black\"><font color=\"white\"><pre id=\"reinstall_os_log\" class=\"reinstall_os_log\"><font color=\"red\">dtc-xen</font>@<font color=\"blue\">{$vps_node}</font>&gt;_ #<br>...</pre></font></td>\n</table>";
    $out .= "\n\t\t<script type=\"text/javascript\">\n\t\t\txanGet(logPushlet,\"logPushlet.php?vps_node=" . $vps_node . "&vps_name=" . $vps_name . "\");\n\t\t</script>";
    return $out;
}