-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrsg.php
101 lines (69 loc) · 1.6 KB
/
rsg.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
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
<?php
require("engine/utils.php");
require("engine/Text.php");
require("engine/Node.php");
require("engine/Renderer.php");
function main() {
if (strlen($_GET["text"])) {
renderSpecified();
} else {
renderDirectory();
}
} // main()
function renderSpecified() {
echoHeader("sans-serif");
$text = new Text("kontent/" . $_GET["text"]);
$text->load();
$renderer = new Renderer(null, $text->nodes);
$renderer->isDirectRendering = false;
$result = $renderer->render("@main");
if ($_GET["plain"]) {
$result = str_replace(" ", " ", $result);
}
echo($result);
echoFooter();
} // renderSpecified()
function renderDirectory() {
echoHeader("monospace");
echo("select file: <br/>");
$a = [];
$dir = dir(getcwd() . "/kontent");
while (($file = $dir->read()) !== false) {
if (!strstr($file,".txt")) continue;
$a[] = (
" <a href=\""
. "rsg.php?text="
. $file
. "\">"
. "$file"
. "</a>"
. " - "
. "<a href=\""
. "kontent/" . $file
. "\">"
. "(source)"
. "</a>"
. "<br/>"
);
}
$dir->close();
sort($a);
foreach ($a as $x) echo($x);
echoFooter();
} // renderDirectory()
function echoHeader($font) {
if ($_GET["plain"]) return;
header("Content-Type: text/html; charset=utf-8");
echo("<html><head><style>\n");
echo("body { font-family: " . $font . "; font-size: 24px;");
echo("</style></head><body>\n");
} // echoHeader()
function echoFooter() {
if ($_GET["plain"]) {
echo("\n");
} else {
echo("</body></html>\n");
}
} // echoFooter()
main();
?>