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

/include/admin/badwords.php

https://bitbucket.org/webop/webop-forum
PHP | 187 lines | 129 code | 39 blank | 19 comment | 30 complexity | 689fc2c2c21efa93191efc914019c6f7 MD5 | raw file
Possible License(s): LGPL-2.1
  1. <?php
  2. ////////////////////////////////////////////////////////////////////////////////
  3. // //
  4. // Copyright (C) 2010 Phorum Development Team //
  5. // http://www.phorum.org //
  6. // //
  7. // This program is free software. You can redistribute it and/or modify //
  8. // it under the terms of either the current Phorum License (viewable at //
  9. // phorum.org) or the Phorum License that was distributed with this file //
  10. // //
  11. // This program is distributed in the hope that it will be useful, //
  12. // but WITHOUT ANY WARRANTY, without even the implied warranty of //
  13. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. //
  14. // //
  15. // You should have received a copy of the Phorum License //
  16. // along with this program. //
  17. ////////////////////////////////////////////////////////////////////////////////
  18. if(!defined("PHORUM_ADMIN")) return;
  19. $error="";
  20. $curr="NEW";
  21. // retrieving the forum-info
  22. $forum_list=phorum_get_forum_info(2);
  23. $forum_list[0]="GLOBAL";
  24. // conversion of old data if existing
  25. if(isset($PHORUM["bad_words"]) && count($PHORUM['bad_words'])) {
  26. echo "upgrading badwords<br />";
  27. foreach($PHORUM['bad_words'] as $key => $data) {
  28. phorum_db_mod_banlists(PHORUM_BAD_WORDS ,0 ,$data ,0 ,0);
  29. unset($PHORUM["bad_words"][$key]);
  30. }
  31. phorum_db_update_settings(array("bad_words"=>$PHORUM["bad_words"]));
  32. }
  33. if(count($_POST) && $_POST["string"]!=""){
  34. if($_POST["curr"]!="NEW"){
  35. $ret=phorum_db_mod_banlists(PHORUM_BAD_WORDS ,0 ,$_POST["string"] ,$_POST['forum_id'] , $_POST['comments'], $_POST['curr']);
  36. } else {
  37. $ret=phorum_db_mod_banlists(PHORUM_BAD_WORDS ,0 ,$_POST["string"] ,$_POST['forum_id'] , $_POST['comments'], 0);
  38. }
  39. if(!$ret){
  40. $error="Database error while updating badwords.";
  41. } else {
  42. if ($_POST["curr"]!="NEW"){
  43. phorum_admin_okmsg("Bad Word Updated");
  44. } else {
  45. phorum_admin_okmsg("Bad Word Added");
  46. }
  47. }
  48. }
  49. if(isset($_POST["curr"]) && isset($_POST["delete"]) && $_POST["confirm"]=="Yes"){
  50. phorum_db_del_banitem((int)$_POST['curr']);
  51. phorum_admin_okmsg("Bad Word Deleted");
  52. }
  53. if(isset($_GET["curr"])){
  54. $curr = $_GET["curr"];
  55. }
  56. if($curr!="NEW"){
  57. extract(phorum_db_get_banitem($curr));
  58. $title="Edit Bad Word Item";
  59. $submit="Update";
  60. } else {
  61. $title="Add A Bad Word";
  62. $submit="Add";
  63. }
  64. settype($comments, "string");
  65. settype($forum_id,"int");
  66. settype($string, "string");
  67. settype($type, "int");
  68. settype($pcre, "int");
  69. if($error){
  70. phorum_admin_error($error);
  71. }
  72. if($_GET["curr"] && $_GET["delete"]){
  73. ?>
  74. <div class="PhorumInfoMessage">
  75. Are you sure you want to delete this entry?
  76. <form action="<?php echo phorum_admin_build_url('base'); ?>" method="post">
  77. <input type="hidden" name="phorum_admin_token" value="<?php echo $PHORUM['admin_token'];?>" />
  78. <input type="hidden" name="module" value="<?php echo $module; ?>" />
  79. <input type="hidden" name="curr" value="<?php echo htmlspecialchars($_GET['curr']) ?>" />
  80. <input type="hidden" name="delete" value="1" />
  81. <input type="submit" name="confirm" value="Yes" />&nbsp;<input type="submit" name="confirm" value="No" />
  82. </form>
  83. </div>
  84. <?php
  85. } else {
  86. // load bad-words-list
  87. $banlists=phorum_db_get_banlists();
  88. $bad_words=$banlists[PHORUM_BAD_WORDS];
  89. include_once "./include/admin/PhorumInputForm.php";
  90. $frm = new PhorumInputForm ("", "post", $submit);
  91. $frm->hidden("module", "badwords");
  92. $frm->hidden("curr", "$curr");
  93. $row = $frm->addbreak($title);
  94. if ($curr == 'NEW') $frm->addmessage(
  95. "This feature can be used to mask bad words in forum messages
  96. with \"".PHORUM_BADWORD_REPLACE."\". All bad words will
  97. automatically be replaced by that string. If you want to use
  98. a different string (e.g. \"CENSORED\" or \"*****\"), then you
  99. can change the definition of the constant
  100. \"PHORUM_BADWORD_REPLACE\" in the Phorum file
  101. include/constants.php."
  102. );
  103. $row = $frm->addrow("Bad Word", $frm->text_box("string", $string, 50));
  104. $frm->addhelp($row, "Bad Word",
  105. "The word that you want to mask in forum messages.
  106. Rules that apply to the matching are:
  107. <ul>
  108. <li><b>Only the full word</b> is matched, so \"foo\" would
  109. not mask (part of) \"foobar\";</li>
  110. <li>The match is <b>case insensitive</b>, so \"foo\" would also
  111. mask \"FoO\".</li>
  112. </ul>");
  113. $frm->addrow("Valid for Forum", $frm->select_tag("forum_id", $forum_list, $forum_id));
  114. $row = $frm->addrow(
  115. 'Comments',
  116. $frm->textarea('comments', $comments, 50, 7)
  117. );
  118. $frm->addhelp($row, "Comments",
  119. "This field can be used to add some comments to the ban (why you
  120. created it, when you did this, when the ban can be deleted, etc.)
  121. These comments will only be shown on this page and are meant as
  122. a means for the administrator to do some bookkeeping."
  123. );
  124. $frm->show();
  125. echo "<hr class=\"PhorumAdminHR\" />";
  126. if(count($bad_words)){
  127. echo "<table border=\"0\" cellspacing=\"1\" cellpadding=\"0\" class=\"PhorumAdminTable\" width=\"100%\">\n";
  128. echo "<tr>\n";
  129. echo " <td class=\"PhorumAdminTableHead\">Word</td>\n";
  130. echo " <td class=\"PhorumAdminTableHead\">Valid for Forum</td>\n";
  131. echo " <td class=\"PhorumAdminTableHead\">&nbsp;</td>\n";
  132. echo "</tr>\n";
  133. foreach($bad_words as $key => $item){
  134. $edit_url = phorum_admin_build_url(array('module=badwords','edit=1',"curr=$key"));
  135. $delete_url = phorum_admin_build_url(array('module=badwords','delete=1',"curr=$key"));
  136. $ta_class = "PhorumAdminTableRow".($ta_class == "PhorumAdminTableRow" ? "Alt" : "");
  137. echo "<tr>\n";
  138. echo " <td class=\"".$ta_class."\">".htmlspecialchars($item[string])."</td>\n";
  139. echo " <td class=\"".$ta_class."\">".$forum_list[$item["forum_id"]]."</td>\n";
  140. echo " <td class=\"".$ta_class."\"><a href=\"$edit_url\">Edit</a>&nbsp;&#149;&nbsp;<a href=\"$delete_url\">Delete</a></td>\n";
  141. echo "</tr>\n";
  142. }
  143. echo "</table>\n";
  144. } else {
  145. echo "No bad words in list currently.";
  146. }
  147. }
  148. ?>