人人商城

sensitiveword.ctrl.php 1.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. <?php
  2. /**
  3. * [WeEngine System] Copyright (c) 2014 WE7.CC
  4. * WeEngine is NOT a free software, it under the license terms, visited http://www.we7.cc/ for more details.
  5. */
  6. defined('IN_IA') or exit('Access Denied');
  7. load()->model('setting');
  8. $dos = array('display', 'add', 'delete');
  9. $do = in_array($_GPC['do'], $dos)? $do : 'display';
  10. $_W['page']['title'] = '站点管理 - 设置 - 敏感词过滤';
  11. $words_list = setting_load('sensitive_words');
  12. $words_list = !empty($words_list['sensitive_words']) ? $words_list['sensitive_words'] : array();
  13. if ($do == 'display') {
  14. $keyword = trim($_GPC['keyword']);
  15. $lists = $words_list;
  16. if (!empty($keyword)) {
  17. $lists = array();
  18. foreach ($words_list as $word) {
  19. if (strexists($word, $keyword)) {
  20. $lists[] = $word;
  21. }
  22. }
  23. }
  24. }
  25. if ($do == 'add') {
  26. $add_word = trim($_GPC['word']);
  27. if (empty($add_word)) {
  28. iajax(-1, '敏感词不能为空', url('system/sensitiveword'));
  29. }
  30. $add_word_array = explode("\n", $add_word);
  31. $words_list = array_merge($words_list, $add_word_array);
  32. $word_add = setting_save(array_unique($words_list), 'sensitive_words');
  33. if (is_error($words_add)) {
  34. iajax(-1, '添加失败', url('system/sensitiveword'));
  35. }
  36. iajax(0, '添加成功', url('system/sensitiveword'));
  37. }
  38. if ($do == 'delete') {
  39. $del_word = trim($_GPC['word']);
  40. if (empty($del_word)) {
  41. iajax(-1, '不能为空');
  42. }
  43. $del_word_index = array_search($del_word, $words_list);
  44. if ($del_word_index === false) {
  45. iajax(-1, '敏感词不存在');
  46. }
  47. unset($words_list[$del_word_index]);
  48. $update = setting_save($words_list, 'sensitive_words');
  49. iajax(0, '删除成功', url('system/sensitiveword'));
  50. }
  51. template('system/sensitive-word');