aboutsummaryrefslogtreecommitdiff
path: root/guestbook/comments.php
diff options
context:
space:
mode:
Diffstat (limited to 'guestbook/comments.php')
-rw-r--r--guestbook/comments.php46
1 files changed, 46 insertions, 0 deletions
diff --git a/guestbook/comments.php b/guestbook/comments.php
new file mode 100644
index 0000000..3f65fb9
--- /dev/null
+++ b/guestbook/comments.php
@@ -0,0 +1,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;
+}
+