-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathindex.php
More file actions
116 lines (92 loc) · 3.56 KB
/
index.php
File metadata and controls
116 lines (92 loc) · 3.56 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
<?php
/**
* Website entry.
*
* @link http://github.com/marcoraddatz/candyCMS
* @author Marco Raddatz <http://marcoraddatz.com>
* @version 2.0
* @since 1.0
*
*/
namespace CandyCMS;
# Override separator due to W3C compatibility.
ini_set('arg_separator.output', '&');
# Compress output.
ini_set('zlib.output_compression', "On");
ini_set('zlib.output_compression_level', 9);
# Set standard timezone for PHP5.
date_default_timezone_set('Europe/Berlin');
# Current version we are working with.
define('VERSION', '20111114');
# Define a standard path
define('PATH_STANDARD', dirname(__FILE__));
# Initialize software
try {
require PATH_STANDARD . '/app/config/Candy.inc.php';
require PATH_STANDARD . '/vendor/candyCMS/core/controllers/Index.controller.php';
}
catch (Exception $e) {
die($e->getMessage());
}
# If we are on a productive enviroment, make sure that we can't override the system.
if (WEBSITE_MODE == 'production' && is_dir('install'))
exit('Please install software via <strong>install/</strong> and delete the folder afterwards.');
# Also disable tools to avoid system crashes.
if (WEBSITE_MODE == 'production' && is_dir('tools'))
exit('Please delete the tools folder.');
# Disable tests on productive system.
if (WEBSITE_MODE == 'production' && is_dir('tests'))
exit('Please delete the tests enviroment (tests.php).');
# Disable the use of composer.
if (WEBSITE_MODE == 'production' && is_file('composer.phar'))
exit('Please delete the composer.phar.');
# Override the system variables in development mode.
if (WEBSITE_MODE == 'test') {
ini_set('display_errors', 0);
ini_set('error_reporting', 0);
ini_set('log_errors', 1);
}
else {
ini_set('display_errors', 1);
ini_set('error_reporting', 1);
ini_set('log_errors', 1);
}
# Define current url
define('CURRENT_URL', isset($_SERVER['REQUEST_URI']) ? WEBSITE_URL . $_SERVER['REQUEST_URI'] : WEBSITE_URL);
# Start user session.
@session_start();
# Do we have a mobile device?
if(isset($_SERVER['HTTP_USER_AGENT'])) {
$bMobile = preg_match('/Opera Mini/i', $_SERVER['HTTP_USER_AGENT']) ||
preg_match('/Symb/i', $_SERVER['HTTP_USER_AGENT']) ||
preg_match('/Windows CE/i', $_SERVER['HTTP_USER_AGENT']) ||
preg_match('/IEMobile/i', $_SERVER['HTTP_USER_AGENT']) ||
preg_match('/iPhone/i', $_SERVER['HTTP_USER_AGENT']) ||
preg_match('/iPod/i', $_SERVER['HTTP_USER_AGENT']) ||
preg_match('/Blackberry/i', $_SERVER['HTTP_USER_AGENT']) ||
preg_match('/Android/i', $_SERVER['HTTP_USER_AGENT']) ?
true :
false;
}
else
$bMobile = false;
# Allow mobile access
if(!isset($_REQUEST['mobile']))
$_SESSION['mobile'] = isset($_SESSION['mobile']) ? $_SESSION['mobile'] : $bMobile;
# Override current session if there is a request.
else
$_SESSION['mobile'] = (boolean) $_REQUEST['mobile'];
define('MOBILE', $_SESSION['mobile'] == true ? true : false);
define('MOBILE_DEVICE', $bMobile);
# page called by crawler?
define('CRAWLER', defined('CRAWLERS') ?
preg_match('/' . CRAWLERS . '/', $_SERVER['HTTP_USER_AGENT']) > 0 :
false);
# Check for extensions?
define('EXTENSION_CHECK', ALLOW_EXTENSIONS === true || WEBSITE_MODE == 'development' || WEBSITE_MODE == 'test');
# Initialize software
# @todo extension check
$oIndex = new \CandyCMS\Core\Controllers\Index(array_merge($_GET, $_POST), $_SESSION, $_FILES, $_COOKIE);
# Print out HTML
echo $oIndex->show();
?>