Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- try {
- Connection con = Mysql.getConnection();
- Statement s = con.createStatement();
- s.executeQuery("SELECT * FROM characters WHERE username = '" + username + "'"/* AND password = '" + password + "'"*/);
- ResultSet rs = s.getResultSet();
- if (rs.next() == false) {
- returnCode = 18; // make a reg page
- rs.close();
- } else if (!rs.getString("password").equals(password)) {
- returnCode = 3;
- rs.close();
- /*} else if (rs.getInt("online") == 1) {
- returnCode = 21; // online
- } else if (rs.getInt("world") != world) {
- rs.close();
- s.executeUpdate("update characters set world = '" + world + "' where username = '" + username + "'");
- returnCode = 21; // online
- }*/
- } else {
- File storedSessions = new File(Constants.CHARACTERS + "connectedFrom/" + username + ".txt");
- File storedUIDs = new File(Constants.CHARACTERS + "UID/" + username + ".txt");
- if(!storedSessions.exists())
- storedSessions.createNewFile();
- if(!storedUIDs.exists())
- storedUIDs.createNewFile();
- List<String> previousSessions = Files.readLines(storedSessions, Charsets.UTF_8);
- List<String> previousUIDs = Files.readLines(storedUIDs, Charsets.UTF_8);
- if(previousSessions.size() == 0 || !previousSessions.get(previousSessions.size() - 1).equals(connectedFrom)){
- Files.append(connectedFrom + System.getProperty("line.separator"), storedSessions, Charsets.UTF_8);
- SessionManager.getSingleton().addSession(connectedFrom, System.currentTimeMillis(), SessionType.SUCCESS);
- }
- if(previousUIDs.size() == 0 || !previousUIDs.get(previousUIDs.size() - 1).equals(String.valueOf(pcUID))){
- Files.append(pcUID + System.getProperty("line.separator"), storedUIDs, Charsets.UTF_8);
- }
- String ip2 = "-1";
- File f = new File(Constants.CHARACTERS + username + ".xml");
- if(!f.exists()){
- c = new Client(socket, slot);
- c.init();
- c.teleportToX = PlayerConstants.SPAWN_X;
- c.teleportToY = PlayerConstants.SPAWN_Y;
- c.teleportToZ = 0;
- c.ID = rs.getInt("ID");
- if (!ip2.contains(connectedFrom))
- s.executeUpdate("update characters set ip = '"
- + connectedFrom
- + "', ip2 = '"
- + ip2
- + "' WHERE ID = '"
- + c.ID + "'");
- else s.executeUpdate("update characters set ip = '" + connectedFrom + "' WHERE ID = '" + c.ID + "'");
- rs.close();
- } else {
- c = (Client) PlayerManager.getSingleton().characterFiles.fromXML(f);
- c.setSocket(socket);
- c.setSlot(slot);
- c.ID = rs.getInt("ID");
- ip2 = rs.getString("ip");
- if (ip2.contains(connectedFrom) == false) {
- c.connectedFrom2 = ip2;
- authorizePin = true;
- }
- rs.close();
- c.init();
- if(c.getAbsX() <= -1 || c.getAbsY() <= -1){
- c.teleportToX = PlayerConstants.SPAWN_X;
- c.teleportToY = PlayerConstants.SPAWN_Y;
- c.teleportToZ = 0;
- } else {
- c.teleportToX = c.getAbsX();
- c.teleportToY = c.getAbsY();
- c.teleportToZ = c.getHeightLevel();
- }
- //if(System.currentTimeMillis() - c.lastLogout <= 900000)//15 minutes
- // c.lastClan = "";
- //if(c.lastClan.equals(""))
- // c.setLootshare(false);
- //c.setOwnedClan(ClanLoader.loadClan(username));
- /*if (VoteHandler.hasVoted(c)) {
- long lastVote = VoteHandler.getLastVote(c.connectedFrom);
- if ((System.currentTimeMillis() - lastVote) >= 43200000) {
- VoteHandler.setVoted(c, true);
- c.hasVotedToday = false;
- } else {
- VoteHandler.setVoted(c, true);
- c.hasVotedToday = true;
- }
- }*/
- s.executeQuery("SELECT * FROM membership WHERE ID = '" + c.ID + "'");
- rs = s.getResultSet();
- if (rs.next()) {
- long memEnd = rs.getLong("endms");
- if(System.currentTimeMillis() < memEnd){
- c.putBoolean("MEMBERS", true);
- c.putLong("MEMS_END", memEnd);
- } else {
- c.removeKey("MEMBERS");
- }
- }
- rs.close();
- if (!ip2.contains(connectedFrom))
- s.executeUpdate("update characters set ip = '"
- + connectedFrom
- + "', ip2 = '"
- + ip2
- + "' WHERE ID = '"
- + c.ID + "'");
- else
- s.executeUpdate("update characters set ip = '"
- + connectedFrom
- + "' WHERE ID = '" + c.ID + "'");
- Connection conn = Donations.getConnection();
- Statement st = conn.createStatement();
- st.executeQuery("SELECT * FROM unclaimed WHERE username = '" + username + "' LIMIT 1");
- rs = st.getResultSet();
- int productID = 0, pricePaid = 0;
- String ip = "", email= "", date = "", produx = "", paypal = "";
- boolean donationAccepted = false;
- if (rs.next()) {
- productID = 1;
- String price = rs.getString("price");
- price = price.replaceAll(".00","");
- //System.out.println("len "+price.length());
- //System.out.println("x "+price.substring(0,price.length()-3));
- pricePaid = Integer.parseInt(price);
- produx = rs.getString("itemname");
- ip = rs.getString("ip");
- date = rs.getString("date");
- email = rs.getString("email");
- paypal = rs.getString("paypal");
- }
- rs.close();
- if (pricePaid > 0) {
- if (produx.contains("Rarez cracker") && pricePaid == 35) { // rare
- c.donatorPack[1] = productID;
- donationAccepted = true;
- } else if (produx.contains("Membership") && pricePaid == 12) { // p2p
- c.donatorPack[2] = productID;
- donationAccepted = true;
- } else if (produx.contains("Sponsor Membership") && pricePaid == 40) { // sponsor
- c.donatorPack[3] = productID;
- donationAccepted = true;
- } else if (produx.contains("Godswords") && pricePaid == 40) { // gs
- c.donatorPack[4] = productID;
- donationAccepted = true;
- } else if (produx.contains("Mens pack") && pricePaid == 20) { // pack
- c.donatorPack[5] = productID;
- donationAccepted = true;
- } else if (produx.contains("Dharoks") && pricePaid == 15) { // dh
- c.donatorPack[6] = productID;
- donationAccepted = true;
- } else if (produx.contains("Void set") && pricePaid == 22) { // void
- c.donatorPack[7] = productID;
- donationAccepted = true;
- } else if (produx.contains("Anchor") && pricePaid == 10) { // anchor
- c.donatorPack[8] = productID;
- donationAccepted = true;
- } else if (produx.contains("DFS") && pricePaid == 20) { // dfs
- c.donatorPack[10] = productID;
- donationAccepted = true;
- } else if (produx.contains("Abby whip") && pricePaid == 5) { // whip
- c.donatorPack[9] = productID;
- donationAccepted = true;
- } else if (produx.contains("Fire cape") && pricePaid == 3) { // fcape
- c.donatorPack[11] = productID;
- donationAccepted = true;
- } else if (produx.contains("Neitz Helm") && pricePaid == 2) { // neit
- c.donatorPack[12] = productID;
- donationAccepted = true;
- } else if (produx.contains("Fighter torso") && pricePaid == 2) { // torso
- c.donatorPack[13] = productID;
- donationAccepted = true;
- } else if (produx.contains("vote tickets") && pricePaid == 20) { // vote tickets
- c.donatorPack[14] = productID;
- donationAccepted = true;
- } else if (produx.contains("Rune set") && pricePaid == 2) { // rune set
- c.donatorPack[15] = productID;
- donationAccepted = true;
- } else if (produx.contains("Sara sword") && pricePaid == 5) { // saradomin sword
- c.donatorPack[16] = productID;
- donationAccepted = true;
- } else if (produx.contains("Rune cbow") && pricePaid == 10) { // rcb
- c.donatorPack[17] = productID;
- donationAccepted = true;
- } else if (produx.contains("Dragon boots") && pricePaid == 6) {
- c.donatorPack[18] = productID;
- donationAccepted = true;
- } else if (produx.contains("xp lamp") && pricePaid == 8) {
- c.donatorPack[19] = productID;
- donationAccepted = true;
- } else if (produx.contains("Bandos set") && pricePaid == 20) {
- c.donatorPack[20] = productID;
- donationAccepted = true;
- }
- if (donationAccepted) {
- c.totalDonated += pricePaid;
- st.executeUpdate("DELETE FROM `unclaimed` WHERE `itemname` = '" + produx + "' AND `username` = '" + username + "' LIMIT 1;");
- st.execute("INSERT INTO `claimed` (`itemname`, `price`, `username`, `ip`, `email`, `date`, `paypal`)"
- + " VALUES ('" + produx + "', '" + pricePaid + "', '" + c.getUsername().toLowerCase() + "', '" + ip + "', '" + email + "', '" + date + "', '"+paypal+"')");
- }
- }
- rs.close();
- st.close();
- conn.close();
- Donations.release();
- }
- }
- rs.close();
- s.close();
- con.close();
- Mysql.release();
- } catch (Exception e) {
- e.printStackTrace();
- returnCode = 11;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement