mirror of
https://github.com/e107inc/e107.git
synced 2025-07-16 20:41:27 +02:00
Upgrade from 0.7.x to 0.8 now leaves a clean error-free table-structure.
This commit is contained in:
@@ -278,27 +278,32 @@ function update_706_to_800($type='')
|
|||||||
|
|
||||||
|
|
||||||
// List of DB tables newly required (defined in core_sql.php) (The existing dblog table gets renamed)
|
// List of DB tables newly required (defined in core_sql.php) (The existing dblog table gets renamed)
|
||||||
$new_tables = array('admin_log', 'audit_log', 'dblog', 'news_rewrite', 'core_media', 'mail_recipients', 'mail_content');
|
// No Longer required. - automatically checked against core_sql.php.
|
||||||
|
// $new_tables = array('audit_log', 'dblog', 'news_rewrite', 'core_media', 'core_media_cat','cron', 'mail_recipients', 'mail_content');
|
||||||
|
|
||||||
// List of core prefs that need to be converted from serialized to e107ArrayStorage.
|
// List of core prefs that need to be converted from serialized to e107ArrayStorage.
|
||||||
$serialized_prefs = array("'emote'", "'menu_pref'", "'search_prefs'", "'emote_default'");
|
$serialized_prefs = array("'emote'", "'menu_pref'", "'search_prefs'", "'emote_default'");
|
||||||
|
|
||||||
|
|
||||||
// List of changed DB tables (defined in core_sql.php)
|
// List of changed DB tables (defined in core_sql.php)
|
||||||
|
// No Longer required. - automatically checked against core_sql.php.
|
||||||
// (primarily those which have changed significantly; for the odd field write some explicit code - it'll run faster)
|
// (primarily those which have changed significantly; for the odd field write some explicit code - it'll run faster)
|
||||||
$changed_tables = array('user', 'dblog', 'admin_log', 'userclass_classes', 'banlist', 'menus',
|
// $changed_tables = array('user', 'dblog', 'admin_log', 'userclass_classes', 'banlist', 'menus',
|
||||||
'plugin', 'news', 'news_category', 'online', 'page', 'links', 'comments');
|
// 'plugin', 'news', 'news_category', 'online', 'page', 'links', 'comments');
|
||||||
|
|
||||||
|
|
||||||
// List of changed DB tables from core plugins (defined in pluginname_sql.php file)
|
// List of changed DB tables from core plugins (defined in pluginname_sql.php file)
|
||||||
// key = plugin directory name. Data = comma-separated list of tables to check
|
// key = plugin directory name. Data = comma-separated list of tables to check
|
||||||
// (primarily those which have changed significantly; for the odd field write some explicit code - it'll run faster)
|
// (primarily those which have changed significantly; for the odd field write some explicit code - it'll run faster)
|
||||||
$pluginChangedTables = array('linkwords' => 'linkwords',
|
// No Longer required. - automatically checked by db-verify
|
||||||
|
/* $pluginChangedTables = array('linkwords' => 'linkwords',
|
||||||
'featurebox' => 'featurebox',
|
'featurebox' => 'featurebox',
|
||||||
'links_page' => 'links_page',
|
'links_page' => 'links_page',
|
||||||
'poll' => 'polls',
|
'poll' => 'polls',
|
||||||
'content' => 'pcontent'
|
'content' => 'pcontent'
|
||||||
);
|
);
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
$setCorePrefs = array( //modified prefs during upgrade.
|
$setCorePrefs = array( //modified prefs during upgrade.
|
||||||
'adminstyle' => 'infopanel',
|
'adminstyle' => 'infopanel',
|
||||||
@@ -337,9 +342,9 @@ function update_706_to_800($type='')
|
|||||||
|
|
||||||
// List of DB tables (key) and field (value) which need changing to accommodate IPV6 addresses
|
// List of DB tables (key) and field (value) which need changing to accommodate IPV6 addresses
|
||||||
$ip_upgrade = array('download_requests' => 'download_request_ip',
|
$ip_upgrade = array('download_requests' => 'download_request_ip',
|
||||||
'submitnews' => 'submitnews_ip',
|
'submitnews' => 'submitnews_ip',
|
||||||
'tmp' => 'tmp_ip',
|
'tmp' => 'tmp_ip',
|
||||||
'chatbox' => 'cb_ip'
|
'chatbox' => 'cb_ip'
|
||||||
);
|
);
|
||||||
|
|
||||||
$db_parser = new db_table_admin; // Class to read table defs and process them
|
$db_parser = new db_table_admin; // Class to read table defs and process them
|
||||||
@@ -573,31 +578,34 @@ function update_706_to_800($type='')
|
|||||||
|
|
||||||
|
|
||||||
// Add index to download history
|
// Add index to download history
|
||||||
if (FALSE !== ($temp = addIndexToTable('download_requests', 'download_request_datestamp', $just_check, $updateMessages)))
|
// Deprecated by db-verify-class
|
||||||
{
|
// if (FALSE !== ($temp = addIndexToTable('download_requests', 'download_request_datestamp', $just_check, $updateMessages)))
|
||||||
if ($just_check)
|
// {
|
||||||
{
|
// if ($just_check)
|
||||||
return update_needed($temp);
|
// {
|
||||||
}
|
// return update_needed($temp);
|
||||||
}
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
// Extra index to tmp table
|
// Extra index to tmp table
|
||||||
if (FALSE !== ($temp = addIndexToTable('tmp', 'tmp_time', $just_check, $updateMessages)))
|
// Deprecated by db-verify-class
|
||||||
{
|
// if (FALSE !== ($temp = addIndexToTable('tmp', 'tmp_time', $just_check, $updateMessages)))
|
||||||
if ($just_check)
|
// {
|
||||||
{
|
// if ($just_check)
|
||||||
return update_needed($temp);
|
// {
|
||||||
}
|
// return update_needed($temp);
|
||||||
}
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
// Extra index to rss table (if used)
|
// Extra index to rss table (if used)
|
||||||
if (FALSE !== ($temp = addIndexToTable('rss', 'rss_name', $just_check, $updateMessages, TRUE)))
|
// Deprecated by db-verify-class
|
||||||
{
|
// if (FALSE !== ($temp = addIndexToTable('rss', 'rss_name', $just_check, $updateMessages, TRUE)))
|
||||||
if ($just_check)
|
// {
|
||||||
{
|
// if ($just_check)
|
||||||
return update_needed($temp);
|
// {
|
||||||
}
|
// return update_needed($temp);
|
||||||
}
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
// Front page prefs (logic has changed)
|
// Front page prefs (logic has changed)
|
||||||
if (!isset($pref['frontpage_force']))
|
if (!isset($pref['frontpage_force']))
|
||||||
@@ -610,7 +618,10 @@ function update_706_to_800($type='')
|
|||||||
$do_save = TRUE;
|
$do_save = TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Deprecated by db-verify-class
|
||||||
|
*
|
||||||
|
|
||||||
if ($sql->db_Table_exists('newsfeed'))
|
if ($sql->db_Table_exists('newsfeed'))
|
||||||
{ // Need to extend field newsfeed_url varchar(250) NOT NULL default ''
|
{ // Need to extend field newsfeed_url varchar(250) NOT NULL default ''
|
||||||
if ($sql->db_Query("SHOW FIELDS FROM ".MPREFIX."newsfeed LIKE 'newsfeed_url'"))
|
if ($sql->db_Query("SHOW FIELDS FROM ".MPREFIX."newsfeed LIKE 'newsfeed_url'"))
|
||||||
@@ -627,7 +638,6 @@ function update_706_to_800($type='')
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//TODO use generic function for this update.
|
//TODO use generic function for this update.
|
||||||
if ($sql->db_Table_exists('download'))
|
if ($sql->db_Table_exists('download'))
|
||||||
{ // Need to extend field download_url varchar(255) NOT NULL default ''
|
{ // Need to extend field download_url varchar(255) NOT NULL default ''
|
||||||
@@ -662,7 +672,7 @@ function update_706_to_800($type='')
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
*/
|
||||||
// Check need for user timezone before we delete the field
|
// Check need for user timezone before we delete the field
|
||||||
if (varsettrue($pref['signup_option_timezone']))
|
if (varsettrue($pref['signup_option_timezone']))
|
||||||
{
|
{
|
||||||
@@ -681,7 +691,7 @@ function update_706_to_800($type='')
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Tables defined in core_sql.php
|
// Tables defined in core_sql.php to be RENAMED.
|
||||||
//---------------------------------
|
//---------------------------------
|
||||||
if ($sql->db_Table_exists('dblog') && !$sql->db_Table_exists('admin_log'))
|
if ($sql->db_Table_exists('dblog') && !$sql->db_Table_exists('admin_log'))
|
||||||
{
|
{
|
||||||
@@ -704,6 +714,8 @@ function update_706_to_800($type='')
|
|||||||
}
|
}
|
||||||
|
|
||||||
// New tables required (list at top. Definitions in core_sql.php)
|
// New tables required (list at top. Definitions in core_sql.php)
|
||||||
|
// ALL DEPRECATED by db_verify class.. see below.
|
||||||
|
/*
|
||||||
foreach ($new_tables as $nt)
|
foreach ($new_tables as $nt)
|
||||||
{
|
{
|
||||||
if (!$sql->db_Table_exists($nt))
|
if (!$sql->db_Table_exists($nt))
|
||||||
@@ -726,7 +738,8 @@ function update_706_to_800($type='')
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Tables whose definition needs changing significantly
|
// Tables whose definition needs changing significantly
|
||||||
$debugLevel = E107_DBG_SQLDETAILS;
|
$debugLevel = E107_DBG_SQLDETAILS;
|
||||||
|
|
||||||
@@ -843,16 +856,7 @@ function update_706_to_800($type='')
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// This has to be done after the table is upgraded
|
*/
|
||||||
if($sql->db_Select('plugin', 'plugin_category', "plugin_category = ''"))
|
|
||||||
{
|
|
||||||
if ($just_check) return update_needed('Update plugin table');
|
|
||||||
require_once(e_HANDLER.'plugin_class.php');
|
|
||||||
$ep = new e107plugin;
|
|
||||||
$ep -> update_plugins_table();
|
|
||||||
// $_pdateMessages[] = LAN_UPDATE_XX24;
|
|
||||||
// catch_error($sql);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// Obsolete tables (list at top)
|
// Obsolete tables (list at top)
|
||||||
@@ -933,7 +937,41 @@ function update_706_to_800($type='')
|
|||||||
$accum[] = $p;
|
$accum[] = $p;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* -------------- Upgrade Entire Table Structure - Multi-Language Supported ----------------- */
|
||||||
|
|
||||||
|
require_once(e_HANDLER."db_verify_class.php");
|
||||||
|
$dbv = new db_verify;
|
||||||
|
$dbv->compareAll(); // core & plugins
|
||||||
|
|
||||||
|
if(count($dbv->errors))
|
||||||
|
{
|
||||||
|
if ($just_check) return update_needed("Database Tables require updating.");
|
||||||
|
}
|
||||||
|
|
||||||
|
$dbv->compileResults();
|
||||||
|
// print_a($dbv->results);
|
||||||
|
// print_a($dbv->fixList);
|
||||||
|
$dbv->runFix(); // Fix entire core database structure.
|
||||||
|
|
||||||
|
//TODO - send notification messages to Log.
|
||||||
|
|
||||||
|
|
||||||
|
// ------------------- Populate Plugin Table With Changes ------------------
|
||||||
|
|
||||||
|
// This has to be done after the table is upgraded
|
||||||
|
if($sql->db_Select('plugin', 'plugin_category', "plugin_category = ''"))
|
||||||
|
{
|
||||||
|
if ($just_check) return update_needed('Update plugin table');
|
||||||
|
require_once(e_HANDLER.'plugin_class.php');
|
||||||
|
$ep = new e107plugin;
|
||||||
|
$ep -> update_plugins_table();
|
||||||
|
// $_pdateMessages[] = LAN_UPDATE_XX24;
|
||||||
|
// catch_error($sql);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//-- Media-manger import --------------------------------------------------
|
//-- Media-manger import --------------------------------------------------
|
||||||
|
|
||||||
@@ -1005,6 +1043,7 @@ function update_706_to_800($type='')
|
|||||||
return $just_check;
|
return $just_check;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* No Longed Used I think
|
||||||
function core_media_import($cat,$epath)
|
function core_media_import($cat,$epath)
|
||||||
{
|
{
|
||||||
if(!vartrue($cat)){ return;}
|
if(!vartrue($cat)){ return;}
|
||||||
@@ -1053,7 +1092,7 @@ function core_media_import($cat,$epath)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
function update_70x_to_706($type='')
|
function update_70x_to_706($type='')
|
||||||
{
|
{
|
||||||
|
@@ -25,6 +25,9 @@
|
|||||||
Note: there are some uncommented 'echo' statements which are intentional to highlight that something's gone wrong! (not that it should, of course)
|
Note: there are some uncommented 'echo' statements which are intentional to highlight that something's gone wrong! (not that it should, of course)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
// DEPRECATED - USE db_verify_class where possible.
|
||||||
|
|
||||||
class db_table_admin
|
class db_table_admin
|
||||||
{
|
{
|
||||||
var $file_buffer = ''; // Contents of a file
|
var $file_buffer = ''; // Contents of a file
|
||||||
|
@@ -27,6 +27,7 @@ class db_verify
|
|||||||
var $sqlLanguageTables = array();
|
var $sqlLanguageTables = array();
|
||||||
var $results = array();
|
var $results = array();
|
||||||
var $indices = array(); // array(0) - Issue?
|
var $indices = array(); // array(0) - Issue?
|
||||||
|
var $fixList = array();
|
||||||
|
|
||||||
var $fieldTypes = array('time','timestamp','datetime','year','tinyblob','blob',
|
var $fieldTypes = array('time','timestamp','datetime','year','tinyblob','blob',
|
||||||
'mediumblob','longblob','tinytext','mediumtext','longtext','text','date');
|
'mediumblob','longblob','tinytext','mediumtext','longtext','text','date');
|
||||||
@@ -34,6 +35,14 @@ class db_verify
|
|||||||
var $fieldTypeNum = array('bit','tinyint','smallint','mediumint','integer','int','bigint',
|
var $fieldTypeNum = array('bit','tinyint','smallint','mediumint','integer','int','bigint',
|
||||||
'real','double','float','decimal','numeric','varchar','char','binary','varbinary','enum','set');
|
'real','double','float','decimal','numeric','varchar','char','binary','varbinary','enum','set');
|
||||||
|
|
||||||
|
var $modes = array(
|
||||||
|
'missing_table' => 'create',
|
||||||
|
'mismatch' => 'alter',
|
||||||
|
'missing_field' => 'insert',
|
||||||
|
'missing_index' => 'index',
|
||||||
|
'mismatch_index' => '', // TODO
|
||||||
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Setup
|
* Setup
|
||||||
*/
|
*/
|
||||||
@@ -88,7 +97,7 @@ class db_verify
|
|||||||
{
|
{
|
||||||
if(isset($_POST['runfix']))
|
if(isset($_POST['runfix']))
|
||||||
{
|
{
|
||||||
$this->runFix();
|
$this->runFix($_POST['fix']);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -141,6 +150,30 @@ class db_verify
|
|||||||
// print_a($match[2]);
|
// print_a($match[2]);
|
||||||
// echo "<pre>".$sql_data."</pre>";
|
// echo "<pre>".$sql_data."</pre>";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check core tables and installed plugin tables
|
||||||
|
*/
|
||||||
|
function compareAll()
|
||||||
|
{
|
||||||
|
$dtables = array_keys($this->tables);
|
||||||
|
|
||||||
|
foreach($dtables as $tb)
|
||||||
|
{
|
||||||
|
$this->compare($tb);
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach($this->sqlLanguageTables as $lng=>$lantab) // language tables.
|
||||||
|
{
|
||||||
|
foreach($dtables as $tb)
|
||||||
|
{
|
||||||
|
$this->compare($tb,$lng);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function compare($selection,$language='')
|
function compare($selection,$language='')
|
||||||
{
|
{
|
||||||
@@ -273,7 +306,47 @@ class db_verify
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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 = $this->results[$tabs]['_file'];
|
||||||
|
if($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']];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -317,13 +390,6 @@ class db_verify
|
|||||||
'missing_index' => DBVLAN_25,
|
'missing_index' => DBVLAN_25,
|
||||||
);
|
);
|
||||||
|
|
||||||
$modes = array(
|
|
||||||
'missing_table' => 'create',
|
|
||||||
'mismatch' => 'alter',
|
|
||||||
'missing_field' => 'insert',
|
|
||||||
'missing_index' => 'index',
|
|
||||||
'mismatch_index' => '', // TODO
|
|
||||||
);
|
|
||||||
|
|
||||||
foreach($this->results as $tabs => $field)
|
foreach($this->results as $tabs => $field)
|
||||||
{
|
{
|
||||||
@@ -354,7 +420,7 @@ class db_verify
|
|||||||
<td>".$k." </td>
|
<td>".$k." </td>
|
||||||
<td class='center middle error'>".$fstat."</td>
|
<td class='center middle error'>".$fstat."</td>
|
||||||
<td>".$this->renderNotes($f)." </td>
|
<td>".$this->renderNotes($f)." </td>
|
||||||
<td class='center middle autocheck e-pointer'>".$this->fixForm($f['_file'],$tabs, $k, $f['_valid'], $modes[$f['_status']]) . "</td>
|
<td class='center middle autocheck e-pointer'>".$this->fixForm($f['_file'],$tabs, $k, $f['_valid'], $this->modes[$f['_status']]) . "</td>
|
||||||
</tr>
|
</tr>
|
||||||
";
|
";
|
||||||
}
|
}
|
||||||
@@ -385,7 +451,7 @@ class db_verify
|
|||||||
<td>".$k." </td>
|
<td>".$k." </td>
|
||||||
<td class='center middle error'>".$fstat."</td>
|
<td class='center middle error'>".$fstat."</td>
|
||||||
<td>".$this->renderNotes($f,'index')." </td>
|
<td>".$this->renderNotes($f,'index')." </td>
|
||||||
<td class='center middle autocheck e-pointer'>".$this->fixForm($f['_file'],$tabs, $k, $f['_valid'], $modes[$f['_status']]) . "</td>
|
<td class='center middle autocheck e-pointer'>".$this->fixForm($f['_file'],$tabs, $k, $f['_valid'], $this->modes[$f['_status']]) . "</td>
|
||||||
</tr>
|
</tr>
|
||||||
";
|
";
|
||||||
}
|
}
|
||||||
@@ -431,7 +497,7 @@ class db_verify
|
|||||||
function fixForm($file,$table,$field, $newvalue,$mode,$after ='')
|
function fixForm($file,$table,$field, $newvalue,$mode,$after ='')
|
||||||
{
|
{
|
||||||
$frm = e107::getForm();
|
$frm = e107::getForm();
|
||||||
$text .= $frm->checkbox("fix[$file][$table][$field]", $mode, false, array('id'=>false));
|
$text .= $frm->checkbox("fix[$file][$table][$field][]", $mode, false, array('id'=>false));
|
||||||
|
|
||||||
return $text;
|
return $text;
|
||||||
}
|
}
|
||||||
@@ -530,16 +596,19 @@ class db_verify
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Fix tables
|
* Fix tables
|
||||||
|
* FixArray eg. [core][table][field] = alter|create|index| etc.
|
||||||
*/
|
*/
|
||||||
function runFix()
|
function runFix($fixArray='')
|
||||||
{
|
{
|
||||||
$mes = e107::getMessage();
|
$mes = e107::getMessage();
|
||||||
|
|
||||||
|
if(!is_array($fixArray))
|
||||||
|
{
|
||||||
|
$fixArray = $this->fixList; // Fix All
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
foreach($_POST['fix'] as $j=>$file)
|
foreach($fixArray as $j=>$file)
|
||||||
{
|
{
|
||||||
|
|
||||||
foreach($file as $table=>$val)
|
foreach($file as $table=>$val)
|
||||||
@@ -547,65 +616,67 @@ class db_verify
|
|||||||
|
|
||||||
$id = $this->getId($this->tables[$j]['tables'],$table);
|
$id = $this->getId($this->tables[$j]['tables'],$table);
|
||||||
|
|
||||||
foreach($val as $field=>$mode)
|
foreach($val as $field=>$fixes)
|
||||||
{
|
{
|
||||||
|
foreach($fixes as $mode)
|
||||||
if(substr($mode,0,5)== 'index')
|
{
|
||||||
{
|
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))
|
|
||||||
{
|
|
||||||
$mes->add(LAN_UPDATED.' [ '.$query.' ]', E_MESSAGE_SUCCESS);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$mes->add(LAN_UPDATED_FAILED.' [ '.$query.' ]', E_MESSAGE_WARNING);
|
|
||||||
if(mysql_errno())
|
|
||||||
{
|
{
|
||||||
$mes->add(' SQL #'.mysql_errno().': '.mysql_error(), E_MESSAGE_WARNING);
|
$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))
|
||||||
|
{
|
||||||
|
$mes->add(LAN_UPDATED.' [ '.$query.' ]', E_MESSAGE_SUCCESS);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$mes->add(LAN_UPDATED_FAILED.' [ '.$query.' ]', E_MESSAGE_WARNING);
|
||||||
|
if(mysql_errno())
|
||||||
|
{
|
||||||
|
$mes->add(' SQL #'.mysql_errno().': '.mysql_error(), E_MESSAGE_WARNING);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -739,7 +810,7 @@ class db_verify
|
|||||||
}
|
}
|
||||||
|
|
||||||
$prefix .= "lan_".$language."_";
|
$prefix .= "lan_".$language."_";
|
||||||
$mes->addDebug("<h2>Retrieving Language Table Data: ".$prefix . $tbl."</h2>");
|
// $mes->addDebug("<h2>Retrieving Language Table Data: ".$prefix . $tbl."</h2>");
|
||||||
}
|
}
|
||||||
|
|
||||||
mysql_query('SET SQL_QUOTE_SHOW_CREATE = 1');
|
mysql_query('SET SQL_QUOTE_SHOW_CREATE = 1');
|
||||||
|
Reference in New Issue
Block a user