diff --git a/includes/auth_integration/phpbb.php b/includes/auth_integration/phpbb.php index de778de..766741e 100755 --- a/includes/auth_integration/phpbb.php +++ b/includes/auth_integration/phpbb.php @@ -27,7 +27,7 @@ function kleeja_auth_login ($name, $pass, $hashed = false, $expire, $loginadm = global $lang, $config, $usrcp, $userinfo; global $script_path, $script_encoding, $script_srv, $script_db, $script_user, $script_pass, $script_prefix; - //check for last slash / + //check for last slash / if (isset($script_path)) { if (isset($script_path[strlen($script_path)]) && $script_path[strlen($script_path)] == '/') @@ -76,7 +76,7 @@ function kleeja_auth_login ($name, $pass, $hashed = false, $expire, $loginadm = return; } - //conecting ... + //conecting ... $SQLBB = new KleejaDatabase($forum_srv, $forum_user, $forum_pass, $forum_db, true); $SQLBB->set_names('utf8'); @@ -91,7 +91,7 @@ function kleeja_auth_login ($name, $pass, $hashed = false, $expire, $loginadm = include_once PATH . $script_path . '/includes/utf/utf_tools.' . $phpEx; $row_leve = 'user_type'; - $admin_level = 3; + $admin_level = 3; $query2 = [ 'SELECT' => '*', 'FROM' => "`{$forum_prefix}users`", @@ -109,7 +109,7 @@ function kleeja_auth_login ($name, $pass, $hashed = false, $expire, $loginadm = if (! $hashed) { - $result2 = $SQLBB->build($query2); + $result2 = $SQLBB->build($query2); while ($row=$SQLBB->fetch_array($result2)) { $SQLBB->freeresult($result2); @@ -169,11 +169,11 @@ function kleeja_auth_login ($name, $pass, $hashed = false, $expire, $loginadm = if (! $hashed && ! $loginadm) { $usrcp->kleeja_set_cookie('ulogu', $usrcp->en_de_crypt( - $row['user_id'] . '|' . - $row['user_password'] . '|' . - $expire . '|' . - sha1(md5($config['h_key'] . $row['user_password']) . $expire) . '|' . - ($row[$row_leve] == $admin_level ? '1' : '3') . '|' . + $row['user_id'] . '|' . + $row['user_password'] . '|' . + $expire . '|' . + sha1(md5($config['h_key'] . $row['user_password']) . $expire) . '|' . + ($row[$row_leve] == $admin_level ? '1' : '3') . '|' . $user_y ), $expire); } @@ -183,14 +183,14 @@ function kleeja_auth_login ($name, $pass, $hashed = false, $expire, $loginadm = else { //he is banned from phpBB - $SQLBB->freeresult($result); + $SQLBB->freeresult($result); unset($pass); $SQLBB->close(); return false; } } - $SQLBB->freeresult($result); + $SQLBB->freeresult($result); unset($pass); $SQLBB->close(); return true; diff --git a/includes/common.php b/includes/common.php index ef33469..64dc7c3 100755 --- a/includes/common.php +++ b/includes/common.php @@ -162,7 +162,7 @@ if (empty($script_encoding)) } //start classes .. -$SQL = new KleejaDatabase($dbserver, $dbuser, $dbpass, $dbname); +$SQL = new KleejaDatabase($dbserver, $dbuser, $dbpass, $dbname, $dbprefix); //no need after now unset($dbpass); diff --git a/includes/functions.php b/includes/functions.php index d74824a..db69801 100755 --- a/includes/functions.php +++ b/includes/functions.php @@ -796,7 +796,7 @@ function update_config($name, $value, $escape = true, $group = false) { global $SQL, $dbprefix, $d_groups, $userinfo; - $value = ($escape) ? $SQL->escape($value) : $value; + $value = $escape ? $SQL->escape($value) : $value; $table = "{$dbprefix}config"; //what if this config is a group-configs related ? diff --git a/includes/mysqli.php b/includes/mysqli.php index 0a112e0..f8c8bca 100755 --- a/includes/mysqli.php +++ b/includes/mysqli.php @@ -20,30 +20,34 @@ define('SQL_LAYER', 'mysqli'); class KleejaDatabase { - public $connect_id = null; - public $result; - public $query_num = 0; - public $in_transaction = 0; - public $debugr = false; - public $show_errors = true; + private $connect_id = null; + private $result = null; + public $dbprefix = ''; + private $dbname = ''; + public $query_num = 0; + private $in_transaction = 0; + public $debugr = false; + private $show_errors = true; /* * initiate the class * with basic data */ - public function __construct($host, $db_username, $db_password, $db_name, $new_link = false) + public function __construct($host, $db_username, $db_password, $db_name, $dbprefix) { - global $script_encoding; + $port = 3306; - $host .= strpos($host, ':') !== false ? '' : ':'; - $this->host = substr($host, 0, strpos($host, ':')); - $this->port = (int) substr($host, strpos($host, ':')+1); - $this->db_username = $db_username; - $this->db_name = $db_name; - $this->db_password = 'hidden'; + if (strpos($host, ':') !== false) + { + $host = substr($host, 0, strpos($host, ':')); + $port = (int) substr($host, strpos($host, ':')+1); + } - $this->connect_id = @mysqli_connect($this->host, $this->db_username, $db_password, $this->db_name, (! $this->port ? 3306 : $this->port)); + $this->dbprefix = $dbprefix; + $this->dbname = $db_name; + + $this->connect_id = @mysqli_connect($host, $db_username, $db_password, $db_name, $port); //no error if (defined('MYSQL_NO_ERRORS')) @@ -56,19 +60,18 @@ class KleejaDatabase { //loggin -> no database -> close connection $this->close(); - $this->error_msg('we can not connect to the server ...'); + $this->error_msg('We can not connect to the server ...'); return false; } - //loggin -> connecting + //connecting kleeja_log('[Connected] : ' . kleeja_get_page()); - if ((! preg_match('/utf/i', strtolower($script_encoding)) && ! defined('IN_LOGINPAGE') && ! defined('IN_ADMIN_LOGIN') && ! defined('DISABLE_INTR')) || (empty($script_encoding) || preg_match('/utf/i', strtolower($script_encoding)) || defined('DISABLE_INTR'))) + if (! defined('DISABLE_MYSQL_UTF8')) { if (mysqli_set_charset($this->connect_id, 'utf8')) { - //loggin -> set utf8 kleeja_log('[Set to UTF8] : --> '); } } @@ -413,7 +416,6 @@ class KleejaDatabase // error message func public function error_msg($msg) { - global $dbprefix; if (! $this->show_errors) { @@ -427,10 +429,10 @@ class KleejaDatabase //some ppl want hide their table names if (! defined('DEV_STAGE')) { - $error_sql = preg_replace_callback("#\s{1,3}`*{$dbprefix}([a-z0-9]+)`*\s{1,3}#", function($m) { - return '' . substr($m[1], 0, 1) . ''; + $error_sql = preg_replace_callback("#\s{1,3}`*{$this->dbprefix}([a-z0-9]+)`*\s{1,3}#", function($m) { + return ' ' . substr($m[1], 0, 1) . ' '; }, $error_sql); - $error_msg = preg_replace_callback("#{$this->db_name}.{$dbprefix}([a-z0-9]+)#", function($m) { + $error_msg = preg_replace_callback("#{$this->dbname}.{$this->dbprefix}([a-z0-9]+)#", function($m) { return ' ' . substr($m[1], 0, 1) . ' '; }, $error_msg); $error_sql = preg_replace_callback("#\s{1,3}(from|update|into)\s{1,3}([a-z0-9]+)\s{1,3}#i", function($m) { @@ -459,7 +461,7 @@ class KleejaDatabase $error_message .= '
'; $error_message .= '
'; $error_message .= " click to Refresh this page ...
"; - $error_message .= '

Sorry , We encounter a MySQL error: ' . ($msg !='' ? $msg : '') . '

'; + $error_message .= '

Sorry , We encountered a MySQL error: ' . ($msg !='' ? $msg : '') . '

'; if ($error_sql != '') { diff --git a/includes/usr.php b/includes/usr.php index 56ccd8b..fdef041 100755 --- a/includes/usr.php +++ b/includes/usr.php @@ -17,20 +17,14 @@ if (! defined('IN_COMMON')) class usrcp { - // this function like a traffic sign :) public function data ($name, $pass, $hashed = false, $expire = 86400, $loginadm = false) { global $config, $userinfo; - //return user system to normal - if (defined('DISABLE_INTR') || $config['user_system'] == '' || empty($config['user_system'])) - { - $config['user_system'] = '1'; - } - - //expire $expire = time() + ((int) $expire ? intval($expire) : 86400); + $name = trim($name); + $pass = trim($pass); $return_now = $login_status = false; @@ -42,19 +36,8 @@ class usrcp } - if ((int) $config['user_system'] != 1) - { - if (file_exists(PATH . 'includes/auth_integration/' . trim($config['user_system']) . '.php')) - { - include_once PATH . 'includes/auth_integration/' . trim($config['user_system']) . '.php'; - $login_status = kleeja_auth_login(trim($name), trim($pass), $hashed, $expire, $loginadm); - - return $login_status; - } - } - //normal - return $this->normal(trim($name), trim($pass), $hashed, $expire, $loginadm); + return $this->normal($name, $pass, $hashed, $expire, $loginadm); } //get username by id @@ -62,12 +45,6 @@ class usrcp { global $config; - //return user system to normal - if (defined('DISABLE_INTR')) - { - $config['user_system'] = 1; - } - $return_now = $auth_status = false; is_array($plugin_run_result = Plugins::getInstance()->run('auth_func_usr_class', get_defined_vars())) ? extract($plugin_run_result) : null; //run hook @@ -77,22 +54,13 @@ class usrcp return $auth_status; } - if ((int) $config['user_system'] != 1) - { - if (file_exists(PATH . 'includes/auth_integration/' . trim($config['user_system']) . '.php')) - { - include_once PATH . 'includes/auth_integration/' . trim($config['user_system']) . '.php'; - return kleeja_auth_username($user_id); - } - } - //normal system $u = $this->get_data('name', $user_id); return $u['name']; } //now our table, normal user system - public function normal ($name, $pass, $hashed = false, $expire, $loginadm = false) + public function normal($name, $pass, $hashed = false, $expire, $loginadm = false) { global $SQL, $dbprefix, $config, $userinfo; diff --git a/install/includes/functions_install.php b/install/includes/functions_install.php index 1d47b89..85b278c 100755 --- a/install/includes/functions_install.php +++ b/install/includes/functions_install.php @@ -168,7 +168,7 @@ function inst_get_config($name) return false; } - $SQL = new KleejaDatabase($dbserver, $dbuser, $dbpass, $dbname); + $SQL = new KleejaDatabase($dbserver, $dbuser, $dbpass, $dbname, $dbprefix); } if (empty($SQL)) diff --git a/install/includes/install_sqls.php b/install/includes/install_sqls.php index 45896fb..cc095f6 100755 --- a/install/includes/install_sqls.php +++ b/install/includes/install_sqls.php @@ -101,18 +101,18 @@ $install_sqls['files'] = " CREATE TABLE `{$dbprefix}files` ( `id` int(11) unsigned NOT NULL auto_increment, `last_down` int(11) unsigned NOT NULL DEFAULT '0', - `name` varchar(300) collate utf8_bin NOT NULL, - `real_filename` VARCHAR( 350 ) collate utf8_bin NOT NULL, + `name` varchar(300) collate utf8_bin NOT NULL DEFAULT '', + `real_filename` VARCHAR( 350 ) collate utf8_bin NOT NULL DEFAULT '', `size` bigint(20) unsigned NOT NULL DEFAULT '0', `uploads` int(11) unsigned NOT NULL DEFAULT '0', - `time` int(11) unsigned NOT NULL, + `time` int(11) unsigned NOT NULL DEFAULT '0', `type` varchar(20) collate utf8_bin NOT NULL, `folder` varchar(100) collate utf8_bin NOT NULL, `report` int(11) unsigned NOT NULL DEFAULT '0', `user` int(11) NOT NULL default '-1', - `code_del` varchar(150) collate utf8_bin NOT NULL, - `user_ip` VARCHAR( 250 ) NOT NULL, - `id_form` VARCHAR( 100 ) NOT NULL, + `code_del` varchar(150) collate utf8_bin NOT NULL DEFAULT '', + `user_ip` VARCHAR( 250 ) NOT NULL DEFAULT '', + `id_form` VARCHAR( 100 ) NOT NULL DEFAULT 'id', PRIMARY KEY (`id`), KEY `name` (`name`(300)), KEY `user` (`user`), @@ -128,8 +128,8 @@ CREATE TABLE `{$dbprefix}files` ( $install_sqls['config'] = " CREATE TABLE `{$dbprefix}config` ( `name` varchar(255) collate utf8_bin NOT NULL, - `value` varchar(255) collate utf8_bin NOT NULL, - `option` mediumtext collate utf8_bin NOT NULL, + `value` varchar(255) collate utf8_bin NOT NULL DEFAULT '', + `option` mediumtext collate utf8_bin NOT NULL DEFAULT '', `display_order` int(10) NOT NULL DEFAULT '1', `type` varchar(20) NULL DEFAULT 'other', `plg_id` int(11) NOT NULL DEFAULT '0', @@ -157,16 +157,16 @@ CREATE TABLE `{$dbprefix}config` ( $install_sqls['plugins'] = " CREATE TABLE `{$dbprefix}plugins` ( `plg_id` int(11) unsigned NOT NULL auto_increment, - `plg_name` varchar(255) collate utf8_bin NOT NULL, + `plg_name` varchar(255) collate utf8_bin NOT NULL DEFAULT '', `plg_ver` varchar(255) collate utf8_bin NOT NULL, - `plg_author` varchar(255) collate utf8_bin NOT NULL, - `plg_dsc` mediumtext COLLATE utf8_bin NOT NULL, - `plg_icon` blob NOT NULL, - `plg_uninstall` mediumtext COLLATE utf8_bin NOT NULL, + `plg_author` varchar(255) collate utf8_bin NOT NULL DEFAULT '', + `plg_dsc` mediumtext COLLATE utf8_bin NOT NULL DEFAULT '', + `plg_icon` blob NOT NULL DEFAULT '', + `plg_uninstall` mediumtext COLLATE utf8_bin NOT NULL DEFAULT '', `plg_disabled` tinyint(1) unsigned NOT NULL default '0', - `plg_instructions` mediumtext COLLATE utf8_bin NOT NULL, - `plg_store` longtext COLLATE utf8_bin NOT NULL, - `plg_files` text COLLATE utf8_bin NOT NULL, + `plg_instructions` mediumtext COLLATE utf8_bin NOT NULL DEFAULT '', + `plg_store` longtext COLLATE utf8_bin NOT NULL DEFAULT '', + `plg_files` text COLLATE utf8_bin NOT NULL DEFAULT '', PRIMARY KEY (`plg_id`), KEY `plg_name` (`plg_name`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin ; @@ -174,9 +174,9 @@ CREATE TABLE `{$dbprefix}plugins` ( $install_sqls['lang'] = " CREATE TABLE `{$dbprefix}lang` ( - `word` varchar(255) collate utf8_bin NOT NULL, - `trans` varchar(255) collate utf8_bin NOT NULL, - `lang_id` varchar(100) COLLATE utf8_bin NOT NULL, + `word` varchar(255) collate utf8_bin NOT NULL , + `trans` varchar(255) collate utf8_bin NOT NULL DEFAULT '', + `lang_id` varchar(100) COLLATE utf8_bin NOT NULL DEFAULT 'en', `plg_id` int(11) unsigned NOT NULL DEFAULT '0', KEY `lang_id` (`lang_id`), KEY `plg_id` (`plg_id`), @@ -198,7 +198,7 @@ $install_sqls['groups_data'] = " CREATE TABLE `{$dbprefix}groups_data` ( `group_id` int(11) unsigned NOT NULL, `name` varchar(255) COLLATE utf8_bin NOT NULL, - `value` varchar(255) COLLATE utf8_bin NOT NULL, + `value` varchar(255) COLLATE utf8_bin NOT NULL DEFAULT '', KEY `group_id` (`group_id`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin; "; diff --git a/install/install.php b/install/install.php index 6598ccf..74e99d0 100755 --- a/install/install.php +++ b/install/install.php @@ -140,7 +140,7 @@ case 'check': if (! empty($dbname) && ! empty($dbuser)) { //connect .. for check - $SQL = new KleejaDatabase($dbserver, $dbuser, $dbpass, $dbname); + $SQL = new KleejaDatabase($dbserver, $dbuser, $dbpass, $dbname, $dbprefix); if (! $SQL->is_connected()) @@ -202,7 +202,7 @@ case 'data' : } //connect .. for check - $SQL = new KleejaDatabase($dbserver, $dbuser, $dbpass, $dbname); + $SQL = new KleejaDatabase($dbserver, $dbuser, $dbpass, $dbname, $dbprefix); include_once PATH . 'includes/usr.php'; include_once PATH . 'includes/functions_alternative.php'; diff --git a/install/quick.php b/install/quick.php index a376ea1..c3baa50 100644 --- a/install/quick.php +++ b/install/quick.php @@ -49,7 +49,7 @@ else exit('`config.php` was missing! so we created one for you, kindly edit the file with database information.'); } -$SQL = new KleejaDatabase($dbserver, $dbuser, $dbpass, $dbname); +$SQL = new KleejaDatabase($dbserver, $dbuser, $dbpass, $dbname, $dbprefix); if (! $SQL->is_connected()) { @@ -76,7 +76,7 @@ foreach (['cache', 'uploads', 'uploads/thumbs'] as $folder) //install -$SQL = new KleejaDatabase($dbserver, $dbuser, $dbpass, $dbname); +$SQL = new KleejaDatabase($dbserver, $dbuser, $dbpass, $dbname, $dbprefix); include_once PATH . 'includes/usr.php'; include_once PATH . 'includes/functions_alternative.php'; diff --git a/install/update.php b/install/update.php index 30b4213..e6209b4 100755 --- a/install/update.php +++ b/install/update.php @@ -34,7 +34,7 @@ include_once 'includes/functions_install.php'; include_once 'includes/update_schema.php'; -$SQL = new KleejaDatabase($dbserver, $dbuser, $dbpass, $dbname); +$SQL = new KleejaDatabase($dbserver, $dbuser, $dbpass, $dbname, $dbprefix); // // fix missing db_version diff --git a/lang/ar/common.php b/lang/ar/common.php index cc98b76..2b2e346 100755 --- a/lang/ar/common.php +++ b/lang/ar/common.php @@ -191,9 +191,6 @@ return [ 'NOT_SAFE_FILE' => 'نظام كليجا اكتشف أن الملف "%s" غير آمن ويحتوي على أكواد خبيثه .. !!', 'ARE_YOU_SURE_DO_THIS' => 'هل أنت متأكد من القيام بهذه العملية؟', 'SITE_FOR_MEMBER_ONLY' => 'المركز للأعضاء فقط ، قم بالتسجيل أو بالدخول حتى تتمكن من التحميل.', - 'AUTH_INTEGRATION_N_UTF8_T' => '%s ليست utf8', - 'AUTH_INTEGRATION_N_UTF8' => '%s يجب أن يكون ترميز قاعدة البيانات الخاصة به utf8 لكي يتم الربط مع كليجا!.', - 'SCRIPT_AUTH_PATH_WRONG' => 'مسار السكربت %s الذي تم ربط عضويات كليجا معه خاطئ ,قم بضبطه', 'SHOW_MY_FILECP' => 'السماح بعرض ملفاتي', 'PASS_CHANGE' => 'تغيير كلمة المرور', 'EDIT_U_AVATER' => 'تغيير الصورة الرمزية', diff --git a/lang/en/common.php b/lang/en/common.php index f050c6f..48ac639 100755 --- a/lang/en/common.php +++ b/lang/en/common.php @@ -187,9 +187,6 @@ return [ 'NOT_SAFE_FILE' => 'Kleeja found that the File "%s" is not safe!', 'ARE_YOU_SURE_DO_THIS' => 'Are you sure you want to do this?', 'SITE_FOR_MEMBER_ONLY' => 'This center is only for members, register or login to upload your files.', - 'AUTH_INTEGRATION_N_UTF8_T' => '%s is not utf8', - 'AUTH_INTEGRATION_N_UTF8' => '%s database must be utf8 to be integrated with Kleeja !.', - 'SCRIPT_AUTH_PATH_WRONG' => 'Path of %s is not valid, change it now.', 'SHOW_MY_FILECP' => 'Show my files', 'PASS_CHANGE' => 'Change password', 'EDIT_U_AVATER' => 'ُEdit your avatar',