tce_config.php 8.52 KB
Newer Older
Nicola Asuni's avatar
Nicola Asuni committed
1
2
3
4
<?php
//============================================================+
// File name   : tce_config.php
// Begin       : 2002-02-24
tecnickcom's avatar
tecnickcom committed
5
// Last Update : 2014-03-24
Nicola Asuni's avatar
Nicola Asuni committed
6
7
8
9
10
//
// Description : Shared configuration file.
//
// Author: Nicola Asuni
//
tecnickcom's avatar
tecnickcom committed
11
// (c) Copyright 2004-2014:
Nicola Asuni's avatar
Nicola Asuni committed
12
13
14
15
16
17
18
//               Nicola Asuni
//               Tecnick.com LTD
//               UK
//               www.tecnick.com
//               info@tecnick.com
//
// License:
tecnickcom's avatar
tecnickcom committed
19
//    Copyright (C) 2004-2014 Nicola Asuni - Tecnick.com LTD
Nicola Asuni's avatar
Nicola Asuni committed
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
//    See LICENSE.TXT file for more information.
//============================================================+

/**
 * @file
 * Shared configuration file.
 * @package com.tecnick.tcexam.shared.cfg
 * @brief TCExam Main Configuration
 * @author Nicola Asuni
 * @since 2002-02-24
 */

/**
 * TCExam version (do not change).
 */
tecnickcom's avatar
tecnickcom committed
35
define ('K_TCEXAM_VERSION', '12.1.026');
Nicola Asuni's avatar
Nicola Asuni committed
36
37
38
39

/**
 * 2-letters code for default language.
 */
40
define ('K_LANGUAGE', 'de');
Nicola Asuni's avatar
Nicola Asuni committed
41
42
43
44
45
46
47
48
49
50

/**
 * If true, display a language selector.
 */
define ('K_LANGUAGE_SELECTOR', true);

/**
 * Defines a serialized array of available languages.
 * Each language is indexed using a 2-letters code (ISO 639).
 */
51
/*
Nicola Asuni's avatar
Nicola Asuni committed
52
53
54
55
56
57
58
59
60
61
define ('K_AVAILABLE_LANGUAGES', serialize(array(
	'ar' => 'Arabian',
	'az' => 'Azerbaijani',
	'bg' => 'Bulgarian',
	'br' => 'Brazilian Portuguese',
	'cn' => 'Chinese',
	'de' => 'German',
	'el' => 'Greek',
	'en' => 'English',
	'es' => 'Spanish',
tecnickcom's avatar
tecnickcom committed
62
	'fa' => 'Farsi',
Nicola Asuni's avatar
Nicola Asuni committed
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
	'fr' => 'French',
	'hi' => 'Hindi',
	'he' => 'Hebrew',
	'hu' => 'Hungarian',
	'id' => 'Indonesian',
	'it' => 'Italian',
	'jp' => 'Japanese',
	'mr' => 'Marathi',
	'ms' => 'Malay (Bahasa Melayu)',
	'nl' => 'Dutch',
	'pl' => 'Polish',
	'ro' => 'Romanian',
	'ru' => 'Russian',
	'tr' => 'Turkish',
	'vn' => 'Vietnamese'
)));
79
80
81
82
83
84
85
86
*/

define ('K_AVAILABLE_LANGUAGES', serialize(array(
	'de' => 'Deutsch',
	'en' => 'English',
	'it' => 'Italiano'
)));

Nicola Asuni's avatar
Nicola Asuni committed
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

ini_set('zend.ze1_compatibility_mode', false); // disable PHP4 compatibility mode

// -- INCLUDE files --
require_once('../../shared/config/tce_paths.php');
require_once('../../shared/config/tce_general_constants.php');

/**
 * If true enable One-Time-Password authentication on login.
 */
define ('K_OTP_LOGIN', false);

/**
 * Ratio at which the delay will be increased after every failed login attempt.
 */
define ('K_BRUTE_FORCE_DELAY_RATIO', 2);

/**
 * Number of difficulty levels for questions.
 */
define ('K_QUESTION_DIFFICULTY_LEVELS', 10);

/**
 * If true enable virtual keyboard on some textarea fields.
 */
define('K_ENABLE_VIRTUAL_KEYBOARD', true);

/**
 * Popup window height in pixels for test info.
 */
define ('K_TEST_INFO_HEIGHT', 400);

/**
 * Popup window width in pixels for test info.
 */
define ('K_TEST_INFO_WIDTH', 700);

/**
 * Number of columns for answer textarea.
 */
define ('K_ANSWER_TEXTAREA_COLS', 70);

/**
 * Number of rows for answer textarea.
 */
define ('K_ANSWER_TEXTAREA_ROWS', 15);

/**
 * If true enable explanation field for questions.
 */
define ('K_ENABLE_QUESTION_EXPLANATION', true);

/**
 * If true enable explanation field for answers.
 */
define ('K_ENABLE_ANSWER_EXPLANATION', true);

/**
 * If true display test description before executing the test.
 */
define ('K_DISPLAY_TEST_DESCRIPTION', true);

/**
 * If true compare short answers in binary mode.
 */
define ('K_SHORT_ANSWERS_BINARY', false);

/**
 * User's session life time in seconds.
 */
define ('K_SESSION_LIFE', K_SECONDS_IN_HOUR);

tecnickcom's avatar
tecnickcom committed
159
160
161
162
163
164
165
/**
 * When an alternate authentication method is used, 
 * if this constant is true the default user groups for the selected
 * authentication method are always added to the user.
 */
define ('K_USER_GROUP_RSYNC', false);

Nicola Asuni's avatar
Nicola Asuni committed
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
/**
 * Define timestamp format using PHP notation (do not change).
 */
define ('K_TIMESTAMP_FORMAT', 'Y-m-d H:i:s');

/**
 * Define max line length in chars for question navigator on test execution interface.
 */
define ('K_QUESTION_LINE_MAX_LENGTH', 70);

/**
 * If true, check for possible session hijacking (set to false if you have login problems).
 */
define ('K_CHECK_SESSION_FINGERPRINT', false);

/**
 * If true uses a strong encryption algorithm for passwords.
 */
define ('K_STRONG_PASSWORD_ENCRYPTION', true);

// Client Cookie settings

/**
 * Cookie domain.
 */
define ('K_COOKIE_DOMAIN', '');

/**
 * Cookie path.
 */
define ('K_COOKIE_PATH', '/');

/**
 * If true use secure cookies.
 */
define ('K_COOKIE_SECURE', false);

/**
 * Expiration time for cookies.
 */
define ('K_COOKIE_EXPIRE', K_SECONDS_IN_DAY);

/**
 * Various pages redirection modes after login (valid values are 1, 2, 3 and 4).
 * 1 = relative redirect.
 * 2 = absolute redirect.
 * 3 = html redirect.
 * 4 = full redirect.
 */
define ('K_REDIRECT_LOGIN_MODE', 4);

/**
 * If true enable password reset feature.
 */
220
define ('K_PASSWORD_RESET', FALSE);
Nicola Asuni's avatar
Nicola Asuni committed
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

/**
 * URL to be redirected at logout (leave empty for default).
 */
define ('K_LOGOUT_URL', '');


// Error settings

/**
 * Define error reporting types for debug.
 */
define ('K_ERROR_TYPES', E_ALL | E_STRICT);
//define ('K_ERROR_TYPES', E_ERROR | E_WARNING | E_PARSE);

/**
 * Enable error logs (../log/tce_errors.log).
 */
define ('K_USE_ERROR_LOG', false);

/**
 * If true display messages and errors on Javascript popup window.
 */
define ('K_ENABLE_JSERRORS', false);

/**
 * Set your own timezone here.
 * Possible values are listed on:
 * http://php.net/manual/en/timezones.php
 */
define ('K_TIMEZONE', 'UTC');

/**
 * Default minutes used to extend test duration.
 */
define('K_EXTEND_TIME_MINUTES', 5);

Ewald's avatar
Ewald committed
258
259
/**
 * Default IP range, e.g. if dedicated exam room is used
260
261
262
263
264
265
266
267
268
 */
define('K_DEFAULT_IP_RANGE', '*.*.*.*');

/**
 * Lowercase user names for login screen
 * if true, all characters in user names will be converted to lowercase
 */
define ('K_AUTH_LOWERCASE_USERNAMES', true);

Nicola Asuni's avatar
Nicola Asuni committed
269
270

// ---------- * ---------- * ---------- * ---------- * ----------
271
272


Nicola Asuni's avatar
Nicola Asuni committed
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
308
309
310
311
312
313
314
315
316
317
/**
 * Error handlers.
 */
require_once('../../shared/code/tce_functions_errmsg.php');

// load language resources

// set user's selected language or default language
if(isset($_REQUEST['lang'])
	AND (strlen($_REQUEST['lang']) == 2)
	AND (array_key_exists($_REQUEST['lang'],unserialize(K_AVAILABLE_LANGUAGES)))) {
	/**
	 * Use requested language.
	 * @ignore
	 */
	define ('K_USER_LANG', $_REQUEST['lang']);
	// set client cookie
	setcookie('SessionUserLang', K_USER_LANG, time() + K_COOKIE_EXPIRE, K_COOKIE_PATH, K_COOKIE_DOMAIN, K_COOKIE_SECURE);
} elseif (isset($_COOKIE['SessionUserLang'])
	AND (strlen($_COOKIE['SessionUserLang']) == 2)
	AND (array_key_exists($_COOKIE['SessionUserLang'],unserialize(K_AVAILABLE_LANGUAGES)))) {
	/**
	 * Use session language.
	 * @ignore
	 */
	define ('K_USER_LANG', $_COOKIE['SessionUserLang']);
} else {
	/**
	 * Use default language.
	 * @ignore
	 */
	define ('K_USER_LANG', K_LANGUAGE);
}

// TMX class
require_once('../../shared/code/tce_tmx.php');
// istantiate new TMXResourceBundle object
$lang_resources = new TMXResourceBundle(K_PATH_TMX_FILE, K_USER_LANG, K_PATH_LANG_CACHE.basename(K_PATH_TMX_FILE, '.xml').'_'.K_USER_LANG.'.php');
$l = $lang_resources->getResource(); // language array

ini_set('arg_separator.output', '&amp;');
//date_default_timezone_set(K_TIMEZONE);

if(!defined('PHP_VERSION_ID')) {
	$version = PHP_VERSION;
tecnickcom's avatar
tecnickcom committed
318
	define('PHP_VERSION_ID', (($version[0] * 10000) + ($version[2] * 100) + $version[4]));
Nicola Asuni's avatar
Nicola Asuni committed
319
320
321
322
323
324
325
326
327
328
329
}
if (PHP_VERSION_ID < 50300) {
	@set_magic_quotes_runtime(false); //disable magic quotes
	ini_set('magic_quotes_gpc', 'On');
	ini_set('magic_quotes_runtime', 'Off');
	ini_set('register_long_arrays', 'On');
	//ini_set('register_globals', 'On');
}

// --- get 'post', 'get' and 'cookie' variables
foreach ($_REQUEST as $postkey => $postvalue) {
tecnickcom's avatar
tecnickcom committed
330
	if (($postkey[0] != '_') AND (!preg_match('/[A-Z]/', $postkey[0]))) {
tecnickcom's avatar
tecnickcom committed
331
332
		if (!function_exists('get_magic_quotes_gpc') OR !get_magic_quotes_gpc()) {
			$postvalue = addSlashesArray($postvalue);
Nicola Asuni's avatar
Nicola Asuni committed
333
334
335
336
337
338
339
340
341
342
343
344
345
			$_REQUEST[$postkey] = $postvalue;
			if (isset($_GET[$postkey])) {
				$_GET[$postkey] = $postvalue;
			} elseif (isset($_POST[$postkey])) {
				$_POST[$postkey] = $postvalue;
			} elseif (isset($_COOKIE[$postkey])) {
				$_COOKIE[$postkey] = $postvalue;
			}
		}
		$$postkey = $postvalue;
	}
}

tecnickcom's avatar
tecnickcom committed
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
/**
 * Escape strings with backslashes before characters that need to be escaped.
 * These characters are single quote ('), double quote ("), backslash (\) and NUL (the NULL byte). 
 * @param $data (array|string) String or array to escape
 * @return array|string
 */
function addSlashesArray($data) {
	if (is_array($data)) {
		return array_map('addSlashesArray', $data);
	}
	if (is_string($data)) {
		return addslashes($data);
	}
	return $data;
}
Nicola Asuni's avatar
Nicola Asuni committed
361
362
//============================================================+
// END OF FILE
363
//============================================================+