Merge branch 'master' of ssh://gitlab-fnwi.uva.nl:1337/11166932/WebDB

This commit is contained in:
K. Nobel
2017-01-19 16:04:07 +01:00
33 changed files with 530 additions and 555 deletions

View File

@@ -1,6 +1,8 @@
<?php
include_once("../queries/private_message.php");
session_start();
require_once("../../queries/connect.php");
require_once("../../queries/private_message.php");
if (isset($_POST["lastID"]) && $_POST["lastID"] != "") {

View File

@@ -1,6 +1,8 @@
<?php
include_once("../queries/private_message.php");
session_start();
require_once("../../queries/connect.php");
require_once("../../queries/private_message.php");
if (isset($_POST["destination"]) &&
isset($_POST["content"])) {

Binary file not shown.

After

Width:  |  Height:  |  Size: 33 KiB

View File

@@ -1,10 +1,12 @@
$(document).ready(function() {
loadMessages();
sayEmpty();
$(".chat-field").hide();
});
function loadMessages() {
$.post(
"loadMessages.php",
"API/loadMessages.php",
$("#lastIDForm").serialize()
).done(function(data) {
if (data && data != "[]") {
@@ -23,7 +25,7 @@ function loadMessages() {
function sendMessage() {
console.log($("#sendMessageForm").serialize());
$.post(
"sendMessage.php",
"API/sendMessage.php",
$("#sendMessageForm").serialize()
).done(function( data ) {
console.log(data);
@@ -51,7 +53,14 @@ function addMessages(messages) {
}
function switchUser(userID) {
$(".chat-field").show();
$(".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");
}
function sayEmpty() {
$("#chat-history").html("Begin nu met chatten!");
}

View File

@@ -2,7 +2,7 @@
<html>
<?php
include("../views/login_head.php");
include_once("../queries/connect.php");
require_once("../queries/connect.php");
include_once("../queries/login.php");
?>
<body>
@@ -15,19 +15,19 @@
// Trying to login
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$uname=strtolower($_POST["uname"]);
// Empty username or password field
if (empty($_POST["uname"]) || empty($_POST["psw"])) {
$loginErr = "Gebruikersnaam of wachtwoord is niet ingevuld";
}
else {
$psw=$_POST["psw"];
$hash=hashPassword()["password"];
$userid=hashPassword()["userID"];
$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.$uname, $hash)) {
if(password_verify($psw, $hash)) {
$_SESSION["userID"] = $userid;
header("location: profile.php");

15
website/public/logout.php Normal file
View File

@@ -0,0 +1,15 @@
<!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>

View File

@@ -2,9 +2,9 @@
<html>
<?php
include("../views/login_head.php");
include_once("../queries/connect.php");
require_once("../queries/connect.php");
include_once("../queries/register.php");
include_once("../queries/checkInput.php");
?>
<body>
<?php
@@ -15,149 +15,27 @@
$genericErr = $nameErr = $surnameErr = $bdayErr = $usernameErr = $passwordErr = $confirmpasswordErr = $locationErr = $housenumberErr = $emailErr = "";
$correct = true;
// Saves information of filling in the form
if (isset($_POST["name"])) {
$name = $_POST["name"];
}
if (isset($_POST["surname"])) {
$surname = $_POST["surname"];
}
if (isset($_POST["bday"])) {
$bday = $_POST["bday"];
}
if (isset($_POST["username"])) {
$username = $_POST["username"];
}
if (isset($_POST["password"])) {
$password = $_POST["password"];
}
if (isset($_POST["location"])) {
$location = $_POST["location"];
}
if (isset($_POST["housenumber"])) {
$housenumber = $_POST["housenumber"];
}
if (isset($_POST["email"])) {
$email = $_POST["email"];
}
// Trying to register an account
if ($_SERVER["REQUEST_METHOD"] == "POST") {
if (empty($_POST["name"])) {
$nameErr = "Naam is verplicht!";
$correct = false;
checkInputChoice("name", "lettersAndSpace");
checkInputChoice("surname", "lettersAndSpace");
} else {
if (!preg_match("/^[a-zA-Z ]*$/",$name)) {
$nameErr = "Alleen letters en spaties zijn toegestaan!";
$correct = false;
}
}
if (empty($_POST["surname"])) {
$surnameErr = "Achternaam is verplicht!";
$correct = false;
} else {
if (!preg_match("/^[a-zA-Z ]*$/",$surname)) {
$surnameErr = "Alleen letters en spaties zijn toegestaan!";
$correct = false;
}
}
if (empty($_POST["bday"])) {
$bdayErr = "Geboortedatum is verplicht!";
$correct = false;
}
if (empty($_POST["username"])) {
$usernameErr = "Gebruikersnaam is verplicht!";
$correct = false;
} else {
if (strlen($username) < 6) {
$usernameErr = "Gebruikersnaam moet minstens 6 karakters bevatten";
$correct = false;
} else if (getExistingUsername() == 1){
$usernameErr = "Gebruikersnaam bestaat al";
$correct = false;
}
$bday = test_input($_POST["bday"]);
}
if (empty($_POST["password"])) {
$passwordErr = "Wachtwoord is verplicht!";
$correct = false;
} else {
if (strlen($password) < 8) {
$passwordErr = "Wachtwoord moet minstens 8 karakters bevatten";
$correct = false;
}
}
if (empty($_POST["confirmpassword"])) {
$confirmpasswordErr = "Herhaal wachtwoord!";
$correct = false;
}
if ($_POST["password"] != $_POST["confirmpassword"]) {
$confirmpasswordErr = "Wachtwoorden matchen niet";
$correct = false;
}
if (empty($_POST["location"])) {
$locationErr = "Straatnaam is verplicht!";
$correct = false;
} else {
if (!preg_match("/^[a-zA-Z ]*$/",$location)) {
$locationErr = "Alleen letters en spaties zijn toegestaan!";
$correct = false;
}
}
if (empty($_POST["email"])) {
$emailErr = "Email is verplicht!";
$correct = false;
} else {
if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
$emailErr = "Geldige email invullen!";
$correct = false;
} else if (getExistingEmail() == 1){
$emailErr = "Email bestaat al";
$correct = false;
}
}
// Checks if everything is filled in correctly
if ($correct == false){
$genericErr = "Bepaalde velden zijn verkeerd of niet ingevuld!";
} else {
registerAccount();
header("location: login.php");
}
checkInputChoice("username", "username");
checkInputChoice("password", "longerEigth");
checkInputChoice("confirmpassword", "");
matchPassword();
checkInputChoice("location", "lettersAndSpace");
checkInputChoice("email", "email");
registerCheck();
}
/* This view adds register view */
include("../views/register-view.php");
?>

View File

@@ -14,6 +14,7 @@
<?php
include("../views/main.php");
$notImplemented = new settingsMessage("angry", "Deze functie werkt nog niet :(");
if ($_SERVER["REQUEST_METHOD"] == "POST") {
switch ($_POST["form"]) {
@@ -24,16 +25,10 @@ if ($_SERVER["REQUEST_METHOD"] == "POST") {
$result = updatePassword();
break;
case "email":
$result = array (
"type" => "settings-message-angry",
"message" => "Deze functie werkt nog niet :("
);
$result = changeEmail();
break;
case "picture":
$result = array (
"type" => "settings-message-angry",
"message" => "Deze functie werkt nog niet :("
);
$result = $notImplemented;
break;
}
}

View File

@@ -88,4 +88,9 @@
padding: 5px 10px;
border-radius: 0 10px 10px 0;
box-shadow: 0 1px 3px rgba(0,0,0,0.12), 0 1px 2px rgba(0,0,0,0.24);
}
.active-friend-chat {
background: aquamarine;
color: #333;
}

View File

@@ -1,22 +1,6 @@
::selection {
background: #845663;
color: white;
}
::-moz-selection {
background: #845663;
color: white;
}
a, a:link, a:visited, a:hover, a:active {
color: inherit;
text-decoration: none;
}
a.button {
background-color: #845663;
border: 2px solid black;
border-radius: 12px;
background-color: #405550;
border-radius: 10px;
color: white;
cursor: pointer;
height: 50%;
@@ -27,64 +11,19 @@ a.button {
font-size: 16px;
}
a[data-title]:hover:after, img[data-title]:hover:after, span[data-title]:hover:after,
div[data-title]:hover:after{
content: attr(data-title);
padding: 4px 4px;
color: #FFFFFF;
position: absolute;
left: 0;
top: 100%;
z-index: 20;
white-space: nowrap;
-moz-border-radius: 5px;
-webkit-border-radius: 5px;
border-radius: 5px;
-moz-box-shadow: 0px 0px 4px #222;
-webkit-box-shadow: 0px 0px 4px #222;
box-shadow: 0px 0px 4px #222;
background-color: #333;
font-size: 15px;
line-height: normal;
font-family: Arial, sans-serif;
}
/* Add Zoom Animation */
.animate {
animation: animatezoom 0.6s
-webkit-animation: animatezoom 0.6s;
}
/* Body */
body {
height: 900px;
background-image: url(https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcTEnqKdVtLbxjKuNsCSCxFRhTOpp3Gm0gsU8bMgA_MeUYyzrUFy);
background-color: #C8CABD;
/*background-image: url(http://play.pokemonshowdown.com/fx/client-bg-shaymin.jpg);
background-size: cover;
background-repeat: repeat-x;
background-attachment: fixed;
background-attachment: fixed;*/
/*background-color: #B78996;*/
color: #333;
font-family: Arial, sans-serif;
}
/* stijl voor alle buttons */
button {
background-color: #845663;
border: 2px solid black;
border-radius: 12px;
color: white;
cursor: pointer;
height: 50%;
margin: 8px 0;
padding: 14px 20px;
width: 25%;
font-family: Arial;
font-size: 16px;
}
/* The Close Button */
.close {
/* Position it in the top right corner outside of the modal */
@@ -106,20 +45,18 @@ button {
/* inlogform */
form {
/*background-color: #a87a87;*/
border: 5px solid #325da3;
background-color: #a87a87;
border-radius: 12px;
height: 55%;
margin: 35px auto;
width: 45%;
height: 75%;
margin: 10px auto;
width: 70%;
overflow-y:auto;
}
/* inlog titel */
h1 {
padding: 16px;
padding: 8px;
text-align: center;
font-size: 2.2em;
font-size: 1.5em;
}
/* registreer titel*/
@@ -130,30 +67,34 @@ h2 {
}
input[type=text], input[type=password], input[type=email], input[type="date"] {
border-radius: 12px;
border: 5px solid #ccc;
box-sizing: border-box;
border-color: #C8CABD;
display: inline-block;
height: 50%;
padding: 8px 20px;
margin: 4px 0;
width: 50%;
font-family: Arial;
font-size: 16px;
}
/*
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: #845663;
border: 2px solid black;
border-radius: 12px;
color: white;
background-color: #C8CABD;
color: black ;
cursor: pointer;
height: 50%;
margin: 8px 0;
padding: 14px 20px;
width: 50%;
font-family: Arial;
font-size: 16px;
width: 50%;
}
.error {
font-family: Arial;
font-size: 15px;
color: red;
}
label {
@@ -179,52 +120,31 @@ label {
color: red;
}
/* The Modal (background) */
.modal {
background-color: rgb(0,0,0); /* Fallback color */
background-color: rgba(0,0,0,0.4); /* Black w/ opacity */
display: none; /* Hidden by default */
height: 100%;
left: 0;
margin: auto;
overflow: auto; /* Enable scroll if needed */
padding-top: 60px;
position: fixed; /* Stay in place */
top: 0;
width: 100%; /* Full width */
z-index: 1; /* Sit on top */
}
/* Modal Content/Box */
.modal-content {
background-color: #B78996;
border: 5px solid #325da3;
margin: 5px auto; /* 15% from the top and centered */
overflow-y: auto;
width: 40%; /* Could be more or less, depending on screen size */
height: 60%;
}
@keyframes animatezoom {
from {transform: scale(0)}
to {transform: scale(1)}
}
/* datepicker */
select {
border-radius: 12px;
border: 5px solid #ccc;
box-sizing: border-box;
display: inline-block;
height: 50%;
padding: 12px 20px;
margin: 8px 0;
width: 18%;
font-family: Arial;
font-size: 16px;
/* White boxes (squares) */
.platform {
background-color: #FFFFFF;
/*background-image: url(http://www.planwallpaper.com/static/images/518071-background-hd_xO1TwRc.jpg);
background-size: cover;
background-repeat: repeat-x;
background-attachment: fixed;*/
box-shadow: 0 1px 3px rgba(0,0,0,0.12), 0 1px 2px rgba(0,0,0,0.24);
height: 53%;
margin: 34px auto;
overflow-y: auto;
padding: 20px;
width: 35%;
}
/*.platform {
width: 40%;
margin: 34px auto;
}*/
@-webkit-keyframes animatezoom {
from {-webkit-transform: scale(0)}
to {-webkit-transform: scale(1)}

View File

@@ -30,9 +30,14 @@
cursor: pointer;
}
.friend-item:hover {
background: #845663;
color: white;
}
.menu button {
background: none;
color: #333;
color: inherit;
width: 100%;
height: 100%;
padding: 0;

View File

@@ -7,7 +7,7 @@
include_once("../queries/connect.php");
include_once("../queries/friendship.php");
$friends = selectAllFriends($db, 666);
$friends = selectAllFriends(666);
while($friend = $friends->fetch(PDO::FETCH_ASSOC)) {
echo $friend['username'].' '.$friend['onlinestatus'] . "<br />";
}