public function extractExtension($tempPath, $extensionFile) { try { $gzip = new Gzip($extensionFile); $gzip->extract($tempPath); unlink($extensionFile); } catch (Exception $e) { if (isset($extensionFile)) { unlink($extensionFile); } throw $e; } }
/** * installs a new plugin * * @param array with posted values * @return void */ protected function install($values) { // check if plugin file is added. if not, only update pluginmanager settings if (!array_key_exists('diffile', $values) || !array_key_exists('tmp_name', $values['diffile']) || !$values['diffile']['tmp_name']) { throw new Exception('Upload file not set. Please supply DIF installation / update file.'); } $file = $values['diffile']; $tempPath = realpath($this->director->getTempPath()); $uploadFile = $tempPath . '/' . $file['name']; if (!move_uploaded_file($file['tmp_name'], $uploadFile)) { throw new Exception("Error moving {$file['tmp_name']} to {$uploadFile}."); } try { $gzip = new Gzip($uploadFile); $gzip->extract($tempPath); $installFile = $tempPath . '/DIFInstaller.php'; if (!file_exists($installFile)) { throw new Exception("Wrong DIF installation file. Use DIF install or update files."); } // get installation script require_once $installFile; $install = new DIFInstaller(); $install->install(); unlink($installFile); unlink($uploadFile); } catch (Exception $e) { if (isset($installFile)) { unlink($installFile); } if (isset($uploadFile)) { unlink($uploadFile); } throw $e; } }