@@ -504,7 +504,7 @@ public Action CommandBanIp(int client, int args)
504
504
}
505
505
506
506
int len , next_len ;
507
- char Arguments [256 ], arg [50 ], time [20 ];
507
+ char Arguments [256 ], arg [50 ], time [20 ], targetName [ MAX_NAME_LENGTH ] ;
508
508
509
509
GetCmdArgString (Arguments , sizeof (Arguments ));
510
510
len = BreakString (Arguments , arg , sizeof (arg ));
@@ -538,7 +538,10 @@ public Action CommandBanIp(int client, int args)
538
538
target = target_list [0 ];
539
539
540
540
if (! IsFakeClient (target ) && CanUserTarget (client , target ))
541
+ {
542
+ GetClientName (target , targetName , sizeof (targetName ));
541
543
GetClientIP (target , arg , sizeof (arg ));
544
+ }
542
545
}
543
546
544
547
char adminIp [24 ], adminAuth [64 ];
@@ -566,6 +569,7 @@ public Action CommandBanIp(int client, int args)
566
569
dataPack .WriteCell (minutes );
567
570
dataPack .WriteString (Arguments [len ]);
568
571
dataPack .WriteString (arg );
572
+ dataPack .WriteString (targetName );
569
573
dataPack .WriteString (adminAuth );
570
574
dataPack .WriteString (adminIp );
571
575
@@ -1220,17 +1224,19 @@ public void VerifyInsert(Database db, DBResultSet results, const char[] error, D
1220
1224
public void SelectBanIpCallback (Database db , DBResultSet results , const char [] error , DataPack dataPack )
1221
1225
{
1222
1226
int admin , minutes ;
1223
- char adminAuth [30 ], adminIp [30 ], banReason [256 ], ip [16 ], Query [512 ];
1224
- char reason [ 128 ];
1227
+ char adminAuth [30 ], adminIp [30 ], banReason [256 ], ip [16 ], reason [ 128 ], Query [512 ];
1228
+ char targetName [ MAX_NAME_LENGTH ], sTEscapedName [ MAX_NAME_LENGTH * 2 + 1 ];
1225
1229
1226
1230
dataPack .Reset ();
1227
1231
admin = dataPack .ReadCell ();
1228
1232
minutes = dataPack .ReadCell ();
1229
1233
dataPack .ReadString (reason , sizeof (reason ));
1230
1234
dataPack .ReadString (ip , sizeof (ip ));
1235
+ dataPack .ReadString (targetName , sizeof (targetName ));
1231
1236
dataPack .ReadString (adminAuth , sizeof (adminAuth ));
1232
1237
dataPack .ReadString (adminIp , sizeof (adminIp ));
1233
1238
DB .Escape (reason , banReason , sizeof (banReason ));
1239
+ DB .Escape (targetName , sTEscapedName , sizeof (sTEscapedName ));
1234
1240
1235
1241
if (results == null )
1236
1242
{
@@ -1254,14 +1260,14 @@ public void SelectBanIpCallback(Database db, DBResultSet results, const char[] e
1254
1260
if (serverID == - 1 )
1255
1261
{
1256
1262
FormatEx (Query , sizeof (Query ), " INSERT INTO %s _bans (type, ip, name, created, ends, length, reason, aid, adminIp, sid, country) VALUES \
1257
- (1, '%s ', '', UNIX_TIMESTAMP(), UNIX_TIMESTAMP() + %d , %d , '%s ', (SELECT aid FROM %s _admins WHERE authid = '%s ' OR authid REGEXP '^STEAM_[0-9]:%s $'), '%s ', \
1263
+ (1, '%s ', '%s ', UNIX_TIMESTAMP(), UNIX_TIMESTAMP() + %d , %d , '%s ', (SELECT aid FROM %s _admins WHERE authid = '%s ' OR authid REGEXP '^STEAM_[0-9]:%s $'), '%s ', \
1258
1264
(SELECT sid FROM %s _servers WHERE ip = '%s ' AND port = '%s ' LIMIT 0,1), ' ')" ,
1259
- DatabasePrefix , ip , (minutes * 60 ), (minutes * 60 ), banReason , DatabasePrefix , adminAuth , adminAuth [8 ], adminIp , DatabasePrefix , ServerIp , ServerPort );
1265
+ DatabasePrefix , ip , sTEscapedName , (minutes * 60 ), (minutes * 60 ), banReason , DatabasePrefix , adminAuth , adminAuth [8 ], adminIp , DatabasePrefix , ServerIp , ServerPort );
1260
1266
} else {
1261
1267
FormatEx (Query , sizeof (Query ), " INSERT INTO %s _bans (type, ip, name, created, ends, length, reason, aid, adminIp, sid, country) VALUES \
1262
- (1, '%s ', '', UNIX_TIMESTAMP(), UNIX_TIMESTAMP() + %d , %d , '%s ', (SELECT aid FROM %s _admins WHERE authid = '%s ' OR authid REGEXP '^STEAM_[0-9]:%s $'), '%s ', \
1268
+ (1, '%s ', '%s ', UNIX_TIMESTAMP(), UNIX_TIMESTAMP() + %d , %d , '%s ', (SELECT aid FROM %s _admins WHERE authid = '%s ' OR authid REGEXP '^STEAM_[0-9]:%s $'), '%s ', \
1263
1269
%d , ' ')" ,
1264
- DatabasePrefix , ip , (minutes * 60 ), (minutes * 60 ), banReason , DatabasePrefix , adminAuth , adminAuth [8 ], adminIp , serverID );
1270
+ DatabasePrefix , ip , sTEscapedName , (minutes * 60 ), (minutes * 60 ), banReason , DatabasePrefix , adminAuth , adminAuth [8 ], adminIp , serverID );
1265
1271
}
1266
1272
1267
1273
db .Query (InsertBanIpCallback , Query , dataPack , DBPrio_High );
@@ -1271,16 +1277,45 @@ public void InsertBanIpCallback(Database db, DBResultSet results, const char[] e
1271
1277
{
1272
1278
// if the pack is good unpack it and close the handle
1273
1279
int admin , minutes ;
1280
+ int target = - 1 ;
1274
1281
char reason [128 ];
1275
- char arg [30 ];
1282
+ char targetIP [30 ];
1276
1283
1277
1284
if (dataPack != null )
1278
1285
{
1279
1286
dataPack .Reset ();
1280
1287
admin = dataPack .ReadCell ();
1281
1288
minutes = dataPack .ReadCell ();
1282
1289
dataPack .ReadString (reason , sizeof (reason ));
1283
- dataPack .ReadString (arg , sizeof (arg ));
1290
+ dataPack .ReadString (targetIP , sizeof (targetIP ));
1291
+
1292
+ for (int i = 1 ; i <= MaxClients ; i ++ )
1293
+ {
1294
+ if (! IsClientInGame (i ) || IsFakeClient (i ))
1295
+ continue ;
1296
+
1297
+ char ip [30 ];
1298
+ GetClientIP (i , ip , sizeof (ip ));
1299
+ if (StrEqual (targetIP , ip , false ))
1300
+ {
1301
+ target = i ;
1302
+ break ;
1303
+ }
1304
+ }
1305
+
1306
+ // Kick player
1307
+ if (target != - 1 )
1308
+ {
1309
+ char length [32 ];
1310
+ if (minutes == 0 )
1311
+ FormatEx (length , sizeof (length ), " permament" );
1312
+ else
1313
+ FormatEx (length , sizeof (length ), " %d %s " , minutes , minutes == 1 ? " minute" : " minutes" );
1314
+
1315
+ if (IsClientConnected (target ))
1316
+ KickClient (target , " %t \n\n %t " , " Banned Check Site" , WebsiteAddress , " Kick Reason" , admin , reason , length );
1317
+ }
1318
+
1284
1319
delete dataPack ;
1285
1320
} else {
1286
1321
// Technically this should not be possible
@@ -1296,12 +1331,12 @@ public void InsertBanIpCallback(Database db, DBResultSet results, const char[] e
1296
1331
return ;
1297
1332
}
1298
1333
1299
- LogAction (admin , - 1 , " %t " , " Ban Added" , admin , minutes , arg , reason );
1334
+ LogAction (admin , - 1 , " %t " , " Ban Added" , admin , minutes , targetIP , reason );
1300
1335
1301
1336
if (admin && IsClientInGame (admin ))
1302
- PrintToChat (admin , " %s%t " , Prefix , " Ban Success Name" , arg );
1337
+ PrintToChat (admin , " %s%t " , Prefix , " Ban Success Name" , targetIP );
1303
1338
else
1304
- PrintToServer (" %s%t " , Prefix , " Ban Success Name" , arg );
1339
+ PrintToServer (" %s%t " , Prefix , " Ban Success Name" , targetIP );
1305
1340
}
1306
1341
1307
1342
public void SelectUnbanCallback (Database db , DBResultSet results , const char [] error , DataPack dataPack )
@@ -1589,13 +1624,13 @@ public void ServerInfoCallback(Database db, DBResultSet results, const char[] er
1589
1624
1590
1625
if (AutoAdd == AUTO_ADD_SERVER_WITH_RCON )
1591
1626
{
1592
- ConVar cvarRconPassword = FindConVar (" rcon_password" );
1593
- if (cvarRconPassword != null )
1594
- {
1595
- cvarRconPassword .GetString (rcon , sizeof (rcon ));
1596
- }
1597
- }
1598
-
1627
+ ConVar cvarRconPassword = FindConVar (" rcon_password" );
1628
+ if (cvarRconPassword != null )
1629
+ {
1630
+ cvarRconPassword .GetString (rcon , sizeof (rcon ));
1631
+ }
1632
+ }
1633
+
1599
1634
FormatEx (query , sizeof (query ), " INSERT INTO %s _servers (ip, port, rcon, modid) VALUES ('%s ', '%s ', '%s ', (SELECT mid FROM %s _mods WHERE modfolder = '%s '))" , DatabasePrefix , ServerIp , ServerPort , rcon , DatabasePrefix , desc );
1600
1635
db .Query (ErrorCheckCallback , query );
1601
1636
}
0 commit comments