:-( missed this file last commit
authorDylan Lloyd <dylan@dylansserver.com>
Fri, 23 Mar 2012 09:25:05 +0000 (05:25 -0400)
committerDylan Lloyd <dylan@dylansserver.com>
Fri, 23 Mar 2012 09:25:05 +0000 (05:25 -0400)
controller.php [new file with mode: 0644]

diff --git a/controller.php b/controller.php
new file mode 100644 (file)
index 0000000..833712d
--- /dev/null
@@ -0,0 +1,83 @@
+<?php
+
+require_once("model/model.php");
+
+abstract class cms {
+
+  public function __construct() {
+    $this->model = new model();
+  }
+
+  public static function determine_type() {
+    if (isset($_GET['page']) && is_numeric($_GET['page'])) {
+      return 'page';
+    } else if (isset($_GET['year'])) {
+      return 'archive';
+    } else if (isset($_GET['note'])) {
+      return 'note';
+    } else if ($_SERVER['REQUEST_URI'] == '/') {
+      return 'index';
+    } else if (isset($_GET['project'])) {
+      return 'project';
+       } else if (isset($_GET['rss'])) {
+         return 'rss';
+       } else if (isset($_GET['challenge'])) {
+      return 'captcha';
+    }
+  }
+
+  public function init() {
+    switch (cms::determine_type()) {
+      case 'index':
+        require_once("model/index.php");
+        $index = new index();
+        $index->display();
+        break;
+      case 'project':
+        require_once("model/project.php");
+        $project = new project();
+        $project->display();
+        break;
+      case 'note':
+        require_once("model/note.php");
+        $note = new note();
+        $note->display();
+        break;
+      case 'page':
+        require_once("model/page.php");
+        $page = new page();
+        $page->display();
+        break;
+      case "rss":
+        require_once("model/rss.php");
+        $rss = new rss();
+        $rss->display();
+        break;
+      case 'archive':
+        require_once("model/archive.php");
+        $archive = new archive();
+        $archive->display();
+        break;
+      case "captcha":
+        require_once("model/captcha.php");
+        $captcha = new captcha();
+        $captcha->display();
+        break;
+    }
+  }
+
+}
+
+class notFound extends Exception {
+
+    public function __construct() {
+      header('HTTP/1.0 404 Not Found');
+      ob_end_clean();
+      include('404.php');
+      exit();
+    }
+
+}
+
+
+?>