blob: 3f65fb92844bf4110517cd943679115cd677db97 (
plain)
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
|
<?php
function echo_comments($page, $Parsedown = null) {
include($_SERVER['DOCUMENT_ROOT'] . '/common.php');
if(!$Parsedown) {
include($_SERVER['DOCUMENT_ROOT']."/Parsedown.php");
$Parsedown = new Parsedown();
$Parsedown->setSafeMode(true);
}
$totaloutput = "";
$postlist = json_decode(file_get_contents($datadir."posts.json"));
$index = 1;
foreach($postlist as $post) {
if($post->entry === $page and $post->modstatus > 0) {
$output = "";
$date = date("Y-m-d h:iA", $post->date);
$name = htmlentities($post->name);
$message = $Parsedown->text($post->message);
$found = htmlentities($post->found);
$website = $post->website;
$cool = $post->cool;
$coolsanitized = htmlentities(preg_replace("/https?:\/\//i", "", $cool));
$reply = $Parsedown->text($post->reply);
$output = $output."<hr><article><div style='grid-area:gb-name;' class='gb-name'>";
if($website) { $output = $output."<a href='$website'>$name</a>"; }
else { $output = $output.$name; }
$output = $output."</div><div style='grid-area:gb-date;' class='gb-date'>$date</div><div style='grid-area:gb-index;' class='gb-index'>Entry #$index</div>";
if($cool) {
$output = $output."<div style='grid-area:gb-cool;' class='gb-cool'><b>cool thing</b>: <a href='$cool'>$coolsanitized</a></div>";
}
if($found) {
$output = $output."<div style='grid-area:gb-found;'><b>How did you find me?</b><br>$found</div>";
}
$output = $output."<div style='grid-area:gb-message;'>$message</div>";
if($reply) {
$output = $output."<div style='grid-area:gb-reply;' class='reply'><b>Reply</b>:$reply</div>";
}
$output = $output."</article>";
$index++;
$totaloutput = $output.$totaloutput;
}
}
echo $totaloutput;
}
|