
נכתב במקור על ידי
Symphony
ניסית איך שסידרת את זה קודם?
כה תראה
זה הJAVA של AUTOREGISTAR
קוד PHP:
package client;
import java.sql.PreparedStatement;import java.io.UnsupportedEncodingException;import java.security.MessageDigest;import java.security.NoSuchAlgorithmException;import java.sql.Connection;import java.sql.ResultSet;import java.util.HashMap;import java.util.Map;import tools.DatabaseConnection;import tools.HexTool;
public class AutoRegister { private static final Map<String, String> accountList = new HashMap<String, String>();
public static boolean getAccountExists(String login) { if (accountList.isEmpty()) { try { Connection con = DatabaseConnection.getConnection(); PreparedStatement ps = con.prepareStatement("SELECT name, lastknownip FROM accounts"); ResultSet rs = ps.executeQuery(); while (rs.next()) { accountList.put(rs.getString("name").toLowerCase(), rs.getString("lastknownip")); } rs.close(); ps.close(); } catch (Exception e) { System.out.println("Error loading the account list: " + e + "."); } } return accountList.containsKey(login); }
public static boolean createAccount(String login, String pwd, String eip) { boolean success = false; int countIP = 0; String eIP = eip.substring(1, eip.lastIndexOf(':')); for (String ips : accountList.values()) { if (ips.equals(eIP)) { countIP++; } } if (5 > countIP) { try { Connection con = DatabaseConnection.getConnection(); PreparedStatement ps = con.prepareStatement("INSERT INTO accounts (name, password, email, birthday, macs, lastknownip) VALUES (?, ?, ?, ?, ?, ?)"); ps.setString(1, login); ps.setString(2, sha1(pwd)); ps.setString(3, "no@email.provided"); ps.setString(4, "0000-00-00"); ps.setString(5, "00-00-00-00-00-00"); ps.setString(6, eIP); ps.executeUpdate(); ps.close(); success = true; accountList.put(login.toLowerCase(), eIP); } catch (Exception e) { System.out.println("Error creating an account (" + login + " | " + pwd + " | " + eip + ")."); } } return success; }
private static String sha1(String in) { try { MessageDigest Digester = MessageDigest.getInstance("SHA-1"); Digester.update(in.getBytes("UTF-8"), 0, in.length()); byte[] sha1Hash = Digester.digest(); return HexTool.toString(sha1Hash).replace(" ", "").toLowerCase(); } catch (NoSuchAlgorithmException ex) { throw new RuntimeException("Hashing the password failed: ", ex); } catch (UnsupportedEncodingException e) { throw new RuntimeException("Encoding the string failed: ", e); } }}
וזה של ה LoginPasswordHandler
קוד PHP:
/* This file is part of the OdinMS Maple Story Server Copyright (C) 2008 Patrick Huy <patrick.huy@frz.cc> Matthias Butz <matze@odinms.de> Jan Christian Meyer <vimes@odinms.de>
This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation version 3 as published by the Free Software Foundation. You may not use, modify or distribute this program under any other version of the GNU Affero General Public License.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.*/package net.login.handler;
import client.AutoRegister;import client.MapleCharacter;import client.MapleClient;import java.util.Calendar;import net.MaplePacketHandler;import server.TimerManager;import tools.DateUtil;import tools.MaplePacketCreator;import tools.data.input.SeekableLittleEndianAccessor;
public final class LoginPasswordHandler implements MaplePacketHandler { public boolean validateState(MapleClient c) { return !c.isLoggedIn(); }
public final void handlePacket(SeekableLittleEndianAccessor slea, MapleClient c) { int loginok = 0; String login = slea.readMapleAsciiString(); String pwd = slea.readMapleAsciiString(); c.setAccountName(login); final boolean isBanned = c.hasBannedIP() || c.hasBannedMac(); if (AutoRegister.getAccountExists(login.toLowerCase())) { loginok = c.login(login, pwd, isBanned); } else if ((!isBanned)) { if (AutoRegister.createAccount(login, pwd, c.getSession().getRemoteAddress().toString())) { loginok = c.login(login, pwd, isBanned); } else { loginok = 10; } } else { loginok = 5; } Calendar tempban = c.getTempBanCalendar(); if (tempban != null) { if (tempban.getTimeInMillis() > System.currentTimeMillis()) { long till = DateUtil.getFileTimestamp(tempban.getTimeInMillis()); c.announce(MaplePacketCreator.getTempBan(till, c.getGReason())); return; } } if (loginok == 3 && !isBanned) { c.announce(MaplePacketCreator.getPermBan(c.getGReason())); return; } if (loginok == 0 && isBanned) { loginok = 3; MapleCharacter.ban(c.getSession().getRemoteAddress().toString().split(":")[0], "Mac/IP Re-ban", false); } else if (loginok != 0) { c.announce(MaplePacketCreator.getLoginFailed(loginok)); return; } if (c.finishLogin() == 0) { c.announce(MaplePacketCreator.getAuthSuccess(c, c.getAccountName())); final MapleClient client = c; c.setIdleTask(TimerManager.getInstance().schedule(new Runnable() { public void run() { client.getSession().close(true); } }, 600000)); } else { c.announce(MaplePacketCreator.getLoginFailed(7)); } }}
ועוד הערצת MYSQL
וזה התוצאה

עריכה:
חשוב לי להגיד
שבגירסא הזאת אחרי שאתה בוחר שם וסיסמה הוא אמור לשאול אותך איזה מין (זכר/נקבה)
ואין את זה ב AUTOREGISTAR
עריכה אפשר לנעול מצאתי