Skip to content

Commit 0135500

Browse files
committed
Fixed possible XSS Injection
Fix #303
1 parent 06edcd9 commit 0135500

File tree

1 file changed

+185
-185
lines changed

1 file changed

+185
-185
lines changed

web/pages/page.home.php

Lines changed: 185 additions & 185 deletions
Original file line numberDiff line numberDiff line change
@@ -1,185 +1,185 @@
1-
<?php
2-
/*************************************************************************
3-
This file is part of SourceBans++
4-
5-
Copyright � 2014-2016 SourceBans++ Dev Team <https://github.com/sbpp>
6-
7-
SourceBans++ is licensed under a
8-
Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License.
9-
10-
You should have received a copy of the license along with this
11-
work. If not, see <http://creativecommons.org/licenses/by-nc-sa/3.0/>.
12-
13-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19-
THE SOFTWARE.
20-
21-
This program is based off work covered by the following copyright(s):
22-
SourceBans 1.4.11
23-
Copyright � 2007-2014 SourceBans Team - Part of GameConnect
24-
Licensed under CC BY-NC-SA 3.0
25-
Page: <http://www.sourcebans.net/> - <http://www.gameconnect.net/>
26-
*************************************************************************/
27-
28-
global $theme;
29-
if (!defined("IN_SB")) {
30-
echo "You should not be here. Only follow links!";
31-
die();
32-
}
33-
define('IN_HOME', true);
34-
35-
$res = $GLOBALS['db']->Execute("SELECT count(name) FROM " . DB_PREFIX . "_banlog");
36-
$totalstopped = (int) $res->fields[0];
37-
38-
$res = $GLOBALS['db']->Execute("SELECT bl.name, time, bl.sid, bl.bid, b.type, b.authid, b.ip
39-
FROM " . DB_PREFIX . "_banlog AS bl
40-
LEFT JOIN " . DB_PREFIX . "_bans AS b ON b.bid = bl.bid
41-
ORDER BY time DESC LIMIT 10");
42-
43-
$GLOBALS['server_qry'] = "";
44-
$stopped = array();
45-
$blcount = 0;
46-
while (!$res->EOF) {
47-
$info = array();
48-
$info['date'] = SBDate($dateformat, $res->fields[1]);
49-
$info['name'] = stripslashes($res->fields[0]);
50-
$info['short_name'] = trunc($info['name'], 40, false);
51-
$info['auth'] = $res->fields['authid'];
52-
$info['ip'] = $res->fields['ip'];
53-
$info['server'] = "block_" . $res->fields['sid'] . "_$blcount";
54-
if ($res->fields['type'] == 1) {
55-
$info['search_link'] = "index.php?p=banlist&advSearch=" . $info['ip'] . "&advType=ip&Submit";
56-
} else {
57-
$info['search_link'] = "index.php?p=banlist&advSearch=" . $info['auth'] . "&advType=steamid&Submit";
58-
}
59-
$info['link_url'] = "window.location = '" . $info['search_link'] . "';";
60-
$info['name'] = htmlspecialchars(addslashes($info['name']), ENT_QUOTES, 'UTF-8');
61-
$info['popup'] = "ShowBox('Blocked player: " . $info['name'] . "', '" . $info['name'] . " tried to enter<br />' + document.getElementById('" . $info['server'] . "').title + '<br />at " . $info['date'] . "<br /><div align=middle><a href=" . $info['search_link'] . ">Click here for ban details.</a></div>', 'red', '', true);";
62-
63-
$GLOBALS['server_qry'] .= "xajax_ServerHostProperty(" . $res->fields['sid'] . ", 'block_" . $res->fields['sid'] . "_$blcount', 'title', 100);";
64-
65-
array_push($stopped, $info);
66-
$res->MoveNext();
67-
++$blcount;
68-
}
69-
70-
$res = $GLOBALS['db']->Execute("SELECT count(bid) FROM " . DB_PREFIX . "_bans");
71-
$BanCount = (int) $res->fields[0];
72-
73-
$res = $GLOBALS['db']->Execute("SELECT bid, ba.ip, ba.authid, ba.name, created, ends, length, reason, ba.aid, ba.sid, ad.user, CONCAT(se.ip,':',se.port), se.sid, mo.icon, ba.RemoveType, ba.type
74-
FROM " . DB_PREFIX . "_bans AS ba
75-
LEFT JOIN " . DB_PREFIX . "_admins AS ad ON ba.aid = ad.aid
76-
LEFT JOIN " . DB_PREFIX . "_servers AS se ON se.sid = ba.sid
77-
LEFT JOIN " . DB_PREFIX . "_mods AS mo ON mo.mid = se.modid
78-
ORDER BY created DESC LIMIT 10");
79-
$bans = array();
80-
while (!$res->EOF) {
81-
$info = array();
82-
if ($res->fields['length'] == 0) {
83-
$info['perm'] = true;
84-
$info['unbanned'] = false;
85-
} else {
86-
$info['temp'] = true;
87-
$info['unbanned'] = false;
88-
}
89-
$info['name'] = stripslashes($res->fields[3]);
90-
$info['created'] = SBDate($dateformat, $res->fields['created']);
91-
$ltemp = explode(",", $res->fields[6] == 0 ? 'Permanent' : SecondsToString(intval($res->fields[6])));
92-
$info['length'] = $ltemp[0];
93-
$info['icon'] = empty($res->fields[13]) ? 'web.png' : $res->fields[13];
94-
$info['authid'] = $res->fields[2];
95-
$info['ip'] = $res->fields[1];
96-
if ($res->fields[15] == 1) {
97-
$info['search_link'] = "index.php?p=banlist&advSearch=" . $info['ip'] . "&advType=ip&Submit";
98-
} else {
99-
$info['search_link'] = "index.php?p=banlist&advSearch=" . $info['authid'] . "&advType=steamid&Submit";
100-
}
101-
$info['link_url'] = "window.location = '" . $info['search_link'] . "';";
102-
$info['short_name'] = trunc($info['name'], 25, false);
103-
104-
if ($res->fields[14] == 'D' || $res->fields[14] == 'U' || $res->fields[14] == 'E' || ($res->fields[6] && $res->fields[5] < time())) {
105-
$info['unbanned'] = true;
106-
107-
if ($res->fields[14] == 'D') {
108-
$info['ub_reason'] = 'D';
109-
} elseif ($res->fields[14] == 'U') {
110-
$info['ub_reason'] = 'U';
111-
} else {
112-
$info['ub_reason'] = 'E';
113-
}
114-
} else {
115-
$info['unbanned'] = false;
116-
}
117-
118-
array_push($bans, $info);
119-
$res->MoveNext();
120-
}
121-
122-
$res = $GLOBALS['db']->Execute("SELECT count(bid) FROM " . DB_PREFIX . "_comms");
123-
$CommCount = (int) $res->fields[0];
124-
125-
$res = $GLOBALS['db']->Execute("SELECT bid, ba.authid, ba.type, ba.name, created, ends, length, reason, ba.aid, ba.sid, ad.user, CONCAT(se.ip,':',se.port), se.sid, mo.icon, ba.RemoveType, ba.type
126-
FROM " . DB_PREFIX . "_comms AS ba
127-
LEFT JOIN " . DB_PREFIX . "_admins AS ad ON ba.aid = ad.aid
128-
LEFT JOIN " . DB_PREFIX . "_servers AS se ON se.sid = ba.sid
129-
LEFT JOIN " . DB_PREFIX . "_mods AS mo ON mo.mid = se.modid
130-
ORDER BY created DESC LIMIT 10");
131-
$comms = array();
132-
while (!$res->EOF) {
133-
$info = array();
134-
if ($res->fields['length'] == 0) {
135-
$info['perm'] = true;
136-
$info['unbanned'] = false;
137-
} else {
138-
$info['temp'] = true;
139-
$info['unbanned'] = false;
140-
}
141-
$info['name'] = stripslashes($res->fields[3]);
142-
$info['created'] = SBDate($dateformat, $res->fields['created']);
143-
$ltemp = explode(",", $res->fields[6] == 0 ? 'Permanent' : SecondsToString(intval($res->fields[6])));
144-
$info['length'] = $ltemp[0];
145-
$info['icon'] = empty($res->fields[13]) ? 'web.png' : $res->fields[13];
146-
$info['authid'] = $res->fields['authid'];
147-
$info['search_link'] = "index.php?p=commslist&advSearch=" . $info['authid'] . "&advType=steamid&Submit";
148-
$info['link_url'] = "window.location = '" . $info['search_link'] . "';";
149-
$info['short_name'] = trunc($info['name'], 25, false);
150-
$info['type'] = $res->fields['type'] == 2 ? "images/type_c.png" : "images/type_v.png";
151-
152-
if ($res->fields[14] == 'D' || $res->fields[14] == 'U' || $res->fields[14] == 'E' || ($res->fields[6] && $res->fields[5] < time())) {
153-
$info['unbanned'] = true;
154-
155-
if ($res->fields[14] == 'D') {
156-
$info['ub_reason'] = 'D';
157-
} elseif ($res->fields[14] == 'U') {
158-
$info['ub_reason'] = 'U';
159-
} else {
160-
$info['ub_reason'] = 'E';
161-
}
162-
} else {
163-
$info['unbanned'] = false;
164-
}
165-
166-
array_push($comms, $info);
167-
$res->MoveNext();
168-
}
169-
170-
171-
require(TEMPLATES_PATH . "/page.servers.php"); //Set theme vars from servers page
172-
173-
$theme->assign('dashboard_lognopopup', (isset($GLOBALS['config']['dash.lognopopup']) && $GLOBALS['config']['dash.lognopopup'] == "1"));
174-
$theme->assign('dashboard_title', stripslashes($GLOBALS['config']['dash.intro.title']));
175-
$theme->assign('dashboard_text', stripslashes($GLOBALS['config']['dash.intro.text']));
176-
$theme->assign('players_blocked', $stopped);
177-
$theme->assign('total_blocked', $totalstopped);
178-
179-
$theme->assign('players_banned', $bans);
180-
$theme->assign('total_bans', $BanCount);
181-
182-
$theme->assign('total_comms', $CommCount);
183-
$theme->assign('players_commed', $comms);
184-
185-
$theme->display('page_dashboard.tpl');
1+
<?php
2+
/*************************************************************************
3+
This file is part of SourceBans++
4+
5+
Copyright � 2014-2016 SourceBans++ Dev Team <https://github.com/sbpp>
6+
7+
SourceBans++ is licensed under a
8+
Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License.
9+
10+
You should have received a copy of the license along with this
11+
work. If not, see <http://creativecommons.org/licenses/by-nc-sa/3.0/>.
12+
13+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19+
THE SOFTWARE.
20+
21+
This program is based off work covered by the following copyright(s):
22+
SourceBans 1.4.11
23+
Copyright � 2007-2014 SourceBans Team - Part of GameConnect
24+
Licensed under CC BY-NC-SA 3.0
25+
Page: <http://www.sourcebans.net/> - <http://www.gameconnect.net/>
26+
*************************************************************************/
27+
28+
global $theme;
29+
if (!defined("IN_SB")) {
30+
echo "You should not be here. Only follow links!";
31+
die();
32+
}
33+
define('IN_HOME', true);
34+
35+
$res = $GLOBALS['db']->Execute("SELECT count(name) FROM " . DB_PREFIX . "_banlog");
36+
$totalstopped = (int) $res->fields[0];
37+
38+
$res = $GLOBALS['db']->Execute("SELECT bl.name, time, bl.sid, bl.bid, b.type, b.authid, b.ip
39+
FROM " . DB_PREFIX . "_banlog AS bl
40+
LEFT JOIN " . DB_PREFIX . "_bans AS b ON b.bid = bl.bid
41+
ORDER BY time DESC LIMIT 10");
42+
43+
$GLOBALS['server_qry'] = "";
44+
$stopped = array();
45+
$blcount = 0;
46+
while (!$res->EOF) {
47+
$info = array();
48+
$info['date'] = SBDate($dateformat, $res->fields[1]);
49+
$info['name'] = stripslashes(filter_var($res->fields[0], FILTER_SANITIZE_STRING, FILTER_FLAG_NO_ENCODE_QUOTES));
50+
$info['short_name'] = trunc($info['name'], 40, false);
51+
$info['auth'] = $res->fields['authid'];
52+
$info['ip'] = $res->fields['ip'];
53+
$info['server'] = "block_" . $res->fields['sid'] . "_$blcount";
54+
if ($res->fields['type'] == 1) {
55+
$info['search_link'] = "index.php?p=banlist&advSearch=" . $info['ip'] . "&advType=ip&Submit";
56+
} else {
57+
$info['search_link'] = "index.php?p=banlist&advSearch=" . $info['auth'] . "&advType=steamid&Submit";
58+
}
59+
$info['link_url'] = "window.location = '" . $info['search_link'] . "';";
60+
$info['name'] = htmlspecialchars(addslashes($info['name']), ENT_QUOTES, 'UTF-8');
61+
$info['popup'] = "ShowBox('Blocked player: " . $info['name'] . "', '" . $info['name'] . " tried to enter<br />' + document.getElementById('" . $info['server'] . "').title + '<br />at " . $info['date'] . "<br /><div align=middle><a href=" . $info['search_link'] . ">Click here for ban details.</a></div>', 'red', '', true);";
62+
63+
$GLOBALS['server_qry'] .= "xajax_ServerHostProperty(" . $res->fields['sid'] . ", 'block_" . $res->fields['sid'] . "_$blcount', 'title', 100);";
64+
65+
array_push($stopped, $info);
66+
$res->MoveNext();
67+
++$blcount;
68+
}
69+
70+
$res = $GLOBALS['db']->Execute("SELECT count(bid) FROM " . DB_PREFIX . "_bans");
71+
$BanCount = (int) $res->fields[0];
72+
73+
$res = $GLOBALS['db']->Execute("SELECT bid, ba.ip, ba.authid, ba.name, created, ends, length, reason, ba.aid, ba.sid, ad.user, CONCAT(se.ip,':',se.port), se.sid, mo.icon, ba.RemoveType, ba.type
74+
FROM " . DB_PREFIX . "_bans AS ba
75+
LEFT JOIN " . DB_PREFIX . "_admins AS ad ON ba.aid = ad.aid
76+
LEFT JOIN " . DB_PREFIX . "_servers AS se ON se.sid = ba.sid
77+
LEFT JOIN " . DB_PREFIX . "_mods AS mo ON mo.mid = se.modid
78+
ORDER BY created DESC LIMIT 10");
79+
$bans = array();
80+
while (!$res->EOF) {
81+
$info = array();
82+
if ($res->fields['length'] == 0) {
83+
$info['perm'] = true;
84+
$info['unbanned'] = false;
85+
} else {
86+
$info['temp'] = true;
87+
$info['unbanned'] = false;
88+
}
89+
$info['name'] = stripslashes($res->fields[3]);
90+
$info['created'] = SBDate($dateformat, $res->fields['created']);
91+
$ltemp = explode(",", $res->fields[6] == 0 ? 'Permanent' : SecondsToString(intval($res->fields[6])));
92+
$info['length'] = $ltemp[0];
93+
$info['icon'] = empty($res->fields[13]) ? 'web.png' : $res->fields[13];
94+
$info['authid'] = $res->fields[2];
95+
$info['ip'] = $res->fields[1];
96+
if ($res->fields[15] == 1) {
97+
$info['search_link'] = "index.php?p=banlist&advSearch=" . $info['ip'] . "&advType=ip&Submit";
98+
} else {
99+
$info['search_link'] = "index.php?p=banlist&advSearch=" . $info['authid'] . "&advType=steamid&Submit";
100+
}
101+
$info['link_url'] = "window.location = '" . $info['search_link'] . "';";
102+
$info['short_name'] = trunc($info['name'], 25, false);
103+
104+
if ($res->fields[14] == 'D' || $res->fields[14] == 'U' || $res->fields[14] == 'E' || ($res->fields[6] && $res->fields[5] < time())) {
105+
$info['unbanned'] = true;
106+
107+
if ($res->fields[14] == 'D') {
108+
$info['ub_reason'] = 'D';
109+
} elseif ($res->fields[14] == 'U') {
110+
$info['ub_reason'] = 'U';
111+
} else {
112+
$info['ub_reason'] = 'E';
113+
}
114+
} else {
115+
$info['unbanned'] = false;
116+
}
117+
118+
array_push($bans, $info);
119+
$res->MoveNext();
120+
}
121+
122+
$res = $GLOBALS['db']->Execute("SELECT count(bid) FROM " . DB_PREFIX . "_comms");
123+
$CommCount = (int) $res->fields[0];
124+
125+
$res = $GLOBALS['db']->Execute("SELECT bid, ba.authid, ba.type, ba.name, created, ends, length, reason, ba.aid, ba.sid, ad.user, CONCAT(se.ip,':',se.port), se.sid, mo.icon, ba.RemoveType, ba.type
126+
FROM " . DB_PREFIX . "_comms AS ba
127+
LEFT JOIN " . DB_PREFIX . "_admins AS ad ON ba.aid = ad.aid
128+
LEFT JOIN " . DB_PREFIX . "_servers AS se ON se.sid = ba.sid
129+
LEFT JOIN " . DB_PREFIX . "_mods AS mo ON mo.mid = se.modid
130+
ORDER BY created DESC LIMIT 10");
131+
$comms = array();
132+
while (!$res->EOF) {
133+
$info = array();
134+
if ($res->fields['length'] == 0) {
135+
$info['perm'] = true;
136+
$info['unbanned'] = false;
137+
} else {
138+
$info['temp'] = true;
139+
$info['unbanned'] = false;
140+
}
141+
$info['name'] = stripslashes($res->fields[3]);
142+
$info['created'] = SBDate($dateformat, $res->fields['created']);
143+
$ltemp = explode(",", $res->fields[6] == 0 ? 'Permanent' : SecondsToString(intval($res->fields[6])));
144+
$info['length'] = $ltemp[0];
145+
$info['icon'] = empty($res->fields[13]) ? 'web.png' : $res->fields[13];
146+
$info['authid'] = $res->fields['authid'];
147+
$info['search_link'] = "index.php?p=commslist&advSearch=" . $info['authid'] . "&advType=steamid&Submit";
148+
$info['link_url'] = "window.location = '" . $info['search_link'] . "';";
149+
$info['short_name'] = trunc($info['name'], 25, false);
150+
$info['type'] = $res->fields['type'] == 2 ? "images/type_c.png" : "images/type_v.png";
151+
152+
if ($res->fields[14] == 'D' || $res->fields[14] == 'U' || $res->fields[14] == 'E' || ($res->fields[6] && $res->fields[5] < time())) {
153+
$info['unbanned'] = true;
154+
155+
if ($res->fields[14] == 'D') {
156+
$info['ub_reason'] = 'D';
157+
} elseif ($res->fields[14] == 'U') {
158+
$info['ub_reason'] = 'U';
159+
} else {
160+
$info['ub_reason'] = 'E';
161+
}
162+
} else {
163+
$info['unbanned'] = false;
164+
}
165+
166+
array_push($comms, $info);
167+
$res->MoveNext();
168+
}
169+
170+
171+
require(TEMPLATES_PATH . "/page.servers.php"); //Set theme vars from servers page
172+
173+
$theme->assign('dashboard_lognopopup', (isset($GLOBALS['config']['dash.lognopopup']) && $GLOBALS['config']['dash.lognopopup'] == "1"));
174+
$theme->assign('dashboard_title', stripslashes($GLOBALS['config']['dash.intro.title']));
175+
$theme->assign('dashboard_text', stripslashes($GLOBALS['config']['dash.intro.text']));
176+
$theme->assign('players_blocked', $stopped);
177+
$theme->assign('total_blocked', $totalstopped);
178+
179+
$theme->assign('players_banned', $bans);
180+
$theme->assign('total_bans', $BanCount);
181+
182+
$theme->assign('total_comms', $CommCount);
183+
$theme->assign('players_commed', $comms);
184+
185+
$theme->display('page_dashboard.tpl');

0 commit comments

Comments
 (0)