Welcome!

Join our community of MMO enthusiasts and game developers! By registering, you'll gain access to discussions on the latest developments in MMO server files and collaborate with like-minded individuals. Join us today and unlock the potential of MMO server development!

Join Today!

[Tut]Auto register

Newbie Spellweaver
Joined
Jan 4, 2009
Messages
9
Reaction score
0
Open Up MySQL Querry Browser.
Click File>NewTab and Execute this file:

ALTER TABLE `accounts` ADD COLUMN `lastknownip` VARCHAR(30) NOT NULL DEFAULT '' AFTER `macs`;

Now, open up Auto-Register.java.
Scroll down until you find this:

private static final boolean autoRegister = true; //enable = true or disable = false

Change it to this if you want to enable Auto-Register

private static final boolean autoRegister = true; //enable = true or disable = true

Go up one line and you'll see

private static final int ACCOUNTS_PER_IP = 1; //change the value to the amount of accounts you want allowed for each ip

Change the 1 to w/e you like. This will allow how many accounts per an IP.

Save like Duh?

Open Up LoginCrypto.java which is in src>net>sf>odinms>client

Hit Ctr + F and put this in:
private static String hexSha1(String in) {

Replace that with :
public static String hexSha1(String in) {

Save obviously.

Now, open LoginPasswordHandler. Which is in src>net>sf>odinms>net>login>handler.

Add this import to it:
import net.sf.odinms.client.AutoRegister;

Then find: loginok = c.login(login, pwd, ipBan || macBan);

Replace it with:

if (AutoRegister.getAccountExists(login) != false) {
loginok = c.login(login, pwd, ipBan || macBan);
} else if (AutoRegister.autoRegister != false && (!ipBan || !macBan)) {
AutoRegister.createAccount(login, pwd, c.getSession().getRemoteAddress().toString());
if (AutoRegister.success != false) {
loginok = c.login(login, pwd, ipBan || macBan);
}
}

SAVE!!!

Open up MapleClient which is in src>net>sf>odinms>client.

Replace:

public int login(String login, String pwd, boolean ipMacBanned) {
int loginok = 5;
Connection con = DatabaseConnection.getConnection();
try {
PreparedStatement ps = con
.prepareStatement("SELECT id,password,salt,tempban,banned,gm,macs,greason FROM accounts WHERE name = ?");
ps.setString(1, login);
ResultSet rs = ps.executeQuery();
if (rs.next()) {
int banned = rs.getInt("banned");
accId = rs.getInt("id");
int igm = rs.getInt("gm");
String passhash = rs.getString("password");
String salt = rs.getString("salt");
gm = igm > 0;
greason = rs.getByte("greason");
tempban = getTempBanCalendar(rs);
if ((banned == 0 && !ipMacBanned) || banned == -1) {
PreparedStatement ips = con.prepareStatement("INSERT INTO iplog (accountid, ip) VALUES (?, ?)");
ips.setInt(1, accId);
String sockAddr = session.getRemoteAddress().toString();
ips.setString(2, sockAddr.substring(1, sockAddr.lastIndexOf(':')));
ips.executeUpdate();
ips.close();
}

// do NOT track ALL mac addresses ever used
/*String[] macData = rs.getString("macs").split(", ");
for (String mac : macData) {
if (!mac.equals(""))
macs.add(mac);
}*/
ps.close();
// if (gm > 0) {
// session.write(MaplePacketCreator.getAuthSuccessReq uestPin(getAccountName()));
// return finishLogin(true);
// }
if (banned == 1) {
loginok = 3;
} else {
// this is to simplify unbanning
// all known ip and mac bans associated with the current
// client
// will be deleted
if (banned == -1)
unban();
if (getLoginState() > MapleClient.LOGIN_NOTLOGGEDIN) { // already
// loggedin
loggedIn = false;
loginok = 7;
} else {
boolean updatePasswordHash = false;
// Check if the passwords are correct here. :B
if (LoginCryptoLegacy.isLegacyPassword(passhash) && LoginCryptoLegacy.checkPassword(pwd, passhash)) {
// 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) {
PreparedStatement pss = con.prepareStatement("UPDATE `accounts` SET `password` = ?, `salt` = ? WHERE id = ?");
try {
String newSalt = LoginCrypto.makeSalt();
pss.setString(1, LoginCrypto.makeSaltedSha512Hash(pwd, newSalt));
pss.setString(2, newSalt);
pss.setInt(3, accId);
pss.executeUpdate();
} finally {
pss.close();
}
}
}
}
}
rs.close();
ps.close();
} catch (SQLException e) {
log.error("ERROR", e);
}
return loginok;
}

With:

public int login(String login, String pwd, boolean ipMacBanned) {
int loginok = 5;
Connection con = DatabaseConnection.getConnection();
try {
PreparedStatement ps = con
.prepareStatement("SELECT id,password,salt,tempban,banned,gm,macs,lastknowni p,greason FROM accounts WHERE name = ?");
ps.setString(1, login);
ResultSet rs = ps.executeQuery();
if (rs.next()) {
int banned = rs.getInt("banned");
accId = rs.getInt("id");
int igm = rs.getInt("gm");
String passhash = rs.getString("password");
String salt = rs.getString("salt");
gm = igm > 0;
greason = rs.getByte("greason");
tempban = getTempBanCalendar(rs);
if ((banned == 0 && !ipMacBanned) || banned == -1) {
PreparedStatement ips = con.prepareStatement("INSERT INTO iplog (accountid, ip) VALUES (?, ?)");
ips.setInt(1, accId);
ips.setString(2, session.getRemoteAddress().toString());
ips.executeUpdate();
ips.close();
}

//update the lastknownip for the player on a successful login if the ip changes
if (!rs.getString("lastknownip").equals(session.getRe moteAddress().toString())) {
PreparedStatement lkip = con.prepareStatement("UPDATE accounts SET lastknownip = ? where id = ?");
String sockAddr = session.getRemoteAddress().toString();
lkip.setString(1, sockAddr.substring(1, sockAddr.lastIndexOf(':')));
lkip.setInt(2, accId);
lkip.executeUpdate();
lkip.close();
}

// do NOT track ALL mac addresses ever used
/*String[] macData = rs.getString("macs").split(", ");
for (String mac : macData) {
if (!mac.equals(""))
macs.add(mac);
}*/
ps.close();
// if (gm > 0) {
// session.write(MaplePacketCreator.getAuthSuccessReq uestPin(getAccountName()));
// return finishLogin(true);
// }
if (banned == 1) {
loginok = 3;
} else {
// this is to simplify unbanning
// all known ip and mac bans associated with the current
// client
// will be deleted
if (banned == -1)
unban();
if (getLoginState() > MapleClient.LOGIN_NOTLOGGEDIN) { // already loggedin
loggedIn = false;
loginok = 7;
} else {
boolean updatePasswordHash = false;
// Check if the passwords are correct here. :B
if (LoginCryptoLegacy.isLegacyPassword(passhash) && LoginCryptoLegacy.checkPassword(pwd, passhash)) {
// 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) {
PreparedStatement pss = con.prepareStatement("UPDATE `accounts` SET `password` = ?, `salt` = ? WHERE id = ?");
try {
String newSalt = LoginCrypto.makeSalt();
pss.setString(1, LoginCrypto.makeSaltedSha512Hash(pwd, newSalt));
pss.setString(2, newSalt);
pss.setInt(3, accId);
pss.executeUpdate();
} finally {
pss.close();
}
}
}
}
}
rs.close();
ps.close();
} catch (SQLException e) {
log.error("ERROR", e);
}
return loginok;
}

Save it!!!
Now, Compile it with w/e you use. NetBeans etc. If you dunno how, Go on my Channel and you'll see a Video called How to Edit GM Hat and Compile etc.

Then it should work perfectly!!!

Enjoy your Server with Non-Registration Page needed.



Download---
 
Newbie Spellweaver
Joined
Sep 9, 2008
Messages
29
Reaction score
0
I have problem in this part

Now, open LoginPasswordHandler. Which is in src>net>sf>odinms>net>login>handler.

Add this import to it:
import net.sf.odinms.client.AutoRegister;

Then find: loginok = c.login(login, pwd, ipBan || macBan);

Replace it with:

if (AutoRegister.getAccountExists(login) != false) {
loginok = c.login(login, pwd, ipBan || macBan);
} else if (AutoRegister.autoRegister != false && (!ipBan || !macBan)) {
AutoRegister.createAccount(login, pwd, c.getSession().getRemoteAddress().toString());
if (AutoRegister.success != false) {
loginok = c.login(login, pwd, ipBan || macBan);
}
}

i follow the instructions but when i compile with netbean apears this error
 

Attachments

You must be registered for see attachments list
Newbie Spellweaver
Joined
Aug 22, 2008
Messages
88
Reaction score
14
Uhm auto register have been released a long time ago like when p server was still v.55 so I guess its not a release but most of a new auto register TuT post

Anyway if you help some noob its alright o_O
 
Newbie Spellweaver
Joined
Jan 9, 2009
Messages
15
Reaction score
0
why i got this error when i wan execute- Script line: 1 Duplicate column name 'lastknownip'
 
Newbie Spellweaver
Joined
Sep 10, 2009
Messages
14
Reaction score
0
I dont get it to work. I dont know how to compile i have tried so many time and when im gonna login it says "this is not a registered id" heeeeeeeeeelllllppppppppppp plssssssss!!!!!!
 
Xephizion Development
Loyal Member
Joined
Apr 19, 2008
Messages
906
Reaction score
31
"open AutoRegister.java"
and who told you that every repack has AutoRegister.java?
 
Newbie Spellweaver
Joined
Aug 8, 2009
Messages
24
Reaction score
2
Lol @ open AutoRegister.java (ThePack has it =/)

Just make a registration page and put it in wamp..
 
Legendary Battlemage
Joined
Mar 30, 2009
Messages
672
Reaction score
676
Not everyone has this. Also you should use the
Code:
 tags.
 
Xephizion Development
Loyal Member
Joined
Apr 19, 2008
Messages
906
Reaction score
31
ehhhhhhh it sucks anyways.. I hate A/R
 
Newbie Spellweaver
Joined
Sep 9, 2009
Messages
7
Reaction score
0
Lol @ open AutoRegister.java (ThePack has it =/)

Just make a registration page and put it in wamp..

not all people can port forward due to their IPS? i have been trying to get a register page i get everything but i cant get ppl to get to my page. i know many ppl have this problem so they turn to A/R
 
Newbie Spellweaver
Joined
Oct 19, 2010
Messages
41
Reaction score
1
Tell us the errors you got... And this is a year old thread
 
Last edited:
Back
Top