/** * Recovery to old version * * @param unknown_type $upgradePackage * */ function doRecovery($product, $folder, $file) { global $jauc; //auto backup when recovery $this->doBackup(); // upgrade process $workingDir = FileSystemHelper::tmpDir(null, 'ja', 0777); $zipFile = $folder . $file; ArchiveHelper::unZip($zipFile, $workingDir); $workingDir = $workingDir . $this->extKey . DS; $objectFilter = new stdClass(); $this->_applyPackage($workingDir, $objectFilter); //get backup info $fileInfo = $folder . FileSystemHelper::stripExt($file) . ".txt"; if (($data = $jauc->_parseBackupInfo($fileInfo)) !== false) { return $data["version"]; } else { return ""; } }
function listBackupFiles($product, $upgradeVersion) { $folder = $this->getLocalBackupPath($product); $FileSystemHelper = new FileSystemHelper(); $files = $FileSystemHelper->files($folder); if ($files) { $aFiles = array(); $i = -1; foreach ($files as $file) { if ($FileSystemHelper->getExt($file) == "zip") { if (strpos($file, $product->extKey) === 0) { $backupName = $FileSystemHelper->stripExt($file); $fileInfo = $folder . $backupName . ".txt"; if (($data = $this->_parseBackupInfo($fileInfo)) !== false) { $i++; $aFiles[$i]['extKey'] = $product->extKey; $aFiles[$i]['version'] = $data["version"]; $aFiles[$i]['name'] = $file; $aFiles[$i]['title'] = date("M d, Y - H:i:s", strtotime($data["createDate"])); $aFiles[$i]['comment'] = $data["comment"]; if (JFolder::exists($folder . $backupName . '/')) { $aFiles[$i]['conflicted'] = 1; $aFiles[$i]['conflictedFolder'] = $backupName; } else { $aFiles[$i]['conflicted'] = 0; } } } } } if ($i >= 0) { //sort by newer down to older $aFiles = array_reverse($aFiles); //group by version return $this->msort($aFiles, 'version'); } else { //throw new Exception('[UpdaterClient->listBackupFiles] No backup file is found', 100); return false; } } else { //throw new Exception('[UpdaterClient->listBackupFiles] No backup file is found', 100); return false; } }