-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinit.php
More file actions
40 lines (33 loc) · 1.45 KB
/
init.php
File metadata and controls
40 lines (33 loc) · 1.45 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
<?php
// Define the project CONSTANTS
if (!defined('PUBLIC_FOLDER_ROOT')) {
define('PUBLIC_FOLDER_ROOT', $_SERVER['DOCUMENT_ROOT']);
}
if(!defined('PUBLIC_FOLDER_NAME')){
define('PUBLIC_FOLDER_NAME', 'public');
}
if(!defined('SECURE_FOLDER_NAME')){
define('SECURE_FOLDER_NAME', 'secure');
}
if(!defined('PUBLIC_FOLDER_SPACE')){
define('PUBLIC_FOLDER_SPACE', '');
}
// PUBLIC_CONTENT_PATH = the live directory where site content lives (style/, assets/, scripts/)
// When a space is defined (e.g. 'quicksite'), content is at PUBLIC_FOLDER_ROOT/quicksite/
// When no space is used, content is at PUBLIC_FOLDER_ROOT directly
if (!defined('PUBLIC_CONTENT_PATH')) {
define('PUBLIC_CONTENT_PATH', PUBLIC_FOLDER_SPACE !== ''
? PUBLIC_FOLDER_ROOT . '/' . PUBLIC_FOLDER_SPACE
: PUBLIC_FOLDER_ROOT);
}
if(!defined('SERVER_ROOT')){
// Remove only the rightmost occurrence of PUBLIC_FOLDER_NAME from path
// This prevents issues when folder name appears multiple times in path
// e.g., C:/wamp64/www/mysite/www -> C:/wamp64/www/mysite/ (not C:/wamp64//mysite/)
$folderPattern = '/' . preg_quote(PUBLIC_FOLDER_NAME, '/') . '[\\\\\\/]?$/';
define('SERVER_ROOT', rtrim(preg_replace($folderPattern, '', PUBLIC_FOLDER_ROOT), '/\\'));
}
if (!defined('SECURE_FOLDER_PATH')) {
// SECURE_FOLDER_PATH = engine files (admin, management, src)
define('SECURE_FOLDER_PATH', SERVER_ROOT . DIRECTORY_SEPARATOR . SECURE_FOLDER_NAME);
}