You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
94 lines
2.5 KiB
PHTML
94 lines
2.5 KiB
PHTML
18 years ago
|
<?php
|
||
17 years ago
|
/**
|
||
|
* Postfix Admin
|
||
|
*
|
||
|
* LICENSE
|
||
|
* This source file is subject to the GPL license that is bundled with
|
||
|
* this package in the file LICENSE.TXT.
|
||
|
*
|
||
11 years ago
|
* Further details on the project are available at http://postfixadmin.sf.net
|
||
17 years ago
|
*
|
||
|
* @version $Id$
|
||
|
* @license GNU GPL v2 or later.
|
||
|
*
|
||
|
* File: viewlog.php
|
||
|
* Shows entries from the log table to users.
|
||
|
*
|
||
15 years ago
|
* Template File: viewlog.tpl
|
||
17 years ago
|
*
|
||
|
* Template Variables:
|
||
|
*
|
||
|
* tLog
|
||
|
*
|
||
|
* Form POST \ GET Variables:
|
||
|
*
|
||
|
* fDomain
|
||
|
*/
|
||
18 years ago
|
|
||
17 years ago
|
require_once('common.php');
|
||
18 years ago
|
|
||
17 years ago
|
authentication_require_role('admin');
|
||
|
$SESSID_USERNAME = authentication_get_username();
|
||
|
if(authentication_has_role('global-admin')) {
|
||
18 years ago
|
$list_domains = list_domains ();
|
||
|
}
|
||
17 years ago
|
else {
|
||
|
$list_domains = list_domains_for_admin ($SESSID_USERNAME);
|
||
|
}
|
||
18 years ago
|
|
||
8 years ago
|
$fDomain = '';
|
||
8 years ago
|
$error = 0;
|
||
|
|
||
18 years ago
|
if ($_SERVER['REQUEST_METHOD'] == "GET")
|
||
|
{
|
||
|
if ((is_array ($list_domains) and sizeof ($list_domains) > 0)) $fDomain = $list_domains[0];
|
||
|
} elseif ($_SERVER['REQUEST_METHOD'] == "POST") {
|
||
|
if (isset ($_POST['fDomain'])) $fDomain = escape_string ($_POST['fDomain']);
|
||
|
} else {
|
||
|
die('Unknown request method');
|
||
|
}
|
||
|
|
||
17 years ago
|
if (! (check_owner ($SESSID_USERNAME, $fDomain) || authentication_has_role('global-admin')))
|
||
18 years ago
|
{
|
||
|
$error = 1;
|
||
14 years ago
|
flash_error($PALANG['pViewlog_result_error']);
|
||
18 years ago
|
}
|
||
|
|
||
14 years ago
|
// we need to initialize $tLog as an array!
|
||
|
$tLog = array();
|
||
|
|
||
18 years ago
|
if ($error != 1)
|
||
|
{
|
||
11 years ago
|
$table_log = table_by_key('log');
|
||
7 years ago
|
$page_size = isset($CONF['page_size']) ? intval($CONF['page_size']) : 35;
|
||
|
|
||
7 years ago
|
$query = "SELECT timestamp,username,domain,action,data FROM $table_log WHERE domain='$fDomain' ORDER BY timestamp DESC LIMIT $page_size";
|
||
11 years ago
|
if (db_pgsql()) {
|
||
7 years ago
|
$query = "SELECT extract(epoch from timestamp) as timestamp,username,domain,action,data FROM $table_log WHERE domain='$fDomain' ORDER BY timestamp DESC LIMIT $page_size";
|
||
18 years ago
|
}
|
||
|
$result=db_query($query);
|
||
|
if ($result['rows'] > 0)
|
||
|
{
|
||
|
while ($row = db_array ($result['result']))
|
||
|
{
|
||
11 years ago
|
if (db_pgsql()) {
|
||
18 years ago
|
$row['timestamp']=gmstrftime('%c %Z',$row['timestamp']);
|
||
|
}
|
||
|
$tLog[] = $row;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
15 years ago
|
for ($i = 0; $i < count ($tLog); $i++)
|
||
|
$tLog[$i]['action'] = $PALANG ['pViewlog_action_'.$tLog [$i]['action']];
|
||
|
|
||
9 years ago
|
$smarty->assign ('domain_list', $list_domains);
|
||
|
$smarty->assign ('domain_selected', $fDomain);
|
||
15 years ago
|
$smarty->assign ('tLog', $tLog,false);
|
||
15 years ago
|
$smarty->assign ('fDomain', $fDomain);
|
||
|
$smarty->assign ('smarty_template', 'viewlog');
|
||
|
$smarty->display ('index.tpl');
|
||
18 years ago
|
|
||
|
/* vim: set expandtab softtabstop=3 tabstop=3 shiftwidth=3: */
|
||
|
?>
|