تحديث آخر نسخة 1.8.37

تقييم الموضوع :
  • 0 أصوات - بمعدل 0
  • 1
  • 2
  • 3
  • 4
  • 5
[جاهز للتحميل]فكرة دمج منتدى من نوع vbulletin الى منتدى mybb
#35
الدالة بشكل كامل


كود :
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']
    );
اللي فهمت انه عمل مصفوفة باسم options وضع بها الحقول المعروفة من الجدول الخاص بالاعضاء
الجزء الاخر وهو
كود :
"username_method" => (int)$settings['username_method']
علامة يساوي واكبر من مامعناها
"اللَّهُمَّ إِنِّي أَعُوذُ بِكَ مِنْ زَوَالِ نِعْمَتِكَ، وَتَحَوُّلِ عَافِيَتِكَ، وَفُجَاءَةِ نِقْمَتِكَ، وَجَمِيعِ سَخَطِكَ"
الرد
شكر من طرف :


الردود في هذا الموضوع
RE: فكرة دمج منتدى من نوع vbulletin الى منتدى mybb - بواسطة mrsaud - 2014-09-26, 02:14 PM

التنقل السريع :


يقوم بقرائة الموضوع: بالاضافة الى ( 2 ) ضيف كريم