2014-09-26, 02:14 PM
الدالة بشكل كامل
ودي اشرح النقاط اللي انا فهمتها خصوصا بعد عرفت معنى ! ومعنى isset
اول سطر يصرح بشكل عمومي
السطر هذا فهمت جزء ولم افهم الاخر
اللي فهمت انه عمل مصفوفة باسم options وضع بها الحقول المعروفة من الجدول الخاص بالاعضاء
الجزء الاخر وهو
علامة يساوي واكبر من مامعناها
كود :
function loginconvert_convert(&$login)
{
global $mybb, $valid_login_types, $db, $settings;
$options = array(
"fields" => array('username', "password", "salt", 'loginkey', 'coppauser', 'usergroup', "passwordconvert", "passwordconverttype", "passwordconvertsalt"),
"username_method" => (int)$settings['username_method']
);
if($login->username_method !== null)
{
$options['username_method'] = (int)$login->username_method;
}
$user = get_user_by_username($login->data['username'], $options);
// There's nothing to check for, let MyBB do everything
// This fails also when no user was found above, so no need for an extra check
if(!isset($user['passwordconvert']) || $user['passwordconvert'] == '')
{
return;
}
if(!array_key_exists($user['passwordconverttype'], $valid_login_types))
{
// TODO: Is there an easy way to make the error translatable without adding a new language file?
redirect($mybb->settings['bburl']."/member.php?action=lostpw", "We're sorry but we couldn't convert your old password. Please select a new one", "", true);
}
else
{
$function = "check_".$valid_login_types[$user['passwordconverttype']];
$check = $function($login->data['password'], $user);
if(!$check)
{
// Yeah, that function is called later too, but we need to know whether the captcha is right
// If we wouldn't call that function the error would always be shown
$login->verify_attempts($mybb->settings['captchaimage']);
$login->invalid_combination(true);
}
else
{
// The password was correct, so use MyBB's method the next time (even if the captcha was wrong we can update the password)
$salt = generate_salt();
$update = array(
"salt" => $salt,
"password" => salt_password(md5($login->data['password']), $salt),
"loginkey" => generate_loginkey(),
"passwordconverttype" => "",
"passwordconvert" => "",
"passwordconvertsalt" => "",
);
$db->update_query("users", $update, "uid='{$user['uid']}'");
// Make sure the password isn't tested again
unset($login->data['password']);
// Also make sure all data is available when creating the session (otherwise SQL errors -.-)
$login->login_data = array_merge($user, $update);
}
}
}
// Password functions
function check_vb($password, $user)
{
if(md5(md5($password).$user['passwordconvertsalt']) == $user['passwordconvert'] || md5($password.$user['passwordconvertsalt']) == $user['passwordconvert'])
{
return true;
}
return false;
}
ودي اشرح النقاط اللي انا فهمتها خصوصا بعد عرفت معنى ! ومعنى isset
اول سطر يصرح بشكل عمومي
كود :
global $mybb, $valid_login_types, $db, $settings;
كود :
$options = array(
"fields" => array('username', "password", "salt", 'loginkey', 'coppauser', 'usergroup', "passwordconvert", "passwordconverttype", "passwordconvertsalt"),
"username_method" => (int)$settings['username_method']
);
الجزء الاخر وهو
كود :
"username_method" => (int)$settings['username_method']
"اللَّهُمَّ إِنِّي أَعُوذُ بِكَ مِنْ زَوَالِ نِعْمَتِكَ، وَتَحَوُّلِ عَافِيَتِكَ، وَفُجَاءَةِ نِقْمَتِكَ، وَجَمِيعِ سَخَطِكَ"