mirror of
https://github.com/kleeja-official/kleeja.git
synced 2026-05-07 09:46:07 +02:00
coding style fixes
This commit is contained in:
@@ -16,11 +16,12 @@
|
||||
* include important files
|
||||
*/
|
||||
define('IN_COMMON', true);
|
||||
$_path = "../";
|
||||
$_path = '../';
|
||||
define('PATH', $_path);
|
||||
if(file_exists($_path . 'config.php'))
|
||||
|
||||
if (file_exists($_path . 'config.php'))
|
||||
{
|
||||
include_once $_path . 'config.php';
|
||||
include_once $_path . 'config.php';
|
||||
}
|
||||
|
||||
include_once $_path . 'includes/functions.php';
|
||||
@@ -31,20 +32,21 @@ include_once $_path . 'includes/mysqli.php';
|
||||
include_once 'includes/functions_install.php';
|
||||
|
||||
|
||||
$order_update_files = array(
|
||||
'1.7_to_2.0' => 9,
|
||||
// filename => db_version
|
||||
);
|
||||
$order_update_files = [
|
||||
'1.7_to_2.0' => 9,
|
||||
// filename => db_version
|
||||
];
|
||||
|
||||
$SQL = new KleejaDatabase($dbserver, $dbuser, $dbpass, $dbname);
|
||||
|
||||
|
||||
//
|
||||
// Is current db is up-to-date ?
|
||||
//
|
||||
$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', '')");
|
||||
$SQL->query("INSERT INTO `{$dbprefix}config` (`name` ,`value`) VALUES ('db_version', '')");
|
||||
}
|
||||
|
||||
|
||||
@@ -54,9 +56,9 @@ $IN_UPDATE = true;
|
||||
/**
|
||||
* print header
|
||||
*/
|
||||
if (!ip('action_file_do'))
|
||||
if (! ip('action_file_do'))
|
||||
{
|
||||
echo gettpl('header.html');
|
||||
echo gettpl('header.html');
|
||||
}
|
||||
|
||||
|
||||
@@ -69,141 +71,146 @@ switch (g('step', 'str', 'action_file'))
|
||||
default:
|
||||
case 'action_file':
|
||||
|
||||
if (ip('action_file_do'))
|
||||
{
|
||||
if (p('action_file_do', 'str', '') !== '')
|
||||
{
|
||||
echo '<meta http-equiv="refresh" content="0;url=' . $_SERVER['PHP_SELF'] . '?step=update_now&action_file_do=' . p('action_file_do') . '&' . getlang(1) . '">';
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//get fles
|
||||
$s_path = "includes/update_files";
|
||||
$dh = opendir($s_path);
|
||||
$upfiles = array();
|
||||
if (ip('action_file_do'))
|
||||
{
|
||||
if (p('action_file_do', 'str', '') !== '')
|
||||
{
|
||||
echo '<meta http-equiv="refresh" content="0;url=' . $_SERVER['PHP_SELF'] . '?step=update_now&action_file_do=' . p('action_file_do') . '&' . getlang(1) . '">';
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//get fles
|
||||
$s_path = 'includes/update_files';
|
||||
$dh = opendir($s_path);
|
||||
$upfiles = [];
|
||||
|
||||
while (($file = readdir($dh)) !== false)
|
||||
{
|
||||
if(substr($file, -3) == 'php')
|
||||
{
|
||||
$file = str_replace('.php','', $file);
|
||||
$db_ver = $order_update_files[$file];
|
||||
while (($file = readdir($dh)) !== false)
|
||||
{
|
||||
if (substr($file, -3) == 'php')
|
||||
{
|
||||
$file = str_replace('.php', '', $file);
|
||||
$db_ver = $order_update_files[$file];
|
||||
|
||||
// var_dump($db_ver);
|
||||
// var_dump($db_ver);
|
||||
|
||||
if((empty($config['db_version']) || $db_ver > $config['db_version']))
|
||||
{
|
||||
if ((empty($config['db_version']) || $db_ver > $config['db_version']))
|
||||
{
|
||||
$upfiles[$db_ver] = $file;
|
||||
}
|
||||
}
|
||||
}
|
||||
@closedir($dh);
|
||||
}
|
||||
}
|
||||
@closedir($dh);
|
||||
|
||||
ksort($upfiles);
|
||||
|
||||
echo gettpl('update_list.html');
|
||||
}
|
||||
ksort($upfiles);
|
||||
|
||||
echo gettpl('update_list.html');
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case 'update_now':
|
||||
|
||||
if(!ig('action_file_do'))
|
||||
{
|
||||
echo '<meta http-equiv="refresh" content="0;url=' . $_SERVER['PHP_SELF'] . '?step=action_file&' . getlang(1) . '">';
|
||||
exit();
|
||||
}
|
||||
|
||||
if(ig('complet_up_func'))
|
||||
{
|
||||
define('C_U_F', true);
|
||||
}
|
||||
|
||||
$file_for_up = 'includes/update_files/' . preg_replace('/[^a-z0-9_\-\.]/i', '', g('action_file_do')) . '.php';
|
||||
if(!file_exists($file_for_up))
|
||||
{
|
||||
echo '<span style="color:red;">' . $lang['INST_ERR_NO_SELECTED_UPFILE_GOOD'] . ' [ ' . $file_for_up . ' ]</span><br />';
|
||||
}
|
||||
else
|
||||
{
|
||||
//get it
|
||||
require $file_for_up;
|
||||
$complete_update = true;
|
||||
$update_msgs_arr = array();
|
||||
|
||||
|
||||
if($config['db_version'] >= LAST_DB_VERSION && !defined('DEV_STAGE'))
|
||||
{
|
||||
$update_msgs_arr[] = '<span style="color:green;">' . $lang['INST_UPDATE_CUR_VER_IS_UP']. '</span>';
|
||||
$complete_update = false;
|
||||
}
|
||||
|
||||
//
|
||||
//is there any sqls
|
||||
//
|
||||
if(($complete_update || (defined('DEV_STAGE')) && !defined('C_U_F')))
|
||||
{
|
||||
$SQL->show_errors = false;
|
||||
if(isset($update_sqls) && sizeof($update_sqls) > 0)
|
||||
{
|
||||
$err = '';
|
||||
foreach($update_sqls as $name=>$sql_content)
|
||||
{
|
||||
$err = '';
|
||||
$SQL->query($sql_content);
|
||||
$err = $SQL->get_error();
|
||||
if (! ig('action_file_do'))
|
||||
{
|
||||
echo '<meta http-equiv="refresh" content="0;url=' . $_SERVER['PHP_SELF'] . '?step=action_file&' . getlang(1) . '">';
|
||||
|
||||
if(strpos($err[1], 'Duplicate') !== false || $err[0] == '1062' || $err[0] == '1060')
|
||||
{
|
||||
$update_msgs_arr[] = '<span style="color:green;">' . $lang['INST_UPDATE_CUR_VER_IS_UP']. '</span>';
|
||||
$complete_update = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
exit();
|
||||
}
|
||||
|
||||
//
|
||||
//is there any functions
|
||||
//
|
||||
if($complete_update || defined('DEV_STAGE') || defined('C_U_F'))
|
||||
{
|
||||
if(isset($update_functions) && sizeof($update_functions) > 0)
|
||||
{
|
||||
foreach($update_functions as $n)
|
||||
{
|
||||
if(is_callable($n))
|
||||
{
|
||||
$n();
|
||||
if (ig('complet_up_func'))
|
||||
{
|
||||
define('C_U_F', true);
|
||||
}
|
||||
|
||||
$file_for_up = 'includes/update_files/' . preg_replace('/[^a-z0-9_\-\.]/i', '', g('action_file_do')) . '.php';
|
||||
|
||||
if (! file_exists($file_for_up))
|
||||
{
|
||||
echo '<span style="color:red;">' . $lang['INST_ERR_NO_SELECTED_UPFILE_GOOD'] . ' [ ' . $file_for_up . ' ]</span><br />';
|
||||
}
|
||||
else
|
||||
{
|
||||
//get it
|
||||
require $file_for_up;
|
||||
$complete_update = true;
|
||||
$update_msgs_arr = [];
|
||||
|
||||
|
||||
if ($config['db_version'] >= LAST_DB_VERSION && ! defined('DEV_STAGE'))
|
||||
{
|
||||
$update_msgs_arr[] = '<span style="color:green;">' . $lang['INST_UPDATE_CUR_VER_IS_UP'] . '</span>';
|
||||
$complete_update = false;
|
||||
}
|
||||
|
||||
//
|
||||
//is there any sqls
|
||||
//
|
||||
if (($complete_update || (defined('DEV_STAGE')) && ! defined('C_U_F')))
|
||||
{
|
||||
$SQL->show_errors = false;
|
||||
|
||||
if (isset($update_sqls) && sizeof($update_sqls) > 0)
|
||||
{
|
||||
$err = '';
|
||||
|
||||
foreach ($update_sqls 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')
|
||||
{
|
||||
$update_msgs_arr[] = '<span style="color:green;">' . $lang['INST_UPDATE_CUR_VER_IS_UP'] . '</span>';
|
||||
$complete_update = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
//is there any notes
|
||||
//
|
||||
$NOTES_CUP = false;
|
||||
if($complete_update || defined('DEV_STAGE'))
|
||||
{
|
||||
if(isset($update_notes) && sizeof($update_notes) > 0)
|
||||
{
|
||||
$i=1;
|
||||
$NOTES_CUP = array();
|
||||
foreach($update_notes as $n)
|
||||
{
|
||||
$NOTES_CUP[$i] = $n;
|
||||
++$i;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
//
|
||||
//is there any functions
|
||||
//
|
||||
if ($complete_update || defined('DEV_STAGE') || defined('C_U_F'))
|
||||
{
|
||||
if (isset($update_functions) && sizeof($update_functions) > 0)
|
||||
{
|
||||
foreach ($update_functions as $n)
|
||||
{
|
||||
if (is_callable($n))
|
||||
{
|
||||
$n();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
//is there any notes
|
||||
//
|
||||
$NOTES_CUP = false;
|
||||
|
||||
if ($complete_update || defined('DEV_STAGE'))
|
||||
{
|
||||
if (isset($update_notes) && sizeof($update_notes) > 0)
|
||||
{
|
||||
$i =1;
|
||||
$NOTES_CUP = [];
|
||||
|
||||
foreach ($update_notes as $n)
|
||||
{
|
||||
$NOTES_CUP[$i] = $n;
|
||||
++$i;
|
||||
}
|
||||
}
|
||||
|
||||
$sql = "UPDATE `{$dbprefix}config` SET `value` = '" . LAST_DB_VERSION . "' WHERE `name` = 'db_version'";
|
||||
$SQL->query($sql);
|
||||
}
|
||||
}
|
||||
|
||||
echo gettpl('update_end.html');
|
||||
}
|
||||
echo gettpl('update_end.html');
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user