edit_record.php
author peter
Sun, 03 Feb 2008 16:50:06 +0000
changeset 72 a5cf0384e9b4
parent 71 e1b918eaf69a
child 79 0c0aa144356a
permissions -rw-r--r--
[feladat @ 119] Modified install.php to have the same footer as the rest of the files.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
71
e1b918eaf69a [feladat @ 118]
peter
parents: 65
diff changeset
     1
<?php
1
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
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    22
require_once("inc/toolkit.inc.php");
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    23
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    24
if (isset($_GET["delid"])) {
57
acc4da012674 [feladat @ 104]
rejo
parents: 47
diff changeset
    25
   delete_record_owner($_GET["domain"],$_GET["delid"],$_GET["id"]);
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    26
}
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    27
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    28
$xsid = (isset($_GET['id'])) ? $_GET['id'] : $_POST['recordid'];
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    29
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    30
if(!xs(recid_to_domid($xsid)))
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    31
{
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    32
    error(ERR_RECORD_ACCESS_DENIED);
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    33
}
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    34
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    35
if ($_POST["commit"])
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    36
{
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    37
        edit_record($_POST["recordid"], $_POST["domainid"], $_POST["name"], $_POST["type"], $_POST["content"], $_POST["ttl"], $_POST["prio"]);
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    38
        clean_page("edit.php?id=".$_POST["domainid"]);
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    39
} elseif($_SESSION["partial_".get_domain_name_from_id($_GET["domain"])] == 1)
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    40
{
65
ce1c4d5e1576 [feladat @ 112]
peter
parents: 57
diff changeset
    41
	$db->setLimit(1);
ce1c4d5e1576 [feladat @ 112]
peter
parents: 57
diff changeset
    42
    $checkPartial = $db->queryOne("SELECT id FROM record_owners WHERE record_id=".$db->quote($_GET["id"])." AND user_id=".$db->quote($_SESSION["userid"]));
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    43
    if (empty($checkPartial)) {
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    44
        error(ERR_RECORD_ACCESS_DENIED);
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    45
    }
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    46
}
13
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
    47
include_once("inc/header.inc.php");
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
    48
?>
71
e1b918eaf69a [feladat @ 118]
peter
parents: 65
diff changeset
    49
    <h2><?php echo _('Edit record in zone'); ?> "<?php echo  get_domain_name_from_id($_GET["domain"]) ?>"</h2>
e1b918eaf69a [feladat @ 118]
peter
parents: 65
diff changeset
    50
<?php
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    51
65
ce1c4d5e1576 [feladat @ 112]
peter
parents: 57
diff changeset
    52
$x_result = $db->query("SELECT r.id,u.fullname FROM record_owners as r, users as u WHERE r.record_id=".$db->quote($_GET['id'])." AND u.id=r.user_id");
13
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
    53
if (level(10) && ($x_result->numRows() > 0)) 
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
    54
{
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
    55
?>
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
    56
    <div id="meta">
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
    57
     <div id="meta-left">
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
    58
      <table>
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
    59
       <tr>
71
e1b918eaf69a [feladat @ 118]
peter
parents: 65
diff changeset
    60
        <th><?php echo _('Sub-owners'); ?></td>
13
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
    61
        <th>&nbsp;</td>
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
    62
       </tr>
71
e1b918eaf69a [feladat @ 118]
peter
parents: 65
diff changeset
    63
<?php
13
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
    64
	while ($x_r = $x_result->fetchRow()) 
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
    65
	{
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    66
?>
13
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
    67
        <tr>
71
e1b918eaf69a [feladat @ 118]
peter
parents: 65
diff changeset
    68
	 <td class="tdbg"><?php echo $x_r["fullname"]; ?></td>
e1b918eaf69a [feladat @ 118]
peter
parents: 65
diff changeset
    69
	 <td class="tdbg"><a href="<?php echo $_SERVER["PHP_SELF"]; ?>?id=<?php echo $_GET["id"]; ?>&amp;domain=<?php echo $_GET["domain"]; ?>&amp;delid=<?php echo $x_r["id"]; ?>"><img src="images/delete.gif" alt="trash"></a></td>
13
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
    70
	</tr>
71
e1b918eaf69a [feladat @ 118]
peter
parents: 65
diff changeset
    71
<?php
13
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
    72
	}
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
    73
?>
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
    74
       </table>
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
    75
      </div>
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
    76
     </div>
71
e1b918eaf69a [feladat @ 118]
peter
parents: 65
diff changeset
    77
<?php 
13
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
    78
}
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
    79
?>
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
    80
    <form method="post" action="edit_record.php">
71
e1b918eaf69a [feladat @ 118]
peter
parents: 65
diff changeset
    81
     <input type="hidden" name="recordid" value="<?php echo  $_GET["id"] ?>">
e1b918eaf69a [feladat @ 118]
peter
parents: 65
diff changeset
    82
     <input type="hidden" name="domainid" value="<?php echo  $_GET["domain"] ?>">
13
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
    83
     <table>
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
    84
      <tr>
71
e1b918eaf69a [feladat @ 118]
peter
parents: 65
diff changeset
    85
       <th><?php echo _('Name'); ?></td>
13
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
    86
       <th>&nbsp;</td>
71
e1b918eaf69a [feladat @ 118]
peter
parents: 65
diff changeset
    87
       <th><?php echo _('Type'); ?></td>
e1b918eaf69a [feladat @ 118]
peter
parents: 65
diff changeset
    88
       <th><?php echo _('Priority'); ?></td>
e1b918eaf69a [feladat @ 118]
peter
parents: 65
diff changeset
    89
       <th><?php echo _('Content'); ?></td>
e1b918eaf69a [feladat @ 118]
peter
parents: 65
diff changeset
    90
       <th><?php echo _('TTL'); ?></td>
13
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
    91
      </tr>
71
e1b918eaf69a [feladat @ 118]
peter
parents: 65
diff changeset
    92
<?php
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    93
	$rec = get_record_from_id($_GET["id"]);
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    94
?>
13
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
    95
       <tr>
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
    96
        <td>
71
e1b918eaf69a [feladat @ 118]
peter
parents: 65
diff changeset
    97
<?php 
13
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
    98
if ($_SESSION[$_GET["domain"]."_ispartial"] == 1)  
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
    99
{
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
   100
?>
71
e1b918eaf69a [feladat @ 118]
peter
parents: 65
diff changeset
   101
         <input type="hidden" name="name" value="<?php echo  trim(str_replace(get_domain_name_from_id($_GET["domain"]), '', $rec["name"]), '.')?>" class="input">
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   102
71
e1b918eaf69a [feladat @ 118]
peter
parents: 65
diff changeset
   103
<?php echo  trim(str_replace(get_domain_name_from_id($_GET["domain"]), '', $rec["name"]), '.') ?>
e1b918eaf69a [feladat @ 118]
peter
parents: 65
diff changeset
   104
<?php 
13
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
   105
} 
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
   106
else 
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
   107
{ 
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
   108
?>
71
e1b918eaf69a [feladat @ 118]
peter
parents: 65
diff changeset
   109
         <input type="text" name="name" value="<?php echo  trim(str_replace(get_domain_name_from_id($_GET["domain"]), '', $rec["name"]), '.') ?>" class="input">
e1b918eaf69a [feladat @ 118]
peter
parents: 65
diff changeset
   110
<?php 
13
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
   111
} 
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
   112
?>
71
e1b918eaf69a [feladat @ 118]
peter
parents: 65
diff changeset
   113
.<?php echo  get_domain_name_from_id($_GET["domain"]) ?>
13
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
   114
        </td>
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
   115
	<td class="n">IN</td>
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
   116
	<td>
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
   117
	 <select name="type">
71
e1b918eaf69a [feladat @ 118]
peter
parents: 65
diff changeset
   118
<?php
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   119
foreach (get_record_types() as $c)
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   120
{
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   121
	if ($c == $rec["type"])
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   122
	{
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   123
		$add = " SELECTED";
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   124
	}
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   125
	else
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   126
	{
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   127
		$add = "";
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   128
	}
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   129
	?>
71
e1b918eaf69a [feladat @ 118]
peter
parents: 65
diff changeset
   130
	<option<?php echo  $add ?> value="<?php echo  $c ?>"><?php echo  $c ?></option><?php
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   131
}
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   132
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   133
?>
13
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
   134
         </select>
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
   135
	</td>
71
e1b918eaf69a [feladat @ 118]
peter
parents: 65
diff changeset
   136
	<td><input type="text" name="prio" value="<?php echo  $rec["prio"] ?>" class="sinput"></td>
e1b918eaf69a [feladat @ 118]
peter
parents: 65
diff changeset
   137
	<td><input type="text" name="content" value="<?php echo  $rec["content"] ?>" class="input"></td>
e1b918eaf69a [feladat @ 118]
peter
parents: 65
diff changeset
   138
	<td><input type="text" name="ttl" value="<?php echo  $rec["ttl"] ?>" class="sinput"></td>
13
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
   139
       </tr>
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
   140
      </table>
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
   141
      <p>
71
e1b918eaf69a [feladat @ 118]
peter
parents: 65
diff changeset
   142
       <input type="submit" name="commit" value="<?php echo _('Commit changes'); ?>" class="button">&nbsp;&nbsp;
e1b918eaf69a [feladat @ 118]
peter
parents: 65
diff changeset
   143
       <input type="reset" name="reset" value="<?php echo _('Reset changes'); ?>" class="button">
13
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
   144
      </p>
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
   145
     </form>
71
e1b918eaf69a [feladat @ 118]
peter
parents: 65
diff changeset
   146
<?php
13
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
   147
include_once("inc/footer.inc.php");
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   148
?>