From e7d80192e9fd7293f0d37c606365428074d1b95f Mon Sep 17 00:00:00 2001 From: Christian Boltz Date: Tue, 21 Aug 2007 23:00:17 +0000 Subject: [PATCH] - merge viewlog.php and admin/viewlog.php git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@45 a1433add-5e2c-0410-b055-b7f2511e0802 --- admin/viewlog.php | 42 ++---------------------------------------- viewlog.php | 27 ++++++++++++++++++--------- 2 files changed, 20 insertions(+), 49 deletions(-) diff --git a/admin/viewlog.php b/admin/viewlog.php index 329886b1..d3da6109 100644 --- a/admin/viewlog.php +++ b/admin/viewlog.php @@ -18,47 +18,9 @@ // // fDomain // -require ("../variables.inc.php"); -require ("../config.inc.php"); -require ("../functions.inc.php"); -include ("../languages/" . check_language () . ".lang"); -$SESSID_USERNAME = check_session (); -(!check_admin($SESSID_USERNAME) ? header("Location: " . $CONF['postfix_admin_url'] . "/main.php") && exit : '1'); +$incpath = ".."; +require("../viewlog.php"); -$list_domains = list_domains (); - -if ($_SERVER['REQUEST_METHOD'] == "GET") -{ - if ((is_array ($list_domains) and sizeof ($list_domains) > 0)) $fDomain = $list_domains[0]; -} -else -{ - if (isset ($_POST['fDomain'])) $fDomain = escape_string ($_POST['fDomain']); -} - -$query = "SELECT timestamp,username,domain,action,substring(data from 1 for 36) as data FROM $table_log WHERE domain='$fDomain' ORDER BY timestamp DESC LIMIT 10"; -if ('pgsql'==$CONF['database_type']) -{ - $query = "SELECT extract(epoch from timestamp) as timestamp,username,domain,action,substring(data from 1 for 36) as data FROM $table_log WHERE domain='$fDomain' ORDER BY timestamp DESC LIMIT 10"; -} - -$result = db_query ($query); -if ($result['rows'] > 0) -{ - while ($row = db_array ($result['result'])) - { - if ('pgsql'==$CONF['database_type']) - { - $row['timestamp']=gmstrftime('%c %Z',$row['timestamp']); - } - $tLog[] = $row; - } -} - -include ("../templates/header.tpl"); -include ("../templates/admin_menu.tpl"); -include ("../templates/viewlog.tpl"); -include ("../templates/footer.tpl"); /* vim: set expandtab softtabstop=3 tabstop=3 shiftwidth=3: */ ?> diff --git a/viewlog.php b/viewlog.php index 8d78cb1f..015521d2 100644 --- a/viewlog.php +++ b/viewlog.php @@ -18,10 +18,13 @@ // // fDomain // -require ("./variables.inc.php"); -require ("./config.inc.php"); -require ("./functions.inc.php"); -include ("./languages/" . check_language () . ".lang"); + +if (!isset($incpath)) $incpath = '.'; + +require ("$incpath/variables.inc.php"); +require ("$incpath/config.inc.php"); +require ("$incpath/functions.inc.php"); +include ("$incpath/languages/" . check_language () . ".lang"); $SESSID_USERNAME = check_session(); if (!check_admin($SESSID_USERNAME)) @@ -42,7 +45,7 @@ if ($_SERVER['REQUEST_METHOD'] == "GET") die('Unknown request method'); } -if (!check_owner ($SESSID_USERNAME, $fDomain)) +if (! (check_owner ($SESSID_USERNAME, $fDomain) || check_admin($SESSID_USERNAME)) ) { $error = 1; $tMessage = $PALANG['pViewlog_result_error']; @@ -69,10 +72,16 @@ if ($error != 1) } } -include ("./templates/header.tpl"); -include ("./templates/menu.tpl"); -include ("./templates/viewlog.tpl"); -include ("./templates/footer.tpl"); +include ("$incpath/templates/header.tpl"); + +if (check_admin($SESSID_USERNAME)) { + include ("$incpath/templates/admin_menu.tpl"); +} else { + include ("$incpath/templates/menu.tpl"); +} + +include ("$incpath/templates/viewlog.tpl"); +include ("$incpath/templates/footer.tpl"); /* vim: set expandtab softtabstop=3 tabstop=3 shiftwidth=3: */ ?>