fixed bugs that prevented proper grading.

This commit is contained in:
Joshua Ashton
2025-02-14 05:08:06 -07:00
parent fcbe71e62b
commit 6f63a4afb8
30 changed files with 95 additions and 87 deletions
View File
View File
View File
View File
+19
View File
@@ -0,0 +1,19 @@
<!doctype html>
<html lang="en">
<head>
<title>Dummy Title</title>
<link href="css/styles.css" type="text/css" rel="stylesheet">
<script src="js/index.js"></script>
</head>
<body>
<h1>Hello cruel world!</h1>
<form method="get">
<input name="something1" placeholder="Enter Something 1">
<input name="something2" placeholder="Enter Something 2">
<button <?php echo 'type="submit"'; ?>>Submit</button>
</form>
</body>
</html>
View File
View File
View File
View File
View File
View File
+26
View File
@@ -0,0 +1,26 @@
<!doctype html>
<html lang="en">
<head>
<title>Dummy Title</title>
<link href="css/styles.css" type="text/css" rel="stylesheet">
<script src="js/index.js"></script>
</head>
<body>
<h1>Hello cruel world!</h1>
<form method="get">
<input name="fname">
<input name="lname">
<button>Submit</button>
</form>
<?php
if (isset($_GET['fname'])) {
echo '<p>' . $_GET['fname'] . '</p>';
echo '<p>' . $_GET['lname'] . '</p>';
}
?>
</body>
</html>
View File
View File
+5
View File
@@ -0,0 +1,5 @@
<h1>beavisandbutthead</h1>
<h1>beavisandbutthead</h1>
<h1>beavisandbutthead</h1>
<h1>first:beavis</h1><h1>middle:and</h1><h1>first:butthead</h1>
<h1>first:beavis</h1><h1>:and</h1><h1>last:butthead</h1>
View File
View File
+4
View File
@@ -0,0 +1,4 @@
<h2>Fail</h2>
<h3>Match</h3>
<h4>Match</h4>
<h2>Match</h2>
View File
View File
+29
View File
@@ -0,0 +1,29 @@
<!doctype html>
<html lang="en">
<head>
<title>Dummy Title</title>
<link href="css/styles.css" type="text/css" rel="stylesheet">
<script src="js/index.js"></script>
</head>
<body>
<h1>Hello cruel world!</h1>
<?php
if (isset($_POST['fname'])) {
echo '<p>' . $_POST['fname'] . '</p>';
echo '<p>' . $_POST['lname'] . '</p>';
} else {
echo '
<form method="POST">
<input name="fname">
<input name="lname">
<button>Submit</button>
</form>
';
}
?>
</body>
</html>
View File
View File
+1 -8
View File
@@ -37,10 +37,6 @@ $poll_options = [
'Visual Studio Code', 'Visual Studio Code',
'XCode', 'XCode',
]; ];
if (isset($_POST['option'])) {
setcookie('form_submitted', 'true', time() + 3600, '/'); // Expires in 1 hour (adjust as needed)
}
?> ?>
<!doctype html> <!doctype html>
@@ -55,7 +51,7 @@ if (isset($_POST['option'])) {
<body> <body>
<h1>Poll</h1> <h1>Poll</h1>
<?php <?php
if (!isset($_POST['option']) && !isset($_COOKIE['form_submitted'])) { if (!isset($_POST['option'])) {
echo ' echo '
<h3>What is the best text editor or IDE?</h3> <h3>What is the best text editor or IDE?</h3>
<form method="post">'; <form method="post">';
@@ -76,9 +72,6 @@ if (!isset($_POST['option']) && !isset($_COOKIE['form_submitted'])) {
</form>'; </form>';
} else { } else {
echo "<h3>Thank you! Here's the results.</h3>"; echo "<h3>Thank you! Here's the results.</h3>";
if ($_COOKIE['form_submitted'])
displayChart();
else
updateDb($_POST['option']); updateDb($_POST['option']);
} }
?> ?>
-71
View File
@@ -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 -1
View File
@@ -1,7 +1,7 @@
<?php <?php
session_start(); session_start();
if ($_SESSION['access'] !== true) if ($_SESSION['new-access'] !== true)
header('Location: .'); header('Location: .');
include_once ('functions.php'); include_once ('functions.php');
+2 -2
View File
@@ -19,7 +19,7 @@ if ($_SERVER['HTTP_HOST'] == 'localhost') {
function getHome() function getHome()
{ {
echo '<h1>View Confidential Information</h1>'; echo '<h1>View Confidential Information</h1>';
if ($_SESSION['access'] !== true) { if ($_SESSION['new-access'] !== true) {
if (isset($_GET['error']) && $_GET['error'] === true) { if (isset($_GET['error']) && $_GET['error'] === true) {
echo ' echo '
<div class="card error"> <div class="card error">
@@ -103,7 +103,7 @@ function authUser()
$row = mysqli_fetch_assoc($results); $row = mysqli_fetch_assoc($results);
if ($row['password'] == $password) { if ($row['password'] == $password) {
$_SESSION['access'] = true; $_SESSION['new-access'] = true;
$_GET['file'] = 'includes/fbi.txt'; $_GET['file'] = 'includes/fbi.txt';
$_SESSION['username'] = $username; $_SESSION['username'] = $username;
} else { } else {
+2 -2
View File
@@ -12,12 +12,12 @@ echo '
function getLogoutButton() function getLogoutButton()
{ {
if ($_SESSION['access'] === true) if ($_SESSION['new-access'] === true)
return '<button name="logout" value="true" class="reset">Logout</button>'; return '<button name="logout" value="true" class="reset">Logout</button>';
} }
if (isset($_GET['logout'])) { if (isset($_GET['logout'])) {
$_SESSION['access'] = false; $_SESSION['new-access'] = false;
session_destroy(); session_destroy();
header('Location: .'); header('Location: .');
} }
+1 -1
View File
@@ -1,7 +1,7 @@
<?php <?php
session_start(); session_start();
if ($_SESSION['access'] !== true) if ($_SESSION['new-access'] !== true)
header('Location: .'); header('Location: .');
echo '<h1>YouTube Video</h1>'; echo '<h1>YouTube Video</h1>';
+4 -1
View File
@@ -1,5 +1,8 @@
<?php <?php
session_start(); session_start();
if ($_SESSION['new-access'] == true) {
$_SESSION['new-access'] = false;
}
require_once 'vendor/autoload.php'; require_once 'vendor/autoload.php';
$dotenv = Dotenv\Dotenv::createImmutable(__DIR__); $dotenv = Dotenv\Dotenv::createImmutable(__DIR__);
@@ -18,7 +21,7 @@ authUser();
</head> </head>
<body> <body>
<?php include ('includes/nav.php'); ?> <?php include_once ('includes/nav.php'); ?>
<div id="content"> <div id="content">
<?php <?php
$page = $_GET['page']; $page = $_GET['page'];