Veteran Member
Join Date: Sep 2013
Location: United Kingdom
|
09-24-2013
, 06:22
Steambans.ru - Decompiled
|
#1
|
Well, I saw another plugin violating Sourcemod by not distributing sourcecode.
Maybe somebody wants to try dropping Tables? (It might be Read Only, but who knows..)
PHP Code:
new Handle:kv = CreateKeyValues("steambans", "", ""); KvSetString(kv, "driver", "mysql"); KvSetString(kv, "host", "db.steambans.ru"); KvSetString(kv, "database", "steambans"); KvSetString(kv, "user", "steambans"); KvSetString(kv, "pass", "4TXokFnTdixnoe"); KvSetString(kv, "port", "3306");
PHP Code:
public PlVers:__version = { version = 5, filevers = "1.4.2", date = "11/18/2012", time = "22:45:42" }; new Float:NULL_VECTOR[3]; new String:NULL_STRING[4]; public Extension:__ext_core = { name = "Core", file = "core", autoload = 0, required = 0, }; new MaxClients; public Extension:__ext_curl = { name = "curl", file = "curl.ext", autoload = 1, required = 0, }; public Extension:__ext_smsock = { name = "Socket", file = "socket.ext", autoload = 1, required = 0, }; public Extension:__ext_SteamTools = { name = "SteamTools", file = "steamtools.ext", autoload = 1, required = 0, }; new bool:g_bSteamLoaded; new Handle:h_Database; new Handle:h_CheckAnnoune; new Handle:h_StatusSpamDelay; new Float:f_StatusSpamDelay; new Handle:h_Timer; new Handle:h_BanAnnoune; new String:local_dest[256]; new String:plugin_path[256]; new String:log_file[256]; new String:g_map[64]; public Plugin:myinfo = { name = "SteamBans.Ru - Единая Российская Бан-Система", description = "Ban Checker", author = "FrozDark (HLModders LLC)", version = "2.0.4", url = "www.hlmod.ru" }; public __ext_core_SetNTVOptional() { MarkNativeAsOptional("GetFeatureStatus"); MarkNativeAsOptional("RequireFeature"); MarkNativeAsOptional("AddCommandListener"); MarkNativeAsOptional("RemoveCommandListener"); VerifyCoreVersion(); return 0; }
RoundFloat(Float:value) { return RoundToNearest(value); }
Float:operator/(Float:,_:)(Float:oper1, oper2) { return oper1 / float(oper2); }
bool:operator>(Float:,Float:)(Float:oper1, Float:oper2) { return FloatCompare(oper1, oper2) > 0; }
bool:StrEqual(String:str1[], String:str2[], bool:caseSensitive) { return strcmp(str1, str2, caseSensitive) == 0; }
FindCharInString(String:str[], c, bool:reverse) { new i; new len = strlen(str); if (!reverse) { i = 0; while (i < len) { if (c == str[i]) { return i; } i++; } } else { i = len + -1; while (0 <= i) { if (c == str[i]) { return i; } i--; } } return -1; }
ExplodeString(String:text[], String:split[], String:buffers[][], maxStrings, maxStringLength, bool:copyRemainder) { new reloc_idx; new idx; new total; if (maxStrings < 1) { return 0; } idx = var2; while (var2 != -1) { reloc_idx = idx + reloc_idx; total++; if (maxStrings == total) { if (copyRemainder) { strcopy(buffers[total + -1], maxStringLength, text[reloc_idx - idx]); } return total; } } total++; strcopy(buffers[total], maxStringLength, text[reloc_idx]); return total; }
bool:WriteFileCell(Handle:hndl, data, size) { new array[1]; array[0] = data; return WriteFile(hndl, array, 1, size); }
PrintToChatAll(String:format[]) { decl String:buffer[192]; new i = 1; while (i <= MaxClients) { if (IsClientInGame(i)) { SetGlobalTransTarget(i); VFormat(buffer, 192, format, 2); PrintToChat(i, "%s", buffer); i++; } i++; } return 0; }
Download_cURL(String:url[], String:dest[]) { new Handle:hFile = curl_OpenFile(dest, "wb"); if (!hFile) { DownloadEnded(false, ""); ThrowError("Error writing to file: %s", dest); } new CURL_Default_opt[5][2]; new Handle:curl = curl_easy_init(); curl_easy_setopt_int_array(curl, CURL_Default_opt, 5); curl_easy_setopt_handle(curl, CURLoption:10001, hFile); curl_easy_setopt_string(curl, CURLoption:10002, url); curl_easy_perform_thread(curl, OnCurlComplete, hFile); return 0; }
public OnCurlComplete(Handle:curl, CURLcode:code, hFile) { CloseHandle(hFile); CloseHandle(curl); if (code) { decl String:sError[256]; curl_easy_strerror(code, sError, 256); Format(sError, 256, "cURL error: %s", sError); DownloadEnded(false, sError); } else { DownloadEnded(true, ""); } return 0; }
Download_Socket(String:url[], String:dest[]) { new Handle:hFile = OpenFile(dest, "wb"); if (!hFile) { DownloadEnded(false, ""); ThrowError("Error writing to file: %s", dest); } decl String:hostname[64]; decl String:location[128]; decl String:filename[64]; decl String:sRequest[384]; ParseURL(url, hostname, 64, location, 128, filename, 64); Format(sRequest, 384, "GET %s/%s HTTP/1.0\r\nHost: %s\r\nConnection: close\r\n\r\n", location, filename, hostname); new Handle:hDLPack = CreateDataPack(); WritePackCell(hDLPack, hFile); WritePackString(hDLPack, sRequest); new Handle:socket = SocketCreate(SocketType:1, OnSocketError); SocketSetArg(socket, hDLPack); SocketConnect(socket, OnSocketConnected, OnSocketReceive, OnSocketDisconnected, hostname, 80); return 0; }
public OnSocketConnected(Handle:socket, hDLPack) { decl String:sRequest[384]; SetPackPosition(hDLPack, 8); ReadPackString(hDLPack, sRequest, 384); SocketSend(socket, sRequest, -1); return 0; }
public OnSocketReceive(Handle:socket, String:data[], size, hDLPack) { ResetPack(hDLPack, false); new Handle:hFile = ReadPackCell(hDLPack); new pos = StrContains(data, "\r\n\r\n", true); if (pos != -1) { var1 = pos + 4; } else { var1 = 0; } pos = var1; new i = pos; while (i < size) { WriteFileCell(hFile, data[i], 1); i++; } return 0; }
public OnSocketDisconnected(Handle:socket, hDLPack) { ResetPack(hDLPack, false); CloseHandle(ReadPackCell(hDLPack)); CloseHandle(hDLPack); CloseHandle(socket); DownloadEnded(true, ""); return 0; }
public OnSocketError(Handle:socket, errorType, errorNum, hDLPack) { ResetPack(hDLPack, false); CloseHandle(ReadPackCell(hDLPack)); CloseHandle(hDLPack); CloseHandle(socket); decl String:sError[256]; FormatEx(sError, 256, "Socket error: %d (Error code %d)", errorType, errorNum); DownloadEnded(false, sError); return 0; }
Download_SteamTools(String:url[], String:dest[]) { decl String:sURL[256]; if (strncmp(url, "http://", 7, true)) { FormatEx(sURL, 256, "http://%s", url); } else { strcopy(sURL, 256, url); } new Handle:hDLPack = CreateDataPack(); WritePackString(hDLPack, dest); new HTTPRequestHandle:hRequest = Steam_CreateHTTPRequest(HTTPMethod:1, sURL); Steam_SendHTTPRequest(hRequest, OnSteamHTTPComplete, hDLPack); return 0; }
public OnSteamHTTPComplete(HTTPRequestHandle:HTTPRequest, bool:requestSuccessful, HTTPStatusCode:statusCode, hDLPack) { decl String:sDest[256]; ResetPack(hDLPack, false); ReadPackString(hDLPack, sDest, 256); CloseHandle(hDLPack); if (requestSuccessful) { Steam_WriteHTTPResponseBody(HTTPRequest, sDest); DownloadEnded(true, ""); } else { decl String:sError[256]; if (requestSuccessful) { var2[0] = 616; } else { var2[0] = 624; } FormatEx(sError, 256, "SteamTools error (status code %i). Request successful: %s", statusCode, var2); DownloadEnded(false, sError); } Steam_ReleaseHTTPRequest(HTTPRequest); return 0; }
public Steam_FullyLoaded() { g_bSteamLoaded = 1; return 0; }
public Steam_Shutdown() { g_bSteamLoaded = 0; return 0; }
public APLRes:AskPluginLoad2(Handle:myself, bool:late, String:error[], err_max) { MarkNativeAsOptional("curl_OpenFile"); MarkNativeAsOptional("curl_easy_init"); MarkNativeAsOptional("curl_easy_setopt_function"); MarkNativeAsOptional("curl_easy_setopt_int_array"); MarkNativeAsOptional("curl_easy_setopt_handle"); MarkNativeAsOptional("curl_easy_setopt_string"); MarkNativeAsOptional("curl_easy_perform_thread"); MarkNativeAsOptional("curl_easy_strerror"); MarkNativeAsOptional("SocketCreate"); MarkNativeAsOptional("SocketSetArg"); MarkNativeAsOptional("SocketConnect"); MarkNativeAsOptional("SocketSend"); MarkNativeAsOptional("Steam_GetPublicIP"); MarkNativeAsOptional("Steam_CreateHTTPRequest"); MarkNativeAsOptional("Steam_SendHTTPRequest"); MarkNativeAsOptional("Steam_WriteHTTPResponseBody"); MarkNativeAsOptional("Steam_ReleaseHTTPRequest"); return APLRes:0; }
public OnPluginStart() { CreateConVar("steambans_version", "2.0.4", "The plugin's version", 418112, false, 0, false, 0); h_CheckAnnoune = CreateConVar("steambans_check_announce", "1", "Whether a player should be announced to others in the chat about his good standing in the banlists", 0, true, 0, true, 1); h_BanAnnoune = CreateConVar("steambans_ban_announce", "1", "Whether a player should be announced to others in the chat about his bad standing in the banlists", 0, true, 0, true, 1); h_StatusSpamDelay = CreateConVar("steambans_status_spam_delay", "300", "How often in seconds to spam status to the players. 0 to disable", 0, true, 0, false, 0); ConnectDatabase(); BuildPath(PathType:0, local_dest, 256, "steambans.update"); BuildPath(PathType:0, plugin_path, 256, "plugins/"); BuildPath(PathType:0, log_file, 256, "logs/steambans.log"); f_StatusSpamDelay = GetConVarFloat(h_StatusSpamDelay); HookConVarChange(h_StatusSpamDelay, OnConVarChange); TriggerTimer(CreateTimer(108000, CheckUpdates, any:0, 1), true); return 0; }
bool:ConnectDatabase() { if (h_Database) { return true; } decl String:error[256]; error[0] = 0; new Handle:kv = CreateKeyValues("steambans", "", ""); KvSetString(kv, "driver", "mysql"); KvSetString(kv, "host", "db.steambans.ru"); KvSetString(kv, "database", "steambans"); KvSetString(kv, "user", "steambans"); KvSetString(kv, "pass", "4TXokFnTdixnoe"); KvSetString(kv, "port", "3306"); h_Database = SQL_ConnectCustom(kv, error, 256, true); CloseHandle(kv); if (error[0]) { LogError("An error has occured while connecting to database - %s", error); } return h_Database != 0; }
CheckTimer() { if (h_Timer) { KillTimer(h_Timer, false); h_Timer = 0; } return 0; }
public OnMapStart() { GetCurrentMap(g_map, 64); CheckTimer(); if (f_StatusSpamDelay > 0) { h_Timer = CreateTimer(f_StatusSpamDelay, SpamStatus, any:0, 1); } return 0; }
public OnConVarChange(Handle:convar, String:oldValue[], String:newValue[]) { if (h_StatusSpamDelay == convar) { CheckTimer(); f_StatusSpamDelay = StringToFloat(newValue); if (f_StatusSpamDelay > 0) { h_Timer = CreateTimer(f_StatusSpamDelay, SpamStatus, any:0, 1); } } return 0; }
public Action:SpamStatus(Handle:timer) { decl String:auth[24]; decl String:name[36]; decl String:hostname[96]; decl String:date[24]; GetClientName(0, hostname, 96); FormatTime(date, 24, "%d %b %Y %H:%M", -1); PrintToChatAll(" "); PrintToChatAll("------------------------------------------------------------------"); PrintToChatAll("Hostname : %s", hostname); PrintToChatAll("Date/Time: %s", date); PrintToChatAll("Map : %s", g_map); PrintToChatAll("Players : %i (%i Max)", GetClientCount(true), MaxClients); PrintToChatAll("------------------------------------------------------------------"); PrintToChatAll("STEAM ID | Name | Ping"); PrintToChatAll("------------------------------------------------------------------"); new i = 1; while (i <= MaxClients) { if (IsClientInGame(i)) { GetClientAuthString(i, auth, 21); GetClientName(i, name, 33); PrintToChatAll("%21s | %32s | %ims", auth, name, Client_GetFakePing(i, false)); i++; } i++; } PrintToChatAll("------------------------------------------------------------------"); PrintToChatAll("SteamIDs list has been generated by SteamBans.ru"); PrintToChatAll(" "); return Action:0; }
public Action:CheckUpdates(Handle:timer) { if (GetFeatureStatus(FeatureType:0, "curl_easy_init")) { if (GetFeatureStatus(FeatureType:0, "SocketCreate")) { if (GetFeatureStatus(FeatureType:0, "Steam_CreateHTTPRequest")) { Download_SteamTools("http://cp.steamhost.ru/SteamBans_ru/updates.txt", local_dest); } LogMessage("Ваша версия плагина не будет обновлена до актуальной версии без одного из следующих расширений: cURL, Socket или SteamTools\nYour version of the plugin won't be up-to-date without one of these extensions: cURL, Socket or SteamTools"); } Download_Socket("http://cp.steamhost.ru/SteamBans_ru/updates.txt", local_dest); } else { Download_cURL("http://cp.steamhost.ru/SteamBans_ru/updates.txt", local_dest); } return Action:0; }
public OnClientAuthorized(client, String:auth[]) { if (auth[0] == 'B') { return 0; } decl String:Query[1024]; decl String:ClientIp[16]; decl String:name[32]; GetClientIP(client, ClientIp, 16, true); GetClientName(client, name, 32); SQL_EscapeString(h_Database, name, name, 32, 0); FormatEx(Query, 1024, "SELECT `bid` FROM `sb_bans` WHERE ((`type` = '0' AND `authid` REGEXP '^STEAM_[0-9]:%s$') OR (`type` = '1' AND `ip` = '%s')) AND (`length` = '0' OR `ends` > UNIX_TIMESTAMP()) AND `RemoveType` IS NULL", auth[2], ClientIp); new Handle:datapack = CreateDataPack(); WritePackCell(datapack, GetClientUserId(client)); WritePackString(datapack, auth); WritePackString(datapack, name); WritePackString(datapack, ClientIp); SQL_TQuery(h_Database, VerifyBan, Query, datapack, DBPriority:1); return 0; }
public OnClientPutInServer(client) { SendTopMessage(client, 10, 255, 0, 0, 255, "Сервер под защитой SteamBans.Ru!"); return 0; }
public VerifyBan(Handle:owner, Handle:hndl, String:error[], hDataPack) { if (error[0]) { LogError(error); } if (hndl) { if (hDataPack) { decl String:name[32]; decl String:steamid[24]; decl String:ClientIp[16]; ResetPack(hDataPack, false); new client = GetClientOfUserId(ReadPackCell(hDataPack)); ReadPackString(hDataPack, steamid, 21); ReadPackString(hDataPack, name, 32); ReadPackString(hDataPack, ClientIp, 16); CloseHandle(hDataPack); if (!client) { return 0; } if (SQL_GetRowCount(hndl)) { if (GetConVarBool(h_BanAnnoune)) { PrintToChatAll("\x04[SteamBans.Ru] \x03Подключение игрока \x04%N \x03заблокировано.", client); } BanClient(client, 5, 4, "Забенен системой SteamBans.Ru", "Вы находитесь в списке забаненых за использование читов. Подробности на SteamBans.Ru", "", any:0); SQL_LockDatabase(h_Database); SQL_FastQuery(h_Database, "SET NAMES \"UTF8\"", -1); SQL_UnlockDatabase(h_Database); decl String:Query[1024]; FormatEx(Query, 1024, "INSERT INTO `sb_banlog` (`sid`, `time` ,`name`, `bid`) VALUES ('1', UNIX_TIMESTAMP(), '%s', (SELECT `bid` FROM `sb_bans` WHERE ((`type` = '0' AND `authid` = '%s') OR (`type` = '1' AND `ip` = '%s')) AND `RemoveType` IS NULL))", name, steamid, ClientIp); SQL_TQuery(h_Database, ErrorCheckCallback, Query, any:0, DBPriority:1); return 0; } if (GetConVarBool(h_CheckAnnoune)) { PrintToChatAll("\x04[SteamBans.Ru] \x03Игрок \x04%N \x03в бан-листах не найден", client); } return 0; } return 0; } if (hDataPack) { CloseHandle(hDataPack); } return 0; }
public ErrorCheckCallback(Handle:owner, Handle:hndl, String:error[], data) { if (error[0]) { LogError(error); } return 0; }
Client_GetFakePing(client, bool:goldSource) { decl ping; new Float:latency = GetClientLatency(client, NetFlow:0); decl String:cl_cmdrate[4]; GetClientInfo(client, "cl_cmdrate", cl_cmdrate, 4); new Float:tickRate = GetTickInterval(); latency -= 1056964608 / StringToInt(cl_cmdrate, 10) + GetTickInterval() * 1; if (goldSource) { latency -= tickRate * 0.5; } ping = RoundFloat(latency * 1000); ping = Math_Clamp(ping, any:5, any:1000); return ping; }
Math_Clamp(value, min, max) { value = Math_Min(value, min); value = Math_Max(value, max); return value; }
Math_Max(value, max) { if (value > max) { value = max; } return value; }
Math_Min(value, min) { if (value < min) { value = min; } return value; }
DownloadEnded(bool:successful, String:error[]) { static bool:IsVersion; if (!successful) { LogError(error); IsVersion = 0; return 0; } decl String:newUrl[256]; decl String:Plugin_Dest[256]; decl String:Plugin_Name[64]; strcopy(newUrl, 256, "http://cp.steamhost.ru/SteamBans_ru/updates.txt"); StripURLFilename(newUrl); GetPluginFilename(Handle:0, Plugin_Name, 64); Format(newUrl, 256, "%s/plugins/%s", newUrl, Plugin_Name); Format(Plugin_Dest, 256, "%s%s.temp", plugin_path, Plugin_Name); if (!IsVersion) { if (!FileExists(local_dest, false)) { LogError("Couldn't create file \"%s\"", local_dest); return 0; } new Handle:filehandle = OpenFile(local_dest, "r"); if (filehandle) { decl String:Line[128]; new bool:verLine = 1; new bool:updateAvailable; new index = 1; while (!IsEndOfFile(filehandle) && ReadFileLine(filehandle, Line, 128)) { TrimString(Line); StripQuotes(Line); if (verLine) { verLine = 0; if (!StrEqual(Line, "2.0.4", true)) { LogToFileEx(log_file, "[SteamBans.ru] Notice: Update available - %s", Line); updateAvailable = 1; IsVersion = 1; if (GetFeatureStatus(FeatureType:0, "curl_easy_init")) { if (GetFeatureStatus(FeatureType:0, "SocketCreate")) { if (GetFeatureStatus(FeatureType:0, "Steam_CreateHTTPRequest")) { Download_SteamTools(newUrl, Plugin_Dest); } } Download_Socket(newUrl, Plugin_Dest); } Download_cURL(newUrl, Plugin_Dest); } } else { if (updateAvailable) { index++; LogToFileEx(log_file, "[SteamBans.ru] [%i] %s", index, Line); } } } CloseHandle(filehandle); DeleteFile(local_dest); } LogError("Couldn't open file \"%s\"", local_dest); return 0; } else { IsVersion = 0; decl String:newpath[256]; strcopy(newpath, FindCharInString(Plugin_Dest, 46, true) + 1, Plugin_Dest); if (FileExists(newpath, false)) { DeleteFile(newpath); } if (RenameFile(newpath, Plugin_Dest)) { LogToFileEx(log_file, "[SteamBans.ru] Updated"); } } return 0; }
SendTopMessage(client, time, r, g, b, a, String:text[]) { decl String:message[256]; VFormat(message, 256, text, 8); new Handle:kv = CreateKeyValues("Stuff", "title", message); KvSetColor(kv, "color", r, g, b, a); KvSetNum(kv, "level", 1); KvSetNum(kv, "time", time); CreateDialog(client, kv, DialogType:0); CloseHandle(kv); return 0; }
StripURLFilename(String:url[]) { strcopy(url, FindCharInString(url, 47, true) + 1, url); return 0; }
ParseURL(String:url[], String:host[], maxHost, String:location[], maxLoc, String:filename[], maxName) { new idx = StrContains(url, "://", true); if (idx != -1) { var1 = idx + 3; } else { var1 = 0; } idx = var1; new String:dirs[64][64] = "@"; new total = ExplodeString(url[idx], "/", dirs, 16, 64, false); Format(host, maxHost, "%s", dirs[0][dirs]); location[0] = 0; new i = 1; while (total + -1 > i) { Format(location, maxLoc, "%s/%s", location, dirs[i]); i++; } Format(filename, maxName, "%s", dirs[total + -1]); return 0; }
Website: http://steambans.ru
Last edited by SM9; 09-24-2013 at 06:25.
|
|