edit_record.php
author peter
Sun, 30 Mar 2008 11:46:45 +0000
changeset 113 e7a448dba024
parent 82 c255196bc447
child 119 f74e4f88b680
permissions -rw-r--r--
[feladat @ 213] Modified the inserts in the pgsql db structure to make sure no duplicate key errors are shown when a new records is created. Also moved the Ueber_user permision item upfront, to make sure it is created with id 1 so the permission template can be created correctly. Added an additional query to check what the ID is of the ueber_user, as it set hardcoded to 53 in the query.
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
47
ae140472d97c [feladat @ 94]
rejo
parents: 37
diff changeset
     3
/*  PowerAdmin, a friendly web-based admin tool for PowerDNS.
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
82
c255196bc447 [feladat @ 182]
rejo
parents: 80
diff changeset
    25
if (verify_permission(zone_content_view_others)) { $perm_view = "all" ; }
c255196bc447 [feladat @ 182]
rejo
parents: 80
diff changeset
    26
elseif (verify_permission(zone_content_view_own)) { $perm_view = "own" ; }
c255196bc447 [feladat @ 182]
rejo
parents: 80
diff changeset
    27
else { $perm_view = "none" ; }
c255196bc447 [feladat @ 182]
rejo
parents: 80
diff changeset
    28
c255196bc447 [feladat @ 182]
rejo
parents: 80
diff changeset
    29
if (verify_permission(zone_content_edit_others)) { $perm_content_edit = "all" ; }
c255196bc447 [feladat @ 182]
rejo
parents: 80
diff changeset
    30
elseif (verify_permission(zone_content_edit_own)) { $perm_content_edit = "own" ; }
c255196bc447 [feladat @ 182]
rejo
parents: 80
diff changeset
    31
else { $perm_content_edit = "none" ; }
c255196bc447 [feladat @ 182]
rejo
parents: 80
diff changeset
    32
c255196bc447 [feladat @ 182]
rejo
parents: 80
diff changeset
    33
if (verify_permission(zone_meta_edit_others)) { $perm_meta_edit = "all" ; }
c255196bc447 [feladat @ 182]
rejo
parents: 80
diff changeset
    34
elseif (verify_permission(zone_meta_edit_own)) { $perm_meta_edit = "own" ; }
c255196bc447 [feladat @ 182]
rejo
parents: 80
diff changeset
    35
else { $perm_meta_edit = "none" ; }
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    36
82
c255196bc447 [feladat @ 182]
rejo
parents: 80
diff changeset
    37
$user_is_zone_owner = verify_user_is_owner_zoneid($_GET["domain"]);
c255196bc447 [feladat @ 182]
rejo
parents: 80
diff changeset
    38
$zone_type = get_domain_type($_GET["domain"]);
c255196bc447 [feladat @ 182]
rejo
parents: 80
diff changeset
    39
$zone_name = get_domain_name_from_id($_GET["domain"]);
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    40
82
c255196bc447 [feladat @ 182]
rejo
parents: 80
diff changeset
    41
if ($_POST["commit"]) {
c255196bc447 [feladat @ 182]
rejo
parents: 80
diff changeset
    42
	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
    43
		error(ERR_PERM_EDIT_RECORD);
c255196bc447 [feladat @ 182]
rejo
parents: 80
diff changeset
    44
	} else {
c255196bc447 [feladat @ 182]
rejo
parents: 80
diff changeset
    45
		$ret_val = edit_record($_POST["recordid"], $_POST["domainid"], $_POST["name"], $_POST["type"], $_POST["content"], $_POST["ttl"], $_POST["prio"]);
c255196bc447 [feladat @ 182]
rejo
parents: 80
diff changeset
    46
		if ( $ret_val == "1" ) {
c255196bc447 [feladat @ 182]
rejo
parents: 80
diff changeset
    47
			success(SUC_RECORD_UPD);
c255196bc447 [feladat @ 182]
rejo
parents: 80
diff changeset
    48
		} else {
c255196bc447 [feladat @ 182]
rejo
parents: 80
diff changeset
    49
			echo "     <div class=\"error\">" . $ret_val . "</div>\n";  
c255196bc447 [feladat @ 182]
rejo
parents: 80
diff changeset
    50
		}
c255196bc447 [feladat @ 182]
rejo
parents: 80
diff changeset
    51
	}
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    52
}
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    53
82
c255196bc447 [feladat @ 182]
rejo
parents: 80
diff changeset
    54
echo "    <h2>" . _('Edit record in zone') . " " .  $zone_name . "</h2>\n";
c255196bc447 [feladat @ 182]
rejo
parents: 80
diff changeset
    55
c255196bc447 [feladat @ 182]
rejo
parents: 80
diff changeset
    56
if ( $perm_view == "none" || $perm_view == "own" && $user_is_zone_owner == "0" ) {
c255196bc447 [feladat @ 182]
rejo
parents: 80
diff changeset
    57
	error(ERR_PERM_VIEW_RECORD);
c255196bc447 [feladat @ 182]
rejo
parents: 80
diff changeset
    58
} else {
c255196bc447 [feladat @ 182]
rejo
parents: 80
diff changeset
    59
	$record = get_record_from_id($_GET["id"]);
c255196bc447 [feladat @ 182]
rejo
parents: 80
diff changeset
    60
	echo "     <form method=\"post\" action=\"edit_record.php?domain=" . $_GET["domain"] . "&id=" . $_GET["id"] . "\">\n";
c255196bc447 [feladat @ 182]
rejo
parents: 80
diff changeset
    61
	echo "      <table>\n";
c255196bc447 [feladat @ 182]
rejo
parents: 80
diff changeset
    62
	echo "       <tr>\n";
c255196bc447 [feladat @ 182]
rejo
parents: 80
diff changeset
    63
	echo "        <th>" . _('Name') . "</td>\n";
c255196bc447 [feladat @ 182]
rejo
parents: 80
diff changeset
    64
	echo "        <th>&nbsp;</td>\n";
c255196bc447 [feladat @ 182]
rejo
parents: 80
diff changeset
    65
	echo "        <th>" . _('Type') . "</td>\n";
c255196bc447 [feladat @ 182]
rejo
parents: 80
diff changeset
    66
	echo "        <th>" . _('Priority') . "</td>\n";
c255196bc447 [feladat @ 182]
rejo
parents: 80
diff changeset
    67
	echo "        <th>" . _('Content') . "</td>\n";
c255196bc447 [feladat @ 182]
rejo
parents: 80
diff changeset
    68
	echo "        <th>" . _('TTL') . "</td>\n";
c255196bc447 [feladat @ 182]
rejo
parents: 80
diff changeset
    69
	echo "       </tr>\n";
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    70
82
c255196bc447 [feladat @ 182]
rejo
parents: 80
diff changeset
    71
	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
    72
		echo "      <tr>\n";
c255196bc447 [feladat @ 182]
rejo
parents: 80
diff changeset
    73
		echo "       <td>" . $record["name"] . "</td>\n";
c255196bc447 [feladat @ 182]
rejo
parents: 80
diff changeset
    74
		echo "       <td>IN</td>\n";
c255196bc447 [feladat @ 182]
rejo
parents: 80
diff changeset
    75
		echo "       <td>" . $record["type"] . "</td>\n";
c255196bc447 [feladat @ 182]
rejo
parents: 80
diff changeset
    76
		echo "       <td>" . $record["content"] . "</td>\n";
c255196bc447 [feladat @ 182]
rejo
parents: 80
diff changeset
    77
		echo "       <td>" . $record["prio"] . "</td>\n";
c255196bc447 [feladat @ 182]
rejo
parents: 80
diff changeset
    78
		echo "       <td>" . $record["ttl"] . "</td>\n";
c255196bc447 [feladat @ 182]
rejo
parents: 80
diff changeset
    79
		echo "      </tr>\n";
c255196bc447 [feladat @ 182]
rejo
parents: 80
diff changeset
    80
	} else {
c255196bc447 [feladat @ 182]
rejo
parents: 80
diff changeset
    81
		echo "      <input type=\"hidden\" name=\"recordid\" value=\"" . $_GET["id"] . "\">\n";
c255196bc447 [feladat @ 182]
rejo
parents: 80
diff changeset
    82
		echo "      <input type=\"hidden\" name=\"domainid\" value=\"" . $_GET["domain"] . "\">\n";
c255196bc447 [feladat @ 182]
rejo
parents: 80
diff changeset
    83
		echo "      <tr>\n";
c255196bc447 [feladat @ 182]
rejo
parents: 80
diff changeset
    84
		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
    85
		echo "       <td>IN</td>\n";
c255196bc447 [feladat @ 182]
rejo
parents: 80
diff changeset
    86
		echo "       <td>\n";
c255196bc447 [feladat @ 182]
rejo
parents: 80
diff changeset
    87
		echo "        <select name=\"type\">\n";
c255196bc447 [feladat @ 182]
rejo
parents: 80
diff changeset
    88
		foreach (get_record_types() as $type_available) {
c255196bc447 [feladat @ 182]
rejo
parents: 80
diff changeset
    89
			if ($type_available == $record["type"]) {
c255196bc447 [feladat @ 182]
rejo
parents: 80
diff changeset
    90
				$add = " SELECTED";
c255196bc447 [feladat @ 182]
rejo
parents: 80
diff changeset
    91
			} else {
c255196bc447 [feladat @ 182]
rejo
parents: 80
diff changeset
    92
				$add = "";
c255196bc447 [feladat @ 182]
rejo
parents: 80
diff changeset
    93
			}
c255196bc447 [feladat @ 182]
rejo
parents: 80
diff changeset
    94
			echo "         <option" . $add . " value=\"" . $type_available . "\" >" . $type_available . "</option>\n";
c255196bc447 [feladat @ 182]
rejo
parents: 80
diff changeset
    95
		}
c255196bc447 [feladat @ 182]
rejo
parents: 80
diff changeset
    96
		echo "        </select>\n";
c255196bc447 [feladat @ 182]
rejo
parents: 80
diff changeset
    97
		echo "       </td>\n";
c255196bc447 [feladat @ 182]
rejo
parents: 80
diff changeset
    98
		echo "       <td><input type=\"text\" name=\"prio\" value=\"" .  $record["prio"] . "\" class=\"sinput\"></td>\n";
c255196bc447 [feladat @ 182]
rejo
parents: 80
diff changeset
    99
		echo "       <td><input type=\"text\" name=\"content\" value=\"" .  $record["content"] . "\" class=\"input\"></td>\n";
c255196bc447 [feladat @ 182]
rejo
parents: 80
diff changeset
   100
		echo "       <td><input type=\"text\" name=\"ttl\" value=\"" . $record["ttl"] . "\" class=\"sinput\"></td>\n";
c255196bc447 [feladat @ 182]
rejo
parents: 80
diff changeset
   101
		echo "      </tr>\n";
13
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
   102
	}
82
c255196bc447 [feladat @ 182]
rejo
parents: 80
diff changeset
   103
	echo "      </table>\n";
c255196bc447 [feladat @ 182]
rejo
parents: 80
diff changeset
   104
	echo "      <p>\n";
c255196bc447 [feladat @ 182]
rejo
parents: 80
diff changeset
   105
	echo "       <input type=\"submit\" name=\"commit\" value=\"" . _('Commit changes') . "\" class=\"button\">&nbsp;&nbsp;\n";
c255196bc447 [feladat @ 182]
rejo
parents: 80
diff changeset
   106
	echo "      </p>\n";
c255196bc447 [feladat @ 182]
rejo
parents: 80
diff changeset
   107
	echo "     </form>\n";
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   108
}
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   109
82
c255196bc447 [feladat @ 182]
rejo
parents: 80
diff changeset
   110
13
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
   111
include_once("inc/footer.inc.php");
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   112
?>
82
c255196bc447 [feladat @ 182]
rejo
parents: 80
diff changeset
   113