Thread: [ALL] Ipboard forum integration

Page 1 of 2 12 LastLast
Results 1 to 10 of 13
  1. #1 [ALL] Ipboard forum integration 
    Banned

    Join Date
    Oct 2010
    Posts
    716
    Thanks given
    82
    Thanks received
    131
    Rep Power
    0
    EDIT: I ment to post this in the snippet section. If you don't know the very basic fundamentals of java, then I think there's no point in you being here.
    EDIT EDIT: If your website goes offline, that will mean no one will be able to log on. To prevent this, make it check off a private table which is not related to your website.

    I've made this a couple of days ago, for a person who paid me $40 for such an easy task.
    I don't see why people should pay for integration, so here you go, this is what I wrote for that particular server.

    Note: You might need to edit things here and there depending on the base you're using, HENCE that this is strictly for ipboard since other forum platforms use different ways of hashing/encrypting account details. I can alter this to work with your forum software if you don't know how to, for a small fee.

    Essentially you can use this for any platform, if you change the encryption logic to the same method your software uses. Obviously you also need to change the columns it has to search for in your query

    My first intention was to make an interface based library which you could edit settings on to pick between most common forum platforms, but in the end I think people should just read this code and be able to somewhat understand the concept instead of being spoonfed a library without understanding the logic operating behind it.

    Currently this only reads the player details and the player rights which I've commented out since not everyone will have the same system as I do.

    I understand that JDBC is a rather outdated method of validating forum users, but it really fits the use that is required.
    I've also thought about having a webserver print out information with the JSON format, but I can imagine alot of things could be exploited with that system depending on how well you authenticate gameserver requests to the webserver.


    Code:
    package com.rs.game.sql;
    
    import java.sql.Connection;
    import java.sql.DriverManager;
    import java.sql.PreparedStatement;
    import java.sql.ResultSet;
    
    import org.apache.commons.codec.digest.DigestUtils;
    
    import com.rs.game.player.Player;
    import com.rs.utils.Logger;
    
    /**
     * @author Arno | Articron
     */
    
    public class ForumIntegration {
    	
    	/* database_details */
    	private static final String database_location = "jdbc:mysql://WEBSITEIPHERE/DBNAMEHERE";
    	private static final String database_username = "USERNAME";
    	private static final String database_password = "PASSWORD";
    
    	/* connection vars */
    	private static Connection server_website_throttle;
    	private PreparedStatement prepared_statement;
    	private ResultSet result_printset;
    
    	/* player_details */
    	private String password;
    	private String password_md5;
    	private String salt_md5;
    	private int player_right;
    
    	/* Entry point for initiation */
    	public static void init() {
    		try {
    			Class.forName("com.mysql.jdbc.Driver");
    			server_website_throttle = DriverManager.getConnection(
    					database_location, database_username, database_password);
    			Logger.log("Forum Integration", "Hooked up correctly...");
    		} catch (Exception e) {
    			e.printStackTrace();
    		}
    	}
    
    	/* Object instance to check authentication */
    	public ForumIntegration(Player player_instance) {
    		this.password = player_instance.getPassword().toLowerCase();
    		try {
    			prepared_statement = server_website_throttle
    					.prepareStatement("SELECT * FROM ipbmembers WHERE name='"
    							+ player_instance.getUsername() + "'");
    			result_printset = prepared_statement.executeQuery();
    
    			/* if player exists in database */
    			if (result_printset.next()) {
    
    				password_md5 = result_printset.getString("members_pass_hash");
    				salt_md5 = result_printset.getString("members_pass_salt");
    				player_right = result_printset.getInt("member_group_id");
    
    			} else {
    				/* if player does not exist in forum database */
    				password_md5 = null;
    				salt_md5 = null;
    
    			}
    			addToStaffHash(player_right, player_instance);
    		} catch (Exception e) {
    			e.printStackTrace();
    		}
    	}
    
    	/* HashMap parsing */
    	private void addToStaffHash(int playerRights, Player player) {
    		switch (playerRights) {
    		case 7: // dev
    		case 4: // owner
    		case 8: // owner
    		//	player.getStaff().put(player, 2);
    			break;
    		default: // regular
    			break;
    		}
    
    	}
    	
    	/* authentication */
    	public boolean getValid() {
    		return (password_md5 == null || salt_md5 == null) ? false
    				: encryptToMD5(password, salt_md5).equalsIgnoreCase(
    						password_md5);
    	}
    
    	/* Apache Commons Codec DigestUtility lib  */
    	private String encryptToMD5(String pass, String salt) {
    		return DigestUtils.md5Hex(DigestUtils.md5Hex(salt).concat(
    				DigestUtils.md5Hex(pass)));
    	}
    	
    }
    Code:
    if (!new ForumIntegration(player).getValid()) {
    				session.getLoginPackets().sendClientPacket(3);
    				return;
    			}
    		}
    Libraries you will need:

    Codec - Home
    JDBC/UCP Download Page
    Reply With Quote  
     

  2. #2  
    Banned
    Join Date
    Sep 2013
    Posts
    116
    Thanks given
    33
    Thanks received
    14
    Rep Power
    0
    Very nice, I like it.
    Reply With Quote  
     

  3. #3  
    Registered Member
    Join Date
    Oct 2012
    Posts
    1,279
    Thanks given
    331
    Thanks received
    257
    Rep Power
    69
    Neat job.
    Reply With Quote  
     

  4. #4  
    Registered Member Seth's Avatar
    Join Date
    Feb 2013
    Posts
    644
    Thanks given
    179
    Thanks received
    101
    Rep Power
    20
    Nice release.
    Reply With Quote  
     

  5. #5  
    Reverse Engineering

    freeezr's Avatar
    Join Date
    Dec 2011
    Posts
    1,067
    Thanks given
    288
    Thanks received
    444
    Rep Power
    401
    looks like a pretty good MySQL setup

    Attached image
    Reply With Quote  
     

  6. #6  
    Aganoth Developer

    Aust1n's Avatar
    Join Date
    Aug 2012
    Posts
    1,857
    Thanks given
    280
    Thanks received
    406
    Rep Power
    60
    Nice job!




    Reply With Quote  
     

  7. #7  
    Donator

    Join Date
    Jan 2014
    Posts
    1,617
    Thanks given
    8
    Thanks received
    196
    Rep Power
    39
    Good job on this.
    Reply With Quote  
     

  8. #8  
    Banned

    Join Date
    Mar 2010
    Posts
    2,218
    Thanks given
    170
    Thanks received
    262
    Rep Power
    0
    Very nice.
    Reply With Quote  
     

  9. #9  
    Registered Member
    Join Date
    Sep 2013
    Posts
    70
    Thanks given
    23
    Thanks received
    46
    Rep Power
    6
    Prepared Statements cache in the MySQL server. Including the player name directly in the statement will cache every unique name. The point is to cache one dynamic statement to boost performance.

    You should also LIMIT your results so that the query stops after the first result.

    Code:
    statement = connection.prepareStatement("SELECT * FROM ipbmembers WHERE name = ? LIMIT 1");
    statement.setString(1, player_instance.getUsername());
    resultSet = statement.executeQuery();
    Lastly, the verification could, and more than likely should, be done through one static method rather than a new instance of class ForumIntegration. Each of the variables stored in this class do not have any outside access, making the new instance creation pointless. This should be converted into a more static design.

    Code:
    public static boolean validate(Player player) {
        PreparedStatement statement = null;
        ResultSet resultSet = null;
        try {
            statement = connection.prepareStatement("SELECT * FROM ipbmembers WHERE name = ? LIMIT 1");
            statement.setString(1, player.getUsername());
            resultSet = statement.executeQuery();
            //table reading to determine if valid user/pass & user rank
        } catch(SQLException e) {
            e.printStackTrace();
        } finally {
            if(statement != null) {
                try {
                    statement.close();
                } catch(SQLException e) {
                    /* could not close */
                }
            }
            if(resultSet != null) {
                try {
                    resultSet.close();
                } catch(SQLException e) {
                    /* could not close */
                }
            }
        }
    }
    Reply With Quote  
     

  10. Thankful user:


  11. #10  
    48 0x69

    Pax M's Avatar
    Join Date
    Oct 2013
    Posts
    2,008
    Thanks given
    36
    Thanks received
    488
    Rep Power
    2270
    Nice.
    Reply With Quote  
     

Page 1 of 2 12 LastLast

Thread Information
Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)


User Tag List

Similar Threads

  1. EdgeX - Forum integration :D
    By Ecstasy in forum Show-off
    Replies: 7
    Last Post: 03-19-2010, 04:29 AM
  2. DownsX PK 24/7 Forums Integrated.
    By Sheddy in forum Advertise
    Replies: 8
    Last Post: 01-01-2010, 09:06 PM
  3. Forum Integration
    By Vastiko in forum Help
    Replies: 4
    Last Post: 11-29-2009, 02:21 AM
  4. Replies: 32
    Last Post: 01-26-2008, 12:11 AM
Posting Permissions
  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •