Updated accounts SQL table to match other branches.
This commit is contained in:
parent
ceb1549b84
commit
dfc25d6642
@ -3,10 +3,12 @@
|
||||
-- ---------------------------
|
||||
CREATE TABLE IF NOT EXISTS `accounts` (
|
||||
`login` VARCHAR(45) NOT NULL default '',
|
||||
`password` VARCHAR(45) ,
|
||||
`lastactive` DECIMAL(20),
|
||||
`access_level` INT,
|
||||
`lastIP` VARCHAR(20),
|
||||
`lastServer` int(4) default 1,
|
||||
`password` VARCHAR(45),
|
||||
`email` varchar(255) DEFAULT NULL,
|
||||
`created_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
`lastactive` bigint(13) unsigned NOT NULL DEFAULT '0',
|
||||
`accessLevel` TINYINT NOT NULL DEFAULT 0,
|
||||
`lastIP` CHAR(15) NULL DEFAULT NULL,
|
||||
`lastServer` TINYINT DEFAULT 1,
|
||||
PRIMARY KEY (`login`)
|
||||
);
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
@ -513,7 +513,7 @@ public class LoginController
|
||||
{
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection())
|
||||
{
|
||||
final String stmt = "UPDATE accounts SET access_level=? WHERE login=?";
|
||||
final String stmt = "UPDATE accounts SET accessLevel=? WHERE login=?";
|
||||
PreparedStatement statement = con.prepareStatement(stmt);
|
||||
statement.setInt(1, banLevel);
|
||||
statement.setString(2, account);
|
||||
@ -531,7 +531,7 @@ public class LoginController
|
||||
boolean ok = false;
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection())
|
||||
{
|
||||
PreparedStatement statement = con.prepareStatement("SELECT access_level FROM accounts WHERE login=?");
|
||||
PreparedStatement statement = con.prepareStatement("SELECT accessLevel FROM accounts WHERE login=?");
|
||||
statement.setString(1, user);
|
||||
ResultSet rset = statement.executeQuery();
|
||||
|
||||
@ -595,14 +595,14 @@ public class LoginController
|
||||
int access = 0;
|
||||
int lastServer = 1;
|
||||
|
||||
PreparedStatement statement = con.prepareStatement("SELECT password, access_level, lastServer FROM accounts WHERE login=?");
|
||||
PreparedStatement statement = con.prepareStatement("SELECT password, accessLevel, lastServer FROM accounts WHERE login=?");
|
||||
statement.setString(1, user);
|
||||
ResultSet rset = statement.executeQuery();
|
||||
|
||||
if (rset.next())
|
||||
{
|
||||
expected = Base64.getDecoder().decode(rset.getString("password"));
|
||||
access = rset.getInt("access_level");
|
||||
access = rset.getInt("accessLevel");
|
||||
lastServer = rset.getInt("lastServer");
|
||||
|
||||
if (lastServer <= 0)
|
||||
@ -628,7 +628,7 @@ public class LoginController
|
||||
{
|
||||
if ((user != null) && ((user.length()) >= 2) && (user.length() <= 14))
|
||||
{
|
||||
statement = con.prepareStatement("INSERT INTO accounts (login,password,lastactive,access_level,lastIP) values(?,?,?,?,?)");
|
||||
statement = con.prepareStatement("INSERT INTO accounts (login,password,lastactive,accessLevel,lastIP) values(?,?,?,?,?)");
|
||||
statement.setString(1, user);
|
||||
statement.setString(2, Base64.getEncoder().encodeToString(hash));
|
||||
statement.setLong(3, System.currentTimeMillis());
|
||||
@ -723,7 +723,7 @@ public class LoginController
|
||||
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection())
|
||||
{
|
||||
PreparedStatement statement = con.prepareStatement("SELECT access_level FROM accounts WHERE login=?");
|
||||
PreparedStatement statement = con.prepareStatement("SELECT accessLevel FROM accounts WHERE login=?");
|
||||
statement.setString(1, user);
|
||||
ResultSet rset = statement.executeQuery();
|
||||
|
||||
|
@ -162,18 +162,18 @@ public class SQLAccountManager
|
||||
int count = 0;
|
||||
Connection con = null;
|
||||
con = DatabaseFactory.getInstance().getConnection();
|
||||
String q = "SELECT login, access_level FROM accounts ";
|
||||
String q = "SELECT login, accessLevel FROM accounts ";
|
||||
if (m.equals("1"))
|
||||
{
|
||||
q = q.concat("WHERE access_level < 0");
|
||||
q = q.concat("WHERE accessLevel < 0");
|
||||
}
|
||||
else if (m.equals("2"))
|
||||
{
|
||||
q = q.concat("WHERE access_level > 0");
|
||||
q = q.concat("WHERE accessLevel > 0");
|
||||
}
|
||||
else if (m.equals("3"))
|
||||
{
|
||||
q = q.concat("WHERE access_level = 0");
|
||||
q = q.concat("WHERE accessLevel = 0");
|
||||
}
|
||||
q = q.concat(" ORDER BY login ASC");
|
||||
|
||||
@ -181,7 +181,7 @@ public class SQLAccountManager
|
||||
ResultSet rset = statement.executeQuery();
|
||||
while (rset.next())
|
||||
{
|
||||
System.out.println(rset.getString("login") + " -> " + rset.getInt("access_level"));
|
||||
System.out.println(rset.getString("login") + " -> " + rset.getInt("accessLevel"));
|
||||
count++;
|
||||
}
|
||||
rset.close();
|
||||
@ -201,7 +201,7 @@ public class SQLAccountManager
|
||||
// Add to Base
|
||||
Connection con = null;
|
||||
con = DatabaseFactory.getInstance().getConnection();
|
||||
PreparedStatement statement = con.prepareStatement("REPLACE accounts (login, password, access_level) VALUES (?,?,?)");
|
||||
PreparedStatement statement = con.prepareStatement("REPLACE accounts (login, password, accessLevel) VALUES (?,?,?)");
|
||||
statement.setString(1, account);
|
||||
statement.setString(2, Base64.getEncoder().encodeToString(newpass));
|
||||
statement.setString(3, level);
|
||||
@ -227,7 +227,7 @@ public class SQLAccountManager
|
||||
{
|
||||
// Exist
|
||||
// Update
|
||||
statement = con.prepareStatement("UPDATE accounts SET access_level=? WHERE login=?;");
|
||||
statement = con.prepareStatement("UPDATE accounts SET accessLevel=? WHERE login=?;");
|
||||
statement.setEscapeProcessing(true);
|
||||
statement.setString(1, level);
|
||||
statement.setString(2, account);
|
||||
|
Loading…
Reference in New Issue
Block a user