PageRenderTime 48ms CodeModel.GetById 14ms RepoModel.GetById 0ms app.codeStats 0ms

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

https://github.com/joechrysler/Campsite
PHP | 141 lines | 87 code | 38 blank | 16 comment | 23 complexity | bd59f34c55f8b06734ab6cb8cfb8c5b9 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. $ban_types = array(PHORUM_BAD_IPS=>"IP Address/Hostname", PHORUM_BAD_NAMES=>"Name/User Name", PHORUM_BAD_EMAILS=>"Email Address", PHORUM_BAD_USERID=>"User-Id (registered User)", PHORUM_BAD_SPAM_WORDS=>"Illegal Words (SPAM)");
  22. $match_types = array("string", "PCRE");
  23. $forum_list=phorum_get_forum_info(2);
  24. $forum_list[0]="GLOBAL";
  25. if(count($_POST) && $_POST["string"]!=""){
  26. if($_POST["curr"]!="NEW"){
  27. $ret=phorum_db_mod_banlists($_POST['type'],$_POST['pcre'],$_POST['string'],$_POST['forumid'],$_POST["curr"]);
  28. } else {
  29. $ret=phorum_db_mod_banlists($_POST['type'],$_POST['pcre'],$_POST['string'],$_POST['forumid'],0);
  30. }
  31. if(!$ret){
  32. $error="Database error while updating settings.";
  33. } else {
  34. echo "Ban Item Updated<br />";
  35. }
  36. }
  37. if(isset($_GET["curr"])){
  38. if(isset($_GET["delete"])){
  39. phorum_db_del_banitem($_GET['curr']);
  40. echo "Ban Item Deleted<br />";
  41. } else {
  42. $curr = $_GET["curr"];
  43. }
  44. }
  45. if($curr!="NEW"){
  46. extract(phorum_db_get_banitem($curr));
  47. $title="Edit Ban Item";
  48. $submit="Update";
  49. } else {
  50. settype($string, "string");
  51. settype($type, "int");
  52. settype($pcre, "int");
  53. settype($forumid,"int");
  54. $title="Add A Ban Item";
  55. $submit="Add";
  56. }
  57. if($error){
  58. phorum_admin_error($error);
  59. }
  60. include_once "./include/admin/PhorumInputForm.php";
  61. $frm = new PhorumInputForm ("", "post", $submit);
  62. $frm->hidden("module", "banlist");
  63. $frm->hidden("curr", "$curr");
  64. $frm->addbreak($title);
  65. $frm->addrow("String To Match", $frm->text_box("string", $string, 50));
  66. $frm->addrow("Field To Match", $frm->select_tag("type", $ban_types, $type));
  67. $frm->addrow("Compare As", $frm->select_tag("pcre", $match_types, $pcre));
  68. $frm->addrow("Valid for Forum", $frm->select_tag("forumid", $forum_list, $forumid));
  69. $frm->show();
  70. echo "If using PCRE for comparison, \"String To Match\" should be a valid PCRE expression. See <a href=\"http://php.net/pcre\" target=\"_blank\">the PHP manual</a> for more information.";
  71. if($curr=="NEW"){
  72. $PHORUM['banlists']=phorum_db_get_banlists(true);
  73. unset($PHORUM['banlists'][PHORUM_BAD_WORDS]);
  74. echo "<hr class=\"PhorumAdminHR\" />";
  75. if(count($PHORUM['banlists'])){
  76. echo "<table border=\"0\" cellspacing=\"1\" cellpadding=\"0\" class=\"PhorumAdminTable\" width=\"100%\">\n";
  77. echo "<tr>\n";
  78. echo " <td class=\"PhorumAdminTableHead\">String</td>\n";
  79. echo " <td class=\"PhorumAdminTableHead\">Field</td>\n";
  80. echo " <td class=\"PhorumAdminTableHead\">Compare Method</td>\n";
  81. echo " <td class=\"PhorumAdminTableHead\">Valid for Forum</td>\n";
  82. echo " <td class=\"PhorumAdminTableHead\">&nbsp;</td>\n";
  83. echo "</tr>\n";
  84. foreach($PHORUM["banlists"] as $type => $content){
  85. $t_last_string = '';
  86. foreach($content as $key => $item){
  87. $ta_class = "PhorumAdminTableRow".($ta_class == "PhorumAdminTableRow" ? "Alt" : "");
  88. echo "<tr>\n";
  89. echo " <td class=\"".$ta_class."\"".($item["string"] == $t_last_string ? " style=\"color:red;\"" : "").">".htmlspecialchars($item['string'])."</td>\n";
  90. echo " <td class=\"".$ta_class."\">".$ban_types[$type]."</td>\n";
  91. echo " <td class=\"".$ta_class."\">".$match_types[$item["pcre"]]."</td>\n";
  92. echo " <td class=\"".$ta_class."\">".$forum_list[$item["forum_id"]]."</td>\n";
  93. echo " <td class=\"".$ta_class."\"><a href=\"$_SERVER[PHP_SELF]?module=banlist&curr=$key&edit=1\">Edit</a>&nbsp;&#149;&nbsp;<a href=\"$_SERVER[PHP_SELF]?module=banlist&curr=$key&delete=1\">Delete</a></td>\n";
  94. echo "</tr>\n";
  95. $t_last_string = $item["string"];
  96. }
  97. }
  98. echo "</table>\n";
  99. } else {
  100. echo "No bans in list currently.";
  101. }
  102. }
  103. ?>