diff --git a/public/main/inc/global-min.inc.php b/public/main/inc/global-min.inc.php deleted file mode 100644 index 6f40021422..0000000000 --- a/public/main/inc/global-min.inc.php +++ /dev/null @@ -1,370 +0,0 @@ -getConfigurationFile())) { - require_once $kernel->getConfigurationFile(); - $alreadyInstalled = true; - // Recalculate a system absolute path symlinks insensible. - $includePath = $_configuration['root_sys'].'main/inc/'; -} else { - //Redirects to the main/install/ page - if (!$alreadyInstalled) { - $global_error_code = 2; - // The system has not been installed yet. - require_once __DIR__.'/../inc/global_error_message.inc.php'; - die(); - } -} - -$kernel->setApi($_configuration); - -// Ensure that _configuration is in the global scope before loading -// main_api.lib.php. This is particularly helpful for unit tests -if (!isset($GLOBALS['_configuration'])) { - $GLOBALS['_configuration'] = $_configuration; -} - -// Include the main Chamilo platform library file. -require_once $_configuration['root_sys'].'main/inc/lib/api.lib.php'; - -// Fix bug in IIS that doesn't fill the $_SERVER['REQUEST_URI']. -api_request_uri(); - -// Do not over-use this variable. It is only for this script's local use. -$libraryPath = __DIR__.'/lib/'; - -// @todo convert this libs in classes -require_once $libraryPath.'database.constants.inc.php'; -require_once $libraryPath.'text.lib.php'; -require_once $libraryPath.'array.lib.php'; -require_once $libraryPath.'online.inc.php'; -require_once $libraryPath.'banner.lib.php'; - -// Doctrine ORM configuration - -$dbParams = [ - 'driver' => 'pdo_mysql', - 'host' => $_configuration['db_host'], - 'user' => $_configuration['db_user'], - 'password' => $_configuration['db_password'], - 'dbname' => $_configuration['main_database'], - // Only relevant for pdo_sqlite, specifies the path to the SQLite database. - 'path' => isset($_configuration['db_path']) ? $_configuration['db_path'] : '', - // Only relevant for pdo_mysql, pdo_pgsql, and pdo_oci/oci8, - 'port' => isset($_configuration['db_port']) ? $_configuration['db_port'] : '', -]; - -try { - $database = new \Database(); - $database->connect($dbParams); -} catch (Exception $e) { - $global_error_code = 3; - // The database server is not available or credentials are invalid. - require $includePath.'/global_error_message.inc.php'; - die(); -} - -/* RETRIEVING ALL THE CHAMILO CONFIG SETTINGS FOR MULTIPLE URLs FEATURE*/ -if (!empty($_configuration['multiple_access_urls'])) { - $_configuration['access_url'] = 1; - $access_urls = api_get_access_urls(); - $root_rel = api_get_self(); - $root_rel = substr($root_rel, 1); - $pos = strpos($root_rel, '/'); - $root_rel = substr($root_rel, 0, $pos); - $protocol = 'http://'; - if (!empty($_SERVER['HTTPS']) && strtoupper($_SERVER['HTTPS']) != 'OFF') { - $protocol = 'https://'; - } elseif (!empty($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https') { - $protocol = 'https://'; - } - - //urls with subdomains (HTTP_HOST is preferred - see #6764) - $request_url_root = ''; - if (empty($_SERVER['HTTP_HOST'])) { - if (empty($_SERVER['SERVER_NAME'])) { - $request_url_root = $protocol.'localhost/'; - } else { - $request_url_root = $protocol.$_SERVER['SERVER_NAME'].'/'; - } - } else { - $request_url_root = $protocol.$_SERVER['HTTP_HOST'].'/'; - } - //urls with subdirs - $request_url_sub = $request_url_root.$root_rel.'/'; - - // You can use subdirs as multi-urls, but in this case none of them can be - // the root dir. The admin portal should be something like https://host/adm/ - // At this time, subdirs will still hold a share cookie, so not ideal yet - // see #6510 - foreach ($access_urls as $details) { - if ($request_url_sub == $details['url']) { - $_configuration['access_url'] = $details['id']; - break; //found one match with subdir, get out of foreach - } - // Didn't find any? Now try without subdirs - if ($request_url_root == $details['url']) { - $_configuration['access_url'] = $details['id']; - break; //found one match, get out of foreach - } - } -} else { - $_configuration['access_url'] = 1; -} - -// Check if APCu is available. If so, store the value in $_configuration -if (extension_loaded('apcu')) { - $apcEnabled = ini_get('apc.enabled'); - if (!empty($apcEnabled) && $apcEnabled != 'Off' && $apcEnabled != 'off') { - $_configuration['apc'] = true; - $_configuration['apc_prefix'] = $_configuration['main_database'].'_'.$_configuration['access_url'].'_'; - } -} - -$charset = 'UTF-8'; - -// Enables the portability layer and configures PHP for UTF-8 -\Patchwork\Utf8\Bootup::initAll(); - -// Start session after the internationalization library has been initialized. -ChamiloSession::start($alreadyInstalled); - -// access_url == 1 is the default chamilo location -if ($_configuration['access_url'] != 1) { - $url_info = api_get_access_url($_configuration['access_url']); - if ($url_info['active'] == 1) { - $settings_by_access = &api_get_settings(null, 'list', $_configuration['access_url'], 1); - foreach ($settings_by_access as &$row) { - if (empty($row['variable'])) { - $row['variable'] = 0; - } - if (empty($row['subkey'])) { - $row['subkey'] = 0; - } - if (empty($row['category'])) { - $row['category'] = 0; - } - $settings_by_access_list[$row['variable']][$row['subkey']][$row['category']] = $row; - } - } -} - -$result = &api_get_settings(null, 'list', 1); -foreach ($result as &$row) { - if ($_configuration['access_url'] != 1) { - if ($url_info['active'] == 1) { - $var = empty($row['variable']) ? 0 : $row['variable']; - $subkey = empty($row['subkey']) ? 0 : $row['subkey']; - $category = empty($row['category']) ? 0 : $row['category']; - } - - if ($row['access_url_changeable'] == 1 && $url_info['active'] == 1) { - if (isset($settings_by_access_list[$var]) && - isset($settings_by_access_list[$var][$subkey]) && - $settings_by_access_list[$var][$subkey][$category]['selected_value'] != '') { - if ($row['subkey'] == null) { - $_setting[$row['variable']] = $settings_by_access_list[$var][$subkey][$category]['selected_value']; - } else { - $_setting[$row['variable']][$row['subkey']] = $settings_by_access_list[$var][$subkey][$category]['selected_value']; - } - } else { - if ($row['subkey'] == null) { - $_setting[$row['variable']] = $row['selected_value']; - } else { - $_setting[$row['variable']][$row['subkey']] = $row['selected_value']; - } - } - } else { - if ($row['subkey'] == null) { - $_setting[$row['variable']] = $row['selected_value']; - } else { - $_setting[$row['variable']][$row['subkey']] = $row['selected_value']; - } - } - } else { - if ($row['subkey'] == null) { - $_setting[$row['variable']] = $row['selected_value']; - } else { - $_setting[$row['variable']][$row['subkey']] = $row['selected_value']; - } - } -} - -$result = &api_get_settings('Plugins', 'list', $_configuration['access_url']); -$_plugins = []; -foreach ($result as &$row) { - $key = &$row['variable']; - if (isset($_setting[$key]) && is_string($_setting[$key])) { - $_setting[$key] = []; - } - if ($row['subkey'] == null) { - $_setting[$key][] = $row['selected_value']; - $_plugins[$key][] = $row['selected_value']; - } else { - $_setting[$key][$row['subkey']] = $row['selected_value']; - $_plugins[$key][$row['subkey']] = $row['selected_value']; - } -} - -ini_set('log_errors', '1'); - -/** - * Include the trad4all language file. - */ -// if we use the javascript version (without go button) we receive a get -// if we use the non-javascript version (with the go button) we receive a post -$user_language = ''; -$browser_language = ''; - -// see #8149 -if (!empty($_SESSION['user_language_choice'])) { - $user_language = $_SESSION['user_language_choice']; -} - -if (!empty($_GET['language'])) { - $user_language = $_GET['language']; -} - -if (!empty($_POST['language_list'])) { - $user_language = preg_replace('/index\.php\?language=/', '', $_POST['language_list']); -} - -if (empty($user_language) && !empty($_SERVER['HTTP_ACCEPT_LANGUAGE']) && !isset($_SESSION['_user'])) { - $l = SubLanguageManager::getLanguageFromBrowserPreference($_SERVER['HTTP_ACCEPT_LANGUAGE']); - if (!empty($l)) { - $user_language = $browser_language = $l; - } -} -// Checking if we have a valid language. If not we set it to the platform language. -$valid_languages = api_get_languages(); - -if (!empty($valid_languages)) { - if (!in_array($user_language, $valid_languages['folder'])) { - $user_language = api_get_setting('platformLanguage'); - } - - $language_priority1 = api_get_setting('languagePriority1'); - $language_priority2 = api_get_setting('languagePriority2'); - $language_priority3 = api_get_setting('languagePriority3'); - $language_priority4 = api_get_setting('languagePriority4'); - - if (isset($_GET['language']) || - (isset($_POST['language_list']) && !empty($_POST['language_list'])) || - !empty($browser_language) - ) { - $user_selected_language = $user_language; // $_GET['language']; or HTTP_ACCEPT_LANGUAGE - $_SESSION['user_language_choice'] = $user_selected_language; - $platformLanguage = $user_selected_language; - } - - if (!empty($language_priority4) && api_get_language_from_type($language_priority4) !== false) { - $language_interface = api_get_language_from_type($language_priority4); - } else { - $language_interface = api_get_setting('platformLanguage'); - } - - if (!empty($language_priority3) && api_get_language_from_type($language_priority3) !== false) { - $language_interface = api_get_language_from_type($language_priority3); - } else { - if (isset($_SESSION['user_language_choice'])) { - $language_interface = $_SESSION['user_language_choice']; - } - } - - if (!empty($language_priority2) && api_get_language_from_type($language_priority2) !== false) { - $language_interface = api_get_language_from_type($language_priority2); - } else { - if (isset($_user['language'])) { - $language_interface = $_user['language']; - } - } - - if (!empty($language_priority1) && api_get_language_from_type($language_priority1) !== false) { - $language_interface = api_get_language_from_type($language_priority1); - } else { - if (isset($_course['language'])) { - $language_interface = $_course['language']; - } - } - - // If language is set via browser ignore the priority - if (isset($_GET['language'])) { - $language_interface = $user_language; - } -} - -$language_interface_initial_value = $language_interface; - -$langPath = api_get_path(SYS_LANG_PATH); -$languageFilesToLoad = [ - $langPath.'english/trad4all.inc.php', - $langPath.$language_interface.'/trad4all.inc.php', -]; - -foreach ($languageFilesToLoad as $languageFile) { - if (is_file($languageFile)) { - require $languageFile; - } -} - -// include the local (contextual) parameters of this course or section -require $includePath.'/local.inc.php'; - -// Update of the logout_date field in the table track_e_login -// (needed for the calculation of the total connection time) -if (!isset($_SESSION['login_as']) && isset($_user)) { - // if $_SESSION['login_as'] is set, then the user is an admin logged as the user - $tbl_track_login = Database::get_main_table(TABLE_STATISTIC_TRACK_E_LOGIN); - $sql = "SELECT login_id, login_date - FROM $tbl_track_login - WHERE - login_user_id='".$_user["user_id"]."' - ORDER BY login_date DESC - LIMIT 0,1"; - - $q_last_connection = Database::query($sql); - if (Database::num_rows($q_last_connection) > 0) { - $now = api_get_utc_datetime(); - $i_id_last_connection = Database::result($q_last_connection, 0, 'login_id'); - - // is the latest logout_date still relevant? - $sql = "SELECT logout_date FROM $tbl_track_login - WHERE login_id = $i_id_last_connection"; - $q_logout_date = Database::query($sql); - $res_logout_date = convert_sql_date(Database::result($q_logout_date, 0, 'logout_date')); - $lifeTime = api_get_configuration_value('session_lifetime'); - - if ($res_logout_date < time() - $lifeTime) { - // it isn't, we should create a fresh entry - Event::eventLogin($_user['user_id']); - // now that it's created, we can get its ID and carry on - } else { - $sql = "UPDATE $tbl_track_login SET logout_date = '$now' - WHERE login_id = '$i_id_last_connection'"; - Database::query($sql); - } - - $tableUser = Database::get_main_table(TABLE_MAIN_USER); - $sql = "UPDATE $tableUser SET last_login = '$now' - WHERE user_id = ".$_user["user_id"]; - Database::query($sql); - } -} diff --git a/public/main/inc/global_error_message.inc.php b/public/main/inc/global_error_message.inc.php deleted file mode 100644 index 9489a8536e..0000000000 --- a/public/main/inc/global_error_message.inc.php +++ /dev/null @@ -1,307 +0,0 @@ -Chamilo Homepage'; -$PoweredBy = 'Powered by Chamilo © '.date('Y'); - -/** - * English language variables. - */ - -// Sections. -$SectionSystemRequirementsProblem = 'System requirements problem'; -$SectionInstallation = 'Installation'; -$SectionDatabaseUnavailable = 'Database is unavailable'; -$SectionTechnicalIssues = 'Technical issues'; -$SectionProtection = 'Protection measure'; - -// Error code. -$ErrorCode = 'Error code'; - -// Error code 1. -$IncorrectPhpVersionTitle = 'Incorrect PHP version'; -$IncorrectPhpVersionDescription = 'Warning: we have detected that your version of PHP is %s1. To install Chamilo, you need to have PHP %s2 or superior. If you don\'t know what we\'re talking about, please contact your hosting provider or your support team. - %s3 Read the installation guide.'; - -// Error code 2. -$InstallationTitle = 'Chamilo has not been installed'; -$InstallationDescription = 'Click to INSTALL Chamilo %s or read the installation guide'; - -// Error code 3. -// Error code 4. -// Error code 5. -$DatabaseUnavailableTitle = 'Database is unavailable'; -$DatabaseUnavailableDescription = 'This portal is currently experiencing database issues. Please report this to the portal administrator. Thank you for your help.'; - -// Error code 6. -$AlreadyInstalledTitle = 'Chamilo has already been installed'; -$AlreadyInstalledDescription = 'The system has already been installed. In order to protect its contents, we have to prevent you from starting the installation script again. Please return to the main page.'; - -// Unspecified error. -$TechnicalIssuesTitle = 'Technical issues'; -$TechnicalIssuesDescription = 'This portal is currently experiencing technical issues. Please report this to the portal administrator. Thank you for your help.'; - -if (is_int($global_error_code) && $global_error_code > 0) { - if (class_exists('Template') && function_exists('api_get_configuration_value')) { - $theme = Template::getThemeFallback().'/'; - } else { - $theme = 'chamilo'; - } - - $root_rel = ''; - $installation_guide_url = $root_rel.'documentation/installation_guide.html'; - $css_list = [ - 'public/build/vendor.css', - 'public/build/css/app.css', - 'public/build/css/base.css', - 'public/build/css/themes/'.$theme.'/default.css', - ]; - - $web_img = 'main/img'; - $root_sys = str_replace('\\', '/', realpath(__DIR__.'/../../')).'/'; - $css_def = ''; - foreach ($css_list as $cssFile) { - $cssFile = $root_sys.$cssFile; - if (file_exists($cssFile)) { - $css_def .= file_get_contents($cssFile); - } - } - - $global_error_message = []; - switch ($global_error_code) { - case 1: - $global_error_message['section'] = $SectionSystemRequirementsProblem; - $global_error_message['title'] = $IncorrectPhpVersionTitle; - $php_version = function_exists('phpversion') ? phpversion() : (defined('PHP_VERSION') ? PHP_VERSION : ''); - $php_version = empty($php_version) ? '' : '(PHP '.$php_version.')'; - $IncorrectPhpVersionDescription = str_replace('%s1', $php_version, $IncorrectPhpVersionDescription); - $IncorrectPhpVersionDescription = str_replace('%s2', REQUIRED_PHP_VERSION, $IncorrectPhpVersionDescription); - $pos = strpos($IncorrectPhpVersionDescription, '%s3'); - if (false !== $pos) { - $length = strlen($IncorrectPhpVersionDescription); - $read_installation_guide = substr($IncorrectPhpVersionDescription, $pos + 3, $length); - $IncorrectPhpVersionDescription = substr($IncorrectPhpVersionDescription, 0, $pos); - $IncorrectPhpVersionDescription .= '
'.$read_installation_guide.''; - } - $global_error_message['description'] = $IncorrectPhpVersionDescription; - break; - case 2: - require __DIR__.'/../install/version.php'; - $global_error_message['section'] = $SectionInstallation; - $global_error_message['title'] = $InstallationTitle; - if (false === ($pos = strpos($InstallationDescription, '%s'))) { - $InstallationDescription = 'Click to INSTALL Chamilo %s or read the installation guide'; - } - $read_installation_guide = substr($InstallationDescription, $pos + 2); - $versionStatus = (!empty($new_version_status) && 'stable' != $new_version_status ? $new_version_status : ''); - $InstallationDescription = '
-
-
-
-

Welcome to the Chamilo '.$new_version.' '.$new_version_status.' installation wizard

-

Let\'s start hunting skills down with Chamilo LMS! This wizard will guide you through the Chamilo installation and configuration process.

-

- - '.$read_installation_guide.' -

-
-
-
-
'; - $global_error_message['description'] = $InstallationDescription; - break; - case 3: - case 4: - case 5: - $global_error_message['section'] = $SectionDatabaseUnavailable; - $global_error_message['title'] = $DatabaseUnavailableTitle; - $global_error_message['description'] = $DatabaseUnavailableDescription; - break; - case 6: - $global_error_message['section'] = $SectionProtection; - $global_error_message['title'] = $AlreadyInstalledTitle; - $global_error_message['description'] = $AlreadyInstalledDescription; - break; - default: - $global_error_message['section'] = $SectionTechnicalIssues; - $global_error_message['title'] = $TechnicalIssuesTitle; - $global_error_message['description'] = $TechnicalIssuesDescription; - break; - } - - $show_error_codes = defined('SHOW_ERROR_CODES') && SHOW_ERROR_CODES && 2 != $global_error_code; - $global_error_message['code'] = $show_error_codes ? $ErrorCode.': '.$global_error_code.'

' : ''; - $global_error_message['details'] = empty($global_error_message['details']) ? '' : ($show_error_codes ? ': '.$global_error_message['details'] : $global_error_message['details']); - $global_error_message['organisation'] = $Organisation; - $global_error_message['powered_by'] = $PoweredBy; - $global_error_message['encoding'] = 'UTF-8'; - $global_error_message['chamilo_logo'] = "data:image/png;base64,".base64_encode(file_get_contents($root_sys.'public/build/css/themes/'.$theme.'/images/header-logo.png')); - $bgImage = base64_encode(file_get_contents("$root_sys/public/img/bg_space.png")); - $bgMoon = base64_encode(file_get_contents("$root_sys/public/img/bg_moon_two.png")); - $installChamiloImage = "data:image/png;base64,".base64_encode(file_get_contents("$root_sys/public/img/mr_chamilo_install.png")); - $global_error_message['mr_chamilo'] = $installChamiloImage; - - if (2 == $global_error_code) { - $global_error_message_page = -<< - - - {TITLE} - - - - - -
-
-
-
-
- -
-
-
-
-
-
-
-
- -
-
-
-
-

- {DESCRIPTION} - {CODE} -

-
-
-
-
-
-
-
- - -EOM; - } else { - $global_error_message_page = -<< - - - {TITLE} - - - - -
-
-
-
-
-
- -
-
-
-
- - -
-
-
- -
-
-
-
-
- - -EOM; - } - foreach ($global_error_message as $key => $value) { - $global_error_message_page = str_replace('{'.strtoupper($key).'}', $value, $global_error_message_page); - } - header('Content-Type: text/html; charset='.$global_error_message['encoding']); - die($global_error_message_page); -} diff --git a/public/main/inc/index.html b/public/main/inc/index.html deleted file mode 100644 index aa7b9c934b..0000000000 --- a/public/main/inc/index.html +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/public/main/install/index.php b/public/main/install/index.php index 4011d47265..e0eda3ac0e 100644 --- a/public/main/install/index.php +++ b/public/main/install/index.php @@ -161,7 +161,7 @@ require_once __DIR__.'/version.php'; if (isAlreadyInstalledSystem()) { // The system has already been installed, so block re-installation. $global_error_code = 6; - require '../inc/global_error_message.inc.php'; + echo 'Portal already installed'; exit; } diff --git a/public/main/work/downloadfolder.inc.php b/public/main/work/downloadfolder.inc.php deleted file mode 100644 index cac826d6e8..0000000000 --- a/public/main/work/downloadfolder.inc.php +++ /dev/null @@ -1,238 +0,0 @@ - visibility != 2 - $sql = "SELECT DISTINCT - url, - title, - description, - insert_user_id, - sent_date, - contains_file - $filenameCondition - FROM $tbl_student_publication AS work - INNER JOIN $prop_table AS props - ON (work.id = props.ref AND props.c_id = work.c_id) - INNER JOIN $tableUser as u - ON ( - work.user_id = u.user_id - ) - WHERE - props.tool = 'work' AND - props.c_id = $course_id AND - work.c_id = $course_id AND - work.parent_id = $workId AND - work.filetype = 'file' AND - props.visibility <> '2' AND - work.active IN (0, 1) AND - work.post_group_id = $groupIid - $sessionCondition - "; -} else { - $courseInfo = api_get_course_info(); - protectWork($courseInfo, $workId); - $userCondition = ''; - - // All users - if (0 == $courseInfo['show_score']) { - // Do another filter - } else { - // Only teachers - $userCondition = ' AND props.insert_user_id = '.api_get_user_id(); - } - - //for other users, we need to create a zipfile with only visible files and folders - $sql = "SELECT DISTINCT - url, - title, - description, - insert_user_id, - sent_date, - contains_file - $filenameCondition - FROM $tbl_student_publication AS work - INNER JOIN $prop_table AS props - ON ( - props.c_id = work.c_id AND - work.id = props.ref - ) - WHERE - props.c_id = $course_id AND - work.c_id = $course_id AND - props.tool = 'work' AND - work.accepted = 1 AND - work.active = 1 AND - work.parent_id = $workId AND - work.filetype = 'file' AND - props.visibility = '1' AND - work.post_group_id = $groupIid - $userCondition - "; -} -$query = Database::query($sql); - -//add tem to the zip file -while ($not_deleted_file = Database::fetch_assoc($query)) { - $userInfo = api_get_user_info($not_deleted_file['insert_user_id']); - $insert_date = api_get_local_time($not_deleted_file['sent_date']); - $insert_date = str_replace([':', '-', ' '], '_', $insert_date); - - $title = basename($not_deleted_file['title']); - if (!empty($filenameCondition)) { - if (isset($not_deleted_file['filename']) && !empty($not_deleted_file['filename'])) { - $title = $not_deleted_file['filename']; - } - } - $filename = $insert_date.'_'.$userInfo['username'].'_'.$title; - $filename = api_replace_dangerous_char($filename); - // File exists - if (file_exists($sys_course_path.$_course['path'].'/'.$not_deleted_file['url']) && - !empty($not_deleted_file['url']) - ) { - $files[basename($not_deleted_file['url'])] = $filename; - $addStatus = $zip_folder->add( - $sys_course_path.$_course['path'].'/'.$not_deleted_file['url'], - PCLZIP_OPT_REMOVE_PATH, - $sys_course_path.$_course['path'].'/work', - PCLZIP_CB_PRE_ADD, - 'my_pre_add_callback' - ); - } else { - // Convert texts in html files - $filename = trim($filename).'.html'; - $work_temp = api_get_path(SYS_ARCHIVE_PATH).api_get_unique_id().'_'.$filename; - file_put_contents($work_temp, $not_deleted_file['description']); - $files[basename($work_temp)] = $filename; - $addStatus = $zip_folder->add( - $work_temp, - PCLZIP_OPT_REMOVE_PATH, - api_get_path(SYS_ARCHIVE_PATH), - PCLZIP_CB_PRE_ADD, - 'my_pre_add_callback' - ); - @unlink($work_temp); - } -} - -if (!empty($files)) { - $fileName = api_replace_dangerous_char($work_data['title']); - // Logging - Event::event_download($fileName.'.zip (folder)'); - - //start download of created file - $name = $fileName.'.zip'; - - if (Security::check_abs_path($temp_zip_file, api_get_path(SYS_ARCHIVE_PATH))) { - DocumentManager::file_send_for_download($temp_zip_file, true, $name); - @unlink($temp_zip_file); - exit; - } -} else { - exit; -} - -/* Extra function (only used here) */ -function my_pre_add_callback($p_event, &$p_header) -{ - global $files; - if (isset($files[basename($p_header['stored_filename'])])) { - $p_header['stored_filename'] = $files[basename($p_header['stored_filename'])]; - - return 1; - } - - return 0; -} - -/** - * Return the difference between two arrays, as an array of those key/values - * Use this as array_diff doesn't give the. - * - * @param array $arr1 first array - * @param array $arr2 second array - * - * @return array difference between the two arrays - */ -function diff($arr1, $arr2) -{ - $res = []; - $r = 0; - foreach ($arr1 as $av) { - if (!in_array($av, $arr2)) { - $res[$r] = $av; - $r++; - } - } - - return $res; -}