vault backup: 2024-10-16 09:12:37
This commit is contained in:
23
Client Server Systems/Week 1/Workshop 1 - Intro to PHP.md
Normal file
23
Client Server Systems/Week 1/Workshop 1 - Intro to PHP.md
Normal file
@@ -0,0 +1,23 @@
|
||||
- Originally stood for "Personal Home Page", and grew to mean PHP: Hypertext Preprocessor.
|
||||
- PHP is a HTML embedded scripting language
|
||||
- Since it's inception, PHP has seen exponential growth in use and now powers around 80% of websites
|
||||
- PHP usually runs on UNIX or LINUX operation systems, but a number of Windows web hosting companies offer emulation on their Windows servers.
|
||||
|
||||

|
||||
|
||||
# Comment Standards for the Module
|
||||
|
||||
```@param <type> $variableName description
|
||||
@return <type> description
|
||||
@author name <email>
|
||||
@copyright copyright
|
||||
@license url licenseName
|
||||
@version version
|
||||
@package package
|
||||
```
|
||||
|
||||
# Workshop Exercises
|
||||
|
||||

|
||||
|
||||

|
@@ -0,0 +1,3 @@
|
||||
|
||||
- 
|
||||
- 
|
8
Client Server Systems/Week 1/workshop1/.idea/.gitignore
generated
vendored
Normal file
8
Client Server Systems/Week 1/workshop1/.idea/.gitignore
generated
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
# Default ignored files
|
||||
/shelf/
|
||||
/workspace.xml
|
||||
# Editor-based HTTP Client requests
|
||||
/httpRequests/
|
||||
# Datasource local storage ignored files
|
||||
/dataSources/
|
||||
/dataSources.local.xml
|
8
Client Server Systems/Week 1/workshop1/.idea/modules.xml
generated
Normal file
8
Client Server Systems/Week 1/workshop1/.idea/modules.xml
generated
Normal file
@@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectModuleManager">
|
||||
<modules>
|
||||
<module fileurl="file://$PROJECT_DIR$/.idea/workshop1.iml" filepath="$PROJECT_DIR$/.idea/workshop1.iml" />
|
||||
</modules>
|
||||
</component>
|
||||
</project>
|
19
Client Server Systems/Week 1/workshop1/.idea/php.xml
generated
Normal file
19
Client Server Systems/Week 1/workshop1/.idea/php.xml
generated
Normal file
@@ -0,0 +1,19 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="MessDetectorOptionsConfiguration">
|
||||
<option name="transferred" value="true" />
|
||||
</component>
|
||||
<component name="PHPCSFixerOptionsConfiguration">
|
||||
<option name="transferred" value="true" />
|
||||
</component>
|
||||
<component name="PHPCodeSnifferOptionsConfiguration">
|
||||
<option name="highlightLevel" value="WARNING" />
|
||||
<option name="transferred" value="true" />
|
||||
</component>
|
||||
<component name="PhpStanOptionsConfiguration">
|
||||
<option name="transferred" value="true" />
|
||||
</component>
|
||||
<component name="PsalmOptionsConfiguration">
|
||||
<option name="transferred" value="true" />
|
||||
</component>
|
||||
</project>
|
8
Client Server Systems/Week 1/workshop1/.idea/workshop1.iml
generated
Normal file
8
Client Server Systems/Week 1/workshop1/.idea/workshop1.iml
generated
Normal file
@@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="WEB_MODULE" version="4">
|
||||
<component name="NewModuleRootManager">
|
||||
<content url="file://$MODULE_DIR$" />
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
</component>
|
||||
</module>
|
2
Client Server Systems/Week 1/workshop1/composer.json
Normal file
2
Client Server Systems/Week 1/workshop1/composer.json
Normal file
@@ -0,0 +1,2 @@
|
||||
{
|
||||
}
|
4
Client Server Systems/Week 1/workshop1/index.php
Normal file
4
Client Server Systems/Week 1/workshop1/index.php
Normal file
@@ -0,0 +1,4 @@
|
||||
<?php
|
||||
echo "Tomorrow I'll learn PHP global variables";
|
||||
echo "<br>";
|
||||
echo "This is a bad command : del c:\*.*";
|
8
Client Server Systems/Week 1/workshop2/.idea/.gitignore
generated
vendored
Normal file
8
Client Server Systems/Week 1/workshop2/.idea/.gitignore
generated
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
# Default ignored files
|
||||
/shelf/
|
||||
/workspace.xml
|
||||
# Editor-based HTTP Client requests
|
||||
/httpRequests/
|
||||
# Datasource local storage ignored files
|
||||
/dataSources/
|
||||
/dataSources.local.xml
|
21
Client Server Systems/Week 1/workshop2/.idea/inspectionProfiles/Project_Default.xml
generated
Normal file
21
Client Server Systems/Week 1/workshop2/.idea/inspectionProfiles/Project_Default.xml
generated
Normal file
@@ -0,0 +1,21 @@
|
||||
<component name="InspectionProjectProfileManager">
|
||||
<profile version="1.0">
|
||||
<option name="myName" value="Project Default" />
|
||||
<inspection_tool class="HtmlUnknownTag" enabled="true" level="WARNING" enabled_by_default="true">
|
||||
<option name="myValues">
|
||||
<value>
|
||||
<list size="7">
|
||||
<item index="0" class="java.lang.String" itemvalue="nobr" />
|
||||
<item index="1" class="java.lang.String" itemvalue="noembed" />
|
||||
<item index="2" class="java.lang.String" itemvalue="comment" />
|
||||
<item index="3" class="java.lang.String" itemvalue="noscript" />
|
||||
<item index="4" class="java.lang.String" itemvalue="embed" />
|
||||
<item index="5" class="java.lang.String" itemvalue="script" />
|
||||
<item index="6" class="java.lang.String" itemvalue="head" />
|
||||
</list>
|
||||
</value>
|
||||
</option>
|
||||
<option name="myCustomValuesEnabled" value="true" />
|
||||
</inspection_tool>
|
||||
</profile>
|
||||
</component>
|
6
Client Server Systems/Week 1/workshop2/.idea/jsLibraryMappings.xml
generated
Normal file
6
Client Server Systems/Week 1/workshop2/.idea/jsLibraryMappings.xml
generated
Normal file
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="JavaScriptLibraryMappings">
|
||||
<file url="PROJECT" libraries="{@types/bootstrap, bootstrap}" />
|
||||
</component>
|
||||
</project>
|
8
Client Server Systems/Week 1/workshop2/.idea/modules.xml
generated
Normal file
8
Client Server Systems/Week 1/workshop2/.idea/modules.xml
generated
Normal file
@@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectModuleManager">
|
||||
<modules>
|
||||
<module fileurl="file://$PROJECT_DIR$/.idea/workshop2.iml" filepath="$PROJECT_DIR$/.idea/workshop2.iml" />
|
||||
</modules>
|
||||
</component>
|
||||
</project>
|
20
Client Server Systems/Week 1/workshop2/.idea/php.xml
generated
Normal file
20
Client Server Systems/Week 1/workshop2/.idea/php.xml
generated
Normal file
@@ -0,0 +1,20 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="MessDetectorOptionsConfiguration">
|
||||
<option name="transferred" value="true" />
|
||||
</component>
|
||||
<component name="PHPCSFixerOptionsConfiguration">
|
||||
<option name="transferred" value="true" />
|
||||
</component>
|
||||
<component name="PHPCodeSnifferOptionsConfiguration">
|
||||
<option name="highlightLevel" value="WARNING" />
|
||||
<option name="transferred" value="true" />
|
||||
</component>
|
||||
<component name="PhpProjectSharedConfiguration" php_language_level="8.3" />
|
||||
<component name="PhpStanOptionsConfiguration">
|
||||
<option name="transferred" value="true" />
|
||||
</component>
|
||||
<component name="PsalmOptionsConfiguration">
|
||||
<option name="transferred" value="true" />
|
||||
</component>
|
||||
</project>
|
10
Client Server Systems/Week 1/workshop2/.idea/workshop2.iml
generated
Normal file
10
Client Server Systems/Week 1/workshop2/.idea/workshop2.iml
generated
Normal file
@@ -0,0 +1,10 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="WEB_MODULE" version="4">
|
||||
<component name="NewModuleRootManager">
|
||||
<content url="file://$MODULE_DIR$" />
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
<orderEntry type="library" name="@types/bootstrap" level="application" />
|
||||
<orderEntry type="library" name="bootstrap" level="application" />
|
||||
</component>
|
||||
</module>
|
19
Client Server Systems/Week 1/workshop2/index.css
Normal file
19
Client Server Systems/Week 1/workshop2/index.css
Normal file
@@ -0,0 +1,19 @@
|
||||
body {
|
||||
outline: 1px solid black;
|
||||
padding: 10px;
|
||||
width: fit-content;
|
||||
height: fit-content;
|
||||
}
|
||||
|
||||
#main * {
|
||||
margin-bottom: 15px;
|
||||
}
|
||||
|
||||
#radio {
|
||||
outline: 1px solid black;
|
||||
width: fit-content;
|
||||
}
|
||||
|
||||
#radio * {
|
||||
margin: 5px;
|
||||
}
|
28
Client Server Systems/Week 1/workshop2/index.html
Normal file
28
Client Server Systems/Week 1/workshop2/index.html
Normal file
@@ -0,0 +1,28 @@
|
||||
<body>
|
||||
<head>
|
||||
<link rel="stylesheet" href="index.css">
|
||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.5.3/dist/css/bootstrap.min.css" integrity="sha384-TX8t27EcRE3e/ihU7zmQxVncDAy5uIKz4rEkgIXeMed4M0jlfIDPvg6uqKI2xXr2" crossorigin="anonymous">
|
||||
<title>Passing Data</title>
|
||||
</head>
|
||||
<p><strong>Please enter your details below:</strong></p>
|
||||
<form name="form1" method="post" action="passingdata.php">
|
||||
<div id="main">
|
||||
<label>First Name:
|
||||
<input type="text" name="firstname">
|
||||
</label>
|
||||
<label>Surname:
|
||||
<input type="text" name="surname">
|
||||
</label>
|
||||
<div id="radio">
|
||||
<label>CS <input type="radio" name="course" value="CS"/> </label>
|
||||
<label>SE <input type="radio" name="course" value="SE"/> </label>
|
||||
<label>MIT <input type="radio" name="course" value="MIT"/> </label>
|
||||
</div>
|
||||
<label>Living on Salford Campus<input type="checkbox" name="onCampus"></label>
|
||||
<br>
|
||||
<input type="submit" name="Submit" value="Submit"/>
|
||||
<input type="reset" name="Reset" value="Reset"/>
|
||||
</div>
|
||||
</form>
|
||||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@4.5.3/dist/js/bootstrap.min.js" integrity="sha384-w1Q4orYjBQndcko6MimVbzY0tgp4pWB4lZ7lr30WKz0vr/aWKhXdBNmNb5D92v7s" crossorigin="anonymous"></script>
|
||||
</body>
|
20
Client Server Systems/Week 1/workshop2/index.php
Normal file
20
Client Server Systems/Week 1/workshop2/index.php
Normal file
@@ -0,0 +1,20 @@
|
||||
<body>
|
||||
<div>
|
||||
<p><strong>Please enter your name and birthday:</strong></p>
|
||||
<form name="form1" method="post" action="passingdata.php">
|
||||
<span>
|
||||
<label>Your name:
|
||||
<input type="text" name="name">
|
||||
</label>
|
||||
<br>
|
||||
<label>Your Birthday (in DD/MM/YY format):
|
||||
<input type="text"
|
||||
name="birthday" required>
|
||||
</label>
|
||||
<br>
|
||||
<input type="submit" name="Submit" value="Submit">
|
||||
<input type="reset" name="Submit2" value="Reset">
|
||||
</span>
|
||||
</form>
|
||||
</div>
|
||||
</body>
|
44
Client Server Systems/Week 1/workshop2/passingdata.php
Normal file
44
Client Server Systems/Week 1/workshop2/passingdata.php
Normal file
@@ -0,0 +1,44 @@
|
||||
<body>
|
||||
<span>
|
||||
<?php
|
||||
|
||||
$birthday = $_POST['birthday'];
|
||||
$test_array = explode("/", $birthday);
|
||||
$firstname = $_POST['firstname'];
|
||||
$surname = $_POST['surname'];
|
||||
$course = $_POST['course'];
|
||||
$onCampus = $_POST['onCampus'];
|
||||
|
||||
echo "Hello, $firstname $surname";
|
||||
echo "<br>";
|
||||
if (isset($_POST["birthday"])) {
|
||||
if (count($test_array) == 3) {
|
||||
if (checkdate($test_array[0], $test_array[1], $test_array[2])) {
|
||||
if (($test_array[2]-2024)<-100) {
|
||||
echo "Birthday: $birthday";
|
||||
echo "<br>";
|
||||
}
|
||||
else {
|
||||
echo "Over 100 years old";
|
||||
}
|
||||
}
|
||||
else {
|
||||
echo "Birthday in Incorrect Format";
|
||||
echo "<br>";
|
||||
}
|
||||
}
|
||||
}
|
||||
echo "Course: $course";
|
||||
echo "<br>";
|
||||
echo "On Campus: ";
|
||||
if (isset($_POST['onCampus'])) {
|
||||
echo "True";
|
||||
} else {
|
||||
echo "False";
|
||||
}
|
||||
?>
|
||||
<br>
|
||||
<a href="index.html"><button>Return to Form</button></a>
|
||||
</span>
|
||||
</body>
|
||||
|
1
Client Server Systems/Week 2/Lecture 2 - HTML Forms.md
Normal file
1
Client Server Systems/Week 2/Lecture 2 - HTML Forms.md
Normal file
@@ -0,0 +1 @@
|
||||
- Bootstrap
|
53
Client Server Systems/Week 3/Workshop 3.md
Normal file
53
Client Server Systems/Week 3/Workshop 3.md
Normal file
@@ -0,0 +1,53 @@
|
||||

|
||||

|
||||
|
||||
```php
|
||||
<html>
|
||||
<head>
|
||||
<title>Train Listings</title>
|
||||
</head>
|
||||
<body>
|
||||
<table>
|
||||
<tr>
|
||||
<th>Title</th>
|
||||
<th>Price</th>
|
||||
</tr>
|
||||
<?php
|
||||
$url = "http://www.classifiedsteam.co.uk/index.php?page=search&sCategory=10";
|
||||
$string = file_get_contents($url);
|
||||
$dom = new DOMDocument();
|
||||
$dom->loadHTML($string);
|
||||
$xpath = new DOMXPath($dom);
|
||||
$titles = $xpath->query("//a[contains(@class, 'title')]");
|
||||
$prices = $xpath->query("//span[contains(@class, 'currency-value')]");
|
||||
for ($i=0; $i<$titles->length; $i++) {
|
||||
$title = $titles->item($i)->textContent;
|
||||
$link = $titles->item($i)->getAttribute('href');
|
||||
$price = $prices->item($i)->textContent;
|
||||
echo "<tr>\n";
|
||||
echo "<td><a href='$link' title='$title'>$title</a></td>\n";
|
||||
echo "<td>$price</td>\n";
|
||||
echo "</tr>\n";
|
||||
}
|
||||
?>
|
||||
</table>
|
||||
</body>
|
||||
<style>
|
||||
html {
|
||||
font-family: "DejaVu Sans";
|
||||
}
|
||||
table, td, th {
|
||||
border: 1px solid;
|
||||
border-collapse: collapse;
|
||||
}
|
||||
td, th {
|
||||
padding: 8px 6px 8px 6px;
|
||||
}
|
||||
a {
|
||||
text-decoration: none;
|
||||
}
|
||||
</style>
|
||||
</html>
|
||||
```
|
||||
|
||||

|
8
Client Server Systems/Week 3/workshop3/.idea/.gitignore
generated
vendored
Normal file
8
Client Server Systems/Week 3/workshop3/.idea/.gitignore
generated
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
# Default ignored files
|
||||
/shelf/
|
||||
/workspace.xml
|
||||
# Editor-based HTTP Client requests
|
||||
/httpRequests/
|
||||
# Datasource local storage ignored files
|
||||
/dataSources/
|
||||
/dataSources.local.xml
|
8
Client Server Systems/Week 3/workshop3/.idea/modules.xml
generated
Normal file
8
Client Server Systems/Week 3/workshop3/.idea/modules.xml
generated
Normal file
@@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectModuleManager">
|
||||
<modules>
|
||||
<module fileurl="file://$PROJECT_DIR$/.idea/workshop3.iml" filepath="$PROJECT_DIR$/.idea/workshop3.iml" />
|
||||
</modules>
|
||||
</component>
|
||||
</project>
|
20
Client Server Systems/Week 3/workshop3/.idea/php.xml
generated
Normal file
20
Client Server Systems/Week 3/workshop3/.idea/php.xml
generated
Normal file
@@ -0,0 +1,20 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="MessDetectorOptionsConfiguration">
|
||||
<option name="transferred" value="true" />
|
||||
</component>
|
||||
<component name="PHPCSFixerOptionsConfiguration">
|
||||
<option name="transferred" value="true" />
|
||||
</component>
|
||||
<component name="PHPCodeSnifferOptionsConfiguration">
|
||||
<option name="highlightLevel" value="WARNING" />
|
||||
<option name="transferred" value="true" />
|
||||
</component>
|
||||
<component name="PhpProjectSharedConfiguration" php_language_level="8.3" />
|
||||
<component name="PhpStanOptionsConfiguration">
|
||||
<option name="transferred" value="true" />
|
||||
</component>
|
||||
<component name="PsalmOptionsConfiguration">
|
||||
<option name="transferred" value="true" />
|
||||
</component>
|
||||
</project>
|
8
Client Server Systems/Week 3/workshop3/.idea/workshop3.iml
generated
Normal file
8
Client Server Systems/Week 3/workshop3/.idea/workshop3.iml
generated
Normal file
@@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="WEB_MODULE" version="4">
|
||||
<component name="NewModuleRootManager">
|
||||
<content url="file://$MODULE_DIR$" />
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
</component>
|
||||
</module>
|
6
Client Server Systems/Week 3/workshop3/emoji.php
Normal file
6
Client Server Systems/Week 3/workshop3/emoji.php
Normal file
@@ -0,0 +1,6 @@
|
||||
<?php
|
||||
for ($i = 128512; $i < 128592; $i++) {
|
||||
$hex = dechex($i);
|
||||
echo "Icon for 0x$hex is '&#x$hex'";
|
||||
echo "<br>";
|
||||
}
|
33
Client Server Systems/Week 3/workshop3/operators.php
Normal file
33
Client Server Systems/Week 3/workshop3/operators.php
Normal file
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
$temp = array(78, 60, 62, 68, 71, 68, 73, 85, 66, 64, 76, 63, 75, 76, 73, 68, 62, 73, 72, 65, 74, 62, 62, 65, 64, 68, 73, 75, 79, 73);
|
||||
|
||||
function smallestTemp($temp)
|
||||
{
|
||||
sort($temp, SORT_NATURAL);
|
||||
for ($i = 0; $i < 7; $i++) {
|
||||
$smallestTemp[$i] = $temp[$i];
|
||||
}
|
||||
return implode(", ", $smallestTemp);
|
||||
}
|
||||
|
||||
function largestTemp($temp) {
|
||||
rsort($temp, SORT_NATURAL);
|
||||
for ($i = 0; $i < 7; $i++) {
|
||||
$largestTemp[$i] = $temp[$i];
|
||||
}
|
||||
return implode(", ", $largestTemp);
|
||||
}
|
||||
|
||||
function calcAvgTemp($temp) {
|
||||
$totalTemp = 0;
|
||||
foreach ($temp as $value) {
|
||||
$totalTemp += $value;
|
||||
}
|
||||
return round( ($totalTemp / count($temp) ), 1 );
|
||||
}
|
||||
|
||||
echo "Average Temperature is : " . calcAvgTemp($temp);
|
||||
echo "<br>";
|
||||
echo "List of seven lowest temperatures : " . smallestTemp($temp);
|
||||
echo "<br>";
|
||||
echo "List of seven highest temperatures : " . largestTemp($temp);
|
46
Client Server Systems/Week 3/workshop3/strings.php
Normal file
46
Client Server Systems/Week 3/workshop3/strings.php
Normal file
@@ -0,0 +1,46 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>Train Listings</title>
|
||||
</head>
|
||||
<body>
|
||||
<table>
|
||||
<tr>
|
||||
<th>Title</th>
|
||||
<th>Price</th>
|
||||
</tr>
|
||||
<?php
|
||||
$url = "http://www.classifiedsteam.co.uk/index.php?page=search&sCategory=10";
|
||||
$string = file_get_contents($url);
|
||||
$dom = new DOMDocument();
|
||||
$dom->loadHTML($string);
|
||||
$xpath = new DOMXPath($dom);
|
||||
$titles = $xpath->query("//a[contains(@class, 'title')]");
|
||||
$prices = $xpath->query("//span[contains(@class, 'currency-value')]");
|
||||
for ($i=0; $i<$titles->length; $i++) {
|
||||
$title = $titles->item($i)->textContent;
|
||||
$link = $titles->item($i)->getAttribute('href');
|
||||
$price = $prices->item($i)->textContent;
|
||||
echo "<tr>\n";
|
||||
echo "<td><a href='$link' title='$title'>$title</a></td>\n";
|
||||
echo "<td>$price</td>\n";
|
||||
echo "</tr>\n";
|
||||
}
|
||||
?>
|
||||
</table>
|
||||
</body>
|
||||
<style>
|
||||
html {
|
||||
font-family: "DejaVu Sans";
|
||||
}
|
||||
table, td, th {
|
||||
border: 1px solid;
|
||||
border-collapse: collapse;
|
||||
}
|
||||
td, th {
|
||||
padding: 8px 6px 8px 6px;
|
||||
}
|
||||
a {
|
||||
text-decoration: none;
|
||||
}
|
||||
</style>
|
||||
</html>
|
Reference in New Issue
Block a user