add_zone_master.php
author rejo
Tue, 10 Jul 2007 21:24:06 +0000
changeset 37 b785e54690ce
parent 35 5533c4fff98f
child 47 ae140472d97c
permissions -rw-r--r--
[feladat @ 84] Bugfix. The function zone_count() now also counts zones an owner has only partial access to, not just those zones the owner has full access to. This fixes just the count, the zones a user has partial access to are not (yet!) shown in the "list zones" page. Bugfix. In the zone listing the "edit" button is now show for users with access level 1. Untill now they were presented an overview of the zones they could change, but there was no link for them to actually edit the zone. Bugfix. Some of the buttons in the "edit zone" interface that are of no use to a user with access level 1 have been hidden. Bugfix. Make sure a user with access level 1 with only partial access to a zone cannot add new records to that zone. Only the zone owner should be able to add new record. Bugfix. If a user with access level 1 edits a record in a zone he has only partial access to, an error was shown because of call to a non- existing function in the PEAR:MDB2. This bug was most likely introduced while migrating from PEAR:DB to PEAR:MDB2. Bugfix. A user with access level 1 was able to delete all records of a zone he has only partial access to. Some additional checks have been added. Bugfix. If a user with accees level 1 has partial access to one or more zones starting with a certain character, but did not own at least one entire zone starting with the same character, the character wasn't clickable in the "list zone" page. Interface. If no record or zone id is given for delete_record.php or delete_domain.php, don't just die but echo a nice message. The i18n files have not yet been updated to reflect this change. Interface. If no master IP is given in delete_supermaster.php, don't just die but echo a nice message. The i18n files have not yet been updated to reflect this change. [All fixes by Peter Beernink.]
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");