From f537abe9f3646c739beaf15076246a2f71a347e9 Mon Sep 17 00:00:00 2001 From: admin <weikou2014> Date: 星期四, 20 二月 2025 16:57:55 +0800 Subject: [PATCH] IOS广告增加区域屏蔽 --- src/main/java/com/yeshi/buwan/util/IPUtil.java | 69 ---------------------------------- 1 files changed, 0 insertions(+), 69 deletions(-) diff --git a/src/main/java/com/yeshi/buwan/util/IPUtil.java b/src/main/java/com/yeshi/buwan/util/IPUtil.java index 6ea66e0..b8dff1e 100644 --- a/src/main/java/com/yeshi/buwan/util/IPUtil.java +++ b/src/main/java/com/yeshi/buwan/util/IPUtil.java @@ -1,89 +1,20 @@ package com.yeshi.buwan.util; import com.google.gson.Gson; -import com.show.api.ShowApiRequest; import net.sf.json.JSONObject; import org.apache.commons.httpclient.HttpClient; -import org.apache.commons.httpclient.HttpException; import org.apache.commons.httpclient.methods.GetMethod; import org.lionsoul.ip2region.xdb.Searcher; -import org.yeshi.utils.HttpUtil; import javax.servlet.http.HttpServletRequest; import java.io.BufferedInputStream; import java.io.File; -import java.io.IOException; -import java.io.UnsupportedEncodingException; import java.net.URL; import java.net.URLConnection; import java.net.URLEncoder; -import java.nio.charset.StandardCharsets; -import java.util.HashMap; -import java.util.Map; public class IPUtil { - private static Searcher searcher; - static { - try { - URL url = IPUtil.class.getClassLoader().getResource("ip2region.xdb"); - String path = new File(url.toURI()).getAbsolutePath(); - byte[] vIndex = Searcher.loadVectorIndexFromFile(path); - searcher = Searcher.newWithVectorIndex(path, vIndex); - } catch (Exception e) { - e.printStackTrace(); - } - } - - // http://verx.daili666.com/ip/?tid=558287898012218&num=1&operator=2 - public static void changeIp() { - System.getProperties().setProperty("proxySet", "true"); // 濡傛灉涓嶈缃紝鍙浠g悊IP鍜屼唬鐞嗙鍙f纭�,姝ら」涓嶈缃篃鍙互 - System.getProperties().setProperty("http.proxyHost", "213.85.92.10"); - System.getProperties().setProperty("http.proxyPort", "80"); - LogUtil.i(getHtml("http://www.ip138.com/ip2city.asp")); // 鍒ゆ柇浠g悊鏄惁璁剧疆鎴愬姛 - } - - private static String getHtml(String address) { - StringBuffer html = new StringBuffer(); - String result = null; - try { - URL url = new URL(address); - URLConnection conn = url.openConnection(); - conn.setRequestProperty("User-Agent", - "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; GTB5; .NET CLR 2.0.50727; CIBA)"); - BufferedInputStream in = new BufferedInputStream(conn.getInputStream()); - try { - String inputLine; - byte[] buf = new byte[4096]; - int bytesRead = 0; - while (bytesRead >= 0) { - inputLine = new String(buf, 0, bytesRead, "ISO-8859-1"); - html.append(inputLine); - bytesRead = in.read(buf); - inputLine = null; - } - buf = null; - } finally { - in.close(); - conn = null; - url = null; - } - result = new String(html.toString().trim().getBytes("ISO-8859-1"), "gb2312").toLowerCase(); - } catch (Exception e) { - e.printStackTrace(); - return null; - } - html = null; - return result; - } - - private static void sendNoticeEmail(String get) { - if (get != null && get.contains("璁㈠崟鍓╀綑鏁伴噺涓嶈冻")) { - /* - * MailSenderUtil.sendEmail("1101184511@qq.com", "绯荤粺鎻愮ず:IP璁㈠崟鍓╀綑鏁伴噺涓嶈冻", - * "IP璁㈠崟鍓╀綑鏁伴噺涓嶈冻锛岃鐧诲綍鍒颁唬鐞�666鍏呭��"); - */ - } } public static String getRemotIP(HttpServletRequest request) { -- Gitblit v1.8.0