-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
127 lines (115 loc) · 3.66 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
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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
<?php
require_once "Parsedown.php";
require_once "RenderConfig.php";
require_once "ModifyElements.php";
require_once "ParsedownModify.php";
parse_str($_SERVER["QUERY_STRING"], $query_array);
if(array_key_exists("cfg", $query_array)) {
$choice = $query_array["cfg"];
} else $choice = "test";
$cfgfile = $choice . ".json";
global $g_pageconfig;
$g_pageconfig = new RenderConfig($cfgfile);
$ElementModifier = new ModifyElements($g_pageconfig);
$render = new ParsedownModify($ElementModifier);
// generic page options - footer, social icons, "to top" button, etc
global $g_mdpage;
if(file_exists($g_pageconfig->mdpageopt))
{
$g_mdpage = json_decode(file_get_contents($g_pageconfig->mdpageopt));
}
// generate a static file?
if($g_pageconfig->genstatic === true) ob_start();
?>
<!DOCTYPE html>
<html lang="en-us">
<?php
include "./head.php";
if(isset($g_mdpage->body) && ($g_mdpage->body != ""))
{
echo stripslashes($g_mdpage->body) . "\n";
} else echo '<body class="container-fluid">' . "\n";
?>
<!-- Document -->
<div class="row doc-body">
<div class="col-lg-8 col-lg-offset-2 col-md-8 col-md-offset-2 col-sm-10 col-sm-offset-1 col-xs-10 col-xs-offset-1">
<!-- Rendered Document -->
<?php
$file = file_get_contents($g_pageconfig->mdfile, true);
echo "\n" . $render->text($file) . "\n";
?>
<!-- ^Rendered Document -->
</div>
<?php
if(isset($g_mdpage->totop) && ($g_mdpage->totop === true))
{
echo ' <button id="gototop" class="gototop" onclick="jumpToTop()" title="Go to top of page">▲<br>top</button>' . "\n";
}
?>
<br>
<br>
</div>
<!-- ^Document -->
<!-- Page Footer -->
<?php
if(isset($g_mdpage->footer) && ($g_mdpage->footer === true))
{
?>
<footer class="navbar navbar-default navbar-fixed-bottom">
<div class="text-center">
<div class="mdfooter col-lg-4 col-lg-offset-4 col-md-4 col-md-offset-4 col-sm-6 col-sm-offset-3 col-xs-12">
<p>
<?php
if(isset($g_mdpage->socicon) && ($g_mdpage->socicon === true))
{
echo " <a href=".$g_mdpage->socitems[0]->url." target=".$g_mdpage->socitems[0]->target." class=".$g_mdpage->socitems[0]->class." title=".$g_mdpage->socitems[0]->title."></a>\n";
if(isset($g_mdpage->footertxt))
{
echo " " . stripslashes($g_mdpage->footertxt) . "\n";
}
echo " <a href=".$g_mdpage->socitems[1]->url." target=".$g_mdpage->socitems[1]->target." class=".$g_mdpage->socitems[1]->class." title=".$g_mdpage->socitems[1]->title."></a>\n";
} else {
if(isset($g_mdpage->footertxt))
{
echo " " . stripslashes($g_mdpage->footertxt) . "\n";
}
}
?>
</p>
</div>
</div>
</footer>
<?php
}
?>
<!-- ^Page Footer -->
<?php
if(isset($g_pageconfig->codecolor) && ($g_pageconfig->codecolor === true))
{
if(isset($g_pageconfig->codecolorfiles))
{
$codecolor = json_decode(file_get_contents($g_pageconfig->codecolorfiles));
for($ix = 0;$codecolor->scripts[$ix] != "END";$ix++)
{
$script = stripslashes($codecolor->scripts[$ix]);
echo " $script\n";
}
}
}
echo "</body>\n";
if(isset($g_mdpage->totop) && ($g_mdpage->totop === true))
{
echo '<!-- code for the "go to top" button -->' . "\n";
echo '<script src="./assets/js/totop.js"></script>' . "\n";
}
echo "</html>\n";
// generate a static file?
if($g_pageconfig->genstatic === true)
{
$content = ob_get_contents();
ob_end_flush();
$fh = fopen("$g_pageconfig->statname",'w');
fwrite($fh,$content);
fclose($fh);
}
?>