tablerender(LAN_SAVED, "
".LAN_SETSAVED."
");
}
// ----------------- delete tables ---------------------------------------------
if (isset($_POST['del_existing']) && $_POST['lang_choices']) {
$lang = strtolower($_POST['lang_choices']);
foreach ($tabs as $del_table) {
if (db_Table_exists($lang."_".$del_table)) {
$qry = "DROP TABLE ".$mySQLprefix."lan_".$lang."_".$del_table;
echo $qry;
$message .= (mysql_query($qry)) ? $_POST['lang_choices']." ".$del_table." deleted
" :
$_POST['lang_choices']." $del_table couldn't be deleted
";
}
}
global $cachevar;
unset($cachevar['table_list']);
}
// ----------create tables -----------------------------------------------------
if (isset($_POST['create_tables']) && $_POST['language']) {
$table_to_copy = array();
$lang_to_create = array();
foreach ($tabs as $value) {
$lang = strtolower($_POST['language']);
if (isset($_POST[$value])) {
$copdata = ($_POST['copydata_'.$value]) ? 1 : 0;
if (copy_table($value, "lan_".$lang."_".$value, $_POST['drop'],$copdata)) {
$message .= " ".$_POST['language']." ".$value." created
";
} else {
$message .= (!$_POST['drop'])? " ".$_POST['language']." ".$value." ".LANG_LAN_00."
" : $_POST['language']." ".$value." ".LANG_LAN_01."
";
}
} elseif(db_Table_exists($lang."_".$value)) {
if ($_POST['remove']) {
// Remove table.
$message .= (mysql_query("DROP TABLE ".$mySQLprefix."lan_".$lang."_".$value)) ? $_POST['language']." ".$value." ".LAN_DELETED."
" : $_POST['language']." $value ".LANG_LAN_02."
";
} else {
// leave table.
$message = $_POST['language']." ".$value." was disabled but left intact.";
}
}
}
global $cachevar;
unset($cachevar['table_list']);
}
if(isset($message) && $message){
$ns->tablerender(LAN_OK, $message);
}
// ------------- render form ---------------------------------------------------
if(isset($pref['multilanguage']) && $pref['multilanguage']){
$caption = LANG_LAN_16; // language
$text = MLAD_LAN_4."
";
// Choose Language to Edit:
$text = "
".ADLAN_132." |
".LANG_LAN_03." |
".LAN_OPTIONS." |
\n\n";
sort($lanlist);
for($i = 0; $i < count($lanlist); $i++) {
$installed = 0;
$text .= "
";
}
$text .= "
";
$ns->tablerender($caption, $text);
}
if (!$_POST['language'] && !$_POST['edit_existing']) {
multilang_prefs();
}
unset($text);
// Grab Language configuration. ---
if ($_POST['edit_existing']) {
$text = $rs->form_open("post", e_SELF);
$text .= "";
$text .= "
\n";
foreach ($tabs as $table_name) {
$installed = strtolower($_POST['lang_choices'])."_".$table_name;
if (stristr($_POST['lang_choices'], $installed) === FALSE) {
$text .= "
\n
\n";
}
}
$text .= "
";
// ===========================================================================
// Drop tables ?
$text .= "
\n
\n";
$text .= $rs->form_close();
$ns->tablerender($_POST['lang_choices'], $text);
}
require_once(e_ADMIN."footer.php");
// ---------------------------------------------------------------------------
function multilang_prefs() {
global $ns, $pref,$lanlist;
$text = "";
$caption = LANG_LAN_13; // "Language Preferences";
$ns->tablerender($caption, $text);
}
// ----------------------------------------------------------------------------
function db_Table_exists($table)
{
global $mySQLdefaultdb;
$tables = getcachedvars("table_list");
if(!$tables)
{
$tablist = mysql_list_tables($mySQLdefaultdb);
while($tmp = mysql_fetch_array($tablist))
{
$tables[] = $tmp[0];
}
cachevars("table_list", $tables);
}
return in_array(strtolower(MPREFIX."lan_".$table), $tables);
}
// ----------------------------------------------------------------------------
function copy_table($oldtable, $newtable, $drop = FALSE, $data = FALSE)
{
global $sql;
$old = MPREFIX.strtolower($oldtable);
$new = MPREFIX.strtolower($newtable);
if($drop)
{
$sql->db_Select_gen("DROP TABLE IF EXISTS {$new}");
}
//Get $old table structure
$sql->db_Select_gen('SET SQL_QUOTE_SHOW_CREATE = 1');
$qry = "SHOW CREATE TABLE {$old}";
if($sql->db_Select_gen($qry))
{
$row = $sql->db_Fetch();
$qry = $row[1];
$qry = str_replace($old, $new, $qry);
}
$result = mysql_query($qry);
if(!$result)
{
return FALSE;
}
if ($data) //We need to copy the data too
{
$qry = "INSERT INTO {$new} SELECT * FROM {$old}";
$sql->db_Select_gen($qry);
}
return TRUE;
}
// ----------------------------------------------------------------------------
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_struc";
$exclude[] = "pm_messages";
$exclude[] = "pm_blocks";
$tables = mysql_list_tables($mySQLdefaultdb);
while (list($temp) = mysql_fetch_array($tables))
{
if(strpos($temp, MPREFIX) === 0)
{
$e107tab = str_replace(MPREFIX, "", $temp);
if (!in_array($e107tab, $exclude) && stristr($e107tab, "lan_") === FALSE)
{
$tabs[] = $e107tab;
}
}
}
return $tabs;
}
// ----------------------------------------------------------------------------
?>