Merge branch 'master' into hendrik-post

This commit is contained in:
Hendrik
2017-01-25 15:59:40 +01:00
35 changed files with 989 additions and 315 deletions

View File

@@ -0,0 +1,31 @@
<?php
session_start();
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.";
return;
}
$friendship_status = getFriendshipStatus($_POST["userID"]);
echo "\nfriendshipstatus: $friendship_status";
echo "You: " . $_SESSION["userID"];
echo "other user: " . $_POST["userID"];
if(!empty($_POST["request"]) AND $friendship_status == 0) {
echo "request";
requestFriendship($_POST["userID"]);
} else if(!empty($_POST["delete"]) AND in_array($friendship_status, array(1, 2, 3))) {
echo "delete";
removeFriendship($_POST["userID"]);
} else if (!empty($_POST["accept"]) AND $friendship_status == 3) {
echo "accept";
acceptFriendship($_POST["userID"]);
}
$username = getUsername($_POST["userID"]);
header("Location: ../profile.php?username=$username");

View File

@@ -3,6 +3,6 @@
session_start();
require_once ("../../queries/connect.php");
require_once ("../../queries/friendship.php");
require_once ("../../queries/private_message.php");
echo selectAllUnreadChat();

View File

@@ -5,9 +5,12 @@ session_start();
require_once("../../queries/connect.php");
require_once("../../queries/private_message.php");
require_once("../../queries/checkInput.php");
require_once("../../queries/friendship.php");
if (isset($_POST["lastID"]) && $_POST["lastID"] != "") {
echo getNewChatMessages(test_input($_POST["lastID"]), test_input($_POST["destination"]));
setLastVisited(test_input($_POST["destination"]));
} else {
echo getOldChatMessages(test_input($_POST["destination"]));
setLastVisited(test_input($_POST["destination"]));
}

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.";
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 98 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 24 KiB

View File

@@ -53,8 +53,8 @@ function switchUser(userID) {
$(".destinationID").val(userID);
$("#chat-history").html("");
$("#lastID").val("");
$(".chat-left .friend-item").removeClass("active-friend-chat");
$(".chat-left #friend-item-" + userID).addClass("active-friend-chat");
$("#chat-recent-panel .friend-item").removeClass("active-friend-chat");
$("#chat-left #friend-item-" + userID).addClass("active-friend-chat");
}
function sayEmpty() {

View File

@@ -1,8 +1,18 @@
function showNotifications(notifications, id) {
$("#" + id).html("");
function showFriendNotifications(notifications) {
$("#friendrequestslist").html("");
for (i in notifications) {
$("#" + id).append(" \
<li class='friend-item $extraItem'> \
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'> \
<form action='profile.php' method='get'> \
<button type='submit' \
name='username' \
@@ -13,6 +23,41 @@ function showNotifications(notifications, id) {
</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> \
");
}
}
function showChatNotifications(notifications) {
$("#unreadChatlist").html("");
for (i in notifications) {
$("#unreadChatlist").append(" \
<li class='friend-item'> \
<form action='chat.php' method='get'> \
<button type='submit' \
name='chatID' \
value='"+ notifications[i].userID +"'> \
<div class='friend'> \
<img alt='PF' class='profile-picture' src='"+ notifications[i].profilepicture +"'/> \
<div class='friend-name'> \
"+ notifications[i].name +"<br/> \
<span style='color: #666'>"+ notifications[i].content +"</span> \
</div> \
</div> \
</button> \
</form> \
</li> \
");
}
@@ -23,14 +68,14 @@ function loadNotifications() {
"API/loadFriendRequestNotifications.php"
).done(function(data) {
if (data && data != "[]") {
showNotifications(JSON.parse(data), "friendrequestslist");
showFriendNotifications(JSON.parse(data));
}
});
$.post(
"API/loadChatNotifications.php"
).done(function(data) {
if (data && data != "[]") {
showNotifications(JSON.parse(data), "unreadChatlist");
showChatNotifications(JSON.parse(data));
}
});

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

@@ -22,7 +22,7 @@ if(empty($_GET["username"])) {
$userID = getUserID($_GET["username"]);
}
$user = selectUser($userID);
$user = selectUser($_SESSION["userID"], $userID);
$profile_friends = selectAllFriends($userID);
$profile_groups = selectAllUserGroups($userID);
$posts = selectAllUserPosts($userID);

View File

@@ -5,38 +5,97 @@
require_once("../queries/connect.php");
include_once("../queries/register.php");
include_once("../queries/checkInput.php");
include_once("../queries/emailconfirm.php");
?>
<body>
<?php
session_start();
if(isset($_SESSION["userID"])){
header("location: profile.php");
header("location: login.php");
}
// define variables and set to empty values
$name = $surname = $bday = $username = $password = $confirmpassword = $location = $housenumber = $email = "";
$genericErr = $nameErr = $surnameErr = $bdayErr = $usernameErr = $passwordErr = $confirmpasswordErr = $locationErr = $housenumberErr = $emailErr = "";
$name = $surname = $bday = $username = $password = $confirmpassword = $location = $housenumber = $email = $captcha = $ip = "";
$genericErr = $nameErr = $surnameErr = $bdayErr = $usernameErr = $passwordErr = $confirmpasswordErr = $locationErr = $housenumberErr = $emailErr = $captchaErr = "";
$correct = true;
// Trying to register an account
if ($_SERVER["REQUEST_METHOD"] == "POST") {
checkInputChoice("name", "lettersAndSpace");
checkInputChoice("surname", "lettersAndSpace");
if (empty($_POST["bday"])) {
$bdayErr = "Geboortedatum is verplicht!";
try {
$name = test_input(($_POST["name"]));
checkInputChoice($name, "lettersAndSpaces");
} catch(lettersAndSpacesException $e){
$correct = false;
} else {
$bday = test_input($_POST["bday"]);
$nameErr = $e->getMessage();
}
checkInputChoice("username", "username");
checkInputChoice("password", "longerEight");
checkInputChoice("confirmpassword", "");
matchPassword();
checkInputChoice("location", "lettersAndSpace");
checkInputChoice("email", "email");
registerCheck();
try {
$surname = test_input(($_POST["surname"]));
checkInputChoice($surname, "lettersAndSpaces");
}
catch(lettersAndSpacesException $e){
$correct = false;
$surnameErr = $e->getMessage();
}
try{
$bday = test_input(($_POST["bday"]));
checkInputChoice($bday, "bday");
} catch(bdayException $e){
$correct = false;
$bdayErr = $e->getMessage();
}
try{
$username = str_replace(' ', '', test_input(($_POST["username"])));
checkInputChoice($username, "username");
} catch(usernameException $e){
$correct = false;
$usernameErr = $e->getMessage();
}
try{
$password = str_replace(' ', '', test_input(($_POST["password"])));
checkInputChoice($password, "longerEight");
matchPassword();
} catch(passwordException $e){
$correct = false;
$passwordErr = $e->getMessage();
} catch(confirmPasswordException $e){
$correct = false;
$confirmPasswordErr = $e->getMessage();
}
try{
$location = test_input(($_POST["location"]));
checkInputChoice($location, "lettersAndSpaces");
} catch(lettersAndSpacesException $e){
$correct = false;
$locationErr = $e->getMessage();
}
try{
$email = test_input(($_POST["email"]));
checkInputChoice($email, "email");
} catch(emailException $e){
$correct = false;
$emailErr = $e->getMessage();
}
try{
$captcha = $_POST['g-recaptcha-response'];
checkCaptcha($captcha);
} catch(captchaException $e){
$correct = false;
$captchaErr = $e->getMessage();
}
try {
getIp();
registerCheck($correct);
sendConfirmEmailUsername($username);
} catch(registerException $e){
$genericErr = $e->getMessage();
}
}
/* This view adds register view */
include("../views/register-view.php");

View File

@@ -12,23 +12,28 @@
</head>
<body>
<?php
$notImplemented = new settingsMessage("angry", "Deze functie werkt nog niet :(");
$alertClass;
$alertMessage;
if ($_SERVER["REQUEST_METHOD"] == "POST") {
switch ($_POST["form"]) {
case "profile":
$result = updateSettings();
break;
case "password":
$result = changePassword();
break;
case "email":
$result = changeEmail();
break;
case "picture":
updateProfilePicture();
$result = new settingsMessage("happy", "Deze melding doet nog niks nuttigs.");
break;
try {
switch ($_POST["form"]) {
case "profile":
updateSettings();
break;
case "password":
changePassword();
break;
case "email":
changeEmail();
break;
case "picture":
updateAvatar();
break;
}
} catch (AlertMessage $w) {
$alertClass = $w->getClass();
$alertMessage = $w->getMessage();
}
}
include("../views/main.php");

View File

@@ -1,34 +1,38 @@
/* Overall chat-screen */
.chat {
position: fixed;
top: 80px;
left: 256px;
padding: 20px 0;
width: calc(100% - 256px);
height: calc(100% - 120px);
display: inline-flex;
padding: 20px 0;
display: inline-block;
}
.chat-left {
#chat-recent-panel {
width: 256px;
height: calc(100% - 100px);
margin: 0 10px;
overflow-y: auto;
}
.chat-right {
width: calc(100% - 256px - 40px);
height: calc(100% - 80px);
margin-right: 10px;
display: inline-block;
overflow-y: auto;
}
/* Chat history. */
.chat-history {
#chat-history {
overflow-y: auto;
overflow-x: hidden;
height: 100%;
width: calc(100% - 256px - 75px);
height: calc(100% - 80px);
padding: 10px;
display: inline-block;
word-wrap: break-word;
}
@@ -36,7 +40,13 @@
.chat-message {
width: 100%;
min-height: 40px;
padding-top: 10px;
padding: 10px 0;
clear: both;
}
.chat-message::after {
content: '';
display: table;
clear: both;
}
@@ -63,7 +73,7 @@
/* Chat reply field */
.chat-field {
width: 100%;
width: calc(100% - 10px);
display: table;
}

View File

@@ -1,20 +1,19 @@
a.button {
background-color: #C8CABD;
border-radius: 10px;
border-radius: 5px;
color: black;
cursor: pointer;
height: 50%;
margin: 8px 0;
padding: 14px 20px;
width: 25%;
padding: 8px 20px;
width: 50%;
font-family: Arial;
font-size: 16px;
font-size: 20px;
}
/* Body */
body {
height: 100%;
background-color: #C8CABD;
background-color: #FBC02D;
/*background-image: url(http://play.pokemonshowdown.com/fx/client-bg-shaymin.jpg);
background-size: cover;
background-attachment: fixed;*/
@@ -24,31 +23,14 @@ body {
font-family: Arial, sans-serif;
}
/* The Close Button */
.close {
/* Position it in the top right corner outside of the modal */
color: white;
font-size: 100px;
font-weight: bold;
position: absolute;
right: 25px;
top: 0;
}
/* Close button on hover */
.close:hover,
.close:focus {
color: red;
cursor: pointer;
}
/* inlogform */
form {
/*background-color: #a87a87;*/
border-radius: 12px;
height: 70%;
height: 75%;
margin: auto;
width: 70%;
width: 80%;
overflow-y:auto;
}
@@ -72,24 +54,20 @@ input[type=text], input[type=password], input[type=email], input[type="date"] {
border-color: #C8CABD;
display: inline-block;
height: 60%;
font-size: 16px;
padding: 8px 20px;
margin: 4px 0;
width: 70%;
width: 55%;
}
/*
input[type=text], input[type=password], input[type=email], input[type="date"] {
border: 0px;
border-bottom: 4px solid lightgray;
border-radius: 0px;
}*/
button[type=submit] {
background-color: #C8CABD;
color: black ;
color: black;
cursor: pointer;
font-family: Arial;
font-size: 16px;
width: 50%;
font-size: 22px;
height: 30px;
width: 120px;
}
.error {
@@ -106,12 +84,12 @@ label {
display: inline-block;
position: relative;
background-color: #C8CABD;
height: 30px;
width: 90px;
padding: 3px 3px 3px 0px;
height: 25px;
width: 120px;
padding: 3px 3px 3px 3px;
text-align: center;
border-radius: 0px 10px 10px 0px;
font-size: 24px;
border-radius: 0px 5px 5px 0px;
font-size: 22px;
}
.left-arrow:after {
@@ -121,9 +99,9 @@ label {
right: 100%;
top: 0;
bottom: 0;
border-top: 15px solid transparent;
border-top: 12px solid transparent;
border-right: 20px solid #C8CABD;
border-bottom: 15px solid transparent;
border-bottom: 12px solid transparent;
border-left: 0px solid transparent;
}
@@ -135,7 +113,7 @@ label {
/* padding voor login_containers */
.login_containerlogin {
padding:25px;
padding:16px;
text-align: center;
}
@@ -163,7 +141,7 @@ label {
margin: 34px auto;
overflow-y: auto;
padding: 20px;
width: 50%;
width: 45%;
}
/*.platform {

View File

@@ -242,3 +242,23 @@ div[data-title]:hover:after {
line-height: normal;
font-family: Arial, sans-serif;
}
.friend {
}
.friend-item, .group-item {
cursor: pointer;
transition-duration: 250ms;
}
.friend-item:hover, .group-item:hover {
background: #FBC02D;
box-shadow: 0 1px 3px rgba(0,0,0,0.12), 0 1px 2px rgba(0,0,0,0.24);
}
.friend-name {
display: inline-block;
vertical-align: middle;
}

View File

@@ -34,16 +34,6 @@
cursor: pointer;
}
.friend-item, .group-item {
cursor: pointer;
transition-duration: 250ms;
}
.friend-item:hover, .group-item:hover {
background: #FBC02D;
box-shadow: 0 1px 3px rgba(0,0,0,0.12), 0 1px 2px rgba(0,0,0,0.24);
}
.menu button {
background: none;
color: inherit;
@@ -73,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;
}

View File

@@ -78,8 +78,9 @@ div.posts .post form textarea.newpost {
font-size: 0.8em;
}
.profile-button {
input.profile-button {
float: right;
height: auto;
padding: 10px;
border-radius: 5px;
background-color: #4CAF50;