Inital ticketing system
authorRichard Whitehouse <github@richardwhiuk.com>
Thu, 3 Feb 2011 04:31:08 +0000 (04:31 +0000)
committerRichard Whitehouse <github@richardwhiuk.com>
Thu, 3 Feb 2011 04:31:08 +0000 (04:31 +0000)
.htaccess [new file with mode: 0644]
index.php [new file with mode: 0644]
pages/index.php [new file with mode: 0644]
templates/index.php [new file with mode: 0644]

diff --git a/.htaccess b/.htaccess
new file mode 100644 (file)
index 0000000..4a19a4d
--- /dev/null
+++ b/.htaccess
@@ -0,0 +1,11 @@
+RewriteEngine On
+RewriteCond %{HTTPS} off
+RewriteRule (.*) http://www.homertonball.com [L]
+
+RewriteRule index.php - [QSA,L]
+RewriteRule (.*) https://www.srcf.ucam.org/hmb/secure/index.php?page=$1 [QSA,L]
+
+AuthType Ucam-WebAuth
+Require valid-user
+Require rjw201
+
diff --git a/index.php b/index.php
new file mode 100644 (file)
index 0000000..e8b091d
--- /dev/null
+++ b/index.php
@@ -0,0 +1,104 @@
+<?php
+
+/**
+ * Homerton May Ball Ticketing System.
+ *
+ * Copyright 2011 Richard Whitehouse for Homerton May Ball 2011
+ **/
+
+class Page {
+
+       public function logic($template){
+               
+       }
+
+}
+
+class Template {
+
+       public function display(){
+
+       }
+
+}
+
+class Ticketing {
+
+       private static $instance;
+
+       public static function Get(){
+               if(!isset(Ticketing::$instance)){
+                       Ticketing::$instance = new Ticketing();
+               }
+
+               return Ticketing::$instance;
+       }
+
+       private $config;
+
+       public function config(){
+               if(!isset($this->config)){
+                       $this->config = Config::Load();
+               }
+               return $config;
+       }
+
+       private $type;
+
+       public function type(){
+               if(!isset($this->type)){
+                       $type = isset($_GET['page']) ? $_GET['page'] : null;
+                       if(isset($type) && file_exists('pages/' . $type . '.php') && file_exists('templates/' . $type . '.php')){
+                               $this->type = $type;
+                       } elseif(file_exists('pages/index.php') && file_exists('templates/index.php')) {
+                               $this->type = 'index';
+                       } else {
+                               throw new Exception('Invalid type');
+                       }
+               }
+               return $this->type;
+       }
+
+       private $page;
+
+       public function page(){
+               if(!isset($this->page)){
+                       require_once('pages/' . $this->type() . '.php');
+                       $class = 'Page_' . $this->type();
+                       $this->page = new $class();
+                       if(!isset($this->page) || !($this->page instanceof Page)){
+                               throw new Exception('Invalid Page Object - ' . $this->type());
+                       }
+               }
+               return $this->page;
+       }
+
+       private $template;
+
+       public function template(){
+               if(!isset($this->template)){
+                       require_once('templates/' . $this->type() . '.php');
+                       $class = 'Template_' . $this->type();
+                       $this->template = new $class();
+                       if(!isset($this->template) || !($this->template instanceof Template)){
+                               throw new Exception('Invalid Template Object - ' . $this->type());
+                       }
+               }
+               return $this->template;
+       }
+
+       public function run(){
+               try {
+
+                       $this->page()->logic($this->template());
+                       $this->template()->display();
+
+               } catch(Exception $e){
+                       header('Content-type: text/plain'); print_r($e); exit;
+               }
+       }
+
+}
+
+Ticketing::Get()->run();
+
diff --git a/pages/index.php b/pages/index.php
new file mode 100644 (file)
index 0000000..ef6a52c
--- /dev/null
@@ -0,0 +1,6 @@
+<?php
+
+class Page_Index extends Page {
+
+
+}
diff --git a/templates/index.php b/templates/index.php
new file mode 100644 (file)
index 0000000..036a849
--- /dev/null
@@ -0,0 +1,6 @@
+<?php
+
+class Template_Index extends Template {
+
+
+}