Below is some code to use as a starting point for completing this
assignment.
<!--
Your Name
CS 4312
Lab 05
-->
<?php
/* Check the protocol for this request. Redirect an HTTP request to
an HTTPS request.
Ref.: https://stackoverflow.com/questions/5106313/redirecting-from-http-to-https-with-php
*/
if (empty($_SERVER['HTTPS']) || $_SERVER['HTTPS'] === "off")
{
$location = 'https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
header('HTTP/1.1 301 Moved Permanently');
header('Location: ' . $location);
exit;
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<title>Lab 05</title>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
</head>
<body>
<p>
<?php
// Function isTriangle takes three arguments, each representing the
// length of a side of a triangle. The function returns true if the
// arguments represent the lengths of the sides of a triangle and false
// otherwise.
function isTriangle($side1, $side2, $side3)
{
}
// Function isEquilateral takes three arguments, each representing the
// length of a side of a triangle. The function returns true if the
// three sides represent a triangle and are equal and false otherwise.
function isEquilateral($side1, $side2, $side3)
{
}
// Function isIsosceles takes three arguments, each representing the
// length of a side of a triangle. The function returns true if the
// three sides represent a triangle and at least two are equal and
// false otherwise.
function isIsosceles($side1, $side2, $side3)
{
}
// Function isScalene takes three arguments, each representing the
// length of a side of a triangle. The function returns true if the
// three sides represent a triangle and no two are equal and
// false otherwise.
function isScalene($side1, $side2, $side3)
{
}
echo "Your Name - CS 4312 - Lab 05<br /><br />\n";
// Obtain the data following the ? in the URL via which the page was
// accessed.
$argv = $_SERVER['QUERY_STRING'];
// Replace all occurrences of %20 with a space character. If URLs
// contain spaces when sent to a server, they are transformed into
// %20. The two characters following % are considered hexadecimal
// values and represent the character's ASCII code. 20 hex is equal to
// 32 decimal, the ASCII representation for a space character.
$argv = str_replace("%20"," ",$argv);
// Use the builtin function trim to remove leading and trailing
// whitespace characters.
$argv = trim($argv);
// Use the builtin function preg_split to tokenize the string $argv,
// using the space character as a delimiter. The delimiter can consist
// of a single space or multiple spaces. This function returns an
// array of the split string $argv.
$myArgvArray = preg_split("/ +/", $argv);
if (count($myArgvArray) != 3)
{
echo "This script expects three arguments separated by spaces.<br />\n";
goto end;
}
$side1 = $myArgvArray[0];
$side2 = $myArgvArray[1];
$side3 = $myArgvArray[2];
// ...
end:
?>
</p>
<p>
<?php
$location = 'https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
$location = urlencode($location);
echo '<a href="https://validator.w3.org/nu/?doc=' . $location . '">';
?>
<img src="https://www.w3.org/QA/Tools/I_heart_validator"
alt="I heart Validator logo" height="31" width="80" />
</a>
</p>
</body>
</html>