AAAA.htaccess000066600000000177151372575720006371 0ustar00 Order allow,deny Deny from all updater.php000066600000016557151372575720006761 0ustar00getDBO(); $retval = false; // Push it into an array if (!is_array($eid)) { $query = 'SELECT DISTINCT update_site_id, type, location, last_check_timestamp FROM #__update_sites WHERE enabled = 1'; } else { $query = 'SELECT DISTINCT update_site_id, type, location, last_check_timestamp FROM #__update_sites' . ' WHERE update_site_id IN' . ' (SELECT update_site_id FROM #__update_sites_extensions WHERE extension_id IN (' . implode(',', $eid) . '))'; } $dbo->setQuery($query); $results = $dbo->loadAssocList(); $result_count = count($results); $now = time(); for ($i = 0; $i < $result_count; $i++) { $result = &$results[$i]; $this->setAdapter($result['type']); if (!isset($this->_adapters[$result['type']])) { // Ignore update sites requiring adapters we don't have installed continue; } if ($cacheTimeout > 0) { if (isset($result['last_check_timestamp']) && ($now - $result['last_check_timestamp'] <= $cacheTimeout)) { // Ignore update sites whose information we have fetched within // the cache time limit $retval = true; continue; } } $update_result = $this->_adapters[$result['type']]->findUpdate($result); if (is_array($update_result)) { if (array_key_exists('update_sites', $update_result) && count($update_result['update_sites'])) { $results = JArrayHelper::arrayUnique(array_merge($results, $update_result['update_sites'])); $result_count = count($results); } if (array_key_exists('updates', $update_result) && count($update_result['updates'])) { for ($k = 0, $count = count($update_result['updates']); $k < $count; $k++) { $current_update = &$update_result['updates'][$k]; $update = JTable::getInstance('update'); $extension = JTable::getInstance('extension'); $uid = $update ->find( array( 'element' => strtolower($current_update->get('element')), 'type' => strtolower($current_update->get('type')), 'client_id' => strtolower($current_update->get('client_id')), 'folder' => strtolower($current_update->get('folder')) ) ); $eid = $extension ->find( array( 'element' => strtolower($current_update->get('element')), 'type' => strtolower($current_update->get('type')), 'client_id' => strtolower($current_update->get('client_id')), 'folder' => strtolower($current_update->get('folder')) ) ); if (!$uid) { // Set the extension id if ($eid) { // We have an installed extension, check the update is actually newer $extension->load($eid); $data = json_decode($extension->manifest_cache, true); if (version_compare($current_update->version, $data['version'], '>') == 1) { $current_update->extension_id = $eid; $current_update->store(); } // Store compatibility information into the extension table if (!empty($update_result['compatibility'])) { $system_data = json_decode($extension->system_data); $system_data->compatibility = new stdClass(); $compatibility = $update_result['compatibility']; ksort($compatibility); // Check data for current installed version if (!empty($compatibility[$data['version']])) { $system_data->compatibility->installed = new stdClass(); $system_data->compatibility->installed->value = $compatibility[$data['version']]; $system_data->compatibility->installed->version = $data['version']; } // Get last item in array which is highest release $system_data->compatibility->available = new stdClass(); $system_data->compatibility->available->value = end($compatibility); $system_data->compatibility->available->version = key($compatibility); $extension->system_data = json_encode($system_data); $extension->store(); } } else { // A potentially new extension to be installed $current_update->store(); } } else { $update->load($uid); // if there is an update, check that the version is newer then replaces if (version_compare($current_update->version, $update->version, '>') == 1) { $current_update->store(); } } } } $update_result = true; } elseif ($retval) { $update_result = true; } // Finally, update the last update check timestamp $query = $dbo->getQuery(true); $query->update($dbo->quoteName('#__update_sites')); $query->set($dbo->quoteName('last_check_timestamp') . ' = ' . $dbo->quote($now)); $query->where($dbo->quoteName('update_site_id') . ' = ' . $dbo->quote($result['update_site_id'])); $dbo->setQuery($query); $dbo->execute(); } return $retval; } /** * Multidimensional array safe unique test * * @param array $myArray The source array. * * @return array * * @deprecated 12.1 * @note Use JArrayHelper::arrayUnique() instead. * @note Borrowed from PHP.net * @see http://au2.php.net/manual/en/function.array-unique.php * @since 11.1 * */ public function arrayUnique($myArray) { JLog::add('JUpdater::arrayUnique() is deprecated. See JArrayHelper::arrayUnique() . ', JLog::WARNING, 'deprecated'); return JArrayHelper::arrayUnique($myArray); } /** * Finds an update for an extension * * @param integer $id Id of the extension * * @return mixed * * @since 11.1 */ public function update($id) { $updaterow = JTable::getInstance('update'); $updaterow->load($id); $update = new JUpdate; if ($update->loadFromXML($updaterow->detailsurl)) { return $update->install(); } return false; } } index.html000066600000000037151372575720006563 0ustar00 update.php000066600000015127151372575720006567 0ustar00', $this->_stack); } /** * Get the last position in stack count * * @return string * * @since 11.1 */ protected function _getLastTag() { return $this->_stack[count($this->_stack) - 1]; } /** * XML Start Element callback * * @param object $parser Parser object * @param string $name Name of the tag found * @param array $attrs Attributes of the tag * * @return void * * @note This is public because it is called externally * @since 11.1 */ public function _startElement($parser, $name, $attrs = array()) { array_push($this->_stack, $name); $tag = $this->_getStackLocation(); // Reset the data if (isset($this->$tag)) { $this->$tag->_data = ""; } switch ($name) { // This is a new update; create a current update case 'UPDATE': $this->_current_update = new stdClass; break; // Don't do anything case 'UPDATES': break; // For everything else there's...the default! default: $name = strtolower($name); if (!isset($this->_current_update->$name)) { $this->_current_update->$name = new stdClass; } $this->_current_update->$name->_data = ''; foreach ($attrs as $key => $data) { $key = strtolower($key); $this->_current_update->$name->$key = $data; } break; } } /** * Callback for closing the element * * @param object $parser Parser object * @param string $name Name of element that was closed * * @return void * * @note This is public because it is called externally * @since 11.1 */ public function _endElement($parser, $name) { array_pop($this->_stack); switch ($name) { // Closing update, find the latest version and check case 'UPDATE': $ver = new JVersion; $product = strtolower(JFilterInput::getInstance()->clean($ver->PRODUCT, 'cmd')); if ($product == $this->_current_update->targetplatform->name && preg_match('/' . $this->_current_update->targetplatform->version . '/', $ver->RELEASE)) { // Check if PHP version supported via tag, assume true if tag isn't present if (!isset($this->_current_update->php_minimum) || version_compare(PHP_VERSION, $this->_current_update->php_minimum->_data, '>=')) { $phpMatch = true; } else { $phpMatch = false; } if ($phpMatch) { if (isset($this->_latest)) { if (version_compare($this->_current_update->version->_data, $this->_latest->version->_data, '>') == 1) { $this->_latest = $this->_current_update; } } else { $this->_latest = $this->_current_update; } } } break; case 'UPDATES': // If the latest item is set then we transfer it to where we want to if (isset($this->_latest)) { foreach (get_object_vars($this->_latest) as $key => $val) { $this->$key = $val; } unset($this->_latest); unset($this->_current_update); } elseif (isset($this->_current_update)) { // The update might be for an older version of j! unset($this->_current_update); } break; } } /** * Character Parser Function * * @param object $parser Parser object. * @param object $data The data. * * @return void * * @note This is public because its called externally. * @since 11.1 */ public function _characterData($parser, $data) { $tag = $this->_getLastTag(); //if(!isset($this->$tag->_data)) $this->$tag->_data = ''; //$this->$tag->_data .= $data; // Throw the data for this item together $tag = strtolower($tag); //$this->_current_update->$tag->_data .= $data; if (isset($this->_current_update->$tag)) { $this->_current_update->$tag->_data .= $data; } } /** * Loads an XML file from a URL. * * @param string $url The URL. * * @return boolean True on success * * @since 11.1 */ public function loadFromXML($url) { $http = JHttpFactory::getHttp(); try { $response = $http->get($url); } catch (Exception $exc) { $response = null; } if (is_null($response) || ($response->code != 200)) { // TODO: Add a 'mark bad' setting here somehow JError::raiseWarning('101', JText::sprintf('JLIB_UPDATER_ERROR_EXTENSION_OPEN_URL', $url)); return false; } $this->xml_parser = xml_parser_create(''); xml_set_object($this->xml_parser, $this); xml_set_element_handler($this->xml_parser, '_startElement', '_endElement'); xml_set_character_data_handler($this->xml_parser, '_characterData'); if (!xml_parse($this->xml_parser, $response->body)) { die( sprintf( "XML error: %s at line %d", xml_error_string(xml_get_error_code($this->xml_parser)), xml_get_current_line_number($this->xml_parser) ) ); } xml_parser_free($this->xml_parser); return true; } } adapters/.htaccess000066600000000177151372575720010174 0ustar00 Order allow,deny Deny from all adapters/extension.php000066600000015606151372575720011126 0ustar00_stack, $name); $tag = $this->_getStackLocation(); // Reset the data if (isset($this->$tag)) { $this->$tag->_data = ""; } switch ($name) { case 'UPDATE': $this->current_update = JTable::getInstance('update'); $this->current_update->update_site_id = $this->_update_site_id; $this->current_update->detailsurl = $this->_url; $this->current_update->folder = ""; $this->current_update->client_id = 1; break; // Don't do anything case 'UPDATES': // Store compatibility info per updates block (usually one per file) $this->compatibility = array(); break; default: if (in_array($name, $this->_updatecols)) { $name = strtolower($name); $this->current_update->$name = ''; } if ($name == 'TARGETPLATFORM') { $this->current_update->targetplatform = $attrs; if (isset($attrs['NAME']) && ($attrs['NAME'] == 'joomla') && !empty($attrs['VERSION'])) { $this->current_update->compatibility = $attrs['VERSION']; } } if ($name == 'PHP_MINIMUM') { $this->current_update->php_minimum = ''; } break; } } /** * Character Parser Function * * @param object $parser Parser object. * @param object $name The name of the element. * * @return void * * @since 11.1 */ protected function _endElement($parser, $name) { array_pop($this->_stack); //echo 'Closing: '. $name .'
'; switch ($name) { case 'UPDATE': $ver = new JVersion; $product = strtolower(JFilterInput::getInstance()->clean($ver->PRODUCT, 'cmd')); // lower case and remove the exclamation mark // Keep compatibility information in class property if (isset($this->current_update->compatibility)) { $this->compatibility[$this->current_update->version][] = $this->current_update->compatibility; unset($this->current_update->compatibility); } // Check that the product matches and that the version matches (optionally a regexp) if ($product == $this->current_update->targetplatform['NAME'] && preg_match('/' . $this->current_update->targetplatform['VERSION'] . '/', $ver->RELEASE)) { // Check if PHP version supported via tag, assume true if tag isn't present if (!isset($this->current_update->php_minimum) || version_compare(PHP_VERSION, $this->current_update->php_minimum, '>=')) { $phpMatch = true; } else { // Notify the user of the potential update $msg = JText::sprintf( 'JLIB_INSTALLER_AVAILABLE_UPDATE_PHP_VERSION', $this->current_update->name, $this->current_update->version, $this->current_update->php_minimum, PHP_VERSION ); JFactory::getApplication()->enqueueMessage($msg, 'warning'); $phpMatch = false; } // Target platform and php_minimum aren't valid fields in the update table so unset them to prevent J! from trying to store them unset($this->current_update->targetplatform); unset($this->current_update->php_minimum); if ($phpMatch) { if (isset($this->latest)) { if (version_compare($this->current_update->version, $this->latest->version, '>') == 1) { $this->latest = $this->current_update; } } else { $this->latest = $this->current_update; } } } break; case 'UPDATES': // :D break; } } /** * Character Parser Function * * @param object $parser Parser object. * @param object $data The data. * * @return void * * @note This is public because its called externally. * @since 11.1 */ protected function _characterData($parser, $data) { $tag = $this->_getLastTag(); //if(!isset($this->$tag->_data)) $this->$tag->_data = ''; //$this->$tag->_data .= $data; if (in_array($tag, $this->_updatecols)) { $tag = strtolower($tag); $this->current_update->$tag .= $data; } if ($tag == 'PHP_MINIMUM') { $this->current_update->php_minimum = $data; } } /** * Finds an update. * * @param array $options Update options. * * @return array Array containing the array of update sites and array of updates * * @since 11.1 */ public function findUpdate($options) { $url = trim($options['location']); $this->_url = &$url; $this->_update_site_id = $options['update_site_id']; if (substr($url, -4) != '.xml') { if (substr($url, -1) != '/') { $url .= '/'; } $url .= 'extension.xml'; } $dbo = $this->parent->getDBO(); $http = JHttpFactory::getHttp(); try { $response = $http->get($url); } catch (Exception $exc) { $response = null; } if (is_null($response) || ($response->code != 200)) { $query = $dbo->getQuery(true); $query->update('#__update_sites'); $query->set('enabled = 0'); $query->where('update_site_id = ' . $this->_update_site_id); $dbo->setQuery($query); $dbo->execute(); JLog::add("Error opening url: " . $url, JLog::WARNING, 'updater'); $app = JFactory::getApplication(); $app->enqueueMessage(JText::sprintf('JLIB_UPDATER_ERROR_EXTENSION_OPEN_URL', $url), 'warning'); return false; } $this->xml_parser = xml_parser_create(''); xml_set_object($this->xml_parser, $this); xml_set_element_handler($this->xml_parser, '_startElement', '_endElement'); xml_set_character_data_handler($this->xml_parser, '_characterData'); if (!xml_parse($this->xml_parser, $response->body)) { JLog::add("Error parsing url: " . $url, JLog::WARNING, 'updater'); $app = JFactory::getApplication(); $app->enqueueMessage(JText::sprintf('JLIB_UPDATER_ERROR_EXTENSION_PARSE_URL', $url), 'warning'); return false; } xml_parser_free($this->xml_parser); if (isset($this->latest)) { if (isset($this->latest->client) && strlen($this->latest->client)) { $this->latest->client_id = JApplicationHelper::getClientInfo($this->latest->client, 1)->id; unset($this->latest->client); } $updates = array($this->latest); } else { $updates = array(); } return array('update_sites' => array(), 'updates' => $updates, 'compatibility' => $this->compatibility); } } adapters/index.html000066600000000037151372575720010366 0ustar00 adapters/collection.php000066600000014714151372575720011244 0ustar00', $this->_stack); } /** * Get the parent tag * * @return string parent * * @since 11.1 */ protected function _getParent() { return end($this->parent); } /** * Opening an XML element * * @param object $parser Parser object * @param string $name Name of element that is opened * @param array $attrs Array of attributes for the element * * @return void * * @since 11.1 */ public function _startElement($parser, $name, $attrs = array()) { array_push($this->_stack, $name); $tag = $this->_getStackLocation(); // Reset the data if (isset($this->$tag)) { $this->$tag->_data = ""; } switch ($name) { case 'CATEGORY': if (isset($attrs['REF'])) { $this->update_sites[] = array('type' => 'collection', 'location' => $attrs['REF'], 'update_site_id' => $this->_update_site_id); } else { // This item will have children, so prepare to attach them $this->pop_parent = 1; } break; case 'EXTENSION': $update = JTable::getInstance('update'); $update->set('update_site_id', $this->_update_site_id); foreach ($this->_updatecols as $col) { // Reset the values if it doesn't exist if (!array_key_exists($col, $attrs)) { $attrs[$col] = ''; if ($col == 'CLIENT') { $attrs[$col] = 'site'; } } } $client = JApplicationHelper::getClientInfo($attrs['CLIENT'], 1); $attrs['CLIENT_ID'] = $client->id; // Lower case all of the fields foreach ($attrs as $key => $attr) { $values[strtolower($key)] = $attr; } // Only add the update if it is on the same platform and release as we are $ver = new JVersion; $product = strtolower(JFilterInput::getInstance()->clean($ver->PRODUCT, 'cmd')); // lower case and remove the exclamation mark // Set defaults, the extension file should clarify in case but it may be only available in one version // This allows an update site to specify a targetplatform // targetplatformversion can be a regexp, so 1.[56] would be valid for an extension that supports 1.5 and 1.6 // Note: Whilst the version is a regexp here, the targetplatform is not (new extension per platform) // Additionally, the version is a regexp here and it may also be in an extension file if the extension is // compatible against multiple versions of the same platform (e.g. a library) if (!isset($values['targetplatform'])) { $values['targetplatform'] = $product; } // set this to ourself as a default if (!isset($values['targetplatformversion'])) { $values['targetplatformversion'] = $ver->RELEASE; } // set this to ourself as a default // validate that we can install the extension if ($product == $values['targetplatform'] && preg_match('/' . $values['targetplatformversion'] . '/', $ver->RELEASE)) { $update->bind($values); $this->updates[] = $update; } break; } } /** * Closing an XML element * Note: This is a protected function though has to be exposed externally as a callback * * @param object $parser Parser object * @param string $name Name of the element closing * * @return void * * @since 11.1 */ protected function _endElement($parser, $name) { $lastcell = array_pop($this->_stack); switch ($name) { case 'CATEGORY': if ($this->pop_parent) { $this->pop_parent = 0; array_pop($this->parent); } break; } } // Note: we don't care about char data in collection because there should be none /** * Finds an update * * @param array $options Options to use: update_site_id: the unique ID of the update site to look at * * @return array Update_sites and updates discovered * * @since 11.1 */ public function findUpdate($options) { $url = trim($options['location']); $this->_update_site_id = $options['update_site_id']; if (substr($url, -4) != '.xml') { if (substr($url, -1) != '/') { $url .= '/'; } $url .= 'update.xml'; } $this->base = new stdClass; $this->update_sites = array(); $this->updates = array(); $dbo = $this->parent->getDBO(); $http = JHttpFactory::getHttp(); try { $response = $http->get($url); } catch (Exception $exc) { $response = null; } if (is_null($response) || ($response->code != 200)) { $query = $dbo->getQuery(true); $query->update('#__update_sites'); $query->set('enabled = 0'); $query->where('update_site_id = ' . $this->_update_site_id); $dbo->setQuery($query); $dbo->execute(); JLog::add("Error parsing url: " . $url, JLog::WARNING, 'updater'); $app = JFactory::getApplication(); $app->enqueueMessage(JText::sprintf('JLIB_UPDATER_ERROR_COLLECTION_OPEN_URL', $url), 'warning'); return false; } $this->xml_parser = xml_parser_create(''); xml_set_object($this->xml_parser, $this); xml_set_element_handler($this->xml_parser, '_startElement', '_endElement'); if (!xml_parse($this->xml_parser, $response->body)) { JLog::add("Error parsing url: " . $url, JLog::WARNING, 'updater'); $app = JFactory::getApplication(); $app->enqueueMessage(JText::sprintf('JLIB_UPDATER_ERROR_COLLECTION_PARSE_URL', $url), 'warning'); return false; } // TODO: Decrement the bad counter if non-zero return array('update_sites' => $this->update_sites, 'updates' => $this->updates); } } updateadapter.php000066600000002462151372575720010126 0ustar00', $this->_stack); } /** * Gets the reference to the last tag * * @return object * * @since 11.1 */ protected function _getLastTag() { return $this->_stack[count($this->_stack) - 1]; } }