1 | <?php |
||
2 | /** |
||
3 | * Simple Machines Forum (SMF) |
||
4 | * |
||
5 | * @package SMF |
||
6 | * @author Simple Machines https://www.simplemachines.org |
||
7 | * @copyright 2022 Simple Machines and individual contributors |
||
8 | * @license https://www.simplemachines.org/about/smf/license.php BSD |
||
9 | * |
||
10 | * @version 2.1.3 |
||
11 | */ |
||
12 | |||
13 | // @todo |
||
14 | /* This template file contains only the sub template fatal_error. It is |
||
15 | shown when an error occurs, and should show at least a back button and |
||
16 | $context['error_message']. |
||
17 | */ |
||
18 | |||
19 | /** |
||
20 | * THis displays a fatal error message |
||
21 | */ |
||
22 | function template_fatal_error() |
||
23 | { |
||
24 | global $context, $txt; |
||
25 | |||
26 | if (!empty($context['simple_action'])) |
||
27 | echo ' |
||
28 | <strong> |
||
29 | ', $context['error_title'], ' |
||
30 | </strong><br> |
||
31 | <div ', $context['error_code'], 'class="padding"> |
||
32 | ', $context['error_message'], ' |
||
33 | </div>'; |
||
34 | else |
||
35 | { |
||
36 | echo ' |
||
37 | <div id="fatal_error"> |
||
38 | <div class="cat_bar"> |
||
39 | <h3 class="catbg"> |
||
40 | ', $context['error_title'], ' |
||
41 | </h3> |
||
42 | </div> |
||
43 | <div class="windowbg"> |
||
44 | <div ', $context['error_code'], 'class="padding"> |
||
45 | ', $context['error_message'], ' |
||
46 | </div> |
||
47 | </div> |
||
48 | </div>'; |
||
49 | |||
50 | // Show a back button |
||
51 | echo ' |
||
52 | <div class="centertext"> |
||
53 | <a class="button floatnone" href="', $context['error_link'], '">', $txt['back'], '</a> |
||
54 | </div>'; |
||
55 | } |
||
56 | } |
||
57 | |||
58 | /** |
||
59 | * This template handles the error log in the admin center. |
||
60 | */ |
||
61 | function template_error_log() |
||
62 | { |
||
63 | global $scripturl, $context, $txt; |
||
64 | |||
65 | echo ' |
||
66 | <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'], '"> |
||
67 | <div class="cat_bar"> |
||
68 | <h3 class="catbg"> |
||
69 | <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'], ' |
||
70 | </h3> |
||
71 | </div> |
||
72 | <div class="information flow_hidden"> |
||
73 | <div class="additional_row">'; |
||
74 | |||
75 | // No errors, so just show a message and be done with it. |
||
76 | if (empty($context['errors'])) |
||
77 | { |
||
78 | echo ' |
||
79 | ', $txt['errorlog_no_entries'], ' |
||
80 | </div> |
||
81 | </div> |
||
82 | </form>'; |
||
83 | return; |
||
84 | } |
||
85 | |||
86 | if ($context['has_filter']) |
||
87 | echo ' |
||
88 | <div class="infobox"> |
||
89 | <strong>', $txt['applying_filter'], ':</strong> ', $context['filter']['entity'], ' ', $context['filter']['value']['html'], ' |
||
90 | </div>'; |
||
91 | |||
92 | echo ' |
||
93 | <div class="floatright"> |
||
94 | <input type="submit" name="removeSelection" value="', $txt['remove_selection'], '" data-confirm="', $txt['remove_selection_confirm'], '" class="button you_sure"> |
||
95 | <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"> |
||
96 | ', ($context['has_filter'] ? '<a href="' . $scripturl . '?action=admin;area=logs;sa=errorlog' . ($context['sort_direction'] == 'down' ? ';desc' : '') . '" class="button">' . $txt['clear_filter'] . '</a>' : ''), ' |
||
97 | </div> |
||
98 | ', $txt['apply_filter_of_type'], ':'; |
||
99 | |||
100 | $error_types = array(); |
||
101 | |||
102 | foreach ($context['error_types'] as $type => $details) |
||
103 | $error_types[] = ($details['is_selected'] ? '<span class="main_icons right_arrow"></span> ' : '') . '<a href="' . $details['url'] . '" ' . ($details['is_selected'] ? 'style="font-weight: bold;"' : 'style="font-weight: normal;"') . ' title="' . $details['description'] . '">' . ($details['error_type'] === 'critical' ? '<span class="error">' . $details['label'] . '</span>' : $details['label']) . '</a>'; |
||
104 | |||
105 | echo ' |
||
106 | ', implode(' | ', $error_types), ' |
||
107 | </div> |
||
108 | </div> |
||
109 | <div class="pagesection"> |
||
110 | <div class="pagelinks"> |
||
111 | ', $context['page_index'], ' |
||
112 | </div> |
||
113 | <div class="floatright" style="padding: 0 12px"> |
||
114 | <label for="check_all"><strong>', $txt['check_all'], '</strong></label> |
||
115 | <input type="checkbox" id="check_all" onclick="invertAll(this, this.form, \'delete[]\');"> |
||
116 | </div> |
||
117 | </div>'; |
||
118 | |||
119 | // We have some errors, must be some mods installed :P |
||
120 | foreach ($context['errors'] as $error) |
||
121 | { |
||
122 | echo ' |
||
123 | <div class="windowbg word_break"> |
||
124 | <div class="counter" style="padding: 0 10px 10px 0">', $error['id'], '</div> |
||
125 | <div class="topic_details"> |
||
126 | <span class="floatright"> |
||
127 | <input type="checkbox" name="delete[]" value="', $error['id'], '"> |
||
128 | </span> |
||
129 | <h5> |
||
130 | <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'], ' |
||
131 | </h5> |
||
132 | <hr class="clear"> |
||
133 | </div> |
||
134 | <div> |
||
135 | <div class="half_content"> |
||
136 | <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"></span></a> |
||
137 | <strong>', $error['member']['link'], '</strong>'; |
||
138 | |||
139 | if (!empty($error['member']['ip'])) |
||
140 | echo ' |
||
141 | <br> |
||
142 | <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"></span></a> |
||
143 | <strong><a href="', $scripturl, '?action=trackip;searchip=', $error['member']['ip'], '">', $error['member']['ip'], '</a></strong>'; |
||
144 | |||
145 | if (!empty($error['member']['session'])) |
||
146 | echo ' |
||
147 | <br> |
||
148 | <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"></span></a> <a class="bbc_link" 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'], '">', $error['member']['session'], '</a>'; |
||
149 | |||
150 | echo ' |
||
151 | <br> |
||
152 | <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> |
||
153 | <a href="', $error['url']['html'], '" class="bbc_link word_break">', $error['url']['html'], '</a>'; |
||
154 | |||
155 | if (!empty($error['file'])) |
||
156 | echo ' |
||
157 | <br> |
||
158 | <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> <a class="bbc_link" href="', $error['file']['href'], '" onclick="return reqWin(this.href, 600, 480, false);">', $error['file']['file'], '</a> (', $txt['line'], ' ', $error['file']['line'], ')'; |
||
159 | |||
160 | echo ' |
||
161 | </div> |
||
162 | <div class="half_content"> |
||
163 | <strong class="floatright"> |
||
164 | <span class="main_icons details"></span> <a class="bbc_link" href="', $scripturl, '?action=admin;area=logs;sa=errorlog;backtrace=', $error['id'], '" onclick="return reqWin(this.href, 600, 480, false);">', $txt['backtrace_title'], '</a> |
||
165 | </strong> |
||
166 | </div> |
||
167 | </div> |
||
168 | <div class="post"> |
||
169 | <br class="clear"> |
||
170 | <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"></span></a>', $txt['error_type'], ': ', $error['error_type']['type'] === 'critical' ? '<span class="error">' . $error['error_type']['name'] . '</span>' : $error['error_type']['name'], '<br> |
||
171 | <a 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 floatleft"></span></a> |
||
172 | <div class="codeheader"><span class="code floatleft">' . $txt['error_message'] . '</span> <a class="codeoperation smf_select_text">' . $txt['code_select'] . '</a> <a class="codeoperation smf_expand_code hidden" data-shrink-txt="' . $txt['code_shrink'] . '" data-expand-txt="' . $txt['code_expand'] . '">' . $txt['code_expand'] . '</a> |
||
173 | </div><code class="bbc_code" style="white-space: pre-line; overflow-y: auto">', $error['message']['html'], '</code> |
||
174 | </div> |
||
175 | </div>'; |
||
176 | } |
||
177 | |||
178 | echo ' |
||
179 | <div class="pagesection"> |
||
180 | <div class="pagelinks"> |
||
181 | ', $context['page_index'], ' |
||
182 | </div> |
||
183 | <div class="floatright"> |
||
184 | <input type="submit" name="removeSelection" value="', $txt['remove_selection'], '" data-confirm="', $txt['remove_selection_confirm'], '" class="button you_sure"> |
||
185 | <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"> |
||
186 | </div> |
||
187 | </div>'; |
||
188 | |||
189 | if ($context['sort_direction'] == 'down') |
||
190 | echo ' |
||
191 | <input type="hidden" name="desc" value="1">'; |
||
192 | |||
193 | echo ' |
||
194 | <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '"> |
||
195 | <input type="hidden" name="', $context['admin-el_token_var'], '" value="', $context['admin-el_token'], '"> |
||
196 | </form>'; |
||
197 | } |
||
198 | |||
199 | /** |
||
200 | * This template shows a snippet of code from a file and highlights which line caused the error. |
||
201 | */ |
||
202 | function template_show_file() |
||
203 | { |
||
204 | global $context, $settings, $modSettings; |
||
205 | |||
206 | echo '<!DOCTYPE html> |
||
207 | <html', $context['right_to_left'] ? ' dir="rtl"' : '', '> |
||
208 | <head> |
||
209 | <meta charset="', $context['character_set'], '"> |
||
210 | <title>', $context['file_data']['file'], '</title> |
||
211 | ', template_css(), ' |
||
0 ignored issues
–
show
|
|||
212 | </head> |
||
213 | <body> |
||
214 | <table class="errorfile_table">'; |
||
215 | foreach ($context['file_data']['contents'] as $index => $line) |
||
216 | { |
||
217 | $line_num = $index + $context['file_data']['min']; |
||
218 | $is_target = $line_num == $context['file_data']['target']; |
||
219 | |||
220 | echo ' |
||
221 | <tr> |
||
222 | <td class="file_line', $is_target ? ' current">==>' : '">', $line_num, ':</td> |
||
223 | <td ', $is_target ? 'class="current"' : '', '>', $line, '</td> |
||
224 | </tr>'; |
||
225 | } |
||
226 | echo ' |
||
227 | </table> |
||
228 | </body> |
||
229 | </html>'; |
||
230 | } |
||
231 | |||
232 | /** |
||
233 | * This template handles showing attachment-related errors |
||
234 | */ |
||
235 | function template_attachment_errors() |
||
236 | { |
||
237 | global $context, $scripturl, $txt; |
||
238 | |||
239 | echo ' |
||
240 | <div> |
||
241 | <div class="cat_bar"> |
||
242 | <h3 class="catbg"> |
||
243 | ', $context['error_title'], ' |
||
244 | </h3> |
||
245 | </div> |
||
246 | <div class="windowbg"> |
||
247 | <div class="padding"> |
||
248 | <div class="noticebox">', |
||
249 | $context['error_message'], ' |
||
250 | </div>'; |
||
251 | |||
252 | if (!empty($context['back_link'])) |
||
253 | echo ' |
||
254 | <a class="button" href="', $scripturl, $context['back_link'], '">', $txt['back'], '</a>'; |
||
255 | |||
256 | echo ' |
||
257 | <span style="float: right; margin:.5em;"></span> |
||
258 | <a class="button" href="', $scripturl, $context['redirect_link'], '">', $txt['continue'], '</a> |
||
259 | </div> |
||
260 | </div> |
||
261 | </div>'; |
||
262 | } |
||
263 | |||
264 | /** |
||
265 | * This template shows a backtrace of the given error |
||
266 | */ |
||
267 | function template_show_backtrace() |
||
268 | { |
||
269 | global $context, $settings, $modSettings, $txt, $scripturl; |
||
270 | |||
271 | echo '<!DOCTYPE html> |
||
272 | <html', $context['right_to_left'] ? ' dir="rtl"' : '', '> |
||
273 | <head> |
||
274 | <meta charset="', $context['character_set'], '"> |
||
275 | <title>', $txt['backtrace_title'], '</title>'; |
||
276 | |||
277 | template_css(); |
||
278 | |||
279 | echo ' |
||
280 | </head> |
||
281 | <body class="padding">'; |
||
282 | |||
283 | if (!empty($context['error_info'])) |
||
284 | { |
||
285 | echo ' |
||
286 | <div class="cat_bar"> |
||
287 | <h3 class="catbg"> |
||
288 | ', $txt['error'], ' |
||
289 | </h3> |
||
290 | </div> |
||
291 | <div class="windowbg" id="backtrace"> |
||
292 | <table class="table_grid"> |
||
293 | <tbody>'; |
||
294 | |||
295 | if (!empty($context['error_info']['error_type'])) |
||
296 | echo ' |
||
297 | <tr class="title_bar"> |
||
298 | <td><strong>', $txt['error_type'], '</strong></td> |
||
299 | </tr> |
||
300 | <tr class="windowbg"> |
||
301 | <td>', ucfirst($context['error_info']['error_type']), '</td> |
||
302 | </tr>'; |
||
303 | |||
304 | if (!empty($context['error_info']['message'])) |
||
305 | echo ' |
||
306 | <tr class="title_bar"> |
||
307 | <td><strong>', $txt['error_message'], '</strong></td> |
||
308 | </tr> |
||
309 | <tr class="windowbg lefttext"> |
||
310 | <td><code class="bbc_code" style="white-space: pre-line; overflow-y: auto">', $context['error_info']['message'], '</code></td> |
||
311 | </tr>'; |
||
312 | |||
313 | if (!empty($context['error_info']['file'])) |
||
314 | echo ' |
||
315 | <tr class="title_bar"> |
||
316 | <td><strong>', $txt['error_file'], '</strong></td> |
||
317 | </tr> |
||
318 | <tr class="windowbg"> |
||
319 | <td>', $context['error_info']['file'], '</td> |
||
320 | </tr>'; |
||
321 | |||
322 | if (!empty($context['error_info']['line'])) |
||
323 | echo ' |
||
324 | <tr class="title_bar"> |
||
325 | <td><strong>', $txt['error_line'], '</strong></td> |
||
326 | </tr> |
||
327 | <tr class="windowbg"> |
||
328 | <td>', $context['error_info']['line'], '</td> |
||
329 | </tr>'; |
||
330 | |||
331 | if (!empty($context['error_info']['url'])) |
||
332 | echo ' |
||
333 | <tr class="title_bar"> |
||
334 | <td><strong>', $txt['error_url'], '</strong></td> |
||
335 | </tr> |
||
336 | <tr class="windowbg word_break"> |
||
337 | <td>', $context['error_info']['url'], '</td> |
||
338 | </tr>'; |
||
339 | |||
340 | echo ' |
||
341 | </tbody> |
||
342 | </table> |
||
343 | </div>'; |
||
344 | } |
||
345 | |||
346 | if (!empty($context['error_info']['backtrace'])) |
||
347 | { |
||
348 | echo ' |
||
349 | <div class="cat_bar"> |
||
350 | <h3 class="catbg"> |
||
351 | ', $txt['backtrace_title'], ' |
||
352 | </h3> |
||
353 | </div> |
||
354 | <div class="windowbg"> |
||
355 | <ul class="padding">'; |
||
356 | |||
357 | foreach ($context['error_info']['backtrace'] as $key => $value) |
||
358 | { |
||
359 | //Check for existing |
||
360 | if (!property_exists($value, 'file') || empty($value->file)) |
||
361 | $value->file = $txt['unknown']; |
||
362 | |||
363 | if (!property_exists($value, 'line') || empty($value->line)) |
||
364 | $value->line = -1; |
||
365 | |||
366 | echo ' |
||
367 | <li class="backtrace">', sprintf($txt['backtrace_info'], $key, $value->function, $value->file, $value->line, base64_encode($value->file), $scripturl), '</li>'; |
||
368 | } |
||
369 | |||
370 | echo ' |
||
371 | </ul> |
||
372 | </div>'; |
||
373 | } |
||
374 | |||
375 | echo ' |
||
376 | </body> |
||
377 | </html>'; |
||
378 | } |
||
379 | |||
380 | ?> |
This check looks for function or method calls that always return null and whose return value is used.
The method
getObject()
can return nothing but null, so it makes no sense to use the return value.The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.