a | b | |
---|
127 | 127 | | |
---|
128 | 128 | | endif; // $INCLUDED_SIGN_IN_PHP |
---|
129 | 129 | | ?> |
---|
... | |
---|
| 130 | + | |
---|
| 130 | + | |
---|
| 130 | + | ------- authentication page --- |
---|
| 130 | + | <?php |
---|
| 130 | + | |
---|
| 130 | + | $pathToRoot=dirname($_SERVER['SCRIPT_FILENAME'])."/"; |
---|
| 130 | + | include($pathToRoot."includes/phpheader.php"); |
---|
| 130 | + | include($pathToRoot."includes/httpheader.php"); |
---|
| 130 | + | include($pathToRoot."includes/database.php"); |
---|
| 130 | + | |
---|
| 130 | + | // Clean the data collected from the user |
---|
| 130 | + | $appUsername = |
---|
| 130 | + | EscapeShellCmd(substr($HTTP_POST_VARS["formUsername"], 0, 25)); |
---|
| 130 | + | $appPassword = |
---|
| 130 | + | EscapeShellCmd(substr($HTTP_POST_VARS["formPassword"], 0, 25)); |
---|
| 130 | + | |
---|
| 130 | + | $authenticated = authenticateDatabaseUser($appUsername, $appPassword); |
---|
| 130 | + | if ($authenticated) |
---|
| 130 | + | { |
---|
| 130 | + | // Register the username |
---|
| 130 | + | $_SESSION["authenticatedUser"] = $appUsername; |
---|
| 130 | + | |
---|
| 130 | + | // Register access priviledges |
---|
| 130 | + | if (!empty($accessPriviledges)) |
---|
| 130 | + | $_SESSION["accessPrivs"] = implode(",", $accessPriviledges); |
---|
| 130 | + | |
---|
| 130 | + | $newURL = ""; |
---|
| 130 | + | |
---|
| 130 | + | // Deduce the URL to go to after authentication. If we aren't told, |
---|
| 130 | + | // just go to the main page |
---|
| 130 | + | if (array_key_exists('fromURL', $queryVars)) |
---|
| 130 | + | $newURL = $queryVars['fromURL']; |
---|
| 130 | + | else |
---|
| 130 | + | $newURL = $URLToRoot; |
---|
| 130 | + | |
---|
| 130 | + | // Relocate back to the desired page |
---|
| 130 | + | header("Location: ".$newURL); |
---|
| 130 | + | } |
---|
| 130 | + | else |
---|
| 130 | + | { |
---|
| 130 | + | // The authentication failed |
---|
| 130 | + | $_SESSION["sessionMessage"] = "Could not sign in as \"$appUsername\".<br />Please check the username and password and try again."; |
---|
| 130 | + | |
---|
| 130 | + | // Relocate back to the sign-in page |
---|
| 130 | + | header("Location: ".$URLToRoot."signin.php"); |
---|
| 130 | + | } |
---|
| 130 | + | ?> |
---|
... | |
---|