Merge branch 'master' into kevin-prototype

This commit is contained in:
K. Nobel
2017-02-02 15:38:39 +01:00
23 changed files with 160 additions and 66 deletions

View File

@@ -12,36 +12,39 @@ if (isset($_SESSION["userID"]) &&
getRoleByID($_SESSION["userID"]) != 'frozen' &&
getRoleByID($_SESSION["userID"]) != 'banned') {
if (empty($_POST["title"]) or
empty($_POST["content"]) or
empty($_SESSION["userID"])
) {
if (empty($_SESSION["userID"])) {
header('HTTP/1.1 500 Non enough arguments');
}
if (empty($_POST["group"])) {
// User Post
makePost(
$_SESSION["userID"],
null,
test_input($_POST["title"]),
test_input($_POST["content"])
);
if (empty(test_input($_POST["title"])) or
empty(test_input($_POST["content"]))
) {
echo "empty";
} else {
// Group Post
if (empty($_POST["group"])) {
// User Post
makePost(
$_SESSION["userID"],
null,
test_input($_POST["title"]),
test_input($_POST["content"])
);
} else {
// Group Post
// Check if the user is an admin or mod of the group.
if (!in_array(selectGroupRole($_POST["group"]), array('mod', 'admin'))) {
header('HTTP/1.1 500 Non enough rights');
return;
// Check if the user is an admin or mod of the group.
if (!in_array(selectGroupRole($_POST["group"]), array('mod', 'admin'))) {
header('HTTP/1.1 500 Non enough rights');
return;
}
makePost(
$_SESSION["userID"],
$_POST["group"],
test_input($_POST["title"]),
test_input($_POST["content"])
);
}
makePost(
$_SESSION["userID"],
$_POST["group"],
test_input($_POST["title"]),
test_input($_POST["content"])
);
}
} else {
echo "frozen";

View File

@@ -0,0 +1,8 @@
<?php
if (isset($_GET["groupname"])) {
$url = "https://myhyvesbookplus.nl/~lars/group.php?groupname=" . $_GET["groupname"];
} else {
$url = "https://myhyvesbookplus.nl/";
}
?>
<a href="<?= $url ?>" target='_blank'><img style="width: 100%; height: auto;" src="../external/nietslecht_button.png" alt='\"Niet slecht\" ons op MyHyvesbook+' /></a>

View File

@@ -25,6 +25,9 @@ function loadMessages() {
addMessages(messages);
$("#lastID").val(messages[messages.length - 1].messageID);
}
loadUnreadMessages();
gettingMessages = false;
});
} else {
@@ -56,7 +59,7 @@ function addMessages(messages) {
for(var i in messages) {
// Initialize message variables.
var thisDate = new Date(messages[i].creationdate.replace(/ /,"T"));
var thisTime = thisDate.getHours() + ":" + thisDate.getMinutes();
var thisTime = thisDate.getHours() + ":" + ('0' + thisDate.getMinutes()).slice(-2);
var type;
thisDate.setHours(0,0,0,0);
@@ -78,6 +81,8 @@ function addMessages(messages) {
</div>';
}
previousDate = thisDate;
previousTime = thisTime;
previousType = type;
messagesText += '<div class="chat-message"><div class="' + type + '">';
// If it is not the first message, and has a different date/time/type then the previous message,
} else if (type != previousType || thisTime != previousTime || thisDate.getTime() > previousDate.getTime()) {

View File

@@ -31,7 +31,7 @@ function fancyText(text) {
}
// Add links
else {
return "<a href='" + link + "'>" + link + "</a>";
return "<a href='" + link + "' target='_blank'>" + link + "</a>";
}
});

View File

@@ -31,14 +31,28 @@ function postPost() {
$.post("API/postPost.php", { title: title,
content : content,
group : groupID })
.done(function() {
masonry(masonryMode);
.done(function(data) {
if (data == "empty") {
$('#alertbox').show();
$('#alerttext').html("Geen titel of inhoud; vul a.u.b. in.");
window.scrollTo(0,0);
} else {
$('#alertbox').hide();
masonry(masonryMode);
}
});
} else {
$.post("API/postPost.php", { title: title,
content : content })
.done(function() {
masonry(masonryMode);
.done(function(data) {
if (data == "empty") {
$('#alertbox').show();
$('#alerttext').html("Geen titel of inhoud; vul a.u.b. in.");
window.scrollTo(0,0);
} else {
$('#alertbox').hide();
masonry(masonryMode);
}
});
}
@@ -98,6 +112,10 @@ function masonry(mode) {
masonryMode = mode;
$container.children().remove();
// reinit posts
noposts = false;
postAmount = 0;
/*
* Initialise columns.
*/
@@ -153,9 +171,6 @@ function loadMorePosts(uID, gID, offset, limit) {
return;
}
console.log(uID, gID, offset, limit);
$.post("API/getPosts.php", { usr : uID,
grp : gID,
offset : offset,

View File

@@ -18,7 +18,7 @@ if ($_SERVER["REQUEST_METHOD"] == "POST") {
try {
switch ($_POST["form"]) {
case "profile":
updateSettings();
checkUpdateSettings();
break;
case "password":
changePassword();

View File

@@ -133,6 +133,12 @@ label {
color: red;
}
.login_containerNoscript {
padding: 4px;
text-align: center;
color: red;
}
@keyframes animatezoom {
from {transform: scale(0)}
to {transform: scale(1)}
@@ -150,7 +156,7 @@ label {
margin: 16px auto;
overflow-y: auto;
padding: 20px;
width: 600px;
width: 650px;
}
select{

View File

@@ -48,6 +48,10 @@
width: 90%;
}
.post-content a {
text-decoration: underline;
}
.commentfield {
margin-bottom: 20px;
}

View File

@@ -1,5 +1,14 @@
/* New */
.alertbox {
display: none;
background-color: firebrick;
}
.alerttext {
color: white;
}
.user-box {
text-align: center;
}
@@ -89,6 +98,10 @@ div.posts div.post {
word-wrap: break-word;
}
div.posts div.post a {
text-decoration: underline;
}
div.posts div.post:hover {
box-shadow: 0 10px 20px rgba(0,0,0,0.19), 0 6px 6px rgba(0,0,0,0.23);
}