completed spies assignment.
This commit is contained in:
@@ -1,17 +0,0 @@
|
|||||||
<!doctype html>
|
|
||||||
<html lang="en">
|
|
||||||
|
|
||||||
<head>
|
|
||||||
<title>Palindrome Tester</title>
|
|
||||||
</head>
|
|
||||||
|
|
||||||
<body>
|
|
||||||
<h1>Palindrome Tester</h1>
|
|
||||||
<form action="palindrome.php" method="post">
|
|
||||||
<input type="text" name="input">
|
|
||||||
<input type="submit">
|
|
||||||
</form>
|
|
||||||
<?php echo $output; ?>
|
|
||||||
</body>
|
|
||||||
|
|
||||||
</html>
|
|
||||||
@@ -1,22 +0,0 @@
|
|||||||
<?php
|
|
||||||
if (isset($_GET['input']))
|
|
||||||
$input = $_GET['input'];
|
|
||||||
else
|
|
||||||
echo '<p>Enter something!</p';
|
|
||||||
|
|
||||||
$sanitized_input = sanitize_input($input);
|
|
||||||
if ($sanitized_input == strrev($sanitized_input))
|
|
||||||
$output = '<p>Is Palindrome</p>';
|
|
||||||
else
|
|
||||||
$output = '<p>Is Not Palindrome</p>';
|
|
||||||
|
|
||||||
function sanitize_input($input)
|
|
||||||
{
|
|
||||||
$invalid_chars = [' ', "'", '?', '/', '\\', '.', ','];
|
|
||||||
$output = strtolower($input);
|
|
||||||
$output = trim($output);
|
|
||||||
$output = str_replace($invalid_chars, '', $output);
|
|
||||||
|
|
||||||
return $output;
|
|
||||||
}
|
|
||||||
?>
|
|
||||||
@@ -1,84 +0,0 @@
|
|||||||
@import url('https://fonts.googleapis.com/css2?family=Ranchers&display=swap');
|
|
||||||
* {margin: 0; padding: 0; box-sizing: border-box; font-family: 'Ranchers', cursive; letter-spacing: 5px;}
|
|
||||||
nav > a:hover
|
|
||||||
{
|
|
||||||
opacity: .5;
|
|
||||||
}
|
|
||||||
nav > a
|
|
||||||
{
|
|
||||||
font-size: 75px;
|
|
||||||
text-decoration: none;
|
|
||||||
text-align: center;
|
|
||||||
margin: 20px;
|
|
||||||
display: block;
|
|
||||||
transition: opacity 500ms;
|
|
||||||
}
|
|
||||||
span.warning, span.message
|
|
||||||
{
|
|
||||||
text-align: center;
|
|
||||||
padding: 3px 5px 3px 10px;
|
|
||||||
display: inline-block;
|
|
||||||
border-radius: 3px;
|
|
||||||
}
|
|
||||||
span.warning {background-color: rgba(200,0,0,.5);}
|
|
||||||
span.message {background-color: rgba(0,200,0,.5);}
|
|
||||||
span.contrast {color: white;}
|
|
||||||
body{background-image: url('../img/watercolor.png');}
|
|
||||||
main
|
|
||||||
{
|
|
||||||
display: flex;
|
|
||||||
flex-wrap: wrap;
|
|
||||||
justify-content: space-around;
|
|
||||||
}
|
|
||||||
section
|
|
||||||
{
|
|
||||||
flex-basis: 30%;
|
|
||||||
padding: 20px;
|
|
||||||
margin: 5px;
|
|
||||||
border: 1px solid #777;
|
|
||||||
background-color: mediumpurple;
|
|
||||||
color: black;
|
|
||||||
border-radius: 5px;
|
|
||||||
box-shadow: 0 8px 6px -6px black;
|
|
||||||
}
|
|
||||||
h3
|
|
||||||
{
|
|
||||||
margin-bottom: 15px;
|
|
||||||
}
|
|
||||||
li
|
|
||||||
{
|
|
||||||
letter-spacing: 2px;
|
|
||||||
margin: 5px;
|
|
||||||
margin-left: 25px;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
input, select
|
|
||||||
{
|
|
||||||
padding: 8px;
|
|
||||||
margin: 5px auto;
|
|
||||||
height: 50px;
|
|
||||||
font-size: 25px;
|
|
||||||
display: inline-block;
|
|
||||||
}
|
|
||||||
select
|
|
||||||
{
|
|
||||||
padding: 0
|
|
||||||
}
|
|
||||||
form h2
|
|
||||||
{
|
|
||||||
text-align: center;
|
|
||||||
margin: 10px auto;
|
|
||||||
font-size: 30px;
|
|
||||||
margin-bottom: 50px;
|
|
||||||
}
|
|
||||||
form
|
|
||||||
{
|
|
||||||
display: block;
|
|
||||||
min-height: 400px;
|
|
||||||
margin: 20px auto;
|
|
||||||
background-color: lavender;
|
|
||||||
padding: 20px;
|
|
||||||
border-radius: 8px;
|
|
||||||
}
|
|
||||||
p.warning {text-align: center; margin: 20px auto; padding: 10px; background-color: rgba(150,0,0,.5); width: 75%; border-radius: 8px; color: white; font-size: 25px;}
|
|
||||||
Binary file not shown.
|
Before Width: | Height: | Size: 28 KiB |
@@ -1,29 +0,0 @@
|
|||||||
<?php
|
|
||||||
$numOfPals = 20;
|
|
||||||
?>
|
|
||||||
<!doctype html>
|
|
||||||
<html lang="en">
|
|
||||||
<head>
|
|
||||||
<title>Palindrome Stuff</title>
|
|
||||||
<link rel="stylesheet" href="css/style.css" type="text/css">
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<main>
|
|
||||||
<form action="palindrome.php" method="post">
|
|
||||||
<select name="pal-count">
|
|
||||||
<option value="" disabled selected hidden>How Many Palindromes?</option>
|
|
||||||
<?php
|
|
||||||
for ($x = 1; $x <=$numOfPals; $x++)
|
|
||||||
echo '<option value="'.$x.'">'.$x.' Palindrome'.($x==1 ? "" : "s").'</option>';
|
|
||||||
?>
|
|
||||||
</select>
|
|
||||||
<input type="text" name="search-word" placeholder="Enter a word">
|
|
||||||
<input type="submit">
|
|
||||||
<?php
|
|
||||||
if (isset($_GET['error']) && $_GET['error'] == "true")
|
|
||||||
echo'<p class="warning">Enter Something!</p>';
|
|
||||||
?>
|
|
||||||
</form>
|
|
||||||
</main>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
@@ -1,89 +0,0 @@
|
|||||||
<?php
|
|
||||||
$wordCounter = 0;
|
|
||||||
$displayPageContent = "";
|
|
||||||
|
|
||||||
function wordCountOutput($sw)
|
|
||||||
{
|
|
||||||
global $wordCounter;
|
|
||||||
echo "<section><p>There are $wordCounter instances of $sw on this site</p></section>";
|
|
||||||
}
|
|
||||||
function output($inputArray, $sw)
|
|
||||||
{
|
|
||||||
global $wordCounter;
|
|
||||||
$return = "";
|
|
||||||
foreach($inputArray as $input)
|
|
||||||
{
|
|
||||||
if(strpos(strtolower($input), $sw) !== false) $wordCounter++;
|
|
||||||
|
|
||||||
$return .= "<section><h3>Facts About \"$input\"</h3>";
|
|
||||||
$return .= "<ul>";
|
|
||||||
$return .= "<li> Palindrome: ".(isPalindrome($input) ? "<span class='message'>TRUE</span>" : "<span class='warning'>FALSE</span>")."</li>";
|
|
||||||
$return .= "<li> Number of Characters: <span class='contrast'>".strlen($input)."</span></li>";
|
|
||||||
$return .= "<li> Number of Words: <span class='contrast'>".str_word_count($input)."</span></li>";
|
|
||||||
$return .= "</ul></section>";
|
|
||||||
}
|
|
||||||
|
|
||||||
return $return;
|
|
||||||
}
|
|
||||||
|
|
||||||
function isPalindrome($phrase)
|
|
||||||
{
|
|
||||||
|
|
||||||
//removes spaces from phrase
|
|
||||||
$phrase = str_replace(" ", "", $phrase);
|
|
||||||
$phrase = str_replace("'", "", $phrase);
|
|
||||||
$phrase = str_replace("?", "", $phrase);
|
|
||||||
$phrase = str_replace("/", "", $phrase);
|
|
||||||
$phrase = str_replace("\\", "", $phrase);
|
|
||||||
$phrase = str_replace(".", "", $phrase);
|
|
||||||
$phrase = str_replace(",", "", $phrase);
|
|
||||||
|
|
||||||
//lower case the phrase
|
|
||||||
$phrase = strtolower($phrase);
|
|
||||||
|
|
||||||
//reverse phrase and assign to variable
|
|
||||||
$revPhrase = strrev($phrase);
|
|
||||||
|
|
||||||
//compare and return
|
|
||||||
if($revPhrase == $phrase) return true;
|
|
||||||
else return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!empty($_POST['search-word']) && !empty($_POST['pal-count']))
|
|
||||||
{
|
|
||||||
$searchWord = $_POST['search-word'];
|
|
||||||
$palCount = $_POST['pal-count'];
|
|
||||||
}
|
|
||||||
else header('location: .?error=true');
|
|
||||||
|
|
||||||
if (!isset($_POST['palindromes']))
|
|
||||||
{
|
|
||||||
$displayPageContent .= '<form method="post">';
|
|
||||||
$displayPageContent .= '<input type="hidden" name="search-word" value="'.$searchWord.'">';
|
|
||||||
$displayPageContent .= '<input type="hidden" name="pal-count" value="'.$palCount.'">';
|
|
||||||
for ($x=0;$x<$_POST['pal-count'];$x++)
|
|
||||||
$displayPageContent .= '<input name="palindromes[]"><br>';
|
|
||||||
|
|
||||||
$displayPageContent .= '<input type="submit">';
|
|
||||||
$displayPageContent .= '</form>';
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$inputs = $_POST['palindromes'];
|
|
||||||
$displayPageContent .= output($inputs, $searchWord);
|
|
||||||
$displayPageContent .= wordCountOutput($searchWord);
|
|
||||||
}
|
|
||||||
?>
|
|
||||||
<!doctype html>
|
|
||||||
<html lang="en">
|
|
||||||
<head>
|
|
||||||
<title>Palindrome Stuff</title>
|
|
||||||
<link rel="stylesheet" href="css/style.css" type="text/css">
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<nav><a href=".">Back Home</a></nav>
|
|
||||||
<main>
|
|
||||||
<?php echo $displayPageContent; ?>
|
|
||||||
</main>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
{
|
||||||
|
"name": "violet/spies",
|
||||||
|
"type": "project",
|
||||||
|
"autoload": {
|
||||||
|
"psr-4": {
|
||||||
|
"Violet\\Spies\\": "src/"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"require": {}
|
||||||
|
}
|
||||||
@@ -0,0 +1,136 @@
|
|||||||
|
* {
|
||||||
|
margin: 0;
|
||||||
|
padding: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
body {
|
||||||
|
/* Positioning */
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
|
||||||
|
/* Styling */
|
||||||
|
background-color: #bbedbe;
|
||||||
|
}
|
||||||
|
|
||||||
|
h1 {
|
||||||
|
/* Positioning */
|
||||||
|
width: 100%;
|
||||||
|
padding: 2vw;
|
||||||
|
|
||||||
|
/* Font */
|
||||||
|
font-size: 6vw;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
h3 {
|
||||||
|
font-size: 4vw;
|
||||||
|
}
|
||||||
|
|
||||||
|
h5 {
|
||||||
|
font-size: 2vw;
|
||||||
|
}
|
||||||
|
|
||||||
|
h1,
|
||||||
|
h3,
|
||||||
|
h5,
|
||||||
|
p,
|
||||||
|
input {
|
||||||
|
color: #0e3610;
|
||||||
|
}
|
||||||
|
|
||||||
|
form {
|
||||||
|
/* Form Shape */
|
||||||
|
width: 60%;
|
||||||
|
padding: 2.5vw 5vw 2.5vw 5vw;
|
||||||
|
|
||||||
|
/* Positioning */
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.row {
|
||||||
|
/* Row Shape */
|
||||||
|
width: 100%;
|
||||||
|
display: flex;
|
||||||
|
}
|
||||||
|
|
||||||
|
input {
|
||||||
|
/* Input Shape */
|
||||||
|
width: 50%;
|
||||||
|
padding: 1vw;
|
||||||
|
margin: 1vw;
|
||||||
|
border: none;
|
||||||
|
border-radius: 18px;
|
||||||
|
|
||||||
|
/* Styling */
|
||||||
|
background-color: #f1fbf2;
|
||||||
|
|
||||||
|
/* Font */
|
||||||
|
font-size: 1vw;
|
||||||
|
font-weight: 400;
|
||||||
|
}
|
||||||
|
|
||||||
|
button {
|
||||||
|
/* Button Shape */
|
||||||
|
width: 60%;
|
||||||
|
padding: 1vw;
|
||||||
|
margin: 1vw;
|
||||||
|
border: none;
|
||||||
|
border-radius: 18px;
|
||||||
|
|
||||||
|
/* Font */
|
||||||
|
color: white;
|
||||||
|
font-size: 1vw;
|
||||||
|
font-weight: 600;
|
||||||
|
|
||||||
|
/* Transition for hover */
|
||||||
|
transition-duration: 500ms;
|
||||||
|
|
||||||
|
background-color: #1c6b20;
|
||||||
|
}
|
||||||
|
|
||||||
|
button:hover {
|
||||||
|
background-color: #26942D;
|
||||||
|
}
|
||||||
|
|
||||||
|
table {
|
||||||
|
border-spacing: 0;
|
||||||
|
table-layout: fixed;
|
||||||
|
width: 40%;
|
||||||
|
border: 1px solid black;
|
||||||
|
}
|
||||||
|
|
||||||
|
td {
|
||||||
|
margin: 0;
|
||||||
|
padding: 1vw;
|
||||||
|
border: 1px solid black;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.card {
|
||||||
|
padding: 2vw;
|
||||||
|
background-color: gray;
|
||||||
|
border-radius: 18px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.error {
|
||||||
|
color: white;
|
||||||
|
background-color: red;
|
||||||
|
}
|
||||||
|
|
||||||
|
.success {
|
||||||
|
color: white;
|
||||||
|
background-color: #0e3610;
|
||||||
|
}
|
||||||
|
|
||||||
|
.reset {
|
||||||
|
background-color: #cc0000;
|
||||||
|
}
|
||||||
|
|
||||||
|
.reset:hover {
|
||||||
|
background-color: #FF0000;
|
||||||
|
}
|
||||||
@@ -0,0 +1,71 @@
|
|||||||
|
<?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
|
||||||
|
?>
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
skinner,gatekeeper||>><<||csm,alien||>><<||dana,skeptic||>><<||fox,believer
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
dale,the government||>><<||bill,the barber||>><<||hank,the texan||>><<||boomhauer,the marshall
|
||||||
+104
@@ -0,0 +1,104 @@
|
|||||||
|
<?php
|
||||||
|
session_start();
|
||||||
|
$users = array(
|
||||||
|
'chuck' => 'roast',
|
||||||
|
'bob' => 'ross'
|
||||||
|
);
|
||||||
|
|
||||||
|
if (isset($_POST['username']) && isset($_POST['password'])) {
|
||||||
|
$username = $_POST['username'];
|
||||||
|
$password = $_POST['password'];
|
||||||
|
if (array_key_exists($username, $users) && $users[$username] === $password) {
|
||||||
|
$_GET['error'] = false;
|
||||||
|
$_SESSION['access'] = true;
|
||||||
|
$_GET['file'] = 'includes/fbi.txt';
|
||||||
|
} else {
|
||||||
|
$_GET['error'] = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($_GET['logout'])) {
|
||||||
|
$_SESSION['access'] = false;
|
||||||
|
header('Location: .');
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
||||||
|
|
||||||
|
<!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 (isset($_SESSION['access']) && $_SESSION['access'] !== true): ?>
|
||||||
|
|
||||||
|
<?php if (isset($_GET['error']) && $_GET['error'] === true): ?>
|
||||||
|
<div class="card error">
|
||||||
|
<h5 class="error">Access Denied.</h5>
|
||||||
|
</div>
|
||||||
|
<?php endif; ?>
|
||||||
|
|
||||||
|
<form method="post">
|
||||||
|
<div class="row">
|
||||||
|
<input name="username" type="text" placeholder="username">
|
||||||
|
<input name="password" type="password" placeholder="password">
|
||||||
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<button>Submit</button>
|
||||||
|
<button type="reset" class="reset">Reset</button>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
|
||||||
|
<?php else: ?>
|
||||||
|
<div class="card success">
|
||||||
|
<h5 class="success">Access Granted.</h5>
|
||||||
|
</div>
|
||||||
|
<form method="get">
|
||||||
|
<div class="row">
|
||||||
|
<button name="file" value="includes/fbi.txt">FBI</button>
|
||||||
|
<button name="file" value="includes/spies.txt">Spies</button>
|
||||||
|
<button name="logout" value="true" class="reset">Logout</button>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
<?php endif; ?>
|
||||||
|
|
||||||
|
<?php
|
||||||
|
if (isset($_GET['file']) && isset($_SESSION['access'])) {
|
||||||
|
fileRead($_GET['file']);
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
|
||||||
|
<?php
|
||||||
|
function fileRead($file)
|
||||||
|
{
|
||||||
|
$fs = fopen($file, 'r');
|
||||||
|
$string = fread($fs, filesize($file));
|
||||||
|
$values = explode('||>><<||', $string);
|
||||||
|
|
||||||
|
echo '
|
||||||
|
<table>
|
||||||
|
<tr>
|
||||||
|
<th>Agent</th>
|
||||||
|
<th>Codename</th>
|
||||||
|
</tr>
|
||||||
|
';
|
||||||
|
foreach ($values as $v) {
|
||||||
|
list($a, $b) = explode(',', $v);
|
||||||
|
|
||||||
|
echo '
|
||||||
|
<tr>
|
||||||
|
<td>' . ucfirst($a) . '</td>
|
||||||
|
<td>' . ucwords($b) . '</td>
|
||||||
|
</tr>
|
||||||
|
';
|
||||||
|
}
|
||||||
|
echo '</table>';
|
||||||
|
}
|
||||||
|
?>
|
||||||
Reference in New Issue
Block a user