add_zone_master.php
author Peter Gervai <grin@grin.hu>
Fri, 14 Nov 2008 14:41:56 +0100
changeset 198 5e0006d24c1c
parent 187 ae77a8f97ee2
permissions -rw-r--r--
Added tag release_2.1.1 for changeset 963d62dc1c80
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
187
ae77a8f97ee2 [feladat @ 296]
rejo
parents: 179
diff changeset
    35
if (isset($_POST['domain'])) {
ae77a8f97ee2 [feladat @ 296]
rejo
parents: 179
diff changeset
    36
	$domain = trim($_POST['domain']);
ae77a8f97ee2 [feladat @ 296]
rejo
parents: 179
diff changeset
    37
} else {
ae77a8f97ee2 [feladat @ 296]
rejo
parents: 179
diff changeset
    38
	$domain = "";
ae77a8f97ee2 [feladat @ 296]
rejo
parents: 179
diff changeset
    39
}
ae77a8f97ee2 [feladat @ 296]
rejo
parents: 179
diff changeset
    40
ae77a8f97ee2 [feladat @ 296]
rejo
parents: 179
diff changeset
    41
if (isset($_POST['webip'])) {
ae77a8f97ee2 [feladat @ 296]
rejo
parents: 179
diff changeset
    42
	$webip = $_POST['webip'];
ae77a8f97ee2 [feladat @ 296]
rejo
parents: 179
diff changeset
    43
} else {
ae77a8f97ee2 [feladat @ 296]
rejo
parents: 179
diff changeset
    44
	$webip = "";
ae77a8f97ee2 [feladat @ 296]
rejo
parents: 179
diff changeset
    45
}
ae77a8f97ee2 [feladat @ 296]
rejo
parents: 179
diff changeset
    46
ae77a8f97ee2 [feladat @ 296]
rejo
parents: 179
diff changeset
    47
if (isset($_POST['mailip'])) {
ae77a8f97ee2 [feladat @ 296]
rejo
parents: 179
diff changeset
    48
	$mailip = $_POST['mailip'];
ae77a8f97ee2 [feladat @ 296]
rejo
parents: 179
diff changeset
    49
} else {
ae77a8f97ee2 [feladat @ 296]
rejo
parents: 179
diff changeset
    50
	$mailip = "";
ae77a8f97ee2 [feladat @ 296]
rejo
parents: 179
diff changeset
    51
}
ae77a8f97ee2 [feladat @ 296]
rejo
parents: 179
diff changeset
    52
ae77a8f97ee2 [feladat @ 296]
rejo
parents: 179
diff changeset
    53
if (isset($_POST['empty'])) {
ae77a8f97ee2 [feladat @ 296]
rejo
parents: 179
diff changeset
    54
	$empty = $_POST['empty'];
ae77a8f97ee2 [feladat @ 296]
rejo
parents: 179
diff changeset
    55
}
82
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
    56
126
cb06e3e29ed8 [feladat @ 230]
peter
parents: 119
diff changeset
    57
(verify_permission('zone_master_add')) ? $zone_master_add = "1" : $zone_master_add = "0" ;
82
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
    58
187
ae77a8f97ee2 [feladat @ 296]
rejo
parents: 179
diff changeset
    59
if (isset($_POST['submit']) && $zone_master_add == "1" ) {
82
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
    60
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
    61
	// Boy. I will be happy when I have found the time to replace
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
    62
	// this "template wanabee" code with something that is really 
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
    63
	// worth to be called "templating". Whoever wrote this should 
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
    64
	// be... should be... how can I say this politicaly correct?
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
    65
	// 20080303/RZ
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
    66
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
    67
        if(!$empty) {
13
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
    68
                $empty = 0;
161
0832d846bf8e [feladat @ 267]
rejo
parents: 126
diff changeset
    69
                if(!eregi('in-addr.arpa', $domain) && (!is_valid_ipv4($webip) || !is_valid_ipv4($mailip)) ) {
110
455405c757e1 [feladat @ 210]
rejo
parents: 82
diff changeset
    70
                        error(_('IP address of web- or mailserver is invalid.')); 
82
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
    71
			$error = "1";
13
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
    72
                }
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
    73
        }
82
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
    74
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
    75
        if (!$error) {
174
a17ec7de4bbb [feladat @ 281]
rejo
parents: 170
diff changeset
    76
                if (!is_valid_hostname_fqdn($domain,0)) {
110
455405c757e1 [feladat @ 210]
rejo
parents: 82
diff changeset
    77
                        error(ERR_DOMAIN_INVALID); 
82
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
    78
			$error = "1";
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
    79
                } elseif (domain_exists($domain)) {
110
455405c757e1 [feladat @ 210]
rejo
parents: 82
diff changeset
    80
                        error(ERR_DOMAIN_EXISTS); 
82
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
    81
			$error = "1";
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
    82
                } else {
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
    83
                        if (add_domain($domain, $owner, $webip, $mailip, $empty, $dom_type, '')) {
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
    84
				success(SUC_ZONE_ADD);
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
    85
				unset($domain, $owner, $webip, $mailip, $empty, $dom_type);
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
    86
			} else {
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
    87
				$error = "1";
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
    88
			}
13
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
    89
                }
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
    90
        }
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
    91
}
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
    92
110
455405c757e1 [feladat @ 210]
rejo
parents: 82
diff changeset
    93
if ( $zone_master_add != "1" ) {
455405c757e1 [feladat @ 210]
rejo
parents: 82
diff changeset
    94
	error(ERR_PERM_ADD_ZONE_MASTER); 
455405c757e1 [feladat @ 210]
rejo
parents: 82
diff changeset
    95
} else {
455405c757e1 [feladat @ 210]
rejo
parents: 82
diff changeset
    96
	echo "     <h2>" . _('Add master zone') . "</h2>\n"; 
13
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
    97
179
5a2d4418385d [feladat @ 287]
rejo
parents: 174
diff changeset
    98
	$available_zone_types = array("NATIVE", "MASTER");
82
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
    99
	$users = show_users();
13
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
   100
82
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
   101
	echo "     <form method=\"post\" action=\"add_zone_master.php\">\n";
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
   102
	echo "      <table>\n";
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
   103
	echo "       <tr>\n";
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
   104
	echo "        <td class=\"n\">" . _('Zone name') . ":</td>\n";
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
   105
	echo "        <td class=\"n\">\n";
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
   106
	echo "         <input type=\"text\" class=\"input\" name=\"domain\" value=\"" .  $domain . "\">\n";
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
   107
	echo "        </td>\n";
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
   108
	echo "       </tr>\n";
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
   109
	echo "       <tr>\n";
110
455405c757e1 [feladat @ 210]
rejo
parents: 82
diff changeset
   110
	echo "        <td class=\"n\">" . _('IP address of webserver') . ":</td>\n";
82
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
   111
	echo "        <td class=\"n\">\n";
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
   112
	echo "         <input type=\"text\" class=\"input\" name=\"webip\" value=\"" . $webip . "\">\n";
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
   113
	echo "        </td>\n";
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
   114
	echo "       </tr>\n";
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
   115
	echo "       <tr>\n";
110
455405c757e1 [feladat @ 210]
rejo
parents: 82
diff changeset
   116
	echo "        <td class=\"n\">" . _('IP address of mailserver') . ":</td>\n";
82
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
   117
	echo "        <td class=\"n\">\n";
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
   118
	echo "         <input type=\"text\" class=\"input\" name=\"mailip\" value=\"" . $mailip . "\">\n";
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
   119
	echo "        </td>\n";
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
   120
	echo "       </tr>\n";
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
   121
	echo "       <tr>\n";
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
   122
	echo "        <td class=\"n\">" . _('Owner') . ":</td>\n";
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
   123
	echo "        <td class=\"n\">\n";
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
   124
	echo "         <select name=\"owner\">\n";
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
   125
        foreach ($users as $user) {
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
   126
		echo "          <option value=\"" . $user['id'] . "\">" . $user['fullname'] . "</option>\n";
13
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
   127
        }
82
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
   128
	echo "         </select>\n";
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
   129
	echo "        </td>\n";
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
   130
	echo "       </tr>\n";
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
   131
	echo "       <tr>\n";
111
0a2342a64b83 [feladat @ 211]
rejo
parents: 110
diff changeset
   132
	echo "        <td class=\"n\">" . _('Type') . ":</td>\n";
82
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
   133
	echo "        <td class=\"n\">\n";
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
   134
	echo "         <select name=\"dom_type\">\n";
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
   135
        foreach($available_zone_types as $type) {
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
   136
		echo "          <option value=\"" . $type . "\">" . strtolower($type) . "</option>\n";
13
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
   137
        }
82
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
   138
	echo "         </select>\n";
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
   139
	echo "        </td>\n";
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
   140
	echo "       </tr>\n";
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
   141
	echo "       <tr>\n";
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
   142
	echo "        <td class=\"n\">" . _('Create zone without applying records-template') . "</td>\n";
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
   143
	echo "        <td class=\"n\"><input type=\"checkbox\" name=\"empty\" value=\"1\"></td>\n";
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
   144
	echo "       </tr>\n";
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
   145
	echo "       <tr>\n";
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
   146
	echo "        <td class=\"n\">&nbsp;</td>\n";
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
   147
	echo "        <td class=\"n\">\n";
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
   148
	echo "         <input type=\"submit\" class=\"button\" name=\"submit\" value=\"" . _('Add zone') . "\">\n";
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
   149
	echo "        </td>\n";
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
   150
	echo "       </tr>\n";
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
   151
	echo "      </table>\n";
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
   152
	echo "     </form>\n";
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
   153
} 
13
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
   154
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
   155
include_once("inc/footer.inc.php");