search.php
changeset 13 2ff220cfde13
parent 8 47dd15d8bb8c
child 47 ae140472d97c
equal deleted inserted replaced
12:7be4525290cc 13:2ff220cfde13
     1 <?php
     1 <?php
     2 
     2 
     3 // +--------------------------------------------------------------------+
     3 require_once("inc/i18n.inc.php");
     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 // Filename: search.php
       
    18 // Startdate: 9-01-2003
       
    19 // Searches the database for corresponding records or domains.
       
    20 //
       
    21 // The sourecode for this program was donated by DeViCeD, THANKS!
       
    22 //
       
    23 // $Id: search.php,v 1.1 2003/01/09 23:23:39 azurazu Exp $
       
    24 //
       
    25 
       
    26 require_once('inc/toolkit.inc.php');
     4 require_once('inc/toolkit.inc.php');
    27 
     5 
    28 if (isset($_POST['s_submit']) || isset($_POST['q']))
     6 if (isset($_POST['s_submit']) || isset($_POST['q']))
    29 {
     7 {
    30 	$submitted = true;
     8 	$submitted=true;
    31 	$search_result = search_record($_POST['q']);
     9 	$search_result=search_record($_POST['q']);
    32 }
    10 }
    33 
       
    34 
    11 
    35 // we will continue after the search form ... 
    12 // we will continue after the search form ... 
    36 include_once('inc/header.inc.php');
    13 include_once('inc/header.inc.php');
    37 ?>
    14 ?>
    38 <P><H2><? echo _('Search zones or records'); ?></H2></P>
       
    39 <P CLASS="nav">
       
    40 <A HREF="index.php"><? echo _('DNS Admin'); ?></A> 
       
    41 <?
       
    42 if (level(10))
       
    43 {
       
    44 	?><A HREF="users.php"><? echo _('User admin'); ?></A> <?
       
    45 }
       
    46 ?>
       
    47 </P><BR>
       
    48 <? echo _('Type a hostname or a record in the box below and press search to see if the record exists in the system.'); ?>
       
    49 	<table border = "0" cellspacing = "4">
       
    50 	<form method = "post" action="<?=$_SERVER['PHP_SELF']?>">
       
    51 		<tr>
       
    52 			<td class = "tdbg"><b><? echo _('Enter a hostname or IP address'); ?></b></td>
       
    53 			<td width = "510" class = "tdbg"><input type = "text" class = "input" name = "q"></td>
       
    54 		</tr>
       
    55 		<tr>
       
    56 			<td class = "tdbg">&nbsp;</td>
       
    57 			<td class = "tdbg"><input type = "submit" class = "button" name = "s_submit" value = "<? echo _('Search'); ?>"></td>
       
    58 		</tr>
       
    59 	</form>
       
    60 	</table>
       
    61 
    15 
    62 
    16     <h2><? echo _('Search zones or records'); ?></h2>
       
    17     <h3>Query</h3>
       
    18     <table>
       
    19      <form method="post" action="<? echo $_SERVER['PHP_SELF']?>">
       
    20       <tr>
       
    21        <td class="n"><? echo _('Enter a hostname or IP address'); ?></td>
       
    22        <td class="n"><input type="text" class="input" name="q"></td>
       
    23       </tr>
       
    24       <tr>
       
    25        <td class="n">&nbsp;</td>
       
    26        <td class="n"><input type="submit" class="button" name="s_submit" value="<? echo _('Search'); ?>"></td>
       
    27       </tr>
       
    28      </form>
       
    29     </table>
       
    30       
    63 <?php
    31 <?php
    64 // results
    32 // results
    65 if ($submitted)
    33 if ($submitted)
    66 {
    34 {
    67 	echo '<br><br>';
    35 	echo '<br><br>';
    68 
    36 
    69   	// let's check if we found any domains ...
    37   	// let's check if we found any domains ...
    70 	if (count($search_result) == 2 && count($search_result['domains']))
    38 	if (count($search_result) == 2 && count($search_result['domains']))
    71   	{
    39   	{
    72 	?>
    40 	?>
    73 	<b><? echo _('Domains found'); ?>:</b>
    41 	<h4><? echo _('Zones found'); ?>:</h4>
    74 	<p>
    42 	<table>
    75 	<table border = "0" cellspacing = "4">
    43 	 <tr>
    76 		<tr style = "font-weight: Bold;">
    44 	  <th>&nbsp;</th>
    77 			<td class = "tdbg">&nbsp;</td>
    45 	  <th><? echo _('Name'); ?></th>
    78 			<td class = "tdbg"><? echo _('Name'); ?></td>
    46 	  <th><? echo _('Records'); ?></th>
    79 			<td class = "tdbg"><? echo _('Records'); ?></td>
    47 	  <th><? echo _('Owner'); ?></th>
    80 			<td class = "tdbg"><? echo _('Owner'); ?></td>
    48          </tr>
    81 		</tr>
    49 <?php
    82 		<?php
    50 foreach($search_result['domains'] as $d)
    83 		foreach($search_result['domains'] as $d)
    51 {
    84 		{
    52 ?>
    85 			?>	
    53          <tr>
    86 			<tr>
    54 <?
    87 			<td class = "tdbg">
    55   if (level(5))
    88 			<?php 
    56   {
    89 			if (level(5))
    57   ?>
    90 			{
    58      <td class="n">
    91 				echo '<a href = "delete_domain.php?id='.$d['id'].'"><img src = "images/delete.gif" alt = "[ ' .  _('Delete zone') . ' ]" border = "0"></a>';
    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>
    92 			}
    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>
    93 			else 
    61      </td>
    94 			{
    62 <?
    95 				echo '&nbsp;';
    63 }
    96 			}
    64 else
    97 			?>
    65 {
    98 			</td>
    66 ?>
    99 			<td class = "tdbg"><a href = "edit.php?id=<?=$d['id']?>"><?=$d['name']?></a></td>
    67      <td class="n">
   100 			<td class = "tdbg"><?=$d['numrec']?></td>
    68       &nbsp;
   101 			<td class = "tdbg"><?=get_owner_from_id($d['owner'])?></td>
    69      </td>
   102 			</tr>
    70 <?
       
    71 }
       
    72 ?>
       
    73      <td class="y"><? echo $d['name']?></td>
       
    74      <td class="y"><? echo $d['numrec']?></td>
       
    75      <td class="y"><? echo get_owner_from_id($d['owner'])?></td>
       
    76     </tr>
   103 			<?php
    77 			<?php
   104 		} // end foreach ...
    78 		} // end foreach ...
   105 		?>
    79 		?>
   106 	</table>
    80 	</table>
   107 	<br><br>
    81 	<br><br>
   108 	<?php
    82 	<?php
   109 	} // end if
    83 	} // end if
   110 	
    84 	
       
    85 
       
    86 
       
    87 
       
    88 
   111 	
    89 	
   112 	// any records ?!
    90 	// any records ?!
   113 	if(count($search_result['records']))
    91 	if(count($search_result['records']))
   114 	{
    92 	{
   115 		?>
    93 		?>
   116 		<b><? echo _('Records found'); ?>:</b>
    94 		<b><? echo _('Records found'); ?>:</b>
   117 		<p>
    95 		<p>
   118 		<table border = "0" cellspacing = "4">
    96 		<table>
   119 			<tr style = "font-weight: Bold;">
    97 			<tr>
   120 				<td class = "tdbg">&nbsp;</td>
    98 				<td class="n">&nbsp;</td>
   121 				<td class = "tdbg"><? echo _('Name'); ?></td>
    99 				<td class="n"><? echo _('Name'); ?></td>
   122 				<td class = "tdbg"><? echo _('Type'); ?></td>
   100 				<td class="n"><? echo _('Type'); ?></td>
   123 				<td class = "tdbg"><? echo _('Content'); ?></td>
   101 				<td class="n"><? echo _('Content'); ?></td>
   124 				<td class = "tdbg"><? echo _('Priority'); ?></td>
   102 				<td class="n"><? echo _('Priority'); ?></td>
   125 				<td class = "tdbg"><? echo _('TTL'); ?></td>
   103 				<td class="n"><? echo _('TTL'); ?></td>
   126 			</tr>
   104 			</tr>
   127 		<?php
   105 		<?php
   128 		foreach($search_result['records'] as $r)
   106 		foreach($search_result['records'] as $r)
   129 		{
   107 		{
   130 		?>
   108 		?>
   131 			<tr>
   109 			<tr>
   132 				<td class = "tdbg">
   110 				<td class="n">
   133 			<?php
   111 			<?php
   134 			if (($r["type"] != "SOA" && $r["type"] != "NS") ||
   112 			if (($r["type"] != "SOA" && $r["type"] != "NS") ||
   135 			  ($GLOBALS["ALLOW_SOA_EDIT"] && $r["type"] == "SOA") ||
   113 			  ($GLOBALS["ALLOW_SOA_EDIT"] && $r["type"] == "SOA") ||
   136 			  ($GLOBALS["ALLOW_NS_EDIT"] && $r["type"] == "NS") ||
   114 			  ($GLOBALS["ALLOW_NS_EDIT"] && $r["type"] == "NS") ||
   137 			  ($r["type"] == "NS" && get_name_from_record_id($r["id"]) != get_domain_name_from_id(recid_to_domid($r["id"])) && 
   115 			  ($r["type"] == "NS" && get_name_from_record_id($r["id"]) != get_domain_name_from_id(recid_to_domid($r["id"])) && 
   138 			  $GLOBALS["ALLOW_NS_EDIT"] != 1))
   116 			  $GLOBALS["ALLOW_NS_EDIT"] != 1))
   139 			{
   117 			{
   140 				?>
   118 				?>
   141 				<a href = "edit_record.php?id=<?=$r['id']?>&amp;domain=<?=$r['domain_id']?>"><img src = "images/edit.gif" alt = "[ <? echo _('Edit record'); ?> ]" border = "0"></a>
   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>
   142 				<a href = "delete_record.php?id=<?=$r['id']?>&amp;domain=<?=$r['domain_id']?>"><img src = "images/delete.gif" alt = "[ <? echo _('Delete record'); ?> ]" border = "0"></a>
   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>
   143 				<?php 
   121 				<?php 
   144 			} // big if ;-)
   122 			} // big if ;-)
   145 			?>
   123 			?>
   146 			</td>
   124 			</td>
   147 			<td style = "border: 1px solid #000000;"><?=$r['name']?></td>
   125 			<td class="y"><? echo $r['name']?></td>
   148 			<td style = "border: 1px solid #000000;"><?=$r['type']?></td>
   126 			<td class="y"><? echo $r['type']?></td>
   149 			<td style = "border: 1px solid #000000;"><?=$r['content']?></td>
   127 			<td class="y"><? echo $r['content']?></td>
   150 			<?php
   128 			<?php
   151 			if ($r['prio'] != 0)
   129 			if ($r['prio'] != 0)
   152 			{
   130 			{
   153 				?><td style = "border: 1px solid #000000;"><?=$r['prio']?></td><?php
   131 				?><td class="y"><? echo $r['prio']?></td><?php
   154 			}
   132 			}
   155 			else 
   133 			else 
   156 			{
   134 			{
   157 			?><td class = "tdbg"></td><?php
   135 			?><td class="n"></td><?php
   158 			} // else
   136 			} // else
   159 			?><td style = "border: 1px solid #000000;"><?=$r['ttl']?></td>
   137 			?><td class="y"><? echo $r['ttl']?></td>
   160 			</tr>
   138 			</tr>
   161 			<?php
   139 			<?php
   162 		} // foreach
   140 		} // foreach
   163 	?>
   141 	?>
   164 	</table>
   142 	</table>
   165 	<?php
   143 	<?php
   166 	} // if
   144 	} // if
   167 	if(count($search_result['domains']) == 0 && count($search_result['records']) == 0)
   145 	if(count($search_result['domains']) == 0 && count($search_result['records']) == 0)
   168 	{
   146 	{
   169 	?>
   147 	?>
   170 		<table border = "0" cellspacing = "4">
   148 		<table border="0" cellspacing="4">
   171 			<tr>
   149 			<tr>
   172 				<td width = "510" class = "tdbg">
   150 				<td width="510" class="n">
   173 				<? echo _('Nothing found for query'); ?> "<?=$_POST['q']?>"
   151 				<? echo _('Nothing found for query'); ?> "<? echo $_POST['q']?>"
   174 				</td>
   152 				</td>
   175 			</tr>
   153 			</tr>
   176 		</table>
   154 		</table>
   177 	<?
   155 	<?
   178 	}
   156 	}