-
Notifications
You must be signed in to change notification settings - Fork 4
/
functions_url.php
180 lines (141 loc) · 5.73 KB
/
functions_url.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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
<?php
include_once('connect.php');
include_once('functions_global.php');
function sanitizeString($input)
{
// Replace problematic characters with an empty string
$replacements = array("'", '"', "\\", ";", "`", "--", "#", "=", ">", "<", "&", "%", "|", "^", "~", "(", ")");
$sanitized = str_replace($replacements, "", $input);
return htmlspecialchars($sanitized, ENT_QUOTES, 'UTF-8'); // Escape HTML entities
}
if (isset($_GET['id']) && !isset($_GET['reban']) && !isset($_GET['edit'])) {
$id = filter_input(INPUT_GET, 'id', FILTER_SANITIZE_NUMBER_INT);
showEbanInfo($id);
}
if (isset($_GET['oldid']) && !isset($_GET['reban']) && !isset($_GET['edit'])) {
if (!isset($_COOKIE['steamID'])) {
die();
}
$admin = new Admin();
$admin->UpdateAdminInfo($_COOKIE['steamID']);
$id = filter_input(INPUT_GET, 'oldid', FILTER_SANITIZE_NUMBER_INT);
$Eban = new Eban();
$info = $Eban->getEbanInfoFromID($id);
if (!IsAdminLoggedIn() || (!$admin->DoesHaveFullAccess() && $info['admin_steamid'] != $admin->adminSteamID)) {
die();
}
$reason = sanitizeString($reason);
$Eban = new Eban();
if (!$Eban->UnbanByID($id, $reason)) {
die();
}
die();
}
function showEbanInfo(int $id) {
GetRowInfo($id);
}
if (isset($_GET['add']) && isset($_GET['playerName'])) {
if (!IsAdminLoggedIn()) {
die();
}
// Sanitize input
$playerName = sanitizeString(filter_input(INPUT_GET, 'playerName', FILTER_SANITIZE_STRING));
$playerSteamID = filter_input(INPUT_GET, 'playerSteamID', FILTER_SANITIZE_STRING);
$length = filter_input(INPUT_GET, 'length', FILTER_SANITIZE_NUMBER_INT);
$reason = sanitizeString(filter_input(INPUT_GET, 'reason', FILTER_SANITIZE_STRING));
$icon = "<i class='fa-solid fa-xmark'></i> ";
if (empty($playerSteamID)) {
echo "<p>$icon Player SteamID cannot be empty!</p>";
die();
}
if (!preg_match("/^STEAM_[0-5]:[01]:\d+$/", $playerSteamID)) {
echo "<p>$icon Invalid SteamID Format</p>";
die();
}
if (empty($reason)) {
echo "<p>$icon Reason cannot be empty!</p>";
die();
}
$Eban = new Eban();
if ($Eban->IsSteamIDAlreadyBanned($playerSteamID)) {
echo "<p>$icon $playerSteamID is already Ebanned!</p>";
die();
}
$Eban->addNewEban($playerName, $playerSteamID, $length, $reason);
}
if (isset($_GET['edit']) && isset($_GET['playerName'])) {
if (!isset($_COOKIE['steamID'])) {
die();
}
$id = filter_input(INPUT_GET, 'id', FILTER_SANITIZE_NUMBER_INT);
$playerName = sanitizeString(filter_input(INPUT_GET, 'playerName', FILTER_SANITIZE_STRING));
$playerSteamID = filter_input(INPUT_GET, 'playerSteamID', FILTER_SANITIZE_STRING);
$length = filter_input(INPUT_GET, 'length', FILTER_SANITIZE_NUMBER_INT);
$reason = sanitizeString(filter_input(INPUT_GET, 'reason', FILTER_SANITIZE_STRING));
$icon = "<i class='fa-solid fa-xmark'></i> ";
if (empty($playerName)) {
echo "<p>$icon Player name cannot be empty!</p>";
die();
}
if (empty($playerSteamID)) {
echo "<p>$icon Player SteamID cannot be empty!</p>";
die();
}
if (!preg_match("/^STEAM_[0-5]:[01]:\d+$/", $playerSteamID)) {
echo "<p>$icon Invalid SteamID Format</p>";
die();
}
if (empty($reason)) {
echo "<p>$icon Reason cannot be empty!</p>";
die();
}
$admin = new Admin();
$admin->UpdateAdminInfo($_COOKIE['steamID']);
if ($length === null && !$admin->DoesHaveFullAccess()) {
echo "<p>$icon You do not have permission for Permanent bans!</p>";
die();
}
if (empty($reason)) {
$reason = "NO REASON";
}
if ($length === null) {
$length = 0;
}
if ($length < 0) {
$length = 60;
}
$Eban = new Eban();
$info = $Eban->getEbanInfoFromID($id);
if (!IsAdminLoggedIn() || (!$admin->DoesHaveFullAccess() && $info['admin_steamid'] != $admin->adminSteamID)) {
die();
}
if ($playerName == $info['client_name'] && $playerSteamID == $info['client_steamid'] && $reason == $info['reason'] && $length == ($info['duration'] * 60)) {
echo "<p>$icon Cannot detect any changes to edit!</p>";
die();
}
if (!$Eban->IsSteamIDAlreadyBanned($playerSteamID)) {
echo "<p>$icon The edited steamid is already Eunbanned and cannot be edited from here</p>";
die();
}
$timestamp_issued = (($info['timestamp_issued'] - ($info['duration'] * 60)) + $length);
if ($length > 0 && $timestamp_issued < time()) {
echo "<p>$icon Invalid Duration! Expected a duration that will last in the future but got one that has already ended.</p>";
die();
}
$Eban->EditEban($id, $playerName, $playerSteamID, $length, $reason);
}
if (isset($_GET['delete'])) {
if (!isset($_COOKIE['steamID'])) {
die();
}
$admin = new Admin();
$admin->UpdateAdminInfo($_COOKIE['steamID']);
if (!IsAdminLoggedIn() || !$admin->DoesHaveFullAccess()) {
die();
}
$id = filter_input(INPUT_GET, 'deleteid', FILTER_SANITIZE_NUMBER_INT);
$Eban = new Eban();
$Eban->RemoveEbanFromDB($id);
die();
}
?>