add_zone_slave.php
author rejo
Wed, 26 Mar 2008 07:40:14 +0000
changeset 83 90fbb34b3d97
parent 82 c255196bc447
child 110 455405c757e1
permissions -rw-r--r--
[feladat @ 183] Bugfix. When changing the username of an existing user, an sql error was shown due to bad quoting of a variable.

<?php

/*  PowerAdmin, a friendly web-based admin tool for PowerDNS.
 *  See <https://rejo.zenger.nl/poweradmin> for more details.
 *
 *  Copyright 2007, 2008  Rejo Zenger <rejo@zenger.nl>
 *
 *  This program is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

require_once("inc/toolkit.inc.php");
include_once("inc/header.inc.php");

$owner = "-1";
if ((isset($_POST['owner'])) && (v_num($_POST['owner']))) {
        $owner = $_POST['owner'];
}

$zone = trim($_POST['domain']);
$master = $_POST['slave_master'];
$type = "SLAVE";

(verify_permission(zone_slave_add)) ? $zone_slave_add = "1" : $zone_slave_add = "0" ;

if ($_POST['submit'] && $zone_slave_add == "1") {
	if (!is_valid_domain($zone)) {
		error(ERR_DNS_HOSTNAME);
	} elseif (domain_exists($zone)) {
		error(ERR_DOMAIN_EXISTS);
	} elseif (!is_valid_ip($master)) {
		error(ERR_DNS_IP);
	} else {
		if(add_domain($zone, $owner, $webip, $mailip, $empty, $type, $master)) {
			success(SUC_ZONE_ADD);
			unset($zone, $owner, $webip, $mailip, $empty, $type, $master);
		}
	}
}

echo "     <h2>" . _('Add slave zone') . "</h2>\n"; 

if ( $zone_slave_add != "1" ) {
	echo "     <p>" . _("You do not have the permission to add a new slave zone.") . "</p>\n"; 
} else {
	$users = show_users();
	echo "     <form method=\"post\" action=\"add_zone_slave.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=\"" . $zone . "\">\n";
	echo "        </td>\n";
	echo "       </tr>\n";
	echo "       <tr>\n";
	echo "        <td class=\"n\">" . _('IP of master NS') . ":</td>\n";
	echo "        <td class=\"n\">\n";
	echo "         <input type=\"text\" class=\"input\" name=\"slave_master\" value=\"" . $master . "\">\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";
	}
	echo "         </select>\n";
	echo "        </td>\n";
	echo "       </tr>\n";
	echo "       <tr>\n";
	echo "        <td class=\"n\">&nbsp;</td>\n";
	echo "        <td class=\"n\">\n";
	echo "         <input type=\"submit\" class=\"button\" name=\"submit\" value=\"" .  _('Add domain') . "\">\n";
	echo "        </td>\n";
	echo "       </tr>\n";
	echo "      </table>\n";
	echo "     </form>\n";
}

include_once("inc/footer.inc.php");
?>