fixed bugs that prevented proper grading.
This commit is contained in:
@@ -1,71 +0,0 @@
|
||||
<?php
|
||||
$users = array('chuck' => 'roast', 'bob' => 'ross');
|
||||
$access = false;
|
||||
|
||||
if (isset($_POST['username']) && isset($_POST['password'])) {
|
||||
$username = $_POST['username'];
|
||||
$password = $_POST['password'];
|
||||
if (array_key_exists($username, $users) && $users[$username] === $password)
|
||||
$access = true;
|
||||
}
|
||||
|
||||
$file = 'fbi.txt';
|
||||
|
||||
function fileRead($file)
|
||||
{
|
||||
if (isset($_GET['fbi']))
|
||||
$file = 'fbi.txt';
|
||||
else
|
||||
$file = 'spies.txt';
|
||||
if ($access) {
|
||||
echo "reading $file";
|
||||
$fs = fopen($file, 'r');
|
||||
$string = fread($fs, filesize($file));
|
||||
$values = explode('||>><<||', $string);
|
||||
|
||||
echo '<table>';
|
||||
foreach ($values as $v) {
|
||||
list($a, $b) = explode(',', $v);
|
||||
|
||||
echo '
|
||||
<tr>
|
||||
<td>' . $a . '</td>
|
||||
<td>' . $b . '</td>
|
||||
</tr>
|
||||
';
|
||||
}
|
||||
echo '</table>';
|
||||
} else
|
||||
header('Location: .?access=false');
|
||||
}
|
||||
?>
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<title>Spies</title>
|
||||
<link href="css/styles.css" type="text/css" rel="stylesheet">
|
||||
<script src="js/index.js"></script>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<h1>View Confidential Information</h1>
|
||||
|
||||
<?php
|
||||
if ($access) {
|
||||
echo '<p>Access Granted</p>';
|
||||
|
||||
echo '
|
||||
<button name="fbi" type="submit" method="get">FBI</button>
|
||||
<button name="spies" type="submit" method="get">Spies</button>
|
||||
';
|
||||
|
||||
fileRead($file);
|
||||
}
|
||||
?>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
|
||||
<?php
|
||||
?>
|
||||
@@ -1,7 +1,7 @@
|
||||
<?php
|
||||
session_start();
|
||||
|
||||
if ($_SESSION['access'] !== true)
|
||||
if ($_SESSION['new-access'] !== true)
|
||||
header('Location: .');
|
||||
|
||||
include_once ('functions.php');
|
||||
|
||||
@@ -19,7 +19,7 @@ if ($_SERVER['HTTP_HOST'] == 'localhost') {
|
||||
function getHome()
|
||||
{
|
||||
echo '<h1>View Confidential Information</h1>';
|
||||
if ($_SESSION['access'] !== true) {
|
||||
if ($_SESSION['new-access'] !== true) {
|
||||
if (isset($_GET['error']) && $_GET['error'] === true) {
|
||||
echo '
|
||||
<div class="card error">
|
||||
@@ -103,7 +103,7 @@ function authUser()
|
||||
$row = mysqli_fetch_assoc($results);
|
||||
|
||||
if ($row['password'] == $password) {
|
||||
$_SESSION['access'] = true;
|
||||
$_SESSION['new-access'] = true;
|
||||
$_GET['file'] = 'includes/fbi.txt';
|
||||
$_SESSION['username'] = $username;
|
||||
} else {
|
||||
|
||||
@@ -12,12 +12,12 @@ echo '
|
||||
|
||||
function getLogoutButton()
|
||||
{
|
||||
if ($_SESSION['access'] === true)
|
||||
if ($_SESSION['new-access'] === true)
|
||||
return '<button name="logout" value="true" class="reset">Logout</button>';
|
||||
}
|
||||
|
||||
if (isset($_GET['logout'])) {
|
||||
$_SESSION['access'] = false;
|
||||
$_SESSION['new-access'] = false;
|
||||
session_destroy();
|
||||
header('Location: .');
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<?php
|
||||
session_start();
|
||||
|
||||
if ($_SESSION['access'] !== true)
|
||||
if ($_SESSION['new-access'] !== true)
|
||||
header('Location: .');
|
||||
|
||||
echo '<h1>YouTube Video</h1>';
|
||||
|
||||
+4
-1
@@ -1,5 +1,8 @@
|
||||
<?php
|
||||
session_start();
|
||||
if ($_SESSION['new-access'] == true) {
|
||||
$_SESSION['new-access'] = false;
|
||||
}
|
||||
require_once 'vendor/autoload.php';
|
||||
|
||||
$dotenv = Dotenv\Dotenv::createImmutable(__DIR__);
|
||||
@@ -18,7 +21,7 @@ authUser();
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<?php include ('includes/nav.php'); ?>
|
||||
<?php include_once ('includes/nav.php'); ?>
|
||||
<div id="content">
|
||||
<?php
|
||||
$page = $_GET['page'];
|
||||
|
||||
Reference in New Issue
Block a user