Esempio n. 1
0
 /**
  * Check if a new version is available
  * @param string $updaterUrl the url to check, i.e. 'http://apps.owncloud.com/updater.php'
  * @return array | bool
  */
 public function check($updaterUrl)
 {
     // Look up the cache - it is invalidated all 30 minutes
     if (\OC_Appconfig::getValue('core', 'lastupdatedat') + 1800 > time()) {
         return json_decode(\OC_Appconfig::getValue('core', 'lastupdateResult'), true);
     }
     \OC_Appconfig::setValue('core', 'lastupdatedat', time());
     if (\OC_Appconfig::getValue('core', 'installedat', '') == '') {
         \OC_Appconfig::setValue('core', 'installedat', microtime(true));
     }
     $version = \OC_Util::getVersion();
     $version['installed'] = \OC_Appconfig::getValue('core', 'installedat');
     $version['updated'] = \OC_Appconfig::getValue('core', 'lastupdatedat');
     $version['updatechannel'] = \OC_Util::getChannel();
     $version['edition'] = \OC_Util::getEditionString();
     $version['build'] = \OC_Util::getBuild();
     $versionString = implode('x', $version);
     //fetch xml data from updater
     $url = $updaterUrl . '?version=' . $versionString;
     // set a sensible timeout of 10 sec to stay responsive even if the update server is down.
     $ctx = stream_context_create(array('http' => array('timeout' => 10)));
     $xml = @file_get_contents($url, 0, $ctx);
     if ($xml == false) {
         return array();
     }
     $data = @simplexml_load_string($xml);
     $tmp = array();
     $tmp['version'] = $data->version;
     $tmp['versionstring'] = $data->versionstring;
     $tmp['url'] = $data->url;
     $tmp['web'] = $data->web;
     // Cache the result
     \OC_Appconfig::setValue('core', 'lastupdateResult', json_encode($data));
     return $tmp;
 }
Esempio n. 2
0
 /**
  * Check if a new version is available
  *
  * @param string $updaterUrl the url to check, i.e. 'http://apps.owncloud.com/updater.php'
  * @return array|bool
  */
 public function check($updaterUrl = null)
 {
     // Look up the cache - it is invalidated all 30 minutes
     if ((int) $this->config->getAppValue('core', 'lastupdatedat') + 1800 > time()) {
         return json_decode($this->config->getAppValue('core', 'lastupdateResult'), true);
     }
     if (is_null($updaterUrl)) {
         $updaterUrl = 'https://updates.owncloud.com/server/';
     }
     $this->config->setAppValue('core', 'lastupdatedat', time());
     if ($this->config->getAppValue('core', 'installedat', '') === '') {
         $this->config->setAppValue('core', 'installedat', microtime(true));
     }
     $version = Util::getVersion();
     $version['installed'] = $this->config->getAppValue('core', 'installedat');
     $version['updated'] = $this->config->getAppValue('core', 'lastupdatedat');
     $version['updatechannel'] = \OC_Util::getChannel();
     $version['edition'] = \OC_Util::getEditionString();
     $version['build'] = \OC_Util::getBuild();
     $versionString = implode('x', $version);
     //fetch xml data from updater
     $url = $updaterUrl . '?version=' . $versionString;
     $tmp = [];
     $xml = $this->getUrlContent($url);
     if ($xml) {
         $loadEntities = libxml_disable_entity_loader(true);
         $data = @simplexml_load_string($xml);
         libxml_disable_entity_loader($loadEntities);
         if ($data !== false) {
             $tmp['version'] = (string) $data->version;
             $tmp['versionstring'] = (string) $data->versionstring;
             $tmp['url'] = (string) $data->url;
             $tmp['web'] = (string) $data->web;
         } else {
             libxml_clear_errors();
         }
     } else {
         $data = [];
     }
     // Cache the result
     $this->config->setAppValue('core', 'lastupdateResult', json_encode($data));
     return $tmp;
 }
Esempio n. 3
0
 /**
  * Get current update channel
  * @return string
  * @since 8.1.0
  */
 public static function getChannel()
 {
     return \OC_Util::getChannel();
 }
Esempio n. 4
0
 /**
  * A human readable string is generated based on version, channel and build number
  *
  * @return string
  */
 public static function getHumanVersion()
 {
     $version = OC_Util::getVersionString() . ' (' . OC_Util::getChannel() . ')';
     $build = OC_Util::getBuild();
     if (!empty($build) and OC_Util::getChannel() === 'daily') {
         $version .= ' Build:' . $build;
     }
     return $version;
 }
Esempio n. 5
0
 /**
  * runs the update actions in maintenance mode, does not upgrade the source files
  * except the main .htaccess file
  *
  * @param string $currentVersion current version to upgrade to
  * @param string $installedVersion previous version from which to upgrade from
  *
  * @throws \Exception
  * @return bool true if the operation succeeded, false otherwise
  */
 private function doUpgrade($currentVersion, $installedVersion)
 {
     // Stop update if the update is over several major versions
     $allowedPreviousVersion = $this->getAllowedPreviousVersion();
     if (!self::isUpgradePossible($installedVersion, $currentVersion, $allowedPreviousVersion)) {
         throw new \Exception('Updates between multiple major versions and downgrades are unsupported.');
     }
     // Update .htaccess files
     try {
         Setup::updateHtaccess();
         Setup::protectDataDirectory();
     } catch (\Exception $e) {
         throw new \Exception($e->getMessage());
     }
     // create empty file in data dir, so we can later find
     // out that this is indeed an ownCloud data directory
     // (in case it didn't exist before)
     file_put_contents($this->config->getSystemValue('datadirectory', \OC::$SERVERROOT . '/data') . '/.ocdata', '');
     // pre-upgrade repairs
     $repair = new Repair(Repair::getBeforeUpgradeRepairSteps());
     $this->emitRepairMessages($repair);
     $repair->run();
     // simulate DB upgrade
     if ($this->simulateStepEnabled) {
         $this->checkCoreUpgrade();
         // simulate apps DB upgrade
         $this->checkAppUpgrade($currentVersion);
     }
     if ($this->updateStepEnabled) {
         $this->doCoreUpgrade();
         // install new shipped apps on upgrade
         OC_Installer::installShippedApps();
         // update all shipped apps
         $disabledApps = $this->checkAppsRequirements();
         $this->doAppUpgrade();
         // upgrade appstore apps
         $this->upgradeAppStoreApps($disabledApps);
         // post-upgrade repairs
         $repair = new Repair(Repair::getRepairSteps());
         $this->emitRepairMessages($repair);
         $repair->run();
         //Invalidate update feed
         $this->config->setAppValue('core', 'lastupdatedat', 0);
         // Check for code integrity on the stable channel
         if (\OC_Util::getChannel() === 'stable') {
             $this->emit('\\OC\\Updater', 'startCheckCodeIntegrity');
             $this->checker->runInstanceVerification();
             $this->emit('\\OC\\Updater', 'finishedCheckCodeIntegrity');
         }
         // only set the final version if everything went well
         $this->config->setSystemValue('version', implode('.', \OCP\Util::getVersion()));
     }
 }
Esempio n. 6
0
 /**
  * @param string $baseUrl
  * @return string
  */
 private function buildUpdateUrl($baseUrl)
 {
     return $baseUrl . '?version=' . implode('x', \OCP\Util::getVersion()) . 'xinstalledatxlastupdatedatx' . \OC_Util::getChannel() . 'x' . \OC_Util::getEditionString() . 'x';
 }
Esempio n. 7
0
 /**
  * A human readable string is generated based on version, channel and build number
  * @return string
  */
 public static function getHumanVersion()
 {
     $version = '7.0.4+dfsg-4~deb8u1 (Debian)' . ' (' . OC_Util::getChannel() . ')';
     $build = OC_Util::getBuild();
     if (!empty($build) and OC_Util::getChannel() === 'daily') {
         $version .= ' Build:' . $build;
     }
     return $version;
 }
 public function testGetChannel()
 {
     $this->assertSame(\OC_Util::getChannel(), $this->environmentHelper->getChannel());
 }
Esempio n. 9
0
 /**
  * @return string
  */
 protected function getChannel()
 {
     return \OC_Util::getChannel();
 }
Esempio n. 10
0
	/**
	 * Check if a new version is available
	 *
	 * @param string $updaterUrl the url to check, i.e. 'http://apps.owncloud.com/updater.php'
	 * @return array|bool
	 */
	public function check($updaterUrl = null) {

		// Look up the cache - it is invalidated all 30 minutes
		if (($this->config->getValue('core', 'lastupdatedat') + 1800) > time()) {
			return json_decode($this->config->getValue('core', 'lastupdateResult'), true);
		}

		if (is_null($updaterUrl)) {
			$updaterUrl = 'https://apps.owncloud.com/updater.php';
		}

		$this->config->setValue('core', 'lastupdatedat', time());

		if ($this->config->getValue('core', 'installedat', '') == '') {
			$this->config->setValue('core', 'installedat', microtime(true));
		}

		$version = \OC_Util::getVersion();
		$version['installed'] = $this->config->getValue('core', 'installedat');
		$version['updated'] = $this->config->getValue('core', 'lastupdatedat');
		$version['updatechannel'] = \OC_Util::getChannel();
		$version['edition'] = \OC_Util::getEditionString();
		$version['build'] = \OC_Util::getBuild();
		$versionString = implode('x', $version);

		//fetch xml data from updater
		$url = $updaterUrl . '?version=' . $versionString;

		// set a sensible timeout of 10 sec to stay responsive even if the update server is down.

		$tmp = array();
		$xml = $this->httpHelper->getUrlContent($url);
		if ($xml) {
			$loadEntities = libxml_disable_entity_loader(true);
			$data = @simplexml_load_string($xml);
			libxml_disable_entity_loader($loadEntities);
			if ($data !== false) {
				$tmp['version'] = $data->version;
				$tmp['versionstring'] = $data->versionstring;
				$tmp['url'] = $data->url;
				$tmp['web'] = $data->web;
			}
		} else {
			$data = array();
		}

		// Cache the result
		$this->config->setValue('core', 'lastupdateResult', json_encode($data));
		return $tmp;
	}