--- nfo/php/libs/org.netfrag.flib/Tracker/Session.php 2002/11/12 05:42:31 1.1
+++ nfo/php/libs/org.netfrag.flib/Tracker/Session.php 2002/12/01 22:32:45 1.2
@@ -1,8 +1,13 @@
// -------------------------------------------------------------------------
-// $Id: Session.php,v 1.1 2002/11/12 05:42:31 joko Exp $
+// $Id: Session.php,v 1.2 2002/12/01 22:32:45 joko Exp $
// -------------------------------------------------------------------------
// $Log: Session.php,v $
+// Revision 1.2 2002/12/01 22:32:45 joko
+// + bugfix: wrong object-hierarchy:
+// use $this->site->user->preLogout and/or $this->site->request->overrideReq...
+// + documented
+//
// Revision 1.1 2002/11/12 05:42:31 joko
// + initial checkin
//
@@ -25,12 +30,16 @@
function start() {
global $session_cfg;
$session_exists = $this->exists($session_cfg["session_id"]);
+ //print Dumper($session_exists);
if (!is_array($session_exists)) {
$this->add_session($session_cfg);
- }
- else {
+ } else {
$session_cfg["session_uid"] = $session_exists["session_uid"];
- if ($this->site->user->isLoggedOn()) { $this->validate_idle(); }
+ if ($this->site->user->isLoggedOn()) {
+ //print "val - idle
";
+ $this->validate_idle();
+ }
+ //print "val - session
";
$this->validate_session($session_cfg);
}
}
@@ -53,7 +62,6 @@
}
function bindUser() {
- global $uservars_db;
$session_id = session_id();
$session_tm = $this->exists($session_id);
$date = date('Y-m-d H:i:s', time());
@@ -78,7 +86,7 @@
connectdb();
$sql_exists = "SELECT session_uid,session_id FROM f_td_sessions WHERE session_id='$session_id'";
$res_exists = send_sql($sql_exists);
- if (!mysql_num_rows($res_exists)>0) {
+ if (!mysql_num_rows($res_exists) > 0) {
return 0;
}
else {
@@ -88,38 +96,40 @@
}
function validate_idle() {
- global $cfg, $site, $site_state;
+
+ //global $cfg, $site, $site_state;
+ global $cfg, $site_state;
$session_id = session_id();
// get "max_idle_time"-time from database
$sql = "SELECT pvalue FROM td_global_private WHERE pname='max_idle_time'";
$res = send_sql($sql);
- $row = mysql_fetch_array($res,MYSQL_ASSOC);
- $max_idle_time = $row[pvalue];
- // use a default idle-time of half an hour if database-value is empty
- if (!$max_idle_time) $max_idle_time = 60 * 30;
-
+ $row = mysql_fetch_array($res, MYSQL_ASSOC);
+ $max_idle_time = $row[pvalue];
+
+ // use a default idle-time of half an hour if database-value is empty
+ if (!$max_idle_time) $max_idle_time = 60 * 30;
// get last "access"-time from database
$sql_mus = "SELECT last_date FROM f_td_sessions WHERE session_id='$session_id'";
$res_mus = send_sql($sql_mus);
- $mus = mysql_fetch_array($res_mus,MYSQL_ASSOC);
+ $mus = mysql_fetch_array($res_mus, MYSQL_ASSOC);
// calculate idletime
- $time_now = time();
+ $time_now = time();
$last_date = strtotime($mus[last_date]);
- $max_idle_date = $last_date + $max_idle_time;
+ $max_idle_date = $last_date + $max_idle_time;
// check timeout
- if ($time_now > $max_idle_date) {
- // set autologout message
- $tpl= array( 'idle_time' => $max_idle_time / 60, );
- $site_state[message] = getlt('table/notify/autologout', $tpl);
- // throw user to (re)login-page
- //$site->redirect( getlink('/pub/login/') );
- $site->user->preLogout();
- $site->request->overrideRequestIdentifier('/home/logout/');
- }
+ if ($time_now > $max_idle_date) {
+ // set autologout message
+ $tpl = array( 'idle_time' => $max_idle_time / 60, );
+ $site_state[message] = getlt('table/notify/autologout', $tpl);
+ // throw user to (re)login-page
+ //$site->redirect( getlink('/pub/login/') );
+ $this->site->user->preLogout();
+ $site->site->request->overrideRequestIdentifier('/home/logout/');
+ }
}