/** * Installs a package */ function installPackage($url, $update = false, $downloadonly) { // Download the package at the URL given try { $p_file = isJInstallerHelper::downloadPackage($url); } catch (Exception $e) { JError::raiseWarning($e->getCode(), $e->getMessage()); return false; } if ($downloadonly) { return true; } // we're done $config =& JFactory::getConfig(); $tmp_dest = $config->getValue('config.tmp_path'); // Unpack the downloaded package file $package = isJInstallerHelper::unpack($tmp_dest . DS . $p_file); if (!$package) { JError::raiseWarning("-2", "Could not unpack file: " . basename($url)); return false; } $installer = new isJInstaller(); // never static $result = false; try { if ($update) { $installer->setOverwrite(true); $result = $installer->update($package['dir']); } else { $result = $installer->install($package['dir']); } } catch (Exception $e) { // Do nothing on error - result is false } // cleanup isJInstallerHelper::cleanupInstall($package['packagefile'], $package['dir']); // JFile::delete($tmp_dest.DS.$p_file); $msg = ''; if (!$result) { // There was an error installing the package $msg .= JText::sprintf('INSTALLEXT', JText::_($package['type']), JText::_('Error')); } else { // Package installed sucessfully $msg .= JText::sprintf('INSTALLEXT', JText::_($package['type']), JText::_('Success')); } return $result; }
function genericInstall($package, $message) { $configModel = new UpdaterModel(); $this->manifest = $configModel->getManifest(); $downloadOnly = $configModel->getFlagDownloadOnly(); $e = null; $success = true; try { $url = $configModel->retrievedownloadlink($package); if ($downloadOnly) { $message .= ' (Download Only) '; $p_file = isJInstallerHelper::downloadPackage($url); if (!$p_file) { $success = false; } } else { $details = coreInstall($url); if (!$details) { $success = false; } } } catch (Exception $e) { $success = false; } if (!$success) { $message .= ' Failed.'; if ($e) { $message .= ': ' . $e->getMessage(); } $this->setRedirect('index.php?option=com_updater&task=display', $message, 'error'); return; } $message .= ' Success'; unlink(SOFTWAREINSTALLEDSTACHE); // Force refresh of installed software // $this->setRedirect('index.php?option=com_updater&task=display', $message, 'success'); include UPDATER_EVIEWS . 'install.view.default.html.php'; }