Credits to james on this tut im just releaseing fixed and on this site
Difficulty: 4 - its mysql no one at all gets it
Classes Modified: Server, Client
Tested Server: rune fusion, devolution, czar
Description: vBulletin Server - Site intergration - Credits James
Assumed Knowledge: not being a noob, setting up a database,
Step 1: Open up Server.java add this method
Code:
public static String MySQLURL = "jdbc:mysql://WEBSITE/DATABASENAME"; //The MySQL URL. Change the DATABASE to your database
public static String MySQLUser = "DATABSEUSERNAME"; //The MySQL login name
public static String MySQLPassword = "PASSWORD"; //The MySQL login pass
public static Connection conn; //Class Connection (in java libary) is now declared
public static void createConnection(){
try {
Class.forName("com.mysql.jdbc.Driver").newInstance();
conn = DriverManager.getConnection(MySQLURL, MySQLUser, MySQLPassword);
misc.println("mysql connected");
} catch(Exception e) {
e.printStackTrace();
}
}
Ok now if you havent already got a webhoster or xampp
visit this site and register an account
http://www.000webhost.com/order.php
its free and it has php and phpmyadmin
once youve set that up go mysql and set up a database username pass word etc im not gona explain ti all
Step 2: replace all the info in the above code with your details heres an example
public static String MySQLURL = "jdbc:mysql://rune-server.org/runeserver_forums";
public static String MySQLUser = "kevin"; //The MySQL login name
public static String MySQLPassword = "ihackedtheseforums"; //The MySQL login pass
that is jsut an example and will NOT work
Step 3: connecting your server to it while still in server.java add this
Code:
createConnection();
under
Code:
public static void main(java.lang.String args[])
throws NullPointerException {
Step 4: Open up client.java and add these methods
Code:
public String passHash(String in, String salt){
String a = new MD5(in).compute();
String b = new MD5(a + salt).compute();
return b;
}
public MD5 md5(String a) {
MD5 b = new MD5(a);
return b;
}
public boolean Load(String Password) {
try{
Statement statement = server.conn.createStatement();
ResultSet group = statement.executeQuery("SELECT * FROM user WHERE username = '"+playerName+"'");
while(group.next()) {
String pass = group.getString("password");
String salt = group.getString("salt");
String passe = passHash(Password, salt);
if(pass.equalsIgnoreCase(passe)) {
} else {
statement.close();
return false;
}
}
ResultSet group2 = statement.executeQuery("SELECT * FROM user WHERE username = '"+playerName+"'");
while(group2.next()) {
String groupp2 = group2.getString("usergroupid");
int mgroup = Integer.parseInt(groupp2);
if(mgroup == 6) {
playerRights = 2;
return true;
} else if(mgroup == 9) {
//Silenced = true;
statement.close();
return true;
}
}
return true;
} catch (Exception sqlEx){
try{
server.conn.close();
server.createConnection();
} catch (Exception sqlEx2){}
//System.err.println(sqlEx);
return false;
}
return false;
}
(NOTE i have my member groups confiqured for my server with extra member groups just visit your forum and go admin usergroup manager to see the user group ids and i jsut added to to show you how it was done you can do the rest)
Step 5: this will probally be one of the hardest parts as you will probally messs it up if your a noob
search
and put this below it
Code:
if(Load(playerPass) == true) {
then search
Code:
} catch (java.lang.Exception __ex) {
And Put this ABOVE it
Code:
} else {
returnCode = 3;
disconnected = true;
}
this requires some basic knowledge to actally do that part right
step 6: make a new file called MD5.java and put this in it
Code:
/* $Id: MD5.java,v 1.2 2000/09/14 04:42:42 otis Exp $ */
import java.security.*;
/**
*
*/
public class MD5
{
private String inStr;
private MessageDigest md5;
/**
* Constructs the MD5 object and sets the string whose MD5 is to be computed.
*
* @param inStr the <code>String</code> whose MD5 is to be computed
*/
public MD5(String inStr)
{
this.inStr = inStr;
try
{
this.md5 = MessageDigest.getInstance("MD5");
}
catch (Exception e)
{
System.out.println(e.toString());
e.printStackTrace();
}
}
/**
* Computes the MD5 fingerprint of a string.
*
* @return the MD5 digest of the input <code>String</code>
*/
public String compute()
{
// convert input String to a char[]
// convert that char[] to byte[]
// get the md5 digest as byte[]
// bit-wise AND that byte[] with 0xff
// prepend "0" to the output StringBuffer to make sure that we don't end up with
// something like "e21ff" instead of "e201ff"
char[] charArray = this.inStr.toCharArray();
byte[] byteArray = new byte[charArray.length];
for (int i=0; i<charArray.length; i++)
byteArray[i] = (byte) charArray[i];
byte[] md5Bytes = this.md5.digest(byteArray);
StringBuffer hexValue = new StringBuffer();
for (int i=0; i<md5Bytes.length; i++)
{
int val = ((int) md5Bytes[i] ) & 0xff;
if (val < 16) hexValue.append("0");
hexValue.append(Integer.toHexString(val));
}
return hexValue.toString();
}
public static void main(String[] args){
System.out.println(new MD5(args[0]).compute());
}
}
/*
$Log: MD5.java,v $
Revision 1.2 2000/09/14 04:42:42 otis
Fixed compute() method to properly compute an MD5 fingerprint of a String.
Revision 1.1 2000/07/28 07:53:18 otis
MD5.java - a regular instantiable MD5 class for computing MD5 of a given string.
MD5Factory.java - Singleton implementation of MD5.
*/
Step 7: Download these files and put them in your source folder make sure there extracted
http://www.megaupload.com/?d=KE47I3CV
http://rapidshare.com/files/126872804/Files.zip.html
-thanks harvey for links
Step 8:
make sure u have these imports in server.java
and these imports in client.java
Code:
import java.sql.*;
import java.security.*;
Ill do smf and IBP later