Merge branch 'joey-testing' into 'master'
Joey testing See merge request !164
This commit was merged in pull request #168.
This commit is contained in:
71
website/public/fb-callback.php
Normal file
71
website/public/fb-callback.php
Normal file
@@ -0,0 +1,71 @@
|
||||
<?php
|
||||
$fb = new Facebook\Facebook([
|
||||
'app_id' => $appID, // Replace {app-id} with your app id
|
||||
'app_secret' => $appSecret,
|
||||
'default_graph_version' => 'v2.2',
|
||||
]);
|
||||
|
||||
$helper = $fb->getRedirectLoginHelper();
|
||||
|
||||
try {
|
||||
$accessToken = $helper->getAccessToken();
|
||||
} catch(Facebook\Exceptions\FacebookResponseException $e) {
|
||||
// When Graph returns an error
|
||||
echo 'Graph returned an error: ' . $e->getMessage();
|
||||
exit;
|
||||
} catch(Facebook\Exceptions\FacebookSDKException $e) {
|
||||
// When validation fails or other local issues
|
||||
echo 'Facebook SDK returned an error: ' . $e->getMessage();
|
||||
exit;
|
||||
}
|
||||
|
||||
if (! isset($accessToken)) {
|
||||
if ($helper->getError()) {
|
||||
header('HTTP/1.0 401 Unauthorized');
|
||||
echo "Error: " . $helper->getError() . "\n";
|
||||
echo "Error Code: " . $helper->getErrorCode() . "\n";
|
||||
echo "Error Reason: " . $helper->getErrorReason() . "\n";
|
||||
echo "Error Description: " . $helper->getErrorDescription() . "\n";
|
||||
} else {
|
||||
header('HTTP/1.0 400 Bad Request');
|
||||
echo 'Bad request';
|
||||
}
|
||||
exit;
|
||||
}
|
||||
|
||||
// Logged in
|
||||
echo '<h3>Access Token</h3>';
|
||||
var_dump($accessToken->getValue());
|
||||
|
||||
// The OAuth 2.0 client handler helps us manage access tokens
|
||||
$oAuth2Client = $fb->getOAuth2Client();
|
||||
|
||||
// Get the access token metadata from /debug_token
|
||||
$tokenMetadata = $oAuth2Client->debugToken($accessToken);
|
||||
echo '<h3>Metadata</h3>';
|
||||
var_dump($tokenMetadata);
|
||||
|
||||
// Validation (these will throw FacebookSDKException's when they fail)
|
||||
$tokenMetadata->validateAppId($appID); // Replace {app-id} with your app id
|
||||
// If you know the user ID this access token belongs to, you can validate it here
|
||||
//$tokenMetadata->validateUserId('123');
|
||||
$tokenMetadata->validateExpiration();
|
||||
|
||||
if (! $accessToken->isLongLived()) {
|
||||
// Exchanges a short-lived access token for a long-lived one
|
||||
try {
|
||||
$accessToken = $oAuth2Client->getLongLivedAccessToken($accessToken);
|
||||
} catch (Facebook\Exceptions\FacebookSDKException $e) {
|
||||
echo "<p>Error getting long-lived access token: " . $helper->getMessage() . "</p>\n\n";
|
||||
exit;
|
||||
}
|
||||
|
||||
echo '<h3>Long-lived</h3>';
|
||||
var_dump($accessToken->getValue());
|
||||
}
|
||||
|
||||
$_SESSION['fb_access_token'] = (string) $accessToken;
|
||||
|
||||
// User is logged in with a long-lived access token.
|
||||
// You can redirect them to a members-only page.
|
||||
//header('Location: https://example.com/members.php');
|
||||
68
website/public/fbRegister.php
Normal file
68
website/public/fbRegister.php
Normal file
@@ -0,0 +1,68 @@
|
||||
<?php
|
||||
try{
|
||||
$fbUsername = str_replace(' ', '', test_input(($_POST["fbUsername"])));
|
||||
checkInputChoice($fbUsername, "fbUsername");
|
||||
} catch(usernameException $e){
|
||||
$fbCorrect = false;
|
||||
$fbUsernameErr = $e->getMessage();
|
||||
}
|
||||
|
||||
try{
|
||||
$fbPassword = str_replace(' ', '', test_input(($_POST["fbPassword"])));
|
||||
checkInputChoice($fbPassword, "longerEight");
|
||||
matchfbPassword();
|
||||
} catch(passwordException $e){
|
||||
$fbCorrect = false;
|
||||
$fbPasswordErr = $e->getMessage();
|
||||
} catch(fbConfirmPasswordException $e){
|
||||
$fbCorrect = false;
|
||||
$fbConfirmpasswordErr = $e->getMessage();
|
||||
}
|
||||
|
||||
try{
|
||||
$fbName = test_input(($_POST["fbName"]));
|
||||
checkInputChoice($fbName, "lettersAndSpaces");
|
||||
} catch(lettersAndSpacesException $e){
|
||||
$fbCorrect = false;
|
||||
}
|
||||
|
||||
try {
|
||||
$fbSurname = test_input(($_POST["fbSurname"]));
|
||||
checkInputChoice($fbSurname, "lettersAndSpaces");
|
||||
}
|
||||
catch(lettersAndSpacesException $e){
|
||||
$fbCorrect = false;
|
||||
}
|
||||
|
||||
try {
|
||||
$fbDay_date = test_input(($_POST["fbDay_date"]));
|
||||
$fbMonth_date = test_input(($_POST["fbMonth_date"]));
|
||||
$fbYear_date = test_input(($_POST["fbYear_date"]));
|
||||
$fbBday = $fbYear_date . "-" . $fbMonth_date . "-" . $fbDay_date;
|
||||
checkInputChoice($fbBday, "bday");
|
||||
} catch (bdayException $e) {
|
||||
$fbBdayErr = $e->getMessage();
|
||||
$fbCorrect = false;
|
||||
}
|
||||
|
||||
try{
|
||||
$fbEmail = test_input(($_POST["fbEmail"]));
|
||||
checkInputChoice($fbEmail, "fbEmail");
|
||||
} catch(emailException $e){
|
||||
$fbCorrect = false;
|
||||
$fbEmailErr = $e->getMessage();
|
||||
|
||||
}
|
||||
|
||||
$fbUserID = test_input(($_POST["fbUserID"]));
|
||||
|
||||
try {
|
||||
fbRegisterCheck($fbCorrect);
|
||||
} catch(registerException $e){
|
||||
echo "<script>
|
||||
window.onload = function() {
|
||||
$('#fbModal').show();
|
||||
}
|
||||
</script>";
|
||||
$fbRegisterErr = $e->getMessage();
|
||||
}
|
||||
@@ -1,15 +1,23 @@
|
||||
function checkLoggedIn() {
|
||||
if (confirm("U bent al ingelogd!!\nWilt u uitloggen?\nKlik ok om uit te loggen.") == true) {
|
||||
if (confirm("U bent al ingelogd!\nWilt u uitloggen?\nKlik ok om uit te loggen.") == true) {
|
||||
window.location.href = "logout.php";
|
||||
} else {
|
||||
window.location.href = "profile.php";
|
||||
}
|
||||
}
|
||||
|
||||
function emailAlert(){
|
||||
alert("Bevestigingsemail is gestuurd!\n");
|
||||
}
|
||||
|
||||
function bannedAlert(){
|
||||
alert("Uw account is geband!");
|
||||
}
|
||||
|
||||
function frozenAlert(){
|
||||
alert("Uw account is bevroren!\n");
|
||||
}
|
||||
|
||||
function emailNotConfirmed(){
|
||||
alert("Uw account is nog niet bevestigd!\nEr is een nieuwe email gestuurd om uw account te bevestigen");
|
||||
}
|
||||
|
||||
@@ -8,56 +8,21 @@
|
||||
include_once("../queries/emailconfirm.php");
|
||||
include_once("../queries/requestpassword.php");
|
||||
include_once("../queries/register.php");
|
||||
require_once("../queries/Facebook/autoload.php");
|
||||
|
||||
?>
|
||||
<body>
|
||||
<?php
|
||||
session_start();
|
||||
|
||||
// Checks if there's an user already logged in
|
||||
if(isset($_SESSION["userID"])){
|
||||
echo "<script>
|
||||
window.onload=checkLoggedIn();
|
||||
</script>";
|
||||
}
|
||||
include("../views/homeLoginRegister.php");
|
||||
|
||||
// define variables and set to empty values
|
||||
$name = $surname = $bday = $username = $password = $confirmpassword = $location = $housenumber = $email = $confirmEmail = $captcha = $ip = "";
|
||||
$genericErr = $nameErr = $surnameErr = $bdayErr = $usernameErr = $passwordErr = $confirmpasswordErr = $locationErr = $housenumberErr = $emailErr = $confirmEmailErr = $captchaErr = "";
|
||||
$correct = true;
|
||||
$day_date = "dag";
|
||||
$month_date = "maand";
|
||||
$year_date = "jaar";
|
||||
|
||||
// Define variables and set to empty values
|
||||
$user = $psw = $remember ="";
|
||||
$loginErr = $resetErr ="";
|
||||
|
||||
if ($_SERVER["REQUEST_METHOD"] == "POST") {
|
||||
switch ($_POST["submit"]) {
|
||||
case "login":
|
||||
try {
|
||||
$user = ($_POST["user"]);
|
||||
validateLogin($_POST["user"], $_POST["psw"]);
|
||||
} catch(loginException $e) {
|
||||
$loginErr = $e->getMessage();
|
||||
}
|
||||
break;
|
||||
case "reset":
|
||||
try {
|
||||
resetEmail($_POST["forgotEmail"]);
|
||||
sendPasswordRecovery($_POST["forgotEmail"]);
|
||||
} catch (emailException $e){
|
||||
$resetErr = $e->getMessage();
|
||||
echo "<script>
|
||||
window.onload = function() {
|
||||
$('#myModal').show();
|
||||
}
|
||||
</script>";
|
||||
}
|
||||
break;
|
||||
case "register":
|
||||
include("register.php");
|
||||
}
|
||||
}
|
||||
/* This view adds login view */
|
||||
include("../views/login-view.php");
|
||||
?>
|
||||
|
||||
@@ -50,7 +50,7 @@
|
||||
|
||||
try{
|
||||
$location = test_input(($_POST["location"]));
|
||||
checkInputChoice($location, "lettersAndSpaces");
|
||||
checkInputChoice($location, "");
|
||||
} catch(lettersAndSpacesException $e){
|
||||
$correct = false;
|
||||
$locationErr = $e->getMessage();
|
||||
@@ -80,12 +80,12 @@
|
||||
try {
|
||||
getIp();
|
||||
registerCheck($correct);
|
||||
sendConfirmEmailUsername($username);
|
||||
sendConfirmEmail(getUserID()["userID"]);
|
||||
} catch(registerException $e){
|
||||
echo "<script>
|
||||
window.onload = function() {
|
||||
$('#registerModal').show();
|
||||
}
|
||||
</script>";
|
||||
window.onload = function() {
|
||||
$('#registerModal').show();
|
||||
}
|
||||
</script>";
|
||||
$genericErr = $e->getMessage();
|
||||
}
|
||||
|
||||
@@ -10,6 +10,19 @@ a.button {
|
||||
|
||||
}
|
||||
|
||||
a.fbButton {
|
||||
background-color: #3B5998;
|
||||
border-radius: 5px;
|
||||
color: black;
|
||||
cursor: pointer;
|
||||
padding: 8px 20px;
|
||||
font-family: Arial;
|
||||
font-size: 22px;
|
||||
color: white;
|
||||
box-shadow: 0 1px 3px rgba(0,0,0,0.12), 0 1px 2px rgba(0,0,0,0.24);
|
||||
|
||||
}
|
||||
|
||||
/* Body */
|
||||
body {
|
||||
height: 100%;
|
||||
@@ -28,7 +41,7 @@ body {
|
||||
form {
|
||||
/*background-color: #a87a87;*/
|
||||
border-radius: 12px;
|
||||
height: 85%;
|
||||
height: 80%;
|
||||
margin: auto;
|
||||
width: 600px;
|
||||
overflow-y: auto;
|
||||
@@ -154,7 +167,7 @@ ul {
|
||||
display: none; /* Hidden by default */
|
||||
position: fixed; /* Stay in place */
|
||||
z-index: 1; /* Sit on top */
|
||||
padding-top: 30px; /* Location of the box */
|
||||
padding-top: 75px; /* Location of the box */
|
||||
left: 0;
|
||||
top: 0;
|
||||
width: 100%; /* Full width */
|
||||
@@ -216,6 +229,7 @@ ul {
|
||||
}
|
||||
|
||||
.modal-footer {
|
||||
padding: 2px 8px;
|
||||
background-color: #FBC02D;
|
||||
color: black;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user