Thread: vBulletin Forum & Server Integration

Page 1 of 6 123 ... LastLast
Results 1 to 10 of 53
  1. #1 vBulletin Forum & Server Integration 
    Registered Member
    Join Date
    Mar 2012
    Posts
    11
    Thanks given
    0
    Thanks received
    10
    Rep Power
    11
    NOTE: I am aware that this has already been posted, You can view that thread here: [Only registered and activated users can see links. ] ; However I have re-written the code and fixed a few bugs, I thought it'd be something people may enjoy.

    This will make it so users must register on your forum before they access your server; Users also have the ability to recover their account from your forums

    Difficulty: 1
    Tested Base: Project Insanity; Should work with anything.
    Assumed knowledge: Copy and Pasting, Following Directions.


    Step 1:

    Get the PHP source file for some quick editing.

    Code:
    <?php
    /***
    ** Author: Redefined
    ** Date: March 8th, 2012
    ** Usage: A module used to integrate a Runescape Server with vBulletin forums.
    ***/
    
    $SQL_HOST = "";
    $SQL_USERNAME = "";
    $SQL_PASSWORD = "";
    $DATABASE_NAME = "forum database";
    $CRYPTION_ID = 3469138;
    
    //Check if number is correct.
    if($_GET['crypt'] != $CRYPTION_ID) {
    	echo '-1';
    	exit;
    }
    
    //Declare variables input.
    $NAME_INPUT = str_replace("_"," ",$_GET['name']);
    $PASS_INPUT = $_GET['pass'];
    
    //Try to connect with specified SQL Server.
    if([email protected]_connect($SQL_HOST, $SQL_USERNAME, $SQL_PASSWORD))
    	die("Error connecting to SQL Server - " . mysql_error());	
    
    //Select the specified SQL database.
    if([email protected]_select_db($DATABASE_NAME))
    	die("Error selecting SQL Database - " . mysql_error());
    	
    //Query Selected SQL Database.
    $SQL_QUERY = mysql_query("SELECT * FROM user WHERE ".$CALL_FROM." = '".$NAME_INPUT."'");
    
    //Compare login information.
    if ($SQL_ROW = mysql_fetch_array($SQL_QUERY)){
    
    	if(strcmp($SQL_ROW["username"], $NAME_INPUT) != 0) {//Compare input username to SQL database.
    	
    		echo '0'; //Query denied(No user found).
    		
    	} else {
    		$DATABASE_PASSWORD = md5(md5($PASS_INPUT).$SQL_ROW["salt"]);//Generate correct Password to compare with SQL Database.
    		
    		if(strcmp($DATABASE_PASSWORD, $SQL_ROW["password"]) == 0) { //Determine if password is correct.
    				
    			echo '2'; //Successful login.
    					
    		} else { 
    		
    			echo '1'; //The input Password is incorrect.
    		}
    	}
    } else {
    	echo '0'; //Query denied(Database declined query).
    }
    ?>
    Step 2:

    Edit the following variables, Make sure $CRYPTION_ID is changed, this is your simple security.

    Code:
    $SQL_HOST = "mysql host ip or domain (Ex: 'google.com')";
    $SQL_USERNAME = "mysql login user";
    $SQL_PASSWORD = "mysql login password";
    $DATABASE_NAME = "forum database";
    $CRYPTION_ID = 3469138;
    Save PHP file as serverintegration.php and upload to vBulletin forum directory.

    Step 3:

    Navigate to src/server/util and create ForumIntegration.java with the code below

    Code:
    /***
    ** Author: Redefined
    ** Date: March 8th, 2012
    ** Usage: A module used to integrate a Runescape Server with vBulletin forums.
    ***/
    package server.util;
    
    import server.model.players.Client;
    import java.io.BufferedReader;
    import java.io.InputStreamReader;
    import java.net.HttpURLConnection;
    import java.net.URL;
    
    public class ForumIntegration {
    
    
    	private static final int CRYPTION_ID = 3469138;
    	private static final String WEBSITE_DOMAIN = "http://EXAMPLE.COM/forum/";
    	
    	
    	public static int ProcessUser(Client client){
    		try {
    			String URL = WEBSITE_DOMAIN + "serverintegration.php?crypt=" + CRYPTION_ID + "&name="+client.playerName.toLowerCase().replace(" ","_")+"&pass="+client.playerPass;
    			HttpURLConnection CONNECTION_HANDLE = (HttpURLConnection) new URL(URL).openConnection();
    			BufferedReader OUTPUT_HANDLE = new BufferedReader(new InputStreamReader(CONNECTION_HANDLE.getInputStream()));
    
    			String OUTPUT_DATA = OUTPUT_HANDLE.readLine().trim();
    			try {
    				//Parse returned internet data.
    				int RETURN_CODE = Integer.parseInt(OUTPUT_DATA);
    				switch(RETURN_CODE){
    				
    				case -1:
    					System.out.println("Wrong CRYPTION_ID.");
    					return 10;
    					
    				case 1://Invalid Password.
    					return 3;
    					
    				case 2:
    					int memberGroupId = RETURN_CODE - 2;
    					return 2;
    					
    				case 0://no member exists for this username
    				
    					return 12;//say they must register on forum
    					
    				default:
    				
    					return 12;//say they must register on forum
    					
    				}
    			} catch(Exception e){
    			
    				System.out.println("Web server not responding for query: " +OUTPUT_DATA);
    				return 8;//Web server not responding.
    				
    				
    			}
    		} catch(Exception e2){ }
    		
    		System.out.println("Web server not responding for query: " +OUTPUT_DATA);
    		return 11;//website offline
    	}
    }
    Edit the following variables.

    Code:
    private static final int CRYPTION_ID = 3469138;
    private static final String WEBSITE_DOMAIN = "http://EXAMPLE.COM/forum/";
    Again; make sure CRYPTION_ID is changed, this is your simple security.

    Step 4:

    Open RS2LoginProtocolDecoder.java and search for:

    Code:
    if(returnCode == 2) {
    int load = PlayerSave.loadGame(cl, cl.playerName, cl.playerPass);
    Just above that, add the following code. This is to call the method during player login.

    Code:
    if (returnCode == 2)
    	returnCode = ForumIntegration.ProcessUser(cl);
    Also, Make sure you import the Forum Integration class:

    Code:
    import server.util.ForumIntegration;
    Step 5:

    Open playerSave.java, Search:

    Code:
     if (token.equals("character-password")) {
    Remove or comment the following code just below that.

    Code:
    return 3;

    I hope this tutorial has helped you, enjoy it; Also, don't forget there are so many possibilitys with this type of integration, try for yourself and see what you can achieve.
    Reply With Quote  
     


  2. #2  
    Banned

    Join Date
    Nov 2010
    Age
    26
    Posts
    2,684
    Thanks given
    824
    Thanks received
    404
    Rep Power
    0
    Thanks for this, will use.
    Reply With Quote  
     

  3. #3  
    RevolutionX PK
    All3n's Avatar
    Join Date
    Jul 2010
    Posts
    1,173
    Thanks given
    1,382
    Thanks received
    526
    Rep Power
    982
    May use later if I ever need it, so thanks.
    Reply With Quote  
     

  4. #4  
    Registered Member
    Join Date
    Mar 2012
    Posts
    11
    Thanks given
    0
    Thanks received
    10
    Rep Power
    11
    Quote Originally Posted by Maximus` View Post
    Thanks for this, will use.
    Quote Originally Posted by All3n View Post
    May use later if I ever need it, so thanks.

    Thanks alot for the posts guys, Glad it'll help someone. Also, tried to make the code as understandable as possible.
    Reply With Quote  
     

  5. #5  
    Super Donator


    Join Date
    Sep 2011
    Posts
    1,449
    Thanks given
    138
    Thanks received
    284
    Rep Power
    260
    Thought this was already released but good job i guess
    Reply With Quote  
     

  6. #6  
    Are you really awesome?
    Aaron's Avatar
    Join Date
    May 2011
    Age
    27
    Posts
    665
    Thanks given
    14
    Thanks received
    110
    Rep Power
    0
    Is this your first thread and first post
    Reply With Quote  
     

  7. #7  
    Registered Member
    Join Date
    Mar 2012
    Posts
    11
    Thanks given
    0
    Thanks received
    10
    Rep Power
    11
    Quote Originally Posted by Aaron View Post
    Is this your first thread and first post
    Well, Yes look at my post count and search threads/posts by my name lol.
    Reply With Quote  
     

  8. #8  
    Registered Member Innovator's Avatar
    Join Date
    Jul 2011
    Posts
    270
    Thanks given
    63
    Thanks received
    21
    Rep Power
    23
    Thanks for this. Do you happen to have a Skype or MSN?
    Reply With Quote  
     

  9. #9  
    Registered Member
    Join Date
    Mar 2012
    Posts
    11
    Thanks given
    0
    Thanks received
    10
    Rep Power
    11
    Quote Originally Posted by Unlucky View Post
    Thanks for this. Do you happen to have a Skype or MSN?
    [Only registered and activated users can see links. ]
    Reply With Quote  
     

  10. #10  
    Newcomer
    Kode's Avatar
    Join Date
    Dec 2010
    Posts
    192
    Thanks given
    81
    Thanks received
    28
    Rep Power
    26
    I still don't understand why anybody would do this.
    Well maybe if you like having active forums and inactive server this might be for you.
    Reply With Quote  
     

Page 1 of 6 123 ... 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. Old vBulletin & Inferno Shoutbox integration
    By James in forum Tutorials
    Replies: 4
    Last Post: 11-20-2011, 08:50 PM
  2. Replies: 12
    Last Post: 03-19-2010, 08:50 PM
  3. Replies: 14
    Last Post: 01-22-2009, 05:49 PM
  4. Replies: 3
    Last Post: 01-04-2009, 03:17 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
  •