edit_record.php
author peter
Fri, 26 Sep 2008 10:02:33 +0000
changeset 194 df674d004508
parent 185 6baa2f78d3fe
permissions -rw-r--r--
[feladat @ 307] Minor bug fix: bg.shiny@gmail.com reported that cyrillic characters where not supported. Applied the patch which was supplied. This closes #93.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
71
e1b918eaf69a [feladat @ 118]
peter
parents: 65
diff changeset
     1
<?php
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
     2
119
f74e4f88b680 [feladat @ 222]
rejo
parents: 82
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
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    22
require_once("inc/toolkit.inc.php");
82
c255196bc447 [feladat @ 182]
rejo
parents: 80
diff changeset
    23
include_once("inc/header.inc.php");
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    24
126
cb06e3e29ed8 [feladat @ 230]
peter
parents: 120
diff changeset
    25
if (verify_permission('zone_content_view_others')) { $perm_view = "all" ; }
cb06e3e29ed8 [feladat @ 230]
peter
parents: 120
diff changeset
    26
elseif (verify_permission('zone_content_view_own')) { $perm_view = "own" ; }
82
c255196bc447 [feladat @ 182]
rejo
parents: 80
diff changeset
    27
else { $perm_view = "none" ; }
c255196bc447 [feladat @ 182]
rejo
parents: 80
diff changeset
    28
126
cb06e3e29ed8 [feladat @ 230]
peter
parents: 120
diff changeset
    29
if (verify_permission('zone_content_edit_others')) { $perm_content_edit = "all" ; }
cb06e3e29ed8 [feladat @ 230]
peter
parents: 120
diff changeset
    30
elseif (verify_permission('zone_content_edit_own')) { $perm_content_edit = "own" ; }
82
c255196bc447 [feladat @ 182]
rejo
parents: 80
diff changeset
    31
else { $perm_content_edit = "none" ; }
c255196bc447 [feladat @ 182]
rejo
parents: 80
diff changeset
    32
126
cb06e3e29ed8 [feladat @ 230]
peter
parents: 120
diff changeset
    33
if (verify_permission('zone_meta_edit_others')) { $perm_meta_edit = "all" ; }
cb06e3e29ed8 [feladat @ 230]
peter
parents: 120
diff changeset
    34
elseif (verify_permission('zone_meta_edit_own')) { $perm_meta_edit = "own" ; }
82
c255196bc447 [feladat @ 182]
rejo
parents: 80
diff changeset
    35
else { $perm_meta_edit = "none" ; }
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    36
127
e2c54e888f7e [feladat @ 231]
rejo
parents: 126
diff changeset
    37
$zid = get_zone_id_from_record_id($_GET['id']);
120
982f722376b4 [feladat @ 223]
rejo
parents: 119
diff changeset
    38
982f722376b4 [feladat @ 223]
rejo
parents: 119
diff changeset
    39
$user_is_zone_owner = verify_user_is_owner_zoneid($zid);
982f722376b4 [feladat @ 223]
rejo
parents: 119
diff changeset
    40
$zone_type = get_domain_type($zid);
140
e68c3d6094d1 [feladat @ 246]
rejo
parents: 127
diff changeset
    41
$zone_name = get_zone_name_from_id($zid);
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    42
185
6baa2f78d3fe [feladat @ 293]
rejo
parents: 140
diff changeset
    43
if (isset($_POST["commit"])) {
82
c255196bc447 [feladat @ 182]
rejo
parents: 80
diff changeset
    44
	if ( $zone_type == "SLAVE" || $perm_content_edit == "none" || $perm_content_edit == "own" && $user_is_zone_owner == "0" ) {
c255196bc447 [feladat @ 182]
rejo
parents: 80
diff changeset
    45
		error(ERR_PERM_EDIT_RECORD);
c255196bc447 [feladat @ 182]
rejo
parents: 80
diff changeset
    46
	} else {
127
e2c54e888f7e [feladat @ 231]
rejo
parents: 126
diff changeset
    47
		$ret_val = edit_record($_POST);
82
c255196bc447 [feladat @ 182]
rejo
parents: 80
diff changeset
    48
		if ( $ret_val == "1" ) {
c255196bc447 [feladat @ 182]
rejo
parents: 80
diff changeset
    49
			success(SUC_RECORD_UPD);
c255196bc447 [feladat @ 182]
rejo
parents: 80
diff changeset
    50
		} else {
c255196bc447 [feladat @ 182]
rejo
parents: 80
diff changeset
    51
			echo "     <div class=\"error\">" . $ret_val . "</div>\n";  
c255196bc447 [feladat @ 182]
rejo
parents: 80
diff changeset
    52
		}
c255196bc447 [feladat @ 182]
rejo
parents: 80
diff changeset
    53
	}
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    54
}
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    55
82
c255196bc447 [feladat @ 182]
rejo
parents: 80
diff changeset
    56
echo "    <h2>" . _('Edit record in zone') . " " .  $zone_name . "</h2>\n";
c255196bc447 [feladat @ 182]
rejo
parents: 80
diff changeset
    57
c255196bc447 [feladat @ 182]
rejo
parents: 80
diff changeset
    58
if ( $perm_view == "none" || $perm_view == "own" && $user_is_zone_owner == "0" ) {
c255196bc447 [feladat @ 182]
rejo
parents: 80
diff changeset
    59
	error(ERR_PERM_VIEW_RECORD);
c255196bc447 [feladat @ 182]
rejo
parents: 80
diff changeset
    60
} else {
c255196bc447 [feladat @ 182]
rejo
parents: 80
diff changeset
    61
	$record = get_record_from_id($_GET["id"]);
120
982f722376b4 [feladat @ 223]
rejo
parents: 119
diff changeset
    62
	echo "     <form method=\"post\" action=\"edit_record.php?domain=" . $zid . "&id=" . $_GET["id"] . "\">\n";
82
c255196bc447 [feladat @ 182]
rejo
parents: 80
diff changeset
    63
	echo "      <table>\n";
c255196bc447 [feladat @ 182]
rejo
parents: 80
diff changeset
    64
	echo "       <tr>\n";
c255196bc447 [feladat @ 182]
rejo
parents: 80
diff changeset
    65
	echo "        <th>" . _('Name') . "</td>\n";
c255196bc447 [feladat @ 182]
rejo
parents: 80
diff changeset
    66
	echo "        <th>&nbsp;</td>\n";
c255196bc447 [feladat @ 182]
rejo
parents: 80
diff changeset
    67
	echo "        <th>" . _('Type') . "</td>\n";
c255196bc447 [feladat @ 182]
rejo
parents: 80
diff changeset
    68
	echo "        <th>" . _('Priority') . "</td>\n";
c255196bc447 [feladat @ 182]
rejo
parents: 80
diff changeset
    69
	echo "        <th>" . _('Content') . "</td>\n";
c255196bc447 [feladat @ 182]
rejo
parents: 80
diff changeset
    70
	echo "        <th>" . _('TTL') . "</td>\n";
c255196bc447 [feladat @ 182]
rejo
parents: 80
diff changeset
    71
	echo "       </tr>\n";
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    72
82
c255196bc447 [feladat @ 182]
rejo
parents: 80
diff changeset
    73
	if ( $zone_type == "SLAVE" || $perm_content_edit == "none" || $perm_content_edit == "own" && $user_is_zone_owner == "0" ) {
c255196bc447 [feladat @ 182]
rejo
parents: 80
diff changeset
    74
		echo "      <tr>\n";
c255196bc447 [feladat @ 182]
rejo
parents: 80
diff changeset
    75
		echo "       <td>" . $record["name"] . "</td>\n";
c255196bc447 [feladat @ 182]
rejo
parents: 80
diff changeset
    76
		echo "       <td>IN</td>\n";
c255196bc447 [feladat @ 182]
rejo
parents: 80
diff changeset
    77
		echo "       <td>" . $record["type"] . "</td>\n";
c255196bc447 [feladat @ 182]
rejo
parents: 80
diff changeset
    78
		echo "       <td>" . $record["content"] . "</td>\n";
c255196bc447 [feladat @ 182]
rejo
parents: 80
diff changeset
    79
		echo "       <td>" . $record["prio"] . "</td>\n";
c255196bc447 [feladat @ 182]
rejo
parents: 80
diff changeset
    80
		echo "       <td>" . $record["ttl"] . "</td>\n";
c255196bc447 [feladat @ 182]
rejo
parents: 80
diff changeset
    81
		echo "      </tr>\n";
c255196bc447 [feladat @ 182]
rejo
parents: 80
diff changeset
    82
	} else {
127
e2c54e888f7e [feladat @ 231]
rejo
parents: 126
diff changeset
    83
		echo "      <input type=\"hidden\" name=\"rid\" value=\"" . $_GET["id"] . "\">\n";
e2c54e888f7e [feladat @ 231]
rejo
parents: 126
diff changeset
    84
		echo "      <input type=\"hidden\" name=\"zid\" value=\"" . $zid . "\">\n";
82
c255196bc447 [feladat @ 182]
rejo
parents: 80
diff changeset
    85
		echo "      <tr>\n";
c255196bc447 [feladat @ 182]
rejo
parents: 80
diff changeset
    86
		echo "       <td><input type=\"text\" name=\"name\" value=\"" . trim(str_replace($zone_name, '', $record["name"]), '.') . "\" class=\"input\">." . $zone_name . "</td>\n";
c255196bc447 [feladat @ 182]
rejo
parents: 80
diff changeset
    87
		echo "       <td>IN</td>\n";
c255196bc447 [feladat @ 182]
rejo
parents: 80
diff changeset
    88
		echo "       <td>\n";
c255196bc447 [feladat @ 182]
rejo
parents: 80
diff changeset
    89
		echo "        <select name=\"type\">\n";
c255196bc447 [feladat @ 182]
rejo
parents: 80
diff changeset
    90
		foreach (get_record_types() as $type_available) {
c255196bc447 [feladat @ 182]
rejo
parents: 80
diff changeset
    91
			if ($type_available == $record["type"]) {
c255196bc447 [feladat @ 182]
rejo
parents: 80
diff changeset
    92
				$add = " SELECTED";
c255196bc447 [feladat @ 182]
rejo
parents: 80
diff changeset
    93
			} else {
c255196bc447 [feladat @ 182]
rejo
parents: 80
diff changeset
    94
				$add = "";
c255196bc447 [feladat @ 182]
rejo
parents: 80
diff changeset
    95
			}
c255196bc447 [feladat @ 182]
rejo
parents: 80
diff changeset
    96
			echo "         <option" . $add . " value=\"" . $type_available . "\" >" . $type_available . "</option>\n";
c255196bc447 [feladat @ 182]
rejo
parents: 80
diff changeset
    97
		}
c255196bc447 [feladat @ 182]
rejo
parents: 80
diff changeset
    98
		echo "        </select>\n";
c255196bc447 [feladat @ 182]
rejo
parents: 80
diff changeset
    99
		echo "       </td>\n";
c255196bc447 [feladat @ 182]
rejo
parents: 80
diff changeset
   100
		echo "       <td><input type=\"text\" name=\"prio\" value=\"" .  $record["prio"] . "\" class=\"sinput\"></td>\n";
c255196bc447 [feladat @ 182]
rejo
parents: 80
diff changeset
   101
		echo "       <td><input type=\"text\" name=\"content\" value=\"" .  $record["content"] . "\" class=\"input\"></td>\n";
c255196bc447 [feladat @ 182]
rejo
parents: 80
diff changeset
   102
		echo "       <td><input type=\"text\" name=\"ttl\" value=\"" . $record["ttl"] . "\" class=\"sinput\"></td>\n";
c255196bc447 [feladat @ 182]
rejo
parents: 80
diff changeset
   103
		echo "      </tr>\n";
13
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
   104
	}
82
c255196bc447 [feladat @ 182]
rejo
parents: 80
diff changeset
   105
	echo "      </table>\n";
c255196bc447 [feladat @ 182]
rejo
parents: 80
diff changeset
   106
	echo "      <p>\n";
c255196bc447 [feladat @ 182]
rejo
parents: 80
diff changeset
   107
	echo "       <input type=\"submit\" name=\"commit\" value=\"" . _('Commit changes') . "\" class=\"button\">&nbsp;&nbsp;\n";
c255196bc447 [feladat @ 182]
rejo
parents: 80
diff changeset
   108
	echo "      </p>\n";
c255196bc447 [feladat @ 182]
rejo
parents: 80
diff changeset
   109
	echo "     </form>\n";
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   110
}
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   111
82
c255196bc447 [feladat @ 182]
rejo
parents: 80
diff changeset
   112
13
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
   113
include_once("inc/footer.inc.php");
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   114
?>
82
c255196bc447 [feladat @ 182]
rejo
parents: 80
diff changeset
   115