edit_record.php
changeset 13 2ff220cfde13
parent 3 64525a2eb098
child 37 b785e54690ce
equal deleted inserted replaced
12:7be4525290cc 13:2ff220cfde13
     1 <?php
     1 <?
     2 
       
     3 // +--------------------------------------------------------------------+
       
     4 // | PowerAdmin								|
       
     5 // +--------------------------------------------------------------------+
       
     6 // | Copyright (c) 1997-2002 The PowerAdmin Team			|
       
     7 // +--------------------------------------------------------------------+
       
     8 // | This source file is subject to the license carried by the overal	|
       
     9 // | program PowerAdmin as found on http://poweradmin.sf.net		|
       
    10 // | The PowerAdmin program falls under the QPL License:		|
       
    11 // | http://www.trolltech.com/developer/licensing/qpl.html		|
       
    12 // +--------------------------------------------------------------------+
       
    13 // | Authors: Roeland Nieuwenhuis <trancer <AT> trancer <DOT> nl>	|
       
    14 // |          Sjeemz <sjeemz <AT> sjeemz <DOT> nl>			|
       
    15 // +--------------------------------------------------------------------+
       
    16 
       
    17 //
       
    18 // $Id: edit_record.php,v 1.9 2003/05/14 22:48:13 azurazu Exp $
       
    19 //
       
    20 
     2 
    21 require_once("inc/toolkit.inc.php");
     3 require_once("inc/toolkit.inc.php");
    22 
     4 
    23 if (isset($_GET["delid"])) {
     5 if (isset($_GET["delid"])) {
    24    $db->query("DELETE FROM record_owners WHERE id='".$_GET["delid"]."'");
     6    $db->query("DELETE FROM record_owners WHERE id='".$_GET["delid"]."'");
    29 if(!xs(recid_to_domid($xsid)))
    11 if(!xs(recid_to_domid($xsid)))
    30 {
    12 {
    31     error(ERR_RECORD_ACCESS_DENIED);
    13     error(ERR_RECORD_ACCESS_DENIED);
    32 }
    14 }
    33 
    15 
    34 /*
       
    35 if($_SESSION["partial_".get_domain_name_from_id($_GET["domain"])] == 1 && !isset($_POST["recordid"])) 
       
    36 {
       
    37     $checkPartial = $db->getOne("SELECT id FROM record_owners WHERE record_id='".$_GET["id"]."' AND user_id='".$_SESSION["userid"]."' LIMIT 1");
       
    38     if (empty($checkPartial)) {
       
    39         error(ERR_RECORD_ACCESS_DENIED);
       
    40     }
       
    41 }
       
    42 */
       
    43 
       
    44 if ($_POST["commit"])
    16 if ($_POST["commit"])
    45 {
    17 {
    46         edit_record($_POST["recordid"], $_POST["domainid"], $_POST["name"], $_POST["type"], $_POST["content"], $_POST["ttl"], $_POST["prio"]);
    18         edit_record($_POST["recordid"], $_POST["domainid"], $_POST["name"], $_POST["type"], $_POST["content"], $_POST["ttl"], $_POST["prio"]);
    47         clean_page("edit.php?id=".$_POST["domainid"]);
    19         clean_page("edit.php?id=".$_POST["domainid"]);
    48 } elseif($_SESSION["partial_".get_domain_name_from_id($_GET["domain"])] == 1)
    20 } elseif($_SESSION["partial_".get_domain_name_from_id($_GET["domain"])] == 1)
    50     $checkPartial = $db->getOne("SELECT id FROM record_owners WHERE record_id='".$_GET["id"]."' AND user_id='".$_SESSION["userid"]."' LIMIT 1");
    22     $checkPartial = $db->getOne("SELECT id FROM record_owners WHERE record_id='".$_GET["id"]."' AND user_id='".$_SESSION["userid"]."' LIMIT 1");
    51     if (empty($checkPartial)) {
    23     if (empty($checkPartial)) {
    52         error(ERR_RECORD_ACCESS_DENIED);
    24         error(ERR_RECORD_ACCESS_DENIED);
    53     }
    25     }
    54 }
    26 }
       
    27 include_once("inc/header.inc.php");
       
    28 ?>
       
    29     <h2><? echo _('Edit record in zone'); ?> "<? echo  get_domain_name_from_id($_GET["domain"]) ?>"</h2>
       
    30 <?
    55 
    31 
    56 
    32 $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");
    57 include_once("inc/header.inc.php");
    33 if (level(10) && ($x_result->numRows() > 0)) 
    58 
    34 {
    59 ?>
    35 ?>
    60 <H2><? echo _('Edit record in zone'); ?> "<?= get_domain_name_from_id($_GET["domain"]) ?>"</H2>
    36     <div id="meta">
    61 <FONT CLASS="nav"><BR><A HREF="index.php"><? echo _('DNS Admin'); ?></A> &gt;&gt; <A HREF="edit.php?id=<?= $_GET["domain"] ?>"><?= get_domain_name_from_id($_GET["domain"]) ?></A> &gt;&gt; <? echo _('Edit record'); ?><BR><BR></FONT>
    37      <div id="meta-left">
    62 
    38       <table>
    63 <FORM METHOD="post" ACTION="edit_record.php">
    39        <tr>
    64 <INPUT TYPE="hidden" NAME="recordid" VALUE="<?= $_GET["id"] ?>">
    40         <th><? echo _('Sub-owners'); ?></td>
    65 <INPUT TYPE="hidden" NAME="domainid" VALUE="<?= $_GET["domain"] ?>">
    41         <th>&nbsp;</td>
    66 <TABLE BORDER="0" CELLSPACING="4">
    42        </tr>
    67 <TR STYLE="font-weight: Bold"><TD CLASS="tdbg"><? echo _('Name'); ?></TD><TD CLASS="tdbg">&nbsp;</TD><TD CLASS="tdbg"><? echo _('Type'); ?></TD><TD CLASS="tdbg"><? echo _('Priority'); ?></TD><TD CLASS="tdbg"><? echo _('Content'); ?></TD><TD CLASS="tdbg"><? echo _('TTL'); ?></TD></TR>
    43 <?
    68 
    44 	while ($x_r = $x_result->fetchRow()) 
       
    45 	{
       
    46 ?>
       
    47         <tr>
       
    48 	 <td class="tdbg"><? echo $x_r["fullname"]; ?></td>
       
    49 	 <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>
       
    50 	</tr>
       
    51 <?
       
    52 	}
       
    53 ?>
       
    54        </table>
       
    55       </div>
       
    56      </div>
       
    57 <? 
       
    58 }
       
    59 ?>
       
    60     <form method="post" action="edit_record.php">
       
    61      <input type="hidden" name="recordid" value="<? echo  $_GET["id"] ?>">
       
    62      <input type="hidden" name="domainid" value="<? echo  $_GET["domain"] ?>">
       
    63      <table>
       
    64       <tr>
       
    65        <th><? echo _('Name'); ?></td>
       
    66        <th>&nbsp;</td>
       
    67        <th><? echo _('Type'); ?></td>
       
    68        <th><? echo _('Priority'); ?></td>
       
    69        <th><? echo _('Content'); ?></td>
       
    70        <th><? echo _('TTL'); ?></td>
       
    71       </tr>
    69 <?
    72 <?
    70 	$rec = get_record_from_id($_GET["id"]);
    73 	$rec = get_record_from_id($_GET["id"]);
    71 ?>
    74 ?>
       
    75        <tr>
       
    76         <td>
       
    77 <? 
       
    78 if ($_SESSION[$_GET["domain"]."_ispartial"] == 1)  
       
    79 {
       
    80 ?>
       
    81          <input type="hidden" name="name" value="<? echo  trim(str_replace(get_domain_name_from_id($_GET["domain"]), '', $rec["name"]), '.')?>" class="input">
    72 
    82 
    73 <TR><TD CLASS="tdbg">
    83 <? echo  trim(str_replace(get_domain_name_from_id($_GET["domain"]), '', $rec["name"]), '.') ?>
    74 
    84 <? 
    75 <? if ($_SESSION[$_GET["domain"]."_ispartial"] == 1)  { ?>
    85 } 
    76 
    86 else 
    77 <INPUT TYPE="hidden" NAME="name" VALUE="<?= trim(str_replace(get_domain_name_from_id($_GET["domain"]), '', $rec["name"]), '.')?>" CLASS="input">
    87 { 
    78 
    88 ?>
    79 <?= trim(str_replace(get_domain_name_from_id($_GET["domain"]), '', $rec["name"]), '.') ?>
    89          <input type="text" name="name" value="<? echo  trim(str_replace(get_domain_name_from_id($_GET["domain"]), '', $rec["name"]), '.') ?>" class="input">
    80 <? } else { ?>
    90 <? 
    81 <INPUT TYPE="text" NAME="name" VALUE="<?= trim(str_replace(get_domain_name_from_id($_GET["domain"]), '', $rec["name"]), '.') ?>" CLASS="input">
    91 } 
    82 <? } ?>
    92 ?>
    83 .<?= get_domain_name_from_id($_GET["domain"]) ?></TD><TD CLASS="tdbg">IN</TD><TD CLASS="tdbg"><SELECT NAME="type">
    93 .<? echo  get_domain_name_from_id($_GET["domain"]) ?>
    84 
    94         </td>
       
    95 	<td class="n">IN</td>
       
    96 	<td>
       
    97 	 <select name="type">
    85 <?
    98 <?
    86 
       
    87 foreach (get_record_types() as $c)
    99 foreach (get_record_types() as $c)
    88 {
   100 {
    89 	if ($c == $rec["type"])
   101 	if ($c == $rec["type"])
    90 	{
   102 	{
    91 		$add = " SELECTED";
   103 		$add = " SELECTED";
    93 	else
   105 	else
    94 	{
   106 	{
    95 		$add = "";
   107 		$add = "";
    96 	}
   108 	}
    97 	?>
   109 	?>
    98 	<OPTION<?= $add ?> VALUE="<?= $c ?>"><?= $c ?></OPTION><?
   110 	<option<? echo  $add ?> value="<? echo  $c ?>"><? echo  $c ?></option><?
    99 }
   111 }
   100 
   112 
   101 ?>
   113 ?>
   102 </SELECT></TD><TD CLASS="tdbg"><INPUT TYPE="text" NAME="prio" VALUE="<?= $rec["prio"] ?>" CLASS="sinput"></TD><TD CLASS="tdbg"><INPUT TYPE="text" NAME="content" VALUE="<?= $rec["content"] ?>" CLASS="input"></TD><TD CLASS="tdbg"><INPUT TYPE="text" NAME="ttl" VALUE="<?= $rec["ttl"] ?>" CLASS="sinput"></TD></TR>
   114          </select>
   103 </TABLE>
   115 	</td>
   104 <BR><INPUT TYPE="submit" NAME="commit" VALUE="<? echo _('Commit changes'); ?>" CLASS="button">&nbsp;&nbsp;<INPUT TYPE="reset" NAME="reset" VALUE="<? echo _('Reset changes'); ?>" CLASS="button">
   116 	<td><input type="text" name="prio" value="<? echo  $rec["prio"] ?>" class="sinput"></td>
   105 </FORM>
   117 	<td><input type="text" name="content" value="<? echo  $rec["content"] ?>" class="input"></td>
   106 
   118 	<td><input type="text" name="ttl" value="<? echo  $rec["ttl"] ?>" class="sinput"></td>
   107 <?if (level(10)) { ?>
   119        </tr>
   108 <table style="width:140px">
   120       </table>
   109 <tr><td CLASS="tdbg"><b><? echo _('Sub-users'); ?></b></td><td CLASS="tdbg"> </td></tr>
   121       <p>
       
   122        <input type="submit" name="commit" value="<? echo _('Commit changes'); ?>" class="button">&nbsp;&nbsp;
       
   123        <input type="reset" name="reset" value="<? echo _('Reset changes'); ?>" class="button">
       
   124       </p>
       
   125      </form>
   110 <?
   126 <?
   111 $x_result = $db->query("SELECT r.id,u.username FROM record_owners as r, users as u WHERE r.record_id='".$_GET['id']."' AND u.id=r.user_id");
   127 include_once("inc/footer.inc.php");
   112 while ($x_r = $x_result->fetchRow()) {
       
   113    echo "<tr><td CLASS=\"tdbg\">".$x_r["username"]."</td><td CLASS=\"tdbg\">";
       
   114    echo "<a href=\"".$_SERVER["PHP_SELF"]."?id=".$_GET["id"]."&domain=".$_GET["domain"]."&delid=".$x_r["id"]."\">";
       
   115    echo "<img src=\"images/delete.gif\" alt=\"" . _('trash') . "\" border=\"0\"/></a></td></tr>";
       
   116 }
       
   117 ?>
   128 ?>
   118 </table>
       
   119 <? }
       
   120 
       
   121 include_once("inc/footer.inc.php");
       
   122 
       
   123 ?>