Commit ffafd1fe60edd578f3e84176be2ea20e0ec75851

Authored by michael
1 parent bb962473

debug logging, changed group lookup to handle multiple groups


git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@200 c91229c3-7414-0410-bfa2-8a42b809f60b
Showing 1 changed file with 16 additions and 6 deletions
lib/Session.inc
@@ -27,7 +27,8 @@ class Session { @@ -27,7 +27,8 @@ class Session {
27 $_SESSION["userID"] = $userID; 27 $_SESSION["userID"] = $userID;
28 28
29 // lookup group id and add to session 29 // lookup group id and add to session
30 - $_SESSION["groupID"] = owlusergroup($userID); 30 + $_SESSION["groupID"] = lookupGroupIDs($userID);
  31 + $default->log->debug("Session::create groupids=" . arrayToString($_SESSION["groupID"]));
31 32
32 // use the PHP generated session id 33 // use the PHP generated session id
33 $sessionID = session_id(); 34 $sessionID = session_id();
@@ -87,9 +88,9 @@ class Session { @@ -87,9 +88,9 @@ class Session {
87 function verify() { 88 function verify() {
88 global $default, $lang_sesstimeout, $lang_sessinuse, $lang_err_sess_notvalid; 89 global $default, $lang_sesstimeout, $lang_sessinuse, $lang_err_sess_notvalid;
89 90
90 - getprefs();  
91 - 91 + session_start();
92 $sessionID = session_id(); 92 $sessionID = session_id();
  93 + $default->log->debug("Session::verify retrieved sessionID=$sessionID");
93 if (strlen($sessionID) > 0) { 94 if (strlen($sessionID) > 0) {
94 95
95 // initialise return status 96 // initialise return status
@@ -99,16 +100,21 @@ class Session { @@ -99,16 +100,21 @@ class Session {
99 $sql = new Owl_DB; 100 $sql = new Owl_DB;
100 $sql->query("select * from $default->owl_sessions_table where session_id = '$sessionID'"); 101 $sql->query("select * from $default->owl_sessions_table where session_id = '$sessionID'");
101 $numrows = $sql->num_rows($sql); 102 $numrows = $sql->num_rows($sql);
102 - $time = time();  
103 103
104 // found one match 104 // found one match
105 - if ($numrows == "1") { 105 + if ($numrows == 1) {
  106 + $default->log->debug("Session::verify found session in db");
106 while($sql->next_record()) { 107 while($sql->next_record()) {
107 $ip = $this->getClientIP(); 108 $ip = $this->getClientIP();
108 // check that ip matches 109 // check that ip matches
109 if ($ip == $sql->f("ip")) { 110 if ($ip == $sql->f("ip")) {
110 // now check if the timeout has been exceeded 111 // now check if the timeout has been exceeded
111 - if(($time - strtotime($sql->f("lastused"))) <= $default->owl_timeout) { 112 + $lastused = $sql->f("lastused");
  113 + $default->log->debug("Session::verify lastused=$lastused; str=" . strtotime($lastused));
  114 + $default->log->debug("Session::verify current time=" . time());
  115 + $diff = time() - strtotime($lastused);
  116 + $default->log->debug("Session::verify timeout = " . $default->owl_timeout . "; diff=$diff");
  117 + if((time() - strtotime($lastused)) <= $default->owl_timeout) {
112 // session has been verified, update status 118 // session has been verified, update status
113 $sessionStatus["status"] = 1; 119 $sessionStatus["status"] = 1;
114 // only set the userID if its not in the array already 120 // only set the userID if its not in the array already
@@ -118,6 +124,7 @@ class Session { @@ -118,6 +124,7 @@ class Session {
118 // lookup the user 124 // lookup the user
119 $sql->query("select * from $default->owl_users_table where id = '".$sessionStatus["userid"]."'"); 125 $sql->query("select * from $default->owl_users_table where id = '".$sessionStatus["userid"]."'");
120 while($sql->next_record()) { 126 while($sql->next_record()) {
  127 + // FIXME: this much change to look at users_groups_link
121 // only set the groupID if its not in the array already 128 // only set the groupID if its not in the array already
122 if (!$sessionStatus["groupID"]) { 129 if (!$sessionStatus["groupID"]) {
123 $sessionStatus["groupID"] = $sql->f("group_id"); 130 $sessionStatus["groupID"] = $sql->f("group_id");
@@ -140,10 +147,13 @@ class Session { @@ -140,10 +147,13 @@ class Session {
140 } 147 }
141 } 148 }
142 } else { 149 } else {
  150 + $default->log->error("Session::verify session not in db");
143 // there is no session 151 // there is no session
144 return false; 152 return false;
145 } 153 }
146 // return the array 154 // return the array
  155 + $output = "Session::verify returning sessionStatus[\"status\"]=" . $sessionStatus["status"];
  156 + $default->log->debug($output);
147 return $sessionStatus; 157 return $sessionStatus;
148 } 158 }
149 159