Thread: [Integration] Account Pairing Base [Project Insanity]

Results 1 to 6 of 6
  1. #1 [Integration] Account Pairing Base [Project Insanity] 
    Registered Member fl3x's Avatar
    Join Date
    Aug 2010
    Posts
    168
    Thanks given
    52
    Thanks received
    45
    Rep Power
    0
    This is the current product of about an hour's work for an optional integration system I'm building to allow users to link their forum account with an ingame account. This works on vB4 (May work on all vbulletin revisions that use the "md5(md5(pass)salt)" encryption method) but could work on any forum if you just modified the link.php so that the $hash variable is correct for that forum type.

    Syntax for the command should be as follows:
    ::link forumUsername forumPassword
    ::unlink forumUsername forumPassword

    I'm not going to go any more in depth on how this works, read the code and this can be easily built upon. You need to add two fields into your `user` table in the vbulletin database (or any forum's database),


    To see all users with their accounts linked, user titles and their IP address, go to:
    [Only registered and activated users can see links. ]


    Fields to add:
    Code:
    linked, needs to be int with length = 45 and default as 0
    gameName, needs to be varchar with a length around 30-50 and default of null.
    Files-

    link.php
    Code:
    <?php
    	$mysql = array(
    		'host' => 'host',
    		'name' => 'db_name',
    		'user' => 'root',
    		'pass' => ''
    	);
    	//assign vars, connect to db
    	$conn = mysql_connect($mysql['host'],$mysql['user'],$mysql['pass']);
    	$db = mysql_select_db($mysql['name']);
    	$user = mysql_real_escape_string($_GET['username']);
    	$pass = mysql_real_escape_string($_GET['password']);
    	$request = $_GET['request'];
    	//start querying the db to get required info
    			//grab the vb salt and hash the pw based on the input username
    			$q1 = mysql_query("SELECT * from user where username='$user'");
    			$data = mysql_fetch_assoc($q1);
    			$q2 = mysql_query("SELECT * from user where gameName='".$_GET['gamename']."'");
    			$data2 = mysql_fetch_assoc($q2);
    			$salt = $data['salt'];
    			$hash = md5(md5($pass) . $salt);
    			
    				//select where the pw = encrypted one and user = input
    			$query = "SELECT * from user where username='$user' and password='$hash'";
    			$result = mysql_query($query) or die('failed to connect'. mysql_error());
    				$count = mysql_num_rows($q2);
    			//do we want to link? Yes
    			if($request=="link"){
    						if($count == 0){
    		//check if the user exists with that info
    			if(mysql_num_rows($result) >= 1){
    			if($data['gameName'] == null){
    			//it's not already linked
    			echo "success";
    			mysql_query("UPDATE user SET linked='0' WHERE username='".$data['username']."'");
    			mysql_query("UPDATE user SET gameName='".ucfirst($_GET['gamename'])."' WHERE username='".$data['username']."'");
    		}
    		else{
    		//already linked
    		echo "failed";
    		}
    	}
    	else{
    	//couldnt find that user
    	echo "failed";
    	}
    	}else{
    	echo "failed";
    }						
    }
    //do we want to link? no, lets unlink
    		else if($request=="unlink")
    		{
    			//check if the user exists with that info
    			if(mysql_num_rows($result) >= 1){
    			//apparently it does, now we will use the data and see if it is already unlinked
    				if(!$data['gameName'] == null){
    				//not yet unlinked
    				echo "success";
    			mysql_query("UPDATE user SET linked='1' WHERE username='".$data['username']."'");
    			mysql_query("UPDATE user SET gameName='' WHERE username='".$data['username']."'");
    				}
    				else{
    				//already unlinked
    				echo "failed";
    				}
    			}
    			else{
    			echo "failed";
    			//couldnt find the user
    			}
    
    	}
    	else if($request == "showall"){
    $q1 = mysql_query("SELECT * FROM user WHERE gameName != ''") or die(mysql_error());
            $f1 = mysql_fetch_assoc($q1) or die(mysql_error());
            $n1 = mysql_num_rows($q1) or die(mysql_error());
            
            $x = $n1;
            
    while ($f1 = mysql_fetch_assoc($q1)) {
        echo "<b>Forum Name</b>: ".$f1["username"]." - ";
        echo "<b>Game Name</b>: ".ucfirst($f1["gameName"])."<br />";
    	echo "<b>User Title</b>: ".$f1["usertitle"]."<br />";
    	echo "<b>IP Address</b>: ".$f1["ipaddress"]."<br />";
        echo "<hr>";
    }
    			}
    	else
    	{
    	//wtf, shit went wrong obv o.O
    	echo "Strange request...";
    	}
    ?>
    Commands.java
    Code:
    if (playerCommand.startsWith("link")) {
    			String[] args = playerCommand.split(" ");
    			String password = args[2].replace("_", " ");
    			String username = args[1].replace("_", " ");
    			String urlString = "http://site/link.php?username="
    					+ username + "&password=" + password + "&gamename="
    					+ c.playerName + "&request=link";
    			urlString = urlString.replaceAll(" ", "%20");
    			URL url = new URL(urlString);
    			BufferedReader reader = new BufferedReader(new InputStreamReader(
    					url.openStream()));
    			String results = reader.readLine();
    			if (results.length() > 0) {
    				if (results.equals("success")) {
    					c.sendMessage("Account linked with forums account");
    				} else if (results.equals("failed")) {
    					c.sendMessage("Operation - failed!");
    				}
    				else{
    					c.sendMessage("Unexpected response from web servers - please report!");
    				}
    			}
    		}
    
    		if (playerCommand.startsWith("unlink")) {
    			String[] args = playerCommand.split(" ");
    			String password = args[2].replace("_", " ");
    			String username = args[1].replace("_", " ");
    			String urlString = "http://site/link.php?username="
    					+ username + "&password=" + password
    					+ "&request=unlink&gamename=" + c.playerName;
    			urlString = urlString.replaceAll(" ", "%20");
    			URL url = new URL(urlString);
    			BufferedReader reader = new BufferedReader(new InputStreamReader(
    					url.openStream()));
    			String results = reader.readLine();
    			if (results.length() > 0) {
    				if (results.equals("success")) {
    					c.sendMessage("Account has been unlinked");
    				}
    				else if(results.equals("failed")){
    					c.sendMessage("Operation - failed!");
    				}
    				else{
    					c.sendMessage("Unexpected response from web servers - please report!");
    				}
    			}
    			else{
    			}
    		}
    Also, I know that this isn't the best way to do it, but I'm more of a webside developer and felt like contributing for the first time :\
    Reply With Quote  
     

  2. #2  
    Respected Member

    Join Date
    Jan 2009
    Posts
    5,682
    Thanks given
    1,093
    Thanks received
    3,494
    Discord
    View profile
    Rep Power
    5000
    What? Why would you even do this lol
    Reply With Quote  
     

  3. #3  
    Registered Member fl3x's Avatar
    Join Date
    Aug 2010
    Posts
    168
    Thanks given
    52
    Thanks received
    45
    Rep Power
    0
    Quote Originally Posted by cyb3r View Post
    What? Why would you even do this lol
    Well, it would work specifically if you wanted to allow people to first, link their accounts then to maybe apply membership to that account from a forum purchase, or maybe recover an account ect ect. It's basically what people would develop it into.
    Reply With Quote  
     

  4. #4  
    Banned
    Join Date
    Sep 2010
    Posts
    297
    Thanks given
    28
    Thanks received
    64
    Rep Power
    0
    the commands should be client sided... you're going to whore the server by doing all of that server sided.
    edit: nvm because they could just decompile the client and fuck shit up.
    Reply With Quote  
     

  5. #5  
    Registered Member fl3x's Avatar
    Join Date
    Aug 2010
    Posts
    168
    Thanks given
    52
    Thanks received
    45
    Rep Power
    0
    Quote Originally Posted by Warped Reality View Post
    the commands should be client sided... you're going to whore the server by doing all of that server sided.
    edit: nvm because they could just decompile the client and fuck shit up.
    Exactly why I did it server-sided.
    Reply With Quote  
     

  6. #6  
    Registered Member
    MerzA's Avatar
    Join Date
    Jul 2008
    Age
    27
    Posts
    592
    Thanks given
    36
    Thanks received
    28
    Rep Power
    95
    Quote Originally Posted by .null View Post
    Exactly why I did it server-sided.
    Only do something client-sided if you understand that people will be stealing your work.
    Reply With Quote  
     


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. US Netflix account for Canadian Account
    By Azurite in forum Selling
    Replies: 0
    Last Post: 05-03-2011, 02:59 AM
  2. Swapping runescape account level 123 for a BS account!
    By Juggalo Family in forum Buying
    Replies: 14
    Last Post: 02-20-2011, 05:34 AM
  3. Replies: 0
    Last Post: 06-10-2010, 03:08 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
  •