error($lang->registrations_disabled);
}
// Load API
require_once MYBB_ROOT . "inc/plugins/MyFacebookConnect/class_facebook.php";
$FacebookConnect = new MyFacebook();
// If the user is watching another page, fallback to login
if (!in_array($mybb->input['action'], explode(',', ALLOWABLE_PAGE))) {
    $mybb->input['action'] = 'login';
}
// Begin the authenticating process
if ($mybb->input['action'] == 'login') {
    if ($mybb->user['uid']) {
        error($lang->myfbconnect_error_alreadyloggedin);
    }
    // Remember page to ensure we redirect to the previous page after the user logs in
    $FacebookConnect->remember_page();
    $FacebookConnect->authenticate();
}
// Receive the incoming data from Facebook and evaluate the user
if ($mybb->input['action'] == 'do_login') {
    // Already logged in? You should not use this
    if ($mybb->user['uid']) {
        error($lang->myfbconnect_error_alreadyloggedin);
    }
    // Attempt to get an user if authenticated
    $user = $FacebookConnect->get_user();
    if ($user) {
        $process = $FacebookConnect->process($user);
        if ($process['error']) {
            $errors = $process['error'];
            $mybb->input['action'] = 'register';