$domains = array();
}
if (isset($_POST['zone_template'])) {
    $zone_template = $_POST['zone_template'];
} else {
    $zone_template = "none";
}
/*
Check user permissions
*/
verify_permission('zone_master_add') ? $zone_master_add = "1" : ($zone_master_add = "0");
verify_permission('user_view_others') ? $perm_view_others = "1" : ($perm_view_others = "0");
if (isset($_POST['submit']) && $zone_master_add == "1") {
    $error = false;
    foreach ($domains as $domain) {
        if (!is_valid_hostname_fqdn($domain, 0)) {
            error($domain . ' failed - ' . ERR_DNS_HOSTNAME);
        } elseif (domain_exists($domain)) {
            error($domain . ' failed - ' . ERR_DOMAIN_EXISTS);
            // TODO: repopulate domain name(s) to the form if there was an error occured
            $error = true;
        } elseif (add_domain($domain, $owner, $dom_type, '', $zone_template)) {
            success("<a href=\"edit.php?id=" . get_zone_id_from_name($domain) . "\">" . $domain . " - " . SUC_ZONE_ADD . '</a>');
        }
    }
    if (false === $error) {
        unset($domains, $owner, $dom_type, $zone_template);
    }
}
if ($zone_master_add != "1") {
    error(ERR_PERM_ADD_ZONE_MASTER);
function is_valid_rr_srv_content(&$content)
{
    $fields = preg_split("/\\s+/", trim($content), 3);
    if (!is_numeric($fields[0]) || $fields[0] < 0 || $fields[0] > 65535) {
        error(ERR_DNS_SRV_WGHT);
        return false;
    }
    if (!is_numeric($fields[1]) || $fields[1] < 0 || $fields[1] > 65535) {
        error(ERR_DNS_SRV_PORT);
        return false;
    }
    if ($fields[2] == "" || $fields[2] != "." && !is_valid_hostname_fqdn($fields[2], 0)) {
        error(ERR_DNS_SRV_TRGT);
        return false;
    }
    $content = join(' ', $fields);
    return true;
}
function is_valid_email($address)
{
    $fields = preg_split("/@/", $address, 2);
    if (!preg_match("/^[0-9a-z]([-_.]?[0-9a-z])*\$/i", $fields[0]) || (!isset($fields[1]) || $fields[1] == '' || !is_valid_hostname_fqdn($fields[1], 0))) {
        return false;
    }
    return true;
}
Esempio n. 4
0
/** 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."));
    }
}
Esempio n. 5
0
$zone = "";
if (isset($_POST['domain'])) {
    $zone = trim($_POST['domain']);
}
$master = "";
if (isset($_POST['slave_master'])) {
    $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);
        }
    }
}
 *  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'];
}
$ns_name = "-1";
if (isset($_GET['ns_name']) && is_valid_hostname_fqdn($_GET['ns_name'], 0)) {
    $ns_name = $_GET['ns_name'];
}
$confirm = "-1";
if (isset($_GET['confirm']) && v_num($_GET['confirm'])) {
    $confirm = $_GET['confirm'];
}
if ($master_ip == "-1" || $ns_name == "-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";
Esempio n. 7
0
function domain_exists($domain)
{
    global $db;
    if (is_valid_hostname_fqdn($domain, 0)) {
        $result = $db->query("SELECT id FROM domains WHERE name=" . $db->quote($domain, 'text'));
        if ($result->numRows() == 0) {
            return false;
        } elseif ($result->numRows() >= 1) {
            return true;
        }
    } else {
        error(ERR_DOMAIN_INVALID);
    }
}
Esempio n. 8
0
function is_valid_email($address)
{
    $fields = split("@", $address, 2);
    if (!eregi("^[0-9a-z]([-_.]?[0-9a-z])*\$", $fields[0]) || !is_valid_hostname_fqdn($fields[1], 0)) {
        return false;
    }
    return true;
}