2
0

ManageBans.template.php 17 KB

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