Stop before Genius Bar visit
This commit is contained in:
@@ -5,14 +5,24 @@ session_start();
|
|||||||
require("../../queries/post.php");
|
require("../../queries/post.php");
|
||||||
require("../../queries/connect.php");
|
require("../../queries/connect.php");
|
||||||
require("../../queries/checkInput.php");
|
require("../../queries/checkInput.php");
|
||||||
if (empty($_POST['newcomment-content'])) {
|
if ($_POST["button"] == "reaction") {
|
||||||
echo 0;
|
if (empty($_POST['newcomment-content'])) {
|
||||||
} else {
|
echo 0;
|
||||||
if(makeComment($_POST['postID'],
|
} else {
|
||||||
$_SESSION['userID'],
|
if (makeComment($_POST['postID'],
|
||||||
test_input($_POST['newcomment-content']))) {
|
$_SESSION['userID'],
|
||||||
|
test_input($_POST['newcomment-content']))) {
|
||||||
|
echo 1;
|
||||||
|
} else {
|
||||||
|
echo 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} elseif ($_POST["button"] == "nietslecht") {
|
||||||
|
if (makeNietSlecht($_POST["postID"], $_SESSION["userID"])) {
|
||||||
echo 1;
|
echo 1;
|
||||||
} else {
|
} else {
|
||||||
echo 0;
|
echo 0;
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
echo 0;
|
||||||
}
|
}
|
||||||
@@ -69,4 +69,9 @@
|
|||||||
.commentcontent {
|
.commentcontent {
|
||||||
margin: 5px auto;
|
margin: 5px auto;
|
||||||
width: 95%;
|
width: 95%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.nietslecht {
|
||||||
|
font-family: Impact, sans-serif;
|
||||||
|
text-shadow: -1.5px 0 1px black, 0 1.5px 1px black, 1px 0 1.5px black, 0 -1.5px 1px black;
|
||||||
}
|
}
|
||||||
@@ -75,7 +75,7 @@ function makePost($userID, $groupID, $title, $content) {
|
|||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
}
|
}
|
||||||
|
|
||||||
function makeComment($postID, $userID, $content) {
|
function makeComment($postID, $userID, $content) : int {
|
||||||
$stmt = $GLOBALS["db"]->prepare("
|
$stmt = $GLOBALS["db"]->prepare("
|
||||||
INSERT INTO
|
INSERT INTO
|
||||||
`comment` (
|
`comment` (
|
||||||
@@ -94,4 +94,55 @@ function makeComment($postID, $userID, $content) {
|
|||||||
$stmt->bindParam(':userID', $userID);
|
$stmt->bindParam(':userID', $userID);
|
||||||
$stmt->bindParam(':content', $content);
|
$stmt->bindParam(':content', $content);
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
}
|
return $stmt->rowCount();
|
||||||
|
}
|
||||||
|
|
||||||
|
function makeNietSlecht(int $postID, int $userID) : int {
|
||||||
|
if (checkNietSlecht($postID, $userID)) {
|
||||||
|
return deleteNietSlecht(postID, $userID);
|
||||||
|
} else {
|
||||||
|
return addNietSlecht($postID, $userID);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function checkNietSlecht(int $postID, int $userID) {
|
||||||
|
$stmt = $GLOBALS["db"]->prepare("
|
||||||
|
SELECT
|
||||||
|
*
|
||||||
|
FROM
|
||||||
|
`niet_slecht`
|
||||||
|
WHERE
|
||||||
|
`userID` = :userID AND
|
||||||
|
`postID` = :postID
|
||||||
|
");
|
||||||
|
$stmt->bindParam(":userID", $userID);
|
||||||
|
$stmt->bindParam(":postID", $postID);
|
||||||
|
$stmt->execute();
|
||||||
|
return $stmt->rowCount();
|
||||||
|
}
|
||||||
|
|
||||||
|
function addNietSlecht(int $postID, int $userID) {
|
||||||
|
$stmt = $GLOBALS["db"]->prepare("
|
||||||
|
INSERT INTO
|
||||||
|
`niet_slecht` (`userID`, `postID`)
|
||||||
|
VALUES (:userID, :postID)
|
||||||
|
");
|
||||||
|
$stmt->bindParam(":userID", $userID);
|
||||||
|
$stmt->bindParam(":postID", $postID);
|
||||||
|
$stmt->execute();
|
||||||
|
return $stmt->rowCount();
|
||||||
|
}
|
||||||
|
|
||||||
|
function deleteNietSlecht(int $postID, int $userID) {
|
||||||
|
$stmt = $GLOBALS["db"]->prepare("
|
||||||
|
DELETE FROM
|
||||||
|
`niet_slecht`
|
||||||
|
WHERE
|
||||||
|
`userID` = :userID AND
|
||||||
|
`postID` = :postID
|
||||||
|
");
|
||||||
|
$stmt->bindParam(":userID", $userID);
|
||||||
|
$stmt->bindParam(":postID", $postID);
|
||||||
|
$stmt->execute();
|
||||||
|
return $stmt->rowCount();
|
||||||
|
}
|
||||||
|
|||||||
@@ -24,7 +24,9 @@ echo("
|
|||||||
<form id="newcommentform" action="javascript:postComment();">
|
<form id="newcommentform" action="javascript:postComment();">
|
||||||
<input type="hidden" id="newcomment-textarea" name="postID" value="<?= $postID ?>">
|
<input type="hidden" id="newcomment-textarea" name="postID" value="<?= $postID ?>">
|
||||||
<textarea id="newcomment" name="newcomment-content" placeholder="Laat een reactie achter..."></textarea> <br>
|
<textarea id="newcomment" name="newcomment-content" placeholder="Laat een reactie achter..."></textarea> <br>
|
||||||
<input type="submit" value="Reageer!">
|
<button type="submit" name="button" value="reaction">Reageer!</button>
|
||||||
|
<!-- TODO: if/else op "niet slecht." button voor like/unlike-->
|
||||||
|
<button type="submit" name="button" value="nietslecht">Vind ik <span class="nietslecht">"Niet slecht."</span></button>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user