Subversion Repositories Applications.papyrus

Rev

Rev 1372 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
831 florian 1
<?php
2
 
3
////////////////////////////////////////////////////////////////////////////////
4
//                                                                            //
5
//   Copyright (C) 2006  Phorum Development Team                              //
6
//   http://www.phorum.org                                                    //
7
//                                                                            //
8
//   This program is free software. You can redistribute it and/or modify     //
9
//   it under the terms of either the current Phorum License (viewable at     //
10
//   phorum.org) or the Phorum License that was distributed with this file    //
11
//                                                                            //
12
//   This program is distributed in the hope that it will be useful,          //
13
//   but WITHOUT ANY WARRANTY, without even the implied warranty of           //
14
//   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.                     //
15
//                                                                            //
16
//   You should have received a copy of the Phorum License                    //
17
//   along with this program.                                                 //
18
////////////////////////////////////////////////////////////////////////////////
19
 
20
    if(!defined("PHORUM_ADMIN")) return;
21
 
22
    $error="";
23
    $curr="NEW";
24
 
25
    $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)");
26
 
27
    $match_types = array("string", "PCRE");
28
 
29
    $forum_list=phorum_get_forum_info(2);
30
    $forum_list[0]="GLOBAL";
31
 
32
    if(count($_POST) && $_POST["string"]!=""){
33
 
34
        if($_POST["curr"]!="NEW"){
35
            $ret=phorum_db_mod_banlists($_POST['type'],$_POST['pcre'],$_POST['string'],$_POST['forumid'],$_POST["curr"]);
36
        } else {
37
            $ret=phorum_db_mod_banlists($_POST['type'],$_POST['pcre'],$_POST['string'],$_POST['forumid'],0);
38
        }
39
 
40
        if(!$ret){
41
            $error="Database error while updating settings.";
42
        } else {
43
            echo "Ban Item Updated<br />";
44
        }
45
    }
46
 
47
    if(isset($_GET["curr"])){
48
        if(isset($_GET["delete"])){
49
            phorum_db_del_banitem($_GET['curr']);
50
            echo "Ban Item Deleted<br />";
51
        } else {
52
            $curr = $_GET["curr"];
53
        }
54
    }
55
 
56
    if($curr!="NEW"){
57
        extract(phorum_db_get_banitem($curr));
58
        $title="Edit Ban Item";
59
        $submit="Update";
60
    } else {
61
        settype($string, "string");
62
        settype($type, "int");
63
        settype($pcre, "int");
64
        settype($forumid,"int");
65
        $title="Add A Ban Item";
66
        $submit="Add";
67
    }
68
 
69
    if($error){
70
        phorum_admin_error($error);
71
    }
72
 
73
    include_once "./include/admin/PhorumInputForm.php";
74
 
75
 
76
    $frm =& new PhorumInputForm ("", "post", $submit);
77
 
78
    $frm->hidden("module", "banlist");
79
 
80
    $frm->hidden("curr", "$curr");
81
 
82
    $frm->addbreak($title);
83
 
84
    $frm->addrow("String To Match", $frm->text_box("string", $string, 50));
85
 
86
    $frm->addrow("Field To Match", $frm->select_tag("type", $ban_types, $type));
87
 
88
    $frm->addrow("Compare As", $frm->select_tag("pcre", $match_types, $pcre));
89
 
90
    $frm->addrow("Valid for Forum", $frm->select_tag("forumid", $forum_list, $forumid));
91
 
92
    $frm->show();
93
 
94
    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.";
95
 
96
    if($curr=="NEW"){
97
 
98
        $PHORUM['banlists']=phorum_db_get_banlists(true);
99
        unset($PHORUM['banlists'][PHORUM_BAD_WORDS]);
100
 
101
        echo "<hr class=\"PhorumAdminHR\" />";
102
 
103
        if(count($PHORUM['banlists'])){
104
 
105
            echo "<table border=\"0\" cellspacing=\"1\" cellpadding=\"0\" class=\"PhorumAdminTable\" width=\"100%\">\n";
106
            echo "<tr>\n";
107
            echo "    <td class=\"PhorumAdminTableHead\">String</td>\n";
108
            echo "    <td class=\"PhorumAdminTableHead\">Field</td>\n";
109
            echo "    <td class=\"PhorumAdminTableHead\">Compare Method</td>\n";
110
            echo "    <td class=\"PhorumAdminTableHead\">Valid for Forum</td>\n";
111
            echo "    <td class=\"PhorumAdminTableHead\">&nbsp;</td>\n";
112
            echo "</tr>\n";
113
 
114
 
115
 
116
            foreach($PHORUM["banlists"] as $type => $content){
117
                $t_last_string = '';
118
                foreach($content as $key => $item){
119
                    $ta_class = "PhorumAdminTableRow".($ta_class == "PhorumAdminTableRow" ? "Alt" : "");
120
                    echo "<tr>\n";
121
                    echo "    <td class=\"".$ta_class."\"".($item["string"] == $t_last_string ? " style=\"color:red;\"" : "").">".htmlspecialchars($item['string'])."</td>\n";
122
                    echo "    <td class=\"".$ta_class."\">".$ban_types[$type]."</td>\n";
123
                    echo "    <td class=\"".$ta_class."\">".$match_types[$item["pcre"]]."</td>\n";
124
                    echo "    <td class=\"".$ta_class."\">".$forum_list[$item["forum_id"]]."</td>\n";
125
                    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";
126
                    echo "</tr>\n";
127
                    $t_last_string = $item["string"];
128
                }
129
            }
130
 
131
            echo "</table>\n";
132
 
133
        } else {
134
 
135
            echo "No bans in list currently.";
136
 
137
        }
138
 
139
    }
140
 
141
?>