You are Unregistered, please register to gain Full access.
    


RaGEZONE sponsored advertisment:

Dragonica Image
The free 3D side scrolling MMORPG.

 
 
LinkBack (11) Thread Tools
Old 07-05-2008   11 links from elsewhere to this Post. Click to view. #1 (permalink)
Account Upgraded | Title Enabled!
 
airflow0's Avatar
 
Rank: Member +
Join Date: Sep 2006
Posts: 648
Thanked 0 Times in 0 Posts

[RELEASE] In-game Auto Register + Auto Login

Your Ad Here
This will allow you to register in-game when you insert an unregistered account name.

Credits to Jelly for helping me test.

The password is set to SHA1 instantly after the account is created.
On the first login the password gets updated to SHA512 with the salt.
lastknownip column added to the accounts table.
Correct reading of the lastknownip(Socket removed).
New AutoRegister.java class file.
Changed ban/enabled check to && instead of ||.
*New* int in AutoRegister.java allowing you to change how many times a player can register under the same ip.
*New* boolean in AutoRegister.java allowing you to enable/disable auto register.
*New* Automatic login after the account is created!!

Add the lastknownip column to accounts table in the database.
Code:
ALTER TABLE `accounts` ADD COLUMN `lastknownip` VARCHAR(30) NOT NULL DEFAULT '' AFTER `macs`;
In AutoRegister.java you can change these values to your preference.

Change autoRegister value to true or false to enable or disable auto registration. Default is true.
Code:
private static final boolean autoRegister = true; //enable = true or disable = false
Change ACCOUNTS_PER_IP value to change how many accounts can be created on one ip. Default set to 1.
Code:
private static final int ACCOUNTS_PER_IP = 1; //change the value to the amount of accounts you want allowed for each ip
In LoginCrypto.java

Replace
Code:
private static String hexSha1(String in) {
with
Code:
public static String hexSha1(String in) {
In LoginPasswordHandler.java

Add import.
Code:
import net.sf.odinms.client.AutoRegister;
then replace
Code:
loginok = c.login(login, pwd, ipBan || macBan);
with
Code:
                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);
                        }
                }
In MapleClient.java.

Replace the entire public int login code block with this.
Code:
	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,lastknownip,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.getRemoteAddress().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.getAuthSuccessRequestPin(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;
	}
Finally create a new java class file in net.sf.odinms.client named AutoRegister and replace the contents with
Code:
/*
	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 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.sf.odinms.client;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.sql.ResultSet;

import net.sf.odinms.database.DatabaseConnection;

public class AutoRegister {
        private static final org.slf4j.Logger log = org.slf4j.LoggerFactory.getLogger(MapleClient.class);
        private static final int ACCOUNTS_PER_IP = 1; //change the value to the amount of accounts you want allowed for each ip
        public static final boolean autoRegister = true; //enable = true or disable = false

        public static boolean success = false; // DONT CHANGE
        
        public static boolean getAccountExists(String login) {
                boolean accountExists = false;
                Connection con = DatabaseConnection.getConnection();
                try {
                        PreparedStatement ps = con.prepareStatement("SELECT name FROM accounts WHERE name = ?");
                        ps.setString(1, login);
                        ResultSet rs = ps.executeQuery();
                        if(rs.first())
                                accountExists = true;
                } catch (Exception ex) {
                        log.error("ERROR", ex);
                }
                return accountExists;
        }

        public static void createAccount(String login, String pwd, String eip) {
                String sockAddr = eip;
                Connection con;

                //connect to database or halt
                try {
                        con = DatabaseConnection.getConnection();
                } catch (Exception ex) {
                        log.error("ERROR", ex);
                        return;
                }

                try {
                        PreparedStatement ipc = con.prepareStatement("SELECT lastknownip FROM accounts WHERE lastknownip = ?");
                        ipc.setString(1, sockAddr.substring(1, sockAddr.lastIndexOf(':')));
                        ResultSet rs = ipc.executeQuery();
                        if (rs.first() == false || rs.last() == true && rs.getRow() < ACCOUNTS_PER_IP) {
                                try {
                                        PreparedStatement ps = con.prepareStatement("INSERT INTO accounts (name, password, email, birthday, macs, lastknownip) VALUES (?, ?, ?, ?, ?, ?)");
                                        ps.setString(1, login);
                                        ps.setString(2, LoginCrypto.hexSha1(pwd));
                                        ps.setString(3, "no@email.provided");
                                        ps.setString(4, "2008-04-07");
                                        ps.setString(5, "00-00-00-00-00-00");
                                        ps.setString(6, sockAddr.substring(1, sockAddr.lastIndexOf(':')));
                                        ps.executeUpdate();

                                        ps.close();

                                        success = true;
                                } catch (SQLException ex) {
                                        log.error("ERROR", ex);
                                        return;
                                }
                        }
                        ipc.close();
                        rs.close();
                } catch (SQLException ex) {
                        log.error("ERROR", ex);
                        return;
                }
        }
}

Last edited by airflow0; 07-07-2008 at 10:56 AM.
airflow0 is offline  

RaGEZONE sponsored advertisment:
Old 07-05-2008   #2 (permalink)
The Omega
 
ShaneBoy's Avatar
 
Rank: Member
Join Date: May 2008
Location: California
Posts: 104
Thanked 0 Times in 0 Posts

Re: [RELEASE] In-game Auto Register (ODIN)

Thanks a lot. This is really helpful for when you don't want to make a registration page!
ShaneBoy is offline  

Endorsement
Old 07-05-2008   #3 (permalink)
TacoStory? o.o
 
iFLON's Avatar
 
Rank: Member +
Join Date: May 2008
Posts: 557
Thanked 0 Times in 0 Posts

Re: [RELEASE] In-game Auto Register (ODIN)

LOL. ok i didnt see that one coming! seems useful..but i really people registering from a site.
__________________
[admin]Signature Edited - Akaruz loves everyone - Akaruz . [/admin]
iFLON is offline  

Endorsement

Old 07-05-2008   #4 (permalink)
RaGEZONER
 
Rank: Hobbit
Join Date: Jul 2008
Posts: 81
Thanked 0 Times in 0 Posts

Re: [RELEASE] In-game Auto Register (ODIN)

i mdont understand the last 1 whre add?
James Renard is offline  
Old 07-05-2008   #5 (permalink)
Account Upgraded | Title Enabled!
 
airflow0's Avatar
 
Rank: Member +
Join Date: Sep 2006
Posts: 648
Thanked 0 Times in 0 Posts

Re: [RELEASE] In-game Auto Register (ODIN)

Under the public int login code block.
airflow0 is offline  
Old 07-05-2008   #6 (permalink)
Grimmjow Jeagerjaques
 
Xerixe's Avatar
 
Rank: Alpha Member
Join Date: Apr 2008
Location: Malaysia
Posts: 1,522
Thanked 53 Times in 38 Posts

Re: [RELEASE] In-game Auto Register (ODIN)

Nice Release =)
__________________
Xerixe is offline  
Old 07-05-2008   #7 (permalink)
Ultimate Member
 
Rank: Member
Join Date: May 2008
Location: Israel
Posts: 168
Thanked 0 Times in 0 Posts

Re: [RELEASE] In-game Auto Register (ODIN)

where are the int login?
__________________
Dragon-KinG is offline  
Old 07-05-2008   #8 (permalink)
Account Upgraded | Title Enabled!
 
airflow0's Avatar
 
Rank: Member +
Join Date: Sep 2006
Posts: 648
Thanked 0 Times in 0 Posts

Re: [RELEASE] In-game Auto Register (ODIN)

*Moved to main post.

Last edited by airflow0; 07-05-2008 at 02:35 PM.
airflow0 is offline  
Old 07-05-2008   #9 (permalink)
Ultimate Member
 
Rank: Member
Join Date: May 2008
Location: Israel
Posts: 168
Thanked 0 Times in 0 Posts

Re: [RELEASE] In-game Auto Register (ODIN)

Originally Posted by Dragon-KinG View Post
where are the int login?
help?,..,

Quote:
Add this under public int login
__________________
Dragon-KinG is offline  
Old 07-05-2008   #10 (permalink)
Account Upgraded | Title Enabled!
 
airflow0's Avatar
 
Rank: Member +
Join Date: Sep 2006
Posts: 648
Thanked 0 Times in 0 Posts

Re: [RELEASE] In-game Auto Register (ODIN)

public int login is in your MapleClient.java.

Add the code to the correct area..
airflow0 is offline  
Old 07-05-2008   #11 (permalink)
Account Upgraded | Title Enabled!
 
pr0666's Avatar
 
Rank: Member +
Join Date: Jun 2008
Location: Holland :P
Posts: 301
Thanked 0 Times in 0 Posts

Re: [RELEASE] In-game Auto Register (ODIN)

thx!
__________________
RageZone FTW!!!!!!
pr0666 is offline  
Old 07-05-2008   #12 (permalink)
Account Upgraded | Title Enabled!
 
pr0666's Avatar
 
Rank: Member +
Join Date: Jun 2008
Location: Holland :P
Posts: 301
Thanked 0 Times in 0 Posts

Talking Re: [RELEASE] In-game Auto Register (ODIN)

Originally Posted by airflow0 View Post
public int login is in your MapleClient.java.

Add the code to the correct area..
ill think he means in wht line can i find public int login =)
__________________
RageZone FTW!!!!!!
pr0666 is offline  
Old 07-05-2008   #13 (permalink)
Account Upgraded | Title Enabled!
 
airflow0's Avatar
 
Rank: Member +
Join Date: Sep 2006
Posts: 648
Thanked 0 Times in 0 Posts

Re: [RELEASE] In-game Auto Register (ODIN)

Quote:
Originally Posted by Dragon-KinG View Post
where are the int login?
help?,..,

Quote:
Add this under public int login
Add this under the entire public int login function

Would someone mind testing the multiple ip functions?? :(
airflow0 is offline  
Old 07-05-2008   #14 (permalink)
Account Upgraded | Title Enabled!
 
pr0666's Avatar
 
Rank: Member +
Join Date: Jun 2008
Location: Holland :P
Posts: 301
Thanked 0 Times in 0 Posts

Re: [RELEASE] In-game Auto Register (ODIN)

yay i got it work!!!
__________________
RageZone FTW!!!!!!
pr0666 is offline  
Old 07-05-2008   #15 (permalink)
Account Upgraded | Title Enabled!
 
airflow0's Avatar
 
Rank: Member +
Join Date: Sep 2006
Posts: 648
Thanked 0 Times in 0 Posts

Re: [RELEASE] In-game Auto Register (ODIN)

Did you try the multiple ip functions?
airflow0 is offline  
Old 07-05-2008   #16 (permalink)
 
darkXmatt's Avatar
 
Rank: Member +
Join Date: Jun 2008
Location: Hong Kong
Posts: 340
Thanked 0 Times in 0 Posts

Re: [RELEASE] In-game Auto Register (ODIN)

few words:
Convenient
Useful
Smart

but needs some minor fixes.
i can imagine myself typing wrong ids and making millions of accounts >_> that wouldnt be nice, would it? : P ~

fix it and we'll love it : )

~dXm
__________________



-MacOSX 10.5 User-
Originally Posted by giro58 View Post
Sharing Failure is the best.
darkXmatt is offline  
Old 07-05-2008   #17 (permalink)
Account Upgraded | Title Enabled!
 
airflow0's Avatar
 
Rank: Member +
Join Date: Sep 2006
Posts: 648
Thanked 0 Times in 0 Posts

Re: [RELEASE] In-game Auto Register (ODIN)

Well as soon as someone tests the new functions I created and reports bugs, it will be fixed.. *COUGH* Added updated insert that should hash the password when the account is created.
airflow0 is offline  
Old 07-05-2008   #18 (permalink)
Ultimate Member
 
Rank: Member
Join Date: May 2008
Location: Israel
Posts: 168
Thanked 0 Times in 0 Posts

Re: [RELEASE] In-game Auto Register (ODIN)

it's not work for me....
=(
__________________
Dragon-KinG is offline  
Old 07-05-2008   #19 (permalink)
 
darkXmatt's Avatar
 
Rank: Member +
Join Date: Jun 2008
Location: Hong Kong
Posts: 340
Thanked 0 Times in 0 Posts

Re: [RELEASE] In-game Auto Register (ODIN)

Originally Posted by Dragon-KinG View Post
it's not work for me....
=(
Did you compile after you edited the files?
If you did, did you make sure you did it correctly?

~dXm
__________________



-MacOSX 10.5 User-
Originally Posted by giro58 View Post
Sharing Failure is the best.
darkXmatt is offline  
Old 07-05-2008   #20 (permalink)
Average Member
 
Rank: Hobbit
Join Date: Jul 2008
Posts: 71
Thanked 0 Times in 0 Posts

Re: [RELEASE] In-game Auto Register (ODIN)

Quote:
i can imagine myself typing wrong ids and making millions of accounts >_> that wouldnt be nice, would it? : P ~
Maybe someone could code / create a programm that auto deletes all accounts without any characters in it (every 2days or something like that) , if that's even possible o.o
InsaneFlaw is offline  
Old 07-05-2008   #21 (permalink)
Account Upgraded | Title Enabled!
 
airflow0's Avatar
 
Rank: Member +
Join Date: Sep 2006
Posts: 648
Thanked 0 Times in 0 Posts

Re: [RELEASE] In-game Auto Register (ODIN)

I could write up an auto account deletion function that removes all accounts that havent had a login attempt for 30 days after this is done unless someone beats me to it. Would be quite easy to do.
airflow0 is offline  
Old 07-05-2008   #22 (permalink)
Ultimate Member
 
Rank: Member
Join Date: May 2008
Location: Israel
Posts: 168
Thanked 0 Times in 0 Posts

Re: [RELEASE] In-game Auto Register (ODIN)

Originally Posted by darkXmatt View Post
Did you compile after you edited the files?
If you did, did you make sure you did it correctly?

~dXm
yes...
and i think yes...
__________________
Dragon-KinG is offline  
Old 07-05-2008   #23 (permalink)
Average Member
 
Rank: Hobbit
Join Date: Jul 2008
Posts: 62
Thanked 0 Times in 0 Posts

Re: [RELEASE] In-game Auto Register (ODIN)

The best solution to solve those people who does not get the In-game auto registration to work is to upload a working complied MapleCilent.java file up here.
bloodinstinct is offline  
Old 07-05-2008   #24 (permalink)
Newbie
 
Rank: Hobbit
Join Date: Jun 2008
Posts: 12
Thanked 0 Times in 0 Posts

Re: [RELEASE] In-game Auto Register (ODIN)

Originally Posted by bloodinstinct View Post
The best solution to solve those people who does not get the In-game auto registration to work is to upload a working complied MapleCilent.java file up here.
i like that idea...i have no idea how to use this ><
hahaudied is offline  
Old 07-05-2008   #25 (permalink)
Owner of RLVHosting
 
keroh93's Avatar
 
Rank: Member +
Join Date: Apr 2008
Location: Las Vegas
Posts: 1,233
Thanked 2 Times in 1 Post

Re: [RELEASE] In-game Auto Register (ODIN)

hey air how would i change how many accounts can be made through that ip address?
Do i change this?


private ResultSet checkMultiIp(String ip) {
try {
Connection con = DatabaseConnection.getConnection();
PreparedStatement ps = con.prepareStatement("SELECT * FROM iplog where ip = ?");
ps.setString(1, ip);
return ps.executeQuery();
} catch (Exception none) {
return null;
}
}


Do I change

ps.setString(1, ip);

Into

ps.setString(2, ip);
__________________

Studio Ghibli Films - Full Movies
http://www.rlvhosting.com
keroh93 is offline  
 

Bookmarks

Thread Tools


LinkBacks (?)
LinkBack to this Thread: http://forum.ragezone.com/f427/release-in-game-auto-register-auto-login-425749/
Posted By For Type Date
[ ODInMs ] This thread Refback 08-07-2009 07:40 AM
maplestory libary This thread Refback 08-01-2009 03:42 AM
[Release] working auto register for odinteh v.60 - Flowsion.net - Social Community for Gamers This thread Refback 07-11-2009 12:02 PM
[ ODInMs ] This thread Refback 06-09-2009 08:31 PM
[ ODInMs ] This thread Refback 05-17-2009 10:39 AM
[ ODInMs ] This thread Refback 05-01-2009 03:48 PM
[ ODInMs ] This thread Refback 04-30-2009 02:31 PM
[Release] [Library of Useful OdinMS Stuff] [Fixes] [Guides] [Registration Pages] - GameCheetah This thread Refback 03-31-2009 05:20 AM
[OdinMS]Releases,Guides,Repacks,Revs,orials,HTML-PHP,Tools,Handbook - Maplestory Releases - ServerFiles.org This thread Refback 03-29-2009 12:07 AM
[ ODInMs ] This thread Refback 03-28-2009 11:31 AM
OdinMS Source Releases,Guides,Repacks,Revs,Tutorials,HTML-PHP,Tools,Handbook - GameCheetah This thread Refback 03-25-2009 06:16 PM



Translated by Google
Albanian Arabic Belarusian Bulgarian Catalan Chinese Croatian Czech Danish Dutch English Estonian Filipino Finnish French Galician German Greek Hebrew Hindi Hungarian Icelandic Indonesian Italian Japanese Korean Latvian Lithuanian Maltese Norwegian Polish Portuguese Romanian Russian Serbian Slovak Slovenian Spanish Swedish Taiwanese Thai Turkish Ukrainian Vietnamese
no new posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274