summaryrefslogtreecommitdiff
path: root/modules/ban.module
diff options
context:
space:
mode:
authorDries Buytaert <dries@buytaert.net>2000-12-14 14:13:37 +0000
committerDries Buytaert <dries@buytaert.net>2000-12-14 14:13:37 +0000
commit7a45d84a9f9458387bf4f57ac5a520f31c1604ab (patch)
tree9ba9bab01e60d7fdba39ab18cef70002dbe0fb4f /modules/ban.module
parentc514e3cd7ec377e8c50e06320db3560dcf01ccb6 (diff)
downloadbrdo-7a45d84a9f9458387bf4f57ac5a520f31c1604ab.tar.gz
brdo-7a45d84a9f9458387bf4f57ac5a520f31c1604ab.tar.bz2
- added a whole bunch of NEW modules
Diffstat (limited to 'modules/ban.module')
-rw-r--r--modules/ban.module107
1 files changed, 107 insertions, 0 deletions
diff --git a/modules/ban.module b/modules/ban.module
new file mode 100644
index 000000000..df7bb5aef
--- /dev/null
+++ b/modules/ban.module
@@ -0,0 +1,107 @@
+<?
+
+$module = array("admin" => "ban_admin");
+
+include "includes/ban.inc";
+
+function ban_check($mask, $category) {
+ $ban = ban_match($mask, $category);
+ $output .= "". ($ban ? "Matched ban '<B>$ban->mask</B>' with reason: <I>$ban->reason</I>.<P>\n" : "No matching bans for '$mask'.<P>\n") ."";
+ print $output;
+}
+
+function ban_new($mask, $category, $reason) {
+ ban_add($mask, $category, $reason, &$message);
+ $output .= "$message\n";
+ print $output;
+}
+
+function ban_display($category = "") {
+ global $type2index;
+
+ // initialize variable:
+ $category = $category ? $category : 1;
+
+ // Perform query:
+ $result = db_query("SELECT * FROM bans WHERE type = $category ORDER BY mask");
+
+ // Generate output:
+ $output .= "<TABLE BORDER=\"1\" CELLPADDING=\"3\" CELLSPACING=\"0\">\n";
+ $output .= " <TR>\n";
+ $output .= " <TH COLSPAN=\"3\">\n";
+ $output .= " <FORM ACTION=\"admin.php?mod=ban\" METHOD=\"post\">\n";
+ $output .= " <SELECT NAME=\"category\">\n";
+ for (reset($type2index); $cur = current($type2index); next($type2index)) {
+ $output .= " <OPTION VALUE=\"$cur\"". ($cur == $category ? " SELECTED" : "") .">Sort by ". key($type2index) ."</OPTION>\n";
+ }
+ $output .= " </SELECT>\n";
+ $output .= " <INPUT TYPE=\"submit\" NAME=\"op\" VALUE=\"Update\">\n";
+ $output .= " </FORM>\n";
+ $output .= " </TH>\n";
+ $output .= " </TR>\n";
+ $output .= " <TR>\n";
+ $output .= " <TH>mask</TH>\n";
+ $output .= " <TH>reason</TH>\n";
+ $output .= " <TH>operations</TH>\n";
+ $output .= " </TR>\n";
+
+ while ($ban = db_fetch_object($result)) {
+ $output .= " <TR><TD>$ban->mask</TD><TD>$ban->reason</TD><TD ALIGN=\"center\"><A HREF=\"admin.php?mod=ban&op=delete&category=$category&id=$ban->id\">delete</A></TD></TR>\n";
+ }
+
+ $output .= " <TR><TD COLSPAN=\"3\"><SMALL>%: matches any number of characters, even zero characters.<BR>_: matches exactly one character.</SMALL></TD></TR>\n";
+ $output .= "</TABLE>\n";
+ $output .= "<BR><HR>\n";
+
+ $output .= "<H3>Add new ban:</H3>\n";
+ $output .= "<FORM ACTION=\"admin.php?mod=ban\" METHOD=\"post\">\n";
+ $output .= "<B>Banmask:</B><BR>\n";
+ $output .= "<INPUT TYPE=\"text\" NAME=\"mask\" SIZE=\"35\"><P>\n";
+ $output .= "<B>Type:</B><BR>\n";
+ $output .= "<SELECT NAME=\"category\"\">\n";
+ for (reset($type2index); $cur = current($type2index); next($type2index)) {
+ $output .= "<OPTION VALUE=\"$cur\"". ($cur == $category ? " SELECTED" : "") .">". key($type2index) ."</OPTION>\n";
+ }
+ $output .= "</SELECT><P>\n";
+ $output .= "<B>Reason:</B><BR>\n";
+ $output .= "<TEXTAREA NAME=\"reason\" COLS=\"50\" ROWS=\"5\"></TEXTAREA><P>\n";
+ $output .= "<INPUT TYPE=\"submit\" NAME=\"op\" VALUE=\"Add ban\"><BR>\n";
+ $output .= "</FORM>\n";
+ $output .= "<BR><HR>\n";
+
+ $output .= "<H3>Ban check:</H3>\n";
+ $output .= "<FORM ACTION=\"admin.php?mod=ban\" METHOD=\"post\">\n";
+ $output .= "<B>Banmask:</B><BR>\n";
+ $output .= "<INPUT TYPE=\"text\" NAME=\"mask\" SIZE=\"35\"><P>\n";
+ $output .= "<B>Type:</B><BR>\n";
+ $output .= "<SELECT NAME=\"category\"\">\n";
+ for (reset($type2index); $cur = current($type2index); next($type2index)) {
+ $output .= "<OPTION VALUE=\"$cur\"". ($cur == $category ? " SELECTED" : "") .">". key($type2index) ."</OPTION>\n";
+ }
+ $output .= "</SELECT><P>\n";
+ $output .= "<INPUT TYPE=\"submit\" NAME=\"op\" VALUE=\"Check ban\"><BR>\n";
+ $output .= "</FORM>\n";
+
+ print $output;
+}
+
+function ban_admin() {
+ global $op, $id, $mask, $category, $reason;
+
+ switch ($op) {
+ case "Add ban":
+ ban_new($mask, $category, $reason);
+ ban_display($category);
+ break;
+ case "Check ban":
+ ban_check($mask, $category);
+ ban_display($category);
+ break;
+ case "delete":
+ ban_delete($id);
+ default:
+ ban_display($category);
+ }
+}
+
+?>