From 36ef6f7c649a95fabb539b42be78340e9c7e50e9 Mon Sep 17 00:00:00 2001 From: mischa Date: Sun, 4 Sep 2022 20:43:21 +0000 Subject: [PATCH] clean up --- add-alias.php | 2 +- add-mailbox.php | 2 +- admin/add-alias.php | 2 +- admin/add-mailbox.php | 2 +- admin/admin.php | 2 +- admin/backup.php | 2 +- admin/delete.php | 2 +- admin/domain.php | 2 +- admin/edit-alias.php | 2 +- admin/edit-mailbox.php | 2 +- admin/index.php | 2 +- admin/list-admin.php | 2 +- admin/list-domain.php | 2 +- admin/list-virtual.php | 2 +- admin/search.php | 47 +++++++++++++++++++++--------------------- admin/viewlog.php | 2 +- delete.php | 2 +- edit-alias.php | 2 +- edit-mailbox.php | 2 +- index.php | 2 +- list-virtual.php | 2 +- logout.php | 2 +- main.php | 2 +- password.php | 2 +- search.php | 47 +++++++++++++++++++++--------------------- sendmail.php | 2 +- users/index.php | 2 +- users/logout.php | 2 +- users/main.php | 3 ++- users/password.php | 2 +- users/vacation.php | 2 +- viewlog.php | 2 +- 32 files changed, 79 insertions(+), 76 deletions(-) diff --git a/add-alias.php b/add-alias.php index d9404d5..3c0802d 100644 --- a/add-alias.php +++ b/add-alias.php @@ -16,7 +16,7 @@ // domain // goto // -// Form POST \ GET Variables: +// Form POST / GET Variables: // // address // domain diff --git a/add-mailbox.php b/add-mailbox.php index 1172294..91bd255 100644 --- a/add-mailbox.php +++ b/add-mailbox.php @@ -16,7 +16,7 @@ // name // domain // -// Form POST \ GET Variables: +// Form POST / GET Variables: // // username // password1 diff --git a/admin/add-alias.php b/admin/add-alias.php index 5ee4352..ac84b03 100644 --- a/admin/add-alias.php +++ b/admin/add-alias.php @@ -16,7 +16,7 @@ // domain // goto // -// Form POST \ GET Variables: +// Form POST / GET Variables: // // address // domain diff --git a/admin/add-mailbox.php b/admin/add-mailbox.php index bb61226..50b2ccb 100644 --- a/admin/add-mailbox.php +++ b/admin/add-mailbox.php @@ -16,7 +16,7 @@ // name // domain // -// Form POST \ GET Variables: +// Form POST / GET Variables: // // username // password1 diff --git a/admin/admin.php b/admin/admin.php index f776b90..916eefe 100644 --- a/admin/admin.php +++ b/admin/admin.php @@ -17,7 +17,7 @@ // username // domains // -// Form POST \ GET Variables: +// Form POST / GET Variables: // // username // password1 diff --git a/admin/backup.php b/admin/backup.php index c55757f..9066fb4 100644 --- a/admin/backup.php +++ b/admin/backup.php @@ -13,7 +13,7 @@ // // -none- // -// Form POST \ GET Variables: +// Form POST / GET Variables: // // -none- // diff --git a/admin/delete.php b/admin/delete.php index 7a1cec7..28c56c0 100644 --- a/admin/delete.php +++ b/admin/delete.php @@ -13,7 +13,7 @@ // // message // -// Form POST \ GET Variables: +// Form POST / GET Variables: // // table // where diff --git a/admin/domain.php b/admin/domain.php index 6ad2f57..7bab9d2 100644 --- a/admin/domain.php +++ b/admin/domain.php @@ -18,7 +18,7 @@ // aliases // mailboxes // -// Form POST \ GET Variables: +// Form POST / GET Variables: // // domain // description diff --git a/admin/edit-alias.php b/admin/edit-alias.php index 102e770..b1c0010 100644 --- a/admin/edit-alias.php +++ b/admin/edit-alias.php @@ -14,7 +14,7 @@ // message // goto // -// Form POST \ GET Variables: +// Form POST / GET Variables: // // address // domain diff --git a/admin/edit-mailbox.php b/admin/edit-mailbox.php index f5f32a7..c0f358a 100644 --- a/admin/edit-mailbox.php +++ b/admin/edit-mailbox.php @@ -14,7 +14,7 @@ // message // name // -// Form POST \ GET Variables: +// Form POST / GET Variables: // // username // domain diff --git a/admin/index.php b/admin/index.php index a11416a..383d9fe 100644 --- a/admin/index.php +++ b/admin/index.php @@ -13,7 +13,7 @@ // // -none- // -// Form POST \ GET Variables: +// Form POST / GET Variables: // // -none- // diff --git a/admin/list-admin.php b/admin/list-admin.php index d2ab8eb..cade867 100644 --- a/admin/list-admin.php +++ b/admin/list-admin.php @@ -13,7 +13,7 @@ // // list_admins // -// Form POST \ GET Variables: +// Form POST / GET Variables: // // -none- // diff --git a/admin/list-domain.php b/admin/list-domain.php index 2134f1b..278f796 100644 --- a/admin/list-domain.php +++ b/admin/list-domain.php @@ -13,7 +13,7 @@ // // list_domains // -// Form POST \ GET Variables: +// Form POST / GET Variables: // // username // diff --git a/admin/list-virtual.php b/admin/list-virtual.php index 76e1928..2eb9ced 100644 --- a/admin/list-virtual.php +++ b/admin/list-virtual.php @@ -14,7 +14,7 @@ // list_alias // list_mailbox // -// Form POST \ GET Variables: +// Form POST / GET Variables: // // domain // offset diff --git a/admin/search.php b/admin/search.php index 3bdc5f9..dc79b30 100644 --- a/admin/search.php +++ b/admin/search.php @@ -14,7 +14,7 @@ // list_alias // list_mailbox // -// Form POST \ GET Variables: +// Form POST / GET Variables: // // search // @@ -23,34 +23,35 @@ include '../languages/' . check_language() . '.lang'; $list_domains = list_domains(); -$search = filter_input(INPUT_POST, 'search', FILTER_DEFAULT); +if ($_SERVER['REQUEST_METHOD'] == "POST") { + $search = filter_input(INPUT_POST, 'search', FILTER_DEFAULT); -if (isset($search)) { - $dbh = pdo_connect(); - $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(); - foreach ($list_alias as $key => $value) { - if (!in_array($value['domain'], array_column($list_domains, 'domain'))) { - unset($list_alias[$key]); + if (isset($search)) { + $dbh = pdo_connect(); + $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(); + foreach ($list_alias as $key => $value) { + if (!in_array($value['domain'], array_column($list_domains, 'domain'))) { + unset($list_alias[$key]); + } } - } - $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(); - foreach ($list_mailbox as $key => $value) { - if (!in_array($value['domain'], array_column($list_domains, 'domain'))) { - unset($list_mailbox[$key]); + $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(); + foreach ($list_mailbox as $key => $value) { + if (!in_array($value['domain'], array_column($list_domains, 'domain'))) { + unset($list_mailbox[$key]); + } } + } else { + $list_alias = array(); + $list_mailbox = array(); } -} else { - $list_alias = array(); - $list_mailbox = array(); } - include '../templates/header.tpl'; include '../templates/admin_menu.tpl'; include '../templates/search.tpl'; diff --git a/admin/viewlog.php b/admin/viewlog.php index 8ff88fe..b8eaec0 100644 --- a/admin/viewlog.php +++ b/admin/viewlog.php @@ -13,7 +13,7 @@ // // log // -// Form POST \ GET Variables: +// Form POST / GET Variables: // // domain // diff --git a/delete.php b/delete.php index c64a5e2..022631a 100644 --- a/delete.php +++ b/delete.php @@ -13,7 +13,7 @@ // // message // -// Form POST \ GET Variables: +// Form POST / GET Variables: // // table // where diff --git a/edit-alias.php b/edit-alias.php index 41a5571..c271581 100644 --- a/edit-alias.php +++ b/edit-alias.php @@ -14,7 +14,7 @@ // message // goto // -// Form POST \ GET Variables: +// Form POST / GET Variables: // // address // domain diff --git a/edit-mailbox.php b/edit-mailbox.php index 0235062..f225334 100644 --- a/edit-mailbox.php +++ b/edit-mailbox.php @@ -14,7 +14,7 @@ // message // name // -// Form POST \ GET Variables: +// Form POST / GET Variables: // // username // domain diff --git a/index.php b/index.php index b20a132..ca5d939 100644 --- a/index.php +++ b/index.php @@ -13,7 +13,7 @@ // // -none- // -// Form POST \ GET Variables: +// Form POST / GET Variables: // // -none- // diff --git a/list-virtual.php b/list-virtual.php index cc9fc89..ce380e6 100644 --- a/list-virtual.php +++ b/list-virtual.php @@ -14,7 +14,7 @@ // list_alias // list_mailbox // -// Form POST \ GET Variables: +// Form POST / GET Variables: // // domain // offset diff --git a/logout.php b/logout.php index 2d6569d..f837b17 100644 --- a/logout.php +++ b/logout.php @@ -13,7 +13,7 @@ // // -none- // -// Form POST \ GET Variables: +// Form POST / GET Variables: // // -none- // diff --git a/main.php b/main.php index a1952da..e6cdc75 100644 --- a/main.php +++ b/main.php @@ -13,7 +13,7 @@ // // -none- // -// Form POST \ GET Variables: +// Form POST / GET Variables: // // -none- // diff --git a/password.php b/password.php index 3cc408f..5f9280c 100644 --- a/password.php +++ b/password.php @@ -13,7 +13,7 @@ // // message // -// Form POST \ GET Variables: +// Form POST / GET Variables: // // password_current // password1 diff --git a/search.php b/search.php index 3aab1b6..7cb0646 100644 --- a/search.php +++ b/search.php @@ -14,7 +14,7 @@ // list_alias // list_mailbox // -// Form POST \ GET Variables: +// Form POST / GET Variables: // // search // @@ -24,34 +24,35 @@ include './languages/' . check_language() . '.lang'; $SESSID_USERNAME = check_session(); $list_domains = list_domains($SESSID_USERNAME); -$search = filter_input(INPUT_POST, 'search', FILTER_DEFAULT); +if ($_SERVER['REQUEST_METHOD'] == "POST") { + $search = filter_input(INPUT_POST, 'search', FILTER_DEFAULT); -if (isset($search)) { - $dbh = pdo_connect(); - $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(); - foreach ($list_alias as $key => $value) { - if (!in_array($value['domain'], array_column($list_domains, 'domain'))) { - unset($list_alias[$key]); + if (isset($search)) { + $dbh = pdo_connect(); + $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(); + foreach ($list_alias as $key => $value) { + if (!in_array($value['domain'], array_column($list_domains, 'domain'))) { + unset($list_alias[$key]); + } } - } - $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(); - foreach ($list_mailbox as $key => $value) { - if (!in_array($value['domain'], array_column($list_domains, 'domain'))) { - unset($list_mailbox[$key]); + $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(); + foreach ($list_mailbox as $key => $value) { + if (!in_array($value['domain'], array_column($list_domains, 'domain'))) { + unset($list_mailbox[$key]); + } } + } else { + $list_alias = array(); + $list_mailbox = array(); } -} else { - $list_alias = array(); - $list_mailbox = array(); } - include './templates/header.tpl'; include './templates/menu.tpl'; include './templates/search.tpl'; diff --git a/sendmail.php b/sendmail.php index 16dadfa..18a4943 100644 --- a/sendmail.php +++ b/sendmail.php @@ -16,7 +16,7 @@ // subject // body // -// Form POST \ GET Variables: +// Form POST / GET Variables: // // to // subject diff --git a/users/index.php b/users/index.php index 9c7dcef..5bf916e 100644 --- a/users/index.php +++ b/users/index.php @@ -13,7 +13,7 @@ // // -none- // -// Form POST \ GET Variables: +// Form POST / GET Variables: // // -none- // diff --git a/users/logout.php b/users/logout.php index 3eebb19..1aae1fc 100644 --- a/users/logout.php +++ b/users/logout.php @@ -13,7 +13,7 @@ // // -none- // -// Form POST \ GET Variables: +// Form POST / GET Variables: // // -none- // diff --git a/users/main.php b/users/main.php index 4d5166d..e7bc2ec 100644 --- a/users/main.php +++ b/users/main.php @@ -13,7 +13,7 @@ // // -none- // -// Form POST \ GET Variables: +// Form POST / GET Variables: // // -none- // @@ -27,3 +27,4 @@ include '../templates/header.tpl'; include '../templates/users_menu.tpl'; include '../templates/users_main.tpl'; include '../templates/footer.tpl'; +?> diff --git a/users/password.php b/users/password.php index 9ddb89b..69a34fa 100644 --- a/users/password.php +++ b/users/password.php @@ -13,7 +13,7 @@ // // message // -// Form POST \ GET Variables: +// Form POST / GET Variables: // // password_current // password1 diff --git a/users/vacation.php b/users/vacation.php index b7bca0b..2ca242c 100644 --- a/users/vacation.php +++ b/users/vacation.php @@ -15,7 +15,7 @@ // tSubject // tBody // -// Form POST \ GET Variables: +// Form POST / GET Variables: // // fSubject // fBody diff --git a/viewlog.php b/viewlog.php index f6c4ee5..6ccfcb4 100644 --- a/viewlog.php +++ b/viewlog.php @@ -13,7 +13,7 @@ // // log // -// Form POST \ GET Variables: +// Form POST / GET Variables: // // domain //