add_record.php
author Peter Gervai <grin@grin.hu>
Fri, 14 Nov 2008 14:40:26 +0100
changeset 197 eabe847b2b65
parent 182 049347a649e0
permissions -rw-r--r--
Added tag release_2.1.2 for changeset 1e24ee6c41e5
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
     1
<?php
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
     2
119
f74e4f88b680 [feladat @ 222]
rejo
parents: 110
diff changeset
     3
/*  Poweradmin, a friendly web-based admin tool for PowerDNS.
47
ae140472d97c [feladat @ 94]
rejo
parents: 37
diff changeset
     4
 *  See <https://rejo.zenger.nl/poweradmin> for more details.
ae140472d97c [feladat @ 94]
rejo
parents: 37
diff changeset
     5
 *
ae140472d97c [feladat @ 94]
rejo
parents: 37
diff changeset
     6
 *  Copyright 2007, 2008  Rejo Zenger <rejo@zenger.nl>
ae140472d97c [feladat @ 94]
rejo
parents: 37
diff changeset
     7
 *
ae140472d97c [feladat @ 94]
rejo
parents: 37
diff changeset
     8
 *  This program is free software: you can redistribute it and/or modify
ae140472d97c [feladat @ 94]
rejo
parents: 37
diff changeset
     9
 *  it under the terms of the GNU General Public License as published by
ae140472d97c [feladat @ 94]
rejo
parents: 37
diff changeset
    10
 *  the Free Software Foundation, either version 3 of the License, or
ae140472d97c [feladat @ 94]
rejo
parents: 37
diff changeset
    11
 *  (at your option) any later version.
ae140472d97c [feladat @ 94]
rejo
parents: 37
diff changeset
    12
 *
ae140472d97c [feladat @ 94]
rejo
parents: 37
diff changeset
    13
 *  This program is distributed in the hope that it will be useful,
ae140472d97c [feladat @ 94]
rejo
parents: 37
diff changeset
    14
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
ae140472d97c [feladat @ 94]
rejo
parents: 37
diff changeset
    15
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
ae140472d97c [feladat @ 94]
rejo
parents: 37
diff changeset
    16
 *  GNU General Public License for more details.
ae140472d97c [feladat @ 94]
rejo
parents: 37
diff changeset
    17
 *
ae140472d97c [feladat @ 94]
rejo
parents: 37
diff changeset
    18
 *  You should have received a copy of the GNU General Public License
ae140472d97c [feladat @ 94]
rejo
parents: 37
diff changeset
    19
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
ae140472d97c [feladat @ 94]
rejo
parents: 37
diff changeset
    20
 */
ae140472d97c [feladat @ 94]
rejo
parents: 37
diff changeset
    21
13
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
    22
require_once("inc/toolkit.inc.php");
82
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
    23
include_once("inc/header.inc.php");
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    24
126
cb06e3e29ed8 [feladat @ 230]
peter
parents: 119
diff changeset
    25
if (verify_permission('zone_content_view_others')) { $perm_view = "all" ; }
cb06e3e29ed8 [feladat @ 230]
peter
parents: 119
diff changeset
    26
elseif (verify_permission('zone_content_view_own')) { $perm_view = "own" ; }
82
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
    27
else { $perm_view = "none" ; }
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
    28
126
cb06e3e29ed8 [feladat @ 230]
peter
parents: 119
diff changeset
    29
if (verify_permission('zone_content_edit_others')) { $perm_content_edit = "all" ; }
cb06e3e29ed8 [feladat @ 230]
peter
parents: 119
diff changeset
    30
elseif (verify_permission('zone_content_edit_own')) { $perm_content_edit = "own" ; }
82
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
    31
else { $perm_content_edit = "none" ; }
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
    32
126
cb06e3e29ed8 [feladat @ 230]
peter
parents: 119
diff changeset
    33
if (verify_permission('zone_meta_edit_others')) { $perm_meta_edit = "all" ; }
cb06e3e29ed8 [feladat @ 230]
peter
parents: 119
diff changeset
    34
elseif (verify_permission('zone_meta_edit_own')) { $perm_meta_edit = "own" ; }
82
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
    35
else { $perm_meta_edit = "none" ; }
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
    36
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
    37
$zone_id = "-1";
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
    38
if ((isset($_GET['id'])) && (v_num($_GET['id']))) {
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
    39
	$zone_id = $_GET['id'];
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
    40
}
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
    41
136
c795dd75a77e [feladat @ 242]
rejo
parents: 132
diff changeset
    42
$ttl = $dns_ttl;
82
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
    43
if ((isset($_POST['ttl'])) && (v_num($_POST['ttl']))) {
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
    44
	$ttl = $_POST['ttl'];
37
b785e54690ce [feladat @ 84]
rejo
parents: 13
diff changeset
    45
}
b785e54690ce [feladat @ 84]
rejo
parents: 13
diff changeset
    46
82
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
    47
$prio = "10";
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
    48
if ((isset($_GET['prio'])) && (v_num($_GET['prio']))) {
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
    49
	$prio = $_GET['prio'];
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
    50
}
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
    51
182
049347a649e0 [feladat @ 290]
rejo
parents: 140
diff changeset
    52
if (isset($_POST['name'])) {
049347a649e0 [feladat @ 290]
rejo
parents: 140
diff changeset
    53
	$name = $_POST['name'];
049347a649e0 [feladat @ 290]
rejo
parents: 140
diff changeset
    54
} else {
049347a649e0 [feladat @ 290]
rejo
parents: 140
diff changeset
    55
	$name = "";
049347a649e0 [feladat @ 290]
rejo
parents: 140
diff changeset
    56
}
049347a649e0 [feladat @ 290]
rejo
parents: 140
diff changeset
    57
049347a649e0 [feladat @ 290]
rejo
parents: 140
diff changeset
    58
if (isset($_POST['type'])) { 
049347a649e0 [feladat @ 290]
rejo
parents: 140
diff changeset
    59
	$type = $_POST['type'];
049347a649e0 [feladat @ 290]
rejo
parents: 140
diff changeset
    60
} else {
049347a649e0 [feladat @ 290]
rejo
parents: 140
diff changeset
    61
	$type = "";
049347a649e0 [feladat @ 290]
rejo
parents: 140
diff changeset
    62
}
049347a649e0 [feladat @ 290]
rejo
parents: 140
diff changeset
    63
049347a649e0 [feladat @ 290]
rejo
parents: 140
diff changeset
    64
if (isset($_POST['content'])) { 
049347a649e0 [feladat @ 290]
rejo
parents: 140
diff changeset
    65
	$content = $_POST['content'];
049347a649e0 [feladat @ 290]
rejo
parents: 140
diff changeset
    66
} else {
049347a649e0 [feladat @ 290]
rejo
parents: 140
diff changeset
    67
	$content = "";
049347a649e0 [feladat @ 290]
rejo
parents: 140
diff changeset
    68
}
82
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
    69
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
    70
if ($zone_id == "-1") {
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
    71
	error(ERR_INV_INPUT);
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
    72
	include_once("inc/footer.inc.php");
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
    73
	exit;
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
    74
}
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
    75
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
    76
$user_is_zone_owner = verify_user_is_owner_zoneid($zone_id);
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
    77
$zone_type = get_domain_type($zone_id);
140
e68c3d6094d1 [feladat @ 246]
rejo
parents: 136
diff changeset
    78
$zone_name = get_zone_name_from_id($zone_id);
82
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
    79
182
049347a649e0 [feladat @ 290]
rejo
parents: 140
diff changeset
    80
if (isset($_POST["commit"])) {
82
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
    81
	if ( $zone_type == "SLAVE" || $perm_content_edit == "none" || $perm_content_edit == "own" && $user_is_zone_owner == "0" ) {
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
    82
		error(ERR_PERM_ADD_RECORD);
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
    83
	} else {
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
    84
		if ( add_record($zone_id, $name, $type, $content, $ttl, $prio)) {
132
155178ad24e4 [feladat @ 238]
rejo
parents: 126
diff changeset
    85
			success(_('The record was successfully added.'));
182
049347a649e0 [feladat @ 290]
rejo
parents: 140
diff changeset
    86
			$name = $type = $content = $ttl = $prio = "";
82
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
    87
		}
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
    88
	}
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    89
}
13
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
    90
110
455405c757e1 [feladat @ 210]
rejo
parents: 82
diff changeset
    91
echo "    <h2>" . _('Add record to zone') . " " .  $zone_name . "</h2>\n";
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    92
82
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
    93
if ( $zone_type == "SLAVE" || $perm_content_edit == "none" || $perm_content_edit == "own" && $user_is_zone_owner == "0" ) {
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
    94
	error(ERR_PERM_ADD_RECORD); 
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
    95
} else {
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
    96
	echo "     <form method=\"post\">\n";
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
    97
	echo "      <input type=\"hidden\" name=\"domain\" value=\"" . $zone_id . "\">\n";
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
    98
	echo "      <table border=\"0\" cellspacing=\"4\">\n";
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
    99
	echo "       <tr>\n";
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
   100
	echo "        <td class=\"n\">" . _('Name') . "</td>\n";
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
   101
	echo "        <td class=\"n\">&nbsp;</td>\n";
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
   102
	echo "        <td class=\"n\">" . _('Type') . "</td>\n";
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
   103
	echo "        <td class=\"n\">" . _('Priority') .  "</td>\n";
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
   104
	echo "        <td class=\"n\">" . _('Content') . "</td>\n";
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
   105
	echo "        <td class=\"n\">" . _('TTL') . "</td>\n";
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
   106
	echo "       </tr>\n";
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
   107
	echo "       <tr>\n";
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
   108
	echo "        <td class=\"n\"><input type=\"text\" name=\"name\" class=\"input\" value=\"" . $name . "\">." . $zone_name . "</td>\n";
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
   109
	echo "        <td class=\"n\">IN</td>\n";
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
   110
	echo "        <td class=\"n\">\n";
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
   111
	echo "         <select name=\"type\">\n";
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
   112
	foreach (get_record_types() as $record_type) {
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
   113
		if ($type) {
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
   114
			if ($type == $record_type) {
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
   115
				$add = " SELECTED";
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
   116
			} else {
182
049347a649e0 [feladat @ 290]
rejo
parents: 140
diff changeset
   117
				$add = "";
82
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
   118
			}
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
   119
		} else {
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
   120
			if (eregi('in-addr.arpa', $zone_name) && strtoupper($record_type) == 'PTR') {
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
   121
				$add = " SELECTED";
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
   122
			} elseif (strtoupper($record_type) == 'A') {
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
   123
				$add = " SELECTED";
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
   124
			} else {
182
049347a649e0 [feladat @ 290]
rejo
parents: 140
diff changeset
   125
				$add = "";
82
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
   126
			}
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
   127
		}
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
   128
		echo "          <option" . $add . " value=\"" . $record_type . "\">" . $record_type . "</option>\n";
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
   129
	}
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
   130
	echo "         </select>\n";
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
   131
	echo "        </td>\n";
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
   132
	echo "        <td class=\"n\"><input type=\"text\" name=\"prio\" class=\"sinput\" value=\"" . $prio . "\"></td>\n";
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
   133
	echo "        <td class=\"n\"><input type=\"text\" name=\"content\" class=\"input\" value=\"" . $content . "\"></td>\n";
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
   134
	echo "        <td class=\"n\"><input type=\"text\" name=\"ttl\" class=\"sinput\" value=\"" . $ttl . "\"</td>\n";
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
   135
	echo "       </tr>\n";
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
   136
	echo "      </table>\n";
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
   137
	echo "      <br>\n";
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
   138
	echo "      <input type=\"submit\" name=\"commit\" value=\"" .  _('Add record') . "\" class=\"button\">\n";
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
   139
	echo "     </form>\n";
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   140
}
82
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
   141
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
   142
include_once("inc/footer.inc.php"); 
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
   143
13
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
   144
?>