-
Notifications
You must be signed in to change notification settings - Fork 5
/
index.php
executable file
·101 lines (84 loc) · 2.53 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
<?php
session_start();
if(file_exists(__DIR__.'/needs_installation.php')){
include(__DIR__.'/installer/installer.php');
exit;
}
// Verifies if there is some debug to do
if(file_exists('debug.php')){
$debugEnvironment = true;
include('debug.php');
if(!defined('SH_IS_DEV')){
define('SH_GLOBAL_DEBUG',false);
define('SH_IS_DEV',false);
}
}
// Gets the site name (using the server name)
include('sites/domains_resolver.php');
// Creates all the required constants
require('constants.php');
if(isset($_GET['robots']) && $_GET['robots'] == 'robots'){
if(!SH_IS_DEV){
include(SH_ROOT_FOLDER.'robots.txt');
}else{
include(SH_ROOT_FOLDER.'robots_dev.txt');
}
if(isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) == 'on'){
$protocol='https';
}else{
$protocol='http';
}
$domain = $_SERVER['SERVER_NAME'];
$baseUri = $protocol.'://'.$domain;
echo "\n\n".'Sitemap: '.$baseUri.'/sitemap.xml'."\n";
exit;
}
// Creates the autoload function that will help finding the classes
function __autoload($className) {
if(file_exists(SH_CLASS_FOLDER.$className .'/'.$className.'.cls.php')){
include_once (SH_CLASS_FOLDER.$className .'/'.$className.'.cls.php');
}
return true;
}
// Create the linker object
$linker = sh_linker::getInstance();
$updater = $linker->updater;
define('SH_MOBILE_DEVICE',$linker->session->checkIfIsMobileDevice());
// Verifies if the site can be accessed to any user
$linker->user->siteIsOpen();
// If the file is cached, we show it and exit
if(!$linker->admin->isAdmin()){
/*if(!($linker->rights->getUserRights() & sh_rights::RIGHT_READ)){
$linker->path->error(403);
exit;
}*/
$cache = sh_cache::getCachedFile();
if($cache){
echo $cache;
exit(1);
}
}
// Gets some variables
$element = $linker->path->page['element'];
$action = $linker->path->page['action'];
if(!$linker->$element->isMinimal($action)){
sh_html::$willRender = true;
}
// Redirect to the 404 error page if the required method doesn't exist.
if(!method_exists($linker->$element,$action)){
$linker->path->error('404');
}
$linker->events->onAfterBaseConstruction();
// Calls the method
$linker->$element->$action();
$linker->events->onBeforeOutput();
// If the action is not minimal, we render the html
if(!$linker->$element->isMinimal($action)){
// Renders the document
$linker->html->render();
}
$linker->events->onAfterOutput();
// Ends the debug if it is on
if($debugEnvironment){
endDebug();
}