From eb6f5bedec8c8039e4031773687c09b065762563 Mon Sep 17 00:00:00 2001
From: Sorrel Harriet <s.harriet@gold.ac.uk>
Date: Fri, 16 Sep 2016 12:51:42 +0100
Subject: [PATCH] replacing week 1 test app

---
 week-1/test_app/README.md              | 19 +++++++++++
 week-1/test_app/includes/functions.php |  5 +++
 week-1/test_app/index.php              | 44 ++++++++++++++++++++++++++
 week-1/test_app/views/404.php          |  6 ++++
 week-1/test_app/views/home.php         |  7 ++++
 week-1/test_app/views/page_2.php       |  3 ++
 6 files changed, 84 insertions(+)
 create mode 100644 week-1/test_app/README.md
 create mode 100644 week-1/test_app/includes/functions.php
 create mode 100755 week-1/test_app/index.php
 create mode 100644 week-1/test_app/views/404.php
 create mode 100755 week-1/test_app/views/home.php
 create mode 100644 week-1/test_app/views/page_2.php

diff --git a/week-1/test_app/README.md b/week-1/test_app/README.md
new file mode 100644
index 0000000..0bc2b71
--- /dev/null
+++ b/week-1/test_app/README.md
@@ -0,0 +1,19 @@
+*********************************
+*		A TEST APPLICATION		*
+*********************************
+
+Description
+-----------
+This is a test PHP application. You can upload use it to test your LAMP stack. You can also browse the directory structure to get an idea of how PHP web applications are commonly structured. You can also read this README file to find out the sorts of things that should be included in a README file!
+
+Author & Contact
+----------------
+Sorrel Harriet	s.harriet@gold.ac.uk
+
+Installation Instructions
+-------------------------
+Upload the application to your web root folder. No further actions needed!
+
+Configuration Instructions
+--------------------------
+There is nothing to configure.
diff --git a/week-1/test_app/includes/functions.php b/week-1/test_app/includes/functions.php
new file mode 100644
index 0000000..906f6b0
--- /dev/null
+++ b/week-1/test_app/includes/functions.php
@@ -0,0 +1,5 @@
+<?php
+
+# Write some helper functions here...
+
+?>
diff --git a/week-1/test_app/index.php b/week-1/test_app/index.php
new file mode 100755
index 0000000..c9ca050
--- /dev/null
+++ b/week-1/test_app/index.php
@@ -0,0 +1,44 @@
+<?php
+
+// Code to detect whether index.php has been requested without query string
+// If no page parameter detected...
+if (!isset($_GET['page'])) {
+    $id = 'home'; 		// display home page
+} else {
+    $id = $_GET['page']; 	// else requested page
+}
+
+$content = '';
+
+// Switch statement to decide content of page will go here.
+// Regardless of which "view" is displayed, the variable $content will
+switch ($id) {
+    case 'home' :
+        include 'views/home.php';
+        break;
+    case 'page_2' :
+        include 'views/page_2.php';
+        break;
+    default :
+        include 'views/404.php';
+}
+?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+    <head>
+        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
+        <title>Test Application</title>
+    </head>
+    <body>
+		<ul>
+			<li><a href="index.php">Home</a></li>
+			<li><a href="index.php?page=page_2">Page 2</a></li>
+		</ul>
+        
+		<?php
+		// Display content for requested view.
+		echo $content;
+		?>
+		
+    </body>
+</html>
diff --git a/week-1/test_app/views/404.php b/week-1/test_app/views/404.php
new file mode 100644
index 0000000..515bef4
--- /dev/null
+++ b/week-1/test_app/views/404.php
@@ -0,0 +1,6 @@
+<?php
+
+$content = "<h1>Page not found</h1>";
+$content .= "<p>Sorry, the page you requested could not be found.</p>";
+
+?>
diff --git a/week-1/test_app/views/home.php b/week-1/test_app/views/home.php
new file mode 100755
index 0000000..cbf88c6
--- /dev/null
+++ b/week-1/test_app/views/home.php
@@ -0,0 +1,7 @@
+<?php
+
+$content = '<h1>Hello world!</h1>';
+$content .= '<p>If you\'re reading this, it means you have successfully launched the <b>test app</b>.</p>'
+
+?>
+
diff --git a/week-1/test_app/views/page_2.php b/week-1/test_app/views/page_2.php
new file mode 100644
index 0000000..59f181b
--- /dev/null
+++ b/week-1/test_app/views/page_2.php
@@ -0,0 +1,3 @@
+<?php
+$content = '<h1>Welcome to page 2!</h1>';
+?>
-- 
GitLab