Merge branch 'master' into hendrik-testing

This commit is contained in:
Hendrik
2017-01-30 16:34:40 +01:00
42 changed files with 583 additions and 376 deletions

View File

@@ -1,7 +1,7 @@
Options +FollowSymLinks
RewriteEngine On
ErrorDocument 404 /error404.jpg
ErrorDocument 404 /error/404.php
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteCond %{SCRIPT_FILENAME} !-f

View File

@@ -1,13 +1,17 @@
<?php
if(empty($_POST["usr"])) {
if(empty($_POST["usr"]) and empty($_POST["grp"])) {
header('HTTP/1.1 500 Non enough arguments');
}
require_once ("../../queries/user.php");
require_once ("../../queries/post.php");
require_once ("../../queries/nicetime.php");
$posts = selectAllUserPosts($_POST["usr"]);
if(empty($_POST["usr"])) {
$posts = selectAllPosts(0, $_POST["grp"]);
} else {
$posts = selectAllPosts($_POST["usr"], 0);
}
if(!$posts) {
header('HTTP/1.1 500 Query failed');
@@ -19,6 +23,4 @@ for($i = 0; $i < sizeof($results); $i++) {
$results[$i]["nicetime"] = nicetime($results[$i]["creationdate"]);
}
//$results[0]["niceTime"] = nicetime($results[0]["creationdate"]);
echo json_encode($results);

View File

@@ -5,7 +5,7 @@ require_once ("../queries/connect.php");
require_once ("../queries/checkInput.php");
function getNietSlechtCountForPost(int $postID) : int {
$stmt = $GLOBALS["db"]->prepare("
$stmt = prepareQuery("
SELECT
`userID`
FROM
@@ -19,7 +19,7 @@ function getNietSlechtCountForPost(int $postID) : int {
}
function getNietSlechtUsersForPost(int $postID) {
$stmt = $GLOBALS["db"]->prepare("
$stmt = prepareQuery("
SELECT
`fname`,
`lname`,

View File

@@ -3,7 +3,7 @@
session_start();
require("../../queries/post.php");
require("../../queries/connect.php");
require_once("../../queries/connect.php");
require("../../queries/checkInput.php");
print_r($_POST);
if ($_POST['button'] == 'reaction') {

View File

@@ -2,7 +2,7 @@
include_once("../queries/connect.php");
include_once("../views/messagepage.php");
if (array_key_exists("u", $_GET) and array_key_exists("h", $_GET)) {
$checkHash = $GLOBALS["db"]->prepare("
$checkHash = prepareQuery("
SELECT
`email`,
`role`
@@ -28,7 +28,7 @@ if (array_key_exists("u", $_GET) and array_key_exists("h", $_GET)) {
function doActivate(string $email) {
if (password_verify($email, $_GET["h"])) {
$confirmUser = $GLOBALS["db"]->prepare("
$confirmUser = prepareQuery("
UPDATE
`user`
SET

View File

@@ -0,0 +1,9 @@
<?php
require_once "../../views/messagepage.php";
messagePage("
<div class='error-page'>
<h1>404</h1>
<h4>Verkeerde link...</h4><br />
<img height='25%' width='25%' src='../img/zelda.png'>
</div>");

View File

@@ -4,6 +4,8 @@
<?php include("../views/head.php"); ?>
<style>
@import url("styles/profile.css");
@import url("styles/post-popup.css");
@import url('https://fonts.googleapis.com/css?family=Anton');
</style>
</head>
<body>
@@ -30,6 +32,20 @@ include("../views/group.php");
/* This adds the footer. */
include("../views/footer.php");
$masonry_mode = 0;
?>
<script src="js/masonry.js"></script>
<script src="js/post.js"></script>
<script>
$(document).ready(function() {
userID = 0;
groupID = <?= $group["groupID"] ?>;
masonry(<?= $masonry_mode ?>);
});
</script>
</body>
</html>

Binary file not shown.

After

Width:  |  Height:  |  Size: 147 KiB

View File

@@ -1,25 +1,31 @@
var previousDate = new Date("1970-01-01 00:00:00");
var previousTime = "00:00";
var gettingMessages = false;
var previousType = "robot";
$(document).ready(function() {
loadMessages();
setInterval(loadMessages, 1000);
sayEmpty();
$(".chat-field").hide();
});
function loadMessages() {
$.post(
"API/loadMessages.php",
$("#lastIDForm").serialize()
).done(function(data) {
if (data && data != "[]") {
messages = JSON.parse(data);
addMessages(messages);
$("#lastID").val(messages[messages.length - 1].messageID);
$("#chat-history").scrollTop($("#chat-history")[0].scrollHeight);
}
});
setTimeout(loadMessages, 1000);
if (!gettingMessages) {
gettingMessages = true;
$.post(
"API/loadMessages.php",
$("#lastIDForm").serialize()
).done(function (data) {
if (data && data != "[]") {
messages = JSON.parse(data);
addMessages(messages);
$("#lastID").val(messages[messages.length - 1].messageID);
}
gettingMessages = false;
});
} else {
setTimeout(loadMessages, 500);
}
}
@@ -30,35 +36,55 @@ function sendMessage() {
);
$("#newContent").val("");
loadMessages();
}
function addMessages(messages) {
var messagesText = "";
for(var i in messages) {
thisDate = new Date(messages[i].creationdate);
// Initialize message variables
var thisDate = new Date(messages[i].creationdate);
var thisTime = thisDate.getHours() + ":" + thisDate.getMinutes();
var type;
thisDate.setHours(0,0,0,0);
if (messages[i].destination == $(".destinationID").val()) {
type = "chat-message-self";
} else {
type = "chat-message-other";
}
if (thisDate > previousDate) {
if (i == 0) {
messagesText += '<div class="chat-message"><div class="' + type + '">';
} else if (type != previousType || thisTime != previousTime || thisDate > previousDate) {
messagesText += '<div class="chat-time">\
' + thisTime + '\
</div></div></div>';
previousDate = thisDate;
$("#chat-history").append('\
<div class="day-message"> \
<div class="day-message-content">\
' + days[thisDate.getDay()] + " " + thisDate.getDate() + " " + months[thisDate.getMonth()] + " " + thisDate.getFullYear() + '\
</div> \
</div>\
');
previousTime = thisTime;
previousType = type;
if (thisDate > previousDate) {
messagesText += '\
<div class="day-message"> \
<div class="day-message-content">\
' + days[thisDate.getDay()] + " " + thisDate.getDate() + " " + months[thisDate.getMonth()] + " " + thisDate.getFullYear() + '\
</div> \
</div>';
}
messagesText += '<div class="chat-message"><div class="' + type + '">';
}
$("#chat-history").append('\
<div class="chat-message"> \
<div class="' + type + '">\
' + fancyText(messages[i].content) + '\
</div> \
</div>\
');
messagesText += fancyText(messages[i].content) + "<br />";
}
// Close the last message
messagesText += '<div class="chat-time">\
' + thisTime + '\
</div></div></div>';
$("#chat-history").append(messagesText);
$("#chat-history").scrollTop($("#chat-history")[0].scrollHeight - $('#chat-history')[0].clientHeight);
}
function switchUser(userID) {
@@ -72,5 +98,5 @@ function switchUser(userID) {
}
function sayEmpty() {
$("#chat-history").html("Begin nu met chatten!");
$("#chat-history").html("Probeer ook eens foto's en video's te sturen");
}

View File

@@ -1,26 +1,73 @@
function placeFriendButtons() {
$.post("API/getFriendshipStatus.php", { usr: userID })
.done(function(data) {
friendshipStatus = data;
$buttonContainer = $("div.friend-button-container");
$buttonContainer.children().remove();
$("#start-profile-chat-form").hide();
if (friendshipStatus == -1) {
return;
} else if(friendshipStatus == 0) {
$buttonContainer.append($("<button class=\"green friend-button\" value=\"request\"><i class=\"fa fa-handshake-o\"></i> Bevriend</button>"));
} else if(friendshipStatus == 1) {
$buttonContainer.append($("<button class=\"red friend-button\" value=\"delete\"><i class=\"fa fa-times\"></i> Verwijder</button>"));
$("#start-profile-chat-form").show();
} else if(friendshipStatus == 2) {
$buttonContainer.append($("<button class=\"red friend-button\" value=\"delete\"><i class=\"fa fa-times\"></i> Trek verzoek in</button>"));
} else if(friendshipStatus == 3) {
$buttonContainer.append($("<button class=\"red friend-button\" value=\"delete\"><i class=\"fa fa-times\"></i> Weiger</button>"));
$buttonContainer.append($("<button class=\"green friend-button\" value=\"accept\"><i class=\"fa fa-check\"></i> Accepteer</button>"));
}
var friendshipStatus = data;
var $buttonContainer = $("div.friend-button-container");
$("#start-profile-chat").hide();
$buttonContainer.html("");
var value1 = "";
var class1 = "empty-button";
var icon1 = "";
var text1 = "";
var value2 = "";
var class2 = "empty-button";
var icon2 = "";
var text2 = "";
switch (friendshipStatus) {
case "0":
value1 = "request";
class1 = "green";
text1 = "Bevriend";
icon1 = "fa-handshake-o";
break;
case "1":
value1 = userID;
class1 = "green";
text1 = "Chat";
icon1 = "fa-comment-o";
value2 = "delete";
class2 = "red";
text2 = "Verwijder";
icon2 = "fa-times";
break;
case "2":
value1 = "delete";
class1 = "red";
text1 = "Trek verzoek in";
icon1 = "fa-cross";
break;
case "3":
value1 = "accept";
class1 = "green";
text1 = "Accepteer";
icon1 = "fa-check";
value2 = "delete";
class2 = "red";
text2 = "Weiger";
icon2 = "fa-times";
break;
default:
console.log(friendshipStatus);
break;
}
$buttonContainer.append(
"<button class='"+ class1 +" friend-button' value='"+ value1 +"'>" +
"<i class='fa "+ icon1 +"'></i> " + text1 +
"</button>");
$buttonContainer.append(
"<button class='"+ class2 +" friend-button' value='"+ value2 +"'>" +
"<i class='fa "+ icon2 +"'></i> " + text2 +
"</button>");
$buttonContainer.children().click(function() {
editFriendship(userID, this.value);
if (isNaN(this.value))
editFriendship(userID, this.value);
else if (this.value != "")
window.location.href = "chat.php?username=" + this.value;
});
});
}

View File

@@ -2,19 +2,39 @@ var days = ["zondag", "maandag", "dinsdag", "woensdag", "donderdag", "vrijdag",
var months = ["januari", "februari", "maart", "april", "mei", "juni", "juli", "augustus", "september", "oktober", "november", "december"]
function fancyText(text) {
// Add images and gifs.
var regex = /(https:\/\/.[^ ]*\.(?:png|jpg|jpeg|gif))/ig;
text = text.replace(regex, function(img) {
return "<img src='" + img + "' />";
// Add links, images, gifs and (youtube) video's.
var regex = /(https?:\/\/.[^ ]*)/ig;
text = text.replace(regex, function(link) {
// Add images
if (link.match(/(https?:\/\/.[^ ]*\.(?:png|jpg|jpeg|gif))/ig)) {
return "<img alt='" + link + "' src='" + link + "' />";
}
// Add mp4 video's
else if (link.match(/(https?:\/\/.[^ ]*\.(?:mp4))/ig)) {
return "<video width='100%'>" +
"<source src='"+ link +"' type='video/mp4'>" +
"<b>Je browser ondersteund geen video</b>" +
"</video><button class='gray' onclick='$(this).prev().get(0).play();'>Speel af</button>";
}
// Add ogg video's
else if (link.match(/(https?:\/\/.[^ ]*\.(?:ogg))/ig)) {
return "<video width='100%'>" +
"<source src='"+ link +"' type='video/ogg'>" +
"<b>Je browser ondersteund geen video</b>" +
"</video><button onclick='$(this).prev().get(0).play();'>Speel af</button>";
}
// Add youtube video's
else if (link.match(/(https?:\/\/.(www.)?youtube|youtu.be)*watch/ig)) {
return '<iframe width="100%"' +
' src="https://www.youtube.com/embed/' + link.substr(link.length - 11) +
'" frameborder="0" allowfullscreen></iframe>';
}
// Add links
else {
return "<a href='" + link + "'>" + link + "</a>";
}
});
// Add links.
// regex = /(https:\/\/.[^ ]*\.(?:net|com|nl))/ig;
// text = text.replace(regex, function(link) {
// return "<a href='" + link + "'>LINK</a>";
// });
return text;
}

View File

@@ -90,7 +90,7 @@ function masonry(mode) {
/*
* Get the posts from the server.
*/
$.post("API/getPosts.php", { usr : userID })
$.post("API/getPosts.php", { usr : userID, grp : groupID })
.done(function(data) {
posts = JSON.parse(data);

View File

@@ -4,7 +4,9 @@ function postComment(buttonValue) {
$.post(
"API/postComment.php",
formData
);
).done(function(data) {
console.log(data);
});
$("#newcomment").val("");

View File

@@ -27,7 +27,6 @@ if(empty($_GET["username"])) {
$user = selectUser($_SESSION["userID"], $userID);
$profile_friends = selectAllFriends($userID);
$profile_groups = selectAllUserGroups($userID);
$posts = selectAllUserPosts($userID);
if ($userID == $_SESSION["userID"]) {
@@ -54,23 +53,12 @@ include("../views/footer.php");
<script src="js/friendButtons.js"></script>
<script src="js/masonry.js"></script>
<script>
var posts;
$(document).ready(function() {
userID = <?= $userID ?>;
groupID = 0;
placeFriendButtons();
masonry(<?= $masonry_mode ?>);
// alert("blap");
// $.post("API/getPosts.php", { usr : userID }, "json")
// .done(function(data) {
// posts = JSON.parse(data);
// alert(posts[0]["content"]);
// }).fail(function() {
// alert("failure...");
// });
});
</script>
</body>

View File

@@ -28,7 +28,7 @@ if ($_SERVER["REQUEST_METHOD"] == "GET") {
}
function changePassword() {
$stmt = $GLOBALS["db"]->prepare("
$stmt = prepareQuery("
UPDATE
`user`
SET
@@ -42,7 +42,7 @@ function changePassword() {
}
function verifyLink(int $userID, string $hash) {
$stmt = $GLOBALS["db"]->prepare("
$stmt = prepareQuery("
SELECT
`password`
FROM

View File

@@ -0,0 +1,3 @@
#quick-links i {
font-size: 32px;
}

View File

@@ -130,4 +130,18 @@ body {
.chat-message img {
max-width: 100%;
}
.chat-message a {
text-decoration: underline;
}
.chat-time {
color: #666666;
font-size: 12px;
margin-bottom: -3px;
}
.chat-message-other .chat-time {
text-align: right;
}

View File

@@ -97,16 +97,16 @@ p {
}
.item-box, .item-box-full-width {
margin: 20px 0 0 0;
padding: 25px;
background-color: #FFFFFF;
}
.item-box {
width: calc(50% - 60px);
width: calc(33% - 50px);
display: inline-table;
}
@media only screen and (max-width: 900px) {
@media only screen and (max-width: 1400px) {
.item-box {
width: calc(100% - 50px);
}
@@ -183,6 +183,10 @@ button.green {
background-color: forestgreen;
}
button.gray{
background-color: #FFF;
color: #333;
}
button,
input[type="submit"],
@@ -224,6 +228,7 @@ td {
/* Custom title box, appears instantaneously */
a[data-title]:hover,
i[data-title]:hover,
img[data-title]:hover,
span[data-title]:hover,
div[data-title]:hover {
@@ -231,6 +236,7 @@ div[data-title]:hover {
}
a[data-title]:hover:after,
i[data-title]:hover:after,
img[data-title]:hover:after,
span[data-title]:hover:after,
div[data-title]:hover:after {

View File

@@ -1,6 +1,9 @@
body {
background-color: #FBC02D;
}
.password-change {
height: 100%;
background-color: #FBC02D;
margin: auto;
}
@@ -12,6 +15,14 @@
margin: 30px auto auto;
display: block;
}
.password-change img {
.top-logo img {
width: 50%;
}
.error-page {
text-align: center;
}
.error-page img {
vertical-align: middle;
}

View File

@@ -71,7 +71,16 @@
width: 95%;
}
.nietslecht {
.nietslecht-text {
font-family: Impact, Anton, sans-serif;
text-shadow: -1.5px 0 1px black, 0 1.5px 1px black, 1px 0 1.5px black, 0 -1.5px 1px black;
text-shadow: -1px 0 1px black, 0 1px 1px black, 1px 0 1px black, 0 -1px 1px black;
}
.nietslecht {
}
.nietslecht img {
vertical-align: middle;
height: 24px;
width: 24px;
}

View File

@@ -1,15 +1,60 @@
.profile-box {
min-height: 150px;
padding: 25px;
background-color: #FFFFFF;
/* New */
.user-box {
text-align: center;
}
.profile-box .profile-picture, .profile-box .group-picture {
.status-buttons-container {
position: relative;
float: left;
width: 200px;
display: inline-block;
}
.friend-button-container {
position: relative;
float: right;
width: 200px;
display: inline-block;
}
.friend-button-container button, .status-buttons-container button {
display: block;
margin: 7px 0;
width: 200px;
font-size: 18px;
}
.empty-button {
background: none;
cursor: auto;
}
.empty-button:active {
box-shadow: none;
}
.profile-info {
display: inline-block;
min-width: 250px;
width: auto;
padding-top: 30px;
}
.main-picture {
position: relative;
border: #4CAF50 solid 5px;
display: inline-block;
width: 150px;
height: 150px;
margin: 0 20px 20px 0;
margin-bottom: -45px;
}
/* Old */
.profile-box h1.profile-username {
padding-top: 50px;
}
@@ -18,14 +63,12 @@
}
div.posts {
padding-top: 20px;
width: calc(100% + 20px);
display: inline-flex;
}
div.posts div.post {
display: block;
margin: 20px 0 0 0;
padding: 10px;
width: calc(100% - 40px);
cursor: pointer;
@@ -60,6 +103,12 @@ div.posts .post form textarea.newpost {
height: 100px;
}
.post .post-date {
float: right;
color: #aaaaaa;
font-size: 0.8em;
}
@media only screen and (max-width: 1500px) {
.post-box {
width: calc(50% - 68px);
@@ -72,23 +121,3 @@ div.posts .post form textarea.newpost {
width: calc(100% - 65px);
}
}
.post .post-date {
float: right;
color: #aaaaaa;
font-size: 0.8em;
}
button.friend-button {
float: right;
height: auto;
padding: 10px;
margin-left: 10px;
border-radius: 5px;
transition-duration: 250ms;
cursor: pointer;
}
button.friend-button:hover {
box-shadow: 0 10px 20px rgba(0,0,0,0.19), 0 6px 6px rgba(0,0,0,0.23);
}