badword.php 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. <?php
  2. /*
  3. [UCenter] (C)2001-2099 Comsenz Inc.
  4. This is NOT a freeware, use is subject to license terms
  5. $Id: badword.php 1139 2012-05-08 09:02:11Z liulanbo $
  6. */
  7. !defined('IN_UC') && exit('Access Denied');
  8. class control extends adminbase {
  9. function __construct() {
  10. $this->control();
  11. }
  12. function control() {
  13. parent::__construct();
  14. $this->check_priv();
  15. if(!$this->user['isfounder'] && !$this->user['allowadminbadword']) {
  16. $this->message('no_permission_for_this_module');
  17. }
  18. $this->load('badword');
  19. }
  20. function onls() {
  21. $page = getgpc('page');
  22. $find = getgpc('find', 'P');
  23. $replacement = getgpc('replacement', 'P');
  24. $replacementnew = getgpc('replacementnew', 'P');
  25. $findnew = getgpc('findnew', 'P');
  26. $delete = getgpc('delete', 'P');
  27. if($find) {
  28. foreach($find as $id => $arr) {
  29. $_ENV['badword']->update_badword($find[$id], $replacement[$id], $id);
  30. }
  31. }
  32. $status = 0;
  33. if($findnew) {
  34. $_ENV['badword']->add_badword($findnew, $replacementnew, $this->user['username']);
  35. $status = 1;
  36. $this->writelog('badword_add', 'findnew='.dhtmlspecialchars($findnew).'&replacementnew='.dhtmlspecialchars($replacementnew));
  37. }
  38. if(@$delete) {
  39. $_ENV['badword']->delete_badword($delete);
  40. $status = 2;
  41. $this->writelog('badword_delete', "delete=".implode(',', $delete));
  42. }
  43. if(getgpc('multisubmit', 'P')) {
  44. $badwords = getgpc('badwords', 'P');
  45. $type = getgpc('type', 'P');
  46. if($type == 0) {
  47. $_ENV['badword']->truncate_badword();
  48. $type = 1;
  49. }
  50. $arr = explode("\n", str_replace(array("\r", "\n\n"), array("\r", "\n"), $badwords));
  51. foreach($arr as $k => $v) {
  52. $arr2 = explode("=", $v);
  53. $_ENV['badword']->add_badword($arr2[0], $arr2[1], $this->user['username'], $type);
  54. }
  55. }
  56. if($status > 0) {
  57. $notedata = $_ENV['badword']->get_list($page, 1000000, 1000000);
  58. $this->load('note');
  59. $_ENV['note']->add('updatebadwords', '', $this->serialize($notedata, 1));
  60. $_ENV['note']->send();
  61. $this->load('cache');
  62. $_ENV['cache']->updatedata('badwords');
  63. }
  64. $num = $_ENV['badword']->get_total_num();
  65. $badwordlist = $_ENV['badword']->get_list($page, UC_PPP, $num);
  66. $multipage = $this->page($num, UC_PPP, $page, 'admin.php?m=badword&a=ls');
  67. $this->view->assign('status', $status);
  68. $this->view->assign('badwordlist', $badwordlist);
  69. $this->view->assign('multipage', $multipage);
  70. $this->view->display('admin_badword');
  71. }
  72. function onexport() {
  73. $data = $_ENV['badword']->get_list(1, 1000000, 1000000);
  74. $s = '';
  75. if($data) {
  76. foreach($data as $v) {
  77. $s .= $v['find'].'='.$v['replacement']."\r\n";
  78. }
  79. }
  80. @header('Content-Disposition: inline; filename=CensorWords.txt');
  81. @header("Content-Type: text/plain");
  82. echo $s;
  83. }
  84. }
  85. ?>