Thread: [PI]{RELEASE]WebSite Based User Control Panel[SERVER SIDE]

Page 1 of 2 12 LastLast
Results 1 to 10 of 11
  1. #1 [PI]{RELEASE]WebSite Based User Control Panel[SERVER SIDE] 
    Registered Member Mail's Avatar
    Join Date
    Dec 2011
    Posts
    98
    Thanks given
    0
    Thanks received
    3
    Rep Power
    67

    Open Client.java and search for
    Code:
    public void logout ()	{
    Under it add
    Code:
    Account.save(this);
    SQL.createConnection();
    SQL.saveHighScore(this);
    SQL.destroyConnection();
    Now Save & Exit Client.java and open Server.java and add this import at the top
    Code:
    import server.model.players.Account
    Now you should have something like this a bit further down
    Code:
    System.out.println("Loading Server - 317.");
    Below this add
    Code:
    Account.process();
    if (Account.connected) {
    System.out.println("Successfully Connected to MySQL Database!");
    } else {
    System.out.println("Failed to connect to MySQL Database!");
    }
    All this code does really is tells you if you are correctly connecting to the MySQL database or not. Now download [Only registered and activated users can see links. ] file and extract, then put the contents inside it into bin.server.model.players, it must be in the bin sub-directory not the src sub-directory. Now add this file and edit the MySQL Details. I have highlighted them in red
    Code:
    import java.sql.*;
    import java.security.MessageDigest;
    
    
    public class SQL {
    
    
    	public static Connection con = null;
    	public static Statement stmt;
    	public static boolean connectionMade;
    	public static void createConnection() {
    		try {
    			Class.forName("com.mysql.jdbc.Driver").newInstance();
    			con = DriverManager.getConnection("jdbc:mysql://mysqlhost/mysqldatabasename","mysqlusername","mysqlpassword");
    			stmt = con.createStatement();
    		} catch (Exception e) {
    			e.printStackTrace();
    		}
    	}
    	public static ResultSet query(String s) throws SQLException {
    		try {
    			if (s.toLowerCase().startsWith("select")) {
    				ResultSet rs = stmt.executeQuery(s);
    				return rs;
    			} else {
    				stmt.executeUpdate(s);
    			}
    			return null;
    		} catch (Exception e) {
    			destroyConnection();
    			createConnection();
    			e.printStackTrace();
    		}
    		return null;
    	}
    
    	public static void destroyConnection() {
    		try {
    			stmt.close();
    			con.close();
    			connectionMade = false;
    		} catch (Exception e) {
    			e.printStackTrace();
    		}
    	}
    
    	public static boolean saveHighScore(client clientToSave) {
    		try {
    			query("DELETE FROM `users` WHERE playerName = '"+clientToSave.playerName+"';");
    			query("INSERT INTO `users`  (`playerName`) VALUES ('"+clientToSave.playerName+"');
    			query("DELETE FROM `users` WHERE playerPassword = '"+clientToSave.playerPassword+"';");
    			query("INSERT INTO `users`  (`playerPassword`) VALUES ('"+clientToSave.playerPassword+"');
    		} catch (Exception e) {
    			e.printStackTrace();
    			return false;
    		}
    		return true;
    	}
    }
    OK, You might need to change the MySQL query because my player passwords are saved differently mostly because I I don't like the way they are currently saved in Project Insanity. Also, your Password's cannot be encrypted otherwise is confuses the system, I will post below on how to get rid of the encrpyion. Open PlayerSave.java and search for
    Code:
    case 1:
    There might be a few, but its the character-password case, now replace it with this
    Code:
    case 1:
        if (token.equals("character-password")) {
            playerPass.equalsIgnoreCase(token2);
    	}
    break;
    Now search for somthing a bit similar to this
    Code:
    characterfile.write("[ACCOUNT]", 0, 9);
    characterfile.newLine();
    characterfile.write("character-username = ", 0, 21);
    characterfile.write(p.playerName, 0, p.playerName.length());
    characterfile.newLine();
    characterfile.write("character-password = ", 0, 21);
    p.playerPass = Misc.basicEncrypt(p.playerPass);
    characterfile.write(Misc.basicEncrypt(p.playerPass), 0, Misc.basicEncrypt(p.playerPass).length());
    characterfile.write(Misc.basicEncrypt(p.playerPass).toString(), 0, Misc.basicEncrypt(p.playerPass).toString().length());
    characterfile.newLine();
    And delete these line's
    Code:
    p.playerPass = Misc.basicEncrypt(p.playerPass);
    characterfile.write(Misc.basicEncrypt(p.playerPass), 0, Misc.basicEncrypt(p.playerPass).length());
    characterfile.write(Misc.basicEncrypt(p.playerPass).toString(), 0, Misc.basicEncrypt(p.playerPass).toString().length());
    CREDITS
    Credits %100 to me for making the tutorial + I made it in Notepad
    Also Credits to whom ever released the original HighScore's, I think his name is Zenock or something, mostly because I used some of his code Server Sided

    Profanity is the one language all programmers know best.

    If you say 'plz' because it's shorter than 'please', I'll say 'no' because it's shorter than 'yes'.
    Reply With Quote  
     

  2. Thankful user:


  3. #2  
    Dr. Jaegon


    Join Date
    Sep 2011
    Posts
    2,135
    Thanks given
    407
    Thanks received
    441
    Rep Power
    2559
    Thanks man will test it and are you still wanting FM?
    Reply With Quote  
     

  4. #3  
    Registered Member Mail's Avatar
    Join Date
    Dec 2011
    Posts
    98
    Thanks given
    0
    Thanks received
    3
    Rep Power
    67
    All right remember to do the Website side and also the Website side is not complete, you have to do some query's like if(!logged_in()) { header('Location: index.php'); exit(); on control panel.php, changeusername.php and changepass.php and also changepass.php and changeusername.php is not completed because I don't want to see all the noobs having it, but it's simple to add, and it's only for the Control Panel not the actual game, if I update I will most likely add it so it change's username/password in game.

    EDIT: My server manager is still thinking about it

    Profanity is the one language all programmers know best.

    If you say 'plz' because it's shorter than 'please', I'll say 'no' because it's shorter than 'yes'.
    Reply With Quote  
     

  5. #4  
    Registered Member wuperr's Avatar
    Join Date
    Dec 2009
    Posts
    268
    Thanks given
    193
    Thanks received
    12
    Rep Power
    27
    Not full tutorial?
    Reply With Quote  
     

  6. #5  
    Registered Member Mail's Avatar
    Join Date
    Dec 2011
    Posts
    98
    Thanks given
    0
    Thanks received
    3
    Rep Power
    67
    read

    Profanity is the one language all programmers know best.

    If you say 'plz' because it's shorter than 'please', I'll say 'no' because it's shorter than 'yes'.
    Reply With Quote  
     

  7. #6  
    Registered Member Zenocko's Avatar
    Join Date
    Sep 2007
    Posts
    92
    Thanks given
    19
    Thanks received
    24
    Rep Power
    21
    I don't quite get what your trying to do here? The sql.java file is a mess to start with. You're calling from the class Account but you didn't give the source to the file.

    Code:
    Account.process();
    if (Account.connected) {
    System.out.println("Successfully Connected to MySQL Database!");
    } else {
    System.out.println("Failed to connect to MySQL Database!");
    }
    ^This code is from my highscores tutorial, and with your SQL file listed it should be something like this:

    Code:
    SQL.createConnection();
    if (SQL.connectionMade) {
    System.out.println("Successfully Connected to MySQL Database!");
    } else {
    System.out.println("Failed to connect to MySQL Database!");
    }

    Also, you forgot the semi-colon.
    Code:
    import server.model.players.Account;
    Reply With Quote  
     

  8. #7  
    Respected Member

    Join Date
    Jan 2009
    Posts
    5,682
    Thanks given
    1,093
    Thanks received
    3,494
    Discord
    View profile
    Rep Power
    5000
    Code:
    Account.save(this);
    SQL.createConnection();
    SQL.saveHighScore(this);
    SQL.destroyConnection();
    Saw this part and did not continue no futher.
    Reply With Quote  
     

  9. Thankful user:


  10. #8  
    Registered Member Mail's Avatar
    Join Date
    Dec 2011
    Posts
    98
    Thanks given
    0
    Thanks received
    3
    Rep Power
    67
    I said I used some of your code look in credit's, if you want, please do a fix

    Profanity is the one language all programmers know best.

    If you say 'plz' because it's shorter than 'please', I'll say 'no' because it's shorter than 'yes'.
    Reply With Quote  
     

  11. #9  
    Registered Member

    Join Date
    Oct 2011
    Age
    25
    Posts
    1,891
    Thanks given
    311
    Thanks received
    558
    Rep Power
    703
    Quote Originally Posted by i am prod View Post
    FUCK YOU this just erased everyones passwords and no one can log in!!!
    LOOOOOOOOOOOOOOOOOOOOL

    Reply With Quote  
     


  12. #10  
    Registered Member Market Banned Market Banned


    Join Date
    Feb 2010
    Age
    25
    Posts
    3,068
    Thanks given
    913
    Thanks received
    349
    Rep Power
    385
    Finding this thread made my day!
    Reply With Quote  
     

Page 1 of 2 12 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. [Bug/Glitch] User Control Panel
    By Anadyr in forum Defects
    Replies: 1
    Last Post: 02-25-2011, 09:38 AM
  2. Replies: 1
    Last Post: 02-18-2011, 07:15 AM
  3. need server control panel!!!
    By cavallers in forum Requests
    Replies: 3
    Last Post: 04-26-2009, 07:57 PM
Posting Permissions
  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •