Commit 494d2bbfdcd33e49ee35eca62f5222b90a21720b

Authored by michael
1 parent b0832f3a

updates for modified session handling


git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@59 c91229c3-7414-0410-bfa2-8a42b809f60b
Showing 1 changed file with 30 additions and 16 deletions
lib/control.inc
... ... @@ -9,7 +9,7 @@
9 9 * Licensed under the GNU GPL. For full terms see the file COPYING.
10 10 * @version $Revision$
11 11 * @author jam dms team
12   - * @package
  12 + * @package dmslib
13 13 */
14 14  
15 15 /**
... ... @@ -19,26 +19,40 @@
19 19 */
20 20 function redirect($url) {
21 21 // everything is relative to the root url
22   - $url = $url . $default->owl_root_url . "/";
23   - // if we have a session
24   - if (isset($uid->sessdata["sessid"])) {
25   - // check url for parameters and add sessid accordingly
26   - if (strstr($url, "?")) {
27   - $url = $url . "&sess=". $uid->sessdata["sessid"];
28   - } else {
29   - $url = $url . "?sess=". $uid->sessdata["sessid"];
30   - }
31   - }
  22 + $url = $default->owl_root_url . $url;
32 23 header("Location: $url");
33 24 }
34 25  
35 26 /**
36   - * Redirects to login if no session is present
  27 + * Generates a link via the control page, with the passed action
  28 + *
  29 + * @param $action
  30 + * the controller action to generate a link for
  31 + * @return the generated href
  32 + */
  33 + //TODO: maybe this should just be the url?
  34 +function generateLink($action) {
  35 + return "<a href=\"control.php?action=$action\">";
  36 +}
  37 +
  38 +/**
  39 + * Validates the session.
  40 + *
  41 + * @param $sessionID
  42 + * the session ID to validate
  43 + * @return
  44 + * true if the session is valid, else false.
37 45 */
38   -function checkSession($sessionID) {
39   - $sessionStatus = Owl_Session::verify($sessionID);
  46 +function checkSession() {
  47 + $sessionStatus = Session::verify();
  48 + // TODO: error handling in here with appropriate actions
  49 + // error messages are in $sessionStatus["errorMessage"]
40 50 switch ($sessionStatus["status"]) {
41   -
  51 + case 1 : // session verified, update lastused time
  52 + return true;
  53 + break;
  54 + case 2 : // session timed out
  55 + case 3 : // session already in use
  56 + return false;
42 57 }
43 58 }
44   -
... ...