mirror of
https://github.com/e107inc/e107.git
synced 2025-04-14 01:22:13 +02:00
Issue #235 - Database Utility fixes.
This commit is contained in:
parent
d76d4c4ef2
commit
a8fc30016c
@ -52,11 +52,7 @@ if(isset($_POST['db_execute']))
|
||||
}
|
||||
}
|
||||
|
||||
if(isset($_POST['db_update']) || varset($_GET['mode'])=='db_update')
|
||||
{
|
||||
header("location: ".e_ADMIN."e107_update.php");
|
||||
exit();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@ -117,11 +113,11 @@ class system_tools
|
||||
'plugin_scan' => array('diz'=>DBLAN_28, 'label'=> DBLAN_29),
|
||||
'pref_editor' => array('diz'=>DBLAN_19, 'label'=> DBLAN_20),
|
||||
// 'backup_core' => array('diz'=>DBLAN_8, 'label'=> DBLAN_9),
|
||||
'verify_sql_record' => array('diz'=>DBLAN_35, 'label'=> DBLAN_36),
|
||||
// 'verify_sql_record' => array('diz'=>DBLAN_35, 'label'=> DBLAN_36),
|
||||
'importForm' => array('diz'=>DBLAN_59, 'label'=> DBLAN_59),
|
||||
'exportForm' => array('diz'=>DBLAN_58, 'label'=> DBLAN_58),
|
||||
'sc_override_scan' => array('diz'=>DBLAN_55, 'label'=> DBLAN_56),
|
||||
'convert_to_utf8' => array('diz'=>'Convert Database to UTF-8','label'=>'Convert DB to UTF-8'),
|
||||
'convert_to_utf8' => array('diz'=>'Check Database Charset','label'=>'Check Charset'),
|
||||
'correct_perms' => array('diz'=>'Correct File and Directory permissions','label'=>'Correct Perms')
|
||||
);
|
||||
|
||||
@ -151,18 +147,25 @@ class system_tools
|
||||
return;
|
||||
}
|
||||
|
||||
if(isset($_POST['verify_sql_record']) || varset($_GET['mode'])=='verify_sql_record' || isset($_POST['check_verify_sql_record']) || isset($_POST['delete_verify_sql_record']))
|
||||
{
|
||||
// if(isset($_POST['verify_sql_record']) || varset($_GET['mode'])=='verify_sql_record' || isset($_POST['check_verify_sql_record']) || isset($_POST['delete_verify_sql_record']))
|
||||
// {
|
||||
|
||||
//$this->verify_sql_record(); // - currently performed in db_verify_class.php
|
||||
}
|
||||
// }
|
||||
|
||||
if(isset($_POST['importForm']) || $_GET['mode']=='importForm')
|
||||
{
|
||||
$this->importForm();
|
||||
}
|
||||
|
||||
|
||||
|
||||
if(isset($_POST['db_update']) || varset($_GET['mode'])=='db_update') // Requires further testing.
|
||||
{
|
||||
// header("location: ".e_ADMIN."e107_update.php");
|
||||
require_once(e_ADMIN."update_routines.php");
|
||||
new e107Update($dbupdate);
|
||||
return;
|
||||
}
|
||||
|
||||
if(isset($_POST['convert_to_utf8']) || $_GET['mode']=='convert_to_utf8')
|
||||
{
|
||||
$this->convertUTF8Form();
|
||||
@ -243,117 +246,188 @@ class system_tools
|
||||
|
||||
private function convertUTF8Form()
|
||||
{
|
||||
$mes = e107::getMessage();
|
||||
$frm = e107::getForm();
|
||||
//TODO a function to call the e107_config information in e107_class.php.
|
||||
require(e_BASE."e107_config.php");
|
||||
$dbtable = $mySQLdefaultdb;
|
||||
$mes = e107::getMessage();
|
||||
$frm = e107::getForm();
|
||||
$config = e107::getMySQLConfig();
|
||||
$sql = e107::getDb();
|
||||
|
||||
$sql->gen('SHOW TABLE STATUS WHERE Name LIKE "'.$config['mySQLprefix'].'%" ');
|
||||
|
||||
|
||||
$text = "<table class='table adminlist'>
|
||||
<colgroup>
|
||||
<col style='width: auto' />
|
||||
<col style='width: auto' />
|
||||
<col style='width: auto' />
|
||||
<col style='width: auto' />
|
||||
</colgroup>
|
||||
<thead>
|
||||
<tr>
|
||||
|
||||
<th>Table</th>
|
||||
<th>Engine</th>
|
||||
<th>Collation</th>
|
||||
<th>Status</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>";
|
||||
|
||||
|
||||
|
||||
$invalidCollations = false;
|
||||
while($row = $sql->fetch())
|
||||
{
|
||||
$text .= "<tr>
|
||||
<td>".$row['Name']."</td>
|
||||
<td>".$row['Engine']."</td>
|
||||
<td>".$row['Collation']."</td>
|
||||
<td>".(($row['Collation'] == 'utf8_general_ci') ? ADMIN_TRUE_ICON : ADMIN_FALSE_ICON)."</td>
|
||||
</tr>";
|
||||
// print_a($row);
|
||||
|
||||
if($row['Collation'] != 'utf8_general_ci')
|
||||
{
|
||||
$invalidCollations = true;
|
||||
}
|
||||
|
||||
//TODO LAN
|
||||
$message = '
|
||||
This function will permanently modify all tables in your database. ('.$mySQLdefaultdb.')<br />
|
||||
It is <b>HIGHLY</b> recommended that you backup your database first.<br />
|
||||
If possible use a copy of your database.<br />
|
||||
Do not forget to purge unnecessary input - e.g. old chatbox messages, pm, …<br />
|
||||
as well as to set the maintenance flag to main admins only.<br />
|
||||
<br />
|
||||
Be sure to click the “Convert Database” button only once.<br />
|
||||
The conversion process can take up to one minute or much much more depending on the size of your database.<br />
|
||||
<br />
|
||||
Known problems (list non-exhaustive):
|
||||
<ul>
|
||||
<li>The MySQL user needs privileges to ALTER the database - this is mandatory.</li>
|
||||
<li>The conversion does not work with serialised arrays.<br />
|
||||
<strong>Be sure</strong> you followed all steps of the upgrade process first.</li>
|
||||
<li>It should work without troubles for databases of sites using only UTF-8 charset. Probably not with other charsets.</li>
|
||||
<li>The function uses the information_schema database for now.</li>
|
||||
</ul>
|
||||
';
|
||||
}
|
||||
|
||||
$text .= "</tbody></table>";
|
||||
|
||||
$mes->add($message, E_MESSAGE_WARNING);
|
||||
|
||||
$text = "
|
||||
<form method='post' action='".e_SELF."' id='linkform'>
|
||||
<fieldset id='core-db-utf8-convert'>
|
||||
<legend class='e-hideme'>"."Convert Database"."</legend>
|
||||
<div class='buttons-bar center'>
|
||||
".$frm->admin_button('perform_utf8_convert', "Convert Database")."
|
||||
</div>
|
||||
</fieldset>
|
||||
</form>";
|
||||
if($invalidCollations == true)
|
||||
{
|
||||
//TODO LAN
|
||||
$message = '
|
||||
This function will permanently modify all tables in your database. ('.$config['mySQLdefaultdb'].')<br />
|
||||
It is <b>HIGHLY</b> recommended that you first backup your database and switch your site into maintenance mode.
|
||||
<br />
|
||||
<br />
|
||||
Please note:
|
||||
<ul>
|
||||
<li>The conversion process can take up to one minute or much much more depending on the size of your database.</li>
|
||||
<li>The conversion does not work with serialized arrays.</li>
|
||||
<li>Be sure that you have followed all steps of the upgrade process first.</li>
|
||||
</ul>
|
||||
';
|
||||
|
||||
$mes->add($message, E_MESSAGE_WARNING);
|
||||
|
||||
$text .= "
|
||||
<form method='post' action='".e_SELF."' id='linkform'>
|
||||
<fieldset id='core-db-utf8-convert'>
|
||||
<legend class='e-hideme'>"."Convert Database"."</legend>
|
||||
<div class='buttons-bar center'>
|
||||
".$frm->admin_button('perform_utf8_convert', "Convert non-UTF8 Tables",false,"Convert non-UTF8 Tables",'class=btn-success&data-loading-text=Please wait...')."
|
||||
</div>
|
||||
</fieldset>
|
||||
</form>";
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
$mes->addSuccess("Your tables are using the correct character set.");
|
||||
}
|
||||
|
||||
e107::getRender()->tablerender(DBLAN_10.SEP."Convert Database to UTF-8", $mes->render().$text);
|
||||
|
||||
e107::getRender()->tablerender(DBLAN_10.SEP."Check Charset".SEP.$config['mySQLdefaultdb'], $mes->render().$text);
|
||||
|
||||
}
|
||||
|
||||
private function perform_utf8_convert()
|
||||
{
|
||||
require(e_BASE."e107_config.php");
|
||||
|
||||
$dbtable = $mySQLdefaultdb;
|
||||
$config = e107::getMySQLConfig();
|
||||
$dbtable = $config['mySQLdefaultdb'];
|
||||
|
||||
//TODO Add a check to be sure the database is not already utf-8.
|
||||
// yep, needs more methods - possibly a class in e107_handler
|
||||
|
||||
$sql = e107::getDb();
|
||||
$sql = e107::getDb('utf8-convert');
|
||||
$mes = e107::getMessage();
|
||||
|
||||
$ERROR = FALSE;
|
||||
|
||||
if(!mysql_query("USE information_schema;"))
|
||||
{
|
||||
$mes->add("Couldn't read information_schema", E_MESSAGE_ERROR);
|
||||
return;
|
||||
}
|
||||
|
||||
// if(!$sql->gen("USE information_schema;"))
|
||||
// {
|
||||
// $mes->add("Couldn't read information_schema", E_MESSAGE_ERROR);
|
||||
// return;
|
||||
// }
|
||||
|
||||
|
||||
$queries = array();
|
||||
$queries[] = $this->getQueries("SELECT CONCAT('ALTER TABLE ', table_name, ' MODIFY ', column_name, ' ', REPLACE(column_type, 'char', 'binary'), ';') FROM columns WHERE table_schema = '".$dbtable."' and data_type LIKE '%char%';");
|
||||
$queries[] = $this->getQueries("SELECT CONCAT('ALTER TABLE ', table_name, ' MODIFY ', column_name, ' ', REPLACE(column_type, 'text', 'blob'), ';') FROM columns WHERE table_schema = '".$dbtable."' and data_type LIKE '%text%';");
|
||||
$queries[] = $this->getQueries("SELECT CONCAT('ALTER TABLE `', table_name, '` MODIFY ', column_name, ' ', REPLACE(column_type, 'char', 'binary'), ';') FROM information_schema.columns WHERE TABLE_SCHEMA = '".$dbtable."' AND TABLE_NAME LIKE '".$config['mySQLprefix']."%' AND COLLATION_NAME != 'utf8_general_ci' and data_type LIKE '%char%';");
|
||||
$queries[] = $this->getQueries("SELECT CONCAT('ALTER TABLE `', table_name, '` MODIFY ', column_name, ' ', REPLACE(column_type, 'text', 'blob'), ';') FROM information_schema.columns WHERE TABLE_SCHEMA = '".$dbtable."' AND TABLE_NAME LIKE '".$config['mySQLprefix']."%' AND COLLATION_NAME != 'utf8_general_ci' and data_type LIKE '%text%';");
|
||||
|
||||
$queries2 = array();
|
||||
$queries2[] = $this->getQueries("SELECT CONCAT('ALTER TABLE ', table_name, ' MODIFY ', column_name, ' ', column_type, ' CHARACTER SET utf8;') FROM columns WHERE table_schema = '".$dbtable."' and data_type LIKE '%char%';");
|
||||
$queries2[] = $this->getQueries("SELECT CONCAT('ALTER TABLE ', table_name, ' MODIFY ', column_name, ' ', column_type, ' CHARACTER SET utf8;') FROM columns WHERE table_schema = '".$dbtable."' and data_type LIKE '%text%';");
|
||||
$queries2[] = $this->getQueries("SELECT CONCAT('ALTER TABLE `', table_name, '` MODIFY ', column_name, ' ', column_type, ' CHARACTER SET utf8;') FROM information_schema.columns WHERE TABLE_SCHEMA ='".$dbtable."' AND TABLE_NAME LIKE '".$config['mySQLprefix']."%' AND COLLATION_NAME != 'utf8_general_ci' and data_type LIKE '%char%';");
|
||||
$queries2[] = $this->getQueries("SELECT CONCAT('ALTER TABLE `', table_name, '` MODIFY ', column_name, ' ', column_type, ' CHARACTER SET utf8;') FROM information_schema.columns WHERE TABLE_SCHEMA = '".$dbtable."' AND TABLE_NAME LIKE '".$config['mySQLprefix']."%' AND COLLATION_NAME != 'utf8_general_ci' and data_type LIKE '%text%';");
|
||||
|
||||
|
||||
mysql_query("USE ".$dbtable);
|
||||
// $sql->gen("USE ".$dbtable);
|
||||
|
||||
|
||||
// print_a($queries2);
|
||||
// echo $mes->render();
|
||||
// return;
|
||||
|
||||
|
||||
// Convert Text tables to Binary.
|
||||
foreach($queries as $qry)
|
||||
{
|
||||
|
||||
foreach($qry as $q)
|
||||
{
|
||||
if(!$sql->db_Query($q))
|
||||
{
|
||||
$mes->add($q, E_MESSAGE_ERROR);
|
||||
$mes->addError($q);
|
||||
$ERROR = TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
$mes->addDebug($q);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//------------
|
||||
|
||||
$result = mysql_list_tables($dbtable);
|
||||
while ($row = mysql_fetch_array($result, MYSQL_NUM))
|
||||
// Convert Table Fields to utf8
|
||||
$sql2 = e107::getDb('sql2');
|
||||
|
||||
$sql->gen('SHOW TABLE STATUS WHERE Collation != "utf8_general_ci" ');
|
||||
while ($row = $sql->fetch())
|
||||
{
|
||||
$table = $row[0];
|
||||
$tab_query = "ALTER TABLE ".$table." charset=utf8; ";
|
||||
if(!$sql->db_Query($tab_query))
|
||||
$table = $row['Name'];
|
||||
$tab_query = "ALTER TABLE ".$table." DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci; ";
|
||||
|
||||
//echo "TABQRT= ".$tab_query;
|
||||
|
||||
if(!$sql2->db_Query($tab_query))
|
||||
{
|
||||
$mes->add($tab_query, E_MESSAGE_ERROR);
|
||||
$mes->addError($tab_query);
|
||||
$ERROR = TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
$mes->addDebug($tab_query);
|
||||
}
|
||||
}
|
||||
|
||||
// ---------------
|
||||
|
||||
// Convert Table Fields back to Text/varchar etc.
|
||||
foreach($queries2 as $qry)
|
||||
{
|
||||
foreach($qry as $q)
|
||||
{
|
||||
if(!$sql->db_Query($q))
|
||||
{
|
||||
$mes->add($q, E_MESSAGE_ERROR);
|
||||
$mes->addError($q);
|
||||
$ERROR = TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
$mes->addDebug($q);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -367,22 +441,40 @@ class system_tools
|
||||
}
|
||||
elseif($ERROR != TRUE)
|
||||
{
|
||||
$message = "Database Converted successfully to UTF-8. <br />
|
||||
Please now add the following line to your e107_config.php file:<br />
|
||||
<b>\$mySQLcharset = 'utf8';</b>
|
||||
";
|
||||
$message = "Database Converted successfully to UTF-8. ";
|
||||
//$message .= "<br />Please now add the following line to your e107_config.php file:<br /><b>\$mySQLcharset = 'utf8';</b>";
|
||||
|
||||
$mes->add($message, E_MESSAGE_SUCCESS);
|
||||
}
|
||||
|
||||
|
||||
echo $mes->render();
|
||||
}
|
||||
|
||||
function getQueries($query)
|
||||
{
|
||||
|
||||
$mes = e107::getMessage();
|
||||
$sql = e107::getDb('utf8-convert');
|
||||
|
||||
if($sql->gen($query))
|
||||
{
|
||||
while ($row = $sql->fetch(MYSQL_NUM))
|
||||
{
|
||||
$qry[] = $row[0];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$mes->addError($query);
|
||||
}
|
||||
|
||||
return $qry;
|
||||
|
||||
|
||||
/*
|
||||
if(!$result = mysql_query($query))
|
||||
{
|
||||
$mes->add("Query Failed", E_MESSAGE_ERROR);
|
||||
$mes->addError("Query Failed: ".$query);
|
||||
return;
|
||||
}
|
||||
while ($row = mysql_fetch_array($result, MYSQL_NUM))
|
||||
@ -391,6 +483,7 @@ class system_tools
|
||||
}
|
||||
|
||||
return $qry;
|
||||
* */
|
||||
}
|
||||
|
||||
|
||||
@ -485,18 +578,7 @@ class system_tools
|
||||
<a class='btn btn-large pull-left' style='margin-right:10px' href='".e_SELF."?mode=".$key."' title=\"".$val['label']."\">".ADMIN_EXECUTE_ICON."</a>
|
||||
<h4 style='margin-bottom:3px'><a href='".e_SELF."?mode=".$key."' title=\"".$val['label']."\">".$val['label']."</a></h4><small>".$val['diz']."</small>
|
||||
</div>";
|
||||
/*
|
||||
$text .= "<tr>
|
||||
<td>".$val['diz']."</td>
|
||||
<td>
|
||||
<a class='btn btn-large' href='".e_SELF."?mode=".$key."' title=\"".$val['label']."\">".ADMIN_EXECUTE_ICON."</a>
|
||||
".
|
||||
// $frm->submit_image('db_execute['.$key.']', '1', 'execute', $val['label']).
|
||||
// $frm->radio('db_execute', $key).$frm->label($val['label'], 'db_execute', $key).
|
||||
"
|
||||
</td>
|
||||
</tr>\n";
|
||||
*/
|
||||
|
||||
}
|
||||
/*
|
||||
$text .= "
|
||||
@ -702,7 +784,7 @@ class system_tools
|
||||
* Optimize SQL
|
||||
* @return none
|
||||
*/
|
||||
private function optimizesql($mySQLdefaultdb)
|
||||
private function optimizesql($mySQLdefaultdb) //FIXME Use mysql class.
|
||||
{
|
||||
// global $mes;
|
||||
$result = mysql_list_tables($mySQLdefaultdb);
|
||||
@ -1118,7 +1200,7 @@ function backup_core()
|
||||
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
function verify_sql_record() // deprecated by db_verify.php ( i think).
|
||||
{
|
||||
global $e107;
|
||||
@ -1531,6 +1613,6 @@ function verify_sql_record() // deprecated by db_verify.php ( i think).
|
||||
$ns->tablerender(DBLAN_10.SEP.DBLAN_50, $mes->render().$text);
|
||||
}
|
||||
}
|
||||
|
||||
*/
|
||||
|
||||
?>
|
@ -158,195 +158,6 @@ function show_updates($dbupdate, $what)
|
||||
*/
|
||||
|
||||
|
||||
// New in v2.x ------------------------------------------------
|
||||
|
||||
class e107Update
|
||||
{
|
||||
var $core = array();
|
||||
var $updates = 0;
|
||||
var $disabled = 0;
|
||||
|
||||
|
||||
function __construct($core=null)
|
||||
{
|
||||
$mes = e107::getMessage();
|
||||
|
||||
$this->core = $core;
|
||||
|
||||
if(varset($_POST['update_core']) && is_array($_POST['update_core']))
|
||||
{
|
||||
$func = key($_POST['update_core']);
|
||||
$message = $this->updateCore();
|
||||
}
|
||||
|
||||
if(varset($_POST['update']) && is_array($_POST['update'])) // Do plugin updates
|
||||
{
|
||||
$func = key($_POST['update']);
|
||||
$this->updatePlugin($func);
|
||||
}
|
||||
|
||||
if(vartrue($message))
|
||||
{
|
||||
$mes->addSuccess($message);
|
||||
}
|
||||
|
||||
$this->renderForm();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
function updateCore($func='')
|
||||
{
|
||||
$mes = e107::getMessage();
|
||||
|
||||
// foreach($this->core as $func => $data)
|
||||
// {
|
||||
if(function_exists('update_'.$func)) // Legacy Method.
|
||||
{
|
||||
$installed = call_user_func("update_".$func);
|
||||
//?! (LAN_UPDATE == $_POST[$func])
|
||||
if(varsettrue($_POST['update_core'][$func]) && !$installed)
|
||||
{
|
||||
if(function_exists("update_".$func))
|
||||
{
|
||||
$message = LAN_UPDATE_7." ".$data['title'];
|
||||
$error = call_user_func("update_".$func, "do");
|
||||
|
||||
if($error != '')
|
||||
{
|
||||
$mes->add($message, E_MESSAGE_ERROR);
|
||||
$mes->add($error, E_MESSAGE_ERROR);
|
||||
}
|
||||
else
|
||||
{
|
||||
$mes->add($message, E_MESSAGE_SUCCESS);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
function updatePlugin($path)
|
||||
{
|
||||
e107::getPlugin()->install_plugin_xml($path, 'upgrade');
|
||||
}
|
||||
|
||||
|
||||
|
||||
function plugins()
|
||||
{
|
||||
if(!$list = e107::getPlugin()->updateRequired())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
$frm = e107::getForm();
|
||||
|
||||
$text = "";
|
||||
foreach($list as $path=>$val)
|
||||
{
|
||||
$text .= "<tr>
|
||||
<td>".$val['@attributes']['name']."</td>
|
||||
<td>".$frm->admin_button('update['.$path.']', LAN_UPDATE, 'warning', '', 'disabled='.$this->disabled)."</td>
|
||||
</tr>";
|
||||
}
|
||||
|
||||
return $text;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
function core()
|
||||
{
|
||||
$frm = e107::getForm();
|
||||
$mes = e107::getMessage();
|
||||
|
||||
$text = "";
|
||||
|
||||
foreach($this->core as $func => $data)
|
||||
{
|
||||
if(function_exists("update_".$func))
|
||||
{
|
||||
$text .= "<tr><td>".$data['title']."</td>";
|
||||
|
||||
|
||||
|
||||
if(call_user_func("update_".$func))
|
||||
{
|
||||
$text .= "<td>".ADMIN_TRUE_ICON."</td>";
|
||||
}
|
||||
else
|
||||
{
|
||||
if(vartrue($data['message']))
|
||||
{
|
||||
$mes->addInfo($data['message']);
|
||||
}
|
||||
|
||||
$this->updates ++;
|
||||
|
||||
$text .= "<td>".$frm->admin_button('update_core['.$func.']', LAN_UPDATE, 'warning', '', "id=e-{$func}&disabled=".$this->disabled)."</td>";
|
||||
if($data['master'] == true)
|
||||
{
|
||||
$this->disabled = 1;
|
||||
}
|
||||
}
|
||||
$text .= "</tr>\n";
|
||||
}
|
||||
}
|
||||
|
||||
return $text;
|
||||
}
|
||||
|
||||
|
||||
|
||||
function renderForm()
|
||||
{
|
||||
$ns = e107::getRender();
|
||||
$mes = e107::getMessage();
|
||||
|
||||
$caption = LAN_UPDATE;
|
||||
$text = "
|
||||
<form method='post' action='".e_SELF."'>
|
||||
<fieldset id='core-e107-update'>
|
||||
<legend>{$caption}</legend>
|
||||
<table class='table adminlist'>
|
||||
<colgroup>
|
||||
<col style='width: 60%' />
|
||||
<col style='width: 40%' />
|
||||
</colgroup>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>".LAN_UPDATE_55."</th>
|
||||
<th class='last'>".LAN_UPDATE_2."</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
";
|
||||
|
||||
$text .= $this->core();
|
||||
$text .= $this->plugins();
|
||||
|
||||
$text .= "
|
||||
</tbody>
|
||||
</table>
|
||||
</fieldset>
|
||||
</form>
|
||||
";
|
||||
|
||||
|
||||
$ns->tablerender("Updates",$mes->render() . $text);
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
new e107Update($dbupdate);
|
||||
|
||||
|
@ -468,7 +468,7 @@ echo getAlert();
|
||||
|
||||
}
|
||||
|
||||
function getAlert($caption)
|
||||
function getAlert($caption='')
|
||||
{
|
||||
|
||||
return '<div id="uiAlert" class="alert alert-block alert-success hide fade in" style="box-shadow:0px 15px 8px #000;width:300px;position:absolute;left:40%;right:40%;top:15%;z-index:10000">
|
||||
|
@ -135,6 +135,199 @@ if (!$dont_check_update)
|
||||
|
||||
|
||||
|
||||
// New in v2.x ------------------------------------------------
|
||||
|
||||
class e107Update
|
||||
{
|
||||
var $core = array();
|
||||
var $updates = 0;
|
||||
var $disabled = 0;
|
||||
|
||||
|
||||
function __construct($core=null)
|
||||
{
|
||||
$mes = e107::getMessage();
|
||||
|
||||
$this->core = $core;
|
||||
|
||||
if(varset($_POST['update_core']) && is_array($_POST['update_core']))
|
||||
{
|
||||
$func = key($_POST['update_core']);
|
||||
$message = $this->updateCore($func);
|
||||
}
|
||||
|
||||
if(varset($_POST['update']) && is_array($_POST['update'])) // Do plugin updates
|
||||
{
|
||||
$func = key($_POST['update']);
|
||||
$this->updatePlugin($func);
|
||||
}
|
||||
|
||||
if(vartrue($message))
|
||||
{
|
||||
$mes->addSuccess($message);
|
||||
}
|
||||
|
||||
$this->renderForm();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
function updateCore($func='')
|
||||
{
|
||||
$mes = e107::getMessage();
|
||||
|
||||
// foreach($this->core as $func => $data)
|
||||
// {
|
||||
if(function_exists('update_'.$func)) // Legacy Method.
|
||||
{
|
||||
$installed = call_user_func("update_".$func);
|
||||
//?! (LAN_UPDATE == $_POST[$func])
|
||||
if(varsettrue($_POST['update_core'][$func]) && !$installed)
|
||||
{
|
||||
if(function_exists("update_".$func))
|
||||
{
|
||||
$message = LAN_UPDATE_7." ".$data['title'];
|
||||
$error = call_user_func("update_".$func, "do");
|
||||
|
||||
if($error != '')
|
||||
{
|
||||
$mes->add($message, E_MESSAGE_ERROR);
|
||||
$mes->add($error, E_MESSAGE_ERROR);
|
||||
}
|
||||
else
|
||||
{
|
||||
$mes->add($message, E_MESSAGE_SUCCESS);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$mes->addDebug("could run 'update_".$func);
|
||||
}
|
||||
|
||||
//}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
function updatePlugin($path)
|
||||
{
|
||||
e107::getPlugin()->install_plugin_xml($path, 'upgrade');
|
||||
}
|
||||
|
||||
|
||||
|
||||
function plugins()
|
||||
{
|
||||
if(!$list = e107::getPlugin()->updateRequired())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
$frm = e107::getForm();
|
||||
|
||||
$text = "";
|
||||
foreach($list as $path=>$val)
|
||||
{
|
||||
$text .= "<tr>
|
||||
<td>".$val['@attributes']['name']."</td>
|
||||
<td>".$frm->admin_button('update['.$path.']', LAN_UPDATE, 'warning', '', 'disabled='.$this->disabled)."</td>
|
||||
</tr>";
|
||||
}
|
||||
|
||||
return $text;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
function core()
|
||||
{
|
||||
$frm = e107::getForm();
|
||||
$mes = e107::getMessage();
|
||||
|
||||
$text = "";
|
||||
|
||||
foreach($this->core as $func => $data)
|
||||
{
|
||||
if(function_exists("update_".$func))
|
||||
{
|
||||
$text .= "<tr><td>".$data['title']."</td>";
|
||||
|
||||
|
||||
|
||||
if(call_user_func("update_".$func))
|
||||
{
|
||||
$text .= "<td>".ADMIN_TRUE_ICON."</td>";
|
||||
}
|
||||
else
|
||||
{
|
||||
if(vartrue($data['message']))
|
||||
{
|
||||
$mes->addInfo($data['message']);
|
||||
}
|
||||
|
||||
$this->updates ++;
|
||||
|
||||
$text .= "<td>".$frm->admin_button('update_core['.$func.']', LAN_UPDATE, 'warning', '', "id=e-{$func}&disabled=".$this->disabled)."</td>";
|
||||
if($data['master'] == true)
|
||||
{
|
||||
$this->disabled = 1;
|
||||
}
|
||||
}
|
||||
$text .= "</tr>\n";
|
||||
}
|
||||
}
|
||||
|
||||
return $text;
|
||||
}
|
||||
|
||||
|
||||
|
||||
function renderForm()
|
||||
{
|
||||
$ns = e107::getRender();
|
||||
$mes = e107::getMessage();
|
||||
|
||||
$caption = LAN_UPDATE;
|
||||
$text = "
|
||||
<form method='post' action='".e_SELF."'>
|
||||
<fieldset id='core-e107-update'>
|
||||
<legend>{$caption}</legend>
|
||||
<table class='table adminlist'>
|
||||
<colgroup>
|
||||
<col style='width: 60%' />
|
||||
<col style='width: 40%' />
|
||||
</colgroup>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>".LAN_UPDATE_55."</th>
|
||||
<th class='last'>".LAN_UPDATE_2."</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
";
|
||||
|
||||
$text .= $this->core();
|
||||
$text .= $this->plugins();
|
||||
|
||||
$text .= "
|
||||
</tbody>
|
||||
</table>
|
||||
</fieldset>
|
||||
</form>
|
||||
";
|
||||
|
||||
|
||||
$ns->tablerender("Updates",$mes->render() . $text);
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Master routine to call to check for updates
|
||||
|
@ -924,7 +924,7 @@ class db_verify
|
||||
</colgroup>
|
||||
<thead>
|
||||
<tr>
|
||||
<th class='last'>".$frm->checkbox_toggle('check-all-verify', 'verify_table').LAN_CHECKALL.' | '.LAN_UNCHECKALL."</th>
|
||||
<th class='last'>".$frm->checkbox_toggle('check-all-verify', 'verify_table',false,LAN_CHECKALL.' | '.LAN_UNCHECKALL)."</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@ -934,7 +934,7 @@ class db_verify
|
||||
{
|
||||
$text .= "
|
||||
<tr>
|
||||
<td>".$frm->checkbox('verify_table[]', $x).$frm->label($x, "verify_table".$x, $x)."</td>
|
||||
<td>".$frm->checkbox('verify_table[]', $x,false,'label='.$x)."</td>
|
||||
</tr>
|
||||
";
|
||||
}
|
||||
|
@ -596,16 +596,20 @@ class e107
|
||||
* Replaces all $mySQL(*) globals
|
||||
* Example: <code>$e107->getMySQLConfig('prefix');</code>
|
||||
*
|
||||
* @param string $for prefix|server|user|password|defaultdb
|
||||
* @return string
|
||||
* @param string $for prefix|server|user|password|defaultdb - leave blank for full array.
|
||||
* @return string or array
|
||||
*/
|
||||
function getMySQLConfig($for)
|
||||
function getMySQLConfig($for='')
|
||||
{
|
||||
$key = 'mySQL'.$for;
|
||||
$self = self::getInstance();
|
||||
return (isset($self->e107_config_mysql_info[$key]) ? $self->e107_config_mysql_info[$key] : '');
|
||||
|
||||
// return (isset($this->e107_config_mysql_info[$key]) ? $this->e107_config_mysql_info[$key] : '');
|
||||
if($for == '')
|
||||
{
|
||||
return $self->e107_config_mysql_info;
|
||||
}
|
||||
|
||||
return (isset($self->e107_config_mysql_info[$key]) ? $self->e107_config_mysql_info[$key] : '');
|
||||
}
|
||||
|
||||
|
||||
|
@ -967,11 +967,12 @@ class e_form
|
||||
return $this->checkbox($name, $value, $checked).$this->label($label ? $label : LAN_ENABLED, $name, $value);
|
||||
}
|
||||
|
||||
function checkbox_toggle($name, $selector = 'multitoggle', $id = false)
|
||||
function checkbox_toggle($name, $selector = 'multitoggle', $id = false, $label='')
|
||||
{
|
||||
$selector = 'jstarget:'.$selector;
|
||||
if($id) $id = $this->name2id($id);
|
||||
return $this->checkbox($name, $selector, false, array('id' => $id,'class' => 'checkbox toggle-all'));
|
||||
|
||||
return $this->checkbox($name, $selector, false, array('id' => $id,'class' => 'checkbox toggle-all','label'=>$label));
|
||||
}
|
||||
|
||||
function uc_checkbox($name, $current_value, $uc_options, $field_options = array())
|
||||
|
@ -397,9 +397,13 @@ i.s-message-debug { background-position: -1480px 0; width: 32px; height: 32px;
|
||||
}
|
||||
|
||||
tr.e-sort { box-shadow: 0 5px 8px #cccccc; -webkit-box-shadow: 0 5px 8px #cccccc; -moz-box-shadow: 0 5px 8px #cccccc;}
|
||||
th label.checkbox { min-height:inherit; } /* Bootstrap Fix but doesn't work */
|
||||
|
||||
/* ****************************** ICONS ************************************* */
|
||||
|
||||
|
||||
|
||||
|
||||
i.S16 {
|
||||
background: url(images/adminicons_16.png) no-repeat top left;
|
||||
display:inline-block;
|
||||
|
@ -123,8 +123,13 @@ $(document).ready(function()
|
||||
|
||||
$('button[data-loading-text],a[data-loading-text]').on('click', function()
|
||||
{
|
||||
var caption = $(this).attr('data-loading-text');
|
||||
$(this).attr('disabled', 'disabled').html(caption);
|
||||
var caption = $(this).attr('data-loading-text');
|
||||
$(this).removeClass('btn-success');
|
||||
$(this).html(caption);
|
||||
if($(this).attr('data-disable') == 'true')
|
||||
{
|
||||
$(this).attr('disabled', 'disabled');
|
||||
}
|
||||
return true;
|
||||
}
|
||||
);
|
||||
|
Loading…
x
Reference in New Issue
Block a user