search.php
author peter
Wed, 12 Mar 2008 19:47:25 +0000
changeset 80 48b5f7021aaa
parent 79 0c0aa144356a
child 82 c255196bc447
permissions -rwxr-xr-x
[feladat @ 158] Bugfix for ticket:18: Minor modification in the CSS to make sure no data is displayed on top of other data. Also a little modification to make sure the sub-owners (if there are any) are displayed above the record form, instead of next to it.
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
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    22
require_once('inc/toolkit.inc.php');
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    23
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    24
if (isset($_POST['s_submit']) || isset($_POST['q']))
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    25
{
13
2ff220cfde13 [feladat @ 60]
rejo
parents: 8
diff changeset
    26
	$submitted=true;
2ff220cfde13 [feladat @ 60]
rejo
parents: 8
diff changeset
    27
	$search_result=search_record($_POST['q']);
79
0c0aa144356a [feladat @ 156]
peter
parents: 71
diff changeset
    28
} else {
0c0aa144356a [feladat @ 156]
peter
parents: 71
diff changeset
    29
	$submitted = false;
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    30
}
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    31
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    32
// we will continue after the search form ... 
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    33
include_once('inc/header.inc.php');
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    34
?>
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    35
71
e1b918eaf69a [feladat @ 118]
peter
parents: 62
diff changeset
    36
    <h2><?php echo _('Search zones or records'); ?></h2>
13
2ff220cfde13 [feladat @ 60]
rejo
parents: 8
diff changeset
    37
    <h3>Query</h3>
2ff220cfde13 [feladat @ 60]
rejo
parents: 8
diff changeset
    38
    <table>
71
e1b918eaf69a [feladat @ 118]
peter
parents: 62
diff changeset
    39
     <form method="post" action="<?php echo $_SERVER['PHP_SELF']?>">
13
2ff220cfde13 [feladat @ 60]
rejo
parents: 8
diff changeset
    40
      <tr>
71
e1b918eaf69a [feladat @ 118]
peter
parents: 62
diff changeset
    41
       <td class="n"><?php echo _('Enter a hostname or IP address'); ?></td>
13
2ff220cfde13 [feladat @ 60]
rejo
parents: 8
diff changeset
    42
       <td class="n"><input type="text" class="input" name="q"></td>
2ff220cfde13 [feladat @ 60]
rejo
parents: 8
diff changeset
    43
      </tr>
2ff220cfde13 [feladat @ 60]
rejo
parents: 8
diff changeset
    44
      <tr>
2ff220cfde13 [feladat @ 60]
rejo
parents: 8
diff changeset
    45
       <td class="n">&nbsp;</td>
71
e1b918eaf69a [feladat @ 118]
peter
parents: 62
diff changeset
    46
       <td class="n"><input type="submit" class="button" name="s_submit" value="<?php echo _('Search'); ?>"></td>
13
2ff220cfde13 [feladat @ 60]
rejo
parents: 8
diff changeset
    47
      </tr>
2ff220cfde13 [feladat @ 60]
rejo
parents: 8
diff changeset
    48
     </form>
2ff220cfde13 [feladat @ 60]
rejo
parents: 8
diff changeset
    49
    </table>
2ff220cfde13 [feladat @ 60]
rejo
parents: 8
diff changeset
    50
      
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    51
<?php
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    52
// results
79
0c0aa144356a [feladat @ 156]
peter
parents: 71
diff changeset
    53
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    54
if ($submitted)
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    55
{
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    56
	echo '<br><br>';
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    57
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    58
  	// let's check if we found any domains ...
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    59
	if (count($search_result) == 2 && count($search_result['domains']))
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    60
  	{
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    61
	?>
71
e1b918eaf69a [feladat @ 118]
peter
parents: 62
diff changeset
    62
	<h4><?php echo _('Zones found'); ?>:</h4>
13
2ff220cfde13 [feladat @ 60]
rejo
parents: 8
diff changeset
    63
	<table>
2ff220cfde13 [feladat @ 60]
rejo
parents: 8
diff changeset
    64
	 <tr>
2ff220cfde13 [feladat @ 60]
rejo
parents: 8
diff changeset
    65
	  <th>&nbsp;</th>
71
e1b918eaf69a [feladat @ 118]
peter
parents: 62
diff changeset
    66
	  <th><?php echo _('Name'); ?></th>
e1b918eaf69a [feladat @ 118]
peter
parents: 62
diff changeset
    67
	  <th><?php echo _('Records'); ?></th>
e1b918eaf69a [feladat @ 118]
peter
parents: 62
diff changeset
    68
	  <th><?php echo _('Owner'); ?></th>
13
2ff220cfde13 [feladat @ 60]
rejo
parents: 8
diff changeset
    69
         </tr>
2ff220cfde13 [feladat @ 60]
rejo
parents: 8
diff changeset
    70
<?php
2ff220cfde13 [feladat @ 60]
rejo
parents: 8
diff changeset
    71
foreach($search_result['domains'] as $d)
2ff220cfde13 [feladat @ 60]
rejo
parents: 8
diff changeset
    72
{
2ff220cfde13 [feladat @ 60]
rejo
parents: 8
diff changeset
    73
?>
2ff220cfde13 [feladat @ 60]
rejo
parents: 8
diff changeset
    74
         <tr>
71
e1b918eaf69a [feladat @ 118]
peter
parents: 62
diff changeset
    75
<?php
13
2ff220cfde13 [feladat @ 60]
rejo
parents: 8
diff changeset
    76
  if (level(5))
2ff220cfde13 [feladat @ 60]
rejo
parents: 8
diff changeset
    77
  {
2ff220cfde13 [feladat @ 60]
rejo
parents: 8
diff changeset
    78
  ?>
2ff220cfde13 [feladat @ 60]
rejo
parents: 8
diff changeset
    79
     <td class="n">
71
e1b918eaf69a [feladat @ 118]
peter
parents: 62
diff changeset
    80
      <a href="edit.php?id=<?php echo $d["id"] ?>"><img src="images/edit.gif" title="<?php echo _('Edit zone') . " " . $d['name']; ?>" alt="[ <?php echo _('Edit zone') . " " . $d['name']; ?> ]"></a>
e1b918eaf69a [feladat @ 118]
peter
parents: 62
diff changeset
    81
      <a href="delete_domain.php?id=<?php echo $d["id"] ?>"><img src="images/delete.gif" title="<?php print _('Delete zone') . " " . $d['name']; ?>" alt="[<?php echo _('Delete zone') . " " . $d['name']; ?>]"></a>
13
2ff220cfde13 [feladat @ 60]
rejo
parents: 8
diff changeset
    82
     </td>
71
e1b918eaf69a [feladat @ 118]
peter
parents: 62
diff changeset
    83
<?php
13
2ff220cfde13 [feladat @ 60]
rejo
parents: 8
diff changeset
    84
}
2ff220cfde13 [feladat @ 60]
rejo
parents: 8
diff changeset
    85
else
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
     <td class="n">
2ff220cfde13 [feladat @ 60]
rejo
parents: 8
diff changeset
    89
      &nbsp;
2ff220cfde13 [feladat @ 60]
rejo
parents: 8
diff changeset
    90
     </td>
71
e1b918eaf69a [feladat @ 118]
peter
parents: 62
diff changeset
    91
<?php
13
2ff220cfde13 [feladat @ 60]
rejo
parents: 8
diff changeset
    92
}
2ff220cfde13 [feladat @ 60]
rejo
parents: 8
diff changeset
    93
?>
71
e1b918eaf69a [feladat @ 118]
peter
parents: 62
diff changeset
    94
     <td class="y"><?php echo $d['name']?></td>
e1b918eaf69a [feladat @ 118]
peter
parents: 62
diff changeset
    95
     <td class="y"><?php echo $d['numrec']?></td>
e1b918eaf69a [feladat @ 118]
peter
parents: 62
diff changeset
    96
     <td class="y"><?php echo get_owner_from_id($d['owner'])?></td>
13
2ff220cfde13 [feladat @ 60]
rejo
parents: 8
diff changeset
    97
    </tr>
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    98
			<?php
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    99
		} // end foreach ...
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   100
		?>
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   101
	</table>
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   102
	<br><br>
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   103
	<?php
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   104
	} // end if
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   105
	
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   106
	// any records ?!
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   107
	if(count($search_result['records']))
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   108
	{
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   109
		?>
71
e1b918eaf69a [feladat @ 118]
peter
parents: 62
diff changeset
   110
		<b><?php echo _('Records found'); ?>:</b>
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   111
		<p>
13
2ff220cfde13 [feladat @ 60]
rejo
parents: 8
diff changeset
   112
		<table>
2ff220cfde13 [feladat @ 60]
rejo
parents: 8
diff changeset
   113
			<tr>
2ff220cfde13 [feladat @ 60]
rejo
parents: 8
diff changeset
   114
				<td class="n">&nbsp;</td>
71
e1b918eaf69a [feladat @ 118]
peter
parents: 62
diff changeset
   115
				<td class="n"><?php echo _('Name'); ?></td>
e1b918eaf69a [feladat @ 118]
peter
parents: 62
diff changeset
   116
				<td class="n"><?php echo _('Type'); ?></td>
e1b918eaf69a [feladat @ 118]
peter
parents: 62
diff changeset
   117
				<td class="n"><?php echo _('Content'); ?></td>
e1b918eaf69a [feladat @ 118]
peter
parents: 62
diff changeset
   118
				<td class="n"><?php echo _('Priority'); ?></td>
e1b918eaf69a [feladat @ 118]
peter
parents: 62
diff changeset
   119
				<td class="n"><?php echo _('TTL'); ?></td>
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   120
			</tr>
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   121
		<?php
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   122
		foreach($search_result['records'] as $r)
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   123
		{
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   124
		?>
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   125
			<tr>
13
2ff220cfde13 [feladat @ 60]
rejo
parents: 8
diff changeset
   126
				<td class="n">
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   127
			<?php
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   128
			if (($r["type"] != "SOA" && $r["type"] != "NS") ||
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   129
			  ($GLOBALS["ALLOW_SOA_EDIT"] && $r["type"] == "SOA") ||
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   130
			  ($GLOBALS["ALLOW_NS_EDIT"] && $r["type"] == "NS") ||
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   131
			  ($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
   132
			  $GLOBALS["ALLOW_NS_EDIT"] != 1))
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   133
			{
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   134
				?>
71
e1b918eaf69a [feladat @ 118]
peter
parents: 62
diff changeset
   135
				<a href="edit_record.php?id=<?php echo $r['id']?>&amp;domain=<?php echo $r['domain_id']?>"><img src="images/edit.gif" alt="[ <?php echo _('Edit record'); ?> ]" border="0"></a>
e1b918eaf69a [feladat @ 118]
peter
parents: 62
diff changeset
   136
				<a href="delete_record.php?id=<?php echo $r['id']?>&amp;domain=<?php echo $r['domain_id']?>"><img src="images/delete.gif" alt="[ <?php echo _('Delete record'); ?> ]" border="0"></a>
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   137
				<?php 
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   138
			} // big if ;-)
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   139
			?>
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   140
			</td>
71
e1b918eaf69a [feladat @ 118]
peter
parents: 62
diff changeset
   141
			<td class="y"><?php echo $r['name']?></td>
e1b918eaf69a [feladat @ 118]
peter
parents: 62
diff changeset
   142
			<td class="y"><?php echo $r['type']?></td>
e1b918eaf69a [feladat @ 118]
peter
parents: 62
diff changeset
   143
			<td class="y"><?php echo $r['content']?></td>
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   144
			<?php
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   145
			if ($r['prio'] != 0)
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   146
			{
71
e1b918eaf69a [feladat @ 118]
peter
parents: 62
diff changeset
   147
				?><td class="y"><?php echo $r['prio']?></td><?php
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   148
			}
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   149
			else 
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   150
			{
13
2ff220cfde13 [feladat @ 60]
rejo
parents: 8
diff changeset
   151
			?><td class="n"></td><?php
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   152
			} // else
71
e1b918eaf69a [feladat @ 118]
peter
parents: 62
diff changeset
   153
			?><td class="y"><?php echo $r['ttl']?></td>
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   154
			</tr>
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   155
			<?php
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   156
		} // foreach
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   157
	?>
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   158
	</table>
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   159
	<?php
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   160
	} // if
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   161
	if(count($search_result['domains']) == 0 && count($search_result['records']) == 0)
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   162
	{
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   163
	?>
13
2ff220cfde13 [feladat @ 60]
rejo
parents: 8
diff changeset
   164
		<table border="0" cellspacing="4">
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   165
			<tr>
13
2ff220cfde13 [feladat @ 60]
rejo
parents: 8
diff changeset
   166
				<td width="510" class="n">
71
e1b918eaf69a [feladat @ 118]
peter
parents: 62
diff changeset
   167
				<?php echo _('Nothing found for query'); ?> "<?php echo $_POST['q']?>".
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   168
				</td>
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   169
			</tr>
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   170
		</table>
71
e1b918eaf69a [feladat @ 118]
peter
parents: 62
diff changeset
   171
	<?php
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   172
	}
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   173
		
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   174
}
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   175
include_once('inc/footer.inc.php');
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   176
?>
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   177