-
Notifications
You must be signed in to change notification settings - Fork 2
/
index.php
345 lines (298 loc) · 10.4 KB
/
index.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
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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
<?php
/**
* Set root folder, you can overwrite this value by including this script from another script and defining the variable $root in the other script
*/
if(!isset($root)){
$root = getcwd();
}
/**
* Send default header in utf-8
*/
header('content-type: text/html; charset=utf-8');
/**
* include configuration
*/
require_once($root . "/xt/includes/config.inc.php");
/**
* load core license
*/
if(function_exists("zend_loader_install_license")){
@zend_loader_install_license(LICENCES_DIR . $GLOBALS['cfg']->get("system","order_nr") . "_ch.iframe.snode.core.zl",1);
}
/**
* start benchmarking
*/
$GLOBALS['cfg']->get("system","benchmarking") ? $time_start = microtime(true) : null;
/**
* start output buffering
*/
$GLOBALS['cfg']->get("system","compression") ? ob_start("ob_gzhandler") : ob_start();
/**
* set locales
*/
setlocale (LC_TIME, 'de_DE@euro', 'de_CH', 'de', 'ge');
/**
* set error reporting
*/
error_reporting($GLOBALS['cfg']->get("system", "error_reporting"));
/**
* include classes
*/
require_once(CLASS_DIR . "logger.class.php"); // load logging class
require_once(CLASS_DIR . 'xt.class.php'); // load core api class
require_once(CLASS_DIR . 'user.class.php'); // load user handling class
require_once(CLASS_DIR . 'application.class.php'); // load application class
/**
* load includes
*/
//require_once(INCLUDE_DIR . "compatibility.inc.php"); // Compatibility for PHP < 5.0
require_once(INCLUDE_DIR . "db.inc.php"); // database connection
require_once(INCLUDE_DIR . "auth.inc.php"); // authentication
/**
* load permission class
*/
require(CLASS_DIR . 'perm.class.php');
/**
* Create permission object
*/
global $perm;
$GLOBALS['perm'] = new XT_Perm();
// css and scriptloader
global $loadedcss;
global $loadedscripts;
/**
* load language stuff
*/
require_once(INCLUDE_DIR . "lang.inc.php");
/**
* Set default theme values
*/
if(@$_GET['theme'] != ''){
$_SESSION['theme'] = addslashes($_GET['theme']);
} else {
if(!isset($_SESSION['theme']) || $_SESSION['theme'] == ''){
$_SESSION['theme'] = $GLOBALS['cfg']->get("system", "theme");
}
}
/**
* load template engine
*/
require_once(INCLUDE_DIR . "template.inc.php"); // embedded template engine
/**
* declare global variables
*/
global $logger; // logger
global $usr; // user object
global $tpl_id; // template id
global $relations;
/**
* create objects
*/
$GLOBALS['logger'] = new XT_Logger();
$GLOBALS['usr'] = new XT_User();
/**
* Get and set requested template if there is one
*/
global $tpl_id;
if(is_numeric(addslashes(@$_REQUEST['TPL']))){
$tpl_id = addslashes($_REQUEST['TPL']);
}else{
// get default tpl for the requested domain
if($GLOBALS['cfg']->get("domain", $_SERVER['HTTP_HOST'])){
$tpl_id = $GLOBALS['cfg']->get("domain", $_SERVER['HTTP_HOST']);
}else{
$tpl_id = $GLOBALS['cfg']->get("system", "tpl");
}
}
// Initialize content stack
global $pagecontents;
$GLOBALS['pagecontents'] = array();
// Get template information
global $pagetitle;
$GLOBALS['pagetitle'] = 'Unknown';
$GLOBALS['realtitle'] = 'Unknown';
if(LANGFILE !='LANGFILE'){
XT::assign("INDEX_PHP", LANGFILE);
}else{
XT::assign("INDEX_PHP", 'index.php');
}
// Assign default values
XT::assign("TIME", TIME);
XT::assign("SYSTEM_LANG", $GLOBALS['lang']->getLang());
XT::assign("SYSTEM_NAME", $GLOBALS['cfg']->get("system","name"));
XT::assign("SYSTEM_EMAIL", $GLOBALS['cfg']->get("system","email"));
XT::assign("SYSTEM_META_TITLE", $GLOBALS['cfg']->get("system","base_meta_title"));
XT::assign("SYSTEM_META_DESCRIPTION", $GLOBALS['cfg']->get("system","base_meta_description"));
XT::assign("SYSTEM_META_KEYWORDS", $GLOBALS['cfg']->get("system","base_meta_keywords"));
XT::assign("SYSTEM_META_COPYRIGHT", $GLOBALS['cfg']->get("system","base_meta_copyright"));
XT::assign("SYSTEM_META_AUTHOR", $GLOBALS['cfg']->get("system","base_meta_author"));
XT::assign("SYSTEM_META_REVISIT_AFTER", $GLOBALS['cfg']->get("system","base_meta_revisit_after"));
XT::assign("SYSTEM_PIWIK_ID", $GLOBALS['cfg']->get("system","piwik_id"));
XT::assign("SYSTEM_GOOGLE_ANALYTICS_KEY", $GLOBALS['cfg']->get("system","google_analytics_key"));
XT::assign("SYSTEM_GOOGLE_MAP_KEY", $GLOBALS['cfg']->get("system","google_map_key"));
XT::assign("XT_THEME", $GLOBALS['cfg']->get("system","theme"));
XT::assign("AUTH", $GLOBALS['auth']->isAuth());
XT::assign("XT_IMAGES", IMAGE_DIR);
XT::assign("XT_STYLES", STYLES_DIR);
XT::assign("XT_SCRIPTS", SCRIPTS_DIR);
XT::assign("XT_TOOLS", TOOLS_DIR);
XT::assign("XT_WEB_ROOT", REL_ROOT);
XT::assign("THEME",$_SESSION['theme']);
XT::assign("THEME_IMAGES",IMAGE_DIR . $_SESSION['theme'] . "/");
// Assign permanent assigns
if(is_array(@$_SESSION['ASSIGN'])){
foreach ($_SESSION['ASSIGN'] as $key => $value){
XT::assign($key, $value);
}
}
// Get all information for a reuested tpl/page
global $application;
$application = new XT_Application();
$result = XT::query("
SELECT
a.node_id,
a.title,
a.pagetitle,
a.tpl_file,
a.live,
a.active,
a.cache,
a.public,
a.description,
a.keywords,
a.author,
a.revisit_after,
a.copyright,
a.c_lang,
a.header,
a.footer,
a.css,
a.image
FROM
" . XT::getDatabasePrefix() . "navigation_details as a
WHERE
a.node_id = " . $tpl_id . "
AND a.lang = '" . $GLOBALS['lang']->getLang() . "'",__FILE__,__LINE__);
if($row = $result->FetchRow()){
/**
* get template information and assign them
*/
// if this page is not public
if($row['public'] != 1){
// Check permissions
if(!XT::getNodePermission($row['node_id'],5,$GLOBALS['application']->getParentID())){
header("Location: " . $_SERVER['PHP_SELF'] . "?TPL=" . $GLOBALS['cfg']->get("system", "tpl_login") . "&x110_url=" . urlencode($_SERVER['REQUEST_URI']));
die();
}
}
$GLOBALS['pagetitle'] = $GLOBALS['cfg']->get("system", "base_meta_title") . $row['title'] ;
$GLOBALS['realtitle'] = $row['title'];
if(!empty($row['pagetitle'])){
$GLOBALS['pagetitle'] = $row['pagetitle'] . " " . $GLOBALS['cfg']->get("system", "base_meta_title");
$GLOBALS['realtitle'] = $row['pagetitle'];
}
XT::assign("TPL_TITLE", $GLOBALS['pagetitle']);
XT::assign("TPL_REAL_TITLE", $row['title']);
XT::assign("TPL_FILE", $row['tpl_file']);
XT::assign("TPL_ACTIVE", $row['active']);
XT::assign("TPL_HEADER", $row['header']);
XT::assign("TPL_FOOTER", $row['footer']);
XT::assign("TPL_CSS", $row['css']);
XT::assign("TPL_IMAGE", $row['image']);
XT::assign("TPL_DESC", $row['description']);
XT::assign("WAY", $GLOBALS['application']->getWayInfo());
//inherited headimage
foreach ($GLOBALS['application']->getWayInfo() as $key => $value){
if($value['headimage'] > 0){
$headimg = $value['headimage'];
}
}
// get image type
if($headimg > 0){
$result = XT::query("SELECT type FROM " . XT::getDatabasePrefix() . "files WHERE id = " . $headimg,__FILE__,__LINE__);
}
$headimg_type= $result->FetchRow();
XT::assign("HEADIMAGE_TYPE", $headimg_type['type']);
XT::assign("HEADIMAGE", $headimg);
unset($headimg);
// Add page to content stack
XT::addToContentStack(60,$row['node_id'], $row['title']);
$meta_description = $row['description'] != '' ? $row['description'] : $GLOBALS['cfg']->get("system", "base_meta_description");
global $pagedescription;
$GLOBALS['pagedescription'] = $meta_description;
$meta_keywords = $row['keywords'] != '' ? $row['keywords'] : $GLOBALS['cfg']->get("system", "base_meta_keywords");
global $pagekeywords;
$GLOBALS['pagekeywords'] = $meta_keywords;
$meta_author = $row['author'] != '' ? $row['author'] : $GLOBALS['cfg']->get("system", "base_meta_author");
$meta_copyright = $row['copyright'] != '' ? $row['copyright'] : $GLOBALS['cfg']->get("system", "base_meta_copyright");
$meta_revisit_after = $row['revisit_after'] != '' ? $row['revisit_after'] : $GLOBALS['cfg']->get("system", "base_meta_revisit_after");
$meta_content_lang = $row['c_lang'];
$tpl_file = $row['tpl_file'];
XT::assign("TPL",$GLOBALS['tpl_id']);
/**
* include meta tags
*/
require_once(INCLUDE_DIR . "metatags.inc.php");
/**
* Assign meta tags
*/
XT::assign("META", implode("\n ", $GLOBALS['meta']));
/**
* include user tracking
*/
$GLOBALS['cfg']->get("system","tracking_mode") > 0 ? require_once(INCLUDE_DIR . "tracking.inc.php") : null;
/**
* Display requested template
*/
unset($tpl_buffer);
if($row['active'] != 1 && !XT::getNodePermission($row['node_id'],8,$GLOBALS['application']->getParentID())){
$tpl_buffer = "";
// Display page not available message
if(!empty($row['header'])){
$tpl_buffer = $GLOBALS['tpl']->fetch("includes/header/" . $row['header']);
} else {
$tpl_buffer = $GLOBALS['tpl']->fetch("includes/header/header.tpl");
}
$tpl_buffer .= $GLOBALS['tpl']->fetchPage('includes/errorpages/template_notavailable.tpl');
if(!empty($row['footer'])){
$tpl_buffer .= $GLOBALS['tpl']->fetch("includes/footer/" . $row['footer']);
} else {
$tpl_buffer .= $GLOBALS['tpl']->fetch("includes/footer/footer.tpl");
}
echo processContent($tpl_buffer);
} else {
$tpl_buffer = "";
// Print out the content with header and footer
if(!empty($row['header'])){
$tpl_buffer = $GLOBALS['tpl']->fetch("includes/header/" . $row['header']);
}
$tpl_buffer .= $GLOBALS['tpl']->fetchPage($tpl_file);
if(!empty($row['footer'])){
$tpl_buffer .= $GLOBALS['tpl']->fetch("includes/footer/" . $row['footer']);
}
echo processContent($tpl_buffer);
}
} else {
// Print the error TPL not found
$tpl_buffer = $GLOBALS['tpl']->fetch("includes/header/header.tpl");
$tpl_buffer .= $GLOBALS['tpl']->fetchPage('includes/errorpages/template_notfound.tpl');
$tpl_buffer .= $GLOBALS['tpl']->fetch("includes/footer/footer.tpl");
echo processContent($tpl_buffer);
}
/**
* Close database
*/
$GLOBALS['db']->close();
/**
* display benchmarking results
*/
if($GLOBALS['cfg']->get("system","benchmarking")){
$time_end = microtime(true);
$time = $time_end - $time_start;
echo "\n<!-- parsed in " . $time . "s -->";
}
/**
* Output contents
*/
ob_end_flush();
?>