public function action_hpm_init() { DB::register_table('packages'); include 'habaripackage.php'; include 'habaripackages.php'; include 'packagearchive.php'; include 'archivereader.php'; include 'tarreader.php'; include 'zipreader.php'; include 'txtreader.php'; PackageArchive::register_archive_reader('application/x-zip', 'ZipReader'); PackageArchive::register_archive_reader('application/zip', 'ZipReader'); PackageArchive::register_archive_reader('application/x-tar', 'TarReader'); PackageArchive::register_archive_reader('application/tar', 'TarReader'); PackageArchive::register_archive_reader('application/x-gzip', 'TarReader'); PackageArchive::register_archive_reader('text/plain', 'TxtReader'); PackageArchive::register_archive_reader('text/php', 'TxtReader'); PackageArchive::register_archive_reader('application/php', 'TxtReader'); $this->add_template('hpm', dirname(__FILE__) . '/templates/hpm.php'); $this->add_template('hpm_packages', dirname(__FILE__) . '/templates/hpm_packages.php'); $this->add_template('hpm_notice', dirname(__FILE__) . '/templates/hpm_notice.php'); }
public function download() { $file = Marketplace::downloadRemoteFile($this->getRemoteFileURL()); if (empty($file) || $file == Package::E_PACKAGE_DOWNLOAD) { return array(Package::E_PACKAGE_DOWNLOAD); } else { if ($file == Package::E_PACKAGE_SAVE) { return array($file); } else { if ($file == Package::E_PACKAGE_INVALID_APP_VERSION) { return array($file); } } } try { Loader::model('package_archive'); $am = new PackageArchive($this->getHandle()); $am->install($file, true); } catch (Exception $e) { return array($e->getMessage()); } if ($install) { $tests = Package::testForInstall($this->getHandle()); if (is_array($tests)) { return $tests; } else { $p = Loader::package($this->getHandle()); try { $p->install(); } catch (Exception $e) { return array(Package::E_PACKAGE_INSTALL); } } } }
/** * Gets the package name of the first standalone application in WCFSetup.tar.gz. */ protected static function getPackageName() { // get package name $tar = new Tar(SETUP_FILE); foreach ($tar->getContentList() as $file) { if ($file['type'] != 'folder' && StringUtil::indexOf($file['filename'], 'install/packages/') === 0) { $packageFile = basename($file['filename']); $packageName = preg_replace('!\\.(tar\\.gz|tgz|tar)$!', '', $packageFile); if ($packageName != 'com.woltlab.wcf') { try { $archive = new PackageArchive(TMP_DIR . TMP_FILE_PREFIX . $packageFile); $archive->openArchive(); self::$setupPackageName = $archive->getPackageInfo('packageName'); $archive->getTar()->close(); break; } catch (SystemException $e) { } } } } $tar->close(); // assign package name WCF::getTPL()->assign('setupPackageName', self::$setupPackageName); }
/** * Saves the stack of package installations in the package installation queue table. */ public function savePackageInstallationStack() { // get new process no require_once WCF_DIR . 'lib/acp/package/PackageInstallationQueue.class.php'; $processNo = PackageInstallationQueue::getNewProcessNo(); // build inserts $inserts = ''; foreach ($this->packageInstallationStack as $package) { // unzip tar $package['archive'] = PackageArchive::unzipPackageArchive($package['archive']); if (!empty($inserts)) { $inserts .= ','; } $inserts .= "(" . $processNo . ", " . WCF::getUser()->userID . ", '" . escapeString($package['package']) . "', " . $package['packageID'] . ", '" . escapeString($package['archive']) . "', '" . escapeString($package['action']) . "')"; } // save inserts if (!empty($inserts)) { $sql = "INSERT INTO\twcf" . WCF_N . "_package_installation_queue\n\t\t\t\t\t\t(processNo, userID, package, packageID, archive, action)\n\t\t\t\tVALUES\t\t" . $inserts; WCF::getDB()->sendQuery($sql); } return $processNo; }
/** * Checks for conflicted exclusions. */ protected function checkExclusions() { $excludedPackages = $this->packageArchive->getConflictedExcludedPackages(); if (count($excludedPackages) > 0) { // this package exludes existing packages -> stop installation WCF::getTPL()->assign(array('excludedPackages' => $excludedPackages)); WCF::getTPL()->display('packageInstallationExcludedPackages'); exit; } $excludingPackages = $this->packageArchive->getConflictedExcludingPackages(); if (count($excludingPackages) > 0) { $stop = 1; // this package is excluded by existing packages $sql = "SELECT\t*\n\t\t\t\tFROM\twcf" . WCF_N . "_package_installation_queue\n\t\t\t\tWHERE\tprocessNo = " . $this->processNo . "\n\t\t\t\t\tAND packageID IN (" . implode(',', array_keys($excludingPackages)) . ")"; $result = WCF::getDB()->sendQuery($sql); while ($row = WCF::getDB()->fetchArray($result)) { $archive = new PackageArchive($row['archive']); $archive->openArchive(); $newExclusions = $archive->getExcludedPackages(); if (!count($newExclusions) || !isset($newExclusions[$this->packageArchive->getPackageInfo('name')]) || isset($newExclusions[$this->packageArchive->getPackageInfo('name')]['version']) && Package::compareVersion($this->packageArchive->getPackageInfo('version'), $newExclusions[$this->packageArchive->getPackageInfo('name')]['version'], '<')) { unset($excludingPackages[$row['packageID']]); $stop = 0; } } if (count($excludingPackages) > 0) { WCF::getTPL()->assign(array('excludingPackages' => $excludingPackages, 'stop' => $stop, 'nextStep' => 'package')); WCF::getTPL()->display('packageInstallationExcludingPackages'); exit; } } }