コード例 #1
0
 public function display($tpl = null)
 {
     if (!class_exists('VmConfig')) {
         require JPATH_COMPONENT_ADMINISTRATOR . DS . 'helpers' . DS . 'config.php';
     }
     VmConfig::loadConfig();
     // Load the CSS
     $config = LiveUpdateConfig::getInstance();
     $this->assign('config', $config);
     if (JVM_VERSION === 2) {
         JHtml::_('bootstrap.loadCss');
     }
     if (!$config->addMedia()) {
         // No custom CSS overrides were set; include our own
         // $document = JFactory::getDocument();
         // $url = JURI::base().'/components/'.JRequest::getCmd('option','').'/liveupdate/assets/liveupdate.css';
         // $document->addStyleSheet($url, 'text/css');
     }
     $requeryURL = 'index.php?option=' . JRequest::getCmd('option', '') . '&view=' . JRequest::getCmd('view', 'liveupdate') . '&force=1';
     $this->assign('requeryURL', $requeryURL);
     $extInfo = (object) $config->getExtensionInformation();
     JToolBarHelper::title($extInfo->title . ' – ' . JText::_('LIVEUPDATE_TASK_OVERVIEW'), 'liveupdate');
     if (version_compare(JVERSION, '1.6.0', 'ge')) {
         $msg = 'JTOOLBAR_BACK';
     } else {
         $msg = 'Back';
     }
     JToolBarHelper::back($msg, 'index.php?option=' . JRequest::getCmd('option', ''));
     switch (JRequest::getCmd('task', 'default')) {
         case 'startupdate':
             $this->setLayout('startupdate');
             $this->assign('url', 'index.php?option=' . JRequest::getCmd('option', '') . '&view=' . JRequest::getCmd('view', 'liveupdate') . '&task=download');
             break;
         case 'install':
             $this->setLayout('install');
             // Get data from the model
             $state =& $this->get('State');
             // Are there messages to display ?
             $showMessage = false;
             if (is_object($state)) {
                 $message1 = $state->get('message');
                 $message2 = $state->get('extension.message');
                 $showMessage = $message1 || $message2;
             }
             $this->assign('showMessage', $showMessage);
             $this->assignRef('state', $state);
             break;
         case 'overview':
         default:
             $this->setLayout('overview');
             $force = JRequest::getInt('force', 0);
             $this->assign('updateInfo', LiveUpdate::getUpdateInformation($force));
             $this->assign('runUpdateURL', 'index.php?option=' . JRequest::getCmd('option', '') . '&view=' . JRequest::getCmd('view', 'liveupdate') . '&task=startupdate');
             $needsAuth = !$config->getAuthorization() && $config->requiresAuthorization();
             $this->assign('needsAuth', $needsAuth);
             break;
     }
     parent::display($tpl);
 }
コード例 #2
0
ファイル: model.php プロジェクト: rkern21/videoeditor
	public function download()
	{
		// Get the path to Joomla!'s temporary directory
		$jreg =& JFactory::getConfig();
		$tmpdir = $jreg->getValue('config.tmp_path');
		
		jimport('joomla.filesystem.folder');
		// Make sure the user doesn't use the system-wide tmp directory. You know, the one that's
		// being erased periodically and will cause a real mess while installing extensions (Grrr!)
		if(realpath($tmpdir) == '/tmp') {
			// Someone inform the user that what he's doing is insecure and stupid, please. In the
			// meantime, I will fix what is broken.
			$tmpdir = JPATH_SITE.DS.'tmp';
		} // Make sure that folder exists (users do stupid things too often; you'd be surprised)
		elseif(!JFolder::exists($tmpdir)) {
			// Darn it, user! WTF where you thinking? OK, let's use a directory I know it's there...
			$tmpdir = JPATH_SITE.DS.'tmp';
		}

		// Oki. Let's get the URL of the package
		$updateInfo = LiveUpdate::getUpdateInformation();
		$config = LiveUpdateConfig::getInstance();
		$auth = $config->getAuthorization();
		$url = $updateInfo->downloadURL;
		
		// Sniff the package type. If sniffing is impossible, I'll assume a ZIP package
		$basename = basename($url);
		if(strstr($basename,'?')) {
			$basename = substr($basename, strstr($basename,'?')+1);
		}
		if(substr($basename,-4) == '.zip') {
			$type = 'zip';
		} elseif(substr($basename,-4) == '.tar') {
			$type = 'tar';
		} elseif(substr($basename,-4) == '.tgz') {
			$type = 'tar.gz';
		} elseif(substr($basename,-7) == '.tar.gz') {
			$type = 'tar.gz';
		} else {
			$type = 'zip';
		}
		
		// Cache the path to the package file and the temp installation directory in the session
		$target = $tmpdir.DS.$updateInfo->extInfo->name.'.update.'.$type;
		$tempdir = $tmpdir.DS.$updateInfo->extInfo->name.'_update';
		
		$session = JFactory::getSession();
		$session->set('target', $target, 'liveupdate');
		$session->set('tempdir', $tempdir, 'liveupdate');
		
		// Let's download!
		require_once dirname(__FILE__).'/download.php';
		return LiveUpdateDownloadHelper::download($url, $target);
	}
コード例 #3
0
ファイル: liveupdate.php プロジェクト: sergy444/joomla
 /**
  * Returns update information about your extension, based on your configuration settings
  * @return stdClass
  */
 public static function getUpdateInformation($force = false)
 {
     require_once dirname(__FILE__) . '/classes/updatefetch.php';
     $update = new LiveUpdateFetch();
     $info = $update->getUpdateInformation($force);
     $hasUpdates = $update->hasUpdates($force);
     $info->hasUpdates = $hasUpdates;
     $config = LiveUpdateConfig::getInstance();
     $extInfo = $config->getExtensionInformation();
     $info->extInfo = (object) $extInfo;
     return $info;
 }
コード例 #4
0
 /**
  * Parses the raw INI data into an array of update information
  * @param string $rawData The raw INI data
  * @return array The parsed data
  */
 private function parseINI($rawData)
 {
     $ret = array('version' => '', 'date' => '', 'stability' => '', 'downloadURL' => '', 'infoURL' => '', 'releasenotes' => '');
     // Get the magic string
     $magicPos = strpos($rawData, '; Live Update provision file');
     if ($magicPos === false) {
         // That's not an INI file :(
         return $ret;
     }
     if ($magicPos !== 0) {
         $rawData = substr($rawData, $magicPos);
     }
     require_once dirname(__FILE__) . '/inihelper.php';
     $iniData = LiveUpdateINIHelper::parse_ini_file($rawData, false, true);
     // Get the supported platforms
     $supportedPlatform = false;
     $versionParts = explode('.', JVERSION);
     $currentPlatform = $versionParts[0] . '.' . $versionParts[1];
     if (array_key_exists('platforms', $iniData)) {
         $rawPlatforms = explode(',', $iniData['platforms']);
         foreach ($rawPlatforms as $platform) {
             $platform = trim($platform);
             if (substr($platform, 0, 7) != 'joomla/') {
                 echo 'continue';
                 continue;
             }
             $platform = substr($platform, 7);
             if ($currentPlatform == $platform) {
                 $supportedPlatform = true;
             }
         }
     } else {
         // Lies, damn lies
         $supportedPlatform = true;
     }
     if (!$supportedPlatform) {
         return $ret;
     }
     $ret['version'] = array_key_exists('version', $iniData) ? $iniData['version'] : '';
     $ret['date'] = array_key_exists('date', $iniData) ? $iniData['date'] : '';
     $config = LiveUpdateConfig::getInstance();
     $auth = $config->getAuthorization();
     if (!array_key_exists('link', $iniData)) {
         $iniData['link'] = '';
     }
     $glue = strpos($iniData['link'], '?') === false ? '?' : '&';
     $ret['downloadURL'] = $iniData['link'] . (empty($auth) ? '' : $glue . $auth);
     if (array_key_exists('stability', $iniData)) {
         $stability = $iniData['stability'];
     } else {
         // Stability not defined; guesswork mode enabled
         $version = $ret['version'];
         if (preg_match('#^[0-9\\.]*a[0-9\\.]*#', $version) == 1) {
             $stability = 'alpha';
         } elseif (preg_match('#^[0-9\\.]*b[0-9\\.]*#', $version) == 1) {
             $stability = 'beta';
         } elseif (preg_match('#^[0-9\\.]*rc[0-9\\.]*#', $version) == 1) {
             $stability = 'rc';
         } elseif (preg_match('#^[0-9\\.]*$#', $version) == 1) {
             $stability = 'stable';
         } else {
             $stability = 'svn';
         }
     }
     $ret['stability'] = $stability;
     if (array_key_exists('releasenotes', $iniData)) {
         $ret['releasenotes'] = $iniData['releasenotes'];
     }
     if (array_key_exists('infourl', $iniData)) {
         $ret['infoURL'] = $iniData['infourl'];
     }
     return $ret;
 }
コード例 #5
0
ファイル: view.php プロジェクト: rkern21/videoeditor
	public function display($tpl = null)
	{
		// Load the CSS
		$config = LiveUpdateConfig::getInstance();
		$this->assign('config', $config);
		if(!$config->addMedia()) {
			// No custom CSS overrides were set; include our own
			$document = JFactory::getDocument();
			$url = JURI::base().'/components/'.JRequest::getCmd('option','').'/liveupdate/assets/liveupdate.css';
			$document->addStyleSheet($url, 'text/css');
		}
		
		$requeryURL = 'index.php?option='.JRequest::getCmd('option','').'&view='.JRequest::getCmd('view','liveupdate').'&force=1';
		$this->assign('requeryURL', $requeryURL);
		
		$model = $this->getModel();
		
		$extInfo = (object)$config->getExtensionInformation();
		JToolBarHelper::title($extInfo->title.' – '.JText::_('LIVEUPDATE_TASK_OVERVIEW'),'liveupdate');
		JToolBarHelper::back('AKEEBA_CONTROLPANEL', 'index.php?option='.JRequest::getCmd('option'));
		
		switch(JRequest::getCmd('task','default'))
		{
			case 'startupdate':
				$this->setLayout('startupdate');
				$this->assign('url','index.php?option='.JRequest::getCmd('option','').'&view='.JRequest::getCmd('view','liveupdate').'&task=download');
				break;
				
			case 'install':
				$this->setLayout('install');

				// Get data from the model
				$state		= &$this->get('State');
		
				// Are there messages to display ?
				$showMessage	= false;
				if ( is_object($state) )
				{
					$message1		= $state->get('message');
					$message2		= $state->get('extension.message');
					$showMessage	= ( $message1 || $message2 );
				}
		
				$this->assign('showMessage',	$showMessage);
				$this->assignRef('state',		$state);
				
				break;
				
			case 'overview':
			default:
				$this->setLayout('overview');
				
				$force = JRequest::getInt('force',0);
				$this->assign('updateInfo', LiveUpdate::getUpdateInformation($force));
				$this->assign('runUpdateURL','index.php?option='.JRequest::getCmd('option','').'&view='.JRequest::getCmd('view','liveupdate').'&task=startupdate');
				
				$needsAuth = !($config->getAuthorization()) && ($config->requiresAuthorization());
				$this->assign('needsAuth', $needsAuth); 
				break;
		}
		
		parent::display($tpl);
	}
コード例 #6
0
 /**
  * Downloads the contents of a URL and writes them to disk (if $fp is not null)
  * or returns them as a string (if $fp is null)
  * @param string $url The URL to download from
  * @param resource $fp The file pointer to download to. Omit to return the contents.
  * @return bool|string False on failure, true on success ($fp not null) or the URL contents (if $fp is null)
  */
 private static function &getCURL($url, $fp = null, $nofollow = false)
 {
     $result = false;
     $ch = curl_init($url);
     $config = new LiveUpdateConfig();
     $config->applyCACert($ch);
     if (!@curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1) && !$nofollow) {
         // Safe Mode is enabled. We have to fetch the headers and
         // parse any redirections present in there.
         curl_setopt($ch, CURLOPT_AUTOREFERER, true);
         curl_setopt($ch, CURLOPT_FAILONERROR, true);
         curl_setopt($ch, CURLOPT_HEADER, true);
         curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
         curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
         curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10);
         curl_setopt($ch, CURLOPT_TIMEOUT, 30);
         // Get the headers
         $data = curl_exec($ch);
         curl_close($ch);
         // Init
         $newURL = $url;
         // Parse the headers
         $lines = explode("\n", $data);
         foreach ($lines as $line) {
             if (substr($line, 0, 9) == "Location:") {
                 $newURL = trim(substr($line, 9));
             }
         }
         // Download from the new URL
         if ($url != $newURL) {
             return self::getCURL($newURL, $fp);
         } else {
             return self::getCURL($newURL, $fp, true);
         }
     } else {
         @curl_setopt($ch, CURLOPT_MAXREDIRS, 20);
     }
     curl_setopt($ch, CURLOPT_AUTOREFERER, true);
     curl_setopt($ch, CURLOPT_FAILONERROR, true);
     curl_setopt($ch, CURLOPT_HEADER, false);
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
     curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
     curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10);
     curl_setopt($ch, CURLOPT_TIMEOUT, 30);
     // Pretend we are IE7, so that webservers play nice with us
     curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 1.0.3705; .NET CLR 1.1.4322; Media Center PC 4.0)');
     if (is_resource($fp)) {
         curl_setopt($ch, CURLOPT_FILE, $fp);
     }
     $result = curl_exec($ch);
     curl_close($ch);
     return $result;
 }
コード例 #7
0
 /**
  * Makes sure that the Professional release can be updated using Joomla!'s
  * own update system. THIS IS AN AKEEBA ORIGINAL!
  */
 public function applyJoomlaExtensionUpdateChanges()
 {
     if (!version_compare(JVERSION, '1.7.0', 'ge')) {
         return;
     }
     if (!AKEEBA_PRO) {
         return;
     }
     $update_url = 'https://www.akeebabackup.com/index.php?option=com_ars&view=update&task=stream&format=xml&id=2';
     $option = 'com_akeeba';
     if (!class_exists('LiveUpdateConfig')) {
         return;
     }
     $luc = new LiveUpdateConfig();
     $dlid = $luc->getAuthorization();
     $db = $this->getDbo();
     $query = $db->getQuery(true)->select(array($db->nq('us') . '.*'))->from($db->nq('#__extensions') . ' AS ' . $db->nq('ex'))->innerJoin($db->nq('#__update_sites_extensions') . ' AS ' . $db->nq('map') . ' ON (' . $db->nq('map') . '.' . $db->nq('extension_id') . ' = ' . $db->nq('ex') . '.' . $db->nq('extension_id') . ')')->innerJoin($db->nq('#__update_sites') . ' AS ' . $db->nq('us') . ' ON (' . $db->nq('us') . '.' . $db->nq('update_site_id') . ' = ' . $db->nq('map') . '.' . $db->nq('update_site_id') . ')')->where($db->nq('ex') . '.' . $db->nq('element') . ' = ' . $db->q($option));
     $db->setQuery($query);
     $update_site = $db->loadObject();
     if ($dlid) {
         $dlid = '&' . $dlid;
     }
     $proper_url = $update_url . $dlid . '/extension.xml';
     if ($update_site->location != $proper_url) {
         if (in_array('last_check_timestamp', get_object_vars($update_site))) {
             $update_site->last_check_timestamp = 0;
         }
         $update_site->location = $proper_url;
         $db->updateObject('#__update_sites', $update_site, 'update_site_id');
     }
 }
コード例 #8
0
 /**
  * Parses the raw INI data into an array of update information
  * @param string $rawData The raw INI data
  * @return array The parsed data
  */
 private function parseINI($rawData)
 {
     $ret = array('version' => '', 'date' => '', 'stability' => '', 'downloadURL' => '', 'infoURL' => '', 'releasenotes' => '');
     // Get the magic string
     $magicPos = strpos($rawData, '; Live Update provision file');
     if ($magicPos === false) {
         // That's not an INI file :(
         return $ret;
     }
     if ($magicPos !== 0) {
         $rawData = substr($rawData, $magicPos);
     }
     require_once dirname(__FILE__) . '/inihelper.php';
     $iniData = LiveUpdateINIHelper::parse_ini_file($rawData, false, true);
     $ret['version'] = $iniData['version'];
     $ret['date'] = $iniData['date'];
     $config = LiveUpdateConfig::getInstance();
     $auth = $config->getAuthorization();
     $glue = strpos($iniData['link'], '?') === false ? '?' : '&';
     $ret['downloadURL'] = $iniData['link'] . (empty($auth) ? '' : $glue . $auth);
     if (array_key_exists('stability', $iniData)) {
         $stability = $iniData['stability'];
     } else {
         // Stability not defined; guesswork mode enabled
         $version = $ret['version'];
         if (preg_match('#^[0-9\\.]*a[0-9\\.]*#', $version) == 1) {
             $stability = 'alpha';
         } elseif (preg_match('#^[0-9\\.]*b[0-9\\.]*#', $version) == 1) {
             $stability = 'beta';
         } elseif (preg_match('#^[0-9\\.]*rc[0-9\\.]*#', $version) == 1) {
             $stability = 'rc';
         } elseif (preg_match('#^[0-9\\.]*$#', $version) == 1) {
             $stability = 'stable';
         } else {
             $stability = 'svn';
         }
     }
     $ret['stability'] = $stability;
     if (array_key_exists('releasenotes', $iniData)) {
         $ret['releasenotes'] = $iniData['releasenotes'];
     }
     if (array_key_exists('infourl', $iniData)) {
         $ret['infoURL'] = $iniData['infourl'];
     }
     return $ret;
 }