add_zone_master.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: 35
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: 35
diff changeset
     4
 *  See <https://rejo.zenger.nl/poweradmin> for more details.
ae140472d97c [feladat @ 94]
rejo
parents: 35
diff changeset
     5
 *
ae140472d97c [feladat @ 94]
rejo
parents: 35
diff changeset
     6
 *  Copyright 2007, 2008  Rejo Zenger <rejo@zenger.nl>
ae140472d97c [feladat @ 94]
rejo
parents: 35
diff changeset
     7
 *
ae140472d97c [feladat @ 94]
rejo
parents: 35
diff changeset
     8
 *  This program is free software: you can redistribute it and/or modify
ae140472d97c [feladat @ 94]
rejo
parents: 35
diff changeset
     9
 *  it under the terms of the GNU General Public License as published by
ae140472d97c [feladat @ 94]
rejo
parents: 35
diff changeset
    10
 *  the Free Software Foundation, either version 3 of the License, or
ae140472d97c [feladat @ 94]
rejo
parents: 35
diff changeset
    11
 *  (at your option) any later version.
ae140472d97c [feladat @ 94]
rejo
parents: 35
diff changeset
    12
 *
ae140472d97c [feladat @ 94]
rejo
parents: 35
diff changeset
    13
 *  This program is distributed in the hope that it will be useful,
ae140472d97c [feladat @ 94]
rejo
parents: 35
diff changeset
    14
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
ae140472d97c [feladat @ 94]
rejo
parents: 35
diff changeset
    15
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
ae140472d97c [feladat @ 94]
rejo
parents: 35
diff changeset
    16
 *  GNU General Public License for more details.
ae140472d97c [feladat @ 94]
rejo
parents: 35
diff changeset
    17
 *
ae140472d97c [feladat @ 94]
rejo
parents: 35
diff changeset
    18
 *  You should have received a copy of the GNU General Public License
ae140472d97c [feladat @ 94]
rejo
parents: 35
diff changeset
    19
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
ae140472d97c [feladat @ 94]
rejo
parents: 35
diff changeset
    20
 */
ae140472d97c [feladat @ 94]
rejo
parents: 35
diff changeset
    21
13
2ff220cfde13 [feladat @ 60]
rejo
parents:
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");
13
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
}
13
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
    29
82
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
    30
$dom_type = "NATIVE";
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
    31
if (isset($_POST["dom_type"]) && (in_array($_POST['dom_type'], $server_types))) {
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
    32
	$dom_type = $_POST["dom_type"];
13
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
    33
}
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
    34
82
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
    35
$domain = trim($_POST["domain"]);
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
    36
$webip = $_POST["webip"];
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
    37
$mailip = $_POST["mailip"];
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
    38
$empty = $_POST["empty"];
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
    39
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
    40
(verify_permission(zone_master_add)) ? $zone_master_add = "1" : $zone_master_add = "0" ;
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
    41
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
    42
if ($_POST['submit'] && $zone_master_add == "1" ) {
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
    43
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
    44
	// Boy. I will be happy when I have found the time to replace
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
    45
	// this "template wanabee" code with something that is really 
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
    46
	// worth to be called "templating". Whoever wrote this should 
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
    47
	// be... should be... how can I say this politicaly correct?
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
    48
	// 20080303/RZ
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
    49
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
    50
        if(!$empty) {
13
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
    51
                $empty = 0;
82
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
    52
                if(!eregi('in-addr.arpa', $domain) && (!is_valid_ip($webip) || !is_valid_ip($mailip)) ) {
110
455405c757e1 [feladat @ 210]
rejo
parents: 82
diff changeset
    53
                        error(_('IP address of web- or mailserver is invalid.')); 
82
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
    54
			$error = "1";
13
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
    55
                }
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
    56
        }
82
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
    57
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
    58
        if (!$error) {
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
    59
                if (!is_valid_domain($domain)) {
110
455405c757e1 [feladat @ 210]
rejo
parents: 82
diff changeset
    60
                        error(ERR_DOMAIN_INVALID); 
82
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
    61
			$error = "1";
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
    62
                } elseif (domain_exists($domain)) {
110
455405c757e1 [feladat @ 210]
rejo
parents: 82
diff changeset
    63
                        error(ERR_DOMAIN_EXISTS); 
82
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
    64
			$error = "1";
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
    65
                } else {
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
    66
                        if (add_domain($domain, $owner, $webip, $mailip, $empty, $dom_type, '')) {
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
    67
				success(SUC_ZONE_ADD);
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
    68
				unset($domain, $owner, $webip, $mailip, $empty, $dom_type);
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
    69
			} else {
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
    70
				$error = "1";
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
    71
			}
13
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
    72
                }
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
    73
        }
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
    74
}
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
    75
110
455405c757e1 [feladat @ 210]
rejo
parents: 82
diff changeset
    76
if ( $zone_master_add != "1" ) {
455405c757e1 [feladat @ 210]
rejo
parents: 82
diff changeset
    77
	error(ERR_PERM_ADD_ZONE_MASTER); 
455405c757e1 [feladat @ 210]
rejo
parents: 82
diff changeset
    78
} else {
455405c757e1 [feladat @ 210]
rejo
parents: 82
diff changeset
    79
	echo "     <h2>" . _('Add master zone') . "</h2>\n"; 
13
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
    80
82
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
    81
	$available_zone_types = array("MASTER", "NATIVE");
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
    82
	$users = show_users();
13
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
    83
82
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
    84
	echo "     <form method=\"post\" action=\"add_zone_master.php\">\n";
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
    85
	echo "      <table>\n";
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
    86
	echo "       <tr>\n";
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
    87
	echo "        <td class=\"n\">" . _('Zone name') . ":</td>\n";
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
    88
	echo "        <td class=\"n\">\n";
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
    89
	echo "         <input type=\"text\" class=\"input\" name=\"domain\" value=\"" .  $domain . "\">\n";
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
    90
	echo "        </td>\n";
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
    91
	echo "       </tr>\n";
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
    92
	echo "       <tr>\n";
110
455405c757e1 [feladat @ 210]
rejo
parents: 82
diff changeset
    93
	echo "        <td class=\"n\">" . _('IP address of webserver') . ":</td>\n";
82
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
    94
	echo "        <td class=\"n\">\n";
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
    95
	echo "         <input type=\"text\" class=\"input\" name=\"webip\" value=\"" . $webip . "\">\n";
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
    96
	echo "        </td>\n";
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
    97
	echo "       </tr>\n";
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
    98
	echo "       <tr>\n";
110
455405c757e1 [feladat @ 210]
rejo
parents: 82
diff changeset
    99
	echo "        <td class=\"n\">" . _('IP address of mailserver') . ":</td>\n";
82
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
   100
	echo "        <td class=\"n\">\n";
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
   101
	echo "         <input type=\"text\" class=\"input\" name=\"mailip\" value=\"" . $mailip . "\">\n";
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
   102
	echo "        </td>\n";
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
   103
	echo "       </tr>\n";
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
   104
	echo "       <tr>\n";
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
   105
	echo "        <td class=\"n\">" . _('Owner') . ":</td>\n";
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
   106
	echo "        <td class=\"n\">\n";
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
   107
	echo "         <select name=\"owner\">\n";
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
   108
        foreach ($users as $user) {
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
   109
		echo "          <option value=\"" . $user['id'] . "\">" . $user['fullname'] . "</option>\n";
13
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
   110
        }
82
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
   111
	echo "         </select>\n";
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
   112
	echo "        </td>\n";
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
   113
	echo "       </tr>\n";
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
   114
	echo "       <tr>\n";
111
0a2342a64b83 [feladat @ 211]
rejo
parents: 110
diff changeset
   115
	echo "        <td class=\"n\">" . _('Type') . ":</td>\n";
82
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
   116
	echo "        <td class=\"n\">\n";
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
   117
	echo "         <select name=\"dom_type\">\n";
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
   118
        foreach($available_zone_types as $type) {
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
   119
		echo "          <option value=\"" . $type . "\">" . strtolower($type) . "</option>\n";
13
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
   120
        }
82
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
   121
	echo "         </select>\n";
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
   122
	echo "        </td>\n";
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
   123
	echo "       </tr>\n";
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
   124
	echo "       <tr>\n";
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
   125
	echo "        <td class=\"n\">" . _('Create zone without applying records-template') . "</td>\n";
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
   126
	echo "        <td class=\"n\"><input type=\"checkbox\" name=\"empty\" value=\"1\"></td>\n";
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
   127
	echo "       </tr>\n";
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
   128
	echo "       <tr>\n";
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
   129
	echo "        <td class=\"n\">&nbsp;</td>\n";
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
   130
	echo "        <td class=\"n\">\n";
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
   131
	echo "         <input type=\"submit\" class=\"button\" name=\"submit\" value=\"" . _('Add zone') . "\">\n";
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
   132
	echo "        </td>\n";
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
   133
	echo "       </tr>\n";
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
   134
	echo "      </table>\n";
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
   135
	echo "     </form>\n";
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
   136
} 
13
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
   137
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
   138
include_once("inc/footer.inc.php");