-
Notifications
You must be signed in to change notification settings - Fork 0
/
regexps.php
117 lines (98 loc) · 3.57 KB
/
regexps.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
<?php
# ------------------------------------------------
# License and copyright:
# See license.txt for license information.
# ------------------------------------------------
include('config.php');
# ------------------------------------------------
function regexp_exists($regexp_id) {
global $DB_LinkID;
# Bounds check
if (isEmpty($regexp_id)) { return FALSE; }
if ($regexp_id == "0") { return FALSE; }
if (!(is_numeric($regexp_id))) { return FALSE; }
# Check for it's existance
$query = "SELECT * FROM InfResp_BounceRegs WHERE BounceRegexpID = '$regexp_id'";
$result = mysql_query($query, $DB_LinkID) or die("Invalid query: " . mysql_error());
if (mysql_num_rows($result) > 0) {
return TRUE;
}
else {
return FALSE;
}
}
# ------------------------------------------------
# Get the action var
$action = strtolower(MakeSafe($_REQUEST['action']));
# Not logged in?
if (!($Is_Auth = User_Auth($X_login, $X_pass))) {
admin_redirect();
}
# Top template
include('templates/open.page.php');
# Cpanel top
$help_section = "regexps";
include('templates/controlpanel.php');
# Set address
$address = MakeSafe($_REQUEST['address']);
# Process actions
if ($action == "add") {
$regexp = MakeSafe($_REQUEST['regx']);
$query = "SELECT * FROM InfResp_BounceRegs WHERE RegX = '$regexp'";
$result = mysql_query($query) or die("Invalid query: " . mysql_error());
if (mysql_num_rows($result) > 0) {
# Print msg
print "<p class=\"big_header\">That Regexp Already Exists!</p>\n";
}
else {
$query = "INSERT INTO InfResp_BounceRegs (RegX) VALUES ('$regexp')";
$result = mysql_query($query) OR die("Invalid query: " . mysql_error());
$regx_id = mysql_insert_id();
# Print msg
print "<p class=\"big_header\">Regexp Added!</p>\n";
}
}
elseif ($action == "remove") {
$regexp_id = MakeSafe($_REQUEST['regx']);
if (regexp_exists($regexp_id)) {
# Delete from the regexp table
$query = "DELETE FROM InfResp_BounceRegs WHERE BounceRegexpID = '$regexp_id'";
$result = mysql_query($query) OR die("Invalid query: " . mysql_error());
# Print msg
print "<p class=\"big_header\">Bouncer Regexp Deleted!</p>\n";
}
else {
# Print msg
print "<p class=\"big_header\">That Regexp Wasn't Found!</p>\n";
}
}
print "<p class=\"big_header\">- Bouncer Regexps -</p>\n";
$query = "SELECT * FROM InfResp_BounceRegs";
$DB_result = mysql_query($query) or die("Invalid query: " . mysql_error());
if (mysql_num_rows($DB_result) > 0) {
# Remove regexp box
print "<center>\n";
print "<FORM action=\"regexps.php\" method=POST> \n";
print "<select name=\"regx\" size=\"10\">\n";
while ($result = mysql_fetch_assoc($DB_result)) {
print "<option value=\"" . $result['BounceRegexpID'] . "\">" . $result['RegX'] . "</option>\n";
}
print "</select>";
print "<br />\n";
print "<input type=\"hidden\" name=\"action\" value=\"remove\"> \n";
print "<input type=\"submit\" name=\"admin\" value=\"Remove Regexp\" alt=\"Remove Regexp\"> \n";
print "</FORM> \n";
print "<br /></center>\n";
}
else {
print "<br /><strong>No Regexps Found!</strong><br /><br />\n";
}
# Template for "add new"
include('templates/add_new.regexps.php');
# Template for "Back to admin"
include('templates/admin_button.regexps.php');
# Template bottom
copyright();
include('templates/close.page.php');
DB_disconnect();
?>