mirror of
https://github.com/kleeja-official/kleeja.git
synced 2025-12-16 04:59:42 +01:00
Miscellaneous changes
* PHP code style fixes * Updated database schema for upgrade
This commit is contained in:
@@ -65,7 +65,7 @@ function getjquerylink()
|
||||
|
||||
/**
|
||||
* Parsing installing templates
|
||||
* @param mixed $tplname
|
||||
* @param mixed $tplname
|
||||
*/
|
||||
function gettpl($tplname)
|
||||
{
|
||||
@@ -108,11 +108,12 @@ function kleeja_eval($code)
|
||||
|
||||
/**
|
||||
* Export config
|
||||
* @param mixed $srv
|
||||
* @param mixed $usr
|
||||
* @param mixed $pass
|
||||
* @param mixed $nm
|
||||
* @param mixed $prf
|
||||
* @param mixed $srv
|
||||
* @param mixed $usr
|
||||
* @param mixed $pass
|
||||
* @param mixed $nm
|
||||
* @param mixed $prf
|
||||
* @param mixed $type
|
||||
*/
|
||||
function do_config_export($srv, $usr, $pass, $nm, $prf, $type = 'mysqli')
|
||||
{
|
||||
@@ -120,7 +121,7 @@ function do_config_export($srv, $usr, $pass, $nm, $prf, $type = 'mysqli')
|
||||
$data .= '//for more information about this file, visit: ' . "\n";
|
||||
$data .= '//https://github.com/kleeja-official/kleeja/wiki/config.php-file' . "\n\n";
|
||||
|
||||
if(!empty($type) && $type != 'mysqli')
|
||||
if (! empty($type) && $type != 'mysqli')
|
||||
{
|
||||
if ($type == 'sqlite' && strpos($nm, '.') === false)
|
||||
{
|
||||
@@ -168,7 +169,7 @@ function get_microtime()
|
||||
|
||||
/**
|
||||
* Get config value from database directly, if not return false.
|
||||
* @param mixed $name
|
||||
* @param mixed $name
|
||||
*/
|
||||
function inst_get_config($name)
|
||||
{
|
||||
@@ -183,7 +184,7 @@ function inst_get_config($name)
|
||||
return false;
|
||||
}
|
||||
|
||||
if(isset($dbtype) && $dbtype == 'sqlite')
|
||||
if (isset($dbtype) && $dbtype == 'sqlite')
|
||||
{
|
||||
@touch(PATH . $dbname);
|
||||
}
|
||||
|
||||
@@ -8,12 +8,14 @@
|
||||
*/
|
||||
|
||||
// not for directly open
|
||||
if (! defined('IN_COMMON')) {
|
||||
if (! defined('IN_COMMON'))
|
||||
{
|
||||
exit();
|
||||
}
|
||||
|
||||
|
||||
if (empty($install_sqls) || ! is_array($install_sqls)) {
|
||||
if (empty($install_sqls) || ! is_array($install_sqls))
|
||||
{
|
||||
$install_sqls = [];
|
||||
}
|
||||
|
||||
|
||||
@@ -34,6 +34,10 @@ $update_schema[9]['sql'] = [
|
||||
// ];
|
||||
|
||||
$update_schema[10]['sql'] = [
|
||||
'about_files' => "ALTER TABLE `{$dbprefix}files` ADD `about` LONGTEXT NULL DEFAULT NULL AFTER `real_filename`;",
|
||||
'enable_multipart' => "INSERT INTO `{$dbprefix}groups_data` (`group_id`, `name`, `value`) SELECT `group_id`, 'enable_multipart', 1 FROM `{$dbprefix}groups`;",
|
||||
'about_files' => "ALTER TABLE `{$dbprefix}files` ADD `about` LONGTEXT NULL DEFAULT NULL AFTER `real_filename`;",
|
||||
'enable_multipart' => "INSERT INTO `{$dbprefix}groups_data` (`group_id`, `name`, `value`) SELECT `group_id`, 'enable_multipart', 1 FROM `{$dbprefix}groups`;",
|
||||
'user_storage_size' => "ALTER TABLE `{$dbprefix}users` ADD `storage_size` bigint(20) NOT NULL DEFAULT '0' AFTER `hash_key`;",
|
||||
'group_max_storage' => "INSERT INTO `{$dbprefix}groups_data` (`group_id`, `name`, `value`) SELECT `group_id`, 'max_storage', 0 FROM `{$dbprefix}groups`;",
|
||||
'multipart_config' => 'INSERT INTO `' . $dbprefix . 'config` (`name`, `value`, `option`, `display_order`, `type`, `plg_id`, `dynamic`) VALUES (\'enable_multipart\', 1, \'<label>{lang.YES}<input type=\"radio\" id=\"enable_multipart\" name=\"enable_multipart\" value=\"1\" <IF NAME=\"con.enable_multipart==1\"> checked=\"checked\"</IF> /></label>\r\n <label>{lang.NO}<input type=\"radio\" id=\"enable_multipart\" name=\"enable_multipart\" value=\"0\" <IF NAME=\"con.enable_multipart==0\"> checked=\"checked\"</IF> /></label>\', 45, \'groups\', 0, 0);',
|
||||
'max_storage_config' => 'INSERT INTO `' . $dbprefix . 'config` (`name`, `value`, `option`, `display_order`, `type`, `plg_id`, `dynamic`) VALUES (\'max_storage\', 0, \'<input type=\"text\" id=\"max_storage\" name=\"max_storage\" value=\"{con.max_storage}\" size=\"20\" style=\"direction:ltr\" />\', 11, \'groups\', 0, 0);',
|
||||
];
|
||||
|
||||
@@ -76,61 +76,61 @@ if (! ip('lang'))
|
||||
*/
|
||||
switch (g('step', 'str'))
|
||||
{
|
||||
default:
|
||||
case 'language':
|
||||
default:
|
||||
case 'language':
|
||||
|
||||
if (ig('ln'))
|
||||
{
|
||||
echo '<meta http-equiv="refresh" content="0;url=./?step=what_is_kleeja&lang=' . g('ln', 'str', 'en') . '">';
|
||||
|
||||
exit;
|
||||
}
|
||||
|
||||
echo gettpl('lang.html');
|
||||
|
||||
break;
|
||||
|
||||
case 'what_is_kleeja':
|
||||
|
||||
echo gettpl('what_is_kleeja.html');
|
||||
|
||||
break;
|
||||
|
||||
case 'official':
|
||||
|
||||
echo gettpl('official.html');
|
||||
|
||||
break;
|
||||
|
||||
case 'choose' :
|
||||
|
||||
$install_or_no = $php_ver = true;
|
||||
|
||||
//check version of PHP
|
||||
if (! function_exists('version_compare')
|
||||
|| version_compare(PHP_VERSION, MIN_PHP_VERSION, '<'))
|
||||
{
|
||||
$php_ver = false;
|
||||
}
|
||||
|
||||
if (file_exists(PATH . 'config.php'))
|
||||
{
|
||||
include_once PATH . 'config.php';
|
||||
|
||||
if (! empty($dbuser) && ! empty($dbname))
|
||||
if (ig('ln'))
|
||||
{
|
||||
$d = inst_get_config('language');
|
||||
echo '<meta http-equiv="refresh" content="0;url=./?step=what_is_kleeja&lang=' . g('ln', 'str', 'en') . '">';
|
||||
|
||||
if (! empty($d))
|
||||
exit;
|
||||
}
|
||||
|
||||
echo gettpl('lang.html');
|
||||
|
||||
break;
|
||||
|
||||
case 'what_is_kleeja':
|
||||
|
||||
echo gettpl('what_is_kleeja.html');
|
||||
|
||||
break;
|
||||
|
||||
case 'official':
|
||||
|
||||
echo gettpl('official.html');
|
||||
|
||||
break;
|
||||
|
||||
case 'choose' :
|
||||
|
||||
$install_or_no = $php_ver = true;
|
||||
|
||||
//check version of PHP
|
||||
if (! function_exists('version_compare')
|
||||
|| version_compare(PHP_VERSION, MIN_PHP_VERSION, '<'))
|
||||
{
|
||||
$php_ver = false;
|
||||
}
|
||||
|
||||
if (file_exists(PATH . 'config.php'))
|
||||
{
|
||||
include_once PATH . 'config.php';
|
||||
|
||||
if (! empty($dbuser) && ! empty($dbname))
|
||||
{
|
||||
$install_or_no = false;
|
||||
$d = inst_get_config('language');
|
||||
|
||||
if (! empty($d))
|
||||
{
|
||||
$install_or_no = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
echo gettpl('choose.html');
|
||||
echo gettpl('choose.html');
|
||||
|
||||
break;
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -83,10 +83,10 @@ else
|
||||
// //navigate ..
|
||||
switch (g('step'))
|
||||
{
|
||||
default:
|
||||
case 'license':
|
||||
default:
|
||||
case 'license':
|
||||
|
||||
$contentof_license = 'GPL version 2
|
||||
$contentof_license = 'GPL version 2
|
||||
GNU General Public License, Free Software Foundation
|
||||
The GNU General Public License is a Free Software license. Like any Free Software license, it grants to you the four following freedoms:
|
||||
1. The freedom to run the program for any purpose.
|
||||
@@ -98,328 +98,332 @@ You must conspicuously and appropriately publish on each copy distributed an app
|
||||
If you modify your copy or copies of the program or any portion of it, or develop a program based upon it, you may distribute the resulting work provided you do so under the GNU General Public License. Any translation of the GNU General Public License must be accompanied by the GNU General Public License.
|
||||
If you copy or distribute the program, you must accompany it with the complete corresponding machine-readable source code or with a written offer, valid for at least three years, to furnish the complete corresponding machine-readable source code.
|
||||
Any of the above conditions can be waived if you get permission from the copyright holder.';
|
||||
$contentof_license = nl2br($contentof_license);
|
||||
echo gettpl('license.html');
|
||||
$contentof_license = nl2br($contentof_license);
|
||||
echo gettpl('license.html');
|
||||
|
||||
break;
|
||||
break;
|
||||
|
||||
case 'f':
|
||||
case 'f':
|
||||
|
||||
$check_ok = true;
|
||||
$advices = $ziparchive_lib = false;
|
||||
$check_ok = true;
|
||||
$advices = $ziparchive_lib = false;
|
||||
|
||||
if (! class_exists('ZipArchive'))
|
||||
{
|
||||
$ziparchive_lib = true;
|
||||
}
|
||||
|
||||
if ($ziparchive_lib)
|
||||
{
|
||||
$advices = true;
|
||||
}
|
||||
|
||||
echo gettpl('check.html');
|
||||
|
||||
break;
|
||||
|
||||
case 'c':
|
||||
|
||||
// after submit, generate config file
|
||||
if (ip('dbsubmit'))
|
||||
{
|
||||
//create config file, or export it to browser on failure
|
||||
do_config_export(p('db_server'), p('db_user'), p('db_pass'), p('db_name'), p('db_prefix'), p('db_type'));
|
||||
}
|
||||
|
||||
$no_config = ! file_exists(PATH . 'config.php') || ig('force') ? false : true;
|
||||
$writeable_path = is_writable(PATH) ? true : false;
|
||||
$sqlite3_exists = class_exists('SQLite3');
|
||||
|
||||
echo gettpl('configs.html');
|
||||
|
||||
break;
|
||||
|
||||
case 'check':
|
||||
|
||||
$submit_disabled = $no_connection = $mysql_ver = false;
|
||||
|
||||
//config.php
|
||||
if (! empty($dbname))
|
||||
{
|
||||
if (isset($dbtype) && $dbtype == 'sqlite')
|
||||
if (! class_exists('ZipArchive'))
|
||||
{
|
||||
@touch(PATH . $dbname);
|
||||
$ziparchive_lib = true;
|
||||
}
|
||||
|
||||
//connect .. for check
|
||||
$SQL = new KleejaDatabase($dbserver, $dbuser, $dbpass, $dbname, $dbprefix);
|
||||
|
||||
|
||||
if (! $SQL->is_connected())
|
||||
if ($ziparchive_lib)
|
||||
{
|
||||
$no_connection = true;
|
||||
$advices = true;
|
||||
}
|
||||
else
|
||||
|
||||
echo gettpl('check.html');
|
||||
|
||||
break;
|
||||
|
||||
case 'c':
|
||||
|
||||
// after submit, generate config file
|
||||
if (ip('dbsubmit'))
|
||||
{
|
||||
if (defined('SQL_LAYER') && SQL_LAYER == 'mysqli')
|
||||
//create config file, or export it to browser on failure
|
||||
do_config_export(p('db_server'), p('db_user'), p('db_pass'), p('db_name'), p('db_prefix'), p('db_type'));
|
||||
}
|
||||
|
||||
$no_config = ! file_exists(PATH . 'config.php') || ig('force') ? false : true;
|
||||
$writeable_path = is_writable(PATH) ? true : false;
|
||||
$sqlite3_exists = class_exists('SQLite3');
|
||||
|
||||
echo gettpl('configs.html');
|
||||
|
||||
break;
|
||||
|
||||
case 'check':
|
||||
|
||||
$submit_disabled = $no_connection = $mysql_ver = false;
|
||||
|
||||
//config.php
|
||||
if (! empty($dbname))
|
||||
{
|
||||
if (isset($dbtype) && $dbtype == 'sqlite')
|
||||
{
|
||||
if (! empty($SQL->version()) && version_compare($SQL->version(), MIN_MYSQL_VERSION, '<'))
|
||||
{
|
||||
$mysql_ver = $SQL->version();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//try to chmod them
|
||||
if (function_exists('chmod'))
|
||||
{
|
||||
@chmod(PATH . 'cache', 0755);
|
||||
@chmod(PATH . 'plugins', 0755);
|
||||
@chmod(PATH . 'styles', 0755);
|
||||
@chmod(PATH . 'uploads', 0755);
|
||||
@chmod(PATH . 'uploads/thumbs', 0755);
|
||||
}
|
||||
|
||||
echo gettpl('check_all.html');
|
||||
|
||||
break;
|
||||
|
||||
case 'data' :
|
||||
|
||||
if (ip('datasubmit'))
|
||||
{
|
||||
//check data ...
|
||||
if (empty(p('sitename')) || empty(p('siteurl')) || empty(p('sitemail'))
|
||||
|| empty(p('username')) || empty(p('password')) || empty(p('password2')) || empty(p('email')))
|
||||
{
|
||||
echo $lang['EMPTY_FIELDS'];
|
||||
echo gettpl('footer.html');
|
||||
exit();
|
||||
}
|
||||
|
||||
//fix bug #r1777 (alta3rq revision)
|
||||
if (! empty(p('password')) && ! empty(p('password2')) && p('password') != p('password2'))
|
||||
{
|
||||
echo $lang['PASS_NEQ_PASS2'];
|
||||
echo gettpl('footer.html');
|
||||
exit();
|
||||
}
|
||||
|
||||
if (strpos(p('email'), '@') === false)
|
||||
{
|
||||
echo $lang['WRONG_EMAIL'];
|
||||
echo gettpl('footer.html');
|
||||
exit();
|
||||
}
|
||||
|
||||
//connect .. for check
|
||||
$SQL = new KleejaDatabase($dbserver, $dbuser, $dbpass, $dbname, $dbprefix);
|
||||
|
||||
include_once PATH . 'includes/usr.php';
|
||||
include_once PATH . 'includes/functions_alternative.php';
|
||||
$usrcp = new usrcp;
|
||||
|
||||
$user_salt = substr(base64_encode(pack('H*', sha1(mt_rand()))), 0, 7);
|
||||
$user_pass = $usrcp->kleeja_hash_password(p('password') . $user_salt);
|
||||
$user_name = $SQL->escape(p('username'));
|
||||
$user_mail = $SQL->escape(p('email'));
|
||||
$config_sitename = $SQL->escape(p('sitename'));
|
||||
$config_siteurl = $SQL->escape(p('siteurl'));
|
||||
$config_sitemail = $SQL->escape(p('sitemail'));
|
||||
$config_time_zone = $SQL->escape(p('time_zone'));
|
||||
//$config_style = ip('style') ? $SQL->escape(p('style')) : '';
|
||||
$config_urls_type = in_array(p('urls_type'), ['id', 'filename', 'direct']) ? p('urls_type') : 'id';
|
||||
$clean_name = $usrcp->cleanusername($SQL->escape($user_name));
|
||||
|
||||
/// ok .. we will get sqls now ..
|
||||
include 'includes/install_sqls.php';
|
||||
include 'includes/default_values.php';
|
||||
|
||||
$err = $dots = 0;
|
||||
$errors = '';
|
||||
|
||||
//do important alter before
|
||||
$SQL->query($install_sqls['ALTER_DATABASE_UTF']);
|
||||
|
||||
$sqls_done = $sql_err = [];
|
||||
|
||||
foreach ($install_sqls as $name=>$sql_content)
|
||||
{
|
||||
if ($name == 'DROP_TABLES' || $name == 'ALTER_DATABASE_UTF')
|
||||
{
|
||||
continue;
|
||||
@touch(PATH . $dbname);
|
||||
}
|
||||
|
||||
if ($SQL->query($sql_content))
|
||||
//connect .. for check
|
||||
$SQL = new KleejaDatabase($dbserver, $dbuser, $dbpass, $dbname, $dbprefix);
|
||||
|
||||
|
||||
if (! $SQL->is_connected())
|
||||
{
|
||||
if ($name == 'call')
|
||||
{
|
||||
$sqls_done[] = $lang['INST_CRT_CALL'];
|
||||
}
|
||||
elseif ($name == 'reports')
|
||||
{
|
||||
$sqls_done[] = $lang['INST_CRT_REPRS'];
|
||||
}
|
||||
elseif ($name == 'stats')
|
||||
{
|
||||
$sqls_done[] = $lang['INST_CRT_STS'];
|
||||
}
|
||||
elseif ($name == 'users')
|
||||
{
|
||||
$sqls_done[] = $lang['INST_CRT_USRS'];
|
||||
}
|
||||
elseif ($name == 'users')
|
||||
{
|
||||
$sqls_done[] = $lang['INST_CRT_ADM'];
|
||||
}
|
||||
elseif ($name == 'files')
|
||||
{
|
||||
$sqls_done[] = $lang['INST_CRT_FLS'];
|
||||
}
|
||||
elseif ($name == 'config')
|
||||
{
|
||||
$sqls_done[] = $lang['INST_CRT_CNF'];
|
||||
}
|
||||
elseif ($name == 'exts')
|
||||
{
|
||||
$sqls_done[] = $lang['INST_CRT_EXT'];
|
||||
}
|
||||
elseif ($name == 'online')
|
||||
{
|
||||
$sqls_done[] = $lang['INST_CRT_ONL'];
|
||||
}
|
||||
elseif ($name == 'hooks')
|
||||
{
|
||||
$sqls_done[] = $lang['INST_CRT_HKS'];
|
||||
}
|
||||
elseif ($name == 'plugins')
|
||||
{
|
||||
$sqls_done[] = $lang['INST_CRT_PLG'];
|
||||
}
|
||||
elseif ($name == 'lang')
|
||||
{
|
||||
$sqls_done[] = $lang['INST_CRT_LNG'];
|
||||
}
|
||||
else
|
||||
{
|
||||
$sqls_done[] = $name . '...';
|
||||
}
|
||||
$no_connection = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
$errors .= implode(':', $SQL->get_error()) . '' . "\n___\n";
|
||||
$sql_err[] = $lang['INST_SQL_ERR'] . ' : ' . $name . '[basic]';
|
||||
$err++;
|
||||
if (defined('SQL_LAYER') && SQL_LAYER == 'mysqli')
|
||||
{
|
||||
if (! empty($SQL->version()) && version_compare($SQL->version(), MIN_MYSQL_VERSION, '<'))
|
||||
{
|
||||
$mysql_ver = $SQL->version();
|
||||
}
|
||||
}
|
||||
}
|
||||
}//for
|
||||
}
|
||||
|
||||
if ($err == 0)
|
||||
//try to chmod them
|
||||
if (function_exists('chmod'))
|
||||
{
|
||||
//add configs
|
||||
foreach ($config_values as $cn)
|
||||
@chmod(PATH . 'cache', 0755);
|
||||
@chmod(PATH . 'plugins', 0755);
|
||||
@chmod(PATH . 'styles', 0755);
|
||||
@chmod(PATH . 'uploads', 0755);
|
||||
@chmod(PATH . 'uploads/thumbs', 0755);
|
||||
}
|
||||
|
||||
echo gettpl('check_all.html');
|
||||
|
||||
break;
|
||||
|
||||
case 'data' :
|
||||
|
||||
if (ip('datasubmit'))
|
||||
{
|
||||
//check data ...
|
||||
if (empty(p('sitename')) || empty(p('siteurl')) || empty(p('sitemail'))
|
||||
|| empty(p('username')) || empty(p('password')) || empty(p('password2')) || empty(p('email')))
|
||||
{
|
||||
if (empty($cn[6]))
|
||||
{
|
||||
$cn[6] = 0;
|
||||
}
|
||||
echo $lang['EMPTY_FIELDS'];
|
||||
echo gettpl('footer.html');
|
||||
|
||||
$sql = "INSERT INTO `{$dbprefix}config` (`name`, `value`, `option`, `display_order`, `type`, `plg_id`, `dynamic`) VALUES ('$cn[0]', '$cn[1]', '$cn[2]', '$cn[3]', '$cn[4]', '$cn[5]', '$cn[6]');";
|
||||
|
||||
if (! $SQL->query($sql))
|
||||
{
|
||||
$errors .= implode(':', $SQL->get_error()) . '' . "\n___\n";
|
||||
$sql_err[] = $lang['INST_SQL_ERR'] . ' : [configs_values] ' . $cn;
|
||||
$err++;
|
||||
}
|
||||
exit();
|
||||
}
|
||||
|
||||
//add groups configs
|
||||
foreach ($config_values as $cn)
|
||||
//fix bug #r1777 (alta3rq revision)
|
||||
if (! empty(p('password')) && ! empty(p('password2')) && p('password') != p('password2'))
|
||||
{
|
||||
if ($cn[4] != 'groups' or ! $cn[4])
|
||||
echo $lang['PASS_NEQ_PASS2'];
|
||||
echo gettpl('footer.html');
|
||||
|
||||
exit();
|
||||
}
|
||||
|
||||
if (strpos(p('email'), '@') === false)
|
||||
{
|
||||
echo $lang['WRONG_EMAIL'];
|
||||
echo gettpl('footer.html');
|
||||
|
||||
exit();
|
||||
}
|
||||
|
||||
//connect .. for check
|
||||
$SQL = new KleejaDatabase($dbserver, $dbuser, $dbpass, $dbname, $dbprefix);
|
||||
|
||||
include_once PATH . 'includes/usr.php';
|
||||
include_once PATH . 'includes/functions_alternative.php';
|
||||
$usrcp = new usrcp;
|
||||
|
||||
$user_salt = substr(base64_encode(pack('H*', sha1(mt_rand()))), 0, 7);
|
||||
$user_pass = $usrcp->kleeja_hash_password(p('password') . $user_salt);
|
||||
$user_name = $SQL->escape(p('username'));
|
||||
$user_mail = $SQL->escape(p('email'));
|
||||
$config_sitename = $SQL->escape(p('sitename'));
|
||||
$config_siteurl = $SQL->escape(p('siteurl'));
|
||||
$config_sitemail = $SQL->escape(p('sitemail'));
|
||||
$config_time_zone = $SQL->escape(p('time_zone'));
|
||||
//$config_style = ip('style') ? $SQL->escape(p('style')) : '';
|
||||
$config_urls_type = in_array(p('urls_type'), ['id', 'filename', 'direct']) ? p('urls_type') : 'id';
|
||||
$clean_name = $usrcp->cleanusername($SQL->escape($user_name));
|
||||
|
||||
/// ok .. we will get sqls now ..
|
||||
include 'includes/install_sqls.php';
|
||||
include 'includes/default_values.php';
|
||||
|
||||
$err = $dots = 0;
|
||||
$errors = '';
|
||||
|
||||
//do important alter before
|
||||
$SQL->query($install_sqls['ALTER_DATABASE_UTF']);
|
||||
|
||||
$sqls_done = $sql_err = [];
|
||||
|
||||
foreach ($install_sqls as $name=>$sql_content)
|
||||
{
|
||||
if ($name == 'DROP_TABLES' || $name == 'ALTER_DATABASE_UTF')
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
$itxt = '';
|
||||
|
||||
foreach ([1, 2, 3] as $im)
|
||||
if ($SQL->query($sql_content))
|
||||
{
|
||||
$itxt .= ($itxt == '' ? '' : ',') . "($im, '$cn[0]', '$cn[1]')";
|
||||
if ($name == 'call')
|
||||
{
|
||||
$sqls_done[] = $lang['INST_CRT_CALL'];
|
||||
}
|
||||
elseif ($name == 'reports')
|
||||
{
|
||||
$sqls_done[] = $lang['INST_CRT_REPRS'];
|
||||
}
|
||||
elseif ($name == 'stats')
|
||||
{
|
||||
$sqls_done[] = $lang['INST_CRT_STS'];
|
||||
}
|
||||
elseif ($name == 'users')
|
||||
{
|
||||
$sqls_done[] = $lang['INST_CRT_USRS'];
|
||||
}
|
||||
elseif ($name == 'users')
|
||||
{
|
||||
$sqls_done[] = $lang['INST_CRT_ADM'];
|
||||
}
|
||||
elseif ($name == 'files')
|
||||
{
|
||||
$sqls_done[] = $lang['INST_CRT_FLS'];
|
||||
}
|
||||
elseif ($name == 'config')
|
||||
{
|
||||
$sqls_done[] = $lang['INST_CRT_CNF'];
|
||||
}
|
||||
elseif ($name == 'exts')
|
||||
{
|
||||
$sqls_done[] = $lang['INST_CRT_EXT'];
|
||||
}
|
||||
elseif ($name == 'online')
|
||||
{
|
||||
$sqls_done[] = $lang['INST_CRT_ONL'];
|
||||
}
|
||||
elseif ($name == 'hooks')
|
||||
{
|
||||
$sqls_done[] = $lang['INST_CRT_HKS'];
|
||||
}
|
||||
elseif ($name == 'plugins')
|
||||
{
|
||||
$sqls_done[] = $lang['INST_CRT_PLG'];
|
||||
}
|
||||
elseif ($name == 'lang')
|
||||
{
|
||||
$sqls_done[] = $lang['INST_CRT_LNG'];
|
||||
}
|
||||
else
|
||||
{
|
||||
$sqls_done[] = $name . '...';
|
||||
}
|
||||
}
|
||||
|
||||
$sql = "INSERT INTO `{$dbprefix}groups_data` (`group_id`, `name`, `value`) VALUES " . $itxt . ';';
|
||||
|
||||
if (! $SQL->query($sql))
|
||||
else
|
||||
{
|
||||
$errors .= implode(':', $SQL->get_error()) . '' . "\n___\n";
|
||||
$sql_err[] = $lang['INST_SQL_ERR'] . ' : [groups_configs_values] ' . $cn;
|
||||
$sql_err[] = $lang['INST_SQL_ERR'] . ' : ' . $name . '[basic]';
|
||||
$err++;
|
||||
}
|
||||
}
|
||||
}//for
|
||||
|
||||
//add exts
|
||||
foreach ($ext_values as $gid=>$exts)
|
||||
if ($err == 0)
|
||||
{
|
||||
$itxt = '';
|
||||
|
||||
foreach ($exts as $t=>$v)
|
||||
//add configs
|
||||
foreach ($config_values as $cn)
|
||||
{
|
||||
$itxt .= ($itxt == '' ? '' : ',') . "('$t', $gid, $v)";
|
||||
if (empty($cn[6]))
|
||||
{
|
||||
$cn[6] = 0;
|
||||
}
|
||||
|
||||
$sql = "INSERT INTO `{$dbprefix}config` (`name`, `value`, `option`, `display_order`, `type`, `plg_id`, `dynamic`) VALUES ('$cn[0]', '$cn[1]', '$cn[2]', '$cn[3]', '$cn[4]', '$cn[5]', '$cn[6]');";
|
||||
|
||||
if (! $SQL->query($sql))
|
||||
{
|
||||
$errors .= implode(':', $SQL->get_error()) . '' . "\n___\n";
|
||||
$sql_err[] = $lang['INST_SQL_ERR'] . ' : [configs_values] ' . $cn;
|
||||
$err++;
|
||||
}
|
||||
}
|
||||
|
||||
$sql = "INSERT INTO `{$dbprefix}groups_exts` (`ext`, `group_id`, `size`) VALUES " . $itxt . ';';
|
||||
|
||||
if (! $SQL->query($sql))
|
||||
//add groups configs
|
||||
foreach ($config_values as $cn)
|
||||
{
|
||||
$errors .= implode(':', $SQL->get_error()) . '' . "\n___\n";
|
||||
$sql_err[] = $lang['INST_SQL_ERR'] . ' : [ext_values] ' . $gid;
|
||||
$err++;
|
||||
if ($cn[4] != 'groups' or ! $cn[4])
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
$itxt = '';
|
||||
|
||||
foreach ([1, 2, 3] as $im)
|
||||
{
|
||||
$itxt .= ($itxt == '' ? '' : ',') . "($im, '$cn[0]', '$cn[1]')";
|
||||
}
|
||||
|
||||
$sql = "INSERT INTO `{$dbprefix}groups_data` (`group_id`, `name`, `value`) VALUES " . $itxt . ';';
|
||||
|
||||
if (! $SQL->query($sql))
|
||||
{
|
||||
$errors .= implode(':', $SQL->get_error()) . '' . "\n___\n";
|
||||
$sql_err[] = $lang['INST_SQL_ERR'] . ' : [groups_configs_values] ' . $cn;
|
||||
$err++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//add acls
|
||||
foreach ($acls_values as $cn=>$ct)
|
||||
{
|
||||
$it = 1;
|
||||
$itxt = '';
|
||||
|
||||
foreach ($ct as $ctk)
|
||||
//add exts
|
||||
foreach ($ext_values as $gid=>$exts)
|
||||
{
|
||||
$itxt .= ($itxt == '' ? '' : ',') . "('$cn', '$it', '$ctk')";
|
||||
$itxt = '';
|
||||
|
||||
foreach ($exts as $t=>$v)
|
||||
{
|
||||
$itxt .= ($itxt == '' ? '' : ',') . "('$t', $gid, $v)";
|
||||
}
|
||||
|
||||
$sql = "INSERT INTO `{$dbprefix}groups_exts` (`ext`, `group_id`, `size`) VALUES " . $itxt . ';';
|
||||
|
||||
if (! $SQL->query($sql))
|
||||
{
|
||||
$errors .= implode(':', $SQL->get_error()) . '' . "\n___\n";
|
||||
$sql_err[] = $lang['INST_SQL_ERR'] . ' : [ext_values] ' . $gid;
|
||||
$err++;
|
||||
}
|
||||
}
|
||||
|
||||
//add acls
|
||||
foreach ($acls_values as $cn=>$ct)
|
||||
{
|
||||
$it = 1;
|
||||
$itxt = '';
|
||||
|
||||
foreach ($ct as $ctk)
|
||||
{
|
||||
$itxt .= ($itxt == '' ? '' : ',') . "('$cn', '$it', '$ctk')";
|
||||
$it++;
|
||||
}
|
||||
|
||||
|
||||
$sql = "INSERT INTO `{$dbprefix}groups_acl` (`acl_name`, `group_id`, `acl_can`) VALUES " . $itxt . ';';
|
||||
|
||||
if (! $SQL->query($sql))
|
||||
{
|
||||
$errors .= implode(':', $SQL->get_error()) . '' . "\n___\n";
|
||||
$sql_err[] = $lang['INST_SQL_ERR'] . ' : [acl_values] ' . $cn;
|
||||
$err++;
|
||||
}
|
||||
$it++;
|
||||
}
|
||||
|
||||
|
||||
$sql = "INSERT INTO `{$dbprefix}groups_acl` (`acl_name`, `group_id`, `acl_can`) VALUES " . $itxt . ';';
|
||||
|
||||
if (! $SQL->query($sql))
|
||||
{
|
||||
$errors .= implode(':', $SQL->get_error()) . '' . "\n___\n";
|
||||
$sql_err[] = $lang['INST_SQL_ERR'] . ' : [acl_values] ' . $cn;
|
||||
$err++;
|
||||
}
|
||||
$it++;
|
||||
}
|
||||
|
||||
echo gettpl('sqls_done.html');
|
||||
}
|
||||
else
|
||||
{
|
||||
$urlsite = 'http://' . $_SERVER['HTTP_HOST'] . str_replace('install', '', dirname($_SERVER['PHP_SELF']));
|
||||
echo gettpl('data.html');
|
||||
}
|
||||
|
||||
echo gettpl('sqls_done.html');
|
||||
}
|
||||
else
|
||||
{
|
||||
$urlsite = 'http://' . $_SERVER['HTTP_HOST'] . str_replace('install', '', dirname($_SERVER['PHP_SELF']));
|
||||
echo gettpl('data.html');
|
||||
}
|
||||
break;
|
||||
|
||||
break;
|
||||
|
||||
case 'end' :
|
||||
case 'end' :
|
||||
|
||||
echo gettpl('end.html');
|
||||
|
||||
//for safe ..
|
||||
//@rename("install.php", "install.lock");
|
||||
break;
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -10,8 +10,8 @@
|
||||
{{if($GLOBALS['complete_update']):}}
|
||||
<div class="hr"></div>
|
||||
<div class="notice">
|
||||
<h6><img src="style/images/info2.png" class="img" alt="" /> {{echo $lang['INST_NOTES_UPDATE']}} :</h6>
|
||||
<p><img src="style/images/inst_notes.png" class="img" alt="" />{{echo $lang['INST_NOTE_RC6_TO_1.0.0']}}</p>
|
||||
<h6><img src="style/images/info2.png" class="img" alt="" /> {{echo $lang['KLEEJA_TEAM_MSG_NAME']}}</h6>
|
||||
<p><img src="style/images/inst_notes.png" class="img" alt="" />{{echo $lang['KLEEJA_TEAM_MSG_TEXT']}}</p>
|
||||
</div>
|
||||
{{else:}}
|
||||
<div class="notice TN">
|
||||
|
||||
@@ -19,7 +19,8 @@ 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';
|
||||
}
|
||||
|
||||
@@ -27,9 +28,12 @@ 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';
|
||||
}
|
||||
|
||||
@@ -44,7 +48,8 @@ $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', '')");
|
||||
}
|
||||
|
||||
@@ -55,7 +60,8 @@ $IN_UPDATE = true;
|
||||
/**
|
||||
* print header
|
||||
*/
|
||||
if (! ip('action_file_do')) {
|
||||
if (! ip('action_file_do'))
|
||||
{
|
||||
echo gettpl('header.html');
|
||||
}
|
||||
|
||||
@@ -63,74 +69,86 @@ if (! ip('action_file_do')) {
|
||||
/**
|
||||
* Navigation ..
|
||||
*/
|
||||
switch (g('step', 'str', 'action_file')) {
|
||||
default:
|
||||
case 'update_now':
|
||||
switch (g('step', 'str', 'action_file'))
|
||||
{
|
||||
default:
|
||||
case 'update_now':
|
||||
|
||||
$complete_update = true;
|
||||
$update_msgs_arr = [];
|
||||
$current_db_version = $config['db_version'];
|
||||
$complete_update = true;
|
||||
$update_msgs_arr = [];
|
||||
$current_db_version = $config['db_version'];
|
||||
|
||||
$all_db_updates = array_keys($update_schema);
|
||||
$all_db_updates = array_keys($update_schema);
|
||||
|
||||
$available_db_updates = array_filter($all_db_updates, function ($v) use ($current_db_version) {
|
||||
return $v > $current_db_version;
|
||||
});
|
||||
$available_db_updates = array_filter($all_db_updates, function ($v) use ($current_db_version) {
|
||||
return $v > $current_db_version;
|
||||
});
|
||||
|
||||
sort($available_db_updates);
|
||||
sort($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;
|
||||
}
|
||||
if (! sizeof($available_db_updates))
|
||||
{
|
||||
$update_msgs_arr[] = '<span style="color:green;">' . $lang['INST_UPDATE_CUR_VER_IS_UP'] . '</span>';
|
||||
$complete_update = false;
|
||||
}
|
||||
|
||||
//
|
||||
//is there any sqls
|
||||
//is there any sqls
|
||||
//
|
||||
if ($complete_update) {
|
||||
//loop through available updates
|
||||
foreach ($available_db_updates as $db_update_version) {
|
||||
$SQL->hideErrors();
|
||||
if ($complete_update)
|
||||
{
|
||||
//loop through available updates
|
||||
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) {
|
||||
$err = '';
|
||||
|
||||
$complete_update = true;
|
||||
|
||||
foreach ($update_schema[$db_update_version]['sql'] as $name=>$sql_content) {
|
||||
//sqls
|
||||
if (isset($update_schema[$db_update_version]['sql'])
|
||||
&& sizeof($update_schema[$db_update_version]['sql']) > 0)
|
||||
{
|
||||
$err = '';
|
||||
$SQL->query($sql_content);
|
||||
$err = $SQL->get_error();
|
||||
|
||||
if (strpos($err[1], 'Duplicate') !== false || $err[0] == '1062' || $err[0] == '1060') {
|
||||
$complete_update = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
$complete_update = true;
|
||||
|
||||
//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)) {
|
||||
$n();
|
||||
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')
|
||||
{
|
||||
$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))
|
||||
{
|
||||
$n();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$sql = "UPDATE `{$dbprefix}config` SET `value` = '" . KLEEJA_DB_VERSION . "' WHERE `name` = 'db_version'";
|
||||
$SQL->query($sql);
|
||||
$update_msgs_arr[] = '<span style="color:green;">' . $lang['INST_UPDATE_IS_FINISH'] . '</span>';
|
||||
}
|
||||
|
||||
$sql = "UPDATE `{$dbprefix}config` SET `value` = '" . KLEEJA_DB_VERSION . "' WHERE `name` = 'db_version'";
|
||||
$SQL->query($sql);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
delete_cache('', true);
|
||||
echo gettpl('update_end.html');
|
||||
delete_cache('', true);
|
||||
echo gettpl('update_end.html');
|
||||
|
||||
break;
|
||||
break;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user