add_zone_master.php
author peter
Sun, 06 Jan 2008 11:49:17 +0000
changeset 67 2f8c29fc5e2e
parent 50 ed18c8317cff
child 71 e1b918eaf69a
permissions -rw-r--r--
[feladat @ 114] Patch for ticket 19. Because of the use of the quote function, empty strings where converted to NULL as MDB2_PORTABILITY_EMPTY_TO_NULL is set by default. This problem also applied to the active state of an user.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
13
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
     1
<?php
47
ae140472d97c [feladat @ 94]
rejo
parents: 35
diff changeset
     2
ae140472d97c [feladat @ 94]
rejo
parents: 35
diff changeset
     3
/*  PowerAdmin, a friendly web-based admin tool for PowerDNS.
ae140472d97c [feladat @ 94]
rejo
parents: 35
diff changeset
     4
 *  See <https://rejo.zenger.nl/poweradmin> for more details.
ae140472d97c [feladat @ 94]
rejo
parents: 35
diff changeset
     5
 *
ae140472d97c [feladat @ 94]
rejo
parents: 35
diff changeset
     6
 *  Copyright 2007, 2008  Rejo Zenger <rejo@zenger.nl>
ae140472d97c [feladat @ 94]
rejo
parents: 35
diff changeset
     7
 *
ae140472d97c [feladat @ 94]
rejo
parents: 35
diff changeset
     8
 *  This program is free software: you can redistribute it and/or modify
ae140472d97c [feladat @ 94]
rejo
parents: 35
diff changeset
     9
 *  it under the terms of the GNU General Public License as published by
ae140472d97c [feladat @ 94]
rejo
parents: 35
diff changeset
    10
 *  the Free Software Foundation, either version 3 of the License, or
ae140472d97c [feladat @ 94]
rejo
parents: 35
diff changeset
    11
 *  (at your option) any later version.
ae140472d97c [feladat @ 94]
rejo
parents: 35
diff changeset
    12
 *
ae140472d97c [feladat @ 94]
rejo
parents: 35
diff changeset
    13
 *  This program is distributed in the hope that it will be useful,
ae140472d97c [feladat @ 94]
rejo
parents: 35
diff changeset
    14
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
ae140472d97c [feladat @ 94]
rejo
parents: 35
diff changeset
    15
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
ae140472d97c [feladat @ 94]
rejo
parents: 35
diff changeset
    16
 *  GNU General Public License for more details.
ae140472d97c [feladat @ 94]
rejo
parents: 35
diff changeset
    17
 *
ae140472d97c [feladat @ 94]
rejo
parents: 35
diff changeset
    18
 *  You should have received a copy of the GNU General Public License
ae140472d97c [feladat @ 94]
rejo
parents: 35
diff changeset
    19
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
ae140472d97c [feladat @ 94]
rejo
parents: 35
diff changeset
    20
 */
ae140472d97c [feladat @ 94]
rejo
parents: 35
diff changeset
    21
13
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
    22
require_once("inc/toolkit.inc.php");
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
    23
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
    24
if (!level(5))
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
    25
{
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
    26
        error(ERR_LEVEL_5);
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
    27
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
    28
}
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
    29
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
    30
if ($_POST["submit"])
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
    31
{
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
    32
        $domain = trim($_POST["domain"]);
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
    33
        $owner = $_POST["owner"];
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
    34
        $webip = $_POST["webip"];
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
    35
        $mailip = $_POST["mailip"];
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
    36
        $empty = $_POST["empty"];
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
    37
        $dom_type = isset($_POST["dom_type"]) ? $_POST["dom_type"] : "NATIVE";
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
    38
        if(!$empty)
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
    39
        {
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
    40
                $empty = 0;
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
    41
                if(!eregi('in-addr.arpa', $domain) && (!is_valid_ip($webip) || !is_valid_ip($mailip)) )
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
    42
                {
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
    43
                        $error = "Web or Mail ip is invalid!";
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
    44
                }
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
    45
        }
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
    46
        if (!$error)
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
    47
        {
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
    48
                if (!is_valid_domain($domain))
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
    49
                {
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
    50
                        $error = "Zone name is invalid!";
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
    51
                }
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
    52
                elseif (domain_exists($domain))
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
    53
                {
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
    54
                        $error = "Zone already exists!";
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
    55
                }
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
    56
                //elseif (isset($mailip) && is_valid_ip(
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
    57
                else
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
    58
                {
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
    59
                        add_domain($domain, $owner, $webip, $mailip, $empty, $dom_type, '');
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
    60
			$success = _('Successfully added master zone.');
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
    61
                }
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
    62
        }
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
    63
}
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
    64
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
    65
include_once("inc/header.inc.php");
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
    66
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
    67
	if ($error != "")
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
    68
	{
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
    69
	        ?><div class="error"><? echo _('Error'); ?>: <? echo $error; ?></div><?
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
    70
	}
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
    71
	elseif ($success != "")
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
    72
	{
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
    73
		?><div class="success"><? echo $success; ?></div><?
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
    74
	}
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
    75
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
    76
	?>
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
    77
	<h2>Add master zone</h2>
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
    78
	<?
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
    79
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
    80
	// Zone type set to master and native only, slave zones are created
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
    81
	// on a different page. 
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
    82
        $zone_types = array("MASTER", "NATIVE");
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
    83
        $users = show_users();
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
    84
        ?>
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
    85
        <form method="post" action="add_zone_master.php">
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
    86
         <table>
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
    87
          <tr>
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
    88
           <td class="n"><? echo _('Zone name'); ?>:</td>
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
    89
           <td class="n">
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
    90
            <input type="text" class="input" name="domain" value="<? if ($error) print $_POST["domain"]; ?>">
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
    91
           </td>
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
    92
          </tr>
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
    93
          <tr>
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
    94
           <td class="n"><? echo _('Web IP'); ?>:</td>
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
    95
           <td class="n">
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
    96
            <input type="text" class="input" name="webip" value="<? if ($error) print $_POST["webip"]; ?>">
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 _('Mail IP'); ?>:</TD>
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
   101
           <td class="n">
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
   102
            <input type="text" class="input" name="mailip" value="<? if ($error) print $_POST["mailip"]; ?>">
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
   103
           </td>
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
   104
          </tr>
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
   105
          <tr>
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
   106
           <td class="n"><? echo _('Owner'); ?>:</td>
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
   107
           <td class="n">
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
   108
            <select name="owner">
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
   109
        <?
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
   110
        foreach ($users as $u)
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
   111
        {
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
   112
           ?><option value="<? echo $u['id'] ?>"><? echo $u['fullname'] ?></option><?
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
   113
        }
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
   114
        ?>
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
   115
            </select>
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
   116
           </td>
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
   117
          </tr>
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
   118
          <tr>
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
   119
           <td class="n"><? echo _('Zone type'); ?>:</td>
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
   120
           <td class="n">
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
   121
            <select name="dom_type">
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
   122
        <?
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
   123
        foreach($zone_types as $s)
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
   124
        {
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
   125
           ?><option value="<? echo $s?>"><? echo $s ?></option><?
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
   126
        }
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
   127
        ?>
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
   128
            </select>
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
   129
           </td>
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
   130
          </tr>
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
   131
          <tr>
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
   132
           <td class="n"><? echo _('Create zone without applying records-template'); ?>:</td>
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
   133
	   <td class="n"><input type="checkbox" name="empty" value="1"></td>
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
   134
	  </tr>
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
   135
          <tr>
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
   136
	   <td class="n">&nbsp;</td>
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
   137
	   <td class="n">
22
0918664b9ff6 [feladat @ 69]
rejo
parents: 13
diff changeset
   138
	    <input type="submit" class="button" name="submit" value="<? echo _('Add zone'); ?>">
13
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
   139
	   </td>
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
   140
	  </tr>
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
   141
         </table>
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
   142
        </form>
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
   143
<?
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
   144
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
   145
include_once("inc/footer.inc.php");