Commit 584629b8 authored by William Paul Liggett's avatar William Paul Liggett

Added an admin login page. It doesn't do anything special yet.

parent d0835ad3
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>OpenVigilance Task: Admin Page</title>
<!-- Copyright (C) 2018 by William Paul Liggett (junktext@junktext.com)
This Source Code Form is subject to the terms of the Mozilla Public License (MPL), v. 2.0.
If a copy of the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/. -->
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="description" content="Administrative login to control various settings of the OpenVigilance Task tests." />
<link rel="stylesheet" type="text/css" href="css/style.css" />
</head>
<body>
<h1>OpenVigilance Task: Admin Page</h1>
<?php
// Used to display an HTML login form on first load or if the username and password was incorrect.
$login_form = '
<form action="admin" name="AdminLogon" method="post">
<label for="username">Username:</label>
<input type="text" name="username" id="username" />
<br />
<label for="password">Password:</label>
<input type="password" name="password" id="password" />
<br />
<input type="submit" value="Submit" />
</form>' . PHP_EOL;
// POST: Confirms if the administrative password is accurate after the <form> has been submitted.
if($_SERVER['REQUEST_METHOD'] === "POST") {
// Sets the $ov_admin_password_hash variable.
require_once "../../../../protected_site_configs/junktext.com/openvigilance_admin_password.php";
$error_msg = "";
$submitted_username = htmlspecialchars($_POST['username']);
$submitted_password = htmlspecialchars($_POST['password']);
// Determines if the login was valid or not.
if($submitted_username !== "ov_admin") {
$error_msg = "Error: The username is not valid on this system.";
}
else if(!password_verify($submitted_password, $ov_admin_password_hash)) {
$error_msg = "Error: The password is incorrect.";
}
// Checks to see whether to re-display the login <form>.
if($error_msg) {
echo "<p class='error_msg'>$error_msg</p>";
echo $login_form;
}
// Login successful!
else {
echo "Login successful!";
}
}
// GET: The page upon first load, before the <form> has been submitted.
else {
// Displays the HTML login <form>.
echo $login_form;
}
?>
</body>
</html>
......@@ -71,4 +71,21 @@ h1 {
/* Used to add or remove this hidden class to hide or show the random letters. */
.hidden {
display: none;
}
/* For styles affecting a <form>. */
label {
width: 5rem;
margin-right: 1.5rem;
float: left;
display: inline-block;
}
input[type = "text"], input[type = "password"] {
width: 8rem;
display: inline-block;
}
.error_msg {
font-weight: bold;
}
\ No newline at end of file
......@@ -7,6 +7,7 @@
This Source Code Form is subject to the terms of the Mozilla Public License (MPL), v. 2.0.
If a copy of the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/. -->
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="description" content="Sustained attention tasks using random letters of O, D, and backwards D to help determine what influences a person's reaction time." />
<link rel="stylesheet" type="text/css" href="css/style.css" />
</head>
<body>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment