} $q = "UPDATE {$pro_mysql_vps_table} SET monitoring_email='" . $_REQUEST["email_addr"] . "',\nmonitor_ping='{$monitor_ping}', monitor_ssh='{$monitor_ssh}', monitor_http='{$monitor_http}', monitor_smtp='{$monitor_smtp}', monitor_pop3='{$monitor_pop3}',\nmonitor_imap4='{$monitor_imap4}', monitor_ftp='{$monitor_ftp}' WHERE vps_xen_name='{$vps_name}' AND vps_server_hostname='{$vps_node}';"; $r = mysql_query($q) or die("Cannot query {$q} line " . __LINE__ . " file " . __FILE__ . " sql said: " . mysql_error()); updateUsingCron("gen_nagios='yes'"); } } if (isset($_REQUEST["action"]) && ($_REQUEST["action"] == "shutdown_vps" || $_REQUEST["action"] == "destroy_vps" || $_REQUEST["action"] == "start_vps")) { if (checkVPSAdmin($adm_login, $adm_pass, $vps_node, $vps_name) == true) { remoteVPSAction($vps_node, $vps_name, $_REQUEST["action"]); } else { $submit_err = _("Access not granted line ") . __LINE__ . _(" file ") . __FILE__; } } if (isset($_REQUEST["action"]) && $_REQUEST["action"] == "set_ip_reverse_dns") { if (checkVPSAdmin($adm_login, $adm_pass, $vps_node, $vps_name) == true) { if (!isIP($_REQUEST["ip_addr"])) { $submit_err = _("This is not a correct IP line ") . __LINE__ . _(" file ") . __FILE__; } else { if (!isHostnameOrIP($_REQUEST["rdns"])) { $submit_err = _("This is not a correct hostname or IP line ") . __LINE__ . _(" file ") . __FILE__; } else { $q = "SELECT * FROM {$pro_mysql_vps_ip_table} WHERE ip_addr='" . $_REQUEST["ip_addr"] . "' AND vps_xen_name='{$vps_name}' AND vps_server_hostname='{$vps_node}';"; $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) { $submit_err = _("Access not granted line ") . __LINE__ . _(" file ") . __FILE__; } else { $q = "UPDATE {$pro_mysql_vps_ip_table} SET rdns_addr='" . $_REQUEST["rdns"] . "',rdns_regen='yes' WHERE ip_addr='" . $_REQUEST["ip_addr"] . "';"; $r = mysql_query($q) or die("Cannot query {$q} line " . __LINE__ . " file " . __FILE__ . " sql said: " . mysql_error()); $q = "SELECT {$pro_mysql_ip_pool_table}.zone_type\n\t\t\t\t\tFROM {$pro_mysql_vps_ip_table},{$pro_mysql_ip_pool_table}\n\t\t\t\t\tWHERE {$pro_mysql_vps_ip_table}.ip_addr='" . $_REQUEST["ip_addr"] . "'\n\t\t\t\t\tAND {$pro_mysql_ip_pool_table}.id={$pro_mysql_vps_ip_table}.ip_pool_id;"; $r = mysql_query($q) or die("Cannot query {$q} line " . __LINE__ . " file " . __FILE__ . " sql said: " . mysql_error());
$out[] = "$no_rights (".getcwd()."/etc)."; $bad = 1; } else { unlink("./etc/foo"); } if (!file_exists($cpath) && !mkdir($cpath)) { $out[] = "$no_path $cpath"; } else { if (@touch("$cpath/foo")==FALSE) { $out[] = "$no_rights $cpath"; $bad = 1; } else { unlink("$cpath/foo"); } } if (!isIP($cip)) { $out[] = $err_ip; $bad = 1; } if (!isSingle($cname)) { $out[] = $err_name; $bad = 1; } if (file_exists("$cpath/$cname")) { $out[] = "$tpath $cpath/$cname $already"; $bad = 1; } if (!isSingle($cmaildom)) { $out[] = $err_domain; $bad = 1; }
<body bgcolor="#000000" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" text="#ffffff"> <? include "top.php"; ?> <table width="100%" border="0" cellspacing="0" cellpadding="5"> <tbody><tr> <TD class=menu_cell_repeater style="PADDING-LEFT: 15px" vAlign=top width=140> <? include ("left.php"); ?> </td> <td style="padding-left: 15px; padding-top: 12px; padding-right: 15px;" valign="top" align="left"> <font color="red"> <? if ($cgi['submit']) { if (($HTTP_SERVER_VARS['REMOTE_ADDR']) && (isIP($HTTP_SERVER_VARS['REMOTE_ADDR']))) { $echoS = "Oops. Somebody has already registered from this IP. If you beleive it is a fault you can contact us via mail {$conf['mail']}."; } elseif (!$cgi['username']) { $echoS = "You should enter user name."; } elseif (getUserDetailsByName($cgi['username'])) { $echoS = "That username has already been taken."; } elseif ($cgi['email'] != $cgi['email2']) { $echoS = "Mails you have entered are not equal."; } elseif (!preg_match("/^.+?@.+?\..+?/i", $cgi['email'])) { $echoS = "You should enter correct e-mail."; } elseif (strpos($cgi['email'], "hotmail.com") > 0) { $echoS = "We have been getting too many complaints that hotmail blocks our activation emails, please use an alternate email such as <a href=\"http://www.gmail.com\" target=\"_blank\">Gmail</a>"; } elseif (getUserDetailsByEmail($cgi['email'])) { $echoS = "That e-mail has already been taken."; } elseif (!$cgi['tos']) { $echoS = "You should agree to comply with the terms of service.";
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> </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; }
function isHostnameOrIP($hostname) { $reg = '/^((([a-z0-9]([-a-z0-9]*[a-z0-9])?)|(#[0-9]+)|(\\[((([01]?[0-9]{0,2})|(2(([0-4][0-9])|(5[0-5]))))\\.){3}(([01]?[0-9]{0,2})|(2(([0-4][0-9])|(5[0-5]))))\\]))\\.)*(([a-z]([-a-z0-9]*[a-z0-9])?)|(#[0-9]+)|(\\[((([01]?[0-9]{0,2})|(2(([0-4][0-9])|(5[0-5]))))\\.){3}(([01]?[0-9]{0,2})|(2(([0-4][0-9])|(5[0-5]))))\\]))$/'; if (!preg_match($reg, $hostname) && !isIP($hostname)) { return false; } else { return true; } }
if (!isDTCPassword($pass)) { die("Requested pass does not look like to be correct. It should be made only with letters, numbers, \".\" or \"-\" sign."); } if (!isHostname($domain)) { die("Requested domain name does not looklike to be correct. Please check !"); } $query = "SELECT * FROM {$pro_mysql_subdomain_table} WHERE login='******' AND pass='******' AND domain_name='{$domain}';"; $result = mysql_query($query) or die("Cannot query: \"{$query}\" !!!" . mysql_error()); $num_rows = mysql_num_rows($result); if ($num_rows != 1) { die("Incorrect login, pass or domain name !"); } else { if (!isset($ip) || $ip == "") { $ip = $_SERVER["REMOTE_ADDR"]; } else { if (!isIP($ip)) { die("Incorrect IP format !"); } } $row = mysql_fetch_array($result); if ($ip != $row["ip"]) { $edit_domain = $row["domain_name"]; $domupdate_query = "UPDATE {$pro_mysql_domain_table} SET generate_flag='yes' WHERE name='{$edit_domain}' LIMIT 1;"; $domupdate_result = mysql_query($domupdate_query) or die("Cannot execute query \"{$domupdate_query}\""); $query = "UPDATE {$pro_mysql_subdomain_table} SET ip='{$ip}' WHERE login='******' AND pass='******';"; mysql_query($query) or die("Cannot execute query \"{$query}\" !!!" . mysql_error()); $adm_query = "UPDATE {$pro_mysql_cronjob_table} SET gen_named='yes',reload_named='yes' WHERE 1;"; mysql_query($adm_query) or die("Cannot execute query \"{$adm_query}\" !!!" . mysql_error()); echo "Succes: updated to {$ip}\n"; } else { echo "Succes: update not needed to {$ip}\n";
function named_generate() { global $pro_mysql_domain_table; global $pro_mysql_admin_table; global $pro_mysql_subdomain_table; global $pro_apache_vhost_path; global $pro_mysql_backup_table; global $console; global $conf_main_site_ip; global $conf_use_multiple_ip; global $conf_use_cname_for_subdomains; global $conf_webmaster_email_addr; $bind_formated_webmaster_email_addr = str_replace('@', ".", $conf_webmaster_email_addr) . "."; global $conf_addr_primary_dns; global $conf_addr_secondary_dns; global $conf_addr_mail_server; global $conf_addr_backup_mail_server; global $conf_ip_slavezone_dns_server; global $conf_generated_file_path; global $conf_named_path; global $conf_named_zonefiles_path; global $conf_named_slavefile_path; global $conf_named_slavezonefiles_path; global $conf_ip_allowed_dns_transfer; global $conf_domainkey_publickey_filepath; global $conf_dtc_system_username; global $conf_dtc_system_groupname; global $conf_autogen_default_subdomains; global $conf_autogen_subdomain_list; global $conf_default_zones_ttl; global $conf_named_soa_refresh; global $conf_named_soa_retry; global $conf_named_soa_expire; global $conf_named_soa_default_ttl; $slave_file = ""; $serial_prefix = date("Ymd"); $djb_file = ""; $named_file = ""; $query = "SELECT * FROM {$pro_mysql_domain_table} WHERE primary_dns='default' OR other_dns='default' ORDER BY name;"; $result = mysql_query($query) or die("Cannot execute query \"{$query}\""); $num_rows = mysql_num_rows($result); if ($num_rows < 1) { // die("No account to generate"); } for ($i = 0; $i < $num_rows; $i++) { unset($wildcard_dns_txt); $row = mysql_fetch_array($result) or die("Cannot fetch user"); $web_name = $row["name"]; // for empty web_names, we need to skip // this is especially true for dedicated servers if (!isset($web_name) || $web_name == "") { continue; } $web_owner = $row["owner"]; $web_serial_flag = $row["generate_flag"]; $ip_addr = $row["ip_addr"]; // domain wide TTL $domain_ttl = $conf_default_zones_ttl; if (isset($row["ttl"])) { $domain_ttl = $row["ttl"]; } $domain_parking = $row["domain_parking"]; // Get DNS addresses from database. Switch to $conf_* values if "default" is found if ($row["primary_dns"] == "default") { $thisdomain_dns1 = $conf_addr_primary_dns; } else { $thisdomain_dns1 = $row["primary_dns"]; } $more_dns_server = ""; if ($row["other_dns"] == "default") { $all_dns = explode("|", $conf_addr_secondary_dns); } else { $all_dns = explode("|", $row["other_dns"]); } $thisdomain_dns2 = $all_dns[0]; $nbr_other_dns = sizeof($all_dns); $all_ip = ""; $temp_ip = gethostbyname($thisdomain_dns2); if (isIP($temp_ip)) { $all_ip .= $temp_ip . "; "; } for ($z = 1; $z < $nbr_other_dns; $z++) { $more_dns_server .= "@\tIN\tNS\t" . $all_dns[$z] . ".\n"; $temp_ip = gethostbyname($all_dns[$z]); if (isIP($temp_ip)) { $all_ip .= $temp_ip . "; "; } } if (strlen($conf_ip_allowed_dns_transfer) > 4) { $more_allowed = explode("|", $conf_ip_allowed_dns_transfer); $v = sizeof($more_allowed); for ($k = 0; $k < $v; $k++) { $all_ip .= $more_allowed[$k] . "; "; } } if (strlen($all_ip) > 4) { $allow_xfer = "allow-transfer { {$all_ip} };"; } else { $allow_xfer = ""; } if ($row["primary_mx"] == "default") { $thisdomain_mx1 = $conf_addr_mail_server; } else { $thisdomain_mx1 = $row["primary_mx"]; } $more_mx_server = ""; $MX_number = 10; if ($row["other_mx"] == "default") { if ($conf_addr_backup_mail_server != "") { $all_mx = explode("|", $conf_addr_backup_mail_server); $nbr_other_mx = sizeof($all_mx); for ($z = 0; $z < $nbr_other_mx; $z++) { $more_mx_server .= "@\tIN\tMX\t" . $MX_number . "\t" . $all_mx[$z] . ".\n"; $MX_number += 5; } } } else { $all_mx = explode("|", $row["other_mx"]); $nbr_other_mx = sizeof($all_mx); for ($z = 0; $z < $nbr_other_mx; $z++) { $more_mx_server .= "@\tIN\tMX\t" . $MX_number . "\t" . $all_mx[$z] . ".\n"; $MX_number += 5; } } $root_txt_record = $row["txt_root_entry"]; $root_txt_record2 = $row["txt_root_entry2"]; $web_extention = substr($web_name, -strpos(strrev($web_name), '.')); $web_default_subdomain = $row["default_subdomain"]; $wildcard_dns = $row["wildcard_dns"]; // Get the owner informations $query2 = "SELECT * FROM {$pro_mysql_admin_table} WHERE adm_login='******';"; $result2 = mysql_query($query2) or die("Cannot execute query \"{$query2}\""); $num_rows2 = mysql_num_rows($result2); if ($num_rows2 != 1) { echo "No user of that name ({$web_owner})!\n"; continue; } $webadmin = mysql_fetch_array($result2) or die("Cannot fetch user"); $web_path = $webadmin["path"]; // This should handle domain parking: need to get the target IP addr if ($domain_parking != "no-parking") { $domain_to_get = $domain_parking; $qp = "SELECT ip_addr FROM {$pro_mysql_domain_table} WHERE name='{$domain_parking}'"; $rp = mysql_query($qp) or die("Cannot query {$qp} line " . __LINE__ . " file " . __FILE__ . " sql said " . mysql_error()); $np = mysql_num_rows($rp); if ($np != 1) { echo "WARNING: error in your SQL table: target domain {$domain_parking} for parking of {$web_name} does not exists, will cancel domain parking!!!<br>"; $domain_to_get = $web_name; $domain_parking = "no-parking"; } else { $ap = mysql_fetch_array($rp); $ip_addr = $ap["ip_addr"]; } } else { $domain_to_get = $web_name; } // Grab all subdomains $query2 = "SELECT * FROM {$pro_mysql_subdomain_table} WHERE domain_name='{$domain_to_get}' ORDER BY subdomain_name;"; $result2 = mysql_query($query2) or die("Cannot execute query \"{$query2}\""); $num_rows2 = mysql_num_rows($result2); if ($num_rows2 < 1) { echo "WARNING: No subdomain for domain {$domain_to_get} !!!"; } if ($conf_use_multiple_ip == "yes") { $ip_to_write = $ip_addr; } else { $ip_to_write = $conf_main_site_ip; } if ($row["primary_dns"] == "default") { $named_file .= "zone \"{$web_name}\" IN {\n\ttype master;\n\t{$allow_xfer}\n\tallow-query { any; };\n\tfile \"{$conf_generated_file_path}/{$conf_named_zonefiles_path}/{$web_name}\";\n};\n"; } if ($row["other_dns"] == "default" || $row["primary_dns"] == "default") { $slave_file .= "zone \"{$web_name}\" {\n\ttype slave;\n\tallow-query { any; };\n\tmasters { {$conf_ip_slavezone_dns_server}; };\n\tfile \"{$conf_generated_file_path}/{$conf_named_slavezonefiles_path}/{$web_name}\";\n};\n"; } if ($row["primary_dns"] == "default") { // DNS serial $oldzonefile = "{$conf_generated_file_path}/{$conf_named_zonefiles_path}/{$web_name}"; if (file_exists($oldzonefile)) { $oldzonefile_contents = file_get_contents($oldzonefile); $matches = array(); if (preg_match("/{$serial_prefix}([0-9]{2}); serial/", $oldzonefile_contents, $matches) > 0) { $serial_incr = $matches[1] + 1; if ($serial_incr > 99) { $serial_incr = 99; $console .= "<br />WARNING: DNS serial number for zone {$web_name} is already at the maximum for today ({$serial_prefix}{$serial_incr}), and therefore was not incremented.<br />\n"; } $todays_serial = $serial_prefix . sprintf("%'02d", $serial_incr); } else { $todays_serial = $serial_prefix . "01"; } } else { $todays_serial = $serial_prefix . "01"; } $this_site_file = "\$TTL {$domain_ttl}\n@ IN SOA {$thisdomain_dns1}. {$bind_formated_webmaster_email_addr} (\n\t\t\t{$todays_serial}; serial\n {$conf_named_soa_refresh} ; refresh\n {$conf_named_soa_retry} ; retry\n {$conf_named_soa_expire} ; expire\n {$conf_named_soa_default_ttl} ; default_ttl\n )\n@\tIN\tNS\t{$thisdomain_dns1}.\n@\tIN\tNS\t{$thisdomain_dns2}.\n{$more_dns_server}\n@\tIN\tMX\t5\t{$thisdomain_mx1}.\n{$more_mx_server}\n@\tIN\tTXT\t\"{$root_txt_record}\"\n@\tIN\tTXT\t\"{$root_txt_record2}\"\n"; // Set the "root subdomain" IP as the same as the "default subdomain" IP $qd = "SELECT ip FROM {$pro_mysql_subdomain_table} WHERE subdomain_name='{$web_default_subdomain}' AND domain_name='{$domain_to_get}';"; $rd = mysql_query($qd) or die("Cannot query {$qd} line " . __LINE__ . " file " . __FILE__ . " sql said: " . mysql_error()); $nd = mysql_num_rows($rd); if ($nd == 1) { $ad = mysql_fetch_array($rd); if ($ad["ip"] == "default") { $this_site_file .= "\tIN\tA\t{$ip_to_write}\n"; } else { // In case of a CNAME, add a final dot if (isIP($ad["ip"])) { $this_site_file .= "\tIN\tA\t" . $ad["ip"] . "\n"; } else { $this_site_file .= "\tIN\tCNAME\t" . $ad["ip"] . ".\n"; } } } else { $this_site_file .= "\tIN\tA\t{$ip_to_write}\n"; } // if we have the public.key for DomainKeys, write it into our zone file if (file_exists($conf_domainkey_publickey_filepath) && $row["primary_mx"] == "default") { $key_file_array = file($conf_domainkey_publickey_filepath, FILE_IGNORE_NEW_LINES); // skip the first and last lines (the ---PUBLIC---) $KEY = ""; for ($key_file_array_count = 1; $key_file_array_count < count($key_file_array) - 1; $key_file_array_count++) { $KEY .= $key_file_array[$key_file_array_count]; } // This line is added for php4 support: $KEY = str_replace("\n", "", $KEY); $SELECTOR = "postfix"; $DOMAIN = $web_name; $NSRECORD = "{$SELECTOR}._domainkey IN TXT \"k=rsa;p={$KEY}\""; $NSRECORDDEFAULT = "_domainkey IN TXT \"o=~\""; $this_site_file .= "{$NSRECORDDEFAULT}\n"; $this_site_file .= "{$NSRECORD}\n"; } // // Add all subdomains to it ! // // First, generate a list of "auto generated subdomains", preseed with "no" $autosubs = array(); $list_autogen = explode("|", $conf_autogen_subdomain_list); $n_autogen = sizeof($list_autogen); for ($autog = 0; $autog < $n_autogen; $autog++) { $autosubs[$list_autogen[$autog]] = "no"; } for ($j = 0; $j < $num_rows2; $j++) { $subdomain = mysql_fetch_array($result2) or die("Cannot fetch user"); $web_subname = $subdomain["subdomain_name"]; // TTL support $sub_ttl = $conf_default_zones_ttl; if (isset($subdomain["ttl"])) { $sub_ttl = $subdomain["ttl"]; } // Check if it's an IP or not, to know if it's a CNAME record or a A record if (isIP($subdomain["ip"]) || $subdomain["ip"] == "default") { if ($subdomain["ssl_ip"] != "none") { $the_ip_writed = "A\t" . $subdomain["ssl_ip"]; } else { if ($subdomain["ip"] == "default") { $the_ip_writed = "A\t" . $ip_to_write; } else { $the_ip_writed = "A\t" . $subdomain["ip"]; } } } else { $the_ip_writed = "CNAME\t" . $subdomain["ip"] . "."; } // Note from Thomas Goirand: // This patch seems to 1/ produce some NOTICE like this: // Notice: Undefined variable: seeb_alias in /usr/share/dtc/admin/genfiles/gen_named_files.php on line 442 // Notice: Undefined variable: seeb_alias in /usr/share/dtc/admin/genfiles/gen_named_files.php on line 441 // as $seeb_alias is never defined anywhere!!! // and 2/ make the stuff unreachable. So I'm commenting out, sorry. Seeb: if you see this, patch this file // so it always work, thanks! // // patch by seeb w3_alias //if ($subdomain['w3_alias'] =="yes" && $subdomain['subdomain_name']!="www"){ // $sub_alias="www.".$subdomain['subdomain_name']; // $console.="Generated w3alias: ".$seeb_alias.".".$subdomain['domain_name']."<br/>"; // $this_site_file .= "$seeb_alias\tIN\tCNAME ".$subdomain['subdomain_name'].".".$subdomain['domain_name'].".\n"; //} // end of patch 3w_alias // See if the subdomain overrides the default for the zone if (isset($autosubs[$web_subname])) { $autosubs[$web_subname] = "yes"; } // if we have a srv_record here (ie a port, then we don't write the normal subdomain entry, just the SRV record if (isset($subdomain["srv_record"]) && $subdomain["srv_record"] != "") { $this_site_file .= "_{$web_subname}._" . $subdomain["srv_record_protocol"] . "\t{$sub_ttl}\tIN\tSRV\t0\t10\t" . $subdomain["srv_record"] . "\t" . $subdomain["ip"] . "\n"; } else { // write TTL values into subdomain if ($conf_use_cname_for_subdomains == "yes") { $this_site_file .= "{$web_subname}\t{$sub_ttl}\tIN\tCNAME\t@\n"; } else { if ($web_subname == $web_default_subdomain && $wildcard_dns == "yes") { $wildcard_dns_txt = "* {$sub_ttl} IN {$the_ip_writed}\n"; } $this_site_file .= "{$web_subname}\t{$sub_ttl}\tIN\t{$the_ip_writed}\n"; } } if ($subdomain["ip6"] != "" && $subdomain["ip6"] != "default") { $this_site_file .= "{$web_subname} {$sub_ttl} IN AAAA " . $subdomain["ip6"] . "\n"; } if ($subdomain["associated_txt_record"] != "" && (isIP($subdomain["ip"]) || $subdomain["ip"] == "default")) { $this_site_file .= "{$web_subname}\tIN\tTXT\t\"" . $subdomain["associated_txt_record"] . "\"\n"; } if (isset($subdomain["nameserver_for"]) && $subdomain["nameserver_for"] != "") { // add support for creating NS records $nameserver_for = $subdomain["nameserver_for"]; $this_site_file .= "{$nameserver_for}\tIN\tNS\t{$web_subname}.{$web_name}.\n"; } } if ($conf_autogen_default_subdomains == "yes") { // For each subdomains not yet defined, but in autogen, add an entry $autosubs_keys = array_keys($autosubs); $n_autogen = sizeof($autosubs); for ($autog = 0; $autog < $n_autogen; $autog++) { if ($autosubs[$autosubs_keys[$autog]] == "no") { $zeautogen = $autosubs_keys[$autog]; if ($conf_use_cname_for_subdomains == "yes") { $this_site_file .= "{$zeautogen}\tIN\tCNAME\t@\n"; } else { if ($zeautogen == "mysql1") { $this_site_file .= "{$zeautogen}\tIN\tA\t127.0.0.1\n"; } else { $this_site_file .= "{$zeautogen}\tIN\tA\t{$ip_to_write}\n"; } } } } } if (isset($wildcard_dns_txt)) { $this_site_file .= $wildcard_dns_txt; } if ($web_serial_flag == "yes") { $console .= "Updating zone file for domain {$web_name} using serial : {$todays_serial}, ipaddr : {$ip_to_write}<br>"; $filep = fopen("{$conf_generated_file_path}/{$conf_named_zonefiles_path}/{$web_name}", "w+"); if ($filep == NULL) { print "Cannot open file {$conf_generated_file_path}/{$conf_named_zonefiles_path}/{$web_name} for writting"; continue; } fwrite($filep, $this_site_file); fclose($filep); chown("{$conf_generated_file_path}/{$conf_named_zonefiles_path}/{$web_name}", $conf_dtc_system_username); chgrp("{$conf_generated_file_path}/{$conf_named_zonefiles_path}/{$web_name}", $conf_dtc_system_groupname); $query_serial = "UPDATE {$pro_mysql_domain_table} SET generate_flag='no' WHERE name='{$web_name}' LIMIT 1;"; $result_serial = mysql_query($query_serial) or die("Cannot execute query \"{$query_serial}\""); } } else { $temp_ip = gethostbyname($thisdomain_dns1); if (isIP($temp_ip)) { $named_file .= "zone \"{$web_name}\" {\n\ttype slave;\n\tallow-query { any; };\n\tmasters { {$temp_ip}; };\n\tfile \"{$conf_generated_file_path}/{$conf_named_slavezonefiles_path}/{$web_name}\";\n};\n"; } } } $named_file .= get_remote_ns_domains(); // include the reverse zone file $named_file .= "include \"{$conf_generated_file_path}/named.conf.reverse\";\n"; // include the slave zone file // $named_file .= "include \"$conf_generated_file_path/$conf_named_slavefile_path\";\n"; // Write of the master zone file $filep = fopen("{$conf_generated_file_path}/{$conf_named_path}", "w+"); if ($filep == NULL) { die("Cannot open file \"{$conf_generated_file_path}/{$conf_named_path}\" for writting"); } fwrite($filep, $named_file); fclose($filep); // Write of the slave zone file $filep = fopen("{$conf_generated_file_path}/{$conf_named_slavefile_path}", "w+"); if ($filep == NULL) { die("Cannot open file \"{$conf_generated_file_path}/{$conf_named_slavefile_path}\" for writting"); } if (!file_exists($conf_generated_file_path . "/" . $conf_named_slavezonefiles_path)) { mkdir($conf_generated_file_path . "/" . $conf_named_slavezonefiles_path, 0775); } // make sure the slave directory is present fwrite($filep, $slave_file); fclose($filep); // Call the reverse DNS function now... rnds_generate(); nodes_vps_generate(); return true; }