-
Notifications
You must be signed in to change notification settings - Fork 0
/
routes.php
executable file
·52 lines (47 loc) · 1.7 KB
/
routes.php
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
52
<?php
$GLOBALS['api_routes'] = array(
'api/testing' => array('functions.php', 'testingFunction'),
'api/printEpisodes' => array('functions.php', 'printEpisodes'),
'api/admin' => array('functions.php', 'admin'),
);
$GLOBALS['routes'] = array(
'' => 'home.php',
'search' => 'search.php',
'about' => 'about.php',
'cards' => 'components/cards.php',
'carousel' => 'components/carousel.php',
'collections' => 'collections.php',
'collection' => 'collection.php',
'collection-records' => 'collection-records.php',
'drawers' => 'components/drawers.php',
'essays' => 'essays.php',
'essay' => 'essay.php',
'fullRecord' => 'components/fullrecord.php',
'tabs' => 'components/tabs.php',
'modal' => 'components/modal.php',
'admin' => 'admin.php',
'searchbar-results' => '../modules/searchbar/searchbar-results.php'
);
if( !isset($_SERVER['HTTP_HOST']) ){
define('CURRENT_VIEW', 'home.php');
return;
}
//$location = (isset($_SERVER['HTTPS']) ? "https" : "http") . "://$_SERVER[HTTP_HOST]";
$location = "https://$_SERVER[HTTP_HOST]";
$path = parse_url($_SERVER['REQUEST_URI'])['path'];
$actualLink = $location . $path;
$currentFile = str_replace(BASE_URL, '', $actualLink);
if( substr($currentFile, -1) == '/' ){
$currentFile = rtrim($currentFile,"/");
}
if( isset($GLOBALS['api_routes'][$currentFile]) ){
$currentApiFile = $GLOBALS['api_routes'][$currentFile];
include_once(BASE_FUNCTIONS_PATH.$currentApiFile[0]);
echo $currentApiFile[1]();
die;
}elseif( !isset($GLOBALS['routes'][$currentFile]) ){
header('HTTP/1.0 404 Not Found');
define('CURRENT_VIEW', '404.php');
}else{
define('CURRENT_VIEW', $GLOBALS['routes'][$currentFile]);
}