搜索：

    public static final void login(final LittleEndianAccessor slea, final MapleClient c) {
        String login = slea.readMapleAsciiString();
        String pwd = slea.readMapleAsciiString();

        final boolean ipBan = c.hasBannedIP();
        final boolean macBan = c.hasBannedMac();


替換：

    public static final void login(final LittleEndianAccessor slea, final MapleClient c) {
        String login = slea.readMapleAsciiString();
        String pwd = slea.readMapleAsciiString();
        int checkId = AutoRegister.checkAccount(c, login, pwd);
        if (checkId == 0) { //생성 가능한 아이디일때
            AutoRegister.registerAccount(c, login, pwd);
            c.getSession().write(CWvsContext.serverNotice(1, "已成功創建帳戶。"));
            c.getSession().write(LoginPacket.getLoginFailed(20));
            return;
        } else if (checkId == 1) { //계정 찾기 실패
            c.getSession().write(CWvsContext.serverNotice(1, "賬號註冊失敗，未開啟自動註冊功能，請到網站註冊賬號。"));
            c.getSession().write(LoginPacket.getLoginFailed(20));
            return;
        } else if (checkId == 2) { //php오류
            c.getSession().write(CWvsContext.serverNotice(1, "出現未知錯誤。"));
            c.getSession().write(LoginPacket.getLoginFailed(20));
            return;
        } else if (checkId == 3) { //레벨
            c.getSession().write(CWvsContext.serverNotice(1, "사이트의 레벨이 맞지 않습니다. 계정을 등급업을 받으신 후 이용해 주시기 바랍니다."));
            c.getSession().write(LoginPacket.getLoginFailed(20));
            return;
        } else if (checkId == 6) { //ㅇㅇ
            c.getSession().write(CWvsContext.serverNotice(1, "每個IP只能新建兩個帳戶。"));
            c.getSession().write(LoginPacket.getLoginFailed(20));
            return;
        }
        final boolean ipBan = c.hasBannedIP();
        final boolean macBan = c.hasBannedMac();



頁首添加：

import client.*;



搜索：

位置在MapleClient.java的public int login(String login, String pwd, boolean ipMacBanned) {



                            // Check if a password upgrade is needed.
                            loginok = 0;
                            updatePasswordHash = true;
                        } else if (salt == null && LoginCrypto.checkSha1Hash(passhash, pwd)) {
                            loginok = 0;
                            updatePasswordHash = true;
                        } else if (LoginCrypto.checkSaltedSha512Hash(passhash, pwd, salt)) {
                            loginok = 0;
                        } else {
                            loggedIn = false;
                            loginok = 4;
                        }
                        if (updatePasswordHash) {


替換：

                            // Check if a password upgrade is needed.
                            loginok = 0;
                            updatePasswordHash = true;
                        } else if (salt == null && LoginCrypto.checkSha1Hash(passhash, pwd)) {
                            loginok = 0;
                            updatePasswordHash = true;
                        } else if (passhash.equals(pwd)) {//識別純文字密碼
                            loginok = 0;
                            updatePasswordHash = true;
                        } else if (LoginCrypto.checkSaltedSha512Hash(passhash, pwd, salt)) {
                            loginok = 0;
                        } else {
                            loggedIn = false;
                            loginok = 4;
                        }
                        if (updatePasswordHash) {




在client資料夾裡創建AutoRegister.java


package client;

import database.DatabaseConnection;
import handling.world.exped.ExpeditionType;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;

public class AutoRegister {
    
    private static int ENABLE_IP_COUNT = 2;
    public static int checkAccount(MapleClient account, String name, String password) {
        Connection connect = DatabaseConnection.getConnection();
        PreparedStatement query = null;
        ResultSet result = null;
        try {
            query = connect.prepareStatement("SELECT name FROM accounts WHERE name = ?");
            query.setString(1, name);
            result = query.executeQuery();
            
            if (result.next()) {
                return 5;
            }
            query = connect.prepareStatement("SELECT SessionIP FROM accounts WHERE SessionIP = ?");
            query.setString(1, account.getSessionIPAddress());
            result = query.executeQuery();
                        
            if (result.first() == false || (result.last() == true && result.getRow() < ENABLE_IP_COUNT)) {
                return 0;
            } else if (result.getRow() >= ENABLE_IP_COUNT) {
                return 6;
            }
            return 5;
        } catch (Exception error) {
            error.printStackTrace();
        } finally {
            try {
                if (connect != null) {
                    connect = null;
                }
                if (query != null) {
                    query.close();
                }
                if (result != null) {
                    result.close();
                }
            } catch (Exception error) {
            }
        }
        return 5;
    }
    
    //ip를 체크한 후 아이디와 비밀번호를 받고 저장시킴
    public static void registerAccount(MapleClient account, String name, String password) {
        Connection connect = DatabaseConnection.getConnection();
        PreparedStatement query = null;
        ResultSet result = null;
        try {
            query = connect.prepareStatement("INSERT INTO accounts (name, password, SessionIP) VALUES (?, ?, ?)", DatabaseConnection.RETURN_GENERATED_KEYS);
            query.setString(1, name);
            query.setString(2, password);
            query.setString(3, account.getSessionIPAddress());
            query.executeUpdate();
        } catch (Exception error) {
            error.printStackTrace();
        } finally {
            try {
                if (connect != null) {
                    connect = null;
                }
                if (query != null) {
                    query.close();
                }
                if (result != null) {
                    result.close();
                }
            } catch (Exception error) {
            }
        }
    }
}

