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
	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
 /**
  * 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;
 }
 /**
  * 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
	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);
	}
 /**
  * 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;
 }