Commit eb11adb59250c4e4d2809ccace09f15b3f8109db
1 parent
838caef8
added check for getActionFromPage failing (and reformatted)
git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@928 c91229c3-7414-0410-bfa2-8a42b809f60b
Showing
1 changed file
with
72 additions
and
65 deletions
presentation/login.php
| @@ -24,32 +24,33 @@ global $default; | @@ -24,32 +24,33 @@ global $default; | ||
| 24 | if ($loginAction == "loginForm") { | 24 | if ($loginAction == "loginForm") { |
| 25 | // TODO: build login form using PatternMainPage | 25 | // TODO: build login form using PatternMainPage |
| 26 | print "<html> | 26 | print "<html> |
| 27 | - <head> | ||
| 28 | - <link rel=\"stylesheet\" href=\"$default->owl_ui_url/stylesheet.php\"> | ||
| 29 | - </head> | ||
| 30 | - <body> | ||
| 31 | - <center> | ||
| 32 | - <img src=\"$default->owl_root_url/locale/$default->owl_lang/graphics/$default->logo\"> | ||
| 33 | - <br><br> | ||
| 34 | - <table>\n | ||
| 35 | - <form action=\"login.php\" method=\"post\"> | ||
| 36 | - <tr><td>Please enter your details below to login</td></tr> | ||
| 37 | - <tr><td></td></tr> | ||
| 38 | - <tr align=\"center\"><td><font color=\"red\">$errorMessage</font><tr><td> | ||
| 39 | - \t<tr><td>$lang_username:</td></tr> | ||
| 40 | - \t<tr><td><input type=\"text\" name=\"fUserName\" size=\"35\"></td></tr> | ||
| 41 | - \t<tr><td>$lang_password:</td></tr> | ||
| 42 | - <tr><td><input type=\"password\" name=\"fPassword\" size=\"35\"> | ||
| 43 | - </td></tr> | ||
| 44 | - <input type=\"hidden\" name=\"redirect\" value=\"$redirect\"/> | ||
| 45 | - <input type=\"hidden\" name=\"loginAction\" value=\"login\">\n | ||
| 46 | - <tr align=\"right\"><td><input type=\"image\" src=\"$default->owl_graphics_url/icons/login.jpg\" border=\"0\"></td></tr>\n | ||
| 47 | - </table> | ||
| 48 | - </center> | ||
| 49 | - </body> | ||
| 50 | - </html>"; | ||
| 51 | - | ||
| 52 | -} elseif ($loginAction == "login") { | 27 | + <head> |
| 28 | + <link rel=\"stylesheet\" href=\"$default->owl_ui_url/stylesheet.php\"> | ||
| 29 | + </head> | ||
| 30 | + <body> | ||
| 31 | + <center> | ||
| 32 | + <img src=\"$default->owl_root_url/locale/$default->owl_lang/graphics/$default->logo\"> | ||
| 33 | + <br><br> | ||
| 34 | + <table>\n | ||
| 35 | + <form action=\"login.php\" method=\"post\"> | ||
| 36 | + <tr><td>Please enter your details below to login</td></tr> | ||
| 37 | + <tr><td></td></tr> | ||
| 38 | + <tr align=\"center\"><td><font color=\"red\">$errorMessage</font><tr><td> | ||
| 39 | + \t<tr><td>$lang_username:</td></tr> | ||
| 40 | + \t<tr><td><input type=\"text\" name=\"fUserName\" size=\"35\"></td></tr> | ||
| 41 | + \t<tr><td>$lang_password:</td></tr> | ||
| 42 | + <tr><td><input type=\"password\" name=\"fPassword\" size=\"35\"> | ||
| 43 | + </td></tr> | ||
| 44 | + <input type=\"hidden\" name=\"redirect\" value=\"$redirect\"/> | ||
| 45 | + <input type=\"hidden\" name=\"loginAction\" value=\"login\">\n | ||
| 46 | + <tr align=\"right\"><td><input type=\"image\" src=\"$default->owl_graphics_url/icons/login.jpg\" border=\"0\"></td></tr>\n | ||
| 47 | + </table> | ||
| 48 | + </center> | ||
| 49 | + </body> | ||
| 50 | + </html>"; | ||
| 51 | + | ||
| 52 | +} | ||
| 53 | +elseif ($loginAction == "login") { | ||
| 53 | // set default url for login failure | 54 | // set default url for login failure |
| 54 | $url = $url . "login.php?loginAction=loginForm"; | 55 | $url = $url . "login.php?loginAction=loginForm"; |
| 55 | // if requirements are met and we have a username and password to authenticate | 56 | // if requirements are met and we have a username and password to authenticate |
| @@ -60,51 +61,57 @@ if ($loginAction == "loginForm") { | @@ -60,51 +61,57 @@ if ($loginAction == "loginForm") { | ||
| 60 | 61 | ||
| 61 | switch ($userDetails["status"]) { | 62 | switch ($userDetails["status"]) { |
| 62 | // bad credentials | 63 | // bad credentials |
| 63 | - case 0: | 64 | + case 0: |
| 64 | $url = $url . "&errorMessage=$lang_loginfail"; | 65 | $url = $url . "&errorMessage=$lang_loginfail"; |
| 65 | - break; | 66 | + break; |
| 66 | // successfully authenticated | 67 | // successfully authenticated |
| 67 | - case 1: | ||
| 68 | - // start the session | ||
| 69 | - $session = new Session(); | ||
| 70 | - $sessionID = $session->create($userDetails["userID"]); | ||
| 71 | - | ||
| 72 | - // initialise page-level authorisation array | ||
| 73 | - $_SESSION["pageAccess"] = NULL; | ||
| 74 | - | ||
| 75 | - // check for a location to forward to | ||
| 76 | - if (isset($redirect) && strlen(trim($redirect))>0) { | ||
| 77 | - // remove any params from redirect before looking up from sitemap | ||
| 78 | - if (strstr($redirect, "?")) { | ||
| 79 | - $queryString = substr($redirect, strpos($redirect, "?")+1, strlen($redirect)); | ||
| 80 | - $redirect = substr($redirect, 0, strpos($redirect, "?")); | ||
| 81 | - $default->log->debug("login.php redirect=$redirect; querystring=$queryString"); | ||
| 82 | - } | ||
| 83 | - | ||
| 84 | - // need to strip owl_root_url off $redirect | ||
| 85 | - if (strlen($default->owl_root_url) > 0) { | ||
| 86 | - $tmp = urldecode($redirect); | ||
| 87 | - $default->log->debug("login.php: substr($tmp, strpos($tmp, $default->owl_root_url)+strlen($default->owl_root_url), strlen($tmp))"); | ||
| 88 | - $redirect = substr($tmp, strpos($tmp, $default->owl_root_url)+strlen($default->owl_root_url), strlen($tmp)); | ||
| 89 | - $default->log->debug("login.php: redirect=$redirect"); | ||
| 90 | - } | 68 | + case 1: |
| 69 | + // start the session | ||
| 70 | + $session = new Session(); | ||
| 71 | + $sessionID = $session->create($userDetails["userID"]); | ||
| 91 | 72 | ||
| 92 | - $url = generateControllerUrl($default->siteMap->getActionFromPage($redirect)); | ||
| 93 | - // else redirect to the dashboard | ||
| 94 | - } else { | 73 | + // initialise page-level authorisation array |
| 74 | + $_SESSION["pageAccess"] = NULL; | ||
| 75 | + | ||
| 76 | + // check for a location to forward to | ||
| 77 | + if (isset($redirect) && strlen(trim($redirect))>0) { | ||
| 78 | + // remove any params from redirect before looking up from sitemap | ||
| 79 | + if (strstr($redirect, "?")) { | ||
| 80 | + $queryString = substr($redirect, strpos($redirect, "?")+1, strlen($redirect)); | ||
| 81 | + $redirect = substr($redirect, 0, strpos($redirect, "?")); | ||
| 82 | + $default->log->debug("login.php redirect=$redirect; querystring=$queryString"); | ||
| 83 | + } | ||
| 84 | + | ||
| 85 | + // need to strip owl_root_url off $redirect | ||
| 86 | + if (strlen($default->owl_root_url) > 0) { | ||
| 87 | + $tmp = urldecode($redirect); | ||
| 88 | + $default->log->debug("login.php: substr($tmp, strpos($tmp, $default->owl_root_url)+strlen($default->owl_root_url), strlen($tmp))"); | ||
| 89 | + $redirect = substr($tmp, strpos($tmp, $default->owl_root_url)+strlen($default->owl_root_url), strlen($tmp)); | ||
| 90 | + $default->log->debug("login.php: redirect=$redirect"); | ||
| 91 | + } | ||
| 92 | + $action = $default->siteMap->getActionFromPage($redirect); | ||
| 93 | + if ($action) { | ||
| 94 | + $url = generateControllerUrl($action); | ||
| 95 | + } else { | ||
| 96 | + // default to the dashboard | ||
| 95 | $url = generateControllerUrl("dashboard"); | 97 | $url = generateControllerUrl("dashboard"); |
| 96 | } | 98 | } |
| 97 | - break; | ||
| 98 | - // login disabled | ||
| 99 | - case 2: | ||
| 100 | - $url = $url . "&errorMessage=$lang_logindisabled"; | ||
| 101 | - break; | 99 | + |
| 100 | + // else redirect to the dashboard if there is none | ||
| 101 | + } else { | ||
| 102 | + $url = generateControllerUrl("dashboard"); | ||
| 103 | + } | ||
| 104 | + break; | ||
| 105 | + // login disabled | ||
| 106 | + case 2: | ||
| 107 | + $url = $url . "&errorMessage=$lang_logindisabled"; | ||
| 108 | + break; | ||
| 102 | // too many sessions | 109 | // too many sessions |
| 103 | - case 3 : | ||
| 104 | - $url = $url . "&errorMessage=$lang_toomanysessions"; | ||
| 105 | - break; | ||
| 106 | - default : | ||
| 107 | - $url = $url . "&errorMessage=$lang_err_general"; | 110 | + case 3 : |
| 111 | + $url = $url . "&errorMessage=$lang_toomanysessions"; | ||
| 112 | + break; | ||
| 113 | + default : | ||
| 114 | + $url = $url . "&errorMessage=$lang_err_general"; | ||
| 108 | } | 115 | } |
| 109 | } else { | 116 | } else { |
| 110 | // didn't receive any login parameters, so redirect login form | 117 | // didn't receive any login parameters, so redirect login form |