ILIAS  Release_4_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
sessioncheck.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
4 // jump to setup if ILIAS is not installed
5 if(!file_exists(getcwd().'/ilias.ini.php'))
6 {
7  header('Location: ./setup/setup.php');
8  exit();
9 }
10 
11 require_once 'Services/Init/classes/class.ilInitialisation.php';
13 $ilInit->returnBeforeAuth(true);
14 $ilInit->initILIAS();
15 $ilInit->initLanguage();
16 
17 include_once 'Services/JSON/classes/class.ilJsonUtil.php';
18 
19 global $ilDB;
20 
21 $ilDB->setLimit(1);
22 $res = $ilDB->queryF('
23  SELECT data, last_remind_ts FROM usr_session
24  WHERE session_id = %s ORDER BY expires DESC',
25  array('text'),
26  array($_GET['session_id']));
27 $oRow = $ilDB->fetchObject($res);
28 
29 $response_data = array('remind' => false);
30 $currentTime = time();
31 
32 if(is_object($oRow))
33 {
34  $data = $oRow->data;
35 
36  $expiresTime = null;
37  $pattern = "idle\";i:";
38  if(($lft_pos = strpos($data, $pattern)) !== false)
39  {
40  $substr = substr($data, $lft_pos + strlen($pattern));
41  $pattern = ";";
42  if(($rgt_pos = strpos($substr, $pattern)) !== false)
43  {
44  $expiresTime = (int)substr($substr, 0, $rgt_pos);
45  }
46  }
47 
48  if($expiresTime === null)
49  {
51  exit();
52  }
53  else
54  {
55  $leadTime = $_GET['lead_time'];
56  $expiresTime += $ilClientIniFile->readVariable('session', 'expire');
57 
58  if($expiresTime >= $currentTime &&
59  $oRow->last_remind_ts <= $currentTime - $_GET['countDownTime'])
60  {
61  include_once 'Services/Calendar/classes/class.ilDate.php';
62  $date = new ilDateTime(time(),IL_CAL_UNIX);
63  $currentTimeTxt = $date->get(IL_CAL_FKT_DATE,'H:i:s', $_GET['timezone']);
64 
65  $ilDB->manipulateF('
66  UPDATE usr_session SET last_remind_ts = %s WHERE session_id = %s',
67  array('integer', 'text'),
68  array($currentTime, $_GET['session_id']));
69 
70  $response_data = array(
71  'remind' => true,
72  'expiresInTimeX' => ilFormat::_secondsToString($leadTime, true),
73  'currentTime' => $currentTimeTxt,
74  );
75  }
76 
77  }
78 }
79 
81 exit();
82 ?>