ManageBans.template.php 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324
  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="', $context['form_url'], '" method="post" accept-charset="', $context['character_set'], '" onsubmit="return confirmBan(this);">
  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. // If there were errors for sending the PM, show them.
  27. if (!empty($context['error_messages']))
  28. {
  29. echo '
  30. <div class="errorbox">
  31. <strong>', $txt['ban_errors_detected'], '</strong>
  32. <ul>';
  33. foreach ($context['error_messages'] as $error)
  34. echo '
  35. <li class="error">', $error, '</li>';
  36. echo '
  37. </ul>
  38. </div>';
  39. }
  40. echo '
  41. <div class="content">
  42. <dl class="settings">
  43. <dt id="ban_name_label">
  44. <strong>', $txt['ban_name'], ':</strong>
  45. </dt>
  46. <dd>
  47. <input type="text" id="ban_name" name="ban_name" value="', $context['ban']['name'], '" size="45" maxlength="60" class="input_text" />
  48. </dd>';
  49. if (isset($context['ban']['reason']))
  50. echo '
  51. <dt>
  52. <strong><label for="reason">', $txt['ban_reason'], ':</label></strong><br />
  53. <span class="smalltext">', $txt['ban_reason_desc'], '</span>
  54. </dt>
  55. <dd>
  56. <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>
  57. </dd>';
  58. if (isset($context['ban']['notes']))
  59. echo '
  60. <dt>
  61. <strong><label for="ban_notes">', $txt['ban_notes'], ':</label></strong><br />
  62. <span class="smalltext">', $txt['ban_notes_desc'], '</span>
  63. </dt>
  64. <dd>
  65. <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>
  66. </dd>';
  67. echo '
  68. </dl>
  69. <fieldset class="ban_settings floatleft">
  70. <legend>
  71. ', $txt['ban_expiration'], '
  72. </legend>
  73. <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 />
  74. <input type="radio" name="expiration" value="one_day" id="expires_one_day" onclick="fUpdateStatus();"', $context['ban']['expiration']['status'] == 'one_day' ? ' 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 />
  75. <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>
  76. </fieldset>
  77. <fieldset class="ban_settings floatright">
  78. <legend>
  79. ', $txt['ban_restriction'], '
  80. </legend>
  81. <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 />
  82. <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 />
  83. <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 />
  84. <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 />
  85. <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 />
  86. </fieldset>
  87. <br class="clear_right" />';
  88. if (!empty($context['ban_suggestions']))
  89. {
  90. echo '
  91. <fieldset>
  92. <legend>
  93. ', $txt['ban_triggers'], '
  94. </legend>
  95. <dl class="settings">
  96. <dt>
  97. <input type="checkbox" name="ban_suggestions[]" id="main_ip_check" value="main_ip" class="input_check" ', !empty($context['ban_suggestions']['main_ip']) ? 'checked="checked" ' : '', '/>
  98. <label for="main_ip_check">', $txt['ban_on_ip'], '</label>
  99. </dt>
  100. <dd>
  101. <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" />
  102. </dd>';
  103. if (empty($modSettings['disableHostnameLookup']))
  104. echo '
  105. <dt>
  106. <input type="checkbox" name="ban_suggestions[]" id="hostname_check" value="hostname" class="input_check" ', !empty($context['ban_suggestions']['hostname']) ? 'checked="checked" ' : '', '/>
  107. <label for="hostname_check">', $txt['ban_on_hostname'], '</label>
  108. </dt>
  109. <dd>
  110. <input type="text" name="hostname" value="', $context['ban_suggestions']['hostname'], '" size="44" onfocus="document.getElementById(\'hostname_check\').checked = true;" class="input_text" />
  111. </dd>';
  112. echo '
  113. <dt>
  114. <input type="checkbox" name="ban_suggestions[]" id="email_check" value="email" class="input_check" ', !empty($context['ban_suggestions']['email']) ? 'checked="checked" ' : '', '/>
  115. <label for="email_check">', $txt['ban_on_email'], '</label>
  116. </dt>
  117. <dd>
  118. <input type="text" name="email" value="', $context['ban_suggestions']['email'], '" size="44" onfocus="document.getElementById(\'email_check\').checked = true;" class="input_text" />
  119. </dd>
  120. <dt>
  121. <input type="checkbox" name="ban_suggestions[]" id="user_check" value="user" class="input_check" ', !empty($context['ban_suggestions']['user']) || isset($context['ban']['from_user']) ? 'checked="checked" ' : '', '/>
  122. <label for="user_check">', $txt['ban_on_username'], '</label>:
  123. </dt>
  124. <dd>
  125. <input type="text" ', isset($context['ban']['from_user']) ? 'readonly="readonly" value="' . $context['ban_suggestions']['member']['name'] . '"' : ' value=""', ' name="user" id="user" size="44" class="input_text" />
  126. </dd>
  127. </dl>';
  128. if (!empty($context['ban_suggestions']['other_ips']))
  129. {
  130. foreach ($context['ban_suggestions']['other_ips'] as $key => $ban_ips)
  131. {
  132. if (!empty($ban_ips))
  133. {
  134. echo '
  135. <div>', $txt[$key], ':</div>
  136. <dl class="settings">';
  137. $count = 0;
  138. foreach ($ban_ips as $ip)
  139. echo '
  140. <dt>
  141. <input type="checkbox" id="suggestions_', $key ,'_', $count, '" name="ban_suggestions[', $key ,'][]" ', !empty($context['ban_suggestions']['saved_triggers'][$key]) && in_array($ip, $context['ban_suggestions']['saved_triggers'][$key]) ? 'checked="checked" ' : '', 'value="', $ip, '" class="input_check" />
  142. </dt>
  143. <dd>
  144. <label for="suggestions_', $key ,'_', $count++, '">', $ip, '</label>
  145. </dd>';
  146. echo '
  147. </dl>';
  148. }
  149. }
  150. }
  151. echo '
  152. </fieldset>';
  153. }
  154. echo '
  155. <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" />
  156. <input type="hidden" name="old_expire" value="', $context['ban']['expiration']['days'], '" />
  157. <input type="hidden" name="bg" value="', $context['ban']['id'], '" />
  158. <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '" />
  159. <input type="hidden" name="', $context['admin-bet_token_var'], '" value="', $context['admin-bet_token'], '" />
  160. </div>
  161. </form>';
  162. if (!$context['ban']['is_new'] && empty($context['ban_suggestions']))
  163. {
  164. echo '
  165. <br />';
  166. template_show_list('ban_items');
  167. }
  168. echo '
  169. </div>
  170. <script type="text/javascript"><!-- // --><![CDATA[
  171. var fUpdateStatus = function ()
  172. {
  173. document.getElementById("expire_date").disabled = !document.getElementById("expires_one_day").checked;
  174. document.getElementById("cannot_post").disabled = document.getElementById("full_ban").checked;
  175. document.getElementById("cannot_register").disabled = document.getElementById("full_ban").checked;
  176. document.getElementById("cannot_login").disabled = document.getElementById("full_ban").checked;
  177. }
  178. addLoadEvent(fUpdateStatus);';
  179. // Auto suggest only needed for adding new bans, not editing
  180. if ($context['ban']['is_new'] && empty($_REQUEST['u']))
  181. echo '
  182. var oAddMemberSuggest = new smc_AutoSuggest({
  183. sSelf: \'oAddMemberSuggest\',
  184. sSessionId: smf_session_id,
  185. sSessionVar: smf_session_var,
  186. sSuggestId: \'user\',
  187. sControlId: \'user\',
  188. sSearchType: \'member\',
  189. sTextDeleteItem: \'', $txt['autosuggest_delete_item'], '\',
  190. bItemList: false
  191. });
  192. function onUpdateName(oAutoSuggest)
  193. {
  194. document.getElementById(\'user_check\').checked = true;
  195. return true;
  196. }
  197. oAddMemberSuggest.registerCallback(\'onBeforeUpdate\', \'onUpdateName\');';
  198. echo '
  199. function confirmBan(aForm)
  200. {
  201. if (aForm.ban_name.value == \'\')
  202. {
  203. alert(\'', $txt['ban_name_empty'], '\');
  204. return false;
  205. }
  206. if (aForm.partial_ban.checked && !(aForm.cannot_post.checked || aForm.cannot_register.checked || aForm.cannot_login.checked))
  207. {
  208. alert(\'', $txt['ban_restriction_empty'], '\');
  209. return false;
  210. }
  211. }// ]]></script>';
  212. }
  213. function template_ban_edit_trigger()
  214. {
  215. global $context, $settings, $options, $scripturl, $txt, $modSettings;
  216. echo '
  217. <div id="manage_bans">
  218. <form id="admin_form_wrapper" action="', $context['form_url'], '" method="post" accept-charset="', $context['character_set'], '">
  219. <div class="cat_bar">
  220. <h3 class="catbg">
  221. ', $context['ban_trigger']['is_new'] ? $txt['ban_add_trigger'] : $txt['ban_edit_trigger_title'], '
  222. </h3>
  223. </div>
  224. <div class="windowbg">
  225. <div class="content">
  226. <fieldset>
  227. <legend>
  228. ', $txt['ban_triggers'], '
  229. </legend>
  230. <dl class="settings">
  231. <dt>
  232. <input type="checkbox" name="ban_suggestions[]" id="main_ip_check" value="main_ip" class="input_check" ', $context['ban_trigger']['ip']['selected'] ? 'checked="checked" ' : '', '/>
  233. <label for="main_ip_check">', $txt['ban_on_ip'], '</label>
  234. </dt>
  235. <dd>
  236. <input type="text" name="main_ip" value="', $context['ban_trigger']['ip']['value'], '" size="44" onfocus="document.getElementById(\'main_ip_check\').checked = true;" class="input_text" />
  237. </dd>';
  238. if (empty($modSettings['disableHostnameLookup']))
  239. echo '
  240. <dt>
  241. <input type="checkbox" name="ban_suggestions[]" id="hostname_check" value="hostname" class="input_check" ', $context['ban_trigger']['hostname']['selected'] ? 'checked="checked" ' : '', '/>
  242. <label for="hostname_check">', $txt['ban_on_hostname'], '</label>
  243. </dt>
  244. <dd>
  245. <input type="text" name="hostname" value="', $context['ban_trigger']['hostname']['value'], '" size="44" onfocus="document.getElementById(\'hostname_check\').checked = true;" class="input_text" />
  246. </dd>';
  247. echo '
  248. <dt>
  249. <input type="checkbox" name="ban_suggestions[]" id="email_check" value="email" class="input_check" ', $context['ban_trigger']['email']['selected'] ? 'checked="checked" ' : '', '/>
  250. <label for="email_check">', $txt['ban_on_email'], '</label>
  251. </dt>
  252. <dd>
  253. <input type="text" name="email" value="', $context['ban_trigger']['email']['value'], '" size="44" onfocus="document.getElementById(\'email_check\').checked = true;" class="input_text" />
  254. </dd>
  255. <dt>
  256. <input type="checkbox" name="ban_suggestions[]" id="user_check" value="user" class="input_check" ', $context['ban_trigger']['banneduser']['selected'] ? 'checked="checked" ' : '', '/>
  257. <label for="user_check">', $txt['ban_on_username'], '</label>:
  258. </dt>
  259. <dd>
  260. <input type="text" value="' . $context['ban_trigger']['banneduser']['value'] . '" name="user" id="user" size="44" onfocus="document.getElementById(\'user_check\').checked = true;"class="input_text" />
  261. </dd>
  262. </dl>
  263. </fieldset>
  264. <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" />
  265. </div>
  266. </div>
  267. <input type="hidden" name="bi" value="' . $context['ban_trigger']['id'] . '" />
  268. <input type="hidden" name="bg" value="' . $context['ban_trigger']['group'] . '" />
  269. <input type="hidden" name="' . $context['session_var'] . '" value="' . $context['session_id'] . '" />
  270. <input type="hidden" name="', $context['admin-bet_token_var'], '" value="', $context['admin-bet_token'], '" />
  271. </form>
  272. </div>
  273. <script type="text/javascript" src="', $settings['default_theme_url'], '/scripts/suggest.js?alp21"></script>
  274. <script type="text/javascript"><!-- // --><![CDATA[
  275. var oAddMemberSuggest = new smc_AutoSuggest({
  276. sSelf: \'oAddMemberSuggest\',
  277. sSessionId: smf_session_id,
  278. sSessionVar: smf_session_var,
  279. sSuggestId: \'username\',
  280. sControlId: \'user\',
  281. sSearchType: \'member\',
  282. sTextDeleteItem: \'', $txt['autosuggest_delete_item'], '\',
  283. bItemList: false
  284. });
  285. function onUpdateName(oAutoSuggest)
  286. {
  287. document.getElementById(\'user_check\').checked = true;
  288. return true;
  289. }
  290. oAddMemberSuggest.registerCallback(\'onBeforeUpdate\', \'onUpdateName\');
  291. // ]]></script>';
  292. }
  293. ?>