for more details. * * Copyright 2007-2010 Rejo Zenger * Copyright 2010-2014 Poweradmin Development Team * * * This program is free software: you can redistribute it and/or modify * 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 . * */ /** * Script that handles editing of zone records * * @package Poweradmin * @copyright 2007-2010 Rejo Zenger * @copyright 2010-2014 Poweradmin Development Team * @license http://opensource.org/licenses/GPL-3.0 GPL */ require_once("inc/toolkit.inc.php"); include_once("inc/header.inc.php"); global $pdnssec_use; $zone_id = "-1"; if (isset($_GET['id']) && v_num($_GET['id'])) { $zone_id = $_GET['id']; } if ($zone_id == "-1") { error(ERR_INV_INPUT); include_once("inc/footer.inc.php"); exit; } if (isset($_POST['commit'])) { $error = false; if (isset($_POST['record'])) { foreach ($_POST['record'] as $record) { $old_record_info = get_record_from_id($record['rid']); $edit_record = edit_record($record); if (false === $edit_record) { $error = true; } else { $new_record_info = get_record_from_id($record["rid"]); //Figure out if record was updated unset($new_record_info["change_date"]); unset($old_record_info["change_date"]); if ($new_record_info != $old_record_info){ //The record was changed, so log the edit_record operation log_info(sprintf('client_ip:%s user:%s operation:edit_record' .' old_record_type:%s old_record:%s old_content:%s old_ttl:%s old_priority:%s' .' record_type:%s record:%s content:%s ttl:%s priority:%s', $_SERVER['REMOTE_ADDR'], $_SESSION["userlogin"], $old_record_info['type'], $old_record_info['name'], $old_record_info['content'], $old_record_info['ttl'], $old_record_info['prio'], $new_record_info['type'], $new_record_info['name'], $new_record_info['content'], $new_record_info['ttl'], $new_record_info['prio'])); } } } } edit_zone_comment($_GET['id'], $_POST['comment']); if (false === $error) { update_soa_serial($_GET['id']); success(SUC_ZONE_UPD); if ($pdnssec_use) { if (dnssec_rectify_zone($_GET['id'])) { success(SUC_EXEC_PDNSSEC_RECTIFY_ZONE); } } } else { error(ERR_ZONE_UPD); } } if (isset($_POST['save_as'])) { if (zone_templ_name_exists($_POST['templ_name'])) { error(ERR_ZONE_TEMPL_EXIST); } elseif ($_POST['templ_name'] == '') { error(ERR_ZONE_TEMPL_IS_EMPTY); } else { success(SUC_ZONE_TEMPL_ADD); $records = get_records_from_domain_id($zone_id); add_zone_templ_save_as($_POST['templ_name'], $_POST['templ_descr'], $_SESSION['userid'], $records, get_zone_name_from_id($zone_id)); } } /* Check permissions */ if (verify_permission('zone_content_view_others')) { $perm_view = "all"; } elseif (verify_permission('zone_content_view_own')) { $perm_view = "own"; } else { $perm_view = "none"; } if (verify_permission('zone_content_edit_others')) { $perm_content_edit = "all"; } elseif (verify_permission('zone_content_edit_own')) { $perm_content_edit = "own"; } else { $perm_content_edit = "none"; } if (verify_permission('zone_meta_edit_others')) { $perm_meta_edit = "all"; } elseif (verify_permission('zone_meta_edit_own')) { $perm_meta_edit = "own"; } else { $perm_meta_edit = "none"; } verify_permission('zone_master_add') ? $perm_zone_master_add = "1" : $perm_zone_master_add = "0"; verify_permission('zone_slave_add') ? $perm_zone_slave_add = "1" : $perm_zone_slave_add = "0"; $user_is_zone_owner = verify_user_is_owner_zoneid($zone_id); if ($perm_meta_edit == "all" || ( $perm_meta_edit == "own" && $user_is_zone_owner == "1")) { $meta_edit = "1"; } else { $meta_edit = "0"; } (verify_permission('user_view_others')) ? $perm_view_others = "1" : $perm_view_others = "0"; if (isset($_POST['slave_master_change']) && is_numeric($_POST["domain"])) { change_zone_slave_master($_POST['domain'], $_POST['new_master']); } if (isset($_POST['type_change']) && in_array($_POST['newtype'], $server_types)) { change_zone_type($_POST['newtype'], $zone_id); } if (isset($_POST["newowner"]) && is_numeric($_POST["domain"]) && is_numeric($_POST["newowner"])) { add_owner_to_zone($_POST["domain"], $_POST["newowner"]); } if (isset($_POST["delete_owner"]) && is_numeric($_POST["delete_owner"])) { delete_owner_from_zone($zone_id, $_POST["delete_owner"]); } if (isset($_POST["template_change"])) { if (!isset($_POST['zone_template']) || "none" == $_POST['zone_template']) { $new_zone_template = 0; } else { $new_zone_template = $_POST['zone_template']; } if ($_POST['current_zone_template'] != $new_zone_template) { update_zone_records($zone_id, $new_zone_template); } } if ($perm_view == "none" || $perm_view == "own" && $user_is_zone_owner == "0") { error(ERR_PERM_VIEW_ZONE); include_once("inc/footer.inc.php"); exit(); } if (zone_id_exists($zone_id) == "0") { error(ERR_ZONE_NOT_EXIST); include_once("inc/footer.inc.php"); exit(); } if (isset($_POST['sign_zone'])) { $zone_name = get_zone_name_from_id($zone_id); update_soa_serial($zone_id); dnssec_secure_zone($zone_name); dnssec_rectify_zone($zone_id); } if (isset($_POST['unsign_zone'])) { $zone_name = get_zone_name_from_id($zone_id); dnssec_unsecure_zone($zone_name); update_soa_serial($zone_id); } $domain_type = get_domain_type($zone_id); $record_count = count_zone_records($zone_id); $zone_templates = get_list_zone_templ($_SESSION['userid']); $zone_template_id = get_zone_template($zone_id); echo "

" . _('Edit zone') . " \"" . get_zone_name_from_id($zone_id) . "\"

\n"; echo "
\n"; show_pages($record_count, $iface_rowamount, $zone_id); echo "
\n"; $records = get_records_from_domain_id($zone_id, ROWSTART, $iface_rowamount, RECORD_SORT_BY); if ($records == "-1") { echo "

" . _("This zone does not have any records. Weird.") . "

\n"; } else { echo "
\n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; foreach ($records as $r) { if ($r['type'] != "SOA") { echo " \n"; echo " \n"; } echo " \n"; if ($domain_type == "SLAVE" || $perm_content_edit == "none" || $perm_content_edit == "own" && $user_is_zone_owner == "0") { echo " \n"; } else { echo " \n"; } echo " \n"; if ($r['type'] == "SOA") { echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; } else { echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; } echo " \n"; } echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo "
 " . _('Id') . "" . _('Name') . "" . _('Type') . "" . _('Content') . "" . _('Priority') . "" . _('TTL') . "
 \n"; echo " \"[\n"; echo " \"[\n"; echo " {$r['id']}" . $r['name'] . "" . $r['type'] . "" . $r['content'] . " " . $r['ttl'] . "\n"; echo " \n"; echo "
 
 Comments:
\n"; echo " \"[\n"; echo "  

Save as new template:
" . _('Template Name') . "
" . _('Template Description') . "
\n"; echo " \n"; echo " \n"; echo " \n"; if ($pdnssec_use) { $zone_name = get_zone_name_from_id($zone_id); if (dnssec_is_zone_secured($zone_name)) { echo " \n"; echo " \n"; } else { echo " \n"; } } echo "
\n"; } if ($perm_content_edit == "all" || $perm_content_edit == "own" && $user_is_zone_owner == "1") { if ($domain_type != "SLAVE") { $zone_name = get_zone_name_from_id($zone_id); echo "
\n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo "
" . _('Name') . " " . _('Type') . "" . _('Content') . "" . _('Priority') . "" . _('TTL') . "
." . $zone_name . "IN\n"; echo " " . _('Add also reverse record') . "\n"; } else { $add = ""; } } echo " " . $record_type . "\n"; } if (!$found_selected_type) echo " \n"; echo " \n"; echo "
\n"; echo " \n"; echo " $rev"; echo "
\n"; } } echo "
\n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; $owners = get_users_from_domain_id($zone_id); if ($owners == "-1") { echo " "; } else { if ($meta_edit) { foreach ($owners as $owner) { echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; } } else { foreach ($owners as $owner) { echo " "; } } } if ($meta_edit) { echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; } echo " \n"; echo " \n"; echo " \n"; if ($meta_edit) { echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; } else { echo " \n"; } echo " \n"; echo " \n"; echo " \n"; if ($meta_edit) { echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; } else { $zone_template_details = get_zone_templ_details($zone_template_id); echo " \n"; } if ($domain_type == "SLAVE") { $slave_master = get_domain_slave_master($zone_id); echo " \n"; echo " \n"; echo " \n"; if ($meta_edit) { echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; } else { echo " \n"; } } echo "
" . _('Owner of zone') . "
" . _('No owner set for this zone.') . "
" . $owner["fullname"] . "\n"; echo " \n"; echo " \n"; echo "
" . $owner["fullname"] . " 
\n"; echo " \n"; echo " \n"; echo " \n"; echo "
" . _('Type') . "
\n"; echo " \n"; echo " \n"; echo " \n"; echo "
" . strtolower($domain_type) . " 
" . _('Template') . "
\n"; echo " \n"; echo " \n"; echo " \n"; echo "
" . (isset($zone_template_details) ? strtolower($zone_template_details['name']) : "none" ) . " 
" . _('IP address of master NS') . "
\n"; echo " \n"; echo " \n"; echo " \n"; echo "
" . $slave_master . " 
\n"; echo "
\n"; // eo div meta include_once("inc/footer.inc.php");