/**
 *
 * Steam Redirect - steam_redirect
 * - - - - - - - - - - - - - - -
 * @desc Redirects the browser to Steam OpenID website for login.
 * @since 1.0
 * @version 1.6
 *
 */
function steam_redirect()
{
    global $mybb, $db;
    // Check if the user is logged in or not.
    if ($mybb->user['uid'] == 0) {
        // Get the Steam API key set in settings.
        $get_key = $db->fetch_array($db->simple_select("settings", "name, value", "name = 'steamlogin_api_key'"));
        if ($get_key['value'] == null) {
            // The Steam API key hasn't been set, so stop the script and output error message.
            die("<strong>Not Configured</strong> The Steam Login plugin hasn't been configured correctly. Please ensure an API key is set in the Configuration settings.");
        } else {
            // close if($get_key['value'] == null)
            // Do a check for required profile fields.
            $count_required_fields = $db->num_rows($db->simple_select("profilefields", "*", "required = '1'"));
            $return_url = '/misc.php?action=steam_return';
            //Set options for the OpenID library.
            require_once MYBB_ROOT . 'inc/class_lightopenid.php';
            $SteamOpenID = new LightOpenID();
            $SteamOpenID->returnUrl = $mybb->settings['bburl'] . $return_url;
            $SteamOpenID->__set('realm', $mybb->settings['bburl'] . $return_url);
            $SteamOpenID->identity = 'http://steamcommunity.com/openid';
            // Redirect directly to Steam.
            redirect($SteamOpenID->authUrl(), 'You are being redirect to Steam to authenticate your account for use on our website.', 'Login via Steam');
        }
        // close else
    }
    // close if($mybb->user['uid'] == 0)
}