-
Notifications
You must be signed in to change notification settings - Fork 0
/
config.inc.php
308 lines (258 loc) · 9.77 KB
/
config.inc.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
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
<?php
/*-------------------------------------------------------------------------------
* Xataface Web Application Framework
* Copyright (C) 2005-2008 Web Lite Solutions Corp ([email protected])
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*-------------------------------------------------------------------------------
*/
/**
* File: config.inc.php
* Author: Steve Hannah <[email protected]>
* Created: September 2005
* Description:
* -------------
*
* Initializes configuration information for Dataface.
*/
if (version_compare(PHP_VERSION, '8.0.0') >= 0) {
define('XF_PHP8', true);
}
if ( !defined('XATAFACE_INI_EXTENSION') ){
define('XATAFACE_INI_EXTENSION', '');
}
if (!defined('XFTEMPLATES_C')) {
$tmpDir = sys_get_temp_dir();
if ($tmpDir) {
$included_files = get_included_files();
if (!empty($included_files)) {
$entryScript = $included_files[0];
$templates_c = dirname($entryScript) . DIRECTORY_SEPARATOR . 'templates_c';
if (!is_dir($templates_c)) {
$templates_c = $tmpDir . $templates_c;
if (mkdir($templates_c, 0777, true)) {
define('XFTEMPLATES_C', $templates_c.DIRECTORY_SEPARATOR);
} else {
define('XFTEMPLATES_C', XFAPPROOT.'templates_c'.DIRECTORY_SEPARATOR);
}
} else {
define('XFTEMPLATES_C', $templates_c.DIRECTORY_SEPARATOR);
}
} else {
define('XFTEMPLATES_C', XFAPPROOT.'templates_c'.DIRECTORY_SEPARATOR);
}
} else {
define('XFTEMPLATES_C', XFAPPROOT.'templates_c'.DIRECTORY_SEPARATOR);
}
}
//Prevent Magic Quotes from affecting scripts, regardless of server settings
//Make sure when reading file data,
//PHP doesn't "magically" mangle backslashes!
//set_magic_quotes_runtime(FALSE);
ini_set('magic_quotes_runtime', false);
if ( !function_exists('microtime_float') ){
function microtime_float()
{
list($usec, $sec) = explode(" ", microtime());
return ((float)$usec + (float)$sec);
}
}
function stripslashes_array($data) {
if (is_array($data)){
foreach ($data as $key => $value){
$data[$key] = stripslashes_array($value);
}
return $data;
}else{
return stripslashes($data);
}
}
if (version_compare(PHP_VERSION, '7.4') < 0 and get_magic_quotes_gpc()) {
define('MAGIC_QUOTES_STRIPPED_SLASHES',1);
/*
All these global variables are slash-encoded by default,
because magic_quotes_gpc is set by default!
(And magic_quotes_gpc affects more than just $_GET, $_POST, and $_COOKIE)
*/
$_SERVER = stripslashes_array(@$_SERVER);
$_GET = stripslashes_array(@$_GET);
$_POST = stripslashes_array(@$_POST);
$_COOKIE = stripslashes_array(@$_COOKIE);
$_FILES = stripslashes_array(@$_FILES);
$_ENV = stripslashes_array(@$_ENV);
$_REQUEST = stripslashes_array(@$_REQUEST);
$HTTP_SERVER_VARS = stripslashes_array(@$HTTP_SERVER_VARS);
$HTTP_GET_VARS = stripslashes_array(@$HTTP_GET_VARS);
$HTTP_POST_VARS = stripslashes_array(@$HTTP_POST_VARS);
$HTTP_COOKIE_VARS = stripslashes_array(@$HTTP_COOKIE_VARS);
$HTTP_POST_FILES = stripslashes_array(@$HTTP_POST_FILES);
$HTTP_ENV_VARS = stripslashes_array(@$HTTP_ENV_VARS);
if (isset($_SESSION)) { #These are unconfirmed (?)
$_SESSION = stripslashes_array($_SESSION, '');
$HTTP_SESSION_VARS = stripslashes_array(@$HTTP_SESSION_VARS, '');
}
/*
The $GLOBALS array is also slash-encoded, but when all the above are
changed, $GLOBALS is updated to reflect those changes. (Therefore
$GLOBALS should never be modified directly). $GLOBALS also contains
infinite recursion, so it's dangerous...
*/
}
if ( defined('DATAFACE_DEBUG') and DATAFACE_DEBUG){
/*
* Debug with APD.
*/
apd_set_pprof_trace();
}
// Define a constant for use as quotes in INI files.
// INI files can use quotes as follows:
// key = "Quoted string: "_Q"I'm in quotes"_Q"."
// I.e. just replace '"' with '"_Q"' (excluding single quotes).
define('_Q', '"');
define('XATAFACEQ', _Q);
if ( !defined('DATAFACE_PATH') ){
// Path to the Dataface installation
define('DATAFACE_PATH', str_replace('\\','/',dirname(__FILE__)));
}
if ( !defined('DATAFACE_URL') ){
// Webserver path to the Dataface installation
define('DATAFACE_URL', str_replace('\\', '/', dirname($_SERVER['PHP_SELF'])));
}
if ( !defined('DATAFACE_FCKEDITOR_BASEPATH') ){
// Webserver path to the FCKEditor installation for use with Dataface
define('DATAFACE_FCKEDITOR_BASEPATH', DATAFACE_URL.'/lib/FCKeditor/');
$GLOBALS['HTML_QuickForm_htmlarea']['FCKeditor_BasePath'] = DATAFACE_FCKEDITOR_BASEPATH;
}
$GLOBALS['HTML_QuickForm_htmlarea']['FCKeditor_BasePath'] = DATAFACE_FCKEDITOR_BASEPATH;
if ( !defined('DATAFACE_TINYMCE_BASEPATH') ){
define('DATAFACE_TINYMCE_BASEPATH', DATAFACE_URL.'/lib/tiny_mce');
}
$GLOBALS['HTML_QuickForm_htmlarea']['TinyMCE_BasePath'] = DATAFACE_TINYMCE_BASEPATH;
if ( !defined('DATAFACE_JSCALENDAR_BASEPATH') ){
define('DATAFACE_JSCALENDAR_BASEPATH', DATAFACE_URL.'/lib/jscalendar/');
}
$GLOBALS['HTML_QuickForm_calendar']['jscalendar_BasePath'] = DATAFACE_JSCALENDAR_BASEPATH;
if ( !defined('DATAFACE_SITE_PATH') ){
// Path to the Site that is using Dataface. This may be different if than DATAFACE_PATH
// if there are multiple sites being run on a single Dataface installation.
define('DATAFACE_SITE_PATH', DATAFACE_PATH);
}
if ( !defined('DATAFACE_SITE_URL') ){
// Webserver path to the current site.
// This may be different than DATAFACE_URL if there are multiple sites being run on a single
// dataface installation.
define('DATAFACE_SITE_URL', DATAFACE_URL);
define('DATAFACE_SITE_HREF', (DATAFACE_URL != '/' ? DATAFACE_URL.'/':'/').basename($_SERVER['PHP_SELF']) );
}
if ( !defined('DATAFACE_DEFAULT_CONFIG_STORAGE') ){
// The type of storage to use for application configuration by default.
// Options include: ini or db.
define('DATAFACE_DEFAULT_CONFIG_STORAGE', 'ini');
}
if ( !defined('DATAFACE_CACHE_PATH') ) {
// Find teh cache directory to cache important stuff.
if ( file_exists( DATAFACE_SITE_PATH.'/templates_c') ){
define('DATAFACE_CACHE_PATH', DATAFACE_SITE_PATH.'/templates_c/__cache');
} else {
define('DATAFACE_CACHE_PATH', DATAFACE_PATH.'/Dataface/templates_c/__cache');
}
}
if ( !defined('TRANSLATION_PAGE_TABLE') ){
// The name of the table that should be used to store temporary content that
// is being translated by a machine translator in whole web page mode.
define('TRANSLATION_PAGE_TABLE', '__pages_to_be_translated');
}
//------------------------------------------------------------------------------------------
// Now we set the include path to include the necessary libraries in the lib directory.
$include_path = ini_get('include_path');
// If the current dir is currently first in the list, then it should remain that way
if ( preg_match('/^\.'.PATH_SEPARATOR.'/', $include_path) ){
$include_path = preg_replace('/^\.'.PATH_SEPARATOR.'/','', $include_path);
$curr_dir_first = true;
} else {
$curr_dir_first = false;
}
$includePathArr = explode(PATH_SEPARATOR, $include_path);
if ( DATAFACE_SITE_PATH != DATAFACE_PATH and !in_array(DATAFACE_PATH,$includePathArr)){
$include_path = DATAFACE_PATH.PATH_SEPARATOR.DATAFACE_PATH.'/lib'.PATH_SEPARATOR.$include_path;
} else if ( !in_array(DATAFACE_PATH.'/lib', $includePathArr)) {
$include_path = DATAFACE_PATH.'/lib'.PATH_SEPARATOR.$include_path;
}
if ( $curr_dir_first ){
$include_path = ".".PATH_SEPARATOR.$include_path;
}
set_include_path($include_path );
//ini_set('display_errors', 'on');
if ( !defined('DATAFACE_EXTENSION_LOADED_APC') ){
define('DATAFACE_EXTENSION_LOADED_APC',extension_loaded('apc'));
}
if ( !defined('DATAFACE_EXTENSION_LOADED_MEMCACHE' ) ){
define('DATAFACE_EXTENSION_LOADED_MEMCACHE', extension_loaded('memcache'));
}
function import($file){
static $imports = 0;
if ( !$imports ){
$imports = array();
}
//$class = str_replace('/','_', $file);
//$class = substr($class, 0, strpos($class,'.'));
if ( !isset($imports[$file]) ){
$imports[$file] = true;
//error_log("importing ".$file);
//if (!file_exists($file)) {
// throw new Exception("File not found $file in ".ini_get('include_path'));
//}
require_once $file;
}
}
if ( !function_exists('sys_get_temp_dir') )
{
// Based on http://www.phpit.net/
// article/creating-zip-tar-archives-dynamically-php/2/
function sys_get_temp_dir()
{
// Try to get from environment variable
if ( !empty($_ENV['TMP']) )
{
return realpath( $_ENV['TMP'] );
}
else if ( !empty($_ENV['TMPDIR']) )
{
return realpath( $_ENV['TMPDIR'] );
}
else if ( !empty($_ENV['TEMP']) )
{
return realpath( $_ENV['TEMP'] );
}
// Detect by creating a temporary file
else
{
// Try to use system's temporary directory
// as random name shouldn't exist
$temp_file = tempnam( md5(uniqid(rand(), TRUE)), '' );
if ( $temp_file )
{
$temp_dir = realpath( dirname($temp_file) );
unlink( $temp_file );
return $temp_dir;
}
else
{
return FALSE;
}
}
}
}
require_once dirname(__FILE__).'/Dataface/Globals.php';