edit_record.php
author peter
Wed, 12 Mar 2008 20:45:56 +0000
changeset 81 c72d6d51f3d3
parent 80 48b5f7021aaa
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:
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
79
0c0aa144356a [feladat @ 156]
peter
parents: 71
diff changeset
    24
if (isset($_GET["delid"]) && isset($_GET['delid']) && isset($_GET['id'])) {
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
79
0c0aa144356a [feladat @ 156]
peter
parents: 71
diff changeset
    35
if (isset($_GET['domain'])) {
0c0aa144356a [feladat @ 156]
peter
parents: 71
diff changeset
    36
	$domain_name = get_domain_name_from_id($_GET['domain']);
0c0aa144356a [feladat @ 156]
peter
parents: 71
diff changeset
    37
}
0c0aa144356a [feladat @ 156]
peter
parents: 71
diff changeset
    38
if (isset($_POST["commit"]) && isset($_POST['recordid']) && isset($_POST['domainid']) && isset($_POST['name']) && isset($_POST['type']) && isset($_POST['content']) && isset($_POST['ttl']) && isset($_POST['prio']))
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    39
{
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    40
        edit_record($_POST["recordid"], $_POST["domainid"], $_POST["name"], $_POST["type"], $_POST["content"], $_POST["ttl"], $_POST["prio"]);
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    41
        clean_page("edit.php?id=".$_POST["domainid"]);
79
0c0aa144356a [feladat @ 156]
peter
parents: 71
diff changeset
    42
} elseif(isset($_SESSION['partial_'.$domain_name]) && ($_SESSION["partial_".$domain_name] == 1))
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    43
{
65
ce1c4d5e1576 [feladat @ 112]
peter
parents: 57
diff changeset
    44
	$db->setLimit(1);
ce1c4d5e1576 [feladat @ 112]
peter
parents: 57
diff changeset
    45
    $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
    46
    if (empty($checkPartial)) {
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    47
        error(ERR_RECORD_ACCESS_DENIED);
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    48
    }
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    49
}
13
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
    50
include_once("inc/header.inc.php");
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
    51
?>
79
0c0aa144356a [feladat @ 156]
peter
parents: 71
diff changeset
    52
    <h2><?php echo _('Edit record in zone'); ?> "<?php echo  $domain_name ?>"</h2>
71
e1b918eaf69a [feladat @ 118]
peter
parents: 65
diff changeset
    53
<?php
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    54
65
ce1c4d5e1576 [feladat @ 112]
peter
parents: 57
diff changeset
    55
$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
    56
if (level(10) && ($x_result->numRows() > 0)) 
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
    57
{
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
    58
?>
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
    59
    <div id="meta">
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
    60
     <div id="meta-left">
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
    61
      <table>
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
    62
       <tr>
71
e1b918eaf69a [feladat @ 118]
peter
parents: 65
diff changeset
    63
        <th><?php echo _('Sub-owners'); ?></td>
13
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
    64
        <th>&nbsp;</td>
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
    65
       </tr>
71
e1b918eaf69a [feladat @ 118]
peter
parents: 65
diff changeset
    66
<?php
13
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
    67
	while ($x_r = $x_result->fetchRow()) 
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
    68
	{
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    69
?>
13
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
    70
        <tr>
71
e1b918eaf69a [feladat @ 118]
peter
parents: 65
diff changeset
    71
	 <td class="tdbg"><?php echo $x_r["fullname"]; ?></td>
e1b918eaf69a [feladat @ 118]
peter
parents: 65
diff changeset
    72
	 <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
    73
	</tr>
71
e1b918eaf69a [feladat @ 118]
peter
parents: 65
diff changeset
    74
<?php
13
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
    75
	}
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
    76
?>
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
    77
       </table>
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
    78
      </div>
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
    79
     </div>
71
e1b918eaf69a [feladat @ 118]
peter
parents: 65
diff changeset
    80
<?php 
13
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
    81
}
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
    82
?>
80
48b5f7021aaa [feladat @ 158]
peter
parents: 79
diff changeset
    83
	<div id="meta">&nbsp;</div>
48b5f7021aaa [feladat @ 158]
peter
parents: 79
diff changeset
    84
	<div>
13
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
    85
    <form method="post" action="edit_record.php">
71
e1b918eaf69a [feladat @ 118]
peter
parents: 65
diff changeset
    86
     <input type="hidden" name="recordid" value="<?php echo  $_GET["id"] ?>">
e1b918eaf69a [feladat @ 118]
peter
parents: 65
diff changeset
    87
     <input type="hidden" name="domainid" value="<?php echo  $_GET["domain"] ?>">
13
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
    88
     <table>
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
    89
      <tr>
71
e1b918eaf69a [feladat @ 118]
peter
parents: 65
diff changeset
    90
       <th><?php echo _('Name'); ?></td>
13
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
    91
       <th>&nbsp;</td>
71
e1b918eaf69a [feladat @ 118]
peter
parents: 65
diff changeset
    92
       <th><?php echo _('Type'); ?></td>
e1b918eaf69a [feladat @ 118]
peter
parents: 65
diff changeset
    93
       <th><?php echo _('Priority'); ?></td>
e1b918eaf69a [feladat @ 118]
peter
parents: 65
diff changeset
    94
       <th><?php echo _('Content'); ?></td>
e1b918eaf69a [feladat @ 118]
peter
parents: 65
diff changeset
    95
       <th><?php echo _('TTL'); ?></td>
13
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
    96
      </tr>
71
e1b918eaf69a [feladat @ 118]
peter
parents: 65
diff changeset
    97
<?php
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    98
	$rec = get_record_from_id($_GET["id"]);
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    99
?>
13
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
   100
       <tr>
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
   101
        <td>
71
e1b918eaf69a [feladat @ 118]
peter
parents: 65
diff changeset
   102
<?php 
13
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
   103
if ($_SESSION[$_GET["domain"]."_ispartial"] == 1)  
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
   104
{
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
   105
?>
79
0c0aa144356a [feladat @ 156]
peter
parents: 71
diff changeset
   106
         <input type="hidden" name="name" value="<?php echo  trim(str_replace($domain_name, '', $rec["name"]), '.')?>" class="input">
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   107
79
0c0aa144356a [feladat @ 156]
peter
parents: 71
diff changeset
   108
<?php echo  trim(str_replace($domain_name, '', $rec["name"]), '.') ?>
71
e1b918eaf69a [feladat @ 118]
peter
parents: 65
diff changeset
   109
<?php 
13
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
   110
} 
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
   111
else 
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
   112
{ 
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
   113
?>
79
0c0aa144356a [feladat @ 156]
peter
parents: 71
diff changeset
   114
         <input type="text" name="name" value="<?php echo  trim(str_replace($domain_name, '', $rec["name"]), '.') ?>" class="input">
71
e1b918eaf69a [feladat @ 118]
peter
parents: 65
diff changeset
   115
<?php 
13
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
   116
} 
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
   117
?>
79
0c0aa144356a [feladat @ 156]
peter
parents: 71
diff changeset
   118
.<?php echo  $domain_name ?>
13
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
   119
        </td>
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
   120
	<td class="n">IN</td>
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
   121
	<td>
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
   122
	 <select name="type">
71
e1b918eaf69a [feladat @ 118]
peter
parents: 65
diff changeset
   123
<?php
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   124
foreach (get_record_types() as $c)
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   125
{
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   126
	if ($c == $rec["type"])
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   127
	{
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   128
		$add = " SELECTED";
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   129
	}
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   130
	else
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   131
	{
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   132
		$add = "";
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   133
	}
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   134
	?>
71
e1b918eaf69a [feladat @ 118]
peter
parents: 65
diff changeset
   135
	<option<?php echo  $add ?> value="<?php echo  $c ?>"><?php echo  $c ?></option><?php
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   136
}
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   137
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   138
?>
13
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
   139
         </select>
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
   140
	</td>
71
e1b918eaf69a [feladat @ 118]
peter
parents: 65
diff changeset
   141
	<td><input type="text" name="prio" value="<?php echo  $rec["prio"] ?>" class="sinput"></td>
e1b918eaf69a [feladat @ 118]
peter
parents: 65
diff changeset
   142
	<td><input type="text" name="content" value="<?php echo  $rec["content"] ?>" class="input"></td>
e1b918eaf69a [feladat @ 118]
peter
parents: 65
diff changeset
   143
	<td><input type="text" name="ttl" value="<?php echo  $rec["ttl"] ?>" class="sinput"></td>
13
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
   144
       </tr>
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
   145
      </table>
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
   146
      <p>
71
e1b918eaf69a [feladat @ 118]
peter
parents: 65
diff changeset
   147
       <input type="submit" name="commit" value="<?php echo _('Commit changes'); ?>" class="button">&nbsp;&nbsp;
e1b918eaf69a [feladat @ 118]
peter
parents: 65
diff changeset
   148
       <input type="reset" name="reset" value="<?php echo _('Reset changes'); ?>" class="button">
13
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
   149
      </p>
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
   150
     </form>
80
48b5f7021aaa [feladat @ 158]
peter
parents: 79
diff changeset
   151
	</div>
71
e1b918eaf69a [feladat @ 118]
peter
parents: 65
diff changeset
   152
<?php
13
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
   153
include_once("inc/footer.inc.php");
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   154
?>