Advertisement
Guest User

Untitled

a guest
Dec 13th, 2016
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.54 KB | None | 0 0
  1. try {
  2.  
  3. Connection con = Mysql.getConnection();
  4. Statement s = con.createStatement();
  5. s.executeQuery("SELECT * FROM characters WHERE username = '" + username + "'"/* AND password = '" + password + "'"*/);
  6. ResultSet rs = s.getResultSet();
  7.  
  8.  
  9. if (rs.next() == false) {
  10. returnCode = 18; // make a reg page
  11. rs.close();
  12. } else if (!rs.getString("password").equals(password)) {
  13. returnCode = 3;
  14. rs.close();
  15. /*} else if (rs.getInt("online") == 1) {
  16. returnCode = 21; // online
  17. } else if (rs.getInt("world") != world) {
  18. rs.close();
  19. s.executeUpdate("update characters set world = '" + world + "' where username = '" + username + "'");
  20. returnCode = 21; // online
  21.  
  22. }*/
  23.  
  24. } else {
  25. File storedSessions = new File(Constants.CHARACTERS + "connectedFrom/" + username + ".txt");
  26. File storedUIDs = new File(Constants.CHARACTERS + "UID/" + username + ".txt");
  27.  
  28. if(!storedSessions.exists())
  29. storedSessions.createNewFile();
  30. if(!storedUIDs.exists())
  31. storedUIDs.createNewFile();
  32.  
  33. List<String> previousSessions = Files.readLines(storedSessions, Charsets.UTF_8);
  34. List<String> previousUIDs = Files.readLines(storedUIDs, Charsets.UTF_8);
  35.  
  36. if(previousSessions.size() == 0 || !previousSessions.get(previousSessions.size() - 1).equals(connectedFrom)){
  37. Files.append(connectedFrom + System.getProperty("line.separator"), storedSessions, Charsets.UTF_8);
  38. SessionManager.getSingleton().addSession(connectedFrom, System.currentTimeMillis(), SessionType.SUCCESS);
  39. }
  40. if(previousUIDs.size() == 0 || !previousUIDs.get(previousUIDs.size() - 1).equals(String.valueOf(pcUID))){
  41. Files.append(pcUID + System.getProperty("line.separator"), storedUIDs, Charsets.UTF_8);
  42. }
  43.  
  44. String ip2 = "-1";
  45. File f = new File(Constants.CHARACTERS + username + ".xml");
  46. if(!f.exists()){
  47. c = new Client(socket, slot);
  48. c.init();
  49. c.teleportToX = PlayerConstants.SPAWN_X;
  50. c.teleportToY = PlayerConstants.SPAWN_Y;
  51. c.teleportToZ = 0;
  52. c.ID = rs.getInt("ID");
  53. if (!ip2.contains(connectedFrom))
  54. s.executeUpdate("update characters set ip = '"
  55. + connectedFrom
  56. + "', ip2 = '"
  57. + ip2
  58. + "' WHERE ID = '"
  59. + c.ID + "'");
  60. else s.executeUpdate("update characters set ip = '" + connectedFrom + "' WHERE ID = '" + c.ID + "'");
  61. rs.close();
  62. } else {
  63. c = (Client) PlayerManager.getSingleton().characterFiles.fromXML(f);
  64. c.setSocket(socket);
  65. c.setSlot(slot);
  66. c.ID = rs.getInt("ID");
  67. ip2 = rs.getString("ip");
  68. if (ip2.contains(connectedFrom) == false) {
  69. c.connectedFrom2 = ip2;
  70. authorizePin = true;
  71. }
  72. rs.close();
  73. c.init();
  74. if(c.getAbsX() <= -1 || c.getAbsY() <= -1){
  75. c.teleportToX = PlayerConstants.SPAWN_X;
  76. c.teleportToY = PlayerConstants.SPAWN_Y;
  77. c.teleportToZ = 0;
  78. } else {
  79. c.teleportToX = c.getAbsX();
  80. c.teleportToY = c.getAbsY();
  81. c.teleportToZ = c.getHeightLevel();
  82. }
  83.  
  84. //if(System.currentTimeMillis() - c.lastLogout <= 900000)//15 minutes
  85. // c.lastClan = "";
  86. //if(c.lastClan.equals(""))
  87. // c.setLootshare(false);
  88.  
  89. //c.setOwnedClan(ClanLoader.loadClan(username));
  90.  
  91. /*if (VoteHandler.hasVoted(c)) {
  92. long lastVote = VoteHandler.getLastVote(c.connectedFrom);
  93. if ((System.currentTimeMillis() - lastVote) >= 43200000) {
  94. VoteHandler.setVoted(c, true);
  95. c.hasVotedToday = false;
  96. } else {
  97. VoteHandler.setVoted(c, true);
  98. c.hasVotedToday = true;
  99. }
  100. }*/
  101.  
  102. s.executeQuery("SELECT * FROM membership WHERE ID = '" + c.ID + "'");
  103. rs = s.getResultSet();
  104. if (rs.next()) {
  105. long memEnd = rs.getLong("endms");
  106. if(System.currentTimeMillis() < memEnd){
  107. c.putBoolean("MEMBERS", true);
  108. c.putLong("MEMS_END", memEnd);
  109. } else {
  110. c.removeKey("MEMBERS");
  111. }
  112. }
  113. rs.close();
  114.  
  115. if (!ip2.contains(connectedFrom))
  116. s.executeUpdate("update characters set ip = '"
  117. + connectedFrom
  118. + "', ip2 = '"
  119. + ip2
  120. + "' WHERE ID = '"
  121. + c.ID + "'");
  122. else
  123. s.executeUpdate("update characters set ip = '"
  124. + connectedFrom
  125. + "' WHERE ID = '" + c.ID + "'");
  126.  
  127. Connection conn = Donations.getConnection();
  128. Statement st = conn.createStatement();
  129. st.executeQuery("SELECT * FROM unclaimed WHERE username = '" + username + "' LIMIT 1");
  130. rs = st.getResultSet();
  131. int productID = 0, pricePaid = 0;
  132. String ip = "", email= "", date = "", produx = "", paypal = "";
  133. boolean donationAccepted = false;
  134. if (rs.next()) {
  135. productID = 1;
  136. String price = rs.getString("price");
  137. price = price.replaceAll(".00","");
  138. //System.out.println("len "+price.length());
  139. //System.out.println("x "+price.substring(0,price.length()-3));
  140. pricePaid = Integer.parseInt(price);
  141. produx = rs.getString("itemname");
  142. ip = rs.getString("ip");
  143. date = rs.getString("date");
  144. email = rs.getString("email");
  145. paypal = rs.getString("paypal");
  146. }
  147. rs.close();
  148.  
  149. if (pricePaid > 0) {
  150. if (produx.contains("Rarez cracker") && pricePaid == 35) { // rare
  151. c.donatorPack[1] = productID;
  152. donationAccepted = true;
  153. } else if (produx.contains("Membership") && pricePaid == 12) { // p2p
  154. c.donatorPack[2] = productID;
  155. donationAccepted = true;
  156. } else if (produx.contains("Sponsor Membership") && pricePaid == 40) { // sponsor
  157. c.donatorPack[3] = productID;
  158. donationAccepted = true;
  159. } else if (produx.contains("Godswords") && pricePaid == 40) { // gs
  160. c.donatorPack[4] = productID;
  161. donationAccepted = true;
  162. } else if (produx.contains("Mens pack") && pricePaid == 20) { // pack
  163. c.donatorPack[5] = productID;
  164. donationAccepted = true;
  165. } else if (produx.contains("Dharoks") && pricePaid == 15) { // dh
  166. c.donatorPack[6] = productID;
  167. donationAccepted = true;
  168. } else if (produx.contains("Void set") && pricePaid == 22) { // void
  169. c.donatorPack[7] = productID;
  170. donationAccepted = true;
  171. } else if (produx.contains("Anchor") && pricePaid == 10) { // anchor
  172. c.donatorPack[8] = productID;
  173. donationAccepted = true;
  174. } else if (produx.contains("DFS") && pricePaid == 20) { // dfs
  175. c.donatorPack[10] = productID;
  176. donationAccepted = true;
  177. } else if (produx.contains("Abby whip") && pricePaid == 5) { // whip
  178. c.donatorPack[9] = productID;
  179. donationAccepted = true;
  180. } else if (produx.contains("Fire cape") && pricePaid == 3) { // fcape
  181. c.donatorPack[11] = productID;
  182. donationAccepted = true;
  183. } else if (produx.contains("Neitz Helm") && pricePaid == 2) { // neit
  184. c.donatorPack[12] = productID;
  185. donationAccepted = true;
  186. } else if (produx.contains("Fighter torso") && pricePaid == 2) { // torso
  187. c.donatorPack[13] = productID;
  188. donationAccepted = true;
  189. } else if (produx.contains("vote tickets") && pricePaid == 20) { // vote tickets
  190. c.donatorPack[14] = productID;
  191. donationAccepted = true;
  192. } else if (produx.contains("Rune set") && pricePaid == 2) { // rune set
  193. c.donatorPack[15] = productID;
  194. donationAccepted = true;
  195. } else if (produx.contains("Sara sword") && pricePaid == 5) { // saradomin sword
  196. c.donatorPack[16] = productID;
  197. donationAccepted = true;
  198. } else if (produx.contains("Rune cbow") && pricePaid == 10) { // rcb
  199. c.donatorPack[17] = productID;
  200. donationAccepted = true;
  201. } else if (produx.contains("Dragon boots") && pricePaid == 6) {
  202. c.donatorPack[18] = productID;
  203. donationAccepted = true;
  204. } else if (produx.contains("xp lamp") && pricePaid == 8) {
  205. c.donatorPack[19] = productID;
  206. donationAccepted = true;
  207. } else if (produx.contains("Bandos set") && pricePaid == 20) {
  208. c.donatorPack[20] = productID;
  209. donationAccepted = true;
  210. }
  211.  
  212. if (donationAccepted) {
  213. c.totalDonated += pricePaid;
  214. st.executeUpdate("DELETE FROM `unclaimed` WHERE `itemname` = '" + produx + "' AND `username` = '" + username + "' LIMIT 1;");
  215. st.execute("INSERT INTO `claimed` (`itemname`, `price`, `username`, `ip`, `email`, `date`, `paypal`)"
  216. + " VALUES ('" + produx + "', '" + pricePaid + "', '" + c.getUsername().toLowerCase() + "', '" + ip + "', '" + email + "', '" + date + "', '"+paypal+"')");
  217. }
  218. }
  219. rs.close();
  220. st.close();
  221. conn.close();
  222. Donations.release();
  223.  
  224.  
  225.  
  226. }
  227. }
  228. rs.close();
  229. s.close();
  230. con.close();
  231. Mysql.release();
  232.  
  233. } catch (Exception e) {
  234. e.printStackTrace();
  235. returnCode = 11;
  236. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement