search.php
author rejo
Tue, 25 Dec 2007 14:44:39 +0000
changeset 48 2b8781fd2e49
parent 47 ae140472d97c
child 50 ed18c8317cff
permissions -rwxr-xr-x
[feladat @ 95] Minor changes to increase inconsistency.
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
47
ae140472d97c [feladat @ 94]
rejo
parents: 13
diff changeset
     3
/*  PowerAdmin, a friendly web-based admin tool for PowerDNS.
ae140472d97c [feladat @ 94]
rejo
parents: 13
diff changeset
     4
 *  See <https://rejo.zenger.nl/poweradmin> for more details.
ae140472d97c [feladat @ 94]
rejo
parents: 13
diff changeset
     5
 *
ae140472d97c [feladat @ 94]
rejo
parents: 13
diff changeset
     6
 *  Copyright 2007, 2008  Rejo Zenger <rejo@zenger.nl>
ae140472d97c [feladat @ 94]
rejo
parents: 13
diff changeset
     7
 *
ae140472d97c [feladat @ 94]
rejo
parents: 13
diff changeset
     8
 *  This program is free software: you can redistribute it and/or modify
ae140472d97c [feladat @ 94]
rejo
parents: 13
diff changeset
     9
 *  it under the terms of the GNU General Public License as published by
ae140472d97c [feladat @ 94]
rejo
parents: 13
diff changeset
    10
 *  the Free Software Foundation, either version 3 of the License, or
ae140472d97c [feladat @ 94]
rejo
parents: 13
diff changeset
    11
 *  (at your option) any later version.
ae140472d97c [feladat @ 94]
rejo
parents: 13
diff changeset
    12
 *
ae140472d97c [feladat @ 94]
rejo
parents: 13
diff changeset
    13
 *  This program is distributed in the hope that it will be useful,
ae140472d97c [feladat @ 94]
rejo
parents: 13
diff changeset
    14
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
ae140472d97c [feladat @ 94]
rejo
parents: 13
diff changeset
    15
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
ae140472d97c [feladat @ 94]
rejo
parents: 13
diff changeset
    16
 *  GNU General Public License for more details.
ae140472d97c [feladat @ 94]
rejo
parents: 13
diff changeset
    17
 *
ae140472d97c [feladat @ 94]
rejo
parents: 13
diff changeset
    18
 *  You should have received a copy of the GNU General Public License
ae140472d97c [feladat @ 94]
rejo
parents: 13
diff changeset
    19
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
ae140472d97c [feladat @ 94]
rejo
parents: 13
diff changeset
    20
 */
ae140472d97c [feladat @ 94]
rejo
parents: 13
diff changeset
    21
13
2ff220cfde13 [feladat @ 60]
rejo
parents: 8
diff changeset
    22
require_once("inc/i18n.inc.php");
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    23
require_once('inc/toolkit.inc.php');
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    24
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    25
if (isset($_POST['s_submit']) || isset($_POST['q']))
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    26
{
13
2ff220cfde13 [feladat @ 60]
rejo
parents: 8
diff changeset
    27
	$submitted=true;
2ff220cfde13 [feladat @ 60]
rejo
parents: 8
diff changeset
    28
	$search_result=search_record($_POST['q']);
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    29
}
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    30
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    31
// we will continue after the search form ... 
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    32
include_once('inc/header.inc.php');
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    33
?>
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    34
13
2ff220cfde13 [feladat @ 60]
rejo
parents: 8
diff changeset
    35
    <h2><? echo _('Search zones or records'); ?></h2>
2ff220cfde13 [feladat @ 60]
rejo
parents: 8
diff changeset
    36
    <h3>Query</h3>
2ff220cfde13 [feladat @ 60]
rejo
parents: 8
diff changeset
    37
    <table>
2ff220cfde13 [feladat @ 60]
rejo
parents: 8
diff changeset
    38
     <form method="post" action="<? echo $_SERVER['PHP_SELF']?>">
2ff220cfde13 [feladat @ 60]
rejo
parents: 8
diff changeset
    39
      <tr>
2ff220cfde13 [feladat @ 60]
rejo
parents: 8
diff changeset
    40
       <td class="n"><? echo _('Enter a hostname or IP address'); ?></td>
2ff220cfde13 [feladat @ 60]
rejo
parents: 8
diff changeset
    41
       <td class="n"><input type="text" class="input" name="q"></td>
2ff220cfde13 [feladat @ 60]
rejo
parents: 8
diff changeset
    42
      </tr>
2ff220cfde13 [feladat @ 60]
rejo
parents: 8
diff changeset
    43
      <tr>
2ff220cfde13 [feladat @ 60]
rejo
parents: 8
diff changeset
    44
       <td class="n">&nbsp;</td>
2ff220cfde13 [feladat @ 60]
rejo
parents: 8
diff changeset
    45
       <td class="n"><input type="submit" class="button" name="s_submit" value="<? echo _('Search'); ?>"></td>
2ff220cfde13 [feladat @ 60]
rejo
parents: 8
diff changeset
    46
      </tr>
2ff220cfde13 [feladat @ 60]
rejo
parents: 8
diff changeset
    47
     </form>
2ff220cfde13 [feladat @ 60]
rejo
parents: 8
diff changeset
    48
    </table>
2ff220cfde13 [feladat @ 60]
rejo
parents: 8
diff changeset
    49
      
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    50
<?php
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    51
// results
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    52
if ($submitted)
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    53
{
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    54
	echo '<br><br>';
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    55
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    56
  	// let's check if we found any domains ...
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    57
	if (count($search_result) == 2 && count($search_result['domains']))
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    58
  	{
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    59
	?>
13
2ff220cfde13 [feladat @ 60]
rejo
parents: 8
diff changeset
    60
	<h4><? echo _('Zones found'); ?>:</h4>
2ff220cfde13 [feladat @ 60]
rejo
parents: 8
diff changeset
    61
	<table>
2ff220cfde13 [feladat @ 60]
rejo
parents: 8
diff changeset
    62
	 <tr>
2ff220cfde13 [feladat @ 60]
rejo
parents: 8
diff changeset
    63
	  <th>&nbsp;</th>
2ff220cfde13 [feladat @ 60]
rejo
parents: 8
diff changeset
    64
	  <th><? echo _('Name'); ?></th>
2ff220cfde13 [feladat @ 60]
rejo
parents: 8
diff changeset
    65
	  <th><? echo _('Records'); ?></th>
2ff220cfde13 [feladat @ 60]
rejo
parents: 8
diff changeset
    66
	  <th><? echo _('Owner'); ?></th>
2ff220cfde13 [feladat @ 60]
rejo
parents: 8
diff changeset
    67
         </tr>
2ff220cfde13 [feladat @ 60]
rejo
parents: 8
diff changeset
    68
<?php
2ff220cfde13 [feladat @ 60]
rejo
parents: 8
diff changeset
    69
foreach($search_result['domains'] as $d)
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
         <tr>
2ff220cfde13 [feladat @ 60]
rejo
parents: 8
diff changeset
    73
<?
2ff220cfde13 [feladat @ 60]
rejo
parents: 8
diff changeset
    74
  if (level(5))
2ff220cfde13 [feladat @ 60]
rejo
parents: 8
diff changeset
    75
  {
2ff220cfde13 [feladat @ 60]
rejo
parents: 8
diff changeset
    76
  ?>
2ff220cfde13 [feladat @ 60]
rejo
parents: 8
diff changeset
    77
     <td class="n">
2ff220cfde13 [feladat @ 60]
rejo
parents: 8
diff changeset
    78
      <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
    79
      <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
    80
     </td>
2ff220cfde13 [feladat @ 60]
rejo
parents: 8
diff changeset
    81
<?
2ff220cfde13 [feladat @ 60]
rejo
parents: 8
diff changeset
    82
}
2ff220cfde13 [feladat @ 60]
rejo
parents: 8
diff changeset
    83
else
2ff220cfde13 [feladat @ 60]
rejo
parents: 8
diff changeset
    84
{
2ff220cfde13 [feladat @ 60]
rejo
parents: 8
diff changeset
    85
?>
2ff220cfde13 [feladat @ 60]
rejo
parents: 8
diff changeset
    86
     <td class="n">
2ff220cfde13 [feladat @ 60]
rejo
parents: 8
diff changeset
    87
      &nbsp;
2ff220cfde13 [feladat @ 60]
rejo
parents: 8
diff changeset
    88
     </td>
2ff220cfde13 [feladat @ 60]
rejo
parents: 8
diff changeset
    89
<?
2ff220cfde13 [feladat @ 60]
rejo
parents: 8
diff changeset
    90
}
2ff220cfde13 [feladat @ 60]
rejo
parents: 8
diff changeset
    91
?>
2ff220cfde13 [feladat @ 60]
rejo
parents: 8
diff changeset
    92
     <td class="y"><? echo $d['name']?></td>
2ff220cfde13 [feladat @ 60]
rejo
parents: 8
diff changeset
    93
     <td class="y"><? echo $d['numrec']?></td>
2ff220cfde13 [feladat @ 60]
rejo
parents: 8
diff changeset
    94
     <td class="y"><? echo get_owner_from_id($d['owner'])?></td>
2ff220cfde13 [feladat @ 60]
rejo
parents: 8
diff changeset
    95
    </tr>
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    96
			<?php
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    97
		} // end foreach ...
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    98
		?>
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    99
	</table>
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   100
	<br><br>
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   101
	<?php
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   102
	} // end if
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   103
	
13
2ff220cfde13 [feladat @ 60]
rejo
parents: 8
diff changeset
   104
2ff220cfde13 [feladat @ 60]
rejo
parents: 8
diff changeset
   105
2ff220cfde13 [feladat @ 60]
rejo
parents: 8
diff changeset
   106
2ff220cfde13 [feladat @ 60]
rejo
parents: 8
diff changeset
   107
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   108
	
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   109
	// any records ?!
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   110
	if(count($search_result['records']))
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   111
	{
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   112
		?>
2
9a485c41cfcf [feladat @ 3]
rejo
parents: 1
diff changeset
   113
		<b><? echo _('Records found'); ?>:</b>
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   114
		<p>
13
2ff220cfde13 [feladat @ 60]
rejo
parents: 8
diff changeset
   115
		<table>
2ff220cfde13 [feladat @ 60]
rejo
parents: 8
diff changeset
   116
			<tr>
2ff220cfde13 [feladat @ 60]
rejo
parents: 8
diff changeset
   117
				<td class="n">&nbsp;</td>
2ff220cfde13 [feladat @ 60]
rejo
parents: 8
diff changeset
   118
				<td class="n"><? echo _('Name'); ?></td>
2ff220cfde13 [feladat @ 60]
rejo
parents: 8
diff changeset
   119
				<td class="n"><? echo _('Type'); ?></td>
2ff220cfde13 [feladat @ 60]
rejo
parents: 8
diff changeset
   120
				<td class="n"><? echo _('Content'); ?></td>
2ff220cfde13 [feladat @ 60]
rejo
parents: 8
diff changeset
   121
				<td class="n"><? echo _('Priority'); ?></td>
2ff220cfde13 [feladat @ 60]
rejo
parents: 8
diff changeset
   122
				<td class="n"><? echo _('TTL'); ?></td>
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   123
			</tr>
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   124
		<?php
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   125
		foreach($search_result['records'] as $r)
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   126
		{
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   127
		?>
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   128
			<tr>
13
2ff220cfde13 [feladat @ 60]
rejo
parents: 8
diff changeset
   129
				<td class="n">
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   130
			<?php
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   131
			if (($r["type"] != "SOA" && $r["type"] != "NS") ||
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   132
			  ($GLOBALS["ALLOW_SOA_EDIT"] && $r["type"] == "SOA") ||
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   133
			  ($GLOBALS["ALLOW_NS_EDIT"] && $r["type"] == "NS") ||
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   134
			  ($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
   135
			  $GLOBALS["ALLOW_NS_EDIT"] != 1))
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   136
			{
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   137
				?>
13
2ff220cfde13 [feladat @ 60]
rejo
parents: 8
diff changeset
   138
				<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
   139
				<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
   140
				<?php 
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   141
			} // big if ;-)
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   142
			?>
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   143
			</td>
13
2ff220cfde13 [feladat @ 60]
rejo
parents: 8
diff changeset
   144
			<td class="y"><? echo $r['name']?></td>
2ff220cfde13 [feladat @ 60]
rejo
parents: 8
diff changeset
   145
			<td class="y"><? echo $r['type']?></td>
2ff220cfde13 [feladat @ 60]
rejo
parents: 8
diff changeset
   146
			<td class="y"><? echo $r['content']?></td>
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   147
			<?php
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   148
			if ($r['prio'] != 0)
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   149
			{
13
2ff220cfde13 [feladat @ 60]
rejo
parents: 8
diff changeset
   150
				?><td class="y"><? echo $r['prio']?></td><?php
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   151
			}
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   152
			else 
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   153
			{
13
2ff220cfde13 [feladat @ 60]
rejo
parents: 8
diff changeset
   154
			?><td class="n"></td><?php
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   155
			} // else
13
2ff220cfde13 [feladat @ 60]
rejo
parents: 8
diff changeset
   156
			?><td class="y"><? echo $r['ttl']?></td>
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   157
			</tr>
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   158
			<?php
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   159
		} // foreach
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   160
	?>
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   161
	</table>
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   162
	<?php
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   163
	} // if
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   164
	if(count($search_result['domains']) == 0 && count($search_result['records']) == 0)
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   165
	{
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   166
	?>
13
2ff220cfde13 [feladat @ 60]
rejo
parents: 8
diff changeset
   167
		<table border="0" cellspacing="4">
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   168
			<tr>
13
2ff220cfde13 [feladat @ 60]
rejo
parents: 8
diff changeset
   169
				<td width="510" class="n">
2ff220cfde13 [feladat @ 60]
rejo
parents: 8
diff changeset
   170
				<? echo _('Nothing found for query'); ?> "<? echo $_POST['q']?>"
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   171
				</td>
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   172
			</tr>
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   173
		</table>
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   174
	<?
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   175
	}
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   176
		
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   177
}
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   178
include_once('inc/footer.inc.php');
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   179
?>
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   180