ManageBans.template.php 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355
  1. <?php
  2. /**
  3. * Simple Machines Forum (SMF)
  4. *
  5. * @package SMF
  6. * @author Simple Machines
  7. * @copyright 2012 Simple Machines
  8. * @license http://www.simplemachines.org/about/smf/license.php BSD
  9. *
  10. * @version 2.1 Alpha 1
  11. */
  12. function template_ban_edit()
  13. {
  14. global $context, $settings, $options, $scripturl, $txt, $modSettings;
  15. echo '
  16. <div id="manage_bans">
  17. <form id="admin_form_wrapper" action="', $scripturl, '?action=admin;area=ban;sa=edit" method="post" accept-charset="', $context['character_set'], '" onsubmit="if (this.ban_name.value == \'\') {alert(\'', $txt['ban_name_empty'], '\'); return false;} if (this.partial_ban.checked &amp;&amp; !(this.cannot_post.checked || this.cannot_register.checked || this.cannot_login.checked)) {alert(\'', $txt['ban_restriction_empty'], '\'); return false;}">
  18. <div class="cat_bar">
  19. <h3 class="catbg">
  20. ', $context['ban']['is_new'] ? $txt['ban_add_new'] : $txt['ban_edit'] . ' \'' . $context['ban']['name'] . '\'', '
  21. </h3>
  22. </div>';
  23. if ($context['ban']['is_new'])
  24. echo '
  25. <div class="information">', $txt['ban_add_notes'], '</div>';
  26. echo '
  27. <div class="content">
  28. <dl class="settings">
  29. <dt>
  30. <strong><label for="ban_name">', $txt['ban_name'], ':</label></strong>
  31. </dt>
  32. <dd>
  33. <input type="text" name="ban_name" id="ban_name" value="', $context['ban']['name'], '" size="47" maxlength="60" class="input_text" />
  34. </dd>
  35. <dt>
  36. <strong><label for="reason">', $txt['ban_reason'], ':</label></strong><br />
  37. <span class="smalltext">', $txt['ban_reason_desc'], '</span>
  38. </dt>
  39. <dd>
  40. <textarea name="reason" id="reason" cols="40" rows="3" style="min-height: 64px; max-height: 64px; min-width: 50%; max-width: 99%;">', $context['ban']['reason'], '</textarea>
  41. </dd>
  42. <dt>
  43. <strong><label for="ban_notes">', $txt['ban_notes'], ':</label></strong><br />
  44. <span class="smalltext">', $txt['ban_notes_desc'], '</span>
  45. </dt>
  46. <dd>
  47. <textarea name="notes" id="ban_notes" cols="40" rows="3" style="min-height: 64px; max-height: 64px; min-width: 50%; max-width: 99%;">', $context['ban']['notes'], '</textarea>
  48. </dd>
  49. </dl>
  50. <fieldset class="ban_settings floatleft">
  51. <legend>
  52. ', $txt['ban_expiration'], '
  53. </legend>
  54. <input type="radio" name="expiration" value="never" id="never_expires" onclick="fUpdateStatus();"', $context['ban']['expiration']['status'] == 'never' ? ' checked="checked"' : '', ' class="input_radio" /> <label for="never_expires">', $txt['never'], '</label><br />
  55. <input type="radio" name="expiration" value="one_day" id="expires_one_day" onclick="fUpdateStatus();"', $context['ban']['expiration']['status'] == 'still_active_but_we_re_counting_the_days' ? ' checked="checked"' : '', ' class="input_radio" /> <label for="expires_one_day">', $txt['ban_will_expire_within'], '</label>: <input type="text" name="expire_date" id="expire_date" size="3" value="', $context['ban']['expiration']['days'], '" class="input_text" /> ', $txt['ban_days'], '<br />
  56. <input type="radio" name="expiration" value="expired" id="already_expired" onclick="fUpdateStatus();"', $context['ban']['expiration']['status'] == 'expired' ? ' checked="checked"' : '', ' class="input_radio" /> <label for="already_expired">', $txt['ban_expired'], '</label>
  57. </fieldset>
  58. <fieldset class="ban_settings floatright">
  59. <legend>
  60. ', $txt['ban_restriction'], '
  61. </legend>
  62. <input type="radio" name="full_ban" id="full_ban" value="1" onclick="fUpdateStatus();"', $context['ban']['cannot']['access'] ? ' checked="checked"' : '', ' class="input_radio" /> <label for="full_ban">', $txt['ban_full_ban'], '</label><br />
  63. <input type="radio" name="full_ban" id="partial_ban" value="0" onclick="fUpdateStatus();"', !$context['ban']['cannot']['access'] ? ' checked="checked"' : '', ' class="input_radio" /> <label for="partial_ban">', $txt['ban_partial_ban'], '</label><br />
  64. <input type="checkbox" name="cannot_post" id="cannot_post" value="1"', $context['ban']['cannot']['post'] ? ' checked="checked"' : '', ' class="ban_restriction input_radio" /> <label for="cannot_post">', $txt['ban_cannot_post'], '</label> (<a href="', $scripturl, '?action=helpadmin;help=ban_cannot_post" onclick="return reqOverlayDiv(this.href);">?</a>)<br />
  65. <input type="checkbox" name="cannot_register" id="cannot_register" value="1"', $context['ban']['cannot']['register'] ? ' checked="checked"' : '', ' class="ban_restriction input_radio" /> <label for="cannot_register">', $txt['ban_cannot_register'], '</label><br />
  66. <input type="checkbox" name="cannot_login" id="cannot_login" value="1"', $context['ban']['cannot']['login'] ? ' checked="checked"' : '', ' class="ban_restriction input_radio" /> <label for="cannot_login">', $txt['ban_cannot_login'], '</label><br />
  67. </fieldset>
  68. <br class="clear_right" />';
  69. if (!empty($context['ban_suggestions']))
  70. {
  71. echo '
  72. <fieldset>
  73. <legend>
  74. ', $txt['ban_triggers'], '
  75. </legend>
  76. <dl class="settings">
  77. <dt>
  78. <input type="checkbox" name="ban_suggestion[]" id="main_ip_check" value="main_ip" class="input_check" />
  79. <label for="main_ip_check">', $txt['ban_on_ip'], '</label>
  80. </dt>
  81. <dd>
  82. <input type="text" name="main_ip" value="', $context['ban_suggestions']['main_ip'], '" size="44" onfocus="document.getElementById(\'main_ip_check\').checked = true;" class="input_text" />
  83. </dd>';
  84. if (empty($modSettings['disableHostnameLookup']))
  85. echo '
  86. <dt>
  87. <input type="checkbox" name="ban_suggestion[]" id="hostname_check" value="hostname" class="input_check" />
  88. <label for="hostname_check">', $txt['ban_on_hostname'], '</label>
  89. </dt>
  90. <dd>
  91. <input type="text" name="hostname" value="', $context['ban_suggestions']['hostname'], '" size="44" onfocus="document.getElementById(\'hostname_check\').checked = true;" class="input_text" />
  92. </dd>';
  93. echo '
  94. <dt>
  95. <input type="checkbox" name="ban_suggestion[]" id="email_check" value="email" class="input_check" checked="checked" />
  96. <label for="email_check">', $txt['ban_on_email'], '</label>
  97. </dt>
  98. <dd>
  99. <input type="text" name="email" value="', $context['ban_suggestions']['email'], '" size="44" onfocus="document.getElementById(\'email_check\').checked = true;" class="input_text" />
  100. </dd>
  101. <dt>
  102. <input type="checkbox" name="ban_suggestion[]" id="user_check" value="user" class="input_check" checked="checked" />
  103. <label for="user_check">', $txt['ban_on_username'], '</label>:
  104. </dt>
  105. <dd>';
  106. if (empty($context['ban_suggestions']['member']['id']))
  107. echo '
  108. <input type="text" name="user" id="user" value="" size="44" class="input_text" />';
  109. else
  110. echo '
  111. ', $context['ban_suggestions']['member']['link'], '
  112. <input type="hidden" name="bannedUser" value="', $context['ban_suggestions']['member']['id'], '" />';
  113. echo '
  114. </dd>';
  115. if (!empty($context['ban_suggestions']['message_ips']))
  116. {
  117. echo '
  118. </dl>
  119. <div>', $txt['ips_in_messages'], ':</div>
  120. <dl class="settings">';
  121. foreach ($context['ban_suggestions']['message_ips'] as $ip)
  122. echo '
  123. <dt>
  124. <input type="checkbox" name="ban_suggestion[ips][]" value="', $ip, '" class="input_check" />
  125. </dt>
  126. <dd>
  127. ', $ip, '
  128. </dd>';
  129. }
  130. if (!empty($context['ban_suggestions']['error_ips']))
  131. {
  132. echo '
  133. </dl>
  134. <div>', $txt['ips_in_errors'], '</div>
  135. <dl class="settings">';
  136. foreach ($context['ban_suggestions']['error_ips'] as $ip)
  137. echo '
  138. <dt>
  139. <input type="checkbox" name="ban_suggestion[ips][]" value="', $ip, '" class="input_check" />
  140. </dt>
  141. <dd>
  142. ', $ip, '
  143. </dd>';
  144. }
  145. echo '
  146. </dl>
  147. </fieldset>';
  148. }
  149. echo '
  150. <input type="submit" name="', $context['ban']['is_new'] ? 'add_ban' : 'modify_ban', '" value="', $context['ban']['is_new'] ? $txt['ban_add'] : $txt['ban_modify'], '" class="button_submit" />
  151. <input type="hidden" name="old_expire" value="', $context['ban']['expiration']['days'], '" />
  152. <input type="hidden" name="bg" value="', $context['ban']['id'], '" />
  153. <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '" />
  154. <input type="hidden" name="', $context['admin-bet_token_var'], '" value="', $context['admin-bet_token'], '" />
  155. </div>
  156. </form>';
  157. if (!$context['ban']['is_new'] && empty($context['ban_suggestions']))
  158. {
  159. echo '
  160. <br />
  161. <form action="', $scripturl, '?action=admin;area=ban;sa=edit" method="post" accept-charset="', $context['character_set'], '" style="padding: 0px;margin: 0px;" onsubmit="return confirm(\'', $txt['ban_remove_selected_triggers_confirm'], '\');">
  162. <table class="table_grid" width="100%">
  163. <thead>
  164. <tr class="catbg">
  165. <th scope="col" class="first_th" width="65%" align="left">', $txt['ban_banned_entity'], '</th>
  166. <th scope="col" width="15%" align="center">', $txt['ban_hits'], '</th>
  167. <th scope="col" width="15%" align="center">', $txt['ban_actions'], '</th>
  168. <th scope="col" class="last_th" width="5%" align="center"><input type="checkbox" onclick="invertAll(this, this.form, \'ban_items\');" class="input_check" /></th>
  169. </tr>
  170. </thead>
  171. <tbody>';
  172. if (empty($context['ban_items']))
  173. echo '
  174. <tr class="windowbg2">
  175. <td colspan="4">(', $txt['ban_no_triggers'], ')</td>
  176. </tr>';
  177. else
  178. {
  179. $alternate = true;
  180. foreach ($context['ban_items'] as $ban_item)
  181. {
  182. echo '
  183. <tr class="', $alternate ? 'windowbg' : 'windowbg2', '" align="left">
  184. <td>';
  185. if ($ban_item['type'] == 'ip')
  186. echo ' <strong>', $txt['ip'], ':</strong>&nbsp;', $ban_item['ip'];
  187. elseif ($ban_item['type'] == 'hostname')
  188. echo ' <strong>', $txt['hostname'], ':</strong>&nbsp;', $ban_item['hostname'];
  189. elseif ($ban_item['type'] == 'email')
  190. echo ' <strong>', $txt['email'], ':</strong>&nbsp;', $ban_item['email'];
  191. elseif ($ban_item['type'] == 'user')
  192. echo ' <strong>', $txt['username'], ':</strong>&nbsp;', $ban_item['user']['link'];
  193. echo '
  194. </td>
  195. <td align="center">', $ban_item['hits'], '</td>
  196. <td align="center"><a href="', $scripturl, '?action=admin;area=ban;sa=edittrigger;bg=', $context['ban']['id'], ';bi=', $ban_item['id'], '">', $txt['ban_edit_trigger'], '</a></td>
  197. <td align="center"><input type="checkbox" name="ban_items[]" value="', $ban_item['id'], '" class="input_check" /></td>
  198. </tr>';
  199. $alternate = !$alternate;
  200. }
  201. }
  202. echo '
  203. </tbody>
  204. </table>
  205. <div class="flow_auto">
  206. <br />
  207. <input type="submit" name="remove_selection" value="', $txt['ban_remove_selected_triggers'], '" class="button_submit" />
  208. <a class="button_link" href="', $scripturl, '?action=admin;area=ban;sa=edittrigger;bg=', $context['ban']['id'], '">', $txt['ban_add_trigger'], '</a>
  209. <input type="hidden" name="bg" value="', $context['ban']['id'], '" />
  210. <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '" />
  211. <input type="hidden" name="', $context['admin-bet_token_var'], '" value="', $context['admin-bet_token'], '" />
  212. </div>
  213. </form>';
  214. }
  215. echo '
  216. </div>
  217. <script type="text/javascript" src="', $settings['default_theme_url'], '/scripts/suggest.js?alp21"></script>
  218. <script type="text/javascript"><!-- // --><![CDATA[
  219. var fUpdateStatus = function ()
  220. {
  221. document.getElementById("expire_date").disabled = !document.getElementById("expires_one_day").checked;
  222. document.getElementById("cannot_post").disabled = document.getElementById("full_ban").checked;
  223. document.getElementById("cannot_register").disabled = document.getElementById("full_ban").checked;
  224. document.getElementById("cannot_login").disabled = document.getElementById("full_ban").checked;
  225. }
  226. addLoadEvent(fUpdateStatus);';
  227. // Auto suggest only needed for adding new bans, not editing
  228. if ($context['ban']['is_new'] && empty($_REQUEST['u']))
  229. echo '
  230. var oAddMemberSuggest = new smc_AutoSuggest({
  231. sSelf: \'oAddMemberSuggest\',
  232. sSessionId: smf_session_id,
  233. sSessionVar: smf_session_var,
  234. sSuggestId: \'user\',
  235. sControlId: \'user\',
  236. sSearchType: \'member\',
  237. sTextDeleteItem: \'', $txt['autosuggest_delete_item'], '\',
  238. bItemList: false
  239. });
  240. function onUpdateName(oAutoSuggest)
  241. {
  242. document.getElementById(\'user_check\').checked = true;
  243. return true;
  244. }
  245. oAddMemberSuggest.registerCallback(\'onBeforeUpdate\', \'onUpdateName\');';
  246. echo '// ]]></script>';
  247. }
  248. function template_ban_edit_trigger()
  249. {
  250. global $context, $settings, $options, $scripturl, $txt, $modSettings;
  251. echo '
  252. <div id="manage_bans">
  253. <form id="admin_form_wrapper" action="', $scripturl, '?action=admin;area=ban;sa=edit" method="post" accept-charset="', $context['character_set'], '">
  254. <div class="cat_bar">
  255. <h3 class="catbg">
  256. ', $context['ban_trigger']['is_new'] ? $txt['ban_add_trigger'] : $txt['ban_edit_trigger_title'], '
  257. </h3>
  258. </div>
  259. <div class="windowbg">
  260. <div class="content">
  261. <fieldset>
  262. <legend>
  263. ', $txt['ban_triggers'], '
  264. </legend>
  265. <dl class="settings">
  266. <dt>
  267. <input type="radio" name="bantype" value="ip_ban"', $context['ban_trigger']['ip']['selected'] ? ' checked="checked"' : '', ' class="input_radio" />
  268. ', $txt['ban_on_ip'], '
  269. </dt>
  270. <dd>
  271. <input type="text" name="ip" value="', $context['ban_trigger']['ip']['value'], '" size="50" onfocus="selectRadioByName(this.form.bantype, \'ip_ban\');" class="input_text" />
  272. </dd>';
  273. if (empty($modSettings['disableHostnameLookup']))
  274. echo '
  275. <dt>
  276. <input type="radio" name="bantype" value="hostname_ban"', $context['ban_trigger']['hostname']['selected'] ? ' checked="checked"' : '', ' class="input_radio" />
  277. ', $txt['ban_on_hostname'], '
  278. </dt>
  279. <dd>
  280. <input type="text" name="hostname" value="', $context['ban_trigger']['hostname']['value'], '" size="50" onfocus="selectRadioByName(this.form.bantype, \'hostname_ban\');" class="input_text" />
  281. </dd>';
  282. echo '
  283. <dt>
  284. <input type="radio" name="bantype" value="email_ban"', $context['ban_trigger']['email']['selected'] ? ' checked="checked"' : '', ' class="input_radio" />
  285. ', $txt['ban_on_email'], '
  286. </dt>
  287. <dd>
  288. <input type="text" name="email" value="', $context['ban_trigger']['email']['value'], '" size="50" onfocus="selectRadioByName(this.form.bantype, \'email_ban\');" class="input_text" />
  289. </dd>
  290. <dt>
  291. <input type="radio" name="bantype" value="user_ban"', $context['ban_trigger']['banneduser']['selected'] ? ' checked="checked"' : '', ' class="input_radio" />
  292. ', $txt['ban_on_username'], '
  293. </dt>
  294. <dd>
  295. <input type="text" name="user" id="user" value="', $context['ban_trigger']['banneduser']['value'], '" size="50" onfocus="selectRadioByName(this.form.bantype, \'user_ban\');" class="input_text" />
  296. </dd>
  297. </dl>
  298. </fieldset>
  299. <input type="submit" name="', $context['ban_trigger']['is_new'] ? 'add_new_trigger' : 'edit_trigger', '" value="', $context['ban_trigger']['is_new'] ? $txt['ban_add_trigger_submit'] : $txt['ban_edit_trigger_submit'], '" class="button_submit" />
  300. </div>
  301. </div>
  302. <input type="hidden" name="bi" value="' . $context['ban_trigger']['id'] . '" />
  303. <input type="hidden" name="bg" value="' . $context['ban_trigger']['group'] . '" />
  304. <input type="hidden" name="' . $context['session_var'] . '" value="' . $context['session_id'] . '" />
  305. <input type="hidden" name="', $context['admin-bet_token_var'], '" value="', $context['admin-bet_token'], '" />
  306. </form>
  307. </div>
  308. <script type="text/javascript" src="', $settings['default_theme_url'], '/scripts/suggest.js?alp21"></script>
  309. <script type="text/javascript"><!-- // --><![CDATA[
  310. var oAddMemberSuggest = new smc_AutoSuggest({
  311. sSelf: \'oAddMemberSuggest\',
  312. sSessionId: smf_session_id,
  313. sSessionVar: smf_session_var,
  314. sSuggestId: \'username\',
  315. sControlId: \'user\',
  316. sSearchType: \'member\',
  317. sTextDeleteItem: \'', $txt['autosuggest_delete_item'], '\',
  318. bItemList: false
  319. });
  320. function onUpdateName(oAutoSuggest)
  321. {
  322. selectRadioByName(oAutoSuggest.oTextHandle.form.bantype, \'user_ban\');
  323. return true;
  324. }
  325. oAddMemberSuggest.registerCallback(\'onBeforeUpdate\', \'onUpdateName\');
  326. // ]]></script>';
  327. }
  328. ?>