Commit e5a77c7cbf0320a79ecb7b10ae6abf5d3658c145

Authored by Michael Joseph
1 parent 0d329e09

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 27 $_SESSION["userID"] = $userID;
28 28  
29 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 33 // use the PHP generated session id
33 34 $sessionID = session_id();
... ... @@ -87,9 +88,9 @@ class Session {
87 88 function verify() {
88 89 global $default, $lang_sesstimeout, $lang_sessinuse, $lang_err_sess_notvalid;
89 90  
90   - getprefs();
91   -
  91 + session_start();
92 92 $sessionID = session_id();
  93 + $default->log->debug("Session::verify retrieved sessionID=$sessionID");
93 94 if (strlen($sessionID) > 0) {
94 95  
95 96 // initialise return status
... ... @@ -99,16 +100,21 @@ class Session {
99 100 $sql = new Owl_DB;
100 101 $sql->query("select * from $default->owl_sessions_table where session_id = '$sessionID'");
101 102 $numrows = $sql->num_rows($sql);
102   - $time = time();
103 103  
104 104 // found one match
105   - if ($numrows == "1") {
  105 + if ($numrows == 1) {
  106 + $default->log->debug("Session::verify found session in db");
106 107 while($sql->next_record()) {
107 108 $ip = $this->getClientIP();
108 109 // check that ip matches
109 110 if ($ip == $sql->f("ip")) {
110 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 118 // session has been verified, update status
113 119 $sessionStatus["status"] = 1;
114 120 // only set the userID if its not in the array already
... ... @@ -118,6 +124,7 @@ class Session {
118 124 // lookup the user
119 125 $sql->query("select * from $default->owl_users_table where id = '".$sessionStatus["userid"]."'");
120 126 while($sql->next_record()) {
  127 + // FIXME: this much change to look at users_groups_link
121 128 // only set the groupID if its not in the array already
122 129 if (!$sessionStatus["groupID"]) {
123 130 $sessionStatus["groupID"] = $sql->f("group_id");
... ... @@ -140,10 +147,13 @@ class Session {
140 147 }
141 148 }
142 149 } else {
  150 + $default->log->error("Session::verify session not in db");
143 151 // there is no session
144 152 return false;
145 153 }
146 154 // return the array
  155 + $output = "Session::verify returning sessionStatus[\"status\"]=" . $sessionStatus["status"];
  156 + $default->log->debug($output);
147 157 return $sessionStatus;
148 158 }
149 159  
... ...