This repository has been archived by the owner on Oct 16, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
config.php
122 lines (99 loc) · 3.51 KB
/
config.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
<?php
class Config {
/**
* This is the array of development urls
*
* @var array
*/
public $developmentUrls = array(
'localhost',
'127.0.0.1',
'::1'
);
/**
* This is the array of frontend scripts
* to include at the bottom of the body
*
* @var array
*/
public $frontendScripts = array();
public function __construct() {
// check if address is using https or http
if (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on') {
$urlPrefix = 'https://';
} else {
$urlPrefix = 'http://';
}
// check if the server is running on localhost
if (in_array($_SERVER['SERVER_NAME'], $this->developmentUrls)) {
// get the url suffix for the local hosting
// example: http://localhost/{suffix}/r5reloaded.com
$url = $_SERVER['REQUEST_URI'];
$urlChunks = explode('/', $url);
$urlSuffix = '';
foreach ($urlChunks as $chunk) {
// skip if the chunk is empty
if ($chunk == '') {
continue;
}
// break if the chunk is the website name
if ($chunk == 'r5reloaded.com') {
break;
}
// add the chunk to the url suffix
$urlSuffix .= '/' . $chunk;
}
// this is a local website url
define('SERVERPATH', $urlPrefix . $_SERVER['SERVER_NAME'] . $urlSuffix . '/r5reloaded.com');
} else {
// this is the website url
define('SERVERPATH', $urlPrefix . $_SERVER['SERVER_NAME']);
}
// this is the path to the root folder
define('ROOTPATH', dirname(__FILE__));
// this is url to the public folder
define('PUBLICPATH', SERVERPATH . '/public');
// this is the path to the public folder
define('RPUBLICPATH', ROOTPATH . '/public');
// this is url to the components folder
define('COMPONENTSPATH', SERVERPATH . '/components');
// this is the path to the components folder
define('RCOMPONENTSPATH', ROOTPATH . '/components');
// this is url to the styles folder
define('STYLESPATH', SERVERPATH . '/styles');
// this is the path to the styles folder
define('RSTYLESPATH', ROOTPATH . '/styles');
// this is url to the lib folder
define('LIBPATH', SERVERPATH . '/lib');
// this is the path to the lib folder
define('RLIBPATH', ROOTPATH . '/lib');
// this is url to the cache folder
define('CACHEPATH', SERVERPATH . '/.cache');
// this is the path to the cache folder
define('RCACHEPATH', ROOTPATH . '/.cache');
// Modules ----------------------------------------
//this is url to the server-list module
define('SERVERLISTPATH', SERVERPATH . '/server-list');
// this is the path to the server-list module
define('RSERVERLISTPATH', ROOTPATH . '/server-list');
}
/**
* This function adds a frontend script to the array
*
* @param string $scriptPath
* @return void
*/
public function addFrontendScript($scriptPath) {
$this->frontendScripts[] = $scriptPath;
}
/**
* This function returns the array of frontend scripts
*
* @return array
*/
public function getFrontendScripts() {
return $this->frontendScripts;
}
}
$CONFIG = new Config();
?>