forked from lholliger/ATC
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpost.php
More file actions
110 lines (97 loc) · 2.58 KB
/
post.php
File metadata and controls
110 lines (97 loc) · 2.58 KB
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
<?php
require("header.php");
?>
<style>
span {
float: right;
}
</style>
<div class='container'>
<h1>
<?php
$path = "../data/posts/" . $_GET["id"];
echo(file_get_contents("$path/0/title"));
$type = file_get_contents("$path/0/type");
if ($type == "encryption") {
echo("</h1> <span class='t-crypt'>ENCRYPTION</span>");
}
if ($type == "ctf") {
echo("</h1> <span class='t-ctf'>CTF</span> ");
}
if ($type == "cg") {
echo("</h1> <span class='t-cg'>CODE GOLF</span> ");
}
if ($type == "code") {
echo("</h1> <span class='t-code'>CODE</span> ");
}
if ($type == "etc") {
echo("</h1> <span class='t-etc'>OTHER</span> ");
}
$status = file_get_contents("$path/0/status");
if ($status == "open") {
echo(" <span class='open'>OPEN</span>");
}
if ($status == "solved") {
echo(" <span class='solved'>SOLVED</span>");
}
if ($status == "issue") {
echo(" <span class='ISSUE'>ISSUE</span>");
}
?>
<br><br>
<center>
<div class='post'>
<div class='op'>
<?php echo(file_get_contents("$path/0/poster")); ?> posted at <?php echo(file_get_contents("$path/0/time")) ?>
</div>
<div class='pc'>
<?php echo(preg_replace("~[[:alpha:]]+://[^<>[:space:]]+[[:alnum:]/]~",
"<a href=\"\\0\">\\0</a>",file_get_contents("$path/0/contents"))); ?>
</div>
</div>
<?php
$files = glob("$path/_*");
usort($files, function($a, $b) {
return filemtime($a) < filemtime($b);
});
$files = array_reverse($files);
foreach ($files as $post) {
?>
<br><br>
<div class='post'>
<div class='pi'>
<?php echo(file_get_contents("$post/poster")); ?> replied at <?php echo(file_get_contents("$post/time")) ?>
</div>
<div class='pc'>
<?php echo(preg_replace("~[[:alpha:]]+://[^<>[:space:]]+[[:alnum:]/]~",
"<a href=\"\\0\">\\0</a>",file_get_contents("$post/contents"))); ?>
</div>
</div>
<?php
}
if ($_SESSION["LOG"] == True) {
?>
<h2>Reply</h2>
<div class='postbox'>
<form action="reply.php?post=<?php echo($_GET["id"]); ?>" method="post">
<textarea name='content' class='rep'></textarea>
<input class='sub' type="submit">
</form>
</div>
<?php
} else {
?>
<p><i>You need to be logged in to reply</i></p>
<?php
}
?>
</center>
<script>
var converter = new showdown.Converter(),
var elements = document.body.getElementsByClassName("pc");
window.onload = function() {
for (i = 0; i < elements.length; i++) {
elements[i].innerHTML = converter.makeHtml(elements[i].innerHTML);
}
}
</script>