add_zone_slave.php
author rejo
Mon, 31 Mar 2008 21:10:19 +0000
changeset 120 982f722376b4
parent 119 f74e4f88b680
child 126 cb06e3e29ed8
permissions -rw-r--r--
[feladat @ 223] Bugfix. No domain id was provided when entering 'edit record' page from a search query. Changed code so 'edit record' does not rely on domain id provided by user but determines it from the record id that is about to be changed. This closes ticket:31.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
13
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
     1
<?php
47
ae140472d97c [feladat @ 94]
rejo
parents: 13
diff changeset
     2
119
f74e4f88b680 [feladat @ 222]
rejo
parents: 111
diff changeset
     3
/*  Poweradmin, a friendly web-based admin tool for PowerDNS.
47
ae140472d97c [feladat @ 94]
rejo
parents: 13
diff changeset
     4
 *  See <https://rejo.zenger.nl/poweradmin> for more details.
ae140472d97c [feladat @ 94]
rejo
parents: 13
diff changeset
     5
 *
ae140472d97c [feladat @ 94]
rejo
parents: 13
diff changeset
     6
 *  Copyright 2007, 2008  Rejo Zenger <rejo@zenger.nl>
ae140472d97c [feladat @ 94]
rejo
parents: 13
diff changeset
     7
 *
ae140472d97c [feladat @ 94]
rejo
parents: 13
diff changeset
     8
 *  This program is free software: you can redistribute it and/or modify
ae140472d97c [feladat @ 94]
rejo
parents: 13
diff changeset
     9
 *  it under the terms of the GNU General Public License as published by
ae140472d97c [feladat @ 94]
rejo
parents: 13
diff changeset
    10
 *  the Free Software Foundation, either version 3 of the License, or
ae140472d97c [feladat @ 94]
rejo
parents: 13
diff changeset
    11
 *  (at your option) any later version.
ae140472d97c [feladat @ 94]
rejo
parents: 13
diff changeset
    12
 *
ae140472d97c [feladat @ 94]
rejo
parents: 13
diff changeset
    13
 *  This program is distributed in the hope that it will be useful,
ae140472d97c [feladat @ 94]
rejo
parents: 13
diff changeset
    14
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
ae140472d97c [feladat @ 94]
rejo
parents: 13
diff changeset
    15
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
ae140472d97c [feladat @ 94]
rejo
parents: 13
diff changeset
    16
 *  GNU General Public License for more details.
ae140472d97c [feladat @ 94]
rejo
parents: 13
diff changeset
    17
 *
ae140472d97c [feladat @ 94]
rejo
parents: 13
diff changeset
    18
 *  You should have received a copy of the GNU General Public License
ae140472d97c [feladat @ 94]
rejo
parents: 13
diff changeset
    19
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
ae140472d97c [feladat @ 94]
rejo
parents: 13
diff changeset
    20
 */
ae140472d97c [feladat @ 94]
rejo
parents: 13
diff changeset
    21
13
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
    22
require_once("inc/toolkit.inc.php");
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
    23
include_once("inc/header.inc.php");
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
    24
82
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
    25
$owner = "-1";
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
    26
if ((isset($_POST['owner'])) && (v_num($_POST['owner']))) {
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
    27
        $owner = $_POST['owner'];
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
    28
}
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
    29
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
    30
$zone = trim($_POST['domain']);
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
    31
$master = $_POST['slave_master'];
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
    32
$type = "SLAVE";
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
    33
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
    34
(verify_permission(zone_slave_add)) ? $zone_slave_add = "1" : $zone_slave_add = "0" ;
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
    35
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
    36
if ($_POST['submit'] && $zone_slave_add == "1") {
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
    37
	if (!is_valid_domain($zone)) {
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
    38
		error(ERR_DNS_HOSTNAME);
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
    39
	} elseif (domain_exists($zone)) {
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
    40
		error(ERR_DOMAIN_EXISTS);
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
    41
	} elseif (!is_valid_ip($master)) {
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
    42
		error(ERR_DNS_IP);
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
    43
	} else {
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
    44
		if(add_domain($zone, $owner, $webip, $mailip, $empty, $type, $master)) {
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
    45
			success(SUC_ZONE_ADD);
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
    46
			unset($zone, $owner, $webip, $mailip, $empty, $type, $master);
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
    47
		}
13
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
    48
	}
82
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
    49
}
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
    50
110
455405c757e1 [feladat @ 210]
rejo
parents: 82
diff changeset
    51
if ( $zone_slave_add != "1" ) {
455405c757e1 [feladat @ 210]
rejo
parents: 82
diff changeset
    52
	error(ERR_PERM_ADD_ZONE_SLAVE);
455405c757e1 [feladat @ 210]
rejo
parents: 82
diff changeset
    53
} else {
455405c757e1 [feladat @ 210]
rejo
parents: 82
diff changeset
    54
	echo "     <h2>" . _('Add slave zone') . "</h2>\n"; 
82
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
    55
13
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
    56
	$users = show_users();
82
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
    57
	echo "     <form method=\"post\" action=\"add_zone_slave.php\">\n";
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
    58
	echo "      <table>\n";
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
    59
	echo "       <tr>\n";
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
    60
	echo "        <td class=\"n\">" . _('Zone name') . "</td>\n";
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
    61
	echo "        <td class=\"n\">\n";
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
    62
	echo "         <input type=\"text\" class=\"input\" name=\"domain\" value=\"" . $zone . "\">\n";
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
    63
	echo "        </td>\n";
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
    64
	echo "       </tr>\n";
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
    65
	echo "       <tr>\n";
110
455405c757e1 [feladat @ 210]
rejo
parents: 82
diff changeset
    66
	echo "        <td class=\"n\">" . _('IP address of master NS') . ":</td>\n";
82
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
    67
	echo "        <td class=\"n\">\n";
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
    68
	echo "         <input type=\"text\" class=\"input\" name=\"slave_master\" value=\"" . $master . "\">\n";
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
    69
	echo "        </td>\n";
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
    70
	echo "       </tr>\n";
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
    71
	echo "       <tr>\n";
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
    72
	echo "        <td class=\"n\">" . _('Owner') . ":</td>\n";
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
    73
	echo "        <td class=\"n\">\n";
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
    74
	echo "         <select name=\"owner\">\n";
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
    75
	foreach ($users as $user) {
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
    76
		echo "          <option value=\"" . $user['id'] . "\">" . $user['fullname'] . "</option>\n";
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
    77
	}
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
    78
	echo "         </select>\n";
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
    79
	echo "        </td>\n";
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
    80
	echo "       </tr>\n";
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
    81
	echo "       <tr>\n";
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
    82
	echo "        <td class=\"n\">&nbsp;</td>\n";
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
    83
	echo "        <td class=\"n\">\n";
111
0a2342a64b83 [feladat @ 211]
rejo
parents: 110
diff changeset
    84
	echo "         <input type=\"submit\" class=\"button\" name=\"submit\" value=\"" .  _('Add zone') . "\">\n";
82
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
    85
	echo "        </td>\n";
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
    86
	echo "       </tr>\n";
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
    87
	echo "      </table>\n";
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
    88
	echo "     </form>\n";
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
    89
}
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
    90
13
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
    91
include_once("inc/footer.inc.php");
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
    92
?>