From ba8fc89347de06ea4929faea6a63239f24c8ba2d Mon Sep 17 00:00:00 2001 From: Christian Boltz Date: Tue, 15 Feb 2011 21:59:03 +0000 Subject: [PATCH] Preparation for removing the $username parameter from db_log() (will be detected by authentication_get_username() instead) scripts/postfixadmin-cli.php: - define ("POSTFIXADMIN_CLI", 1) (we have no session running and need a way to tell authentication_get_username() that this is a CLI access) functions.inc.php: - authentication_get_username(): check for POSTFIXADMIN_CLI constant, return 'CLI' if set (hmmm, do we need a similar thing for XMLRPC?) - db_log(): override $username parameter with authentication_get_username() (removing it from function parameters will be my next big commit) git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@965 a1433add-5e2c-0410-b055-b7f2511e0802 --- functions.inc.php | 7 +++++++ scripts/postfixadmin-cli.php | 1 + 2 files changed, 8 insertions(+) diff --git a/functions.inc.php b/functions.inc.php index e9e356b2..95aab4f2 100644 --- a/functions.inc.php +++ b/functions.inc.php @@ -27,6 +27,11 @@ $version = '2.4 develop'; function authentication_get_username() { global $CONF; + + if (defined('POSTFIXADMIN_CLI')) { + return 'CLI'; + } + if (!isset($_SESSION['sessid'])) { header ("Location: " . $CONF['postfix_admin_url'] . "/login.php"); exit(0); @@ -1828,6 +1833,8 @@ function db_log ($username,$domain,$action,$data) global $table_log; $REMOTE_ADDR = getRemoteAddr(); + $username = authentication_get_username(); + $action_list = array( 'create_alias', 'edit_alias', 'edit_alias_state', 'delete_alias', 'create_mailbox', 'edit_mailbox', 'edit_mailbox_state', 'delete_mailbox', diff --git a/scripts/postfixadmin-cli.php b/scripts/postfixadmin-cli.php index c7f80de7..76b1d89e 100644 --- a/scripts/postfixadmin-cli.php +++ b/scripts/postfixadmin-cli.php @@ -557,6 +557,7 @@ class PostfixAdmin { } +define ("POSTFIXADMIN_CLI", 1); $dispatcher = new PostfixAdmin($argv);