add_record.php
author peter
Wed, 12 Mar 2008 20:45:56 +0000
changeset 81 c72d6d51f3d3
parent 79 0c0aa144356a
child 82 c255196bc447
permissions -rw-r--r--
[feladat @ 159] Bugfix for ticket:16: A minor glitch in the query caused partially owned records not to be shown.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
     1
<?php
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
     2
47
ae140472d97c [feladat @ 94]
rejo
parents: 37
diff changeset
     3
/*  PowerAdmin, a friendly web-based admin tool for PowerDNS.
ae140472d97c [feladat @ 94]
rejo
parents: 37
diff changeset
     4
 *  See <https://rejo.zenger.nl/poweradmin> for more details.
ae140472d97c [feladat @ 94]
rejo
parents: 37
diff changeset
     5
 *
ae140472d97c [feladat @ 94]
rejo
parents: 37
diff changeset
     6
 *  Copyright 2007, 2008  Rejo Zenger <rejo@zenger.nl>
ae140472d97c [feladat @ 94]
rejo
parents: 37
diff changeset
     7
 *
ae140472d97c [feladat @ 94]
rejo
parents: 37
diff changeset
     8
 *  This program is free software: you can redistribute it and/or modify
ae140472d97c [feladat @ 94]
rejo
parents: 37
diff changeset
     9
 *  it under the terms of the GNU General Public License as published by
ae140472d97c [feladat @ 94]
rejo
parents: 37
diff changeset
    10
 *  the Free Software Foundation, either version 3 of the License, or
ae140472d97c [feladat @ 94]
rejo
parents: 37
diff changeset
    11
 *  (at your option) any later version.
ae140472d97c [feladat @ 94]
rejo
parents: 37
diff changeset
    12
 *
ae140472d97c [feladat @ 94]
rejo
parents: 37
diff changeset
    13
 *  This program is distributed in the hope that it will be useful,
ae140472d97c [feladat @ 94]
rejo
parents: 37
diff changeset
    14
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
ae140472d97c [feladat @ 94]
rejo
parents: 37
diff changeset
    15
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
ae140472d97c [feladat @ 94]
rejo
parents: 37
diff changeset
    16
 *  GNU General Public License for more details.
ae140472d97c [feladat @ 94]
rejo
parents: 37
diff changeset
    17
 *
ae140472d97c [feladat @ 94]
rejo
parents: 37
diff changeset
    18
 *  You should have received a copy of the GNU General Public License
ae140472d97c [feladat @ 94]
rejo
parents: 37
diff changeset
    19
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
ae140472d97c [feladat @ 94]
rejo
parents: 37
diff changeset
    20
 */
ae140472d97c [feladat @ 94]
rejo
parents: 37
diff changeset
    21
13
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
    22
require_once("inc/toolkit.inc.php");
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    23
37
b785e54690ce [feladat @ 84]
rejo
parents: 13
diff changeset
    24
$xsid = (isset($_GET['id'])) ? $_GET['id'] : $_POST['zoneid'];
b785e54690ce [feladat @ 84]
rejo
parents: 13
diff changeset
    25
if ((!level(5)) && ((!xs($xsid) || ($_SESSION[$xsid.'_ispartial'])))) {
b785e54690ce [feladat @ 84]
rejo
parents: 13
diff changeset
    26
	error(ERR_RECORD_ACCESS_DENIED);
b785e54690ce [feladat @ 84]
rejo
parents: 13
diff changeset
    27
}
b785e54690ce [feladat @ 84]
rejo
parents: 13
diff changeset
    28
79
0c0aa144356a [feladat @ 156]
peter
parents: 71
diff changeset
    29
if (isset($_POST["commit"]) && isset($_POST['zoneid']) && isset($_POST['name']) && isset($_POST['type']) && isset($_POST['content']) && isset($_POST['ttl']) && isset($_POST['prio']) ) {
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    30
        $ret = add_record($_POST["zoneid"], $_POST["name"], $_POST["type"], $_POST["content"], $_POST["ttl"], $_POST["prio"]);
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    31
        if ($ret != '1') {
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    32
                die("$ret");
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    33
        }
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    34
        clean_page("edit.php?id=".$_POST["zoneid"]);
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    35
}
13
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
    36
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    37
include_once("inc/header.inc.php");
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    38
?>
13
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
    39
71
e1b918eaf69a [feladat @ 118]
peter
parents: 47
diff changeset
    40
    <h2><?php echo _('Add record to zone'); ?> "<?php echo get_domain_name_from_id($_GET["id"]) ?>"</H2>
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    41
13
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
    42
    <form method="post">
71
e1b918eaf69a [feladat @ 118]
peter
parents: 47
diff changeset
    43
     <input type="hidden" name="zoneid" value="<?php echo $_GET["id"] ?>">
13
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
    44
     <table border="0" cellspacing="4">
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
    45
      <tr>
71
e1b918eaf69a [feladat @ 118]
peter
parents: 47
diff changeset
    46
       <td class="n"><?php echo _('Name'); ?></td>
13
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
    47
       <td class="n">&nbsp;</td>
71
e1b918eaf69a [feladat @ 118]
peter
parents: 47
diff changeset
    48
       <td class="n"><?php echo _('Type'); ?></td>
e1b918eaf69a [feladat @ 118]
peter
parents: 47
diff changeset
    49
       <td class="n"><?php echo _('Priority'); ?></td>
e1b918eaf69a [feladat @ 118]
peter
parents: 47
diff changeset
    50
       <td class="n"><?php echo _('Content'); ?></td>
e1b918eaf69a [feladat @ 118]
peter
parents: 47
diff changeset
    51
       <td class="n"><?php echo _('TTL'); ?></td>
13
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
    52
      </tr>
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
    53
      <tr>
71
e1b918eaf69a [feladat @ 118]
peter
parents: 47
diff changeset
    54
       <td class="n"><input type="text" name="name" class="input">.<?php echo get_domain_name_from_id($_GET["id"]) ?></td>
13
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
    55
       <td class="n">IN</td>
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
    56
       <td class="n">
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
    57
        <select name="type">
71
e1b918eaf69a [feladat @ 118]
peter
parents: 47
diff changeset
    58
<?php
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    59
$dname = get_domain_name_from_id($_GET["id"]);
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    60
foreach (get_record_types() as $c) {
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    61
        if (eregi('in-addr.arpa', $dname) && strtoupper($c) == 'PTR') {
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    62
                $add = " SELECTED";
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    63
        } elseif (strtoupper($c) == 'A') {
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    64
                $add = " SELECTED";
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    65
        } else {
79
0c0aa144356a [feladat @ 156]
peter
parents: 71
diff changeset
    66
                $add = '';
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    67
        }
71
e1b918eaf69a [feladat @ 118]
peter
parents: 47
diff changeset
    68
        ?><option<?php echo $add ?> value="<?php echo $c ?>"><?php echo $c ?></option><?php
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    69
}
13
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
    70
?>
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
    71
        </select>
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
    72
       </td>
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
    73
       <td class="n"><input type="text" name="prio" class="sinput"></td>
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
    74
       <td class="n"><input type="text" name="content" class="input"></td>
71
e1b918eaf69a [feladat @ 118]
peter
parents: 47
diff changeset
    75
       <td class="n"><input type="text" name="ttl" class="sinput" value="<?php echo $DEFAULT_TTL?>"></td>
13
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
    76
      </tr>
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
    77
     </table>
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
    78
     <br>
71
e1b918eaf69a [feladat @ 118]
peter
parents: 47
diff changeset
    79
     <input type="submit" name="commit" value="<?php echo _('Add record'); ?>" class="button">
13
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
    80
    </form>
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    81
71
e1b918eaf69a [feladat @ 118]
peter
parents: 47
diff changeset
    82
<?php include_once("inc/footer.inc.php"); ?>