search.php
author rejo
Wed, 18 Apr 2007 22:48:49 +0000
changeset 7 ac0ca51809b1
parent 3 64525a2eb098
child 8 47dd15d8bb8c
permissions -rwxr-xr-x
[feladat @ 8] - Removal of left-over backup file.
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
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
     3
// +--------------------------------------------------------------------+
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
     4
// | PowerAdmin                                                         |
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
     5
// +--------------------------------------------------------------------+
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
     6
// | Copyright (c) 1997-2002 The PowerAdmin Team                        |
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
     7
// +--------------------------------------------------------------------+
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
     8
// | This source file is subject to the license carried by the overal   |
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
     9
// | program PowerAdmin as found on http://poweradmin.sf.net            |
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    10
// | The PowerAdmin program falls under the QPL License:                |
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    11
// | http://www.trolltech.com/developer/licensing/qpl.html              |
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    12
// +--------------------------------------------------------------------+
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    13
// | Authors: Roeland Nieuwenhuis <trancer <AT> trancer <DOT> nl>       |
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    14
// |          Sjeemz <sjeemz <AT> sjeemz <DOT> nl>                      |
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    15
// +--------------------------------------------------------------------+
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    16
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    17
// Filename: search.php
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    18
// Startdate: 9-01-2003
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    19
// Searches the database for corresponding records or domains.
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    20
//
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    21
// The sourecode for this program was donated by DeViCeD, THANKS!
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    22
//
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    23
// $Id: search.php,v 1.1 2003/01/09 23:23:39 azurazu Exp $
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    24
//
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    25
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    26
require_once('inc/toolkit.inc.php');
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    27
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    28
if (isset($_POST['s_submit']) || isset($_POST['q']))
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    29
{
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    30
	$submitted = true;
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    31
	$search_result = search_record($_POST['q']);
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    32
}
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    33
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    34
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    35
// we will continue after the search form ... 
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    36
include_once('inc/header.inc.php');
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    37
?>
2
9a485c41cfcf [feladat @ 3]
rejo
parents: 1
diff changeset
    38
<P><H2><? echo _('Search zones or records'); ?></H2></P>
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    39
<P CLASS="nav">
2
9a485c41cfcf [feladat @ 3]
rejo
parents: 1
diff changeset
    40
<A HREF="index.php"><? echo _('DNS Admin'); ?></A> 
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    41
<?
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    42
if (level(10))
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    43
{
3
64525a2eb098 [feladat @ 4]
rejo
parents: 2
diff changeset
    44
	?><A HREF="users.php"><? echo _('User admin'); ?></A> <A HREF="seq_update.php"><? echo _('Synchronize database'); ?></A><?
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    45
}
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    46
?>
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    47
</P><BR>
2
9a485c41cfcf [feladat @ 3]
rejo
parents: 1
diff changeset
    48
<? echo _('Type a hostname or a record in the box below and press search to see if the record exists in the system.'); ?>
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    49
	<table border = "0" cellspacing = "4">
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    50
	<form method = "post" action="<?=$_SERVER['PHP_SELF']?>">
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    51
		<tr>
2
9a485c41cfcf [feladat @ 3]
rejo
parents: 1
diff changeset
    52
			<td class = "tdbg"><b><? echo _('Enter a hostname or IP address'); ?></b></td>
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    53
			<td width = "510" class = "tdbg"><input type = "text" class = "input" name = "q"></td>
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    54
		</tr>
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    55
		<tr>
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    56
			<td class = "tdbg">&nbsp;</td>
2
9a485c41cfcf [feladat @ 3]
rejo
parents: 1
diff changeset
    57
			<td class = "tdbg"><input type = "submit" class = "button" name = "s_submit" value = "<? echo _('Search'); ?>"></td>
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    58
		</tr>
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    59
	</form>
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    60
	</table>
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    61
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    62
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    63
<?php
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    64
// results
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    65
if ($submitted)
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    66
{
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    67
	echo '<br><br>';
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    68
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    69
  	// let's check if we found any domains ...
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    70
	if (count($search_result) == 2 && count($search_result['domains']))
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    71
  	{
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    72
	?>
2
9a485c41cfcf [feladat @ 3]
rejo
parents: 1
diff changeset
    73
	<b><? echo _('Domains found'); ?>:</b>
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    74
	<p>
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    75
	<table border = "0" cellspacing = "4">
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    76
		<tr style = "font-weight: Bold;">
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    77
			<td class = "tdbg">&nbsp;</td>
2
9a485c41cfcf [feladat @ 3]
rejo
parents: 1
diff changeset
    78
			<td class = "tdbg"><? echo _('Name'); ?></td>
9a485c41cfcf [feladat @ 3]
rejo
parents: 1
diff changeset
    79
			<td class = "tdbg"><? echo _('Records'); ?></td>
9a485c41cfcf [feladat @ 3]
rejo
parents: 1
diff changeset
    80
			<td class = "tdbg"><? echo _('Owner'); ?></td>
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    81
		</tr>
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    82
		<?php
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    83
		foreach($search_result['domains'] as $d)
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    84
		{
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    85
			?>	
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    86
			<tr>
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    87
			<td class = "tdbg">
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    88
			<?php 
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    89
			if (level(5))
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    90
			{
3
64525a2eb098 [feladat @ 4]
rejo
parents: 2
diff changeset
    91
				echo '<a href = "delete_domain.php?id='.$d['id'].'"><img src = "images/delete.gif" alt = "[ ' .  _('Delete zone') . ' ]" border = "0"></a>';
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    92
			}
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    93
			else 
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    94
			{
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    95
				echo '&nbsp;';
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    96
			}
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    97
			?>
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    98
			</td>
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    99
			<td class = "tdbg"><a href = "edit.php?id=<?=$d['id']?>"><?=$d['name']?></a></td>
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   100
			<td class = "tdbg"><?=$d['numrec']?></td>
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   101
			<td class = "tdbg"><?=get_owner_from_id($d['owner'])?></td>
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   102
			</tr>
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   103
			<?php
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   104
		} // end foreach ...
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   105
		?>
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   106
	</table>
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   107
	<br><br>
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   108
	<?php
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   109
	} // end if
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   110
	
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   111
	
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   112
	// any records ?!
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   113
	if(count($search_result['records']))
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   114
	{
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   115
		?>
2
9a485c41cfcf [feladat @ 3]
rejo
parents: 1
diff changeset
   116
		<b><? echo _('Records found'); ?>:</b>
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   117
		<p>
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   118
		<table border = "0" cellspacing = "4">
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   119
			<tr style = "font-weight: Bold;">
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   120
				<td class = "tdbg">&nbsp;</td>
2
9a485c41cfcf [feladat @ 3]
rejo
parents: 1
diff changeset
   121
				<td class = "tdbg"><? echo _('Name'); ?></td>
9a485c41cfcf [feladat @ 3]
rejo
parents: 1
diff changeset
   122
				<td class = "tdbg"><? echo _('Type'); ?></td>
9a485c41cfcf [feladat @ 3]
rejo
parents: 1
diff changeset
   123
				<td class = "tdbg"><? echo _('Content'); ?></td>
9a485c41cfcf [feladat @ 3]
rejo
parents: 1
diff changeset
   124
				<td class = "tdbg"><? echo _('Priority'); ?></td>
9a485c41cfcf [feladat @ 3]
rejo
parents: 1
diff changeset
   125
				<td class = "tdbg"><? echo _('TTL'); ?></td>
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   126
			</tr>
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   127
		<?php
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   128
		foreach($search_result['records'] as $r)
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   129
		{
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   130
		?>
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   131
			<tr>
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   132
				<td class = "tdbg">
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   133
			<?php
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   134
			if (($r["type"] != "SOA" && $r["type"] != "NS") ||
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   135
			  ($GLOBALS["ALLOW_SOA_EDIT"] && $r["type"] == "SOA") ||
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   136
			  ($GLOBALS["ALLOW_NS_EDIT"] && $r["type"] == "NS") ||
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   137
			  ($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
   138
			  $GLOBALS["ALLOW_NS_EDIT"] != 1))
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   139
			{
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   140
				?>
3
64525a2eb098 [feladat @ 4]
rejo
parents: 2
diff changeset
   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>
64525a2eb098 [feladat @ 4]
rejo
parents: 2
diff changeset
   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>
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   143
				<?php 
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   144
			} // big if ;-)
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   145
			?>
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   146
			</td>
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   147
			<td style = "border: 1px solid #000000;"><?=$r['name']?></td>
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   148
			<td style = "border: 1px solid #000000;"><?=$r['type']?></td>
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   149
			<td style = "border: 1px solid #000000;"><?=$r['content']?></td>
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   150
			<?php
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   151
			if ($r['prio'] != 0)
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   152
			{
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   153
				?><td style = "border: 1px solid #000000;"><?=$r['prio']?></td><?php
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   154
			}
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   155
			else 
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   156
			{
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   157
			?><td class = "tdbg"></td><?php
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   158
			} // else
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   159
			?><td style = "border: 1px solid #000000;"><?=$r['ttl']?></td>
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   160
			</tr>
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   161
			<?php
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   162
		} // foreach
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   163
	?>
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   164
	</table>
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   165
	<?php
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   166
	} // if
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   167
	if(count($search_result['domains']) == 0 && count($search_result['records']) == 0)
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   168
	{
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   169
	?>
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   170
		<table border = "0" cellspacing = "4">
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   171
			<tr>
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   172
				<td width = "510" class = "tdbg">
2
9a485c41cfcf [feladat @ 3]
rejo
parents: 1
diff changeset
   173
				<? echo _('Nothing found for query'); ?> "<?=$_POST['q']?>"
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   174
				</td>
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   175
			</tr>
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   176
		</table>
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   177
	<?
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   178
	}
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   179
		
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   180
}
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   181
include_once('inc/footer.inc.php');
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   182
?>
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   183