forked from Jceggbert5/ABXD
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
265 lines (215 loc) · 6.08 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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
<?php
// Protect from <iframe> password steal hack
header('X-Frame-Options: DENY');
$ajaxPage = false;
if(isset($_GET["ajax"]))
$ajaxPage = true;
require('lib/common.php');
//TODO: Put this in a proper place.
function getBirthdaysText()
{
$rBirthdays = Query("select u.birthday, u.(_userfields) from {users} u where birthday > 0 and powerlevel >= 0 order by name");
$birthdays = array();
while($user = Fetch($rBirthdays))
{
$b = $user['birthday'];
if(gmdate("m-d", $b) == gmdate("m-d"))
{
$y = gmdate("Y") - gmdate("Y", $b);
$birthdays[] = UserLink(getDataPrefix($user, "u_"))." (".$y.")";
}
}
if(count($birthdays))
$birthdaysToday = implode(", ", $birthdays);
if($birthdaysToday)
return "<br>".__("Birthdays today:")." ".$birthdaysToday;
else
return "";
}
//Use buffering to draw the page.
//Useful to have it disabled when running from the terminal.
$useBuffering = true;
//Support for running pages from the terminal.
if(isset($argv))
{
$_GET = array();
$_GET["page"] = $argv[1];
$_SERVER = array();
$_SERVER["REMOTE_ADDR"] = "0.0.0.0";
$ajaxPage = true;
$useBuffering = false;
}
//=======================
// Do the page
if (isset($_GET['page']))
$page = $_GET["page"];
else
$page = $mainPage;
if(!ctype_alnum($page))
$page = $mainPage;
if($page == $mainPage)
{
if(isset($_GET['fid']) && (int)$_GET['fid'] > 0 && !isset($_GET['action']))
die(header("Location: ".actionLink("forum", (int)$_GET['fid'])));
if(isset($_GET['tid']) && (int)$_GET['tid'] > 0)
die(header("Location: ".actionLink("thread", (int)$_GET['tid'])));
if(isset($_GET['uid']) && (int)$_GET['uid'] > 0)
die(header("Location: ".actionLink("profile", (int)$_GET['uid'])));
if(isset($_GET['pid']) && (int)$_GET['pid'] > 0)
die(header("Location: ".actionLink("post", (int)$_GET['pid'])));
}
define('CURRENT_PAGE', $page);
if($useBuffering)
ob_start();
$layout_crumbs = new PipeMenu();
$layout_links = new PipeMenu();
try {
try {
if(array_key_exists($page, $pluginpages))
{
$plugin = $pluginpages[$page];
$self = $plugins[$plugin];
$page = "./plugins/".$self['dir']."/page_".$page.".php";
if(!file_exists($page))
throw new Exception(404);
include($page);
unset($self);
}
else {
$page = 'pages/'.$page.'.php';
if(!file_exists($page))
throw new Exception(404);
include($page);
}
}
catch(Exception $e)
{
if ($e->getMessage() != 404)
{
throw $e;
}
require('pages/404.php');
}
}
catch(KillException $e)
{
// Nothing. Just ignore this exception.
}
if($ajaxPage)
{
if($useBuffering)
{
header("Content-Type: text/plain");
ob_end_flush();
}
die();
}
$layout_contents = ob_get_contents();
ob_end_clean();
//Do these things only if it's not an ajax page.
include("lib/views.php");
setLastActivity();
//=======================
// Panels and footer
require('navigation.php');
require('userpanel.php');
ob_start();
require('footer.php');
$layout_footer = ob_get_contents();
ob_end_clean();
//=======================
// Notification bars
ob_start();
$bucket = "userBar"; include("./lib/pluginloader.php");
/*
if($rssBar)
{
write("
<div style=\"float: left; width: {1}px;\"> </div>
<div id=\"rss\">
{0}
</div>
", $rssBar, $rssWidth + 4);
}*/
DoPrivateMessageBar();
$bucket = "topBar"; include("./lib/pluginloader.php");
$layout_bars = ob_get_contents();
ob_end_clean();
//=======================
// Misc stuff
$layout_time = formatdatenow();
$layout_onlineusers = getOnlineUsersText();
$layout_birthdays = getBirthdaysText();
$layout_views = __("Views:")." ".'<span id="viewCount">'.number_format($misc['views']).'</span>';
$layout_title = htmlspecialchars(Settings::get("boardname"));
if($title != "")
$layout_title .= " » ".$title;
$layout_logotitle = Settings::get("boardname");
//=======================
// Board logo and theme
function checkForImage(&$image, $external, $file)
{
global $dataDir, $dataUrl;
if($image) return;
if($external)
{
if(file_exists($dataDir.$file))
$image = $dataUrl.$file;
}
else
{
if(file_exists($file))
$image = resourceLink($file);
}
}
if (!file_exists("themes/$theme")) { //Are we using some invalid theme?
if ($loguserid) {
$defaultTheme = Settings::get("defaultTheme");
query("update users set theme='" . $defaultTheme . "' where id=$loguserid");
$theme = $defaultTheme;
}
}
checkForImage($layout_logopic, true, "logos/logo_$theme.png");
checkForImage($layout_logopic, true, "logos/logo_$theme.jpg");
checkForImage($layout_logopic, true, "logos/logo_$theme.gif");
checkForImage($layout_logopic, true, "logos/logo.png");
checkForImage($layout_logopic, true, "logos/logo.jpg");
checkForImage($layout_logopic, true, "logos/logo.gif");
checkForImage($layout_logopic, false, "themes/$theme/logo.png");
checkForImage($layout_logopic, false, "themes/$theme/logo.jpg");
checkForImage($layout_logopic, false, "themes/$theme/logo.gif");
checkForImage($layout_logopic, false, "img/logo.png");
checkForImage($layout_favicon, true, "logos/favicon.gif");
checkForImage($layout_favicon, true, "logos/favicon.ico");
checkForImage($layout_favicon, false, "img/favicon.ico");
$layout_themefile = "themes/$theme/style.css";
if(!file_exists($layout_themefile))
$layout_themefile = "themes/$theme/style.php";
$layout_contents = "<div id=\"page_contents\">$layout_contents</div>";
//=======================
// PoRA box
if(Settings::get("showPoRA"))
{
$layout_pora = '
<div class="PoRT nom">
<table class="message outline">
<tr class="header0"><th>'.Settings::get("PoRATitle").'</th></tr>
<tr class="cell0"><td>'.Settings::get("PoRAText").'</td></tr>
</table>
</div>';
}
else
$layout_pora = "";
//=======================
// Print everything!
$layout = Settings::get("defaultLayout");
if($debugQueries)
$layout_contents.="<table class=\"outline margin width100\"><tr class=header0><th colspan=4>List of queries
<tr class=header1><th>Query<th>Backtrace$querytext</table>";
if($mobileLayout)
$layout = "mobile";
if(!file_exists("layouts/$layout/layout.php"))
$layout = "abxd";
require("layouts/$layout/layout.php"); echo (isset($times) ? $times : "");
$bucket = "finish"; include('lib/pluginloader.php');
?>