edit_record.php
author rejo
Sun, 06 Jan 2008 13:27:51 +0000
changeset 68 0b8572de80f5
parent 65 ce1c4d5e1576
child 71 e1b918eaf69a
permissions -rw-r--r--
[feladat @ 115] Fixed a missing slash in a html tag in list_zones.php.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
13
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
     1
<?
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
?>
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
    49
    <h2><? echo _('Edit record in zone'); ?> "<? echo  get_domain_name_from_id($_GET["domain"]) ?>"</h2>
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
    50
<?
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>
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
    60
        <th><? echo _('Sub-owners'); ?></td>
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
    61
        <th>&nbsp;</td>
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
    62
       </tr>
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
    63
<?
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>
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
    68
	 <td class="tdbg"><? echo $x_r["fullname"]; ?></td>
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
    69
	 <td class="tdbg"><a href="<? echo $_SERVER["PHP_SELF"]; ?>?id=<? echo $_GET["id"]; ?>&amp;domain=<? echo $_GET["domain"]; ?>&amp;delid=<? echo $x_r["id"]; ?>"><img src="images/delete.gif" alt="trash"></a></td>
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
    70
	</tr>
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
    71
<?
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>
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
    77
<? 
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">
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
    81
     <input type="hidden" name="recordid" value="<? echo  $_GET["id"] ?>">
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
    82
     <input type="hidden" name="domainid" value="<? echo  $_GET["domain"] ?>">
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
    83
     <table>
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
    84
      <tr>
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
    85
       <th><? echo _('Name'); ?></td>
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
    86
       <th>&nbsp;</td>
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
    87
       <th><? echo _('Type'); ?></td>
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
    88
       <th><? echo _('Priority'); ?></td>
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
    89
       <th><? echo _('Content'); ?></td>
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
    90
       <th><? echo _('TTL'); ?></td>
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
    91
      </tr>
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    92
<?
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>
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
    97
<? 
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
?>
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
   101
         <input type="hidden" name="name" value="<? echo  trim(str_replace(get_domain_name_from_id($_GET["domain"]), '', $rec["name"]), '.')?>" class="input">
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   102
13
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
   103
<? echo  trim(str_replace(get_domain_name_from_id($_GET["domain"]), '', $rec["name"]), '.') ?>
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
   104
<? 
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
?>
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
   109
         <input type="text" name="name" value="<? echo  trim(str_replace(get_domain_name_from_id($_GET["domain"]), '', $rec["name"]), '.') ?>" class="input">
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
   110
<? 
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
   111
} 
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
   112
?>
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
   113
.<? echo  get_domain_name_from_id($_GET["domain"]) ?>
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">
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   118
<?
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
	?>
13
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
   130
	<option<? echo  $add ?> value="<? echo  $c ?>"><? echo  $c ?></option><?
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>
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
   136
	<td><input type="text" name="prio" value="<? echo  $rec["prio"] ?>" class="sinput"></td>
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
   137
	<td><input type="text" name="content" value="<? echo  $rec["content"] ?>" class="input"></td>
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
   138
	<td><input type="text" name="ttl" value="<? echo  $rec["ttl"] ?>" class="sinput"></td>
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>
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
   142
       <input type="submit" name="commit" value="<? echo _('Commit changes'); ?>" class="button">&nbsp;&nbsp;
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
   143
       <input type="reset" name="reset" value="<? echo _('Reset changes'); ?>" class="button">
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
   144
      </p>
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
   145
     </form>
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   146
<?
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
?>