AAAAhome/academiac/www/administrator/components/com_virtuemart_allinone/classes/model.php000060400000012441151372245020025442 0ustar00 */ defined('_JEXEC') or die(); jimport('joomla.application.component.model'); /** * The Live Update MVC model */ class LiveUpdateModel extends JModel { 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); } public function extract() { $session = JFactory::getSession(); $target = $session->get('target', '', 'liveupdate'); $tempdir = $session->get('tempdir', '', 'liveupdate'); jimport('joomla.filesystem.archive'); return JArchive::extract( $target, $tempdir); } public function install() { $session = JFactory::getSession(); $tempdir = $session->get('tempdir', '', 'liveupdate'); jimport('joomla.installer.installer'); jimport('joomla.installer.helper'); $installer =& JInstaller::getInstance(); $packageType = JInstallerHelper::detectType($tempdir); if(!$packageType) { $msg = JText::_('LIVEUPDATE_INVALID_PACKAGE_TYPE'); $result = false; } elseif (!$installer->install($tempdir)) { // There was an error installing the package $msg = JText::sprintf('LIVEUPDATE_INSTALLEXT', JText::_($packageType), JText::_('LIVEUPDATE_Error')); $result = false; } else { // Package installed sucessfully $msg = JText::sprintf('LIVEUPDATE_INSTALLEXT', JText::_($packageType), JText::_('LIVEUPDATE_Success')); $result = true; } $app = JFactory::getApplication(); $app->enqueueMessage($msg); $this->setState('result', $result); $this->setState('packageType', $packageType); if($packageType) { $this->setState('name', $installer->get('name')); $this->setState('message', $installer->message); if(version_compare(JVERSION,'1.6.0','ge')) { $this->setState('extmessage', $installer->get('extension_message')); } else { $this->setState('extmessage', $installer->get('extension.message')); } } return $result; } public function cleanup() { $session = JFactory::getSession(); $target = $session->get('target', '', 'liveupdate'); $tempdir = $session->get('tempdir', '', 'liveupdate'); jimport('joomla.installer.helper'); JInstallerHelper::cleanupInstall($target, $tempdir); $session->clear('target','liveupdate'); $session->clear('tempdir','liveupdate'); } public function getSRPURL($return = '') { $session = JFactory::getSession(); $tempdir = $session->get('tempdir', '', 'liveupdate'); jimport('joomla.installer.installer'); jimport('joomla.installer.helper'); jimport('joomla.filesystem.file'); $instModelFile = JPATH_ADMINISTRATOR.'/components/com_akeeba/models/installer.php'; if(!JFile::exists($instModelFile)) return false; require_once JPATH_ADMINISTRATOR.'/components/com_akeeba/models/installer.php'; $model = JModel::getInstance('Installer', 'AkeebaModel'); $packageType = JInstallerHelper::detectType($tempdir); $name = $model->getExtensionName($tempdir); $url = 'index.php?option=com_akeeba&view=backup&tag=restorepoint&type='.$packageType.'&name='.urlencode($name['name']); switch($type) { case 'module': case 'template': $url .= '&group='.$name['client']; break; case 'plugin': $url .= '&group='.$name['group']; break; } if(!empty($return)) $url .= '&returnurl='.urlencode($return); return $url; } }home/academiac/www/administrator/components/com_virtuemart/liveupdate/classes/model.php000060400000012545151372403220025726 0ustar00 */ defined('_JEXEC') or die(); if(!class_exists('JModel')) require JPATH_VM_LIBRARIES.DS.'joomla'.DS.'application'.DS.'component'.DS.'model.php'; /** * The Live Update MVC model */ class LiveUpdateModel extends JModel { 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); } public function extract() { $session = JFactory::getSession(); $target = $session->get('target', '', 'liveupdate'); $tempdir = $session->get('tempdir', '', 'liveupdate'); jimport('joomla.filesystem.archive'); return JArchive::extract( $target, $tempdir); } public function install() { $session = JFactory::getSession(); $tempdir = $session->get('tempdir', '', 'liveupdate'); jimport('joomla.installer.installer'); jimport('joomla.installer.helper'); $installer =& JInstaller::getInstance(); $packageType = JInstallerHelper::detectType($tempdir); if(!$packageType) { $msg = JText::_('LIVEUPDATE_INVALID_PACKAGE_TYPE'); $result = false; } elseif (!$installer->install($tempdir)) { // There was an error installing the package $msg = JText::sprintf('LIVEUPDATE_INSTALLEXT', JText::_($packageType), JText::_('LIVEUPDATE_Error')); $result = false; } else { // Package installed sucessfully $msg = JText::sprintf('LIVEUPDATE_INSTALLEXT', JText::_($packageType), JText::_('LIVEUPDATE_Success')); $result = true; } $app = JFactory::getApplication(); $app->enqueueMessage($msg); $this->setState('result', $result); $this->setState('packageType', $packageType); if($packageType) { $this->setState('name', $installer->get('name')); $this->setState('message', $installer->message); if(version_compare(JVERSION,'1.6.0','ge')) { $this->setState('extmessage', $installer->get('extension_message')); } else { $this->setState('extmessage', $installer->get('extension.message')); } } return $result; } public function cleanup() { $session = JFactory::getSession(); $target = $session->get('target', '', 'liveupdate'); $tempdir = $session->get('tempdir', '', 'liveupdate'); jimport('joomla.installer.helper'); JInstallerHelper::cleanupInstall($target, $tempdir); $session->clear('target','liveupdate'); $session->clear('tempdir','liveupdate'); } public function getSRPURL($return = '') { $session = JFactory::getSession(); $tempdir = $session->get('tempdir', '', 'liveupdate'); jimport('joomla.installer.installer'); jimport('joomla.installer.helper'); jimport('joomla.filesystem.file'); $instModelFile = JPATH_ADMINISTRATOR.'/components/com_akeeba/models/installer.php'; if(!JFile::exists($instModelFile)) return false; require_once JPATH_ADMINISTRATOR.'/components/com_akeeba/models/installer.php'; $model = JModel::getInstance('Installer', 'AkeebaModel'); $packageType = JInstallerHelper::detectType($tempdir); $name = $model->getExtensionName($tempdir); $url = 'index.php?option=com_akeeba&view=backup&tag=restorepoint&type='.$packageType.'&name='.urlencode($name['name']); switch($type) { case 'module': case 'template': $url .= '&group='.$name['client']; break; case 'plugin': $url .= '&group='.$name['group']; break; } if(!empty($return)) $url .= '&returnurl='.urlencode($return); return $url; } }home/academiac/www/libraries/joomla/application/component/model.php000064400000026051151372612220021567 0ustar00 $type))); if (!$path) { $path = JPath::find(self::addIncludePath(null, ''), self::_createFileName('model', array('name' => $type))); } if ($path) { require_once $path; if (!class_exists($modelClass)) { JError::raiseWarning(0, JText::sprintf('JLIB_APPLICATION_ERROR_MODELCLASS_NOT_FOUND', $modelClass)); return false; } } else { return false; } } return new $modelClass($config); } /** * Constructor * * @param array $config An array of configuration options (name, state, dbo, table_path, ignore_request). * * @since 11.1 */ public function __construct($config = array()) { // Guess the option from the class name (Option)Model(View). if (empty($this->option)) { $r = null; if (!preg_match('/(.*)Model/i', get_class($this), $r)) { JError::raiseError(500, JText::_('JLIB_APPLICATION_ERROR_MODEL_GET_NAME')); } $this->option = 'com_' . strtolower($r[1]); } // Set the view name if (empty($this->name)) { if (array_key_exists('name', $config)) { $this->name = $config['name']; } else { $this->name = $this->getName(); } } // Set the model state if (array_key_exists('state', $config)) { $this->state = $config['state']; } else { $this->state = new JObject; } // Set the model dbo if (array_key_exists('dbo', $config)) { $this->_db = $config['dbo']; } else { $this->_db = JFactory::getDbo(); } // Set the default view search path if (array_key_exists('table_path', $config)) { $this->addTablePath($config['table_path']); } elseif (defined('JPATH_COMPONENT_ADMINISTRATOR')) { $this->addTablePath(JPATH_COMPONENT_ADMINISTRATOR . '/tables'); } // Set the internal state marker - used to ignore setting state from the request if (!empty($config['ignore_request'])) { $this->__state_set = true; } // Set the clean cache event if (isset($config['event_clean_cache'])) { $this->event_clean_cache = $config['event_clean_cache']; } elseif (empty($this->event_clean_cache)) { $this->event_clean_cache = 'onContentCleanCache'; } } /** * Gets an array of objects from the results of database query. * * @param string $query The query. * @param integer $limitstart Offset. * @param integer $limit The number of records. * * @return array An array of results. * * @since 11.1 */ protected function _getList($query, $limitstart = 0, $limit = 0) { $this->_db->setQuery($query, $limitstart, $limit); $result = $this->_db->loadObjectList(); return $result; } /** * Returns a record count for the query * * @param string $query The query. * * @return integer Number of rows for query * * @since 11.1 */ protected function _getListCount($query) { $this->_db->setQuery($query); $this->_db->execute(); return $this->_db->getNumRows(); } /** * Method to load and return a model object. * * @param string $name The name of the view * @param string $prefix The class prefix. Optional. * @param array $config Configuration settings to pass to JTable::getInstance * * @return mixed Model object or boolean false if failed * * @since 11.1 * @see JTable::getInstance */ protected function _createTable($name, $prefix = 'Table', $config = array()) { // Clean the model name $name = preg_replace('/[^A-Z0-9_]/i', '', $name); $prefix = preg_replace('/[^A-Z0-9_]/i', '', $prefix); // Make sure we are returning a DBO object if (!array_key_exists('dbo', $config)) { $config['dbo'] = $this->getDbo(); } return JTable::getInstance($name, $prefix, $config); } /** * Method to get the database driver object * * @return JDatabase */ public function getDbo() { return $this->_db; } /** * Method to get the model name * * The model name. By default parsed using the classname or it can be set * by passing a $config['name'] in the class constructor * * @return string The name of the model * * @since 11.1 */ public function getName() { if (empty($this->name)) { $r = null; if (!preg_match('/Model(.*)/i', get_class($this), $r)) { JError::raiseError(500, JText::_('JLIB_APPLICATION_ERROR_MODEL_GET_NAME')); } $this->name = strtolower($r[1]); } return $this->name; } /** * Method to get model state variables * * @param string $property Optional parameter name * @param mixed $default Optional default value * * @return object The property where specified, the state object where omitted * * @since 11.1 */ public function getState($property = null, $default = null) { if (!$this->__state_set) { // Protected method to auto-populate the model state. $this->populateState(); // Set the model state set flag to true. $this->__state_set = true; } return $property === null ? $this->state : $this->state->get($property, $default); } /** * Method to get a table object, load it if necessary. * * @param string $name The table name. Optional. * @param string $prefix The class prefix. Optional. * @param array $options Configuration array for model. Optional. * * @return JTable A JTable object * * @since 11.1 */ public function getTable($name = '', $prefix = 'Table', $options = array()) { if (empty($name)) { $name = $this->getName(); } if ($table = $this->_createTable($name, $prefix, $options)) { return $table; } JError::raiseError(0, JText::sprintf('JLIB_APPLICATION_ERROR_TABLE_NAME_NOT_SUPPORTED', $name)); return null; } /** * Method to auto-populate the model state. * * This method should only be called once per instantiation and is designed * to be called on the first call to the getState() method unless the model * configuration flag to ignore the request is set. * * @return void * * @note Calling getState in this method will result in recursion. * @since 11.1 */ protected function populateState() { } /** * Method to set the database driver object * * @param JDatabase &$db A JDatabase based object * * @return void * * @since 11.1 */ public function setDbo(&$db) { $this->_db = &$db; } /** * Method to set model state variables * * @param string $property The name of the property. * @param mixed $value The value of the property to set or null. * * @return mixed The previous value of the property or null if not set. * * @since 11.1 */ public function setState($property, $value = null) { return $this->state->set($property, $value); } /** * Clean the cache * * @param string $group The cache group * @param integer $client_id The ID of the client * * @return void * * @since 11.1 */ protected function cleanCache($group = null, $client_id = 0) { // Initialise variables; $conf = JFactory::getConfig(); $dispatcher = JDispatcher::getInstance(); $options = array( 'defaultgroup' => ($group) ? $group : (isset($this->option) ? $this->option : JRequest::getCmd('option')), 'cachebase' => ($client_id) ? JPATH_ADMINISTRATOR . '/cache' : $conf->get('cache_path', JPATH_SITE . '/cache')); $cache = JCache::getInstance('callback', $options); $cache->clean(); // Trigger the onContentCleanCache event. $dispatcher->trigger($this->event_clean_cache, $options); } }