Search enhancements

git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@4 a1433add-5e2c-0410-b055-b7f2511e0802
postfixadmin-2.3
Greg 17 years ago
parent d7cca670cb
commit fc7bc9529a

@ -26,30 +26,33 @@ use DBI;
use strict;
use Sys::Syslog;
# values that will be set in /etc/mail/vacation/vacationrc:
our $db_type;
our $db_host;
our $db_user;
our $db_pass;
our $db_name;
our $sendmail;
our $logfile;
our $debugfile;
our $syslog;
our $logger;
require "/etc/mail/vacation/vacationrc";
# example config file:
# $db_type = 'mysql';
# $db_host = 'localhost';
# $db_user = 'postfixadmin';
# $db_pass = 'postfixadmin';
# $db_name = 'postfix';
# $sendmail = "/usr/sbin/sendmail";
# $logfile = ""; # specify a file name here for example: vacation.log
# $debugfile = ""; # sepcify a file name here for example: vacation.debug
# $syslog = 0; # 1 if log entries should be sent to syslog
# $logger = "/usr/bin/logger";
$db_type = 'mysql';
$db_host = 'localhost';
$db_user = 'postfixadmin';
$db_pass = 'postfixadmin';
$db_name = 'postfix';
$sendmail = "/usr/sbin/sendmail";
$logfile = ""; # specify a file name here for example: vacation.log
$debugfile = ""; # specify a file name here for example: vacation.debug
$syslog = 0; # 1 if log entries should be sent to syslog
$logger = "/usr/bin/logger";
# Alternatively, you can put the variables above in a
# config file that is readable by the vacation user.
# To do so, move them from here to there, declare them
# with 'our' here and include the file with 'require'
#our $db_type;
#our $db_host;
#our $db_user;
#our $db_pass;
#our $db_name;
#our $sendmail;
#our $logfile;
#our $debugfile;
#our $syslog;
#our $logger;
#require "/etc/mail/vacation/vacationrc";
my $dbh = DBI->connect("DBI:$db_type:$db_name:$db_host", "$db_user", "$db_pass", { RaiseError => 1 }) or &exit_error($DBI::errstr);

@ -16,7 +16,9 @@
//
// Form POST \ GET Variables:
//
// fSearch
// search
// fDomain
// fGo
//
require ("../variables.inc.php");
require ("../config.inc.php");
@ -28,6 +30,8 @@ $SESSID_USERNAME = check_session ();
$tAlias = array();
$tMailbox = array();
$list_domains = list_domains ();
if ($_SERVER['REQUEST_METHOD'] == "GET")
{
@ -94,6 +98,14 @@ if ($_SERVER['REQUEST_METHOD'] == "GET")
if ($_SERVER['REQUEST_METHOD'] == "POST")
{
if (isset ($_POST['search'])) $fSearch = escape_string ($_POST['search']);
if (isset ($_POST['fGo'])) $fGo = escape_string ($_POST['fGo']);
if (isset ($_POST['fDomain'])) $fDomain = escape_string ($_POST['fDomain']);
if (empty ($fSearch) && !empty ($fGo))
{
header("Location: list-virtual.php?domain=" . $fDomain ) && exit;
}
if ($CONF['alias_control'] == "YES")
{
@ -126,7 +138,7 @@ if ($_SERVER['REQUEST_METHOD'] == "POST")
}
}
$query = "SELECT * FROM $table_mailbox WHERE username LIKE '%$fSearch%' ORDER BY username";
$query = "SELECT * FROM $table_mailbox WHERE username LIKE '%$fSearch%' OR name LIKE '%$fSearch%' ORDER BY username";
if ('pgsql'==$CONF['database_type'])
{
$query = "SELECT *,extract(epoch from created) as uts_created,extract(epoch from modified) as uts_modified FROM $table_mailbox WHERE username LIKE '%$fSearch%' ORDER BY username";

@ -24,6 +24,15 @@ require ("./functions.inc.php");
include ("./languages/" . check_language () . ".lang");
$SESSID_USERNAME = check_session();
if (!check_admin($SESSID_USERNAME))
{
$list_domains = list_domains_for_admin ($SESSID_USERNAME);
}
else
{
$list_domains = list_domains ();
}
$tAlias = array();
$tMailbox = array();
@ -48,7 +57,11 @@ if ($_SERVER['REQUEST_METHOD'] == "GET")
{
if (check_owner ($SESSID_USERNAME, $row['domain']))
{
$tAlias[] = $row;
if ('pgsql'==$CONF['database_type'])
{
$row['modified']=gmstrftime('%c %Z',$row['modified']);
}
$tAlias[] = $row;
}
}
}
@ -56,28 +69,25 @@ if ($_SERVER['REQUEST_METHOD'] == "GET")
if ($CONF['vacation_control_admin'] == 'YES')
{
$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%' ORDER BY $table_mailbox.username");
if ('pgsql'==$CONF['database_type'])
{
// FIXME: postgres query needs to be rewrited
$query = "SELECT *,extract(epoch from created) as uts_created,extract(epoch from modified) as uts_modified FROM $table_mailbox WHERE domain='$fDomain' ORDER BY username LIMIT $limitSql";
}
}
else
{
$query = "SELECT * FROM $table_mailbox WHERE username LIKE '%$fSearch%' ORDER BY username";
if ('pgsql'==$CONF['database_type'])
{
$query = "SELECT *,extract(epoch from created) as uts_created,extract(epoch from modified) as uts_modified FROM $table_mailbox WHERE domain='$fDomain' ORDER BY username LIMIT $limitSql";
}
}
$result = db_query ($query);
if ($result['rows'] > 0)
{
while ($row = db_array ($result['result']))
{
if (check_owner ($SESSID_USERNAME, $row['domain']))
{
$tMailbox[] = $row;
if ('pgsql'==$CONF['database_type'])
{
$row['modified']=gmstrftime('%c %Z',$row['modified']);
$row['active']=('t'==$row['active']) ? 1 : 0;
}
$tMailbox[] = $row;
}
}
}
@ -91,6 +101,14 @@ if ($_SERVER['REQUEST_METHOD'] == "GET")
if ($_SERVER['REQUEST_METHOD'] == "POST")
{
if (isset ($_POST['search'])) $fSearch = escape_string ($_POST['search']);
if (isset ($_POST['fgo'])) $fgo = escape_string ($_POST['fgo']);
if (isset ($_POST['domain'])) $fdomain = escape_string ($_POST['domain']);
if (empty ($fSearch) && !empty ($fgo))
{
header("Location: overview.php?domain=" . $_POST['domain'] ) && exit;
}
if ($CONF['alias_control_admin'] == "YES")
{
@ -108,6 +126,10 @@ if ($_SERVER['REQUEST_METHOD'] == "POST")
{
if (check_owner ($SESSID_USERNAME, $row['domain']))
{
if ('pgsql'==$CONF['database_type'])
{
$row['modified']=gmstrftime('%c %Z',$row['modified']);
}
$tAlias[] = $row;
}
}
@ -115,20 +137,11 @@ if ($_SERVER['REQUEST_METHOD'] == "POST")
if ($CONF['vacation_control_admin'] == 'YES')
{
$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%' ORDER BY $table_mailbox.username");
if ('pgsql'==$CONF['database_type'])
{
// FIXME: postgres query needs to be rewrited
$query = "SELECT *,extract(epoch from created) as uts_created,extract(epoch from modified) as uts_modified FROM $table_mailbox WHERE domain='$fDomain' ORDER BY username LIMIT $limitSql";
}
$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");
}
else
{
$query = "SELECT * FROM $table_mailbox WHERE username LIKE '%$fSearch%' ORDER BY username";
if ('pgsql'==$CONF['database_type'])
{
$query = "SELECT *,extract(epoch from created) as uts_created,extract(epoch from modified) as uts_modified FROM $table_mailbox WHERE domain='$fDomain' ORDER BY username LIMIT $limitSql";
}
$query = "SELECT * FROM $table_mailbox WHERE username LIKE '%$fSearch%' OR name LIKE '%$fSearch%' ORDER BY username";
}
$result = db_query ("$query");
@ -138,6 +151,11 @@ if ($_SERVER['REQUEST_METHOD'] == "POST")
{
if (check_owner ($SESSID_USERNAME, $row['domain']))
{
if ('pgsql'==$CONF['database_type'])
{
$row['modified']=gmstrftime('%c %Z',$row['modified']);
$row['active']=('t'==$row['active']) ? 1 : 0;
}
$tMailbox[] = $row;
}
}

@ -1,7 +1,23 @@
<div id="overview">
<h4><?php print $PALANG['pSearch_welcome'] . $fSearch; ?></h4>
<form name="search" method="post" action="search.php">
<input type="textbox" name="search">
<table width=750><tr>
<td>
<h4><?php print $PALANG['pSearch_welcome'] . $fSearch; ?></h4>
</td>
<td>
New search:<input type="textbox" name="search">
</td>
<td align=right><select class="flat" name="fDomain" >
<?php
print "<option value=\"$list_domains[0]\" selected>$list_domains[0]</option>\n";
for ($i = 1; $i < sizeof ($list_domains); $i++)
{
print "<option value=\"$list_domains[$i]\">$list_domains[$i]</option>\n";
}
?>
</select>
<input class="button" type="submit" name="fGo" value="Return to <?php print $PALANG['pAdminMenu_list_virtual']; ?>" /></td>
</tr></table>
</form>
</div>
@ -71,7 +87,7 @@ if (sizeof ($tMailbox) > 0)
print " <td><a href=\"edit-active.php?username=" . urlencode ($tMailbox[$i]['username']) . "&domain=" . $tMailbox[$i]['domain'] . "\">" . $active . "</a></td>\n";
if ($CONF['alias_control'] == 'YES')
{
print " <td><a href=\"edit-alias.php?address=" . urlencode ($tMailbox[$i]['username']) . "&domain=$fDomain" . "\">" . $PALANG['pOverview_alias_edit'] . "</a></td>\n";
print " <td><a href=\"edit-alias.php?address=" . urlencode ($tMailbox[$i]['username']) . "&domain=" . $tMailbox[$i]['domain'] . "\">" . $PALANG['pOverview_alias_edit'] . "</a></td>\n";
}
print " <td><a href=\"edit-mailbox.php?username=" . urlencode ($tMailbox[$i]['username']) . "&domain=" . $tMailbox[$i]['domain'] . "\">" . $PALANG['edit'] . "</a></td>\n";
print " <td><a href=\"delete.php?table=mailbox&delete=" . urlencode ($tMailbox[$i]['username']) . "&domain=" . $tMailbox[$i]['domain'] . "\"onclick=\"return confirm ('" . $PALANG['confirm'] . $PALANG['pOverview_get_mailboxes'] . ": ". $tMailbox[$i]['username'] . "')\">" . $PALANG['del'] . "</a></td>\n";

@ -1,7 +1,25 @@
<div id="overview">
<h4><?php print $PALANG['pSearch_welcome'] . $fSearch; ?></h4>
<form name="search" method="post" action="search.php">
<input type="textbox" name="search">
<table width=750><tr>
<td>
<h4><?php print $PALANG['pSearch_welcome'] . $fSearch; ?></h4>
</td>
<td>
New search:<input type="textbox" name="search">
</td>
<td></td>
<td align=right><select class="flat" name="domain" >
<?php
print "<option value=\"$list_domains[0]\" selected>$list_domains[0]</option>\n";
for ($i = 1; $i < sizeof ($list_domains); $i++)
{
print "<option value=\"$list_domains[$i]\">$list_domains[$i]</option>\n";
}
?>
</select>
<input class="button" type="submit" name="fgo" value="Return to <?php print $PALANG['pMenu_overview']; ?>" /></td>
</tr></table>
</form>
</div>

Loading…
Cancel
Save