3 * Copyright (C) 2003-2004 Polytechnique.org
4 * http://opensource.polytechnique.org/
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 require_once 'diogenes/diogenes.core.logger.inc.php';
24 /** Class for logging WebDAV activity.
26 * The difference with DiogenesCoreLogger is that we do not have
27 * PHP sessions in WebDAV mode so we need a small hack to avoid creating
28 * a new 'session' entry for each operation.
30 class DiogenesWebDAVLogger
extends DiogenesCoreLogger
{
32 /** is this a new WebDAV 'session' ? */
35 /** WebDAV 'session' duration in seconds */
36 var $sessionlength = 1800;
38 /** The constructor, creates a new entry in the sessions table
40 * @param $uid the id of the logged user
41 * @param $auth authentication method for the logged user
42 * @param $username the username of the logged user
45 function DiogenesWebDAVLogger($uid,$auth,$username) {
48 $this->DiogenesCoreLogger($uid,'',$auth,'');
50 if ($this->newsession
) {
51 $this->log("auth_ok","{$username}@WebDAV");
56 /** Try to pickup an existing session, otherwise create a new entry
58 * @param $uid the id of the logged user
59 * @param $suid the id of the administrator who has just su'd to the user
60 * @param $auth authentication method for the logged user
61 * @param $sauth authentication method for the su'er
62 * @return session the session id
64 function writeSession($uid,$suid,$auth,$sauth) {
67 // we look for a session with the same user, auth and browser that is less
68 // than $sessionlength seconds old
69 $browser = (isset($_SERVER['HTTP_USER_AGENT']) ?
$_SERVER['HTTP_USER_AGENT'] : '');
70 $stime = date("YmdHis",time()-$this->sessionlength
);
71 $res = $globals->db
->query("select id from {$this->table_sessions} where uid='$uid' and auth='$auth' and browser='$browser' and start > $stime");
73 if (list($session) = mysql_fetch_row($res)) {
74 // we have an existing session
75 $this->newsession
= false
;
77 // we do not have an existing session
78 $this->newsession
= true
;
79 $session = parent
::writeSession($uid,$suid,$auth,$sauth);
81 mysql_free_result($res);