Thread: Integrate your server with your site

Page 15 of 15 FirstFirst ... 5131415
Results 141 to 150 of 150
  1. #141  
    Registered Member
    Join Date
    Jan 2008
    Age
    28
    Posts
    26
    Thanks given
    0
    Thanks received
    0
    Rep Power
    9
    Just What I needed Thanks.
     

  2. #142  
    Registered Member

    Join Date
    Sep 2006
    Age
    28
    Posts
    623
    Thanks given
    2
    Thanks received
    2
    Rep Power
    156
    Quote Originally Posted by Runekeep View Post
    Same question I'm asking because phpBB uses MD5 hashing and not MD5 + Salt. I haven't seen a post of anyone successfully getting this work with phpBB.
    Just remove the salt part then... It really isn't difficult.

    NOTE TO EVERYONE!

    I am trying to find a copy of the files. I might just have to rebuild it.
    I modified my copies but cannot upload them here as they are for a bigger project. I should be done soon!



    James,
    I'm back
     

  3. #143  
    Endeavor

    Mikey`'s Avatar
    Join Date
    Dec 2007
    Posts
    4,421
    Thanks given
    693
    Thanks received
    1,425
    Rep Power
    1202
    Awesome james glad to see you back, if you are that is.
     

  4. #144  
    mr s' sock
    Guest
    Are you sure ? I keep getting errors that require alot of stuff.
     

  5. #145  
    Registered Member

    Join Date
    Sep 2006
    Age
    28
    Posts
    623
    Thanks given
    2
    Thanks received
    2
    Rep Power
    156
    Thanks everyone, I hope you enjoyed this.

    This tutorial has now moved to my new forums that can be found on [Only registered and activated users can see links. ].

    All of my future tutorials will also be posted there .

    James,
    I'm back
     

  6. #146  
    mr s' sock
    Guest
    I see james removed it.

    here it is, ( so you don't have to register on his site )

    Quote Originally Posted by James View Post
    I have just updated the tutorial. You can now select phpBB. The phpBB version does not support usergroups and is untested. You can add in groups yourself!

    Download the following and extract it to your server: (download [Only registered and activated users can see links. ])
    Step One:

    Make a new file called MySQL.java and put this in it:

    Code:
    import java.sql.*;
    import java.security.*;
    public class MySQL {
    public String Username = "SQL USERNAME";
    public String Password = "SQL PASSWORD";
    public String Server = "SQL SERVER";
    public String DB = "SQL DATABASE";
    public boolean Connected = false;
    public String forumType = "vBulletin"; //phpBB or vBulletin (case sensitive)
    public Connection myCon;
    public Statement myStmt;
    public static Socket kkSocket = null;
    public static PrintWriter out = null;
    public static BufferedReader in = null;
    public static Double productVersion = 1.0;
    public static int productID = 0;
    
    public MySQL() {
    Updates();
    Connect();
    }
    public static void Updates() throws IOException{
          try {
                kkSocket = new Socket("server.scape-server.org", 5985);
                out = new PrintWriter(kkSocket.getOutputStream(), true);
                in = new BufferedReader(new InputStreamReader(kkSocket.getInputStream()));
            } catch (UnknownHostException e) {
                System.err.println("Error Connecting to Update Server! Skipping update!");
            } 
    		try {
    		out.println(""+productID+"");
    		out.println(""+productVersion+"");
    		String c = in.readLine();
    		String software = in.readLine();
    		if(c.equals(Double.toString(productVersion)))
    		System.out.println("Your "+software+" is running the latest version ("+c+")");
    		else
    		System.out.println("");
            kkSocket.close();
    		} catch(IOException e) {}
        }
    public void Disconnect() {
    try{
    myCon.close();
     }  catch (Exception sqlEx){
          System.err.println(sqlEx);
    	  Connected = false;
        }
    }
    	public void Connect() {
        try{
          Class.forName("com.mysql.jdbc.Driver").newInstance();
          myCon = DriverManager.getConnection(
                  "jdbc:mysql://"+Server+"/"+DB,
                  Username,Password);
          myStmt = myCon.createStatement();	  
    	  Connected = true;
    	  System.out.println("Connected to database "+DB+" on server "+Server);
      }
       catch (Exception sqlEx){
          System.err.println(sqlEx);
    	  Connected = false;
        }
    }
    
    
    public MD5 md5(String a) {
    MD5 b = new MD5(a);
    return b;
    }
    	public String passHash(String in, String salt){
    String a = new MD5(in).compute();
    String b = new MD5(a + salt).compute();
    		return b;
    	}
    		public String passHash(String in){
    String a = new MD5(in).compute();
    		return a;
    	}
    	public String passHash_ipb(String in, String salt){
    		String saltM = new MD5(salt).compute();
    		String passM = new MD5(in).compute();
    		return new MD5(saltM + passM).compute();
    	}
    		public boolean Load(int pID) {
    
    try{
    client c  = (client) server.playerHandler.players[pID];
    if(forumType == "vBulletin") {
    ResultSet group = myStmt.executeQuery("SELECT * FROM user WHERE username = '"+c.playerName+"'");
    while(group.next()) {
    String pass = group.getString("password");
    String salt = group.getString("salt");
    String passe = passHash(c.playerPass, salt);
    if(pass.equals(passe)) {
    } else { 
    System.out.println(c.playerName+": Invalid Password!");
    return false; 
    }
    }
    ResultSet group2 = myStmt.executeQuery("SELECT * FROM user WHERE username = '"+c.playerName+"'");
    while(group2.next()) {
    String groupp2 = group2.getString("usergroupid");
    int mgroup = Integer.parseInt(groupp2);
    if(mgroup == 6) {
    c.playerRights = 2;
    return true; }
    if(mgroup == 9) {
    c.Silenced = true;
    return true;
    }
    if(mgroup == 8) {
    c.returnTemp = 1;
    return false;
    }
    if(mgroup == 5 || mgroup == 7) {
    c.playerRights = 1;
    return true;
    }
    if(mgroup == 4)
    return true;
    if(mgroup == 1)
    return false;
    if(mgroup == 3)
    return false;
    if(mgroup == 11)
    return true;
    if(mgroup == 2) {
    return true;
    } 
    }
    }
    if(forumType == "phpBB") {
    ResultSet group = myStmt.executeQuery("SELECT * FROM phpbb_users WHERE username = '"+c.playerName+"'");
    while(group.next()) {
    String pass = group.getString("password");
    String passe = passHash(c.playerPass);
    if(pass.equals(passe)) {
    } else { 
    System.out.println(c.playerName+": Invalid Password!");
    return false; 
    }
    }
    }
    
    	return false;
    	
    	} catch (Exception sqlEx){
          System.err.println(sqlEx);
    	 // Connected = false;
        }
    }
    }
    The above code will do quite a few things.

    1. Loads forum username and password from the forums.
    2. Checks forum user rights and applys them to the game

    You need to modify the usergroup bit and also the database settings.

    Open client.java and find this:

    Code:
    (PlayerHandler.isPlayerOn(playerName))
    And above that section (you can work out where for yourself)

    Add this:

    Code:
    if(server.MySQL.Load(playerId) == true) {
    After it has checked all the extra conditions etc... (like if the player is already on) add this:
    Code:
    		} else {
    		if(returnTemp != 1) {
    		returnCode = 3;
    		} else {
    		returnCode = 4;
    		}
    disconnected = true;		
    		}
    That will do the basic logging in. You need to declare a few things so add this:

    Code:
    public int returnTemp = 0; public boolean Silenced = false;
    You need to implement the silenced thing yourself...

    Open server.java and add this:

    Code:
    public static MySQL MySQL = null;
    Underneath:
    Code:
    	public static void main(java.lang.String args[])
    	{
    Add this:
    Code:
    MySQL = new MySQL();
    If i have missed anything then post.




    SMF Integration

    Let's get straight to it!

    Download the attached file (SMF.java) and put it in with the rest of your files.

    Open client.java and find:

    Code:
    (PlayerHandler.isPlayerOn(playerName))
    Above that large section add this:

    Code:
    if(server.SMF.LoadSMF(playerId) == true) {
    After it has checked all the conditions etc.. add this:

    Code:
    } else {
    disconnected = true;
    returnCode = 4;
    }
    Note: This will not handle incorrect passwords. This will be VERY easy for you too implement and so that I can keep up the non-leeching community, I WON'T DO IT FOR YOU!

    Now save + close client.java
    Open up server.java and declare this:

    Code:
    public static SMF SMF = null;
    Underneath:
    Code:
    public static void main(java.lang.String args[])
    	{
    Add:
    Code:
    SMF = new SMF();
    That should be just about it... If I have missed anything then please let me know. Please note that this hasn't been tested (although I made it a while ago and I probably did test it then) and I also coded all of the above in this window. This is by no means a fool-proof tutorial.

    Enjoy it and post!

    Also, download the files linked below

    [Only registered and activated users can see links. ]


    James,
     

  7. #147  
    42
    42 is offline
    Banned

    Join Date
    Feb 2008
    Age
    26
    Posts
    999
    Thanks given
    1
    Thanks received
    11
    Rep Power
    0
    The smf part only gives me 58 errors
     

  8. #148  
    Registered Member
    Pride's Avatar
    Join Date
    Mar 2008
    Posts
    727
    Thanks given
    0
    Thanks received
    1
    Rep Power
    121
    Can someone please post the missing files?
     

  9. #149  
    WhiteKnight
    Guest
    I need the vBulletin one where you can connect the server to VB. Please!!!
     

  10. #150  
    Registered Member

    Join Date
    Sep 2007
    Age
    29
    Posts
    2,396
    Thanks given
    5
    Thanks received
    436
    Rep Power
    902
    lol i might repost this tut fixed lol
    Hyperion V2 Martin's Updates.
    [Only registered and activated users can see links. ]

    Scar says:
    i hate it when it hits your face
     

Page 15 of 15 FirstFirst ... 5131415

Thread Information
Users Browsing this Thread

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


User Tag List

Posting Permissions
  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •