edit_record.php
author rejo
Tue, 01 Jan 2008 22:07:00 +0000
changeset 57 acc4da012674
parent 47 ae140472d97c
child 65 ce1c4d5e1576
permissions -rw-r--r--
[feladat @ 104] Created function to delete sub-owner from record.
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
{
37
b785e54690ce [feladat @ 84]
rejo
parents: 13
diff changeset
    41
    $checkPartial = $db->queryOne("SELECT id FROM record_owners WHERE record_id='".$_GET["id"]."' AND user_id='".$_SESSION["userid"]."' LIMIT 1");
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    42
    if (empty($checkPartial)) {
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    43
        error(ERR_RECORD_ACCESS_DENIED);
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    44
    }
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    45
}
13
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
    46
include_once("inc/header.inc.php");
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
    47
?>
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
    48
    <h2><? echo _('Edit record in zone'); ?> "<? echo  get_domain_name_from_id($_GET["domain"]) ?>"</h2>
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
    49
<?
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    50
13
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
    51
$x_result = $db->query("SELECT r.id,u.fullname FROM record_owners as r, users as u WHERE r.record_id='".$_GET['id']."' AND u.id=r.user_id");
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
    52
if (level(10) && ($x_result->numRows() > 0)) 
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
    53
{
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
    54
?>
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
    55
    <div id="meta">
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
    56
     <div id="meta-left">
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
    57
      <table>
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
    58
       <tr>
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
    59
        <th><? echo _('Sub-owners'); ?></td>
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
    60
        <th>&nbsp;</td>
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
    61
       </tr>
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
    62
<?
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
    63
	while ($x_r = $x_result->fetchRow()) 
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
    64
	{
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    65
?>
13
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
    66
        <tr>
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
    67
	 <td class="tdbg"><? echo $x_r["fullname"]; ?></td>
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
    68
	 <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
    69
	</tr>
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
    70
<?
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
       </table>
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
    74
      </div>
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
    75
     </div>
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
    76
<? 
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
    <form method="post" action="edit_record.php">
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
    80
     <input type="hidden" name="recordid" value="<? echo  $_GET["id"] ?>">
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
    81
     <input type="hidden" name="domainid" value="<? echo  $_GET["domain"] ?>">
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
    82
     <table>
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
    83
      <tr>
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
    84
       <th><? echo _('Name'); ?></td>
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
    85
       <th>&nbsp;</td>
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
    86
       <th><? echo _('Type'); ?></td>
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
    87
       <th><? echo _('Priority'); ?></td>
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
    88
       <th><? echo _('Content'); ?></td>
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
    89
       <th><? echo _('TTL'); ?></td>
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
    90
      </tr>
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    91
<?
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    92
	$rec = get_record_from_id($_GET["id"]);
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    93
?>
13
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
    94
       <tr>
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
    95
        <td>
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
    96
<? 
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
    97
if ($_SESSION[$_GET["domain"]."_ispartial"] == 1)  
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
    98
{
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
    99
?>
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
   100
         <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
   101
13
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
   102
<? echo  trim(str_replace(get_domain_name_from_id($_GET["domain"]), '', $rec["name"]), '.') ?>
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
   103
<? 
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
   104
} 
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
   105
else 
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
   106
{ 
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
   107
?>
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
   108
         <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
   109
<? 
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
.<? echo  get_domain_name_from_id($_GET["domain"]) ?>
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
   113
        </td>
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
   114
	<td class="n">IN</td>
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
   115
	<td>
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
   116
	 <select name="type">
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   117
<?
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   118
foreach (get_record_types() as $c)
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   119
{
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   120
	if ($c == $rec["type"])
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   121
	{
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   122
		$add = " SELECTED";
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   123
	}
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   124
	else
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   125
	{
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   126
		$add = "";
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   127
	}
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   128
	?>
13
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
   129
	<option<? echo  $add ?> value="<? echo  $c ?>"><? echo  $c ?></option><?
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   130
}
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   131
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   132
?>
13
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
   133
         </select>
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
   134
	</td>
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
   135
	<td><input type="text" name="prio" value="<? echo  $rec["prio"] ?>" class="sinput"></td>
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
   136
	<td><input type="text" name="content" value="<? echo  $rec["content"] ?>" class="input"></td>
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
   137
	<td><input type="text" name="ttl" value="<? echo  $rec["ttl"] ?>" class="sinput"></td>
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
   138
       </tr>
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
   139
      </table>
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
   140
      <p>
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
   141
       <input type="submit" name="commit" value="<? echo _('Commit changes'); ?>" class="button">&nbsp;&nbsp;
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
   142
       <input type="reset" name="reset" value="<? echo _('Reset changes'); ?>" class="button">
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
   143
      </p>
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
   144
     </form>
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   145
<?
13
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
   146
include_once("inc/footer.inc.php");
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   147
?>