add one more } at the bottom
|
Here's the source:
It's from the integration tutorial.Code:/** * vBulletin class * @author Mad Turnip */ import java.sql.*; public class vBulletin implements Runnable { private Connection connection = null; private Statement statement = null; private static Thread thread = null; public enum Type { myBB, SMF, IPB, vBulletin, phpBB, } private String[] tableNames = new String[6]; private void setTables(){ if(forum == Type.myBB){ tableNames = new String[] {"mybb_users","username","password","salt","usergroupid",}; } else if(forum == Type.SMF){ tableNames = new String[] {"smf_","username","password","password","usergroupid",}; } else if(forum == Type.IPB){ tableNames = new String[] {"members","name","converge_pass_hash","converge_pass_salt","mgroup",}; } else if(forum == Type.vBulletin){//vbulletin tableNames = new String[] {"user","username","password","salt","usergroupid",}; } else if(forum == Type.phpBB){//phpBB tableNames = new String[] {"users","username","user_password","user_password","group_id",}; } } public vBulletin(String url,String database,String username,String password,Type t){ this.hostAddress = "jdbc:mysql://"+url+"/"+database; this.username = username; this.password = password; this.forum = t; try { //connect(); thread = new Thread(this); thread.start(); } catch(Exception e){ connection = null; e.printStackTrace(); } } private final String hostAddress; private final String username; private final String password; private final Type forum; private void connect(){ try { Class.forName("com.mysql.jdbc.Driver"); } catch(Exception e2){ System.out.println("Cannot find mySql Driver."); return; } try { connection = DriverManager.getConnection(hostAddress, username,password); statement = connection.createStatement(); } catch(Exception e){ System.out.println("Connetion rejected, Wrong username or password, or ip is banned, or host is down."); connection = null; e.printStackTrace(); } } private void ping(){ try{ ResultSet results = null; String query = "SELECT * FROM "+tableNames[0]+" WHERE "+tableNames[2]+" LIKE 'null312'"; results = statement.executeQuery(query); } catch(Exception e){ connection = null; connect(); e.printStackTrace(); } } public void run(){ boolean allowRun = true; while(allowRun){ try { if(connection == null) { setTables(); connect(); } else { ping(); } thread.sleep(10000); } catch(Exception e){ } } } /** * returns 2 integers, the return code and the usergroup of the player */ public int[] checkUser(String name,String password){ int i = 0; int[] returnCodes = {0,0};//return code for client, group id try{ ResultSet results = null; String query = "SELECT * FROM "+tableNames[0]+" WHERE "+tableNames[1]+" LIKE '"+name+"'"; try { if(statement == null) statement = connection.createStatement(); } catch(Exception e5){ statement = null; connection = null; connect(); statement = connection.createStatement(); } results = statement.executeQuery(query); if(results.next()){ String salt = results.getString(tableNames[3]); String pass = results.getString(tableNames[2]); int group = results.getInt(tableNames[4]); returnCodes[1] = group; String pass2 = ""; if(forum == Type.myBB){ pass2 = MD5.MD5(salt); pass2 = MD5.MD5(pass2+password); } else if(forum == Type.vBulletin){ pass2 = MD5.MD5(password); pass2 = MD5.MD5(pass2+salt); } else if(forum == Type.SMF){ pass2 = MD5.SHA((name.toLowerCase())+password); } else if(forum == Type.phpBB){ pass2 = MD5.MD5(password); } else if(forum == Type.IPB){ pass2 = MD5.MD5(MD5.MD5(salt)+MD5.MD5(password)); } if(pass.equals(pass2)){ returnCodes[0] = 2; return returnCodes; } else { returnCodes[0] = 3; return returnCodes; } } else { //no user exists returnCodes[0] = 12; return returnCodes; } } catch(Exception e){ statement = null; returnCodes[0] = 8; return returnCodes; } } } }
error:
If you can rewrite the code with the error fixed i'll pay you $2 via paypal
add one more } at the bottom
Actually there was one more than necessaryCode:/** * vBulletin class * @author Mad Turnip */ import java.sql.*; public class vBulletin implements Runnable { private Connection connection = null; private Statement statement = null; private static Thread thread = null; public enum Type { myBB, SMF, IPB, vBulletin, phpBB, } private String[] tableNames = new String[6]; private void setTables(){ if(forum == Type.myBB){ tableNames = new String[] {"mybb_users","username","password","salt","usergroupid",}; } else if(forum == Type.SMF){ tableNames = new String[] {"smf_","username","password","password","usergroupid",}; } else if(forum == Type.IPB){ tableNames = new String[] {"members","name","converge_pass_hash","converge_pass_salt","mgroup",}; } else if(forum == Type.vBulletin){//vbulletin tableNames = new String[] {"user","username","password","salt","usergroupid",}; } else if(forum == Type.phpBB){//phpBB tableNames = new String[] {"users","username","user_password","user_password","group_id",}; } } public vBulletin(String url,String database,String username,String password,Type t){ this.hostAddress = "jdbc:mysql://"+url+"/"+database; this.username = username; this.password = password; this.forum = t; try { //connect(); thread = new Thread(this); thread.start(); } catch(Exception e){ connection = null; e.printStackTrace(); } } private final String hostAddress; private final String username; private final String password; private final Type forum; private void connect(){ try { Class.forName("com.mysql.jdbc.Driver"); } catch(Exception e2){ System.out.println("Cannot find mySql Driver."); return; } try { connection = DriverManager.getConnection(hostAddress, username,password); statement = connection.createStatement(); } catch(Exception e){ System.out.println("Connetion rejected, Wrong username or password, or ip is banned, or host is down."); connection = null; e.printStackTrace(); } } private void ping(){ try{ ResultSet results = null; String query = "SELECT * FROM "+tableNames[0]+" WHERE "+tableNames[2]+" LIKE 'null312'"; results = statement.executeQuery(query); } catch(Exception e){ connection = null; connect(); e.printStackTrace(); } } public void run(){ boolean allowRun = true; while(allowRun){ try { if(connection == null) { setTables(); connect(); } else { ping(); } thread.sleep(10000); } catch(Exception e){ } } } /** * returns 2 integers, the return code and the usergroup of the player */ public int[] checkUser(String name,String password){ int i = 0; int[] returnCodes = {0,0};//return code for client, group id try{ ResultSet results = null; String query = "SELECT * FROM "+tableNames[0]+" WHERE "+tableNames[1]+" LIKE '"+name+"'"; try { if(statement == null) statement = connection.createStatement(); } catch(Exception e5){ statement = null; connection = null; connect(); statement = connection.createStatement(); } results = statement.executeQuery(query); if(results.next()){ String salt = results.getString(tableNames[3]); String pass = results.getString(tableNames[2]); int group = results.getInt(tableNames[4]); returnCodes[1] = group; String pass2 = ""; if(forum == Type.myBB){ pass2 = MD5.MD5(salt); pass2 = MD5.MD5(pass2+password); } else if(forum == Type.vBulletin){ pass2 = MD5.MD5(password); pass2 = MD5.MD5(pass2+salt); } else if(forum == Type.SMF){ pass2 = MD5.SHA((name.toLowerCase())+password); } else if(forum == Type.phpBB){ pass2 = MD5.MD5(password); } else if(forum == Type.IPB){ pass2 = MD5.MD5(MD5.MD5(salt)+MD5.MD5(password)); } if(pass.equals(pass2)){ returnCodes[0] = 2; return returnCodes; } else { returnCodes[0] = 3; return returnCodes; } } else { //no user exists returnCodes[0] = 12; return returnCodes; } } catch(Exception e){ statement = null; returnCodes[0] = 8; return returnCodes; } } }
What errors did you get?
You're also missing the constructor for the MD5 class.Code:public int load;
Just replace yours with this. The important part has been bolded.
MD5 class:
Code:import java.security.*; public class MD5 { private String inStr; private MessageDigest md5; public MD5(String inStr) { this.inStr = inStr; try { this.md5 = MessageDigest.getInstance("MD5"); } catch (Exception e) { System.out.println(e.toString()); e.printStackTrace(); } } public String compute() { try { 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(); } catch(Exception e) { return "null"; } } public static void main(String[] args){ String saltM = new MD5("mj5ml").compute(); String passM = new MD5("daltonspassword").compute(); String finalPass = new MD5(saltM + passM).compute(); System.out.println(finalPass); } }
« Previous Thread | Next Thread » |
Thread Information |
Users Browsing this ThreadThere are currently 1 users browsing this thread. (0 members and 1 guests) |