Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
73 changes: 0 additions & 73 deletions src/main/java/cn/niter/forum/config/HttpsConfig.java

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
import cn.niter.forum.cache.HotTagCache;
import cn.niter.forum.cache.LoginUserCache;
import cn.niter.forum.dto.PaginationDTO;
import cn.niter.forum.dto.QuestionDTO;
import cn.niter.forum.dto.UserDTO;
import cn.niter.forum.model.User;
import cn.niter.forum.model.UserAccount;
import cn.niter.forum.service.QuestionService;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
Expand All @@ -30,7 +30,7 @@
*/

@Controller
public class TController {
public class TalkController {

@Autowired
private QuestionService questionService;
Expand All @@ -41,6 +41,9 @@ public class TController {
@Autowired
private LoginUserCache loginUserCache;

@Value("${vaptcha.vid}")
private String vaptcha_vid;

@GetMapping("/t")
public String tIndex(HttpServletRequest request, Model model,
@RequestParam(name = "page",defaultValue = "1")Integer page,
Expand All @@ -49,7 +52,7 @@ public String tIndex(HttpServletRequest request, Model model,
@RequestParam(name = "search", defaultValue = "") String search,
@RequestParam(name = "tag", defaultValue = "") String tag,
@RequestParam(name = "sort", defaultValue = "new") String sort) {
List<QuestionDTO> topQuestions = questionService.listTopwithColumn(search, tag, sort,column2);
//List<QuestionDTO> topQuestions = questionService.listTopwithColumn(search, tag, sort,column2);
// UserAccount userAccount = (UserAccount)request.getSession().getAttribute("userAccount");
//PaginationDTO pagination = questionService.listwithColumn(search, tag, sort, page,size,column2,userAccount);
List<String> tags = hotTagCache.getHots();
Expand All @@ -63,8 +66,9 @@ public String tIndex(HttpServletRequest request, Model model,
model.addAttribute("sort", sort);
model.addAttribute("column", column2);
model.addAttribute("page", page);
model.addAttribute("topQuestions", topQuestions);
//model.addAttribute("topQuestions", topQuestions);
model.addAttribute("navtype", "communitynav");
model.addAttribute("vaptcha_vid", vaptcha_vid);
//return "index";
return "t/index";
}
Expand Down
40 changes: 23 additions & 17 deletions src/main/java/cn/niter/forum/controller/UserController.java
Original file line number Diff line number Diff line change
Expand Up @@ -123,25 +123,31 @@ public Map<String,Object> set(HttpServletRequest request,
String constellation = userInfoService.getConstellation(Integer.parseInt(birthday[1]), Integer.parseInt(birthday[2]));
userInfo.setConstellation(constellation);
}
int i = userInfoService.updateByUserId(userInfo,user.getId());
int j = userService.updateUsernameById(user.getId(),obj.getString("username"));

if(j!=1){
map.put("code",500);
map.put("msg","妈呀,昵称修改失败啦!");
}
else if(i!=1) {
int conflictCount = userService.countUserByName(obj.getString("username"));
if (conflictCount == 0) {
int i = userInfoService.updateByUserId(userInfo,user.getId());
int j = userService.updateUsernameById(user.getId(),obj.getString("username"));
if(j!=1){
map.put("code",500);
map.put("msg","妈呀,昵称修改失败啦!");
}
else if(i!=1) {
map.put("code",500);
map.put("msg","妈呀,资料修改失败啦!");
}
else{
User dbUser = userService.selectUserByUserId(user.getId());
UserDTO userDTO = userService.getUserDTO(dbUser);
Cookie cookie = cookieUtils.getCookie("token",tokenUtils.getToken(userDTO),86400*3);
response.addCookie(cookie);
map.put("code",200);
map.put("msg","恭喜您,资料修改成功!!!");
}
}else{
map.put("code",500);
map.put("msg","妈呀,资料修改失败啦!");
}
else{
User dbUser = userService.selectUserByUserId(user.getId());
UserDTO userDTO = userService.getUserDTO(dbUser);
Cookie cookie = cookieUtils.getCookie("token",tokenUtils.getToken(userDTO),86400*3);
response.addCookie(cookie);
map.put("code",200);
map.put("msg","恭喜您,资料修改成功!!!");
map.put("msg","妈呀,昵称重复了!");
}

}

return map;
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/cn/niter/forum/mapper/UserMapper.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ public interface UserMapper {
*/
long countByExample(UserExample example);

long countUserByName(String name);

/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table user
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/cn/niter/forum/schedule/LoginUserTasks.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ public class LoginUserTasks {
private LoginUserCache loginUserCache;


@Scheduled(fixedRate = 1000 * 60 * 10)
// @Scheduled(fixedRate = 1000 * 60 * 10)
@Scheduled(fixedDelay = 1000 * 5)
public void loginUserSchedule() {
log.info("loginUserSchedule start {}", new Date());
//从cache中读取最近登录用户
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/cn/niter/forum/service/UserService.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ public User selectUserByExample(UserExample userExample){
return null;
}

public int countUserByName(String name){
return (int)userMapper.countUserByName(name);
}

public ResultDTO repass(Long user_id,String nowpass,String pass){
User user = userMapper.selectByPrimaryKey(user_id);
if((StringUtils.isBlank(nowpass)&&StringUtils.isBlank(user.getPassword()))||DigestUtils.sha256Hex(nowpass+salt).equals(user.getPassword())){
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/cn/niter/forum/util/CookieUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public class CookieUtils {

public Cookie getCookie(String key,String value,int time) {
Cookie cookie = new Cookie(key, value);
cookie.setSecure(true); //服务只能通过https来进行cookie的传递,使用http服务无法提供服务。
// cookie.setSecure(true); //服务只能通过https来进行cookie的传递,使用http服务无法提供服务。
cookie.setHttpOnly(true);//通过js脚本是无法获取到cookie的信息的。防止XSS攻击。
cookie.setMaxAge(time);//缩短为三天86400 * 3 * 1
cookie.setDomain(domain);
Expand Down
34 changes: 14 additions & 20 deletions src/main/resources/application.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,16 @@
#\u914D\u7F6E\u7AEF\u53E3\u53F7\uFF0C\u5B89\u88C5SSL\u914D\u7F6EHTTPS\uFF0C\u8BE6\u89C1\uFF1Ahttps://niter.cn/p/104
#\u5982\u679C\u65E0\u9700\u914D\u7F6EHTTPS\uFF0C\u8BF7\u53C2\u8003\u8BE6\u7EC6\u8BF4\u660E\u7684\u7B2C\u4E00\u70B9https://niter.cn/p/135\u3002
#http\u7AEF\u53E3\u53F7 80
server.custom.httpPort=80
#https\u52A0\u5BC6\u7AEF\u53E3\u53F7 443
server.port=443
#SSL\u8BC1\u4E66\u8DEF\u5F84 \u4E00\u5B9A\u8981\u52A0\u4E0Aclasspath:
server.ssl.key-store=classpath:niter_cn.jks
#SSL\u8BC1\u4E66\u5BC6\u7801
server.ssl.key-store-password=***
#\u8BC1\u4E66\u7C7B\u578B
server.ssl.key-store-type=JKS
#server.custom.httpPort=8080
server.port=8080


#\u7AD9\u70B9\u4FE1\u606F\uFF0C\u6539\u6210\u81EA\u5DF1\u7684\u5C31\u884C\u4E86
site.main.title=\u5C3C\u7279\u793E\u533A
site.main.titleInfo= _\u5C3C\u7279\u793E\u533A_Now ITer CN_niter.cn
site.main.title=\u4e8c\u624b\u793e\u533a
site.main.titleInfo= _\u4e8c\u624b\u793e\u533a_kunlun.com
#\u8FD9\u9879\u975E\u5E38\u91CD\u8981,\u8BF7\u52A1\u5FC5\u51C6\u786E\u586B\u5199\u57DF\u540D\u3001ip\u6216\u8005localhost\uFF0C\u4E0D\u8981\u52A0http(s)://\uFF0C\u4EE5\u53CA\u540E\u9762\u7684/\u3002
site.main.domain=niter.cn
site.main.domain=localhost
#site.main.domain=192.168.0.111
site.main.beian=***
site.home.title=\u5C3C\u7279IT
#\u7AD9\u70B9\u9996\u9875\u8BBE\u7F6E\uFF0C\u9ED8\u8BA41\u4E3A\u793E\u533Aforum\u8BBE\u4E3A\u9996\u9875\uFF0C2\u4E3A\u4E3B\u9875home\u8BBE\u4E3A\u9996\u9875
Expand Down Expand Up @@ -86,13 +80,13 @@ ali.showapi.appid=***
ali.showapi.sign=***

#\u624B\u52BF\u9A8C\u8BC1\u7801vaptcha\u7684vid\u4E0Ekey\uFF0C\u8BF7\u53BB\u5B98\u7F51\u83B7\u53D6https://www.vaptcha.com/ \u3002\u4E5F\u53EF\u4EE5\u4F7F\u7528\u81EA\u5DF1\u9009\u7528\u9A8C\u8BC1\u7801\u670D\u52A1\uFF0C\u4F46\u9700\u8981\u4FEE\u6539\u6E90\u7801\uFF01
vaptcha.vid=***
vaptcha.key=***
vaptcha.vid=5f6b08996b50b90a08399a0e
vaptcha.key=d65fa618a37d416e91e6b8097c3e7f62

#\u817E\u8BAF\u4F01\u4E1A\u90AE\u7BB1\u76F8\u5173\u914D\u7F6E\u4FE1\u606F\uFF0C\u8BF7\u53BB\u5B98\u7F51\u83B7\u53D6https://exmail.qq.com/ \u3002\u4E5F\u53EF\u4EE5\u4F7F\u7528\u81EA\u5DF1\u7684\u90AE\u7BB1\u8D26\u53F7\u3002\u4FEE\u6539\u6210\u5BF9\u5E94\u4FE1\u606F\u5373\u53EF\uFF01
exmail.account=***
exmail.password=***
exmail.smtp.host=smtp.exmail.qq.com
exmail.account=2720502910@qq.com
exmail.password=hwfmnndzsjpddfbc
exmail.smtp.host=smtp.qq.com

#\u6781\u5149\u77ED\u4FE1\u76F8\u5173\u914D\u7F6E\u4FE1\u606F\uFF0Cenable\u4E3A1\u5F00\u542F\u3002\u8BF7\u53BB\u5B98\u7F51\u83B7\u53D6https://www.jiguang.cn/ \u6587\u6863\uFF1Ahttps://docs.jiguang.cn/jsms/guideline/JSMS_guide/ \u3002 \u4E5F\u53EF\u4EE5\u4F7F\u7528\u81EA\u5DF1\u9009\u7528\u77ED\u4FE1\u670D\u52A1\uFF0C\u4F46\u9700\u8981\u4FEE\u6539\u6E90\u7801\uFF01
jiguang.devKey=***
Expand Down Expand Up @@ -125,9 +119,9 @@ qq.redirect.uri=http(s)://yourdomain/callbackqq
qq.api.unionId=0

#\u6570\u636E\u5E93\u914D\u7F6E\uFF0C\u586B\u5199\u4F60\u81EA\u5DF1\u7684
spring.datasource.url=jdbc:mysql://localhost:3306/niter
spring.datasource.username=***
spring.datasource.password=***
spring.datasource.url=jdbc:mysql://localhost:3306/niter?useSSL=false&characterEncoding=utf8&serverTimezone=GMT%2B8
spring.datasource.username=root
spring.datasource.password=zwx424036_!@#

#\u6570\u636E\u5E93\u914D\u7F6E2\uFF0C\u6309\u9700\u4FEE\u6539\uFF0C\u5982\u4E0D\u719F\u6089\u3002\u4E0D\u5EFA\u8BAE\u4FEE\u6539
spring.datasource.hikari.connection-init-sql=set names utf8mb4;
Expand Down
5 changes: 5 additions & 0 deletions src/main/resources/mapper/UserMapper.xml
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,11 @@
<include refid="Example_Where_Clause" />
</if>
</select>

<select id="countUserByName" parameterType="java.lang.String" resultType="java.lang.Long">
select count(*) from user where name=#{name}
</select>

<update id="updateByExampleSelective" parameterType="map">
<!--
WARNING - @mbg.generated
Expand Down
Binary file modified src/main/resources/static/images/qunQrcode.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/main/resources/static/images/qunQrcode11.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions src/main/resources/static/js/xss.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,13 @@ function getDefaultWhiteList() {
hr: [],
i: [],
iframe: ["src","scrolling","border","frameborder","framespacing","allowfullscreen"],
img: ["src", "alt", "title", "width", "height",'layer-index','style'],
img: ["src", "alt", "title", "width", "height","layer-index","style"],
ins: ["datetime"],
li: [],
mark: [],
nav: [],
ol: [],
p: ['id'],
p: ['id',"style"],
pre: [],
s: [],
section: [],
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/static/js/xss.min.js

Large diffs are not rendered by default.

Loading