search.php
author rejo
Mon, 23 Jul 2007 22:05:19 +0000
changeset 38 cf767482333a
parent 13 2ff220cfde13
child 47 ae140472d97c
permissions -rwxr-xr-x
[feladat @ 85] The type of zone wasn't show to users with access level 1. If a user with access level 1 did have access to a slave zone the user did not see the IP of the master nameserver of that zone. Now the user will the IP address (readonly and only if one is set). Bugfix. If no master IP for a slave zone is given, a warning is shown regardless of the userlevel. Bugfix. Both the "add record" and "edit record" buttons in the "edit zone" screen is no longer available for users with level 1 for domains of type "slave". Bug report by Antonio Prado. Some PHP and HTML cleanup (removing of empty tags and unnecessary repeatings of calls to a single function).
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
     1
<?php
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
     2
13
2ff220cfde13 [feladat @ 60]
rejo
parents: 8
diff changeset
     3
require_once("inc/i18n.inc.php");
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
     4
require_once('inc/toolkit.inc.php');
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
     5
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
     6
if (isset($_POST['s_submit']) || isset($_POST['q']))
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
     7
{
13
2ff220cfde13 [feladat @ 60]
rejo
parents: 8
diff changeset
     8
	$submitted=true;
2ff220cfde13 [feladat @ 60]
rejo
parents: 8
diff changeset
     9
	$search_result=search_record($_POST['q']);
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    10
}
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    11
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    12
// we will continue after the search form ... 
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    13
include_once('inc/header.inc.php');
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    14
?>
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    15
13
2ff220cfde13 [feladat @ 60]
rejo
parents: 8
diff changeset
    16
    <h2><? echo _('Search zones or records'); ?></h2>
2ff220cfde13 [feladat @ 60]
rejo
parents: 8
diff changeset
    17
    <h3>Query</h3>
2ff220cfde13 [feladat @ 60]
rejo
parents: 8
diff changeset
    18
    <table>
2ff220cfde13 [feladat @ 60]
rejo
parents: 8
diff changeset
    19
     <form method="post" action="<? echo $_SERVER['PHP_SELF']?>">
2ff220cfde13 [feladat @ 60]
rejo
parents: 8
diff changeset
    20
      <tr>
2ff220cfde13 [feladat @ 60]
rejo
parents: 8
diff changeset
    21
       <td class="n"><? echo _('Enter a hostname or IP address'); ?></td>
2ff220cfde13 [feladat @ 60]
rejo
parents: 8
diff changeset
    22
       <td class="n"><input type="text" class="input" name="q"></td>
2ff220cfde13 [feladat @ 60]
rejo
parents: 8
diff changeset
    23
      </tr>
2ff220cfde13 [feladat @ 60]
rejo
parents: 8
diff changeset
    24
      <tr>
2ff220cfde13 [feladat @ 60]
rejo
parents: 8
diff changeset
    25
       <td class="n">&nbsp;</td>
2ff220cfde13 [feladat @ 60]
rejo
parents: 8
diff changeset
    26
       <td class="n"><input type="submit" class="button" name="s_submit" value="<? echo _('Search'); ?>"></td>
2ff220cfde13 [feladat @ 60]
rejo
parents: 8
diff changeset
    27
      </tr>
2ff220cfde13 [feladat @ 60]
rejo
parents: 8
diff changeset
    28
     </form>
2ff220cfde13 [feladat @ 60]
rejo
parents: 8
diff changeset
    29
    </table>
2ff220cfde13 [feladat @ 60]
rejo
parents: 8
diff changeset
    30
      
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    31
<?php
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    32
// results
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    33
if ($submitted)
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    34
{
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    35
	echo '<br><br>';
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    36
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    37
  	// let's check if we found any domains ...
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    38
	if (count($search_result) == 2 && count($search_result['domains']))
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    39
  	{
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    40
	?>
13
2ff220cfde13 [feladat @ 60]
rejo
parents: 8
diff changeset
    41
	<h4><? echo _('Zones found'); ?>:</h4>
2ff220cfde13 [feladat @ 60]
rejo
parents: 8
diff changeset
    42
	<table>
2ff220cfde13 [feladat @ 60]
rejo
parents: 8
diff changeset
    43
	 <tr>
2ff220cfde13 [feladat @ 60]
rejo
parents: 8
diff changeset
    44
	  <th>&nbsp;</th>
2ff220cfde13 [feladat @ 60]
rejo
parents: 8
diff changeset
    45
	  <th><? echo _('Name'); ?></th>
2ff220cfde13 [feladat @ 60]
rejo
parents: 8
diff changeset
    46
	  <th><? echo _('Records'); ?></th>
2ff220cfde13 [feladat @ 60]
rejo
parents: 8
diff changeset
    47
	  <th><? echo _('Owner'); ?></th>
2ff220cfde13 [feladat @ 60]
rejo
parents: 8
diff changeset
    48
         </tr>
2ff220cfde13 [feladat @ 60]
rejo
parents: 8
diff changeset
    49
<?php
2ff220cfde13 [feladat @ 60]
rejo
parents: 8
diff changeset
    50
foreach($search_result['domains'] as $d)
2ff220cfde13 [feladat @ 60]
rejo
parents: 8
diff changeset
    51
{
2ff220cfde13 [feladat @ 60]
rejo
parents: 8
diff changeset
    52
?>
2ff220cfde13 [feladat @ 60]
rejo
parents: 8
diff changeset
    53
         <tr>
2ff220cfde13 [feladat @ 60]
rejo
parents: 8
diff changeset
    54
<?
2ff220cfde13 [feladat @ 60]
rejo
parents: 8
diff changeset
    55
  if (level(5))
2ff220cfde13 [feladat @ 60]
rejo
parents: 8
diff changeset
    56
  {
2ff220cfde13 [feladat @ 60]
rejo
parents: 8
diff changeset
    57
  ?>
2ff220cfde13 [feladat @ 60]
rejo
parents: 8
diff changeset
    58
     <td class="n">
2ff220cfde13 [feladat @ 60]
rejo
parents: 8
diff changeset
    59
      <a href="edit.php?id=<? echo $d["id"] ?>"><img src="images/edit.gif" title="<? echo _('Edit zone') . " " . $d['name']; ?>" alt="[ <? echo _('Edit zone') . " " . $d['name']; ?> ]"></a>
2ff220cfde13 [feladat @ 60]
rejo
parents: 8
diff changeset
    60
      <a href="delete_domain.php?id=<? echo $d["id"] ?>"><img src="images/delete.gif" title="<? print _('Delete zone') . " " . $d['name']; ?>" alt="[<? echo _('Delete zone') . " " . $d['name']; ?>]"></a>
2ff220cfde13 [feladat @ 60]
rejo
parents: 8
diff changeset
    61
     </td>
2ff220cfde13 [feladat @ 60]
rejo
parents: 8
diff changeset
    62
<?
2ff220cfde13 [feladat @ 60]
rejo
parents: 8
diff changeset
    63
}
2ff220cfde13 [feladat @ 60]
rejo
parents: 8
diff changeset
    64
else
2ff220cfde13 [feladat @ 60]
rejo
parents: 8
diff changeset
    65
{
2ff220cfde13 [feladat @ 60]
rejo
parents: 8
diff changeset
    66
?>
2ff220cfde13 [feladat @ 60]
rejo
parents: 8
diff changeset
    67
     <td class="n">
2ff220cfde13 [feladat @ 60]
rejo
parents: 8
diff changeset
    68
      &nbsp;
2ff220cfde13 [feladat @ 60]
rejo
parents: 8
diff changeset
    69
     </td>
2ff220cfde13 [feladat @ 60]
rejo
parents: 8
diff changeset
    70
<?
2ff220cfde13 [feladat @ 60]
rejo
parents: 8
diff changeset
    71
}
2ff220cfde13 [feladat @ 60]
rejo
parents: 8
diff changeset
    72
?>
2ff220cfde13 [feladat @ 60]
rejo
parents: 8
diff changeset
    73
     <td class="y"><? echo $d['name']?></td>
2ff220cfde13 [feladat @ 60]
rejo
parents: 8
diff changeset
    74
     <td class="y"><? echo $d['numrec']?></td>
2ff220cfde13 [feladat @ 60]
rejo
parents: 8
diff changeset
    75
     <td class="y"><? echo get_owner_from_id($d['owner'])?></td>
2ff220cfde13 [feladat @ 60]
rejo
parents: 8
diff changeset
    76
    </tr>
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    77
			<?php
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    78
		} // end foreach ...
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    79
		?>
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    80
	</table>
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    81
	<br><br>
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    82
	<?php
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    83
	} // end if
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    84
	
13
2ff220cfde13 [feladat @ 60]
rejo
parents: 8
diff changeset
    85
2ff220cfde13 [feladat @ 60]
rejo
parents: 8
diff changeset
    86
2ff220cfde13 [feladat @ 60]
rejo
parents: 8
diff changeset
    87
2ff220cfde13 [feladat @ 60]
rejo
parents: 8
diff changeset
    88
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    89
	
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    90
	// any records ?!
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    91
	if(count($search_result['records']))
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    92
	{
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    93
		?>
2
9a485c41cfcf [feladat @ 3]
rejo
parents: 1
diff changeset
    94
		<b><? echo _('Records found'); ?>:</b>
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    95
		<p>
13
2ff220cfde13 [feladat @ 60]
rejo
parents: 8
diff changeset
    96
		<table>
2ff220cfde13 [feladat @ 60]
rejo
parents: 8
diff changeset
    97
			<tr>
2ff220cfde13 [feladat @ 60]
rejo
parents: 8
diff changeset
    98
				<td class="n">&nbsp;</td>
2ff220cfde13 [feladat @ 60]
rejo
parents: 8
diff changeset
    99
				<td class="n"><? echo _('Name'); ?></td>
2ff220cfde13 [feladat @ 60]
rejo
parents: 8
diff changeset
   100
				<td class="n"><? echo _('Type'); ?></td>
2ff220cfde13 [feladat @ 60]
rejo
parents: 8
diff changeset
   101
				<td class="n"><? echo _('Content'); ?></td>
2ff220cfde13 [feladat @ 60]
rejo
parents: 8
diff changeset
   102
				<td class="n"><? echo _('Priority'); ?></td>
2ff220cfde13 [feladat @ 60]
rejo
parents: 8
diff changeset
   103
				<td class="n"><? echo _('TTL'); ?></td>
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   104
			</tr>
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   105
		<?php
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   106
		foreach($search_result['records'] as $r)
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   107
		{
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   108
		?>
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   109
			<tr>
13
2ff220cfde13 [feladat @ 60]
rejo
parents: 8
diff changeset
   110
				<td class="n">
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   111
			<?php
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   112
			if (($r["type"] != "SOA" && $r["type"] != "NS") ||
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   113
			  ($GLOBALS["ALLOW_SOA_EDIT"] && $r["type"] == "SOA") ||
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   114
			  ($GLOBALS["ALLOW_NS_EDIT"] && $r["type"] == "NS") ||
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   115
			  ($r["type"] == "NS" && get_name_from_record_id($r["id"]) != get_domain_name_from_id(recid_to_domid($r["id"])) && 
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   116
			  $GLOBALS["ALLOW_NS_EDIT"] != 1))
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   117
			{
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   118
				?>
13
2ff220cfde13 [feladat @ 60]
rejo
parents: 8
diff changeset
   119
				<a href="edit_record.php?id=<? echo $r['id']?>&amp;domain=<? echo $r['domain_id']?>"><img src="images/edit.gif" alt="[ <? echo _('Edit record'); ?> ]" border="0"></a>
2ff220cfde13 [feladat @ 60]
rejo
parents: 8
diff changeset
   120
				<a href="delete_record.php?id=<? echo $r['id']?>&amp;domain=<? echo $r['domain_id']?>"><img src="images/delete.gif" alt="[ <? echo _('Delete record'); ?> ]" border="0"></a>
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   121
				<?php 
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   122
			} // big if ;-)
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   123
			?>
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   124
			</td>
13
2ff220cfde13 [feladat @ 60]
rejo
parents: 8
diff changeset
   125
			<td class="y"><? echo $r['name']?></td>
2ff220cfde13 [feladat @ 60]
rejo
parents: 8
diff changeset
   126
			<td class="y"><? echo $r['type']?></td>
2ff220cfde13 [feladat @ 60]
rejo
parents: 8
diff changeset
   127
			<td class="y"><? echo $r['content']?></td>
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   128
			<?php
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   129
			if ($r['prio'] != 0)
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   130
			{
13
2ff220cfde13 [feladat @ 60]
rejo
parents: 8
diff changeset
   131
				?><td class="y"><? echo $r['prio']?></td><?php
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   132
			}
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   133
			else 
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   134
			{
13
2ff220cfde13 [feladat @ 60]
rejo
parents: 8
diff changeset
   135
			?><td class="n"></td><?php
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   136
			} // else
13
2ff220cfde13 [feladat @ 60]
rejo
parents: 8
diff changeset
   137
			?><td class="y"><? echo $r['ttl']?></td>
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   138
			</tr>
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   139
			<?php
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   140
		} // foreach
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   141
	?>
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   142
	</table>
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   143
	<?php
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   144
	} // if
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   145
	if(count($search_result['domains']) == 0 && count($search_result['records']) == 0)
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   146
	{
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   147
	?>
13
2ff220cfde13 [feladat @ 60]
rejo
parents: 8
diff changeset
   148
		<table border="0" cellspacing="4">
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   149
			<tr>
13
2ff220cfde13 [feladat @ 60]
rejo
parents: 8
diff changeset
   150
				<td width="510" class="n">
2ff220cfde13 [feladat @ 60]
rejo
parents: 8
diff changeset
   151
				<? echo _('Nothing found for query'); ?> "<? echo $_POST['q']?>"
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   152
				</td>
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   153
			</tr>
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   154
		</table>
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   155
	<?
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   156
	}
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   157
		
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   158
}
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   159
include_once('inc/footer.inc.php');
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   160
?>
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   161