Blob


1 <?php
2 //
3 // OpenSMTPD Admin
4 // by Mischa Peters <mischa at high5 dot nl>
5 // Copyright (c) 2022 High5!
6 // License Info: LICENSE.TXT
7 //
8 // File: viewlog.php
9 //
10 // Template File: viewlog.tpl
11 //
12 // Template Variables:
13 //
14 // log
15 //
16 // POST / GET Variables:
17 //
18 // domain
19 //
20 require_once './functions.inc.php';
21 include './languages/' . check_language() . '.lang';
23 $SESSID_USERNAME = check_session();
24 $ROLE = check_role($SESSID_USERNAME);
26 if ($ROLE == ADMIN_ROLE) {
27 $list_domains = list_domains();
28 } else {
29 $list_domains = list_domains($SESSID_USERNAME);
30 }
32 if ($_SERVER['REQUEST_METHOD'] == "GET") {
33 $domain = filter_input(INPUT_GET, 'domain', FILTER_VALIDATE_DOMAIN);
34 $limit = LOG_SIZE;
36 if (empty($domain) && count($list_domains) > 0) {
37 $domain = $list_domains[0]['domain'];
38 }
40 if (in_array($domain, array_column($list_domains, 'domain'))) {
41 $domain_key = array_search($domain, array_column($list_domains, 'domain'));
42 $dbh = pdo_connect();
43 $sth = $dbh->prepare("SELECT * FROM log WHERE domain=? ORDER BY timestamp DESC LIMIT ?");
44 $sth->bindParam(1, $domain, PDO::PARAM_STR);
45 $sth->bindParam(2, $limit, PDO::PARAM_INT);
46 $sth->execute();
47 $log = $sth->fetchAll();
48 }
49 }
50 include './templates/header.tpl';
51 include './templates/menu.tpl';
52 include './templates/viewlog.tpl';
53 include './templates/footer.tpl';
54 ?>