Commit 3f0d4c87 authored by hmead's avatar hmead
Browse files

Upload of assignment two

parents
Pipeline #3093 failed with stages
in 0 seconds
<Files .htaccess>
Order allow,deny
Deny from all
</Files>
# Disable directory browsing
Options -Indexes
\ No newline at end of file
<?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>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="JavaScriptSettings">
<option name="languageLevel" value="ES6" />
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/AssignmentTwo.iml" filepath="$PROJECT_DIR$/.idea/AssignmentTwo.iml" />
</modules>
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$" vcs="Git" />
</component>
</project>
\ No newline at end of file
{
"type": "FeatureCollection",
"features": [
{
"type": "Feature",
"properties": {
"marker-color": "#7e7e7e",
"marker-size": "medium",
"marker-symbol": "",
"type": "campsite",
"name": "Dunedin Holiday Park"
},
"geometry": {
"type": "Point",
"coordinates": [
170.5153065919876,
-45.90540437585189
]
}
},
{
"type": "Feature",
"properties": {
"marker-color": "#7e7e7e",
"marker-size": "medium",
"marker-symbol": "triangle",
"name": "St Clair Beach",
"type": "landmark"
},
"geometry": {
"type": "Point",
"coordinates": [
170.49052566289902,
-45.911734850052895
]
}
},
{
"type": "Feature",
"properties": {
"marker-color": "#7e7e7e",
"marker-size": "medium",
"marker-symbol": "",
"name": "Hot Water Pool",
"type": "landmark"
},
"geometry": {
"type": "Point",
"coordinates": [
170.48803120851517,
-45.913724171912456
]
}
},
{
"type": "Feature",
"properties": {
"marker-color": "#7e7e7e",
"marker-size": "medium",
"marker-symbol": "",
"name": "Cliff Top Hiking Track",
"type": "landmark"
},
"geometry": {
"type": "Point",
"coordinates": [
170.499,
-45.90948
]
}
},
{
"type": "Feature",
"properties": {
"marker-color": "#7e7e7e",
"marker-size": "medium",
"marker-symbol": "",
"name": "Harry's Homely Tavern",
"type": "landmark"
},
"geometry": {
"type": "Point",
"coordinates": [
170.492386,
-45.905837
]
}
},
{
"type": "Feature",
"properties": {
"marker-color": "#7e7e7e",
"marker-size": "medium",
"marker-symbol": "",
"name": "Mathews Average Fish & Chips",
"type": "landmark"
},
"geometry": {
"type": "Point",
"coordinates": [
170.504498,
-45.902612
]
}
},
{
"type": "Feature",
"properties": {
"marker-color": "#7e7e7e",
"marker-size": "medium",
"marker-symbol": "",
"type": "restaurant",
"name": "Esplanade"
},
"geometry": {
"type": "Point",
"coordinates": [
170.49030303955075,
-45.911675131971606
]
}
}
]
}
\ No newline at end of file
<?php
$scriptList = array('./scripts/jquery-3.4.1.js', './scripts/admin.js');
$styleList = array('./styles/jquery-ui.css', 'styles/style-admin.css');
include("htaccess/header.php")
?>
</header>
<div id="delete-booking">
<h3>Delete Campsite</h3>
<form method="POST" action="htaccess/deleteSite.php">
<select id='delete-site' name='sitenumber'>
</select>
<button id="remove-button" type="submit" value="Delete Site">Delete Site</button>
</form>
</div>
<div id="edit-booking">
<h3>Edit or Add Campsite</h3>
<form method="POST" action="htaccess/editSite.php">
<select id='edit-site' name='sitenumber'>
<option value="new">New Campsite</option>
</select>
<input type="number" name="newsitenumber" id="newsitenumber" placeholder='New Site Number' max="999" required>
<select id='site-type' name='sitetype'>
<option value="Cabin">Cabin</option>
<option value="Tent">Tent</option>
<option value="Van">Van</option>
</select>
<input type="text" name="description" id="description" placeholder='Description' required>
<input type="number" name="pricepernight" id="pricepernight" placeholder='Price Per Night' required>
<button id="edit-button" type="submit" value="new">Edit/Add Site</button>
</form>
</div>
<div id="bookings-list">
<h3>Confirmed Bookings</h3>
</div>
</body>
</html>
\ No newline at end of file
{
"bookings": {
"booking": null
}
}
<?php
$scriptList = array('./scripts/jquery-3.4.1.js', './scripts/campsites.js', './scripts/scrollTop.js', 'scripts/leaflet.js');
$styleList = array('./styles/jquery-ui.css', 'styles/style-booking.css', './styles/leaflet.css');
include("htaccess/header.php")
?>
</header>
<div id="campsites-content">
<h3 id="campsites-title">Available campsites</h3>
<div id="campsites-listings">
</div>
<div id="campsites-map">
<div id="map"></div>
<div id="map-show-hide">Show/Hide markers</div>
</div>
</div>
</html>
\ No newline at end of file
<?php
//Check that we have been given a name and number for the new booking
if (isset($_GET['name']) && isset($_GET['number'])) {
//Build an array for the check in data, accessing variables from GET
$checkindata = array(
'day'=> $_GET['check-in-day'],
'month'=> $_GET['check-in-month'],
'year'=> $_GET['check-in-year'],
);
//Build an array for the check out data, accessing variables from GET
$checkoutdata = array(
'day'=> $_GET['check-out-day'],
'month'=> $_GET['check-out-month'],
'year'=> $_GET['check-out-year'],
);
//Build a final array to be added to bookings.json
$formdata = array(
'number'=> $_GET['number'],
'name'=> $_GET['name'],
'checkin'=> $checkindata,
'checkout'=> $checkoutdata,
);
//Read in the JSON file
$input_filename = "bookings.json";
$output_filename = "bookings.json";
$json_input = file_get_contents($input_filename);
$json = json_decode($json_input,true);
//Push the new array to the JSON file
array_push($json['bookings']['booking'],$formdata);
//Ensure that the booking is unique
$json['bookings']['booking'] = array_unique($json['bookings']['booking'], SORT_REGULAR);
//Re-write the JSON file
$json_output = json_encode($json,JSON_PRETTY_PRINT)."\n";
file_put_contents($output_filename,$json_output);
//Send the user to the bookings page and give them an alert so they know the booking was succesful
echo ("<script LANGUAGE='JavaScript'>
window.location.href='../bookings.php';
window.alert('Succesfully Added');
</script>");
}
?>
\ No newline at end of file
{
"bookings": {
"booking": [
{
"number": "101",
"name": "Mr and Mrs Smith",
"checkin": {
"day": "15",
"month": "8",
"year": "2019"
},
"checkout": {
"day": "21",
"month": "8",
"year": "2019"
}
},
{
"number": "203",
"name": "Alice, Bob, and family",
"checkin": {
"day": "12",
"month": "8",
"year": "2019"
},
"checkout": {
"day": "17",
"month": "8",
"year": "2019"
}
},
{
"number": "204",
"name": "Alice, Bob, and family",
"checkin": {
"day": "12",
"month": "8",
"year": "2019"
},
"checkout": {
"day": "17",
"month": "8",
"year": "2019"
}
},
{
"number": "203",
"name": "Carol and Dave",
"checkin": {
"day": "17",
"month": "8",
"year": "2019"
},
"checkout": {
"day": "21",
"month": "8",
"year": "2019"
}
},
{
"number": "101",
"name": "Nicks Test # 101",
"checkin": {
"day": "1",
"month": "10",
"year": "2019"
},
"checkout": {
"day": "10",
"month": "10",
"year": "2019"
}
},
{
"number": "203",
"name": "Nicks Test # 203",
"checkin": {
"day": "1",
"month": "10",
"year": "2019"
},
"checkout": {
"day": "10",
"month": "10",
"year": "2019"
}
}
]
}
}
\ No newline at end of file
{
"bookings": {
"booking": [
{
"number": "204",
"name": "Alice, Bob, and family",
"checkin": {
"day": "12",
"month": "8",
"year": "2019"
},
"checkout": {
"day": "17",
"month": "8",
"year": "2019"
}
},
{
"number": "204",
"name": "Amy Rose",
"checkin": {
"day": "1",
"month": "10",
"year": "2019"
},
"checkout": {
"day": "22",
"month": "10",
"year": "2019"
}
},
{
"number": "112",
"name": "Tom",
"checkin": {
"day": "1",
"month": "10",
"year": "2019"
},
"checkout": {
"day": "22",
"month": "10",
"year": "2019"
}
}
]
}
}
{
"campSites": {
"site": [
{
"number": "101",
"siteType": "Tent",
"description": "Tent site.",
"pricePerNight": "40.0"
},
{
"number": "102",
"siteType": "Tent",
"description": "tent site.",
"pricePerNight": "40.0"
},
{
"number": "201",
"siteType": "Tent",
"description": "Tent site",
"pricePerNight": "40.0"
},
{
"number": "202",
"siteType": "Tent",
"description": "tent site",
"pricePerNight": "40.0"
},
{
"number": "203",
"siteType": "Cabin",
"description": "Cabin",
"pricePerNight": "195.00"
},
{
"number": "204",
"siteType": "Cabin",
"description": "Cabin",
"pricePerNight": "80.0"
},
{
"number": "205",
"siteType": "Cabin",
"description": "Cabin",
"pricePerNight": "80.0"
},
{
"number": "301",
"siteType": "Cabin",
"description": "Cabin",
"pricePerNight": "90.0"
},
{
"number": "302",
"siteType": "Van",
"description": "Van",
"pricePerNight": "60.0"
},
{
"number": "303",
"siteType": "Van",
"description": "Van.",
"pricePerNight": "60.0"
}
]
}
}
{
"campSites": {
"site": [
{
"number": "202",
"siteType": "Tent",
"description": "tent site",
"pricePerNight": "40.0"
},
{
"number": "112",
"siteType": "Cabin",
"description": "Cabin",
"pricePerNight": "80.0"
},
{
"number": "205",
"siteType": "Tent",
"description": "Cabin",
"pricePerNight": "80.0"
},
{
"number": "301",
"siteType": "Cabin",
"description": "Cabin",
"pricePerNight": "90.0"
},
{
"number": "302",
"siteType": "Van",
"description": "Van",
"pricePerNight": "60.0"
},
{
"number": "903",
"siteType": "Van",
"description": "Van.",
"pricePerNight": "60.0"
},
{
"number": "999",
"siteType": "Tent",
"description": "Amy Rose",
"pricePerNight": "25000"
},
{
"number": "234",
"siteType": "Cabin",
"description": "234",
"pricePerNight": "23"
},
{
"number": "995",
"siteType": "Cabin",
"description": "testerer",
"pricePerNight": "24"
},
{
"number": "333",
"siteType": "Tent",
"description": "tent site",
"pricePerNight": "12"
},
{
"number": "800",
"siteType": "Van",
"description": "Nicoles van",
"pricePerNight": "5"
},
{
"number": "345",
"siteType": "Cabin",
"description": "345",
"pricePerNight": "345"
}
]
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment