issue 171

This commit is contained in:
Mitan Omar
2020-12-25 18:18:48 +01:00
parent 625d14ffcc
commit 730c30042b
2 changed files with 85 additions and 153 deletions

View File

@@ -19,8 +19,7 @@ define('IN_COMMON', true);
define('STOP_PLUGINS', true);
define('PATH', '../');
if (file_exists(PATH . 'config.php'))
{
if (file_exists(PATH . 'config.php')) {
include_once PATH . 'config.php';
}
@@ -28,12 +27,9 @@ include_once PATH . 'includes/plugins.php';
include_once PATH . 'includes/functions.php';
include_once PATH . 'includes/functions_alternative.php';
if (isset($dbtype) && $dbtype == 'sqlite')
{
if (isset($dbtype) && $dbtype == 'sqlite') {
include PATH . 'includes/sqlite.php';
}
else
{
} else {
include PATH . 'includes/mysqli.php';
}
@@ -48,8 +44,7 @@ $SQL = new KleejaDatabase($dbserver, $dbuser, $dbpass, $dbname, $dbprefix);
//
$config['db_version'] = inst_get_config('db_version');
if ($config['db_version'] == false)
{
if ($config['db_version'] == false) {
$SQL->query("INSERT INTO `{$dbprefix}config` (`name` ,`value`) VALUES ('db_version', '')");
}
@@ -60,8 +55,7 @@ $IN_UPDATE = true;
/**
* print header
*/
if (! ip('action_file_do'))
{
if (! ip('action_file_do')) {
echo gettpl('header.html');
}
@@ -69,8 +63,7 @@ if (! ip('action_file_do'))
/**
* Navigation ..
*/
switch (g('step', 'str', 'action_file'))
{
switch (g('step', 'str', 'action_file')) {
default:
case 'update_now':
@@ -86,8 +79,7 @@ case 'update_now':
sort($available_db_updates);
if (! sizeof($available_db_updates))
{
if (! sizeof($available_db_updates)) {
$update_msgs_arr[] = '<span style="color:green;">' . $lang['INST_UPDATE_CUR_VER_IS_UP'] . '</span>';
$complete_update = false;
}
@@ -95,50 +87,41 @@ case 'update_now':
//
//is there any sqls
//
if ($complete_update)
{
if ($complete_update) {
//loop through available updates
foreach ($available_db_updates as $db_update_version)
{
$SQL->show_errors = false;
foreach ($available_db_updates as $db_update_version) {
$SQL->hideErrors();
//sqls
if (isset($update_schema[$db_update_version]['sql'])
&& sizeof($update_schema[$db_update_version]['sql']) > 0)
{
&& sizeof($update_schema[$db_update_version]['sql']) > 0) {
$err = '';
$complete_update = true;
foreach ($update_schema[$db_update_version]['sql'] as $name=>$sql_content)
{
foreach ($update_schema[$db_update_version]['sql'] as $name=>$sql_content) {
$err = '';
$SQL->query($sql_content);
$err = $SQL->get_error();
if (strpos($err[1], 'Duplicate') !== false || $err[0] == '1062' || $err[0] == '1060')
{
if (strpos($err[1], 'Duplicate') !== false || $err[0] == '1062' || $err[0] == '1060') {
$complete_update = false;
}
}
}
//functions
if ($complete_update)
{
if (isset($update_schema[$db_update_version]['functions']) && sizeof($update_schema[$db_update_version]['functions']) > 0)
{
foreach ($update_schema[$db_update_version]['functions'] as $n)
{
if (is_callable($n))
{
if ($complete_update) {
if (isset($update_schema[$db_update_version]['functions']) && sizeof($update_schema[$db_update_version]['functions']) > 0) {
foreach ($update_schema[$db_update_version]['functions'] as $n) {
if (is_callable($n)) {
$n();
}
}
}
}
$sql = "UPDATE `{$dbprefix}config` SET `value` = '" . UPDATE_DB_VERSION . "' WHERE `name` = 'db_version'";
$sql = "UPDATE `{$dbprefix}config` SET `value` = '" . KLEEJA_DB_VERSION . "' WHERE `name` = 'db_version'";
$SQL->query($sql);
}
}