opensmtpdadmin/viewlog.php

53 lines
1.2 KiB
PHP
Raw Normal View History

2022-08-18 14:01:52 +02:00
<?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:
//
2022-09-04 13:10:23 +02:00
// log
2022-08-18 14:01:52 +02:00
//
2022-09-05 20:29:41 +02:00
// POST / GET Variables:
2022-08-18 14:01:52 +02:00
//
2022-09-04 13:10:23 +02:00
// domain
2022-08-18 14:01:52 +02:00
//
2022-09-04 13:10:23 +02:00
require_once './functions.inc.php';
include './languages/' . check_language() . '.lang';
2022-08-18 14:01:52 +02:00
$SESSID_USERNAME = check_session();
2022-09-06 13:56:05 +02:00
$ROLE = check_role($SESSID_USERNAME);
2022-09-05 20:29:41 +02:00
if ($ROLE == ADMIN_ROLE) {
2022-09-05 20:29:41 +02:00
$list_domains = list_domains();
} else {
$list_domains = list_domains($SESSID_USERNAME);
}
2022-08-18 14:01:52 +02:00
if ($_SERVER['REQUEST_METHOD'] == "GET") {
$domain = filter_input(INPUT_GET, 'domain', FILTER_VALIDATE_DOMAIN);
2022-09-04 16:04:56 +02:00
if (empty($domain) && count($list_domains) > 0) {
$domain = $list_domains[0]['domain'];
}
if (in_array($domain, array_column($list_domains, 'domain'))) {
$domain_key = array_search($domain, array_column($list_domains, 'domain'));
2022-09-04 20:50:21 +02:00
$dbh = pdo_connect();
2022-09-04 16:04:56 +02:00
$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();
}
2022-08-18 14:01:52 +02:00
}
2022-09-04 13:10:23 +02:00
include './templates/header.tpl';
include './templates/menu.tpl';
include './templates/viewlog.tpl';
include './templates/footer.tpl';
2022-08-18 14:01:52 +02:00
?>