* Admin: optional session-action column in access-log and sessions

also no longer update access-log in session-class destructor, as it fails with skipping permanent logging for WebDAV and others
This commit is contained in:
Ralf Becker 2019-12-14 13:09:22 +02:00
parent 06f8f7456d
commit 7b30bb7b0d
7 changed files with 37 additions and 41 deletions

View File

@ -5,9 +5,8 @@
* @link http://www.egroupware.org * @link http://www.egroupware.org
* @author Ralf Becker <RalfBecker-AT-outdoor-training.de> * @author Ralf Becker <RalfBecker-AT-outdoor-training.de>
* @package admin * @package admin
* @copyright (c) 2009-16 by Ralf Becker <RalfBecker-AT-outdoor-training.de> * @copyright (c) 2009-19 by Ralf Becker <RalfBecker-AT-outdoor-training.de>
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License * @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @version $Id$
*/ */
use EGroupware\Api; use EGroupware\Api;
@ -166,7 +165,7 @@ class admin_accesslog
'start' => 0, // IO position in list 'start' => 0, // IO position in list
'order' => 'li', // IO name of the column to sort after (optional for the sortheaders) 'order' => 'li', // IO name of the column to sort after (optional for the sortheaders)
'sort' => 'DESC', // IO direction of the sort: 'ASC' or 'DESC' 'sort' => 'DESC', // IO direction of the sort: 'ASC' or 'DESC'
//'default_cols' => // I columns to use if there's no user or default pref (! as first char uses all but the named columns), default all columns 'default_cols' => '!session_action', // I columns to use if there's no user or default pref (! as first char uses all but the named columns), default all columns
'csv_fields' => false, // I false=disable csv export, true or unset=enable it with auto-detected fieldnames, 'csv_fields' => false, // I false=disable csv export, true or unset=enable it with auto-detected fieldnames,
//or array with name=>label or name=>array('label'=>label,'type'=>type) pairs (type is a eT widget-type) //or array with name=>label or name=>array('label'=>label,'type'=>type) pairs (type is a eT widget-type)
'actions' => $this->get_actions($sessions_list), 'actions' => $this->get_actions($sessions_list),

View File

@ -176,7 +176,7 @@ app.classes.admin = AppJS.extend(
jQuery(this.ajax_target.node).empty(); jQuery(this.ajax_target.node).empty();
} }
this.egw.json( this.egw.json(
framework.activeApp.getMenuaction('ajax_exec'), framework.activeApp.getMenuaction('ajax_exec', _url),
// It's important that the context is null, or etemplate2 // It's important that the context is null, or etemplate2
// won't load the template properly // won't load the template properly
[_url], this._ajax_load_callback,null, true, this [_url], this._ajax_load_callback,null, true, this

View File

@ -14,6 +14,7 @@
<column disabled="@no_total" width="80"/> <column disabled="@no_total" width="80"/>
<column width="80"/> <column width="80"/>
<column width="40%"/> <column width="40%"/>
<column width="30%"/>
</columns> </columns>
<rows> <rows>
<row class="th"> <row class="th">
@ -26,6 +27,7 @@
<nextmatch-header label="Total" id="total"/> <nextmatch-header label="Total" id="total"/>
<nextmatch-sortheader label="Idle" id="session_dla"/> <nextmatch-sortheader label="Idle" id="session_dla"/>
<nextmatch-sortheader label="User-Agent" id="user_agent"/> <nextmatch-sortheader label="User-Agent" id="user_agent"/>
<nextmatch-header label="Action" id="session_action"/>
</row> </row>
<row class="row $row_cont[class]"> <row class="row $row_cont[class]">
<hbox> <hbox>
@ -42,6 +44,7 @@
<date-duration id="${row}[total]" readonly="true" options=",hm,24"/> <date-duration id="${row}[total]" readonly="true" options=",hm,24"/>
<date-since id="${row}[session_dla]" readonly="true"/> <date-since id="${row}[session_dla]" readonly="true"/>
<description statustext="$row_cont[user_agent]" id="${row}[os_browser]" class="admin_userAgent"/> <description statustext="$row_cont[user_agent]" id="${row}[os_browser]" class="admin_userAgent"/>
<description id="${row}[session_action]"/>
</row> </row>
</rows> </rows>
</grid> </grid>

View File

@ -286,7 +286,7 @@ var fw_browser = (function(){ "use strict"; return Class.extend(
jQuery(this.contentDiv).empty(); jQuery(this.contentDiv).empty();
var self_egw = egw(this.app.appName); var self_egw = egw(this.app.appName);
var req = self_egw.json( var req = self_egw.json(
this.app.getMenuaction('ajax_exec'), this.app.getMenuaction('ajax_exec', targetUrl),
[targetUrl], this.browse_callback,this, true, this [targetUrl], this.browse_callback,this, true, this
); );
req.sendRequest(); req.sendRequest();

View File

@ -12,7 +12,7 @@
----------------------------*/ ----------------------------*/
/** /**
* application class constructor * application class constructor
* *
* @param {type} _parentFw * @param {type} _parentFw
* @param {type} _appName * @param {type} _appName
* @param {type} _displayName * @param {type} _displayName
@ -59,8 +59,9 @@ function egw_fw_class_application(_parentFw, _appName, _displayName, _icon,
* lie inside the default egw instance. * lie inside the default egw instance.
* *
* @param {string} _fun is the function which shall be called on the server. * @param {string} _fun is the function which shall be called on the server.
* @param {string} _ajax_exec_url contains menuaction for _fun === 'ajax_exec'
*/ */
egw_fw_class_application.prototype.getMenuaction = function(_fun) egw_fw_class_application.prototype.getMenuaction = function(_fun, _ajax_exec_url)
{ {
var baseUrl = ''; var baseUrl = '';
var appName = 'home'; var appName = 'home';
@ -79,8 +80,11 @@ egw_fw_class_application.prototype.getMenuaction = function(_fun)
baseUrl = baseUrl + 'json.php?menuaction='; baseUrl = baseUrl + 'json.php?menuaction=';
} }
var menuaction = _ajax_exec_url ? _ajax_exec_url.match(/menuaction=([^&]+)/) : null;
// use template handler to call current framework, eg. pixelegg // use template handler to call current framework, eg. pixelegg
return baseUrl + appName + '.jdots_framework.' + _fun + '.template'; return baseUrl + appName + '.jdots_framework.' + _fun + '.template'+
(menuaction ? '.'+menuaction[1] : '');
}; };
/** /**

View File

@ -282,12 +282,6 @@ class Session
*/ */
function __destruct() function __destruct()
{ {
// write dla update on destruct, allows to modify session action by calling Session::set_action()
if (!isset($GLOBALS['egw_info']['flags']['no_dla_update']) || !$GLOBALS['egw_info']['flags']['no_dla_update'])
{
$this->update_dla(true);
}
self::encrypt($this->kp3); self::encrypt($this->kp3);
} }
@ -1301,7 +1295,7 @@ class Session
// allow xajax / notifications to not update the dla, so sessions can time out again // allow xajax / notifications to not update the dla, so sessions can time out again
if (!isset($GLOBALS['egw_info']['flags']['no_dla_update']) || !$GLOBALS['egw_info']['flags']['no_dla_update']) if (!isset($GLOBALS['egw_info']['flags']['no_dla_update']) || !$GLOBALS['egw_info']['flags']['no_dla_update'])
{ {
$this->update_dla(); $this->update_dla(true);
} }
elseif ($GLOBALS['egw_info']['flags']['currentapp'] == 'notifications') elseif ($GLOBALS['egw_info']['flags']['currentapp'] == 'notifications')
{ {
@ -1774,33 +1768,29 @@ class Session
private function update_dla($update_access_log=false) private function update_dla($update_access_log=false)
{ {
// This way XML-RPC users aren't always listed as xmlrpc.php // This way XML-RPC users aren't always listed as xmlrpc.php
if (!$update_access_log) if (isset($_GET['menuaction']))
{ {
if ($this->xmlrpc_method_called) list(, $action) = explode('.ajax_exec.template.', $_GET['menuaction']);
{
$action = $this->xmlrpc_method_called; if (empty($action)) $action = $_GET['menuaction'];
}
elseif (isset($_GET['menuaction']))
{
$action = $_GET['menuaction'];
}
else
{
$action = $_SERVER['PHP_SELF'];
// remove EGroupware path, if not installed in webroot
$egw_path = $GLOBALS['egw_info']['server']['webserver_url'];
if ($egw_path[0] != '/') $egw_path = parse_url($egw_path,PHP_URL_PATH);
if ($action == '/Microsoft-Server-ActiveSync')
{
$action .= '?Cmd='.$_GET['Cmd'].'&DeviceId='.$_GET['DeviceId'];
}
elseif ($egw_path)
{
list(,$action) = explode($egw_path,$action,2);
}
}
$this->set_action($action);
} }
else
{
$action = $_SERVER['PHP_SELF'];
// remove EGroupware path, if not installed in webroot
$egw_path = $GLOBALS['egw_info']['server']['webserver_url'];
if ($egw_path[0] != '/') $egw_path = parse_url($egw_path,PHP_URL_PATH);
if ($action == '/Microsoft-Server-ActiveSync')
{
$action .= '?Cmd='.$_GET['Cmd'].'&DeviceId='.$_GET['DeviceId'];
}
elseif ($egw_path)
{
list(,$action) = explode($egw_path,$action,2);
}
}
$this->set_action($action);
// update dla in access-log table, if we have an access-log row (non-anonymous session) // update dla in access-log table, if we have an access-log row (non-anonymous session)
if ($this->sessionid_access_log && $update_access_log && if ($this->sessionid_access_log && $update_access_log &&
// ignore updates (session creation is written) of *dav, avatar and thumbnail, due to possible high volume of updates // ignore updates (session creation is written) of *dav, avatar and thumbnail, due to possible high volume of updates

View File

@ -104,7 +104,7 @@ try {
'no_exception_handler' => true, // we already installed our own 'no_exception_handler' => true, // we already installed our own
// only log ajax requests which represent former GET requests or submits // only log ajax requests which represent former GET requests or submits
// cuts down updates to egw_access_log table // cuts down updates to egw_access_log table
'no_dla_update' => !preg_match('/(Etemplate::ajax_process_content|\.jdots_framework\.ajax_exec\.template)$/', $_GET['menuaction']), 'no_dla_update' => !preg_match('/(Etemplate::ajax_process_content|\.jdots_framework\.ajax_exec\.template)/', $_GET['menuaction']),
) )
); );
include_once('./header.inc.php'); include_once('./header.inc.php');