function installUpdate() { if (!file_exists($this->versions_path)) { $params =& $this->params; RokUpdater::updateVersion($params->get('update_name'), $params->get('update_slug'), $params->get('current_version'), $this->details_url); } // read version file jimport('joomla/filesystem.file'); $version = json_decode(JFile::read($this->versions_path)); $this->current_version = $version->current_version; $alldetails = $this->_decodeJSONData($this->details_path); foreach ($alldetails as $key => $details) { if ($key == $version->slug) { foreach ($details->versions as $newversion) { if (version_compare($this->current_version, $newversion->minimum_version, '>=')) { $details->download_url = $newversion->download_url; $details->version = $newversion->version; $details->md5 = $newversion->md5; } } $file_path = $this->tmp_path . DS . basename($details->download_url); $result = RokUpdater::downloadFile($details->download_url, $file_path); if (is_object($result)) { HTML_RokError::showError('Download Failed: ' . $result->message . '(' . $result->number . ')</p>'); return false; } if (md5_file($file_path) != $details->md5) { HTML_RokError::showError('MD5 Mismatch: The MD5 hash for the downloaded file does not match the anticipated value.</p>'); return false; } $extractor = $this->extractor; $install_path = $this->tmp_path; // Temporary folder to extract the archive into $tmpdir = uniqid('install_'); $install_path = $install_path . DS . $tmpdir; switch ($extractor) { case ROKUPDATER_EXTRACTOR_16: RokUpdater::import('joomla.filesystem.archive'); if (!JArchive::extract($file_path, $install_path)) { HTML_RokError::showError('Failed to extract archive!'); return false; } break; case ROKUPDATER_EXTRACTOR_15: jimport('joomla.filesystem.archive'); if (!JArchive::extract($file_path, $install_path)) { HTML_RokError::showError('Failed to extract archive!'); return false; } break; case ROKUPDATER_EXTRACTOR_PEAR: jimport('pear.archive_tar.Archive_Tar'); $extractor = new Archive_Tar($install_path); if (!$extractor->extract(JPATH_SITE)) { HTML_RokError::showError('Failed to extract archive!'); return false; } break; } jimport('joomla.installer.installer'); jimport('joomla.installer.helper'); jimport('joomla.filesystem.folder'); jimport('joomla.filesystem.file'); // Get an installer instance $installer =& RokStarInstaller::getInstance(); // Run the installer and catch any output ob_start(); $ret = $installer->install($install_path); $output = ob_get_clean(); $errors = JError::getErrors(); JFolder::delete($install_path); JFile::delete($file_path); RokUpdater::updateVersion($details->name, $version->slug, $details->version, $this->details_url); return $ret; } } }