public VerifyBan(Handle:owner, Handle:hndl, const String:error[], any:userid)
{
decl String:clientName[64];
decl String:clientAuth[64];
decl String:clientIp[64];
new client = GetClientOfUserId(userid);
if (!client)
return;
/* Failure happen. Do retry with delay */
if (hndl == INVALID_HANDLE)
{
LogToFile(logFile, "Verify Ban Query Failed: %s", error);
PlayerRecheck[client] = CreateTimer(RetryTime, ClientRecheck, client);
return;
}
GetClientIP(client, clientIp, sizeof(clientIp));
GetSID(client, clientAuth, sizeof(clientAuth));
GetClientName(client, clientName, sizeof(clientName));
if (SQL_FetchRow(hndl))
{
if (g_FloodControl)
{
ServerCommand("banid 5 %s", clientAuth);
}
decl String:reason[256], String:szLength[64], String:szCreated[128], String:buffer2[512];
new length = SQL_FetchInt(hndl, 1);
new created = SQL_FetchInt(hndl, 2);
SQL_FetchString(hndl, 3, reason, sizeof(reason));
if(!length)
Format(szLength, sizeof(szLength), "%T", "Permanent", client);
else
{
new days = length / (60 * 60 * 24);
new hours = (length - (days * (60 * 60 * 24))) / (60 * 60);
new minutes = (length % (60 * 60)) / 60;
new len = 0;
if(days) len += Format(szLength[len], sizeof(szLength) - len, "%d %T ", days, "Days", client);
if(hours) len += Format(szLength[len], sizeof(szLength) - len, "%d %T ", hours, "Hours", client);
if(minutes) len += Format(szLength[len], sizeof(szLength) - len, "%d %T", minutes, "Minutes", client);
}
FormatTime(szCreated, sizeof(szCreated), NULL_STRING, created);
if(!SQL_IsFieldNull(hndl, 4))
{
decl String:admin[64];
SQL_FetchString(hndl, 4, admin, sizeof(admin));
Format(buffer2, sizeof(buffer2), "%T", "Banned Admin", client, admin, reason, szCreated, szLength, WebsiteAddress);
KickClient(client, buffer2);
}
else
{
Format(buffer2, sizeof(buffer2), "%T", "Banned", client, reason, szCreated, szLength, WebsiteAddress);
KickClient(client, buffer2);
}
decl String:Name[128];
decl String:Query[512];
SQL_EscapeString(DB, clientName, Name, sizeof(Name));
if (serverID == -1)
{
FormatEx(Query, sizeof(Query), "INSERT INTO %s_banlog (sid ,time ,name ,bid) VALUES \
((SELECT sid FROM %s_servers WHERE ip = '%s' AND port = '%s' LIMIT 0,1), UNIX_TIMESTAMP(), '%s', \
(SELECT bid FROM %s_bans WHERE ((type = 0 AND authid REGEXP '^STEAM_[0-9]:%s$') OR (type = 1 AND ip = '%s')) AND RemoveType IS NULL LIMIT 0,1))",
DatabasePrefix, DatabasePrefix, ServerIp, ServerPort, Name, DatabasePrefix, clientAuth[8], clientIp);
}
else
{
FormatEx(Query, sizeof(Query), "INSERT INTO %s_banlog (sid ,time ,name ,bid) VALUES \
(%d, UNIX_TIMESTAMP(), '%s', \
(SELECT bid FROM %s_bans WHERE ((type = 0 AND authid REGEXP '^STEAM_[0-9]:%s$') OR (type = 1 AND ip = '%s')) AND RemoveType IS NULL LIMIT 0,1))",
DatabasePrefix, serverID, Name, DatabasePrefix, clientAuth[8], clientIp);
}
SQL_TQuery(DB, ErrorCheckCallback, Query, client, DBPrio_High);
return;
}
#if defined DEBUG
LogToFile(logFile, "%s is NOT banned.", clientAuth);
#endif
PlayerStatus[client] = true;
}