Example #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;
 }
Example #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;
 }
Example #3
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;
 }
Example #4
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;
 }
Example #5
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;
	}