Ejemplo n.º 1
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;
}
Ejemplo n.º 2
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;
}
Ejemplo n.º 3
0
function drawAdminTools_VPSMonitor($admin, $vps)
{
    global $vps_name;
    global $vps_node;
    global $adm_login;
    global $adm_pass;
    global $rub;
    global $addrlink;
    global $vps_soap_err;
    global $pro_mysql_product_table;
    global $pro_mysql_vps_ip_table;
    global $pro_mysql_vps_stats_table;
    global $secpayconf_currency_letters;
    global $panel_type;
    $reinstall_os = 1;
    get_secpay_conf();
    $out = "";
    $checker = checkVPSAdmin($adm_login, $adm_pass, $vps_node, $vps_name);
    if ($checker != true) {
        return _("Credential not correct: can't display in file ") . __FILE__ . " line " . __LINE__;
    }
    $vps_out = "";
    $vps_out_net_stats = "";
    $vps_out_hdd_stats = "";
    $vps_out_swap_stats = "";
    $vps_out_cpu_stats = "";
    // Calculate last month
    $cur_year = date("Y");
    $cur_month = date("m");
    $last_month = $cur_month - 1;
    if ($last_month == 0) {
        $last_month_year = $cur_year - 1;
        $last_month = 12;
    } else {
        $last_month_year = $cur_year;
    }
    $tow_month_ago = $last_month - 1;
    if ($tow_month_ago == 0) {
        $tow_month_ago = 12;
        $tow_month_ago_year = $last_month_year - 1;
    } else {
        $tow_month_ago_year = $last_month_year;
    }
    $q = "SELECT * FROM {$pro_mysql_vps_stats_table} WHERE vps_server_hostname='{$vps_node}' AND vps_xen_name='xen{$vps_name}'\n\tAND year='{$tow_month_ago_year}' AND month='{$tow_month_ago}';";
    $r = mysql_query($q) or die("Cannot query {$q} line " . __LINE__ . " file " . __FILE__ . " sql said: " . mysql_error());
    $n = mysql_num_rows($r);
    if ($n == 1) {
        $a = mysql_fetch_array($r);
        $net_total = $a["network_in_count"] + $a["network_out_count"];
        $vps_out_net_stats .= _("2 months ago: ") . smartByte($net_total) . "<br>";
        $vps_out_cpu_stats .= _("2 months ago: ") . $a["cpu_usage"] . _(" CPU seconds") . "<br>";
        $vps_out_swap_stats .= _("2 months ago: ") . smartByte($a["swapio_count"]) . "<br>";
        $vps_out_hdd_stats .= _("2 months ago: ") . smartByte($a["diskio_count"]) . "<br>";
    }
    $q = "SELECT * FROM {$pro_mysql_vps_stats_table} WHERE vps_server_hostname='{$vps_node}' AND vps_xen_name='xen{$vps_name}'\n\tAND year='{$last_month_year}' AND month='{$last_month}';";
    $r = mysql_query($q) or die("Cannot query {$q} line " . __LINE__ . " file " . __FILE__ . " sql said: " . mysql_error());
    $n = mysql_num_rows($r);
    if ($n == 1) {
        $a = mysql_fetch_array($r);
        $net_total = $a["network_in_count"] + $a["network_out_count"];
        $vps_out_net_stats .= _("Last month: ") . smartByte($net_total) . "<br>";
        $vps_out_cpu_stats .= _("Last month: ") . $a["cpu_usage"] . _(" CPU seconds") . "<br>";
        $vps_out_swap_stats .= _("Last month: ") . smartByte($a["swapio_count"]) . "<br>";
        $vps_out_hdd_stats .= _("Last month: ") . smartByte($a["diskio_count"]) . "<br>";
    }
    $q = "SELECT * FROM {$pro_mysql_vps_stats_table} WHERE vps_server_hostname='{$vps_node}' AND vps_xen_name='xen{$vps_name}'\n\tAND year='{$cur_year}' AND month='{$cur_month}';";
    $r = mysql_query($q) or die("Cannot query {$q} line " . __LINE__ . " file " . __FILE__ . " sql said: " . mysql_error());
    $n = mysql_num_rows($r);
    if ($n == 1) {
        $a = mysql_fetch_array($r);
        $net_total = $a["network_in_count"] + $a["network_out_count"];
        $vps_out_net_stats .= _("This month: ") . smartByte($net_total);
        $vps_out_cpu_stats .= _("This month: ") . $a["cpu_usage"] . _(" CPU seconds");
        $vps_out_swap_stats .= _("This month: ") . smartByte($a["swapio_count"]);
        $vps_out_hdd_stats .= _("This month: ") . smartByte($a["diskio_count"]);
    }
    // Display the stats of the VPS
    $vps_stat_out = "";
    $vps_stat_out .= "<table cellspacing=\"2\" cellpaddig=\"2\" border=\"0\">";
    $vps_stat_out .= "<tr><td>" . _("Network:") . "<br>";
    $vps_stat_out .= "<img width=\"120\" height=\"48\" src=\"vps_stats_network.php?adm_login={$adm_login}&adm_pass={$adm_pass}&vps_node={$vps_node}&vps_name={$vps_name}\"></td>";
    $vps_stat_out .= "<td>" . _("CPU Time:") . "<br>";
    $vps_stat_out .= "<img width=\"120\" height=\"48\" src=\"vps_stats_cpu.php?adm_login={$adm_login}&adm_pass={$adm_pass}&vps_node={$vps_node}&vps_name={$vps_name}\"></td></tr>";
    $vps_stat_out .= "<tr><td>" . $vps_out_net_stats . "</td><td>{$vps_out_cpu_stats}</td></tr>";
    $vps_stat_out .= "<tr><td>" . _("Swap I/O:") . "<br>";
    $vps_stat_out .= "<img width=\"120\" height=\"48\" src=\"vps_stats_swap.php?adm_login={$adm_login}&adm_pass={$adm_pass}&vps_node={$vps_node}&vps_name={$vps_name}\"></td>";
    $vps_stat_out .= "<td>" . _("HDD I/O:") . "<br>";
    $vps_stat_out .= "<img width=\"120\" height=\"48\" src=\"vps_stats_hdd.php?adm_login={$adm_login}&adm_pass={$adm_pass}&vps_node={$vps_node}&vps_name={$vps_name}\"></td></tr>";
    $vps_stat_out .= "<tr><td>" . $vps_out_swap_stats . "</td><td>" . $vps_out_hdd_stats . "</td></tr></table>";
    // VPS (remote SOAP) Status
    $soap_client = connectToVPSServer($vps_node);
    if ($soap_client != false) {
        $vps_remote_info = getVPSInfo($vps_node, $vps_name, $soap_client);
        if ($vps_remote_info == false) {
            if (strstr($vps_soap_err, _("Method getVPSState failed"))) {
                $vps_out .= _("Could not get remote status (Method getVPSState() failed). Maybe the VPS is not running?") . "<br><br>";
            } else {
                if (strstr($vps_soap_err, _("couldn't connect to host"))) {
                    $vps_out .= _("Could not get remote status: could not connect to the SOAP server (HTTP error).") . "<br><br>";
                } else {
                    $vps_out .= _("Could not get remote status. Unkown error: ") . "{$vps_soap_err}<br><br>";
                }
            }
        } else {
            if ($vps_remote_info == "fsck") {
                $vps_out .= _("Checking filesystem...") . "<br><br>";
            } else {
                if ($vps_remote_info == "mkos") {
                    $vps_out .= _("Reinstalling operating system...") . "<br><br>";
                } else {
                    if (isset($vps_remote_info["id"])) {
                        $vps_out .= _("VM id: ") . $vps_remote_info["id"] . "<br>";
                    }
                    if (isset($vps_remote_info["name"])) {
                        $vps_out .= _("Name: ") . $vps_remote_info["name"] . "<br>";
                    }
                    if (isset($vps_remote_info["memory"])) {
                        $vps_out .= _("Memory: ") . $vps_remote_info["memory"] . "<br>";
                    }
                    if (isset($vps_remote_info["maxmem"])) {
                        $vps_out .= _("Max memory: ") . $vps_remote_info["maxmem"] . "<br>";
                    } else {
                        $vps_out .= _("Maxmem: cannot fetch (maybe boot in progress?)") . "<br>";
                    }
                    if (isset($vps_remote_info["cpu"])) {
                        $vps_out .= _("Number of CPU: ") . $vps_remote_info["cpu"] . "<br>";
                    } else {
                        $vps_out .= _("Number of CPU: cannot fetch (maybe boot in progress?)") . "<br>";
                    }
                    if (isset($vps_remote_info["state"])) {
                        $vps_out .= _("VPS State: ") . $vps_remote_info["state"] . "<br>";
                    } else {
                        $vps_out .= _("State: cannot fetch (maybe boot in progress?)") . "<br>";
                    }
                    if ($vps_remote_info["xen_type"] == 2 && isset($vps_remote_info["up_time"])) {
                        $uptime = substr($vps_remote_info["up_time"], 0, strpos($vps_remote_info["up_time"], "."));
                        $uptime_s = $uptime % 60;
                        $uptime_m = round($uptime / 60) % 60;
                        $uptime_h = round($uptime / 3600) % 24;
                        $uptime_j = round($uptime / 86400);
                        if ($uptime_s > 1) {
                            $upt_s_s = "s";
                        } else {
                            $upt_s_s = "";
                        }
                        if ($uptime_m > 1) {
                            $upt_s_m = "s";
                        } else {
                            $upt_s_m = "";
                        }
                        if ($uptime_h > 1) {
                            $upt_s_h = "s";
                        } else {
                            $upt_s_h = "";
                        }
                        if ($uptime_j > 1) {
                            $upt_s_j = "s";
                        } else {
                            $upt_s_j = "";
                        }
                        $vps_out .= _("Up time: ") . "{$uptime_j} day{$upt_s_j} {$uptime_h} hour{$upt_s_h} {$uptime_m} minute{$upt_s_m} {$uptime_s} seconde{$upt_s_s}<br>";
                        $vps_out .= _("Last boot date: ") . date("Y-m-d H:i:s", substr($vps_remote_info["start_time"], 0, strlen($vps_remote_info["start_time"]) - 2)) . "<br>";
                    }
                    $vps_out .= "<br>";
                }
            }
        }
    } else {
        $vps_out .= _("Could not connect to the VPS SOAP Server.");
    }
    $frm_start = "<form action=\"?\">\n<input type=\"hidden\" name=\"adm_login\" value=\"{$adm_login}\">\n<input type=\"hidden\" name=\"adm_pass\" value=\"{$adm_pass}\">\n<input type=\"hidden\" name=\"addrlink\" value=\"{$addrlink}\">";
    // The ip address(es)
    $out .= "<br><h3>" . _("IP address(es) of your VPS:") . "</h3>";
    $vps_ips = $vps["ip_addr"];
    $n = sizeof($vps_ips);
    if ($n > 1) {
        $out .= _("IP addresses: ");
    } else {
        $out .= _("IP address: ");
    }
    for ($i = 0; $i < $n; $i++) {
        if ($i != 0) {
            $out .= ", ";
        }
        $out .= $vps_ips[$i];
    }
    $out .= "<br><br>";
    // VPS status
    $out .= $vps_stat_out;
    $out .= "<h3>" . _("Current VPS status:") . "</h3><br>";
    $out .= $vps_out;
    // VPS Monitoring
    $out .= "<br><h3>" . _("Service monitoring:") . "</h3><br>";
    $frm_start = dtcFormTableAttrs() . "<form action=\"?\">\n<input type=\"hidden\" name=\"adm_login\" value=\"{$adm_login}\">\n<input type=\"hidden\" name=\"adm_pass\" value=\"{$adm_pass}\">\n<input type=\"hidden\" name=\"addrlink\" value=\"{$addrlink}\">";
    $out .= $frm_start . "\n<input type=\"hidden\" name=\"action\" value=\"set_vps_monitoring_values\">\n";
    if ($vps["monitor_ping"] == "yes") {
        $monitor_ping = " checked ";
    } else {
        $monitor_ping = " ";
    }
    if ($vps["monitor_ssh"] == "yes") {
        $monitor_ssh = " checked ";
    } else {
        $monitor_ssh = " ";
    }
    if ($vps["monitor_http"] == "yes") {
        $monitor_http = " checked ";
    } else {
        $monitor_http = " ";
    }
    if ($vps["monitor_smtp"] == "yes") {
        $monitor_smtp = " checked ";
    } else {
        $monitor_smtp = " ";
    }
    if ($vps["monitor_pop3"] == "yes") {
        $monitor_pop3 = " checked ";
    } else {
        $monitor_pop3 = " ";
    }
    if ($vps["monitor_imap4"] == "yes") {
        $monitor_imap4 = " checked ";
    } else {
        $monitor_imap4 = " ";
    }
    if ($vps["monitor_ftp"] == "yes") {
        $monitor_ftp = " checked ";
    } else {
        $monitor_ftp = " ";
    }
    $out .= dtcFormLineDraw(_("VPS monitoring alerts email address: "), "<input type=\"text\" name=\"email_addr\" value=\"" . $vps["monitoring_email"] . "\">", 1);
    $out .= dtcFormLineDraw(_("Ping: "), "<input type=\"checkbox\" name=\"monitor_ping\" value=\"yes\" {$monitor_ping}>", 0);
    $out .= dtcFormLineDraw(_("SSH: "), "<input type=\"checkbox\" name=\"monitor_ssh\" value=\"yes\" {$monitor_ssh}>", 1);
    $out .= dtcFormLineDraw(_("HTTP: "), "<input type=\"checkbox\" name=\"monitor_http\" value=\"yes\" {$monitor_http}>", 0);
    $out .= dtcFormLineDraw(_("SMTP: "), "<input type=\"checkbox\" name=\"monitor_smtp\" value=\"yes\" {$monitor_smtp}>", 1);
    $out .= dtcFormLineDraw(_("POP3: "), "<input type=\"checkbox\" name=\"monitor_pop3\" value=\"yes\" {$monitor_pop3}>", 0);
    $out .= dtcFormLineDraw(_("IMAP4: "), "<input type=\"checkbox\" name=\"monitor_imap4\" value=\"yes\" {$monitor_imap4}>", 1);
    $out .= dtcFormLineDraw(_("FTP: "), "<input type=\"checkbox\" name=\"monitor_ftp\" value=\"yes\" {$monitor_ftp}>", 0);
    $out .= dtcFormLineDraw("", dtcApplyButton(), 1);
    $out .= "</form></table>";
    return $out;
}