本文整理汇总了PHP中JInstallerHelper::downloadPackage方法的典型用法代码示例。如果您正苦于以下问题:PHP JInstallerHelper::downloadPackage方法的具体用法?PHP JInstallerHelper::downloadPackage怎么用?PHP JInstallerHelper::downloadPackage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JInstallerHelper
的用法示例。
在下文中一共展示了JInstallerHelper::downloadPackage方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: install
/**
* Download and install
*/
function install($id, $url)
{
if (!is_string($url)) {
return JText::_('NNEM_ERROR_NO_VALID_URL');
}
$url = 'http://' . str_replace('http://', '', $url);
if (!($target = JInstallerHelper::downloadPackage($url))) {
return JText::_('NNEM_ERROR_CANNOT_DOWNLOAD_FILE');
}
$target = JFactory::getConfig()->get('tmp_path') . '/' . $target;
NNFrameworkFunctions::loadLanguage('com_installer', JPATH_ADMINISTRATOR);
jimport('joomla.installer.installer');
jimport('joomla.installer.helper');
// Get an installer instance
$installer = JInstaller::getInstance();
// Unpack the package
$package = JInstallerHelper::unpack($target);
// Cleanup the install files
if (!is_file($package['packagefile'])) {
$config = JFactory::getConfig();
$package['packagefile'] = $config->get('tmp_path') . '/' . $package['packagefile'];
}
JInstallerHelper::cleanupInstall($package['packagefile'], $package['packagefile']);
// Install the package
if (!$installer->install($package['dir'])) {
// There was an error installing the package
return JText::sprintf('COM_INSTALLER_INSTALL_ERROR', JText::_('COM_INSTALLER_TYPE_TYPE_' . strtoupper($package['type'])));
}
return true;
}
示例2: postflight
function postflight($type, $parent)
{
$url = "http://www.jhackguard.com/downloads/com_jhackguard.zip";
// Download the package at the URL given
$p_file = JInstallerHelper::downloadPackage($url);
// Was the package downloaded?
if (!$p_file) {
JError::raiseWarning('', JText::_('COM_INSTALLER_MSG_INSTALL_INVALID_URL'));
return false;
}
$config = JFactory::getConfig();
$tmp_dest = $config->get('tmp_path');
// Unpack the downloaded package file
$package = JInstallerHelper::unpack($tmp_dest . '/' . $p_file, true);
// Was the package unpacked?
if (!$package || !$package['type']) {
if (in_array($installType, array('upload', 'url'))) {
JInstallerHelper::cleanupInstall($package['packagefile'], $package['extractdir']);
}
$app->setUserState('com_installer.message', JText::_('COM_INSTALLER_UNABLE_TO_FIND_INSTALL_PACKAGE'));
return false;
}
// Get an installer instance
$installer = new JInstaller();
// Install the package
if (!$installer->install($package['dir'])) {
// There was an error installing the package
$msg = JText::sprintf('COM_INSTALLER_INSTALL_ERROR', JText::_('COM_INSTALLER_TYPE_TYPE_' . strtoupper($package['type'])));
$result = false;
} else {
// Package installed sucessfully
$msg = JText::sprintf('COM_INSTALLER_INSTALL_SUCCESS', JText::_('COM_INSTALLER_TYPE_TYPE_' . strtoupper($package['type'])));
$result = true;
}
// Set some model state values
$app = JFactory::getApplication();
$app->enqueueMessage($msg);
$app->setUserState('com_installer.message', $installer->message);
$app->setUserState('com_installer.extension_message', $installer->get('extension_message'));
$app->setUserState('com_installer.redirect_url', $installer->get('redirect_url'));
// Cleanup the install files
if (!is_file($package['packagefile'])) {
$config = JFactory::getConfig();
$package['packagefile'] = $config->get('tmp_path') . '/' . $package['packagefile'];
}
JInstallerHelper::cleanupInstall($package['packagefile'], $package['extractdir']);
$app->enqueueMessage("The default installation of jHackGuard has no filters included. Please download the latest filters by going to the '<b>Filter Maintenance</b>' page in the component menu.", "error");
}
示例3: init
/**
* Initialize all img tags to schedule image resizing via AJAX request.
*
* @param string $path Absolute path to the directory for storing optimized image.
* @param integer $maxWidth Maximum allowed image width.
* @param string $responseBody Generated HTML response body.
* @param boolean $setNewResponse Set new response body directly or return as string.
*
* @return mixed
*/
public static function init($path, $maxWidth, $responseBody = '', $setNewResponse = true)
{
if (!JFolder::exists($path)) {
JFolder::create($path);
}
// Initialize reponse body
!empty($responseBody) or $responseBody = JResponse::getBody();
// Get all img tags loaded in response body
if (preg_match_all('#<img([^>]+)? src=("|\')([^"\']+)("|\')([^>]+)?>#i', $responseBody, $matches, PREG_SET_ORDER)) {
foreach ($matches as $match) {
// Image already optimized
$replace = '';
if (is_readable($imagePath = $path . DS . $maxWidth . DS . basename($match[3]))) {
// Get link to optimized image
$link = JURI::root(true) . str_replace(str_replace(array('/', '\\'), array('/', '/'), JPATH_ROOT), '', str_replace(array('/', '\\'), array('/', '/'), $path . DS . $maxWidth . DS . basename($match[3])));
// Get image dimension
$imageSize = @getimagesize($imagePath);
// Generate replacement
$replace = self::updateImageDimension(str_replace('src=' . $match[2] . $match[3] . $match[4], 'src=' . $match[2] . $link . $match[4], $match[0]), $imageSize[0], $imageSize[1], $match[2]);
// Update response body
$responseBody = str_replace($match[0], $replace, $responseBody);
} else {
// Get image path
$imagePath = str_replace(array(JURI::root(), JURI::root(true)), array(JPATH_ROOT, JPATH_ROOT), $match[3]);
// Download remote image
if (substr($imagePath, 0, 5) == 'http:' or substr($imagePath, 0, 6) == 'https:') {
if (!($tmp = JInstallerHelper::downloadPackage($imagePath))) {
continue;
}
$imagePath = $path . DS . basename($tmp);
// Move downloaded image to the directory for storing optimized image files
JFile::move(JFactory::getConfig()->get('tmp_path') . DS . $tmp, $imagePath);
}
// Get image dimension
$imageSize = @getimagesize($imagePath);
if ($imageSize[0] > $maxWidth) {
// Replace remote image with local one if necessary
if (strpos($match[3], JURI::root()) !== 0 and strpos($match[3], JURI::root(true)) !== 0) {
// Generate replacement
$tmpPath = str_replace(JPATH_ROOT, JURI::root(true), $imagePath);
$replace[3] = str_replace('\\', '/', $tmpPath);
$replace[0] = str_replace($match[3], $replace[3], $match[0]);
// Update response body
$responseBody = str_replace($match[0], $replace[0], $responseBody);
// Update matching result
$match[0] = $replace[0];
$match[3] = $replace[3];
}
// Update response body
self::updateResponseBody($responseBody, $match, $path, $maxWidth, $imageSize);
} elseif (strpos($match[0], 'width=') === false or strpos($match[0], 'height=') === false) {
// Generate replacement
$replace = self::updateImageDimension($match[0], $imageSize[0], $imageSize[1], $match[2]);
// Update response body
$responseBody = str_replace($match[0], $replace, $responseBody);
}
}
}
}
// Set new response body directly or return it?
return $setNewResponse ? JResponse::setBody($responseBody) : $responseBody;
}
示例4: update
function update()
{
$installtype = JRequest::getVar('installtype');
$jshopConfig = JSFactory::getConfig();
$back = JRequest::getVar('back');
if (!extension_loaded('zlib')) {
JError::raiseWarning('', JText::_('COM_INSTALLER_MSG_INSTALL_WARNINSTALLZLIB'));
$this->setRedirect("index.php?option=com_jshopping&controller=update");
return false;
}
if ($installtype == 'package') {
$userfile = JRequest::getVar('install_package', null, 'files', 'array');
if (!(bool) ini_get('file_uploads')) {
JError::raiseWarning('', JText::_('COM_INSTALLER_MSG_INSTALL_WARNINSTALLFILE'));
$this->setRedirect("index.php?option=com_jshopping&controller=update");
return false;
}
if (!is_array($userfile)) {
JError::raiseWarning('', JText::_('No file selected'));
$this->setRedirect("index.php?option=com_jshopping&controller=update");
return false;
}
if ($userfile['error'] || $userfile['size'] < 1) {
JError::raiseWarning('', JText::_('COM_INSTALLER_MSG_INSTALL_WARNINSTALLUPLOADERROR'));
$this->setRedirect("index.php?option=com_jshopping&controller=update");
return false;
}
$config = JFactory::getConfig();
$tmp_dest = $config->get('tmp_path') . '/' . $userfile['name'];
$tmp_src = $userfile['tmp_name'];
jimport('joomla.filesystem.file');
$uploaded = JFile::upload($tmp_src, $tmp_dest, false, true);
$archivename = $tmp_dest;
$tmpdir = uniqid('install_');
$extractdir = JPath::clean(dirname($archivename) . '/' . $tmpdir);
$archivename = JPath::clean($archivename);
} else {
jimport('joomla.installer.helper');
$url = JRequest::getVar('install_url');
if (preg_match('/(sm\\d+):(.*)/', $url, $matches)) {
$url = $jshopConfig->updates_server[$matches[1]] . "/" . $matches[2];
}
if (!$url) {
JError::raiseWarning('', JText::_('COM_INSTALLER_MSG_INSTALL_ENTER_A_URL'));
$this->setRedirect("index.php?option=com_jshopping&controller=update");
return false;
}
$p_file = JInstallerHelper::downloadPackage($url);
if (!$p_file) {
JError::raiseWarning('', JText::_('COM_INSTALLER_MSG_INSTALL_INVALID_URL'));
$this->setRedirect("index.php?option=com_jshopping&controller=update");
return false;
}
$config = JFactory::getConfig();
$tmp_dest = $config->get('tmp_path');
$tmpdir = uniqid('install_');
$extractdir = JPath::clean(dirname(JPATH_BASE) . '/tmp/' . $tmpdir);
$archivename = JPath::clean($tmp_dest . '/' . $p_file);
}
saveToLog("install.log", "\nStart install: " . $archivename);
$result = JArchive::extract($archivename, $extractdir);
if ($result === false) {
JError::raiseWarning('500', "Archive error");
saveToLog("install.log", "Archive error");
$this->setRedirect("index.php?option=com_jshopping&controller=update");
return false;
}
$pathinfo = pathinfo($archivename);
$this->backup_folder = 'jsbk' . date('ymdHis') . '_' . $pathinfo['filename'];
if (file_exists($extractdir . "/checkupdate.php")) {
include $extractdir . "/checkupdate.php";
}
if (file_exists($extractdir . "/configupdate.php")) {
include $extractdir . "/configupdate.php";
}
if (isset($configupdate['version']) && !$this->checkVersionUpdate($configupdate['version'])) {
$this->setRedirect("index.php?option=com_jshopping&controller=update");
return 0;
}
if (!$this->copyFiles($extractdir)) {
JError::raiseWarning(500, _JSHOP_INSTALL_THROUGH_JOOMLA);
saveToLog("install.log", 'INSTALL_THROUGH_JOOMLA');
$this->setRedirect("index.php?option=com_jshopping&controller=update");
return 0;
}
if (file_exists($extractdir . "/update.sql")) {
$db = JFactory::getDBO();
$lines = file($extractdir . "/update.sql");
$fullline = implode(" ", $lines);
$queryes = $db->splitSql($fullline);
foreach ($queryes as $query) {
if (trim($query) != '') {
$db->setQuery($query);
$db->query();
if ($db->getErrorNum()) {
JError::raiseWarning(500, $db->stderr());
saveToLog("install.log", "Update - " . $db->stderr());
}
}
}
//.........这里部分代码省略.........
示例5: _getPackageFromUrl
/**
* Install an extension from a URL
*
* @return Package details or false on failure
*
* @since 1.5
*/
protected function _getPackageFromUrl()
{
$input = JFactory::getApplication()->input;
// Get the URL of the package to install
$url = $input->getString('install_url');
// Did you give us a URL?
if (!$url) {
JError::raiseWarning('', JText::_('COM_INSTALLER_MSG_INSTALL_ENTER_A_URL'));
return false;
}
// Download the package at the URL given
$p_file = JInstallerHelper::downloadPackage($url);
// Was the package downloaded?
if (!$p_file) {
JError::raiseWarning('', JText::_('COM_INSTALLER_MSG_INSTALL_INVALID_URL'));
return false;
}
$config = JFactory::getConfig();
$tmp_dest = $config->get('tmp_path');
// Unpack the downloaded package file
$package = JInstallerHelper::unpack($tmp_dest . '/' . $p_file);
return $package;
}
示例6: update
/**
* Method to upgrade a specific extension
*
* @package MageBridge
* @access public
* @param string $exension_name
* @return bool
*/
private function update($extension_name = null)
{
// Do not continue if the extension name is empty
if ($extension_name == null) {
JError::raiseWarning('SOME_ERROR_CODE', JText::_('COM_MAGEBRIDGE_MODEL_UPDATE_INSTALL_NO_EXTENSION'));
return false;
}
// Fetch a list of available packages
$packages = MageBridgeUpdateHelper::getPackageList();
foreach ($packages as $package) {
if ($package['name'] == $extension_name) {
$extension = $package;
break;
}
}
// Do not continue if the extension does not appear from the list
if ($extension == null) {
JError::raiseWarning('SOME_ERROR_CODE', JText::_('COM_MAGEBRIDGE_MODEL_UPDATE_INSTALL_UNKNOWN_EXTENSION'));
return false;
}
// Premature check for the component-directory to be writable
if ($extension['type'] == 'component' && JFactory::getConfig()->get('ftp_enable') == 0) {
if (is_dir(JPATH_ADMINISTRATOR . '/components/' . $extension['name']) && !is_writable(JPATH_ADMINISTRATOR . '/components/' . $extension['name'])) {
JError::raiseWarning('SOME_ERROR_CODE', JText::sprintf('COM_MAGEBRIDGE_MODEL_UPDATE_INSTALL_DIR_NOT_WRITABLE', JPATH_ADMINISTRATOR . '/components/' . $extension['name']));
return false;
} else {
if (!is_dir(JPATH_ADMINISTRATOR . '/components/' . $extension['name']) && !is_writable(JPATH_ADMINISTRATOR . '/components')) {
JError::raiseWarning('SOME_ERROR_CODE', JText::sprintf('COM_MAGEBRIDGE_MODEL_UPDATE_INSTALL_DIR_NOT_WRITABLE', JPATH_ADMINISTRATOR . '/components'));
return false;
}
}
}
// Construct the update URL
$extension_uri = $extension['name'];
$extension_uri .= '_j25';
$extension_uri .= '.' . MagebridgeModelConfig::load('update_format');
$extension_url = $this->getUrl($extension_uri);
// Either use fopen() or CURL
if (ini_get('allow_url_fopen') == 1 && MagebridgeModelConfig::load('update_method') == 'joomla') {
$package_file = JInstallerHelper::downloadPackage($extension_url, $extension_uri);
} else {
$package_file = MageBridgeUpdateHelper::downloadPackage($extension_url, $extension_uri);
}
// Simple check for the result
if ($package_file == false) {
JError::raiseWarning('SOME_ERROR_CODE', JText::sprintf('COM_MAGEBRIDGE_MODEL_UPDATE_INSTALL_DOWNLOAD_FAILED', $extension_uri));
return false;
}
// Check if the downloaded file exists
$tmp_path = JFactory::getConfig()->get('tmp_path');
$package_path = $tmp_path . '/' . $package_file;
if (!is_file($package_path)) {
JError::raiseWarning('MB', JText::sprintf('COM_MAGEBRIDGE_MODEL_UPDATE_INSTALL_FILE_NOT_EXISTS', $package_path));
return false;
}
// Check if the file is readable
if (!is_readable($package_path)) {
JError::raiseWarning('MB', JText::sprintf('COM_MAGEBRIDGE_MODEL_UPDATE_INSTALL_FILE_NOT_READABLE', $package_path));
return false;
}
// Check if the downloaded file is abnormally small (so it might just contain a simple warning-text)
if (filesize($package_path) < 128) {
$contents = @file_get_contents($package_path);
if (empty($contents)) {
JError::raiseWarning('MB', JText::_('COM_MAGEBRIDGE_MODEL_UPDATE_INSTALL_FILE_EMPTY'));
return false;
} else {
if (preg_match('/^Restricted/', $contents)) {
JError::raiseWarning('MB', JText::sprintf('COM_MAGEBRIDGE_MODEL_UPDATE_INSTALL_NO_ACCESS'));
return false;
}
}
JError::raiseWarning('MB', JText::sprintf('COM_MAGEBRIDGE_MODEL_UPDATE_INSTALL_FILE_NO_ARCHIVE', $package_path));
return false;
}
// Now we assume this is an archive, so let's unpack it
$package = JInstallerHelper::unpack($package_path);
if ($package == false) {
JError::raiseWarning('SOME_ERROR_CODE', JText::sprintf('COM_MAGEBRIDGE_MODEL_UPDATE_INSTALL_FILE_GONE', $extension['name']));
return false;
}
// Quick workaround to prevent Koowa proxying the database
if (class_exists('KInput')) {
KInput::set('option', 'com_installer', 'get');
}
// Call the actual installer to install the package
$installer = JInstaller::getInstance();
if ($installer->install($package['dir']) == false) {
JError::raiseWarning('SOME_ERROR_CODE', JText::sprintf('COM_MAGEBRIDGE_MODEL_UPDATE_INSTALL_FAILED', $extension['name']));
return false;
}
// Get the name of downloaded package
//.........这里部分代码省略.........
示例7: _getPackageFromUrl
/**
* Import an spreadsheet from a URL
*
* @return Package details or false on failure
*
*/
protected function _getPackageFromUrl()
{
$app = JFactory::getApplication();
$input = $app->input;
// Get the URL of the package to import
$url = $input->getString('import_url');
// Did you give us a URL?
if (!$url) {
$app->enqueueMessage(JText::_('COM_DEMO_IMPORT_MSG_ENTER_A_URL'), 'warning');
return false;
}
// Download the package at the URL given
$p_file = JInstallerHelper::downloadPackage($url);
// Was the package downloaded?
if (!$p_file) {
$app->enqueueMessage(JText::_('COM_DEMO_IMPORT_MSG_INVALID_URL'), 'warning');
return false;
}
// check that this is a valid spreadsheet
$package = $this->check($p_file);
return $package;
}
示例8: restore
public function restore()
{
if (!JSession::checkToken()) {
$this->response->errors[] = JText::_('JINVALID_TOKEN');
$this->response->failed = 1;
} else {
// database
$db = JFactory::getDbo();
// Delete v3 tables
$sql = JPATH_SITE . '/administrator/components/com_k2/uninstall.sql';
$queries = JDatabaseDriver::splitSql(file_get_contents($sql));
foreach ($queries as $query) {
$query = trim($query);
if ($query != '' && $query[0] != '#') {
$db->setQuery($query);
$db->execute();
}
}
// Restore v2 tables
$tables = array('#__k2_v2_attachments', '#__k2_v2_categories', '#__k2_v2_comments', '#__k2_v2_extra_fields', '#__k2_v2_extra_fields_groups', '#__k2_v2_items', '#__k2_v2_rating', '#__k2_v2_tags', '#__k2_v2_tags_xref', '#__k2_v2_users', '#__k2_v2_user_groups');
foreach ($tables as $table) {
$name = str_replace('#__k2_v2_', '#__k2_', $table);
$db->setQuery('DROP TABLE IF EXISTS ' . $db->quoteName($name));
$db->execute();
$db->setQuery('RENAME TABLE ' . $db->quoteName($table) . ' TO ' . $db->quoteName($name));
$db->execute();
}
// Restore component files manually to keep any custom templates
if (JFolder::exists(JPATH_SITE . '/components/com_k2')) {
JFolder::delete(JPATH_SITE . '/components/com_k2');
JFolder::move(JPATH_SITE . '/components/com_k2_v2', JPATH_SITE . '/components/com_k2');
}
if (JFolder::exists(JPATH_ADMINISTRATOR . '/components/com_k2')) {
JFolder::delete(JPATH_ADMINISTRATOR . '/components/com_k2');
JFolder::move(JPATH_ADMINISTRATOR . '/components/com_k2_v2', JPATH_ADMINISTRATOR . '/components/com_k2');
}
// Install K2 v2 package to restore rest extension files
$installer = JInstaller::getInstance();
$file = JInstallerHelper::downloadPackage('http://getk2.org/downloads/?f=K2_v2.6.9.zip');
$config = JFactory::getConfig();
$package = JInstallerHelper::unpack($config->get('tmp_path') . '/' . $file, true);
$installer->install($package['dir']);
}
echo json_encode($this->response);
return $this;
}
示例9: _getPackageFromUrl
/**
* Install an extension from a URL
*
* @static
* @return boolean True on success
* @since 1.5
*/
function _getPackageFromUrl()
{
// Get a database connector
$db =& JFactory::getDBO();
// Get the URL of the package to install
$url = JRequest::getString('install_url');
// Did you give us a URL?
if (!$url) {
JError::raiseWarning('SOME_ERROR_CODE', JText::_('Please enter a URL'));
return false;
}
// Download the package at the URL given
$p_file = JInstallerHelper::downloadPackage($url);
// Was the package downloaded?
if (!$p_file) {
JError::raiseWarning('SOME_ERROR_CODE', JText::_('Invalid URL'));
return false;
}
$config =& JFactory::getConfig();
$tmp_dest = $config->getValue('config.tmp_path');
// Unpack the downloaded package file
$package = JInstallerHelper::unpack($tmp_dest . '/' . $p_file);
return $package;
}
示例10: handleDownload
/**
* Prepare the installation for an extension specified by a URL
*
* @param OutputInterface $output An OutputInterface instance
* @param string $source The extension source
*
* @return string The location of the prepared extension
*/
private function handleDownload(OutputInterface $output, $source)
{
$this->writeln($output, "Downloading {$source}", OutputInterface::VERBOSITY_VERBOSE);
return $this->unpack(\JInstallerHelper::downloadPackage($source));
}
示例11: _getPackageFromUrl
/**
* Install an extension from a URL
*
* @return Package details or false on failure
* @since 1.5
*/
protected function _getPackageFromUrl()
{
// Get a database connector
$db = JFactory::getDbo();
// Get the URL of the package to install
$url = JRequest::getString('install_url');
// Did you give us a URL?
if (!$url) {
JCKHelper::error(JText::_('COM_INSTALLER_MSG_INSTALL_ENTER_A_URL'));
return false;
}
// Download the package at the URL given
$p_file = JInstallerHelper::downloadPackage($url);
// Was the package downloaded?
if (!$p_file) {
JCKHelper::error(JText::_('COM_INSTALLER_MSG_INSTALL_INVALID_URL'));
return false;
}
$config = JFactory::getConfig();
$tmp_dest = $config->get('tmp_path');
// Unpack the downloaded package file
$package = JInstallerHelper::unpack($tmp_dest . DS . $p_file);
return $package;
}
示例12: getPackageFromUrl
/**
* Get the package from the updates server
*
* @return Package details or false on failure
*/
protected function getPackageFromUrl($type = 'library')
{
jimport('joomla.installer.helper');
// Get a database connector
$db = JFactory::getDbo();
// Get the URL of the package to install
if (version_compare(JVERSION, '1.6.0', 'ge')) {
// Joomla! 1.6+ code here
switch ($type) {
case "plugin":
$url = $this->plugin_url;
break;
case "library":
default:
$url = $this->lib_url;
break;
}
} else {
// Joomla! 1.5 code here
$url = $this->plugin_url_j15;
}
// Download the package at the URL given
$p_file = JInstallerHelper::downloadPackage($url);
// Was the package downloaded?
if (!$p_file) {
$this->setError(JText::_('Could not download library installation package'));
return false;
}
$config = JFactory::getConfig();
if (version_compare(JVERSION, '1.6.0', 'ge')) {
// Joomla! 1.6+ code here
$tmp_dest = $config->get('tmp_path');
} else {
// Joomla! 1.5 code here
$tmp_dest = $config->getValue('config.tmp_path');
}
// Unpack the downloaded package file
$package = JInstallerHelper::unpack($tmp_dest . '/' . $p_file);
return $package;
}
示例13: _getPackageFromUrl
protected function _getPackageFromUrl()
{
// Get the URL of the package to install
$url = JRequest::getString('url');
// Download the package at the URL given
$file = JInstallerHelper::downloadPackage($url);
// Was the package downloaded?
if (!$file) {
JError::raiseWarning(0, JText::_('Invalid URL'));
return false;
}
$config = JFactory::getConfig();
$tmp_dest = $config->getValue('config.tmp_path');
// Unpack the downloaded package file
$package = JInstallerHelper::unpack($tmp_dest . DS . $file);
return $package;
}
示例14: download
public function download()
{
// Get a database connector
$db = & JFactory::getDBO();
// Get the URL of the package to install
$url = JRequest::getString('install_url');
// Did you give us a URL?
if (!$url) {
if(version_compare(JVERSION, '1.6.0', 'ge')) {
JError::raiseWarning('', JText::_('COM_INSTALLER_MSG_INSTALL_ENTER_A_URL'));
} else {
JError::raiseWarning('SOME_ERROR_CODE', JText::_('Please enter a URL'));
}
return false;
}
// Download the package at the URL given
$p_file = JInstallerHelper::downloadPackage($url);
// Was the package downloaded?
if (!$p_file) {
if(version_compare(JVERSION, '1.6.0', 'ge')) {
JError::raiseWarning('', JText::_('COM_INSTALLER_MSG_INSTALL_INVALID_URL'));
} else {
JError::raiseWarning('SOME_ERROR_CODE', JText::_('Invalid URL'));
}
return false;
}
$config =& JFactory::getConfig();
$tmp_dest = $config->getValue('config.tmp_path');
// Store the uploaded package's location
$session = JFactory::getSession();
$session->set('compressed_package', $tmp_dest.DS.$p_file, 'akeeba');
return true;
}
示例15: _remoteInstaller
function _remoteInstaller($url)
{
jimport('joomla.installer.helper');
jimport('joomla.installer.installer');
if (!$url) {
return false;
}
$filename = JInstallerHelper::downloadPackage($url);
$config =& JFactory::getConfig();
$target = $config->getValue('config.tmp_path') . DS . basename($filename);
// Unpack
$package = JInstallerHelper::unpack($target);
if (!$package) {
// unable to find install package
}
// Install the package
$msg = '';
$installer =& JInstaller::getInstance();
//Work around: delete the manifest file to prevent plugin upgrade, only for 1.6
if (JFile::exists(JPATH_ROOT . DS . 'plugins' . DS . 'system' . DS . 'zend' . DS . 'zend.xml')) {
file_put_contents(JPATH_ROOT . DS . 'plugins' . DS . 'system' . DS . 'zend' . DS . 'zend.xml', '<?xml version="1.0" encoding="utf-8"?><install version="1.5" type="plugin" group="system" method="upgrade"></install>');
}
if (!$installer->install($package['dir'])) {
// There was an error installing the package
$msg = JText::sprintf('INSTALLEXT', JText::_($package['type']), JText::_('Error'));
$result = false;
} else {
// Package installed sucessfully
$msg = JText::sprintf('INSTALLEXT', JText::_($package['type']), JText::_('Success'));
$result = true;
}
// Clean up the install files
if (!is_file($package['packagefile'])) {
$package['packagefile'] = $config->getValue('config.tmp_path') . DS . $package['packagefile'];
}
JInstallerHelper::cleanupInstall($package['packagefile'], $package['extractdir']);
return $result;
}