-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvBulletin.java
156 lines (138 loc) · 4.58 KB
/
vBulletin.java
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
/**************************************************************************
* This file is part of MCbb.
* MCbb is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* MCbb 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 General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with MCbb. If not, see <http://www.gnu.org/licenses/>.
*************************************************************************/
import java.sql.ResultSet;
import java.sql.SQLException;
import de.javakara.manf.software.Software;
import de.javakara.manf.software.User;
import de.javakara.manf.util.EncryptionManager;
public class vBulletin extends Software {
@Override
public String getForumGroup(User user) {
try {
int gid = user.getGroupId();
if (gid != 0) {
ResultSet rs = database.executeQuery("SELECT servergroup FROM "
+ this.config.getString("mysql.prefix")
+ "usergroup WHERE usergroupid='" + gid + "'");
if (rs.next()) {
return rs.getString("servergroup");
}
} else {
System.out.println("[MCbb] Sorry... Theres a fail in there!");
}
} catch (SQLException e) {
System.out.println("ForumUserError: " + e.toString());
}
System.out.println("User Forum Group not recognised!");
return null;
}
@Override
public int getNewPosts() {
return 0;
}
@Override
protected boolean isRegisteredOld(User user) {
try {
ResultSet rs = database.executeQuery("SELECT userid,username,usergroupid FROM "
+ this.config.getString("mysql.prefix")
+ "user WHERE username="
+ "lower('" + user.getName() + "')"
+ " LIMIT 1");
if (rs.next()) {
int id = rs.getInt("userid");
int gid = rs.getInt("usergroupid");
user.setGroupId(gid);
user.setUserId(id);
return (gid != 8);
}
} catch (SQLException e) {
System.out.println("Qwertzy2");
e.printStackTrace();
}
return false;
}
@Override
protected boolean isCustomFieldRegistered(User user) {
try {
ResultSet rs = database.executeQuery("SELECT userid FROM "
+ this.config.getString("mysql.prefix")
+ "userfield WHERE field" + this.config.getString("field.id") + "'"
+ user.getName() + "' LIMIT 1");
if (rs.next()) {
int id = rs.getInt("userid");
user.setUserId(id);
rs = database.executeQuery("SELECT username,usergroupid FROM "
+ this.config.getString("mysql.prefix")
+ "user WHERE userid='" + id + "' LIMIT 1");
if (rs.next()) {
int gid= rs.getInt("usergroupid");
user.setGroupId(gid);
return (gid != 8);
}
}
} catch (Exception e) {
e.printStackTrace();
}
return false;
}
@Override
public boolean isPasswordCorrect(User user,String password) {
try {
ResultSet rs;
switch (authType) {
case 0:
rs = database.executeQuery("SELECT password,salt FROM "
+ this.config.getString("mysql.prefix")
+ "user WHERE username="
+ "lower('" + user.getName() + "')"
+ " LIMIT 1");
break;
case 1:
int id = user.getId();
if(id == 0){
rs = database.executeQuery("SELECT userid FROM "
+ this.config.getString("mysql.prefix")
+ "userfield WHERE field" + this.config.getString("field.id") + "'"
+ user.getName() + "' LIMIT 1");
if (rs.next()) {
id = rs.getInt("userid");
}
}
rs = database.executeQuery("SELECT password,salt FROM "
+ this.config.getString("mysql.prefix")
+ "user WHERE userid='" + id + "' LIMIT 1");
break;
default:
return false;
}
if (rs.next()) {
String realpassword = rs.getString("password");
String salt = rs.getString("salt");
return realpassword.equals(sha256(sha256(password) + salt));
}
} catch (SQLException e) {
e.printStackTrace();
} catch (NumberFormatException e) {
e.printStackTrace();
}
return false;
}
private String sha256(String input) {
return EncryptionManager.sha256(input);
}
@Override
protected String getName() {
return "vBulletin";
}
}