0byt3m1n1-V2
Path:
/
home
/
a
/
c
/
a
/
academiac
/
www
/
[
Home
]
File: update.php.tar
home/academiac/www/administrator/components/com_installer/models/update.php 0000644 00000015045 15137210335 0023372 0 ustar 00 <?php /** * @package Joomla.Administrator * @subpackage com_installer * @copyright Copyright (C) 2005 - 2014 Open Source Matters, Inc. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE.txt */ // No direct access defined('_JEXEC') or die; // Import library dependencies jimport('joomla.application.component.modellist'); jimport('joomla.updater.update'); /** * @package Joomla.Administrator * @subpackage com_installer * @since 1.6 */ class InstallerModelUpdate extends JModelList { /** * Constructor. * * @param array An optional associative array of configuration settings. * @see JController * @since 1.6 */ public function __construct($config = array()) { if (empty($config['filter_fields'])) { $config['filter_fields'] = array( 'name', 'client_id', 'type', 'folder', 'extension_id', 'update_id', 'update_site_id', ); } parent::__construct($config); } /** * Method to auto-populate the model state. * * Note. Calling getState in this method will result in recursion. * * @since 1.6 */ protected function populateState($ordering = null, $direction = null) { $app = JFactory::getApplication('administrator'); $this->setState('message', $app->getUserState('com_installer.message')); $this->setState('extension_message', $app->getUserState('com_installer.extension_message')); $app->setUserState('com_installer.message', ''); $app->setUserState('com_installer.extension_message', ''); parent::populateState('name', 'asc'); } /** * Method to get the database query * * @return JDatabaseQuery The database query * @since 1.6 */ protected function getListQuery() { $db = $this->getDbo(); $query = $db->getQuery(true); // grab updates ignoring new installs $query->select('*')->from('#__updates')->where('extension_id != 0'); $query->order($this->getState('list.ordering').' '.$this->getState('list.direction')); // Filter by extension_id if ($eid = $this->getState('filter.extension_id')) { $query->where($db->nq('extension_id') . ' = ' . $db->q((int) $eid)); } else { $query->where($db->nq('extension_id').' != '.$db->q(0)); $query->where($db->nq('extension_id').' != '.$db->q(700)); } return $query; } /** * 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; } /** * Removes all of the updates from the table. * * @return boolean result of operation * @since 1.6 */ public function purge() { $db = JFactory::getDBO(); // Note: TRUNCATE is a DDL operation // This may or may not mean depending on your database $db->setQuery('TRUNCATE TABLE #__updates'); if ($db->Query()) { // Reset the last update check timestamp $query = $db->getQuery(true); $query->update($db->nq('#__update_sites')); $query->set($db->nq('last_check_timestamp').' = '.$db->q(0)); $db->setQuery($query); $db->query(); $this->_message = JText::_('COM_INSTALLER_PURGED_UPDATES'); return true; } else { $this->_message = JText::_('COM_INSTALLER_FAILED_TO_PURGE_UPDATES'); return false; } } /** * Enables any disabled rows in #__update_sites table * * @return boolean result of operation * @since 1.6 */ public function enableSites() { $db = JFactory::getDBO(); $db->setQuery('UPDATE #__update_sites SET enabled = 1 WHERE enabled = 0'); if ($db->Query()) { if ($rows = $db->getAffectedRows()) { $this->_message .= JText::plural('COM_INSTALLER_ENABLED_UPDATES', $rows); } return true; } else { $this->_message .= JText::_('COM_INSTALLER_FAILED_TO_ENABLE_UPDATES'); return false; } } /** * Update function. * * Sets the "result" state with the result of the operation. * * @param Array[int] List of updates to apply * @since 1.6 */ public function update($uids) { $result = true; foreach($uids as $uid) { $update = new JUpdate(); $instance = JTable::getInstance('update'); $instance->load($uid); $update->loadFromXML($instance->detailsurl); // install sets state and enqueues messages $res = $this->install($update); if ($res) { $instance->delete($uid); } $result = $res & $result; } // Set the final state $this->setState('result', $result); } /** * Handles the actual update installation. * * @param JUpdate An update definition * @return boolean Result of install * @since 1.6 */ private function install($update) { $app = JFactory::getApplication(); if (isset($update->get('downloadurl')->_data)) { $url = trim($update->downloadurl->_data); } else { JError::raiseWarning('', JText::_('COM_INSTALLER_INVALID_EXTENSION_UPDATE')); return false; } $p_file = JInstallerHelper::downloadPackage($url); // Was the package downloaded? if (!$p_file) { JError::raiseWarning('', JText::sprintf('COM_INSTALLER_PACKAGE_DOWNLOAD_FAILED', $url)); return false; } $config = JFactory::getConfig(); $tmp_dest = $config->get('tmp_path'); // Unpack the downloaded package file $package = JInstallerHelper::unpack($tmp_dest . '/' . $p_file); // Get an installer instance $installer = JInstaller::getInstance(); $update->set('type', $package['type']); // Install the package if (!$installer->update($package['dir'])) { // There was an error updating the package $msg = JText::sprintf('COM_INSTALLER_MSG_UPDATE_ERROR', JText::_('COM_INSTALLER_TYPE_TYPE_'.strtoupper($package['type']))); $result = false; } else { // Package updated successfully $msg = JText::sprintf('COM_INSTALLER_MSG_UPDATE_SUCCESS', JText::_('COM_INSTALLER_TYPE_TYPE_'.strtoupper($package['type']))); $result = true; } // Quick change $this->type = $package['type']; // Set some model state values $app->enqueueMessage($msg); // TODO: Reconfigure this code when you have more battery life left $this->setState('name', $installer->get('name')); $this->setState('result', $result); $app->setUserState('com_installer.message', $installer->message); $app->setUserState('com_installer.extension_message', $installer->get('extension_message')); // Cleanup the install files if (!is_file($package['packagefile'])) { $config = JFactory::getConfig(); $package['packagefile'] = $config->get('tmp_path') . '/' . $package['packagefile']; } JInstallerHelper::cleanupInstall($package['packagefile'], $package['extractdir']); return $result; } } home/academiac/www/administrator/components/com_installer/controllers/update.php 0000644 00000007117 15137212263 0024460 0 ustar 00 <?php /** * @package Joomla.Administrator * @subpackage com_installer * @copyright Copyright (C) 2005 - 2014 Open Source Matters, Inc. All rights reserved. * @license GNU General Public License, see LICENSE.php */ defined('_JEXEC') or die; /** * @package Joomla.Administrator * @subpackage com_installer */ class InstallerControllerUpdate extends JControllerLegacy { /** * Update a set of extensions. * * @since 1.6 */ function update() { // Check for request forgeries JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN')); $model = $this->getModel('update'); $uid = JRequest::getVar('cid', array(), '', 'array'); JArrayHelper::toInteger($uid, array()); if ($model->update($uid)) { $cache = JFactory::getCache('mod_menu'); $cache->clean(); } $app = JFactory::getApplication(); $redirect_url = $app->getUserState('com_installer.redirect_url'); if(empty($redirect_url)) { $redirect_url = JRoute::_('index.php?option=com_installer&view=update', false); } else { // wipe out the user state when we're going to redirect $app->setUserState('com_installer.redirect_url', ''); $app->setUserState('com_installer.message', ''); $app->setUserState('com_installer.extension_message', ''); } $this->setRedirect($redirect_url); } /** * Find new updates. * * @since 1.6 */ function find() { // Check for request forgeries JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN')); // Get the caching duration 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 updates $model = $this->getModel('update'); $result = $model->findUpdates(0, $cache_timeout); $this->setRedirect(JRoute::_('index.php?option=com_installer&view=update', false)); //$view->display(); } /** * Purges updates. * * @since 1.6 */ function purge() { // Purge updates // Check for request forgeries JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN')); $model = $this->getModel('update'); $model->purge(); $model->enableSites(); $this->setRedirect(JRoute::_('index.php?option=com_installer&view=update', false), $model->_message); } /** * Fetch and report updates in JSON format, for AJAX requests * * @return void * * @since 2.5 */ function ajax() { // Note: we don't do a token check as we're fetching information // asynchronously. This means that between requests the token might // change, making it impossible for AJAX to work. $eid = JRequest::getInt('eid', 0); $skip = JRequest::getVar('skip', array(), 'default', 'array'); $cache_timeout = JRequest::getInt('cache_timeout', 0); if($cache_timeout == 0) { 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; } $model = $this->getModel('update'); $result = $model->findUpdates($eid, $cache_timeout); $model->setState('list.start', 0); $model->setState('list.limit', 0); if($eid != 0) { $model->setState('filter.extension_id', $eid); } $updates = $model->getItems(); if(!empty($skip)) { $unfiltered_updates = $updates; $updates = array(); foreach($unfiltered_updates as $update) { if(!in_array($update->extension_id, $skip)) $updates[] = $update; } } echo json_encode($updates); JFactory::getApplication()->close(); } } home/academiac/www/administrator/components/com_joomlaupdate/controllers/update.php 0000644 00000010017 15137243300 0025134 0 ustar 00 <?php /** * @package Joomla.Administrator * @subpackage com_joomlaupdate * @copyright Copyright (C) 2005 - 2014 Open Source Matters, Inc. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE.txt * @since 2.5.4 */ defined('_JEXEC') or die; /** * The Joomla! update controller for the Update view * * @package Joomla.Administrator * @subpackage com_joomlaupdate * @since 2.5.4 */ class JoomlaupdateControllerUpdate extends JControllerLegacy { /** * Performs the download of the update package * * @return void * * @since 2.5.4 */ public function download() { $this->_applyCredentials(); $model = $this->getModel('Default'); $file = $model->download(); $message = null; $messageType = null; if ($file) { JFactory::getApplication()->setUserState('com_joomlaupdate.file', $file); $url = 'index.php?option=com_joomlaupdate&task=update.install'; } else { JFactory::getApplication()->setUserState('com_joomlaupdate.file', null); $url = 'index.php?option=com_joomlaupdate'; $message = JText::_('COM_JOOMLAUPDATE_VIEW_UPDATE_DOWNLOADFAILED'); } $this->setRedirect($url, $message, $messageType); } /** * Start the installation of the new Joomla! version * * @return void * * @since 2.5.4 */ public function install() { $this->_applyCredentials(); $model = $this->getModel('Default'); $file = JFactory::getApplication()->getUserState('com_joomlaupdate.file', null); $model->createRestorationFile($file); $this->display(); } /** * Finalise the upgrade by running the necessary scripts * * @return void * * @since 2.5.4 */ public function finalise() { $this->_applyCredentials(); $model = $this->getModel('Default'); $model->finaliseUpgrade(); $url = 'index.php?option=com_joomlaupdate&task=update.cleanup'; $this->setRedirect($url); } /** * Clean up after ourselves * * @return void * * @since 2.5.4 */ public function cleanup() { $this->_applyCredentials(); $model = $this->getModel('Default'); $model->cleanUp(); $url = 'index.php?option=com_joomlaupdate&layout=complete'; $this->setRedirect($url); } /** * Method to display a view. * * @param boolean $cachable If true, the view output will be cached * @param array $urlparams An array of safe url parameters and their variable types, for valid values see {@link JFilterInput::clean()}. * * @return JController This object to support chaining. * * @since 2.5.4 */ public function display($cachable = false, $urlparams = false) { // Get the document object. $document = JFactory::getDocument(); // Set the default view name and format from the Request. $vName = JRequest::getCmd('view', 'update'); $vFormat = $document->getType(); $lName = JRequest::getCmd('layout', 'default'); // Get and render the view. if ($view = $this->getView($vName, $vFormat)) { // Get the model for the view. $model = $this->getModel('Default'); // Push the model into the view (as default). $view->setModel($model, true); $view->setLayout($lName); // Push document object into the view. $view->assignRef('document', $document); $view->display(); } return $this; } /** * Applies FTP credentials to Joomla! itself, when required * * @return void * * @since 2.5.4 */ protected function _applyCredentials() { jimport('joomla.client.helper'); if (!JClientHelper::hasCredentials('ftp')) { $user = JFactory::getApplication()->getUserStateFromRequest('com_joomlaupdate.ftp_user', 'ftp_user', null, 'raw'); $pass = JFactory::getApplication()->getUserStateFromRequest('com_joomlaupdate.ftp_pass', 'ftp_pass', null, 'raw'); if ($user != '' && $pass != '') { // Add credentials to the session if (JClientHelper::setCredentials('ftp', $user, $pass)) { $return = false; } else { $return = JError::raiseWarning('SOME_ERROR_CODE', JText::_('JLIB_CLIENT_ERROR_HELPER_SETCREDENTIALSFROMREQUEST_FAILED')); } } } } } home/academiac/www/libraries/joomla/database/table/update.php 0000644 00000004653 15137272065 0020312 0 ustar 00 <?php /** * @package Joomla.Platform * @subpackage Database * * @copyright Copyright (C) 2005 - 2014 Open Source Matters, Inc. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE */ defined('JPATH_PLATFORM') or die; jimport('joomla.database.table'); /** * Update table * Stores updates temporarily * * @package Joomla.Platform * @subpackage Table * @since 11.1 */ class JTableUpdate extends JTable { /** * Constructor * * @param JDatabase &$db A database connector object * * @since 11.1 */ public function __construct(&$db) { parent::__construct('#__updates', 'update_id', $db); } /** * Overloaded check function * * @return boolean True if the object is ok * * @see JTable::check * @since 11.1 */ public function check() { // check for valid name if (trim($this->name) == '' || trim($this->element) == '') { $this->setError(JText::_('JLIB_DATABASE_ERROR_MUSTCONTAIN_A_TITLE_EXTENSION')); return false; } return true; } /** * Overloaded bind function * * @param array $array Named array * @param mixed $ignore An optional array or space separated list of properties * to ignore while binding. * * @return mixed Null if operation was satisfactory, otherwise returns an error * * @see JTable::bind * @since 11.1 */ public function bind($array, $ignore = '') { if (isset($array['params']) && is_array($array['params'])) { $registry = new JRegistry; $registry->loadArray($array['params']); $array['params'] = (string) $registry; } if (isset($array['control']) && is_array($array['control'])) { $registry = new JRegistry; $registry->loadArray($array['control']); $array['control'] = (string) $registry; } return parent::bind($array, $ignore); } /** * Method to create and execute a SELECT WHERE query. * * @param array $options Array of options * * @return JDatabase Results of query * * @since 11.1 */ public function find($options = array()) { $where = array(); foreach ($options as $col => $val) { $where[] = $col . ' = ' . $this->_db->Quote($val); } $query = $this->_db->getQuery(true); $query->select($this->_db->quoteName($this->_tbl_key)); $query->from($this->_db->quoteName($this->_tbl)); $query->where(implode(' AND ', $where)); $this->_db->setQuery($query); return $this->_db->loadResult(); } } home/academiac/www/libraries/joomla/updater/update.php 0000644 00000015127 15137272274 0017123 0 ustar 00 <?php /** * @package Joomla.Platform * @subpackage Updater * * @copyright Copyright (C) 2005 - 2014 Open Source Matters, Inc. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE */ defined('JPATH_PLATFORM') or die; /** * Update class. * * @package Joomla.Platform * @subpackage Updater * @since 11.1 */ class JUpdate extends JObject { /** * @var string * @since 11.1 */ protected $name; /** * @var string * @since 11.1 */ protected $description; /** * @var string * @since 11.1 */ protected $element; /** * @var string * @since 11.1 */ protected $type; /** * @var string * @since 11.1 */ protected $version; /** * @var string * @since 11.1 */ protected $infourl; /** * @var string * @since 11.1 */ protected $client; /** * @var string * @since 11.1 */ protected $group; /** * @var string * @since 11.1 */ protected $downloads; /** * @var string * @since 11.1 */ protected $tags; /** * @var string * @since 11.1 */ protected $maintainer; /** * @var string * @since 11.1 */ protected $maintainerurl; /** * @var string * @since 11.1 */ protected $category; /** * @var string * @since 11.1 */ protected $relationships; /** * @var string * @since 11.1 */ protected $targetplatform; /** * @var string * @since 11.1 */ protected $_xml_parser; /** * @var array * @since 11.1 */ protected $_stack = array('base'); /** * @var array * @since 11.1 */ protected $_state_store = array(); /** * Gets the reference to the current direct parent * * @return object * * @since 11.1 */ protected function _getStackLocation() { return implode('->', $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 <php_minimum> 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; } }
©
2018.