diff --git a/VERSION b/VERSION index e4eccd4e6..0c2380a58 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -14.2.2 +14.2.3 diff --git a/admin/code/tce_colorpicker.php b/admin/code/tce_colorpicker.php index 41eab35bd..77f2d1bcf 100644 --- a/admin/code/tce_colorpicker.php +++ b/admin/code/tce_colorpicker.php @@ -96,6 +96,7 @@ function F_html_color_picker($callingform, $callingfield, $tag) $onclick = 'FJ_insert_tag(window.opener.document.getElementById(\''.$callingform.'\').'.$callingfield.', \'['.$tag.'=\'+document.getElementById(\'CSELECTED\').value+\']\');'; echo ''.K_NEWLINE; echo ''.K_NEWLINE; + echo F_getCSRFTokenField().K_NEWLINE; echo ''.K_NEWLINE; echo ''.K_NEWLINE; ?> diff --git a/admin/code/tce_edit_answer.php b/admin/code/tce_edit_answer.php index a80f86f0a..48417c346 100644 --- a/admin/code/tce_edit_answer.php +++ b/admin/code/tce_edit_answer.php @@ -2,7 +2,7 @@ //============================================================+ // File name : tce_edit_answer.php // Begin : 2004-04-27 -// Last Update : 2018-07-06 +// Last Update : 2020-05-06 // // Description : Edit answers. // @@ -15,7 +15,7 @@ // info@tecnick.com // // License: -// Copyright (C) 2004-2018 Nicola Asuni - Tecnick.com LTD +// Copyright (C) 2004-2020 Nicola Asuni - Tecnick.com LTD // See LICENSE.TXT file for more information. //============================================================+ @@ -159,8 +159,7 @@ // check user's authorization for parent module if ((!F_isAuthorizedUser(K_TABLE_MODULES, 'module_id', $m['subject_module_id'], 'module_user_id')) and (!F_isAuthorizedUser(K_TABLE_SUBJECTS, 'subject_id', $m['question_subject_id'], 'subject_user_id'))) { - F_print_error('ERROR', $l['m_authorization_denied']); - exit; + F_print_error('ERROR', $l['m_authorization_denied'], true); } } } else { @@ -197,6 +196,7 @@ @@ -890,7 +890,7 @@ echo ' '.K_NEWLINE; echo ''.K_NEWLINE; echo ''.K_NEWLINE; - +echo F_getCSRFTokenField().K_NEWLINE; echo ''.K_NEWLINE; echo ''.K_NEWLINE; diff --git a/admin/code/tce_edit_backup.php b/admin/code/tce_edit_backup.php index f8be48160..e9ec5d76f 100644 --- a/admin/code/tce_edit_backup.php +++ b/admin/code/tce_edit_backup.php @@ -2,7 +2,7 @@ //============================================================+ // File name : tce_edit_backup.php // Begin : 2009-04-06 -// Last Update : 2014-01-27 +// Last Update : 2020-05-06 // // Description : Backup and Restore TCExam Database. // ONLY FOR POSIX SYSTEMS @@ -18,7 +18,7 @@ // info@tecnick.com // // License: -// Copyright (C) 2004-2014 Nicola Asuni - Tecnick.com LTD +// Copyright (C) 2004-2020 Nicola Asuni - Tecnick.com LTD // See LICENSE.TXT file for more information. //============================================================+ @@ -52,14 +52,17 @@ $menu_mode = 'download'; } +function F_isValidbackupFile($file) +{ + return ((strlen($file) === 35) and (substr($file, -3) === '.gz') and (preg_match('|\.\./|i', $file) === 0) and (preg_match('/[^a-zA-Z0-9\_\-\.]+/i', $file) === 0)); +} + // check backup filename -if (isset($backup_file) and !empty($backup_file)) { - if ((preg_match('/[^a-zA-Z0-9\_\-\.]+/i', $backup_file) > 0) or (strlen($backup_file) != 35) or (substr($backup_file, -3) != '.gz')) { - // ERROR - F_print_error('ERROR', 'SECURITY ERROR'); - } +if (!empty($backup_file) and !F_isValidbackupFile($backup_file)) { + F_print_error('ERROR', 'SECURITY ERROR', true); } + switch ($menu_mode) { // process submitted data case 'restore':{ @@ -72,6 +75,7 @@ F_submit_button('forcerestore', $l['w_restore'], $l['h_restore']); F_submit_button('cancel', $l['w_cancel'], $l['h_cancel']); echo ''.K_NEWLINE; + echo F_getCSRFTokenField().K_NEWLINE; echo ''.K_NEWLINE; echo ''.K_NEWLINE; } @@ -200,7 +204,7 @@ // get backup files $files_list = array(); while (false !== ($file = readdir($handle))) { - if (is_file(K_PATH_BACKUP.$file)) { + if (F_isValidbackupFile($file) and is_file(K_PATH_BACKUP.$file)) { $files_list[] = $file; } } @@ -229,7 +233,7 @@ } echo ''.K_NEWLINE; - +echo F_getCSRFTokenField().K_NEWLINE; echo ''.K_NEWLINE; echo ''.K_NEWLINE; diff --git a/admin/code/tce_edit_group.php b/admin/code/tce_edit_group.php index 3a174b9c9..1f5cff44d 100644 --- a/admin/code/tce_edit_group.php +++ b/admin/code/tce_edit_group.php @@ -81,6 +81,7 @@ F_submit_button('forcedelete', $l['w_delete'], $l['h_delete']); F_submit_button('cancel', $l['w_cancel'], $l['h_cancel']); echo ''.K_NEWLINE; + echo F_getCSRFTokenField().K_NEWLINE; echo ''.K_NEWLINE; echo ''.K_NEWLINE; break; @@ -254,7 +255,7 @@ F_submit_button('clear', $l['w_clear'], $l['h_clear']); echo ''.K_NEWLINE; - +echo F_getCSRFTokenField().K_NEWLINE; echo ''.K_NEWLINE; echo ''.K_NEWLINE; diff --git a/admin/code/tce_edit_module.php b/admin/code/tce_edit_module.php index de032383a..1bfd59a3a 100644 --- a/admin/code/tce_edit_module.php +++ b/admin/code/tce_edit_module.php @@ -2,7 +2,7 @@ //============================================================+ // File name : tce_edit_module.php // Begin : 2008-11-28 -// Last Update : 2018-07-06 +// Last Update : 2020-05-06 // // Description : Display form to edit modules. // @@ -15,7 +15,7 @@ // info@tecnick.com // // License: -// Copyright (C) 2004-2018 Nicola Asuni - Tecnick.com LTD +// Copyright (C) 2004-2020 Nicola Asuni - Tecnick.com LTD // See LICENSE.TXT file for more information. //============================================================+ @@ -61,8 +61,7 @@ $module_id = intval($_REQUEST['module_id']); // check user's authorization for module if (!F_isAuthorizedUser(K_TABLE_MODULES, 'module_id', $module_id, 'module_user_id')) { - F_print_error('ERROR', $l['m_authorization_denied']); - exit; + F_print_error('ERROR', $l['m_authorization_denied'], true); } } else { $module_id = 0; @@ -97,6 +96,7 @@ @@ -329,7 +329,7 @@ $sql = 'SELECT user_id, user_lastname, user_firstname, user_name FROM '.K_TABLE_USERS.' WHERE user_id='.$module_user_id.''; if ($r = F_db_query($sql, $db)) { if ($m = F_db_fetch_array($r)) { - echo '('.$m['user_name'].') '.$m['user_lastname'].' '.$m['user_firstname'].''.K_NEWLINE; + echo '('.unhtmlentities(strip_tags($m['user_name'].') '.$m['user_lastname'].' '.$m['user_firstname'])).''.K_NEWLINE; } } else { echo ''.K_NEWLINE; @@ -365,7 +365,7 @@ if ($rg = F_db_query($sqlg, $db)) { echo ''; while ($mg = F_db_fetch_array($rg)) { - echo ' · '.$mg['group_name'].''; + echo ' · '.unhtmlentities(strip_tags($mg['group_name'])).''; } echo ''; } else { @@ -404,6 +404,7 @@ echo ''.K_NEWLINE; echo ' '.K_NEWLINE; echo ''.K_NEWLINE; +echo F_getCSRFTokenField().K_NEWLINE; echo ''.K_NEWLINE; echo ''.K_NEWLINE; diff --git a/admin/code/tce_edit_question.php b/admin/code/tce_edit_question.php index 15c888ed5..990000bd9 100644 --- a/admin/code/tce_edit_question.php +++ b/admin/code/tce_edit_question.php @@ -2,7 +2,7 @@ //============================================================+ // File name : tce_edit_question.php // Begin : 2004-04-27 -// Last Update : 2018-07-06 +// Last Update : 2020-05-06 // // Description : Edit questions // @@ -15,7 +15,7 @@ // info@tecnick.com // // License: -// Copyright (C) 2004-2018 Nicola Asuni - Tecnick.com LTD +// Copyright (C) 2004-2020 Nicola Asuni - Tecnick.com LTD // See LICENSE.TXT file for more information. //============================================================+ @@ -161,8 +161,7 @@ // check user's authorization for parent module if ((!F_isAuthorizedUser(K_TABLE_MODULES, 'module_id', $m['subject_module_id'], 'module_user_id')) and (!F_isAuthorizedUser(K_TABLE_SUBJECTS, 'subject_id', $m['question_subject_id'], 'subject_user_id'))) { - F_print_error('ERROR', $l['m_authorization_denied']); - exit; + F_print_error('ERROR', $l['m_authorization_denied'], true); } } } else { @@ -197,6 +196,7 @@ F_submit_button('forcedelete', $l['w_delete'], $l['h_delete']); F_submit_button('cancel', $l['w_cancel'], $l['h_cancel']); echo ''.K_NEWLINE; + echo F_getCSRFTokenField().K_NEWLINE; echo ''.K_NEWLINE; echo ''.K_NEWLINE; } @@ -871,7 +871,7 @@ echo ' '.K_NEWLINE; echo ''.K_NEWLINE; echo ''.K_NEWLINE; - +echo F_getCSRFTokenField().K_NEWLINE; echo ''.K_NEWLINE; echo ''.K_NEWLINE; diff --git a/admin/code/tce_edit_rating.php b/admin/code/tce_edit_rating.php index bd2b2be7e..b5548a174 100644 --- a/admin/code/tce_edit_rating.php +++ b/admin/code/tce_edit_rating.php @@ -2,7 +2,7 @@ //============================================================+ // File name : tce_edit_rating.php // Begin : 2004-06-09 -// Last Update : 2018-07-06 +// Last Update : 2020-05-06 // // Description : Editor to manually rate free text answers. // @@ -15,7 +15,7 @@ // info@tecnick.com // // License: -// Copyright (C) 2004-2018 Nicola Asuni - Tecnick.com LTD +// Copyright (C) 2004-2020 Nicola Asuni - Tecnick.com LTD // See LICENSE.TXT file for more information. //============================================================+ @@ -54,8 +54,7 @@ $test_id = intval($_REQUEST['test_id']); // check user's authorization if (!F_isAuthorizedUser(K_TABLE_TESTS, 'test_id', $test_id, 'test_user_id')) { - F_print_error('ERROR', $l['m_authorization_denied']); - exit; + F_print_error('ERROR', $l['m_authorization_denied'], true); } } else { $test_id = 0; @@ -377,6 +376,7 @@ } echo ''.K_NEWLINE; +echo F_getCSRFTokenField().K_NEWLINE; echo ''.K_NEWLINE; echo ''.K_NEWLINE; diff --git a/admin/code/tce_edit_sslcerts.php b/admin/code/tce_edit_sslcerts.php index f7dc4c4f6..73084e050 100644 --- a/admin/code/tce_edit_sslcerts.php +++ b/admin/code/tce_edit_sslcerts.php @@ -2,7 +2,7 @@ //============================================================+ // File name : tce_edit_sslcerts.php // Begin : 2013-07-04 -// Last Update : 2013-07-09 +// Last Update : 2020-05-06 // // Description : Upload and edit SSL certificates. // @@ -15,7 +15,7 @@ // info@tecnick.com // // License: -// Copyright (C) 2004-2013 Nicola Asuni - Tecnick.com LTD +// Copyright (C) 2004-2020 Nicola Asuni - Tecnick.com LTD // See LICENSE.TXT file for more information. //============================================================+ @@ -60,8 +60,7 @@ $ssl_id = intval($_REQUEST['ssl_id']); // check user's authorization for this certificate if (!F_isAuthorizedUser(K_TABLE_SSLCERTS, 'ssl_id', $ssl_id, 'ssl_user_id')) { - F_print_error('ERROR', $l['m_authorization_denied']); - exit; + F_print_error('ERROR', $l['m_authorization_denied'], true); } } else { $ssl_id = 0; @@ -107,6 +106,7 @@ F_submit_button('forcedelete', $l['w_delete'], $l['h_delete']); F_submit_button('cancel', $l['w_cancel'], $l['h_cancel']); echo ''.K_NEWLINE; + echo F_getCSRFTokenField().K_NEWLINE; echo ''.K_NEWLINE; echo ''.K_NEWLINE; } @@ -324,7 +324,7 @@ F_submit_button('clear', $l['w_clear'], $l['h_clear']); echo ''.K_NEWLINE; - +echo F_getCSRFTokenField().K_NEWLINE; echo ''.K_NEWLINE; echo ''.K_NEWLINE; diff --git a/admin/code/tce_edit_subject.php b/admin/code/tce_edit_subject.php index c538ea2b7..2602fc028 100644 --- a/admin/code/tce_edit_subject.php +++ b/admin/code/tce_edit_subject.php @@ -2,7 +2,7 @@ //============================================================+ // File name : tce_edit_subject.php // Begin : 2004-04-26 -// Last Update : 2018-07-06 +// Last Update : 2020-05-06 // // Description : Display form to edit exam subject_id (topics). // @@ -15,7 +15,7 @@ // info@tecnick.com // // License: -// Copyright (C) 2004-2018 Nicola Asuni - Tecnick.com LTD +// Copyright (C) 2004-2020 Nicola Asuni - Tecnick.com LTD // See LICENSE.TXT file for more information. //============================================================+ @@ -95,8 +95,7 @@ // check user's authorization for parent module if ((!F_isAuthorizedUser(K_TABLE_MODULES, 'module_id', $subject_module_id, 'module_user_id')) and (!F_isAuthorizedUser(K_TABLE_SUBJECTS, 'subject_id', $subject_id, 'subject_user_id'))) { - F_print_error('ERROR', $l['m_authorization_denied']); - exit; + F_print_error('ERROR', $l['m_authorization_denied'], true); } } } else { @@ -133,6 +132,7 @@ @@ -464,7 +464,7 @@ echo ' '.K_NEWLINE; echo ''.K_NEWLINE; echo ''.K_NEWLINE; - +echo F_getCSRFTokenField().K_NEWLINE; echo ''.K_NEWLINE; echo ''.K_NEWLINE; diff --git a/admin/code/tce_edit_test.php b/admin/code/tce_edit_test.php index fecc6e1b4..f3f350e3f 100644 --- a/admin/code/tce_edit_test.php +++ b/admin/code/tce_edit_test.php @@ -2,7 +2,7 @@ //============================================================+ // File name : tce_edit_test.php // Begin : 2004-04-27 -// Last Update : 2018-07-06 +// Last Update : 2020-05-06 // // Description : Edit Tests // @@ -15,7 +15,7 @@ // info@tecnick.com // // License: -// Copyright (C) 2004-2018 Nicola Asuni - Tecnick.com LTD +// Copyright (C) 2004-2020 Nicola Asuni - Tecnick.com LTD // See LICENSE.TXT file for more information. //============================================================+ @@ -195,8 +195,7 @@ $test_id = intval($_REQUEST['test_id']); // check user's authorization if (!F_isAuthorizedUser(K_TABLE_TESTS, 'test_id', $test_id, 'test_user_id')) { - F_print_error('ERROR', $l['m_authorization_denied']); - exit; + F_print_error('ERROR', $l['m_authorization_denied'], true); } } else { $test_id = 0; @@ -417,6 +416,7 @@ @@ -1320,7 +1320,7 @@ echo ''.K_NEWLINE; } } - +echo F_getCSRFTokenField().K_NEWLINE; echo ''.K_NEWLINE; echo ''.K_NEWLINE; diff --git a/admin/code/tce_edit_user.php b/admin/code/tce_edit_user.php index ddbc82003..524930508 100644 --- a/admin/code/tce_edit_user.php +++ b/admin/code/tce_edit_user.php @@ -2,7 +2,7 @@ //============================================================+ // File name : tce_edit_user.php // Begin : 2002-02-08 -// Last Update : 2018-07-06 +// Last Update : 2020-05-06 // // Description : Edit user data. // @@ -15,7 +15,7 @@ // info@tecnick.com // // License: -// Copyright (C) 2004-2018 Nicola Asuni - Tecnick.com LTD +// Copyright (C) 2004-2020 Nicola Asuni - Tecnick.com LTD // See LICENSE.TXT file for more information. //============================================================+ @@ -47,15 +47,13 @@ if (isset($_REQUEST['user_id'])) { $user_id = intval($_REQUEST['user_id']); if (!F_isAuthorizedEditorForUser($user_id)) { - F_print_error('ERROR', $l['m_authorization_denied']); - exit; + F_print_error('ERROR', $l['m_authorization_denied'], true); } } if (isset($_REQUEST['group_id'])) { $group_id = intval($_REQUEST['group_id']); if (!F_isAuthorizedEditorForGroup($group_id)) { - F_print_error('ERROR', $l['m_authorization_denied']); - exit; + F_print_error('ERROR', $l['m_authorization_denied'], true); } } if (isset($_REQUEST['user_level'])) { @@ -93,6 +91,7 @@ @@ -183,7 +182,7 @@ if (!$r = F_db_query($sql, $db)) { F_display_db_error(false); } else { - F_print_error('MESSAGE', $user_name.': '.$l['m_user_updated']); + F_print_error('MESSAGE', stripslashes($user_name).': '.$l['m_user_updated']); } // remove old groups $old_user_groups = F_get_user_groups($user_id); @@ -529,7 +528,7 @@ echo ''.K_NEWLINE; echo ''.K_NEWLINE; - +echo F_getCSRFTokenField().K_NEWLINE; echo ''.K_NEWLINE; echo ''.K_NEWLINE; diff --git a/admin/code/tce_filemanager.php b/admin/code/tce_filemanager.php index b4282596e..182cc4238 100644 --- a/admin/code/tce_filemanager.php +++ b/admin/code/tce_filemanager.php @@ -139,6 +139,7 @@ F_submit_button('forcedelete', $l['w_delete'], $l['h_delete']); F_submit_button('cancel', $l['w_cancel'], $l['h_cancel']); echo ''.K_NEWLINE; + echo F_getCSRFTokenField().K_NEWLINE; echo ''.K_NEWLINE; echo ''.K_NEWLINE; break; @@ -324,6 +325,7 @@ } echo ''.K_NEWLINE; +echo F_getCSRFTokenField().K_NEWLINE; echo ''.K_NEWLINE; echo ''.K_NEWLINE; diff --git a/admin/code/tce_functions_users_online.php b/admin/code/tce_functions_users_online.php index bb3e9b9f9..02645b0fb 100644 --- a/admin/code/tce_functions_users_online.php +++ b/admin/code/tce_functions_users_online.php @@ -2,7 +2,7 @@ //============================================================+ // File name : tce_functions_levels.php // Begin : 2001-10-18 -// Last Update : 2011-05-24 +// Last Update : 2020-05-06 // // Description : Functions to display online users' data. // @@ -15,7 +15,7 @@ // info@tecnick.com // // License: -// Copyright (C) 2004-2010 Nicola Asuni - Tecnick.com LTD +// Copyright (C) 2004-2020 Nicola Asuni - Tecnick.com LTD // See LICENSE.TXT file for more information. //============================================================+ @@ -119,6 +119,7 @@ function F_list_online_users($wherequery, $order_field, $orderdir, $firstrow, $r $user_str .= urldecode($this_session['session_user_firstname']).''; } $user_str .= ' ('.urldecode($this_session['session_user_name']).')'; + $user_str = unhtmlentities(strip_tags($user_str)); if (F_isAuthorizedEditorForUser($this_session['session_user_id'])) { echo ''.$user_str.''; } else { diff --git a/admin/code/tce_import_omr_answers.php b/admin/code/tce_import_omr_answers.php index e5b4f2d8e..2b265cf63 100644 --- a/admin/code/tce_import_omr_answers.php +++ b/admin/code/tce_import_omr_answers.php @@ -181,7 +181,7 @@ // show upload button F_submit_button('upload', $l['w_upload'], $l['h_submit_file']); echo ''.K_NEWLINE; - +echo F_getCSRFTokenField().K_NEWLINE; echo ''.K_NEWLINE; echo ''.K_NEWLINE; diff --git a/admin/code/tce_import_omr_bulk.php b/admin/code/tce_import_omr_bulk.php index b211fa5a5..774becc9b 100644 --- a/admin/code/tce_import_omr_bulk.php +++ b/admin/code/tce_import_omr_bulk.php @@ -168,7 +168,7 @@ // show upload button F_submit_button('upload', $l['w_upload'], $l['h_submit_file']); echo ''.K_NEWLINE; - +echo F_getCSRFTokenField().K_NEWLINE; echo ''.K_NEWLINE; echo ''.K_NEWLINE; diff --git a/admin/code/tce_import_questions.php b/admin/code/tce_import_questions.php index 1e7cf7670..00e05bdcc 100644 --- a/admin/code/tce_import_questions.php +++ b/admin/code/tce_import_questions.php @@ -136,6 +136,7 @@ F_submit_button('upload', $l['w_upload'], $l['h_submit_file']); echo ''.K_NEWLINE; +echo F_getCSRFTokenField().K_NEWLINE; echo ''.K_NEWLINE; echo ''.K_NEWLINE; diff --git a/admin/code/tce_import_users.php b/admin/code/tce_import_users.php index 55de34d50..1fdee98a6 100644 --- a/admin/code/tce_import_users.php +++ b/admin/code/tce_import_users.php @@ -105,6 +105,7 @@ diff --git a/admin/code/tce_page_info.php b/admin/code/tce_page_info.php index 8369f10c9..e30d92684 100644 --- a/admin/code/tce_page_info.php +++ b/admin/code/tce_page_info.php @@ -2,7 +2,7 @@ //============================================================+ // File name : tce_page_info.php // Begin : 2004-05-21 -// Last Update : 2019-07-31 +// Last Update : 2020-05-06 // // Description : Outputs TCExam information page. // @@ -15,7 +15,7 @@ // info@tecnick.com // // License: -// Copyright (C) 2004-2019 Nicola Asuni - Tecnick.com LTD +// Copyright (C) 2004-2020 Nicola Asuni - Tecnick.com LTD // See LICENSE.TXT file for more information. //============================================================+ @@ -46,7 +46,7 @@ echo '