Facebook login implemented

This commit is contained in:
Joey Lai
2017-01-31 16:12:22 +01:00
parent 08f668859c
commit 8e98001217
82 changed files with 11126 additions and 133 deletions

View File

@@ -18,6 +18,21 @@ function getUser() {
return $stmt->fetch(PDO::FETCH_ASSOC);
}
function getUserID() {
$stmt = $GLOBALS["db"]->prepare("
SELECT
`userID`
FROM
`user`
WHERE
`username` LIKE :username
");
$stmt->bindValue(":username", test_input($_POST["username"]));
$stmt->execute();
return $stmt->fetch(PDO::FETCH_ASSOC);
}
function validateLogin($username, $password){
// Empty username or password field
if (empty($username) || empty($password)) {
@@ -35,6 +50,12 @@ function validateLogin($username, $password){
echo "<script>
window.onload=bannedAlert();
</script>";
} else if ($role == "frozen"){
$_SESSION["userID"] = $userID;
echo "<script>
window.onload=frozenAlert();
window.location.href= 'profile.php';
</script>";
} else if ($role == "unconfirmed"){
sendConfirmEmail(getUser()["userID"]);
echo "<script>
@@ -42,9 +63,6 @@ function validateLogin($username, $password){
</script>";
} else {
$_SESSION["userID"] = $userID;
// if($_POST[rememberMe] == 1){
// ini_set("session.gc_maxlifetime", "10");
// }
header("location: profile.php");
}
} else {
@@ -54,6 +72,40 @@ function validateLogin($username, $password){
}
}
function fbLogin($email) {
$stmt = $GLOBALS["db"]->prepare("
SELECT
`email`,
`userID`,
`role`
FROM
`user`
WHERE
`email` LIKE :email
");
$stmt->bindValue(":email", $email);
$stmt->execute();
return $stmt->rowCount();
}
function getfbUserID($email) {
$stmt = $GLOBALS["db"]->prepare("
SELECT
`userID`,
`role`
FROM
`user`
WHERE
`email` LIKE :email
");
$stmt->bindValue(":email", $email);
$stmt->execute();
return $stmt->fetch(PDO::FETCH_ASSOC);
}
class loginException extends Exception
{
public function __construct($message = "", $code = 0, Exception $previous = null)