PHP Code:
////////////////////////////////////////////////////////////////////////////////////////////////////
public VertifyBan(id)
{
if(do_connection())
{
new iSteam[32]
get_user_authid(id, iSteam, 31) ; trim(iSteam)
if(equal("STEAM_ID_PEDING", iSteam) )
{
set_task(4.0, "VertifyBan", id)
return PLUGIN_CONTINUE
}
new iIp[32] ; get_user_ip(id, iIp, 31) ; trim(iIp)
new Handle:query = SQL_PrepareQuery(sqlconnect, "SELECT bid FROM %s_bans WHERE ((type = 0 AND authid REGEXP '^^%s$') OR (type = 1 AND ip = '%s')) AND (length = '0' OR ends > UNIX_TIMESTAMP()) AND RemoveType IS NULL",prefix, iSteam, iIp )
SQL_Execute(query)
new Result
if(SQL_MoreResults(query))
Result = SQL_ReadResult(query, 0)
if(!Result)
{
log_to_file(LOG_FILE, "No Result found on : %s (Result : %d)", iSteam, Result)
SQL_FreeHandle(query) ; SQL_FreeHandle(sqlconnect)
return PLUGIN_CONTINUE
}
new iName[32] ; get_user_name(id, iName, 31) ; trim(iName)
new iName2[32] ; MakeStringSQLSafe(iName, iName2, 31)
new iQuery[512]
formatex(iQuery, 511, "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 '^^%s$') OR (type = 1 AND ip = '%s')) AND RemoveType IS NULL LIMIT 0,1))", prefix, prefix, ServerIp, ServerPort, iName2, prefix, iSteam, iIp)
trim(iQuery) ; query = Empty_Handle
query = SQL_PrepareQuery(sqlconnect, "%s", iQuery)
SQL_Execute(query) ; SQL_FreeHandle(query) ; SQL_FreeHandle(sqlconnect)
log_to_file(LOG_FILE, "AMXX Sourcebans Kicked : (Name : %s | STEAM : %s | IP : %s)", iName, iSteam, iIp)
server_cmd("kick #%i ^"You are banned from this server. Visit %s for info^"", get_user_userid(id), WEBSITE)
return PLUGIN_CONTINUE
}
return PLUGIN_CONTINUE
}
////////////////////////////////////////////////////////////////////////////////////////////////////
public UTIL_InsertBan(banTime, id, const Name[], const Authid[], const Ip[], const Reason[], const AdminAuthid[], const AdminIp[])
{
if(do_connection())
{
new iQ[1024]
formatex(iQ,1023,"INSERT INTO %s_bans (ip, authid, name, created, ends, length, reason, aid, adminIp, sid, country) VALUES ('%s', '%s', '%s', UNIX_TIMESTAMP(), UNIX_TIMESTAMP() + %d, %d, '%s', IFNULL((SELECT aid FROM %s_admins WHERE authid = '%s' OR authid REGEXP '^^%s$'),'0'), '%s', (SELECT sid FROM %s_servers WHERE ip = '%s' AND port='%s' LIMIT 0,1), ' ')", prefix, Ip, Authid, Name, (banTime*60), (banTime*60), Reason, prefix, AdminAuthid, AdminAuthid, AdminIp, prefix, ServerIp, ServerPort)
log_to_file(LOG_FILE, "iQ : %s", iQ)
new Handle:query = SQL_PrepareQuery(sqlconnect, "%s", iQ )
SQL_Execute(query) ; SQL_FreeHandle(query) ; SQL_FreeHandle(sqlconnect)
if(!id)
return 1
server_cmd("kick #%d ^"BANNED: Reason: >%s< - Visit %s for info^"", get_user_userid(id), Reason, WEBSITE)
return 1
}
return 0
}
////////////////////////////////////////////////////////////////////////////////////////////////////
public BanMenu(id)
{
new menu = menu_create("\rAMXX Sourcebans menu:", "BanMenu_handler")
new players[32], pnum, tempid
new szName[32], szTempid[10]
get_players(players, pnum)
for( new i; i<pnum; i++ )
{
tempid = players[i]
if(is_user_bot(tempid))
continue
get_user_name(tempid, szName, 31)
num_to_str(tempid, szTempid, 9)
menu_additem(menu, szName, szTempid, ADMIN_BAN)
}
menu_display(id, menu, 0)
return PLUGIN_HANDLED
}
////////////////////////////////////////////////////////////////////////////////////////////////////
public BanMenu_handler(id, menu, item)
{
if( item == MENU_EXIT )
{
menu_destroy(menu)
return PLUGIN_HANDLED
}
new data[6], iName[64]
new access, callback
menu_item_getinfo(menu, item, access, data, 5, iName, 63, callback)
new tempid = str_to_num(data)
AdminTarget[id] = tempid
menu_destroy(menu)
BanTimeMenu(id)
return PLUGIN_HANDLED;
}
////////////////////////////////////////////////////////////////////////////////////////////////////
public BanTimeMenu(id)
{
new menu = menu_create("\rPick Time To Ban:", "BanTimeMenu_handler")
for(new r ; r < sizeof BanTimesStr ; r ++)
{
new str[4] ; num_to_str(r, str, 3)
menu_additem(menu, BanTimesStr[r], str, ADMIN_BAN)
}
menu_display(id, menu, 0)
return PLUGIN_HANDLED
}
////////////////////////////////////////////////////////////////////////////////////////////////////
public BanTimeMenu_handler(id, menu, item)
{
if( item == MENU_EXIT )
{
menu_destroy(menu)
return PLUGIN_HANDLED
}
new data[6], iName[64]
new iAccess, callback
menu_item_getinfo(menu, item, iAccess, data,5, iName, 63, callback);
new key = str_to_num(data)
AdminBanTime[id] = BanTimesInt[key] ; AdminBanTimeStrNum[id] = key
BanReasonMenu(id)
return PLUGIN_HANDLED
}
////////////////////////////////////////////////////////////////////////////////////////////////////
public BanReasonMenu(id)
{
new menu = menu_create("\rPick Ban Reason:", "BanReasonMenu_handler");
for(new r = 0 ; r < sizeof BanReasons ; r ++)
{
new str[4] ; num_to_str(r, str, 3)
menu_additem(menu, BanReasons[r], str, ADMIN_BAN);
}
menu_display(id, menu, 0)
return PLUGIN_HANDLED
}
////////////////////////////////////////////////////////////////////////////////////////////////////
public BanReasonMenu_handler(id, menu, item)
{
if( item == MENU_EXIT )
{
menu_destroy(menu)
AdminBanTime[id] = 1
return PLUGIN_HANDLED
}
new data[6], iName[64]
new iAccess, callback
menu_item_getinfo(menu, item, iAccess, data,5, iName, 63, callback)
new key = str_to_num(data)
new iReason[64] ; formatex(iReason, 63, "%s", BanReasons[key])
new iReason2[64] ; MakeStringSQLSafe(iReason, iReason2, 63)
new szName[32] ; get_user_name(AdminTarget[id], szName, 31)
client_print(id, 3, "Client : %s | BanTime : %d | Reason : %s", szName, AdminBanTime[id], iReason)
//////////////////////////////////////////////////////////////
new AdminId[32] ; get_user_authid(id, AdminId, 31)
new AdminIp[32] ; get_user_ip(id, AdminIp, 31, 1)
new AdminName[32] ; get_user_name(id, AdminName, 31)
new BannedId[32] ; get_user_authid(AdminTarget[id], BannedId, 31)
new BannedIp[32] ; get_user_ip(AdminTarget[id], BannedIp, 31, 1)
new BannedName[32] ; get_user_name(AdminTarget[id], BannedName, 31)
new BannedName2[32] ; MakeStringSQLSafe(BannedName, BannedName2, 31)
log_to_file(LOG_FILE, "Admin: %s(%s) Banned %s(%s) %s -> Reason: %s", AdminName, AdminId, BannedName, BannedId, BanTimesStr[AdminBanTimeStrNum[id]], iReason)
/////////////////////////////////////
new HudMessage[128]
formatex(HudMessage, 127, " - Admin:%s^n - Banned:%s^n - Ban Time:%s^n - Reason:%s", AdminName, BannedName, BanTimesStr[AdminBanTimeStrNum[id]], iReason)
set_hudmessage(255, 0, 0, 0.03, 0.15, 2, 1.5, 15.0, 0.06)
show_hudmessage(0, "%s", HudMessage)
/////////////////////////////////////
client_print(0, print_console, "[SERVER CONSOLE] Admin: %s Banned %s (%s) %s", AdminName, BannedName, BannedId, BanTimesStr[AdminBanTimeStrNum[id]])
client_print(0, print_console, "[SERVER CONSOLE] -> Ban Reason: %s", iReason)
/////////////////////////////////////
client_print(AdminTarget[id], print_console, "*************************************")
client_print(AdminTarget[id], print_console, "---------------------- BANNED -------------------")
client_print(AdminTarget[id], print_console, "* -> Ban Reason: %s", iReason)
client_print(AdminTarget[id], print_console, "* -> Ban Time: %s", BanTimesStr[AdminBanTimeStrNum[id]])
client_print(AdminTarget[id], print_console, "* If you think you where treated unfair you can *")
client_print(AdminTarget[id], print_console, "---------- protest @ %s ------------", WEBSITE)
client_print(AdminTarget[id], print_console, "*************************************")
/////////////////////////////////////
if(!UTIL_InsertBan(AdminBanTime[id], AdminTarget[id], BannedName2, BannedId, BannedIp, iReason2, AdminId, AdminIp))
server_cmd("banid %d #%d kick;writeid", AdminBanTime[id], BannedId)
server_cmd("banid %d #%d ;writeid", AdminBanTime[id], get_user_userid(id))
server_exec()
AdminBanTime[id] = 1 ; AdminBanTimeStrNum[id] = 0
return PLUGIN_HANDLED
}