Errors.template.php 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246
  1. <?php
  2. /**
  3. * Simple Machines Forum (SMF)
  4. *
  5. * @package SMF
  6. * @author Simple Machines http://www.simplemachines.org
  7. * @copyright 2014 Simple Machines and individual contributors
  8. * @license http://www.simplemachines.org/about/smf/license.php BSD
  9. *
  10. * @version 2.1 Alpha 1
  11. */
  12. // @todo
  13. /* This template file contains only the sub template fatal_error. It is
  14. shown when an error occurs, and should show at least a back button and
  15. $context['error_message'].
  16. */
  17. // Show an error message.....
  18. function template_fatal_error()
  19. {
  20. global $context, $txt;
  21. echo '
  22. <div id="fatal_error">
  23. <div class="cat_bar">
  24. <h3 class="catbg">
  25. ', $context['error_title'], '
  26. </h3>
  27. </div>
  28. <div class="windowbg generic_list_wrapper">
  29. <div ', $context['error_code'], 'class="padding">', $context['error_message'], '</div>
  30. </div>
  31. </div>
  32. <br class="clear">';
  33. // Show a back button (using javascript.)
  34. echo '
  35. <div class="centertext">
  36. <a class="button_link" style="float:none" href="javascript:document.location=document.referrer">', $txt['back'], '</a>
  37. </div>';
  38. }
  39. function template_error_log()
  40. {
  41. global $context, $settings, $scripturl, $txt, $modSettings;
  42. echo '
  43. <form class="generic_list_wrapper" 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'], '">';
  44. echo '
  45. <div class="cat_bar clear_right">
  46. <h3 class="catbg">
  47. <a href="', $scripturl, '?action=helpadmin;help=error_log" onclick="return reqOverlayDiv(this.href);" class="help"><img src="', $settings['images_url'], '/helptopics.png" class="icon" alt="', $txt['help'], '"></a> ', $txt['errlog'], '
  48. </h3>
  49. </div>
  50. <div class="pagesection">
  51. <div class="floatleft">
  52. ', $context['page_index'], '
  53. </div>
  54. <div class="floatright" style="margin-top: 1ex">
  55. <input type="submit" name="removeSelection" value="' . $txt['remove_selection'] . '" onclick="return confirm(\'' . $txt['remove_selection_confirm'] . '\');" class="button_submit">
  56. <input type="submit" name="delall" value="', $context['has_filter'] ? $txt['remove_filtered_results'] : $txt['remove_all'], '" onclick="return confirm(\'', $context['has_filter'] ? $txt['remove_filtered_results_confirm'] : $txt['sure_about_errorlog_remove'], '\');" class="button_submit">
  57. </div>
  58. </div>
  59. <table border="0" cellspacing="1" class="table_grid" id="error_log">
  60. <tr>
  61. <td colspan="3" class="windowbg">
  62. &nbsp;&nbsp;', $txt['apply_filter_of_type'], ':';
  63. $error_types = array();
  64. foreach ($context['error_types'] as $type => $details)
  65. $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['label'] . '</a>';
  66. echo '
  67. ', implode('&nbsp;|&nbsp;', $error_types), '
  68. </td>
  69. </tr>';
  70. if ($context['has_filter'])
  71. echo '
  72. <tr>
  73. <td colspan="3" class="windowbg">
  74. <strong>&nbsp;&nbsp;', $txt['applying_filter'], ':</strong> ', $context['filter']['entity'], ' ', $context['filter']['value']['html'], '&nbsp;&nbsp;[<a href="', $scripturl, '?action=admin;area=logs;sa=errorlog', $context['sort_direction'] == 'down' ? ';desc' : '', '">', $txt['clear_filter'], '</a>]
  75. </td>
  76. </tr>';
  77. echo '
  78. <tr class="titlebg">
  79. <td colspan="3" class="righttext" style="padding: 4px 8px;">
  80. <label for="check_all1"><strong>', $txt['check_all'], '</strong></label>&nbsp;
  81. <input type="checkbox" id="check_all1" onclick="invertAll(this, this.form, \'delete[]\'); this.form.check_all2.checked = this.checked;" class="input_check">
  82. </td>
  83. </tr>';
  84. // No errors, then show a message
  85. if (count($context['errors']) == 0)
  86. echo '
  87. <tr class="windowbg">
  88. <td class="centertext" colspan="2">', $txt['errlog_no_entries'], '</td>
  89. </tr>';
  90. // we have some errors, must be some mods installed :P
  91. foreach ($context['errors'] as $error)
  92. {
  93. echo '
  94. <tr class="windowbg', $error['alternate'] ? '2' : '', '">
  95. <td>
  96. <div style="float: left; width: 50%; line-height: 1.8em; padding: 0 4px 4px 4px; vertical-align: bottom;">
  97. <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="generic_icons filter centericon"></span></a>
  98. <strong>', $error['member']['link'], '</strong><br>
  99. <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="sort sort_' . $context['sort_direction'] . '">', $txt['reverse_direction'], '</span></a>
  100. ', $error['time'], '<br>';
  101. if (!empty($error['member']['ip']))
  102. echo '
  103. <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="generic_icons filter centericon"></span></a>
  104. <strong><a href="', $scripturl, '?action=trackip;searchip=', $error['member']['ip'], '">', $error['member']['ip'], '</a></strong>&nbsp;&nbsp;<br>';
  105. echo '
  106. </div>
  107. <div style="float: left; width: 50%; line-height: 1.8em; padding: 0 4px;">';
  108. if ($error['member']['session'] != '')
  109. echo '
  110. <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="generic_icons filter centericon"></span></a>
  111. ', $error['member']['session'], '<br>';
  112. echo '
  113. <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="generic_icons filter centericon"></span></a>
  114. ', $txt['error_type'], ': ', $error['error_type']['name'], '<br>
  115. <a style="display: table-cell; padding: 4px 0; width: 20px; vertical-align: top;" 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="generic_icons filter"></span></a>
  116. <span style="display: table-cell;">', $error['message']['html'], '</span>
  117. </div>
  118. <div style="float: left; width: 100%; padding: 4px 0; line-height: 1.6em; border-top: 1px solid #e3e3e3;">
  119. <a style="display: table-cell; padding: 4px; width: 20px; vertical-align: top;" 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="generic_icons filter"></span></a>
  120. <a style="display: table-cell;" href="', $error['url']['html'], '">', $error['url']['html'], '</a>
  121. </div>';
  122. if (!empty($error['file']))
  123. echo '
  124. <div style="float: left; width: 100%; padding: 4px 0; line-height: 1.6em; border-top: 1px solid #e3e3e3;">
  125. <a style="display: table-cell; padding: 4px; width: 20px; vertical-align: top;" 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="generic_icons filter"></span></a>
  126. <div style="display: table-cell;">
  127. ', $txt['file'], ': ', $error['file']['link'], '<br>
  128. ', $txt['line'], ': ', $error['file']['line'], '
  129. </div>
  130. </div>';
  131. echo '
  132. </td>
  133. <td class="checkbox_column">
  134. <input type="checkbox" name="delete[]" value="', $error['id'], '" class="input_check">
  135. </td>
  136. </tr>';
  137. }
  138. echo '
  139. <tr class="titlebg">
  140. <td colspan="3" class="righttext" style="padding-right: 1.2ex">
  141. <label for="check_all2"><strong>', $txt['check_all'], '</strong></label>&nbsp;
  142. <input type="checkbox" id="check_all2" onclick="invertAll(this, this.form, \'delete[]\'); this.form.check_all1.checked = this.checked;" class="input_check">
  143. </td>
  144. </tr>
  145. </table>
  146. <div class="pagesection floatleft">
  147. &nbsp;&nbsp;', $context['page_index'], '
  148. </div>';
  149. echo '
  150. <div class="floatright" style="margin-top: 1ex">
  151. <input type="submit" name="removeSelection" value="' . $txt['remove_selection'] . '" onclick="return confirm(\'' . $txt['remove_selection_confirm'] . '\');" class="button_submit">
  152. <input type="submit" name="delall" value="', $context['has_filter'] ? $txt['remove_filtered_results'] : $txt['remove_all'], '" onclick="return confirm(\'', $context['has_filter'] ? $txt['remove_filtered_results_confirm'] : $txt['sure_about_errorlog_remove'], '\');" class="button_submit">
  153. </div>
  154. <br>';
  155. if ($context['sort_direction'] == 'down')
  156. echo '
  157. <input type="hidden" name="desc" value="1">';
  158. echo '
  159. <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">';
  160. echo '
  161. <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
  162. <input type="hidden" name="', $context['admin-el_token_var'], '" value="', $context['admin-el_token'], '">
  163. </form>';
  164. }
  165. function template_show_file()
  166. {
  167. global $context, $settings;
  168. echo '<!DOCTYPE html>
  169. <html', $context['right_to_left'] ? ' dir="rtl"' : '', '>
  170. <head>
  171. <title>', $context['file_data']['file'], '</title>
  172. <meta http-equiv="Content-Type" content="text/html; charset=', $context['character_set'], '">
  173. <link rel="stylesheet" type="text/css" href="', $settings['theme_url'], '/css/index', $context['theme_variant'], '.css?alp21">
  174. </head>
  175. <body>
  176. <table class="errorfile_table">';
  177. foreach ($context['file_data']['contents'] as $index => $line)
  178. {
  179. $line_num = $index + $context['file_data']['min'];
  180. $is_target = $line_num == $context['file_data']['target'];
  181. echo '
  182. <tr>
  183. <td align="right"', $is_target ? ' class="current">==&gt;' : '>', $line_num , ':</td>
  184. <td style="white-space: nowrap;', $is_target ? ' border: 1px solid black;border-width: 1px 1px 1px 0;':'','">', $line, '</td>
  185. </tr>';
  186. }
  187. echo '
  188. </table>
  189. </body>
  190. </html>';
  191. }
  192. function template_attachment_errors()
  193. {
  194. global $context, $scripturl, $txt;
  195. echo '
  196. <div>
  197. <div class="cat_bar">
  198. <h3 class="catbg">
  199. ', $context['error_title'], '
  200. </h3>
  201. </div>
  202. <div class="windowbg">
  203. <div class="padding">
  204. <div class="noticebox">',
  205. $context['error_message'], '
  206. </div>',
  207. !empty($context['back_link']) ? ('<a class="button_link" href="' . $scripturl . $context['back_link'] . '">' . $txt['back'] . '</a>') : '',
  208. '<span style="float: right; margin:.5em;"></span>
  209. <a class="button_link" href="', $scripturl, $context['redirect_link'], '">', $txt['continue'], '</a>
  210. </div>
  211. </div>
  212. </div>';
  213. }
  214. ?>