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'; }
/** * Custom install method * * @access public * @return boolean True on success * @since 1.5 */ function install() { global $installresults; $installresults = array(); $out = array(); // Get the extension manifest object $manifest =& $this->parent->getManifest(); $this->manifest =& $manifest->document; $manifestpath = $this->parent->getPath('manifest'); $sigpath = str_replace('.xml', '.sig', $manifestpath); $mf = new JEXPackageManifest($manifestpath); switch ($mf->verify) { case 'good': $msg = "Package {$mf->name} verified with openssl. Installing."; break; case 'unknown': case 'error': $msg = "Package {$mg->name} could not be checked. To verify, please install openssl. Installing."; break; case 'bad': $this->parent->abort(JText::_('Package') . ' ' . JText::_('Install') . ' Failed: ' . JText::_('Signature mismatch.')); } $installresults['verify'] = $mf->verify; $installresults['check'] = $msg; $out[] = "<div class='msg'>{$msg}</div>"; # TODO verify signature /** * --------------------------------------------------------------------------------------------- * Manifest Document Setup Section * --------------------------------------------------------------------------------------------- */ // Set the extensions name $name = $mf->name; $name = JFilterInput::clean($name, 'cmd'); $this->set('name', $name); $description = $mf->description; /** * Load the local installer class */ // If there is an install file, lets load it. $installScriptElement =& $this->manifest->getElementByPath('installfile'); $installClass = $name . 'PkgInstallHooks'; if (is_a($installScriptElement, 'JSimpleXMLElement')) { if (!class_exists($installClass, false)) { include_once $this->parent->getPath('source') . DS . $installScriptElement->data(); call_user_func(array($installClass, 'onLoad')); } } if (class_exists($installClass)) { call_user_func(array($installClass, 'beforeInstall')); } /** * --------------------------------------------------------------------------------------------- * Filesystem Processing Section * --------------------------------------------------------------------------------------------- */ $element =& $this->manifest->getElementByPath('files'); if (is_a($element, 'JSimpleXMLElement') && count($element->children())) { if ($folder = $element->attributes('folder')) { $source = $this->parent->getPath('source') . DS . $folder; } else { $source = $this->parent->getPath('source'); } foreach ($mf->filelist as $oFile) { /** @var JEXExtension */ $oFile = $oFile; $file = $source . DS . $oFile->filename; $dest = $oFile->dest; $md5 = md5(file_get_contents($file)); if ($md5 != $oFile->md5) { $out[] = "<div class='msg'>Skipping File: " . basename($file) . " signature does not match.</div>"; continue; } if ($dest) { isJInstallerHelper::extract($file, $dest, true); $out[] = "<div class='msg'>Installed: " . basename($file) . " ({$md5})</div><br>\n"; continue; // we're done with the tarball } $package = isJInstallerHelper::unpack($file); if (!$package) { $out = "<div class='msg'>Can't extract package: " . basename($file) . ". file skipped."; continue; } // Use core installer $installer =& JInstaller::getInstance(); $success = $installer->install($package['dir']); $msg = "<div class='msg'>Installed: " . basename(basename($file)) . " Signature good: ({$md5})</div><br>\n"; if ($installer->message) { $msg .= $installer->message; } $out[] = $msg; if (!is_file($package['packagefile'])) { $package['packagefile'] = $config->getValue('config.tmp_path') . DS . $package['packagefile']; } JInstallerHelper::cleanupInstall($package['packagefile'], $package['extractdir']); // End core Installer if (!$success) { $out[] = JText::_('Package') . ' ' . JText::_($install_type) . ': ' . JText::_('There was an error installing an extension:') . basename($file); } $out[] = "<hr>\n"; } // foreach } else { // Do Nothing - nothing to install } /** * --------------------------------------------------------------------------------------------- * Finalization and Cleanup Section * --------------------------------------------------------------------------------------------- */ if (class_exists($installClass)) { call_user_func(array($installClass, 'afterInstall')); } // Lastly, we will copy the manifest file to its appropriate place. @copy($manifestpath, EXPACKAGE_MANIFEST_PATH . '/' . basename($manifestpath)); @copy($sigpath, EXPACKAGE_MANIFEST_PATH . '/' . basename($sigpath)); $msg = ''; foreach ($out as $txt) { $msg .= "<p class='out'>{$txt}</p>\n"; } $this->parent->message = $msg; $installresults['out'] = $out; $installresults['msg'] = $out; return true; }
/** * Unpacks a file and verifies it as a Joomla element package * Supports .gz .tar .tar.gz and .zip * * @static * @param string $p_filename The uploaded package filename or install directory * @return boolean True on success, False on error * @since 1.5 */ static function unpack($p_filename) { // Path to the archive $archivename = $p_filename; // Temporary folder to extract the archive into $tmpdir = uniqid('install_'); // Clean the paths to use for archive extraction $extractdir = JPath::clean(dirname($p_filename) . DS . $tmpdir); $archivename = JPath::clean($archivename); // do the unpacking of the archive $result = self::archive_extract($archivename, $extractdir); if ($result === false) { return false; } /* * Lets set the extraction directory and package file in the result array so we can * cleanup everything properly later on. */ $retval['extractdir'] = $extractdir; $retval['packagefile'] = $archivename; /* * Try to find the correct install directory. In case the package is inside a * subdirectory detect this and set the install directory to the correct path. * * List all the items in the installation directory. If there is only one, and * it is a folder, then we will set that folder to be the installation folder. */ $dirList = array_merge(JFolder::files($extractdir, ''), JFolder::folders($extractdir, '')); if (count($dirList) == 1) { if (JFolder::exists($extractdir . DS . $dirList[0])) { $extractdir = JPath::clean($extractdir . DS . $dirList[0]); } } /* * We have found the install directory so lets set it and then move on * to detecting the extension type. */ $retval['dir'] = $extractdir; /* * Get the extension type and return the directory/type array on success or * false on fail. */ if ($retval['type'] = isJInstallerHelper::detectType($extractdir)) { return $retval; } else { return false; } }
<?php defined('_JEXEC') or die; global $isnid; global $mid; $url = "http://www.intellispire.com/network/order/banner.php?zone={$zoneid}&sku={$sku}&ref={$package}&isnid={$isnid1}&mid={$machineid}"; $remote_data = isJInstallerHelper::url_retrieve_curl($url); if ($remote_data) { print $remote_data; }
function remote() { if (isset($this->remote_data)) { return; } $url = UPDATER_DISPLAY . '?package=' . urlencode($this->sku); $remote_data = isJInstallerHelper::url_retrieve_curl($url); $remote_data = Spyc::YAMLLoad($remote_data); // print "<pre>\n"; // print "$url\n"; // print_r($remote_data); // print "</pre>\n"; $this->set($remote_data, 'description'); $this->set($remote_data, 'link_home'); $this->set($remote_data, 'link_extdir'); $this->set($remote_data, 'link_support'); $this->remote_data = $remote_data; }