edit_record.php
changeset 1 58094faf794d
child 2 9a485c41cfcf
equal deleted inserted replaced
0:2cd8c1649ba9 1:58094faf794d
       
     1 <?php
       
     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 
       
    21 require_once("inc/toolkit.inc.php");
       
    22 
       
    23 if (isset($_GET["delid"])) {
       
    24    $db->query("DELETE FROM record_owners WHERE id='".$_GET["delid"]."'");
       
    25 }
       
    26 
       
    27 $xsid = (isset($_GET['id'])) ? $_GET['id'] : $_POST['recordid'];
       
    28 
       
    29 if(!xs(recid_to_domid($xsid)))
       
    30 {
       
    31     error(ERR_RECORD_ACCESS_DENIED);
       
    32 }
       
    33 
       
    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"])
       
    45 {
       
    46         edit_record($_POST["recordid"], $_POST["domainid"], $_POST["name"], $_POST["type"], $_POST["content"], $_POST["ttl"], $_POST["prio"]);
       
    47         clean_page("edit.php?id=".$_POST["domainid"]);
       
    48 } elseif($_SESSION["partial_".get_domain_name_from_id($_GET["domain"])] == 1)
       
    49 {
       
    50     $checkPartial = $db->getOne("SELECT id FROM record_owners WHERE record_id='".$_GET["id"]."' AND user_id='".$_SESSION["userid"]."' LIMIT 1");
       
    51     if (empty($checkPartial)) {
       
    52         error(ERR_RECORD_ACCESS_DENIED);
       
    53     }
       
    54 }
       
    55 
       
    56 
       
    57 include_once("inc/header.inc.php");
       
    58 
       
    59 ?>
       
    60 <H2>Edit record in zone "<?= get_domain_name_from_id($_GET["domain"]) ?>"</H2>
       
    61 <FONT CLASS="nav"><BR><A HREF="index.php">DNS Admin</A> &gt;&gt; <A HREF="edit.php?id=<?= $_GET["domain"] ?>"><?= get_domain_name_from_id($_GET["domain"]) ?></A> &gt;&gt; Edit record<BR><BR></FONT>
       
    62 
       
    63 <FORM METHOD="post" ACTION="edit_record.php">
       
    64 <INPUT TYPE="hidden" NAME="recordid" VALUE="<?= $_GET["id"] ?>">
       
    65 <INPUT TYPE="hidden" NAME="domainid" VALUE="<?= $_GET["domain"] ?>">
       
    66 <TABLE BORDER="0" CELLSPACING="4">
       
    67 <TR STYLE="font-weight: Bold"><TD CLASS="tdbg">Name</TD><TD CLASS="tdbg">&nbsp;</TD><TD CLASS="tdbg">Type</TD><TD CLASS="tdbg">Priority</TD><TD CLASS="tdbg">Content</TD><TD CLASS="tdbg">TimeToLive</TD></TR>
       
    68 
       
    69 <?
       
    70 	$rec = get_record_from_id($_GET["id"]);
       
    71 ?>
       
    72 
       
    73 <TR><TD CLASS="tdbg">
       
    74 
       
    75 <? if ($_SESSION[$_GET["domain"]."_ispartial"] == 1)  { ?>
       
    76 
       
    77 <INPUT TYPE="hidden" NAME="name" VALUE="<?= trim(str_replace(get_domain_name_from_id($_GET["domain"]), '', $rec["name"]), '.')?>" CLASS="input">
       
    78 
       
    79 <?= trim(str_replace(get_domain_name_from_id($_GET["domain"]), '', $rec["name"]), '.') ?>
       
    80 <? } else { ?>
       
    81 <INPUT TYPE="text" NAME="name" VALUE="<?= trim(str_replace(get_domain_name_from_id($_GET["domain"]), '', $rec["name"]), '.') ?>" CLASS="input">
       
    82 <? } ?>
       
    83 .<?= get_domain_name_from_id($_GET["domain"]) ?></TD><TD CLASS="tdbg">IN</TD><TD CLASS="tdbg"><SELECT NAME="type">
       
    84 
       
    85 <?
       
    86 
       
    87 foreach (get_record_types() as $c)
       
    88 {
       
    89 	if ($c == $rec["type"])
       
    90 	{
       
    91 		$add = " SELECTED";
       
    92 	}
       
    93 	else
       
    94 	{
       
    95 		$add = "";
       
    96 	}
       
    97 	?>
       
    98 	<OPTION<?= $add ?> VALUE="<?= $c ?>"><?= $c ?></OPTION><?
       
    99 }
       
   100 
       
   101 ?>
       
   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>
       
   103 </TABLE>
       
   104 <BR><INPUT TYPE="submit" NAME="commit" VALUE="Commit changes" CLASS="button">&nbsp;&nbsp;<INPUT TYPE="reset" NAME="reset" VALUE="Reset changes" CLASS="button">
       
   105 </FORM>
       
   106 
       
   107 <?if (level(10)) { ?>
       
   108 <table style="width:140px">
       
   109 <tr><td CLASS="tdbg"><b>Sub-users</b></td><td CLASS="tdbg"> </td></tr>
       
   110 <?
       
   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");
       
   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 ?>
       
   118 </table>
       
   119 <? }
       
   120 
       
   121 include_once("inc/footer.inc.php");
       
   122 
       
   123 ?>