search.php
author peter
Mon, 11 Feb 2008 18:42:04 +0000
changeset 73 8a239565e9b3
parent 71 e1b918eaf69a
child 79 0c0aa144356a
permissions -rwxr-xr-x
[feladat @ 120] Fixed a bug reported by Techwolf. When editing or deleting an user the user was redirected to a non existing page. This probably happened when BASE_URL and/or BASE_PATH was set wrong in the config.inc.php.
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']);
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    28
}
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    29
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    30
// we will continue after the search form ... 
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    31
include_once('inc/header.inc.php');
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    32
?>
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    33
71
e1b918eaf69a [feladat @ 118]
peter
parents: 62
diff changeset
    34
    <h2><?php echo _('Search zones or records'); ?></h2>
13
2ff220cfde13 [feladat @ 60]
rejo
parents: 8
diff changeset
    35
    <h3>Query</h3>
2ff220cfde13 [feladat @ 60]
rejo
parents: 8
diff changeset
    36
    <table>
71
e1b918eaf69a [feladat @ 118]
peter
parents: 62
diff changeset
    37
     <form method="post" action="<?php echo $_SERVER['PHP_SELF']?>">
13
2ff220cfde13 [feladat @ 60]
rejo
parents: 8
diff changeset
    38
      <tr>
71
e1b918eaf69a [feladat @ 118]
peter
parents: 62
diff changeset
    39
       <td class="n"><?php echo _('Enter a hostname or IP address'); ?></td>
13
2ff220cfde13 [feladat @ 60]
rejo
parents: 8
diff changeset
    40
       <td class="n"><input type="text" class="input" name="q"></td>
2ff220cfde13 [feladat @ 60]
rejo
parents: 8
diff changeset
    41
      </tr>
2ff220cfde13 [feladat @ 60]
rejo
parents: 8
diff changeset
    42
      <tr>
2ff220cfde13 [feladat @ 60]
rejo
parents: 8
diff changeset
    43
       <td class="n">&nbsp;</td>
71
e1b918eaf69a [feladat @ 118]
peter
parents: 62
diff changeset
    44
       <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
    45
      </tr>
2ff220cfde13 [feladat @ 60]
rejo
parents: 8
diff changeset
    46
     </form>
2ff220cfde13 [feladat @ 60]
rejo
parents: 8
diff changeset
    47
    </table>
2ff220cfde13 [feladat @ 60]
rejo
parents: 8
diff changeset
    48
      
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    49
<?php
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    50
// results
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    51
if ($submitted)
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    52
{
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    53
	echo '<br><br>';
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    54
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    55
  	// let's check if we found any domains ...
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    56
	if (count($search_result) == 2 && count($search_result['domains']))
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    57
  	{
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    58
	?>
71
e1b918eaf69a [feladat @ 118]
peter
parents: 62
diff changeset
    59
	<h4><?php echo _('Zones found'); ?>:</h4>
13
2ff220cfde13 [feladat @ 60]
rejo
parents: 8
diff changeset
    60
	<table>
2ff220cfde13 [feladat @ 60]
rejo
parents: 8
diff changeset
    61
	 <tr>
2ff220cfde13 [feladat @ 60]
rejo
parents: 8
diff changeset
    62
	  <th>&nbsp;</th>
71
e1b918eaf69a [feladat @ 118]
peter
parents: 62
diff changeset
    63
	  <th><?php echo _('Name'); ?></th>
e1b918eaf69a [feladat @ 118]
peter
parents: 62
diff changeset
    64
	  <th><?php echo _('Records'); ?></th>
e1b918eaf69a [feladat @ 118]
peter
parents: 62
diff changeset
    65
	  <th><?php echo _('Owner'); ?></th>
13
2ff220cfde13 [feladat @ 60]
rejo
parents: 8
diff changeset
    66
         </tr>
2ff220cfde13 [feladat @ 60]
rejo
parents: 8
diff changeset
    67
<?php
2ff220cfde13 [feladat @ 60]
rejo
parents: 8
diff changeset
    68
foreach($search_result['domains'] as $d)
2ff220cfde13 [feladat @ 60]
rejo
parents: 8
diff changeset
    69
{
2ff220cfde13 [feladat @ 60]
rejo
parents: 8
diff changeset
    70
?>
2ff220cfde13 [feladat @ 60]
rejo
parents: 8
diff changeset
    71
         <tr>
71
e1b918eaf69a [feladat @ 118]
peter
parents: 62
diff changeset
    72
<?php
13
2ff220cfde13 [feladat @ 60]
rejo
parents: 8
diff changeset
    73
  if (level(5))
2ff220cfde13 [feladat @ 60]
rejo
parents: 8
diff changeset
    74
  {
2ff220cfde13 [feladat @ 60]
rejo
parents: 8
diff changeset
    75
  ?>
2ff220cfde13 [feladat @ 60]
rejo
parents: 8
diff changeset
    76
     <td class="n">
71
e1b918eaf69a [feladat @ 118]
peter
parents: 62
diff changeset
    77
      <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
    78
      <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
    79
     </td>
71
e1b918eaf69a [feladat @ 118]
peter
parents: 62
diff changeset
    80
<?php
13
2ff220cfde13 [feladat @ 60]
rejo
parents: 8
diff changeset
    81
}
2ff220cfde13 [feladat @ 60]
rejo
parents: 8
diff changeset
    82
else
2ff220cfde13 [feladat @ 60]
rejo
parents: 8
diff changeset
    83
{
2ff220cfde13 [feladat @ 60]
rejo
parents: 8
diff changeset
    84
?>
2ff220cfde13 [feladat @ 60]
rejo
parents: 8
diff changeset
    85
     <td class="n">
2ff220cfde13 [feladat @ 60]
rejo
parents: 8
diff changeset
    86
      &nbsp;
2ff220cfde13 [feladat @ 60]
rejo
parents: 8
diff changeset
    87
     </td>
71
e1b918eaf69a [feladat @ 118]
peter
parents: 62
diff changeset
    88
<?php
13
2ff220cfde13 [feladat @ 60]
rejo
parents: 8
diff changeset
    89
}
2ff220cfde13 [feladat @ 60]
rejo
parents: 8
diff changeset
    90
?>
71
e1b918eaf69a [feladat @ 118]
peter
parents: 62
diff changeset
    91
     <td class="y"><?php echo $d['name']?></td>
e1b918eaf69a [feladat @ 118]
peter
parents: 62
diff changeset
    92
     <td class="y"><?php echo $d['numrec']?></td>
e1b918eaf69a [feladat @ 118]
peter
parents: 62
diff changeset
    93
     <td class="y"><?php echo get_owner_from_id($d['owner'])?></td>
13
2ff220cfde13 [feladat @ 60]
rejo
parents: 8
diff changeset
    94
    </tr>
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    95
			<?php
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    96
		} // end foreach ...
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    97
		?>
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    98
	</table>
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    99
	<br><br>
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   100
	<?php
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   101
	} // end if
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   102
	
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   103
	// any records ?!
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   104
	if(count($search_result['records']))
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   105
	{
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   106
		?>
71
e1b918eaf69a [feladat @ 118]
peter
parents: 62
diff changeset
   107
		<b><?php echo _('Records found'); ?>:</b>
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   108
		<p>
13
2ff220cfde13 [feladat @ 60]
rejo
parents: 8
diff changeset
   109
		<table>
2ff220cfde13 [feladat @ 60]
rejo
parents: 8
diff changeset
   110
			<tr>
2ff220cfde13 [feladat @ 60]
rejo
parents: 8
diff changeset
   111
				<td class="n">&nbsp;</td>
71
e1b918eaf69a [feladat @ 118]
peter
parents: 62
diff changeset
   112
				<td class="n"><?php echo _('Name'); ?></td>
e1b918eaf69a [feladat @ 118]
peter
parents: 62
diff changeset
   113
				<td class="n"><?php echo _('Type'); ?></td>
e1b918eaf69a [feladat @ 118]
peter
parents: 62
diff changeset
   114
				<td class="n"><?php echo _('Content'); ?></td>
e1b918eaf69a [feladat @ 118]
peter
parents: 62
diff changeset
   115
				<td class="n"><?php echo _('Priority'); ?></td>
e1b918eaf69a [feladat @ 118]
peter
parents: 62
diff changeset
   116
				<td class="n"><?php echo _('TTL'); ?></td>
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   117
			</tr>
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   118
		<?php
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   119
		foreach($search_result['records'] as $r)
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   120
		{
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   121
		?>
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   122
			<tr>
13
2ff220cfde13 [feladat @ 60]
rejo
parents: 8
diff changeset
   123
				<td class="n">
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   124
			<?php
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   125
			if (($r["type"] != "SOA" && $r["type"] != "NS") ||
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   126
			  ($GLOBALS["ALLOW_SOA_EDIT"] && $r["type"] == "SOA") ||
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   127
			  ($GLOBALS["ALLOW_NS_EDIT"] && $r["type"] == "NS") ||
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   128
			  ($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
   129
			  $GLOBALS["ALLOW_NS_EDIT"] != 1))
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   130
			{
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   131
				?>
71
e1b918eaf69a [feladat @ 118]
peter
parents: 62
diff changeset
   132
				<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
   133
				<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
   134
				<?php 
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   135
			} // big if ;-)
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   136
			?>
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   137
			</td>
71
e1b918eaf69a [feladat @ 118]
peter
parents: 62
diff changeset
   138
			<td class="y"><?php echo $r['name']?></td>
e1b918eaf69a [feladat @ 118]
peter
parents: 62
diff changeset
   139
			<td class="y"><?php echo $r['type']?></td>
e1b918eaf69a [feladat @ 118]
peter
parents: 62
diff changeset
   140
			<td class="y"><?php echo $r['content']?></td>
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   141
			<?php
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   142
			if ($r['prio'] != 0)
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   143
			{
71
e1b918eaf69a [feladat @ 118]
peter
parents: 62
diff changeset
   144
				?><td class="y"><?php echo $r['prio']?></td><?php
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   145
			}
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   146
			else 
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   147
			{
13
2ff220cfde13 [feladat @ 60]
rejo
parents: 8
diff changeset
   148
			?><td class="n"></td><?php
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   149
			} // else
71
e1b918eaf69a [feladat @ 118]
peter
parents: 62
diff changeset
   150
			?><td class="y"><?php echo $r['ttl']?></td>
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   151
			</tr>
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   152
			<?php
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   153
		} // foreach
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   154
	?>
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   155
	</table>
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   156
	<?php
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   157
	} // if
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   158
	if(count($search_result['domains']) == 0 && count($search_result['records']) == 0)
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   159
	{
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   160
	?>
13
2ff220cfde13 [feladat @ 60]
rejo
parents: 8
diff changeset
   161
		<table border="0" cellspacing="4">
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   162
			<tr>
13
2ff220cfde13 [feladat @ 60]
rejo
parents: 8
diff changeset
   163
				<td width="510" class="n">
71
e1b918eaf69a [feladat @ 118]
peter
parents: 62
diff changeset
   164
				<?php echo _('Nothing found for query'); ?> "<?php echo $_POST['q']?>".
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   165
				</td>
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   166
			</tr>
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   167
		</table>
71
e1b918eaf69a [feladat @ 118]
peter
parents: 62
diff changeset
   168
	<?php
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   169
	}
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   170
		
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   171
}
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   172
include_once('inc/footer.inc.php');
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   173
?>
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   174