This repository has been archived by the owner on Nov 9, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
executable file
·68 lines (66 loc) · 1.56 KB
/
index.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
57
58
59
60
61
62
63
64
65
66
67
68
<html>
<head>
<title>guestbook</title>
<style>
#cdiv {
text-align: center;
}
#rdiv {
text-align: left;
display: inline-block;
}
body {
font-family: Arial;
color: black;
background-color: #EFB2D0;
}
a {
color: black;
}
#cmts {
position: absolute;
left: 10%;
right: 10%;
width: 80%;
word-break: break-word;
}
pre {
white-space: pre-wrap;
}
</style>
</head>
<body>
<div id="cdiv">
<h2>guestbook</h2>
<p>leave a comment!</p>
<div id="rdiv">
<p>the (extremely) bodged together code is available on <a href="https://github.com/x-t/ok-guestbook">github</a>!</p>
<form action="result.php" method="post">
(optional) Username:<br>
<input type="text" name="uname" autocomplete="off" maxlength="32">
<br>Message:<br>
<input type="text" name="message" autocomplete="off" maxlength="512">
<br><br>
<input type="submit">
</form>
<br><br>
<div id="cmts">
<?php
$s = file_get_contents("comments.json");
if ($s === FALSE) {
echo "sysadmin error: error reading comment file";
}
else if ($s === NULL) {
echo "sysadmin error: file_get_conents may be disabled";
}
$cmts = json_decode($s);
$arr_cmts = array_reverse($cmts->comments);
foreach ($arr_cmts as $comment) {
echo "<pre>[" . $comment->time . "] <strong>" . htmlspecialchars($comment->name) . "</strong>: " . htmlspecialchars($comment->data) . "</pre>\n";
}
?>
</div>
</div>
</div>
</body>
</html>