implemented robot assignment
This commit is contained in:
@@ -3,7 +3,7 @@
|
|||||||
$db_pass = $_ENV['DATABASE_PASSWORD'];
|
$db_pass = $_ENV['DATABASE_PASSWORD'];
|
||||||
$ip_addr = $_ENV['IP_ADDRESS'];
|
$ip_addr = $_ENV['IP_ADDRESS'];
|
||||||
|
|
||||||
if ($_SERVER['HTTP_HOST'] == 'localhost') {
|
if ($_SERVER['HTTP_HOST'] == 'localhost:2440') {
|
||||||
define('HOST', 'localhost');
|
define('HOST', 'localhost');
|
||||||
define('USER', 'root');
|
define('USER', 'root');
|
||||||
define('PASS', $db_pass);
|
define('PASS', $db_pass);
|
||||||
@@ -14,7 +14,6 @@ if ($_SERVER['HTTP_HOST'] == 'localhost') {
|
|||||||
define('PASS', $db_pass);
|
define('PASS', $db_pass);
|
||||||
define('DB', 'secureusers');
|
define('DB', 'secureusers');
|
||||||
}
|
}
|
||||||
// Make some constants
|
|
||||||
|
|
||||||
function table_from_file($file)
|
function table_from_file($file)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -0,0 +1,63 @@
|
|||||||
|
@font-face {
|
||||||
|
font-family: 'Hack Nerd Font Mono';
|
||||||
|
src: url('/includes/HackNerdFontMono-Regular.woff');
|
||||||
|
font-weight: normal;
|
||||||
|
font-style: normal;
|
||||||
|
}
|
||||||
|
|
||||||
|
* {
|
||||||
|
padding: 0;
|
||||||
|
margin: 0;
|
||||||
|
font-family: 'Hack Nerd Font Mono', Hack, sans-serif;
|
||||||
|
}
|
||||||
|
|
||||||
|
h1 {
|
||||||
|
font-size: 5vw;
|
||||||
|
font-weight: 800;
|
||||||
|
text-align: center;
|
||||||
|
margin: 35px;
|
||||||
|
}
|
||||||
|
|
||||||
|
h3 {
|
||||||
|
font-size: 3vw;
|
||||||
|
font-weight: 600;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
p,
|
||||||
|
label,
|
||||||
|
select,
|
||||||
|
option,
|
||||||
|
input {
|
||||||
|
font-size: 1.75vw;
|
||||||
|
margin: 15px;
|
||||||
|
}
|
||||||
|
|
||||||
|
pre {
|
||||||
|
font-size: 1.5vw;
|
||||||
|
}
|
||||||
|
|
||||||
|
form {
|
||||||
|
width: 90%;
|
||||||
|
margin: 0 auto;
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: 25% 50%;
|
||||||
|
column-gap: 25%;
|
||||||
|
}
|
||||||
|
|
||||||
|
input[type="submit"] {
|
||||||
|
grid-column: span 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
.card {
|
||||||
|
padding: 50px;
|
||||||
|
width: 40%;
|
||||||
|
margin: 0 auto;
|
||||||
|
background-color: green;
|
||||||
|
border-radius: 18px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.row {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: row;
|
||||||
|
}
|
||||||
+177
@@ -0,0 +1,177 @@
|
|||||||
|
<?php
|
||||||
|
class Robot
|
||||||
|
{
|
||||||
|
private $model;
|
||||||
|
private $color;
|
||||||
|
private $os;
|
||||||
|
|
||||||
|
public function __construct($model, $color, $os)
|
||||||
|
{
|
||||||
|
$this->set_model($model);
|
||||||
|
$this->set_color($color);
|
||||||
|
$this->set_os($os);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function __toString()
|
||||||
|
{
|
||||||
|
return '<p>Your ' . $this->get_color() . ' <em>' . $this->get_model() . '</em> running <em>' . $this->get_os() . '</em> will be built shortly. Thank you.</p>';
|
||||||
|
}
|
||||||
|
|
||||||
|
public function get_model()
|
||||||
|
{
|
||||||
|
return $this->model;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function set_model($model)
|
||||||
|
{
|
||||||
|
$this->model = $model;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function get_color()
|
||||||
|
{
|
||||||
|
return $this->color;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function set_color($color)
|
||||||
|
{
|
||||||
|
$this->color = $color;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function get_os()
|
||||||
|
{
|
||||||
|
return $this->os;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function set_os($os)
|
||||||
|
{
|
||||||
|
$this->os = $os;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
||||||
|
|
||||||
|
<!doctype html>
|
||||||
|
<html lang="en">
|
||||||
|
|
||||||
|
<head>
|
||||||
|
<title>Robot</title>
|
||||||
|
<link href="css/styles.css" type="text/css" rel="stylesheet">
|
||||||
|
<script src="js/index.js"></script>
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<h1>I, Object</h1>
|
||||||
|
|
||||||
|
<?php
|
||||||
|
if (!isset($_POST['model']))
|
||||||
|
echo form();
|
||||||
|
else
|
||||||
|
echo message();
|
||||||
|
?>
|
||||||
|
</body>
|
||||||
|
|
||||||
|
</html>
|
||||||
|
|
||||||
|
<?php
|
||||||
|
function form()
|
||||||
|
{
|
||||||
|
$models = [
|
||||||
|
'Sonny',
|
||||||
|
'Rosey',
|
||||||
|
'SICO',
|
||||||
|
'Data',
|
||||||
|
'Gort',
|
||||||
|
'Wall-E',
|
||||||
|
'Optimus Prime',
|
||||||
|
'Hal 9000',
|
||||||
|
'Twiki',
|
||||||
|
'Bender',
|
||||||
|
'Johnny 5',
|
||||||
|
];
|
||||||
|
|
||||||
|
$colors = [
|
||||||
|
'Shiny',
|
||||||
|
'Chrome',
|
||||||
|
'Silver',
|
||||||
|
'Brass',
|
||||||
|
'Gold',
|
||||||
|
];
|
||||||
|
|
||||||
|
$oss = [
|
||||||
|
'Linux',
|
||||||
|
'Unix',
|
||||||
|
'SPARC',
|
||||||
|
'Binary',
|
||||||
|
'DOS',
|
||||||
|
'Tiny Hamsters',
|
||||||
|
];
|
||||||
|
|
||||||
|
$form = '
|
||||||
|
<div class="card">
|
||||||
|
<form method="post">
|
||||||
|
<label for="model">Model:</label>
|
||||||
|
<select id="model" name="model" required>
|
||||||
|
';
|
||||||
|
|
||||||
|
foreach ($models as $m)
|
||||||
|
$form .= '<option value="' . $m . '">' . ucwords($m) . '</option>';
|
||||||
|
|
||||||
|
$form .= '
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<label for="color">Color:</label>
|
||||||
|
<select id="color" name="color" required>
|
||||||
|
';
|
||||||
|
|
||||||
|
foreach ($colors as $c)
|
||||||
|
$form .= '<option value="' . $c . '">' . ucwords($c) . '</option>';
|
||||||
|
|
||||||
|
$form .= '
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<label for="os">OS:</label>
|
||||||
|
<select id="os" name="os" required>
|
||||||
|
';
|
||||||
|
foreach ($oss as $o)
|
||||||
|
$form .= '<option value="' . $o . '">' . ucwords($o) . '</option>';
|
||||||
|
|
||||||
|
$form .= '
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<input type="submit" value="Build Robot">
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
';
|
||||||
|
|
||||||
|
return $form;
|
||||||
|
}
|
||||||
|
|
||||||
|
function message()
|
||||||
|
{
|
||||||
|
if (isset($_POST['model']) && isset($_POST['color']) && isset($_POST['os']))
|
||||||
|
$robot = new Robot($_POST['model'], $_POST['color'], $_POST['os']);
|
||||||
|
|
||||||
|
if (!$robot)
|
||||||
|
return form();
|
||||||
|
|
||||||
|
ob_start();
|
||||||
|
print_r($robot);
|
||||||
|
$dump = ob_get_clean();
|
||||||
|
|
||||||
|
$msg = '
|
||||||
|
<div class="card">
|
||||||
|
<h3>Processing...</h3>
|
||||||
|
' . $robot->__toString() . '
|
||||||
|
<pre>
|
||||||
|
';
|
||||||
|
|
||||||
|
$msg .= $dump;
|
||||||
|
|
||||||
|
$msg .= '
|
||||||
|
</pre>
|
||||||
|
</div>
|
||||||
|
';
|
||||||
|
|
||||||
|
return $msg;
|
||||||
|
}
|
||||||
|
?>
|
||||||
Reference in New Issue
Block a user