'create',
'mismatch' => 'alter',
'missing_field' => 'insert',
'missing_index' => 'index',
'mismatch_index' => '', // TODO
);
var $errors = array();
/**
* Setup
*/
function __construct()
{
$ns = e107::getRender();
$pref = e107::getPref();
$mes = e107::getMessage();
$frm = e107::getForm();
$this->backUrl = e_SELF;
$core_data = file_get_contents(e_CORE.'sql/core_sql.php');
$this->tables['core'] = $this->getTables($core_data);
$this->sqlLanguageTables = $this->getSqlLanguages();
if(varset($pref['e_sql_list']))
{
foreach($pref['e_sql_list'] as $path => $file)
{
$filename = e_PLUGIN.$path.'/'.$file.'.php';
if(is_readable($filename))
{
$id = str_replace('_sql','',$file);
$data = file_get_contents($filename);
$this->tables[$id] = $this->getTables($data);
unset($data);
}
else
{
$message = str_replace("[x]",$filename,DBVLAN_22);
$mes->add($message, E_MESSAGE_WARNING);
}
}
}
}
/**
* Main Routine for checking and rendering results.
*/
function verify()
{
if(vartrue($_POST['verify_table']))
{
$this->runComparison($_POST['verify_table']);
}
else
{
if(isset($_POST['runfix']))
{
$this->runFix($_POST['fix']);
}
$this->renderTableSelect();
}
}
function runComparison($fileArray)
{
$ns = e107::getRender();
$mes = e107::getMessage();
$frm = e107::getForm();
foreach($fileArray as $tab)
{
$this->compare($tab);
foreach($this->sqlLanguageTables as $lng=>$lantab)
{
$this->compare($tab,$lng);
}
}
if($cnt = count($this->errors))
{
$message = str_replace("[x]",$cnt,DBVLAN_26); // Found [x] issues.
$mes->add($message, E_MESSAGE_WARNING);
$this->renderResults();
}
else
{
$mes->addSuccess("Tables appear to be okay!"); //TODO LAN
$mes->addSuccess("".LAN_BACK."");
//$debug = "
".print_r($this->results,TRUE)."
";
//$mes->add($debug,E_MESSAGE_DEBUG);
//$text .= "".$frm->admin_button('back', DBVLAN_17, 'back')."
";
$ns->tablerender("Okay",$mes->render().$text);
}
}
// $this->sqlTables = $this->sqlTableList();
// print_a($this->tables);
// $this->renderTableSelect();
// print_a($field);
// print_a($match[2]);
// echo "".$sql_data."
";
/**
* Check core tables and installed plugin tables
* @param $exclude - array of plugins to exclude.
*/
function compareAll($exclude = null)
{
if(is_array($exclude))
{
foreach($exclude as $val)
{
unset($this->tables[$val]);
}
}
$dtables = array_keys($this->tables);
foreach($dtables as $tb)
{
$this->compare($tb);
}
if(!empty($this->sqlLanguageTables)) // language tables.
{
foreach($this->sqlLanguageTables as $lng=>$lantab)
{
foreach($dtables as $tb)
{
$this->compare($tb,$lng);
}
}
}
}
function compare($selection,$language='')
{
if(empty($this->tables[$selection]['tables']))
{
return;
}
foreach($this->tables[$selection]['tables'] as $key=>$tbl)
{
//$this->errors[$tbl]['_status'] = 'ok'; // default table status
$rawSqlData = $this->getSqlData($tbl,$language);
if($rawSqlData === FALSE)
{
if($language) continue;
$this->errors[$tbl]['_status'] = 'missing_table';
$this->results[$tbl]['_file'] = $selection;
// echo "missing table: $tbl";
continue;
}
$sqlDataArr = $this->getTables($rawSqlData);
$fileFieldData = $this->getFields($this->tables[$selection]['data'][$key]);
$sqlFieldData = $this->getFields($sqlDataArr['data'][0]);
$fileIndexData = $this->getIndex($this->tables[$selection]['data'][$key]);
$sqlIndexData = $this->getIndex($sqlDataArr['data'][0]);
/*
$debugA = print_r($fileFieldData,TRUE); // Extracted Field Arrays
$debugA .= "Index
";
$debugA .= print_r($fileIndexData,TRUE);
$debugB = print_r($sqlFieldData,TRUE); // Extracted Field Arrays
$debugB .= "Index
";
$debugB .= print_r($sqlIndexData,TRUE);
*/
$debugA = $this->tables[$selection]['data'][$key]; // Extracted Raw Field Text
// $debugB = $rawSqlData;
$debugB = $sqlDataArr['data'][0]; // Extracted Raw Field Text
if(isset($debugA) && (e_PAGE == 'db.php'))
{
$debug = "
FILE: ".$tbl." (key=".$key.") |
SQL: ".$tbl." |
".$debugA." |
".$debugB." |
";
$mes = e107::getMessage();
$mes->add($debug,E_MESSAGE_DEBUG);
}
if($language)
{
$tbl = "lan_".$language."_".$tbl;
}
// Check Field Data.
foreach($fileFieldData as $field => $info )
{
$this->results[$tbl][$field]['_status'] = 'ok';
if(!is_array($sqlFieldData[$field]))
{
// echo "".$field."
".print_r($info,TRUE)." |
// - ".print_r($sqlFieldData[$field],TRUE)." |
";
$this->errors[$tbl]['_status'] = 'error'; // table status
$this->results[$tbl][$field]['_status'] = 'missing_field'; // field status
$this->results[$tbl][$field]['_valid'] = $info;
$this->results[$tbl][$field]['_file'] = $selection;
}
elseif(count($off = array_diff_assoc($info,$sqlFieldData[$field])))
{
$this->errors[$tbl]['_status'] = 'mismatch';
$this->results[$tbl][$field]['_status'] = 'mismatch';
$this->results[$tbl][$field]['_diff'] = $off;
$this->results[$tbl][$field]['_valid'] = $info;
$this->results[$tbl][$field]['_invalid'] = $sqlFieldData[$field];
$this->results[$tbl][$field]['_file'] = $selection;
}
}
// print_a($fileIndexData);
// print_a($sqlIndexData);
// Check Index data
foreach($fileIndexData as $field => $info )
{
if(!is_array($sqlIndexData[$field])) // missing index.
{
// print_a($info);
// print_a($sqlIndexData[$field]);
$this->errors[$tbl]['_status'] = 'error'; // table status
$this->indices[$tbl][$field]['_status'] = 'missing_index'; // index status
$this->indices[$tbl][$field]['_valid'] = $info;
$this->indices[$tbl][$field]['_file'] = $selection;
}
elseif(count($offin = array_diff_assoc($info,$sqlIndexData[$field]))) // missmatch data
{
// print_a($info);
// print_a($sqlIndexData[$field]);
$this->errors[$tbl]['_status'] = 'mismatch_index';
$this->indices[$tbl][$field]['_status'] = 'mismatch';
$this->indices[$tbl][$field]['_diff'] = $offin;
$this->indices[$tbl][$field]['_valid'] = $info;
$this->indices[$tbl][$field]['_invalid'] = $sqlIndexData[$field];
$this->indices[$tbl][$field]['_file'] = $selection;
}
// TODO Check for additional fields in SQL that should be removed.
// TODO Add support for MYSQL 5 table layout .eg. journal_id INT( 10 ) UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY ,
}
unset($data);
}
}
/**
* Compile Results into a complete list of Fixes that could be run without the need of a form selection.
*/
function compileResults()
{
foreach($this->results as $tabs => $field)
{
$file = varset($this->results[$tabs]['_file']);
if(varset($this->errors[$tabs]['_status']) == 'missing_table') // Missing Table
{
$this->fixList[$file][$tabs]['all'][] = 'create';
}
elseif($this->errors[$tabs] != 'ok') // All Other Issues..
{
foreach($field as $k=>$f)
{
if($f['_status']=='ok') continue;
$this->fixList[$f['_file']][$tabs][$k][] = $this->modes[$f['_status']];
}
}
}
// Index
if(count($this->indices))
{
foreach($this->indices as $tabs => $field)
{
if($this->errors[$tabs] != 'ok')
{
foreach($field as $k=>$f)
{
if($f['_status']=='ok') continue;
$this->fixList[$f['_file']][$tabs][$k][] = $this->modes[$f['_status']];
}
}
}
}
}
/**
* Returns the number of errors
*/
public function errors()
{
return count($this->errors);
}
function renderResults()
{
$frm = e107::getForm();
$ns = e107::getRender();
$mes = e107::getMessage();
$text = "
";
$ns->tablerender(DBVLAN_23.' - '.DBVLAN_16, $mes->render().$text);
}
function renderTableName($tabs)
{
if(substr($tabs,0,4)=="lan_")
{
list($tmp,$lang,$table) = explode("_",$tabs,3);
return $table. " (".ucfirst($lang).")";
}
return $tabs;
}
function fixForm($file,$table,$field, $newvalue,$mode,$after ='')
{
$frm = e107::getForm();
$text = $frm->checkbox("fix[$file][$table][$field][]", $mode, false, array('id'=>false));
return $text;
}
function renderNotes($data,$mode='field')
{
// return "".print_r($data,TRUE)."
";
$v = $data['_valid'];
$i = $data['_invalid'];
$valid = $this->toMysql($v,$mode);
$invalid = $this->toMysql($i,$mode);
$text = "";
if($invalid)
{
$text .= "".DBVLAN_9."
".$invalid."
";
}
$text .= "".DBVLAN_10."
".$valid."
";
return $text;
}
function toMysql($data,$mode = 'field')
{
if(!$data) return;
if($mode == 'index')
{
// print_a($data);
if($data['type'])
{
return $data['type']." (".$data['field'].");";
}
else
{
return "INDEX `".$data['keyname']."` (".$data['field'].");";
}
}
if(!in_array(strtolower($data['type']), $this->fieldTypes))
{
return $data['type']."(".$data['value'].") ".$data['attributes']." ".$data['null']." ".$data['default'];
}
else
{
return $data['type']." ".$data['attributes']." ".$data['null']." ".$data['default'];
}
}
// returns the previous Field
function getPrevious($array,$cur)
{
$fkeys = array_keys($array);
foreach($fkeys as $fields)
{
if($fields == $cur)
{
$current = prev($fkeys); // required.
$previous = prev($fkeys);
return $previous;
}
}
}
/**
* get the key ID for the current table which is being Fixed.
*/
function getId($tabl,$cur)
{
$key = array_flip($tabl);
if(substr($cur,0,4)=="lan_") // language table adjustment.
{
list($tmp,$lang,$cur) = explode("_",$cur,3);
}
if(isset($key[$cur]))
{
return $key[$cur];
}
}
/**
* Fix tables
* FixArray eg. [core][table][field] = alter|create|index| etc.
*/
function runFix($fixArray='')
{
$mes = e107::getMessage();
$log = e107::getAdminLog();
if(!is_array($fixArray))
{
$fixArray = $this->fixList; // Fix All
}
foreach($fixArray as $j=>$file)
{
foreach($file as $table=>$val)
{
$id = $this->getId($this->tables[$j]['tables'],$table);
foreach($val as $field=>$fixes)
{
foreach($fixes as $mode)
{
if(substr($mode,0,5)== 'index')
{
$fdata = $this->getIndex($this->tables[$j]['data'][$id]);
$newval = $this->toMysql($fdata[$field],'index');
}
else
{
$fdata = $this->getFields($this->tables[$j]['data'][$id]);
$newval = $this->toMysql($fdata[$field]);
}
switch($mode)
{
case 'alter':
$query = "ALTER TABLE `".MPREFIX.$table."` CHANGE `$field` `$field` $newval";
break;
case 'insert':
$after = ($aft = $this->getPrevious($fdata,$field)) ? " AFTER {$aft}" : "";
$query = "ALTER TABLE `".MPREFIX.$table."` ADD `$field` $newval{$after}";
break;
case 'drop':
$query = "ALTER TABLE `".MPREFIX.$table."` DROP `$field` ";
break;
case 'index':
$query = "ALTER TABLE `".MPREFIX.$table."` ADD $newval ";
break;
case 'indexdrop':
$query = "ALTER TABLE `".MPREFIX.$table."` DROP INDEX `$field`";
break;
case 'create':
$query = "CREATE TABLE `".MPREFIX.$table."` (".$this->tables[$j]['data'][$id].") ENGINE=MyISAM;";
break;
}
// $mes->addDebug("Query: ".$query);
// continue;
if(mysql_query($query))
{
$log->addDebug(LAN_UPDATED.' ['.$query.']');
}
else
{
$log->addWarning(LAN_UPDATED_FAILED.' ['.$query.']');
if(mysql_errno())
{
$log->addWarning('SQL #'.mysql_errno().': '.mysql_error());
}
}
}
}
} //
}
$log->flushMessages();
}
function getTables($sql_data)
{
if(!$sql_data)
{
return;
}
$ret = array();
$sql_data = preg_replace("#\/\*.*?\*\/#mis", '', $sql_data); // remove comments
// $regex = "/CREATE TABLE `?([\w]*)`?\s*?\(([\s\w\+\-_\(\),'\. `]*)\)\s*(ENGINE|TYPE)\s*?=\s?([\w]*)[\w =]*;/i";
$regex = "/CREATE TABLE (?:IF NOT EXISTS )?`?([\w]*)`?\s*?\(([\s\w\+\-_\(\),'\. `]*)\)\s*(ENGINE|TYPE)\s*?=\s?([\w]*)[\w =]*;/i";
$table = preg_match_all($regex,$sql_data,$match);
$tables = array();
foreach($match[1] as $c=>$k)
{
if(substr($k,0, 5) == 'e107_') // remove prefix if found in sql dump.
{
$k = substr($k, 5);
}
$tables[$c] = $k;
}
$ret['tables'] = $tables;
$ret['data'] = $match[2];
return $ret;
}
function getFields($data, $print = false)
{
// Clean $data and add ` ` arond field-names - prevents issues when field == field-type.
$tmp = explode("\n",$data);
$newline = array();
foreach($tmp as $line)
{
$line = trim($line);
$newline[] = preg_replace("/^([^`A-Z\s][a-z_]*)/","`$1`", $line);
}
$data = implode("\n",$newline);
// --------------------
$mes = e107::getMessage();
// $regex = "/`?([\w]*)`?\s*?(".implode("|",$this->fieldTypes)."|".implode("|",$this->fieldTypeNum).")\s?(?:\([\s]?([0-9,]*)[\s]?\))?[\s]?(unsigned)?[\s]?.*?(?:(NOT NULL|NULL))?[\s]*(auto_increment|default .*)?[\s]?(?:PRIMARY KEY)?[\s]*?,?\s*?\n/im";
$regex = "/^\s*?`?([\w]*)`?\s*?(".implode("|",$this->fieldTypes)."|".implode("|",$this->fieldTypeNum).")\s?(?:\([\s]?([0-9,]*)[\s]?\))?[\s]?(unsigned)?[\s]?.*?(?:(NOT NULL|NULL))?[\s]*(auto_increment|default [\w'.-]*)?[\s]?(comment [\w\s'.-]*)?[\s]?(?:PRIMARY KEY)?[\s]*?,?\s*?\n/im";
// echo $regex."
";
// $regex = "/`?([\w]*)`?\s*(int|varchar|tinyint|smallint|text|char|tinyint) ?(?:\([\s]?([0-9]*)[\s]?\))?[\s]?(unsigned)?[\s]?.*?(NOT NULL|NULL)?[\s]*(auto_increment|default .*)?[\s]?,/i";
// $regex = "/^\s*?`?([\w]*)`?\s*?(".implode("|",$this->fieldTypes)."|".implode("|",$this->fieldTypeNum).")\s?(?:\([\s]?([0-9,]*)[\s]?\))?[\s]?(unsigned)?[\s]?.*?(?:(NOT NULL|NULL))?[\s]*?(auto_increment|default [\w'\".-]*)?[\s]?(?:PRIMARY KEY)?[\s]*?,?\n/im";
//$regex = "/^\s*?`?([\w]*)`?\s*?(date|time|timestamp|datetime|year|tinyblob|blob|mediumblob|longblob|tinytext|mediumtext|longtext|text|bit|tinyint|smallint|mediumint|integer|int|bigint|real|double|float|decimal|numeric|varchar|char|binary|varbinary|enum|set)\s?(?:\([\s]?([0-9,]*)[\s]?\))?[\s]?(unsigned)?[\s]*?(?:(NOT NULL|NULL))?[\s]*?(auto_increment|default [\w'\".-]*)?[\s]?(?:PRIMARY KEY)?[\s]*?,?\n/im";
// $mes->addDebug($regex);
//$regex = "/^\s*?`?([\w]*)`?\s*?(date|time|timestamp|datetime|year|text|bit|tinyint|smallint|mediumint|integer|int|bigint|real|double|float|decimal|numeric|varchar|char|binary|varbinary|enum|set)\s?(?:\([\s]?([0-9,]*)[\s]?\))?[\s]?(unsigned)?[\s]*?(?:(NOT NULL|NULL))?[\s]*?(auto_increment|default [\w'.-]*)?[\s]?(?:PRIMARY KEY)?[\s]*?,?\n/i";
// echo "reg=".$regex;
preg_match_all($regex,$data,$m);
$ret = array();
if($print) var_dump($regex, $m);
foreach($m[1] as $k=>$val)
{
$ret[$val] = array(
'type' => trim(strtoupper($m[2][$k])),
'value' => $m[3][$k],
'attributes' => strtoupper($m[4][$k]),
'null' => strtoupper($m[5][$k]),
'default' => strtoupper($m[6][$k])
);
}
return $ret;
}
function getIndex($data, $print = false)
{
// $regex = "/(?:(PRIMARY|UNIQUE|FULLTEXT))?[\s]*?KEY (?: ?`?([\w]*)`?)[\s]* ?(?:\([\s]?`?([\w,]*[\s]?)`?\))?,?/i";
$regex = "/(?:(PRIMARY|UNIQUE|FULLTEXT))?[\s]*?KEY (?: ?`?([\w]*)`?)[\s]* ?(?:\([\s]?([\w\s,`]*[\s]?)`?\))?,?/i";
preg_match_all($regex,$data,$m);
$ret = array();
if($print) var_dump($regex, $m);
// Standard Detection Method.
foreach($m[3] as $k=>$val)
{
if(!$val) continue;
$val = str_replace("`","",$val);
$ret[$val] = array(
'type' => strtoupper($m[1][$k]),
'keyname' => (vartrue($m[2][$k])) ? str_replace("`","",$m[2][$k]) : str_replace("`","",$m[3][$k]),
'field' => str_replace("`","",$m[3][$k])
);
}
//Alternate Index detection method.
// eg. `table_id` INT( 10 ) UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY ,
$regex = "/`?([\w]*)`? .*((?:AUTO_INCREMENT))\s?(PRIMARY|UNIQUE|FULLTEXT)\s?KEY\s?,/i";
preg_match_all($regex,$data,$m);
foreach($m[1] as $k=>$val)
{
if(!$val) continue;
$ret[$val] = array(
'type' => strtoupper($m[3][$k]),
'keyname' => $m[1][$k],
'field' => str_replace("`","",$m[1][$k])
);
}
return $ret;
}
function getSqlData($tbl,$language='')
{
$mes = e107::getMessage();
$prefix = MPREFIX;
if($language)
{
if(!in_array($tbl,$this->sqlLanguageTables[$language]))
{
return FALSE;
}
$prefix .= "lan_".$language."_";
// $mes->addDebug("Retrieving Language Table Data: ".$prefix . $tbl."
");
}
$sql = e107::getDb();
$sql->gen('SET SQL_QUOTE_SHOW_CREATE = 1');
// mysql_query('SET SQL_QUOTE_SHOW_CREATE = 1');
$qry = 'SHOW CREATE TABLE `' . $prefix . $tbl . "`";
// $z = mysql_query($qry);
$z = $sql->gen($qry);
if($z)
{
// $row = mysql_fetch_row($z);
$row = $sql->fetch(MYSQL_NUM);
//return $row[1];
return stripslashes($row[1]).';'; // backticks needed.
// return str_replace("`", "", stripslashes($row[1])).';';
}
else
{
$mes->addDebug('Failed: '.$qry);
return FALSE;
}
}
function getSqlLanguages()
{
$sql = e107::getDb();
$list = $sql->db_TableList('lan');
$array = array();
foreach($list as $tb)
{
list($tmp,$lang,$table) = explode("_",$tb,3);
$array[$lang][] = $table;
}
return $array;
}
function renderTableSelect()
{
$frm = e107::getForm();
$ns = e107::getRender();
$mes = e107::getMessage();
$text = "
";
$ns->tablerender(DBVLAN_23.' - '.DBVLAN_16, $mes->render().$text);
}
}
/*
function check_tables($what)
{
global $tablines, $table_list, $frm, $emessage;
$cur = 0;
$table_list = "";
read_tables($what);
$fix_active = FALSE; // Flag set as soon as there's a fix - enables 'Fix it' button
$text = "
";
return $text;
}
global $table_list;
// -------------------- Table Fixing ------------------------------
if(isset($_POST['do_fix']))
{
//$emessage->add(DBVLAN_20);
foreach( $_POST['fix_active'] as $key=>$val)
{
if (MAGIC_QUOTES_GPC == TRUE)
{
$table = stripslashes($_POST['fix_table'][$key][0]);
$newval = stripslashes($_POST['fix_newval'][$key][0]);
$mode = stripslashes($_POST['fix_mode'][$key][0]);
$after = stripslashes($_POST['fix_after'][$key][0]);
}
else
{
$table = $_POST['fix_table'][$key][0];
$newval = $_POST['fix_newval'][$key][0];
$mode = $_POST['fix_mode'][$key][0];
$after = $_POST['fix_after'][$key][0];
}
$field= $key;
switch($mode)
{
case 'alter':
$query = "ALTER TABLE `".MPREFIX.$table."` CHANGE `$field` `$field` $newval";
break;
case 'insert':
if($after) $after = " AFTER {$after}";
$query = "ALTER TABLE `".MPREFIX.$table."` ADD `$field` $newval{$after}";
break;
case 'drop':
$query = "ALTER TABLE `".MPREFIX.$table."` DROP `$field` ";
break;
case 'index':
$query = "ALTER TABLE `".MPREFIX.$table."` ADD INDEX `$field` ($newval)";
break;
case 'indexalt':
$query = "ALTER TABLE `".MPREFIX.$table."` ADD $field ($newval)";
break;
case 'indexdrop':
$query = "ALTER TABLE `".MPREFIX.$table."` DROP INDEX `$field`";
break;
case 'create':
$query = "CREATE TABLE `".MPREFIX.$table."` ({$newval}";
if (!preg_match('#.*?\s+?(?:TYPE|ENGINE)\s*\=\s*(.*?);#is', $newval))
{
$query .= ') TYPE=MyISAM;';
}
break;
}
return $query;
//FIXME - db handler!!!
if(mysql_query($query)) $emessage->add(LAN_UPDATED.' [ '.$query.' ]', E_MESSAGE_SUCCESS);
else
{
$emessage->add(LAN_UPDATED_FAILED.' [ '.$query.' ]', E_MESSAGE_WARNING);
if(mysql_errno())
{
$emessage->add(' SQL #'.mysql_errno().': '.mysql_error(), E_MESSAGE_WARNING);
}
}
}
}
$text = "
";
$e107->ns->tablerender(DBVLAN_23.' - '.DBVLAN_16, $emessage->render().$text);
require_once(e_ADMIN."footer.php");
exit;
// --------------------------------------------------------------
function fix_form($table,$field, $newvalue,$mode,$after ='')
{
global $frm;
if($mode == 'create')
{
$newvalue = implode("\n",$newvalue);
$field = $table; // Value for $field may be rubbish!
}
else
{
if(stristr($field, 'KEY ') !== FALSE)
{
$field = chop(str_replace('KEY ','',$field));
$mode = ($mode == 'drop') ? 'indexdrop' : 'index';
$search = array('(', ')');
$newvalue = str_replace($search,'',$newvalue);
$after = '';
}
if($mode == 'index' && (stristr($field, 'FULLTEXT ') !== FALSE || stristr($field, 'UNIQUE ') !== FALSE))
{
$mode = 'indexalt';
}
elseif($mode == 'indexdrop' && (stristr($field, 'FULLTEXT ') !== FALSE || stristr($field, 'UNIQUE ') !== FALSE))
{
$field = trim(str_replace(array('FULLTEXT ', 'UNIQUE '), '', $field));
}
$field = trim($field, '`');
}
$text .= "\n\n";
$text .= $frm->checkbox("fix_active[$field][]", 1, false, array('id'=>false));
$text .= "\n";
$text .= "\n";
$text .= "\n";
$text .= ($after) ? "\n" : "";
$text .= "\n\n";
return $text;
}
function table_list()
{
// grab default language lists.
global $mySQLdefaultdb;
$exclude[] = "banlist"; $exclude[] = "banner";
$exclude[] = "cache"; $exclude[] = "core";
$exclude[] = "online"; $exclude[] = "parser";
$exclude[] = "plugin"; $exclude[] = "user";
$exclude[] = "upload"; $exclude[] = "userclass_classes";
$exclude[] = "rbinary"; $exclude[] = "session";
$exclude[] = "tmp"; $exclude[] = "flood";
$exclude[] = "stat_info"; $exclude[] = "stat_last";
$exclude[] = "submit_news"; $exclude[] = "rate";
$exclude[] = "stat_counter";$exclude[] = "user_extended";
$exclude[] = "user_extended_struct";
$exclude[] = "pm_messages";
$exclude[] = "pm_blocks";
$replace = array();
$lanlist = explode(",",e_LANLIST);
foreach($lanlist as $lang)
{
if($lang != $pref['sitelanguage'])
{
$replace[] = "lan_".strtolower($lang)."_";
}
}
$tables = mysql_list_tables($mySQLdefaultdb);
while (list($temp) = mysql_fetch_array($tables))
{
$prefix = MPREFIX."lan_";
$match = array();
if(strpos($temp,$prefix)!==FALSE)
{
$e107tab = str_replace(MPREFIX, "", $temp);
$core = str_replace($replace,"",$e107tab);
if (str_replace($exclude, "", $e107tab))
{
$tabs[$core] = $e107tab;
}
}
}
return $tabs;
}
*/
?>