Ejemplo n.º 1
0
# verify that user is logged in
$User->check_user_session();
# fetch old record
if ($_POST['action'] != "add") {
    $record = $PowerDNS->fetch_record($_POST['id']);
    $record !== false ?: $Result->show("danger", _("Invalid ID"), true, true);
}
# edit and add - check that smth is in name and content!
if ($_POST['action'] != "delete") {
    if (strlen($_POST['name']) < 2) {
        $Result->show("danger", _("Invalid name"), true);
    }
    if (strlen($_POST['content']) < 2) {
        $Result->show("danger", _("Invalid content"), true);
    }
}
# validate and set values
if ($_POST['action'] == "edit") {
    $values = $PowerDNS->formulate_update_record($_POST['name'], $_POST['type'], $_POST['content'], $_POST['ttl'], $_POST['prio'], $_POST['disabled'], $record->change_date);
    $values['domain_id'] = $_POST['domain_id'];
} elseif ($_POST['action'] == "add") {
    $values = $PowerDNS->formulate_new_record($_POST['domain_id'], $_POST['name'], $_POST['type'], $_POST['content'], $_POST['ttl'], $_POST['prio'], $_POST['disabled']);
} elseif ($_POST['action'] == "delete") {
    $values['domain_id'] = $_POST['domain_id'];
}
# add id
$values['id'] = @$_POST['id'];
# remove empty records
$values = $PowerDNS->remove_empty_array_fields($values);
# update
$PowerDNS->record_edit($_POST['action'], $values);
    $PowerDNS->create_default_records($values);
}
// remove existing records and links
$PowerDNS->remove_all_ptr_records($domain->id);
$Addresses->ptr_unlink_subnet_addresses($subnet->id);
// fetch all hosts
$hosts = $Addresses->fetch_subnet_addresses($subnet->id, "ip_addr", "asc");
// create PTR records
if (sizeof($hosts) > 0) {
    foreach ($hosts as $h) {
        // ignore PTR
        if ($h->PTRignore == "1") {
            $ignored[] = $h;
        } elseif ($Result->validate_hostname($h->dns_name) !== false) {
            // formulate new record
            $record = $PowerDNS->formulate_new_record($domain->id, $PowerDNS->get_ip_ptr_name($h->ip), "PTR", $h->dns_name, $values['ttl']);
            // insert record
            $PowerDNS->add_domain_record($record, false);
            // link
            $Addresses->ptr_link($h->id, $PowerDNS->lastId);
            // ok
            $success[] = $h;
        } else {
            $failures[] = $h;
        }
    }
} else {
    $empty = true;
}
# generate print
if (sizeof(@$success) > 0) {