hlmod.hu

Magyar Half-Life Mód közösség!
Pontos idő: 2024.06.06. 15:55



Jelenlévő felhasználók

Jelenleg 265 felhasználó van jelen :: 2 regisztrált, 0 rejtett és 263 vendég

A legtöbb felhasználó (1565 fő) 2020.11.21. 11:26-kor tartózkodott itt.

Regisztrált felhasználók: Bing [Bot], Google [Bot] az elmúlt 5 percben aktív felhasználók alapján

Utoljára aktív
Ahhoz hogy lásd ki volt utoljára aktív, be kell jelentkezned.



Az oldal teljeskörű
használatához regisztrálj.

Regisztráció

Kereső


Új téma nyitása  Hozzászólás a témához  [ 5 hozzászólás ] 
Szerző Üzenet
 Hozzászólás témája: MySQL ban
HozzászólásElküldve: 2015.08.10. 19:55 
Offline
Tud valamit

Csatlakozott: 2013.03.02. 17:41
Hozzászólások: 124
Megköszönt másnak: 31 alkalommal
Üdvözletem!

olyan plugint keresek, amivel MySQL táblázatba menthetem a banokat NÉV, IP, SteamID, ban ideje alapján.

előre is köszönöm a segítségeket :D


Hozzászólás jelentése
Vissza a tetejére
   
 Hozzászólás témája: Re: MySQL ban
HozzászólásElküldve: 2015.08.10. 20:07 
Offline
Fanatikus
Avatar

Csatlakozott: 2015.07.21. 00:49
Hozzászólások: 178
Megköszönt másnak: 23 alkalommal
Megköszönték neki: 20 alkalommal
Advanced Ban.


Hozzászólás jelentése
Vissza a tetejére
   
 Hozzászólás témája: Re: MySQL ban
HozzászólásElküldve: 2015.08.10. 20:30 
Offline
Tiszteletbeli
Avatar

Csatlakozott: 2014.09.08. 22:21
Hozzászólások: 3014
Megköszönt másnak: 96 alkalommal
Megköszönték neki: 555 alkalommal
Az régi.
mforce @ Advanced Ban
Ebbe javítva van a megszakadás.

_________________
GitHub - mforce


Hozzászólás jelentése
Vissza a tetejére
   
 Hozzászólás témája: Re: MySQL ban
HozzászólásElküldve: 2015.08.11. 18:36 
Offline
Jómunkásember
Avatar

Csatlakozott: 2013.01.15. 19:04
Hozzászólások: 407
Megköszönt másnak: 17 alkalommal
Megköszönték neki: 176 alkalommal
Mivel nekem mforce által átírt plugint nem volt hajlandó megfelelően működni, ezért én is javítottam az alap plugint egy másik megoldással ami nekem tökéletesen működik.
Ha neked sem működne mforce pluginja akkor próbáld ezt:
SMA Forráskód: [ Mindet kijelol ]
  1. #include <amxmodx>
  2. #include <amxmisc>
  3. #include <engine>
  4. #include <regex>
  5.  
  6. #define PLUGIN_NAME "Advanced Bans"
  7. #define PLUGIN_VERSION "0.8.1"
  8. #define PLUGIN_AUTHOR "Exolent"
  9.  
  10. #pragma semicolon 1
  11.  
  12. // uncomment the line below if you want this plugin to
  13. // load old bans from the banned.cfg and listip.cfg files
  14. //#define KEEP_DEFAULT_BANS
  15.  
  16. // uncomment the line below if you want the history to be in one file
  17. //#define HISTORY_ONE_FILE
  18.  
  19. // if you must have a maximum amount of bans to be compatible with AMXX versions before 1.8.0
  20. // change this number to your maximum amount
  21. // if you would rather have unlimited (requires AMXX 1.8.0 or higher) then set it to 0
  22. #define MAX_BANS 0
  23.  
  24. #include <sqlx>
  25.  
  26. #define TABLE_NAME "advanced_bans"
  27. #define KEY_NAME "name"
  28. #define KEY_STEAMID "steamid"
  29. #define KEY_BANLENGTH "banlength"
  30. #define KEY_UNBANTIME "unbantime"
  31. #define KEY_REASON "reason"
  32. #define KEY_ADMIN_NAME "admin_name"
  33. #define KEY_ADMIN_STEAMID "admin_steamid"
  34.  
  35. #define RELOAD_BANS_INTERVAL 60.0
  36.  
  37. #define REGEX_IP_PATTERN "\b(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\b"
  38. #define REGEX_STEAMID_PATTERN "^^STEAM_0:(0|1):\d+$"
  39.  
  40. new Regex:g_IP_pattern;
  41. new Regex:g_SteamID_pattern;
  42. new g_regex_return;
  43.  
  44. #define IsValidIP(%1) (regex_match_c(%1, g_IP_pattern, g_regex_return) > 0)
  45. #define IsValidAuthid(%1) (regex_match_c(%1, g_SteamID_pattern, g_regex_return) > 0)
  46.  
  47. enum // for name displaying
  48. {
  49. ACTIVITY_NONE, // nothing is shown
  50. ACTIVITY_HIDE, // admin name is hidden
  51. ACTIVITY_SHOW // admin name is shown
  52. };
  53. new const g_admin_activity[] =
  54. {
  55. ACTIVITY_NONE, // amx_show_activity 0 = show nothing to everyone
  56. ACTIVITY_HIDE, // amx_show_activity 1 = hide admin name from everyone
  57. ACTIVITY_SHOW, // amx_show_activity 2 = show admin name to everyone
  58. ACTIVITY_SHOW, // amx_show_activity 3 = show name to admins but hide it from normal users
  59. ACTIVITY_SHOW, // amx_show_activity 4 = show name to admins but show nothing to normal users
  60. ACTIVITY_HIDE // amx_show_activity 5 = hide name from admins but show nothing to normal users
  61. };
  62. new const g_normal_activity[] =
  63. {
  64. ACTIVITY_NONE, // amx_show_activity 0 = show nothing to everyone
  65. ACTIVITY_HIDE, // amx_show_activity 1 = hide admin name from everyone
  66. ACTIVITY_SHOW, // amx_show_activity 2 = show admin name to everyone
  67. ACTIVITY_HIDE, // amx_show_activity 3 = show name to admins but hide it from normal users
  68. ACTIVITY_NONE, // amx_show_activity 4 = show name to admins but show nothing to normal users
  69. ACTIVITY_NONE // amx_show_activity 5 = hide name from admins but show nothing to normal users
  70. };
  71.  
  72.  
  73. #if MAX_BANS <= 0
  74. enum _:BannedData
  75. {
  76. bd_name[32],
  77. bd_steamid[35],
  78. bd_banlength,
  79. bd_unbantime[32],
  80. bd_reason[128],
  81. bd_admin_name[64],
  82. bd_admin_steamid[35]
  83. };
  84.  
  85. new Trie:g_trie;
  86. new Array:g_array;
  87. #else
  88. new g_names[MAX_BANS][32];
  89. new g_steamids[MAX_BANS][35];
  90. new g_banlengths[MAX_BANS];
  91. new g_unbantimes[MAX_BANS][32];
  92. new g_reasons[MAX_BANS][128];
  93. new g_admin_names[MAX_BANS][64];
  94. new g_admin_steamids[MAX_BANS][35];
  95. #endif
  96. new g_total_bans;
  97.  
  98. new Handle:g_SqlTuple;
  99.  
  100. new Host[] = "Host";
  101. new User[] = "Felhasznalo";
  102. new Pass[] = "Jelszo";
  103. new Db[] = "Adatbazis";
  104.  
  105. new bool:g_loading_bans = true;
  106.  
  107. new const Prefix[] = "[AdvancedBans]";
  108. new ab_website;
  109. new ab_immunity;
  110. new ab_bandelay;
  111. new ab_unbancheck;
  112.  
  113. new amx_show_activity;
  114.  
  115. #if MAX_BANS <= 0
  116. new Array:g_maxban_times;
  117. new Array:g_maxban_flags;
  118. #else
  119. #define MAX_BANLIMITS 30
  120. new g_maxban_times[MAX_BANLIMITS];
  121. new g_maxban_flags[MAX_BANLIMITS];
  122. #endif
  123. new g_total_maxban_times;
  124.  
  125. new g_unban_entity;
  126.  
  127. new g_max_clients;
  128.  
  129. new g_msgid_SayText;
  130. new timp[64];
  131.  
  132. public plugin_init()
  133. {
  134. register_plugin(PLUGIN_NAME, PLUGIN_VERSION, PLUGIN_AUTHOR);
  135. register_cvar("advanced_bans", PLUGIN_VERSION, FCVAR_SPONLY);
  136.  
  137. register_dictionary("advanced_bans.txt");
  138.  
  139. register_concmd("amx_ban", "CmdBan", ADMIN_BAN, "<nick, #userid, authid> <time in minutes> <reason>");
  140. register_concmd("amx_banip", "CmdBanIp", ADMIN_BAN, "<nick, #userid, authid> <time in minutes> <reason>");
  141. register_concmd("amx_addban", "CmdAddBan", ADMIN_BAN, "<name> <authid or ip> <time in minutes> <reason>");
  142. register_concmd("amx_unban", "CmdUnban", ADMIN_BAN, "<authid or ip>");
  143. register_concmd("amx_banlist", "CmdBanList", ADMIN_BAN, "[start] -- shows everyone who is banned");
  144. register_srvcmd("amx_addbanlimit", "CmdAddBanLimit", -1, "<flag> <time in minutes>");
  145.  
  146. ab_website = register_cvar("ab_website", "");
  147. ab_immunity = register_cvar("ab_immunity", "1");
  148. ab_bandelay = register_cvar("ab_bandelay", "1.0");
  149. ab_unbancheck = register_cvar("ab_unbancheck", "5.0");
  150.  
  151. amx_show_activity = register_cvar("amx_show_activity", "2");
  152.  
  153. #if MAX_BANS <= 0
  154. g_trie = TrieCreate();
  155. g_array = ArrayCreate(BannedData);
  156. #endif
  157.  
  158. #if !defined MAX_BANLIMITS
  159. g_maxban_times = ArrayCreate(1);
  160. g_maxban_flags = ArrayCreate(1);
  161. #endif
  162.  
  163. makeTuple();
  164. createTable();
  165.  
  166. new error[2];
  167. g_IP_pattern = regex_compile(REGEX_IP_PATTERN, g_regex_return, error, sizeof(error) - 1);
  168. g_SteamID_pattern = regex_compile(REGEX_STEAMID_PATTERN, g_regex_return, error, sizeof(error) - 1);
  169.  
  170. g_max_clients = get_maxplayers();
  171.  
  172. g_msgid_SayText = get_user_msgid("SayText");
  173. }
  174.  
  175. public makeTuple()
  176. {
  177. g_SqlTuple = SQL_MakeDbTuple(Host,User,Pass,Db);
  178. }
  179. public createTable()
  180. {
  181. new query[1024];
  182. formatex(query, sizeof(query) - 1,\
  183. "CREATE TABLE IF NOT EXISTS `%s` (`%s` varchar(32) NOT NULL, `%s` varchar(35) NOT NULL, `%s` int(10) NOT NULL, `%s` varchar(32) NOT NULL, `%s` varchar(128) NOT NULL, `%s` varchar(64) NOT NULL, `%s` varchar(35) NOT NULL);",\
  184. TABLE_NAME, KEY_NAME, KEY_STEAMID, KEY_BANLENGTH, KEY_UNBANTIME, KEY_REASON, KEY_ADMIN_NAME, KEY_ADMIN_STEAMID
  185. );
  186.  
  187. SQL_ThreadQuery(g_SqlTuple, "QueryCreateTable", query);
  188. }
  189.  
  190. public QueryCreateTable(failstate, Handle:query, error[], errcode, data[], datasize, Float:queuetime)
  191. {
  192. if( failstate == TQUERY_CONNECT_FAILED )
  193. {
  194. set_fail_state("Could not connect to database.");
  195. }
  196. else if( failstate == TQUERY_QUERY_FAILED )
  197. {
  198. set_fail_state("Query failed.");
  199. }
  200. else if( errcode )
  201. {
  202. log_amx("Error on query: %s", error);
  203. }
  204. else
  205. {
  206. LoadBans();
  207. }
  208. }
  209.  
  210. public plugin_cfg()
  211. {
  212. CreateUnbanEntity();
  213. }
  214.  
  215. public CreateUnbanEntity()
  216. {
  217. static failtimes;
  218.  
  219. g_unban_entity = create_entity("info_target");
  220.  
  221. if( !is_valid_ent(g_unban_entity) )
  222. {
  223. ++failtimes;
  224.  
  225. log_amx("[ERROR] Failed to create unban entity (%i/10)", failtimes);
  226.  
  227. if( failtimes < 10 )
  228. {
  229. set_task(1.0, "CreateUnbanEntity");
  230. }
  231. else
  232. {
  233. log_amx("[ERROR] Could not create unban entity!");
  234. }
  235.  
  236. return;
  237. }
  238.  
  239. entity_set_string(g_unban_entity, EV_SZ_classname, "unban_entity");
  240. entity_set_float(g_unban_entity, EV_FL_nextthink, get_gametime() + 1.0);
  241.  
  242. register_think("unban_entity", "FwdThink");
  243. }
  244.  
  245. public client_authorized(client)
  246. {
  247. static authid[35];
  248. get_user_authid(client, authid, sizeof(authid) - 1);
  249.  
  250. static ip[35];
  251. get_user_ip(client, ip, sizeof(ip) - 1, 1);
  252.  
  253. #if MAX_BANS > 0
  254. static banned_authid[35], bool:is_ip;
  255. for( new i = 0; i < g_total_bans; i++ )
  256. {
  257. copy(banned_authid, sizeof(banned_authid) - 1, g_steamids[i]);
  258.  
  259. is_ip = bool:(containi(banned_authid, ".") != -1);
  260.  
  261. if( is_ip && equal(ip, banned_authid) || !is_ip && equal(authid, banned_authid) )
  262. {
  263. static name[32], reason[128], unbantime[32], admin_name[32], admin_steamid[64];
  264. copy(name, sizeof(name) - 1, g_names[i]);
  265. copy(reason, sizeof(reason) - 1, g_reasons[i]);
  266. new banlength = g_banlengths[i];
  267. copy(unbantime, sizeof(unbantime) - 1, g_unbantimes[i]);
  268. copy(admin_name, sizeof(admin_name) - 1, g_admin_names[i]);
  269. copy(admin_steamid, sizeof(admin_steamid) - 1, g_admin_steamids[i]);
  270.  
  271. PrintBanInformation(client, name, banned_authid, reason, banlength, unbantime, admin_name, admin_steamid, true, true);
  272.  
  273. set_task(get_pcvar_float(ab_bandelay), "TaskDisconnectPlayer", client);
  274. break;
  275. }
  276. }
  277. #else
  278. static array_pos;
  279.  
  280. if( TrieGetCell(g_trie, authid, array_pos) || TrieGetCell(g_trie, ip, array_pos) )
  281. {
  282. static data[BannedData];
  283. ArrayGetArray(g_array, array_pos, data);
  284.  
  285. PrintBanInformation(client, data[bd_name], data[bd_steamid], data[bd_reason], data[bd_banlength], data[bd_unbantime], data[bd_admin_name], data[bd_admin_steamid], true, true);
  286.  
  287. set_task(get_pcvar_float(ab_bandelay), "TaskDisconnectPlayer", client);
  288. }
  289. #endif
  290. }
  291.  
  292. public CmdBan(client, level, cid)
  293. {
  294. if( !cmd_access(client, level, cid, 4) ) return PLUGIN_HANDLED;
  295.  
  296. static arg[128];
  297. read_argv(1, arg, sizeof(arg) - 1);
  298.  
  299. new target = cmd_target(client, arg, GetTargetFlags(client));
  300. if( !target ) return PLUGIN_HANDLED;
  301.  
  302. static target_authid[35];
  303. get_user_authid(target, target_authid, sizeof(target_authid) - 1);
  304.  
  305. if( !IsValidAuthid(target_authid) )
  306. {
  307. console_print(client, "%s %L", Prefix, client, "AB_NOT_AUTHORIZED");
  308. return PLUGIN_HANDLED;
  309. }
  310.  
  311. #if MAX_BANS <= 0
  312. if( TrieKeyExists(g_trie, target_authid) )
  313. {
  314. console_print(client, "%s %L", Prefix, client, "AB_ALREADY_BANNED_STEAMID");
  315. return PLUGIN_HANDLED;
  316. }
  317. #else
  318. for( new i = 0; i < g_total_bans; i++ )
  319. {
  320. if( !strcmp(target_authid, g_steamids[i], 1) )
  321. {
  322. console_print(client, "%s %L", Prefix, client, "AB_ALREADY_BANNED_STEAMID");
  323. return PLUGIN_HANDLED;
  324. }
  325. }
  326. #endif
  327.  
  328. read_argv(2, arg, sizeof(arg) - 1);
  329.  
  330. new length = str_to_num(arg);
  331. new maxlength = GetMaxBanTime(client);
  332.  
  333. if( maxlength && (!length || length > maxlength) )
  334. {
  335. console_print(client, "%s %L", Prefix, client, "AB_MAX_BAN_TIME", maxlength);
  336. return PLUGIN_HANDLED;
  337. }
  338.  
  339. static unban_time[64];
  340. if( length == 0 )
  341. {
  342. formatex(unban_time, sizeof(unban_time) - 1, "%L", client, "AB_PERMANENT_BAN");
  343. }
  344. else
  345. {
  346. GenerateUnbanTime(length, unban_time, sizeof(unban_time) - 1);
  347. }
  348.  
  349. read_argv(3, arg, sizeof(arg) - 1);
  350.  
  351. static admin_name[64], target_name[32];
  352. get_user_name(client, admin_name, sizeof(admin_name) - 1);
  353. get_user_name(target, target_name, sizeof(target_name) - 1);
  354.  
  355. static admin_authid[35];
  356. get_user_authid(client, admin_authid, sizeof(admin_authid) - 1);
  357.  
  358. AddBan(target_name, target_authid, arg, length, unban_time, admin_name, admin_authid);
  359.  
  360. PrintBanInformation(target, target_name, target_authid, arg, length, unban_time, admin_name, admin_authid, true, true);
  361. PrintBanInformation(client, target_name, target_authid, arg, length, unban_time, admin_name, admin_authid, false, false);
  362.  
  363. get_time("%Y.%m.%d / %H:%M:%S",timp,63);
  364. set_task( 0.1, "snapshot1", target );
  365. set_task( 0.9, "snapshot2", target );
  366.  
  367. GetBanTime(length, unban_time, sizeof(unban_time) - 1);
  368.  
  369. ChatColorM( target, "!t%s Admin neve: !g %s", Prefix, admin_name);
  370. ChatColorM( target, "!t%s Játékos neved:!g %s", Prefix, target_name);
  371. ChatColorM( target, "!t%s Indok:!g %s", Prefix, arg);
  372. ChatColorM( target, "!t%s Dátum / Idõ:!g %s", Prefix, timp);
  373. PrintActivity(admin_name, "^x03%s^x04 $name^x03 : bannolta^x04 %s^x03. Indok:^x04 %s^x03. Idõ:^x04 %s", Prefix, target_name, arg, unban_time);
  374. set_task(get_pcvar_float(ab_bandelay), "TaskDisconnectPlayer", target);
  375.  
  376. Log("%s <%s> Kitiltotta %s <%s> || Indok: ^"%s^" || Idő: %s", admin_name, admin_authid, target_name, target_authid, arg, unban_time);
  377.  
  378. return PLUGIN_HANDLED;
  379. }
  380.  
  381. public snapshot1( tempid )
  382. {
  383. client_cmd( tempid, "snapshot" );
  384. }
  385. public snapshot2( tempid )
  386. {
  387. client_cmd( tempid, "snapshot" );
  388. }
  389.  
  390. stock ChatColorM(const id, const input[], any:...)
  391. {
  392. new count = 1, players[32];
  393. static msg[191];
  394. vformat(msg, 190, input, 3);
  395.  
  396. replace_all(msg, 190, "!g", "^4"); // Green Color
  397. replace_all(msg, 190, "!y", "^1"); // Default Color
  398. replace_all(msg, 190, "!t", "^3"); // Team Color
  399.  
  400. if (id) players[0] = id; else get_players(players, count, "ch");
  401. {
  402. for (new i = 0; i < count; i++)
  403. {
  404. if (is_user_connected(players[i]))
  405. {
  406. message_begin(MSG_ONE_UNRELIABLE, get_user_msgid("SayText"), _, players[i]);
  407. write_byte(players[i]);
  408. write_string(msg);
  409. message_end();
  410. }
  411. }
  412. }
  413. }
  414.  
  415. public CmdBanIp(client, level, cid)
  416. {
  417. if( !cmd_access(client, level, cid, 4) ) return PLUGIN_HANDLED;
  418.  
  419. static arg[128];
  420. read_argv(1, arg, sizeof(arg) - 1);
  421.  
  422. new target = cmd_target(client, arg, GetTargetFlags(client));
  423. if( !target ) return PLUGIN_HANDLED;
  424.  
  425. static target_ip[35];
  426. get_user_ip(target, target_ip, sizeof(target_ip) - 1, 1);
  427.  
  428. #if MAX_BANS <= 0
  429. if( TrieKeyExists(g_trie, target_ip) )
  430. {
  431. console_print(client, "%s %L", Prefix, client, "AB_ALREADY_BANNED_IP");
  432. return PLUGIN_HANDLED;
  433. }
  434. #else
  435. for( new i = 0; i < g_total_bans; i++ )
  436. {
  437. if( !strcmp(target_ip, g_steamids[i], 1) )
  438. {
  439. console_print(client, "%s %L", Prefix, client, "AB_ALREADY_BANNED_IP");
  440. return PLUGIN_HANDLED;
  441. }
  442. }
  443. #endif
  444.  
  445. read_argv(2, arg, sizeof(arg) - 1);
  446.  
  447. new length = str_to_num(arg);
  448. new maxlength = GetMaxBanTime(client);
  449.  
  450. if( maxlength && (!length || length > maxlength) )
  451. {
  452. console_print(client, "%s %L", Prefix, client, "AB_MAX_BAN_TIME", maxlength);
  453. return PLUGIN_HANDLED;
  454. }
  455.  
  456. static unban_time[32];
  457.  
  458. if( length == 0 )
  459. {
  460. formatex(unban_time, sizeof(unban_time) - 1, "%L", client, "AB_PERMANENT_BAN");
  461. }
  462. else
  463. {
  464. GenerateUnbanTime(length, unban_time, sizeof(unban_time) - 1);
  465. }
  466.  
  467. read_argv(3, arg, sizeof(arg) - 1);
  468.  
  469. static admin_name[64], target_name[32];
  470. get_user_name(client, admin_name, sizeof(admin_name) - 1);
  471. get_user_name(target, target_name, sizeof(target_name) - 1);
  472.  
  473. static admin_authid[35];
  474. get_user_authid(client, admin_authid, sizeof(admin_authid) - 1);
  475.  
  476. AddBan(target_name, target_ip, arg, length, unban_time, admin_name, admin_authid);
  477.  
  478. PrintBanInformation(target, target_name, target_ip, arg, length, unban_time, admin_name, admin_authid, true, true);
  479. PrintBanInformation(client, target_name, target_ip, arg, length, unban_time, admin_name, admin_authid, false, false);
  480.  
  481. set_task(get_pcvar_float(ab_bandelay), "TaskDisconnectPlayer", target);
  482.  
  483. GetBanTime(length, unban_time, sizeof(unban_time) - 1);
  484.  
  485. PrintActivity(admin_name, "^x03%s^x04 $name^x03 : bannolta^x04 %s^x03. Indok:^x04 %s^x03. Idõ:^x04 %s", Prefix, target_name, arg, unban_time);
  486.  
  487. Log("%s <%s> banned %s <%s> || Reason: ^"%s^" || Ban Length: %s", admin_name, admin_authid, target_name, target_ip, arg, unban_time);
  488.  
  489. return PLUGIN_HANDLED;
  490. }
  491.  
  492. public CmdAddBan(client, level, cid)
  493. {
  494. if( !cmd_access(client, level, cid, 5) ) return PLUGIN_HANDLED;
  495.  
  496. static target_name[32], target_authid[35], bantime[10], reason[128];
  497. read_argv(1, target_name, sizeof(target_name) - 1);
  498. read_argv(2, target_authid, sizeof(target_authid) - 1);
  499. read_argv(3, bantime, sizeof(bantime) - 1);
  500. read_argv(4, reason, sizeof(reason) - 1);
  501.  
  502. new bool:is_ip = bool:(containi(target_authid, ".") != -1);
  503.  
  504. if( !is_ip && !IsValidAuthid(target_authid) )
  505. {
  506. console_print(client, "%s %L", Prefix, client, "AB_INVALID_STEAMID");
  507. console_print(client, "%s %L", Prefix, client, "AB_VALID_STEAMID_FORMAT");
  508.  
  509. return PLUGIN_HANDLED;
  510. }
  511. else if( is_ip )
  512. {
  513. new pos = contain(target_authid, ":");
  514. if( pos > 0 )
  515. {
  516. target_authid[pos] = 0;
  517. }
  518.  
  519. if( !IsValidIP(target_authid) )
  520. {
  521. console_print(client, "%s %L", Prefix, client, "AB_INVALID_IP");
  522.  
  523. return PLUGIN_HANDLED;
  524. }
  525. }
  526.  
  527. #if MAX_BANS <= 0
  528. if( TrieKeyExists(g_trie, target_authid) )
  529. {
  530. console_print(client, "%s %L", Prefix, client, is_ip ? "AB_ALREADY_BANNED_IP" : "AB_ALREADY_BANNED_STEAMID");
  531. return PLUGIN_HANDLED;
  532. }
  533. #else
  534. for( new i = 0; i < g_total_bans; i++ )
  535. {
  536. if( !strcmp(target_authid, g_steamids[i], 1) )
  537. {
  538. console_print(client, "%s %L", Prefix, client, is_ip ? "AB_ALREADY_BANNED_IP" : "AB_ALREADY_BANNED_STEAMID");
  539. return PLUGIN_HANDLED;
  540. }
  541. }
  542. #endif
  543.  
  544. new length = str_to_num(bantime);
  545. new maxlength = GetMaxBanTime(client);
  546.  
  547. if( maxlength && (!length || length > maxlength) )
  548. {
  549. console_print(client, "%s %L", Prefix, client, "AB_MAX_BAN_TIME", maxlength);
  550. return PLUGIN_HANDLED;
  551. }
  552.  
  553. if( is_user_connected(find_player(is_ip ? "d" : "c", target_authid)) )
  554. {
  555. client_cmd(client, "amx_ban ^"%s^" %i ^"%s^"", target_authid, length, reason);
  556. return PLUGIN_HANDLED;
  557. }
  558.  
  559. static unban_time[32];
  560. if( length == 0 )
  561. {
  562. formatex(unban_time, sizeof(unban_time) - 1, "%L", client, "AB_PERMANENT_BAN");
  563. }
  564. else
  565. {
  566. GenerateUnbanTime(length, unban_time, sizeof(unban_time) - 1);
  567. }
  568.  
  569. static admin_name[64], admin_authid[35];
  570. get_user_name(client, admin_name, sizeof(admin_name) - 1);
  571. get_user_authid(client, admin_authid, sizeof(admin_authid) - 1);
  572.  
  573. AddBan(target_name, target_authid, reason, length, unban_time, admin_name, admin_authid);
  574.  
  575. PrintBanInformation(client, target_name, target_authid, reason, length, unban_time, "", "", false, false);
  576.  
  577. GetBanTime(length, unban_time, sizeof(unban_time) - 1);
  578.  
  579. PrintActivity(admin_name, "^x04%s $name^x01 :^x03 ban %s %s. Indok: %s. Idő: %s", Prefix, is_ip ? "IP" : "SteamID", target_authid, reason, unban_time);
  580.  
  581. Log("%s <%s> banned %s <%s> || Reason: ^"%s^" || Ban Length: %s", admin_name, admin_authid, target_name, target_authid, reason, unban_time);
  582.  
  583. return PLUGIN_HANDLED;
  584. }
  585.  
  586. public CmdUnban(client, level, cid)
  587. {
  588. if( !cmd_access(client, level, cid, 2) ) return PLUGIN_HANDLED;
  589.  
  590. static arg[35];
  591. read_argv(1, arg, sizeof(arg) - 1);
  592.  
  593. #if MAX_BANS > 0
  594. static banned_authid[35];
  595. for( new i = 0; i < g_total_bans; i++ )
  596. {
  597. copy(banned_authid, sizeof(banned_authid) - 1, g_steamids[i]);
  598.  
  599. if( equal(arg, banned_authid) )
  600. {
  601. static admin_name[64];
  602. get_user_name(client, admin_name, sizeof(admin_name) - 1);
  603.  
  604. static name[32], reason[128];
  605. copy(name, sizeof(name) - 1, g_names[i]);
  606. copy(reason, sizeof(reason) - 1, g_reasons[i]);
  607.  
  608. PrintActivity(admin_name, "^x04%s $name^x01 :^x03 feloldotta %s^x01 [%s] [Indok: %s]", Prefix, name, arg, reason);
  609.  
  610. static authid[35];
  611. get_user_authid(client, authid, sizeof(authid) - 1);
  612.  
  613. Log("%s <%s> unbanned %s <%s> || Ban Reason: ^"%s^"", admin_name, authid, name, arg, reason);
  614.  
  615. RemoveBan(i);
  616.  
  617. return PLUGIN_HANDLED;
  618. }
  619. }
  620. #else
  621. if( TrieKeyExists(g_trie, arg) )
  622. {
  623. static array_pos;
  624. TrieGetCell(g_trie, arg, array_pos);
  625.  
  626. static data[BannedData];
  627. ArrayGetArray(g_array, array_pos, data);
  628.  
  629. static unban_name[32];
  630. get_user_name(client, unban_name, sizeof(unban_name) - 1);
  631.  
  632. PrintActivity(unban_name, "^x04%s $name^x01 :^x03 feloldotta %s^x01 [%s] [Indok: %s]", Prefix, data[bd_name], data[bd_steamid], data[bd_reason]);
  633.  
  634. static admin_name[64];
  635. get_user_name(client, admin_name, sizeof(admin_name) - 1);
  636.  
  637. static authid[35];
  638. get_user_authid(client, authid, sizeof(authid) - 1);
  639.  
  640. Log("%s <%s> unbanned %s <%s> || Ban Reason: ^"%s^"", admin_name, authid, data[bd_name], data[bd_steamid], data[bd_reason]);
  641.  
  642. RemoveBan(array_pos, data[bd_steamid]);
  643.  
  644. return PLUGIN_HANDLED;
  645. }
  646. #endif
  647.  
  648. console_print(client, "%s %L", Prefix, client, "AB_NOT_IN_BAN_LIST", arg);
  649.  
  650. return PLUGIN_HANDLED;
  651. }
  652.  
  653. public CmdBanList(client, level, cid)
  654. {
  655. if( !cmd_access(client, level, cid, 1) ) return PLUGIN_HANDLED;
  656.  
  657. if( !g_total_bans )
  658. {
  659. console_print(client, "%s %L", Prefix, client, "AB_NO_BANS");
  660. return PLUGIN_HANDLED;
  661. }
  662.  
  663. static start;
  664.  
  665. if( read_argc() > 1 )
  666. {
  667. static arg[5];
  668. read_argv(1, arg, sizeof(arg) - 1);
  669.  
  670. start = min(str_to_num(arg), g_total_bans) - 1;
  671. }
  672. else
  673. {
  674. start = 0;
  675. }
  676.  
  677. new last = min(start + 10, g_total_bans);
  678.  
  679. if( client == 0 )
  680. {
  681. server_cmd("echo ^"%L^"", client, "AB_BAN_LIST_NUM", start + 1, last);
  682. }
  683. else
  684. {
  685. client_cmd(client, "echo ^"%L^"", client, "AB_BAN_LIST_NUM", start + 1, last);
  686. }
  687.  
  688. for( new i = start; i < last; i++ )
  689. {
  690. #if MAX_BANS <= 0
  691. static data[BannedData];
  692. ArrayGetArray(g_array, i, data);
  693.  
  694. PrintBanInformation(client, data[bd_name], data[bd_steamid], data[bd_reason], data[bd_banlength], data[bd_unbantime], data[bd_admin_name], data[bd_admin_steamid], true, false);
  695. #else
  696. static name[32], steamid[35], reason[128], banlength, unbantime[32], admin_name[32], admin_steamid[35];
  697.  
  698. copy(name, sizeof(name) - 1, g_names[i]);
  699. copy(steamid, sizeof(steamid) - 1, g_steamids[i]);
  700. copy(reason, sizeof(reason) - 1, g_reasons[i]);
  701. banlength = g_banlengths[i];
  702. copy(unbantime, sizeof(unbantime) - 1, g_unbantimes[i]);
  703. copy(admin_name, sizeof(admin_name) - 1, g_admin_names[i]);
  704. copy(admin_steamid, sizeof(admin_steamid) - 1, g_admin_steamids[i]);
  705.  
  706. PrintBanInformation(client, name, steamid, reason, banlength, unbantime, admin_name, admin_steamid, true, false);
  707. #endif
  708. }
  709.  
  710. if( ++last < g_total_bans )
  711. {
  712. if( client == 0 )
  713. {
  714. server_cmd("echo ^"%L^"", client, "AB_BAN_LIST_NEXT", last);
  715. }
  716. else
  717. {
  718. client_cmd(client, "echo ^"%L^"", client, "AB_BAN_LIST_NEXT", last);
  719. }
  720. }
  721.  
  722. return PLUGIN_HANDLED;
  723. }
  724.  
  725. public CmdAddBanLimit()
  726. {
  727. if( read_argc() != 3 )
  728. {
  729. log_amx("amx_addbanlimit was used with incorrect parameters!");
  730. log_amx("Usage: amx_addbanlimit <flags> <time in minutes>");
  731. return PLUGIN_HANDLED;
  732. }
  733.  
  734. static arg[16];
  735.  
  736. read_argv(1, arg, sizeof(arg) - 1);
  737. new flags = read_flags(arg);
  738.  
  739. read_argv(2, arg, sizeof(arg) - 1);
  740. new minutes = str_to_num(arg);
  741.  
  742. #if !defined MAX_BANLIMITS
  743. ArrayPushCell(g_maxban_flags, flags);
  744. ArrayPushCell(g_maxban_times, minutes);
  745. #else
  746. if( g_total_maxban_times >= MAX_BANLIMITS )
  747. {
  748. static notified;
  749. if( !notified )
  750. {
  751. log_amx("The amx_addbanlimit has reached its maximum!");
  752. notified = 1;
  753. }
  754. return PLUGIN_HANDLED;
  755. }
  756.  
  757. g_maxban_flags[g_total_maxban_times] = flags;
  758. g_maxban_times[g_total_maxban_times] = minutes;
  759. #endif
  760. g_total_maxban_times++;
  761.  
  762. return PLUGIN_HANDLED;
  763. }
  764.  
  765. public FwdThink(entity)
  766. {
  767. if( entity != g_unban_entity ) return;
  768.  
  769. if( g_total_bans > 0 && !g_loading_bans )
  770. {
  771. static _hours[5], _minutes[5], _seconds[5], _month[5], _day[5], _year[7];
  772. format_time(_hours, sizeof(_hours) - 1, "%H");
  773. format_time(_minutes, sizeof(_minutes) - 1, "%M");
  774. format_time(_seconds, sizeof(_seconds) - 1, "%S");
  775. format_time(_month, sizeof(_month) - 1, "%m");
  776. format_time(_day, sizeof(_day) - 1, "%d");
  777. format_time(_year, sizeof(_year) - 1, "%Y");
  778.  
  779. // c = current
  780. // u = unban
  781.  
  782. new c_hours = str_to_num(_hours);
  783. new c_minutes = str_to_num(_minutes);
  784. new c_seconds = str_to_num(_seconds);
  785. new c_month = str_to_num(_month);
  786. new c_day = str_to_num(_day);
  787. new c_year = str_to_num(_year);
  788.  
  789. static unban_time[32];
  790. static u_hours, u_minutes, u_seconds, u_month, u_day, u_year;
  791.  
  792. for( new i = 0; i < g_total_bans; i++ )
  793. {
  794. #if MAX_BANS <= 0
  795. static data[BannedData];
  796. ArrayGetArray(g_array, i, data);
  797.  
  798. if( data[bd_banlength] == 0 ) continue;
  799. #else
  800. if( g_banlengths[i] == 0 ) continue;
  801. #endif
  802.  
  803. #if MAX_BANS <= 0
  804. copy(unban_time, sizeof(unban_time) - 1, data[bd_unbantime]);
  805. #else
  806. copy(unban_time, sizeof(unban_time) - 1, g_unbantimes[i]);
  807. #endif
  808. replace_all(unban_time, sizeof(unban_time) - 1, ":", " ");
  809. replace_all(unban_time, sizeof(unban_time) - 1, "/", " ");
  810.  
  811. parse(unban_time,\
  812. _hours, sizeof(_hours) - 1,\
  813. _minutes, sizeof(_minutes) - 1,\
  814. _seconds, sizeof(_seconds) - 1,\
  815. _month, sizeof(_month) - 1,\
  816. _day, sizeof(_day) - 1,\
  817. _year, sizeof(_year) - 1
  818. );
  819.  
  820. u_hours = str_to_num(_hours);
  821. u_minutes = str_to_num(_minutes);
  822. u_seconds = str_to_num(_seconds);
  823. u_month = str_to_num(_month);
  824. u_day = str_to_num(_day);
  825. u_year = str_to_num(_year);
  826.  
  827. if( u_year < c_year
  828. || u_year == c_year && u_month < c_month
  829. || u_year == c_year && u_month == c_month && u_day < c_day
  830. || u_year == c_year && u_month == c_month && u_day == c_day && u_hours < c_hours
  831. || u_year == c_year && u_month == c_month && u_day == c_day && u_hours == c_hours && u_minutes < c_minutes
  832. || u_year == c_year && u_month == c_month && u_day == c_day && u_hours == c_hours && u_minutes == c_minutes && u_seconds <= c_seconds )
  833. {
  834. #if MAX_BANS <= 0
  835. Log("Ban time is up for: %s [%s]", data[bd_name], data[bd_steamid]);
  836.  
  837. Print("^x04%s^x03 %s^x01[^x04%s^x01]^x03 Lejárt a ban!^x01 [Indok: %s]", Prefix, data[bd_name], data[bd_steamid], data[bd_reason]);
  838.  
  839. RemoveBan(i, data[bd_steamid]);
  840. #else
  841. Log("Ban time is up for: %s [%s]", g_names[i], g_steamids[i]);
  842.  
  843. Print("^x04%s^x03 %s^x01[^x04%s^x01]^x03 lejárt a ban idő!^x01 [Indok: %s]", Prefix, g_names[i], g_steamids[i], g_reasons[i]);
  844.  
  845. RemoveBan(i);
  846. #endif
  847.  
  848. i--; // current pos was replaced with another ban, so we need to check it again.
  849. }
  850. }
  851. }
  852.  
  853. entity_set_float(g_unban_entity, EV_FL_nextthink, get_gametime() + get_pcvar_float(ab_unbancheck));
  854. }
  855.  
  856. public TaskDisconnectPlayer(client)
  857. {
  858. server_cmd("kick #%i ^"Bannolva lettel. Nezd meg a konzolod!^"", get_user_userid(client));
  859. }
  860.  
  861. AddBan(const target_name[], const target_steamid[], const reason[], const length, const unban_time[], const admin_name[], const admin_steamid[])
  862. {
  863. #if MAX_BANS > 0
  864. if( g_total_bans == MAX_BANS )
  865. {
  866. log_amx("Ban list is full! (%i)", g_total_bans);
  867. return;
  868. }
  869. #endif
  870.  
  871. static target_name2[32], reason2[128], admin_name2[32];
  872. MakeStringSQLSafe(target_name, target_name2, sizeof(target_name2) - 1);
  873. MakeStringSQLSafe(reason, reason2, sizeof(reason2) - 1);
  874. MakeStringSQLSafe(admin_name, admin_name2, sizeof(admin_name2) - 1);
  875.  
  876. static query[1024];
  877. formatex(query, sizeof(query) - 1,\
  878. "INSERT INTO `%s` (`%s`, `%s`, `%s`, `%s`, `%s`, `%s`, `%s`) VALUES ('%s', '%s', '%i', '%s', '%s', '%s', '%s');",\
  879. TABLE_NAME, KEY_NAME, KEY_STEAMID, KEY_BANLENGTH, KEY_UNBANTIME, KEY_REASON, KEY_ADMIN_NAME, KEY_ADMIN_STEAMID,\
  880. target_name2, target_steamid, length, unban_time, reason2, admin_name2, admin_steamid
  881. );
  882.  
  883. SQL_ThreadQuery(g_SqlTuple, "QueryAddBan", query);
  884.  
  885. #if MAX_BANS <= 0
  886. static data[BannedData];
  887. copy(data[bd_name], sizeof(data[bd_name]) - 1, target_name);
  888. copy(data[bd_steamid], sizeof(data[bd_steamid]) - 1, target_steamid);
  889. data[bd_banlength] = length;
  890. copy(data[bd_unbantime], sizeof(data[bd_unbantime]) - 1, unban_time);
  891. copy(data[bd_reason], sizeof(data[bd_reason]) - 1, reason);
  892. copy(data[bd_admin_name], sizeof(data[bd_admin_name]) - 1, admin_name);
  893. copy(data[bd_admin_steamid], sizeof(data[bd_admin_steamid]) - 1, admin_steamid);
  894.  
  895. TrieSetCell(g_trie, target_steamid, g_total_bans);
  896. ArrayPushArray(g_array, data);
  897. #else
  898. copy(g_names[g_total_bans], sizeof(g_names[]) - 1, target_name);
  899. copy(g_steamids[g_total_bans], sizeof(g_steamids[]) - 1, target_steamid);
  900. g_banlengths[g_total_bans] = length;
  901. copy(g_unbantimes[g_total_bans], sizeof(g_unbantimes[]) - 1, unban_time);
  902. copy(g_reasons[g_total_bans], sizeof(g_reasons[]) - 1, reason);
  903. copy(g_admin_names[g_total_bans], sizeof(g_admin_names[]) - 1, admin_name);
  904. copy(g_admin_steamids[g_total_bans], sizeof(g_admin_steamids[]) - 1, admin_steamid);
  905. #endif
  906.  
  907. g_total_bans++;
  908.  
  909. #if MAX_BANS > 0
  910. if( g_total_bans == MAX_BANS )
  911. {
  912. log_amx("Ban list is full! (%i)", g_total_bans);
  913. }
  914. #endif
  915. }
  916. public QueryAddBan(failstate, Handle:query, error[], errcode, data[], datasize, Float:queuetime)
  917. {
  918. if( failstate == TQUERY_CONNECT_FAILED )
  919. {
  920. set_fail_state("Could not connect to database.");
  921. }
  922. else if( failstate == TQUERY_QUERY_FAILED )
  923. {
  924. set_fail_state("Query failed.");
  925. }
  926. else if( errcode )
  927. {
  928. log_amx("Error on query: %s", error);
  929. }
  930. else
  931. {
  932. // Yay, ban was added! We can all rejoice!
  933. }
  934. }
  935.  
  936. public QueryDeleteBan(failstate, Handle:query, error[], errcode, data[], datasize, Float:queuetime)
  937. {
  938. if( failstate == TQUERY_CONNECT_FAILED )
  939. {
  940. set_fail_state("Could not connect to database.");
  941. }
  942. else if( failstate == TQUERY_QUERY_FAILED )
  943. {
  944. set_fail_state("Query failed.");
  945. }
  946. else if( errcode )
  947. {
  948. log_amx("Error on query: %s", error);
  949. }
  950. else
  951. {
  952. // Yay, ban was deleted! We can all rejoice!
  953. }
  954. }
  955.  
  956. public QueryLoadBans(failstate, Handle:query, error[], errcode, data[], datasize, Float:queuetime)
  957. {
  958. if( failstate == TQUERY_CONNECT_FAILED )
  959. {
  960. set_fail_state("Could not connect to database.");
  961. }
  962. else if( failstate == TQUERY_QUERY_FAILED )
  963. {
  964. set_fail_state("Query failed.");
  965. }
  966. else if( errcode )
  967. {
  968. log_amx("Error on query: %s", error);
  969. }
  970. else
  971. {
  972. if( SQL_NumResults(query) )
  973. {
  974. #if MAX_BANS <= 0
  975. static data[BannedData];
  976. while( SQL_MoreResults(query) )
  977. #else
  978. while( SQL_MoreResults(query) && g_total_bans < MAX_BANS )
  979. #endif
  980. {
  981. #if MAX_BANS <= 0
  982. SQL_ReadResult(query, 0, data[bd_name], sizeof(data[bd_name]) - 1);
  983. SQL_ReadResult(query, 1, data[bd_steamid], sizeof(data[bd_steamid]) - 1);
  984. data[bd_banlength] = SQL_ReadResult(query, 2);
  985. SQL_ReadResult(query, 3, data[bd_unbantime], sizeof(data[bd_unbantime]) - 1);
  986. SQL_ReadResult(query, 4, data[bd_reason], sizeof(data[bd_reason]) - 1);
  987. SQL_ReadResult(query, 5, data[bd_admin_name], sizeof(data[bd_admin_name]) - 1);
  988. SQL_ReadResult(query, 6, data[bd_admin_steamid], sizeof(data[bd_admin_steamid]) - 1);
  989.  
  990. ArrayPushArray(g_array, data);
  991. TrieSetCell(g_trie, data[bd_steamid], g_total_bans);
  992. #else
  993. SQL_ReadResult(query, 0, g_names[g_total_bans], sizeof(g_names[]) - 1);
  994. SQL_ReadResult(query, 1, g_steamids[g_total_bans], sizeof(g_steamids[]) - 1);
  995. g_banlengths[g_total_bans] = SQL_ReadResult(query, 2);
  996. SQL_ReadResult(query, 3, g_unbantimes[g_total_bans], sizeof(g_unbantimes[]) - 1);
  997. SQL_ReadResult(query, 4, g_reasons[g_total_bans], sizeof(g_reasons[]) - 1);
  998. SQL_ReadResult(query, 5, g_admin_names[g_total_bans], sizeof(g_admin_names[]) - 1);
  999. SQL_ReadResult(query, 6, g_admin_steamids[g_total_bans], sizeof(g_admin_steamids[]) - 1);
  1000. #endif
  1001.  
  1002. g_total_bans++;
  1003.  
  1004. SQL_NextRow(query);
  1005. }
  1006. }
  1007.  
  1008. set_task(RELOAD_BANS_INTERVAL, "LoadBans");
  1009.  
  1010. g_loading_bans = false;
  1011. }
  1012. }
  1013.  
  1014. #if MAX_BANS > 0
  1015. RemoveBan(remove)
  1016. {
  1017. static query[128];
  1018. formatex(query, sizeof(query) - 1,\
  1019. "DELETE FROM `%s` WHERE `%s` = '%s';",\
  1020. TABLE_NAME, KEY_STEAMID, g_steamids[remove]
  1021. );
  1022.  
  1023. SQL_ThreadQuery(g_SqlTuple, "QueryDeleteBan", query);
  1024.  
  1025. for( new i = remove; i < g_total_bans; i++ )
  1026. {
  1027. if( (i + 1) == g_total_bans )
  1028. {
  1029. copy(g_names[i], sizeof(g_names[]) - 1, "");
  1030. copy(g_steamids[i], sizeof(g_steamids[]) - 1, "");
  1031. g_banlengths[i] = 0;
  1032. copy(g_unbantimes[i], sizeof(g_unbantimes[]) - 1, "");
  1033. copy(g_reasons[i], sizeof(g_reasons[]) - 1, "");
  1034. copy(g_admin_names[i], sizeof(g_admin_names[]) - 1, "");
  1035. copy(g_admin_steamids[i], sizeof(g_admin_steamids[]) - 1, "");
  1036. }
  1037. else
  1038. {
  1039. copy(g_names[i], sizeof(g_names[]) - 1, g_names[i + 1]);
  1040. copy(g_steamids[i], sizeof(g_steamids[]) - 1, g_steamids[i + 1]);
  1041. g_banlengths[i] = g_banlengths[i + 1];
  1042. copy(g_unbantimes[i], sizeof(g_unbantimes[]) - 1, g_unbantimes[i + 1]);
  1043. copy(g_reasons[i], sizeof(g_reasons[]) - 1, g_reasons[i + 1]);
  1044. copy(g_admin_names[i], sizeof(g_admin_names[]) - 1, g_admin_names[i + 1]);
  1045. copy(g_admin_steamids[i], sizeof(g_admin_steamids[]) - 1, g_admin_steamids[i + 1]);
  1046. }
  1047. }
  1048.  
  1049. g_total_bans--;
  1050. }
  1051. #else
  1052. RemoveBan(pos, const authid[])
  1053. {
  1054. TrieDeleteKey(g_trie, authid);
  1055. ArrayDeleteItem(g_array, pos);
  1056.  
  1057. g_total_bans--;
  1058.  
  1059. static query[128];
  1060. formatex(query, sizeof(query) - 1,\
  1061. "DELETE FROM `%s` WHERE `%s` = '%s';",\
  1062. TABLE_NAME, KEY_STEAMID, authid
  1063. );
  1064.  
  1065. SQL_ThreadQuery(g_SqlTuple, "QueryDeleteBan", query);
  1066.  
  1067. new data[BannedData];
  1068. for( new i = 0; i < g_total_bans; i++ )
  1069. {
  1070. ArrayGetArray(g_array, i, data);
  1071. TrieSetCell(g_trie, data[bd_steamid], i);
  1072. }
  1073. }
  1074. #endif
  1075.  
  1076. #if defined KEEP_DEFAULT_BANS
  1077. LoadOldBans(filename[])
  1078. {
  1079. if( file_exists(filename) )
  1080. {
  1081. new f = fopen(filename, "rt");
  1082.  
  1083. static data[96];
  1084. static command[10], minutes[10], steamid[35], length, unban_time[32];
  1085.  
  1086. while( !feof(f) )
  1087. {
  1088. fgets(f, data, sizeof(data) - 1);
  1089. if( !data[0] ) continue;
  1090.  
  1091. parse(data, command, sizeof(command) - 1, minutes, sizeof(minutes) - 1, steamid, sizeof(steamid) - 1);
  1092. if( filename[0] == 'b' && !equali(command, "banid") || filename[0] == 'l' && !equali(command, "addip") ) continue;
  1093.  
  1094. length = str_to_num(minutes);
  1095. GenerateUnbanTime(length, unban_time, sizeof(unban_time) - 1);
  1096.  
  1097. AddBan("", steamid, "", length, unban_time, "", "");
  1098. }
  1099.  
  1100. fclose(f);
  1101.  
  1102. static filename2[32];
  1103.  
  1104. // copy current
  1105. copy(filename2, sizeof(filename2) - 1, filename);
  1106.  
  1107. // cut off at the "."
  1108. // banned.cfg = banned
  1109. // listip.cfg = listip
  1110. filename2[containi(filename2, ".")] = 0;
  1111.  
  1112. // add 2.cfg
  1113. // banned = banned2.cfg
  1114. // listip = listip2.cfg
  1115. add(filename2, sizeof(filename2) - 1, "2.cfg");
  1116.  
  1117. // rename file so that it isnt loaded again
  1118. while( !rename_file(filename, filename2, 1) ) { }
  1119. }
  1120. }
  1121. #endif
  1122.  
  1123. public LoadBans()
  1124. {
  1125. if( g_total_bans )
  1126. {
  1127. #if MAX_BANS <= 0
  1128. TrieClear(g_trie);
  1129. ArrayClear(g_array);
  1130. #endif
  1131.  
  1132. g_total_bans = 0;
  1133. }
  1134.  
  1135. static query[128];
  1136. formatex(query, sizeof(query) - 1,\
  1137. "SELECT * FROM `%s`;",\
  1138. TABLE_NAME
  1139. );
  1140.  
  1141. SQL_ThreadQuery(g_SqlTuple, "QueryLoadBans", query);
  1142.  
  1143. g_loading_bans = true;
  1144.  
  1145. // load these after, so when they are added to the file with AddBan(), they aren't loaded again from above.
  1146.  
  1147. #if defined KEEP_DEFAULT_BANS
  1148. LoadOldBans("banned.cfg");
  1149. LoadOldBans("listip.cfg");
  1150. #endif
  1151. }
  1152.  
  1153. MakeStringSQLSafe(const input[], output[], len)
  1154. {
  1155. copy(output, len, input);
  1156. replace_all(output, len, "'", "*");
  1157. replace_all(output, len, "^"", "*");
  1158. replace_all(output, len, "`", "*");
  1159. }
  1160.  
  1161. GetBanTime(const bantime, length[], len)
  1162. {
  1163. new minutes = bantime;
  1164. new hours = 0;
  1165. new days = 0;
  1166.  
  1167. while( minutes >= 60 )
  1168. {
  1169. minutes -= 60;
  1170. hours++;
  1171. }
  1172.  
  1173. while( hours >= 24 )
  1174. {
  1175. hours -= 24;
  1176. days++;
  1177. }
  1178.  
  1179. new bool:add_before;
  1180. if( minutes )
  1181. {
  1182. formatex(length, len, "%i perc%s", minutes, minutes == 1 ? "" : "");
  1183.  
  1184. add_before = true;
  1185. }
  1186. if( hours )
  1187. {
  1188. if( add_before )
  1189. {
  1190. format(length, len, "%i Ăłra%s, %s", hours, hours == 1 ? "" : "", length);
  1191. }
  1192. else
  1193. {
  1194. formatex(length, len, "%i Ăłra%s", hours, hours == 1 ? "" : "");
  1195.  
  1196. add_before = true;
  1197. }
  1198. }
  1199. if( days )
  1200. {
  1201. if( add_before )
  1202. {
  1203. format(length, len, "%i nap%s, %s", days, days == 1 ? "" : "", length);
  1204. }
  1205. else
  1206. {
  1207. formatex(length, len, "%i nap%s", days, days == 1 ? "" : "");
  1208.  
  1209. add_before = true;
  1210. }
  1211. }
  1212. if( !add_before )
  1213. {
  1214. // minutes, hours, and days = 0
  1215. // assume permanent ban
  1216. copy(length, len, "Orokos Ban");
  1217. }
  1218. }
  1219.  
  1220. GenerateUnbanTime(const bantime, unban_time[], len)
  1221. {
  1222. static _hours[5], _minutes[5], _seconds[5], _month[5], _day[5], _year[7];
  1223. format_time(_hours, sizeof(_hours) - 1, "%H");
  1224. format_time(_minutes, sizeof(_minutes) - 1, "%M");
  1225. format_time(_seconds, sizeof(_seconds) - 1, "%S");
  1226. format_time(_month, sizeof(_month) - 1, "%m");
  1227. format_time(_day, sizeof(_day) - 1, "%d");
  1228. format_time(_year, sizeof(_year) - 1, "%Y");
  1229.  
  1230. new hours = str_to_num(_hours);
  1231. new minutes = str_to_num(_minutes);
  1232. new seconds = str_to_num(_seconds);
  1233. new month = str_to_num(_month);
  1234. new day = str_to_num(_day);
  1235. new year = str_to_num(_year);
  1236.  
  1237. minutes += bantime;
  1238.  
  1239. while( minutes >= 60 )
  1240. {
  1241. minutes -= 60;
  1242. hours++;
  1243. }
  1244.  
  1245. while( hours >= 24 )
  1246. {
  1247. hours -= 24;
  1248. day++;
  1249. }
  1250.  
  1251. new max_days = GetDaysInMonth(month, year);
  1252. while( day > max_days )
  1253. {
  1254. day -= max_days;
  1255. month++;
  1256. }
  1257.  
  1258. while( month > 12 )
  1259. {
  1260. month -= 12;
  1261. year++;
  1262. }
  1263.  
  1264. formatex(unban_time, len, "%i:%02i:%02i %i/%i/%i", hours, minutes, seconds, month, day, year);
  1265. }
  1266.  
  1267. GetDaysInMonth(month, year=0)
  1268. {
  1269. switch( month )
  1270. {
  1271. case 1: return 31; // january
  1272. case 2: return ((year % 4) == 0) ? 29 : 28; // february
  1273. case 3: return 31; // march
  1274. case 4: return 30; // april
  1275. case 5: return 31; // may
  1276. case 6: return 30; // june
  1277. case 7: return 31; // july
  1278. case 8: return 31; // august
  1279. case 9: return 30; // september
  1280. case 10: return 31; // october
  1281. case 11: return 30; // november
  1282. case 12: return 31; // december
  1283. }
  1284.  
  1285. return 30;
  1286. }
  1287.  
  1288. GetTargetFlags(client)
  1289. {
  1290. static const flags_no_immunity = (CMDTARGET_ALLOW_SELF|CMDTARGET_NO_BOTS);
  1291. static const flags_immunity = (CMDTARGET_ALLOW_SELF|CMDTARGET_NO_BOTS|CMDTARGET_OBEY_IMMUNITY);
  1292.  
  1293. switch( get_pcvar_num(ab_immunity) )
  1294. {
  1295. case 1: return flags_immunity;
  1296. case 2: return access(client, ADMIN_IMMUNITY) ? flags_no_immunity : flags_immunity;
  1297. }
  1298.  
  1299. return flags_no_immunity;
  1300. }
  1301.  
  1302. GetMaxBanTime(client)
  1303. {
  1304. if( !g_total_maxban_times ) return 0;
  1305.  
  1306. new flags = get_user_flags(client);
  1307.  
  1308. for( new i = 0; i < g_total_maxban_times; i++ )
  1309. {
  1310. #if !defined MAX_BANLIMITS
  1311. if( flags & ArrayGetCell(g_maxban_flags, i) )
  1312. {
  1313. return ArrayGetCell(g_maxban_times, i);
  1314. }
  1315. #else
  1316. if( flags & g_maxban_flags[i] )
  1317. {
  1318. return g_maxban_times[i];
  1319. }
  1320. #endif
  1321. }
  1322.  
  1323. return 0;
  1324. }
  1325.  
  1326. PrintBanInformation(client, const target_name[], const target_authid[], const reason[], const length, const unban_time[], const admin_name[], const admin_authid[], bool:show_admin, bool:show_website)
  1327. {
  1328. static website[64], ban_length[64];
  1329. if( client == 0 )
  1330. {
  1331. server_print("************************************************");
  1332. server_print("%L", client, "AB_BAN_INFORMATION");
  1333. server_print("%L: %s", client, "AB_NAME", target_name);
  1334. server_print("%L: %s", client, IsValidAuthid(target_authid) ? "AB_STEAMID" : "AB_IP", target_authid);
  1335. server_print("%L: %s", client, "AB_REASON", reason);
  1336. if( length > 0 )
  1337. {
  1338. GetBanTime(length, ban_length, sizeof(ban_length) - 1);
  1339. server_print("%L: %s", client, "AB_BAN_LENGTH", ban_length);
  1340. }
  1341. server_print("%L: %s", client, "AB_UNBAN_TIME", unban_time);
  1342. if( show_admin )
  1343. {
  1344. server_print("%L: %s", client, "AB_ADMIN_NAME", admin_name);
  1345. server_print("%L: %s", client, "AB_ADMIN_STEAMID", admin_authid);
  1346. }
  1347. if( show_website )
  1348. {
  1349. get_pcvar_string(ab_website, website, sizeof(website) - 1);
  1350. if( website[0] )
  1351. {
  1352. server_print("");
  1353. server_print("%L", client, "AB_WEBSITE");
  1354. server_print("%s", website);
  1355. }
  1356. }
  1357. server_print("************************************************");
  1358. }
  1359. else
  1360. {
  1361. client_cmd(client, "echo ^"************************************************^"");
  1362. client_cmd(client, "echo ^"%L^"", client, "AB_BAN_INFORMATION");
  1363. client_cmd(client, "echo ^"%L: %s^"", client, "AB_NAME", target_name);
  1364. client_cmd(client, "echo ^"%L: %s^"", client, IsValidAuthid(target_authid) ? "AB_STEAMID" : "AB_IP", target_authid);
  1365. client_cmd(client, "echo ^"%L: %s^"", client, "AB_REASON", reason);
  1366. if( length > 0 )
  1367. {
  1368. GetBanTime(length, ban_length, sizeof(ban_length) - 1);
  1369. client_cmd(client, "echo ^"%L: %s^"", client, "AB_BAN_LENGTH", ban_length);
  1370. }
  1371. client_cmd(client, "echo ^"%L: %s^"", client, "AB_UNBAN_TIME", unban_time);
  1372. if( show_admin )
  1373. {
  1374. client_cmd(client, "echo ^"%L: %s^"", client, "AB_ADMIN_NAME", admin_name);
  1375. client_cmd(client, "echo ^"%L: %s^"", client, "AB_ADMIN_STEAMID", admin_authid);
  1376. }
  1377. if( show_website )
  1378. {
  1379. get_pcvar_string(ab_website, website, sizeof(website) - 1);
  1380. if( website[0] )
  1381. {
  1382. client_cmd(client, "echo ^"^"");
  1383. client_cmd(client, "echo ^"%L^"", client, "AB_WEBSITE");
  1384. client_cmd(client, "echo ^"%s^"", website);
  1385. }
  1386. }
  1387. client_cmd(client, "echo ^"************************************************^"");
  1388. }
  1389. }
  1390.  
  1391. PrintActivity(const admin_name[], const message_fmt[], any:...)
  1392. {
  1393. if( !get_playersnum() ) return;
  1394.  
  1395. new activity = get_pcvar_num(amx_show_activity);
  1396. if( !(0 <= activity <= 5) )
  1397. {
  1398. set_pcvar_num(amx_show_activity, (activity = 2));
  1399. }
  1400.  
  1401. static message[192], temp[192];
  1402. vformat(message, sizeof(message) - 1, message_fmt, 3);
  1403.  
  1404. for( new client = 1; client <= g_max_clients; client++ )
  1405. {
  1406. if( !is_user_connected(client) ) continue;
  1407.  
  1408. switch( is_user_admin(client) ? g_admin_activity[activity] : g_normal_activity[activity] )
  1409. {
  1410. case ACTIVITY_NONE:
  1411. {
  1412.  
  1413. }
  1414. case ACTIVITY_HIDE:
  1415. {
  1416. copy(temp, sizeof(temp) - 1, message);
  1417. replace(temp, sizeof(temp) - 1, "$name", "ADMIN");
  1418.  
  1419. message_begin(MSG_ONE_UNRELIABLE, g_msgid_SayText, _, client);
  1420. write_byte(client);
  1421. write_string(temp);
  1422. message_end();
  1423. }
  1424. case ACTIVITY_SHOW:
  1425. {
  1426. copy(temp, sizeof(temp) - 1, message);
  1427. replace(temp, sizeof(temp) - 1, "$name", admin_name);
  1428.  
  1429. message_begin(MSG_ONE_UNRELIABLE, g_msgid_SayText, _, client);
  1430. write_byte(client);
  1431. write_string(temp);
  1432. message_end();
  1433. }
  1434. }
  1435. }
  1436. }
  1437.  
  1438. Print(const message_fmt[], any:...)
  1439. {
  1440. if( !get_playersnum() ) return;
  1441.  
  1442. static message[192];
  1443. vformat(message, sizeof(message) - 1, message_fmt, 2);
  1444.  
  1445. for( new client = 1; client <= g_max_clients; client++ )
  1446. {
  1447. if( !is_user_connected(client) ) continue;
  1448.  
  1449. message_begin(MSG_ONE_UNRELIABLE, g_msgid_SayText, _, client);
  1450. write_byte(client);
  1451. write_string(message);
  1452. message_end();
  1453. }
  1454. }
  1455.  
  1456. Log(const message_fmt[], any:...)
  1457. {
  1458. static message[256];
  1459. vformat(message, sizeof(message) - 1, message_fmt, 2);
  1460.  
  1461. static filename[96];
  1462. #if defined HISTORY_ONE_FILE
  1463. if( !filename[0] )
  1464. {
  1465. get_basedir(filename, sizeof(filename) - 1);
  1466. add(filename, sizeof(filename) - 1, "/logs/ban_history.log");
  1467. }
  1468. #else
  1469. static dir[64];
  1470. if( !dir[0] )
  1471. {
  1472. get_basedir(dir, sizeof(dir) - 1);
  1473. add(dir, sizeof(dir) - 1, "/logs");
  1474. }
  1475.  
  1476. format_time(filename, sizeof(filename) - 1, "%m%d%Y");
  1477. format(filename, sizeof(filename) - 1, "%s/BAN_HISTORY_%s.log", dir, filename);
  1478. #endif
  1479.  
  1480. log_amx("%s", message);
  1481. log_to_file(filename, "%s", message);
  1482. }

Az SQL adatokat a 100. sortól a 103. sorig kell megadni.
Kód:
new Host[] = "Host";
new User[] = "Felhasznalo";
new Pass[] = "Jelszo";
new Db[] = "Adatbazis";


Hozzászólás jelentése
Vissza a tetejére
   
 Hozzászólás témája: Re: MySQL ban
HozzászólásElküldve: 2015.08.11. 21:54 
Offline
Jómunkásember
Avatar

Csatlakozott: 2013.12.15. 19:13
Hozzászólások: 495
Megköszönt másnak: 289 alkalommal
Megköszönték neki: 14 alkalommal
Mit javítottál rajta? Mi miatt nem működött NEKED?


Hozzászólás jelentése
Vissza a tetejére
   
Hozzászólások megjelenítése:  Rendezés  
Új téma nyitása  Hozzászólás a témához  [ 5 hozzászólás ] 


Ki van itt

Jelenlévő fórumozók: nincs regisztrált felhasználó valamint 35 vendég


Nyithatsz új témákat ebben a fórumban.
Válaszolhatsz egy témára ebben a fórumban.
Nem szerkesztheted a hozzászólásaidat ebben a fórumban.
Nem törölheted a hozzászólásaidat ebben a fórumban.
Nem küldhetsz csatolmányokat ebben a fórumban.

Keresés:
Ugrás:  
Powered by phpBB® Forum Software © phpBB Limited
Magyar fordítás © Magyar phpBB Közösség
Portal: Kiss Portal Extension © Michael O'Toole