PageRenderTime 45ms CodeModel.GetById 11ms RepoModel.GetById 0ms app.codeStats 0ms

/includes/acp/acp_asacp.php

https://github.com/Vexilurz/phpbb_forum
PHP | 600 lines | 476 code | 95 blank | 29 comment | 69 complexity | f5dcd1357233ba660d98c508389d9d40 MD5 | raw file
Possible License(s): AGPL-1.0
  1. <?php
  2. /**
  3. *
  4. * @package Anti-Spam ACP
  5. * @copyright (c) 2008 EXreaction
  6. * @license http://opensource.org/licenses/gpl-license.php GNU Public License
  7. *
  8. */
  9. /**
  10. * @ignore
  11. */
  12. if (!defined('IN_PHPBB'))
  13. {
  14. exit;
  15. }
  16. class acp_asacp
  17. {
  18. var $u_action;
  19. function main($id, $mode)
  20. {
  21. global $db, $user, $auth, $template, $cache;
  22. global $config, $phpbb_admin_path, $phpbb_root_path, $phpEx;
  23. $user->add_lang(array('acp/board', 'mods/asacp', 'mods/acp_asacp', 'install'));
  24. include($phpbb_root_path . 'antispam/acp_functions.' . $phpEx);
  25. $error = $notify = array();
  26. $submit = (isset($_POST['submit'])) ? true : false;
  27. $action = request_var('action', '');
  28. add_form_key('as_acp');
  29. if ($submit && !check_form_key('as_acp'))
  30. {
  31. trigger_error($user->lang['FORM_INVALID'] . adm_back_link($this->u_action), E_USER_WARNING);
  32. }
  33. $error = $options = array();
  34. switch ($mode)
  35. {
  36. case 'spam_words' :
  37. $this->tpl_name = 'acp_asacp';
  38. $this->page_title = 'ASACP_SPAM_WORDS';
  39. $word_id = request_var('w', 0);
  40. $word_data = array(
  41. 'word_text' => utf8_normalize_nfc(request_var('word_text', '', true)),
  42. 'word_regex' => request_var('word_regex', 0),
  43. 'word_regex_auto' => request_var('word_regex_auto', 0),
  44. );
  45. switch ($action)
  46. {
  47. case 'edit' :
  48. if (!$word_id)
  49. {
  50. trigger_error('NO_SPAM_WORD');
  51. }
  52. $result = $db->sql_query('SELECT * FROM ' . SPAM_WORDS_TABLE . ' WHERE word_id = ' . $word_id);
  53. $word = $db->sql_fetchrow($result);
  54. if (!$word)
  55. {
  56. trigger_error('NO_SPAM_WORD');
  57. }
  58. if (!$submit)
  59. {
  60. $word_data = $word;
  61. }
  62. case 'add' :
  63. $template->assign_vars(array(
  64. 'WORD_TEXT' => $word_data['word_text'],
  65. 'WORD_REGEX' => ($word_data['word_regex']) ? true : false,
  66. 'WORD_REGEX_AUTO' => ($word_data['word_regex_auto']) ? true : false,
  67. 'S_ADD' => ($action == 'add') ? true : false,
  68. 'U_WORD_ACTION' => $this->u_action . '&amp;action=' . $action . (($action == 'edit') ? '&amp;w=' . $word_id : ''),
  69. ));
  70. if ($submit)
  71. {
  72. if ($word_data['word_regex'])
  73. {
  74. $delim = substr($word_data['word_text'], 0, 1);
  75. if (strrpos($word_data['word_text'], $delim) == 0)
  76. {
  77. trigger_error('SPAM_WORD_TEXT_EXPLAIN');
  78. }
  79. }
  80. if ($action == 'add')
  81. {
  82. $db->sql_query('INSERT INTO ' . SPAM_WORDS_TABLE . ' ' . $db->sql_build_array('INSERT', $word_data));
  83. $cache->destroy('_spam_words');
  84. trigger_error($user->lang['SPAM_WORD_ADD_SUCCESS'] . adm_back_link($this->u_action));
  85. }
  86. else
  87. {
  88. $db->sql_query('UPDATE ' . SPAM_WORDS_TABLE . ' SET ' . $db->sql_build_array('UPDATE', $word_data) . ' WHERE word_id = ' . $word_id);
  89. $cache->destroy('_spam_words');
  90. trigger_error($user->lang['SPAM_WORD_EDIT_SUCCESS'] . adm_back_link($this->u_action));
  91. }
  92. }
  93. break;
  94. case 'delete' :
  95. if (!$word_id)
  96. {
  97. trigger_error('NO_SPAM_WORD');
  98. }
  99. $result = $db->sql_query('SELECT * FROM ' . SPAM_WORDS_TABLE . ' WHERE word_id = ' . $word_id);
  100. $word = $db->sql_fetchrow($result);
  101. if (!$word)
  102. {
  103. trigger_error('NO_SPAM_WORD');
  104. }
  105. if (confirm_box(true))
  106. {
  107. $db->sql_query('DELETE FROM ' . SPAM_WORDS_TABLE . ' WHERE word_id = ' . $word_id);
  108. $cache->destroy('_spam_words');
  109. trigger_error($user->lang['SPAM_WORD_DELETE_SUCCESS'] . adm_back_link($this->u_action));
  110. }
  111. else
  112. {
  113. confirm_box(false, 'DELETE_SPAM_WORD');
  114. }
  115. break;
  116. default :
  117. $sql = 'SELECT * FROM ' . SPAM_WORDS_TABLE . '
  118. ORDER BY word_text ASC';
  119. $result = $db->sql_query($sql);
  120. while ($row = $db->sql_fetchrow($result))
  121. {
  122. $template->assign_block_vars('spam_words', array(
  123. 'TEXT' => $row['word_text'],
  124. 'REGEX' => $row['word_regex'],
  125. 'REGEX_AUTO' => $row['word_regex_auto'],
  126. 'U_DELETE' => append_sid($this->u_action . '&amp;action=delete&amp;w=' . $row['word_id']),
  127. 'U_EDIT' => append_sid($this->u_action . '&amp;action=edit&amp;w=' . $row['word_id']),
  128. ));
  129. }
  130. $db->sql_freeresult($result);
  131. $template->assign_var('S_SPAM_WORD_LIST', true);
  132. break;
  133. }
  134. $template->assign_vars(array(
  135. 'L_TITLE' => $user->lang['ASACP_SPAM_WORDS'],
  136. 'L_TITLE_EXPLAIN' => $user->lang['ASACP_SPAM_WORDS_EXPLAIN'],
  137. 'S_SPAM_WORDS' => true,
  138. ));
  139. break;
  140. //case 'spam_words' :
  141. case 'ip_search' :
  142. $this->tpl_name = 'acp_asacp';
  143. $this->page_title = 'ASACP_IP_SEARCH';
  144. $ip = request_var('ip', '');
  145. $type = request_var('type', '');
  146. if ($ip)
  147. {
  148. asacp_display_ip_search($type, $ip, $this->u_action . '&amp;ip=' . $ip, request_var('start', 0));
  149. }
  150. $template->assign_vars(array(
  151. 'L_TITLE' => $user->lang['ASACP_IP_SEARCH'],
  152. 'L_TITLE_EXPLAIN' => $user->lang['ASACP_IP_SEARCH_EXPLAIN'],
  153. 'S_DATA_OUTPUT' => true,
  154. 'S_DISPLAY_IP_INPUT' => ($ip) ? false : true,
  155. 'U_BACK' => ($type) ? $this->u_action . '&amp;ip=' . $ip : false,
  156. 'U_BACK_NONE' => $this->u_action,
  157. ));
  158. break;
  159. // case 'ip_search' :
  160. case 'log' :
  161. case 'flag' :
  162. $this->tpl_name = 'acp_logs';
  163. if ($mode == 'log')
  164. {
  165. $this->page_title = $user->lang['ASACP_SPAM_LOG'];
  166. }
  167. else
  168. {
  169. $this->page_title = $user->lang['ASACP_FLAG_LOG'];
  170. // Reset the user flag new notification
  171. if ($user->data['user_flag_new'])
  172. {
  173. $db->sql_query('UPDATE ' . USERS_TABLE . ' SET user_flag_new = 0 WHERE user_id = ' . $user->data['user_id']);
  174. }
  175. }
  176. $user->add_lang('mcp');
  177. // Set up general vars
  178. $start = request_var('start', 0);
  179. $action = request_var('action', array('' => ''));
  180. if (is_array($action))
  181. {
  182. list($action, ) = each($action);
  183. }
  184. else
  185. {
  186. $action = request_var('action', '');
  187. }
  188. $deletemark = (!empty($_POST['delmarked']) || $action == 'del_marked') ? true : false;
  189. $deleteall = (!empty($_POST['delall']) || $action == 'del_all') ? true : false;
  190. $marked = request_var('mark', array(0));
  191. // Sort keys
  192. $sort_days = request_var('st', 0);
  193. $sort_key = request_var('sk', 't');
  194. $sort_dir = request_var('sd', 'd');
  195. $keywords = utf8_normalize_nfc(request_var('keywords', '', true));
  196. $keywords_param = !empty($keywords) ? '&amp;keywords=' . urlencode(htmlspecialchars_decode($keywords)) : '';
  197. // Delete entries if requested and able
  198. if (($deletemark || $deleteall) && $auth->acl_get('a_clearlogs'))
  199. {
  200. if (confirm_box(true))
  201. {
  202. clear_spam_log($mode, (($deletemark) ? false : $deleteall), $marked, $keywords);
  203. }
  204. else
  205. {
  206. confirm_box(false, $user->lang['CONFIRM_OPERATION'], build_hidden_fields(array(
  207. 'start' => $start,
  208. 'delmarked' => $deletemark,
  209. 'delall' => $deleteall,
  210. 'mark' => $marked,
  211. 'st' => $sort_days,
  212. 'sk' => $sort_key,
  213. 'sd' => $sort_dir,
  214. 'keywords' => $keywords,
  215. 'i' => $id,
  216. 'mode' => $mode,
  217. 'action' => $this->u_action))
  218. );
  219. }
  220. }
  221. // Sorting
  222. $limit_days = array(0 => $user->lang['ALL_ENTRIES'], 1 => $user->lang['1_DAY'], 7 => $user->lang['7_DAYS'], 14 => $user->lang['2_WEEKS'], 30 => $user->lang['1_MONTH'], 90 => $user->lang['3_MONTHS'], 180 => $user->lang['6_MONTHS'], 365 => $user->lang['1_YEAR']);
  223. $sort_by_text = array('t' => $user->lang['SORT_DATE'], 'u' => $user->lang['SORT_USERNAME'], 'i' => $user->lang['SORT_IP'], 'o' => $user->lang['SORT_ACTION']);
  224. $sort_by_sql = array('t' => 'l.log_time', 'u' => 'u.username_clean', 'i' => 'l.log_ip', 'o' => 'l.log_operation');
  225. $s_limit_days = $s_sort_key = $s_sort_dir = $u_sort_param = '';
  226. gen_sort_selects($limit_days, $sort_by_text, $sort_days, $sort_key, $sort_dir, $s_limit_days, $s_sort_key, $s_sort_dir, $u_sort_param);
  227. // Define where and sort sql for use in displaying logs
  228. $sql_days = ($sort_days) ? (time() - ($sort_days * 86400)) : 0;
  229. $sql_sort = $sort_by_sql[$sort_key] . ' ' . (($sort_dir == 'd') ? 'DESC' : 'ASC');
  230. // Grab log data
  231. $log_data = array();
  232. $log_count = 0;
  233. if ($mode == 'log')
  234. {
  235. view_spam_log('spam', $log_data, $log_count, $config['topics_per_page'], $start, '', $sql_days, $sql_sort, $keywords);
  236. }
  237. else
  238. {
  239. view_spam_log('flag', $log_data, $log_count, $config['topics_per_page'], $start, '', $sql_days, $sql_sort, $keywords);
  240. }
  241. $template->assign_vars(array(
  242. 'L_TITLE' => $this->page_title,
  243. 'L_EXPLAIN' => '',
  244. 'S_ON_PAGE' => on_page($log_count, $config['topics_per_page'], $start),
  245. 'PAGE_NUMBER' => on_page($log_count, $config['topics_per_page'], $start),
  246. 'PAGINATION' => generate_pagination($this->u_action . "&amp;$u_sort_param$keywords_param", $log_count, $config['topics_per_page'], $start, true),
  247. 'TOTAL' => ($log_count == 1) ? $user->lang['TOTAL_LOG'] : sprintf($user->lang['TOTAL_LOGS'], $log_count),
  248. 'S_LIMIT_DAYS' => $s_limit_days, // Yes, these duplicates are shit, but the acp/mcp use different variables
  249. 'S_SELECT_SORT_DAYS' => $s_limit_days,
  250. 'S_SORT_KEY' => $s_sort_key,
  251. 'S_SELECT_SORT_KEY' => $s_sort_key,
  252. 'S_SORT_DIR' => $s_sort_dir,
  253. 'S_SELECT_SORT_DIR' => $s_sort_dir,
  254. 'S_CLEARLOGS' => $auth->acl_get('a_clearlogs'),
  255. 'S_CLEAR_ALLOWED' => $auth->acl_get('a_clearlogs'),
  256. 'S_KEYWORDS' => $keywords,
  257. 'S_LOGS' => ($log_count > 0) ? true : false,
  258. ));
  259. foreach ($log_data as $row)
  260. {
  261. $template->assign_block_vars('log', array(
  262. 'USERNAME' => $row['username_full'],
  263. 'REPORTEE_USERNAME' => ($row['reportee_username'] && $row['user_id'] != $row['reportee_id']) ? $row['reportee_username_full'] : '',
  264. 'IP' => '<a href="' . append_sid("{$phpbb_admin_path}index.$phpEx", "i={$id}&amp;mode=ip_search&amp;ip={$row['ip']}") . '">' . $row['ip'] . '</a>',
  265. 'DATE' => $user->format_date($row['time']),
  266. 'ACTION' => $row['action'],
  267. 'DATA' => (sizeof($row['data'])) ? @vsprintf($user->lang[$row['operation'] . '_DATA'], $row['data']) : '',
  268. 'ID' => $row['id'],
  269. ));
  270. }
  271. break;
  272. //case 'log' :
  273. //case 'flag' :
  274. case 'flag_list' :
  275. $user->add_lang('memberlist');
  276. $this->tpl_name = 'acp_asacp';
  277. $this->page_title = 'ASACP_FLAG_LIST';
  278. $start = request_var('start', 0);
  279. $limit = request_var('limit', 20);
  280. $db->sql_query('SELECT count(user_id) as cnt FROM ' . USERS_TABLE . ' WHERE user_flagged = 1');
  281. $total = $db->sql_fetchfield('cnt');
  282. $sql = 'SELECT user_id, username, user_colour, user_ip, user_posts FROM ' . USERS_TABLE . ' WHERE user_flagged = 1';
  283. $result = $db->sql_query_limit($sql, $limit, $start);
  284. $cnt = 0;
  285. $output = '';
  286. while ($row = $db->sql_fetchrow($result))
  287. {
  288. $row['username'] = get_username_string('full', $row['user_id'], $row['username'], $row['user_colour']);
  289. if ($auth->acl_get('m_asacp_ip_search'))
  290. {
  291. $row['user_ip'] = '<a href="' . append_sid("{$phpbb_admin_path}index.$phpEx", "i={$id}&amp;mode=ip_search&amp;ip={$row['user_ip']}") . '">' . $row['user_ip'] . '</a>';
  292. }
  293. if ($auth->acl_get('a_user'))
  294. {
  295. $row[$user->lang['ACTION']] = '<a href="' . append_sid("{$phpbb_admin_path}index.$phpEx", "i=users&amp;mode=overview&amp;u={$row['user_id']}") . '">' . $user->lang['USER_ADMIN'] . '</a>';
  296. }
  297. unset($row['user_id'], $row['user_colour']);
  298. $cnt++;
  299. if ($cnt == 1)
  300. {
  301. $output .= asacp_display_table_head($row);
  302. }
  303. $output .= asacp_display_table_row($row, $cnt);
  304. }
  305. $db->sql_freeresult($result);
  306. $template->assign_vars(array(
  307. 'L_TITLE' => $user->lang['ASACP_FLAG_LIST'],
  308. 'L_TITLE_EXPLAIN' => $user->lang['ASACP_FLAG_LIST_EXPLAIN'],
  309. 'S_DATA_OUTPUT' => true,
  310. ));
  311. $template->assign_block_vars('data_output', array(
  312. 'TITLE' => $user->lang['USERS'],
  313. 'DATA' => $output,
  314. 'PAGINATION' => ($total) ? generate_pagination($this->u_action . "&amp;limit=$limit", $total, $limit, $start, true, 'data_output') : '',
  315. ));
  316. break;
  317. //case 'flag_list' :
  318. case 'profile_fields' :
  319. $user->add_lang('ucp');
  320. $this->tpl_name = 'acp_asacp';
  321. $this->page_title = 'ASACP_PROFILE_FIELDS';
  322. $options = array(
  323. 'legend1' => 'ASACP_PROFILE_FIELDS',
  324. );
  325. $cfg_array = (isset($_REQUEST['config'])) ? utf8_normalize_nfc(request_var('config', array('' => ''), true)) : $config;
  326. foreach (antispam::$profile_fields as $field => $ary)
  327. {
  328. if ($submit)
  329. {
  330. switch ($cfg_array['asacp_profile_' . $field])
  331. {
  332. case 1 :
  333. // Required
  334. break;
  335. case 2 :
  336. // Normal
  337. break;
  338. case 3 :
  339. // Never allowed
  340. $sql = 'UPDATE ' . USERS_TABLE . ' SET ' . $db->sql_build_array('UPDATE', array($ary['db'] => ''));
  341. $db->sql_query($sql);
  342. break;
  343. case 4 :
  344. // Post Count
  345. $sql = 'UPDATE ' . USERS_TABLE . ' SET ' . $db->sql_build_array('UPDATE', array($ary['db'] => '')) . '
  346. WHERE user_posts < ' . (int) $cfg_array['asacp_profile_' . $field . '_post_limit'];
  347. $db->sql_query($sql);
  348. break;
  349. }
  350. }
  351. $options['asacp_profile_' . $field] = array('lang' => $ary['lang'], 'validate' => 'int:1:4', 'type' => 'custom', 'method' => 'profile_fields_select', 'explain' => false);
  352. $options['asacp_profile_' . $field . '_post_limit'] = array('lang' => $ary['lang'] . '_POST_COUNT', 'validate' => 'int:1:99999', 'type' => 'text:40:255', 'explain' => true);
  353. }
  354. $template->assign_vars(array(
  355. 'L_TITLE' => $user->lang['ASACP_PROFILE_FIELDS'],
  356. 'L_TITLE_EXPLAIN' => $user->lang['ASACP_PROFILE_FIELDS_EXPLAIN'],
  357. ));
  358. break;
  359. //case 'profile_fields' :
  360. default :
  361. $this->tpl_name = 'acp_asacp';
  362. $this->page_title = 'ASACP_SETTINGS';
  363. $options = array(
  364. 'legend1' => 'ASACP_SETTINGS',
  365. 'asacp_enable' => array('lang' => 'ASACP_ENABLE', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true),
  366. 'asacp_log' => array('lang' => 'ASACP_LOG', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true),
  367. 'asacp_user_flag_enable' => array('lang' => 'ASACP_USER_FLAG_ENABLE', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true),
  368. 'asacp_notify_new_flag' => array('lang' => 'ASACP_NOTIFY_NEW_FLAG', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true),
  369. 'legend2' => 'ASACP_PROFILE_FIELDS',
  370. 'asacp_profile_during_reg' => array('lang' => 'ASACP_PROFILE_DURING_REG', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true),
  371. 'legend3' => 'ASACP_AKISMET',
  372. 'asacp_akismet_enable' => array('lang' => 'ASACP_AKISMET_ENABLE', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => false),
  373. 'asacp_akismet_key' => array('lang' => 'ASACP_AKISMET_KEY', 'validate' => 'string', 'type' => 'text:14:14', 'explain' => true),
  374. 'asacp_akismet_domain' => array('lang' => 'ASACP_AKISMET_DOMAIN', 'validate' => 'string', 'type' => 'text:40:255', 'explain' => true),
  375. 'asacp_akismet_post_limit' => array('lang' => 'ASACP_AKISMET_POST_LIMIT', 'validate' => 'int', 'type' => 'text:14:14', 'explain' => true),
  376. 'asacp_akismet_post_action' => array('lang' => 'ASACP_SPAM_WORDS_POSTING_ACTION', 'validate' => 'int:0:2', 'type' => 'custom', 'method' => 'spam_words_nothing_deny_approval_action', 'explain' => true),
  377. 'asacp_akismet_pm_action' => array('lang' => 'ASACP_SPAM_WORDS_PM_ACTION', 'validate' => 'int:0:1', 'type' => 'custom', 'method' => 'spam_words_nothing_deny_action', 'explain' => true),
  378. 'legend4' => 'ASACP_SPAM_WORDS',
  379. 'asacp_spam_words_enable' => array('lang' => 'ASACP_SPAM_WORDS_ENABLE', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true),
  380. 'asacp_spam_words_post_limit' => array('lang' => 'ASACP_SPAM_WORDS_POST_LIMIT', 'validate' => 'string', 'type' => 'text:40:255', 'explain' => true),
  381. 'asacp_spam_words_flag_limit' => array('lang' => 'ASACP_SPAM_WORDS_FLAG_LIMIT', 'validate' => 'int:1', 'type' => 'text:40:255', 'explain' => true),
  382. 'asacp_spam_words_posting_action' => array('lang' => 'ASACP_SPAM_WORDS_POSTING_ACTION', 'validate' => 'int:0:2', 'type' => 'custom', 'method' => 'spam_words_nothing_deny_approval_action', 'explain' => true),
  383. 'asacp_spam_words_pm_action' => array('lang' => 'ASACP_SPAM_WORDS_PM_ACTION', 'validate' => 'int:0:1', 'type' => 'custom', 'method' => 'spam_words_nothing_deny_action', 'explain' => true),
  384. 'asacp_spam_words_profile_action' => array('lang' => 'ASACP_SPAM_WORDS_PROFILE_ACTION', 'validate' => 'int:0:1', 'type' => 'custom', 'method' => 'spam_words_nothing_deny_action', 'explain' => true),
  385. 'legend5' => 'ASACP_SFS_SETTINGS',
  386. 'asacp_sfs_min_freq' => array('lang' => 'ASACP_SFS_MIN_FREQ', 'validate' => 'int:1', 'type' => 'text:6:10', 'explain' => true),
  387. 'asacp_sfs_action' => array('lang' => 'ASACP_SFS_ACTION', 'validate' => 'int:0:5', 'type' => 'custom', 'method' => 'sfs_action', 'explain' => true),
  388. 'asacp_sfs_key' => array('lang' => 'ASACP_SFS_KEY', 'validate' => 'string', 'type' => 'text:14:14', 'explain' => true),
  389. 'legend6' => 'ASACP_BAN_SETTINGS',
  390. 'asacp_ocban_username' => array('lang' => 'ASACP_BAN_USERNAME', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true),
  391. 'asacp_ocban_deactivate' => array('lang' => 'ASACP_BAN_DEACTIVATE_USER', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true),
  392. 'asacp_ocban_move_to_group' => array('lang' => 'ASACP_BAN_MOVE_TO_GROUP', 'validate' => 'int:0', 'type' => 'custom', 'method' => 'group_list', 'explain' => true),
  393. 'asacp_ocban_delete_posts' => array('lang' => 'ASACP_BAN_DELETE_POSTS', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true),
  394. 'asacp_ocban_clear_outbox' => array('lang' => 'ASACP_BAN_CLEAR_OUTBOX', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true),
  395. 'asacp_ocban_delete_avatar' => array('lang' => 'ASACP_BAN_DELETE_AVATAR', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true),
  396. 'asacp_ocban_delete_signature' => array('lang' => 'ASACP_BAN_DELETE_SIGNATURE', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true),
  397. 'asacp_ocban_delete_profile_fields' => array('lang' => 'ASACP_BAN_DELETE_PROFILE_FIELDS', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true),
  398. );
  399. if (file_exists($phpbb_root_path . 'blog/includes/functions_admin.' . $phpEx))
  400. {
  401. $options['asacp_ocban_blog'] = array('lang' => 'ASACP_BAN_DELETE_BLOG', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true);
  402. }
  403. $template->assign_vars(array(
  404. 'L_TITLE' => $user->lang['ASACP_SETTINGS'],
  405. 'L_TITLE_EXPLAIN' => '',
  406. 'S_SETTINGS' => true,
  407. 'CURRENT_VERSION' => ASACP_VERSION,
  408. 'LATEST_VERSION' => $this->asacp_latest_version(),
  409. ));
  410. break;
  411. }
  412. // switch($mode)
  413. // Display the options if there are any (setup similar to acp_board)
  414. if (sizeof($options))
  415. {
  416. asacp_display_options($options, $error, $this->u_action);
  417. }
  418. $template->assign_vars(array(
  419. 'ERROR' => implode('<br />', $error),
  420. 'U_ACTION' => $this->u_action,
  421. ));
  422. }
  423. function group_list($value, $key)
  424. {
  425. global $db, $user;
  426. $return = '<select name="config[' . $key . ']"><option value="0">--------</option>';
  427. $sql = 'SELECT group_id, group_founder_manage, group_name FROM ' . GROUPS_TABLE;
  428. $result = $db->sql_query($sql);
  429. while ($row = $db->sql_fetchrow($result))
  430. {
  431. if (!$row['group_founder_manage'] || $user->data['user_type'] == USER_FOUNDER)
  432. {
  433. $lang = (isset($user->lang[$row['group_name']])) ? $user->lang[$row['group_name']] : ((isset($user->lang['G_' . $row['group_name']])) ? $user->lang['G_' . $row['group_name']] : $row['group_name']);
  434. $return .= '<option value="' . $row['group_id'] . '"' . (($value == $row['group_id']) ? ' selected="selected"' : '') . '>' . $lang . '</option>';
  435. }
  436. }
  437. $db->sql_freeresult($result);
  438. $return .= '</select>';
  439. return $return;
  440. }
  441. function sfs_action($value, $key)
  442. {
  443. global $user;
  444. $key1 = ($value == 1) ? ' checked="checked"' : '';
  445. $key2 = ($value == 2) ? ' checked="checked"' : '';
  446. $key3 = ($value == 3) ? ' checked="checked"' : '';
  447. $key4 = ($value == 4) ? ' checked="checked"' : '';
  448. $key5 = ($value == 5) ? ' checked="checked"' : '';
  449. return '<label><input type="radio" name="config[' . $key . ']" value="1"' . $key1 . ' class="radio" /> ' . $user->lang['NOTHING'] . '</label>
  450. <label><input type="radio" name="config[' . $key . ']" value="2"' . $key2 . ' class="radio" /> ' . $user->lang['FLAG_USER'] . '</label>
  451. <label><input type="radio" name="config[' . $key . ']" value="3"' . $key3 . ' class="radio" /> ' . $user->lang['REQUIRE_USER_ACTIVATION'] . '</label><br /><br />
  452. <label><input type="radio" name="config[' . $key . ']" value="4"' . $key4 . ' class="radio" /> ' . $user->lang['REQUIRE_ADMIN_ACTIVATION'] . '</label>
  453. <label><input type="radio" name="config[' . $key . ']" value="5"' . $key5 . ' class="radio" /> ' . $user->lang['DENY_SUBMISSION'] . '</label>';
  454. }
  455. function profile_fields_select($value, $key)
  456. {
  457. global $user;
  458. $key1 = ($value == 1) ? ' checked="checked"' : '';
  459. $key2 = ($value == 2) ? ' checked="checked"' : '';
  460. $key3 = ($value == 3) ? ' checked="checked"' : '';
  461. $key4 = ($value == 4) ? ' checked="checked"' : '';
  462. return '<label><input type="radio" name="config[' . $key . ']" value="1"' . $key1 . ' class="radio" /> ' . $user->lang['REQUIRE_FIELD'] . '</label>
  463. <label><input type="radio" name="config[' . $key . ']" value="2"' . $key2 . ' class="radio" /> ' . $user->lang['ALLOW_FIELD'] . '</label>
  464. <label><input type="radio" name="config[' . $key . ']" value="3"' . $key3 . ' class="radio" /> ' . $user->lang['DENY_FIELD'] . '</label>
  465. <label><input type="radio" name="config[' . $key . ']" value="4"' . $key4 . ' class="radio" /> ' . $user->lang['POST_COUNT'] . '</label>';
  466. }
  467. function spam_words_nothing_deny_approval_action($value, $key)
  468. {
  469. global $user;
  470. $key0 = ($value == 0) ? ' checked="checked"' : '';
  471. $key1 = ($value == 1) ? ' checked="checked"' : '';
  472. $key2 = ($value == 2) ? ' checked="checked"' : '';
  473. return '<label><input type="radio" name="config[' . $key . ']" value="0"' . $key0 . ' class="radio" /> ' . $user->lang['NOTHING'] . '</label>
  474. <label><input type="radio" name="config[' . $key . ']" value="1"' . $key1 . ' class="radio" /> ' . $user->lang['DENY_SUBMISSION'] . '</label>
  475. <label><input type="radio" name="config[' . $key . ']" value="2"' . $key2 . ' class="radio" /> ' . $user->lang['REQUIRE_APPROVAL'] . '</label>';
  476. }
  477. function spam_words_nothing_deny_action($value, $key)
  478. {
  479. global $user;
  480. $key0 = ($value == 0) ? ' checked="checked"' : '';
  481. $key1 = ($value == 1) ? ' checked="checked"' : '';
  482. return '<label><input type="radio" name="config[' . $key . ']" value="0"' . $key0 . ' class="radio" /> ' . $user->lang['NOTHING'] . '</label>
  483. <label><input type="radio" name="config[' . $key . ']" value="1"' . $key1 . ' class="radio" /> ' . $user->lang['DENY_SUBMISSION'] . '</label>';
  484. }
  485. function asacp_latest_version()
  486. {
  487. global $user, $config;
  488. $latest_version = antispam::version_check();
  489. if ($latest_version === false)
  490. {
  491. $version = $user->lang['NOT_AVAILABLE'];
  492. $version .= '<br />' . sprintf($user->lang['CLICK_CHECK_NEW_VERSION'], '<a href="http://www.lithiumstudios.org/phpBB3/viewtopic.php?f=31&amp;t=941">', '</a>');
  493. }
  494. else
  495. {
  496. $version = $latest_version;
  497. if (version_compare(ASACP_VERSION, $latest_version, '<'))
  498. {
  499. $version .= '<br />' . sprintf($user->lang['CLICK_GET_NEW_VERSION'], '<a href="http://www.lithiumstudios.org/phpBB3/viewtopic.php?f=31&amp;t=941">', '</a>');
  500. }
  501. }
  502. return $version;
  503. }
  504. }
  505. ?>