احتاج مساعدة في ربط سكربت mybb
علمناً اني انشأت ملف الربط mybb.php
انا مبتدأ في البرمجة , قمت بنسخ محتويات vb.php و التعديل عليها ووصلت لهذا الحد
كود: تحديد الكل
<?php
//no for directly open
if (!defined('IN_COMMON'))
{
exit();
}
//
//Path of config file in vb
//
if(!defined('SCRIPT_CONFIG_PATH'))
{
define('SCRIPT_CONFIG_PATH', '/inc/config.php');
}
function kleeja_auth_login ($name, $pass, $hashed = false, $expire, $loginadm = false, $return_name = false)
{
global $lang, $config, $usrcp, $userinfo;
global $script_path, $script_cp1256, $script_srv, $script_db, $script_user, $script_pass, $script_prefix, $script_db_charset;
global $allow_group ;
if(isset($script_path))
{
//check for last slash
if(isset($script_path[strlen($script_path)]) && $script_path[strlen($script_path)] == '/')
{
$script_path = substr($script_path, 0, strlen($script_path));
}
//get some useful data from mybb config file
if(file_exists(PATH . $script_path . SCRIPT_CONFIG_PATH))
{
require_once (PATH . $script_path . SCRIPT_CONFIG_PATH);
//
//get config from config file
//
$forum_srv = $config['database']['hostname'];
$forum_db = $config['database']['database'];
$forum_user = $config['database']['username'];
$forum_pass = $config['database']['password'];
$forum_prefix= $config['Database']['tableprefix'];
//some people change their db charset
if(isset($config['database']['encoding']))
{
$forum_db_charset = $config['database']['encoding'];
}
}
else
{
big_error('Forum path is not correct', sprintf($lang['SCRIPT_AUTH_PATH_WRONG'], 'Mybb'));
}
}
else
{
//
//custom config data
//
$forum_srv = $script_srv;
$forum_db = $script_db;
$forum_user = $script_user;
$forum_pass = $script_pass;
$forum_prefix = $script_prefix;
//some people change their db charset
if(isset($script_db_charset))
{
$forum_db_charset = $script_db_charset;
}
}
if(empty($forum_srv) || empty($forum_user) || empty($forum_db))
{
return;
}
$SQLMBB = new SSQL($forum_srv, $forum_user, $forum_pass, $forum_db, true);
if(isset($forum_db_charset))
{ //config
$SQLMBB->set_names($forum_db_charset);
}
else //auto
{
$SQLMBB->set_names('utf8');
}
unset($forum_pass); // We do not need this any longer
$pass = $usrcp->kleeja_utf8($pass, false);
$name = $usrcp->kleeja_utf8($name, false);
$query_salt = array(
'SELECT' => '*',
'FROM' => "`$forum_prefix users`",
);
$query_salt['WHERE'] = $hashed ? "uid=" . intval($name) ."' AND usergroup != '7'" : "username='" . $SQLMBB->real_escape($name) . "' AND usergroup != '7'";
//if return only name let's ignore the obove
if($return_name)
{
$query_salt['SELECT'] = "username";
$query_salt['WHERE'] = "uid=" . intval($name);
}
($hook = kleeja_run_hook('qr_select_usrdata_mybb_usr_class')) ? eval($hook) : null; //run hook
$result_salt = $SQLMBB->build($query_salt);
if ($SQLMBB->num_rows($result_salt) != 0)
{
while($row1=$SQLMBB->fetch_array($result_salt))
{
if($return_name)
{
return empty($script_cp1256) || !$script_cp1256 ? $row1['username'] : $usrcp->kleeja_utf8($row1['username']);
}
if(!$hashed)
{
$pass = md5(md5($row1['salt']).md5($pass)); // without normal md5
$query = array(
'SELECT' => '*',
'FROM' => "`{$forum_prefix}users`",
'WHERE' => "username='" . $SQLMBB->real_escape($name) . "' AND password='" . $SQLMBB->real_escape($pass) . "' AND uid != '7' "
);
$result = $SQLMBB->build($query);
if ($SQLMBB->num_rows($result) != 0)
{
while($row=$SQLMBB->fetch_array($result))
{
if(!$loginadm)
{
define('USER_ID', $row['uid']);
define('USER_NAME', empty($script_cp1256) || !$script_cp1256 ? $row['username'] : $usrcp->kleeja_utf8($row['username']));
define('USER_MAIL', $row['email']);
define('USER_ADMIN', $row['usergroup'] == 1 ? 1 : 0);
}
//define('LAST_VISIT',$row['last_visit']);
$userinfo = $row;
$user_y = kleeja_base64_encode(serialize(array('id'=>$row['uid'], 'name'=>USER_NAME, 'mail'=>$row['email'], 'last_visit'=>time())));
$hash_key_expire = sha1(md5($config['h_key'] . $row['password']) . $expire);
if(!$loginadm)
{
$usrcp->kleeja_set_cookie('ulogu', $usrcp->en_de_crypt($row['uid'] . '|' . $row['password'] . '|' . $expire . '|' . $hash_key_expire . '|' . (defined('USER_ADMIN') ? '1': '0') . '|' . $user_y), $expire);
}
($hook = kleeja_run_hook('qr_while_usrdata_mybb_usr_class')) ? eval($hook) : null; //run hook
}
$SQLMBB->freeresult($result);
}#nums_sql2
else
{
$SQLMBB->close();
return false;
}
}
else
{
if(!$loginadm)
{
define('USER_ID', $row1['uid']);
define('USER_NAME', empty($script_cp1256) || !$script_cp1256 ? $row1['username'] : $usrcp->kleeja_utf8($row1['username']));
define('USER_MAIL',$row1['email']);
define('USER_ADMIN',($row1['usergroup'] == 1) ? 1 : 0);
$userinfo = $row1;
}
}
}#whil1
$SQLMBB->freeresult($result_salt);
unset($pass);
$SQLMBB->close();
return true;
}
else
{
$SQLMBB->close();
return false;
}
}
function kleeja_auth_username ($user_id)
{
return kleeja_auth_login ($user_id, false, true, 0, false, true);
}