-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathfront-controller.php
More file actions
51 lines (40 loc) · 1.4 KB
/
front-controller.php
File metadata and controls
51 lines (40 loc) · 1.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
<?php
ob_start();
session_start();
$q = $_GET['q'];
$path = preg_replace('/\/$|.php/', '', $q);
if(empty($path)) { // HOME
$file = 'index';
} elseif(file_exists("views/$path.php")) { // PAGE
$file = $path;
} else { // NOT FOUND
$file = '404';
}
$isHome = ($q == '');
$isProgress = preg_match('#progress/?$#', $q);
$isAbout = preg_match('#about-cell-industries/?$#', $q);
$isTechnology = preg_match('#technology/?$#', $q);
$isCloningProcess = preg_match('#the-cloning-process/?$#', $q);
$isUser = preg_match('#user\/[0-9a-zA-Z]+/?$#', $q);
$isEnv = preg_match('#env\/\d+/?$#', $q);
$isNewEnv = preg_match('#env\/new/?$#', $q);
$isRecentlyClonedEnvs = preg_match('#recently-cloned-environments/?$#', $q);
$isCapturing = preg_match('#capturing-environment#', $q);
$currentUrl = "http://{$_SERVER['HTTP_HOST']}{$_SERVER['REQUEST_URI']}";
if($isProgress) {
require_once('model-progress.php');
}
if($isUser) {
require_once('model-user.php');
}
if($isEnv) {
require_once('model-environment.php');
}
if($isNewEnv) {
$file = 'new-environment';
}
if($isRecentlyClonedEnvs) {
require_once('model-recently-cloned-environments.php');
$file = 'recently-cloned-environments';
}
require_once('front-view.php');