coding style fixes

This commit is contained in:
Abdulrahman
2019-05-03 23:52:08 +03:00
parent 87c5631b40
commit f142da94f3
62 changed files with 12149 additions and 11750 deletions

View File

@@ -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_display.php';
include_once $_path . 'includes/functions_alternative.php';
@@ -30,7 +31,7 @@ include_once $_path . 'includes/mysqli.php';
include_once 'includes/functions_install.php';
#an alias class for plugins class
//an alias class for plugins class
class Plugins
{
private static $instance;
@@ -43,56 +44,60 @@ class Plugins
return self::$instance;
}
function run($name){ return null; }
public function run($name)
{
return null;
}
}
if(!ig('step'))
if (! ig('step'))
{
//if anyone request this file directly without passing index.php we will return him to index.php
header('Location: index.php');
exit;
//if anyone request this file directly without passing index.php we will return him to index.php
header('Location: index.php');
exit;
}
//
// Kleeja must be safe ..
//
if(!empty($dbuser) && !empty($dbname) && !(ig('step') && in_array(g('step'), array('c','check', 'data', 'end', 'wizard'))))
if (! empty($dbuser) && ! empty($dbname) && ! (ig('step') && in_array(g('step'), ['c','check', 'data', 'end', 'wizard'])))
{
$d = inst_get_config('language');
if(!empty($d))
{
header('Location: index.php');
exit;
}
$d = inst_get_config('language');
if (! empty($d))
{
header('Location: index.php');
exit;
}
}
/**
* Print header
*/
if(ip('dbsubmit') && !is_writable($_path))
if (ip('dbsubmit') && ! is_writable($_path))
{
// soon
// soon
}
else
{
echo gettpl('header.html');
echo gettpl('header.html');
}
/*
//navigate ..
*/
// //navigate ..
switch (g('step'))
{
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.
@@ -103,7 +108,7 @@ You may exercise the freedoms specified here provided that you comply with the e
You must conspicuously and appropriately publish on each copy distributed an appropriate copyright notice and disclaimer of warranty and keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of the GNU General Public License along with the Program. Any translation of the GNU General Public License must be accompanied by the GNU General Public License.
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.";
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');
@@ -111,278 +116,326 @@ break;
case 'f':
$check_ok = true;
$advices = $register_globals = $get_magic_quotes_gpc = false;
$check_ok = true;
$advices = $register_globals = $get_magic_quotes_gpc = false;
if (@ini_get('register_globals') == '1' || strtolower(@ini_get('register_globals')) == 'on')
{
$register_globals = true;
}
if( (function_exists("get_magic_quotes_gpc") && get_magic_quotes_gpc()) ||
(@ini_get('magic_quotes_sybase') && (strtolower(@ini_get('magic_quotes_sybase')) != "off")) )
{
$get_magic_quotes_gpc = true;
}
if (@ini_get('register_globals') == '1' || strtolower(@ini_get('register_globals')) == 'on')
{
$register_globals = true;
}
if($register_globals || $get_magic_quotes_gpc)
{
$advices = true;
}
if ( (function_exists('get_magic_quotes_gpc') && get_magic_quotes_gpc()) ||
(@ini_get('magic_quotes_sybase') && (strtolower(@ini_get('magic_quotes_sybase')) != 'off')) )
{
$get_magic_quotes_gpc = true;
}
echo gettpl('check.html');
if ($register_globals || $get_magic_quotes_gpc)
{
$advices = true;
}
echo gettpl('check.html');
break;
case 'c':
// after submit, generate config file
if(ip('dbsubmit'))
{
//lets do it
do_config_export(
p('db_server'),
p('db_user'),
p('db_pass'),
p('db_name'),
p('db_prefix')
);
}
// after submit, generate config file
if (ip('dbsubmit'))
{
//lets do it
do_config_export(
p('db_server'),
p('db_user'),
p('db_pass'),
p('db_name'),
p('db_prefix')
);
}
$no_config = !file_exists($_path . 'config.php') ? false : true;
$writeable_path = is_writable($_path) ? true : false;
$no_config = ! file_exists($_path . 'config.php') ? false : true;
$writeable_path = is_writable($_path) ? true : false;
echo gettpl('configs.html');
echo gettpl('configs.html');
break;
case 'check':
$submit_disabled = $no_connection = $mysql_ver = false;
$submit_disabled = $no_connection = $mysql_ver = false;
//config.php
if(!empty($dbname) && !empty($dbuser))
{
//connect .. for check
//config.php
if (! empty($dbname) && ! empty($dbuser))
{
//connect .. for check
$SQL = new KleejaDatabase($dbserver, $dbuser, $dbpass, $dbname);
if (!$SQL->is_connected())
{
$no_connection = true;
}
else
{
if (!empty($SQL->mysql_version()) && version_compare($SQL->mysql_version(), MIN_MYSQL_VERSION, '<'))
{
$mysql_ver = $SQL->mysql_version();
}
}
}
if (! $SQL->is_connected())
{
$no_connection = true;
}
else
{
if (! empty($SQL->mysql_version()) && version_compare($SQL->mysql_version(), MIN_MYSQL_VERSION, '<'))
{
$mysql_ver = $SQL->mysql_version();
}
}
}
//try to chmod them
if(function_exists('chmod'))
{
//try to chmod them
if (function_exists('chmod'))
{
@chmod($_path . 'cache', 0755);
@chmod($_path . 'uploads', 0755);
@chmod($_path . 'uploads/thumbs', 0755);
}
}
echo gettpl('check_all.html');
echo gettpl('check_all.html');
break;
case 'data' :
if (ip('datasubmit'))
{
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 $footer_inst;
exit();
}
//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 $footer_inst;
//fix bug #r1777 (alta3rq revision)
if(!empty(p('password')) && !empty(p('password2')) && p('password') != p('password2'))
{
echo $lang['PASS_NEQ_PASS2'];
echo $footer_inst;
exit();
}
if (strpos(p('email'),'@') === false)
{
echo $lang['WRONG_EMAIL'];
echo $footer_inst;
exit();
}
exit();
}
//connect .. for check
//fix bug #r1777 (alta3rq revision)
if (! empty(p('password')) && ! empty(p('password2')) && p('password') != p('password2'))
{
echo $lang['PASS_NEQ_PASS2'];
echo $footer_inst;
exit();
}
if (strpos(p('email'), '@') === false)
{
echo $lang['WRONG_EMAIL'];
echo $footer_inst;
exit();
}
//connect .. for check
$SQL = new KleejaDatabase($dbserver, $dbuser, $dbpass, $dbname);
include_once '../includes/usr.php';
include_once '../includes/functions_alternative.php';
$usrcp = new usrcp;
include_once '../includes/usr.php';
include_once '../includes/functions_alternative.php';
$usrcp = new usrcp;
$user_salt = substr(kleeja_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'), array('id', 'filename', 'direct')) ? p('urls_type') : 'id';
$clean_name = $usrcp->cleanusername($SQL->escape($user_name));
$user_salt = substr(kleeja_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';
/// ok .. we will get sqls now ..
include 'includes/install_sqls.php';
include 'includes/default_values.php';
$err = $dots = 0;
$errors = '';
$err = $dots = 0;
$errors = '';
//do important alter before
$SQL->query($install_sqls['ALTER_DATABASE_UTF']);
//do important alter before
$SQL->query($install_sqls['ALTER_DATABASE_UTF']);
$sqls_done = $sql_err = array();
foreach($install_sqls as $name=>$sql_content)
{
if($name == 'DROP_TABLES' || $name == 'ALTER_DATABASE_UTF')
{
continue;
}
$sqls_done = $sql_err = [];
if($SQL->query($sql_content))
{
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 . '...';
}
}
else
{
$errors .= implode(':', $SQL->get_error()) . '' . "\n___\n";
$sql_err[] = $lang['INST_SQL_ERR'] . ' : ' . $name . '[basic]';
$err++;
}
foreach ($install_sqls as $name=>$sql_content)
{
if ($name == 'DROP_TABLES' || $name == 'ALTER_DATABASE_UTF')
{
continue;
}
}#for
if ($SQL->query($sql_content))
{
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 . '...';
}
}
else
{
$errors .= implode(':', $SQL->get_error()) . '' . "\n___\n";
$sql_err[] = $lang['INST_SQL_ERR'] . ' : ' . $name . '[basic]';
$err++;
}
}//for
if($err == 0)
{
//add configs
foreach($config_values as $cn)
{
if(empty($cn[6]))
{
$cn[6] = 0;
}
if ($err == 0)
{
//add configs
foreach ($config_values as $cn)
{
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}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]');";
//add groups configs
foreach($config_values as $cn)
{
if($cn[4] != 'groups' or !$cn[4])
{
continue;
}
if (! $SQL->query($sql))
{
$errors .= implode(':', $SQL->get_error()) . '' . "\n___\n";
$sql_err[] = $lang['INST_SQL_ERR'] . ' : [configs_values] ' . $cn;
$err++;
}
}
$itxt = '';
foreach(array(1, 2, 3) as $im)
{
$itxt .= ($itxt == '' ? '' : ','). "($im, '$cn[0]', '$cn[1]')";
}
//add groups configs
foreach ($config_values as $cn)
{
if ($cn[4] != 'groups' or ! $cn[4])
{
continue;
}
$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++;
}
}
$itxt = '';
//add exts
foreach($ext_values as $gid=>$exts)
{
$itxt = '';
foreach($exts as $t=>$v)
{
$itxt .= ($itxt == '' ? '' : ','). "('$t', $gid, $v)";
}
foreach ([1, 2, 3] as $im)
{
$itxt .= ($itxt == '' ? '' : ',') . "($im, '$cn[0]', '$cn[1]')";
}
$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++;
}
}
$sql = "INSERT INTO `{$dbprefix}groups_data` (`group_id`, `name`, `value`) VALUES " . $itxt . ';';
//add acls
foreach($acls_values as $cn=>$ct)
{
$it = 1;
$itxt = '';
foreach($ct as $ctk)
{
$itxt .= ($itxt == '' ? '' : ','). "('$cn', '$it', '$ctk')";
$it++;
}
if (! $SQL->query($sql))
{
$errors .= implode(':', $SQL->get_error()) . '' . "\n___\n";
$sql_err[] = $lang['INST_SQL_ERR'] . ' : [groups_configs_values] ' . $cn;
$err++;
}
}
//add exts
foreach ($ext_values as $gid=>$exts)
{
$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 . ';';
echo gettpl('sqls_done.html');
if (! $SQL->query($sql))
{
$errors .= implode(':', $SQL->get_error()) . '' . "\n___\n";
$sql_err[] = $lang['INST_SQL_ERR'] . ' : [acl_values] ' . $cn;
$err++;
}
$it++;
}
}
}
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;
case 'end' :
echo gettpl('end.html');
//for safe ..
//@rename("install.php", "install.lock");
echo gettpl('end.html');
//for safe ..
//@rename("install.php", "install.lock");
break;
}
@@ -391,6 +444,3 @@ break;
* print footer
*/
echo gettpl('footer.html');