Skip to content

Commit 06072e1

Browse files
committed
Merge remote-tracking branch 'origin/V4.0' into V5
2 parents b347bcd + bf1a66a commit 06072e1

File tree

20 files changed

+122
-75
lines changed

20 files changed

+122
-75
lines changed

data/publiccms/README.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
删除文件备份,由系统自动创建
33

44
dict
5-
自定义分词文件目录
5+
自定义分词文件目录,ip2region_v4.xdb,ip2region_v6.xdb存放在这里
66

77
history
88
文件修改历史,由系统自动创建

publiccms-parent/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ subprojects {
120120
// https://mvnrepository.com/artifact/com.github.therapi/therapi-runtime-javadoc
121121
therapiJavadocVersion = "0.15.0"
122122
// https://mvnrepository.com/artifact/org.jsoup/jsoup
123-
jsoupVersion = "1.21.2"
123+
jsoupVersion = "1.22.1"
124124
// https://mvnrepository.com/artifact/jakarta.annotation/jakarta.annotation-api
125125
annotationVersion = "3.0.0"
126126
// https://mvnrepository.com/artifact/jakarta.mail/jakarta.mail-api

publiccms-parent/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@
113113
<!-- https://mvnrepository.com/artifact/com.github.therapi/therapi-runtime-javadoc -->
114114
<version.therapiJavadoc>0.15.0</version.therapiJavadoc>
115115
<!-- https://mvnrepository.com/artifact/org.jsoup/jsoup -->
116-
<version.jsoup>1.21.2</version.jsoup>
116+
<version.jsoup>1.22.1</version.jsoup>
117117
<!-- https://mvnrepository.com/artifact/jakarta.annotation/jakarta.annotation-api -->
118118
<version.annotation>3.0.0</version.annotation>
119119
<!-- https://mvnrepository.com/artifact/jakarta.mail/jakarta.mail-api -->

publiccms-parent/publiccms-analyzer/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,6 @@ dependencies {
1010

1111
implementation "org.apache.lucene:lucene-analysis-smartcn:${luceneVersion}"
1212
// https://mvnrepository.com/artifact/org.lionsoul/ip2region
13-
implementation 'org.lionsoul:ip2region:3.3.1'
13+
implementation 'org.lionsoul:ip2region:3.3.3'
1414
implementation "jakarta.servlet:jakarta.servlet-api:${servletVersion}"
1515
}

publiccms-parent/publiccms-analyzer/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
<dependency>
2222
<groupId>org.lionsoul</groupId>
2323
<artifactId>ip2region</artifactId>
24-
<version>3.3.1</version>
24+
<version>3.3.3</version>
2525
</dependency>
2626
<dependency>
2727
<groupId>com.github.therapi</groupId>

publiccms-parent/publiccms-analyzer/src/main/java/com/publiccms/views/method/tools/GetIpRegionMethod.java

Lines changed: 52 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,25 @@
11
package com.publiccms.views.method.tools;
22

3+
import java.io.File;
34
import java.io.IOException;
4-
import java.io.InputStream;
55
import java.util.List;
66

7-
import org.apache.commons.io.IOUtils;
87
import org.apache.commons.lang3.StringUtils;
9-
import org.lionsoul.ip2region.xdb.LongByteArray;
10-
import org.lionsoul.ip2region.xdb.Searcher;
11-
import org.lionsoul.ip2region.xdb.Version;
8+
import org.lionsoul.ip2region.service.Config;
9+
import org.lionsoul.ip2region.service.InvalidConfigException;
10+
import org.lionsoul.ip2region.service.Ip2Region;
11+
import org.lionsoul.ip2region.xdb.XdbException;
1212
import org.springframework.stereotype.Component;
1313

1414
import com.publiccms.common.base.BaseMethod;
15+
import com.publiccms.common.constants.CommonConstants;
16+
import com.publiccms.common.tools.AnalyzerDictUtils;
1517
import com.publiccms.common.tools.CommonUtils;
16-
import com.publiccms.common.tools.IpUtils;
1718
import com.publiccms.views.pojo.entities.IpRegion;
1819

1920
import freemarker.template.TemplateModel;
2021
import freemarker.template.TemplateModelException;
22+
import jakarta.annotation.PreDestroy;
2123

2224
/**
2325
*
@@ -43,34 +45,51 @@
4345
*/
4446
@Component
4547
public class GetIpRegionMethod extends BaseMethod {
46-
private static LongByteArray longByteArray;
48+
private static Ip2Region ip2Region = null;
4749

48-
public GetIpRegionMethod() {
49-
try (InputStream inputStream = GetIpRegionMethod.class.getResourceAsStream("/ip2region_v4.xdb")) {
50-
longByteArray = new LongByteArray(IOUtils.toByteArray(inputStream));
51-
} catch (IOException e) {
52-
e.printStackTrace();
53-
longByteArray = null;
50+
private void init() {
51+
if (null == ip2Region) {
52+
synchronized (ip2Region) {
53+
try {
54+
if (null == ip2Region) {
55+
Config v4Config = null;
56+
File ipv4 = getFilePath("ip2region_v4.xdb");
57+
File ipv6 = getFilePath("ip2region_v6.xdb");
58+
if (ipv4.exists()) {
59+
Config.custom().setCachePolicy(Config.VIndexCache).setSearchers(20).setXdbFile(ipv4).asV4();
60+
} else {
61+
Config.custom().setCachePolicy(Config.BufferCache)
62+
.setXdbInputStream(GetIpRegionMethod.class.getResourceAsStream("/ip2region_v4.xdb")).asV4();
63+
}
64+
Config v6Config = null;
65+
if (ipv6.exists()) {
66+
v6Config = Config.custom().setCachePolicy(Config.VIndexCache).setSearchers(20).setXdbFile(ipv6)
67+
.asV6();
68+
}
69+
ip2Region = Ip2Region.create(v4Config, v6Config);
70+
}
71+
} catch (IOException | XdbException | InvalidConfigException e) {
72+
}
73+
}
5474
}
5575
}
5676

77+
private File getFilePath(String path) {
78+
File file = new File(CommonUtils.joinString(CommonConstants.CMS_FILEPATH, AnalyzerDictUtils.DIR_DICT, path));
79+
return file;
80+
}
81+
5782
@Override
5883
public Object execute(List<TemplateModel> arguments) throws TemplateModelException {
5984
String ip = getString(0, arguments);
60-
if (CommonUtils.notEmpty(ip) && IpUtils.isIpv4(ip) && null != longByteArray) {
61-
Searcher searcher = null;
85+
if (CommonUtils.notEmpty(ip)) {
6286
try {
63-
searcher = Searcher.newWithBuffer(Version.IPv4, longByteArray);
64-
return getIpRegion(searcher.search(ip));
87+
init();
88+
if (null != ip2Region) {
89+
return getIpRegion(ip2Region.search(ip));
90+
}
6591
} catch (Exception e) {
6692
log.error(e.getMessage());
67-
} finally {
68-
if (null != searcher) {
69-
try {
70-
searcher.close();
71-
} catch (IOException e) {
72-
}
73-
}
7493
}
7594
}
7695
return null;
@@ -104,4 +123,13 @@ private static IpRegion getIpRegion(String region) {
104123
return ipRegion;
105124
}
106125

126+
@PreDestroy
127+
public void destroy() {
128+
if (null != ip2Region) {
129+
try {
130+
ip2Region.close();
131+
} catch (InterruptedException e) {
132+
}
133+
}
134+
}
107135
}

publiccms-parent/publiccms-core/src/main/java/com/publiccms/controller/admin/sys/UeditorAdminController.java

Lines changed: 30 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
@Controller
4848
@RequestMapping("ueditor")
4949
public class UeditorAdminController extends AbstractUeditorController {
50-
50+
5151
/**
5252
* @param site
5353
* @return view name
@@ -137,8 +137,8 @@ public Map<String, Object> uploadScraw(@RequestAttribute SysSite site, @SessionA
137137
return getResultMap(false, e.getMessage());
138138
}
139139
} else {
140-
return getResultMap(false,
141-
LanguagesUtils.getMessage(CommonConstants.applicationContext, localeResolver.resolveLocale(request), "verify.notEmpty.file"));
140+
return getResultMap(false, LanguagesUtils.getMessage(CommonConstants.applicationContext,
141+
localeResolver.resolveLocale(request), "verify.notEmpty.file"));
142142
}
143143

144144
}
@@ -153,12 +153,13 @@ public Map<String, Object> uploadScraw(@RequestAttribute SysSite site, @SessionA
153153
@ResponseBody
154154
public Map<String, Object> catchimage(@RequestAttribute SysSite site, @SessionAttribute SysUser admin,
155155
HttpServletRequest request) {
156-
try (CloseableHttpClient httpclient = HttpClients.custom().setDefaultRequestConfig(Constants.defaultRequestConfig)
157-
.build()) {
158-
String[] files = request.getParameterValues(FIELD_NAME + "[]");
159-
if (CommonUtils.notEmpty(files)) {
160-
List<Map<String, Object>> list = new ArrayList<>();
161-
for (String image : files) {
156+
157+
String[] files = request.getParameterValues(FIELD_NAME + "[]");
158+
if (CommonUtils.notEmpty(files)) {
159+
List<Map<String, Object>> list = new ArrayList<>();
160+
for (String image : files) {
161+
try (CloseableHttpClient httpclient = HttpClients.custom().setDefaultRequestConfig(Constants.defaultRequestConfig)
162+
.build()) {
162163
HttpGet httpget = new HttpGet(image);
163164
CloseableHttpResponse response = httpclient.execute(httpget);
164165
HttpEntity entity = response.getEntity();
@@ -191,26 +192,31 @@ public Map<String, Object> catchimage(@RequestAttribute SysSite site, @SessionAt
191192
map.put("url", fileName);
192193
map.put("source", image);
193194
list.add(map);
195+
} else {
196+
Map<String, Object> map = getResultMap(false,"FAIL");
197+
map.put("source", image);
198+
list.add(map);
194199
}
200+
EntityUtils.consume(entity);
195201
}
196-
EntityUtils.consume(entity);
197-
}
198-
if (list.isEmpty()) {
199-
return getResultMap(false, LanguagesUtils.getMessage(CommonConstants.applicationContext, localeResolver.resolveLocale(request),
200-
"verify.notEmpty.file"));
201-
} else {
202-
Map<String, Object> map = getResultMap();
203-
map.put("list", list);
204-
return map;
202+
} catch (Exception e) {
203+
log.error(e.getMessage(), e);
204+
Map<String, Object> map = getResultMap(false,"FAIL");
205+
map.put("source", image);
206+
list.add(map);
205207
}
208+
}
209+
if (list.isEmpty()) {
210+
return getResultMap(false, LanguagesUtils.getMessage(CommonConstants.applicationContext,
211+
localeResolver.resolveLocale(request), "verify.notEmpty.file"));
206212
} else {
207-
return getResultMap(false, LanguagesUtils.getMessage(CommonConstants.applicationContext, localeResolver.resolveLocale(request),
208-
"verify.notEmpty.file"));
213+
Map<String, Object> map = getResultMap();
214+
map.put("list", list);
215+
return map;
209216
}
210-
} catch (Exception e) {
211-
log.error(e.getMessage(), e);
212-
return getResultMap(false,
213-
LanguagesUtils.getMessage(CommonConstants.applicationContext, localeResolver.resolveLocale(request), "verify.notEmpty.file"));
217+
} else {
218+
return getResultMap(false, LanguagesUtils.getMessage(CommonConstants.applicationContext,
219+
localeResolver.resolveLocale(request), "verify.notEmpty.file"));
214220
}
215221
}
216222

publiccms-parent/publiccms-oauth/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ dependencies {
1212
implementation "com.github.bastiaanjansen:otp-java:2.1.0"
1313
// https://mvnrepository.com/artifact/com.webauthn4j/webauthn4j-core
1414
// https://github.com/webauthn4j/webauthn4j
15-
implementation "com.webauthn4j:webauthn4j-core:0.30.1.RELEASE"
15+
implementation "com.webauthn4j:webauthn4j-core:0.30.2.RELEASE"
1616

1717
compileOnly "com.github.therapi:therapi-runtime-javadoc-scribe:${therapiJavadocVersion}"
1818
compileOnly "jakarta.servlet:jakarta.servlet-api:${servletVersion}"

publiccms-parent/publiccms-oauth/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
<dependency>
2727
<groupId>com.webauthn4j</groupId>
2828
<artifactId>webauthn4j-core</artifactId>
29-
<version>0.30.1.RELEASE</version>
29+
<version>0.30.2.RELEASE</version>
3030
</dependency>
3131
<dependency>
3232
<groupId>com.github.therapi</groupId>

publiccms-parent/publiccms-oss/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ dependencies {
88
implementation project(':publiccms-core')
99

1010
// https://mvnrepository.com/artifact/software.amazon.awssdk/s3
11-
implementation "software.amazon.awssdk:s3:2.40.9"
11+
implementation "software.amazon.awssdk:s3:2.41.1"
1212

1313
compileOnly "com.github.therapi:therapi-runtime-javadoc-scribe:${therapiJavadocVersion}"
1414
compileOnly "jakarta.servlet:jakarta.servlet-api:${servletVersion}"

0 commit comments

Comments
 (0)