/** * Adds all non-Joomla tables to the exclusion filters */ function ExcludeNonJoomla() { // Get all tables $db = JoomlapackAbstraction::getDatabase(); $sql = "SHOW TABLES"; $db->setQuery($sql); $tables = $db->loadRowList(); // Get prefix $prefix = JoomlapackAbstraction::getDBPrefix(); // Loop tables foreach ($tables as $row) { $table = $row[0]; $abstractTable = str_replace($prefix, '#__', $table); if ($table == $abstractTable) { // Filter only non-Joomla tables $this->modifyFilter($abstractTable, true); } } }
function getTables() { $db = JoomlapackAbstraction::getDatabase(); $sql = "SHOW TABLES"; $db->setQuery($sql); $results = $db->loadRowList(); $ret = array(); foreach ($results as $row) { $ret[] = $row[0]; } return $ret; }
/** * Return an instance of JDatabase * * @return JDatabase */ function _getDB() { if ($this->_isJoomla) { // Core Joomla! database, get the existing instance $db = JoomlapackAbstraction::getDatabase(); return $db; } else { // We have to connect ourselves if (defined('_JEXEC')) { // Joomla! 1.5.x jimport('joomla.database.database'); jimport('joomla.database.table'); $conf =& JFactory::getConfig(); $host = $this->_host . ($this->_port != '' ? ':' . $this->_port : ''); $user = $this->_username; $password = $this->_password; $database = $this->_database; $prefix = ''; $driver = $conf->getValue('config.dbtype'); $debug = $conf->getValue('config.debug'); $options = array('driver' => $driver, 'host' => $host, 'user' => $user, 'password' => $password, 'database' => $database, 'prefix' => $prefix); $db =& JDatabase::getInstance($options); if (JError::isError($db)) { $this->_errorMessage = "JoomlapackDumperDefault :: Database Error:" . $db->toString(); $this->_isError = true; $this->setError($this->_errorMessage); return false; } if ($db->getErrorNum() > 0) { $this->_errorMessage = 'JDatabase::getInstance: Could not connect to database <br/>' . 'joomla.library:' . $db->getErrorNum() . ' - ' . $db->getErrorMsg(); $this->_isError = true; $this->setError($this->_errorMessage); return false; } $db->debug($debug); return $db; } else { // Joomla! 1.0.x $host = $this->_host . ($this->_port != '' ? ':' . $this->_port : ''); $user = $this->_username; $password = $this->_password; $database = $this->_database; $prefix = ''; $db = new database($host, $user, $password, $database, $prefix, false); // A dummy SQL statement which shouldn't fail $sql = 'SHOW TABLES'; $db->setQuery($sql); $db->query(); // If the query failed, I guess we're not connected to the database if ($db->getErrorNum() > 0) { $this->_errorMessage = 'database(): Could not connect to database <br/>' . 'joomla.library:' . $db->getErrorNum() . ' - ' . $db->getErrorMsg(); $this->_isError = true; $this->setError($this->_errorMessage); return false; } return $db; } } }
function isInclusionFilterSet($filterClass, $value) { if (isset($value['id'])) { $newval = array(); foreach ($value as $key => $data) { if ($key != 'id') { $newval[$key] = $data; } } $value = $newval; unset($newval); } $value = serialize($value); $db = JoomlapackAbstraction::getDatabase(); $sql = 'SELECT COUNT(' . $db->nameQuote('id') . ') FROM #__jp_inclusion WHERE ' . $db->nameQuote('class') . ' = ' . $db->Quote($filterClass) . ' AND ' . $db->nameQuote('value') . ' = ' . $db->Quote($value); $db->setQuery($sql); $count = $db->loadResult(); return $count > 0; }
function _echoFix() { $jpconfiguration =& JoomlapackConfiguration::getInstance(); $db = JoomlapackAbstraction::getDatabase(); echo JoomlapackCommonHTML::getAdminHeadingHTML(JoomlapackLangManager::_('CPANEL_CONFIGMIGRATE')); // Catch the "nothing to do" case if ($jpconfiguration->get('siteRoot') == JPATH_SITE) { echo JoomlapackLangManager::_('CONFIGMIGRATE_NOFIXREQUIRED'); return; } // Sometimes, it is possible that the siteRoot configuration value is not set // (e.g. manually upgrading from an older version, keeping the config xml file). // This will fix it if (is_null($jpconfiguration->get('siteRoot'))) { echo JoomlapackLangManager::_('CONFIGMIGRATE_NOROOTSTORED'); $jpconfiguration->set('siteRoot', JPATH_SITE); $jpconfiguration->SaveConfiguration(); return; } // A genuine case of site location mismatch. Let's take a look at it. $oldPath = JoomlapackAbstraction::TranslateWinPath($jpconfiguration->get('siteRoot')); $newPath = JoomlapackAbstraction::TranslateWinPath(JPATH_SITE); $sql = 'SELECT * FROM ' . $db->nameQuote('#__jp_exclusion'); $db->setQuery($sql); $temparray = $db->loadAssocList(); foreach ($temparray as $row) { $value = $row['value']; if (strstr($value, $oldPath)) { $value = str_replace($oldPath, $newPath, $value); $sql = 'UPDATE ' . $db->nameQuote('#__jp_exclusion') . ' SET ' . $db->nameQuote('value') . ' = ' . $db->Quote($value) . ' WHERE ' . $db->nameQuote('id') . ' = ' . $db->Quote($row['id']); $db->setQuery($sql); $db->query(); } } echo JoomlapackLangManager::_('CONFIGMIGRATE_FIXED'); }
/** * Counts the number of instances for a specific variable * * @param string $key The varaible's name * @return string */ function CountVar($key) { $database = JoomlapackAbstraction::getDatabase(); $sql = "SELECT `key` FROM #__jp_packvars WHERE `key` = \"" . $database->getEscaped($key) . "\""; $database->setQuery($sql); $database->query(); return $database->getNumRows(); }