source-function-addSlashesArray

It appears that you are using AdBlocking software. The cost of running this website is covered by advertisements. If you like it please feel free to a small amount of money to secure the future of this website.
Overview

Classes

Interfaces

Exceptions

Functions

  1: <?php
  2: //============================================================+
  3: // File name   : tce_config.php
  4: // Begin       : 2002-02-24
  5: // Last Update : 2014-03-24
  6: //
  7: // Description : Shared configuration file.
  8: //
  9: // Author: Nicola Asuni
 10: //
 11: // (c) Copyright 2004-2014:
 12: //               Nicola Asuni
 13: //               Tecnick.com LTD
 14: //               UK
 15: //               www.tecnick.com
 16: //               info@tecnick.com
 17: //
 18: // License:
 19: //    Copyright (C) 2004-2016 Nicola Asuni - Tecnick.com LTD
 20: //    See LICENSE.TXT file for more information.
 21: //============================================================+
 22: 
 23: /**
 24:  * @file
 25:  * Shared configuration file.
 26:  * @package com.tecnick.tcexam.shared.cfg
 27:  * @brief TCExam Main Configuration
 28:  * @author Nicola Asuni
 29:  * @since 2002-02-24
 30:  */
 31: 
 32: /**
 33:  * TCExam version (do not change).
 34:  */
 35: define('K_TCEXAM_VERSION', '14.0.3');
 36: 
 37: /**
 38:  * 2-letters code for default language.
 39:  */
 40: define('K_LANGUAGE', 'en');
 41: 
 42: /**
 43:  * If true, display a language selector.
 44:  */
 45: define('K_LANGUAGE_SELECTOR', true);
 46: 
 47: /**
 48:  * Defines a serialized array of available languages.
 49:  * Each language is indexed using a 2-letters code (ISO 639).
 50:  */
 51: define('K_AVAILABLE_LANGUAGES', serialize(array(
 52:     'ar' => 'Arabian',
 53:     'az' => 'Azerbaijani',
 54:     'bg' => 'Bulgarian',
 55:     'br' => 'Brazilian Portuguese',
 56:     'cn' => 'Chinese',
 57:     'de' => 'German',
 58:     'el' => 'Greek',
 59:     'en' => 'English',
 60:     'es' => 'Spanish',
 61:     'fa' => 'Farsi',
 62:     'fr' => 'French',
 63:     'hi' => 'Hindi',
 64:     'he' => 'Hebrew',
 65:     'hu' => 'Hungarian',
 66:     'id' => 'Indonesian',
 67:     'it' => 'Italian',
 68:     'jp' => 'Japanese',
 69:     'mr' => 'Marathi',
 70:     'ms' => 'Malay (Bahasa Melayu)',
 71:     'nl' => 'Dutch',
 72:     'pl' => 'Polish',
 73:     'ro' => 'Romanian',
 74:     'ru' => 'Russian',
 75:     'tr' => 'Turkish',
 76:     'vn' => 'Vietnamese'
 77: )));
 78: 
 79: ini_set('zend.ze1_compatibility_mode', false); // disable PHP4 compatibility mode
 80: 
 81: // -- INCLUDE files --
 82: require_once('../../shared/config/tce_paths.php');
 83: require_once('../../shared/config/tce_general_constants.php');
 84: 
 85: /**
 86:  * If true enable One-Time-Password authentication on login.
 87:  */
 88: define('K_OTP_LOGIN', false);
 89: 
 90: /**
 91:  * Ratio at which the delay will be increased after every failed login attempt.
 92:  */
 93: define('K_BRUTE_FORCE_DELAY_RATIO', 2);
 94: 
 95: /**
 96:  * Number of difficulty levels for questions.
 97:  */
 98: define('K_QUESTION_DIFFICULTY_LEVELS', 10);
 99: 
100: /**
101:  * If true enable virtual keyboard on some textarea fields.
102:  */
103: define('K_ENABLE_VIRTUAL_KEYBOARD', true);
104: 
105: /**
106:  * Popup window height in pixels for test info.
107:  */
108: define('K_TEST_INFO_HEIGHT', 400);
109: 
110: /**
111:  * Popup window width in pixels for test info.
112:  */
113: define('K_TEST_INFO_WIDTH', 700);
114: 
115: /**
116:  * Number of columns for answer textarea.
117:  */
118: define('K_ANSWER_TEXTAREA_COLS', 70);
119: 
120: /**
121:  * Number of rows for answer textarea.
122:  */
123: define('K_ANSWER_TEXTAREA_ROWS', 15);
124: 
125: /**
126:  * If true enable explanation field for questions.
127:  */
128: define('K_ENABLE_QUESTION_EXPLANATION', true);
129: 
130: /**
131:  * If true enable explanation field for answers.
132:  */
133: define('K_ENABLE_ANSWER_EXPLANATION', true);
134: 
135: /**
136:  * If true display test description before executing the test.
137:  */
138: define('K_DISPLAY_TEST_DESCRIPTION', true);
139: 
140: /**
141:  * If true compare short answers in binary mode.
142:  */
143: define('K_SHORT_ANSWERS_BINARY', false);
144: 
145: /**
146:  * User's session life time in seconds.
147:  */
148: define('K_SESSION_LIFE', K_SECONDS_IN_HOUR);
149: 
150: /**
151:  * When an alternate authentication method is used,
152:  * if this constant is true the default user groups for the selected
153:  * authentication method are always added to the user.
154:  */
155: define('K_USER_GROUP_RSYNC', false);
156: 
157: /**
158:  * Define timestamp format using PHP notation (do not change).
159:  */
160: define('K_TIMESTAMP_FORMAT', 'Y-m-d H:i:s');
161: 
162: /**
163:  * Define max line length in chars for question navigator on test execution interface.
164:  */
165: define('K_QUESTION_LINE_MAX_LENGTH', 70);
166: 
167: /**
168:  * If true, check for possible session hijacking (set to false if you have login problems).
169:  */
170: define('K_CHECK_SESSION_FINGERPRINT', true);
171: 
172: // Client Cookie settings
173: 
174: /**
175:  * Cookie domain.
176:  */
177: define('K_COOKIE_DOMAIN', '');
178: 
179: /**
180:  * Cookie path.
181:  */
182: define('K_COOKIE_PATH', '/');
183: 
184: /**
185:  * If true use secure cookies.
186:  */
187: define('K_COOKIE_SECURE', false);
188: 
189: /**
190:  * Expiration time for cookies.
191:  */
192: define('K_COOKIE_EXPIRE', K_SECONDS_IN_DAY);
193: 
194: /**
195:  * Various pages redirection modes after login (valid values are 1, 2, 3 and 4).
196:  * 1 = relative redirect.
197:  * 2 = absolute redirect.
198:  * 3 = html redirect.
199:  * 4 = full redirect.
200:  */
201: define('K_REDIRECT_LOGIN_MODE', 4);
202: 
203: /**
204:  * If true enable password reset feature.
205:  */
206: define('K_PASSWORD_RESET', true);
207: 
208: /**
209:  * URL to be redirected at logout (leave empty for default).
210:  */
211: define('K_LOGOUT_URL', '');
212: 
213: 
214: // Error settings
215: 
216: /**
217:  * Define error reporting types for debug.
218:  */
219: define('K_ERROR_TYPES', E_ALL | E_STRICT);
220: //define ('K_ERROR_TYPES', E_ERROR | E_WARNING | E_PARSE);
221: 
222: /**
223:  * Enable error logs (../log/tce_errors.log).
224:  */
225: define('K_USE_ERROR_LOG', false);
226: 
227: /**
228:  * If true display messages and errors on Javascript popup window.
229:  */
230: define('K_ENABLE_JSERRORS', false);
231: 
232: /**
233:  * Set your own timezone here.
234:  * Possible values are listed on:
235:  * http://php.net/manual/en/timezones.php
236:  */
237: define('K_TIMEZONE', 'UTC');
238: 
239: /**
240:  * Default minutes used to extend test duration.
241:  */
242: define('K_EXTEND_TIME_MINUTES', 5);
243: 
244: 
245: // ---------- * ---------- * ---------- * ---------- * ----------
246: 
247: 
248: /**
249:  * Error handlers.
250:  */
251: require_once('../../shared/code/tce_functions_errmsg.php');
252: 
253: // load language resources
254: 
255: // set user's selected language or default language
256: if (isset($_REQUEST['lang'])
257:     and (strlen($_REQUEST['lang']) == 2)
258:     and (array_key_exists($_REQUEST['lang'], unserialize(K_AVAILABLE_LANGUAGES)))) {
259:     /**
260:      * Use requested language.
261:      * @ignore
262:      */
263:     define('K_USER_LANG', $_REQUEST['lang']);
264:     // set client cookie
265:     setcookie('SessionUserLang', K_USER_LANG, time() + K_COOKIE_EXPIRE, K_COOKIE_PATH, K_COOKIE_DOMAIN, K_COOKIE_SECURE);
266: } elseif (isset($_COOKIE['SessionUserLang'])
267:     and (strlen($_COOKIE['SessionUserLang']) == 2)
268:     and (array_key_exists($_COOKIE['SessionUserLang'], unserialize(K_AVAILABLE_LANGUAGES)))) {
269:     /**
270:      * Use session language.
271:      * @ignore
272:      */
273:     define('K_USER_LANG', $_COOKIE['SessionUserLang']);
274: } else {
275:     /**
276:      * Use default language.
277:      * @ignore
278:      */
279:     define('K_USER_LANG', K_LANGUAGE);
280: }
281: 
282: // TMX class
283: require_once('../../shared/code/tce_tmx.php');
284: // istantiate new TMXResourceBundle object
285: $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');
286: $l = $lang_resources->getResource(); // language array
287: 
288: ini_set('arg_separator.output', '&amp;');
289: //date_default_timezone_set(K_TIMEZONE);
290: 
291: if (!defined('PHP_VERSION_ID')) {
292:     $version = PHP_VERSION;
293:     define('PHP_VERSION_ID', (($version[0] * 10000) + ($version[2] * 100) + $version[4]));
294: }
295: if (PHP_VERSION_ID < 50300) {
296:     @set_magic_quotes_runtime(false); //disable magic quotes
297:     ini_set('magic_quotes_gpc', 'On');
298:     ini_set('magic_quotes_runtime', 'Off');
299:     ini_set('register_long_arrays', 'On');
300:     //ini_set('register_globals', 'On');
301: }
302: 
303: // --- get 'post', 'get' and 'cookie' variables
304: foreach ($_REQUEST as $postkey => $postvalue) {
305:     if (($postkey[0] != '_') and (!preg_match('/[A-Z]/', $postkey[0]))) {
306:         if (!function_exists('get_magic_quotes_gpc') or !get_magic_quotes_gpc()) {
307:             $postvalue = addSlashesArray($postvalue);
308:             $_REQUEST[$postkey] = $postvalue;
309:             if (isset($_GET[$postkey])) {
310:                 $_GET[$postkey] = $postvalue;
311:             } elseif (isset($_POST[$postkey])) {
312:                 $_POST[$postkey] = $postvalue;
313:             } elseif (isset($_COOKIE[$postkey])) {
314:                 $_COOKIE[$postkey] = $postvalue;
315:             }
316:         }
317:         $$postkey = $postvalue;
318:     }
319: }
320: 
321: /**
322:  * Escape strings with backslashes before characters that need to be escaped.
323:  * These characters are single quote ('), double quote ("), backslash (\) and NUL (the NULL byte).
324:  * @param $data (array|string) String or array to escape
325:  * @return array|string
326:  */
327: function addSlashesArray($data)
328: {
329:     if (is_array($data)) {
330:         return array_map('addSlashesArray', $data);
331:     }
332:     if (is_string($data)) {
333:         return addslashes($data);
334:     }
335:     return $data;
336: }
337: //============================================================+
338: // END OF FILE
339: //============================================================+
340: 
 

© 2004-2018 – Nicola Asuni - Tecnick.com - All rights reserved.
about - disclaimer - privacy