-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.php
More file actions
133 lines (108 loc) · 3.86 KB
/
index.php
File metadata and controls
133 lines (108 loc) · 3.86 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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
<?php
/**
* Index
*
* Where it all starts
*
* @package GetSimple Extended
* @subpackage FrontEnd
*/
/* pre-common setup, load gsconfig and get GSADMIN path */
/* GSCONFIG definitions */
if (!defined('GSFRONT')) define('GSFRONT', 1);
if (!defined('GSBACK')) define('GSBACK', 2);
if (!defined('GSBOTH')) define('GSBOTH', 3);
# Check and load gsconfig
if (file_exists('gsconfig.php')) require_once('gsconfig.php');
# Apply GSADMIN env
$GSADMIN = defined('GSADMIN') ? GSADMIN : 'admin';
# setup paths
# @todo wtf are these for ?
$admin_relative = $GSADMIN . '/inc/';
$lang_relative = $GSADMIN . '/';
$load['plugin'] = true;
$base = true;
/* end */
# Include common.php
include($GSADMIN . '/inc/common.php');
exec_action('index-header');
# get page id (url slug) that is being passed via .htaccess mod_rewrite
$id = isset($_GET['id']) ? lowercase(str_replace(array('..', '/'), '', $_GET['id'])) : 'index';
// filter to modify page id request
$id = exec_filter('indexid', $id);
// $_GET['id'] = $id; // support for plugins that are checking get?
$GSCANONICAL = getDef('GSCANONICAL', true);
// define page
if ($dataw->maintenance == '1' && (!is_logged_in() || $datau->accessFrontMaintenance != '1')) {
// apply page data if maintance mode enabled
$data_index = getXml(GSDATAOTHERPATH . '503.xml');
if ($data_index) {
header($_SERVER['SERVER_PROTOCOL'] . ' 503 Service Unavailable');
$GSCANONICAL = false;
} else {
redirect('503');
}
} elseif (isset($pagesArray[$id])) {
// apply page data if page id exists
$data_index = getXml(GSDATAPAGESPATH . $id . '.xml');
} else {
$data_index = null;
}
// filter to modify data_index obj
$data_index = exec_filter('data_index', $data_index);
// page not found handling
if (!$data_index || $data_index->private == '2') {
if (file_exists(GSDATAOTHERPATH . '404.xml')) {
// default 404
$data_index = getXml(GSDATAOTHERPATH . '404.xml');
$GSCANONICAL = false;
} else {
// fail over
redirect('404');
}
exec_action('error-404');
header($_SERVER['SERVER_PROTOCOL'] . ' 404 Not Found');
}
// if page is private, check user
if ($data_index->private == 'Y' || $data_index->private == '1' && !is_logged_in()) {
if (file_exists(GSDATAOTHERPATH . '403.xml')) {
// default 403
$data_index = getXml(GSDATAOTHERPATH . '403.xml');
$GSCANONICAL = false;
} else {
// fail over
redirect('403');
}
exec_action('error-403');
header($_SERVER['SERVER_PROTOCOL'] . ' 403 Forbidden');
}
$title = $data_index->title;
$date = $data_index->pubDate;
$metak = $data_index->meta;
$metad = $data_index->metad;
$url = $data_index->url;
$parent = $data_index->parent;
$template_file = $data_index->template;
$private = $data_index->private;
$content = $data_index->content;
// after fields from dataindex, can modify globals here or do whatever by checking them
exec_action('index-post-dataindex');
# check for correctly formed url
if ($GSCANONICAL == true) {
if (strpos($_SERVER['REQUEST_URI'], find_url($url, false)) !== 0) {
$query = $_GET;
unset($query['id']);
header($_SERVER['SERVER_PROTOCOL'] . ' 301 Moved');
header('Cache-Control: no-cache');
header('Location: ' . find_url($url, true, $query));
}
}
# include the functions.php page if it exists within the theme
if (file_exists(GSTHEMESPATH . $TEMPLATE . '/functions.php')) include(GSTHEMESPATH . $TEMPLATE . '/functions.php');
# call pretemplate Hook
exec_action('index-pretemplate');
# include the template and template file set within theme.php and each page
if ((!file_exists(GSTHEMESPATH . $TEMPLATE . '/' . $template_file)) || ($template_file == '')) $template_file = 'template.php';
include(GSTHEMESPATH . $TEMPLATE . '/' . $template_file);
# call posttemplate Hook
exec_action('index-posttemplate');