* it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ require_once "inc/toolkit.inc.php"; include_once "inc/header.inc.php"; $master_ip = "-1"; if (isset($_GET['master_ip']) && (is_valid_ipv4($_GET['master_ip']) || is_valid_ipv6($_GET['master_ip']))) { $master_ip = $_GET['master_ip']; } $confirm = "-1"; if (isset($_GET['confirm']) && v_num($_GET['confirm'])) { $confirm = $_GET['confirm']; } if ($master_ip == "-1") { error(ERR_INV_INPUT); } else { verify_permission('supermaster_edit') ? $perm_sm_edit = "1" : ($perm_sm_edit = "0"); if ($perm_sm_edit == "0") { error(ERR_PERM_DEL_SM); } else { $info = get_supermaster_info_from_ip($master_ip); echo " <h2>" . _('Delete supermaster') . " \"" . $master_ip . "\"</h2>\n";
function are_multipe_valid_ips($ips) { // multiple master NS-records are permitted and must be separated by , // eg. "192.0.0.1, 192.0.0.2, 2001:1::1" $are_valid = false; $multiple_ips = explode(",", $ips); if (is_array($multiple_ips)) { foreach ($multiple_ips as $m_ip) { $trimmed_ip = trim($m_ip); if (is_valid_ipv4($trimmed_ip, false) || is_valid_ipv6($trimmed_ip, true)) { $are_valid = true; } else { // as soon there is an invalid ip-addr // exit and return false echo "hin:={$trimmed_ip}="; return false; } } } elseif (is_valid_ipv4($ips) || is_valid_ipv6($ips)) { $are_valid = true; } if ($are_valid) { return true; } else { return false; } }
/** Check if Supermaster IP Address and NS Name combo exists * * @param string $master_ip Supermaster IP Address * @param string $ns_name Supermaster NS Name * * @return boolean true if exists, false otherwise */ function supermaster_ip_name_exists($master_ip, $ns_name) { global $db; if ((is_valid_ipv4($master_ip) || is_valid_ipv6($master_ip)) && is_valid_hostname_fqdn($ns_name, 0)) { $result = $db->queryOne("SELECT ip FROM supermasters WHERE ip = " . $db->quote($master_ip, 'text') . " AND nameserver = " . $db->quote($ns_name, 'text')); return $result ? true : false; } else { error(sprintf(ERR_INV_ARGC, "supermaster_exists", "No or no valid IPv4 or IPv6 address given.")); } }
$master = $_POST['slave_master']; } $type = "SLAVE"; /* Check permissions */ do_hook('verify_permission', 'zone_slave_add') ? $zone_slave_add = "1" : ($zone_slave_add = "0"); do_hook('verify_permission', 'user_view_others') ? $perm_view_others = "1" : ($perm_view_others = "0"); if (isset($_POST['submit']) && $zone_slave_add == "1") { if (!is_valid_hostname_fqdn($zone, 0)) { error(ERR_DNS_HOSTNAME); } elseif ($dns_third_level_check && get_domain_level($zone) > 2 && domain_exists(get_second_level_domain($zone))) { error(ERR_DOMAIN_EXISTS); } elseif (domain_exists($zone) || record_name_exists($zone)) { error(ERR_DOMAIN_EXISTS); } elseif (!is_valid_ipv4($master, false) && !is_valid_ipv6($master)) { error(ERR_DNS_IP); } else { if (add_domain($zone, $owner, $type, $master, 'none')) { success("<a href=\"edit.php?id=" . get_zone_id_from_name($zone) . "\">" . SUC_ZONE_ADD . '</a>'); log_info(sprintf('client_ip:%s user:%s operation:add_zone zone:%s zone_type:SLAVE zone_master:%s', $_SERVER['REMOTE_ADDR'], $_SESSION["userlogin"], $zone, $master, $zone_template)); unset($zone, $owner, $webip, $mailip, $empty, $type, $master); } } } if ($zone_slave_add != "1") { error(ERR_PERM_ADD_ZONE_SLAVE); } else { echo " <h2>" . _('Add slave zone') . "</h2>\n"; $users = do_hook('show_users'); echo " <form method=\"post\" action=\"add_zone_slave.php\">\n";
function change_zone_slave_master($zone_id, $ip_slave_master) { global $db; if (is_numeric($zone_id)) { if (is_valid_ipv4($ip_slave_master) || is_valid_ipv6($ip_slave_master)) { $result = $db->query("UPDATE domains SET master = " . $db->quote($ip_slave_master, 'text') . " WHERE id = " . $db->quote($zone_id, 'integer')); } else { error(sprintf(ERR_INV_ARGC, "change_domain_ip_slave_master", "This is not a valid IPv4 or IPv6 address: {$ip_slave_master}")); } } else { error(sprintf(ERR_INV_ARG, "change_domain_type", "no or no valid zoneid given")); } }
function validate_input($zid, $type, &$content, &$name, &$prio, &$ttl) { $zone = get_zone_name_from_id($zid); // TODO check for return if (!preg_match("/{$zone}\$/i", $name)) { if (isset($name) && $name != "") { $name = $name . "." . $zone; } else { $name = $zone; } } switch ($type) { case "A": if (!is_valid_ipv4($content)) { return false; } if (!is_valid_hostname_fqdn($name, 1)) { return false; } break; case "AAAA": if (!is_valid_ipv6($content)) { return false; } if (!is_valid_hostname_fqdn($name, 1)) { return false; } break; case "CNAME": if (!is_valid_rr_cname_name($name)) { return false; } if (!is_valid_hostname_fqdn($name, 1)) { return false; } if (!is_valid_hostname_fqdn($content, 0)) { return false; } break; case "HINFO": if (!is_valid_rr_hinfo_content($content)) { return false; } if (!is_valid_hostname_fqdn($name, 1)) { return false; } break; case "MX": if (!is_valid_hostname_fqdn($content, 0)) { return false; } if (!is_valid_hostname_fqdn($name, 1)) { return false; } if (!is_valid_non_alias_target($content)) { return false; } break; case "NS": if (!is_valid_hostname_fqdn($content, 0)) { return false; } if (!is_valid_hostname_fqdn($name, 1)) { return false; } if (!is_valid_non_alias_target($content)) { return false; } break; case "PTR": if (!is_valid_hostname_fqdn($content, 0)) { return false; } if (!is_valid_hostname_fqdn($name, 1)) { return false; } break; case "SOA": if (!is_valid_rr_soa_name($name, $zone)) { return false; } if (!is_valid_hostname_fqdn($name, 1)) { return false; } if (!is_valid_rr_soa_content($content)) { return false; } break; case "SRV": if (!is_valid_rr_srv_name($name)) { return false; } if (!is_valid_rr_srv_content($content)) { return false; } break; case "TXT": if (!is_valid_printable($name)) { return false; } if (!is_valid_printable($content)) { return false; } break; case "MBOXFW": case "NAPTR": case "SPF": case "SSHFP": case "URL": // These types are supported by PowerDNS, but there is not // yet code for validation. Validation needs to be added // for these types. One Day Real Soon Now. [tm] break; default: error(ERR_DNS_RR_TYPE); return false; } if (!is_valid_rr_prio($prio, $type)) { return false; } if (!is_valid_rr_ttl($ttl)) { return false; } return true; }