mirror of
https://github.com/201206030/novel.git
synced 2025-04-27 07:30:50 +00:00
漫画图片防封功能增强
This commit is contained in:
parent
53d169360f
commit
7bf7db85e9
@ -13,16 +13,17 @@
|
||||
<label class="col-sm-3 control-label">分类:</label>
|
||||
<div class="col-sm-8">
|
||||
<select data-placeholder="--选择类别--" name="catid" id="catid"
|
||||
class="form-control chosen-select" tabindex="2" dict-type="novel_category" >
|
||||
class="form-control chosen-select" tabindex="2" dict-type="novel_category">
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="col-sm-3 control-label">封面:</label>
|
||||
<div class="col-sm-8">
|
||||
<img title="点击选择图片" id="picImage" style="cursor:pointer;width: 100px;height: 100px" src="/img/webuploader.png"/>
|
||||
<img title="点击选择图片" id="picImage" style="cursor:pointer;width: 100px;height: 100px"
|
||||
src="/img/webuploader.png"/>
|
||||
<input id="picUrl" name="picUrl" class="form-control"
|
||||
type="hidden" >
|
||||
type="hidden">
|
||||
|
||||
</div>
|
||||
</div>
|
||||
@ -104,7 +105,7 @@
|
||||
size: 1000,
|
||||
accept: 'file',
|
||||
done: function (r) {
|
||||
$("#picImage").attr("src",r.fileName);
|
||||
$("#picImage").attr("src", r.fileName);
|
||||
$("#picUrl").val(r.fileName);
|
||||
},
|
||||
error: function (r) {
|
||||
|
@ -10,7 +10,7 @@
|
||||
</parent>
|
||||
<groupId>xyz.zinglizingli</groupId>
|
||||
<artifactId>novel-front</artifactId>
|
||||
<version>2.0.1</version>
|
||||
<version>2.0.2.beta</version>
|
||||
<name>novel-front</name>
|
||||
<description>小说精品楼-前台web网站</description>
|
||||
|
||||
|
@ -3,6 +3,7 @@ package xyz.zinglizingli.common.filter;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.core.io.Resource;
|
||||
import org.springframework.http.*;
|
||||
import org.springframework.util.LinkedMultiValueMap;
|
||||
import org.springframework.util.MultiValueMap;
|
||||
@ -15,7 +16,7 @@ import xyz.zinglizingli.common.utils.SpringUtil;
|
||||
import javax.servlet.*;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.io.*;
|
||||
import java.net.URLDecoder;
|
||||
import java.util.*;
|
||||
import java.util.regex.Matcher;
|
||||
@ -152,7 +153,6 @@ public class SearchFilter implements Filter {
|
||||
}
|
||||
|
||||
|
||||
|
||||
String queryString = req.getQueryString();
|
||||
if (queryString != null && queryString.length() > 0 && !queryString.contains("bsh_bid=")) {
|
||||
queryString = "?" + URLDecoder.decode(req.getQueryString());
|
||||
@ -162,25 +162,62 @@ public class SearchFilter implements Filter {
|
||||
|
||||
|
||||
if (forObject == null) {
|
||||
String postFix = requestURI.substring(requestURI.lastIndexOf(".") + 1);
|
||||
if (picPostFix.contains(postFix)) {
|
||||
// 对服务端请求返回的输入流(byte[])采用何种编码转换成字符串(String)
|
||||
restTemplate = RestTemplateUtil.getInstance("iso-8859-1");//请求图片
|
||||
resp.setContentType("image/apng");
|
||||
}
|
||||
if (requestURI.startsWith("/manhua/images/")) {
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
headers.add("Referer","https://www.dmzj.com");
|
||||
HttpEntity<String> requestEntity = new HttpEntity<>(null, headers);
|
||||
String realUrl = "https://images.dmzj.com/" + requestURI.substring(15);
|
||||
ResponseEntity<Resource> resEntity = restTemplate.exchange(realUrl, HttpMethod.GET, requestEntity, Resource.class);
|
||||
InputStream input = resEntity.getBody().getInputStream();
|
||||
OutputStream out = resp.getOutputStream();
|
||||
byte[] b = new byte[4096];
|
||||
for (int n; (n = input.read(b)) != -1;) {
|
||||
out.write(b, 0, n);
|
||||
}
|
||||
input.close();
|
||||
out.close();
|
||||
return;
|
||||
|
||||
|
||||
ResponseEntity<String> forEntity = restTemplate.getForEntity("https://www.dmzj.com/"+requestURI.substring(8), String.class);
|
||||
// 对服务端请求返回的输入流(byte[])采用何种编码转换成字符串(String)
|
||||
|
||||
|
||||
|
||||
|
||||
} else if(requestURI.startsWith("/manhua/statics/")){
|
||||
String realPath = "https://static.dmzj.com/"+requestURI.substring(16);
|
||||
ResponseEntity<String> forEntity = restTemplate.getForEntity(realPath, String.class);
|
||||
forObject = forEntity.getBody();
|
||||
forObject = forObject.replaceAll("https://images.dmzj.com/", "/manhua/images/");
|
||||
|
||||
}else {
|
||||
String realPath = "https://www.dmzj.com/" + requestURI.substring(8);
|
||||
|
||||
ResponseEntity<String> forEntity = restTemplate.getForEntity(realPath, String.class);
|
||||
forObject = forEntity.getBody();
|
||||
|
||||
// forObject = new String(forObject.getBytes("ISO-8859-1"),"utf-8");
|
||||
forObject=forObject.replace("https://www.dmzj.com/js/ad/ad_12.js","");
|
||||
forObject=forObject.replace("https://www.dmzj.com/js/ad/ad_13.js","");
|
||||
forObject=forObject.replace("https://static.dmzj.com/ocomic/js/dmzjMhFinally-new.js","");
|
||||
forObject=forObject.replace("https://static.dmzj.com/ocomic/js/dmzjMhFinally-new.js","");
|
||||
forObject=forObject.replace("https://static.dmzj.com/module/js/float_code.js","");
|
||||
forObject=forObject.replaceAll("<script type=\"text/javascript\">var cnzz_protocol =[^<]+</script>","");
|
||||
forObject=forObject.replaceAll("https://static.dmzj.com/public/js/dmzj-land-2015.6.js","");
|
||||
forObject=forObject.replaceAll("<script type=\"text/javascript\">var cnzz_protocol =[^<]+</script>","");
|
||||
forObject=forObject.replaceAll("<script type=\"text/javascript\">var cnzz_protocol =[^<]+</script>","");
|
||||
forObject=forObject.replaceAll("<script type=\"text/javascript\">var cnzz_protocol =[^<]+</script>","");
|
||||
forObject=forObject.replaceAll("globalNav.js","");
|
||||
forObject=forObject.replaceAll("TSB.js","");
|
||||
forObject=forObject+"<script>var browser={\n" +
|
||||
forObject = forObject.replace("https://www.dmzj.com/js/ad/ad_12.js", "");
|
||||
forObject = forObject.replace("https://www.dmzj.com/js/ad/ad_13.js", "");
|
||||
forObject = forObject.replace("https://static.dmzj.com/ocomic/js/dmzjMhFinally-new.js", "");
|
||||
forObject = forObject.replace("https://static.dmzj.com/ocomic/js/dmzjMhFinally-new.js", "");
|
||||
forObject = forObject.replace("https://static.dmzj.com/module/js/float_code.js", "");
|
||||
forObject = forObject.replaceAll("<script type=\"text/javascript\">var cnzz_protocol =[^<]+</script>", "");
|
||||
forObject = forObject.replaceAll("https://static.dmzj.com/public/js/dmzj-land-2015.6.js", "");
|
||||
forObject = forObject.replaceAll("<script type=\"text/javascript\">var cnzz_protocol =[^<]+</script>", "");
|
||||
forObject = forObject.replaceAll("<script type=\"text/javascript\">var cnzz_protocol =[^<]+</script>", "");
|
||||
forObject = forObject.replaceAll("<script type=\"text/javascript\">var cnzz_protocol =[^<]+</script>", "");
|
||||
forObject = forObject.replaceAll("globalNav.js", "");
|
||||
forObject = forObject.replaceAll("TSB.js", "");
|
||||
forObject = forObject.replaceAll("https://images.dmzj.com/", "/manhua/images/");
|
||||
forObject = forObject.replaceAll("https://static.dmzj.com/", "/manhua/statics/");
|
||||
forObject = forObject + "<script>var browser={\n" +
|
||||
" versions:function(){\n" +
|
||||
" var u = window.navigator.userAgent;\n" +
|
||||
" return {\n" +
|
||||
@ -199,7 +236,7 @@ public class SearchFilter implements Filter {
|
||||
" }()\n" +
|
||||
"};" +
|
||||
"</script>";
|
||||
forObject=forObject+"<script>$(function(){$(\"#app_manhua\").remove();" +
|
||||
forObject = forObject + "<script>$(function(){$(\"#app_manhua\").remove();" +
|
||||
"$('.btmBtnBox').remove();$('.red_box').remove()" +
|
||||
";$('.mainNav').remove();$('.wrap_last_head').remove();$('.wrap_last_mid').remove()" +
|
||||
";$('.comic_gd').remove();$('.comic_last').remove();$('.side_bar').remove()" +
|
||||
@ -276,6 +313,7 @@ public class SearchFilter implements Filter {
|
||||
//
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
} else {
|
||||
@ -293,7 +331,7 @@ public class SearchFilter implements Filter {
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED);
|
||||
HttpEntity<MultiValueMap<String, String>> request = new HttpEntity<>(map, headers);
|
||||
forObject = restTemplate.postForEntity("https://www.dmzj.com/"+requestURI.substring(8), request, String.class).getBody();
|
||||
forObject = restTemplate.postForEntity("https://www.dmzj.com/" + requestURI.substring(8), request, String.class).getBody();
|
||||
// forObject = new String(forObject.getBytes("ISO-8859-1"),"utf-8");
|
||||
forObject = forObject.replaceAll("/manhua/", "https://www.dmzj.com/")
|
||||
.replaceAll("笔趣岛", "酸味书屋")
|
||||
@ -317,7 +355,6 @@ public class SearchFilter implements Filter {
|
||||
}
|
||||
|
||||
|
||||
|
||||
} catch (RuntimeException e) {
|
||||
log.error(e.getMessage(), e);
|
||||
if (e instanceof HttpClientErrorException && (((HttpClientErrorException) e).getStatusCode() == HttpStatus.NOT_FOUND)) {
|
||||
@ -333,6 +370,7 @@ public class SearchFilter implements Filter {
|
||||
//resp.setCharacterEncoding("utf-8");
|
||||
|
||||
}
|
||||
|
||||
resp.getWriter().print(forObject);
|
||||
return;
|
||||
}
|
||||
|
@ -3,12 +3,12 @@ server:
|
||||
|
||||
spring:
|
||||
datasource:
|
||||
# url: jdbc:mysql://148.70.59.92:3306/books?useUnicode=true&characterEncoding=utf-8&useSSL=false&allowPublicKeyRetrieval=true&serverTimezone=Asia/Shanghai
|
||||
# username: xiongxiaoyang
|
||||
# password: Lzslov123!
|
||||
url: jdbc:mysql://127.0.0.1:3306/books?useUnicode=true&characterEncoding=utf8&useSSL=false&allowPublicKeyRetrieval=true&serverTimezone=Asia/Shanghai
|
||||
url: jdbc:mysql://127.0.0.1:3306/books?useUnicode=true&characterEncoding=utf-8&useSSL=false&allowPublicKeyRetrieval=true&serverTimezone=Asia/Shanghai
|
||||
username: books
|
||||
password: books
|
||||
# url: jdbc:mysql://127.0.0.1:3306/books?useUnicode=true&characterEncoding=utf8&useSSL=false&allowPublicKeyRetrieval=true&serverTimezone=Asia/Shanghai
|
||||
# username: root
|
||||
# password: test123456
|
||||
cache:
|
||||
ehcache:
|
||||
config: classpath:ehcache.xml
|
||||
|
Loading…
x
Reference in New Issue
Block a user