opensmtpdadmin/admin/search.php
2022-09-03 08:44:32 +00:00

47 lines
1.2 KiB
PHP

<?php
//
// OpenSMTPD Admin
// by Mischa Peters <mischa at high5 dot nl>
// Copyright (c) 2022 High5!
// License Info: LICENSE.TXT
//
// File: search.php
//
// Template File: search.tpl
//
// Template Variables:
//
// list_alias
// list_mailbox
//
// Form POST \ GET Variables:
//
// search
//
require_once '../functions.inc.php';
include '../languages/' . check_language() . '.lang';
$search = filter_input(INPUT_POST, 'search', FILTER_DEFAULT);
if (isset($search)) {
$dbh = connect_db();
$sth = $dbh->prepare("SELECT alias.address,alias.goto,alias.modified,alias.domain FROM alias LEFT JOIN mailbox ON alias.address=mailbox.username WHERE alias.address LIKE ? AND mailbox.maildir IS NULL ORDER BY alias.address");
$sth->bindValue(1, '%'.$search.'%', PDO::PARAM_STR);
$sth->execute();
$list_alias = $sth->fetchAll();
$sth = $dbh->prepare("SELECT * FROM mailbox WHERE username LIKE ? ORDER BY username");
$sth->bindValue(1, '%'.$search.'%', PDO::PARAM_STR);
$sth->execute();
$list_mailbox = $sth->fetchAll();
} else {
$list_alias = array();
$list_mailbox = array();
}
include '../templates/header.tpl';
include '../templates/admin_menu.tpl';
include '../templates/admin_search.tpl';
include '../templates/footer.tpl';
?>