-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathmain.php
130 lines (104 loc) · 3.99 KB
/
main.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
128
129
130
<?php
require 'require.php';
//FRONTPAGE
if ((!isset($_GET["board"])) || ($_GET["board"] == '') && $_GET["page"] == '') {
$title = $site_name;
$total_posts = 0;
if (!file_exists($path . '/' . $database_folder . '/frontpage.php')) { //no frontpage? lets create boards folder
if (!file_exists($path . '/' . $database_folder . '/boards')) {
mkdir($path . '/' . $database_folder . '/boards');
}
}
foreach ($config['boards'] as $boards) {
//now lets create counters for each board, no matter if frontpage exists or not in case of new boards being made
if (!file_exists($path . '/' . $database_folder . '/boards/' . $boards['url'] . '/counter.php')) {
mkdir($path . '/' . $database_folder . '/boards/' . $boards['url']);
file_put_contents($path . '/' . $database_folder . '/boards/' . $boards['url'] . '/counter.php', 1);
}
//
$total_posts += file_get_contents($path . '/' . $database_folder . '/boards/' . $boards['url'] . '/counter.php');
$total_posts -= 1; //idk how i fucked up the counter.php in post.php this badly.
}
if (isset($_GET["theme"])) {
$output_html .= '<html data-stylesheet="'. htmlspecialchars($_GET["theme"]) .'">';
} else {
$output_html .= '<html data-stylesheet="'. $current_theme .'">';
}
$output_html .= '<head>';
include $path . '/templates/header.php';
$output_html .= '</head>';
$output_html .= '<body class="frontpage">';
include $path . '/templates/boardlist.php';
include $path . '/templates/frontpage.php';
include $path . '/templates/footer.php';
$output_html .= '</body>';
$output_html .= '</html>';
echo $output_html;
exit();
}
// PAGES
if ((!isset($_GET["board"])) || ($_GET["board"] == '') && $_GET["page"] != '') {
if (!ctype_alnum($_GET["page"])) {
error('Invalid page.');
}
if (!file_exists($path . '/templates/pages/' . $_GET["page"] . '.php')) {
http_response_code(404);
error('Page does not exist.');
}
include $path . '/templates/pages/' . $_GET["page"] . '.php';
if (isset($_GET["theme"])) {
$output_html .= '<html data-stylesheet="'. htmlspecialchars($_GET["theme"]) .'">';
} else {
$output_html .= '<html data-stylesheet="'. $current_theme .'">';
}
$output_html .= '<head>';
include $path . '/templates/header.php';
$output_html .= '</head>';
$output_html .= '<body class="page">';
include $path . '/templates/boardlist.php';
if ($config['display_banner'] === true) {
include $path . '/assets/img/banner.php';
}
$output_html .= '<div class="page-info">';
$output_html .= '<h1>' . $h1 . '</h1>';
$output_html .= '<span class="small">' . $description . '</span>';
$output_html .= '</div>';
$output_html .= $page_content; //taken from the file
include $path . '/templates/footer.php';
$output_html .= '</body>';
$output_html .= '</html>';
echo $output_html;
exit();
}
//
// IF BOARD EXISTS
if (in_Array(htmlspecialchars($_GET["board"]), $config['boardlist'])) {
$current_board = htmlspecialchars($_GET["board"]);
$board_description = $config['boards'][$current_board]['description'];
$board_slogan = $config['boards'][$current_board]['slogan'];
$board_title = $config['boards'][$current_board]['title'];
//if modonly
if ($config['boards'][$current_board]['mod_only'] == 1) {
if ($config['mod']['mod_only'] > $mod_level) {
error('Permission denied. Authenticated staff only.');
}
$forced_anon = true; //all names will be username in post.php
}
if ($config["boards"][$current_board]["type"] == "img") { //IMAGEBOARD INDEX+CATALOG
if ($catalog_enable == true) {
include $path . '/templates/catalog.php';
}
include $path . '/templates/index.php';
}
if ($config["boards"][$current_board]["type"] == "txt") { //TEXTBOARD INDEX+CATALOG+LIST
if ($catalog_enable == true) {
include $path . '/templates/catalog-txt.php';
}
include $path . '/templates/index-txt.php';
}
}
//NOT A BOARD
if ((htmlspecialchars($_GET["board"]) !== '') && (!in_Array(htmlspecialchars($_GET["board"]), $config['boardlist']))) {
error('This board doesn\'t exist.. You\'re not trying anything funny — are you, Anon-san??');
}
?>