4 require_once(
'Services/Authentication/classes/class.ilSessionControl.php');
5 require_once(
'Services/Authentication/classes/class.ilSessionStatistics.php');
6 require_once(
'Services/Authentication/classes/class.ilSessionIStorage.php');
77 $q =
"SELECT data FROM usr_session WHERE session_id = ".
78 $ilDB->quote($a_session_id,
"text");
79 $set = $ilDB->query($q);
80 $rec = $ilDB->fetchAssoc($set);
83 return (
string) $rec[
"data"];
96 $query =
'SELECT expires FROM usr_session WHERE session_id = '.
97 $ilDB->quote($a_session_id,
'text');
101 return (
int)
$row->expires;
115 global
$ilDB, $ilClientIniFile;
117 if (self::isWebAccessWithoutSessionEnabled())
129 "user_id" =>
array(
"integer", (
int)
$_SESSION[
'_authsession_user_id']),
130 "expires" =>
array(
"integer", self::getExpireValue()),
131 "data" =>
array(
"clob", $a_data),
132 "ctime" =>
array(
"integer", $now),
133 "type" =>
array(
"integer", (
int) $_SESSION[
"SessionType"])
135 if ($ilClientIniFile->readVariable(
"session",
"save_ip"))
137 $fields[
"remote_addr"] =
array(
"text",
$_SERVER[
"REMOTE_ADDR"]);
142 $ilDB->update(
"usr_session", $fields,
143 array(
"session_id" =>
array(
"text", $a_session_id)));
147 $fields[
"session_id"] =
array(
"text", $a_session_id);
148 $fields[
"createtime"] =
array(
"integer", $now);
150 $ilDB->insert(
"usr_session", $fields);
153 $type = $fields[
"type"][1];
157 $type, $fields[
"createtime"][1], $fields[
"user_id"][1]);
165 self::_destroyExpiredSessions();
182 if (! $a_session_id) {
187 $q =
"SELECT 1 FROM usr_session WHERE session_id = " . $ilDB->quote($a_session_id,
"text");
188 $set = $ilDB->query($q);
190 return $ilDB->numRows($set) > 0;
200 static function _destroy($a_session_id, $a_closing_context = null, $a_expired_at = null)
204 if(!$a_closing_context)
206 $a_closing_context = self::$closing_context;
212 if(!is_array($a_session_id))
214 $q =
"DELETE FROM usr_session WHERE session_id = ".
215 $ilDB->quote($a_session_id,
"text");
222 $a_session_id = array_keys($a_session_id);
224 $q =
"DELETE FROM usr_session WHERE ".
225 $ilDB->in(
"session_id", $a_session_id,
"",
"text");
230 $ilDB->manipulate($q);
244 $q =
"DELETE FROM usr_session WHERE user_id = ".
245 $ilDB->quote($a_user_id,
"integer");
246 $ilDB->manipulate($q);
258 $q =
"SELECT session_id,expires FROM usr_session WHERE expires < ".
259 $ilDB->quote(
time(),
"integer");
260 $res = $ilDB->query($q);
262 while(
$row = $ilDB->fetchAssoc(
$res))
264 $ids[
$row[
"session_id"]] = $row[
"expires"];
268 self::_destroy($ids, self::SESSION_CLOSE_EXPIRE,
true);
285 $new_session = $a_session_id;
288 $new_session = md5($new_session);
289 $q =
"SELECT * FROM usr_session WHERE ".
290 "session_id = ".$ilDB->quote($new_session,
"text");
291 $res = $ilDB->query($q);
292 }
while($ilDB->fetchAssoc(
$res));
294 $query =
"SELECT * FROM usr_session ".
295 "WHERE session_id = ".$ilDB->quote($a_session_id,
"text");
298 while (
$row = $ilDB->fetchObject(
$res))
320 if( $fixedMode || $ilSetting->get(
'session_handling_type', self::SESSION_HANDLING_FIXED) == self::SESSION_HANDLING_FIXED )
323 return time() + self::getIdleValue($fixedMode);
325 else if( $ilSetting->get(
'session_handling_type', self::SESSION_HANDLING_FIXED) == self::SESSION_HANDLING_LOAD_DEPENDENT )
346 if( $fixedMode || $ilSetting->get(
'session_handling_type', self::SESSION_HANDLING_FIXED) == self::SESSION_HANDLING_FIXED )
349 return $ilClientIniFile->readVariable(
'session',
'expire');
351 else if( $ilSetting->get(
'session_handling_type', self::SESSION_HANDLING_FIXED) == self::SESSION_HANDLING_LOAD_DEPENDENT )
369 return self::getIdleValue(
true);
382 $query =
"SELECT DISTINCT user_id FROM usr_session" 383 .
" WHERE remote_addr = " . $ilDB->quote($a_ip,
"text")
384 .
" AND user_id > 0";
390 $users[] =
$row->user_id;
401 static function set($a_var, $a_val)
412 static function get($a_var)
435 self::$closing_context = (int)$a_context;
445 return self::$closing_context;
455 return (
bool)self::$enable_web_access_without_session;
static _destroy($a_session_id, $a_closing_context=null, $a_expired_at=null)
Destroy session.
static enableWebAccessWithoutSession($enable_web_access_without_session)
const SESSION_CLOSE_CAPTCHA
if((!isset($_SERVER['DOCUMENT_ROOT'])) OR(empty($_SERVER['DOCUMENT_ROOT']))) $_SERVER['DOCUMENT_ROOT']
const SESSION_CLOSE_INACTIVE
static $session_types_controlled
const SESSION_CLOSE_LOGIN
const SESSION_HANDLING_FIXED
static _destroyExpiredSessions()
Destroy expired sessions.
const SESSION_CLOSE_EXPIRE
static getExpireValue($fixedMode=false)
Returns the expiration timestamp in seconds.
static _exists($a_session_id)
Check whether session exists.
static destroySession($a_session_id)
Destroy session(s).
static clear($a_var)
Unset a value.
static _getData($a_session_id)
Get session data from table.
static createRawEntry($a_session_id, $a_session_type, $a_timestamp, $a_user_id)
Create raw data entry.
static _destroyByUserId($a_user_id)
Destroy session.
static getIdleValue($fixedMode=false)
Returns the idle time in seconds.
static isWebAccessWithoutSessionEnabled()
const SESSION_CLOSE_LIMIT
Create styles array
The data for the language used.
static lookupExpireTime($a_session_id)
Lookup expire time for a specific session ilDB $ilDB.
static $enable_web_access_without_session
const SESSION_CLOSE_PUBLIC
const SESSION_CLOSE_SIMUL
static _writeData($a_session_id, $a_data)
Write session data.
static _duplicate($a_session_id)
Duplicate session.
static setClosingContext($a_context)
set closing context (for statistics)
const SESSION_HANDLING_LOAD_DEPENDENT
static _getUsersWithIp($a_ip)
Get the active users with a specific remote ip address.
Add data(end) time
Method that wraps PHPs time in order to allow simulations with the workflow.
static getClosingContext()
get closing context (for statistics)
static getSessionExpireValue()
Returns the session expiration value.
static aggretateRaw($a_now)
Aggregate raw session data (older than given time)
const SESSION_CLOSE_FIRST
static closeRawEntry($a_session_id, $a_context=null, $a_expired_at=null)
Close raw data entry.