Пример #1
0
/**
 * Backs-up files that are targeted for patch/upgrade to a restore directory
 * @param string rest_dir Full path to the directory containing the original, replaced files.
 * @param string install_file Full path to the uploaded patch/upgrade zip file
 * @param string unzip_dir Full path to the unzipped files in a temporary directory
 * @param string zip_from_dir Name of directory that the unzipped files containing the actuall replacement files
 * @param array errors Collection of errors to be displayed at end of process
 * @param string path Optional full path to the log file.
 * @return array errors
 */
function commitMakeBackupFiles($rest_dir, $install_file, $unzip_dir, $zip_from_dir, $errors, $path = '')
{
    global $mod_strings;
    // create restore file directory
    sugar_mkdir($rest_dir, 0775, true);
    if (file_exists($rest_dir) && is_dir($rest_dir)) {
        logThis('backing up files to be overwritten...', $path);
        $newFiles = findAllFiles(clean_path($unzip_dir . '/' . $zip_from_dir), array());
        // keep this around for canceling
        $_SESSION['uw_restore_dir'] = getUploadRelativeName($rest_dir);
        foreach ($newFiles as $file) {
            if (strpos($file, 'md5')) {
                continue;
            }
            // get name of current file to place in restore directory
            $cleanFile = str_replace(clean_path($unzip_dir . '/' . $zip_from_dir), '', $file);
            // make sure the directory exists
            $cleanDir = $rest_dir . '/' . dirname($cleanFile);
            sugar_mkdir($cleanDir, 0775, true);
            $oldFile = clean_path(getcwd() . '/' . $cleanFile);
            // only copy restore files for replacements - ignore new files from patch
            if (is_file($oldFile)) {
                if (is_writable($rest_dir)) {
                    logThis('Backing up file: ' . $oldFile, $path);
                    if (!copy($oldFile, $rest_dir . '/' . $cleanFile)) {
                        logThis('*** ERROR: could not backup file: ' . $oldFile, $path);
                        $errors[] = "{$mod_strings['LBL_UW_BACKUP']}::{$mod_strings['ERR_UW_FILE_NOT_COPIED']}: {$oldFile}";
                    } else {
                        $backupFilesExist = true;
                    }
                } else {
                    logThis('*** ERROR: directory not writable: ' . $rest_dir, $path);
                    $errors[] = "{$mod_strings['LBL_UW_BACKUP']}::{$mod_strings['ERR_UW_DIR_NOT_WRITABLE']}: {$oldFile}";
                }
            }
        }
    }
    logThis('file backup done.', $path);
    return $errors;
}
Пример #2
0
    $type = $installed->type;
    //rrs only display patches here
    if ($type == 'patch') {
        $version = $installed->version;
        $upgrades_installed++;
        $link = is_file($filename) ? '   <input type="hidden" name="module" value="UpgradeWizard">
					<input type="hidden" name="action" value="index">
					<input type="hidden" name="step" value="' . $_REQUEST['step'] . '">
					<input type="hidden" name="delete_package" value="true">
	        		<input type=hidden name="install_file" value="' . $filename . '" />
	        		<input type=submit value="' . $mod_strings['LBL_BUTTON_DELETE'] . '" />' : '';
        $view = 'default';
        $target_manifest = remove_file_extension($filename) . "-manifest.php";
        // cn: bug 9174 - cleared out upgrade dirs, or corrupt entries in upgrade_history give us bad file paths
        if (is_file($target_manifest)) {
            require_once getUploadRelativeName($target_manifest);
            $name = empty($manifest['name']) ? $filename : $manifest['name'];
            $description = empty($manifest['description']) ? $mod_strings['LBL_UW_NONE'] : $manifest['description'];
            if (isset($manifest['icon']) && $manifest['icon'] != "") {
                $manifest_copy_files_to_dir = isset($manifest['copy_files']['to_dir']) ? clean_path($manifest['copy_files']['to_dir']) : "";
                $manifest_copy_files_from_dir = isset($manifest['copy_files']['from_dir']) ? clean_path($manifest['copy_files']['from_dir']) : "";
                $manifest_icon = clean_path($manifest['icon']);
                $icon = "<!--not_in_theme!--><img src=\"" . $manifest_copy_files_to_dir . ($manifest_copy_files_from_dir != "" ? substr($manifest_icon, strlen($manifest_copy_files_from_dir) + 1) : $manifest_icon) . "\">";
            } else {
                $icon = getImageForType($manifest['type']);
            }
            $uwHistory .= "<form action=\"index.php\" method=\"post\">\n" . "<tr><td align=left>{$icon}</td><td align=left>{$name}</td><td align=left>{$type}</td><td align=left>{$version}</td><td align=left>{$date_entered}</td><td align=left>{$description}</td><td align=left>{$link}</td></tr>\n" . "</form>\n";
        }
    }
}
if ($upgrades_installed == 0) {