PageRenderTime 52ms CodeModel.GetById 25ms RepoModel.GetById 0ms app.codeStats 0ms

/mods/replace/settings.php

https://bitbucket.org/webop/webop-forum
PHP | 107 lines | 75 code | 32 blank | 0 comment | 20 complexity | cb5af126dafd3c9a85f99137dd00af00 MD5 | raw file
Possible License(s): LGPL-2.1
  1. <?php
  2. if(!defined("PHORUM_ADMIN")) return;
  3. $error="";
  4. $curr="NEW";
  5. $match_types = array("string", "PCRE");
  6. if(count($_POST) && $_POST["search"]!="" && $_POST["replace"]!=""){
  7. $item = array("search"=>$_POST["search"], "replace"=>$_POST["replace"], "pcre"=>$_POST["pcre"]);
  8. if($_POST["curr"]!="NEW"){
  9. $PHORUM["mod_replace"][$_POST["curr"]]=$item;
  10. } else {
  11. $PHORUM["mod_replace"][]=$item;
  12. }
  13. if(empty($error)){
  14. if(!phorum_db_update_settings(array("mod_replace"=>$PHORUM["mod_replace"]))){
  15. $error="Database error while updating settings.";
  16. } else {
  17. echo "Replacement Updated<br />";
  18. }
  19. }
  20. }
  21. if(isset($_GET["curr"])){
  22. if(isset($_GET["delete"])){
  23. unset($PHORUM["mod_replace"][$_GET["curr"]]);
  24. phorum_db_update_settings(array("mod_replace"=>$PHORUM["mod_replace"]));
  25. echo "Replacement Deleted<br />";
  26. } else {
  27. $curr = $_GET["curr"];
  28. }
  29. }
  30. if($curr!="NEW"){
  31. extract($PHORUM["mod_replace"][$curr]);
  32. $title="Edit Replacement";
  33. $submit="Update";
  34. } else {
  35. settype($string, "string");
  36. settype($type, "int");
  37. settype($pcre, "int");
  38. $title="Add A Replacement";
  39. $submit="Add";
  40. }
  41. include_once "./include/admin/PhorumInputForm.php";
  42. $frm =& new PhorumInputForm ("", "post", $submit);
  43. $frm->hidden("module", "modsettings");
  44. $frm->hidden("mod", "replace");
  45. $frm->hidden("curr", "$curr");
  46. $frm->addbreak($title);
  47. $frm->addrow("String To Match", $frm->text_box("search", $search, 50));
  48. $frm->addrow("Replacement", $frm->text_box("replace", $replace, 50));
  49. $frm->addrow("Compare As", $frm->select_tag("pcre", $match_types, $pcre));
  50. $frm->show();
  51. echo "If using PCRE for comparison, \"Sting To Match\" should be a valid PCRE expression. See <a href=\"http://php.net/pcre\">the PHP manual</a> for more information.";
  52. if($curr=="NEW"){
  53. echo "<hr class=\"PhorumAdminHR\" />";
  54. if(count($PHORUM["mod_replace"])){
  55. echo "<table border=\"0\" cellspacing=\"1\" cellpadding=\"0\" class=\"PhorumAdminTable\" width=\"100%\">\n";
  56. echo "<tr>\n";
  57. echo " <td class=\"PhorumAdminTableHead\">Search</td>\n";
  58. echo " <td class=\"PhorumAdminTableHead\">Replace</td>\n";
  59. echo " <td class=\"PhorumAdminTableHead\">Compare Method</td>\n";
  60. echo " <td class=\"PhorumAdminTableHead\">&nbsp;</td>\n";
  61. echo "</tr>\n";
  62. foreach($PHORUM["mod_replace"] as $key => $item){
  63. echo "<tr>\n";
  64. echo " <td class=\"PhorumAdminTableRow\">".htmlspecialchars($item["search"])."</td>\n";
  65. echo " <td class=\"PhorumAdminTableRow\">".htmlspecialchars($item["replace"])."</td>\n";
  66. echo " <td class=\"PhorumAdminTableRow\">".$match_types[$item["pcre"]]."</td>\n";
  67. echo " <td class=\"PhorumAdminTableRow\"><a href=\"$_SERVER[PHP_SELF]?module=modsettings&mod=replace&curr=$key&?edit=1\">Edit</a>&nbsp;&#149;&nbsp;<a href=\"$_SERVER[PHP_SELF]?module=modsettings&mod=replace&curr=$key&delete=1\">Delete</a></td>\n";
  68. echo "</tr>\n";
  69. }
  70. echo "</table>\n";
  71. } else {
  72. echo "No replacements in list currently.";
  73. }
  74. }
  75. ?>