4 // by Mischa Peters <mischa at high5 dot nl>
5 // Copyright (c) 2022 High5!
6 // License Info: LICENSE.TXT
10 // Template File: search.tpl
12 // Template Variables:
17 // POST / GET Variables:
21 require_once './functions.inc.php';
22 include './languages/' . check_language() . '.lang';
24 $SESSID_USERNAME = check_session();
25 $ROLE = check_role($SESSID_USERNAME);
27 if ($ROLE == ADMIN_ROLE) {
28 $list_domains = list_domains();
30 $list_domains = list_domains($SESSID_USERNAME);
33 if ($_SERVER['REQUEST_METHOD'] == "POST") {
34 $search = filter_input(INPUT_POST, 'search', FILTER_DEFAULT);
38 $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");
39 $sth->bindValue(1, '%'.$search.'%', PDO::PARAM_STR);
41 $list_alias = $sth->fetchAll();
42 foreach ($list_alias as $key => $value) {
43 if (!in_array($value['domain'], array_column($list_domains, 'domain'))) {
44 unset($list_alias[$key]);
48 $sth = $dbh->prepare("SELECT * FROM mailbox WHERE username LIKE ? ORDER BY username");
49 $sth->bindValue(1, '%'.$search.'%', PDO::PARAM_STR);
51 $list_mailbox = $sth->fetchAll();
52 foreach ($list_mailbox as $key => $value) {
53 if (!in_array($value['domain'], array_column($list_domains, 'domain'))) {
54 unset($list_mailbox[$key]);
58 $list_alias = array();
59 $list_mailbox = array();
62 include './templates/header.tpl';
63 include './templates/menu.tpl';
64 include './templates/search.tpl';
65 include './templates/footer.tpl';