-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgetGJComments19.php
56 lines (36 loc) · 1.37 KB
/
getGJComments19.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
<?php
include __DIR__ . "/incl/lib/connection.php";
# Getting data
$page = $_POST['page'];
$levelID = $_POST['levelID'];
$secret = $_POST['secret'];
$page2 = $page*5;
$commentString = "";
$userString = "";
# Secret check
if($secret != "Wmfd2893gb7") {
die("-1");
}
$sql = $conn->prepare("SELECT * FROM comments WHERE levelID = :levelID LIMIT 5 OFFSET $page2");
$sql->bindParam(":levelID", $levelID);
$sql->execute();
$result = $sql->fetchAll(PDO::FETCH_ASSOC);
foreach($result as $comment) {
$commentString .= "1~" . $comment['levelID'] . "~2~" . base64_decode($comment['comment']). "~3~" . $comment['userID'] . "~4~" . $comment['likes'] . "~5~0" . "~6~" . $comment['id'] . "~7~" . $comment['spam'] . "~8~" . $comment['accountID'] . "|";
}
$commentString = rtrim($commentString, "|");
foreach($result as $userComment) {
$userString .= $userComment['userID'] . ":" . $userComment['userName'] . ":" . $userComment['accountID'] . "|";
}
$userString = rtrim($userString, "|");
# query number of comments
$sql = $conn->prepare("SELECT count(*) FROM comments WHERE levelID = :levelID");
$sql->bindParam(":levelID", $levelID);
$sql->execute();
$commentCount = $sql->fetchColumn();
if($commentCount != 0) {
echo($commentString . "#" . $userString . "#" . $commentCount . ":" . $page2 . ":5");
} else {
echo("-2");
}
?>