Merge branch 'master' into kevin-prototype

This commit is contained in:
K. Nobel
2017-01-25 15:08:34 +01:00
21 changed files with 253 additions and 54 deletions

View File

@@ -1,7 +1,8 @@
<?php
session_start();
require("../queries/friendship.php");
require("../queries/user.php");
require("../../queries/friendship.php");
require("../../queries/user.php");
if(empty($_POST["userID"]) OR empty($_POST["delete"]) AND empty($_POST["accept"]) AND empty($_POST["request"])) {
echo "Not enough arguments.";
@@ -27,4 +28,4 @@ if(!empty($_POST["request"]) AND $friendship_status == 0) {
$username = getUsername($_POST["userID"]);
header("Location: profile.php?username=$username");
header("Location: ../profile.php?username=$username");

View File

@@ -0,0 +1,49 @@
<?php
include_once("../queries/connect.php");
if (array_key_exists("u", $_GET) and array_key_exists("h", $_GET)) {
$checkHash = $GLOBALS["db"]->prepare("
SELECT
`email`,
`role`
FROM
`user`
WHERE
`userID` = :userID
");
$checkHash->bindParam(":userID", $_GET["u"]);
$checkHash->execute();
$result = $checkHash->fetch();
$email = $result["email"];
$role = $result["role"];
if ($role == "unconfirmed") {
doActivate($email);
} else {
echo "Ongeldige link.";
}
} else {
echo "Ongeldige link.";
}
function doActivate(string $email) {
if (password_verify($email, $_GET["h"])) {
$confirmUser = $GLOBALS["db"]->prepare("
UPDATE
`user`
SET
`role` = :role
WHERE
`userID` = :userID
");
$confirmUser->bindValue(":role", "user");
$confirmUser->bindParam(":userID", $_GET["u"]);
$confirmUser->execute();
if ($confirmUser->rowCount()) {
echo "Email bevestigd <br />
<a href='index.php'>U wordt automatisch doorgestuurd naar de login pagina over 5 seconden.</a> ";
header("refresh:5;url=login.php");
}
} else {
echo "Ongeldige link.";
}
}

View File

@@ -1,8 +1,18 @@
function showFriendNotifications(notifications) {
$("#friendrequestslist").html("");
for (i in notifications) {
var outgoing = "";
if (notifications[i].friend_state == "3") {
outgoing = "<button\
name='accept' \
class='accept-notification' \
value='"+ notifications[i].userID +"'> \
<i class='fa fa-check'></i> \
</button>";
}
$("#friendrequestslist").append(" \
<li class='friend-item $extraItem'> \
<li class='friend-item'> \
<form action='profile.php' method='get'> \
<button type='submit' \
name='username' \
@@ -13,6 +23,18 @@ function showFriendNotifications(notifications) {
</div> \
</button> \
</form> \
<div class='notification-options'>\
<form action='API/edit_friendship.php' method='post'> \
<input type='hidden' name='userID' value='"+ notifications[i].userID +"' /> \
"+ outgoing +" \
<button type='submit' \
name='delete' \
class='deny-notification' \
value='"+ notifications[i].userID +"'> \
<i class='fa fa-times'></i> \
</button>\
<form>\
</div> \
</li> \
");
}
@@ -22,10 +44,10 @@ function showChatNotifications(notifications) {
$("#unreadChatlist").html("");
for (i in notifications) {
$("#unreadChatlist").append(" \
<li class='friend-item $extraItem'> \
<li class='friend-item'> \
<form action='chat.php' method='get'> \
<button type='submit' \
name='username' \
name='chatID' \
value='"+ notifications[i].userID +"'> \
<div class='friend'> \
<img alt='PF' class='profile-picture' src='"+ notifications[i].profilepicture +"'/> \

View File

@@ -4,5 +4,12 @@ function checkLoggedIn() {
} else {
window.location.href = "profile.php";
}
document.getElementById("demo").innerHTML = x;
}
function bannedAlert(){
alert("Your account is banned");
}
function emailNotConfirmed(){
alert("Your account has not been verified yet!\nAnother email has been sent to you")
}

View File

@@ -5,6 +5,7 @@
require_once("../queries/connect.php");
include_once("../queries/login.php");
include_once("../queries/checkInput.php");
include_once("../queries/emailconfirm.php");
?>
<body>
<?php
@@ -22,26 +23,11 @@
// Trying to login
if ($_SERVER["REQUEST_METHOD"] == "POST") {
// Empty username or password field
if (empty($_POST["uname"]) || empty($_POST["psw"])) {
$loginErr = "Gebruikersnaam of wachtwoord is niet ingevuld";
}
else {
$uname = strtolower(test_input($_POST["uname"]));
$psw = test_input($_POST["psw"]);
$hash = getUser()["password"];
$userid = getUser()["userID"];
// If there's an account, go to the profile page
if(password_verify($psw, $hash)) {
$_SESSION["userID"] = $userid;
header("location: profile.php");
} else {
$loginErr = "Inloggegevens zijn niet correct";
}
try{
$uname = ($_POST["uname"]);
validateLogin($_POST["uname"], $_POST["psw"]);
} catch(loginException $e) {
$loginErr = $e->getMessage();
}
}

View File

@@ -1,15 +1,4 @@
<!DOCTYPE html>
<html>
<?php
include("../views/login_head.php");
require_once("../queries/connect.php");
include_once("../queries/login.php");
?>
<body>
<?php
session_start();
unset($_SESSION["userID"]);
header("Location: login.php");
?>
</body>
</html>
session_start();
session_destroy();
header("Location: login.php");

View File

@@ -15,7 +15,6 @@ include("../queries/nicetime.php");
if(empty($_GET["username"])) {
$userID = $_SESSION["userID"];
echo "USERNAME NOT GIVEN";
} else {
$userID = getUserID($_GET["username"]);
}

View File

@@ -5,6 +5,7 @@
require_once("../queries/connect.php");
include_once("../queries/register.php");
include_once("../queries/checkInput.php");
include_once("../queries/emailconfirm.php");
?>
<body>
<?php
@@ -45,7 +46,7 @@
}
try{
$username = test_input(($_POST["username"]));
$username = str_replace(' ', '', test_input(($_POST["username"])));
checkInputChoice($username, "username");
} catch(usernameException $e){
$correct = false;
@@ -53,7 +54,7 @@
}
try{
$password = test_input(($_POST["password"]));
$password = str_replace(' ', '', test_input(($_POST["password"])));
checkInputChoice($password, "longerEight");
matchPassword();
} catch(passwordException $e){
@@ -91,6 +92,7 @@
try {
getIp();
registerCheck($correct);
sendConfirmEmailUsername($username);
} catch(registerException $e){
$genericErr = $e->getMessage();
}

View File

@@ -1,6 +1,6 @@
a.button {
background-color: #C8CABD;
border-radius: 10px;
border-radius: 5px;
color: black;
cursor: pointer;
height: 50%;

View File

@@ -63,4 +63,32 @@
#quick-links i:hover {
color: #FBC02D;
}
.notification-options {
display: none;
width: 100%;
}
.notification-options form {
width: 100%;
text-align: center;
}
.notification-options button {
display: inline-block;
padding: 5px 20px;
width: auto;
}
.accept-notification:hover {
color: #4CAF50;
}
.deny-notification:hover {
color: firebrick;
}
.friend-item:hover .notification-options {
display: inline-block;
}