Errors.template.php 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204
  1. <?php
  2. /**
  3. * Simple Machines Forum (SMF)
  4. *
  5. * @package SMF
  6. * @author Simple Machines
  7. * @copyright 2011 Simple Machines
  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, $settings, $options, $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">
  29. <span class="topslice"><span></span></span>
  30. <div class="padding">', $context['error_message'], '</div>
  31. <span class="botslice"><span></span></span>
  32. </div>
  33. </div>';
  34. // Show a back button (using javascript.)
  35. echo '
  36. <div class="centertext"><a href="javascript:history.go(-1)">', $txt['back'], '</a></div>';
  37. }
  38. function template_error_log()
  39. {
  40. global $context, $settings, $options, $scripturl, $txt, $modSettings;
  41. echo '
  42. <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'], '" onsubmit="if (lastClicked == \'remove_all\' &amp;&amp; !confirm(\'', $txt['sure_about_errorlog_remove'], '\')) return false; else return true;">
  43. <script type="text/javascript"><!-- // --><![CDATA[
  44. var lastClicked = "";
  45. // ]]></script>
  46. <div class="title_bar clear_right">
  47. <h3 class="titlebg">
  48. <span class="ie6_header floatleft">
  49. <a href="', $scripturl, '?action=helpadmin;help=error_log" onclick="return reqWin(this.href);" class="help"><img src="', $settings['images_url'], '/helptopics.gif" alt="', $txt['help'], '" align="top" /></a> ', $txt['errlog'], '
  50. </span>
  51. </h3>
  52. </div>
  53. <table border="0" cellspacing="1" class="table_grid" id="error_log">
  54. <tr>
  55. <td colspan="3" class="windowbg">
  56. &nbsp;&nbsp;', $txt['apply_filter_of_type'], ':';
  57. $error_types = array();
  58. foreach ($context['error_types'] as $type => $details)
  59. $error_types[] = ($details['is_selected'] ? '<img src="' . $settings['images_url'] . '/selected.gif" alt="" /> ' : '') . '<a href="' . $details['url'] . '" ' . ($details['is_selected'] ? 'style="font-weight: bold;"' : '') . ' title="' . $details['description'] . '">' . $details['label'] . '</a>';
  60. echo '
  61. ', implode('&nbsp;|&nbsp;', $error_types), '
  62. </td>
  63. </tr>
  64. <tr>
  65. <td colspan="3" class="windowbg">
  66. &nbsp;&nbsp;', $txt['pages'], ': ', $context['page_index'], '
  67. </td>
  68. </tr>';
  69. if ($context['has_filter'])
  70. echo '
  71. <tr>
  72. <td colspan="3" class="windowbg">
  73. <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>)
  74. </td>
  75. </tr>';
  76. if (!empty($context['errors']))
  77. echo '
  78. <tr class="titlebg">
  79. <td colspan="3" class="lefttext">
  80. <div class="floatright"><input type="submit" value="', $txt['remove_selection'], '" onclick="lastClicked = \'remove_selection\';" class="button_submit" /> <input type="submit" name="delall" value="', $context['has_filter'] ? $txt['remove_filtered_results'] : $txt['remove_all'], '" onclick="lastClicked = \'remove_all\';" class="button_submit" /></div>
  81. <label for="check_all1"><input type="checkbox" id="check_all1" onclick="invertAll(this, this.form, \'delete[]\'); this.form.check_all2.checked = this.checked;" class="input_check" /><strong>', $txt['check_all'], '</strong></label>
  82. </td>
  83. </tr>';
  84. foreach ($context['errors'] as $error)
  85. {
  86. echo '
  87. <tr class="windowbg', $error['alternate'] ? '2' : '', '">
  88. <td rowspan="2" class="checkbox_column">
  89. <input type="checkbox" name="delete[]" value="', $error['id'], '" class="input_check" />
  90. </td>
  91. <td class="half_width">
  92. <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'], '"><img src="', $settings['images_url'], '/filter.gif" alt="', $txt['apply_filter'], ': ', $txt['filter_only_member'], '" /></a>
  93. <strong>', $error['member']['link'], '</strong><br />
  94. <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'], '"><img src="', $settings['images_url'], '/filter.gif" alt="', $txt['apply_filter'], ': ', $txt['filter_only_ip'], '" /></a>
  95. <strong><a href="', $scripturl, '?action=trackip;searchip=', $error['member']['ip'], '">', $error['member']['ip'], '</a></strong>&nbsp;&nbsp;
  96. <br />&nbsp;
  97. </td>
  98. <td class="half_width">
  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'], '"><img src="', $settings['images_url'], '/sort_', $context['sort_direction'], '.gif" alt="', $txt['reverse_direction'], '" /></a>
  100. ', $error['time'], '
  101. <br />';
  102. if ($error['member']['session'] != '')
  103. echo '
  104. <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'], '"><img src="', $settings['images_url'], '/filter.gif" alt="', $txt['apply_filter'], ': ', $txt['filter_only_session'], '" /></a>
  105. ', $error['member']['session'], '
  106. <br />';
  107. echo '
  108. <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'], '"><img src="', $settings['images_url'], '/filter.gif" alt="', $txt['apply_filter'], ': ', $txt['filter_only_type'], '" /></a>
  109. ', $txt['error_type'], ': ', $error['error_type']['name'], '
  110. </td>
  111. </tr>
  112. <tr class="windowbg', $error['alternate'] ? '2' : '', '">
  113. <td colspan="2">
  114. <div class="clear_left floatleft"><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'], '"><img src="', $settings['images_url'], '/filter.gif" alt="', $txt['apply_filter'], ': ', $txt['filter_only_url'], '" /></a></div>
  115. <div class="floatleft marginleft"><a href="', $error['url']['html'], '">', $error['url']['html'], '</a></div>
  116. <div class="clear_left floatleft"><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'], '"><img src="', $settings['images_url'], '/filter.gif" alt="', $txt['apply_filter'], ': ', $txt['filter_only_message'], '" /></a></div>
  117. <div class="floatleft marginleft">', $error['message']['html'], '</div>';
  118. if (!empty($error['file']))
  119. echo '
  120. <div class="clear_left floatleft"><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'], '"><img src="', $settings['images_url'], '/filter.gif" alt="', $txt['apply_filter'], ': ', $txt['filter_only_file'], '" /></a></div>
  121. <div class="floatleft marginleft">
  122. ', $txt['file'], ': ', $error['file']['link'], '<br />
  123. ', $txt['line'], ': ', $error['file']['line'], '
  124. </div>';
  125. echo '
  126. </td>
  127. </tr>';
  128. }
  129. if (!empty($context['errors']))
  130. echo '
  131. <tr class="titlebg">
  132. <td colspan="3" class="lefttext">
  133. <div class="floatright"><input type="submit" value="', $txt['remove_selection'], '" onclick="lastClicked = \'remove_selection\';" class="button_submit" /> <input type="submit" name="delall" value="', $context['has_filter'] ? $txt['remove_filtered_results'] : $txt['remove_all'], '" onclick="lastClicked = \'remove_all\';" class="button_submit" /></div>
  134. &nbsp;<label for="check_all2"><input type="checkbox" id="check_all2" onclick="invertAll(this, this.form, \'delete[]\'); this.form.check_all1.checked = this.checked;" class="input_check" /><strong>', $txt['check_all'], '</strong></label>
  135. </td>
  136. </tr>';
  137. else
  138. echo '
  139. <tr>
  140. <td colspan="3" class="windowbg2">', $txt['errlog_no_entries'], '</td>
  141. </tr>';
  142. echo '
  143. <tr>
  144. <td colspan="3" class="windowbg">
  145. &nbsp;&nbsp;', $txt['pages'], ': ', $context['page_index'], '
  146. </td>
  147. </tr>
  148. </table><br />';
  149. if ($context['sort_direction'] == 'down')
  150. echo '
  151. <input type="hidden" name="desc" value="1" />';
  152. echo '
  153. <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '" />
  154. <input type="hidden" name="', $context['admin-el_token_var'], '" value="', $context['admin-el_token'], '" />
  155. </form>';
  156. }
  157. function template_show_file()
  158. {
  159. global $context, $settings;
  160. echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  161. <html xmlns="http://www.w3.org/1999/xhtml"', $context['right_to_left'] ? ' dir="rtl"' : '', '>
  162. <head>
  163. <title>', $context['file_data']['file'], '</title>
  164. <meta http-equiv="Content-Type" content="text/html; charset=', $context['character_set'], '" />
  165. <link rel="stylesheet" type="text/css" href="', $settings['theme_url'], '/css/index.css" />
  166. </head>
  167. <body>
  168. <table border="0" cellpadding="0" cellspacing="3">';
  169. foreach ($context['file_data']['contents'] as $index => $line)
  170. {
  171. $line_num = $index+$context['file_data']['min'];
  172. $is_target = $line_num == $context['file_data']['target'];
  173. echo '
  174. <tr>
  175. <td align="right"', $is_target ? ' style="font-weight: bold; border: 1px solid black;border-width: 1px 0 1px 1px;">==&gt;' : '>', $line_num , ':</td>
  176. <td style="white-space: nowrap;', $is_target ? ' border: 1px solid black;border-width: 1px 1px 1px 0;':'','">', $line, '</td>
  177. </tr>';
  178. }
  179. echo '
  180. </table>
  181. </body>
  182. </html>';
  183. }
  184. ?>