-
Notifications
You must be signed in to change notification settings - Fork 25
Expand file tree
/
Copy pathheader.php
More file actions
executable file
·179 lines (146 loc) · 9.78 KB
/
header.php
File metadata and controls
executable file
·179 lines (146 loc) · 9.78 KB
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
<?php
/*
* Copyright (C) 2013-2020 Luna
* Based on code by FluxBB copyright (C) 2008-2012 FluxBB
* Based on code by Rickard Andersson copyright (C) 2002-2008 PunBB
* Licensed under GPLv2 (http://getluna.org/license.php)
*/
// Make sure no one attempts to run this script "directly"
if (!defined('FORUM'))
exit;
// Send no-cache headers
header('Expires: Thu, 21 Jul 1977 07:30:00 GMT'); // When yours truly first set eyes on this world! :)
header('Last-Modified: '.date('D, d M Y H:i:s').' GMT');
header('Cache-Control: post-check=0, pre-check=0', false);
header('Pragma: no-cache'); // For HTTP/1.0 compatibility
// Send the Content-type header in case the web server is setup to send something else
header('Content-type: text/html; charset=utf-8');
// Prevent site from being embedded in a frame
$frame_options = defined('LUNA_FRAME_OPTIONS') ? LUNA_FRAME_OPTIONS : 'deny';
header('X-Frame-Options: '.$frame_options);
// Define $p if it's not set to avoid a PHP notice
$p = isset($p) ? $p : null;
// Generate user avatar
$user_avatar = draw_user_avatar($luna_user['id'], true, 'avatar');
// Generate quick links
$page_statusinfo = $page_threadsearches = array();
if (!$luna_user['is_guest']) {
if (!empty($forum_actions))
$page_statusinfo[] = '<li>'.implode(' · ', $forum_actions).'</li>';
if (!empty($thread_actions))
$page_statusinfo[] = '<li>'.implode(' · ', $thread_actions).'</li>';
if ($luna_user['is_admmod']) {
if ($luna_config['o_report_method'] == '0' || $luna_config['o_report_method'] == '2') {
$result_header = $db->query('SELECT 1 FROM '.$db->prefix.'reports WHERE zapped IS NULL') or error('Unable to fetch reports info', __FILE__, __LINE__, $db->error());
if ($db->result($result_header))
$page_statusinfo[] = '<li class="reportlink"><strong><a href="backstage/reports.php">'.__('New reports', 'luna').'</a></strong></li>';
}
if ($luna_config['o_maintenance'] == '1')
$page_statusinfo[] = '<li class="maintenancelink"><strong><a href="backstage/settings.php#maintenance">'.__('Maintenance mode is enabled', 'luna').'</a></strong></li>';
}
if ($luna_user['g_read_board'] == '1' && $luna_user['g_search'] == '1')
$page_threadsearches[] = '<a class="list-group-item" href="search.php?action=show_new" title="'.__('Show all new comments since your last visit', 'luna').'"><span class="fas fa-fw fa-newspaper"></span> '.__('New', 'luna').'</a>';
$page_threadsearches_inline[] = '<a href="search.php?action=show_new" title="'.__('Show all new comments since your last visit', 'luna').'"><span class="fas fa-fw fa-newspaper"></span> '.__('New', 'luna').'</a>';
}
// Quick searches
if ($luna_user['g_read_board'] == '1' && $luna_user['g_search'] == '1') {
$page_threadsearches[] = '<a class="list-group-item" href="search.php?action=show_recent" title="'.__('Show all active threads', 'luna').'"><span class="fas fa-fw fa-clock"></span> '.__('Active', 'luna').'</a>';
$page_threadsearches[] = '<a class="list-group-item" href="search.php?action=show_unanswered" title="'.__('Show all unanswered threads', 'luna').'"><span class="fas fa-fw fa-question"></span> '.__('Unanswered', 'luna').'</a>';
$page_threadsearches_inline[] = '<a href="search.php?action=show_recent" title="'.__('Show all active threads', 'luna').'"><span class="fas fa-fw fa-clock"></span> '.__('Active', 'luna').'</a>';
$page_threadsearches_inline[] = '<a href="search.php?action=show_unanswered" title="'.__('Show all unanswered threads', 'luna').'"><span class="fas fa-fw fa-question"></span> '.__('Unanswered', 'luna').'</a>';
}
// Generate all that jazz
$tpl_temp = '<div id="brdwelcome">';
// The status information
if (is_array($page_statusinfo)) {
$tpl_temp .= "\n\t\t\t".'<ul class="conl">';
$tpl_temp .= "\n\t\t\t\t".implode("\n\t\t\t\t", $page_statusinfo);
$tpl_temp .= "\n\t\t\t".'</ul>';
} else
$tpl_temp .= "\n\t\t\t".$page_statusinfo;
// Generate quicklinks
if (!empty($page_threadsearches)) {
$tpl_temp .= "\n\t\t\t".'<ul class="conr">';
$tpl_temp .= "\n\t\t\t\t".'<li>'.implode(' · ', $page_threadsearches_inline).'</li>';
$tpl_temp .= "\n\t\t\t".'</ul>';
}
$tpl_temp .= '</div>';
// Navbar data
$links = array();
$menu_title = $luna_config['o_board_title'];
$inbox_menu_item = '';
$num_new_pm = 0;
if ($luna_config['o_enable_inbox'] == '1' && $luna_user['g_inbox'] == '1' && $luna_user['use_inbox'] == '1') {
// Check for new messages
$result = $db->query('SELECT COUNT(id) FROM '.$db->prefix.'messages WHERE showed=0 AND show_message=1 AND owner='.$luna_user['id']) or error('Unable to check the availibility of new messages', __FILE__, __LINE__, $db->error());
$num_new_pm = $db->result($result);
if ($num_new_pm > 0)
$new_inbox = $num_new_pm.' ';
else
$new_inbox = '';
$inbox_menu_item = '<li><a href="inbox.php"><span class="'.(($num_new_pm > 0)? ' flash' : '').'">'.$new_inbox.'<span class="fas fa-fw fa-paper-plane"></span><span class="visible-xs-inline"> '.__( 'Inbox', 'luna' ).'</span></span></a></li>';
}
if (!$luna_user['is_guest']) {
// Check for new notifications
$result = $db->query('SELECT COUNT(id) FROM '.$db->prefix.'notifications WHERE viewed = 0 AND user_id = '.$luna_user['id']) or error ('Unable to load notifications', __FILE__, __LINE__, $db->error());
$num_notifications = $db->result($result);
if ($luna_config['o_notification_flyout'] == 1) {
if ($num_notifications == '0') {
$notificon = '<span class="far fa-fw fa-circle"></span>';
$ind_notification[] = '<li><a href="notifications.php">'.__( 'No new notifications', 'luna' ).'</a></li>';
} else {
$notificon = $num_notifications.' <span class="fas fa-fw fa-circle"></span>';
$notification_result = $db->query('SELECT * FROM '.$db->prefix.'notifications WHERE user_id = '.$luna_user['id'].' AND viewed = 0 ORDER BY time DESC LIMIT 10') or error ('Unable to load notifications', __FILE__, __LINE__, $db->error());
while ($cur_notifi = $db->fetch_assoc($notification_result)) {
$notifitime = format_time($cur_notifi['time'], false, null, $luna_config['o_time_format'], true, true);
$ind_notification[] = '<li class="overflow"><a href="notifications.php?notification='.$cur_notifi['id'].'"><span class="timestamp">'.$notifitime.'</span> <span class="fas fa-fw '.$cur_notifi['icon'].'"></span> '.$cur_notifi['message'].'</a></li>';
}
}
$notifications = implode('<li class="divider"></li>', $ind_notification);
$notification_menu_item = '
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown"><span class="'.(($num_notifications != 0)? ' flash' : '').'">'.$notificon.'<span class="visible-xs-inline"> '.__( 'Notifications', 'luna' ).'</span></span></a>
<ul class="dropdown-menu notification-menu">
<li role="presentation" class="dropdown-header">'.__( 'Notifications', 'luna' ).'</li>
<li class="divider"></li>
'.$notifications.'
<li class="divider"></li>
<li class="dropdown-footer hidden-xs"><a class="pull-right" href="notifications.php">'.__('More', 'luna').' <i class="fas fa-fw fa-arrow-right"></i></a></li>
<li class="dropdown-footer hidden-lg hidden-md hidden-sm"><a href="notifications.php">'.__('More', 'luna').' <i class="fas fa-fw fa-arrow-right"></i></a></li>
</ul>
</li>';
} else {
if ($num_notifications == '0')
$notificon = '<span class="far fa-fw fa-circle"></span>';
else
$notificon = $num_notifications.' <span class="fas fa-fw fa-circle"></span>';
$notification_menu_item = '<li><a href="notifications.php" class="'.(($num_notifications != 0)? ' flash' : '').'">'.$notificon.'<span class="visible-xs-inline"> '.__( 'Notifications', 'luna' ).'</span></a></li>';
}
}
// Generate navigation items
if (!$luna_user['is_admmod'])
$backstage = '';
else
$backstage = '<li><a href="backstage/"><span class="fas fa-fw fa-tachometer-alt"></span><span class="visible-xs-inline"> '.__( 'Backstage', 'luna' ).'</span></a></li>';
$result = $db->query('SELECT id, url, name, disp_position, visible FROM '.$db->prefix.'menu ORDER BY disp_position') or error('Unable to fetch menu items', __FILE__, __LINE__, $db->error());
if ($luna_user['is_guest'])
$usermenu = '<li id="navregister"'.((LUNA_ACTIVE_PAGE == 'register') ? ' class="active"' : '').'><a href="register.php">'.__( 'Register', 'luna' ).'</a></li>
<li><a href="#" data-toggle="modal" data-target="#login-form">'.__( 'Login', 'luna' ).'</a></li>';
else
$usermenu = $backstage.$inbox_menu_item.$notification_menu_item.'
<li class="dropdown">
<a href="#" class="dropdown-toggle avatar-item" data-toggle="dropdown"><i class="fas fa-fw fa-user"></i><span class="visible-xs-inline"> '.luna_htmlspecialchars($luna_user['username']).'</span> <i class="fas fa-fw fa-angle-down"></i></a>
<ul class="dropdown-menu">
<li><a href="profile.php?id='.$luna_user['id'].'"><i class="fas fa-fw fa-user"></i> '.__( 'Profile', 'luna' ).'</a></li>
<li><a href="settings.php"><i class="fas fa-fw fa-cogs"></i> '.__( 'Settings', 'luna' ).'</a></li>
<li class="divider"></li>
<li><a href="help.php"><i class="fas fa-fw fa-info-circle"></i> '.__( 'Help', 'luna' ).'</a></li>
<li class="divider"></li>
<li><a href="login.php?action=out&id='.$luna_user['id'].'&csrf_token='.luna_csrf_token().'"><i class="fas fa-fw fa-sign-out-alt"></i> '.__( 'Logout', 'luna' ).'</a></li>
</ul>
</li>
';
if ($db->num_rows($result) > 0)
while ($cur_item = $db->fetch_assoc($result))
if ($cur_item['visible'] == '1')
$links[] = '<li><a href="'.$cur_item['url'].'">'.$cur_item['name'].'</a></li>';