!unban <Alternative> <Unbans Macs and IP Address Also>

Page 1 of 3 123 LastLast
Results 1 to 15 of 36
  1. #1
    Account Upgraded | Title Enabled! Sathon is offline
    MemberRank
    Feb 2008 Join Date
    C:\Nexon\Location
    275Posts

    !unban <Alternative> <Unbans Macs and IP Address Also>

    Hi, I was about 50% finished making this !unban command when I notice someone released one. However, I notice that the current one doesn't unban macs and ip addresses, and mine does, so I decided I'd finish mine and release it.


    Here's the code for CommandProcessor.java:

    Code:
    else if(splitted[0].equals("!unban"))
                {
                    String playerName = splitted[1];
                    
                    Connection con = DatabaseConnection.getConnection();
                    PreparedStatement ps;
                    
                    int accountid = 0;
                    
                    try
                    {
                        //get points according to town
                        ps = con.prepareStatement("SELECT accountid FROM characters WHERE name = ?");
                        ps.setString(1, playerName);
                        ResultSet rs = ps.executeQuery();
                        if (!rs.next())
                        {
                            ps.close();
                        }
                        accountid = rs.getInt("accountid");
                        ps.close();
                    }
                    catch (SQLException e) {System.out.println("SQL Exception: " + e);}
                    
                    String banString = "";
                    String macsOrig = "";
                    
                    try
                    {
                        ps = con.prepareStatement("SELECT banreason, macs FROM accounts WHERE id = " + accountid);
                        ResultSet rs = ps.executeQuery();
                        if (!rs.next())
                        {
                            ps.close();
                        }
                        banString = rs.getString("banreason");
                        macsOrig = rs.getString("macs");
                        ps.close();
                    }
                    catch (SQLException e) {System.out.println("SQL Exception: " + e);}
                    
                    if(macsOrig != null)
                    {
                        int occurs = 0;
                     
                        for(int i = 0; i < macsOrig.length(); i++)
                        {
                            
                              char next = macsOrig.charAt(i);
                              
                              if(next == ',')
                              {
                                   occurs++;
                              }
                        }
                        
                        String macs[] = new String[occurs + 1];
                        
                        System.out.println("Creating macs array...");
                        for(int i = 0; i <= occurs; i++)
                        {
                            int offset = 0;
                            
                            if(i > 0)
                                offset = 2;
                            
                            macs[i] = macsOrig.substring((i * 17) + offset, (i * 17) + 17);
                            System.out.println(macs[i]);
                        }
                        
                        for(int i = 0; i < macs.length; i++)
                        {
                            try
                            {
                                ps = con.prepareStatement("DELETE FROM macbans WHERE mac = ?");
                                ps.setString(1, macs[i]);
                                ps.executeUpdate();
                                ps.close();
                            }
                            catch (SQLException e) {System.out.println("SQL Exception: " + e);}
                        }
                        mc.dropMessage("Macs Unbanned");
                    }    
                    
                    if(banString.indexOf("IP: /") != -1)
                    {
                        String ip = banString.substring(banString.indexOf("IP: /") + 5, banString.length() - 1);
                        try
                        {
                            ps = con.prepareStatement("DELETE FROM ipbans WHERE ip = ?");
                            ps.setString(1, ip);
                            ps.executeUpdate();
                            ps.close();
                            mc.dropMessage("IP Address Unbanned");
                        }
                        catch (SQLException e) {System.out.println("SQL Exception: " + e);}
                    }
                    
                    
                    try
                    {
                        ps = con.prepareStatement("UPDATE accounts SET banned = -1, banreason = null WHERE id = " + accountid);
                        ps.executeUpdate();
                        ps.close();
                        mc.dropMessage("Account Unbanned");
                    }
                    catch (SQLException e) {System.out.println("SQL Exception: " + e);}
                    
                    
                }


    And you'll need to execute this query in your database.
    REMEMBER: Always make backups of your database before making any changes

    Code:
    ALTER TABLE `accounts` MODIFY COLUMN `banreason` VARCHAR(500) CHARACTER SET latin1 COLLATE latin1_swedish_ci;


  2. #2
    Account Upgraded | Title Enabled! RMZero213 is offline
    MemberRank
    Apr 2008 Join Date
    Far, far awayLocation
    1,280Posts

    Re: [RELEASE] !unban <Alternative> <Unbans Macs and IP Address Also>

    Mine sets banned to -1, unbanning the ip and mac *sigh

    But its a good alternative anyway.

  3. #3
    Member MrPrettyBoy is offline
    MemberRank
    Jul 2008 Join Date
    61Posts

    Re: [RELEASE] !unban <Alternative> <Unbans Macs and IP Address Also>

    Great Release, I'll test right now.

  4. #4
    Account Upgraded | Title Enabled! Sathon is offline
    MemberRank
    Feb 2008 Join Date
    C:\Nexon\Location
    275Posts

    Re: [RELEASE] !unban <Alternative> <Unbans Macs and IP Address Also>

    Quote Originally Posted by RMZero213 View Post
    Mine sets banned to -1, unbanning the ip and mac *sigh

    But its a good alternative anyway.
    I know, I'm not trying to compete or anything, but like I said, I had already started and didn't want what I'd done to go to waste, so I finished it.

  5. #5
    Account Upgraded | Title Enabled! zander145 is offline
    MemberRank
    Apr 2008 Join Date
    Norfolk, VALocation
    966Posts

    Re: [RELEASE] !unban <Alternative> <Unbans Macs and IP Address Also>

    lol, i already use'd zero's >.<

    Oh well, they essentially do the same thing right?

  6. #6
    Account Upgraded | Title Enabled! RMZero213 is offline
    MemberRank
    Apr 2008 Join Date
    Far, far awayLocation
    1,280Posts

    Re: [RELEASE] !unban <Alternative> <Unbans Macs and IP Address Also>

    Quote Originally Posted by Sathon
    However, I notice that the current one doesn't unban macs and ip addresses, and mine does, so I decided I'd finish mine and release it.
    I'm not competing either, more like asking why you included that.

  7. #7
    Account Upgraded | Title Enabled! Sathon is offline
    MemberRank
    Feb 2008 Join Date
    C:\Nexon\Location
    275Posts

    Re: [RELEASE] !unban <Alternative> <Unbans Macs and IP Address Also>

    Quote Originally Posted by RMZero213 View Post
    I'm not competing either, more like asking why you included that.
    This actually removes the ip and mac bans, which insures that they are completely unbanned if, say, they have another account or something, or they have family members that play on the same computer/ip address.

  8. #8
    Member MrPrettyBoy is offline
    MemberRank
    Jul 2008 Join Date
    61Posts

    Re: [RELEASE] !unban <Alternative> <Unbans Macs and IP Address Also>

    Kk, I tested on one of my Gm's and it works just fine..=D
    Ty Sathon!

  9. #9
    Account Upgraded | Title Enabled! Sathon is offline
    MemberRank
    Feb 2008 Join Date
    C:\Nexon\Location
    275Posts

    Re: [RELEASE] !unban <Alternative> <Unbans Macs and IP Address Also>

    Quote Originally Posted by zander145 View Post
    lol, i already use'd zero's >.<

    Oh well, they essentially do the same thing right?
    Essentially; this one is just more elaborate.

  10. #10
    Valued Member TeamH is offline
    MemberRank
    Jun 2008 Join Date
    126Posts

    Re: [RELEASE] !unban <Alternative> <Unbans Macs and IP Address Also>

    i add it to the java file and when i type it in game it dont work

  11. #11
    Apprentice xDutch is offline
    MemberRank
    Jul 2008 Join Date
    6Posts

    Re: [RELEASE] !unban <Alternative> <Unbans Macs and IP Address Also>

    How to add it to the .java file??

    Just copy Paste it at the end? :S

    I don't understand it..

    I pasted it in the .java file, but it doesn't work for me..

  12. #12
    Account Upgraded | Title Enabled! zcikkita is offline
    MemberRank
    Jul 2008 Join Date
    Europe.Location
    317Posts

    Re: [RELEASE] !unban <Alternative> <Unbans Macs and IP Address Also>

    xDutch be sure to paste the .java in jre_6_0 blablabla too ...

  13. #13
    Account Upgraded | Title Enabled! Sathon is offline
    MemberRank
    Feb 2008 Join Date
    C:\Nexon\Location
    275Posts

    Re: [RELEASE] !unban <Alternative> <Unbans Macs and IP Address Also>

    Quote Originally Posted by TeamH View Post
    i add it to the java file and when i type it in game it dont work
    Did you make sure you compiled and replace your source code first?

    Quote Originally Posted by xDutch View Post
    How to add it to the .java file??

    Just copy Paste it at the end? :S

    I don't understand it..

    I pasted it in the .java file, but it doesn't work for me..
    Go ahead and paste it all UNDER ALL of this code:
    Code:
    else if (splitted[0].equals("!ban")) {
    				if (splitted.length < 3) {
    					new ServernoticeMapleClientMessageCallback(2, c).dropMessage("Syntaxhelper : Syntax: !ban charname reason");
    					return true;
                                           
    				}
    				String originalReason = StringUtil.joinStringFrom(splitted, 2);
    				String reason = c.getPlayer().getName() + " banned " + splitted[1] + ": " +
    				originalReason;
    				MapleCharacter target = cserv.getPlayerStorage().getCharacterByName(splitted[1]);
    				if (target != null) {
    					String readableTargetName = MapleCharacterUtil.makeMapleReadable(target.getName());
    					String ip = target.getClient().getSession().getRemoteAddress().toString().split(":")[0];
    					reason += " (IP: " + ip + ")";
                                            String gmsname = player.getName();
    					target.ban(reason);
                                            c.getPlayer().getMap().broadcastMessage(MaplePacketCreator.serverNotice(6, "" +  splitted[1] + "  got pwned REAL bad by " + gmsname + " for " + originalReason));
                                          
    				} else {
    					if (MapleCharacter.ban(splitted[1], reason, false)) {
    						mc.dropMessage("Offline Banned " + splitted[1]);
    					} else {
    						mc.dropMessage("Failed to ban " + splitted[1]);
    					}
                                    }
    			}

  14. #14
    Account Upgraded | Title Enabled! SmartyX is offline
    MemberRank
    Apr 2008 Join Date
    GermanyLocation
    341Posts

    Re: [RELEASE] !unban <Alternative> <Unbans Macs and IP Address Also>

    ps = con.prepareStatement("UPDATE accounts SET banned = -1, banreason = null WHERE id = " + accountid);


    Shouldnt it be banned = 0 ?

  15. #15
    Account Upgraded | Title Enabled! Sathon is offline
    MemberRank
    Feb 2008 Join Date
    C:\Nexon\Location
    275Posts

    Re: [RELEASE] !unban <Alternative> <Unbans Macs and IP Address Also>

    Quote Originally Posted by SmartyX View Post
    ps = con.prepareStatement("UPDATE accounts SET banned = -1, banreason = null WHERE id = " + accountid);


    Shouldnt it be banned = 0 ?
    That would work too, I guess the best way to describe it is that -1 is like a "stronger" unban, it really ensures that they get unbanned.



Page 1 of 3 123 LastLast

Advertisement