ManageBans.template.php 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357
  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. <hr class="hrcolor" />
  151. <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" />
  152. <input type="hidden" name="old_expire" value="', $context['ban']['expiration']['days'], '" />
  153. <input type="hidden" name="bg" value="', $context['ban']['id'], '" />
  154. <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '" />
  155. <input type="hidden" name="', $context['admin-bet_token_var'], '" value="', $context['admin-bet_token'], '" />
  156. </div>
  157. </form>';
  158. if (!$context['ban']['is_new'] && empty($context['ban_suggestions']))
  159. {
  160. echo '
  161. <br />
  162. <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'], '\');">
  163. <table class="table_grid" width="100%">
  164. <thead>
  165. <tr class="catbg">
  166. <th scope="col" class="first_th" width="65%" align="left">', $txt['ban_banned_entity'], '</th>
  167. <th scope="col" width="15%" align="center">', $txt['ban_hits'], '</th>
  168. <th scope="col" width="15%" align="center">', $txt['ban_actions'], '</th>
  169. <th scope="col" class="last_th" width="5%" align="center"><input type="checkbox" onclick="invertAll(this, this.form, \'ban_items\');" class="input_check" /></th>
  170. </tr>
  171. </thead>
  172. <tbody>';
  173. if (empty($context['ban_items']))
  174. echo '
  175. <tr class="windowbg2">
  176. <td colspan="4">(', $txt['ban_no_triggers'], ')</td>
  177. </tr>';
  178. else
  179. {
  180. $alternate = true;
  181. foreach ($context['ban_items'] as $ban_item)
  182. {
  183. echo '
  184. <tr class="', $alternate ? 'windowbg' : 'windowbg2', '" align="left">
  185. <td>';
  186. if ($ban_item['type'] == 'ip')
  187. echo ' <strong>', $txt['ip'], ':</strong>&nbsp;', $ban_item['ip'];
  188. elseif ($ban_item['type'] == 'hostname')
  189. echo ' <strong>', $txt['hostname'], ':</strong>&nbsp;', $ban_item['hostname'];
  190. elseif ($ban_item['type'] == 'email')
  191. echo ' <strong>', $txt['email'], ':</strong>&nbsp;', $ban_item['email'];
  192. elseif ($ban_item['type'] == 'user')
  193. echo ' <strong>', $txt['username'], ':</strong>&nbsp;', $ban_item['user']['link'];
  194. echo '
  195. </td>
  196. <td align="center">', $ban_item['hits'], '</td>
  197. <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>
  198. <td align="center"><input type="checkbox" name="ban_items[]" value="', $ban_item['id'], '" class="input_check" /></td>
  199. </tr>';
  200. $alternate = !$alternate;
  201. }
  202. }
  203. echo '
  204. </tbody>
  205. </table>
  206. <div class="flow_auto">
  207. <br />
  208. <input type="submit" name="remove_selection" value="', $txt['ban_remove_selected_triggers'], '" class="button_submit" />
  209. <a class="button_link" href="', $scripturl, '?action=admin;area=ban;sa=edittrigger;bg=', $context['ban']['id'], '">', $txt['ban_add_trigger'], '</a>
  210. <input type="hidden" name="bg" value="', $context['ban']['id'], '" />
  211. <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '" />
  212. <input type="hidden" name="', $context['admin-bet_token_var'], '" value="', $context['admin-bet_token'], '" />
  213. </div>
  214. </form>';
  215. }
  216. echo '
  217. </div>
  218. <script type="text/javascript" src="', $settings['default_theme_url'], '/scripts/suggest.js?alp21"></script>
  219. <script type="text/javascript"><!-- // --><![CDATA[
  220. var fUpdateStatus = function ()
  221. {
  222. document.getElementById("expire_date").disabled = !document.getElementById("expires_one_day").checked;
  223. document.getElementById("cannot_post").disabled = document.getElementById("full_ban").checked;
  224. document.getElementById("cannot_register").disabled = document.getElementById("full_ban").checked;
  225. document.getElementById("cannot_login").disabled = document.getElementById("full_ban").checked;
  226. }
  227. addLoadEvent(fUpdateStatus);';
  228. // Auto suggest only needed for adding new bans, not editing
  229. if ($context['ban']['is_new'] && empty($_REQUEST['u']))
  230. echo '
  231. var oAddMemberSuggest = new smc_AutoSuggest({
  232. sSelf: \'oAddMemberSuggest\',
  233. sSessionId: smf_session_id,
  234. sSessionVar: smf_session_var,
  235. sSuggestId: \'user\',
  236. sControlId: \'user\',
  237. sSearchType: \'member\',
  238. sTextDeleteItem: \'', $txt['autosuggest_delete_item'], '\',
  239. bItemList: false
  240. });
  241. function onUpdateName(oAutoSuggest)
  242. {
  243. document.getElementById(\'user_check\').checked = true;
  244. return true;
  245. }
  246. oAddMemberSuggest.registerCallback(\'onBeforeUpdate\', \'onUpdateName\');';
  247. echo '// ]]></script>';
  248. }
  249. function template_ban_edit_trigger()
  250. {
  251. global $context, $settings, $options, $scripturl, $txt, $modSettings;
  252. echo '
  253. <div id="manage_bans">
  254. <form id="admin_form_wrapper" action="', $scripturl, '?action=admin;area=ban;sa=edit" method="post" accept-charset="', $context['character_set'], '">
  255. <div class="cat_bar">
  256. <h3 class="catbg">
  257. ', $context['ban_trigger']['is_new'] ? $txt['ban_add_trigger'] : $txt['ban_edit_trigger_title'], '
  258. </h3>
  259. </div>
  260. <div class="windowbg">
  261. <div class="content">
  262. <fieldset>
  263. <legend>
  264. ', $txt['ban_triggers'], '
  265. </legend>
  266. <dl class="settings">
  267. <dt>
  268. <input type="radio" name="bantype" value="ip_ban"', $context['ban_trigger']['ip']['selected'] ? ' checked="checked"' : '', ' class="input_radio" />
  269. ', $txt['ban_on_ip'], '
  270. </dt>
  271. <dd>
  272. <input type="text" name="ip" value="', $context['ban_trigger']['ip']['value'], '" size="50" onfocus="selectRadioByName(this.form.bantype, \'ip_ban\');" class="input_text" />
  273. </dd>';
  274. if (empty($modSettings['disableHostnameLookup']))
  275. echo '
  276. <dt>
  277. <input type="radio" name="bantype" value="hostname_ban"', $context['ban_trigger']['hostname']['selected'] ? ' checked="checked"' : '', ' class="input_radio" />
  278. ', $txt['ban_on_hostname'], '
  279. </dt>
  280. <dd>
  281. <input type="text" name="hostname" value="', $context['ban_trigger']['hostname']['value'], '" size="50" onfocus="selectRadioByName(this.form.bantype, \'hostname_ban\');" class="input_text" />
  282. </dd>';
  283. echo '
  284. <dt>
  285. <input type="radio" name="bantype" value="email_ban"', $context['ban_trigger']['email']['selected'] ? ' checked="checked"' : '', ' class="input_radio" />
  286. ', $txt['ban_on_email'], '
  287. </dt>
  288. <dd>
  289. <input type="text" name="email" value="', $context['ban_trigger']['email']['value'], '" size="50" onfocus="selectRadioByName(this.form.bantype, \'email_ban\');" class="input_text" />
  290. </dd>
  291. <dt>
  292. <input type="radio" name="bantype" value="user_ban"', $context['ban_trigger']['banneduser']['selected'] ? ' checked="checked"' : '', ' class="input_radio" />
  293. ', $txt['ban_on_username'], '
  294. </dt>
  295. <dd>
  296. <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" />
  297. </dd>
  298. </dl>
  299. </fieldset>
  300. <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" />
  301. </div>
  302. </div>
  303. <input type="hidden" name="bi" value="' . $context['ban_trigger']['id'] . '" />
  304. <input type="hidden" name="bg" value="' . $context['ban_trigger']['group'] . '" />
  305. <input type="hidden" name="' . $context['session_var'] . '" value="' . $context['session_id'] . '" />
  306. <input type="hidden" name="', $context['admin-bet_token_var'], '" value="', $context['admin-bet_token'], '" />
  307. </form>
  308. </div>
  309. <script type="text/javascript" src="', $settings['default_theme_url'], '/scripts/suggest.js?alp21"></script>
  310. <script type="text/javascript"><!-- // --><![CDATA[
  311. var oAddMemberSuggest = new smc_AutoSuggest({
  312. sSelf: \'oAddMemberSuggest\',
  313. sSessionId: smf_session_id,
  314. sSessionVar: smf_session_var,
  315. sSuggestId: \'username\',
  316. sControlId: \'user\',
  317. sSearchType: \'member\',
  318. sTextDeleteItem: \'', $txt['autosuggest_delete_item'], '\',
  319. bItemList: false
  320. });
  321. function onUpdateName(oAutoSuggest)
  322. {
  323. selectRadioByName(oAutoSuggest.oTextHandle.form.bantype, \'user_ban\');
  324. return true;
  325. }
  326. oAddMemberSuggest.registerCallback(\'onBeforeUpdate\', \'onUpdateName\');
  327. // ]]></script>';
  328. }
  329. ?>