Example #1
0
 /**
  * @param bool $returnCount
  *
  * @return bool|int|string
  */
 public function getUpdates($returnCount = FALSE)
 {
     // If Joomla 1.5 - No concept of updates
     if (!file_exists(JPATH_LIBRARIES . '/joomla/updater/updater.php')) {
         return FALSE;
     }
     // Joomla 1.7.x has to be a pain in the arse!
     if (!class_exists('JUpdater')) {
         require JPATH_LIBRARIES . '/joomla/updater/updater.php';
     }
     // Let Joomla to the caching of the latest version of updates available from vendors
     $updater = JUpdater::getInstance();
     $updater->findUpdates();
     // get the resultant list of updates available
     $db = JFactory::getDbo();
     $db->setQuery('SELECT * from #__updates');
     $updates = $db->LoadObjectList();
     // reformat into a useable array with the extension_id as the array key
     $extensionUpdatesAvailable = array();
     foreach ($updates as $update) {
         $extensionUpdatesAvailable[$update->extension_id] = $update;
     }
     // get all the installed extensions from the site
     $db->setQuery('SELECT * from #__extensions');
     $items = $db->LoadObjectList();
     // init what we will return, a neat and tidy array
     $updatesAvailable = array();
     // for all installed items...
     foreach ($items as $item) {
         // merge by inject all known info into this item
         foreach ($extensionUpdatesAvailable[$item->extension_id] as $k => $v) {
             $item->{$k} = $v;
         }
         // Crappy Joomla
         $item->current_version = array_key_exists(@$item->extension_id, @$extensionUpdatesAvailable) ? @$extensionUpdatesAvailable[@$item->extension_id]->version : @$item->version;
         // if there is a newer version we want that!
         if ($item->current_version !== NULL) {
             // compose a nice new class, doesnt matter as we are json_encoding later anyway
             $i = new stdClass();
             $i->name = $item->name;
             $i->eid = $item->extension_id;
             $i->current_version = $item->current_version;
             $i->infourl = $item->infourl;
             // inject to our array we will return
             $updatesAvailable[] = $i;
         }
     }
     // Harvest update sites for better features in the future
     $db->setQuery('SELECT * from #__update_sites');
     $updateSites = $db->LoadObjectList();
     // if we are in bfAuditor then we want just a count of the items or the actual items?
     if (FALSE === $returnCount) {
         $data = array();
         $data['updates'] = $updatesAvailable;
         $data['sites'] = json_encode($updateSites);
         return $data;
     } else {
         return count($updatesAvailable);
     }
 }
 public function __construct(JInputCli $input = null, JRegistry $config = null, JDispatcher $dispatcher = null)
 {
     // CLI Constructor
     parent::__construct($input, $config, $dispatcher);
     // Utilities
     $this->db = JFactory::getDBO();
     $this->updater = JUpdater::getInstance();
     $this->installer = JComponentHelper::getComponent('com_installer');
     // Validate Log Path
     $logPath = $this->config->get('log_path');
     if (!is_dir($logPath) || !is_writeable($logPath)) {
         $logPath = JPATH_BASE . '/logs';
         if (!is_dir($logPath) || !is_writeable($logPath)) {
             $this->out('Log Path not found - ' . $logPath);
         }
         $this->config->set('log_path', JPATH_BASE . '/logs');
     }
     // Validate Tmp Path
     $tmpPath = $this->config->get('tmp_path');
     if (!is_writeable($tmpPath)) {
         $tmpPath = JPATH_BASE . '/tmp';
         if (!is_dir($tmpPath) || !is_writeable($tmpPath)) {
             $this->out('Tmp Path not found - ' . $tmpPath);
         }
         $this->config->set('tmp_path', JPATH_BASE . '/tmp');
     }
     // Push to Global Config
     $config = JFactory::getConfig();
     $config->set('tmp_path', $this->config->get('tmp_path'));
     $config->set('log_path', $this->config->get('log_path'));
 }
Example #3
0
 /**
  * Generate a list of language choices to install in the Joomla CMS.
  *
  * @return  boolean  True if successful.
  *
  * @since   3.1
  */
 public function getItems()
 {
     // Get the extension_id of the en-GB package.
     $db = JFactory::getDbo();
     $extQuery = $db->getQuery(true);
     $extQuery->select($db->qn('extension_id'))->from($db->qn('#__extensions'))->where($db->qn('type') . ' = ' . $db->q('language'))->where($db->qn('element') . ' = ' . $db->q('en-GB'))->where($db->qn('client_id') . ' = 0');
     $db->setQuery($extQuery);
     $extId = (int) $db->loadResult();
     if ($extId) {
         $updater = JUpdater::getInstance();
         /*
          * The following function call uses the extension_id of the en-GB package.
          * In #__update_sites_extensions you should have this extension_id linked
          * to the Accredited Translations Repo.
          */
         $updater->findUpdates(array($extId), 0);
         $query = $db->getQuery(true);
         // Select the required fields from the updates table.
         $query->select($db->qn(array('update_id', 'name', 'version')))->from($db->qn('#__updates'))->order($db->qn('name'));
         $db->setQuery($query);
         $list = $db->loadObjectList();
         if (!$list || $list instanceof Exception) {
             $list = array();
         }
     } else {
         $list = array();
     }
     return $list;
 }
Example #4
0
 /**
  * Returns a reference to the global Installer object, only creating it
  * if it doesn't already exist.
  *
  * @return  JUpdater  An installer object
  *
  * @since   11.1
  */
 public static function getInstance()
 {
     if (!isset(self::$instance)) {
         self::$instance = new JUpdater();
     }
     return self::$instance;
 }
Example #5
0
 /**
  * Search for 3rd party extensions
  *
  * @return	bool	True if everything is ok
  * @since	0.4.5
  * @throws	Exception
  */
 public function search()
 {
     $updater = JUpdater::getInstance();
     //print_r($updater);
     /*
     		$rows = parent::getSourceData(
     			'`bid` AS id,`cid`,`type`,`name`,`alias`, `imptotal` ,`impmade`, `clicks`, '
     		 .'`clickurl`, `checked_out`, `checked_out_time`, `showBanner` AS state,'
     		 .' `custombannercode`, `description`, `sticky`, `ordering`, `publish_up`, '
     		 .' `publish_down`, `params`',
     			null,
     			'bid'
     		);
     
     		// Do some custom post processing on the list.
     		foreach ($rows as &$row)
     		{
     			$row['params'] = $this->convertParams($row['params']);
     
     			// Remove unused fields.
     			unset($row['gid']);
     		}
     */
     //return $rows;
 }
Example #6
0
 public function findUpdates($eid = 0, $cache_timeout = 0)
 {
     $updater = JUpdater::getInstance();
     $error_r = error_reporting();
     error_reporting(0);
     $results = $updater->findUpdates($eid, $cache_timeout);
     error_reporting($error_r);
     return $results;
 }
Example #7
0
 /**
  * Me aseguro que el cache esta realmente actualizado
  *
  * @param   bool  $force  Force reload, ignoring the cache timeout
  * @return	void
  * @since	2.5.4
  */
 public function refreshUpdates($force = false)
 {
     if ($force) {
         $cache_timeout = 0;
     } else {
         $update_params = JComponentHelper::getParams('com_installer');
         $cache_timeout = $update_params->get('cachetimeout', 6, 'int');
         $cache_timeout = 3600 * $cache_timeout;
     }
     $updater = JUpdater::getInstance();
 }
Example #8
0
 /**
  * Return min or recommend Joomla! version
  * @param $recommended
  * @return array
  */
 public static function minCmsVersion($recommended = false)
 {
     $updater = JUpdater::getInstance();
     $updater->findUpdates(700, 0);
     $version = SPFactory::db()->select('version', '#__updates', array('extension_id' => 700))->loadResult();
     $recommendedVersion = array('major' => 3, 'minor' => 2, 'build' => 3);
     if ($version) {
         $version = explode('.', $version);
         $recommendedVersion = array('major' => $version[0], 'minor' => $version[1], 'build' => $version[2]);
     }
     return $recommended ? $recommendedVersion : array('major' => 3, 'minor' => 2, 'build' => 0);
 }
Example #9
0
 protected function checkForGantryUpdate()
 {
     $updates = RTMCUpdates::getInstance();
     $last_updated = $updates->getLastUpdated();
     $diff = time() - $last_updated;
     if ($diff > 60 * 60 * 24) {
         jimport('joomla.updater.updater');
         // check for update
         $updater = JUpdater::getInstance();
         $results = $updater->findUpdates($updates->getExtensionId());
         $updates->setLastChecked(time());
     }
 }
Example #10
0
 /**
  * Entry point for the script
  *
  * @return  void
  *
  * @since   2.5
  */
 public function doExecute()
 {
     // Get the update cache time
     $component = JComponentHelper::getComponent('com_installer');
     $params = $component->params;
     $cache_timeout = $params->get('cachetimeout', 6, 'int');
     $cache_timeout = 3600 * $cache_timeout;
     // Find all updates
     $this->out('Fetching updates...');
     $updater = JUpdater::getInstance();
     $updater->findUpdates(0, $cache_timeout);
     $this->out('Finished fetching updates');
 }
Example #11
0
 /**
  * Entry point for the script
  *
  * @return  void
  *
  * @since   2.5
  */
 public function doExecute()
 {
     // Purge all old records
     $db = JFactory::getDBO();
     // Get the update cache time
     jimport('joomla.application.component.helper');
     $component = JComponentHelper::getComponent('com_installer');
     $params = $component->params;
     $cache_timeout = $params->get('cachetimeout', 6, 'int');
     $cache_timeout = 3600 * $cache_timeout;
     // Find all updates
     $this->out('Fetching updates...');
     $updater = JUpdater::getInstance();
     $results = $updater->findUpdates(0, $cache_timeout);
     $this->out('Finished fetching updates');
 }
Example #12
0
 /**
  * Generate a list of language choices to install in the Joomla CMS
  *
  * @return  boolean  True if successful
  *
  * @since   3.1
  */
 public function getItems()
 {
     $updater = JUpdater::getInstance();
     /*
      * The following function uses extension_id 600, that is the English language extension id.
      * In #__update_sites_extensions you should have 600 linked to the Accredited Translations Repo
      */
     $updater->findUpdates(array(600), 0);
     $db = JFactory::getDbo();
     $query = $db->getQuery(true);
     // Select the required fields from the updates table
     $query->select('update_id, name, version')->from('#__updates')->order('name');
     $db->setQuery($query);
     $list = $db->loadObjectList();
     if (!$list || $list instanceof Exception) {
         $list = array();
     }
     return $list;
 }
Example #13
0
 function checkUpdates()
 {
     //get cache timeout from com_installer params
     jimport('joomla.application.component.helper');
     $component = JComponentHelper::getComponent('com_installer');
     $params = $component->params;
     $cache_timeout = $params->get('cachetimeout', 6, 'int');
     $cache_timeout = 3600 * $cache_timeout;
     //find $eid Extension identifier to look for
     $dbo = JFactory::getDBO();
     $query = $dbo->getQuery(true);
     $query->select($dbo->qn('extension_id'))->from($dbo->qn('#__extensions'))->where($dbo->qn('element') . ' = ' . $dbo->Quote('pkg_falang'));
     $dbo->setQuery($query);
     $dbo->query();
     $result = $dbo->loadObject();
     $eid = $result->extension_id;
     //find update for pkg_falang
     $updater = JUpdater::getInstance();
     $update = $updater->findUpdates(array($eid), $cache_timeout);
     //seem $update has problem with cache
     //check manually
     $query = $dbo->getQuery(true);
     $query->select('version')->from('#__updates')->where('element = ' . $dbo->Quote('pkg_falang'));
     $dbo->setQuery($query);
     $dbo->query();
     $result = $dbo->loadObject();
     $document =& JFactory::getDocument();
     $document->setMimeEncoding('application/json');
     $version = new FalangVersion();
     if (!$result) {
         echo json_encode(array('update' => "false", 'version' => $version->getVersionShort()));
         return true;
     }
     $last_version = $result->version;
     if (version_compare($last_version, $version->getVersionShort(), '>')) {
         echo json_encode(array('update' => "true", 'version' => $last_version));
     } else {
         echo json_encode(array('update' => "false", 'version' => $version->getVersionShort()));
     }
     return true;
 }
Example #14
0
 /**
  * Public constructor. Initialises the protected members as well. Useful $config keys:
  * update_component		The component name, e.g. com_foobar
  * update_version		The default version if the manifest cache is unreadable
  * update_site			The URL to the component's update XML stream
  * update_extraquery	The extra query to append to (commercial) components' download URLs
  * update_sitename		The update site's name (description)
  *
  * @param array $config
  */
 public function __construct($config = array())
 {
     parent::__construct($config);
     // Get an instance of the updater class
     $this->updater = JUpdater::getInstance();
     // Get the component name
     if (isset($config['update_component'])) {
         $this->component = $config['update_component'];
     } else {
         $this->component = $this->input->getCmd('option', '');
     }
     // Get the component version
     if (isset($config['update_version'])) {
         $this->version = $config['update_version'];
     }
     // Get the update site
     if (isset($config['update_site'])) {
         $this->updateSite = $config['update_site'];
     }
     // Get the extra query
     if (isset($config['update_extraquery'])) {
         $this->extraQuery = $config['update_extraquery'];
     }
     // Get the extra query
     if (isset($config['update_sitename'])) {
         $this->updateSiteName = $config['update_sitename'];
     }
     // Find the extension ID
     $db = $this->getDbo();
     $query = $db->getQuery(true)->select('*')->from($db->qn('#__extensions'))->where($db->qn('type') . ' = ' . $db->q('component'))->where($db->qn('element') . ' = ' . $db->q($this->component));
     $db->setQuery($query);
     $extension = $db->loadObject();
     if (is_object($extension)) {
         $this->extension_id = $extension->extension_id;
         $data = json_decode($extension->manifest_cache, true);
         if (isset($data['version'])) {
             $this->version = $data['version'];
         }
     }
 }
Example #15
0
 /**
  * Finds new Languages.
  *
  * @return  void
  *
  * @since   2.5.7
  */
 public function find()
 {
     require_once JPATH_ADMINISTRATOR . '/components/com_installer/models/update.php';
     // Purge the updates list
     $config = array();
     $model = new InstallerModelUpdate($config);
     $model->purge();
     // Check for request forgeries
     JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN'));
     // Get the caching duration
     $params = JComponentHelper::getParams('com_installer');
     $cache_timeout = $params->get('cachetimeout', 6, 'int');
     $cache_timeout = 3600 * $cache_timeout;
     // Find updates
     $updater = JUpdater::getInstance();
     /*
      * The following function uses extension_id 600, that is the english language extension id.
      * In #__update_sites_extensions you should have 600 linked to the Accredited Translations Repo
      */
     $updater->findUpdates(array(600), $cache_timeout);
     $this->setRedirect(JRoute::_('index.php?option=com_jalang&view=tool', false));
 }
Example #16
0
 /**
  * Makes sure that the Joomla! Update Component Update is in the database and check if there is a new version.
  *
  * @return  boolean  True if there is an update else false
  *
  * @since   3.6.3
  */
 private function checkForSelfUpdate()
 {
     $db = JFactory::getDbo();
     $query = $db->getQuery(true)->select($db->quoteName('extension_id'))->from($db->quoteName('#__extensions'))->where($db->quoteName('element') . " = " . $db->quote('com_joomlaupdate'));
     $db->setQuery($query);
     try {
         // Get the component extension ID
         $joomlaUpdateComponentId = $db->loadResult();
     } catch (RuntimeException $e) {
         // Something is wrong here!
         $joomlaUpdateComponentId = 0;
         JFactory::getApplication()->enqueueMessage($e->getMessage(), 'error');
     }
     // Try the update only if we have an extension id
     if ($joomlaUpdateComponentId != 0) {
         // Allways force to check for an update!
         $cache_timeout = 0;
         $updater = JUpdater::getInstance();
         $updater->findUpdates($joomlaUpdateComponentId, $cache_timeout, JUpdater::STABILITY_STABLE);
         // Fetch the update information from the database.
         $query = $db->getQuery(true)->select('*')->from($db->quoteName('#__updates'))->where($db->quoteName('extension_id') . ' = ' . $db->quote($joomlaUpdateComponentId));
         $db->setQuery($query);
         try {
             $joomlaUpdateComponentObject = $db->loadObject();
         } catch (RuntimeException $e) {
             // Something is wrong here!
             $joomlaUpdateComponentObject = null;
             JFactory::getApplication()->enqueueMessage($e->getMessage(), 'error');
         }
         if (is_null($joomlaUpdateComponentObject)) {
             // No Update great!
             return false;
         }
         return true;
     }
 }
Example #17
0
 public function checkForGantryUpdate()
 {
     gantry_import('core.gantryupdates');
     $gantry_updates = GantryUpdates::getInstance();
     $last_updated = $gantry_updates->getLastUpdated();
     $diff = time() - $last_updated;
     if ($diff > 60 * 60 * 24) {
         jimport('joomla.updater.updater');
         // check for update
         $updater = JUpdater::getInstance();
         $results = @$updater->findUpdates($gantry_updates->getGantryExtensionId());
         $gantry_updates->setLastChecked(time());
     }
 }
Example #18
0
 /**
  * Method to find available languages in the Accredited Languages Update Site.
  *
  * @param   int  $cache_timeout  time before refreshing the cached updates
  *
  * @return  bool
  *
  * @since   2.5.7
  */
 public function findLanguages($cache_timeout = 0)
 {
     if (!$this->enableUpdateSite()) {
         return false;
     }
     if (!$this->enGbExtensionId) {
         return false;
     }
     $updater = JUpdater::getInstance();
     /*
      * The following function call uses the extension_id of the en-GB package.
      * In #__update_sites_extensions you should have this extension_id linked
      * to the Accredited Translations Repo.
      */
     $updater->findUpdates(array($this->enGbExtensionId), $cache_timeout);
     return true;
 }
Example #19
0
 /**
  * Finds updates for an extension.
  *
  * @param	int		Extension identifier to look for
  * @return	boolean Result
  * @since	2.5
  */
 public function findUpdates($cid = 0)
 {
     $updater = JUpdater::getInstance();
     $results = $updater->findUpdates($cid);
     return true;
 }
 /**
  * The update check and notification email code is triggered after the page has fully rendered.
  *
  * @return  void
  *
  * @since   3.5
  */
 public function onAfterRender()
 {
     // Get the timeout for Joomla! updates, as configured in com_installer's component parameters
     JLoader::import('joomla.application.component.helper');
     $component = JComponentHelper::getComponent('com_installer');
     /** @var \Joomla\Registry\Registry $params */
     $params = $component->params;
     $cache_timeout = (int) $params->get('cachetimeout', 6);
     $cache_timeout = 3600 * $cache_timeout;
     // Do we need to run? Compare the last run timestamp stored in the plugin's options with the current
     // timestamp. If the difference is greater than the cache timeout we shall not execute again.
     $now = time();
     $last = (int) $this->params->get('lastrun', 0);
     if (!defined('PLG_SYSTEM_UPDATENOTIFICATION_DEBUG') && abs($now - $last) < $cache_timeout) {
         return;
     }
     // Update last run status
     // If I have the time of the last run, I can update, otherwise insert
     $this->params->set('lastrun', $now);
     $db = JFactory::getDbo();
     $query = $db->getQuery(true)->update($db->qn('#__extensions'))->set($db->qn('params') . ' = ' . $db->q($this->params->toString('JSON')))->where($db->qn('type') . ' = ' . $db->q('plugin'))->where($db->qn('folder') . ' = ' . $db->q('system'))->where($db->qn('element') . ' = ' . $db->q('updatenotification'));
     try {
         // Lock the tables to prevent multiple plugin executions causing a race condition
         $db->lockTable('#__extensions');
     } catch (Exception $e) {
         // If we can't lock the tables it's too risky to continue execution
         return;
     }
     try {
         // Update the plugin parameters
         $result = $db->setQuery($query)->execute();
         $this->clearCacheGroups(array('com_plugins'), array(0, 1));
     } catch (Exception $exc) {
         // If we failed to execite
         $db->unlockTables();
         $result = false;
     }
     try {
         // Unlock the tables after writing
         $db->unlockTables();
     } catch (Exception $e) {
         // If we can't lock the tables assume we have somehow failed
         $result = false;
     }
     // Abort on failure
     if (!$result) {
         return;
     }
     // This is the extension ID for Joomla! itself
     $eid = 700;
     // Get any available updates
     $updater = JUpdater::getInstance();
     $results = $updater->findUpdates(array($eid), $cache_timeout);
     // If there are no updates our job is done. We need BOTH this check AND the one below.
     if (!$results) {
         return;
     }
     // Unfortunately Joomla! MVC doesn't allow us to autoload classes
     JModelLegacy::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_installer/models', 'InstallerModel');
     // Get the update model and retrieve the Joomla! core updates
     $model = JModelLegacy::getInstance('Update', 'InstallerModel');
     $model->setState('filter.extension_id', $eid);
     $updates = $model->getItems();
     // If there are no updates we don't have to notify anyone about anything. This is NOT a duplicate check.
     if (empty($updates)) {
         return;
     }
     // Get the available update
     $update = array_pop($updates);
     // Check the available version. If it's the same as the installed version we have no updates to notify about.
     if (version_compare($update->version, JVERSION, 'eq')) {
         return;
     }
     // If we're here, we have updates. First, get a link to the Joomla! Update component.
     $baseURL = JUri::base();
     $baseURL = rtrim($baseURL, '/');
     $baseURL .= substr($baseURL, -13) != 'administrator' ? '/administrator/' : '/';
     $baseURL .= 'index.php?option=com_joomlaupdate';
     $uri = new JUri($baseURL);
     /**
      * Some third party security solutions require a secret query parameter to allow log in to the administrator
      * backend of the site. The link generated above will be invalid and could probably block the user out of their
      * site, confusing them (they can't understand the third party security solution is not part of Joomla! proper).
      * So, we're calling the onBuildAdministratorLoginURL system plugin event to let these third party solutions
      * add any necessary secret query parameters to the URL. The plugins are supposed to have a method with the
      * signature:
      *
      * public function onBuildAdministratorLoginURL(JUri &$uri);
      *
      * The plugins should modify the $uri object directly and return null.
      */
     JEventDispatcher::getInstance()->trigger('onBuildAdministratorLoginURL', array(&$uri));
     // Let's find out the email addresses to notify
     $superUsers = array();
     $specificEmail = $this->params->get('email', '');
     if (!empty($specificEmail)) {
         $superUsers = $this->getSuperUsers($specificEmail);
     }
     if (empty($superUsers)) {
         $superUsers = $this->getSuperUsers();
     }
     if (empty($superUsers)) {
         return;
     }
     /* Load the appropriate language. We try to load English (UK), the current user's language and the forced
      * language preference, in this order. This ensures that we'll never end up with untranslated strings in the
      * update email which would make Joomla! seem bad. So, please, if you don't fully understand what the
      * following code does DO NOT TOUCH IT. It makes the difference between a hobbyist CMS and a professional
      * solution! */
     $jLanguage = JFactory::getLanguage();
     $jLanguage->load('plg_system_updatenotification', JPATH_ADMINISTRATOR, 'en-GB', true, true);
     $jLanguage->load('plg_system_updatenotification', JPATH_ADMINISTRATOR, null, true, false);
     // Then try loading the preferred (forced) language
     $forcedLanguage = $this->params->get('language_override', '');
     if (!empty($forcedLanguage)) {
         $jLanguage->load('plg_system_updatenotification', JPATH_ADMINISTRATOR, $forcedLanguage, true, false);
     }
     // Set up the email subject and body
     $email_subject = JText::_('PLG_SYSTEM_UPDATENOTIFICATION_EMAIL_SUBJECT');
     $email_body = JText::_('PLG_SYSTEM_UPDATENOTIFICATION_EMAIL_BODY');
     // Replace merge codes with their values
     $newVersion = $update->version;
     $jVersion = new JVersion();
     $currentVersion = $jVersion->getShortVersion();
     $jConfig = JFactory::getConfig();
     $sitename = $jConfig->get('sitename');
     $mailFrom = $jConfig->get('mailfrom');
     $fromName = $jConfig->get('fromname');
     $substitutions = array('[NEWVERSION]' => $newVersion, '[CURVERSION]' => $currentVersion, '[SITENAME]' => $sitename, '[URL]' => JUri::base(), '[LINK]' => $uri->toString(), '\\n' => "\n");
     foreach ($substitutions as $k => $v) {
         $email_subject = str_replace($k, $v, $email_subject);
         $email_body = str_replace($k, $v, $email_body);
     }
     // Send the emails to the Super Users
     foreach ($superUsers as $superUser) {
         $mailer = JFactory::getMailer();
         $mailer->setSender(array($mailFrom, $fromName));
         $mailer->addRecipient($superUser->email);
         $mailer->setSubject($email_subject);
         $mailer->setBody($email_body);
         $mailer->Send();
     }
 }
Example #21
0
 function registerAdapters()
 {
     $app = JFactory::getApplication();
     // Register adapters only in admin area
     if (!$app->isAdmin()) {
         return;
     }
     // Include adapter files
     require_once JPATH_ADMINISTRATOR . '/components/com_sef/adapters/sef_ext.php';
     require_once JPATH_ADMINISTRATOR . '/components/com_sef/adapters/sef_update.php';
     // Set installer adapter
     $installer = JInstaller::getInstance();
     $adapterSefExt = new JInstallerAdapterSef_ext($installer);
     $installer->setAdapter('sef_ext', $adapterSefExt);
     // Set updater adapter
     $updater = JUpdater::getInstance();
     $adapterSefUpdate = new JUpdaterSEF_Update($updater, $updater->getDBO());
     $updater->setAdapter('sef_update', $adapterSefUpdate);
 }
Example #22
0
 /**
  * Finds updates for an extension.
  *
  * @param   int  $eid                Extension identifier to look for
  * @param   int  $cache_timeout      Cache timout
  * @param   int  $minimum_stability  Minimum stability for updates {@see JUpdater} (0=dev, 1=alpha, 2=beta, 3=rc, 4=stable)
  *
  * @return  boolean Result
  *
  * @since   1.6
  */
 public function findUpdates($eid = 0, $cache_timeout = 0, $minimum_stability = JUpdater::STABILITY_STABLE)
 {
     // Purge the updates list
     $this->purge();
     $updater = JUpdater::getInstance();
     $updater->findUpdates($eid, $cache_timeout, $minimum_stability);
     return true;
 }
Example #23
0
 /**
  * checks if there are updates available and
  * @return object - the updates
  */
 private function checkForUpdates()
 {
     jimport('joomla.updater.updater');
     $updater = JUpdater::getInstance();
     $updater->findUpdates(0, 0);
     $db = JFactory::getDbo();
     $query = $db->getQuery(true);
     $query->select('*');
     $query->from('#__updates')->where('extension_id != 0');
     $db->setQuery($query);
     return $db->loadObjectList();
 }
 /**
  * Makes sure that the Professional release can be updated using Joomla!'s
  * own update system. THIS IS AN AKEEBA ORIGINAL!
  */
 public function applyJoomlaExtensionUpdateChanges($isPro = -1)
 {
     $ret = true;
     // Don';'t bother if this is not Joomla! 1.7+
     if (!version_compare(JVERSION, '1.7.0', 'ge')) {
         return $ret;
     }
     // Do we have Admin Tools Professional?
     if ($isPro === -1) {
         $isPro = AKEEBA_PRO;
     }
     // Action parameters
     $action = 'none';
     // What to do: none, update, create, delete
     $purgeUpdates = false;
     // Should I purge existing updates?
     $fetchUpdates = false;
     // Should I fetch new udpater
     // Init
     $db = $this->getDbo();
     // Figure out the correct XML update stream URL
     if ($isPro) {
         $update_url = 'https://www.akeebabackup.com/index.php?option=com_ars&view=update&task=stream&format=xml&id=6';
         JLoader::import('joomla.application.component.helper');
         $params = JComponentHelper::getParams('com_akeeba');
         if (version_compare(JVERSION, '3.0', 'ge')) {
             $dlid = $params->get('update_dlid', '');
         } else {
             $dlid = $params->getValue('update_dlid', '');
         }
         if (!preg_match('/^[0-9a-f]{32}$/i', $dlid)) {
             $ret = false;
             $dlid = '';
         }
         if ($dlid) {
             $dlid = $dlid;
             $url = $update_url . '&dlid=' . $dlid . '/extension.xml';
         } else {
             $url = '';
         }
     } else {
         $url = 'http://cdn.akeebabackup.com/updates/atcore.xml';
     }
     // Get the extension ID
     $extensionID = JComponentHelper::getComponent('com_akeeba')->id;
     // Get the update site record
     $query = $db->getQuery(true)->select(array($db->qn('us') . '.*'))->from($db->qn('#__update_sites_extensions') . ' AS ' . $db->qn('map'))->innerJoin($db->qn('#__update_sites') . ' AS ' . $db->qn('us') . ' ON (' . $db->qn('us') . '.' . $db->qn('update_site_id') . ' = ' . $db->qn('map') . '.' . $db->qn('update_site_id') . ')')->where($db->qn('map') . '.' . $db->qn('extension_id') . ' = ' . $db->q($extensionID));
     $db->setQuery($query);
     $update_site = $db->loadObject();
     // Decide on the course of action to take
     if ($url) {
         if (!is_object($update_site)) {
             $action = 'create';
             $fetchUpdates = true;
         } else {
             $action = $update_site->location != $url ? 'update' : 'none';
             $purgeUpdates = $action == 'update';
             $fetchUpdates = $action == 'update';
         }
     } else {
         // Disable the update site for Akeeba Backup
         if (!is_object($update_site)) {
             $action = 'none';
         } else {
             $action = 'delete';
             $purgeUpdates = true;
         }
     }
     switch ($action) {
         case 'none':
             // No change
             break;
         case 'create':
         case 'update':
             // Remove old update site
             $query = $db->getQuery(true)->delete($db->qn('#__update_sites'))->where($db->qn('name') . ' = ' . $db->q('Akeeba Backup updates'));
             $db->setQuery($query);
             $db->execute();
             // Create new update site
             $oUpdateSite = (object) array('name' => 'Akeeba Backup updates', 'type' => 'extension', 'location' => $url, 'enabled' => 1, 'last_check_timestamp' => 0);
             $db->insertObject('#__update_sites', $oUpdateSite);
             // Get the update site ID
             $usID = $db->insertid();
             // Delete existing #__update_sites_extensions records
             $query = $db->getQuery(true)->delete($db->qn('#__update_sites_extensions'))->where($db->qn('extension_id') . ' = ' . $db->q($extensionID));
             $db->setQuery($query);
             $db->execute();
             // Create new #__update_sites_extensions record
             $oUpdateSitesExtensions = (object) array('update_site_id' => $usID, 'extension_id' => $extensionID);
             $db->insertObject('#__update_sites_extensions', $oUpdateSitesExtensions);
             break;
         case 'delete':
             // Remove update sites
             $query = $db->getQuery(true)->delete($db->qn('#__update_sites'))->where($db->qn('update_site_id') . ' = ' . $db->q($update_site->update_site_id));
             $db->setQuery($query);
             $db->execute();
             // Delete existing #__update_sites_extensions records
             $query = $db->getQuery(true)->delete($db->qn('#__update_sites_extensions'))->where($db->qn('extension_id') . ' = ' . $db->q($extensionID));
             $db->setQuery($query);
             $db->execute();
             break;
     }
     // Do I have to purge updates?
     if ($purgeUpdates) {
         $query = $db->getQuery(true)->delete($db->qn('#__updates'))->where($db->qn('element') . ' = ' . $db->q('com_akeeba'));
         $db->setQuery($query);
         $db->execute();
     }
     // Do I have to fetch updates?
     if ($fetchUpdates) {
         JLoader::import('joomla.update.update');
         $x = new JUpdater();
         $x->findUpdates($extensionID);
     }
     return $ret;
 }
Example #25
0
 /**
  * Makes sure that the Joomla! update cache is up-to-date.
  *
  * @param   boolean  $force  Force reload, ignoring the cache timeout.
  *
  * @return  void
  *
  * @since    2.5.4
  */
 public function refreshUpdates($force = false)
 {
     if ($force) {
         $cache_timeout = 0;
     } else {
         $update_params = JComponentHelper::getParams('com_installer');
         $cache_timeout = $update_params->get('cachetimeout', 6, 'int');
         $cache_timeout = 3600 * $cache_timeout;
     }
     $updater = JUpdater::getInstance();
     $reflection = new ReflectionObject($updater);
     $reflectionMethod = $reflection->getMethod('findUpdates');
     $methodParameters = $reflectionMethod->getParameters();
     if (count($methodParameters) >= 4) {
         // Reinstall support is available in JUpdater
         $updater->findUpdates(700, $cache_timeout, JUpdater::STABILITY_STABLE, true);
     } else {
         $updater->findUpdates(700, $cache_timeout, JUpdater::STABILITY_STABLE);
     }
 }
Example #26
0
 /**
  * Get a list of languages
  *
  * @param   bool $allSupported All the languages supported by Joomla
  *
  * @return array
  */
 public static function findLanguages($allSupported = false)
 {
     $enGbExtensionId = self::getEnGbExtensionId();
     NenoLog::log('en-GB Extension ID ' . $enGbExtensionId);
     $languagesFound = array();
     $db = JFactory::getDbo();
     $query = $db->getQuery(true);
     if (!empty($enGbExtensionId)) {
         // Let's enable it if it's disabled
         $query->select('a.update_site_id')->from('#__update_sites AS a')->innerJoin('#__update_sites_extensions AS b ON a.update_site_id = b.update_site_id')->where('b.extension_id = ' . (int) $enGbExtensionId);
         $db->setQuery($query);
         $updateId = $db->loadResult();
         if (!empty($updateId)) {
             $query->clear()->update('#__update_sites')->set('enabled = 1')->where('update_site_id = ' . (int) $updateId);
             $db->setQuery($query);
             $db->execute();
         }
         // Find updates for languages
         $updater = JUpdater::getInstance();
         $updater->findUpdates($enGbExtensionId);
         $updateSiteId = self::getLanguagesUpdateSite($enGbExtensionId);
         NenoLog::log('UpdateSiteID: ' . $updateSiteId);
         $updates = self::getUpdates($updateSiteId);
         NenoLog::log('Updates: ' . json_encode($updateSiteId));
         $languagesFound = $updates;
     }
     if ($allSupported) {
         $query->clear()->select(array('DISTINCT element AS iso', 'name'))->from('#__extensions')->where('type = ' . $db->quote('language'))->group('element');
         $db->setQuery($query);
         $languagesFound = array_merge($db->loadAssocList(), $languagesFound);
     }
     return $languagesFound;
 }
Example #27
0
 /**
  * Public constructor. Initialises the protected members as well. Useful $config keys:
  * update_component		The component name, e.g. com_foobar
  * update_version		The default version if the manifest cache is unreadable
  * update_site			The URL to the component's update XML stream
  * update_extraquery	The extra query to append to (commercial) components' download URLs
  * update_sitename		The update site's name (description)
  *
  * @param array $config
  */
 public function __construct($config = array())
 {
     parent::__construct($config);
     // Get an instance of the updater class
     $this->updater = JUpdater::getInstance();
     // Get the component name
     if (isset($config['update_component'])) {
         $this->component = $config['update_component'];
     } else {
         $this->component = $this->input->getCmd('option', '');
     }
     // Get the component description
     if (isset($config['update_component_description'])) {
         $this->component = $config['update_component_description'];
     } else {
         // Try to auto-translate (hopefully you've loaded the language files)
         $key = strtoupper($this->component);
         $description = JText::_($key);
     }
     // Get the component version
     if (isset($config['update_version'])) {
         $this->version = $config['update_version'];
     }
     // Get the common key
     if (isset($config['common_key'])) {
         $this->commonKey = $config['common_key'];
     } else {
         // Convert com_foobar, pkg_foobar etc to "foobar"
         $this->commonKey = substr($this->component, 4);
     }
     // Get the update site
     if (isset($config['update_site'])) {
         $this->updateSite = $config['update_site'];
     }
     // Get the extra query
     if (isset($config['update_extraquery'])) {
         $this->extraQuery = $config['update_extraquery'];
     }
     // Get the update site's name
     if (isset($config['update_sitename'])) {
         $this->updateSiteName = $config['update_sitename'];
     }
     // Find the extension ID
     $db = F0FPlatform::getInstance()->getDbo();
     $query = $db->getQuery(true)->select('*')->from($db->qn('#__extensions'))->where($db->qn('type') . ' = ' . $db->q('component'))->where($db->qn('element') . ' = ' . $db->q($this->component));
     $db->setQuery($query);
     $extension = $db->loadObject();
     if (is_object($extension)) {
         $this->extension_id = $extension->extension_id;
         $data = json_decode($extension->manifest_cache, true);
         if (isset($data['version'])) {
             $this->version = $data['version'];
         }
     }
 }
Example #28
0
 /**
  * Finds updates for an extension.
  *
  * @param	int		Extension identifier to look for
  * @return	boolean Result
  * @since	1.6
  */
 public function findUpdates($eid = 0, $cache_timeout = 0)
 {
     $updater = JUpdater::getInstance();
     $results = $updater->findUpdates($eid, $cache_timeout);
     return true;
 }
Example #29
0
 /**
  * Finds updates for an extension.
  *
  * @param   int  $eid            Extension identifier to look for
  * @param   int  $cache_timeout  Cache timout
  *
  * @return  boolean Result
  *
  * @since   1.6
  */
 public function findUpdates($eid = 0, $cache_timeout = 0)
 {
     // Purge the updates list
     $this->purge();
     $updater = JUpdater::getInstance();
     $updater->findUpdates($eid, $cache_timeout);
     return true;
 }
Example #30
0
 /**
  * Method to find available languages in the Accredited Languages Update Site.
  *
  * @param   int  $cache_timeout  time before refreshing the cached updates
  *
  * @return  bool
  *
  * @since   2.5.7
  */
 public function findLanguages($cache_timeout = 0)
 {
     $updater = JUpdater::getInstance();
     /*
      * The following function uses extension_id 600, that is the english language extension id.
      * In #__update_sites_extensions you should have 600 linked to the Accredited Translations Repo
      */
     $updater->findUpdates(array(600), $cache_timeout);
     return true;
 }