add_zone_master.php
author rejo
Mon, 24 Dec 2007 22:27:43 +0000
changeset 45 eddff78bf57f
parent 35 5533c4fff98f
child 47 ae140472d97c
permissions -rw-r--r--
[feladat @ 92] Fix for ticket #3. Patch supplied by Peter Beernink. Added i18n.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
13
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
     1
<?php
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
     2
require_once("inc/i18n.inc.php");
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
     3
require_once("inc/toolkit.inc.php");
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
     4
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
     5
if (!level(5))
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
     6
{
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
     7
        error(ERR_LEVEL_5);
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
     8
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
     9
}
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
    10
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
    11
if ($_POST["submit"])
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
    12
{
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
    13
        $domain = trim($_POST["domain"]);
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
    14
        $owner = $_POST["owner"];
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
    15
        $webip = $_POST["webip"];
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
    16
        $mailip = $_POST["mailip"];
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
    17
        $empty = $_POST["empty"];
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
    18
        $dom_type = isset($_POST["dom_type"]) ? $_POST["dom_type"] : "NATIVE";
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
    19
        if(!$empty)
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
    20
        {
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
    21
                $empty = 0;
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
    22
                if(!eregi('in-addr.arpa', $domain) && (!is_valid_ip($webip) || !is_valid_ip($mailip)) )
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
    23
                {
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
    24
                        $error = "Web or Mail ip is invalid!";
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
    25
                }
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
    26
        }
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
    27
        if (!$error)
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
    28
        {
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
    29
                if (!is_valid_domain($domain))
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
    30
                {
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
    31
                        $error = "Zone name is invalid!";
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
    32
                }
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
    33
                elseif (domain_exists($domain))
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
    34
                {
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
    35
                        $error = "Zone already exists!";
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
    36
                }
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
    37
                //elseif (isset($mailip) && is_valid_ip(
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
    38
                else
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
    39
                {
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
    40
                        add_domain($domain, $owner, $webip, $mailip, $empty, $dom_type, '');
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
    41
			$success = _('Successfully added master zone.');
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
    42
                }
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
    43
        }
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
    44
}
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
    45
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
    46
include_once("inc/header.inc.php");
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
    47
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
    48
	if ($error != "")
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
    49
	{
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
    50
	        ?><div class="error"><? echo _('Error'); ?>: <? echo $error; ?></div><?
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
    51
	}
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
    52
	elseif ($success != "")
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
    53
	{
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
    54
		?><div class="success"><? echo $success; ?></div><?
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
    55
	}
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
    56
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
    57
	?>
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
    58
	<h2>Add master zone</h2>
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
    59
	<?
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
    60
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
    61
	// Zone type set to master and native only, slave zones are created
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
    62
	// on a different page. 
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
    63
        $zone_types = array("MASTER", "NATIVE");
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
    64
        $users = show_users();
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
    65
        ?>
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
    66
        <form method="post" action="add_zone_master.php">
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
    67
         <table>
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
    68
          <tr>
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
    69
           <td class="n"><? echo _('Zone name'); ?>:</td>
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
    70
           <td class="n">
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
    71
            <input type="text" class="input" name="domain" value="<? if ($error) print $_POST["domain"]; ?>">
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
    72
           </td>
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
    73
          </tr>
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
    74
          <tr>
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
    75
           <td class="n"><? echo _('Web IP'); ?>:</td>
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
    76
           <td class="n">
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
    77
            <input type="text" class="input" name="webip" value="<? if ($error) print $_POST["webip"]; ?>">
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
    78
           </td>
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
    79
          </tr>
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
    80
          <tr>
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
    81
           <td class="n"><? echo _('Mail IP'); ?>:</TD>
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
    82
           <td class="n">
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
    83
            <input type="text" class="input" name="mailip" value="<? if ($error) print $_POST["mailip"]; ?>">
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
    84
           </td>
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
    85
          </tr>
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
    86
          <tr>
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
    87
           <td class="n"><? echo _('Owner'); ?>:</td>
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
    88
           <td class="n">
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
    89
            <select name="owner">
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
    90
        <?
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
    91
        foreach ($users as $u)
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
    92
        {
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
    93
           ?><option value="<? echo $u['id'] ?>"><? echo $u['fullname'] ?></option><?
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
    94
        }
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
    95
        ?>
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
    96
            </select>
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
    97
           </td>
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
    98
          </tr>
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
    99
          <tr>
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
   100
           <td class="n"><? echo _('Zone type'); ?>:</td>
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
   101
           <td class="n">
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
   102
            <select name="dom_type">
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
   103
        <?
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
   104
        foreach($zone_types as $s)
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
   105
        {
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
   106
           ?><option value="<? echo $s?>"><? echo $s ?></option><?
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
   107
        }
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
   108
        ?>
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
   109
            </select>
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
   110
           </td>
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
   111
          </tr>
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
   112
          <tr>
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
   113
           <td class="n"><? echo _('Create zone without applying records-template'); ?>:</td>
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
   114
	   <td class="n"><input type="checkbox" name="empty" value="1"></td>
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
   115
	  </tr>
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
   116
          <tr>
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
   117
	   <td class="n">&nbsp;</td>
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
   118
	   <td class="n">
22
0918664b9ff6 [feladat @ 69]
rejo
parents: 13
diff changeset
   119
	    <input type="submit" class="button" name="submit" value="<? echo _('Add zone'); ?>">
13
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
   120
	   </td>
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
   121
	  </tr>
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
   122
         </table>
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
   123
        </form>
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
   124
<?
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
   125
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
   126
include_once("inc/footer.inc.php");