My pserver Prob
2 posters
BetaStory V75 :: Support :: Bugs :: Resolved
Page 1 of 1
My pserver Prob
- Code:
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 = 5;
public static final boolean autoRegister = false;
public static boolean success;
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) {
}
return accountExists;
}
public static void createAccount(String login, String pwd, String eip) {
String sockAddr = eip;
Connection con;
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, "0000-00-00");
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) {
}
}
}
Please Help
Frosti- Gamemaster
- Posts : 38
Reputation : 0
Join date : 2010-01-25
Age : 30
Re: My pserver Prob
Change
To
(name, password, email, birthday, macs, lastknownip) VALUES (?, ?, ?, ?, ?, ?)
And change
(name, password, email, birthday, lastknownip) VALUES (?, ?, ?, ?, ?)
To
ps.setString(5, "00-00-00-00-00-00");
ps.setString(6, sockAddr.substring(1, sockAddr.lastIndexOf(':')));
ps.setString(5, sockAddr.substring(1, sockAddr.lastIndexOf(':')));
Stealth- Admin
- Posts : 262
Reputation : 14
Join date : 2010-01-21
Age : 31
Location : Canada, Alberta
BetaStory V75 :: Support :: Bugs :: Resolved
Page 1 of 1
Permissions in this forum:
You cannot reply to topics in this forum