108 lines
3.7 KiB
Plaintext
108 lines
3.7 KiB
Plaintext
<?
|
|
|
|
$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=\"2\" CELLSPACING=\"2\">\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" : "") .">Bans 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);
|
|
}
|
|
}
|
|
|
|
?>
|