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

/campsite/src/include/phorum/include/admin/badwords.php

https://github.com/joechrysler/Campsite
PHP | 131 lines | 83 code | 29 blank | 19 comment | 21 complexity | 33e5ba6af530b22583d0cb60d0511679 MD5 | raw file
Possible License(s): BSD-3-Clause, AGPL-1.0, LGPL-2.1, Apache-2.0
  1. <?php
  2. ////////////////////////////////////////////////////////////////////////////////
  3. // //
  4. // Copyright (C) 2006 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. print "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['forumid'] ,$_POST['curr']);
  36. } else {
  37. $ret=phorum_db_mod_banlists(PHORUM_BAD_WORDS ,0 ,$_POST["string"] ,$_POST['forumid'] ,0);
  38. }
  39. if(!$ret){
  40. $error="Database error while updating badwords.";
  41. } else {
  42. echo "Bad Word Added<br />";
  43. }
  44. }
  45. if(isset($_GET["curr"])){
  46. if(isset($_GET["delete"])){
  47. phorum_db_del_banitem($_GET['curr']);
  48. echo "Ban Item Deleted<br />";
  49. } else {
  50. $curr = $_GET["curr"];
  51. }
  52. }
  53. if($curr!="NEW"){
  54. extract(phorum_db_get_banitem($curr));
  55. $title="Edit Bad Word Item";
  56. $submit="Update";
  57. } else {
  58. settype($string, "string");
  59. settype($type, "int");
  60. settype($pcre, "int");
  61. settype($forumid,"int");
  62. $title="Add A Bad Word";
  63. $submit="Add";
  64. }
  65. settype($string, "string");
  66. settype($type, "int");
  67. settype($pcre, "int");
  68. if($error){
  69. phorum_admin_error($error);
  70. }
  71. // load bad-words-list
  72. $banlists=phorum_db_get_banlists();
  73. $bad_words=$banlists[PHORUM_BAD_WORDS];
  74. include_once "./include/admin/PhorumInputForm.php";
  75. $frm = new PhorumInputForm ("", "post", $submit);
  76. $frm->hidden("module", "badwords");
  77. $frm->hidden("curr", "$curr");
  78. $frm->addbreak($title);
  79. $frm->addrow("Bad Word", $frm->text_box("string", $string, 50));
  80. $frm->addrow("Valid for Forum", $frm->select_tag("forumid", $forum_list, $forumid));
  81. $frm->show();
  82. echo "<hr class=\"PhorumAdminHR\" />";
  83. if(count($bad_words)){
  84. echo "<table border=\"0\" cellspacing=\"1\" cellpadding=\"0\" class=\"PhorumAdminTable\" width=\"100%\">\n";
  85. echo "<tr>\n";
  86. echo " <td class=\"PhorumAdminTableHead\">Word</td>\n";
  87. echo " <td class=\"PhorumAdminTableHead\">Valid for Forum</td>\n";
  88. echo " <td class=\"PhorumAdminTableHead\">&nbsp;</td>\n";
  89. echo "</tr>\n";
  90. foreach($bad_words as $key => $item){
  91. $ta_class = "PhorumAdminTableRow".($ta_class == "PhorumAdminTableRow" ? "Alt" : "");
  92. echo "<tr>\n";
  93. echo " <td class=\"".$ta_class."\">".htmlspecialchars($item[string])."</td>\n";
  94. echo " <td class=\"".$ta_class."\">".$forum_list[$item["forum_id"]]."</td>\n";
  95. echo " <td class=\"".$ta_class."\"><a href=\"$_SERVER[PHP_SELF]?module=badwords&curr=$key&edit=1\">Edit</a>&nbsp;&#149;&nbsp;<a href=\"$_SERVER[PHP_SELF]?module=badwords&curr=$key&delete=1\">Delete</a></td>\n";
  96. echo "</tr>\n";
  97. }
  98. echo "</table>\n";
  99. } else {
  100. echo "No bad words in list currently.";
  101. }
  102. ?>