edit_record.php
author rejo
Wed, 27 Jun 2007 20:45:51 +0000
changeset 29 e1c60f72d494
parent 13 2ff220cfde13
child 37 b785e54690ce
permissions -rw-r--r--
[feladat @ 76] Changed some of the functions that are used for the listing of (all) zones. Instead of getting all zones from the database, it now only requests exactlty what it needs. Considerable perfomance improvement.
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
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
     3
require_once("inc/toolkit.inc.php");
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
     4
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
     5
if (isset($_GET["delid"])) {
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
     6
   $db->query("DELETE FROM record_owners WHERE id='".$_GET["delid"]."'");
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
     7
}
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
     8
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
     9
$xsid = (isset($_GET['id'])) ? $_GET['id'] : $_POST['recordid'];
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    10
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    11
if(!xs(recid_to_domid($xsid)))
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    12
{
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    13
    error(ERR_RECORD_ACCESS_DENIED);
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    14
}
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    15
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    16
if ($_POST["commit"])
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    17
{
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    18
        edit_record($_POST["recordid"], $_POST["domainid"], $_POST["name"], $_POST["type"], $_POST["content"], $_POST["ttl"], $_POST["prio"]);
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    19
        clean_page("edit.php?id=".$_POST["domainid"]);
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    20
} elseif($_SESSION["partial_".get_domain_name_from_id($_GET["domain"])] == 1)
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    21
{
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    22
    $checkPartial = $db->getOne("SELECT id FROM record_owners WHERE record_id='".$_GET["id"]."' AND user_id='".$_SESSION["userid"]."' LIMIT 1");
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    23
    if (empty($checkPartial)) {
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    24
        error(ERR_RECORD_ACCESS_DENIED);
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    25
    }
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    26
}
13
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
    27
include_once("inc/header.inc.php");
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
    28
?>
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
    29
    <h2><? echo _('Edit record in zone'); ?> "<? echo  get_domain_name_from_id($_GET["domain"]) ?>"</h2>
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
    30
<?
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    31
13
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
    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");
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
    33
if (level(10) && ($x_result->numRows() > 0)) 
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
    34
{
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
    35
?>
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
    36
    <div id="meta">
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
    37
     <div id="meta-left">
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
    38
      <table>
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
    39
       <tr>
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
    40
        <th><? echo _('Sub-owners'); ?></td>
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
    41
        <th>&nbsp;</td>
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
    42
       </tr>
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
    43
<?
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
    44
	while ($x_r = $x_result->fetchRow()) 
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
    45
	{
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    46
?>
13
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
    47
        <tr>
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
    48
	 <td class="tdbg"><? echo $x_r["fullname"]; ?></td>
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
    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>
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
    50
	</tr>
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
    51
<?
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
    52
	}
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
    53
?>
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
    54
       </table>
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
    55
      </div>
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
    56
     </div>
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
?>
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
    60
    <form method="post" action="edit_record.php">
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
    61
     <input type="hidden" name="recordid" value="<? echo  $_GET["id"] ?>">
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
    62
     <input type="hidden" name="domainid" value="<? echo  $_GET["domain"] ?>">
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
    63
     <table>
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
    64
      <tr>
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
    65
       <th><? echo _('Name'); ?></td>
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
    66
       <th>&nbsp;</td>
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
    67
       <th><? echo _('Type'); ?></td>
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
    68
       <th><? echo _('Priority'); ?></td>
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
    69
       <th><? echo _('Content'); ?></td>
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
    70
       <th><? echo _('TTL'); ?></td>
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
    71
      </tr>
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    72
<?
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    73
	$rec = get_record_from_id($_GET["id"]);
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    74
?>
13
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
    75
       <tr>
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
    76
        <td>
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
    77
<? 
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
    78
if ($_SESSION[$_GET["domain"]."_ispartial"] == 1)  
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
    79
{
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
    80
?>
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
    81
         <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
    82
13
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
    83
<? echo  trim(str_replace(get_domain_name_from_id($_GET["domain"]), '', $rec["name"]), '.') ?>
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
    84
<? 
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
    85
} 
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
    86
else 
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
    87
{ 
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
    88
?>
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
    89
         <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
    90
<? 
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
    91
} 
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
    92
?>
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
    93
.<? echo  get_domain_name_from_id($_GET["domain"]) ?>
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
    94
        </td>
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
    95
	<td class="n">IN</td>
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
    96
	<td>
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
    97
	 <select name="type">
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    98
<?
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    99
foreach (get_record_types() as $c)
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   100
{
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   101
	if ($c == $rec["type"])
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   102
	{
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   103
		$add = " SELECTED";
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   104
	}
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   105
	else
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   106
	{
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   107
		$add = "";
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   108
	}
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   109
	?>
13
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
   110
	<option<? echo  $add ?> value="<? echo  $c ?>"><? echo  $c ?></option><?
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   111
}
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   112
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   113
?>
13
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
   114
         </select>
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
   115
	</td>
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
   116
	<td><input type="text" name="prio" value="<? echo  $rec["prio"] ?>" class="sinput"></td>
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
   117
	<td><input type="text" name="content" value="<? echo  $rec["content"] ?>" class="input"></td>
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
   118
	<td><input type="text" name="ttl" value="<? echo  $rec["ttl"] ?>" class="sinput"></td>
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
   119
       </tr>
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
   120
      </table>
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
   121
      <p>
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
   122
       <input type="submit" name="commit" value="<? echo _('Commit changes'); ?>" class="button">&nbsp;&nbsp;
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
   123
       <input type="reset" name="reset" value="<? echo _('Reset changes'); ?>" class="button">
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
   124
      </p>
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
   125
     </form>
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   126
<?
13
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
   127
include_once("inc/footer.inc.php");
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   128
?>