6
* This source file is subject to the GPL license that is bundled with
7
* this package in the file LICENSE.TXT.
9
* Further details on the project are available at :
10
* http://www.postfixadmin.com or http://postfixadmin.sf.net
12
* @version $Id: search.php 566 2009-02-15 15:02:26Z christian_boltz $
13
* @license GNU GPL v2 or later.
16
* Provides a method for searching for a user/mailbox
17
* Template File: search.php
24
* Form POST \ GET Variables:
31
require_once('common.php');
33
authentication_require_role('admin');
34
$SESSID_USERNAME = authentication_get_username();
35
if(authentication_has_role('global-admin')) {
36
$list_domains = list_domains ();
39
$list_domains = list_domains_for_admin ($SESSID_USERNAME);
46
if ($_SERVER['REQUEST_METHOD'] == "GET")
48
if (isset ($_GET['search'])) $fSearch = escape_string ($_GET['search']);
49
if (isset ($_GET['fGo'])) $fGo = escape_string ($_GET['fGo']);
50
if (isset ($_GET['fDomain'])) $fDomain = escape_string ($_GET['domain']);
53
if ($_SERVER['REQUEST_METHOD'] == "POST")
55
if (isset ($_POST['search'])) $fSearch = escape_string ($_POST['search']);
56
if (isset ($_POST['fGo'])) $fGo = escape_string ($_POST['fGo']);
57
if (isset ($_POST['fDomain'])) $fDomain = escape_string ($_POST['fDomain']);
60
if (empty ($fSearch) /* && !empty ($fGo) */)
62
header("Location: list-virtual.php?domain=" . $fDomain ) && exit;
65
if ($CONF['alias_control_admin'] == "YES")
67
$query = "SELECT $table_alias.address AS address, $table_alias.goto AS goto,
68
$table_alias.modified AS modified, $table_alias.domain AS domain, $table_alias.active AS active
70
WHERE address LIKE '%$fSearch%' OR goto LIKE '%$fSearch%' ORDER BY address";
74
// find all aliases which don't have a matching entry in table_mailbox
75
$query = "SELECT $table_alias.address AS address, $table_alias.goto AS goto,
76
$table_alias.modified AS modified, $table_alias.domain AS domain, $table_alias.active AS active
77
FROM $table_alias LEFT JOIN $table_mailbox ON $table_alias.address=$table_mailbox.username
78
WHERE address LIKE '%$fSearch%' AND $table_mailbox.maildir IS NULL ORDER BY $table_alias.address";
82
$result = db_query ($query);
83
if ($result['rows'] > 0)
85
while ($row = db_array ($result['result']))
87
if (check_owner ($SESSID_USERNAME, $row['domain']) || authentication_has_role('global-admin'))
89
if ('pgsql'==$CONF['database_type'])
91
$row['modified']=gmstrftime('%c %Z',$row['modified']);
92
$row['active']=('t'==$row['active']) ? 1 : 0;
100
if ($CONF['vacation_control_admin'] == 'YES' && $CONF['vacation'] == 'YES')
102
$query = ("SELECT $table_mailbox.*, $table_vacation.active AS v_active FROM $table_mailbox LEFT JOIN $table_vacation ON $table_mailbox.username=$table_vacation.email WHERE $table_mailbox.username LIKE '%$fSearch%' OR $table_mailbox.name LIKE '%$fSearch%' ORDER BY $table_mailbox.username");
106
$query = "SELECT * FROM $table_mailbox WHERE username LIKE '%$fSearch%' OR name LIKE '%$fSearch%' ORDER BY username";
109
$result = db_query ($query);
110
if ($result['rows'] > 0)
112
while ($row = db_array ($result['result']))
114
if (check_owner ($SESSID_USERNAME, $row['domain']) || authentication_has_role('global-admin'))
116
if ('pgsql'==$CONF['database_type'])
118
$row['created']=gmstrftime('%c %Z',strtotime($row['created']));
119
$row['modified']=gmstrftime('%c %Z',strtotime($row['modified']));
120
$row['active']=('t'==$row['active']) ? 1 : 0;
127
include ("templates/header.php");
128
include ("templates/menu.php");
129
include ("templates/search.php");
130
include ("templates/footer.php");
132
/* vim: set expandtab softtabstop=4 tabstop=4 shiftwidth=4: */