add_zone_slave.php
changeset 82 c255196bc447
parent 79 0c0aa144356a
child 110 455405c757e1
equal deleted inserted replaced
81:c72d6d51f3d3 82:c255196bc447
    18  *  You should have received a copy of the GNU General Public License
    18  *  You should have received a copy of the GNU General Public License
    19  *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
    19  *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
    20  */
    20  */
    21 
    21 
    22 require_once("inc/toolkit.inc.php");
    22 require_once("inc/toolkit.inc.php");
       
    23 include_once("inc/header.inc.php");
    23 
    24 
    24 if (!level(5))
    25 $owner = "-1";
    25 {
    26 if ((isset($_POST['owner'])) && (v_num($_POST['owner']))) {
    26         error(ERR_LEVEL_5);
    27         $owner = $_POST['owner'];
    27 
       
    28 }
    28 }
    29 
    29 
    30 if (isset($_POST["submit"]))
    30 $zone = trim($_POST['domain']);
    31 {
    31 $master = $_POST['slave_master'];
    32      $domain = trim($_POST["domain"]);
    32 $type = "SLAVE";
    33      $owner = $_POST["owner"];
    33 
    34      $slave_master = $_POST["slave_master"];
    34 (verify_permission(zone_slave_add)) ? $zone_slave_add = "1" : $zone_slave_add = "0" ;
    35      $dom_type = "SLAVE";
    35 
    36      if (!isset($error))
    36 if ($_POST['submit'] && $zone_slave_add == "1") {
    37      {
    37 	if (!is_valid_domain($zone)) {
    38              if (!is_valid_domain($domain))
    38 		error(ERR_DNS_HOSTNAME);
    39              {
    39 	} elseif (domain_exists($zone)) {
    40                      $error = "Zone name is invalid!";
    40 		error(ERR_DOMAIN_EXISTS);
    41              }
    41 	} elseif (!is_valid_ip($master)) {
    42              elseif (domain_exists($domain))
    42 		error(ERR_DNS_IP);
    43              {
    43 	} else {
    44                      $error = "Zone already exists!";
    44 		if(add_domain($zone, $owner, $webip, $mailip, $empty, $type, $master)) {
    45              }
    45 			success(SUC_ZONE_ADD);
    46              elseif (!is_valid_ip($slave_master))
    46 			unset($zone, $owner, $webip, $mailip, $empty, $type, $master);
    47              {
    47 		}
    48                      $error = "IP of master NS for slave zone is not valid!";
    48 	}
    49              }
       
    50              else
       
    51              {
       
    52                      if(add_domain($domain, $owner, '', '', 1, $dom_type, $slave_master))
       
    53 		     {
       
    54                                 $success = _('Successfully added slave zone.');
       
    55 		     }
       
    56              }
       
    57      }
       
    58 }
    49 }
    59 
    50 
    60 include_once("inc/header.inc.php");
    51 echo "     <h2>" . _('Add slave zone') . "</h2>\n"; 
    61 
    52 
    62 	if ((isset($error)) && ($error != ""))
    53 if ( $zone_slave_add != "1" ) {
    63 	{
    54 	echo "     <p>" . _("You do not have the permission to add a new slave zone.") . "</p>\n"; 
    64 	        ?><div class="error"><?php echo _('Error'); ?>: <?php echo $error; ?></div><?php
    55 } else {
       
    56 	$users = show_users();
       
    57 	echo "     <form method=\"post\" action=\"add_zone_slave.php\">\n";
       
    58 	echo "      <table>\n";
       
    59 	echo "       <tr>\n";
       
    60 	echo "        <td class=\"n\">" . _('Zone name') . "</td>\n";
       
    61 	echo "        <td class=\"n\">\n";
       
    62 	echo "         <input type=\"text\" class=\"input\" name=\"domain\" value=\"" . $zone . "\">\n";
       
    63 	echo "        </td>\n";
       
    64 	echo "       </tr>\n";
       
    65 	echo "       <tr>\n";
       
    66 	echo "        <td class=\"n\">" . _('IP of master NS') . ":</td>\n";
       
    67 	echo "        <td class=\"n\">\n";
       
    68 	echo "         <input type=\"text\" class=\"input\" name=\"slave_master\" value=\"" . $master . "\">\n";
       
    69 	echo "        </td>\n";
       
    70 	echo "       </tr>\n";
       
    71 	echo "       <tr>\n";
       
    72 	echo "        <td class=\"n\">" . _('Owner') . ":</td>\n";
       
    73 	echo "        <td class=\"n\">\n";
       
    74 	echo "         <select name=\"owner\">\n";
       
    75 	foreach ($users as $user) {
       
    76 		echo "          <option value=\"" . $user['id'] . "\">" . $user['fullname'] . "</option>\n";
    65 	}
    77 	}
    66 	elseif ((isset($success)) && ($success != ""))
    78 	echo "         </select>\n";
    67 	{
    79 	echo "        </td>\n";
    68 		?><div class="success"><?php echo $success; ?></div><?php
    80 	echo "       </tr>\n";
    69 	}
    81 	echo "       <tr>\n";
    70 	
    82 	echo "        <td class=\"n\">&nbsp;</td>\n";
    71 	$users = show_users();
    83 	echo "        <td class=\"n\">\n";
    72 	
    84 	echo "         <input type=\"submit\" class=\"button\" name=\"submit\" value=\"" .  _('Add domain') . "\">\n";
    73 	?>
    85 	echo "        </td>\n";
    74 	    <h2><?php echo _('Add slave zone'); ?></h2>
    86 	echo "       </tr>\n";
    75 	    <form method="post" action="add_zone_slave.php">
    87 	echo "      </table>\n";
    76 	     <table>
    88 	echo "     </form>\n";
    77 	      <tr>
    89 }
    78 	       <td class="n"><?php echo _('Zone name'); ?>:</td>
    90 
    79 	       <td class="n">
       
    80 	        <input type="text" class="input" name="domain" value="<?php if (isset($error)) print $_POST["domain"]; ?>">
       
    81 	       </td>
       
    82 	      </tr>
       
    83 	      <tr>
       
    84 	       <td class="n"><?php echo _('IP of master NS'); ?>:</td>
       
    85 	       <td class="n">
       
    86 	        <input type="text" class="input" name="slave_master" value="<?php if (isset($error)) print $_POST["slave_master"]; ?>">
       
    87 	       </td>
       
    88 	      </tr>
       
    89 	      <tr>
       
    90 	       <td class="n"><?php echo _('Owner'); ?>:</td>
       
    91 	       <td class="n">
       
    92 	        <select name="owner">
       
    93 	         <?php 
       
    94 	         foreach ($users as $u)
       
    95 	         {
       
    96 	           ?><option value="<?php echo $u['id'] ?>"><?php echo $u['fullname'] ?></option><?php
       
    97 	         } 
       
    98 	        ?>
       
    99 	        </select>
       
   100 	       </td>
       
   101 	      </tr>
       
   102 	      <tr>
       
   103 	       <td class="n">&nbsp;</td>
       
   104 	       <td class="n">
       
   105 	        <input type="submit" class="button" name="submit" value="<?php echo _('Add domain'); ?>">
       
   106 	       </td>
       
   107 	      </tr>
       
   108 	     </table>
       
   109 	    </form>
       
   110 <?php
       
   111 include_once("inc/footer.inc.php");
    91 include_once("inc/footer.inc.php");
   112 ?>
    92 ?>