--- a/add_zone_master.php Wed Mar 12 20:45:56 2008 +0000
+++ b/add_zone_master.php Tue Mar 25 22:45:31 2008 +0000
@@ -20,126 +20,119 @@
*/
require_once("inc/toolkit.inc.php");
+include_once("inc/header.inc.php");
-if (!level(5))
-{
- error(ERR_LEVEL_5);
+$owner = "-1";
+if ((isset($_POST['owner'])) && (v_num($_POST['owner']))) {
+ $owner = $_POST['owner'];
+}
+$dom_type = "NATIVE";
+if (isset($_POST["dom_type"]) && (in_array($_POST['dom_type'], $server_types))) {
+ $dom_type = $_POST["dom_type"];
}
-if (isset($_POST["submit"]))
-{
- $domain = (isset($_POST['domain']) ? trim($_POST["domain"]) : '');
- $owner = (isset($_POST['owner']) ? $_POST["owner"] : 0 );
- $webip = (isset($_POST["webip"]) ? $_POST['webip'] : '');
- $mailip = (isset($_POST["mailip"]) ? $_POST['mailip'] : '');
- $empty = (isset($_POST["empty"]) ? $_POST['empty'] : 0);
- $dom_type = (isset($_POST["dom_type"]) ? $_POST["dom_type"] : "NATIVE");
- if(!$empty)
- {
+$domain = trim($_POST["domain"]);
+$webip = $_POST["webip"];
+$mailip = $_POST["mailip"];
+$empty = $_POST["empty"];
+
+(verify_permission(zone_master_add)) ? $zone_master_add = "1" : $zone_master_add = "0" ;
+
+if ($_POST['submit'] && $zone_master_add == "1" ) {
+
+ // Boy. I will be happy when I have found the time to replace
+ // this "template wanabee" code with something that is really
+ // worth to be called "templating". Whoever wrote this should
+ // be... should be... how can I say this politicaly correct?
+ // 20080303/RZ
+
+ if(!$empty) {
$empty = 0;
- if(!eregi('in-addr.arpa', $domain) && (!is_valid_ip($webip) || !is_valid_ip($mailip)) )
- {
- $error = "Web or Mail ip is invalid!";
+ if(!eregi('in-addr.arpa', $domain) && (!is_valid_ip($webip) || !is_valid_ip($mailip)) ) {
+ error(_('Web or mail ip is invalid!'));
+ $error = "1";
}
}
- if (!isset($error))
- {
- if (!is_valid_domain($domain))
- {
- $error = "Zone name is invalid!";
- }
- elseif (domain_exists($domain))
- {
- $error = "Zone already exists!";
- }
- //elseif (isset($mailip) && is_valid_ip(
- else
- {
- add_domain($domain, $owner, $webip, $mailip, $empty, $dom_type, '');
- $success = _('Successfully added master zone.');
+
+ if (!$error) {
+ if (!is_valid_domain($domain)) {
+ error(_('Zone name is invalid!'));
+ $error = "1";
+ } elseif (domain_exists($domain)) {
+ error(_('Zone already exists!!'));
+ $error = "1";
+ } else {
+ if (add_domain($domain, $owner, $webip, $mailip, $empty, $dom_type, '')) {
+ success(SUC_ZONE_ADD);
+ unset($domain, $owner, $webip, $mailip, $empty, $dom_type);
+ } else {
+ $error = "1";
+ }
}
}
}
-include_once("inc/header.inc.php");
+echo " <h2>" . _('Add master zone') . "</h2>\n";
- if ((isset($error)) && ($error != ""))
- {
- ?><div class="error"><?php echo _('Error'); ?>: <?php echo $error; ?></div><?php
- }
- elseif ((isset($success)) && ($success != ""))
- {
- ?><div class="success"><?php echo $success; ?></div><?php
- }
-
- ?>
- <h2>Add master zone</h2>
- <?php
+if ( $zone_master_add != "1" ) {
+ echo " <p>" . _("You do not have the permission to add a new master zone.") . "</p>\n";
+} else {
+ $available_zone_types = array("MASTER", "NATIVE");
+ $users = show_users();
- // Zone type set to master and native only, slave zones are created
- // on a different page.
- $zone_types = array("MASTER", "NATIVE");
- $users = show_users();
- ?>
- <form method="post" action="add_zone_master.php">
- <table>
- <tr>
- <td class="n"><?php echo _('Zone name'); ?>:</td>
- <td class="n">
- <input type="text" class="input" name="domain" value="<?php if (isset($error)) print $_POST["domain"]; ?>">
- </td>
- </tr>
- <tr>
- <td class="n"><?php echo _('Web IP'); ?>:</td>
- <td class="n">
- <input type="text" class="input" name="webip" value="<?php if (isset($error)) print $_POST["webip"]; ?>">
- </td>
- </tr>
- <tr>
- <td class="n"><?php echo _('Mail IP'); ?>:</TD>
- <td class="n">
- <input type="text" class="input" name="mailip" value="<?php if (isset($error)) print $_POST["mailip"]; ?>">
- </td>
- </tr>
- <tr>
- <td class="n"><?php echo _('Owner'); ?>:</td>
- <td class="n">
- <select name="owner">
- <?php
- foreach ($users as $u)
- {
- ?><option value="<?php echo $u['id'] ?>"><?php echo $u['fullname'] ?></option><?php
+ echo " <form method=\"post\" action=\"add_zone_master.php\">\n";
+ echo " <table>\n";
+ echo " <tr>\n";
+ echo " <td class=\"n\">" . _('Zone name') . ":</td>\n";
+ echo " <td class=\"n\">\n";
+ echo " <input type=\"text\" class=\"input\" name=\"domain\" value=\"" . $domain . "\">\n";
+ echo " </td>\n";
+ echo " </tr>\n";
+ echo " <tr>\n";
+ echo " <td class=\"n\">" . _('Web IP') . ":</td>\n";
+ echo " <td class=\"n\">\n";
+ echo " <input type=\"text\" class=\"input\" name=\"webip\" value=\"" . $webip . "\">\n";
+ echo " </td>\n";
+ echo " </tr>\n";
+ echo " <tr>\n";
+ echo " <td class=\"n\">" . _('Mail IP') . ":</td>\n";
+ echo " <td class=\"n\">\n";
+ echo " <input type=\"text\" class=\"input\" name=\"mailip\" value=\"" . $mailip . "\">\n";
+ echo " </td>\n";
+ echo " </tr>\n";
+ echo " <tr>\n";
+ echo " <td class=\"n\">" . _('Owner') . ":</td>\n";
+ echo " <td class=\"n\">\n";
+ echo " <select name=\"owner\">\n";
+ foreach ($users as $user) {
+ echo " <option value=\"" . $user['id'] . "\">" . $user['fullname'] . "</option>\n";
}
- ?>
- </select>
- </td>
- </tr>
- <tr>
- <td class="n"><?php echo _('Zone type'); ?>:</td>
- <td class="n">
- <select name="dom_type">
- <?php
- foreach($zone_types as $s)
- {
- ?><option value="<?php echo $s?>"><?php echo $s ?></option><?php
+ echo " </select>\n";
+ echo " </td>\n";
+ echo " </tr>\n";
+ echo " <tr>\n";
+ echo " <td class=\"n\">" . _('Zone type') . ":</td>\n";
+ echo " <td class=\"n\">\n";
+ echo " <select name=\"dom_type\">\n";
+ foreach($available_zone_types as $type) {
+ echo " <option value=\"" . $type . "\">" . strtolower($type) . "</option>\n";
}
- ?>
- </select>
- </td>
- </tr>
- <tr>
- <td class="n"><?php echo _('Create zone without applying records-template'); ?>:</td>
- <td class="n"><input type="checkbox" name="empty" value="1"></td>
- </tr>
- <tr>
- <td class="n"> </td>
- <td class="n">
- <input type="submit" class="button" name="submit" value="<?php echo _('Add zone'); ?>">
- </td>
- </tr>
- </table>
- </form>
-<?php
+ echo " </select>\n";
+ echo " </td>\n";
+ echo " </tr>\n";
+ echo " <tr>\n";
+ echo " <td class=\"n\">" . _('Create zone without applying records-template') . "</td>\n";
+ echo " <td class=\"n\"><input type=\"checkbox\" name=\"empty\" value=\"1\"></td>\n";
+ echo " </tr>\n";
+ echo " <tr>\n";
+ echo " <td class=\"n\"> </td>\n";
+ echo " <td class=\"n\">\n";
+ echo " <input type=\"submit\" class=\"button\" name=\"submit\" value=\"" . _('Add zone') . "\">\n";
+ echo " </td>\n";
+ echo " </tr>\n";
+ echo " </table>\n";
+ echo " </form>\n";
+}
include_once("inc/footer.inc.php");