From 7ab231a76ff0b493652de4581cde201fd0aeb360 Mon Sep 17 00:00:00 2001
From: admin <1782158860@qq.com>
Date: Thu, 13 Oct 2022 16:04:14 +0800
Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dbug?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../pay/interceptor/testInterceptor.java | 82 -------------------
src/sc545/pay/utils/GsonUtils.java | 2 -
src/sc545/pay/utils/HttpUtils.java | 16 +---
src/sc545/pay/utils/ReadTxt.java | 1 -
src/sc545/pay/utils/Utils.java | 16 ++--
src/springmvc-servlet.xml | 17 ----
6 files changed, 12 insertions(+), 122 deletions(-)
delete mode 100644 src/sc545/pay/interceptor/testInterceptor.java
diff --git a/src/sc545/pay/interceptor/testInterceptor.java b/src/sc545/pay/interceptor/testInterceptor.java
deleted file mode 100644
index 4d77c25..0000000
--- a/src/sc545/pay/interceptor/testInterceptor.java
+++ /dev/null
@@ -1,82 +0,0 @@
-package sc545.pay.interceptor;
-
-
-
-import java.io.PrintWriter;
-import java.util.Date;
-import java.util.List;
-import java.util.Map;
-
-import javax.servlet.http.*;
-
-import org.springframework.web.servlet.HandlerInterceptor;
-
-import sc545.pay.utils.DBUtil;
-import sc545.pay.utils.ReadTxt;
-import sc545.pay.utils.Utils;
-
-
-
-
-public class testInterceptor implements HandlerInterceptor{
-
- @Override
- public boolean preHandle(
- HttpServletRequest request,
- HttpServletResponse response,
- Object handler) throws Exception {
-
- response.setCharacterEncoding("utf-8");
- response.setContentType("text/html;charset=utf-8");
- request.setCharacterEncoding("utf-8");
-
- /*************************************拉黑高频访问ip******************************************/
- if(!"".equals(ReadTxt.getSetting(null, "拉黑ip.txt", Utils.getIpAddr(request), ""))){
- PrintWriter out = response.getWriter();
- out.print("系统检测到高频次访问已被拉黑IP
若误封请前往微信公众号【顺诚百宝箱】反馈
感谢理解!
IP:"+Utils.getIpAddr(request));
- return false;
- }
- String ipdate = ReadTxt.getSetting(null, "访问者IP.txt", Utils.getIpAddr(request), "");//获取此ip上次访问时间和已经访问的次数
- String[] idt = ipdate.split("_");//分隔
- long i=0;//已经访问的次数
- if(!"".equals(ipdate)){
- if(ipdate.indexOf("_")>0) i=Utils.getNum(idt[1]);
- //检查此ip第一次访问到现在过了几秒
- Date ds = Utils.string2Date(idt[0], null);
- long xc = (new Date().getTime() - ds.getTime())/1000;
- if(xc<=30){//30秒超过50次
- if(i>50){//拉黑此ip3天
- ReadTxt.writeSetting(null,"拉黑ip.txt", Utils.getIpAddr(request), Utils.date2String(new Date(), null));
- ReadTxt.delSetting(null, "访问者IP.txt", Utils.getIpAddr(request));
- }else{//正常ip
- }
- }else{//正常ip
- ReadTxt.delSetting(null, "访问者IP.txt", Utils.getIpAddr(request));
- }
- ReadTxt.writeSetting(null,"访问者IP.txt", Utils.getIpAddr(request), idt[0]+"_"+(++i));
- }else
- ReadTxt.writeSetting(null,"访问者IP.txt", Utils.getIpAddr(request), Utils.date2String(new Date(), "yyyy-MM-dd HH:mm:ss")+"_1");
- /*******************************************************************************/
-
-
-
-
-
- DBUtil db = new DBUtil();
-
- //闭站
- String cw = ReadTxt.getSetting(null, "setting.ini", "closeweb", "0");
- if("1".equals(cw)) {
- String uri = request.getRequestURI();
- if(uri.indexOf("/admin")<0){
- Utils.outHtml(response.getWriter(), ReadTxt.getSetting(null, "setting.ini", "closewebtxt", "本站暂停访问"), "/*about:blank*/");
- return false;
- }
- }
-
-
-
- return true;
- }
-
-}
diff --git a/src/sc545/pay/utils/GsonUtils.java b/src/sc545/pay/utils/GsonUtils.java
index 60821c3..a2bcb27 100644
--- a/src/sc545/pay/utils/GsonUtils.java
+++ b/src/sc545/pay/utils/GsonUtils.java
@@ -2,10 +2,8 @@ package sc545.pay.utils;
import java.lang.reflect.Type;
-import java.util.HashMap;
import java.util.List;
import java.util.Map;
-
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonParser;
diff --git a/src/sc545/pay/utils/HttpUtils.java b/src/sc545/pay/utils/HttpUtils.java
index 5bbe9cc..6922ac1 100644
--- a/src/sc545/pay/utils/HttpUtils.java
+++ b/src/sc545/pay/utils/HttpUtils.java
@@ -1,15 +1,7 @@
package sc545.pay.utils;
-import java.io.BufferedReader;
import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.PrintWriter;
import java.io.UnsupportedEncodingException;
-import java.net.HttpURLConnection;
-import java.net.URL;
-import java.net.URLConnection;
-import java.net.URLEncoder;
import java.security.KeyManagementException;
import java.security.KeyStoreException;
import java.security.NoSuchAlgorithmException;
@@ -29,12 +21,9 @@ import javax.net.ssl.TrustManager;
import javax.net.ssl.X509TrustManager;
import org.apache.commons.lang3.StringUtils;
-import org.apache.http.Header;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.NameValuePair;
-import org.apache.http.ParseException;
-import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.CookieStore;
import org.apache.http.client.HttpClient;
import org.apache.http.client.config.RequestConfig;
@@ -317,7 +306,8 @@ public class HttpUtils {
}
- private static org.apache.http.client.HttpClient wrapClient(HttpClient base) {
+ @SuppressWarnings("deprecation")
+ private static org.apache.http.client.HttpClient wrapClient(HttpClient base) {
try {
SSLContext ctx = SSLContext.getInstance("TLSv1");
X509TrustManager tm = new X509TrustManager() {
@@ -491,6 +481,7 @@ public class HttpUtils {
* @param header
* @return
*/
+ @SuppressWarnings("rawtypes")
public static String doPost2(String url, Map params, CookieStore cookie,Map header,String charset) {
if(charset==null||charset.trim().length()<1) charset="UTF-8";
if (StringUtils.isBlank(url)) {
@@ -548,6 +539,7 @@ public class HttpUtils {
return null;
}
+ @SuppressWarnings("rawtypes")
public static String doGet2(String url, Map params, CookieStore cookie,Map header,String charset) {
if(charset==null||charset.trim().length()<1) charset="UTF-8";
if (StringUtils.isBlank(url)) {
diff --git a/src/sc545/pay/utils/ReadTxt.java b/src/sc545/pay/utils/ReadTxt.java
index 7ae0838..b4f27f2 100644
--- a/src/sc545/pay/utils/ReadTxt.java
+++ b/src/sc545/pay/utils/ReadTxt.java
@@ -2,7 +2,6 @@ package sc545.pay.utils;
import java.io.*;
import java.util.ArrayList;
-import java.util.Calendar;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map.Entry;
diff --git a/src/sc545/pay/utils/Utils.java b/src/sc545/pay/utils/Utils.java
index f841cde..536da2c 100644
--- a/src/sc545/pay/utils/Utils.java
+++ b/src/sc545/pay/utils/Utils.java
@@ -29,8 +29,7 @@ import org.apache.commons.lang.time.DateUtils;
public class Utils {
public static void main(String[] args) {
- String s = floatToString(0.01235788889f, 3,false);
- System.out.println(s);
+ getWeekNum();
}
/**
@@ -702,12 +701,6 @@ public class Utils {
*/
public static long getDatePoor(Date endDate, Date nowDate) {
- long nd = 1000 * 24 * 60 * 60;// 一天
-
- long nh = 1000 * 60 * 60;// 一小时
-
- long nm = 1000 * 60;// 一分钟
-
long ns = 1000;// 一秒
// 获得两个时间的毫秒时间差异
@@ -718,6 +711,13 @@ public class Utils {
return sec;
}
+
+ /**获取今天是周几,1-7*/
+ public static long getWeekNum() {
+ long[] weekDays = {7,1,2,3,4,5,6};
+ Calendar c = Calendar.getInstance();
+ return weekDays[c.get(Calendar.DAY_OF_WEEK)-1];
+ }
/**
* 获取用户真实ip
diff --git a/src/springmvc-servlet.xml b/src/springmvc-servlet.xml
index 679c0be..06bfc76 100644
--- a/src/springmvc-servlet.xml
+++ b/src/springmvc-servlet.xml
@@ -37,21 +37,4 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-