/** * Check if files can be upgraded * * @param string $path files path * @param array $hash_table table with hashes of original files * @param array $result resulting array * @param string $package package to check files from * @param array $custom_theme_files list of custom theme files * @return boolean always true */ function fn_uc_check_files($path, $hash_table, &$result, $package, $custom_theme_files) { // Simple copy for a file if (is_file($path)) { // Get original file name $original_file = str_replace(Registry::get('config.dir.upgrade') . $package . '/package/', Registry::get('config.dir.root') . '/', $path); $relative_file = str_replace(Registry::get('config.dir.root') . '/', '', $original_file); $file_name = fn_basename($original_file); if (file_exists($original_file)) { if (md5_file($original_file) != md5_file($path)) { $_relative_file = $relative_file; // For themes, convert relative path to themes_repository if (strpos($relative_file, 'design/themes/') === 0) { $_relative_file = str_replace('design/themes/', 'var/themes_repository/', $relative_file); // replace all themes except base if (fn_uc_check_array_value($relative_file, $custom_theme_files) && strpos($relative_file, '/' . Registry::get('config.base_theme') . '/') === false) { $_relative_file = preg_replace('!design/\\themes/([\\w]+)/!S', 'var/themes_repository/${1}/', $relative_file); } } if (!empty($hash_table[$_relative_file])) { if (md5_file($original_file) != $hash_table[$_relative_file]) { $result['changed'][] = $relative_file; } } else { $result['changed'][] = $relative_file; } } } else { $result['new'][] = $relative_file; } return true; } if (is_dir($path)) { $dir = dir($path); while (false !== ($entry = $dir->read())) { if ($entry == '.' || $entry == '..') { continue; } fn_uc_check_files(rtrim($path, '/') . '/' . $entry, $hash_table, $result, $package, $custom_theme_files); } // Clean up $dir->close(); return true; } else { fn_set_notification('E', __('error'), __('text_uc_incorrect_upgrade_path')); return false; } }
/** * Create directory structure for current active skins and copy templates there * * @param string $path path with skins repository * @param string $package package to create skins structure in * @param array $skip_files list of files that should not be copied to installed skins * @param array $custom_skin_files list of custom skin files * @return boolean true if structured created correctly, false - otherwise */ function fn_uc_create_skins($path, $package, $skip_files, $custom_skin_files) { static $installed_skins = array(); if (empty($installed_skins)) { $installed_skins = fn_get_dir_contents(DIR_SKINS, true, false); } if (is_file($path)) { $files = array(); if (strpos($path, DIR_REPOSITORY) !== false) { // customer skin if (strpos($path, DIR_REPOSITORY . 'customer/') !== false || strpos($path, DIR_REPOSITORY . 'mail/') !== false) { foreach ($installed_skins as $s) { if (!fn_uc_check_array_value($path, $custom_skin_files) || ($s = 'basic')) { // copy non-custom files only $files[] = str_replace(DIR_UPGRADE . $package . '/package/' . DIR_REPOSITORY, DIR_UPGRADE . $package . '/package/skins/' . $s . '/', $path); } } // admin skin } else { $files[] = str_replace(DIR_UPGRADE . $package . '/package/' . DIR_REPOSITORY, DIR_UPGRADE . $package . '/package/skins/' . Registry::get('settings.skin_name_admin') . '/', $path); } // Copy data from alternative skins } elseif (strpos($path, 'var/skins_repository/' . Registry::get('settings.skin_name_customer')) !== false) { $files[] = str_replace(DIR_UPGRADE . $package . '/package/var/skins_repository/', DIR_UPGRADE . $package . '/package/skins/', $path); } foreach ($files as $file) { $fname = basename($file); if (!in_array($fname, $skip_files) && !(file_exists($file) && strpos($path, '/base/') !== false)) { fn_mkdir(dirname($file)); fn_copy($path, dirname($file)); } } return true; } if (is_dir($path)) { $dir = dir($path); while (false !== ($entry = $dir->read())) { if ($entry == '.' || $entry == '..') { continue; } fn_uc_create_skins(rtrim($path, '/') . '/' . $entry, $package, $skip_files, $custom_skin_files); } // Clean up $dir->close(); return true; } else { return false; } }