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 .= '