add_supermaster.php
author rejo
Tue, 25 Dec 2007 14:57:43 +0000
changeset 49 58911245e817
parent 47 ae140472d97c
child 50 ed18c8317cff
permissions -rw-r--r--
[feladat @ 96] Changed list of credits to an online version.
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: 13
diff changeset
     2
ae140472d97c [feladat @ 94]
rejo
parents: 13
diff changeset
     3
/*  PowerAdmin, a friendly web-based admin tool for PowerDNS.
ae140472d97c [feladat @ 94]
rejo
parents: 13
diff changeset
     4
 *  See <https://rejo.zenger.nl/poweradmin> for more details.
ae140472d97c [feladat @ 94]
rejo
parents: 13
diff changeset
     5
 *
ae140472d97c [feladat @ 94]
rejo
parents: 13
diff changeset
     6
 *  Copyright 2007, 2008  Rejo Zenger <rejo@zenger.nl>
ae140472d97c [feladat @ 94]
rejo
parents: 13
diff changeset
     7
 *
ae140472d97c [feladat @ 94]
rejo
parents: 13
diff changeset
     8
 *  This program is free software: you can redistribute it and/or modify
ae140472d97c [feladat @ 94]
rejo
parents: 13
diff changeset
     9
 *  it under the terms of the GNU General Public License as published by
ae140472d97c [feladat @ 94]
rejo
parents: 13
diff changeset
    10
 *  the Free Software Foundation, either version 3 of the License, or
ae140472d97c [feladat @ 94]
rejo
parents: 13
diff changeset
    11
 *  (at your option) any later version.
ae140472d97c [feladat @ 94]
rejo
parents: 13
diff changeset
    12
 *
ae140472d97c [feladat @ 94]
rejo
parents: 13
diff changeset
    13
 *  This program is distributed in the hope that it will be useful,
ae140472d97c [feladat @ 94]
rejo
parents: 13
diff changeset
    14
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
ae140472d97c [feladat @ 94]
rejo
parents: 13
diff changeset
    15
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
ae140472d97c [feladat @ 94]
rejo
parents: 13
diff changeset
    16
 *  GNU General Public License for more details.
ae140472d97c [feladat @ 94]
rejo
parents: 13
diff changeset
    17
 *
ae140472d97c [feladat @ 94]
rejo
parents: 13
diff changeset
    18
 *  You should have received a copy of the GNU General Public License
ae140472d97c [feladat @ 94]
rejo
parents: 13
diff changeset
    19
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
ae140472d97c [feladat @ 94]
rejo
parents: 13
diff changeset
    20
 */
ae140472d97c [feladat @ 94]
rejo
parents: 13
diff changeset
    21
13
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
    22
require_once("inc/i18n.inc.php");
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
    23
require_once("inc/toolkit.inc.php");
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
    24
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
    25
if (!level(5))
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
    26
{
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
    27
	 error(ERR_LEVEL_5);
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
	$master_ip = $_POST["master_ip"];
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
    33
	$ns_name = $_POST["ns_name"];
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
    34
	$account = $_POST["account"];
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
    35
	if (!$error)
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
    36
	{
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
    37
		if (!is_valid_ip($master_ip) && !is_valid_ip6($master_ip))
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
    38
		{
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
    39
			$error = _('Given master IP address is not valid IPv4 or IPv6.');
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
    40
		}
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
    41
		elseif (!is_valid_hostname($ns_name))
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
    42
		{
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
    43
			$error = _('Given hostname for NS record not valid.');
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
    44
		}
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
    45
		elseif (!validate_account($account))
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
    46
		{
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
    47
			$error = _('Account name is not valid (may contain only alpha chars).');
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
    48
		}
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
    49
		else    
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
    50
		{
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
    51
			if(add_supermaster($master_ip, $ns_name, $account))
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
    52
			{
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
    53
				$success = _('Successfully added supermaster.');
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
    54
			}
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
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
    59
include_once("inc/header.inc.php");
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
    60
    
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
    61
    if ($error != "")
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
    62
    {
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
    63
    	?><div class="error"><? echo _('Error'); ?>: <? echo $error; ?></div><?
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
    64
    }
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
    65
    elseif ($success != "")
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
    66
    {
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
    67
    	?><div class="success"><? echo $success; ?></div><?
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
    68
    }
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
    69
    
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
    70
    ?>
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
    71
    <h2><? echo _('Add supermaster'); ?></h2>
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
    72
    <form method="post" action="add_supermaster.php">
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
    73
     <table>
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
    74
      <tr>
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
    75
       <td class="n"><? echo _('IP address of supermaster'); ?>:</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="master_ip" value="<? if ($error) print $_POST["master_ip"]; ?>">
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 _('Hostname in NS record'); ?>:</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="ns_name" value="<? if ($error) print $_POST["ns_name"]; ?>">
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 _('Account'); ?>:</td>
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
    88
       <td class="n">
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
    89
        <input type="text" class="input" name="account" value="<? if ($error) print $_POST["account"]; ?>">
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
    90
       </td>
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
    91
      </tr>
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
    92
      <tr>
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
    93
       <td class="n">&nbsp;</td>
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
    94
       <td class="n">
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
    95
        <input type="submit" class="button" name="submit" value="<? echo _('Add supermaster'); ?>">
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
    96
       </td>
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
    97
      </tr>
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
    98
     </table>
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
    99
    </form>
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
   100
<?
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
   101
include_once("inc/footer.inc.php");
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
   102
?>