Esempio n. 1
0
# verify that user is logged in
$User->check_user_session();
// save settings for powerDNS default
$pdns = $PowerDNS->db_settings;
// default post
$post = $_POST;
# get record
if ($_POST['action'] != "add") {
    $record = $PowerDNS->fetch_record($_POST['id']);
    $record !== false ?: $Result->show("danger", _("Invalid ID"), true, true);
} else {
    // from IP table
    // we provide record hostname and strip domain from it
    if (!is_numeric($_POST['domain_id']) && !is_numeric($_POST['id'])) {
        // fetch all domains
        foreach ($PowerDNS->fetch_all_domains() as $domain_s) {
            if (strpos($_POST['domain_id'], $domain_s->name) !== false) {
                $_POST['domain_id'] = $domain_s->id;
                break;
            }
        }
        // die if not existing
        if (!is_numeric($_POST['domain_id'])) {
            $Result->show("danger", _("Domain does not exist"), true, true);
        } else {
            $record = new StdClass();
            $record->ttl = 3600;
            $record->name = $post['domain_id'];
            $record->content = $_POST['id'];
        }
    }
Esempio n. 2
0
# create csrf token
$csrf = $User->csrf_cookie("create", "record");
# save settings for powerDNS default
$pdns = $PowerDNS->db_settings;
# default post
$post = $_POST;
# get record
if ($_POST['action'] != "add") {
    $record = $PowerDNS->fetch_record($_POST['id']);
    $record !== false ?: $Result->show("danger", _("Invalid ID"), true, true);
} else {
    // from IP table
    // we provide record hostname and strip domain from it
    if (!is_numeric($_POST['domain_id']) && !is_numeric($_POST['id'])) {
        // fetch all domains
        $all_domains = $PowerDNS->fetch_all_domains();
        if ($all_domains !== false) {
            foreach ($all_domains as $dk => $domain_s) {
                // loop through and find all matches
                if (strpos($_POST['domain_id'], $domain_s->name) !== false) {
                    // check best match to avoid for example a.example.net.nz1 added to example.net.nz
                    if (substr($_POST['domain_id'], -strlen($domain_s->name)) === $domain_s->name) {
                        $matches[$dk] = $domain_s;
                    }
                }
            }
            // match found ?
            if (isset($matches)) {
                foreach ($matches as $k => $m) {
                    $length = strlen($m->name);
                    if ($length > $max) {