Spaces:
Paused
Paused
htr
commited on
Commit
·
dfb239e
1
Parent(s):
d781d0d
up set cookie
Browse files- Dockerfile +1 -0
- cronjob_78184.html +1 -0
- src/main/java/com/example/demo/DemoApplication.java +5 -18
- src/main/java/tqtk/Entity/SessionEntity.java +11 -1
- src/main/java/tqtk/Tqtk.java +4 -0
- src/main/java/tqtk/Utils/Util.java +360 -88
- src/main/java/tqtk/XuLy/Worker.java +96 -135
- src/main/java/tqtk/XuLy/XuLyPacket.java +34 -25
- src/main/resources/application.properties +2 -2
Dockerfile
CHANGED
|
@@ -12,6 +12,7 @@ FROM openjdk:11-jdk-slim
|
|
| 12 |
COPY --from=build /target/demo-0.0.1-SNAPSHOT.jar demo.jar
|
| 13 |
COPY --from=build /user.properties user.properties
|
| 14 |
COPY --from=build /truyna.properties truyna.properties
|
|
|
|
| 15 |
# ENV PORT=8080
|
| 16 |
EXPOSE 8081
|
| 17 |
ENTRYPOINT ["java","-Dfile.encoding=UTF-8","-jar","demo.jar"]
|
|
|
|
| 12 |
COPY --from=build /target/demo-0.0.1-SNAPSHOT.jar demo.jar
|
| 13 |
COPY --from=build /user.properties user.properties
|
| 14 |
COPY --from=build /truyna.properties truyna.properties
|
| 15 |
+
COPY --from=build /cronjob_78184.html cronjob_78184.html
|
| 16 |
# ENV PORT=8080
|
| 17 |
EXPOSE 8081
|
| 18 |
ENTRYPOINT ["java","-Dfile.encoding=UTF-8","-jar","demo.jar"]
|
cronjob_78184.html
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
cronjob.de
|
src/main/java/com/example/demo/DemoApplication.java
CHANGED
|
@@ -79,6 +79,11 @@ public class DemoApplication {
|
|
| 79 |
}
|
| 80 |
return "ok";
|
| 81 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 82 |
|
| 83 |
@RequestMapping(value = "/stopAll", method = RequestMethod.GET)
|
| 84 |
@ResponseBody
|
|
@@ -117,24 +122,6 @@ public class DemoApplication {
|
|
| 117 |
return "ok";
|
| 118 |
}
|
| 119 |
|
| 120 |
-
|
| 121 |
-
@RequestMapping(value = "/resumeOne", method = RequestMethod.GET)
|
| 122 |
-
@ResponseBody
|
| 123 |
-
public String resumeOne(@RequestParam(value = "id", required = true) String id) throws IOException, UnknownHostException, InterruptedException, Exception {
|
| 124 |
-
try {
|
| 125 |
-
|
| 126 |
-
for (int i = 0; i < Tqtk.listWorker.size(); ++i) {
|
| 127 |
-
if (id.equals(Tqtk.listWorker.get(i).getSs().getUserId())) {
|
| 128 |
-
|
| 129 |
-
Tqtk.listWorker.get(i).createSocket1(Tqtk.listWorker.get(i).getSs());
|
| 130 |
-
|
| 131 |
-
}
|
| 132 |
-
}
|
| 133 |
-
} catch (Exception e) {
|
| 134 |
-
return e.getMessage();
|
| 135 |
-
}
|
| 136 |
-
return "ok";
|
| 137 |
-
}
|
| 138 |
|
| 139 |
@RequestMapping(value = "/updateInfo", method = RequestMethod.GET)
|
| 140 |
@ResponseBody
|
|
|
|
| 79 |
}
|
| 80 |
return "ok";
|
| 81 |
}
|
| 82 |
+
|
| 83 |
+
@GetMapping("cronjob_78184.html")
|
| 84 |
+
public String cronjob_78184() throws Exception {
|
| 85 |
+
return "cronjob.de";
|
| 86 |
+
}
|
| 87 |
|
| 88 |
@RequestMapping(value = "/stopAll", method = RequestMethod.GET)
|
| 89 |
@ResponseBody
|
|
|
|
| 122 |
return "ok";
|
| 123 |
}
|
| 124 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 125 |
|
| 126 |
@RequestMapping(value = "/updateInfo", method = RequestMethod.GET)
|
| 127 |
@ResponseBody
|
src/main/java/tqtk/Entity/SessionEntity.java
CHANGED
|
@@ -37,6 +37,8 @@ public class SessionEntity {
|
|
| 37 |
List<String> SkillIds = new ArrayList();
|
| 38 |
@JsonProperty("LinhThuKoHa")
|
| 39 |
List<String> LinhThuKoHa = new ArrayList();
|
|
|
|
|
|
|
| 40 |
|
| 41 |
private Socket socket;
|
| 42 |
private boolean isConnected;
|
|
@@ -124,7 +126,6 @@ public class SessionEntity {
|
|
| 124 |
this.SkillIds = SkillIds;
|
| 125 |
}
|
| 126 |
|
| 127 |
-
|
| 128 |
public Socket getSocketApi() {
|
| 129 |
return socketApi;
|
| 130 |
}
|
|
@@ -175,4 +176,13 @@ public class SessionEntity {
|
|
| 175 |
public void setMessage(StringBuilder message) {
|
| 176 |
this.message = message;
|
| 177 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 178 |
}
|
|
|
|
| 37 |
List<String> SkillIds = new ArrayList();
|
| 38 |
@JsonProperty("LinhThuKoHa")
|
| 39 |
List<String> LinhThuKoHa = new ArrayList();
|
| 40 |
+
@JsonProperty("cookie")
|
| 41 |
+
String Cookie;
|
| 42 |
|
| 43 |
private Socket socket;
|
| 44 |
private boolean isConnected;
|
|
|
|
| 126 |
this.SkillIds = SkillIds;
|
| 127 |
}
|
| 128 |
|
|
|
|
| 129 |
public Socket getSocketApi() {
|
| 130 |
return socketApi;
|
| 131 |
}
|
|
|
|
| 176 |
public void setMessage(StringBuilder message) {
|
| 177 |
this.message = message;
|
| 178 |
}
|
| 179 |
+
|
| 180 |
+
public String getCookie() {
|
| 181 |
+
return Cookie;
|
| 182 |
+
}
|
| 183 |
+
|
| 184 |
+
public void setCookie(String Cookie) {
|
| 185 |
+
this.Cookie = Cookie;
|
| 186 |
+
}
|
| 187 |
+
|
| 188 |
}
|
src/main/java/tqtk/Tqtk.java
CHANGED
|
@@ -37,6 +37,7 @@ public class Tqtk {
|
|
| 37 |
public static List<User_test> listUser = new ArrayList<>();
|
| 38 |
public static List<SessionEntity> listSession = new ArrayList<>();
|
| 39 |
public static List<Worker> listWorker = new ArrayList<>();
|
|
|
|
| 40 |
|
| 41 |
static {
|
| 42 |
loaiTruyna = Collections.synchronizedList(loaiTruyna);
|
|
@@ -44,6 +45,7 @@ public class Tqtk {
|
|
| 44 |
listtruyna = Collections.synchronizedList(listtruyna);
|
| 45 |
listUser = Collections.synchronizedList(listUser);
|
| 46 |
listSession = Collections.synchronizedList(listSession);
|
|
|
|
| 47 |
}
|
| 48 |
|
| 49 |
public static void main() {
|
|
@@ -51,8 +53,10 @@ public class Tqtk {
|
|
| 51 |
try {
|
| 52 |
listSession = Util.setData1(listSession);
|
| 53 |
loaiTruyna = Util.docFileTruyNa("truyna.properties");
|
|
|
|
| 54 |
|
| 55 |
for (int i = 0; i < listSession.size(); ++i) {
|
|
|
|
| 56 |
Worker worker = new Worker(listSession.get(i));
|
| 57 |
worker.setLock(new Object());
|
| 58 |
listWorker.add((Worker) worker);
|
|
|
|
| 37 |
public static List<User_test> listUser = new ArrayList<>();
|
| 38 |
public static List<SessionEntity> listSession = new ArrayList<>();
|
| 39 |
public static List<Worker> listWorker = new ArrayList<>();
|
| 40 |
+
public static List<String> cauhoithuthue = new ArrayList<>();
|
| 41 |
|
| 42 |
static {
|
| 43 |
loaiTruyna = Collections.synchronizedList(loaiTruyna);
|
|
|
|
| 45 |
listtruyna = Collections.synchronizedList(listtruyna);
|
| 46 |
listUser = Collections.synchronizedList(listUser);
|
| 47 |
listSession = Collections.synchronizedList(listSession);
|
| 48 |
+
cauhoithuthue = Collections.synchronizedList(cauhoithuthue);
|
| 49 |
}
|
| 50 |
|
| 51 |
public static void main() {
|
|
|
|
| 53 |
try {
|
| 54 |
listSession = Util.setData1(listSession);
|
| 55 |
loaiTruyna = Util.docFileTruyNa("truyna.properties");
|
| 56 |
+
cauhoithuthue = Util.docFileTruyNa("user.properties");
|
| 57 |
|
| 58 |
for (int i = 0; i < listSession.size(); ++i) {
|
| 59 |
+
listSession.get(i).setSessionKey(Util.getSessiongId(listSession.get(i).getCookie()));
|
| 60 |
Worker worker = new Worker(listSession.get(i));
|
| 61 |
worker.setLock(new Object());
|
| 62 |
listWorker.add((Worker) worker);
|
src/main/java/tqtk/Utils/Util.java
CHANGED
|
@@ -35,6 +35,8 @@ import org.apache.commons.lang3.StringUtils;
|
|
| 35 |
import tqtk.Entity.SessionEntity;
|
| 36 |
import java.io.FileReader;
|
| 37 |
import java.util.Iterator;
|
|
|
|
|
|
|
| 38 |
import org.apache.http.util.ByteArrayBuffer;
|
| 39 |
import org.json.simple.JSONArray;
|
| 40 |
import org.json.simple.JSONObject;
|
|
@@ -47,22 +49,22 @@ import tqtk.Entity.Accounts;
|
|
| 47 |
* @author Alex
|
| 48 |
*/
|
| 49 |
public class Util {
|
| 50 |
-
|
| 51 |
public CookieManager msCookieManager = null;
|
| 52 |
-
|
| 53 |
public Util() {
|
| 54 |
msCookieManager = new CookieManager();
|
| 55 |
}
|
| 56 |
-
|
| 57 |
public void setCookie(CookieManager msCookieManager) {
|
| 58 |
CookieHandler.setDefault(msCookieManager);
|
| 59 |
}
|
| 60 |
-
|
| 61 |
public String getPageSource(String url) throws Exception {
|
| 62 |
HttpURLConnection con = null;
|
| 63 |
try {
|
| 64 |
URL obj = new URL(url);
|
| 65 |
-
|
| 66 |
String pro = obj.getProtocol();
|
| 67 |
if (pro.equals("http")) {
|
| 68 |
con = (HttpURLConnection) obj.openConnection();
|
|
@@ -76,10 +78,10 @@ public class Util {
|
|
| 76 |
con.setRequestProperty("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36");
|
| 77 |
con.setUseCaches(false);
|
| 78 |
con.setDoOutput(true);
|
| 79 |
-
|
| 80 |
int responseCode = con.getResponseCode();
|
| 81 |
if (200 <= responseCode && responseCode <= 399) {
|
| 82 |
-
|
| 83 |
BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream(), "UTF-8"));
|
| 84 |
StringBuffer response = new StringBuffer();
|
| 85 |
String inputLine;
|
|
@@ -87,13 +89,13 @@ public class Util {
|
|
| 87 |
response.append(inputLine);
|
| 88 |
}
|
| 89 |
in.close();
|
| 90 |
-
|
| 91 |
return response.toString();
|
| 92 |
-
|
| 93 |
} else {
|
| 94 |
return "Hệ thống đang quá tải vui lòng";
|
| 95 |
}
|
| 96 |
-
|
| 97 |
} catch (Exception e) {
|
| 98 |
if (e instanceof SocketTimeoutException) {
|
| 99 |
throw new SocketTimeoutException("");
|
|
@@ -101,7 +103,7 @@ public class Util {
|
|
| 101 |
throw e;
|
| 102 |
}
|
| 103 |
}
|
| 104 |
-
|
| 105 |
public static String getToken(String htmlCode) {
|
| 106 |
String prefix = "name=\"_token\" value=\"";
|
| 107 |
int index = htmlCode.indexOf(prefix);
|
|
@@ -109,7 +111,7 @@ public class Util {
|
|
| 109 |
// Could not find the prefix string.
|
| 110 |
return null;
|
| 111 |
}
|
| 112 |
-
|
| 113 |
index += prefix.length();
|
| 114 |
|
| 115 |
// Login token has a fixed length of 40.
|
|
@@ -118,11 +120,11 @@ public class Util {
|
|
| 118 |
// Given html code is not long enough.
|
| 119 |
return null;
|
| 120 |
}
|
| 121 |
-
|
| 122 |
String token = htmlCode.substring(index, index + TokenLength);
|
| 123 |
return token;
|
| 124 |
}
|
| 125 |
-
|
| 126 |
public static String getRefer(String htmlCode) throws UnsupportedEncodingException {
|
| 127 |
String prefix = "action=\"";
|
| 128 |
int prefixIndex = htmlCode.indexOf(prefix);
|
|
@@ -132,19 +134,19 @@ public class Util {
|
|
| 132 |
}
|
| 133 |
String suffix = "\" accept-charset";
|
| 134 |
int suffixIndex = htmlCode.indexOf(suffix);
|
| 135 |
-
|
| 136 |
int beginIndex = prefixIndex + prefix.length();
|
| 137 |
int endIndex = suffixIndex;
|
| 138 |
String address = htmlCode.substring(beginIndex, endIndex);
|
| 139 |
String result = java.net.URLDecoder.decode(address, StandardCharsets.UTF_8.toString());
|
| 140 |
return result.replace("&", "&");
|
| 141 |
}
|
| 142 |
-
|
| 143 |
public String dangNhap(String url, String user, String pass, String token, String Refer) throws Exception {
|
| 144 |
HttpURLConnection con = null;
|
| 145 |
try {
|
| 146 |
URL obj = new URL(Refer);
|
| 147 |
-
|
| 148 |
String pro = obj.getProtocol();
|
| 149 |
if (pro.equals("http")) {
|
| 150 |
con = (HttpURLConnection) obj.openConnection();
|
|
@@ -164,14 +166,14 @@ public class Util {
|
|
| 164 |
con.setRequestProperty("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
|
| 165 |
con.setUseCaches(false);
|
| 166 |
con.setDoOutput(true);
|
| 167 |
-
|
| 168 |
DataOutputStream wr = new DataOutputStream(con.getOutputStream());
|
| 169 |
wr.write(postData);
|
| 170 |
wr.flush();
|
| 171 |
wr.close();
|
| 172 |
int responseCode = con.getResponseCode();
|
| 173 |
if (200 <= responseCode && responseCode <= 399) {
|
| 174 |
-
|
| 175 |
BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream(), "UTF-8"));
|
| 176 |
StringBuffer response = new StringBuffer();
|
| 177 |
String inputLine;
|
|
@@ -179,13 +181,13 @@ public class Util {
|
|
| 179 |
response.append(inputLine);
|
| 180 |
}
|
| 181 |
in.close();
|
| 182 |
-
|
| 183 |
return response.toString();
|
| 184 |
-
|
| 185 |
} else {
|
| 186 |
return "Hệ thống đang quá tải vui lòng";
|
| 187 |
}
|
| 188 |
-
|
| 189 |
} catch (Exception e) {
|
| 190 |
if (e instanceof SocketTimeoutException) {
|
| 191 |
throw new SocketTimeoutException("");
|
|
@@ -193,12 +195,12 @@ public class Util {
|
|
| 193 |
throw e;
|
| 194 |
}
|
| 195 |
}
|
| 196 |
-
|
| 197 |
public String getThongTinFrame(String url) throws Exception {
|
| 198 |
HttpURLConnection con = null;
|
| 199 |
try {
|
| 200 |
URL obj = new URL(url);
|
| 201 |
-
|
| 202 |
String pro = obj.getProtocol();
|
| 203 |
if (pro.equals("http")) {
|
| 204 |
con = (HttpURLConnection) obj.openConnection();
|
|
@@ -212,10 +214,10 @@ public class Util {
|
|
| 212 |
// con.setRequestProperty("Upgrade-Insecure-Requests", "1");
|
| 213 |
con.setUseCaches(false);
|
| 214 |
con.setDoOutput(true);
|
| 215 |
-
|
| 216 |
int responseCode = con.getResponseCode();
|
| 217 |
if (200 <= responseCode && responseCode <= 399) {
|
| 218 |
-
|
| 219 |
BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream(), "UTF-8"));
|
| 220 |
StringBuffer response = new StringBuffer();
|
| 221 |
String inputLine;
|
|
@@ -223,13 +225,13 @@ public class Util {
|
|
| 223 |
response.append(inputLine);
|
| 224 |
}
|
| 225 |
in.close();
|
| 226 |
-
|
| 227 |
return response.toString();
|
| 228 |
-
|
| 229 |
} else {
|
| 230 |
return "Hệ thống đang quá tải vui lòng";
|
| 231 |
}
|
| 232 |
-
|
| 233 |
} catch (Exception e) {
|
| 234 |
if (e instanceof SocketTimeoutException) {
|
| 235 |
throw new SocketTimeoutException("");
|
|
@@ -237,12 +239,12 @@ public class Util {
|
|
| 237 |
throw e;
|
| 238 |
}
|
| 239 |
}
|
| 240 |
-
|
| 241 |
public String getThongTinPort(String url) throws Exception {
|
| 242 |
HttpURLConnection con = null;
|
| 243 |
try {
|
| 244 |
URL obj = new URL(url);
|
| 245 |
-
|
| 246 |
String pro = obj.getProtocol();
|
| 247 |
if (pro.equals("http")) {
|
| 248 |
con = (HttpURLConnection) obj.openConnection();
|
|
@@ -257,10 +259,10 @@ public class Util {
|
|
| 257 |
con.setRequestProperty("Upgrade-Insecure-Requests", "1");
|
| 258 |
con.setUseCaches(false);
|
| 259 |
con.setDoOutput(true);
|
| 260 |
-
|
| 261 |
int responseCode = con.getResponseCode();
|
| 262 |
if (200 <= responseCode && responseCode <= 399) {
|
| 263 |
-
|
| 264 |
BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream(), "UTF-8"));
|
| 265 |
StringBuffer response = new StringBuffer();
|
| 266 |
String inputLine;
|
|
@@ -269,11 +271,11 @@ public class Util {
|
|
| 269 |
}
|
| 270 |
in.close();
|
| 271 |
return response.toString();
|
| 272 |
-
|
| 273 |
} else {
|
| 274 |
return "Hệ thống đang quá tải vui lòng";
|
| 275 |
}
|
| 276 |
-
|
| 277 |
} catch (Exception e) {
|
| 278 |
if (e instanceof SocketTimeoutException) {
|
| 279 |
throw new SocketTimeoutException("");
|
|
@@ -281,7 +283,7 @@ public class Util {
|
|
| 281 |
throw e;
|
| 282 |
}
|
| 283 |
}
|
| 284 |
-
|
| 285 |
public static String getFrameString(String htmlCode) throws UnsupportedEncodingException {
|
| 286 |
String prefix = "src=\"";
|
| 287 |
int index = htmlCode.indexOf(prefix);
|
|
@@ -289,40 +291,40 @@ public class Util {
|
|
| 289 |
// Could not find the prefix string.
|
| 290 |
return null;
|
| 291 |
}
|
| 292 |
-
|
| 293 |
index += prefix.length();
|
| 294 |
int suffixIndex = htmlCode.indexOf("\" frameborder");
|
| 295 |
if (suffixIndex == -1) {
|
| 296 |
// Could not find the suffix string.
|
| 297 |
return null;
|
| 298 |
}
|
| 299 |
-
|
| 300 |
String address = htmlCode.substring(index, suffixIndex);
|
| 301 |
return java.net.URLDecoder.decode(address, StandardCharsets.UTF_8.toString()).replace("&", "&");
|
| 302 |
}
|
| 303 |
-
|
| 304 |
public static String getInfoSocket(String htmlCode, String token) {
|
| 305 |
token = token + " : ";
|
| 306 |
int index = htmlCode.indexOf(token);
|
| 307 |
if (index == -1) {
|
| 308 |
return null;
|
| 309 |
}
|
| 310 |
-
|
| 311 |
index += token.length();
|
| 312 |
int suffixIndex = htmlCode.indexOf(",", index);
|
| 313 |
if (suffixIndex == -1) {
|
| 314 |
return null;
|
| 315 |
}
|
| 316 |
-
|
| 317 |
String value = htmlCode.substring(index, suffixIndex);
|
| 318 |
value = value.replaceAll("[\'||\"]", "");
|
| 319 |
return value;
|
| 320 |
}
|
| 321 |
-
|
| 322 |
public static String TaoMsg(String commandId, List<String> list, SessionEntity ss) throws NoSuchAlgorithmException, UnsupportedEncodingException {
|
| 323 |
String what_is_this = "5dcd73d391c90e8769618d42a916ea1b";
|
| 324 |
String input = commandId + ss.getUserId();
|
| 325 |
-
|
| 326 |
String msg = String.format("%s\u0001%s\t%s\u0002", commandId, ss.getUserId(), ss.getSessionKey());
|
| 327 |
Date date = new Date();
|
| 328 |
long millisecondsSinceEpoch = date.getTime();
|
|
@@ -332,17 +334,17 @@ public class Util {
|
|
| 332 |
msg += string + '\t';
|
| 333 |
}
|
| 334 |
}
|
| 335 |
-
|
| 336 |
input += what_is_this;
|
| 337 |
if (list != null && list.size() > 0) {
|
| 338 |
msg = msg.substring(0, msg.length());
|
| 339 |
}
|
| 340 |
-
|
| 341 |
String checksum = hash(input);
|
| 342 |
msg += String.format("\u0003%s\u0004%d\u0005\0", checksum, millisecondsSinceEpoch);
|
| 343 |
return msg;
|
| 344 |
}
|
| 345 |
-
|
| 346 |
public static String hash(String input) throws NoSuchAlgorithmException, UnsupportedEncodingException {
|
| 347 |
MessageDigest md = MessageDigest.getInstance("MD5");
|
| 348 |
byte[] buffer = md.digest(input.getBytes("UTF8"));
|
|
@@ -352,9 +354,9 @@ public class Util {
|
|
| 352 |
}
|
| 353 |
return builder.toString();
|
| 354 |
}
|
| 355 |
-
|
| 356 |
public static Properties loadProperties(String file_name) {
|
| 357 |
-
|
| 358 |
final Properties pr = new Properties();
|
| 359 |
//window
|
| 360 |
// String x = "D:\\7-Project\\Java\\1. Netbean\\2. nghien-cuu\\TQTK\\runshell\\"+file_name;
|
|
@@ -369,7 +371,7 @@ public class Util {
|
|
| 369 |
}
|
| 370 |
return pr;
|
| 371 |
}
|
| 372 |
-
|
| 373 |
public static void setData(String file_name, List<SessionEntity> ss) {
|
| 374 |
org.json.simple.JSONObject jSONObject = null;
|
| 375 |
JSONParser jsonParser = new JSONParser();
|
|
@@ -378,9 +380,9 @@ public class Util {
|
|
| 378 |
try (FileReader reader = new FileReader(x)) {
|
| 379 |
//Read JSON file
|
| 380 |
jSONObject = (org.json.simple.JSONObject) jsonParser.parse(reader);
|
| 381 |
-
|
| 382 |
JSONArray jSONArray = (JSONArray) jSONObject.get("accounts");
|
| 383 |
-
|
| 384 |
for (Iterator it = jSONArray.iterator(); it.hasNext();) {
|
| 385 |
jSONObject = (JSONObject) it.next();
|
| 386 |
SessionEntity s1 = new SessionEntity();
|
|
@@ -390,15 +392,15 @@ public class Util {
|
|
| 390 |
s1.setUserId((String) jSONObject.get("UserId"));
|
| 391 |
ss.add(s1);
|
| 392 |
}
|
| 393 |
-
|
| 394 |
} catch (Exception e) {
|
| 395 |
e.printStackTrace();
|
| 396 |
}
|
| 397 |
}
|
| 398 |
-
|
| 399 |
public static List<SessionEntity> setData1(List<SessionEntity> ss) throws Exception {
|
| 400 |
try {
|
| 401 |
-
|
| 402 |
String x = HttpURLConnectionGet("http://subsixcyber13.pythonanywhere.com/main");
|
| 403 |
ObjectMapper mapper = new ObjectMapper();
|
| 404 |
mapper.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);
|
|
@@ -410,10 +412,10 @@ public class Util {
|
|
| 410 |
}
|
| 411 |
return null;
|
| 412 |
}
|
| 413 |
-
|
| 414 |
public static void updateData(String id) throws Exception {
|
| 415 |
try {
|
| 416 |
-
|
| 417 |
String x = HttpURLConnectionGet("http://subsixcyber13.pythonanywhere.com/main");
|
| 418 |
ObjectMapper mapper = new ObjectMapper();
|
| 419 |
mapper.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);
|
|
@@ -431,15 +433,16 @@ public class Util {
|
|
| 431 |
item.setHeroIds(entity.getHeroIds());
|
| 432 |
item.setItemIds(entity.getItemIds());
|
| 433 |
item.setSkillIds(entity.getSkillIds());
|
| 434 |
-
item.
|
|
|
|
| 435 |
}
|
| 436 |
}
|
| 437 |
-
|
| 438 |
} catch (Exception e) {
|
| 439 |
e.printStackTrace();
|
| 440 |
}
|
| 441 |
}
|
| 442 |
-
|
| 443 |
public static List<String> docFileTruyNa(String file_name) {
|
| 444 |
//window
|
| 445 |
// String x = "D:\\7-Project\\Java\\1. Netbean\\2. nghien-cuu\\TQTK\\tqtk-render.com-main\\"+file_name;
|
|
@@ -451,7 +454,19 @@ public class Util {
|
|
| 451 |
return null;
|
| 452 |
}
|
| 453 |
}
|
| 454 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 455 |
private static String HttpURLConnectionGet(final String url) throws Exception {
|
| 456 |
try {
|
| 457 |
final URL obj = new URL(url);
|
|
@@ -464,7 +479,7 @@ public class Util {
|
|
| 464 |
con.setRequestMethod("GET");
|
| 465 |
con.setRequestProperty("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36");
|
| 466 |
con.setRequestProperty("Host", "subsixcyber13.pythonanywhere.com");
|
| 467 |
-
|
| 468 |
int responseCode = con.getResponseCode();
|
| 469 |
if (200 <= responseCode && responseCode <= 399) {
|
| 470 |
String queryResult = "";
|
|
@@ -483,32 +498,18 @@ public class Util {
|
|
| 483 |
queryResult = new String(baf.toByteArray());
|
| 484 |
return queryResult;
|
| 485 |
}
|
| 486 |
-
|
| 487 |
} catch (Exception e) {
|
| 488 |
e.getMessage();
|
| 489 |
}
|
| 490 |
return null;
|
| 491 |
}
|
| 492 |
-
|
| 493 |
-
public static List<String> docFileCauHoiThuThue(String file_name) {
|
| 494 |
-
|
| 495 |
-
final Properties pr = new Properties();
|
| 496 |
-
//window
|
| 497 |
-
// String x = "D:\\7-Project\\Java\\1. Netbean\\2. nghien-cuu\\TQTK\\runshell\\cauhoi\\"+file_name;
|
| 498 |
-
//heroku
|
| 499 |
-
String x = file_name;
|
| 500 |
-
try {
|
| 501 |
-
return Doc_file_kieu_txt.readFile(x);
|
| 502 |
-
} catch (Exception e) {
|
| 503 |
-
return null;
|
| 504 |
-
}
|
| 505 |
-
}
|
| 506 |
-
|
| 507 |
public String test2(String url) throws Exception {
|
| 508 |
HttpURLConnection con = null;
|
| 509 |
try {
|
| 510 |
URL obj = new URL(url);
|
| 511 |
-
|
| 512 |
String pro = obj.getProtocol();
|
| 513 |
if (pro.equals("http")) {
|
| 514 |
con = (HttpURLConnection) obj.openConnection();
|
|
@@ -523,10 +524,10 @@ public class Util {
|
|
| 523 |
con.setRequestProperty("Upgrade-Insecure-Requests", "1");
|
| 524 |
con.setUseCaches(false);
|
| 525 |
con.setDoOutput(true);
|
| 526 |
-
|
| 527 |
int responseCode = con.getResponseCode();
|
| 528 |
if (200 <= responseCode && responseCode <= 399) {
|
| 529 |
-
|
| 530 |
BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream(), "UTF-8"));
|
| 531 |
StringBuffer response = new StringBuffer();
|
| 532 |
String inputLine;
|
|
@@ -535,11 +536,11 @@ public class Util {
|
|
| 535 |
}
|
| 536 |
in.close();
|
| 537 |
return con.getHeaderField("Location");
|
| 538 |
-
|
| 539 |
} else {
|
| 540 |
return "rea2";
|
| 541 |
}
|
| 542 |
-
|
| 543 |
} catch (Exception e) {
|
| 544 |
if (e instanceof SocketTimeoutException) {
|
| 545 |
throw new SocketTimeoutException("");
|
|
@@ -547,12 +548,12 @@ public class Util {
|
|
| 547 |
throw e;
|
| 548 |
}
|
| 549 |
}
|
| 550 |
-
|
| 551 |
public String test1(String url) throws Exception {
|
| 552 |
HttpURLConnection con = null;
|
| 553 |
try {
|
| 554 |
URL obj = new URL(url);
|
| 555 |
-
|
| 556 |
String pro = obj.getProtocol();
|
| 557 |
if (pro.equals("http")) {
|
| 558 |
con = (HttpURLConnection) obj.openConnection();
|
|
@@ -567,10 +568,10 @@ public class Util {
|
|
| 567 |
con.setRequestProperty("Upgrade-Insecure-Requests", "1");
|
| 568 |
con.setUseCaches(false);
|
| 569 |
con.setDoOutput(true);
|
| 570 |
-
|
| 571 |
int responseCode = con.getResponseCode();
|
| 572 |
if (200 <= responseCode && responseCode <= 399) {
|
| 573 |
-
|
| 574 |
BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream(), "UTF-8"));
|
| 575 |
StringBuffer response = new StringBuffer();
|
| 576 |
String inputLine;
|
|
@@ -579,11 +580,11 @@ public class Util {
|
|
| 579 |
}
|
| 580 |
in.close();
|
| 581 |
return response.toString();
|
| 582 |
-
|
| 583 |
} else {
|
| 584 |
return "tre1";
|
| 585 |
}
|
| 586 |
-
|
| 587 |
} catch (Exception e) {
|
| 588 |
if (e instanceof SocketTimeoutException) {
|
| 589 |
throw new SocketTimeoutException("");
|
|
@@ -591,4 +592,275 @@ public class Util {
|
|
| 591 |
throw e;
|
| 592 |
}
|
| 593 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 594 |
}
|
|
|
|
| 35 |
import tqtk.Entity.SessionEntity;
|
| 36 |
import java.io.FileReader;
|
| 37 |
import java.util.Iterator;
|
| 38 |
+
import java.util.regex.Matcher;
|
| 39 |
+
import java.util.regex.Pattern;
|
| 40 |
import org.apache.http.util.ByteArrayBuffer;
|
| 41 |
import org.json.simple.JSONArray;
|
| 42 |
import org.json.simple.JSONObject;
|
|
|
|
| 49 |
* @author Alex
|
| 50 |
*/
|
| 51 |
public class Util {
|
| 52 |
+
|
| 53 |
public CookieManager msCookieManager = null;
|
| 54 |
+
|
| 55 |
public Util() {
|
| 56 |
msCookieManager = new CookieManager();
|
| 57 |
}
|
| 58 |
+
|
| 59 |
public void setCookie(CookieManager msCookieManager) {
|
| 60 |
CookieHandler.setDefault(msCookieManager);
|
| 61 |
}
|
| 62 |
+
|
| 63 |
public String getPageSource(String url) throws Exception {
|
| 64 |
HttpURLConnection con = null;
|
| 65 |
try {
|
| 66 |
URL obj = new URL(url);
|
| 67 |
+
|
| 68 |
String pro = obj.getProtocol();
|
| 69 |
if (pro.equals("http")) {
|
| 70 |
con = (HttpURLConnection) obj.openConnection();
|
|
|
|
| 78 |
con.setRequestProperty("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36");
|
| 79 |
con.setUseCaches(false);
|
| 80 |
con.setDoOutput(true);
|
| 81 |
+
|
| 82 |
int responseCode = con.getResponseCode();
|
| 83 |
if (200 <= responseCode && responseCode <= 399) {
|
| 84 |
+
|
| 85 |
BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream(), "UTF-8"));
|
| 86 |
StringBuffer response = new StringBuffer();
|
| 87 |
String inputLine;
|
|
|
|
| 89 |
response.append(inputLine);
|
| 90 |
}
|
| 91 |
in.close();
|
| 92 |
+
|
| 93 |
return response.toString();
|
| 94 |
+
|
| 95 |
} else {
|
| 96 |
return "Hệ thống đang quá tải vui lòng";
|
| 97 |
}
|
| 98 |
+
|
| 99 |
} catch (Exception e) {
|
| 100 |
if (e instanceof SocketTimeoutException) {
|
| 101 |
throw new SocketTimeoutException("");
|
|
|
|
| 103 |
throw e;
|
| 104 |
}
|
| 105 |
}
|
| 106 |
+
|
| 107 |
public static String getToken(String htmlCode) {
|
| 108 |
String prefix = "name=\"_token\" value=\"";
|
| 109 |
int index = htmlCode.indexOf(prefix);
|
|
|
|
| 111 |
// Could not find the prefix string.
|
| 112 |
return null;
|
| 113 |
}
|
| 114 |
+
|
| 115 |
index += prefix.length();
|
| 116 |
|
| 117 |
// Login token has a fixed length of 40.
|
|
|
|
| 120 |
// Given html code is not long enough.
|
| 121 |
return null;
|
| 122 |
}
|
| 123 |
+
|
| 124 |
String token = htmlCode.substring(index, index + TokenLength);
|
| 125 |
return token;
|
| 126 |
}
|
| 127 |
+
|
| 128 |
public static String getRefer(String htmlCode) throws UnsupportedEncodingException {
|
| 129 |
String prefix = "action=\"";
|
| 130 |
int prefixIndex = htmlCode.indexOf(prefix);
|
|
|
|
| 134 |
}
|
| 135 |
String suffix = "\" accept-charset";
|
| 136 |
int suffixIndex = htmlCode.indexOf(suffix);
|
| 137 |
+
|
| 138 |
int beginIndex = prefixIndex + prefix.length();
|
| 139 |
int endIndex = suffixIndex;
|
| 140 |
String address = htmlCode.substring(beginIndex, endIndex);
|
| 141 |
String result = java.net.URLDecoder.decode(address, StandardCharsets.UTF_8.toString());
|
| 142 |
return result.replace("&", "&");
|
| 143 |
}
|
| 144 |
+
|
| 145 |
public String dangNhap(String url, String user, String pass, String token, String Refer) throws Exception {
|
| 146 |
HttpURLConnection con = null;
|
| 147 |
try {
|
| 148 |
URL obj = new URL(Refer);
|
| 149 |
+
|
| 150 |
String pro = obj.getProtocol();
|
| 151 |
if (pro.equals("http")) {
|
| 152 |
con = (HttpURLConnection) obj.openConnection();
|
|
|
|
| 166 |
con.setRequestProperty("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
|
| 167 |
con.setUseCaches(false);
|
| 168 |
con.setDoOutput(true);
|
| 169 |
+
|
| 170 |
DataOutputStream wr = new DataOutputStream(con.getOutputStream());
|
| 171 |
wr.write(postData);
|
| 172 |
wr.flush();
|
| 173 |
wr.close();
|
| 174 |
int responseCode = con.getResponseCode();
|
| 175 |
if (200 <= responseCode && responseCode <= 399) {
|
| 176 |
+
|
| 177 |
BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream(), "UTF-8"));
|
| 178 |
StringBuffer response = new StringBuffer();
|
| 179 |
String inputLine;
|
|
|
|
| 181 |
response.append(inputLine);
|
| 182 |
}
|
| 183 |
in.close();
|
| 184 |
+
|
| 185 |
return response.toString();
|
| 186 |
+
|
| 187 |
} else {
|
| 188 |
return "Hệ thống đang quá tải vui lòng";
|
| 189 |
}
|
| 190 |
+
|
| 191 |
} catch (Exception e) {
|
| 192 |
if (e instanceof SocketTimeoutException) {
|
| 193 |
throw new SocketTimeoutException("");
|
|
|
|
| 195 |
throw e;
|
| 196 |
}
|
| 197 |
}
|
| 198 |
+
|
| 199 |
public String getThongTinFrame(String url) throws Exception {
|
| 200 |
HttpURLConnection con = null;
|
| 201 |
try {
|
| 202 |
URL obj = new URL(url);
|
| 203 |
+
|
| 204 |
String pro = obj.getProtocol();
|
| 205 |
if (pro.equals("http")) {
|
| 206 |
con = (HttpURLConnection) obj.openConnection();
|
|
|
|
| 214 |
// con.setRequestProperty("Upgrade-Insecure-Requests", "1");
|
| 215 |
con.setUseCaches(false);
|
| 216 |
con.setDoOutput(true);
|
| 217 |
+
|
| 218 |
int responseCode = con.getResponseCode();
|
| 219 |
if (200 <= responseCode && responseCode <= 399) {
|
| 220 |
+
|
| 221 |
BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream(), "UTF-8"));
|
| 222 |
StringBuffer response = new StringBuffer();
|
| 223 |
String inputLine;
|
|
|
|
| 225 |
response.append(inputLine);
|
| 226 |
}
|
| 227 |
in.close();
|
| 228 |
+
|
| 229 |
return response.toString();
|
| 230 |
+
|
| 231 |
} else {
|
| 232 |
return "Hệ thống đang quá tải vui lòng";
|
| 233 |
}
|
| 234 |
+
|
| 235 |
} catch (Exception e) {
|
| 236 |
if (e instanceof SocketTimeoutException) {
|
| 237 |
throw new SocketTimeoutException("");
|
|
|
|
| 239 |
throw e;
|
| 240 |
}
|
| 241 |
}
|
| 242 |
+
|
| 243 |
public String getThongTinPort(String url) throws Exception {
|
| 244 |
HttpURLConnection con = null;
|
| 245 |
try {
|
| 246 |
URL obj = new URL(url);
|
| 247 |
+
|
| 248 |
String pro = obj.getProtocol();
|
| 249 |
if (pro.equals("http")) {
|
| 250 |
con = (HttpURLConnection) obj.openConnection();
|
|
|
|
| 259 |
con.setRequestProperty("Upgrade-Insecure-Requests", "1");
|
| 260 |
con.setUseCaches(false);
|
| 261 |
con.setDoOutput(true);
|
| 262 |
+
|
| 263 |
int responseCode = con.getResponseCode();
|
| 264 |
if (200 <= responseCode && responseCode <= 399) {
|
| 265 |
+
|
| 266 |
BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream(), "UTF-8"));
|
| 267 |
StringBuffer response = new StringBuffer();
|
| 268 |
String inputLine;
|
|
|
|
| 271 |
}
|
| 272 |
in.close();
|
| 273 |
return response.toString();
|
| 274 |
+
|
| 275 |
} else {
|
| 276 |
return "Hệ thống đang quá tải vui lòng";
|
| 277 |
}
|
| 278 |
+
|
| 279 |
} catch (Exception e) {
|
| 280 |
if (e instanceof SocketTimeoutException) {
|
| 281 |
throw new SocketTimeoutException("");
|
|
|
|
| 283 |
throw e;
|
| 284 |
}
|
| 285 |
}
|
| 286 |
+
|
| 287 |
public static String getFrameString(String htmlCode) throws UnsupportedEncodingException {
|
| 288 |
String prefix = "src=\"";
|
| 289 |
int index = htmlCode.indexOf(prefix);
|
|
|
|
| 291 |
// Could not find the prefix string.
|
| 292 |
return null;
|
| 293 |
}
|
| 294 |
+
|
| 295 |
index += prefix.length();
|
| 296 |
int suffixIndex = htmlCode.indexOf("\" frameborder");
|
| 297 |
if (suffixIndex == -1) {
|
| 298 |
// Could not find the suffix string.
|
| 299 |
return null;
|
| 300 |
}
|
| 301 |
+
|
| 302 |
String address = htmlCode.substring(index, suffixIndex);
|
| 303 |
return java.net.URLDecoder.decode(address, StandardCharsets.UTF_8.toString()).replace("&", "&");
|
| 304 |
}
|
| 305 |
+
|
| 306 |
public static String getInfoSocket(String htmlCode, String token) {
|
| 307 |
token = token + " : ";
|
| 308 |
int index = htmlCode.indexOf(token);
|
| 309 |
if (index == -1) {
|
| 310 |
return null;
|
| 311 |
}
|
| 312 |
+
|
| 313 |
index += token.length();
|
| 314 |
int suffixIndex = htmlCode.indexOf(",", index);
|
| 315 |
if (suffixIndex == -1) {
|
| 316 |
return null;
|
| 317 |
}
|
| 318 |
+
|
| 319 |
String value = htmlCode.substring(index, suffixIndex);
|
| 320 |
value = value.replaceAll("[\'||\"]", "");
|
| 321 |
return value;
|
| 322 |
}
|
| 323 |
+
|
| 324 |
public static String TaoMsg(String commandId, List<String> list, SessionEntity ss) throws NoSuchAlgorithmException, UnsupportedEncodingException {
|
| 325 |
String what_is_this = "5dcd73d391c90e8769618d42a916ea1b";
|
| 326 |
String input = commandId + ss.getUserId();
|
| 327 |
+
|
| 328 |
String msg = String.format("%s\u0001%s\t%s\u0002", commandId, ss.getUserId(), ss.getSessionKey());
|
| 329 |
Date date = new Date();
|
| 330 |
long millisecondsSinceEpoch = date.getTime();
|
|
|
|
| 334 |
msg += string + '\t';
|
| 335 |
}
|
| 336 |
}
|
| 337 |
+
|
| 338 |
input += what_is_this;
|
| 339 |
if (list != null && list.size() > 0) {
|
| 340 |
msg = msg.substring(0, msg.length());
|
| 341 |
}
|
| 342 |
+
|
| 343 |
String checksum = hash(input);
|
| 344 |
msg += String.format("\u0003%s\u0004%d\u0005\0", checksum, millisecondsSinceEpoch);
|
| 345 |
return msg;
|
| 346 |
}
|
| 347 |
+
|
| 348 |
public static String hash(String input) throws NoSuchAlgorithmException, UnsupportedEncodingException {
|
| 349 |
MessageDigest md = MessageDigest.getInstance("MD5");
|
| 350 |
byte[] buffer = md.digest(input.getBytes("UTF8"));
|
|
|
|
| 354 |
}
|
| 355 |
return builder.toString();
|
| 356 |
}
|
| 357 |
+
|
| 358 |
public static Properties loadProperties(String file_name) {
|
| 359 |
+
|
| 360 |
final Properties pr = new Properties();
|
| 361 |
//window
|
| 362 |
// String x = "D:\\7-Project\\Java\\1. Netbean\\2. nghien-cuu\\TQTK\\runshell\\"+file_name;
|
|
|
|
| 371 |
}
|
| 372 |
return pr;
|
| 373 |
}
|
| 374 |
+
|
| 375 |
public static void setData(String file_name, List<SessionEntity> ss) {
|
| 376 |
org.json.simple.JSONObject jSONObject = null;
|
| 377 |
JSONParser jsonParser = new JSONParser();
|
|
|
|
| 380 |
try (FileReader reader = new FileReader(x)) {
|
| 381 |
//Read JSON file
|
| 382 |
jSONObject = (org.json.simple.JSONObject) jsonParser.parse(reader);
|
| 383 |
+
|
| 384 |
JSONArray jSONArray = (JSONArray) jSONObject.get("accounts");
|
| 385 |
+
|
| 386 |
for (Iterator it = jSONArray.iterator(); it.hasNext();) {
|
| 387 |
jSONObject = (JSONObject) it.next();
|
| 388 |
SessionEntity s1 = new SessionEntity();
|
|
|
|
| 392 |
s1.setUserId((String) jSONObject.get("UserId"));
|
| 393 |
ss.add(s1);
|
| 394 |
}
|
| 395 |
+
|
| 396 |
} catch (Exception e) {
|
| 397 |
e.printStackTrace();
|
| 398 |
}
|
| 399 |
}
|
| 400 |
+
|
| 401 |
public static List<SessionEntity> setData1(List<SessionEntity> ss) throws Exception {
|
| 402 |
try {
|
| 403 |
+
|
| 404 |
String x = HttpURLConnectionGet("http://subsixcyber13.pythonanywhere.com/main");
|
| 405 |
ObjectMapper mapper = new ObjectMapper();
|
| 406 |
mapper.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);
|
|
|
|
| 412 |
}
|
| 413 |
return null;
|
| 414 |
}
|
| 415 |
+
|
| 416 |
public static void updateData(String id) throws Exception {
|
| 417 |
try {
|
| 418 |
+
|
| 419 |
String x = HttpURLConnectionGet("http://subsixcyber13.pythonanywhere.com/main");
|
| 420 |
ObjectMapper mapper = new ObjectMapper();
|
| 421 |
mapper.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);
|
|
|
|
| 433 |
item.setHeroIds(entity.getHeroIds());
|
| 434 |
item.setItemIds(entity.getItemIds());
|
| 435 |
item.setSkillIds(entity.getSkillIds());
|
| 436 |
+
item.setCookie(entity.getCookie());
|
| 437 |
+
// item.setSessionKey(entity.getSessionKey());
|
| 438 |
}
|
| 439 |
}
|
| 440 |
+
|
| 441 |
} catch (Exception e) {
|
| 442 |
e.printStackTrace();
|
| 443 |
}
|
| 444 |
}
|
| 445 |
+
|
| 446 |
public static List<String> docFileTruyNa(String file_name) {
|
| 447 |
//window
|
| 448 |
// String x = "D:\\7-Project\\Java\\1. Netbean\\2. nghien-cuu\\TQTK\\tqtk-render.com-main\\"+file_name;
|
|
|
|
| 454 |
return null;
|
| 455 |
}
|
| 456 |
}
|
| 457 |
+
|
| 458 |
+
public static List<String> docFileCauHoiThuThue(String file_name) {
|
| 459 |
+
//window
|
| 460 |
+
// String x = "D:\\7-Project\\Java\\1. Netbean\\2. nghien-cuu\\TQTK\\runshell\\cauhoi\\"+file_name;
|
| 461 |
+
//heroku
|
| 462 |
+
String x = file_name;
|
| 463 |
+
try {
|
| 464 |
+
return Doc_file_kieu_txt.readFile(x);
|
| 465 |
+
} catch (Exception e) {
|
| 466 |
+
return null;
|
| 467 |
+
}
|
| 468 |
+
}
|
| 469 |
+
|
| 470 |
private static String HttpURLConnectionGet(final String url) throws Exception {
|
| 471 |
try {
|
| 472 |
final URL obj = new URL(url);
|
|
|
|
| 479 |
con.setRequestMethod("GET");
|
| 480 |
con.setRequestProperty("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36");
|
| 481 |
con.setRequestProperty("Host", "subsixcyber13.pythonanywhere.com");
|
| 482 |
+
|
| 483 |
int responseCode = con.getResponseCode();
|
| 484 |
if (200 <= responseCode && responseCode <= 399) {
|
| 485 |
String queryResult = "";
|
|
|
|
| 498 |
queryResult = new String(baf.toByteArray());
|
| 499 |
return queryResult;
|
| 500 |
}
|
| 501 |
+
|
| 502 |
} catch (Exception e) {
|
| 503 |
e.getMessage();
|
| 504 |
}
|
| 505 |
return null;
|
| 506 |
}
|
| 507 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 508 |
public String test2(String url) throws Exception {
|
| 509 |
HttpURLConnection con = null;
|
| 510 |
try {
|
| 511 |
URL obj = new URL(url);
|
| 512 |
+
|
| 513 |
String pro = obj.getProtocol();
|
| 514 |
if (pro.equals("http")) {
|
| 515 |
con = (HttpURLConnection) obj.openConnection();
|
|
|
|
| 524 |
con.setRequestProperty("Upgrade-Insecure-Requests", "1");
|
| 525 |
con.setUseCaches(false);
|
| 526 |
con.setDoOutput(true);
|
| 527 |
+
|
| 528 |
int responseCode = con.getResponseCode();
|
| 529 |
if (200 <= responseCode && responseCode <= 399) {
|
| 530 |
+
|
| 531 |
BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream(), "UTF-8"));
|
| 532 |
StringBuffer response = new StringBuffer();
|
| 533 |
String inputLine;
|
|
|
|
| 536 |
}
|
| 537 |
in.close();
|
| 538 |
return con.getHeaderField("Location");
|
| 539 |
+
|
| 540 |
} else {
|
| 541 |
return "rea2";
|
| 542 |
}
|
| 543 |
+
|
| 544 |
} catch (Exception e) {
|
| 545 |
if (e instanceof SocketTimeoutException) {
|
| 546 |
throw new SocketTimeoutException("");
|
|
|
|
| 548 |
throw e;
|
| 549 |
}
|
| 550 |
}
|
| 551 |
+
|
| 552 |
public String test1(String url) throws Exception {
|
| 553 |
HttpURLConnection con = null;
|
| 554 |
try {
|
| 555 |
URL obj = new URL(url);
|
| 556 |
+
|
| 557 |
String pro = obj.getProtocol();
|
| 558 |
if (pro.equals("http")) {
|
| 559 |
con = (HttpURLConnection) obj.openConnection();
|
|
|
|
| 568 |
con.setRequestProperty("Upgrade-Insecure-Requests", "1");
|
| 569 |
con.setUseCaches(false);
|
| 570 |
con.setDoOutput(true);
|
| 571 |
+
|
| 572 |
int responseCode = con.getResponseCode();
|
| 573 |
if (200 <= responseCode && responseCode <= 399) {
|
| 574 |
+
|
| 575 |
BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream(), "UTF-8"));
|
| 576 |
StringBuffer response = new StringBuffer();
|
| 577 |
String inputLine;
|
|
|
|
| 580 |
}
|
| 581 |
in.close();
|
| 582 |
return response.toString();
|
| 583 |
+
|
| 584 |
} else {
|
| 585 |
return "tre1";
|
| 586 |
}
|
| 587 |
+
|
| 588 |
} catch (Exception e) {
|
| 589 |
if (e instanceof SocketTimeoutException) {
|
| 590 |
throw new SocketTimeoutException("");
|
|
|
|
| 592 |
throw e;
|
| 593 |
}
|
| 594 |
}
|
| 595 |
+
|
| 596 |
+
public static String getSessiongId(String cookie) throws Exception {
|
| 597 |
+
String rs = getSessionId1(cookie);
|
| 598 |
+
String[] rs1 = getSessionId2(rs, cookie);
|
| 599 |
+
rs = getSessionId3(rs1, cookie);
|
| 600 |
+
return rs;
|
| 601 |
+
}
|
| 602 |
+
|
| 603 |
+
public static String getSessionId1(String cookie) throws Exception {
|
| 604 |
+
String rs = null;
|
| 605 |
+
try {
|
| 606 |
+
final URL obj = new URL("http://app.gesoten.com/extend/container?appId=9008");
|
| 607 |
+
// Proxy proxy = new Proxy(Proxy.Type.SOCKS, new InetSocketAddress("0.0.0.0", 1080));
|
| 608 |
+
HttpURLConnection con;
|
| 609 |
+
if (obj.getProtocol().equals("http")) {
|
| 610 |
+
con = (HttpURLConnection) obj.openConnection();
|
| 611 |
+
} else {
|
| 612 |
+
con = (HttpsURLConnection) obj.openConnection();
|
| 613 |
+
}
|
| 614 |
+
|
| 615 |
+
con.setRequestMethod("GET");
|
| 616 |
+
con.setRequestProperty("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36");
|
| 617 |
+
con.setRequestProperty("Host", "app.gesoten.com");
|
| 618 |
+
con.setRequestProperty("Cookie", cookie);
|
| 619 |
+
// con.setRequestProperty("Sec-Fetch-Site", "none");
|
| 620 |
+
// con.setRequestProperty("Sec-Fetch-Mode", "navigate");
|
| 621 |
+
// con.setRequestProperty("Sec-Fetch-User", "?1");
|
| 622 |
+
|
| 623 |
+
int responseCode = con.getResponseCode();
|
| 624 |
+
|
| 625 |
+
// BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream(), "UTF-8"));
|
| 626 |
+
// StringBuffer response = new StringBuffer();
|
| 627 |
+
// String inputLine;
|
| 628 |
+
// while ((inputLine = in.readLine()) != null) {
|
| 629 |
+
// response.append(inputLine);
|
| 630 |
+
// }
|
| 631 |
+
// in.close();
|
| 632 |
+
if (200 <= responseCode && responseCode <= 399) {
|
| 633 |
+
String queryResult = "";
|
| 634 |
+
BufferedInputStream bis = new BufferedInputStream(con.getInputStream());
|
| 635 |
+
ByteArrayBuffer baf = new ByteArrayBuffer(50);
|
| 636 |
+
int read = 0;
|
| 637 |
+
int bufSize = 512;
|
| 638 |
+
byte[] buffer = new byte[bufSize];
|
| 639 |
+
while (true) {
|
| 640 |
+
read = bis.read(buffer);
|
| 641 |
+
if (read == -1) {
|
| 642 |
+
break;
|
| 643 |
+
}
|
| 644 |
+
baf.append(buffer, 0, read);
|
| 645 |
+
}
|
| 646 |
+
queryResult = new String(baf.toByteArray());
|
| 647 |
+
|
| 648 |
+
Pattern pattern = null;
|
| 649 |
+
Matcher matcher = null;
|
| 650 |
+
String update = "";
|
| 651 |
+
|
| 652 |
+
pattern = Pattern.compile("var\\s{0,3}stoken\\s{0,3}=\\s{0,3}'default%3A(.*?)'");
|
| 653 |
+
matcher = pattern.matcher(queryResult);
|
| 654 |
+
if (matcher.find()) {
|
| 655 |
+
|
| 656 |
+
return matcher.group(1);
|
| 657 |
+
} else {
|
| 658 |
+
return "";
|
| 659 |
+
}
|
| 660 |
+
|
| 661 |
+
}
|
| 662 |
+
|
| 663 |
+
} catch (Exception e) {
|
| 664 |
+
e.getMessage();
|
| 665 |
+
}
|
| 666 |
+
return rs;
|
| 667 |
+
}
|
| 668 |
+
|
| 669 |
+
public static String[] getSessionId2(String sign, String cookie) throws Exception {
|
| 670 |
+
String rs = null;
|
| 671 |
+
try {
|
| 672 |
+
final URL obj = new URL("http://app.gesoten.com/gadgets/makeRequest");
|
| 673 |
+
HttpURLConnection con;
|
| 674 |
+
if (obj.getProtocol().equals("http")) {
|
| 675 |
+
con = (HttpURLConnection) obj.openConnection();
|
| 676 |
+
} else {
|
| 677 |
+
con = (HttpsURLConnection) obj.openConnection();
|
| 678 |
+
}
|
| 679 |
+
|
| 680 |
+
sign = "st=default:" + sign;
|
| 681 |
+
|
| 682 |
+
String postData = "url=https%3A%2F%2Fplatforms.sengokugifu.jp%2Fgesoten%2Fplay-link&httpMethod=POST&headers=Content-Type%3Dapplication%252Fx-www-form-urlencoded&postData=server_id%3Ds17&authz=signed&contentType=JSON&numEntries=3&getSummaries=false&signOwner=true&signViewer=true&gadget=https%3A%2F%2Fplatforms.sengokugifu.jp%2Fgesoten%2Fgadget.xml&container=default&bypassSpecCache=1&getFullHeaders=false&oauthState=&" + sign;
|
| 683 |
+
|
| 684 |
+
byte[] postDataBytes = postData.getBytes("UTF-8");
|
| 685 |
+
|
| 686 |
+
con.setRequestMethod("POST");
|
| 687 |
+
con.setRequestProperty("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36");
|
| 688 |
+
con.setRequestProperty("Host", "app.gesoten.com");
|
| 689 |
+
con.setRequestProperty("Cookie", cookie);
|
| 690 |
+
con.setRequestProperty("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
|
| 691 |
+
|
| 692 |
+
con.setUseCaches(false);
|
| 693 |
+
con.setDoOutput(true);
|
| 694 |
+
DataOutputStream wr = new DataOutputStream(con.getOutputStream());
|
| 695 |
+
wr.write(postDataBytes);
|
| 696 |
+
wr.flush();
|
| 697 |
+
wr.close();
|
| 698 |
+
int responseCode = con.getResponseCode();
|
| 699 |
+
if (200 <= responseCode && responseCode <= 399) {
|
| 700 |
+
String queryResult = "";
|
| 701 |
+
BufferedInputStream bis = new BufferedInputStream(con.getInputStream());
|
| 702 |
+
ByteArrayBuffer baf = new ByteArrayBuffer(50);
|
| 703 |
+
int read = 0;
|
| 704 |
+
int bufSize = 512;
|
| 705 |
+
byte[] buffer = new byte[bufSize];
|
| 706 |
+
while (true) {
|
| 707 |
+
read = bis.read(buffer);
|
| 708 |
+
if (read == -1) {
|
| 709 |
+
break;
|
| 710 |
+
}
|
| 711 |
+
baf.append(buffer, 0, read);
|
| 712 |
+
}
|
| 713 |
+
queryResult = new String(baf.toByteArray());
|
| 714 |
+
|
| 715 |
+
Pattern pattern = null;
|
| 716 |
+
Matcher matcher = null;
|
| 717 |
+
String[] update = new String[3];
|
| 718 |
+
|
| 719 |
+
pattern = Pattern.compile("userid=(\\d{3,25})&.*?&Time=(\\d{3,20})&.*?&Sign=(.*?)&");
|
| 720 |
+
matcher = pattern.matcher(queryResult);
|
| 721 |
+
if (matcher.find()) {
|
| 722 |
+
update[0] = matcher.group(1);
|
| 723 |
+
update[1] = matcher.group(2);
|
| 724 |
+
update[2] = matcher.group(3);
|
| 725 |
+
|
| 726 |
+
return update;
|
| 727 |
+
} else {
|
| 728 |
+
return null;
|
| 729 |
+
}
|
| 730 |
+
|
| 731 |
+
}
|
| 732 |
+
|
| 733 |
+
} catch (Exception e) {
|
| 734 |
+
e.getMessage();
|
| 735 |
+
}
|
| 736 |
+
return null;
|
| 737 |
+
}
|
| 738 |
+
|
| 739 |
+
public static String getSessionId3(String[] path, String cookie) throws Exception {
|
| 740 |
+
String rs = null;
|
| 741 |
+
try {
|
| 742 |
+
URL obj = new URL("http://api.sengokugifu.jp/home/login/login?Uname=" + path[0] + "&userid=" + path[0] + "&GameId=2001&ServerId=s17&Time=" + path[1] + "&al=1&from=gesoten&siteurl=gesoten.com&Sign=" + path[2] + "&nickname=gesoten-" + path[0]);
|
| 743 |
+
HttpURLConnection con;
|
| 744 |
+
|
| 745 |
+
if (obj.getProtocol().equals("http")) {
|
| 746 |
+
con = (HttpURLConnection) obj.openConnection();
|
| 747 |
+
} else {
|
| 748 |
+
con = (HttpsURLConnection) obj.openConnection();
|
| 749 |
+
}
|
| 750 |
+
con.setInstanceFollowRedirects(true);
|
| 751 |
+
HttpURLConnection.setFollowRedirects(true);
|
| 752 |
+
|
| 753 |
+
con.setRequestMethod("GET");
|
| 754 |
+
con.setRequestProperty("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36");
|
| 755 |
+
con.setRequestProperty("Host", "app.gesoten.com");
|
| 756 |
+
con.setRequestProperty("Cookie", cookie);
|
| 757 |
+
|
| 758 |
+
int responseCode = con.getResponseCode();
|
| 759 |
+
// xu ly redirect
|
| 760 |
+
obj = new URL(con.getHeaderField("Location"));
|
| 761 |
+
|
| 762 |
+
String cookies = con.getHeaderField("Set-Cookie");
|
| 763 |
+
|
| 764 |
+
con = (HttpURLConnection) obj.openConnection();
|
| 765 |
+
|
| 766 |
+
con.setRequestMethod("GET");
|
| 767 |
+
con.setRequestProperty("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36");
|
| 768 |
+
con.setRequestProperty("Host", "gesoten.com");
|
| 769 |
+
con.setRequestProperty("Cookie", cookies);
|
| 770 |
+
|
| 771 |
+
responseCode = con.getResponseCode();
|
| 772 |
+
|
| 773 |
+
if (200 <= responseCode && responseCode <= 399) {
|
| 774 |
+
String queryResult = "";
|
| 775 |
+
BufferedInputStream bis = new BufferedInputStream(con.getInputStream());
|
| 776 |
+
ByteArrayBuffer baf = new ByteArrayBuffer(50);
|
| 777 |
+
int read = 0;
|
| 778 |
+
int bufSize = 512;
|
| 779 |
+
byte[] buffer = new byte[bufSize];
|
| 780 |
+
while (true) {
|
| 781 |
+
read = bis.read(buffer);
|
| 782 |
+
if (read == -1) {
|
| 783 |
+
break;
|
| 784 |
+
}
|
| 785 |
+
baf.append(buffer, 0, read);
|
| 786 |
+
}
|
| 787 |
+
queryResult = new String(baf.toByteArray());
|
| 788 |
+
|
| 789 |
+
Pattern pattern = null;
|
| 790 |
+
Matcher matcher = null;
|
| 791 |
+
String update = "";
|
| 792 |
+
|
| 793 |
+
pattern = Pattern.compile("sessionKey\\s{0,3}:\\s{0,3}\"(.*?)\"");
|
| 794 |
+
matcher = pattern.matcher(queryResult);
|
| 795 |
+
if (matcher.find()) {
|
| 796 |
+
return matcher.group(1);
|
| 797 |
+
} else {
|
| 798 |
+
return "";
|
| 799 |
+
}
|
| 800 |
+
|
| 801 |
+
}
|
| 802 |
+
|
| 803 |
+
} catch (Exception e) {
|
| 804 |
+
e.getMessage();
|
| 805 |
+
}
|
| 806 |
+
return rs;
|
| 807 |
+
}
|
| 808 |
+
|
| 809 |
+
public static boolean checkIdRunUyPhai(String id) throws Exception {
|
| 810 |
+
boolean rs = false;
|
| 811 |
+
try {
|
| 812 |
+
final URL obj = new URL("http://subsixcyber13.pythonanywhere.com/check-uy-phai?id="+id);
|
| 813 |
+
// Proxy proxy = new Proxy(Proxy.Type.SOCKS, new InetSocketAddress("0.0.0.0", 1080));
|
| 814 |
+
HttpURLConnection con;
|
| 815 |
+
if (obj.getProtocol().equals("http")) {
|
| 816 |
+
con = (HttpURLConnection) obj.openConnection();
|
| 817 |
+
} else {
|
| 818 |
+
con = (HttpsURLConnection) obj.openConnection();
|
| 819 |
+
}
|
| 820 |
+
|
| 821 |
+
con.setRequestMethod("GET");
|
| 822 |
+
con.setRequestProperty("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36");
|
| 823 |
+
con.setRequestProperty("Host", "pythonanywhere.com");
|
| 824 |
+
// con.setRequestProperty("Sec-Fetch-Site", "none");
|
| 825 |
+
// con.setRequestProperty("Sec-Fetch-Mode", "navigate");
|
| 826 |
+
// con.setRequestProperty("Sec-Fetch-User", "?1");
|
| 827 |
+
|
| 828 |
+
int responseCode = con.getResponseCode();
|
| 829 |
+
|
| 830 |
+
// BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream(), "UTF-8"));
|
| 831 |
+
// StringBuffer response = new StringBuffer();
|
| 832 |
+
// String inputLine;
|
| 833 |
+
// while ((inputLine = in.readLine()) != null) {
|
| 834 |
+
// response.append(inputLine);
|
| 835 |
+
// }
|
| 836 |
+
// in.close();
|
| 837 |
+
if (200 <= responseCode && responseCode <= 399) {
|
| 838 |
+
String queryResult = "";
|
| 839 |
+
BufferedInputStream bis = new BufferedInputStream(con.getInputStream());
|
| 840 |
+
ByteArrayBuffer baf = new ByteArrayBuffer(50);
|
| 841 |
+
int read = 0;
|
| 842 |
+
int bufSize = 512;
|
| 843 |
+
byte[] buffer = new byte[bufSize];
|
| 844 |
+
while (true) {
|
| 845 |
+
read = bis.read(buffer);
|
| 846 |
+
if (read == -1) {
|
| 847 |
+
break;
|
| 848 |
+
}
|
| 849 |
+
baf.append(buffer, 0, read);
|
| 850 |
+
}
|
| 851 |
+
queryResult = new String(baf.toByteArray());
|
| 852 |
+
if (queryResult.contains("ok")) {
|
| 853 |
+
rs = true;
|
| 854 |
+
} else {
|
| 855 |
+
rs = false;
|
| 856 |
+
}
|
| 857 |
+
|
| 858 |
+
}
|
| 859 |
+
|
| 860 |
+
} catch (Exception e) {
|
| 861 |
+
e.getMessage();
|
| 862 |
+
}
|
| 863 |
+
return rs;
|
| 864 |
+
}
|
| 865 |
+
|
| 866 |
}
|
src/main/java/tqtk/XuLy/Worker.java
CHANGED
|
@@ -1,4 +1,3 @@
|
|
| 1 |
-
|
| 2 |
package tqtk.XuLy;
|
| 3 |
|
| 4 |
import com.fasterxml.jackson.core.type.TypeReference;
|
|
@@ -32,6 +31,7 @@ import tqtk.exception.JsonException;
|
|
| 32 |
import java.io.*;
|
| 33 |
import java.util.*;
|
| 34 |
import java.util.Collections;
|
|
|
|
| 35 |
|
| 36 |
/**
|
| 37 |
*
|
|
@@ -609,6 +609,9 @@ public class Worker extends Thread {
|
|
| 609 |
Thread.sleep(5000);
|
| 610 |
GuiPacket(ss, "12100", list1);
|
| 611 |
}
|
|
|
|
|
|
|
|
|
|
| 612 |
|
| 613 |
} catch (Exception e) {
|
| 614 |
System.out.println("NangNha " + ss.getUserId() + e.getMessage());
|
|
@@ -708,10 +711,10 @@ public class Worker extends Thread {
|
|
| 708 |
List<String> list1 = new ArrayList<>();
|
| 709 |
list1.add(0, "17");
|
| 710 |
list1.add(1, "1");
|
| 711 |
-
|
| 712 |
-
|
| 713 |
list2.add(0, "1");
|
| 714 |
-
|
| 715 |
try {
|
| 716 |
|
| 717 |
Tqtk.sendMessage("nhan thuong " + ss.getUserId());
|
|
@@ -758,9 +761,9 @@ public class Worker extends Thread {
|
|
| 758 |
GuiPacket(ss, "60702", null);
|
| 759 |
Thread.sleep(2000);
|
| 760 |
GuiPacket(ss, "60703", null);
|
| 761 |
-
|
| 762 |
-
|
| 763 |
-
|
| 764 |
GuiPacket(ss, "64002", list2);
|
| 765 |
|
| 766 |
} catch (Exception e) {
|
|
@@ -865,37 +868,34 @@ public class Worker extends Thread {
|
|
| 865 |
break;
|
| 866 |
}
|
| 867 |
}
|
| 868 |
-
|
| 869 |
-
|
| 870 |
-
|
| 871 |
Map<String, Object> carMap1 = (Map<String, Object>) ((Map<String, Object>) carMap.get("m")).get("imposedto");
|
| 872 |
|
| 873 |
-
|
| 874 |
-
|
| 875 |
if (carMap1 != null) {
|
| 876 |
Integer imposenum = (Integer) carMap1.get("imposenum");
|
| 877 |
-
|
| 878 |
-
|
| 879 |
-
|
| 880 |
-
|
| 881 |
}
|
| 882 |
} catch (Exception e) {
|
| 883 |
throw new JsonException();
|
| 884 |
}
|
| 885 |
|
| 886 |
}
|
| 887 |
-
|
| 888 |
} catch (Exception ex) {
|
| 889 |
if (!(ex instanceof JsonException)) {
|
| 890 |
System.out.println("loi qd " + ss.getUserId() + ex.getMessage());
|
| 891 |
} else {
|
| 892 |
System.out.println("loi qd json" + ss.getUserId() + ex.getMessage());
|
| 893 |
}
|
| 894 |
-
|
| 895 |
}
|
| 896 |
}
|
| 897 |
|
| 898 |
-
|
| 899 |
public void ThuThue() {
|
| 900 |
// danh quan doan vu van thi toc
|
| 901 |
List<String> list1 = new ArrayList<>();
|
|
@@ -905,63 +905,62 @@ public class Worker extends Thread {
|
|
| 905 |
list2.add(0, "0");
|
| 906 |
|
| 907 |
try {
|
| 908 |
-
|
| 909 |
-
|
| 910 |
-
|
| 911 |
-
|
| 912 |
-
|
| 913 |
-
|
| 914 |
|
| 915 |
-
|
| 916 |
-
|
| 917 |
-
|
| 918 |
-
|
| 919 |
-
|
| 920 |
-
|
| 921 |
-
|
| 922 |
-
|
| 923 |
-
|
|
|
|
| 924 |
}
|
| 925 |
-
}
|
| 926 |
|
| 927 |
-
|
| 928 |
|
| 929 |
-
|
| 930 |
|
| 931 |
-
|
| 932 |
-
|
| 933 |
-
|
| 934 |
|
| 935 |
-
|
| 936 |
|
| 937 |
-
|
| 938 |
-
|
| 939 |
-
|
| 940 |
-
|
| 941 |
-
|
| 942 |
-
|
| 943 |
-
|
| 944 |
-
|
| 945 |
-
|
| 946 |
-
|
| 947 |
-
|
| 948 |
-
|
| 949 |
-
|
| 950 |
-
|
| 951 |
-
|
| 952 |
-
|
|
|
|
| 953 |
}
|
| 954 |
-
}
|
| 955 |
|
|
|
|
|
|
|
|
|
|
| 956 |
}
|
| 957 |
-
|
| 958 |
-
throw new JsonException();
|
| 959 |
}
|
| 960 |
|
| 961 |
}
|
| 962 |
-
|
| 963 |
-
|
| 964 |
-
}
|
| 965 |
|
| 966 |
} catch (Exception ex) {
|
| 967 |
if (!(ex instanceof JsonException)) {
|
|
@@ -1211,12 +1210,12 @@ public class Worker extends Thread {
|
|
| 1211 |
throw new JsonException();
|
| 1212 |
}
|
| 1213 |
} else {
|
| 1214 |
-
|
| 1215 |
}
|
| 1216 |
} catch (Exception ex) {
|
| 1217 |
if (!(ex instanceof JsonException)) {
|
| 1218 |
System.out.println("NangItem " + ss.getUserId() + ex.getMessage());
|
| 1219 |
-
|
| 1220 |
} else {
|
| 1221 |
System.out.println("NangItem json " + ss.getUserId() + ex.getMessage());
|
| 1222 |
}
|
|
@@ -1300,12 +1299,12 @@ public class Worker extends Thread {
|
|
| 1300 |
throw new JsonException();
|
| 1301 |
}
|
| 1302 |
} else {
|
| 1303 |
-
|
| 1304 |
}
|
| 1305 |
} catch (Exception ex) {
|
| 1306 |
if (!(ex instanceof JsonException)) {
|
| 1307 |
System.out.println("NangItem " + ss.getUserId() + ex.getMessage());
|
| 1308 |
-
|
| 1309 |
} else {
|
| 1310 |
System.out.println("NangItem json " + ss.getUserId() + ex.getMessage());
|
| 1311 |
}
|
|
@@ -1315,6 +1314,9 @@ public class Worker extends Thread {
|
|
| 1315 |
}
|
| 1316 |
|
| 1317 |
public void UyPhai() throws IOException, UnknownHostException, InterruptedException, Exception {
|
|
|
|
|
|
|
|
|
|
| 1318 |
List<String> list1 = new ArrayList<>();
|
| 1319 |
list1.add(0, "0");
|
| 1320 |
list1.add(1, "0");
|
|
@@ -1358,7 +1360,7 @@ public class Worker extends Thread {
|
|
| 1358 |
} catch (Exception ex) {
|
| 1359 |
if (!(ex instanceof JsonException)) {
|
| 1360 |
System.out.println("UyPhai " + ss.getUserId() + ex.getMessage());
|
| 1361 |
-
|
| 1362 |
} else {
|
| 1363 |
System.out.println("UyPhai json " + ss.getUserId() + ex.getMessage());
|
| 1364 |
}
|
|
@@ -1381,14 +1383,14 @@ public class Worker extends Thread {
|
|
| 1381 |
StringBuilder rs = GuiPacket(ss, "62007", list1);
|
| 1382 |
Thread.sleep(5000);
|
| 1383 |
if (rs != null) {
|
| 1384 |
-
|
| 1385 |
-
|
| 1386 |
GuiPacket(ss, "62006", list2);
|
| 1387 |
-
|
| 1388 |
if (!rs.toString().contains("掘削中です")) {
|
| 1389 |
-
|
| 1390 |
}
|
| 1391 |
-
}
|
| 1392 |
|
| 1393 |
} catch (Exception ex) {
|
| 1394 |
System.out.println(ex.getMessage());
|
|
@@ -1476,7 +1478,7 @@ public class Worker extends Thread {
|
|
| 1476 |
} catch (Exception ex) {
|
| 1477 |
if (!(ex instanceof JsonException)) {
|
| 1478 |
System.out.println("CapNhatThongTin " + ss.getUserId() + ex.getMessage());
|
| 1479 |
-
|
| 1480 |
} else {
|
| 1481 |
System.out.println("CapNhatThongTin " + ss.getUserId() + ex.getMessage());
|
| 1482 |
}
|
|
@@ -1533,8 +1535,8 @@ public class Worker extends Thread {
|
|
| 1533 |
}
|
| 1534 |
|
| 1535 |
}
|
| 1536 |
-
|
| 1537 |
-
|
| 1538 |
try {
|
| 1539 |
Thread.sleep(5000);
|
| 1540 |
GuiPacketLinhThu(ss, "11102", null);
|
|
@@ -1623,7 +1625,7 @@ public class Worker extends Thread {
|
|
| 1623 |
} catch (Exception ex) {
|
| 1624 |
if (!(ex instanceof JsonException)) {
|
| 1625 |
System.out.println("cho den " + ss.getUserId() + ex.getMessage());
|
| 1626 |
-
|
| 1627 |
} else {
|
| 1628 |
System.out.println("cho den json " + ss.getUserId() + ex.getMessage());
|
| 1629 |
}
|
|
@@ -1632,7 +1634,6 @@ public class Worker extends Thread {
|
|
| 1632 |
|
| 1633 |
}
|
| 1634 |
|
| 1635 |
-
|
| 1636 |
public void MuaRuong() throws IOException, UnknownHostException, InterruptedException, Exception {
|
| 1637 |
List<String> list1 = new ArrayList<>();
|
| 1638 |
list1.add(0, "3");
|
|
@@ -1695,7 +1696,7 @@ public class Worker extends Thread {
|
|
| 1695 |
} catch (Exception ex) {
|
| 1696 |
if (!(ex instanceof JsonException)) {
|
| 1697 |
System.out.println("cho den " + ss.getUserId() + ex.getMessage());
|
| 1698 |
-
|
| 1699 |
} else {
|
| 1700 |
System.out.println("cho den json " + ss.getUserId() + ex.getMessage());
|
| 1701 |
}
|
|
@@ -1703,9 +1704,8 @@ public class Worker extends Thread {
|
|
| 1703 |
}
|
| 1704 |
|
| 1705 |
}
|
| 1706 |
-
|
| 1707 |
-
|
| 1708 |
-
public void NangHaLinhThu(SessionEntity ss) throws IOException, UnknownHostException, InterruptedException, Exception {
|
| 1709 |
List<String> list1 = new ArrayList<>();
|
| 1710 |
list1.add(0, "0");
|
| 1711 |
list1.add(1, "0");
|
|
@@ -1786,9 +1786,9 @@ public class Worker extends Thread {
|
|
| 1786 |
}
|
| 1787 |
|
| 1788 |
}
|
| 1789 |
-
|
| 1790 |
|
| 1791 |
public static void createSocket(SessionEntity session) throws Exception {
|
|
|
|
| 1792 |
Socket socket = new Socket();
|
| 1793 |
socket.connect(new InetSocketAddress(InetAddress.getByName(session.getIp()), Integer.parseInt(session.getPort())), 7000);
|
| 1794 |
socket.setSoTimeout(350000);
|
|
@@ -1816,51 +1816,7 @@ public class Worker extends Thread {
|
|
| 1816 |
list1 = null;
|
| 1817 |
} catch (Exception e) {
|
| 1818 |
}
|
| 1819 |
-
|
| 1820 |
|
| 1821 |
-
}
|
| 1822 |
-
|
| 1823 |
-
|
| 1824 |
-
public static void createSocketLinhThu(SessionEntity session) throws Exception {
|
| 1825 |
-
Socket socket = new Socket();
|
| 1826 |
-
socket.connect(new InetSocketAddress(InetAddress.getByName(session.getIp()), Integer.parseInt(session.getPort())), 7000);
|
| 1827 |
-
socket.setSoTimeout(350000);
|
| 1828 |
-
try {
|
| 1829 |
-
session.getSocketNuoiLinhThu().close();
|
| 1830 |
-
} catch (Exception e) {
|
| 1831 |
-
}
|
| 1832 |
-
session.setSocketNuoiLinhThu(socket);
|
| 1833 |
-
|
| 1834 |
-
try {
|
| 1835 |
-
|
| 1836 |
-
// packet cap nhat thong tin lien tuc tu server
|
| 1837 |
-
Thread.sleep(5000);
|
| 1838 |
-
StaticCapNhatThongTinLinhThu(session);
|
| 1839 |
-
Thread.sleep(5000);
|
| 1840 |
-
GuiPacketKhongKQLinhThu(session, "52103", null);
|
| 1841 |
-
Thread.sleep(5000);
|
| 1842 |
-
GuiPacketKhongKQLinhThu(session, "10108", null);
|
| 1843 |
-
Thread.sleep(5000);
|
| 1844 |
-
GuiPacketKhongKQLinhThu(session, "20101", null);
|
| 1845 |
-
Thread.sleep(5000);
|
| 1846 |
-
List<String> list1 = new ArrayList<>();
|
| 1847 |
-
list1.add(0, "1");
|
| 1848 |
-
StringBuilder rs1 = GuiPacketLinhThu(session, "12200", list1);
|
| 1849 |
-
list1 = null;
|
| 1850 |
-
} catch (Exception e) {
|
| 1851 |
-
}
|
| 1852 |
-
|
| 1853 |
-
}
|
| 1854 |
-
|
| 1855 |
-
public void createSocket1(SessionEntity session) throws Exception {
|
| 1856 |
-
Socket socket = new Socket();
|
| 1857 |
-
socket.connect(new InetSocketAddress(InetAddress.getByName(session.getIp()), Integer.parseInt(session.getPort())), 7000);
|
| 1858 |
-
socket.setSoTimeout(350000);
|
| 1859 |
-
try {
|
| 1860 |
-
session.getSocket().close();
|
| 1861 |
-
} catch (Exception e) {
|
| 1862 |
-
}
|
| 1863 |
-
session.setSocket(socket);
|
| 1864 |
}
|
| 1865 |
|
| 1866 |
public static void createSocketApi(SessionEntity session) throws Exception {
|
|
@@ -1887,27 +1843,32 @@ public class Worker extends Thread {
|
|
| 1887 |
//}
|
| 1888 |
|
| 1889 |
MuaLinh();
|
| 1890 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1891 |
NangItem();
|
| 1892 |
LuyenTuong();
|
| 1893 |
NangNha();
|
| 1894 |
NangKiNang();
|
| 1895 |
NhanThuong();
|
| 1896 |
GianKhoan();
|
|
|
|
| 1897 |
// FarmDoLv60();
|
| 1898 |
-
|
| 1899 |
|
| 1900 |
ChiemMo();
|
| 1901 |
ChiemRuong();
|
| 1902 |
MuaRuong();
|
| 1903 |
CapNhatThongTin();
|
| 1904 |
|
| 1905 |
-
synchronized (this.lock) {
|
| 1906 |
-
if (this.isStop) {
|
| 1907 |
-
lock.wait();
|
| 1908 |
-
}
|
| 1909 |
-
}
|
| 1910 |
-
|
| 1911 |
//synchronized (lock) {
|
| 1912 |
// isfinish = true;
|
| 1913 |
// lock.wait();
|
|
|
|
|
|
|
| 1 |
package tqtk.XuLy;
|
| 2 |
|
| 3 |
import com.fasterxml.jackson.core.type.TypeReference;
|
|
|
|
| 31 |
import java.io.*;
|
| 32 |
import java.util.*;
|
| 33 |
import java.util.Collections;
|
| 34 |
+
import static tqtk.Tqtk.cauhoithuthue;
|
| 35 |
|
| 36 |
/**
|
| 37 |
*
|
|
|
|
| 609 |
Thread.sleep(5000);
|
| 610 |
GuiPacket(ss, "12100", list1);
|
| 611 |
}
|
| 612 |
+
list1.set(0, "5");
|
| 613 |
+
list1.add(1, "201");
|
| 614 |
+
GuiPacket(ss, "62005", list1);
|
| 615 |
|
| 616 |
} catch (Exception e) {
|
| 617 |
System.out.println("NangNha " + ss.getUserId() + e.getMessage());
|
|
|
|
| 711 |
List<String> list1 = new ArrayList<>();
|
| 712 |
list1.add(0, "17");
|
| 713 |
list1.add(1, "1");
|
| 714 |
+
|
| 715 |
+
List<String> list2 = new ArrayList<>();
|
| 716 |
list2.add(0, "1");
|
| 717 |
+
|
| 718 |
try {
|
| 719 |
|
| 720 |
Tqtk.sendMessage("nhan thuong " + ss.getUserId());
|
|
|
|
| 761 |
GuiPacket(ss, "60702", null);
|
| 762 |
Thread.sleep(2000);
|
| 763 |
GuiPacket(ss, "60703", null);
|
| 764 |
+
|
| 765 |
+
// quay so
|
| 766 |
+
Thread.sleep(2000);
|
| 767 |
GuiPacket(ss, "64002", list2);
|
| 768 |
|
| 769 |
} catch (Exception e) {
|
|
|
|
| 868 |
break;
|
| 869 |
}
|
| 870 |
}
|
| 871 |
+
if (carMap == null) {
|
| 872 |
+
return false;
|
| 873 |
+
}
|
| 874 |
Map<String, Object> carMap1 = (Map<String, Object>) ((Map<String, Object>) carMap.get("m")).get("imposedto");
|
| 875 |
|
|
|
|
|
|
|
| 876 |
if (carMap1 != null) {
|
| 877 |
Integer imposenum = (Integer) carMap1.get("imposenum");
|
| 878 |
+
if (imposenum > 38) {
|
| 879 |
+
return true;
|
| 880 |
+
}
|
| 881 |
+
return false;
|
| 882 |
}
|
| 883 |
} catch (Exception e) {
|
| 884 |
throw new JsonException();
|
| 885 |
}
|
| 886 |
|
| 887 |
}
|
| 888 |
+
return false;
|
| 889 |
} catch (Exception ex) {
|
| 890 |
if (!(ex instanceof JsonException)) {
|
| 891 |
System.out.println("loi qd " + ss.getUserId() + ex.getMessage());
|
| 892 |
} else {
|
| 893 |
System.out.println("loi qd json" + ss.getUserId() + ex.getMessage());
|
| 894 |
}
|
| 895 |
+
return false;
|
| 896 |
}
|
| 897 |
}
|
| 898 |
|
|
|
|
| 899 |
public void ThuThue() {
|
| 900 |
// danh quan doan vu van thi toc
|
| 901 |
List<String> list1 = new ArrayList<>();
|
|
|
|
| 905 |
list2.add(0, "0");
|
| 906 |
|
| 907 |
try {
|
| 908 |
+
if (CheckThuThue()) {
|
| 909 |
+
StringBuilder rs1 = GuiPacket(ss, "12401", list1);
|
| 910 |
+
Thread.sleep(5000);
|
| 911 |
+
if (rs1 != null) {
|
| 912 |
+
try {
|
| 913 |
+
String[] temp = rs1.toString().split("");
|
| 914 |
|
| 915 |
+
ObjectMapper mapper = new ObjectMapper();
|
| 916 |
+
Map<String, Object> carMap = null;
|
| 917 |
+
int h = 0;
|
| 918 |
+
for (String string : temp) {
|
| 919 |
+
carMap = mapper.readValue(string, new TypeReference<Map<String, Object>>() {
|
| 920 |
+
});
|
| 921 |
+
h = (int) carMap.get("h");
|
| 922 |
+
if (h == Integer.parseInt("12401")) {
|
| 923 |
+
break;
|
| 924 |
+
}
|
| 925 |
}
|
|
|
|
| 926 |
|
| 927 |
+
Map<String, Object> carMap1 = (Map<String, Object>) ((Map<String, Object>) carMap.get("m")).get("larrydto");
|
| 928 |
|
| 929 |
+
Tqtk.sendMessage("thuthue " + ss.getUserId());
|
| 930 |
|
| 931 |
+
if (carMap1 != null) {
|
| 932 |
+
String optdisc1 = (String) carMap1.get("optdisc1");
|
| 933 |
+
String optdisc2 = (String) carMap1.get("optdisc2");
|
| 934 |
|
| 935 |
+
List<String> cauhoi = cauhoithuthue;
|
| 936 |
|
| 937 |
+
for (String item : cauhoi) {
|
| 938 |
+
if (optdisc1.contains(item)) {
|
| 939 |
+
list2.set(0, "1");
|
| 940 |
+
rs1 = GuiPacket(ss, "12406", list2);
|
| 941 |
+
Thread.sleep(5000);
|
| 942 |
+
break;
|
| 943 |
+
} else if (optdisc2.contains(item)) {
|
| 944 |
+
list2.set(0, "2");
|
| 945 |
+
rs1 = GuiPacket(ss, "12406", list2);
|
| 946 |
+
Thread.sleep(5000);
|
| 947 |
+
break;
|
| 948 |
+
} else {
|
| 949 |
+
list2.set(0, "1");
|
| 950 |
+
rs1 = GuiPacket(ss, "12406", list2);
|
| 951 |
+
Thread.sleep(5000);
|
| 952 |
+
break;
|
| 953 |
+
}
|
| 954 |
}
|
|
|
|
| 955 |
|
| 956 |
+
}
|
| 957 |
+
} catch (Exception e) {
|
| 958 |
+
throw new JsonException();
|
| 959 |
}
|
| 960 |
+
|
|
|
|
| 961 |
}
|
| 962 |
|
| 963 |
}
|
|
|
|
|
|
|
|
|
|
| 964 |
|
| 965 |
} catch (Exception ex) {
|
| 966 |
if (!(ex instanceof JsonException)) {
|
|
|
|
| 1210 |
throw new JsonException();
|
| 1211 |
}
|
| 1212 |
} else {
|
| 1213 |
+
|
| 1214 |
}
|
| 1215 |
} catch (Exception ex) {
|
| 1216 |
if (!(ex instanceof JsonException)) {
|
| 1217 |
System.out.println("NangItem " + ss.getUserId() + ex.getMessage());
|
| 1218 |
+
|
| 1219 |
} else {
|
| 1220 |
System.out.println("NangItem json " + ss.getUserId() + ex.getMessage());
|
| 1221 |
}
|
|
|
|
| 1299 |
throw new JsonException();
|
| 1300 |
}
|
| 1301 |
} else {
|
| 1302 |
+
|
| 1303 |
}
|
| 1304 |
} catch (Exception ex) {
|
| 1305 |
if (!(ex instanceof JsonException)) {
|
| 1306 |
System.out.println("NangItem " + ss.getUserId() + ex.getMessage());
|
| 1307 |
+
|
| 1308 |
} else {
|
| 1309 |
System.out.println("NangItem json " + ss.getUserId() + ex.getMessage());
|
| 1310 |
}
|
|
|
|
| 1314 |
}
|
| 1315 |
|
| 1316 |
public void UyPhai() throws IOException, UnknownHostException, InterruptedException, Exception {
|
| 1317 |
+
if(!Util.checkIdRunUyPhai(ss.getUserId())){
|
| 1318 |
+
return;
|
| 1319 |
+
}
|
| 1320 |
List<String> list1 = new ArrayList<>();
|
| 1321 |
list1.add(0, "0");
|
| 1322 |
list1.add(1, "0");
|
|
|
|
| 1360 |
} catch (Exception ex) {
|
| 1361 |
if (!(ex instanceof JsonException)) {
|
| 1362 |
System.out.println("UyPhai " + ss.getUserId() + ex.getMessage());
|
| 1363 |
+
|
| 1364 |
} else {
|
| 1365 |
System.out.println("UyPhai json " + ss.getUserId() + ex.getMessage());
|
| 1366 |
}
|
|
|
|
| 1383 |
StringBuilder rs = GuiPacket(ss, "62007", list1);
|
| 1384 |
Thread.sleep(5000);
|
| 1385 |
if (rs != null) {
|
| 1386 |
+
Tqtk.sendMessage("gian khoan " + ss.getUserId());
|
| 1387 |
+
// bat dau khoan
|
| 1388 |
GuiPacket(ss, "62006", list2);
|
| 1389 |
+
|
| 1390 |
if (!rs.toString().contains("掘削中です")) {
|
| 1391 |
+
|
| 1392 |
}
|
| 1393 |
+
}
|
| 1394 |
|
| 1395 |
} catch (Exception ex) {
|
| 1396 |
System.out.println(ex.getMessage());
|
|
|
|
| 1478 |
} catch (Exception ex) {
|
| 1479 |
if (!(ex instanceof JsonException)) {
|
| 1480 |
System.out.println("CapNhatThongTin " + ss.getUserId() + ex.getMessage());
|
| 1481 |
+
|
| 1482 |
} else {
|
| 1483 |
System.out.println("CapNhatThongTin " + ss.getUserId() + ex.getMessage());
|
| 1484 |
}
|
|
|
|
| 1535 |
}
|
| 1536 |
|
| 1537 |
}
|
| 1538 |
+
|
| 1539 |
+
public static void StaticCapNhatThongTinLinhThu(SessionEntity ss) throws IOException, UnknownHostException, InterruptedException, Exception {
|
| 1540 |
try {
|
| 1541 |
Thread.sleep(5000);
|
| 1542 |
GuiPacketLinhThu(ss, "11102", null);
|
|
|
|
| 1625 |
} catch (Exception ex) {
|
| 1626 |
if (!(ex instanceof JsonException)) {
|
| 1627 |
System.out.println("cho den " + ss.getUserId() + ex.getMessage());
|
| 1628 |
+
|
| 1629 |
} else {
|
| 1630 |
System.out.println("cho den json " + ss.getUserId() + ex.getMessage());
|
| 1631 |
}
|
|
|
|
| 1634 |
|
| 1635 |
}
|
| 1636 |
|
|
|
|
| 1637 |
public void MuaRuong() throws IOException, UnknownHostException, InterruptedException, Exception {
|
| 1638 |
List<String> list1 = new ArrayList<>();
|
| 1639 |
list1.add(0, "3");
|
|
|
|
| 1696 |
} catch (Exception ex) {
|
| 1697 |
if (!(ex instanceof JsonException)) {
|
| 1698 |
System.out.println("cho den " + ss.getUserId() + ex.getMessage());
|
| 1699 |
+
|
| 1700 |
} else {
|
| 1701 |
System.out.println("cho den json " + ss.getUserId() + ex.getMessage());
|
| 1702 |
}
|
|
|
|
| 1704 |
}
|
| 1705 |
|
| 1706 |
}
|
| 1707 |
+
|
| 1708 |
+
public void NangHaLinhThu(SessionEntity ss) throws IOException, UnknownHostException, InterruptedException, Exception {
|
|
|
|
| 1709 |
List<String> list1 = new ArrayList<>();
|
| 1710 |
list1.add(0, "0");
|
| 1711 |
list1.add(1, "0");
|
|
|
|
| 1786 |
}
|
| 1787 |
|
| 1788 |
}
|
|
|
|
| 1789 |
|
| 1790 |
public static void createSocket(SessionEntity session) throws Exception {
|
| 1791 |
+
session.setSessionKey(Util.getSessiongId(session.getCookie()));
|
| 1792 |
Socket socket = new Socket();
|
| 1793 |
socket.connect(new InetSocketAddress(InetAddress.getByName(session.getIp()), Integer.parseInt(session.getPort())), 7000);
|
| 1794 |
socket.setSoTimeout(350000);
|
|
|
|
| 1816 |
list1 = null;
|
| 1817 |
} catch (Exception e) {
|
| 1818 |
}
|
|
|
|
| 1819 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1820 |
}
|
| 1821 |
|
| 1822 |
public static void createSocketApi(SessionEntity session) throws Exception {
|
|
|
|
| 1843 |
//}
|
| 1844 |
|
| 1845 |
MuaLinh();
|
| 1846 |
+
UyPhai();
|
| 1847 |
+
UyPhai();
|
| 1848 |
+
UyPhai();
|
| 1849 |
+
UyPhai();
|
| 1850 |
+
UyPhai();
|
| 1851 |
+
NangHaLinhThu(ss);
|
| 1852 |
NangItem();
|
| 1853 |
LuyenTuong();
|
| 1854 |
NangNha();
|
| 1855 |
NangKiNang();
|
| 1856 |
NhanThuong();
|
| 1857 |
GianKhoan();
|
| 1858 |
+
GianKhoan();
|
| 1859 |
// FarmDoLv60();
|
| 1860 |
+
ThuThue();
|
| 1861 |
|
| 1862 |
ChiemMo();
|
| 1863 |
ChiemRuong();
|
| 1864 |
MuaRuong();
|
| 1865 |
CapNhatThongTin();
|
| 1866 |
|
| 1867 |
+
// synchronized (this.lock) {
|
| 1868 |
+
// if (this.isStop) {
|
| 1869 |
+
// lock.wait();
|
| 1870 |
+
// }
|
| 1871 |
+
// }
|
|
|
|
| 1872 |
//synchronized (lock) {
|
| 1873 |
// isfinish = true;
|
| 1874 |
// lock.wait();
|
src/main/java/tqtk/XuLy/XuLyPacket.java
CHANGED
|
@@ -36,16 +36,17 @@ public class XuLyPacket {
|
|
| 36 |
wr.write(message);
|
| 37 |
wr.flush();
|
| 38 |
} catch (Exception e) {
|
| 39 |
-
System.out.println("GuiPacketKhongKQ "+e.getMessage());
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
|
|
|
| 45 |
}
|
| 46 |
|
| 47 |
}
|
| 48 |
-
|
| 49 |
public static void GuiPacketKhongKQLinhThu(SessionEntity ss, String code, List<String> list) throws UnknownHostException, IOException, InterruptedException {
|
| 50 |
BufferedWriter wr = null;
|
| 51 |
try {
|
|
@@ -55,11 +56,12 @@ public class XuLyPacket {
|
|
| 55 |
wr.write(message);
|
| 56 |
wr.flush();
|
| 57 |
} catch (Exception e) {
|
| 58 |
-
System.out.println("GuiPacketKhongKQLinhThu "+e.getMessage());
|
| 59 |
// if (e.getMessage().contains("socket write error")) {
|
| 60 |
try {
|
| 61 |
-
|
| 62 |
-
|
|
|
|
| 63 |
// }
|
| 64 |
}
|
| 65 |
|
|
@@ -91,12 +93,16 @@ public class XuLyPacket {
|
|
| 91 |
}
|
| 92 |
return rp;
|
| 93 |
} catch (Exception e) {
|
| 94 |
-
|
| 95 |
-
|
| 96 |
-
|
| 97 |
-
|
| 98 |
-
|
|
|
|
|
|
|
| 99 |
|
|
|
|
|
|
|
| 100 |
}
|
| 101 |
|
| 102 |
public static StringBuilder GuiPacketLinhThu(SessionEntity ss, String code, List<String> list) throws UnknownHostException, IOException, InterruptedException {
|
|
@@ -125,17 +131,17 @@ public class XuLyPacket {
|
|
| 125 |
}
|
| 126 |
return rp;
|
| 127 |
} catch (Exception e) {
|
| 128 |
-
System.out.println("GuiPacketLinhThu "+e.getMessage());
|
| 129 |
-
|
| 130 |
-
|
| 131 |
-
|
| 132 |
-
|
|
|
|
| 133 |
return null;
|
| 134 |
}
|
| 135 |
|
| 136 |
}
|
| 137 |
|
| 138 |
-
|
| 139 |
public static String GuiPacketHTTP(SessionEntity ss, String message) throws UnknownHostException, IOException, InterruptedException {
|
| 140 |
BufferedWriter wr = null;
|
| 141 |
StringBuilder rp = null;
|
|
@@ -331,10 +337,13 @@ public class XuLyPacket {
|
|
| 331 |
}
|
| 332 |
|
| 333 |
} catch (Exception e) {
|
| 334 |
-
System.out.println(e.getMessage());
|
| 335 |
-
|
| 336 |
-
|
| 337 |
-
|
|
|
|
|
|
|
|
|
|
| 338 |
return null;
|
| 339 |
}
|
| 340 |
return rp;
|
|
|
|
| 36 |
wr.write(message);
|
| 37 |
wr.flush();
|
| 38 |
} catch (Exception e) {
|
| 39 |
+
System.out.println("GuiPacketKhongKQ " + e.getMessage());
|
| 40 |
+
if (e.getMessage().contains("socket write error")) {
|
| 41 |
+
try {
|
| 42 |
+
tqtk.XuLy.Worker.createSocket(ss);
|
| 43 |
+
} catch (Exception e1) {
|
| 44 |
+
}
|
| 45 |
+
}
|
| 46 |
}
|
| 47 |
|
| 48 |
}
|
| 49 |
+
|
| 50 |
public static void GuiPacketKhongKQLinhThu(SessionEntity ss, String code, List<String> list) throws UnknownHostException, IOException, InterruptedException {
|
| 51 |
BufferedWriter wr = null;
|
| 52 |
try {
|
|
|
|
| 56 |
wr.write(message);
|
| 57 |
wr.flush();
|
| 58 |
} catch (Exception e) {
|
| 59 |
+
System.out.println("GuiPacketKhongKQLinhThu " + e.getMessage());
|
| 60 |
// if (e.getMessage().contains("socket write error")) {
|
| 61 |
try {
|
| 62 |
+
//tqtk.XuLy.Worker.createSocket(ss);
|
| 63 |
+
} catch (Exception e1) {
|
| 64 |
+
}
|
| 65 |
// }
|
| 66 |
}
|
| 67 |
|
|
|
|
| 93 |
}
|
| 94 |
return rp;
|
| 95 |
} catch (Exception e) {
|
| 96 |
+
System.out.println("GuiPacket " + e.getMessage());
|
| 97 |
+
if (e.getMessage().contains("socket write error")) {
|
| 98 |
+
try {
|
| 99 |
+
tqtk.XuLy.Worker.createSocket(ss);
|
| 100 |
+
} catch (Exception e1) {
|
| 101 |
+
}
|
| 102 |
+
}
|
| 103 |
|
| 104 |
+
}
|
| 105 |
+
return null;
|
| 106 |
}
|
| 107 |
|
| 108 |
public static StringBuilder GuiPacketLinhThu(SessionEntity ss, String code, List<String> list) throws UnknownHostException, IOException, InterruptedException {
|
|
|
|
| 131 |
}
|
| 132 |
return rp;
|
| 133 |
} catch (Exception e) {
|
| 134 |
+
System.out.println("GuiPacketLinhThu " + e.getMessage());
|
| 135 |
+
try {
|
| 136 |
+
//tqtk.XuLy.Worker.createSocket(ss);
|
| 137 |
+
} catch (Exception e1) {
|
| 138 |
+
}
|
| 139 |
+
|
| 140 |
return null;
|
| 141 |
}
|
| 142 |
|
| 143 |
}
|
| 144 |
|
|
|
|
| 145 |
public static String GuiPacketHTTP(SessionEntity ss, String message) throws UnknownHostException, IOException, InterruptedException {
|
| 146 |
BufferedWriter wr = null;
|
| 147 |
StringBuilder rp = null;
|
|
|
|
| 337 |
}
|
| 338 |
|
| 339 |
} catch (Exception e) {
|
| 340 |
+
System.out.println("GuiPacket1 " + e.getMessage());
|
| 341 |
+
if (e.getMessage().contains("socket write error")) {
|
| 342 |
+
try {
|
| 343 |
+
tqtk.XuLy.Worker.createSocket(ss);
|
| 344 |
+
} catch (Exception e1) {
|
| 345 |
+
}
|
| 346 |
+
}
|
| 347 |
return null;
|
| 348 |
}
|
| 349 |
return rp;
|
src/main/resources/application.properties
CHANGED
|
@@ -4,7 +4,7 @@ spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.PostgreSQLDialec
|
|
| 4 |
spring.jpa.hibernate.ddl-auto=update
|
| 5 |
spring.jpa.hibernate.show-sql=true
|
| 6 |
|
| 7 |
-
spring.datasource.url=jdbc:postgresql://dpg-
|
| 8 |
spring.datasource.username=test_3ff6_user
|
| 9 |
-
spring.datasource.password=
|
| 10 |
spring.datasource.driver-class-name=org.postgresql.Driver
|
|
|
|
| 4 |
spring.jpa.hibernate.ddl-auto=update
|
| 5 |
spring.jpa.hibernate.show-sql=true
|
| 6 |
|
| 7 |
+
spring.datasource.url=jdbc:postgresql://dpg-cj00ba18g3n4ain0ldgg-a.oregon-postgres.render.com:5432/test_3ff6_286p
|
| 8 |
spring.datasource.username=test_3ff6_user
|
| 9 |
+
spring.datasource.password=0FzOOVj8yjOB3SYE5jWDuaRaqonxUQOF
|
| 10 |
spring.datasource.driver-class-name=org.postgresql.Driver
|