Skip to content

Commit

Permalink
created new function for checking if supermaster exists with specifie…
Browse files Browse the repository at this point in the history
…d ns name
  • Loading branch information
Edmondas Girkantas committed Nov 11, 2011
1 parent b2651e9 commit cf0a3bc
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 6 deletions.
2 changes: 1 addition & 1 deletion delete_supermaster.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
echo " <h2>" . _('Delete supermaster') . " \"" . $master_ip . "\"</h2>\n";

if (isset($_GET['confirm']) && $_GET["confirm"] == '1') {
if (!supermaster_exists($master_ip, $ns_name)) {
if (!supermaster_ip_name_exists($master_ip, $ns_name)) {
header("Location: list_supermasters.php");
exit;
}
Expand Down
30 changes: 25 additions & 5 deletions inc/record.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ function add_supermaster($master_ip, $ns_name, $account)
error(sprintf(ERR_INV_ARGC, "add_supermaster", "given account name is invalid (alpha chars only)"));
return false;
}
if (supermaster_exists($master_ip, $ns_name)) {
if (supermaster_ip_name_exists($master_ip, $ns_name)) {
error(ERR_SM_EXISTS);
return false;
} else {
Expand Down Expand Up @@ -818,13 +818,12 @@ function get_supermasters()
}
}

function supermaster_exists($master_ip, $hostname)
function supermaster_exists($master_ip)
{
global $db;
if ((is_valid_ipv4($master_ip) || is_valid_ipv6($master_ip)) && is_valid_hostname_fqdn($hostname,0))
if (is_valid_ipv4($master_ip) || is_valid_ipv6($master_ip))
{
$result = $db->query("SELECT ip FROM supermasters WHERE ip = ".$db->quote($master_ip, 'text').
" AND nameserver = ".$db->quote($hostname, 'text'));
$result = $db->query("SELECT ip FROM supermasters WHERE ip = ".$db->quote($master_ip, 'text'));
if ($result->numRows() == 0)
{
return false;
Expand All @@ -840,6 +839,27 @@ function supermaster_exists($master_ip, $hostname)
}
}

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->query("SELECT ip FROM supermasters WHERE ip = ".$db->quote($master_ip, 'text').
" AND nameserver = ".$db->quote($ns_name, 'text'));
if ($result->numRows() == 0)
{
return false;
}
elseif ($result->numRows() >= 1)
{
return true;
}
}
else
{
error(sprintf(ERR_INV_ARGC, "supermaster_exists", "No or no valid IPv4 or IPv6 address given."));
}
}

function get_zones($perm,$userid=0,$letterstart='all',$rowstart=0,$rowamount=999999,$sortby='name')
{
Expand Down

0 comments on commit cf0a3bc

Please sign in to comment.