/
Errors.template.php
340 lines (296 loc) · 12.7 KB
/
Errors.template.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
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
<?php
/**
* Simple Machines Forum (SMF)
*
* @package SMF
* @author Simple Machines https://www.simplemachines.org
* @copyright 2020 Simple Machines and individual contributors
* @license https://www.simplemachines.org/about/smf/license.php BSD
*
* @version 2.1 RC3
*/
// @todo
/* This template file contains only the sub template fatal_error. It is
shown when an error occurs, and should show at least a back button and
$context['error_message'].
*/
/**
* THis displays a fatal error message
*/
function template_fatal_error()
{
global $context, $txt;
if (!empty($context['simple_action']))
echo '
<strong>
', $context['error_title'], '
</strong><br>
<div ', $context['error_code'], 'class="padding">
', $context['error_message'], '
</div>';
else
{
echo '
<div id="fatal_error">
<h4 class="sub_bar">
', $context['error_title'], '
</h4>
<div class="windowbg">
<div ', $context['error_code'], 'class="padding">
', $context['error_message'], '
</div>
</div>
</div>';
// Show a back button (using javascript.)
echo '
<div class="centertext">
<a class="button" href="javascript:document.location=document.referrer">', $txt['back'], '</a>
</div>';
}
}
/**
* This template handles the error log in the admin center.
*/
function template_error_log()
{
global $context, $settings, $scripturl, $txt;
echo '
<form action="', $scripturl, '?action=admin;area=logs;sa=errorlog', $context['sort_direction'] == 'down' ? ';desc' : '', ';start=', $context['start'], $context['has_filter'] ? $context['filter']['href'] : '', '" method="post" accept-charset="', $context['character_set'], '">
<h4 class="sub_bar">
<a href="', $scripturl, '?action=helpadmin;help=error_log" onclick="return reqOverlayDiv(this.href);" class="help"><span class="main_icons help" title="', $txt['help'], '"></span></a> ', $txt['errorlog'], '
</h4>
<div class="pagesection">
<div class="floatleft">
', $context['page_index'], '
</div>
<div class="floatright">
<input type="submit" name="removeSelection" value="', $txt['remove_selection'], '" data-confirm="', $txt['remove_selection_confirm'], '" class="button you_sure">
<input type="submit" name="delall" value="', ($context['has_filter'] ? $txt['remove_filtered_results'] : $txt['remove_all']), '" data-confirm="', ($context['has_filter'] ? $txt['remove_filtered_results_confirm'] : $txt['sure_about_errorlog_remove']), '" class="button you_sure">
</div>
</div>
<table class="table_grid" id="error_log">
<tr class="title_bar">
<td colspan="3">
', $txt['apply_filter_of_type'], ':';
$error_types = array();
foreach ($context['error_types'] as $type => $details)
$error_types[] = ($details['is_selected'] ? '<img src="' . $settings['images_url'] . '/selected.png" alt=""> ' : '') . '<a href="' . $details['url'] . '" ' . ($details['is_selected'] ? 'style="font-weight: bold;"' : '') . ' title="' . $details['description'] . '">' . ($details['error_type'] === 'critical' ? '<span class="error">' . $details['label'] . '</span>' : $details['label']) . '</a>';
echo '
', implode(' | ', $error_types), '
</td>
</tr>';
if ($context['has_filter'])
echo '
<tr>
<td colspan="3" class="windowbg">
<strong>', $txt['applying_filter'], ':</strong> ', $context['filter']['entity'], ' ', $context['filter']['value']['html'], ' [<a href="', $scripturl, '?action=admin;area=logs;sa=errorlog', $context['sort_direction'] == 'down' ? ';desc' : '', '">', $txt['clear_filter'], '</a>]
</td>
</tr>';
echo '
<tr>
<td colspan="3" class="righttext">
<label for="check_all1"><strong>', $txt['check_all'], '</strong></label>
<input type="checkbox" id="check_all1" onclick="invertAll(this, this.form, \'delete[]\'); this.form.check_all2.checked = this.checked;">
</td>
</tr>';
// No errors, then show a message
if (count($context['errors']) == 0)
echo '
<tr class="windowbg">
<td class="centertext" colspan="2">', $txt['errorlog_no_entries'], '</td>
</tr>';
// We have some errors, must be some mods installed :P
foreach ($context['errors'] as $error)
{
echo '
<tr class="windowbg">
<td colspan="2">
<div class="error_info word_break">
<a href="', $scripturl, '?action=admin;area=logs;sa=errorlog', $context['sort_direction'] == 'down' ? ';desc' : '', ';filter=id_member;value=', $error['member']['id'], '" title="', $txt['apply_filter'], ': ', $txt['filter_only_member'], '"><span class="main_icons filter centericon"></span></a>
<strong>', $error['member']['link'], '</strong><br>
<a href="', $scripturl, '?action=admin;area=logs;sa=errorlog', $context['sort_direction'] == 'down' ? '' : ';desc', $context['has_filter'] ? $context['filter']['href'] : '', '" title="', $txt['reverse_direction'], '"><span class="main_icons sort_' . $context['sort_direction'] . '"></span></a>
', $error['time'], '<br>';
if (!empty($error['member']['ip']))
echo '
<a href="', $scripturl, '?action=admin;area=logs;sa=errorlog', $context['sort_direction'] == 'down' ? ';desc' : '', ';filter=ip;value=', $error['member']['ip'], '" title="', $txt['apply_filter'], ': ', $txt['filter_only_ip'], '"><span class="main_icons filter centericon"></span></a>
<strong><a href="', $scripturl, '?action=trackip;searchip=', $error['member']['ip'], '">', $error['member']['ip'], '</a></strong>';
if ($error['member']['session'] != '')
echo '
<br>
<a href="', $scripturl, '?action=admin;area=logs;sa=errorlog', $context['sort_direction'] == 'down' ? ';desc' : '', ';filter=session;value=', $error['member']['session'], '" title="', $txt['apply_filter'], ': ', $txt['filter_only_session'], '"><span class="main_icons filter centericon"></span></a>
', $error['member']['session'], '<br>';
echo '
<strong><a href ="', $scripturl, '?action=admin;area=logs;sa=errorlog;backtrace=', $error['id'], '" onclick="return reqWin(this.href, 600, 480, false);"><span class="main_icons details"></span>', $txt['backtrace_title'], '</a></strong>
</div>
<div class="error_info word_break">';
echo '
<a href="', $scripturl, '?action=admin;area=logs;sa=errorlog', $context['sort_direction'] == 'down' ? ';desc' : '', ';filter=error_type;value=', $error['error_type']['type'], '" title="', $txt['apply_filter'], ': ', $txt['filter_only_type'], '"><span class="main_icons filter centericon"></span></a>
', $txt['error_type'], ': ', $error['error_type']['type'] === 'critical' ? '<span class="error">' . $error['error_type']['name'] . '</span>' : $error['error_type']['name'], '<br>
<a class="error_message" href="', $scripturl, '?action=admin;area=logs;sa=errorlog', $context['sort_direction'] == 'down' ? ';desc' : '', ';filter=message;value=', $error['message']['href'], '" title="', $txt['apply_filter'], ': ', $txt['filter_only_message'], '"><span class="main_icons filter"></span></a>
<span class="error_message">', $error['message']['html'], '</span>
<a href="', $scripturl, '?action=admin;area=logs;sa=errorlog', $context['sort_direction'] == 'down' ? ';desc' : '', ';filter=url;value=', $error['url']['href'], '" title="', $txt['apply_filter'], ': ', $txt['filter_only_url'], '"><span class="main_icons filter"></span></a>
<a href="', $error['url']['html'], '">', $error['url']['html'], '</a>';
if (!empty($error['file']))
echo '
<div>
<a href="', $scripturl, '?action=admin;area=logs;sa=errorlog', $context['sort_direction'] == 'down' ? ';desc' : '', ';filter=file;value=', $error['file']['search'], '" title="', $txt['apply_filter'], ': ', $txt['filter_only_file'], '">'
. ' <span class="main_icons filter"></span></a> ', $error['file']['link'], ' (', $txt['line'], ' ', $error['file']['line'], ')
</div>';
echo '
</div>
</td>
<td class="checkbox_column">
<input type="checkbox" name="delete[]" value="', $error['id'], '">
</td>
</tr>';
}
echo '
<tr>
<td colspan="3" class="righttext">
<label for="check_all2"><strong>', $txt['check_all'], '</strong></label>
<input type="checkbox" id="check_all2" onclick="invertAll(this, this.form, \'delete[]\'); this.form.check_all1.checked = this.checked;">
</td>
</tr>
</table>
<div class="pagesection">
<div class="floatleft">
', $context['page_index'], '
</div>
<div class="floatright">
<input type="submit" name="removeSelection" value="', $txt['remove_selection'], '" data-confirm="', $txt['remove_selection_confirm'], '" class="button you_sure">
<input type="submit" name="delall" value="', ($context['has_filter'] ? $txt['remove_filtered_results'] : $txt['remove_all']), '" data-confirm="', ($context['has_filter'] ? $txt['remove_filtered_results_confirm'] : $txt['sure_about_errorlog_remove']), '" class="button you_sure">
</div>
</div>';
if ($context['sort_direction'] == 'down')
echo '
<input type="hidden" name="desc" value="1">';
echo '
<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
<input type="hidden" name="', $context['admin-el_token_var'], '" value="', $context['admin-el_token'], '">
</form>';
}
/**
* This template shows a snippet of code from a file and highlights which line caused the error.
*/
function template_show_file()
{
global $context, $settings, $modSettings;
echo '<!DOCTYPE html>
<html', $context['right_to_left'] ? ' dir="rtl"' : '', '>
<head>
<meta charset="', $context['character_set'], '">
<title>', $context['file_data']['file'], '</title>
<link rel="stylesheet" href="', $settings['theme_url'], '/css/index', $context['theme_variant'], '.css', $context['browser_cache'], '">
</head>
<body>
<table class="errorfile_table">';
foreach ($context['file_data']['contents'] as $index => $line)
{
$line_num = $index + $context['file_data']['min'];
$is_target = $line_num == $context['file_data']['target'];
echo '
<tr>
<td class="file_line', $is_target ? ' current">==>' : '">', $line_num, ':</td>
<td ', $is_target ? 'class="current"' : '', '>', $line, '</td>
</tr>';
}
echo '
</table>
</body>
</html>';
}
/**
* This template handles showing attachment-related errors
*/
function template_attachment_errors()
{
global $context, $scripturl, $txt;
echo '
<div>
<h4 class="sub_bar">
', $context['error_title'], '
</h4>
<div class="windowbg">
<div class="padding">
<div class="noticebox">',
$context['error_message'], '
</div>';
if (!empty($context['back_link']))
echo '
<a class="button" href="', $scripturl, $context['back_link'], '">', $txt['back'], '</a>';
echo '
<span style="float: right; margin:.5em;"></span>
<a class="button" href="', $scripturl, $context['redirect_link'], '">', $txt['continue'], '</a>
</div>
</div>
</div>';
}
/**
* This template shows a backtrace of the given error
*/
function template_show_backtrace()
{
global $context, $settings, $modSettings, $txt, $scripturl;
echo '<!DOCTYPE html>
<html', $context['right_to_left'] ? ' dir="rtl"' : '', '>
<head>
<meta charset="', $context['character_set'], '">
<title>Backtrace</title>';
template_css();
echo '
</head>
<body class="padding">';
if (!empty($context['error_info']))
{
echo '
<h4 class="sub_bar">
', $txt['error'], '
</h4>
<div class="windowbg" id="backtrace">
<ul class="padding">';
if (!empty($context['error_info']['error_type']))
echo '
<li>', $txt['error_type'], ': ', ucfirst($context['error_info']['error_type']), '</li>';
if (!empty($context['error_info']['message']))
echo '
<li>', $txt['error_message'], ': <span class = "error_message">', $context['error_info']['message'], '</span></li>';
if (!empty($context['error_info']['file']))
echo '
<li>', $txt['error_file'], ': ', $context['error_info']['file'], '</li>';
if (!empty($context['error_info']['line']))
echo '
<li>', $txt['error_line'], ': ', $context['error_info']['line'], '</li>';
if (!empty($context['error_info']['url']))
echo '
<li>', $txt['error_url'], ': ', $context['error_info']['url'], '</li>';
echo '
</ul>
</div>';
}
if (!empty($context['error_info']['backtrace']))
{
echo '
<h4 class="sub_bar">
', $txt['backtrace_title'], '
</h4>
<div class="windowbg">
<ul class="padding">';
foreach ($context['error_info']['backtrace'] as $key => $value)
{
//Check for existing
if (!property_exists($value, 'file') || empty($value->file))
$value->file = $txt['unknown'];
if (!property_exists($value, 'line') || empty($value->line))
$value->line = -1;
echo '
<li class="backtrace">', sprintf($txt['backtrace_info'], $key, $value->function, $value->file, $value->line, base64_encode($value->file), $scripturl), '</li>';
}
echo '
</ul>
</div>';
}
echo '
</body>
</html>';
}
?>