-
Notifications
You must be signed in to change notification settings - Fork 0
/
redirect.php
73 lines (64 loc) · 1.92 KB
/
redirect.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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
<?php
include('include/config.inc.php');
/* This is the main page of the project
Redirects all the index.php?/home/url to the correct template, with the appropriate content.
*/
$page = new stdClass;
// Saving the URL and each part of the URL
$page->full_url=$_SERVER['REQUEST_URI'];
$page->url_array = explode ('/',$page->full_url);
// Remove the useless part of the URL in the tab
$i = 0;
$flag = 0;
array_shift($page->url_array); // Shift the array once to remove the first empty cell
foreach ($page->url_array as $cell) {
$i++;
if (strpos($cell, "?") != FALSE) { // Detect the filename to begin store the URL
while ($i>0) {
array_shift($page->url_array); // Remove unused part of the URL
$i--;
}
$flag = 1;
break;
}
}
// Test to redirect "", "?toto" URLs to the homepage
if ($flag == 0 || $page->url_array == NULL || $page->url_array[0] == "") {
unset($page->url_array);
header('Location: '.$_SERVER["SCRIPT_NAME"].'?/home');
}
// Switching between each
switch ($page->url_array[0]) {
case "home":
$page->theme = "orange";
$page->template = "home";
break;
case "guides":
$page->theme = "dark";
$page->template = "guides";
break;
case "shelters":
$page->theme = "purple";
$page->template = "shelters";
break;
case "carpooling":
$page->theme = "blue";
$page->template = "carpooling";
break;
default:
$page->theme = "orange";
$page->template = "home";
$page->url_array[1] = "404";
break;
}
include("templates/".$page->template.".php");
include("include/create_page.php");
if (!isset($page->url_array[1])) { $page->url_array[1] = NULL; }
if (!isset($page->url_array[2])) { $page->url_array[2] = NULL; }
html_head($page->theme, $page->template, $page->title, $page->url_array[1],$page->url_array[2]);
site_header($page->theme, $config->sitename);
site_nav($page->theme, $page->title);
site_content($page->url_array[1],$page->url_array[2], $config);
site_footer($page->theme, $page->title);
html_end();
?>