public function uploadAction() { $this->view->installNavigation = $this->getInstallNavigation('select'); $this->_helper->contextSwitch->initContext(); // Check method if (!$this->getRequest()->isPost()) { return; } // Check ul bit if (!$this->_getParam('ul')) { return; } // Process // Prepare $info = $_FILES['Filedata']; try { $archiveDir = $this->_packageManager->getTemporaryPath(Engine_Package_Manager::PATH_ARCHIVES); $extractDir = $this->_packageManager->getTemporaryPath(Engine_Package_Manager::PATH_PACKAGES); } catch (Exception $e) { $this->view->error = $e->getMessage(); return; } $targetFile = $archiveDir . '/' . $info['name']; // Check extension if (strtolower(substr($info['name'], -4, 4)) != '.tar') { $this->view->error = 'The file uploaded was not a TAR archive.'; return; } // Check if already exists if (file_exists($targetFile) && !@unlink($targetFile)) { $this->view->error = 'This file has already been uploaded, and the previous file could not be removed. Please try removing it manually in temporary/package/archives'; return; } // Check if already extracted $outputPath = $extractDir . DIRECTORY_SEPARATOR . substr($info['name'], 0, -4); if (file_exists($outputPath) && is_dir($outputPath)) { try { Engine_Package_Utilities::fsRmdirRecursive($outputPath, true); } catch (Exception $e) { $this->view->error = 'Extract path already exists and could not be removed. Please try removing it manually in temporary/package/packages'; return; } } // Try to move uploaded file if (!move_uploaded_file($info['tmp_name'], $targetFile)) { $this->view->error = 'Unable to move file to packages directory. Please set chmod 0777 on the temporary/package/archives directory.'; return; } $this->view->status = 1; $this->view->file = $info['name']; }
public function compareAction() { // Get packages $packages = $this->_packageManager->listInstalledPackages(); // Get cached diffs if (isset($this->_session->diffs)) { $diffs = $this->_session->diffs; } else { $this->_session->diffs = $diffs = new Engine_Cache_ArrayContainer(array(), $this->_cache); } // Flush diffs if ($this->_getParam('flush')) { $diffs->clean(); unset($diffs); unset($this->_session->diffs); return $this->_helper->redirector->gotoRoute(array('flush' => null)); } // Check for skip identical $showAll = (bool) $this->_getParam('all', false); // Build diffs $indexedCount = array(); if ($diffs->count() <= 0) { foreach ($packages as $key => $package) { $operation = new Engine_Package_Manager_Operation_Install($this->_packageManager, $package); $fileOperations = $operation->getFileOperations(!$showAll); $fileOperations = $fileOperations['operations']; $currentCount = 0; $indexedOperations = array(); if (!empty($fileOperations)) { // Re-index file operations do { // Get key/val and remove $path = key($fileOperations); $info = $fileOperations[$path]; $code = $info['key']; unset($fileOperations[$path]); if (!$showAll) { if ($code == 'identical') { continue; } } // Save to index $indexedOperations[$code][$path] = $info; // Count $currentCount++; // Clear unset($path); unset($info); unset($code); } while (count($fileOperations) > 0); } unset($operation); unset($fileOperations); // Save cache //if( !empty($indexedOperations) ) { $diffs->offsetSet($package->getKey(), $indexedOperations); $indexedCount[$package->getKey()] = $currentCount; //} unset($indexedOperations); } $this->_compareCountIndex = $indexedCount; // Sort $diffs->uksort(array($this, 'compareSort')); } $this->view->diffs = $diffs; // Get extracted packages $oldPackages = array(); $it = new DirectoryIterator($this->_packageManager->getTemporaryPath(Engine_Package_Manager::PATH_PACKAGES)); foreach ($it as $child) { if ($it->isDot() || $it->isFile() || !$it->isDir()) { continue; } $oldPackages[] = basename($child->getPathname()); } $this->view->oldPackages = $oldPackages; }