52 lines
1.3 KiB
PHP
52 lines
1.3 KiB
PHP
<?php
|
|
//
|
|
// OpenSMTPD Admin
|
|
// by Mischa Peters <mischa at high5 dot nl>
|
|
// Copyright (c) 2022 High5!
|
|
// License Info: LICENSE.TXT
|
|
//
|
|
// File: viewlog.php
|
|
//
|
|
// Template File: viewlog.tpl
|
|
//
|
|
// Template Variables:
|
|
//
|
|
// log
|
|
//
|
|
// POST / GET Variables:
|
|
//
|
|
// domain
|
|
//
|
|
require_once './functions.inc.php';
|
|
include './languages/' . check_language() . '.lang';
|
|
|
|
$SESSID_USERNAME = check_session();
|
|
$ROLE = check_role();
|
|
$SESSID_USERNAME = $SESSID_USERNAME ?? ADMIN_EMAIL;
|
|
|
|
if ($ROLE == ADMIN_ROLE) {
|
|
$list_domains = list_domains();
|
|
$list_admins = list_admins();
|
|
} else {
|
|
$list_domains = list_domains($SESSID_USERNAME);
|
|
}
|
|
|
|
if ($_SERVER['REQUEST_METHOD'] == "GET") {
|
|
$domain = filter_input(INPUT_GET, 'domain', FILTER_VALIDATE_DOMAIN) ?? $list_domains[0]['domain'];
|
|
$domain_key = array_search($domain, array_column($list_domains, 'domain'));
|
|
$domain_exist = in_array($domain, array_column($list_domains, 'domain'));
|
|
|
|
if ($domain_exist) {
|
|
$dbh = pdo_connect();
|
|
$sth = $dbh->prepare("SELECT * FROM log WHERE domain=? ORDER BY timestamp DESC LIMIT 10");
|
|
$sth->bindParam(1, $domain, PDO::PARAM_STR);
|
|
$sth->execute();
|
|
$log = $sth->fetchAll();
|
|
}
|
|
}
|
|
include './templates/header.tpl';
|
|
include './templates/menu.tpl';
|
|
include './templates/viewlog.tpl';
|
|
include './templates/footer.tpl';
|
|
?>
|