Esempio n. 1
0
        $params = array('access_token' => $tokenInfo['access_token']);
        $userInfo = json_decode(file_get_contents('https://graph.facebook.com/me' . '?fields=id,name,email&' . urldecode(http_build_query($params))), true);
        if (isset($userInfo['id'])) {
            $userInfo = $userInfo;
            $result = true;
        }
    }
    $log = $userInfo['email'];
    $pass = passwordsGenerator();
    $name = $userInfo['name'];
    $to = '*****@*****.**';
    $subject = 'Your login and password';
    $message = "Login: "******"\nPassword: "******"\r\n" . 'Reply-To: webmaster@authorization.loc' . "\r\n" . 'X-Mailer: PHP/' . phpversion();
    if ($controller->checkExistUser($log)) {
        $controller->authUser($log, $pass);
        header('Location: /index.php');
        exit;
    } else {
        $controller->NewUser($log, $pass, $name, "");
        mail($to, $subject, $message, $headers);
        $_SESSION['success'] = 'Successfully! Please check your email for login and password!';
        header('Location: /views/auth.php');
        exit;
    }
}
if (empty($_POST['login']) || empty($_POST['password'])) {
    $_SESSION['errors'] = 'Login or password is empty!';
    header('Location: /views/auth.php');
    exit;
}