Commit 482298097042064883ba980aa1d7870138448456
1 parent
224b1531
changed to use default error handling
fixed datetime sql in session table git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@99 c91229c3-7414-0410-bfa2-8a42b809f60b
Showing
1 changed file
with
8 additions
and
7 deletions
lib/Session.inc
| ... | ... | @@ -33,7 +33,6 @@ class Session { |
| 33 | 33 | // use the PHP generated session id |
| 34 | 34 | $sessionID = session_id(); |
| 35 | 35 | |
| 36 | - | |
| 37 | 36 | // retrieve client ip |
| 38 | 37 | if(getenv("HTTP_CLIENT_IP")) { |
| 39 | 38 | $ip = getenv("HTTP_CLIENT_IP"); |
| ... | ... | @@ -45,10 +44,12 @@ class Session { |
| 45 | 44 | } |
| 46 | 45 | |
| 47 | 46 | $current = time(); |
| 47 | + | |
| 48 | 48 | // insert session information into db |
| 49 | 49 | $sql = new Owl_DB; |
| 50 | - $result = $sql->query("insert into $default->owl_sessions_table (id, user_id, lastused, ip) values ('$sessionID', '$userID', '$current', '$ip')"); | |
| 51 | - if(!'result') { | |
| 50 | + $query = "insert into $default->owl_sessions_table (id, user_id, lastused, ip) values ('$sessionID', '$userID', '" . date("Y-m-d H:i:s",$current) . "', '$ip')"; | |
| 51 | + $result = $sql->query($query); | |
| 52 | + if(!$result) { | |
| 52 | 53 | die("$lang_err_sess_write"); |
| 53 | 54 | } |
| 54 | 55 | |
| ... | ... | @@ -123,7 +124,7 @@ class Session { |
| 123 | 124 | // check that ip matches |
| 124 | 125 | if ($ip == $sql->f("ip")) { |
| 125 | 126 | // if timeout not exceeded |
| 126 | - if(($time - $sql->f("lastused")) <= $default->owl_timeout) { | |
| 127 | + if(($time - strtotime($sql->f("lastused"))) <= $default->owl_timeout) { | |
| 127 | 128 | // set verified status |
| 128 | 129 | $verified["status"] = 1; |
| 129 | 130 | // update userID? this should be the same value on the session |
| ... | ... | @@ -138,14 +139,14 @@ class Session { |
| 138 | 139 | $sql->query("update $default->owl_sessions_table set lastused = '$lastused' where user_id = '$userID'"); |
| 139 | 140 | |
| 140 | 141 | } else { |
| 141 | - // session time out status | |
| 142 | + // session timed out status | |
| 142 | 143 | $verified["status"] = 2; |
| 143 | - $verified["errorMessage"] = $lang_sesstimeout; | |
| 144 | + $default->errorMessage = $lang_sesstimeout; | |
| 144 | 145 | } |
| 145 | 146 | } else { |
| 146 | 147 | // session in use status |
| 147 | 148 | $verified["status"] = 3; |
| 148 | - $verified["errorMessage"] = $lang_sessinuse; | |
| 149 | + $default->errorMessage = $lang_sessinuse; | |
| 149 | 150 | } |
| 150 | 151 | } |
| 151 | 152 | } | ... | ... |