-
Notifications
You must be signed in to change notification settings - Fork 80
/
paths.php
287 lines (243 loc) · 8.56 KB
/
paths.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
<?php
/**
* Module: paths.php
* Description: This module sets global file folder paths. Also houses
* specific, site-wide variables.
*
* The following are file path definitions for various
* script and document storage folders used/accessed by the
* application.
*/
define('ROOT',dirname( __FILE__ ).DIRECTORY_SEPARATOR);
define('ADMIN',ROOT.'admin'.DIRECTORY_SEPARATOR);
define('SSO',ROOT.'sso'.DIRECTORY_SEPARATOR);
define('EVALS',ROOT.'eval'.DIRECTORY_SEPARATOR);
define('CLASSES',ROOT.'classes'.DIRECTORY_SEPARATOR);
define('CONFIG',ROOT.'site'.DIRECTORY_SEPARATOR);
define('DB',ROOT.'includes'.DIRECTORY_SEPARATOR.'db'.DIRECTORY_SEPARATOR);
define('IMAGES',ROOT.'images'.DIRECTORY_SEPARATOR);
define('INCLUDES',ROOT.'includes'.DIRECTORY_SEPARATOR);
define('LIB',ROOT.'lib'.DIRECTORY_SEPARATOR);
define('MODS',ROOT.'mods'.DIRECTORY_SEPARATOR);
define('PROCESS',ROOT.'includes'.DIRECTORY_SEPARATOR.'process'.DIRECTORY_SEPARATOR);
define('SECTIONS',ROOT.'sections'.DIRECTORY_SEPARATOR);
define('COMPONENTS',ROOT.'components'.DIRECTORY_SEPARATOR);
define('TEMPLATES',ROOT.'templates'.DIRECTORY_SEPARATOR);
define('SETUP',ROOT.'setup'.DIRECTORY_SEPARATOR);
define('UPDATE',ROOT.'update'.DIRECTORY_SEPARATOR);
define('OUTPUT',ROOT.'output'.DIRECTORY_SEPARATOR);
define('USER_IMAGES',ROOT.'user_images'.DIRECTORY_SEPARATOR);
define('USER_DOCS',ROOT.'user_docs'.DIRECTORY_SEPARATOR);
define('USER_TEMP',ROOT.'user_temp'.DIRECTORY_SEPARATOR);
define('LANG',ROOT.'lang'.DIRECTORY_SEPARATOR);
define('DEBUGGING',ROOT.'includes'.DIRECTORY_SEPARATOR.'debug'.DIRECTORY_SEPARATOR);
define('AJAX',ROOT.'ajax'.DIRECTORY_SEPARATOR);
/**
* --------------------------------------------------------
* Global Definitions
* --------------------------------------------------------
*/
/**
* The following are for use by the developer
* Default for all is FALSE
*/
define('HOSTED', FALSE);
define('NHC', FALSE);
define('SINGLE', FALSE);
define('EVALUATION', TRUE);
/**
* Enable to following to put your installation into
* "mainenance mode" - bypasses the default index.php script
* and displays the maintenance.php file to alert visitors.
* Default is FALSE.
*/
define('MAINT', FALSE);
/**
* Disable the following to utilize the Load Libraries
* Locally option if your installation is having trouble
* loading libraries via CDN or if you wish to host libraries
* in the root folder of your installation.
* If set to FALSE, the local libraries must be in place
* PRIOR to proceeding through the setup process.
* @see http://www.brewingcompetitions.com/local-load
* Default is TRUE.
*/
define('CDN', TRUE);
/**
* Enable the following to put the site into "test mode"
* Useful for testing the PayPal IPN functions in their
* sandbox environment, etc.
* Default is FALSE.
*/
define('TESTING', FALSE);
/**
* Enable the following to display php errors on screen.
* Default is FALSE.
*/
define('DEBUG', FALSE);
/**
* Enable the following to show a collapsable table of all
* session variables on screen.
* Default is FALSE.
*/
define('DEBUG_SESSION_VARS', FALSE);
/**
* Enable the following when receiving mySQL "column does
* not exist" errors and the like.
* This will trigger DB structure updates contained in the
* run_update.php file.
* ONLY enbable for a single refresh of the index.php
* page for performance issues.
* Default is FALSE.
*/
define('FORCE_UPDATE', FALSE);
/**
* Set the following to TRUE if receiving mod_security
* "Not Acceptable!" errors. This may not alleviate the
* problem, but it's a good first step in diagnosing
* why some mod_security errors are occurring.
* Default is FALSE.
*/
define('ENABLE_MARKDOWN', FALSE);
/**
* Set the following to TRUE if you would like to use
* PHPMailer to send emails from your BCOE&M installation.
* PHPMailer uses your server's SMTP configuration to send
* emails instead of using PHP's native mail() function,
* which may be disabled on certain web hosts.
* Requires configuration in the /site/config.mail.php file
* Default is FALSE.
*/
define('ENABLE_MAILER', FALSE);
/**
* Error Reporting
*/
ini_set('error_reporting', E_ALL ^ E_DEPRECATED);
ini_set('log_errors','On');
if (DEBUG) ini_set('display_errors','On');
else ini_set('display_errors','Off');
/**
* Function to check for HTTPS protocol (SSL) will be
* called when constructing the $base_url variable in the
* /sites/config.php file.
* @see https://github.com/geoffhumphrey/brewcompetitiononlineentry/issues/1123
* @see https://stackoverflow.com/questions/1175096/how-to-find-out-if-youre-using-https-without-serverhttps
*/
function is_https() {
if (((!empty($_SERVER['HTTPS'])) && (strtolower($_SERVER['HTTPS']) !== "off")) || ((isset($_SERVER['SERVER_PORT'])) && ($_SERVER['SERVER_PORT'] === "443"))) return TRUE;
elseif (((!empty($_SERVER['HTTP_X_FORWARDED_PROTO'])) && (strtolower($_SERVER['HTTP_X_FORWARDED_PROTO']) == "https")) || ((!empty($_SERVER['HTTP_X_FORWARDED_SSL'])) && (strtolower($_SERVER['HTTP_X_FORWARDED_SSL']) == "on"))) return TRUE;
else return FALSE;
}
/**
* General sanitization function.
* Needs to be top-level due to use in
* url_variables.inc.php file.
*/
function sterilize($sterilize = NULL) {
if ($sterilize == NULL) return NULL;
elseif (empty($sterilize)) return $sterilize;
else {
$sterilize = trim($sterilize);
if (is_numeric($sterilize)) {
if (is_float($sterilize)) $sterilize = filter_var($sterilize,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
if (is_int($sterilize)) $sterilize = filter_var($sterilize,FILTER_SANITIZE_NUMBER_INT);
}
else $sterilize = filter_var($sterilize,FILTER_SANITIZE_FULL_SPECIAL_CHARS);
$sterilize = strip_tags($sterilize);
$sterilize = stripcslashes($sterilize);
$sterilize = stripslashes($sterilize);
$sterilize = addslashes($sterilize);
return $sterilize;
}
}
if (HOSTED) {
$installation_id = md5(__FILE__);
$session_expire_after = 60;
}
/**
* Using an MD5 of __FILE__ will ensure a different session
* name for multiple installs on the same domain name.
*
* @see https://github.com/geoffhumphrey/brewcompetitiononlineentry/issues/781
*/
if (empty($installation_id)) $prefix_session = md5(__FILE__);
else $prefix_session = md5($installation_id);
if (session_status() == PHP_SESSION_ACTIVE) {
// **PREVENTING SESSION HIJACKING**
// Prevents javascript XSS attacks aimed to steal the session ID
ini_set('session.cookie_httponly', 1);
// **PREVENTING SESSION FIXATION**
// Session ID cannot be passed through URLs
ini_set('session.use_only_cookies', 1);
// Uses a secure connection (HTTPS) if possible
ini_set('session.cookie_secure', 1);
}
if (session_status() == PHP_SESSION_NONE) {
session_name($prefix_session);
session_start();
}
/**
* Load DB connection and configuration files
*/
require_once (CONFIG.'config.php');
require_once (CONFIG.'MysqliDb.php');
$db_conn = new MysqliDb($connection);
if (ENABLE_MAILER) require_once (CONFIG.'config.mail.php');
require_once (INCLUDES.'current_version.inc.php');
if (isset($_SESSION['last_action'])) {
$seconds_inactive = time() - $_SESSION['last_action'];
$session_expire_after_seconds = $session_expire_after * 60;
if ($seconds_inactive >= $session_expire_after_seconds) {
session_unset();
session_destroy();
}
}
$_SESSION['last_action'] = time();
/**
* RECAPTCHA Keys
* One set is for hosted installations, the other is for outside use.
* Per Google guidelines, all keys validate the domain from
* which it was generated:
* @see https://developers.google.com/recaptcha/docs/domain_validation
* You may need to change the second set with your own API keys if
* reCAPTCHA is not functioning on your self-hosted installation.
* @see https://developers.google.com/recaptcha/
* These are the fallback default. Custom keys must be defined in site
* preferences.
*/
if (HOSTED) {
$public_captcha_key = "6LdUsBATAAAAAEJYbnqmygjGK-S6CHCoGcLALg5W";
$private_captcha_key = "6LdUsBATAAAAAMPhk5yRSmY5BMXlBgcTjiLjiyPb";
}
else {
$public_captcha_key = "";
$private_captcha_key = "";
}
/**
* Uncomment to display paths.
*/
/*
echo ROOT."<br>";
echo ADMIN."<br>";
echo SSO."<br>";
echo CLASSES."<br>";
echo CONFIG."<br>";
echo DB."<br>";
echo IMAGES."<br>";
echo INCLUDES."<br>";
echo LIB."<br>";
echo MODS."<br>";
echo PROCESS."<br>";
echo SECTIONS."<br>";
echo COMPONENTS."<br>";
echo TEMPLATES."<br>";
echo SETUP."<br>";
echo UPDATE."<br>";
echo OUTPUT."<br>";
echo USER_IMAGES."<br>";
echo USER_DOCS."<br>";
echo USER_TEMP."<br>";
echo LANG."<br>";
echo DEBUGGING."<br>";
*/
?>