forked from TomokoTomoki/Blargboard
-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathindex.php
243 lines (191 loc) · 7.13 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
<?php
$starttime = microtime(true);
define('BLARG', 1);
// change this to change your board's default page
define('MAIN_PAGE', 'home');
$ajaxPage = false;
if(isset($_GET['ajax']))
$ajaxPage = true;
require(__DIR__.'/lib/common.php');
$layout_crumbs = '';
$layout_actionlinks = '';
if (isset($_GET['forcelayout']))
{
setcookie('forcelayout', (int)$_GET['forcelayout'], time()+365*24*3600, URL_ROOT, "", false, true);
die(header('Location: '.$_SERVER['HTTP_REFERER']));
}
$layout_birthdays = getBirthdaysText();
$tpl->assign('logusername', htmlspecialchars($loguser['displayname'] ?: $loguser['name']));
$tpl->assign('loguserlink', UserLink($loguser));
$metaStuff = array(
'description' => Settings::get('metaDescription'),
'tags' => Settings::get('metaTags')
);
//=======================
// Do the page
if (isset($_GET['page']))
$page = $_GET['page'];
else
$page = MAIN_PAGE;
if(!ctype_alnum($page))
$page = MAIN_PAGE;
define('CURRENT_PAGE', $page);
ob_start();
$layout_crumbs = "";
$fakeerror = false;
if ($loguser['flags'] & 0x2)
{
if (rand(0,100) <= 75)
{
Alert("Could not load requested page: failed to connect to the database. Try again later.", 'Error');
$fakeerror = true;
}
}
if (!$fakeerror)
{
try
{
try
{
if(array_key_exists($page, $pluginpages))
{
$plugin = $pluginpages[$page];
$self = $plugins[$plugin];
$page = __DIR__.'/plugins/'.$self['dir']."/pages/".$page.".php";
if(!file_exists($page))
throw new Exception(404);
include($page);
unset($self);
}
else
{
$page = __DIR__.'/pages/'.$page.'.php';
if(!file_exists($page))
throw new Exception(404);
include($page);
}
}
catch(Exception $e)
{
if ($e->getMessage() != 404)
{
throw $e;
}
require(__DIR__.'/pages/404.php');
}
}
catch(KillException $e)
{
// Nothing. Just ignore this exception.
}
}
if($ajaxPage)
{
ob_end_flush();
die();
}
$layout_contents = ob_get_contents();
ob_end_clean();
//Do these things only if it's not an ajax page.
include(__DIR__."/lib/views.php");
setLastActivity();
//=======================
// Panels and footer
require(__DIR__.'/layout/userpanel.php');
require(__DIR__.'/layout/menus.php');
$mobileswitch = '';
if ($mobileLayout) $mobileswitch .= 'Mobile view - ';
if ($_COOKIE['forcelayout']) $mobileswitch .= '<a href="?forcelayout=0" rel="nofollow">Auto view</a>';
else if ($mobileLayout) $mobileswitch .= '<a href="?forcelayout=-1" rel="nofollow">Force normal view</a>';
else $mobileswitch .= '<a href="?forcelayout=1" rel="nofollow">Force mobile view [BETA]</a>';
//=======================
// Notification bars
$notifications = getNotifications();
//=======================
// Misc stuff
$layout_time = formatdatenow();
$layout_onlineusers = getOnlineUsersText();
$layout_birthdays = getBirthdaysText();
$layout_views = '<span id="viewCount">'.number_format($misc['views']).'</span> '.__('views');
$layout_title = htmlspecialchars(Settings::get('boardname'));
if($title != '')
$layout_title .= ' » '.$title;
//=======================
// Board logo and theme
$layout_logopic = 'img/logo.png';
if (!file_exists(__DIR__.'/'.$layout_logopic))
$layout_logopic = 'img/logo.jpg';
$layout_logopic = resourceLink($layout_logopic);
$favicon = resourceLink('img/favicon.ico');
$themefile = "themes/$theme/style.css";
if(!file_exists(__DIR__.'/'.$themefile))
$themefile = "themes/$theme/style.php";
$layout_credits =
'<img src="'.resourceLink('img/poweredbyblarg.png').'" style="float: left; margin-right: 3px;">
<a href="http://blargboard.kuribo64.net/" target="_blank">Blargboard '.BLARG_VERSION.'</a> · by StapleButter<br>
Based off <a href="http://abxd.dirbaio.net/" target="_blank">ABXD</a> by Dirbaio, Kawa & co.<br>';
$layout_contents = "<div id=\"page_contents\">$layout_contents</div>";
//=======================
// Print everything!
$perfdata = 'Page rendered in '.sprintf('%.03f',microtime(true)-$starttime).' seconds (with '.$queries.' SQL queries and '.sprintf('%.03f',memory_get_usage() / 1024).'K of RAM)';
?>
<!doctype html>
<html lang="en">
<head>
<title><?php print $layout_title; ?></title>
<meta http-equiv="Content-Type" content="text/html; CHARSET=utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=10">
<meta name="description" content="<?php print $metaStuff['description']; ?>">
<meta name="keywords" content="<?php print $metaStuff['tags']; ?>">
<link rel="shortcut icon" type="image/x-icon" href="<?php print $favicon;?>">
<link rel="stylesheet" type="text/css" href="<?php print resourceLink("css/common.css");?>">
<link rel="stylesheet" type="text/css" id="theme_css" href="<?php print resourceLink($themefile); ?>">
<link rel="stylesheet" type="text/css" href="<?php print resourceLink('css/font-awesome.min.css'); ?>">
<script type="text/javascript" src="<?php print resourceLink("js/jquery.js");?>"></script>
<script type="text/javascript" src="<?php print resourceLink("js/tricks.js");?>"></script>
<script type="text/javascript" src="<?php print resourceLink("js/jquery.tablednd_0_5.js");?>"></script>
<script type="text/javascript" src="<?php print resourceLink("js/jquery.scrollTo-1.4.2-min.js");?>"></script>
<script type="text/javascript" src="<?php print resourceLink("js/jscolor/jscolor.js");?>"></script>
<script type="text/javascript">boardroot = <?php print json_encode(URL_ROOT); ?>;</script>
<?php $bucket = "pageHeader"; include(__DIR__."/lib/pluginloader.php"); ?>
<?php if ($mobileLayout) { ?>
<meta name="viewport" content="user-scalable=yes, initial-scale=1.0, width=device-width">
<script type="text/javascript" src="<?php echo resourceLink('js/mobile.js'); ?>"></script>
<?php if ($oldAndroid) { ?>
<style type="text/css">
#mobile-sidebar { height: auto!important; max-height: none!important; }
#realbody { max-height: none!important; max-width: none!important; overflow: scroll!important; }
</style>
<?php } ?>
<?php } ?>
</head>
<body style="width:100%; font-size: <?php echo $loguser['fontsize']; ?>%;">
<form action="<?php echo htmlentities(actionLink('login')); ?>" method="post" id="logout" style="display:none;"><input type="hidden" name="action" value="logout"></form>
<?php
if (Settings::get('maintenance'))
echo '<div style="font-size:30px; font-weight:bold; color:red; background:black; padding:5px; border:2px solid red; position:absolute; top:30px; left:30px;">MAINTENANCE MODE</div>';
RenderTemplate('pagelayout', array(
'layout_contents' => $layout_contents,
'layout_crumbs' => $layout_crumbs,
'layout_actionlinks' => $layout_actionlinks,
'headerlinks' => $headerlinks,
'sidelinks' => $sidelinks,
'layout_userpanel' => $layout_userpanel,
'notifications' => $notifications,
'boardname' => Settings::get('boardname'),
'poratitle' => Settings::get('PoRATitle'),
'poratext' => Settings::get('PoRAText'),
'layout_logopic' => $layout_logopic,
'layout_time' => $layout_time,
'layout_views' => $layout_views,
'layout_onlineusers' => $layout_onlineusers,
'layout_birthdays' => $layout_birthdays,
'layout_credits' => $layout_credits,
'mobileswitch' => $mobileswitch,
'perfdata' => $perfdata));
?>
</body>
</html>
<?php
$bucket = "finish"; include(__DIR__.'/lib/pluginloader.php');
?>