function cleanFromCache($sugar_config, $dir) { //Clean smarty from cache if (is_dir($sugar_config['cache_dir'] . $dir)) { $allModFiles = array(); $allModFiles = findAllFiles($sugar_config['cache_dir'] . $dir, $allModFiles); foreach ($allModFiles as $file) { if (file_exists($file)) { unlink($file); } } } }
/** * deletes files created by unzipping a package */ function unlinkTempFiles() { global $sugar_config; logThis('at unlinkTempFiles()'); $tempDir = clean_path(getcwd() . '/' . $sugar_config['upload_dir'] . '/upgrades/temp'); $files = findAllFiles($tempDir, array(), false); rsort($files); foreach ($files as $file) { if (!is_dir($file)) { logThis('unlinking [' . $file . ']'); @unlink($file); } } // now do dirs $files = findAllFiles($tempDir, array(), true); foreach ($files as $dir) { if (is_dir($dir)) { logThis('removing dir [' . $dir . ']'); @rmdir($dir); } } $cacheFile = "modules/UpgradeWizard/_persistence.php"; if (is_file($cacheFile)) { logThis("Unlinking Upgrade cache file: '_persistence.php'"); @unlink($cacheFile); } }
$trackerManager = TrackerManager::getInstance(); $trackerManager->pause(); $trackerManager->unsetMonitors(); include 'modules/ACLActions/actiondefs.php'; include 'include/modules.php'; require_once 'modules/Administration/upgrade_custom_relationships.php'; upgrade_custom_relationships(); logThis('Upgrading user preferences start .', $path); if (function_exists('upgradeUserPreferences')) { upgradeUserPreferences(); } logThis('Upgrading user preferences finish .', $path); // clear out the theme cache if (is_dir($GLOBALS['sugar_config']['cache_dir'] . 'themes')) { $allModFiles = array(); $allModFiles = findAllFiles($GLOBALS['sugar_config']['cache_dir'] . 'themes', $allModFiles); foreach ($allModFiles as $file) { //$file_md5_ref = str_replace(clean_path(getcwd()),'',$file); if (file_exists($file)) { unlink($file); } } } // re-minify the JS source files $_REQUEST['root_directory'] = getcwd(); $_REQUEST['js_rebuild_concat'] = 'rebuild'; require_once 'jssource/minify.php'; //Add the cache cleaning here. if (function_exists('deleteCache')) { logThis('Call deleteCache', $path); @deleteCache();
logThis('clear ' . $GLOBALS['sugar_config']['cache_dir'] . 'modules' . ' files'); $allModFiles = array(); $allModFiles = findAllFiles($GLOBALS['sugar_config']['cache_dir'] . 'modules', $allModFiles); foreach ($allModFiles as $file) { //$file_md5_ref = str_replace(clean_path(getcwd()),'',$file); if (file_exists($file)) { logThis('unlink ' . $file); unlink($file); } } } //Clean jsLanguage from cache if (is_dir($GLOBALS['sugar_config']['cache_dir'] . 'jsLanguage')) { logThis('clear ' . $GLOBALS['sugar_config']['cache_dir'] . 'jsLanguage' . ' files'); $allModFiles = array(); $allModFiles = findAllFiles($GLOBALS['sugar_config']['cache_dir'] . 'jsLanguage', $allModFiles); foreach ($allModFiles as $file) { //$file_md5_ref = str_replace(clean_path(getcwd()),'',$file); if (file_exists($file)) { logThis('unlink ' . $file); unlink($file); } } } } logThis('finished check to see if current_db_version in $_SESSION equals target_db_version in $_SESSION'); //Look for chance folder and delete it if found. Bug 23595 if (function_exists('deleteChance')) { logThis('running deleteChance() function'); @deleteChance(); }
function getPackagesInStaging($view = 'module') { global $sugar_config; global $current_language; $uh = new UpgradeHistory(); $base_upgrade_dir = "upload://upgrades"; $base_tmp_upgrade_dir = sugar_cached("upgrades/temp"); $uContent = findAllFiles($base_upgrade_dir, array(), false, 'zip'); $upgrade_contents = array(); $content_values = array_values($uContent); $alreadyProcessed = array(); foreach ($content_values as $val) { if (empty($alreadyProcessed[$val])) { $upgrade_contents[] = $val; $alreadyProcessed[$val] = true; } } $upgrades_available = 0; $packages = array(); $mod_strings = return_module_language($current_language, "Administration"); foreach ($upgrade_contents as $upgrade_content) { if (!preg_match('#.*\\.zip$#', strtolower($upgrade_content)) || preg_match("#.*./zips/.*#", strtolower($upgrade_content))) { continue; } $the_base = basename($upgrade_content); $the_md5 = md5_file($upgrade_content); $md5_matches = $uh->findByMd5($the_md5); $file_install = $upgrade_content; if (empty($md5_matches)) { $target_manifest = remove_file_extension($upgrade_content) . '-manifest.php'; require_once $target_manifest; $name = empty($manifest['name']) ? $upgrade_content : $manifest['name']; $version = empty($manifest['version']) ? '' : $manifest['version']; $published_date = empty($manifest['published_date']) ? '' : $manifest['published_date']; $icon = ''; $description = empty($manifest['description']) ? 'None' : $manifest['description']; $uninstallable = empty($manifest['is_uninstallable']) ? 'No' : 'Yes'; $type = $this->getUITextForType($manifest['type']); $manifest_type = $manifest['type']; $dependencies = array(); if (isset($manifest['dependencies'])) { $dependencies = $manifest['dependencies']; } //check dependencies first if (!empty($dependencies)) { $uh = new UpgradeHistory(); $not_found = $uh->checkDependencies($dependencies); if (!empty($not_found) && count($not_found) > 0) { $file_install = 'errors_' . $mod_strings['ERR_UW_NO_DEPENDENCY'] . "[" . implode(',', $not_found) . "]"; } } if ($view == 'default' && $manifest_type != 'patch') { continue; } if ($view == 'module' && $manifest_type != 'module' && $manifest_type != 'theme' && $manifest_type != 'langpack') { continue; } if (empty($manifest['icon'])) { $icon = $this->getImageForType($manifest['type']); } else { $path_parts = pathinfo($manifest['icon']); $icon = "<img src=\"" . remove_file_extension($upgrade_content) . "-icon." . $path_parts['extension'] . "\">"; } $upgrades_available++; $packages[] = array('name' => $name, 'version' => $version, 'published_date' => $published_date, 'description' => $description, 'uninstallable' => $uninstallable, 'type' => $type, 'file' => fileToHash($upgrade_content), 'file_install' => fileToHash($upgrade_content)); } //fi } //rof return $packages; }
/** * change from using the older SugarCache in 6.1 and below to the new one in 6.2 */ function upgradeSugarCache($file) { global $sugar_config; $cacheUploadUpgradesTemp = mk_temp_dir(sugar_cached('upgrades/temp')); unzip($file, $cacheUploadUpgradesTemp); if (!file_exists(clean_path("{$cacheUploadUpgradesTemp}/manifest.php"))) { logThis("*** ERROR: no manifest file detected while bootstraping upgrade wizard files!"); return; } else { include clean_path("{$cacheUploadUpgradesTemp}/manifest.php"); } $from_dir = "{$cacheUploadUpgradesTemp}/{$manifest['copy_files']['from_dir']}"; $allFiles = array(); if (file_exists("{$from_dir}/include/SugarCache")) { $allFiles = findAllFiles("{$from_dir}/include/SugarCache", $allFiles); } if (file_exists("{$from_dir}/include/database")) { $allFiles = findAllFiles("{$from_dir}/include/database", $allFiles); } if (file_exists("{$from_dir}/include/utils/external_cache.php")) { $allFiles[] = "{$from_dir}/include/utils/external_cache.php"; } if (file_exists("{$from_dir}/include/utils/sugar_file_utils.php")) { $allFiles[] = "{$from_dir}/include/utils/sugar_file_utils.php"; } if (file_exists("{$from_dir}/include/utils/sugar_file_utils.php")) { $allFiles[] = "{$from_dir}/include/utils/sugar_file_utils.php"; } foreach ($allFiles as $k => $file) { $destFile = str_replace($from_dir . "/", "", $file); if (!is_dir(dirname($destFile))) { mkdir_recursive(dirname($destFile)); // make sure the directory exists } if (stristr($file, 'uw_main.tpl')) { logThis('Skipping "' . $file . '" - file copy will during commit step.'); } else { logThis('updating UpgradeWizard code: ' . $destFile); copy_recursive($file, $destFile); } } }
function clearInboundAccountCache($ieId) { global $sugar_config; $cacheRoot = sugar_cached("modules/Emails/{$ieId}"); $files = findAllFiles($cacheRoot . "/messages/", array()); foreach ($files as $file) { unlink($file); } // fn $files = findAllFiles($cacheRoot . "/attachments/", array()); foreach ($files as $file) { unlink($file); } // for }
/** * Get all the customized modules. Compare the file md5s with the base md5s * If a file has been modified then put the module in the list of customized * modules. Show the list in the preflight check UI. */ function getAllCustomizedModules() { require_once 'files.md5'; $return_array = array(); $modules = getAllModules(); foreach ($modules as $mod) { //find all files in each module if the files have been modified //as compared to the base version then add the module to the //customized modules array $modFiles = findAllFiles(clean_path(getcwd()) . "/modules/{$mod}", array()); foreach ($modFiles as $file) { $fileContents = file_get_contents($file); $file = str_replace(clean_path(getcwd()), '', $file); if ($md5_string['./' . $file]) { if (md5($fileContents) != $md5_string['./' . $file]) { //A file has been customized in the module. Put the module into the // customized modules array. echo 'Changed File' . $file; $return_array[$mod]; break; } } else { // This is a new file in user's version and indicates that module has been //customized. Put the module in the customized array. echo 'New File' . $file; $return_array[$mod]; break; } } } //foreach return $return_array; }
/** * getSources * Returns an Array of source entries found under the given directory * @param String $directory The directory to search * @return mixed $sources An Array of source entries */ private static function getSources($directory = 'modules/Connectors/connectors/sources') { if (file_exists($directory)) { $files = array(); $files = findAllFiles($directory, $files, false, 'config\\.php'); $start = strrpos($directory, '/') == strlen($directory) - 1 ? strlen($directory) : strlen($directory) + 1; $sources = array(); foreach ($files as $file) { require $file; $end = strrpos($file, '/') - $start; $source = array(); $source['id'] = str_replace('/', '_', substr($file, $start, $end)); $source['name'] = !empty($config['name']) ? $config['name'] : $source['id']; $source['enabled'] = true; $source['directory'] = $directory . '/' . str_replace('_', '/', $source['id']); $instance = ConnectorFactory::getInstance($source['id']); $mapping = $instance->getMapping(); $modules = array(); if (!empty($mapping['beans'])) { foreach ($mapping['beans'] as $module => $mapping_entry) { $modules[] = $module; } } $source['modules'] = $modules; $sources[$source['id']] = $source; } return $sources; } return array(); }
function getPackagesInStaging($view = 'module') { global $sugar_config; global $current_language; $uh = new UpgradeHistory(); $base_upgrade_dir = $sugar_config['upload_dir'] . "/upgrades"; $base_tmp_upgrade_dir = "{$base_upgrade_dir}/temp"; $uContent = findAllFiles("{$base_upgrade_dir}", array(), false, 'zip', $base_tmp_upgrade_dir); //other variations of zip file i.e. ZIP, zIp,zIP,Zip,ZIp,ZiP $extns = array('ZIP', 'ZIp', 'ZiP', 'Zip', 'zIP', 'zIp', 'ziP'); foreach ($extns as $extn) { $uContent = array_merge($uContent, findAllFiles("{$base_upgrade_dir}", array(), false, $extn, $base_tmp_upgrade_dir)); } $upgrade_contents = array(); $content_values = array_values($uContent); $alreadyProcessed = array(); foreach ($content_values as $val) { if (empty($alreadyProcessed[$val])) { $upgrade_contents[] = $val; $alreadyProcessed["{$val}"] = true; } } $upgrades_available = 0; $packages = array(); $mod_strings = return_module_language($current_language, "Administration"); foreach ($upgrade_contents as $upgrade_content) { if (!preg_match("#.*\\.zip\$#", strtolower($upgrade_content)) || preg_match("#.*./zips/.*#", strtolower($upgrade_content))) { continue; } $upgrade_content = clean_path($upgrade_content); // Bug 22285 - fix for UNC paths if (substr($upgrade_content, 0, 2) == '\\\\') { $upgrade_content = '\\\\' . $upgrade_content; } $the_base = basename($upgrade_content); $the_md5 = md5_file($upgrade_content); $md5_matches = $uh->findByMd5($the_md5); $file_install = $upgrade_content; if (0 == sizeof($md5_matches)) { $target_manifest = remove_file_extension($upgrade_content) . '-manifest.php'; require_once $target_manifest; $name = empty($manifest['name']) ? $upgrade_content : $manifest['name']; $version = empty($manifest['version']) ? '' : $manifest['version']; $published_date = empty($manifest['published_date']) ? '' : $manifest['published_date']; $icon = ''; $description = empty($manifest['description']) ? 'None' : $manifest['description']; $uninstallable = empty($manifest['is_uninstallable']) ? 'No' : 'Yes'; $type = $this->getUITextForType($manifest['type']); $manifest_type = $manifest['type']; $dependencies = array(); if (isset($manifest['dependencies'])) { $dependencies = $manifest['dependencies']; } //check dependencies first if (!empty($dependencies)) { $uh = new UpgradeHistory(); $not_found = $uh->checkDependencies($dependencies); if (!empty($not_found) && count($not_found) > 0) { $file_install = 'errors_' . $mod_strings['ERR_UW_NO_DEPENDENCY'] . "[" . implode(',', $not_found) . "]"; } //fi } if ($view == 'default' && $manifest_type != 'patch') { continue; } if ($view == 'module' && $manifest_type != 'module' && $manifest_type != 'theme' && $manifest_type != 'langpack') { continue; } if (empty($manifest['icon'])) { $icon = $this->getImageForType($manifest['type']); } else { $path_parts = pathinfo($manifest['icon']); $icon = "<img src=\"" . remove_file_extension($upgrade_content) . "-icon." . $path_parts['extension'] . "\">"; } $upgrades_available++; // uploaded file in cache/upload $fileS = explode('/', $upgrade_content); $c = count($fileS); $fileName = isset($fileS[$c - 1]) && !empty($fileS[$c - 1]) ? $fileS[$c - 1] : $fileS[$c - 2]; $upload_file = $sugar_config['upload_dir'] . $fileName; $upgrade_content = urlencode($upgrade_content); $upload_content = urlencode($upload_file); $packages[] = array('name' => $name, 'version' => $version, 'published_date' => $published_date, 'description' => $description, 'uninstallable' => $uninstallable, 'type' => $type, 'file_install' => fileToHash($file_install), 'file' => fileToHash($upgrade_content), 'upload_file' => $upload_content); } //fi } //rof return $packages; }
/** * deletes files created by unzipping a package */ function unlinkUWTempFiles() { global $sugar_config; global $path; logThis('at unlinkUWTempFiles()'); $tempDir = ''; list($upgDir, $tempDir) = getUWDirs(); if (file_exists($tempDir) && is_dir($tempDir)) { $files = findAllFiles($tempDir, array(), false); rsort($files); foreach ($files as $file) { if (!is_dir($file)) { //logThis('unlinking ['.$file.']', $path); @unlink($file); } } // now do dirs $files = findAllFiles($tempDir, array(), true); foreach ($files as $dir) { if (is_dir($dir)) { //logThis('removing dir ['.$dir.']', $path); @rmdir($dir); } } $cacheFile = sugar_cached("modules/UpgradeWizard/_persistence.php"); if (is_file($cacheFile)) { logThis("Unlinking Upgrade cache file: '_persistence.php'", $path); @unlink($cacheFile); } } logThis("finished!"); }
/** * searches upgrade dir for lang pack files. * * @return string HTML of available lang packs */ function getLangPacks() { global $mod_strings; global $next_step; global $base_upgrade_dir; $ret = "<tr><td colspan=7 align=left>{$mod_strings['LBL_LANG_PACK_READY']}</td></tr>"; $ret .= "<tr>\n\t <td nowrap align=left><b>{$mod_strings['LBL_ML_NAME']}</b></td>\n\t <td nowrap><b>{$mod_strings['LBL_ML_VERSION']}</b></td>\n\t <td nowrap><b>{$mod_strings['LBL_ML_PUBLISHED']}</b></td>\n\t <td nowrap><b>{$mod_strings['LBL_ML_UNINSTALLABLE']}</b></td>\n\t <td nowrap><b>{$mod_strings['LBL_ML_DESCRIPTION']}</b></td>\n </tr>\n"; $files = array(); // duh, new installs won't have the upgrade folders if (!is_dir(getcwd() . "/cache/upload/upgrades")) { $subdirs = array('full', 'langpack', 'module', 'patch', 'theme', 'temp'); foreach ($subdirs as $subdir) { mkdir_recursive("{$base_upgrade_dir}/{$subdir}"); } } $files = findAllFiles(getcwd() . "/cache/upload/upgrades", $files); foreach ($files as $file) { if (!preg_match("#.*\\.zip\$#", $file)) { continue; } // skip installed lang packs if (isset($_SESSION['INSTALLED_LANG_PACKS']) && in_array($file, $_SESSION['INSTALLED_LANG_PACKS'])) { continue; } // handle manifest.php $target_manifest = remove_file_extension($file) . '-manifest.php'; include $target_manifest; $name = empty($manifest['name']) ? $file : $manifest['name']; $version = empty($manifest['version']) ? '' : $manifest['version']; $published_date = empty($manifest['published_date']) ? '' : $manifest['published_date']; $icon = ''; $description = empty($manifest['description']) ? 'None' : $manifest['description']; $uninstallable = empty($manifest['is_uninstallable']) ? 'No' : 'Yes'; $manifest_type = $manifest['type']; $commitPackage = getPackButton('commit', $target_manifest, $file, $next_step); $deletePackage = getPackButton('remove', $target_manifest, $file, $next_step); $ret .= "<tr>"; $ret .= "<td nowrap>" . $name . "</td>"; $ret .= "<td nowrap>" . $version . "</td>"; $ret .= "<td nowrap>" . $published_date . "</td>"; $ret .= "<td nowrap>" . $uninstallable . "</td>"; $ret .= "<td>" . $description . "</td>"; $ret .= "<td nowrap>{$commitPackage}</td>"; $ret .= "<td nowrap>{$deletePackage}</td>"; $ret .= "</td></tr>"; } if (count($files) > 0) { $ret .= "</tr><td colspan=7>"; $ret .= "<form name='commit' action='install.php' method='POST'>\n <input type='hidden' name='current_step' value='{$next_step}'>\n <input type='hidden' name='goto' value='Re-check'>\n <input type='hidden' name='languagePackAction' value='commit'>\n </form>\n "; $ret .= "</td></tr>"; } else { $ret .= "</tr><td colspan=7><i>{$mod_strings['LBL_LANG_NO_PACKS']}</i></td></tr>"; } return $ret; }
function get_encoded_portal_zip_file($session, $md5file, $last_sync, $is_md5_sync = 1) { // files might be big global $sugar_config; ini_set("memory_limit", "-1"); $md5 = ""; $data = ""; $error = new SoapError(); $the_error = ""; if (!validate_authenticated($session)) { $the_error = "Invalid session"; } require "install/data/disc_client.php"; $tempdir_parent = create_cache_directory("disc_client"); $temp_dir = tempnam($tempdir_parent, "sug"); sugar_mkdir($temp_dir, 0775); $temp_file = tempnam($temp_dir, "sug"); write_encoded_file($md5file, $temp_dir, $temp_file); $ignore = false; //generate md5 files on server require_once $temp_file; $server_files = array(); // used later for removing unneeded local files $zip_file = tempnam(tempdir_parent, $session); $root_files = array(); $custom_files = array(); $file_list = array(); if (!$is_md5_sync) { if (is_dir("portal")) { $root_files = findAllTouchedFiles("portal", array(), $last_sync); } if (is_dir("custom/portal")) { $custom_files = findAllTouchedFiles("custom/portal", array(), $last_sync); } $all_src_files = array_merge($root_files, $custom_files); foreach ($all_src_files as $src_file) { $ignore = false; foreach ($disc_client_ignore as $ignore_pattern) { if (preg_match("#" . $ignore_pattern . "#", $src_file)) { $ignore = true; } } if (!$ignore) { //we have to strip off portal or custom/portal before the src file to look it up $key = str_replace('custom/portal/', '', $src_file); $key = str_replace('portal/', '', $key); if ($client_file_list != null && isset($client_file_list[$key])) { //we have found a file out of sync $file_list[] = $src_file; //since we have processed this element of the client //list of files, remove it from the list unset($client_file_list[$key]); } else { //this file does not exist on the client side $file_list[] = $src_file; } } } } else { if (is_dir("portal")) { $root_files = findAllFiles("portal", array()); } if (is_dir("custom/portal")) { $custom_files = findAllFiles("custom/portal", array()); } $all_src_files = array_merge($root_files, $custom_files); foreach ($all_src_files as $src_file) { $ignore = false; foreach ($disc_client_ignore as $ignore_pattern) { if (preg_match("#" . $ignore_pattern . "#", $src_file)) { $ignore = true; } } if (!$ignore) { $value = md5_file($src_file); //we have to strip off portal or custom/portal before the src file to look it up $key = str_replace('custom/portal/', '', $src_file); $key = str_replace('portal/', '', $key); if ($client_file_list != null && isset($client_file_list[$key])) { if ($value != $client_file_list[$key]) { //we have found a file out of sync $file_list[] = $src_file; //since we have processed this element of the client //list of files, remove it from the list } unset($client_file_list[$key]); } else { //this file does not exist on the client side $file_list[] = $src_file; } } } } zip_files_list($zip_file, $file_list, '|.*portal/|'); $contents = sugar_file_get_contents($zip_file); // encode data $data = base64_encode($contents); unlink($zip_file); return array('result' => $data, 'error' => $error->get_soap_array()); }
if (empty($errors)) { $file = "{$unzip_dir}/" . constant('SUGARCRM_PRE_INSTALL_FILE'); if (is_file($file)) { $out .= "{$mod_strings['LBL_UW_INCLUDING']}: {$file} <br>\n"; include $file; logThis('Running pre_install()...'); pre_install(); logThis('pre_install() done.'); } } //// HANDLE PREINSTALL SCRIPTS /////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////// //// COPY NEW FILES INTO TARGET INSTANCE logThis('Starting file copy process...'); $newFiles = findAllFiles(clean_path($unzip_dir . '/' . $zip_from_dir), array()); $zipPath = clean_path($unzip_dir . '/' . $zip_from_dir); $doNotOverwrite = explode('::', $_REQUEST['overwrite_files_serial']); $copiedFiles = array(); $skippedFiles = array(); foreach ($newFiles as $file) { $cleanFile = str_replace($zipPath, '', $file); $srcFile = $zipPath . $cleanFile; $targetFile = clean_path(getcwd() . '/' . $cleanFile); if (!is_dir(dirname($targetFile))) { mkdir_recursive(dirname($targetFile)); // make sure the directory exists } if (!file_exists($targetFile) || !in_array($targetFile, $doNotOverwrite)) { // handle sugar_version.php if (strpos($targetFile, 'sugar_version.php') !== false) {
* Section 5 of the GNU Affero General Public License version 3. * * In accordance with Section 7(b) of the GNU Affero General Public License version 3, * these Appropriate Legal Notices must retain the display of the "Powered by * SugarCRM" logo. If the display of the logo is not reasonably feasible for * technical reasons, the Appropriate Legal Notices must display the words * "Powered by SugarCRM". ********************************************************************************/ global $sugar_version; if (!defined('sugarEntry') || !sugarEntry) { die('Not A Valid Entry Point'); } /////////////////////////////////////////////////////////////////////////////// //// DYNAMICALLY GENERATE UPGRADEWIZARD MODULE FILE LIST $uwFilesCurrent = findAllFiles('modules/UpgradeWizard/', array()); // handle 4.x to 4.5.x+ (no UpgradeWizard module) if (count($uwFilesCurrent) < 5) { $uwFiles = array('modules/UpgradeWizard/language/en_us.lang.php', 'modules/UpgradeWizard/cancel.php', 'modules/UpgradeWizard/commit.php', 'modules/UpgradeWizard/commitJson.php', 'modules/UpgradeWizard/end.php', 'modules/UpgradeWizard/Forms.php', 'modules/UpgradeWizard/index.php', 'modules/UpgradeWizard/Menu.php', 'modules/UpgradeWizard/preflight.php', 'modules/UpgradeWizard/preflightJson.php', 'modules/UpgradeWizard/start.php', 'modules/UpgradeWizard/su_utils.php', 'modules/UpgradeWizard/su.php', 'modules/UpgradeWizard/systemCheck.php', 'modules/UpgradeWizard/systemCheckJson.php', 'modules/UpgradeWizard/upgradeWizard.js', 'modules/UpgradeWizard/upload.php', 'modules/UpgradeWizard/uw_ajax.php', 'modules/UpgradeWizard/uw_files.php', 'modules/UpgradeWizard/uw_main.tpl', 'modules/UpgradeWizard/uw_utils.php'); } else { $uwFilesCurrent = findAllFiles('ModuleInstall', $uwFilesCurrent); $uwFilesCurrent = findAllFiles('include/javascript/yui', $uwFilesCurrent); $uwFilesCurrent[] = 'HandleAjaxCall.php'; $uwFiles = array(); foreach ($uwFilesCurrent as $file) { $uwFiles[] = str_replace("./", "", clean_path($file)); } } //// END DYNAMICALLY GENERATE UPGRADEWIZARD MODULE FILE LIST /////////////////////////////////////////////////////////////////////////////// $uw_files = array('log4php.properties', 'include/utils/encryption_utils.php', 'include/Pear/Crypt_Blowfish/Blowfish.php', 'include/Pear/Crypt_Blowfish/Blowfish/DefaultKey.php', 'include/utils.php', 'include/language/en_us.lang.php', 'include/modules.php', 'include/Localization/Localization.php', 'install/language/en_us.lang.php', 'XTemplate/xtpl.php', 'include/database/DBHelper.php', 'include/database/DBManager.php', 'include/database/DBManagerFactory.php', 'include/database/MssqlHelper.php', 'include/database/MssqlManager.php', 'include/database/MysqlHelper.php', 'include/database/MysqlManager.php', 'include/database/DBManagerFactory.php'); $uw_files = array_merge($uw_files, $uwFiles);
/** * finds all files in the passed path, but skips select directories * @param string dir Relative path * @param array the_array Collections of found files/dirs * @param bool include_dir True if we want to include directories in the * returned collection */ function findAllFiles($dir, $the_array, $include_dirs = false, $skip_dirs = array(), $echo = false) { // check skips foreach ($skip_dirs as $skipMe) { if (strpos(clean_path($dir), $skipMe) !== false) { return $the_array; } } $d = dir($dir); while ($f = $d->read()) { if ($f == "." || $f == "..") { // skip *nix self/parent continue; } if (is_dir("{$dir}/{$f}")) { if ($include_dirs) { // add the directory if flagged $the_array[] = clean_path("{$dir}/{$f}"); } // recurse in $the_array = findAllFiles("{$dir}/{$f}/", $the_array, $include_dirs, $skip_dirs, $echo); } else { $the_array[] = clean_path("{$dir}/{$f}"); } } rsort($the_array); return $the_array; }
/** * getSources * Returns an Array of source entries found under the given directory * @param String $directory The directory to search * @return mixed $sources An Array of source entries */ private static function getSources($directory = 'modules/Connectors/connectors/sources') { if (file_exists($directory)) { $files = array(); $files = findAllFiles($directory, $files, false, 'config\\.php'); $start = strrpos($directory, '/') == strlen($directory) - 1 ? strlen($directory) : strlen($directory) + 1; $sources = array(); $sources_ordering = array(); foreach ($files as $file) { require $file; $end = strrpos($file, '/') - $start; $source = array(); $source['id'] = str_replace('/', '_', substr($file, $start, $end)); $source['name'] = !empty($config['name']) ? $config['name'] : $source['id']; $source['enabled'] = true; $source['directory'] = $directory . '/' . str_replace('_', '/', $source['id']); $order = isset($config['order']) ? $config['order'] : 99; //default to end using 99 if no order set $instance = ConnectorFactory::getInstance($source['id']); $source['eapm'] = empty($config['eapm']) ? false : $config['eapm']; $mapping = $instance->getMapping(); $modules = array(); if (!empty($mapping['beans'])) { foreach ($mapping['beans'] as $module => $mapping_entry) { $modules[] = $module; } } $source['modules'] = $modules; $sources_ordering[$source['id']] = array('order' => $order, 'source' => $source); } usort($sources_ordering, 'sources_sort_function'); foreach ($sources_ordering as $entry) { $sources[$entry['source']['id']] = $entry['source']; } return $sources; } return array(); }
* Website: www.jtips.com.au * @since 08 July 2009 * * Description: * * */ global $jLang; global $mosConfig_absolute_path; if (isJoomla15()) { $dir = $mosConfig_absolute_path . DS . 'components' . DS . 'com_jtips' . DS . 'css' . DS; jimport('joomla.filesystem.folder'); $files = JFolder::files($dir); } else { $dir = $mosConfig_absolute_path . '/components/com_jtips/css/'; $files = findAllFiles($dir); } // get the key of the index.html file $flipped = array_flip($files); unset($files[$flipped['index.html']]); sort($files); $filekeys = jTipsGetParam($_REQUEST, 'cid', array()); $key = array_shift($filekeys); if (isJoomla15()) { jimport('joomla.filesystem.file'); $content = JFile::read($dir . $files[$key]); } else { $content = file_get_contents($dir . $files[$key]); } $title = $jLang['_ADMIN_STYLE_EDIT']; $formData = array('fieldset' => array('legend' => '_ADMIN_STYLE_EDIT', 'fields' => array('label' => array('label' => '_ADMIN_STYLE_FILENAME', 'field' => array('type' => 'label', 'attributes' => array('value' => $files[$key], 'type' => 'label'))), 'content' => array('label' => '_ADMIN_STYLE_CONTENT', 'field' => array('type' => 'textarea', 'attributes' => array('style' => "width:100%;height:400px;", 'name' => 'jstyle'), 'text' => $content)), 'cid' => array('label' => '', 'field' => array('type' => 'hidden', 'attributes' => array('value' => $key, 'name' => 'cid', 'type' => 'hidden'))), 'filename' => array('label' => '', 'field' => array('type' => 'hidden', 'attributes' => array('value' => $files[$key], 'name' => 'filename', 'type' => 'hidden'))))));
/** * deletes files created by unzipping a package */ function unlinkTempFiles() { global $sugar_config; global $path; logThis('at unlinkTempFiles()'); $tempDir = ''; $sugar_config['upload_dir'] = 'cache/upload/'; //if(isset($sugar_config['upload_dir']) && $sugar_config['upload_dir'] != null && $sugar_config['upload_dir']=='cache/upload/'){ $tempDir = clean_path(getcwd() . '/' . $sugar_config['upload_dir'] . 'upgrades/temp'); /* } else{ $uploadDir = getcwd()."/".'cache/upload/'; $tempDir = clean_path(getcwd().'/'.$uploadDir.'upgrades/temp'); }*/ if (file_exists($tempDir) && is_dir($tempDir)) { $files = findAllFiles($tempDir, array(), false); rsort($files); foreach ($files as $file) { if (!is_dir($file)) { logThis('unlinking [' . $file . ']', $path); @unlink($file); } } // now do dirs $files = findAllFiles($tempDir, array(), true); foreach ($files as $dir) { if (is_dir($dir)) { logThis('removing dir [' . $dir . ']', $path); @rmdir($dir); } } $cacheFile = "modules/UpgradeWizard/_persistence.php"; if (is_file($cacheFile)) { logThis("Unlinking Upgrade cache file: '_persistence.php'", $path); @unlink($cacheFile); } } logThis("finished!"); }
<input type=hidden name="run" value="upload" /> <input type=hidden name="upgrade_zip_escaped" value="" /> </td> </tr> </table></td></tr></table> </form> <table width="100%" border="0" cellspacing="0" cellpadding="0" class="tabForm"> <tr><td> <table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr><td> eoq; echo $form; // scan for new files (that are not installed) print "{$descItemsQueued}<br>\n"; print "<ul>\n"; $upgrade_contents = findAllFiles("{$base_upgrade_dir}", array()); $upgrades_available = 0; print "<table>\n"; print "<tr><th></th><th align=left>{$mod_strings['LBL_ML_NAME']}</th><th>{$mod_strings['LBL_ML_TYPE']}</th><th>{$mod_strings['LBL_ML_VERSION']}</th><th>{$mod_strings['LBL_ML_PUBLISHED']}</th><th>{$mod_strings['LBL_ML_UNINSTALLABLE']}</th><th>{$mod_strings['LBL_ML_DESCRIPTION']}</th></tr>\n"; foreach ($upgrade_contents as $upgrade_content) { if (!preg_match("#.*\\.zip\$#", $upgrade_content)) { continue; } $upgrade_content = clean_path($upgrade_content); $the_base = basename($upgrade_content); $the_md5 = md5_file($upgrade_content); $md5_matches = $uh->findByMd5($the_md5); if (0 == sizeof($md5_matches)) { $target_manifest = remove_file_extension($upgrade_content) . '-manifest.php'; require_once $target_manifest; $name = empty($manifest['name']) ? $upgrade_content : $manifest['name'];
* (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ header('Content-type: image/jpeg'); session_start(); require_once 'init.php'; require_once 'dirs.php'; if (isset($settings['photo.collapse_dirs']) && $settings['photo.collapse_dirs']) { $files = findAllFiles($settings['photo.dirs']); $file = $files[$_GET['nr']]; $expires = 60 * 60 * 24 * 365; header('Pragma: public'); header('Cache-Control: maxage=' . $expires); header('Expires: ' . gmdate('D, d M Y H:i:s', time() + $expires) . ' GMT'); } else { $dir = @$_SESSION['display.dir']; $dircount = @$_SESSION['display.dircount']; $previous = @$_SESSION['display.previous']; if (strlen($dir) <= 0 || file_exists($dir)) { $dir = newDir($settings['photo.dirs']); $dircount = 0; } $files = findFiles($dir); if ($dircount > $settings['photo.max_from_dir'] || $dircount >= count($files)) {
* Description: */ global $mainframe; require_once 'components/com_jtips/modules/Customisations/edit.tmpl.php'; $ids = jTipsGetParam($_REQUEST, 'cid', array()); if (empty($ids)) { //mosRedirect('index2.php?option=com_jtips&module=Customisations', $jLang['_ADMIN_CSTM_NO_FILE_SPECIFIED']); } $id = array_shift($ids); $mainframe->addCustomHeadTag("<script type='text/javascript' src='components/com_jtips/lib/edit_area/edit_area_full.js'></script>"); $mainframe->addCustomHeadTag("<script type='text/javascript' src='components/com_jtips/modules/Customisations/Edit.js'></script>"); $tpl = new EditMode(); if ($id or $id === '0') { $path = $mosConfig_absolute_path . '/components/com_jtips/custom/'; $files = array(); $fileList = findAllFiles($path, $files); $file = $fileList[$id]; $tpl->path = $file; if (isJoomla15()) { jimport('joomla.filesystem.file'); $tpl->content = JFile::read($file); } else { $tpl->content = file_get_contents($file); } } else { $tpl->path = $tpl->content = ''; $viewOptions = array(jTipsHTML::makeOption('', $jLang['_ADMIN_CONF_NONE']), jTipsHTML::makeOption('Administration', 'Administration'), jTipsHTML::makeOption('CompetitionLadder', 'Competition Ladder'), jTipsHTML::makeOption('Dashboard', 'Dashboard'), jTipsHTML::makeOption('Menu', 'Menu'), jTipsHTML::makeOption('TeamLadder', 'Team Ladder'), jTipsHTML::makeOption('Tips', 'Tips Panel'), jTipsHTML::makeOption('UserPreferences', 'User Preferences')); $tpl->viewList = jTipsHTML::selectList($viewOptions, 'view', "class='inputbox'", 'value', 'text'); //$tpl->displayFileSetup(); } $tpl->display();
* of this program must display Appropriate Legal Notices, as required under * Section 5 of the GNU Affero General Public License version 3. * * In accordance with Section 7(b) of the GNU Affero General Public License version 3, * these Appropriate Legal Notices must retain the display of the "Powered by * SugarCRM" logo. If the display of the logo is not reasonably feasible for * technical reasons, the Appropriate Legal Notices must display the words * "Powered by SugarCRM". ********************************************************************************/ global $sugar_config, $mod_strings; print $mod_strings['LBL_CLEAR_CHART_DATA_CACHE_FINDING'] . "<br>"; $search_dir = 'cache/'; if (!empty($sugar_config['cache_dir'])) { $search_dir = $sugar_config['cache_dir']; } $all_src_files = findAllFiles($search_dir . '/xml', array()); print $mod_strings['LBL_CLEAR_CHART_DATA_CACHE_DELETING1'] . "<br>"; foreach ($all_src_files as $src_file) { if (preg_match('/\\.xml$/', $src_file)) { print $mod_strings['LBL_CLEAR_CHART_DATA_CACHE_DELETING2'] . " {$src_file}<BR>"; unlink("{$src_file}"); } } include 'modules/Versions/ExpectedVersions.php'; global $expect_versions; if (isset($expect_versions['Chart Data Cache'])) { $version = new Version(); $version->retrieve_by_string_fields(array('name' => 'Chart Data Cache')); $version->name = $expect_versions['Chart Data Cache']['name']; $version->file_version = $expect_versions['Chart Data Cache']['file_version']; $version->db_version = $expect_versions['Chart Data Cache']['db_version'];
if (file_exists($srcFile)) { logThis('Save the version file in session variable', $path); $_SESSION['sugar_version_file'] = $srcFile; } //check exit on conflicts $exitOnConflict = 'yes'; //default if ($argv[5] != null && !empty($argv[5])) { if (strtolower($argv[5]) == 'no') { $exitOnConflict = 'no'; //override } } if ($exitOnConflict == 'yes') { $customFiles = array(); $customFiles = findAllFiles(clean_path("{$argv[3]}/custom"), $customFiles); if ($customFiles != null) { logThis("*** **************************** ****", $path); logThis("*** START LOGGING CUSTOM FILES ****", $path); $existsCustomFile = false; foreach ($customFiles as $file) { $srcFile = clean_path($file); //$targetFile = clean_path(getcwd() . '/' . $srcFile); if (strpos($srcFile, ".svn") !== false) { //do nothing } else { $existsCustomFile = true; //log the custom file in logThis($file, $path); } }
function findAllFilesRelative($the_dir, $the_array) { if (!is_dir($the_dir)) { return $the_array; } $original_dir = getCwd(); if (is_dir($the_dir)) { chdir($the_dir); $the_array = findAllFiles(".", $the_array); if (is_dir($original_dir)) { chdir($original_dir); } } return $the_array; }
/** * change from using the older SugarCache in 6.1 and below to the new one in 6.2 */ function upgradeSugarCache($file) { global $sugar_config; // file = getcwd().'/'.$sugar_config['upload_dir'].$_FILES['upgrade_zip']['name']; $cacheUploadUpgradesTemp = clean_path(mk_temp_dir("{$sugar_config['upload_dir']}upgrades/temp")); unzip($file, $cacheUploadUpgradesTemp); if (!file_exists(clean_path("{$cacheUploadUpgradesTemp}/manifest.php"))) { logThis("*** ERROR: no manifest file detected while bootstraping upgrade wizard files!"); return; } else { include clean_path("{$cacheUploadUpgradesTemp}/manifest.php"); } $allFiles = array(); if (file_exists(clean_path("{$cacheUploadUpgradesTemp}/{$manifest['copy_files']['from_dir']}/include/database"))) { $allFiles = findAllFiles(clean_path("{$cacheUploadUpgradesTemp}/{$manifest['copy_files']['from_dir']}/include/database"), $allFiles); } if (file_exists(clean_path("{$cacheUploadUpgradesTemp}/{$manifest['copy_files']['from_dir']}/include/SugarCache"))) { $allFiles = findAllFiles(clean_path("{$cacheUploadUpgradesTemp}/{$manifest['copy_files']['from_dir']}/include/SugarCache"), $allFiles); } if (file_exists(clean_path("{$cacheUploadUpgradesTemp}/{$manifest['copy_files']['from_dir']}/include/utils/external_cache.php"))) { $allFiles[] = clean_path("{$cacheUploadUpgradesTemp}/{$manifest['copy_files']['from_dir']}/include/utils/external_cache.php"); } $cwd = clean_path(getcwd()); foreach ($allFiles as $k => $file) { $file = clean_path($file); $destFile = str_replace(clean_path($cacheUploadUpgradesTemp . '/' . $manifest['copy_files']['from_dir']), $cwd, $file); if (!is_dir(dirname($destFile))) { mkdir_recursive(dirname($destFile)); // make sure the directory exists } if (stristr($file, 'uw_main.tpl')) { logThis('Skipping "' . $file . '" - file copy will during commit step.'); } else { logThis('updating UpgradeWizard code: ' . $destFile); copy_recursive($file, $destFile); } } logThis('is sugar_file_util there ' . file_exists(clean_path("{$cacheUploadUpgradesTemp}/{$manifest['copy_files']['from_dir']}/include/utils/sugar_file_utils.php"))); if (file_exists(clean_path("{$cacheUploadUpgradesTemp}/{$manifest['copy_files']['from_dir']}/include/utils/sugar_file_utils.php"))) { $file = clean_path("{$cacheUploadUpgradesTemp}/{$manifest['copy_files']['from_dir']}/include/utils/sugar_file_utils.php"); $destFile = str_replace(clean_path($cacheUploadUpgradesTemp . '/' . $manifest['copy_files']['from_dir']), $cwd, $file); copy($file, $destFile); } }
/** * searches upgrade dir for lang pack files. * * @return string HTML of available lang packs */ function getLangPacks($display_commit = true, $types = array('langpack'), $notice_text = '') { global $mod_strings; global $next_step; global $base_upgrade_dir; if (empty($notice_text)) { $notice_text = $mod_strings['LBL_LANG_PACK_READY']; } $ret = "<tr><td colspan=7 align=left>{$notice_text}</td></tr>"; //$ret .="<table width='100%' cellpadding='0' cellspacing='0' border='0'>"; $ret .= "<tr>\n <td width='20%' ><b>{$mod_strings['LBL_ML_NAME']}</b></td>\n <td width='15%' ><b>{$mod_strings['LBL_ML_VERSION']}</b></td>\n <td width='15%' ><b>{$mod_strings['LBL_ML_PUBLISHED']}</b></td>\n <td width='15%' ><b>{$mod_strings['LBL_ML_UNINSTALLABLE']}</b></td>\n <td width='20%' ><b>{$mod_strings['LBL_ML_DESCRIPTION']}</b></td>\n <td width='7%' ></td>\n <td width='1%' ></td>\n <td width='7%' ></td>\n </tr>\n"; $files = array(); // duh, new installs won't have the upgrade folders if (!is_dir($base_upgrade_dir)) { mkdir_recursive($base_upgrade_dir); } $subdirs = array('full', 'langpack', 'module', 'patch', 'theme', 'temp'); foreach ($subdirs as $subdir) { mkdir_recursive("{$base_upgrade_dir}/{$subdir}"); } $files = findAllFiles($base_upgrade_dir, $files); $hidden_input = ''; unset($_SESSION['hidden_input']); foreach ($files as $file) { if (!preg_match("#.*\\.zip\$#", $file)) { continue; } // skip installed lang packs if (isset($_SESSION['INSTALLED_LANG_PACKS']) && in_array($file, $_SESSION['INSTALLED_LANG_PACKS'])) { continue; } // handle manifest.php $target_manifest = remove_file_extension($file) . '-manifest.php'; $license_file = remove_file_extension($file) . '-license.txt'; include $target_manifest; if (!empty($types)) { if (!in_array(strtolower($manifest['type']), $types)) { continue; } } $md5_matches = array(); if ($manifest['type'] == 'module') { $uh = new UpgradeHistory(); $upgrade_content = clean_path($file); $the_base = basename($upgrade_content); $the_md5 = md5_file($upgrade_content); $md5_matches = $uh->findByMd5($the_md5); } if ($manifest['type'] != 'module' || 0 == sizeof($md5_matches)) { $name = empty($manifest['name']) ? $file : $manifest['name']; $version = empty($manifest['version']) ? '' : $manifest['version']; $published_date = empty($manifest['published_date']) ? '' : $manifest['published_date']; $icon = ''; $description = empty($manifest['description']) ? 'None' : $manifest['description']; $uninstallable = empty($manifest['is_uninstallable']) ? 'No' : 'Yes'; $manifest_type = $manifest['type']; $commitPackage = getPackButton('commit', $target_manifest, $file, $next_step); $deletePackage = getPackButton('remove', $target_manifest, $file, $next_step); //$ret .="<table width='100%' cellpadding='0' cellspacing='0' border='0'>"; $ret .= "<tr>"; $ret .= "<td width='20%' >" . $name . "</td>"; $ret .= "<td width='15%' >" . $version . "</td>"; $ret .= "<td width='15%' >" . $published_date . "</td>"; $ret .= "<td width='15%' >" . $uninstallable . "</td>"; $ret .= "<td width='20%' >" . $description . "</td>"; if ($display_commit) { $ret .= "<td width='7%'>{$commitPackage}</td>"; } $ret .= "<td width='1%'></td>"; $ret .= "<td width='7%'>{$deletePackage}</td>"; $ret .= "</td></tr>"; $clean_field_name = "accept_lic_" . str_replace('.', '_', urlencode(basename($file))); if (is_file($license_file)) { //rrs $ret .= "<tr><td colspan=6>"; $ret .= getLicenseDisplay('commit', $target_manifest, $file, $next_step, $license_file, $clean_field_name); $ret .= "</td></tr>"; $hidden_input .= "<input type='hidden' name='{$clean_field_name}' id='{$clean_field_name}' value='no'>"; } else { $hidden_input .= "<input type='hidden' name='{$clean_field_name}' id='{$clean_field_name}' value='yes'>"; } } //fi } //rof $_SESSION['hidden_input'] = $hidden_input; if (count($files) > 0) { $ret .= "</tr><td colspan=7>"; $ret .= "<form name='commit' action='install.php' method='POST'>\n <input type='hidden' name='current_step' value='{$next_step}'>\n <input type='hidden' name='goto' value='Re-check'>\n <input type='hidden' name='languagePackAction' value='commit'>\n <input type='hidden' name='install_type' value='custom'>\n </form>\n "; $ret .= "</td></tr>"; } else { $ret .= "</tr><td colspan=7><i>{$mod_strings['LBL_LANG_NO_PACKS']}</i></td></tr>"; } return $ret; }
function disc_client_file_sync($soapclient, $session, $verbose = false, $attempts = 0) { $max_attempts = 3; global $sugar_config; // files might be big ini_set("memory_limit", "-1"); $return_str = ""; $tempdir_parent = create_cache_directory("disc_client"); $temp_dir = tempnam($tempdir_parent, "sug"); sugar_mkdir($temp_dir, 0775); if (!is_dir($temp_dir)) { die("Could not create a temp dir."); } // get pattern file $result = $soapclient->call('get_encoded_file', array('session' => $session, 'filename' => "install/data/disc_client.php")); if (!empty($soapclient->error_str)) { if ($attempts < $max_attempts && substr_count($soapclient->error_str, 'HTTP Error: socket read of headers timed out') > 0) { echo "Could not retrieve file patterns list. Error was: " . $soapclient->error_str; $attempts++; echo "<BR> {$attempts} of {$max_attempts} attempts trying again<br>"; flush(); ob_flush(); return disc_client_file_sync($soapclient, $session, $verbose, $attempts); } die("Failed: Could not retrieve file patterns list. Error was: " . $soapclient->error_str); } if ($result['error']['number'] != 0) { die("Failed: Could not retrieve file patterns list. Error was: " . $result['error']['name'] . ' - ' . $result['description']); } $newfile = write_encoded_file($result, $temp_dir); if (!copy($newfile, $result['filename'])) { die("Could not copy {$newfile} to new location."); } // get array definitions: $disc_client_ignore require "install/data/disc_client.php"; // get file list/md5s, write as temp file, then require_once from tmp location $result = $soapclient->call('get_disc_client_file_list', array('session' => $session)); if (!empty($soapclient->error_str)) { if ($attempts < $max_attempts && substr_count($soapclient->error_str, 'HTTP Error: socket read of headers timed out') > 0) { echo "Could not retrieve file patterns list. Error was: " . $soapclient->error_str; $attempts++; echo "<BR> {$attempts} of {$max_attempts} attempts trying again<br>"; flush(); ob_flush(); return disc_client_file_sync($soapclient, $session, $verbose, $attempts); } die("Failed: Could not retrieve file list. Error was: " . $soapclient->error_str); } if ($result['error']['number'] != 0) { die("Failed: Could not retrieve file list. Error was: " . $result['error']['name'] . ' - ' . $result['description']); } $temp_file = tempnam($temp_dir, "sug"); write_encoded_file($result, $temp_dir, $temp_file); require_once $temp_file; // determine which files are needed locally $needed_file_list = array(); $server_files = array(); // used later for removing unneeded local files foreach ($server_file_list as $result) { $server_filename = $result['filename']; $server_md5 = $result['md5']; $server_files[] = $server_filename; $ignore = false; foreach ($disc_client_ignore as $ignore_pattern) { if (preg_match("#" . $ignore_pattern . "#", $server_filename)) { $ignore = true; } } if (file_exists($server_filename)) { if (!$ignore && md5_file($server_filename) != $server_md5) { // not on the ignore list and the client's md5sum does not match the server's $needed_file_list[] = $server_filename; } } else { if (!$ignore) { $return_str .= disc_client_utils_print("File missing from client : {$temp_dir}/{$server_filename}<br>", $verbose); $needed_file_list[] = $server_filename; } } } if (sizeof($server_files) < 100) { if ($attempts < $max_attempts && substr_count($soapclient->error_str, 'HTTP Error: socket read of headers timed out') > 0) { echo "Could not retrieve file patterns list. Error was: " . $soapclient->error_str; $attempts++; echo "<BR> {$attempts} of {$max_attempts} attempts trying again<br>"; flush(); ob_flush(); return disc_client_file_sync($soapclient, $session, $verbose, $attempts); } die("Failed: Empty file list returned from server. Please try again."); } // get needed files foreach ($needed_file_list as $needed_file) { $result = $soapclient->call('get_encoded_file', array('session' => $session, 'filename' => "{$needed_file}")); write_encoded_file($result, $temp_dir); } // all files recieved, copy them into place foreach ($needed_file_list as $needed_file) { if (file_exists("{$temp_dir}/{$needed_file}")) { mkdir_recursive(dirname($needed_file), true); copy("{$temp_dir}/{$needed_file}", $needed_file); $return_str .= disc_client_utils_print("Updated file: {$needed_file} <br>", $verbose); } else { $return_str .= disc_client_utils_print("File missing from client : {$temp_dir}/{$needed_file}<br>", $verbose); } } if (sizeof($needed_file_list) == 0) { $return_str .= disc_client_utils_print("No files needed to be synchronized.<br>", $verbose); } // scrub local files that are not part of client application $local_file_list = findAllFiles(".", array()); $removed_file_count = 0; foreach ($local_file_list as $local_file) { $ignore = false; foreach ($disc_client_ignore as $ignore_pattern) { if (preg_match("#" . $ignore_pattern . "#", $local_file)) { $ignore = true; } } if (!$ignore && !in_array($local_file, $server_files)) { // not on the ignore list and the server does not know about it unlink($local_file); $return_str .= disc_client_utils_print("Removed file: {$local_file} <br>", $verbose); $removed_file_count++; } } if ($removed_file_count == 0) { $return_str .= disc_client_utils_print("No files needed to be removed.<br>", $verbose); } return $return_str; }
$cachedir = sugar_cached('modules'); if (is_dir($cachedir)) { $allModFiles = array(); $allModFiles = findAllFiles($cachedir, $allModFiles); foreach ($allModFiles as $file) { //$file_md5_ref = str_replace(clean_path(getcwd()),'',$file); if (file_exists($file)) { unlink($file); } } } //delete cache/themes $cachedir = sugar_cached('themes'); if (is_dir($cachedir)) { $allModFiles = array(); $allModFiles = findAllFiles($cachedir, $allModFiles); foreach ($allModFiles as $file) { //$file_md5_ref = str_replace(clean_path(getcwd()),'',$file); if (file_exists($file)) { unlink($file); } } } ob_start(); if (!isset($_REQUEST['silent'])) { $_REQUEST['silent'] = true; } else { if (isset($_REQUEST['silent']) && $_REQUEST['silent'] != true) { $_REQUEST['silent'] = true; } }
function findAllFilesRelative($the_dir, $the_array) { $original_dir = getCwd(); chdir($the_dir); $the_array = findAllFiles(".", $the_array); chdir($original_dir); return $the_array; }