aboutsummaryrefslogtreecommitdiff
path: root/index.php
diff options
context:
space:
mode:
authorCamil Staps2015-02-05 00:40:47 +0100
committerCamil Staps2015-02-05 00:40:47 +0100
commitc50a323c25a0787ba2051b19721983776a229615 (patch)
tree87e13060ca6633bed3f5de2e25c5eedf866a0073 /index.php
parentInitial commit (diff)
Initial commit
Diffstat (limited to 'index.php')
-rw-r--r--index.php66
1 files changed, 66 insertions, 0 deletions
diff --git a/index.php b/index.php
new file mode 100644
index 0000000..238b72e
--- /dev/null
+++ b/index.php
@@ -0,0 +1,66 @@
+<?php
+/**
+ * Landing page
+ *
+ * This handles basically all requests. Every request not to an existing file path, should be redirected here.
+ * This file checks basic configuration and includes the required page, based on the REQUEST_URI.
+ *
+ * @author Camil Staps
+ *
+ * BusinessAdmin: administrative software for small companies
+ * Copyright (C) 2015 Camil Staps (ViviSoft)
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+/**
+ * Load the basic configuration (sessions, database, class autoloading, etc.)
+ */
+require_once('./conf.php');
+
+// Fetch information from the REQUEST_URI.
+$_request = parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH);
+$_request = str_replace(constants::url_internal, '', $_request);
+
+// This is the REQUEST_URI switch
+// The default shows a 404 page
+$pages = array(
+ '' => './include/home.php',
+ '/clients' => './include/clients.php',
+ '/clients/new' => './include/clients-new.php',
+ '/clients/edit' => './include/clients-edit.php',
+ '/contacts' => './include/contacts.php',
+ '/contacts/new' => './include/contacts-new.php',
+ '/contacts/edit' => './include/contacts-edit.php',
+ '/offers' => './include/offers.php',
+ '/offers/new' => './include/offers-new.php',
+ '/offers/edit' => './include/offers-edit.php',
+ '/assignments' => './include/assignments.php',
+ '/assignments/new' => './include/assignments-new.php',
+ '/assignments/edit' => './include/assignments-edit.php',
+ '/about' => './include/about.php'
+);
+$_page = null;
+foreach ($pages as $uri => $path) {
+ if ($_request == $uri && file_exists($path)) {
+ $_page = $uri;
+ require($path);
+ break;
+ }
+}
+if ($_page === null) {
+ $_page = '/404';
+ http_response_code(404);
+ require('./include/404.php');
+} \ No newline at end of file