芝麻web文件管理V1.00
编辑当前文件:/home/asmplong/www/ancien-site-2019/site/administrator/components/com_akeeba/models/selfheal.php
tableExists('#__ak_profiles')) { if(!$this->runSQL($this->schemata['#__ak_profiles'])) return false; if(!$this->runSQL($this->schemata['default_profile'])) return false; } foreach(array('#__ak_stats','#__ak_acl','#__ak_storage') as $table) { if(!$this->tableExists($table)) { if(!$this->runSQL($this->schemata[$table])) return false; } } // Fix the #__ak_stats table (req. for upgrades from 3.0/.a1 to 3.1./3.1 releases) if(!$this->columnExists('#__ak_stats', 'total_size')) { $hasTagColumn = !$this->columnExists('#__ak_stats', 'tag'); // Drop any existing #__ak_stats_bak table if(!$this->runSQL('DROP TABLE IF EXISTS `#__ak_stats_bak`')) { if($db->getErrorNum() != 1060) return false; } // Create a new #__ak_stats_bak table $sql = $this->schemata['#__ak_stats']; $sql = str_replace('#__ak_stats', '#__ak_stats_bak', $sql); if(!$this->runSQL($sql)) { if($db->getErrorNum() != 1060) return false; } // Copy existing data from #__ak_stats to #__ak_stats_bak if($hasTagColumn) { // Upgrade from 3.1.3 or later (has tag and filesexist columns) $sql = <<
runSQL($sql)) { if($db->getErrorNum() != 1060) return false; } // Drop the broken #__ak_stats table if(!$this->runSQL('DROP TABLE IF EXISTS `#__ak_stats`')) return false; // Create the #__ak_stats table afresh if(!$this->runSQL($this->schemata['#__ak_stats'])) return false; // Move data from the #__ak_stats_bak to the new #__ak_stats table if(!$this->runSQL('INSERT IGNORE INTO `#__ak_stats` SELECT * FROM `#__ak_stats_bak`')) return false; // Drop the #__ak_stats_bak table if(!$this->runSQL('DROP TABLE IF EXISTS `#__ak_stats_bak`')) return false; } // If we're still here, our schema is up-to-date! return true; } /** * Runs a SQL statement and return false if the query failed * @param string $sql The SQL command to run * @return bool */ private function runSQL($sql) { $db = JFactory::getDBO(); $db->setQuery($sql); try { $db->query(); } catch(DatabaseException $e) { return false; } if(!version_compare(JVERSION, '1.6.0', 'ge')) { // Joomla! 1.5 returns the error message on failure if($db->getError()) return false; } return true; } /** * Checks if a particular column exists in a table * @param string $table The table name to check, e.g. #__ak_stats * @param string $column The column to check, e.g. tag * * @return bool True if the column exists */ private function columnExists($table, $column) { $db = JFactory::getDBO(); // First, try using DESCRIBE (preferred method) $db->setQuery('DESCRIBE '.$db->nameQuote($table)); try { $columns = $db->loadResultArray(0); } catch(DatabaseException $e) { $columns = null; } if(!is_null($columns)) { return in_array($column, $columns); } // DESCRIBE failed. Try the hard way... $db->setQuery('SHOW CREATE TABLE '.$db->nameQuote($table)); try { $creates = $db->loadResultArray(1); } catch(DatabaseException $e) { return false; } $create = $creates[0]; $search = $db->nameQuote($column); return strpos($search, $create) !== false; } /** * Checks if a specific table exists in the database * @param string $table Table name, e.g. #__ak_stats * * @return bool */ private function tableExists($table) { $db = JFactory::getDBO(); return $this->runSQL('SELECT COUNT(*) FROM '.$db->nameQuote($table)); } }