/src/main/java/com/authdb/util/API.java

https://github.com/Minecraftserver-si/AuthDB · Java · 845 lines · 777 code · 9 blank · 59 comment · 529 complexity · f678968000c5c7e64b056ac8a042e8d0 MD5 · raw file

  1. /**
  2. (C) Copyright 2011 CraftFire <dev@craftfire.com>
  3. Contex <contex@craftfire.com>, Wulfspider <wulfspider@craftfire.com>
  4. This work is licensed under the Creative Commons Attribution-NonCommercial-NoDerivs 3.0 Unported License.
  5. To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-nd/3.0/
  6. or send a letter to Creative Commons, 171 Second Street, Suite 300, San Francisco, California, 94105, USA.
  7. **/
  8. package com.authdb.util;
  9. import java.sql.SQLException;
  10. import org.bukkit.entity.Player;
  11. import com.authdb.scripts.cms.DLE;
  12. import com.authdb.scripts.cms.Drupal;
  13. import com.authdb.scripts.cms.Joomla;
  14. import com.authdb.scripts.cms.WordPress;
  15. import com.authdb.scripts.forum.IPB;
  16. import com.authdb.scripts.forum.PunBB;
  17. import com.authdb.scripts.forum.SMF;
  18. import com.authdb.scripts.forum.Vanilla;
  19. import com.authdb.scripts.forum.XenForo;
  20. import com.authdb.scripts.forum.BBPress;
  21. import com.authdb.scripts.forum.MyBB;
  22. import com.authdb.scripts.forum.PhpBB;
  23. import com.authdb.scripts.forum.VBulletin;
  24. import com.authdb.util.databases.MySQL;
  25. public class API {
  26. public static String getScript(String what, Player player, String extra) throws SQLException {
  27. String script = Config.script_name;
  28. String GroupName = "fail";
  29. String GroupID = "0";
  30. String UserID = "0";
  31. String IsBanned = "";
  32. String BanReason = "";
  33. String BannedToDate = "";
  34. if (script.equalsIgnoreCase(PhpBB.Name) || script.equalsIgnoreCase(PhpBB.ShortName)) {
  35. if (Util.checkVersionInRange(PhpBB.VersionRange)) {
  36. // phpBB 3
  37. if (what.equalsIgnoreCase("getgroup")) {
  38. GroupID = MySQL.getfromtable(Config.script_tableprefix + "users", "`group_id`", "username", player.getName());
  39. GroupName = MySQL.getfromtable(Config.script_tableprefix + "groups", "`group_name`", "group_id", GroupID);
  40. } else if (what.equalsIgnoreCase("checkifbanned")) {
  41. if (player == null) {
  42. IsBanned = MySQL.getfromtable(Config.script_tableprefix + "banlist", "`ban_id`", "ban_ip", extra);
  43. if (IsBanned.equalsIgnoreCase("fail")) {
  44. return "false";
  45. } else {
  46. return "true";
  47. }
  48. } else {
  49. UserID = MySQL.getfromtable(Config.script_tableprefix + "users", "`user_id`", "username_clean", player.getName().toLowerCase());
  50. IsBanned = MySQL.getfromtable(Config.script_tableprefix + "banlist", "`ban_id`", "ban_userid", UserID);
  51. if (IsBanned.equalsIgnoreCase("fail")) {
  52. return "false";
  53. } else {
  54. return "true";
  55. }
  56. }
  57. } else if (what.equalsIgnoreCase("banreason")) {
  58. if (player == null) {
  59. IsBanned = MySQL.getfromtable(Config.script_tableprefix + "banlist", "`ban_reason`", "ban_ip", extra);
  60. if (IsBanned.equalsIgnoreCase("fail")) {
  61. return "false";
  62. } else {
  63. return "true";
  64. }
  65. } else {
  66. UserID = MySQL.getfromtable(Config.script_tableprefix + "users", "`users_id`", "username_clean",player.getName().toLowerCase());
  67. BanReason = MySQL.getfromtable(Config.script_tableprefix + "banlist", "`ban_reason`", "ban_userid", UserID);
  68. if (BanReason != "fail" && BanReason != "" && BanReason != null) {
  69. return BanReason;
  70. } else {
  71. return "noreason";
  72. }
  73. }
  74. } else if (what.equalsIgnoreCase("bannedtodate")) {
  75. if (player == null) {
  76. BannedToDate = MySQL.getfromtable(Config.script_tableprefix + "banlist", "`ban_end`", "ban_ip", extra);
  77. if (BannedToDate != "fail") {
  78. if (BannedToDate == null || BannedToDate.equalsIgnoreCase("NULL") || BannedToDate.equalsIgnoreCase("0")) {
  79. return "perma";
  80. } else {
  81. return BannedToDate + ",unix";
  82. }
  83. } else {
  84. return "nodate";
  85. }
  86. } else {
  87. UserID = MySQL.getfromtable(Config.script_tableprefix + "users", "`user_id`", "username_clean", player.getName().toLowerCase());
  88. BannedToDate = MySQL.getfromtable(Config.script_tableprefix + "banlist", "`ban_end`", "ban_userid", UserID);
  89. if (BannedToDate != "fail") {
  90. if (BannedToDate == null || BannedToDate.equalsIgnoreCase("NULL") || BannedToDate.equalsIgnoreCase("0")) {
  91. return "perma";
  92. } else {
  93. return BannedToDate + ",unix";
  94. }
  95. } else {
  96. return "nodate";
  97. }
  98. }
  99. }
  100. } else if (Util.checkVersionInRange(PhpBB.VersionRange2)) {
  101. // phpBB 2
  102. if (what.equalsIgnoreCase("getgroup")) {
  103. UserID = MySQL.getfromtable(Config.script_tableprefix + "users", "`users_id`", "username", player.getName());
  104. GroupID = MySQL.getfromtable(Config.script_tableprefix + "users_group", "`group_id`", "user_id", UserID);
  105. GroupName = MySQL.getfromtable(Config.script_tableprefix + "groups", "`group_name`", "group_id", GroupID);
  106. } else if (what.equalsIgnoreCase("checkifbanned")) {
  107. if (player == null) {
  108. extra = Util.hexToString(extra);
  109. IsBanned = MySQL.getfromtable(Config.script_tableprefix + "banlist", "`ban_id`", "ban_ip", extra);
  110. if (IsBanned.equalsIgnoreCase("fail")) {
  111. return "false";
  112. } else {
  113. return "true";
  114. }
  115. } else {
  116. UserID = MySQL.getfromtable(Config.script_tableprefix + "users", "`user_id`", "username", player.getName());
  117. IsBanned = MySQL.getfromtable(Config.script_tableprefix + "banlist", "`ban_id`", "ban_userid", UserID);
  118. if (IsBanned.equalsIgnoreCase("fail")) {
  119. return "false";
  120. } else {
  121. return "true";
  122. }
  123. }
  124. } else if (what.equalsIgnoreCase("banreason")) {
  125. // No ban reason defined
  126. return "noreason";
  127. } else if (what.equalsIgnoreCase("bannedtodate")) {
  128. // No date
  129. return "nodate";
  130. }
  131. }
  132. } else if (script.equalsIgnoreCase(SMF.Name) || script.equalsIgnoreCase(SMF.ShortName)) {
  133. if (Util.checkVersionInRange(SMF.VersionRange)) {
  134. // Simple Machines 1
  135. if (what.equalsIgnoreCase("getgroup")) {
  136. GroupID = MySQL.getfromtable(Config.script_tableprefix + "members", "`ID_GROUP`", "memberName", player.getName());
  137. if (UserID.equalsIgnoreCase("0")) {
  138. GroupID = MySQL.getfromtable(Config.script_tableprefix + "members", "`ID_POST_GROUP`", "memberName", player.getName());
  139. }
  140. GroupName = MySQL.getfromtable(Config.script_tableprefix + "membersgroups", "`groupName`", "ID_GROUP", GroupID);
  141. } else if (what.equalsIgnoreCase("checkifbanned")) {
  142. return "";
  143. // Next version, need to check if between 0 and 255.
  144. } else if (what.equalsIgnoreCase("banreason")) {
  145. if (player == null) {
  146. return "";
  147. //
  148. } else {
  149. UserID = MySQL.getfromtable(Config.script_tableprefix + "members", "`ID_MEMBER`", "memberName", player.getName());
  150. String BanGroup = MySQL.getfromtable(Config.script_tableprefix + "ban_items", "`ID_BAN_GROUP`", "ID_MEMBER", UserID);
  151. BanReason = MySQL.getfromtable(Config.script_tableprefix + "ban_groups", "`reason`", "ID_BAN_GROUP", BanGroup);
  152. if (BanReason != "fail" && BanReason != "" && BanReason != null) {
  153. return BanReason;
  154. } else {
  155. return "noreason";
  156. }
  157. }
  158. } else if (what.equalsIgnoreCase("bannedtodate")) {
  159. if (player == null) {
  160. return "";
  161. //
  162. } else {
  163. UserID = MySQL.getfromtable(Config.script_tableprefix + "members", "`ID_MEMBER`", "memberName", player.getName());
  164. String BanGroup = MySQL.getfromtable(Config.script_tableprefix + "ban_items", "`ID_BAN_GROUP`", "ID_MEMBER", UserID);
  165. BanReason = MySQL.getfromtable(Config.script_tableprefix + "ban_groups", "`expire_time`", "ID_BAN_GROUP", BanGroup);
  166. if (BannedToDate != "fail") {
  167. if (BannedToDate == null || BannedToDate.equalsIgnoreCase("NULL")) {
  168. return "perma";
  169. } else {
  170. return BannedToDate + ",unix";
  171. }
  172. } else {
  173. return "nodate";
  174. }
  175. }
  176. }
  177. } else if (Util.checkVersionInRange(SMF.VersionRange2) || Util.checkVersionInRange("2.0") || Util.checkVersionInRange("2.0.0") || Util.checkVersionInRange("2.0.0.0")) {
  178. // Simple Machines 2
  179. if (what.equalsIgnoreCase("getgroup")) {
  180. GroupID = MySQL.getfromtable(Config.script_tableprefix + "members", "`id_group`", "member_name", player.getName());
  181. if (UserID.equalsIgnoreCase("0")) {
  182. GroupID = MySQL.getfromtable(Config.script_tableprefix + "members", "`id_post_group`", "member_name", player.getName());
  183. }
  184. GroupName = MySQL.getfromtable(Config.script_tableprefix + "membersgroups", "`group_name`", "id_group", GroupID);
  185. } else if (what.equalsIgnoreCase("checkifbanned")) {
  186. if (player == null) {
  187. return "";
  188. // Next version, need to check if between 0 and 255.
  189. } else {
  190. UserID = MySQL.getfromtable(Config.script_tableprefix + "users", "`user_id`", "username", player.getName());
  191. IsBanned = MySQL.getfromtable(Config.script_tableprefix + "ban_items", "`id_ban`", "id_member", UserID);
  192. if (IsBanned.equalsIgnoreCase("fail")) {
  193. return "false";
  194. } else {
  195. return "true";
  196. }
  197. }
  198. } else if (what.equalsIgnoreCase("banreason")) {
  199. if (player == null) {
  200. return "";
  201. //
  202. } else {
  203. UserID = MySQL.getfromtable(Config.script_tableprefix + "members", "`id_member`", "member_name", player.getName());
  204. String BanGroup = MySQL.getfromtable(Config.script_tableprefix + "ban_items", "`id_ban_group`", "id_member", UserID);
  205. BanReason = MySQL.getfromtable(Config.script_tableprefix + "ban_groups", "`reason`", "id_ban_group", BanGroup);
  206. if (BanReason != "fail" && BanReason != "" && BanReason != null) {
  207. return BanReason;
  208. } else {
  209. return "noreason";
  210. }
  211. }
  212. } else if (what.equalsIgnoreCase("bannedtodate")) {
  213. if (player == null) {
  214. return "";
  215. //
  216. } else {
  217. UserID = MySQL.getfromtable(Config.script_tableprefix + "members", "`id_member`", "member_name", player.getName());
  218. String BanGroup = MySQL.getfromtable(Config.script_tableprefix + "ban_items", "`id_ban_group`", "id_member", UserID);
  219. BannedToDate = MySQL.getfromtable(Config.script_tableprefix + "ban_groups", "`expire_time`", "id_ban_group", BanGroup);
  220. if (BannedToDate != "fail") {
  221. if (BannedToDate == null || BannedToDate.equalsIgnoreCase("NULL")) {
  222. return "perma";
  223. } else {
  224. return BannedToDate + ",unix";
  225. }
  226. } else {
  227. return "nodate";
  228. }
  229. }
  230. }
  231. }
  232. } else if (script.equalsIgnoreCase(MyBB.Name) || script.equalsIgnoreCase(MyBB.ShortName)) {
  233. if (Util.checkVersionInRange(MyBB.VersionRange)) {
  234. if (what.equalsIgnoreCase("getgroup")) {
  235. GroupID = MySQL.getfromtable(Config.script_tableprefix + "users", "`usersgroup`", "username", player.getName());
  236. GroupName = MySQL.getfromtable(Config.script_tableprefix + "usersgroups", "`title`", "gid", GroupID);
  237. } else if (what.equalsIgnoreCase("checkifbanned")) {
  238. if (player == null) {
  239. IsBanned = MySQL.getfromtable(Config.script_tableprefix + "banfliters", "`fid`", "filter", extra);
  240. if (IsBanned.equalsIgnoreCase("fail")) {
  241. String delimiter = "\\.";
  242. StringBuffer tempIP = new StringBuffer();
  243. String[] temp = extra.split(delimiter);
  244. int counter = 0;
  245. while (counter > (temp.length - 1)) {
  246. tempIP.append(temp[counter] + ".");
  247. counter++;
  248. }
  249. tempIP.append("*");
  250. IsBanned = MySQL.getfromtable(Config.script_tableprefix + "banfliters", "`fid`", "filter", tempIP.toString());
  251. if (IsBanned.equalsIgnoreCase("fail")) {
  252. return "false";
  253. }
  254. }
  255. return "true";
  256. } else {
  257. UserID = MySQL.getfromtable(Config.script_tableprefix + "users", "`uid`", "username", player.getName());
  258. IsBanned = MySQL.getfromtable(Config.script_tableprefix + "banned", "`dateline`", "uid", UserID);
  259. if (IsBanned.equalsIgnoreCase("fail")) {
  260. return "false";
  261. } else {
  262. return "true";
  263. }
  264. }
  265. } else if (what.equalsIgnoreCase("banreason")) {
  266. if (player == null) {
  267. // No reason
  268. return "noreason";
  269. } else {
  270. UserID = MySQL.getfromtable(Config.script_tableprefix + "users", "`uid`", "username", player.getName());
  271. BanReason = MySQL.getfromtable(Config.script_tableprefix + "banned", "`reason`", "uid", UserID);
  272. if (BanReason != "fail" && BanReason != "" && BanReason != null) {
  273. return BanReason;
  274. } else {
  275. return "noreason";
  276. }
  277. }
  278. } else if (what.equalsIgnoreCase("bannedtodate")) {
  279. if (player == null) {
  280. // No date
  281. return "nodate";
  282. } else {
  283. UserID = MySQL.getfromtable(Config.script_tableprefix + "users", "`uid`", "username", player.getName());
  284. BannedToDate = MySQL.getfromtable(Config.script_tableprefix + "banned", "`lifted`", "uid", UserID);
  285. if (BannedToDate != "fail") {
  286. if (BannedToDate == null || BannedToDate.equalsIgnoreCase("0")) {
  287. return "perma";
  288. } else {
  289. return BannedToDate + ",unix";
  290. }
  291. } else {
  292. return "nodate";
  293. }
  294. }
  295. }
  296. }
  297. } else if (script.equalsIgnoreCase(VBulletin.Name) || script.equalsIgnoreCase(VBulletin.ShortName)) {
  298. if (Util.checkVersionInRange(VBulletin.VersionRange)) {
  299. // vBulletin 3
  300. if (what.equalsIgnoreCase("getgroup")) {
  301. GroupID = MySQL.getfromtable(Config.script_tableprefix + "user", "`usergroupid`", "username", player.getName());
  302. GroupName = MySQL.getfromtable(Config.script_tableprefix + "usergroup", "`title`", "usergroupid", GroupID);
  303. } else if (what.equalsIgnoreCase("checkifbanned")) {
  304. if (player == null) {
  305. IsBanned = MySQL.getfromtable(Config.script_tableprefix + "setting", "`datatype`", "varname", "value", "banip", extra);
  306. if (IsBanned.equalsIgnoreCase("fail")) {
  307. return "false";
  308. } else {
  309. return "true";
  310. }
  311. } else {
  312. UserID = MySQL.getfromtable(Config.script_tableprefix + "user", "`userid`", "username", player.getName());
  313. IsBanned = MySQL.getfromtable(Config.script_tableprefix + "userban", "`bandate`", "userid", UserID);
  314. if (IsBanned.equalsIgnoreCase("fail")) {
  315. return "false";
  316. } else {
  317. return "true";
  318. }
  319. }
  320. } else if (what.equalsIgnoreCase("banreason")) {
  321. if (player == null) {
  322. return "noreason";
  323. } else {
  324. UserID = MySQL.getfromtable(Config.script_tableprefix + "user", "`userid`", "username", player.getName());
  325. BanReason = MySQL.getfromtable(Config.script_tableprefix + "userban", "`reason`", "userid", UserID);
  326. if (BanReason != "fail" && BanReason != "" && BanReason != null) {
  327. return BanReason;
  328. } else {
  329. return "noreason";
  330. }
  331. }
  332. } else if (what.equalsIgnoreCase("bannedtodate")) {
  333. if (player == null) {
  334. return "nodate";
  335. } else {
  336. UserID = MySQL.getfromtable(Config.script_tableprefix + "user", "`userid`", "username", player.getName());
  337. BannedToDate = MySQL.getfromtable(Config.script_tableprefix + "userban", "`liftdate`", "userid", UserID);
  338. if (BannedToDate != "fail") {
  339. if (BannedToDate == null || BannedToDate.equalsIgnoreCase("0")) {
  340. return "perma";
  341. } else {
  342. return BannedToDate + ",unix";
  343. }
  344. } else {
  345. return "nodate";
  346. }
  347. }
  348. }
  349. } else if (Util.checkVersionInRange(VBulletin.VersionRange2)) {
  350. // vBulletin 4
  351. if (what.equalsIgnoreCase("getgroup")) {
  352. GroupID = MySQL.getfromtable(Config.script_tableprefix + "user", "`usergroupid`", "username", player.getName());
  353. GroupName = MySQL.getfromtable(Config.script_tableprefix + "usergroup", "`title`", "usergroupid", GroupID);
  354. } else if (what.equalsIgnoreCase("checkifbanned")) {
  355. if (player == null) {
  356. IsBanned = MySQL.getfromtable(Config.script_tableprefix + "setting", "`datatype`", "varname", "value", "banip", extra);
  357. if (IsBanned.equalsIgnoreCase("fail")) {
  358. return "false";
  359. } else {
  360. return "true";
  361. }
  362. } else {
  363. UserID = MySQL.getfromtable(Config.script_tableprefix + "user", "`userid`", "username", player.getName());
  364. IsBanned = MySQL.getfromtable(Config.script_tableprefix + "userban", "`bandate`", "userid", UserID);
  365. if (IsBanned.equalsIgnoreCase("fail")) {
  366. return "false";
  367. } else {
  368. return "true";
  369. }
  370. }
  371. } else if (what.equalsIgnoreCase("banreason")) {
  372. if (player == null) {
  373. return "noreason";
  374. } else {
  375. UserID = MySQL.getfromtable(Config.script_tableprefix + "user", "`userid`", "username", player.getName());
  376. BanReason = MySQL.getfromtable(Config.script_tableprefix + "userban", "`bandate`", "userid", UserID);
  377. if (BanReason != "fail" && BanReason != "" && BanReason != null) {
  378. return BanReason;
  379. } else {
  380. return "noreason";
  381. }
  382. }
  383. } else if (what.equalsIgnoreCase("bannedtodate")) {
  384. if (player == null) {
  385. return "nodate";
  386. } else {
  387. UserID = MySQL.getfromtable(Config.script_tableprefix + "user", "`userid`", "username", player.getName());
  388. BannedToDate = MySQL.getfromtable(Config.script_tableprefix + "userban", "`liftdate`", "userid", UserID);
  389. if (BannedToDate != "fail") {
  390. if (BannedToDate == null || BannedToDate.equalsIgnoreCase("0")) {
  391. return "perma";
  392. } else {
  393. return BannedToDate + ",unix";
  394. }
  395. } else {
  396. return "nodate";
  397. }
  398. }
  399. }
  400. }
  401. } else if (script.equalsIgnoreCase(Drupal.Name) || script.equalsIgnoreCase(Drupal.ShortName)) {
  402. if (Util.checkVersionInRange(Drupal.VersionRange)) {
  403. // Drupal 6
  404. if (what.equalsIgnoreCase("getgroup")) {
  405. UserID = MySQL.getfromtable(Config.script_tableprefix + "users", "`uid`", "name", player.getName());
  406. GroupID = MySQL.getfromtable(Config.script_tableprefix + "users_roles", "`rid`", "uid", UserID);
  407. GroupName = MySQL.getfromtable(Config.script_tableprefix + "role", "`name`", "rid", GroupID);
  408. } else if (what.equalsIgnoreCase("checkifbanned")) {
  409. if (player == null) {
  410. IsBanned = MySQL.getfromtable(Config.script_tableprefix + "access", "`type`", "mask", extra);
  411. if (IsBanned.equalsIgnoreCase("fail")) {
  412. String delimiter = "\\.";
  413. StringBuffer tempIP = new StringBuffer();
  414. String[] temp = extra.split(delimiter);
  415. int counter = 0;
  416. while (counter > (temp.length - 1)) {
  417. tempIP.append(temp[counter] + ".");
  418. counter++;
  419. }
  420. tempIP.append("%");
  421. IsBanned = MySQL.getfromtable(Config.script_tableprefix + "access", "`type`", "mask", tempIP.toString());
  422. if (IsBanned.equalsIgnoreCase("fail")) {
  423. return "false";
  424. }
  425. }
  426. return "true";
  427. } else {
  428. IsBanned = MySQL.getfromtable(Config.script_tableprefix + "access", "`type`", "mask", player.getName());
  429. if (IsBanned.equalsIgnoreCase("fail")) {
  430. return "false";
  431. } else { return "true"; }
  432. }
  433. } else if (what.equalsIgnoreCase("banreason")) {
  434. // No ban reason on ban
  435. return "noreason";
  436. } else if (what.equalsIgnoreCase("bannedtodate")) {
  437. // No date set on ban, it's perma
  438. return "nodate";
  439. }
  440. } else if (Util.checkVersionInRange(Drupal.VersionRange2)) {
  441. // Drupal 7
  442. if (what.equalsIgnoreCase("getgroup")) {
  443. UserID = MySQL.getfromtable(Config.script_tableprefix + "users", "`uid`", "name", player.getName());
  444. GroupID = MySQL.getfromtable(Config.script_tableprefix + "users_roles", "`rid`", "uid", UserID);
  445. GroupName = MySQL.getfromtable(Config.script_tableprefix + "role", "`name`", "rid", GroupID);
  446. } else if (what.equalsIgnoreCase("checkifbanned")) {
  447. if (player == null) {
  448. IsBanned = MySQL.getfromtable(Config.script_tableprefix + "blocked_ips", "`iid`", "ip", extra);
  449. if (IsBanned.equalsIgnoreCase("fail")) {
  450. return "false";
  451. } else {
  452. return "true";
  453. }
  454. } else {
  455. IsBanned = MySQL.getfromtable2(Config.script_tableprefix + "users", "`uid`", "name", "status", player.getName(), "0");
  456. if (IsBanned.equalsIgnoreCase("fail")) {
  457. return "false";
  458. } else { return "true"; }
  459. }
  460. } else if (what.equalsIgnoreCase("banreason")) {
  461. // No ban reason on ban
  462. return "noreason";
  463. } else if (what.equalsIgnoreCase("bannedtodate")) {
  464. // No date on ban, it's perma
  465. return "nodate";
  466. }
  467. }
  468. } else if (script.equalsIgnoreCase(Joomla.Name) || script.equalsIgnoreCase(Joomla.ShortName)) {
  469. if (Util.checkVersionInRange(Joomla.VersionRange)) {
  470. // 1.5
  471. if (what.equalsIgnoreCase("getgroup")) {
  472. GroupID = MySQL.getfromtable(Config.script_tableprefix + "users", "`gid`", "username", player.getName());
  473. GroupName = MySQL.getfromtable(Config.script_tableprefix + "core_acl_aro_groups", "`name`", "id", GroupID);
  474. } else if (what.equalsIgnoreCase("checkifbanned")) {
  475. if (player == null) {
  476. //String BanID = MySQL.getfromtable(Config.script_tableprefix + "plugins", "`params`", "name", "System - Ban IP Address");
  477. IsBanned = MySQL.getfromtablelike(Config.script_tableprefix + "plugins", "`name`", "element", "params", "ban", extra);
  478. if (IsBanned.equalsIgnoreCase("fail")) {
  479. return "false";
  480. } else { return "true"; }
  481. } else {
  482. return "false";
  483. }
  484. } else if (what.equalsIgnoreCase("banreason")) {
  485. // No reason yet on ban
  486. return "noreason";
  487. } else if (what.equalsIgnoreCase("bannedtodate")) {
  488. // Extension needed
  489. return "nodate";
  490. }
  491. } else if (Util.checkVersionInRange(Joomla.VersionRange2)) {
  492. // 1.6
  493. if (what.equalsIgnoreCase("getgroup")) {
  494. UserID = MySQL.getfromtable(Config.script_tableprefix + "users", "`id`", "username", player.getName());
  495. GroupID = MySQL.getfromtable(Config.script_tableprefix + "user_usergroup_map", "`group_id`", "user_id", UserID);
  496. GroupName = MySQL.getfromtable(Config.script_tableprefix + "usergroups", "`title`", "id", GroupID);
  497. } else if (what.equalsIgnoreCase("checkifbanned")) {
  498. // Not built in, need a extension.
  499. return "";
  500. } else if (what.equalsIgnoreCase("banreason")) {
  501. // No reason yet on ban
  502. return "noreason";
  503. } else if (what.equalsIgnoreCase("bannedtodate")) {
  504. // No date yet
  505. return "nodate";
  506. }
  507. }
  508. } else if (script.equalsIgnoreCase(Vanilla.Name) || script.equalsIgnoreCase(Vanilla.ShortName)) {
  509. if (Util.checkVersionInRange(Vanilla.VersionRange)) {
  510. String userTable = "User";
  511. String userRoleTable = "UserRole";
  512. String roleTable = "Role";
  513. if (Vanilla.check() == 2) {
  514. userTable = userTable.toLowerCase();
  515. userRoleTable = userRoleTable.toLowerCase();
  516. roleTable = roleTable.toLowerCase();
  517. }
  518. if (what.equalsIgnoreCase("getgroup")) {
  519. UserID = MySQL.getfromtable(Config.script_tableprefix + userTable, "`UserID`", "Name", player.getName());
  520. GroupID = MySQL.getfromtable(Config.script_tableprefix + userRoleTable, "`RoleID`", "UserID", UserID);
  521. GroupName = MySQL.getfromtable(Config.script_tableprefix + roleTable, "`Name`", "RoleID", GroupID);
  522. } else if (what.equalsIgnoreCase("checkifbanned")) {
  523. if (player == null) {
  524. return "";
  525. // Find addon
  526. } else {
  527. String BanID = MySQL.getfromtable(Config.script_tableprefix + roleTable, "`RoleID`", "Name", "Banned");
  528. UserID = MySQL.getfromtable(Config.script_tableprefix + userTable, "`UserID`", "Name", player.getName());
  529. IsBanned = MySQL.getfromtable2(Config.script_tableprefix + userRoleTable, "`UserID`", "UserID", "RoleID", UserID, BanID);
  530. if (IsBanned.equalsIgnoreCase("fail")) {
  531. return "false";
  532. } else {
  533. return "true";
  534. }
  535. }
  536. } else if (what.equalsIgnoreCase("banreason")) {
  537. // No reason on ban
  538. return "noreason";
  539. } else if (what.equalsIgnoreCase("bannedtodate")) {
  540. // No date on ban, just a group
  541. return "nodate";
  542. }
  543. }
  544. } else if (script.equalsIgnoreCase(PunBB.Name) || script.equalsIgnoreCase(PunBB.ShortName)) {
  545. if (Util.checkVersionInRange(PunBB.VersionRange)) {
  546. if (what.equalsIgnoreCase("getgroup")) {
  547. GroupID = MySQL.getfromtable(Config.script_tableprefix + "users", "`group_id`", "username", player.getName());
  548. GroupName = MySQL.getfromtable(Config.script_tableprefix + "groups", "`g_title`", "g_id", GroupID);
  549. } else if (what.equalsIgnoreCase("checkifbanned")) {
  550. if (player == null) {
  551. IsBanned = MySQL.getfromtable(Config.script_tableprefix + "bans", "`ban_creator`", "ip", extra);
  552. if (IsBanned.equalsIgnoreCase("fail")) {
  553. return "false";
  554. } else {
  555. return "true";
  556. }
  557. } else {
  558. IsBanned = MySQL.getfromtable(Config.script_tableprefix + "bans", "`ban_creator`", "username", player.getName());
  559. if (IsBanned.equalsIgnoreCase("fail")) {
  560. return "false";
  561. } else {
  562. return "true";
  563. }
  564. }
  565. } else if (what.equalsIgnoreCase("banreason")) {
  566. if (player == null) {
  567. BanReason = MySQL.getfromtable(Config.script_tableprefix + "bans", "`message`", "ip", extra);
  568. if (BanReason != "fail" && BanReason != "" && BanReason != null) {
  569. return BanReason;
  570. } else {
  571. return "noreason";
  572. }
  573. } else {
  574. BanReason = MySQL.getfromtable(Config.script_tableprefix + "bans", "`message`", "username", player.getName());
  575. if (BanReason != "fail" && BanReason != "" && BanReason != null) {
  576. return BanReason;
  577. } else {
  578. return "noreason";
  579. }
  580. }
  581. } else if (what.equalsIgnoreCase("bannedtodate")) {
  582. if (player == null) {
  583. BannedToDate = MySQL.getfromtable(Config.script_tableprefix + "bans", "`expire`", "ip", extra);
  584. if (BannedToDate != "fail") {
  585. if (BannedToDate == null || BannedToDate.equalsIgnoreCase("0") || BannedToDate.equalsIgnoreCase("NULL")) {
  586. return "perma";
  587. } else {
  588. return BannedToDate + ",unix";
  589. }
  590. } else { return "nodate"; }
  591. } else {
  592. BannedToDate = MySQL.getfromtable(Config.script_tableprefix + "bans", "`expire`", "username", player.getName());
  593. if (BannedToDate != "fail") {
  594. if (BannedToDate == null || BannedToDate.equalsIgnoreCase("0") || BannedToDate.equalsIgnoreCase("NULL")) {
  595. return "perma";
  596. } else {
  597. return BannedToDate + ",unix";
  598. }
  599. } else {
  600. return "nodate";
  601. }
  602. }
  603. }
  604. }
  605. } else if (script.equalsIgnoreCase(XenForo.Name) || script.equalsIgnoreCase(XenForo.ShortName)) {
  606. if (Util.checkVersionInRange(XenForo.VersionRange)) {
  607. if (what.equalsIgnoreCase("getgroup")) {
  608. return "";
  609. //next version
  610. } else if (what.equalsIgnoreCase("checkifbanned")) {
  611. if (player == null) {
  612. IsBanned = MySQL.getfromtable(Config.script_tableprefix + "ip_match", "`match_type`", "ip", extra);
  613. if (IsBanned.equalsIgnoreCase("fail")) {
  614. String delimiter = "\\.";
  615. StringBuffer tempIP = new StringBuffer();
  616. String[] temp = extra.split(delimiter);
  617. int counter = 0;
  618. while (counter > (temp.length - 1)) {
  619. tempIP.append(temp[counter] + ".");
  620. counter++;
  621. }
  622. tempIP.append("*");
  623. IsBanned = MySQL.getfromtable(Config.script_tableprefix + "ip_match", "`match_type`", "ip", tempIP.toString());
  624. if (IsBanned.equalsIgnoreCase("fail")) {
  625. return "false";
  626. }
  627. }
  628. return "true";
  629. } else {
  630. UserID = MySQL.getfromtable(Config.script_tableprefix + "user", "`user_id`", "username", player.getName());
  631. IsBanned = MySQL.getfromtable(Config.script_tableprefix + "user_ban", "`ban_date`", "user_id", UserID);
  632. if (IsBanned.equalsIgnoreCase("fail")) { return "false"; }
  633. else { return "true"; }
  634. }
  635. } else if (what.equalsIgnoreCase("banreason")) {
  636. if (player == null) {
  637. return "noreason";
  638. } else {
  639. UserID = MySQL.getfromtable(Config.script_tableprefix + "user", "`user_id`", "username", player.getName());
  640. BanReason = MySQL.getfromtable(Config.script_tableprefix + "user_ban", "`user_reason`", "user_id", UserID);
  641. if (BanReason != "fail" && BanReason != "" && BanReason != null) {
  642. return BanReason;
  643. } else {
  644. return "noreason";
  645. }
  646. }
  647. } else if (what.equalsIgnoreCase("bannedtodate")) {
  648. if (player == null) {
  649. return "nodate";
  650. } else {
  651. UserID = MySQL.getfromtable(Config.script_tableprefix + "user", "`user_id`", "username", player.getName());
  652. BannedToDate = MySQL.getfromtable(Config.script_tableprefix + "user_ban", "`end_date`", "user_id", UserID);
  653. if (BannedToDate != "fail") {
  654. if (BannedToDate == null || BannedToDate.equalsIgnoreCase("0") || BannedToDate.equalsIgnoreCase("NULL")) {
  655. return "perma";
  656. } else {
  657. return BannedToDate + ",unix";
  658. }
  659. } else {
  660. return "nodate";
  661. }
  662. }
  663. }
  664. }
  665. } else if (script.equalsIgnoreCase(BBPress.Name) || script.equalsIgnoreCase(BBPress.ShortName)) {
  666. if (Util.checkVersionInRange(BBPress.VersionRange)) {
  667. if (what.equalsIgnoreCase("getgroup")) {
  668. return "";
  669. // Next version: http://buddypress.org/
  670. } else if (what.equalsIgnoreCase("checkifbanned")) {
  671. if (player == null) {
  672. return "";
  673. // Next version, need to install addon: http://bbpress.org/plugins/topic/bbpress-moderation-suite/
  674. } else {
  675. return "";
  676. // Next version, need to install addon: http://bbpress.org/plugins/topic/bbpress-moderation-suite/
  677. }
  678. } else if (what.equalsIgnoreCase("banreason")) {
  679. // No reason yet, add addon
  680. return "noreason";
  681. } else if (what.equalsIgnoreCase("bannedtodate")) {
  682. // No date yet, add addon
  683. return "nodate";
  684. }
  685. }
  686. } else if (script.equalsIgnoreCase(DLE.Name) || script.equalsIgnoreCase(DLE.ShortName)) {
  687. if (Util.checkVersionInRange(DLE.VersionRange)) {
  688. if (what.equalsIgnoreCase("getgroup")) {
  689. GroupID = MySQL.getfromtable(Config.script_tableprefix + "users", "`users_group`", "name", player.getName());
  690. GroupName = MySQL.getfromtable(Config.script_tableprefix + "usergroups", "`group_name`", "id", GroupID);
  691. } else if (what.equalsIgnoreCase("checkifbanned")) {
  692. if (player == null) {
  693. IsBanned = MySQL.getfromtable(Config.script_tableprefix + "banned", "`date`", "ip", extra);
  694. if (IsBanned.equalsIgnoreCase("fail")) {
  695. String delimiter = "\\.";
  696. StringBuffer tempIP = new StringBuffer();
  697. String[] temp = extra.split(delimiter);
  698. int counter = 0;
  699. while (counter > (temp.length - 1)) {
  700. tempIP.append(temp[counter] + ".");
  701. counter++;
  702. }
  703. tempIP.append("*");
  704. IsBanned = MySQL.getfromtable(Config.script_tableprefix + "banned", "`date`", "ip", tempIP.toString());
  705. if (IsBanned.equalsIgnoreCase("fail")) {
  706. return "false";
  707. }
  708. } else {
  709. return "true";
  710. }
  711. } else {
  712. UserID = MySQL.getfromtable(Config.script_tableprefix + "users", "`user_id`", "name", player.getName());
  713. IsBanned = MySQL.getfromtable(Config.script_tableprefix + "banned", "`date`", "users_id", UserID);
  714. if (IsBanned.equalsIgnoreCase("fail")) {
  715. return "false";
  716. } else {
  717. return "true";
  718. }
  719. }
  720. } else if (what.equalsIgnoreCase("banreason")) {
  721. if (player == null) {
  722. BanReason = MySQL.getfromtable(Config.script_tableprefix + "banned", "`descr`", "ip", extra);
  723. if (BanReason != "fail" && BanReason != "" && BanReason != null) {
  724. return BanReason;
  725. } else {
  726. String delimiter = "\\.";
  727. StringBuffer tempIP = new StringBuffer();
  728. String[] temp = extra.split(delimiter);
  729. int counter = 0;
  730. while (counter > (temp.length - 1)) {
  731. tempIP.append(temp[counter] + ".");
  732. counter++;
  733. }
  734. tempIP.append("*");
  735. IsBanned = MySQL.getfromtable(Config.script_tableprefix + "banned", "`date`", "ip", tempIP.toString());
  736. if (BanReason != "fail" && BanReason != "" && BanReason != null) {
  737. return BanReason;
  738. }
  739. }
  740. return "noreason";
  741. } else {
  742. UserID = MySQL.getfromtable(Config.script_tableprefix + "users", "`user_id`", "name", player.getName());
  743. BanReason = MySQL.getfromtable(Config.script_tableprefix + "banned", "`descr`", "users_id", UserID);
  744. if (BanReason != "fail" && BanReason != "" && BanReason != null) {
  745. return BanReason;
  746. } else {
  747. return "noreason";
  748. }
  749. }
  750. } else if (what.equalsIgnoreCase("bannedtodate")) {
  751. if (player == null) {
  752. BannedToDate = MySQL.getfromtable(Config.script_tableprefix + "banned", "`days`", "ip", extra);
  753. if (BannedToDate != "fail") {
  754. if (BannedToDate == null || BannedToDate.equalsIgnoreCase("0") || BannedToDate.equalsIgnoreCase("NULL")) {
  755. return "perma";
  756. } else {
  757. int StartUnix = Integer.parseInt(MySQL.getfromtable(Config.script_tableprefix + "banned", "`date`", "ip", extra));
  758. StartUnix += Integer.parseInt(BannedToDate) * 86400;
  759. return StartUnix + ",unix";
  760. }
  761. } else {
  762. return "nodate";
  763. }
  764. } else {
  765. UserID = MySQL.getfromtable(Config.script_tableprefix + "users", "`user_id`", "name", player.getName());
  766. BannedToDate = MySQL.getfromtable(Config.script_tableprefix + "banned", "`days`", "users_id", UserID);
  767. if (BannedToDate != "fail") {
  768. if (BannedToDate == null || BannedToDate.equalsIgnoreCase("0") || BannedToDate.equalsIgnoreCase("NULL")) {
  769. return "perma";
  770. } else {
  771. int StartUnix = Integer.parseInt(MySQL.getfromtable(Config.script_tableprefix + "banned", "`date`", "users_id", UserID));
  772. StartUnix += Integer.parseInt(BannedToDate) * 86400;
  773. return StartUnix + ",unix";
  774. }
  775. } else {
  776. return "nodate";
  777. }
  778. }
  779. }
  780. }
  781. } else if ((script.equalsIgnoreCase(IPB.Name) || script.equalsIgnoreCase(IPB.ShortName)) && Util.checkVersionInRange(IPB.VersionRange)) {
  782. if (what.equalsIgnoreCase("getgroup")) {
  783. // Next version
  784. return "";
  785. } else if (what.equalsIgnoreCase("checkifbanned")) {
  786. if (player == null) {
  787. // Next version
  788. return "";
  789. } else {
  790. // Next version
  791. return "";
  792. }
  793. } else if (what.equalsIgnoreCase("banreason")) {
  794. if (player == null) {
  795. //
  796. return "";
  797. }
  798. // Nothing yet
  799. return "noreason";
  800. } else if (what.equalsIgnoreCase("bannedtodate")) {
  801. if (player == null) {
  802. //
  803. return "";
  804. }
  805. // Install IPB on local
  806. return "nodate";
  807. }
  808. } else if (script.equalsIgnoreCase(WordPress.Name) || script.equalsIgnoreCase(WordPress.ShortName)) {
  809. if (Util.checkVersionInRange(WordPress.VersionRange)) {
  810. if (what.equalsIgnoreCase("getgroup")) {
  811. return "";
  812. // Next version: http://buddypress.org/
  813. } else if (what.equalsIgnoreCase("checkifbanned")) {
  814. if (player == null) {
  815. return "";
  816. // Next version, need to install addon: http://bbpress.org/plugins/topic/bbpress-moderation-suite/
  817. } else {
  818. return "";
  819. // Next version, need to install addon: http://bbpress.org/plugins/topic/bbpress-moderation-suite/
  820. }
  821. } else if (what.equalsIgnoreCase("banreason")) {
  822. // No reason yet, add addon
  823. return "noreason";
  824. } else if (what.equalsIgnoreCase("bannedtodate")) {
  825. // No date yet, add addon
  826. return "nodate";
  827. }
  828. }
  829. }
  830. if (what.equalsIgnoreCase("getgroup")) {
  831. return GroupName.toLowerCase();
  832. }
  833. return "fail";
  834. }
  835. }