From ee52957d319c686ec1a058faeb934381e25e8db9 Mon Sep 17 00:00:00 2001 From: Hellohao <923453645@qq.com> Date: Sun, 15 Dec 2019 17:55:12 +0800 Subject: [PATCH] =?UTF-8?q?2019-12-13=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pom.xml | 10 +- .../hellohao/controller/AdminController.java | 55 +- .../controller/AdminRootController.java | 32 +- .../hellohao/controller/ClientController.java | 22 +- .../hellohao/controller/CodeController.java | 12 +- .../hellohao/controller/GroupController.java | 16 +- .../controller/ImageReviewController.java | 4 - .../controller/UpdateImgController.java | 148 +++-- .../hellohao/controller/UserController.java | 15 +- src/main/java/cn/hellohao/pojo/Config.java | 7 +- .../java/cn/hellohao/pojo/UploadConfig.java | 13 +- src/main/java/cn/hellohao/quartz/test.java | 13 - .../hellohao/service/impl/COSImageupload.java | 30 +- .../hellohao/service/impl/FTPImageupload.java | 22 +- .../service/impl/GroupServiceImpl.java | 1 - .../cn/hellohao/service/impl/IPblacklist.java | 10 + .../hellohao/service/impl/ImgServiceImpl.java | 17 - .../service/impl/InitializationStorage.java | 7 +- .../service/impl/KODOImageupload.java | 18 - .../service/impl/KeysServiceImpl.java | 1 - .../hellohao/service/impl/NOSImageupload.java | 20 +- .../hellohao/service/impl/OSSImageupload.java | 43 +- .../hellohao/service/impl/USSImageupload.java | 12 +- .../service/impl/UserServiceImpl.java | 11 +- .../hellohao/utils/AfterServiceStarted.java | 17 - .../cn/hellohao/utils/Base64Encryption.java | 21 - .../java/cn/hellohao/utils/DateUtils.java | 10 +- src/main/java/cn/hellohao/utils/DeleImg.java | 5 - src/main/java/cn/hellohao/utils/FTPUtils.java | 108 +--- src/main/java/cn/hellohao/utils/FirstRun.java | 50 ++ .../cn/hellohao/utils/GetCurrentSource.java | 1 - src/main/java/cn/hellohao/utils/GetIPS.java | 4 - .../java/cn/hellohao/utils/GetSource.java | 2 - .../java/cn/hellohao/utils/IPPortUtil.java | 2 - .../java/cn/hellohao/utils/ImageReview.java | 84 --- .../java/cn/hellohao/utils/ImgUrlUtil.java | 65 -- .../cn/hellohao/utils/JianHuangThread.java | 32 - .../java/cn/hellohao/utils/LocUpdateImg.java | 23 +- .../java/cn/hellohao/utils/PrintThread.java | 31 - .../java/cn/hellohao/utils/SendEmail.java | 3 - src/main/java/cn/hellohao/utils/Sentence.java | 5 - src/main/java/cn/hellohao/utils/SetFiles.java | 1 - .../hellohao/utils/SpringContextHolder.java | 3 +- .../java/cn/hellohao/utils/SqlHelper.java | 111 ++++ .../java/cn/hellohao/utils/StringUtils.java | 15 - .../cn/hellohao/utils/VerificationDomain.java | 40 -- src/main/resources/application.properties | 2 +- src/main/resources/mapper/ConfigMapper.xml | 1 + .../resources/mapper/UploadConfigMapper.xml | 5 +- .../resources/static/js/main_constellation.js | 4 +- src/main/resources/static/layui/js/zadmin.js | 3 + .../resources/static/static/css/style.css | 2 +- .../static/static/js/login-register.js | 17 +- .../resources/static/webuploade/js/upload.js | 21 +- .../static/webuploade/js/webuploader.js | 3 +- src/main/resources/templates/admin/about.html | 3 +- src/main/resources/templates/admin/index.html | 4 + .../resources/templates/admin/modifyuser.html | 10 - .../resources/templates/admin/setgroup.html | 10 - .../resources/templates/admin/setuser.html | 20 - .../templates/admin/storageconfig.html | 31 +- .../resources/templates/admin/survey.html | 61 +- src/main/resources/templates/admin/table.html | 149 +---- src/main/resources/templates/admin/user.html | 46 +- .../resources/templates/admin/webconfig.html | 30 +- src/main/resources/templates/check.html | 13 +- src/main/resources/templates/footer.html | 64 -- src/main/resources/templates/header.html | 48 -- src/main/resources/templates/index.html | 232 +++---- .../resources/templates/index_upload.html | 578 ------------------ src/main/resources/templates/isok.html | 4 +- 71 files changed, 547 insertions(+), 1986 deletions(-) delete mode 100644 src/main/java/cn/hellohao/quartz/test.java create mode 100644 src/main/java/cn/hellohao/service/impl/IPblacklist.java create mode 100644 src/main/java/cn/hellohao/utils/FirstRun.java delete mode 100644 src/main/java/cn/hellohao/utils/ImageReview.java delete mode 100644 src/main/java/cn/hellohao/utils/JianHuangThread.java delete mode 100644 src/main/java/cn/hellohao/utils/PrintThread.java create mode 100644 src/main/java/cn/hellohao/utils/SqlHelper.java delete mode 100644 src/main/java/cn/hellohao/utils/VerificationDomain.java delete mode 100644 src/main/resources/templates/footer.html delete mode 100644 src/main/resources/templates/header.html delete mode 100644 src/main/resources/templates/index_upload.html diff --git a/pom.xml b/pom.xml index 0feb0f6..4a2fe48 100644 --- a/pom.xml +++ b/pom.xml @@ -81,11 +81,11 @@ 5.5.7 - - cn.ucloud.ufile - ufile-client-java - 2.3.0 - + + + + + commons-net diff --git a/src/main/java/cn/hellohao/controller/AdminController.java b/src/main/java/cn/hellohao/controller/AdminController.java index b4c4823..274b115 100644 --- a/src/main/java/cn/hellohao/controller/AdminController.java +++ b/src/main/java/cn/hellohao/controller/AdminController.java @@ -71,7 +71,6 @@ public class AdminController { model.addAttribute("usermemory", 0);//单位M }else{ float d = (float) (Math.round((usermemory/1024.0F) * 100.0) / 100.0); - //Print.Normal(); model.addAttribute("usermemory", d);//单位M } return "admin/index"; @@ -137,25 +136,20 @@ public class AdminController { @ResponseBody public String getwebconfig(HttpSession session) { JSONObject jsonObject = new JSONObject(); - Config config = configService.getSourceype(); + //Config config = configService.getSourceype(); + UploadConfig uploadConfig = uploadConfigService.getUpdateConfig(); User u = (User) session.getAttribute("user"); - Integer Sourcekey = GetCurrentSource.GetSource(u.getId()); Imgreview imgreview = imgreviewService.selectByPrimaryKey(1); jsonObject.put("usercount", imgService.countimg(u.getId())); jsonObject.put("counts", imgService.counts(null) ); - jsonObject.put("getusertotal", userService.getUserTotal() ); + jsonObject.put("getusertotal", userService.getUserTotal()); jsonObject.put("imgreviewcount", imgreview.getCount()); - Keys key= keysService.selectKeys(Sourcekey); - Boolean b =false; - if(Sourcekey==5){ - b =true; + if(uploadConfig.getIsupdate()!=1){ + jsonObject.put("VisitorUpload", 0);//是否禁用了游客上传 }else{ - b = StringUtils.doNull(Sourcekey,key);//判断对象是否有空值 - } - if(b){ - jsonObject.put("source", key.getStorageType()); - }else{ - jsonObject.put("source", 456); + jsonObject.put("VisitorUpload", uploadConfig.getIsupdate());//是否禁用了游客上传 + jsonObject.put("UsedSize", (imgService.getusermemory(0)/1024));//访客已用大小 + jsonObject.put("VisitorMemory", uploadConfig.getVisitormemory());//访客共大小 } return jsonObject.toString(); } @@ -178,28 +172,25 @@ public class AdminController { img.setStoptime(stoptime); } } - // 使用Pagehelper传入当前页数和页面显示条数会自动为我们的select语句加上limit查询 - // 从他的下一条sql开始分页 PageHelper.startPage(pageNum, pageSize); List images = null; - if (u.getLevel() > 1) { //根据用户等级查询管理员查询所有的信息 + if (u.getLevel() > 1) { if (selecttype == 1) { - images = imgService.selectimg(img);// 这是我们的sql + images = imgService.selectimg(img); } else { img.setUserid(u.getId()); - images = imgService.selectimg(img);// 这是我们的sql + images = imgService.selectimg(img); } } else { img.setUserid(u.getId()); - images = imgService.selectimg(img);// 这是我们的sql + images = imgService.selectimg(img); } - // 使用pageInfo包装查询 - PageInfo rolePageInfo = new PageInfo<>(images);// + PageInfo rolePageInfo = new PageInfo<>(images); return new PageResultBean<>(rolePageInfo.getTotal(), rolePageInfo.getList()); } - //获取用户信息列表 + @RequestMapping(value = "/selectusertable") @ResponseBody public Map selectByFy12(HttpSession session, @RequestParam(required = false, defaultValue = "1") int page, @@ -207,12 +198,11 @@ public class AdminController { User u = (User) session.getAttribute("user"); PageHelper.startPage(page, limit); List users = null; - if (u.getLevel() > 1) { //根据用户等级查询管理员查询所有的信息 + if (u.getLevel() > 1) { User user = new User(); user.setUsername(username); - users = userService.getuserlist(user);// 这是我们的sql - // 使用pageInfo包装查询 - PageInfo rolePageInfo = new PageInfo<>(users);// + users = userService.getuserlist(user); + PageInfo rolePageInfo = new PageInfo<>(users); Map map = new HashMap(); map.put("code", 0); map.put("msg", ""); @@ -273,12 +263,10 @@ public class AdminController { return jsonObject.toString(); } - //批量删除图片 @PostMapping("/deleallimg") @ResponseBody public String deleallimg(HttpSession session, @RequestParam("ids[]") Integer[] ids) { JSONObject jsonObject = new JSONObject(); - Integer v = 0; ImgServiceImpl de = new ImgServiceImpl(); User u = (User) session.getAttribute("user"); @@ -326,27 +314,22 @@ public class AdminController { return jsonObject.toString(); } - //进入修改密码页面 @RequestMapping(value = "/tosetuser") public String tosetuser(HttpSession session, Model model, HttpServletRequest request) { User u = (User) session.getAttribute("user"); - //key信息 model.addAttribute("user", u); return "admin/setuser"; } - //修改资料 @PostMapping("/change") @ResponseBody public String change(HttpSession session, User user) { User u = (User) session.getAttribute("user"); User us = new User(); - //user.setEmail(u.getEmail()); us.setEmail(user.getEmail()); us.setUsername(user.getUsername()); us.setPassword(Base64Encryption.encryptBASE64(user.getPassword().getBytes())); us.setUid(u.getUid()); - //user.setUid(u.getUid()); JSONArray jsonArray = new JSONArray(); Integer ret =0; if(u.getLevel()==1){ @@ -359,7 +342,6 @@ public class AdminController { jsonArray.add(ret); if (u.getEmail() != null && u.getPassword() != null) { session.removeAttribute("user"); - //刷新view session.invalidate(); } // -1 用户名重复 @@ -387,7 +369,6 @@ public class AdminController { Integer ret =0; Integer sizes = 0; if(u!=null){ - //List code = codeService.selectCode(codestring); Code c = codeService.selectCodekey(codestring); Print.warning(c); if(c!=null) { @@ -398,7 +379,6 @@ public class AdminController { ret = userServiceImpl.usersetmemory(user,codestring); if(ret>0){ ret = 1; } }else{ - //扩容码不存在 ret=-1; } }else{ @@ -410,7 +390,6 @@ public class AdminController { return jsonObject.toString(); } - @GetMapping(value = "/images/{id}") @ResponseBody public Images selectByFy(@PathVariable("id") Integer id) { diff --git a/src/main/java/cn/hellohao/controller/AdminRootController.java b/src/main/java/cn/hellohao/controller/AdminRootController.java index 8db9c88..56d46ba 100644 --- a/src/main/java/cn/hellohao/controller/AdminRootController.java +++ b/src/main/java/cn/hellohao/controller/AdminRootController.java @@ -41,29 +41,24 @@ public class AdminRootController { private SysConfigService sysConfigService; @Autowired private GroupService groupService; - //@Autowired - //private UserGroupService userGroupService; @Value("${systemupdate}") private String systemupdate; - //返回对象存储界面 @RequestMapping(value = "/touser") public String touser() { return "admin/user"; } - //返回对象存储界面 @RequestMapping(value = "tostorage") public String tostorage(HttpSession session, Model model, HttpServletRequest request) { User u = (User) session.getAttribute("user"); Integer Sourcekey = GetCurrentSource.GetSource(u.getId()); - Keys key= keysService.selectKeys(Sourcekey);//然后根据类型再查询key - Boolean b = StringUtils.doNull(Sourcekey,key);//判断对象是否有空值 + Keys key= keysService.selectKeys(Sourcekey); + Boolean b = StringUtils.doNull(Sourcekey,key); Integer StorageType = 0; if(Sourcekey!=5){ if(b){ - //key信息 model.addAttribute("AccessKey", key.getAccessKey()); model.addAttribute("AccessSecret", key.getAccessSecret()); model.addAttribute("Endpoint", key.getEndpoint()); @@ -71,20 +66,18 @@ public class AdminRootController { model.addAttribute("RequestAddress", key.getRequestAddress()); model.addAttribute("StorageType", Sourcekey); } - //如果是4就是七牛 if(Sourcekey==4){ model.addAttribute("Endpoint2", key.getEndpoint()); }else{ model.addAttribute("Endpoint2", 0); } }else{ - model.addAttribute("StorageType", 5);//切换到本地 + model.addAttribute("StorageType", 5); model.addAttribute("Endpoint2", 0); } return "admin/storageconfig"; } - @PostMapping("/getkey") @ResponseBody public String getkey(Integer storageType) { @@ -113,7 +106,6 @@ public class AdminRootController { Config config = new Config(); config.setSourcekey(key.getStorageType()); Integer val = configService.setSourceype(config); - //if (val > 0) { Integer ret = -2; //修改完初始化 if(key.getStorageType()==1){ @@ -140,13 +132,9 @@ public class AdminRootController { //0,保存失败 //1 正确 jsonArray.add(ret); - //} else { - //jsonArray.add(0); - // } return jsonArray.toString(); } - //刪除用戶 @PostMapping("/deleuser") @ResponseBody public String deleuser(HttpSession session, Integer id) { @@ -156,13 +144,11 @@ public class AdminRootController { jsonArray.add("-1"); }else{ Integer ret = userService.deleuser(id); - //userGroupService.deleusergroup(id); jsonArray.add(ret); } return jsonArray.toString(); } - //跳转邮箱配置页面 @RequestMapping(value = "/emailconfig") public String emailconfig(Model model) { EmailConfig emailConfig = emailConfigService.getemail(); @@ -170,7 +156,6 @@ public class AdminRootController { return "admin/emailconfig"; } - @PostMapping("/updateemail") @ResponseBody public Integer updateemail(HttpSession session,String emails, String emailkey, String emailurl, String port, String emailname, Integer using ) { @@ -198,11 +183,9 @@ public class AdminRootController { model.addAttribute("group",Sourcekey); return "admin/webconfig"; } - //修改站点配置 @PostMapping("/updateconfig") @ResponseBody public Integer updateconfig(Config config ) { - Integer ret = configService.setSourceype(config); return ret; } @@ -214,7 +197,6 @@ public class AdminRootController { return ret; } - //修改用户激活状态 @PostMapping("/setisok") @ResponseBody public String setisok(HttpSession session, User user) { @@ -223,7 +205,7 @@ public class AdminRootController { jsonArray.add(ret); return jsonArray.toString(); } - //修改资料 + @PostMapping("/setmemory") @ResponseBody public String setmemory(HttpSession session, User user) { @@ -233,7 +215,6 @@ public class AdminRootController { return jsonArray.toString(); } - //修改注册开关 @PostMapping("/setstate") @ResponseBody public Integer setstate(HttpSession session, SysConfig sysConfig) { @@ -261,8 +242,6 @@ public class AdminRootController { return val; } - - //关于系统 @RequestMapping("/about") public String about(HttpSession session,Model model ) { //Integer ret = uploadConfigService.setUpdateConfig(updateConfig); @@ -271,7 +250,7 @@ public class AdminRootController { model.addAttribute("systemupdate",systemupdate); return "admin/about"; } - //检查更新 + @PostMapping("/sysupdate") @ResponseBody public Integer sysupdate(String dates) { @@ -279,7 +258,6 @@ public class AdminRootController { String urls ="http://tc.hellohao.cn/systemupdate"; paramMap.put("dates",dates); String result= HttpUtil.post(urls, paramMap); -// System.out.println(Integer.parseInt( result )); return Integer.parseInt( result ); } diff --git a/src/main/java/cn/hellohao/controller/ClientController.java b/src/main/java/cn/hellohao/controller/ClientController.java index 72cfc81..ad93090 100644 --- a/src/main/java/cn/hellohao/controller/ClientController.java +++ b/src/main/java/cn/hellohao/controller/ClientController.java @@ -112,7 +112,6 @@ public class ClientController { Map map = new HashMap<>(); for (MultipartFile multipartFile : file) { //获取文件名 - System.out.println(multipartFile.toString()); String fileName = multipartFile.getOriginalFilename(); String lastname = fileName.substring(fileName.lastIndexOf(".") + 1);//获取文件后缀 if (!multipartFile.isEmpty()) { //判断文件是否为空 @@ -213,7 +212,6 @@ public class ClientController { jsonArray.add(jsonObject); } } - //上传成功 resultBean = ResultBean.success(jsonArray); } else {resultBean = ResultBean.error(-1, "服务器内部错误,请联系管理员");} } @@ -221,7 +219,6 @@ public class ClientController { } else {resultBean = ResultBean.error(-3, "邮箱密码为空");} } else{resultBean = ResultBean.error(-4, "管理员关闭了API接口");} - //return jsonArray.toString(); return resultBean; } @@ -280,14 +277,11 @@ public class ClientController { usermemory= imgService.getusermemory(u.getId()); if(usermemory==null){usermemory = 0;} } - //先判断对象存储key是不是null Print.warning("上传地址是:"+request.getSession().getServletContext().getRealPath("/")+"/hellohaotmp/"); if(bo){ if(usermemory/10240 && imgsize<=(yonghu*1024*1024)){ try{ boolean bl =ImgUrlUtil.downLoadFromUrl(imgurl, @@ -298,13 +292,10 @@ public class ClientController { is.read(b, 0, b.length); String xxx = ImgUrlUtil.bytesToHexString(b); xxx = xxx.toUpperCase(); - System.out.println("头文件是:" + xxx); String ooo = TypeDict.checkType(xxx); - System.out.println("后缀名是:" + ooo); if(is!=null){ is.close(); } - //判断文件头是否是图片 if(!ooo.equals("0000")){ Map map = new HashMap<>(); map.put(ooo, request.getSession().getServletContext().getRealPath("/")+"/hellohaotmp/"+uuid); @@ -347,9 +338,9 @@ public class ClientController { img.setUpdatetime(times); img.setSource(key.getStorageType()); if (u == null) { - img.setUserid(0);//用户id + img.setUserid(0); } else { - img.setUserid(u.getId());//用户id + img.setUserid(u.getId()); } img.setSizes((entry.getValue())); img.setImgname(SetText.getSubString(entry.getKey().getImgurl(), key.getRequestAddress() + "/", "")); @@ -370,7 +361,6 @@ public class ClientController { resultBean = ResultBean.error(-4,"该文件不支持上传"); } }else{ - //文件过大 resultBean = ResultBean.error(-2,"文件过大"); } }else{ @@ -384,13 +374,10 @@ public class ClientController { is.read(b, 0, b.length); String xxx = ImgUrlUtil.bytesToHexString(b); xxx = xxx.toUpperCase(); - //System.out.println("头文件是:" + xxx); String ooo = TypeDict.checkType(xxx); - //System.out.println("后缀名是:" + ooo); if(is!=null){ is.close(); } - //判断文件头是否是图片 if(!xxx.equals("0000")){ Map map = new HashMap<>(); map.put(ooo, request.getSession().getServletContext().getRealPath("/")+"/hellohaotmp/"+uuid); @@ -445,7 +432,6 @@ public class ClientController { long etime = System.currentTimeMillis(); System.out.println("上传图片所用时长:" + String.valueOf(etime - stime) + "ms"); } - //上传成功 resultBean = ResultBean.success(jsonArray); }else{ resultBean = ResultBean.error(-3,"文件类型不符合要求"); @@ -457,7 +443,6 @@ public class ClientController { resultBean = ResultBean.error(-4,"文件类型不符合要求"); } }else{ - //文件过大 resultBean = ResultBean.error(-2,"图片太大或不存在"); } } @@ -504,7 +489,6 @@ Print.Normal(resultBean.toString()); @GetMapping (value = "/notices") @ResponseBody public String notices() throws Exception { - return "-1";//-1就是没有公告,客户端不显示 } //主端接口 @@ -512,7 +496,6 @@ Print.Normal(resultBean.toString()); @ResponseBody public String sysupdate(String dates) { Integer i=dates.compareTo(systemupdate);//小于0则需要更新 - System.out.println(i); return i.toString(); } //主端接口 @@ -520,7 +503,6 @@ Print.Normal(resultBean.toString()); @ResponseBody public String getdomain(String domain) { Integer count = domainService.getDomain(domain); - //System.out.println(i); return count.toString(); } diff --git a/src/main/java/cn/hellohao/controller/CodeController.java b/src/main/java/cn/hellohao/controller/CodeController.java index 8c4ac3e..161c97a 100644 --- a/src/main/java/cn/hellohao/controller/CodeController.java +++ b/src/main/java/cn/hellohao/controller/CodeController.java @@ -32,27 +32,23 @@ public class CodeController { private CodeService codeService; - //返回code界面 @RequestMapping(value = "/tocode") public String tocode() { return "admin/code"; } - //获取code列表 @RequestMapping(value = "/selectcodelist") @ResponseBody public Map selectcodel(HttpSession session, @RequestParam(required = false, defaultValue = "1") int page, @RequestParam(required = false) int limit) { User u = (User) session.getAttribute("user"); - // 使用Pagehelper传入当前页数和页面显示条数会自动为我们的select语句加上limit查询 - // 从他的下一条sql开始分页 PageHelper.startPage(page, limit); List codes = null; - if (u.getLevel() > 1) { //根据用户等级查询管理员查询所有的信息 + if (u.getLevel() > 1) { codes = codeService.selectCode(null); // 使用pageInfo包装查询 - PageInfo rolePageInfo = new PageInfo<>(codes);// + PageInfo rolePageInfo = new PageInfo<>(codes); Map map = new HashMap(); map.put("code", 0); map.put("msg", ""); @@ -67,7 +63,6 @@ public class CodeController { @RequestMapping("/deletecodes") @ResponseBody public Integer deletecodes(HttpSession session, @RequestParam("arr[]") String[] arr){ - //JSONObject jsonObject = new JSONObject(); Integer v = 0; User u = (User) session.getAttribute("user"); for (int i = 0; i < arr.length; i++) { @@ -81,6 +76,7 @@ public class CodeController { Integer v = codeService.deleteCode(code); return v; } + @RequestMapping("/addcode") @ResponseBody public Integer addcode(Integer value,Integer counts){ @@ -90,10 +86,8 @@ public class CodeController { java.text.DateFormat format1 = new java.text.SimpleDateFormat("hhmmss"); Integer number = (int)(Math.random()*100000)+1; String uuid = UUID.randomUUID().toString().replace("-", "").toLowerCase().substring(0,5); - code.setValue(value); code.setCode(SecureUtil.sha256(number+format1.format(new Date())+uuid)); - //code.setCode(SecureUtil.md5(format1.format(new Date())+number+value)); codeService.addCode(code); val = 1; } diff --git a/src/main/java/cn/hellohao/controller/GroupController.java b/src/main/java/cn/hellohao/controller/GroupController.java index 32c7ee6..512607d 100644 --- a/src/main/java/cn/hellohao/controller/GroupController.java +++ b/src/main/java/cn/hellohao/controller/GroupController.java @@ -53,14 +53,11 @@ public class GroupController { public Map getgrouplist(HttpSession session, @RequestParam(required = false, defaultValue = "1") int page, @RequestParam(required = false) int limit) { User u = (User) session.getAttribute("user"); - // 使用Pagehelper传入当前页数和页面显示条数会自动为我们的select语句加上limit查询 - // 从他的下一条sql开始分页 PageHelper.startPage(page, limit); List group = null; - if (u.getLevel() > 1) { //根据用户等级查询管理员查询所有的信息 + if (u.getLevel() > 1) { group = groupService.grouplist(); - // 使用pageInfo包装查询 - PageInfo rolePageInfo = new PageInfo<>(group);// + PageInfo rolePageInfo = new PageInfo<>(group); Map map = new HashMap(); map.put("code", 0); map.put("msg", ""); @@ -86,7 +83,7 @@ public class GroupController { if(b){ ret = groupService.addgroup(group); }else{ - ret = -1;//该存储源key配置不完整 + ret = -1; } return ret; } @@ -114,10 +111,6 @@ public class GroupController { @PostMapping("/updateuser") @ResponseBody public Integer updateuser(User user) { -// UserGroup userGroup = new UserGroup(); -// userGroup.setUserid(user.getId()); -// userGroup.setGroupid(user.getGroupid()); - //userGroupService.updateusergroup(userGroup); Integer ret = userService.change(user); return ret; } @@ -126,9 +119,6 @@ public class GroupController { @ResponseBody public Integer updategroup(Group group) { Integer ret = groupService.setgroup(group); -// if(ret>0){ -// groupService.setgroup(group); -// } return ret; } diff --git a/src/main/java/cn/hellohao/controller/ImageReviewController.java b/src/main/java/cn/hellohao/controller/ImageReviewController.java index 653bc83..dc6b5e9 100644 --- a/src/main/java/cn/hellohao/controller/ImageReviewController.java +++ b/src/main/java/cn/hellohao/controller/ImageReviewController.java @@ -18,23 +18,19 @@ public class ImageReviewController { @RequestMapping(value = "/root/ImageReview") public String ForwardImageReview(Model model) { - //查询百度鉴黄的key Imgreview imgreview = imgreviewService.selectByPrimaryKey(1); model.addAttribute("appid", imgreview.getAppId()); model.addAttribute("apikey", imgreview.getApiKey()); model.addAttribute("secretkey", imgreview.getSecretKey()); model.addAttribute("using", imgreview.getUsing()); - return "admin/imageIdentify"; } - //鉴黄功能开关 @RequestMapping(value = "/root/ImgreviewSwitch") @ResponseBody public String ImgreviewSwitch(String appId, String apiKey, String secretKey, Integer using) { Imgreview imgreview = new Imgreview(); imgreview.setId(1);//目前就一种鉴黄功能所以设死了 - //if(using!=null&&using.equals("")){ imgreview.setUsing(using); imgreview.setAppId(appId); imgreview.setApiKey(apiKey); diff --git a/src/main/java/cn/hellohao/controller/UpdateImgController.java b/src/main/java/cn/hellohao/controller/UpdateImgController.java index 3dbcc71..23daff4 100644 --- a/src/main/java/cn/hellohao/controller/UpdateImgController.java +++ b/src/main/java/cn/hellohao/controller/UpdateImgController.java @@ -1,30 +1,27 @@ package cn.hellohao.controller; -import java.io.FileInputStream; -import java.text.SimpleDateFormat; -import java.util.*; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpSession; - -import cn.hellohao.exception.StorageSourceInitException; import cn.hellohao.pojo.*; import cn.hellohao.service.*; import cn.hellohao.service.impl.*; -import cn.hellohao.utils.IPPortUtil; import cn.hellohao.utils.*; -import cn.hutool.http.HttpUtil; +import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.HttpRequest; import org.springframework.stereotype.Controller; import org.springframework.ui.Model; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.ResponseBody; -import org.springframework.web.context.request.RequestContextHolder; -import org.springframework.web.context.request.ServletRequestAttributes; +import org.springframework.web.bind.annotation.*; import org.springframework.web.multipart.MultipartFile; -import com.alibaba.fastjson.JSONArray; +import org.springframework.web.servlet.ModelAndView; +import org.springframework.web.servlet.view.RedirectView; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import javax.servlet.http.HttpSession; +import java.io.FileInputStream; +import java.io.IOException; +import java.text.SimpleDateFormat; +import java.util.*; @Controller public class UpdateImgController { @@ -51,16 +48,12 @@ public class UpdateImgController { @Autowired private ImgService imgService; - //private Integer updatekey; + private String[] iparr; @RequestMapping({"/", "/index"}) - public String indexImg(Model model, HttpSession httpSession,HttpServletRequest request) { - //boolean b = VerificationDomain.verification(); - boolean b = true; - if(b){ - Print.Normal("欢迎使用Hellohao图床源码。者也许是最好用的java图床项目。"); + public String indexImg(Model model, HttpSession httpSession, HttpServletRequest request, HttpServletResponse response) { Print.Normal("当前项目路径:"+System.getProperty("user.dir")); - Config config = configService.getSourceype();//查询当前系统使用的存储源类型。 + Config config = configService.getSourceype(); UploadConfig uploadConfig = uploadConfigService.getUpdateConfig(); User u = (User) httpSession.getAttribute("user"); String email = (String) httpSession.getAttribute("email"); @@ -72,10 +65,7 @@ public class UpdateImgController { if(uploadConfig.getFilesizeuser()!=null){filesizeuser = uploadConfig.getFilesizeuser();} if(uploadConfig.getImgcounttourists()!=null){imgcounttourists = uploadConfig.getImgcounttourists();} if(uploadConfig.getImgcountuser()!=null){imgcountuser = uploadConfig.getImgcountuser();} - //Boolean b =false; - //Integer Sourcekey = GetCurrentSource.GetSource(u==null?null:u.getId());//查询当当前用户或者游客使用的数据源 if (email != null) { - //登陆成功 Integer ret = userService.login(u.getEmail(), u.getPassword()); if (ret > 0) { User user = userService.getUsers(u.getEmail()); @@ -84,7 +74,6 @@ public class UpdateImgController { model.addAttribute("loginid", 100); model.addAttribute("imgcount", imgcountuser); model.addAttribute("filesize", filesizeuser*1024*1024); - } else { model.addAttribute("loginid", -1); model.addAttribute("imgcount", imgcounttourists); @@ -99,17 +88,10 @@ public class UpdateImgController { model.addAttribute("uploadConfig", uploadConfig); Integer isupdate = 1; if(uploadConfig.getIsupdate()!=1){ - isupdate = (u == null) ? 0: 1;//如果u等于null那么isupdate就等于0,否则等于1 + isupdate = (u == null) ? 0: 1; } - model.addAttribute("ykxz", isupdate); - }else{ - return "index"; - } - Random random = new Random(); - //updatekey = random.nextInt(10000); - //model.addAttribute("updatekey", updatekey); + model.addAttribute("VisitorUpload", isupdate); return "index"; - } @RequestMapping(value = "/upimg") @@ -126,64 +108,66 @@ public class UpdateImgController { User u = (User) session.getAttribute("user"); Integer usermemory =0; Integer memory =0; - Integer Sourcekey=0; + Integer sourcekey=0; Integer maxsize = 0; String userpath = "tourist"; Boolean b =false; - + if(uploadConfig.getBlacklist()!=null){ + iparr = uploadConfig.getBlacklist().split(";"); + for (String s : iparr) { + if(s.equals(userip)){ + jsonObject.put("imgurls",911); + return jsonObject.toString(); + } + } + } if(Integer.parseInt(Base64Encryption.decryptBASE64(upurlk))!=yzupdate()){ - jsonObject.put("imgurls",403);//非法调用 + jsonObject.put("imgurls",403); return jsonObject.toString(); } if(u==null){ - Sourcekey = GetCurrentSource.GetSource(null); + sourcekey = GetCurrentSource.GetSource(null); memory = uploadConfig.getVisitormemory(); maxsize = uploadConfig.getFilesizetourists(); usermemory= imgService.getusermemory(0); if(usermemory==null){usermemory = 0;} }else{ userpath = u.getUsername(); - Sourcekey = GetCurrentSource.GetSource(u.getId()); + sourcekey = GetCurrentSource.GetSource(u.getId()); memory = userService.getUsers(u.getEmail()).getMemory(); maxsize = uploadConfig.getFilesizeuser(); usermemory= imgService.getusermemory(u.getId()); if(usermemory==null){usermemory = 0;} } - //查询到如果使用目录格式是日期,就重新给userpath赋值 if(uploadConfig.getUrltype()==2){ userpath = dateFormat.format(new Date()); } - Keys key = keysService.selectKeys(Sourcekey); - if(Sourcekey==5){b =true;} - else{b = StringUtils.doNull(Sourcekey,key);}//判断对象是否有空值 + Keys key = keysService.selectKeys(sourcekey); + if(sourcekey==5){b =true;} + else{b = StringUtils.doNull(sourcekey,key);} if(!b){ - jsonObject.put("imgurls",-1);//存储源不完整 + jsonObject.put("imgurls",-1); return jsonObject.toString(); } - //如果memory为-1说明无限制给值-2就行, - int tmp =memory==-1? -2:(usermemory/1024); + int tmp =(memory==-1? -2:(usermemory/1024)); if(tmp>=memory){ - jsonObject.put("imgurls",-5);//可用空间不足 + jsonObject.put("imgurls",-5); return jsonObject.toString(); } long stime = System.currentTimeMillis(); Map map = new HashMap<>(); - //for (MultipartFile multipartFile : file) { Print.Normal("文件大小:"+multipartFile.getSize()); if(multipartFile.getSize()>maxsize*1024*1024){ - jsonObject.put("imgurls",-6);//超出设定大小 + jsonObject.put("imgurls",-6); return jsonObject.toString(); } - // 获取ImageReader对象的迭代器 String fileName = multipartFile.getOriginalFilename(); - String lastname = fileName.substring(fileName.lastIndexOf(".") + 1);//获取文件后缀 - if (!multipartFile.isEmpty()) { //判断文件是否为空 + String lastname = fileName.substring(fileName.lastIndexOf(".") + 1); + if (!multipartFile.isEmpty()) { map.put(lastname, multipartFile); } - //} Map m = null; m = GetSource.storageSource(key.getStorageType(),map, userpath,null,setday); - //开始存数据 Images img = new Images(); SimpleDateFormat df=new SimpleDateFormat("yyyy-MM-dd"); Print.Normal("上传图片的时间是:"+df.format(new Date())); @@ -192,7 +176,7 @@ public class UpdateImgController { if(config.getDomain()!=null){ jsonObject.put("imgurls",config.getDomain()+"/links/"+entry.getKey().getImgurl()); jsonObject.put("imgnames",entry.getKey().getImgname()); - img.setImgurl(config.getDomain()+"/links/"+entry.getKey().getImgurl());//图片链接 + img.setImgurl(config.getDomain()+"/links/"+entry.getKey().getImgurl()); }else{ jsonObject.put("imgurls",config.getDomain()+"/links/"+entry.getKey().getImgurl()); jsonObject.put("imgnames",entry.getKey().getImgname()); @@ -201,7 +185,7 @@ public class UpdateImgController { }else{ jsonObject.put("imgurls",entry.getKey().getImgurl()); jsonObject.put("imgnames",entry.getKey().getImgname()); - img.setImgurl(entry.getKey().getImgurl());//图片链接 + img.setImgurl(entry.getKey().getImgurl()); } jsonArray.add(jsonObject); img.setUpdatetime(df.format(new Date())); @@ -222,13 +206,23 @@ public class UpdateImgController { @PostMapping(value = "/upurlimg") @ResponseBody public String upurlimg(HttpSession session, String imgurl, HttpServletRequest request,Integer setday,String upurlk) throws Exception { - Config config = configService.getSourceype();//查询当前系统使用的存储源类型。 + JSONArray jsonArray = new JSONArray(); + Config config = configService.getSourceype(); UploadConfig uploadConfig = uploadConfigService.getUpdateConfig(); User u = (User) session.getAttribute("user"); Integer usermemory =0; Integer memory =0; Integer Sourcekey=0; String userpath = "tourist"; + String userip = GetIPS.getIpAddr(request); + Print.Normal("上传者ip:"+userip); + iparr = uploadConfig.getBlacklist().split(";"); + for (String s : iparr) { + if(s.equals(userip)){ + jsonArray.add(911); + return jsonArray.toString(); + } + } if(u==null){ Sourcekey = GetCurrentSource.GetSource(null); memory = uploadConfig.getVisitormemory(); @@ -245,10 +239,8 @@ public class UpdateImgController { java.text.DateFormat dateFormat = new java.text.SimpleDateFormat("yyyy/MM/dd"); userpath = dateFormat.format(new Date()); } - JSONArray jsonArray = new JSONArray(); - //判断非法调用 if(Integer.parseInt(Base64Encryption.decryptBASE64(upurlk))!=yzupdate()){ - jsonArray.add(-403);//非法调用 + jsonArray.add(-403); return jsonArray.toString(); } Keys key = keysService.selectKeys(Sourcekey); @@ -259,23 +251,18 @@ public class UpdateImgController { Boolean bo =false; bo = Sourcekey==5?true:StringUtils.doNull(Sourcekey,key); if(!bo){ - jsonArray.add(-1);//存储源不完整 + jsonArray.add(-1); return jsonArray.toString(); } - //先判断对象存储key是不是null Print.warning("上传地址是:"+request.getSession().getServletContext().getRealPath("/")+"/hellohaotmp/"); - String userip = GetIPS.getIpAddr(request); - Print.Normal("上传者ip:"+userip); + if(usermemory/1024>=memory) { jsonArray.add(-5); return jsonArray.toString(); } long stime = System.currentTimeMillis(); - //判断是会员还是游客 if(u!=null){ - //判断文件大小 if(imgsize>0 && imgsize>=(yonghu*1024*1024)) { - //文件过大 jsonArray.add(-2); return jsonArray.toString(); } @@ -289,7 +276,6 @@ public class UpdateImgController { String xxx = ImgUrlUtil.bytesToHexString(b); xxx = xxx.toUpperCase(); if(is!=null){is.close();} - //判断文件头是否是图片 if(TypeDict.checkType(xxx).equals("0000")) { jsonArray.add(-3);//不是图片格式 return jsonArray.toString(); @@ -348,14 +334,12 @@ public class UpdateImgController { String xxx = ImgUrlUtil.bytesToHexString(b); xxx = xxx.toUpperCase(); if(is!=null){is.close(); } - //判断文件头是否是图片 if(xxx.equals("0000")) { jsonArray.add(-3); return jsonArray.toString(); } Map map = new HashMap<>(); map.put(TypeDict.checkType(xxx), request.getSession().getServletContext().getRealPath("/")+"/hellohaotmp/"+uuid); - Map m = null; m = GetSource.storageSource(key.getStorageType(), null, userpath,map,setday); Images img = new Images(); @@ -366,14 +350,14 @@ public class UpdateImgController { if(key.getStorageType()==5){ if(config.getDomain()!=null){ jsonArray.add(config.getDomain()+"/links/"+entry.getKey().getImgurl()); - img.setImgurl(config.getDomain()+"/links/"+entry.getKey().getImgurl());//图片链接 + img.setImgurl(config.getDomain()+"/links/"+entry.getKey().getImgurl()); }else{ jsonArray.add(config.getDomain()+"/links/"+entry.getKey().getImgurl()); img.setImgurl("http://"+IPPortUtil.getLocalIP()+":"+IPPortUtil.getLocalPort()+"/links/"+entry.getKey().getImgurl());//图片链接 } }else{ jsonArray.add(entry.getKey().getImgurl()); - img.setImgurl(entry.getKey().getImgurl());//图片链接 + img.setImgurl(entry.getKey().getImgurl()); } img.setUpdatetime(times); img.setSource(key.getStorageType()); @@ -392,7 +376,6 @@ public class UpdateImgController { jsonArray.add(-4); } } - return jsonArray.toString(); /** * 错误返回值含义: @@ -402,7 +385,6 @@ public class UpdateImgController { * */ } - //刪除用戶 @RequestMapping("/sentence") @ResponseBody public String sentence(HttpSession session, Integer id) { @@ -429,14 +411,22 @@ public class UpdateImgController { } return jsonObject.toString(); } + + @GetMapping(value = "/images/{id}") + @ResponseBody + public Images selectByFy(@PathVariable("id") Integer id) { + return imgService.selectByPrimaryKey(id); + } + + private Integer yzupdate(){ Calendar cal = Calendar.getInstance(); int y=cal.get(Calendar.YEAR); int m=cal.get(Calendar.MONTH); int d=cal.get(Calendar.DATE); - int h=cal.get(Calendar.HOUR_OF_DAY); - int mm=cal.get(Calendar.MINUTE); - return y+m+d+h+mm; + //int h=cal.get(Calendar.HOUR_OF_DAY); + //int mm=cal.get(Calendar.MINUTE); + return y+m+d+999; } @RequestMapping("/err") diff --git a/src/main/java/cn/hellohao/controller/UserController.java b/src/main/java/cn/hellohao/controller/UserController.java index 669e932..7756f73 100644 --- a/src/main/java/cn/hellohao/controller/UserController.java +++ b/src/main/java/cn/hellohao/controller/UserController.java @@ -50,7 +50,6 @@ public class UserController { public String Register(@Valid User u,Integer zctmp) { JSONObject jsonObject = new JSONObject(); if((zctmp-number2)==(istmp2-number2)){ - //取当前时间 User user = new User(); UploadConfig updateConfig = uploadConfigService.getUpdateConfig(); EmailConfig emailConfig = emailConfigService.getemail(); @@ -70,13 +69,11 @@ public class UserController { user.setEmail(u.getEmail()); user.setUsername(u.getUsername()); user.setPassword(Base64Encryption.encryptBASE64(u.getPassword().getBytes())); - //查询是否启用了邮箱验证。 Config config = configService.getSourceype(); System.err.println("是否启用了邮箱激活:"+emailConfig.getUsing()); Integer type = 0; if(emailConfig.getUsing()==1){ user.setIsok(0); - //初始化邮箱 MimeMessage message = SendEmail.Emails(emailConfig); //注册完发激活链接 Thread thread = new Thread() { @@ -93,11 +90,6 @@ public class UserController { } Integer ret = userService.register(user); if(ret>0){ -// UserGroup userGroup = new UserGroup(); -// User user1 = userService.getUsersMail(uid); -// userGroup.setUserid(user1.getId()); -// userGroup.setGroupid(1); -// userGroupService.addusergroup(userGroup); } jsonObject.put("ret",ret); jsonObject.put("zctype",type); @@ -152,7 +144,6 @@ public class UserController { session.removeAttribute(user.getEmail()); session.removeAttribute(user.getPassword()); session.removeAttribute("user"); - } //刷新view session.invalidate(); @@ -164,7 +155,7 @@ public class UserController { //邮箱激活 @RequestMapping(value = "/activation.do", method = RequestMethod.GET) public String activation(Model model, HttpServletRequest request, HttpSession session, String activation, String username) { - Config config = configService.getSourceype();//查询当前系统使用的存储源类型。 + Config config = configService.getSourceype(); Integer ret = 0; User user = userService.getUsersMail(activation); model.addAttribute("config", config); @@ -172,13 +163,10 @@ public class UserController { Integer setisok = userService.uiduser(activation); model.addAttribute("setisok", ret); model.addAttribute("username", username); - return "isok"; } else { return "redirect:/index"; - //return "isok"; } - } @PostMapping(value = "/verification") @ResponseBody @@ -194,7 +182,6 @@ public class UserController { istmp2 = tmp; Print.Normal(tmp-number2); } - return 1; } diff --git a/src/main/java/cn/hellohao/pojo/Config.java b/src/main/java/cn/hellohao/pojo/Config.java index eea60d7..586370d 100644 --- a/src/main/java/cn/hellohao/pojo/Config.java +++ b/src/main/java/cn/hellohao/pojo/Config.java @@ -12,15 +12,16 @@ public class Config { private String notice; private String baidu; private String domain; - private String background1; - private String background2; - private String sett; + private String background1; + private String background2; + private String sett; private String webms; private String webkeywords; private String webfavicons; public Config() { } + public Config(Integer id, Integer sourcekey, Integer emails, String webname, String explain, String video, Integer backtype, String links, String notice, String baidu, String domain, String background1, String background2, String sett, String webms, String webkeywords, String webfavicons) { this.id = id; this.sourcekey = sourcekey; diff --git a/src/main/java/cn/hellohao/pojo/UploadConfig.java b/src/main/java/cn/hellohao/pojo/UploadConfig.java index db3bc0a..0aaffa3 100644 --- a/src/main/java/cn/hellohao/pojo/UploadConfig.java +++ b/src/main/java/cn/hellohao/pojo/UploadConfig.java @@ -11,11 +11,13 @@ public class UploadConfig { private Integer api; private Integer visitormemory; private Integer usermemory; + private String blacklist; + public UploadConfig() { } - public UploadConfig(String suffix, Integer filesizetourists, Integer filesizeuser, Integer imgcounttourists, Integer imgcountuser, Integer urltype, Integer isupdate, Integer api, Integer visitormemory, Integer usermemory) { + public UploadConfig(String suffix, Integer filesizetourists, Integer filesizeuser, Integer imgcounttourists, Integer imgcountuser, Integer urltype, Integer isupdate, Integer api, Integer visitormemory, Integer usermemory, String blacklist) { this.suffix = suffix; this.filesizetourists = filesizetourists; this.filesizeuser = filesizeuser; @@ -26,6 +28,7 @@ public class UploadConfig { this.api = api; this.visitormemory = visitormemory; this.usermemory = usermemory; + this.blacklist = blacklist; } public String getSuffix() { @@ -107,4 +110,12 @@ public class UploadConfig { public void setUsermemory(Integer usermemory) { this.usermemory = usermemory; } + + public String getBlacklist() { + return blacklist; + } + + public void setBlacklist(String blacklist) { + this.blacklist = blacklist; + } } diff --git a/src/main/java/cn/hellohao/quartz/test.java b/src/main/java/cn/hellohao/quartz/test.java deleted file mode 100644 index a4993c1..0000000 --- a/src/main/java/cn/hellohao/quartz/test.java +++ /dev/null @@ -1,13 +0,0 @@ -package cn.hellohao.quartz; - -import java.text.SimpleDateFormat; -import java.util.Date; - -public class test { - public static void main(String[] args) { - Date d = new Date(); - SimpleDateFormat df=new SimpleDateFormat("yyyy-MM-dd"); - String oldtime = df.format(new Date(d.getTime())); - System.out.println(df.format(new Date())); - } -} diff --git a/src/main/java/cn/hellohao/service/impl/COSImageupload.java b/src/main/java/cn/hellohao/service/impl/COSImageupload.java index 7b627e1..487a799 100644 --- a/src/main/java/cn/hellohao/service/impl/COSImageupload.java +++ b/src/main/java/cn/hellohao/service/impl/COSImageupload.java @@ -61,7 +61,6 @@ public class COSImageupload { String deleimg = DateUtils.plusDay(setday); DeleImg.charu(username + "/" + uuid + times + "." + entry.getKey() + "|" + deleimg + "|" + "6"); } - } catch (CosServiceException serverException) { serverException.printStackTrace(); } catch (CosClientException clientException) { @@ -71,7 +70,6 @@ public class COSImageupload { return ImgUrl; }else{ Map ImgUrl = new HashMap<>(); - //设置Header ObjectMetadata meta = new ObjectMetadata(); meta.setHeader("Content-Disposition", "inline"); for (Map.Entry entry : fileMap2.entrySet()) { @@ -82,7 +80,6 @@ public class COSImageupload { File file = new File(imgurl); FileInputStream fileInputStream = new FileInputStream(file); try { - // 指定要上传到 COS 上对象键 String userkey =username + "/" + uuid+times + "." + entry.getKey(); PutObjectRequest putObjectRequest = new PutObjectRequest(BarrelName, userkey, file); PutObjectResult putObjectResult = cosClient.putObject(putObjectRequest); @@ -96,7 +93,7 @@ public class COSImageupload { boolean bb= new File(imgurl).getAbsoluteFile().delete(); Print.Normal("删除情况"+bb); } catch (Exception e) { - System.out.println("上传报错:" + e.getMessage()); + System.err.println("上传报错:" + e.getMessage()); } if(fileInputStream!=null){ fileInputStream.close(); @@ -106,7 +103,6 @@ public class COSImageupload { cosClient.shutdown(); return ImgUrl; } - } // 转换文件方法 @@ -117,7 +113,6 @@ public class COSImageupload { String prefix = fileName.substring(fileName.lastIndexOf(".")); // todo 修改临时文件文件名 File file = File.createTempFile(fileName, prefix); - // MultipartFile to File multipartFile.transferTo(file); return file; } @@ -129,31 +124,13 @@ public class COSImageupload { && k.getBucketname()!=null && k.getRequestAddress()!=null ) { if(!k.getEndpoint().equals("") && !k.getAccessSecret().equals("") && !k.getEndpoint().equals("") && !k.getBucketname().equals("") && !k.getRequestAddress().equals("") ) { - // 1 初始化用户身份信息(secretId, secretKey)。 String secretId = k.getAccessKey(); String secretKey = k.getAccessSecret(); COSCredentials cred = new BasicCOSCredentials(secretId, secretKey); - // 2 设置 bucket 的区域, COS 地域的简称请参照 https://cloud.tencent.com/document/product/436/6224 - // clientConfig 中包含了设置 region, https(默认 http), 超时, 代理等 set 方法, 使用可参见源码或者常见问题 Java SDK 部分。 Region region = new Region(k.getEndpoint()); ClientConfig clientConfig = new ClientConfig(region); - // 3 生成 cos 客户端。 cosClient = new COSClient(cred, clientConfig); BarrelName = k.getBucketname(); - //查询桶 -// try { -// List buckets = cosClient.listBuckets(); -// for (Bucket bucket : buckets) { -// if (bucket.getName().equals(k.getBucketname())) { -// Print.Normal("当前桶名称:" + bucket.getName()); -// BarrelName = bucket.getName(); -// } -// } -// } catch (CosServiceException serverException) { -// serverException.printStackTrace(); -// } catch (CosClientException clientException) { -// clientException.printStackTrace(); -// } key = k; ret = 1; } @@ -175,22 +152,19 @@ public class COSImageupload { try { ReturnImage returnImage = new ReturnImage(); if(entry.getValue().getSize()/1024<=uploadConfig.getFilesizeuser()*1024){ - // 指定要上传到 COS 上对象键 String userkey =username + "/" + uuid+times + "." + entry.getKey(); PutObjectRequest putObjectRequest = new PutObjectRequest(BarrelName, userkey, file); PutObjectResult putObjectResult = cosClient.putObject(putObjectRequest); returnImage.setImgname(entry.getValue().getOriginalFilename()); returnImage.setImgurl(key.getRequestAddress() + "/" + userkey); ImgUrl.put(returnImage, (int) (entry.getValue().getSize())); - -// ImgUrl.put(key.getRequestAddress() + "/" + username + "/" + uuid+times + "." + entry.getKey(), (int) (entry.getValue().getSize())); }else{ returnImage.setImgname(entry.getValue().getOriginalFilename()); returnImage.setImgurl("文件超出系统设定大小,不得超过"); ImgUrl.put(returnImage, -1); } } catch (Exception e) { - System.out.println("上传报错:" + e.getMessage()); + System.err.println("上传报错:" + e.getMessage()); } } return ImgUrl; diff --git a/src/main/java/cn/hellohao/service/impl/FTPImageupload.java b/src/main/java/cn/hellohao/service/impl/FTPImageupload.java index 323a669..b8d0c28 100644 --- a/src/main/java/cn/hellohao/service/impl/FTPImageupload.java +++ b/src/main/java/cn/hellohao/service/impl/FTPImageupload.java @@ -31,22 +31,15 @@ public class FTPImageupload { if(fileMap2==null){ File file = null; Map ImgUrl = new HashMap<>(); - ftps.mkDir(File.separator+username); for (Map.Entry entry : fileMap.entrySet()) { String uuid = UUID.randomUUID().toString().replace("-", "").toLowerCase().substring(0,5);//生成一个没有-的uuid,然后取前5位 java.text.DateFormat format1 = new java.text.SimpleDateFormat("MMddhhmmss"); String times = format1.format(new Date()); file = changeFile(entry.getValue()); - System.out.println("文件地址:"+file.toString()); String userkey =username + File.separator+ uuid+times + "." + entry.getKey(); - //fuzhi(file.toString(),File.separator+"tmp"+File.separator+uuid+times + "." + entry.getKey()); if (flag) { - // 上传 - //ftps.upload(File.separator+"tmp"+File.separator+uuid+times + "." + entry.getKey(), File.separator+userkey, ""); ftps.upload(file, File.separator+userkey, ""); - - //boolean isSet = ftp.sendSiteCommand("chmod 744 " + File.separator+userkey);//设置权限 ReturnImage returnImage = new ReturnImage(); returnImage.setImgname(entry.getValue().getOriginalFilename()); returnImage.setImgurl(key.getRequestAddress() + File.separator+ userkey); @@ -73,10 +66,8 @@ public class FTPImageupload { ftps.mkDir(File.separator+username); if (flag) { ftps.upload(file, File.separator+userkey, ""); - ReturnImage returnImage = new ReturnImage(); returnImage.setImgurl(key.getRequestAddress() + File.separator+ userkey); - Print.Normal("Url上传成功返回地址"); ImgUrl.put(returnImage, ImgUrlUtil.getFileSize2(new File(imgurl))); if(setday>0) { String deleimg = DateUtils.plusDay(setday); @@ -86,11 +77,9 @@ public class FTPImageupload { } boolean bb= new File(imgurl).getAbsoluteFile().delete(); Print.Normal("删除情况"+bb); - } return ImgUrl; } - } // 转换文件方法 @@ -101,7 +90,6 @@ public class FTPImageupload { String prefix = fileName.substring(fileName.lastIndexOf(".")); // todo 修改临时文件文件名 File file = File.createTempFile(fileName, prefix); - // MultipartFile to File multipartFile.transferTo(file); return file; } @@ -121,14 +109,12 @@ public class FTPImageupload { if(!ftp.isConnected()){ ftp.connect(h,p); } - //如果是需要认证的服务器,就需要账号和密码来登录 ftp.login(k.getAccessKey(), k.getAccessSecret()); } catch (IOException e) { e.printStackTrace(); } //获取服务器返回的状态码 int reply = ftp.getReplyCode(); - System.out.println(reply); /* * 判断是否连接成功 * 所有以2开头的代码是正完成响应。 @@ -138,13 +124,10 @@ public class FTPImageupload { try { ftp.disconnect(); }catch (IOException e){ - System.out.println(e); + e.printStackTrace(); } - //Print.warning("连接失败"); ret = -1; } - //Print.Normal("链接成功"); - //boolean isUpload = ftp.storeFile("/ftp/upload.jpg", fis); ftpClient1 = ftp; key = k; ret = 1; @@ -180,7 +163,6 @@ public class FTPImageupload { returnImage.setImgname(entry.getValue().getOriginalFilename()); returnImage.setImgurl(key.getRequestAddress() + File.separator+ userkey); ImgUrl.put(returnImage, (int) (entry.getValue().getSize())); - //ImgUrl.put(key.getRequestAddress() + File.separator+userkey + username + File.separator+userkey + uuid+times + "." + entry.getKey(), (int) (entry.getValue().getSize())); ftps.close(); }else{ returnImage.setImgname(entry.getValue().getOriginalFilename()); @@ -188,11 +170,9 @@ public class FTPImageupload { ImgUrl.put(returnImage, -1); ftps.close(); } - } } return ImgUrl; - } public static void fuzhi(String p1,String p2){ diff --git a/src/main/java/cn/hellohao/service/impl/GroupServiceImpl.java b/src/main/java/cn/hellohao/service/impl/GroupServiceImpl.java index 29441ea..e1b9b98 100644 --- a/src/main/java/cn/hellohao/service/impl/GroupServiceImpl.java +++ b/src/main/java/cn/hellohao/service/impl/GroupServiceImpl.java @@ -45,7 +45,6 @@ public class GroupServiceImpl implements GroupService { Integer ret = 0; ret = groupMapper.delegroup(id); if(ret>0){ - //userGroupMapper.updateusergroupdefault(id); List userList = userMapper.getuserlistforgroupid(id); for (User user : userList) { User u = new User(); diff --git a/src/main/java/cn/hellohao/service/impl/IPblacklist.java b/src/main/java/cn/hellohao/service/impl/IPblacklist.java new file mode 100644 index 0000000..7a71681 --- /dev/null +++ b/src/main/java/cn/hellohao/service/impl/IPblacklist.java @@ -0,0 +1,10 @@ +package cn.hellohao.service.impl; + +/** + * @author Hellohao + * @version 1.0 + * @date 2019/11/29 15:33 + */ +public class IPblacklist { + +} diff --git a/src/main/java/cn/hellohao/service/impl/ImgServiceImpl.java b/src/main/java/cn/hellohao/service/impl/ImgServiceImpl.java index 9e8e3b1..30d34a0 100644 --- a/src/main/java/cn/hellohao/service/impl/ImgServiceImpl.java +++ b/src/main/java/cn/hellohao/service/impl/ImgServiceImpl.java @@ -60,7 +60,6 @@ public class ImgServiceImpl implements ImgService { public Images selectByPrimaryKey(Integer id) { return imgMapper.selectByPrimaryKey(id); } - //删除对象存储的图片文件 public void delect(Keys key, String fileName) { // 初始化 @@ -79,7 +78,6 @@ public class ImgServiceImpl implements ImgService { tname = object.toString(); //查看桶的ACL CannedAccessControlList acl = nosClient.getBucketAcl(object.toString()); - // bucket权限 } //这种方法不能删除指定文件夹下的文件 boolean isExist = nosClient.doesObjectExist(tname, fileName, null); @@ -88,22 +86,14 @@ public class ImgServiceImpl implements ImgService { nosClient.deleteObject(tname, fileName); } } - - //删除OSS对象存储的图片文件 public void delectOSS(Keys key, String fileName) { - // 初始化 -// Endpoint以杭州为例,其它Region请按实际情况填写。 String endpoint = key.getEndpoint(); -// 阿里云主账号AccessKey拥有所有API的访问权限,风险很高。强烈建议您创建并使用RAM账号进行API访问或日常运维,请登录 https://ram.console.aliyun.com 创建RAM账号。 String accessKeyId = key.getAccessKey(); String accessKeySecret = key.getAccessSecret(); String bucketName = key.getBucketname(); String objectName = fileName; -// 创建OSSClient实例。 OSSClient ossClient = new OSSClient(endpoint, accessKeyId, accessKeySecret); -// 删除文件。 ossClient.deleteObject(bucketName, objectName); -// 关闭OSSClient。 ossClient.shutdown(); } //删除USS对象存储的图片文件 @@ -117,10 +107,8 @@ public class ImgServiceImpl implements ImgService { e.printStackTrace(); } } - //删除KODO对象存储的图片文件 public void delectKODO(Keys key, String fileName) { Configuration cfg; - //构造一个带指定Zone对象的配置类 if(key.getEndpoint().equals("1")){cfg = new Configuration(Zone.zone0());} else if(key.getEndpoint().equals("2")){cfg = new Configuration(Zone.zone1());} else if(key.getEndpoint().equals("3")){cfg = new Configuration(Zone.zone2());} @@ -143,9 +131,7 @@ public class ImgServiceImpl implements ImgService { ClientConfig clientConfig = new ClientConfig(region); COSClient cosClient= new COSClient(cred, clientConfig); try { - // 指定对象所在的存储桶 String bucketName = key.getBucketname(); - // 指定对象在 COS 上的对象键 String userkey = fileName; cosClient.deleteObject(key.getBucketname(), userkey); } catch (CosServiceException serverException) { @@ -154,7 +140,6 @@ public class ImgServiceImpl implements ImgService { clientException.printStackTrace(); } } - //删除FTP存储的图片文件 public void delectFTP(Keys key, String fileName) { FTPClient ftp = new FTPClient(); String[] host = key.getEndpoint().split("\\:"); @@ -164,7 +149,6 @@ public class ImgServiceImpl implements ImgService { if(!ftp.isConnected()){ ftp.connect(h,p); } - //如果是需要认证的服务器,就需要账号和密码来登录 ftp.login(key.getAccessKey(), key.getAccessSecret()); ftp.deleteFile(fileName); } catch (IOException e) { @@ -178,7 +162,6 @@ public class ImgServiceImpl implements ImgService { return imgMapper.counts(userid); } - @Override public Integer countimg(Integer userid) { // TODO Auto-generated method stub diff --git a/src/main/java/cn/hellohao/service/impl/InitializationStorage.java b/src/main/java/cn/hellohao/service/impl/InitializationStorage.java index 99a990f..4fe637b 100644 --- a/src/main/java/cn/hellohao/service/impl/InitializationStorage.java +++ b/src/main/java/cn/hellohao/service/impl/InitializationStorage.java @@ -45,14 +45,9 @@ public class InitializationStorage implements CommandLineRunner { }else if(key.getStorageType()==7){ ret = FTPImageupload.Initialize(key); } - else{ - //Print.warning("未获取到存储参数,或者使用存储源是本地的。"); - } -// if(ret<1){model.addAttribute("error", "当前存储源参数配置不完整,请联系管理员配置存储源。");} -// else{model.addAttribute("error", 1);} } } -Print.Normal("初始化完成"); + Print.Normal("初始化完成"); } public void sout(){ diff --git a/src/main/java/cn/hellohao/service/impl/KODOImageupload.java b/src/main/java/cn/hellohao/service/impl/KODOImageupload.java index 966e141..6d14888 100644 --- a/src/main/java/cn/hellohao/service/impl/KODOImageupload.java +++ b/src/main/java/cn/hellohao/service/impl/KODOImageupload.java @@ -34,7 +34,6 @@ public class KODOImageupload { public Map ImageuploadKODO(Map fileMap, String username, Map fileMap2,Integer setday) throws Exception { - // 要上传文件的路径 if(fileMap2==null){ File file = null; Map ImgUrl = new HashMap<>(); @@ -44,12 +43,8 @@ public class KODOImageupload { java.text.DateFormat format1 = new java.text.SimpleDateFormat("MMddhhmmss"); String times = format1.format(new Date()); file = changeFile(entry.getValue()); - // 上传文件流。 - System.out.println("待上传的图片:"+username + "/" + uuid+times + "." + entry.getKey()); - //ossClient.putObject(key.getBucketname(), username + "/" + uuid+times + "." + entry.getKey(),file,meta); try { Response response = uploadManager.put(file,username + "/" + uuid+times + "." + entry.getKey(),upToken); - //解析上传成功的结果 DefaultPutRet putRet = new Gson().fromJson(response.bodyString(), DefaultPutRet.class); ReturnImage returnImage = new ReturnImage(); returnImage.setImgname(entry.getValue().getOriginalFilename()); @@ -65,7 +60,6 @@ public class KODOImageupload { try { System.err.println(r.bodyString()); } catch (QiniuException ex2) { - //ignore } } } @@ -77,11 +71,9 @@ public class KODOImageupload { java.text.DateFormat format1 = new java.text.SimpleDateFormat("MMddhhmmss"); String times = format1.format(new Date()); String imgurl = entry.getValue(); - // 上传文件流。 System.out.println("待上传的图片:"+username + "/" + uuid+times + "." + entry.getKey()); try { Response response = uploadManager.put(new File(imgurl),username + "/" + uuid+times + "." + entry.getKey(),upToken); - //解析上传成功的结果 DefaultPutRet putRet = new Gson().fromJson(response.bodyString(), DefaultPutRet.class); ReturnImage returnImage = new ReturnImage(); returnImage.setImgurl(key.getRequestAddress() + "/" + username + "/" + uuid+times + "." + entry.getKey()); @@ -97,13 +89,11 @@ public class KODOImageupload { try { System.err.println(r.bodyString()); } catch (QiniuException ex2) { - //ignore } } } return ImgUrl; } - } // 转换文件方法 @@ -114,7 +104,6 @@ public class KODOImageupload { String prefix = fileName.substring(fileName.lastIndexOf(".")); // todo 修改临时文件文件名 File file = File.createTempFile(fileName, prefix); - // MultipartFile to File multipartFile.transferTo(file); return file; } @@ -126,10 +115,7 @@ public class KODOImageupload { && k.getBucketname() != null && k.getRequestAddress() != null) { if (!k.getEndpoint().equals("") && !k.getAccessSecret() .equals("") && !k.getEndpoint() .equals("") && !k.getBucketname().equals("") && !k.getRequestAddress() .equals("")) { - // 初始化 - // 创建KODOClient实例。 Configuration cfg; - //构造一个带指定Zone对象的配置类 if (k.getEndpoint().equals("1")) { cfg = new Configuration(Zone.zone0()); } else if (k.getEndpoint().equals("2")) { @@ -157,7 +143,6 @@ public class KODOImageupload { public Map clientuploadKODO(Map fileMap, String username, UploadConfig uploadConfig) throws Exception { File file = null; Map ImgUrl = new HashMap<>(); - for (Map.Entry entry : fileMap.entrySet()) { String uuid = UUID.randomUUID().toString().replace("-", "").toLowerCase().substring(0,5);//生成一个没有-的uuid,然后取前5位 java.text.DateFormat format1 = new java.text.SimpleDateFormat("MMddhhmmss"); @@ -168,13 +153,10 @@ public class KODOImageupload { ReturnImage returnImage = new ReturnImage(); if(entry.getValue().getSize()/1024<=uploadConfig.getFilesizeuser()*1024){ Response response = uploadManager.put(file,username + "/" + uuid+times + "." + entry.getKey(),upToken); - //解析上传成功的结果 DefaultPutRet putRet = new Gson().fromJson(response.bodyString(), DefaultPutRet.class); - returnImage.setImgname(entry.getValue().getOriginalFilename()); returnImage.setImgurl(key.getRequestAddress() + "/" + username + "/" + uuid+times + "." + entry.getKey()); ImgUrl.put(returnImage, (int) (entry.getValue().getSize())); - //ImgUrl.put(key.getRequestAddress() + "/" + username + "/" + uuid+times + "." + entry.getKey(), (int) (entry.getValue().getSize())); }else{ returnImage.setImgname(entry.getValue().getOriginalFilename()); returnImage.setImgurl("文件超出系统设定大小,不得超过"); diff --git a/src/main/java/cn/hellohao/service/impl/KeysServiceImpl.java b/src/main/java/cn/hellohao/service/impl/KeysServiceImpl.java index 1da5ee7..ccfffd6 100644 --- a/src/main/java/cn/hellohao/service/impl/KeysServiceImpl.java +++ b/src/main/java/cn/hellohao/service/impl/KeysServiceImpl.java @@ -21,7 +21,6 @@ public class KeysServiceImpl implements KeysService { return keysMapper.selectKeys(storageType); } - @Override public Integer updateKey(Keys key) { // TODO Auto-generated method stub diff --git a/src/main/java/cn/hellohao/service/impl/NOSImageupload.java b/src/main/java/cn/hellohao/service/impl/NOSImageupload.java index 7bbf366..528a71b 100644 --- a/src/main/java/cn/hellohao/service/impl/NOSImageupload.java +++ b/src/main/java/cn/hellohao/service/impl/NOSImageupload.java @@ -29,24 +29,12 @@ import cn.hellohao.pojo.Keys; @Service public class NOSImageupload { - //直接读取properties文件的值 -// @Value("${AccessKey}") -// private String AccessKey; -// @Value("${AccessSecret}") -// private String AccessSecret; -// @Value("${Endpoint}") -// private String Endpoint; -// @Value("${Bucketname}") -// private String Bucketname; -// @Value("${RequestAddress}") -// private String RequestAddress; static String BarrelName; static NosClient nosClient; static Keys key; public Map Imageupload(Map fileMap, String username, Map fileMap2,Integer setday) throws Exception { - // 要上传文件的路径 if(fileMap2==null){ File file = null; Map ImgUrl = new HashMap<>(); @@ -68,7 +56,6 @@ public class NOSImageupload { return ImgUrl; }else{ Map ImgUrl = new HashMap<>(); - //设置Header ObjectMetadata meta = new ObjectMetadata(); meta.setHeader("Content-Disposition", "inline"); for (Map.Entry entry : fileMap2.entrySet()) { @@ -76,7 +63,6 @@ public class NOSImageupload { java.text.DateFormat format1 = new java.text.SimpleDateFormat("MMddhhmmss"); String times = format1.format(new Date()); String imgurl = entry.getValue(); - String head = ""; if(entry.getKey().equals("jpg")||entry.getKey().equals("jpeg")){ head = "image/jpeg"; @@ -93,10 +79,7 @@ public class NOSImageupload { File file = new File(imgurl); FileInputStream fileInputStream = new FileInputStream(file); try { - //nosClient.putObject(BarrelName, username + "/" + uuid+times + "." + entry.getKey(), new File(imgurl)); - //new FileInputStream(file) nosClient.putObject(BarrelName, username + "/" + uuid+times + "." + entry.getKey(), fileInputStream,meta); - ReturnImage returnImage = new ReturnImage(); returnImage.setImgurl(key.getRequestAddress() + "/" + username + "/" + uuid+times + "." + entry.getKey()); ImgUrl.put(returnImage, ImgUrlUtil.getFileSize2(new File(imgurl))); @@ -104,11 +87,10 @@ public class NOSImageupload { String deleimg = DateUtils.plusDay(setday); DeleImg.charu(username + "/" + uuid + times + "." + entry.getKey() + "-" + deleimg + "-" + "1"); } - boolean bb= new File(imgurl).getAbsoluteFile().delete(); Print.Normal("删除情况"+bb); } catch (Exception e) { - System.out.println("上传报错:" + e.getMessage()); + System.err.println("上传报错:" + e.getMessage()); } if(fileInputStream!=null){ fileInputStream.close(); diff --git a/src/main/java/cn/hellohao/service/impl/OSSImageupload.java b/src/main/java/cn/hellohao/service/impl/OSSImageupload.java index 5130230..d45ebd9 100644 --- a/src/main/java/cn/hellohao/service/impl/OSSImageupload.java +++ b/src/main/java/cn/hellohao/service/impl/OSSImageupload.java @@ -3,10 +3,7 @@ package cn.hellohao.service.impl; import cn.hellohao.pojo.Keys; import cn.hellohao.pojo.ReturnImage; import cn.hellohao.pojo.UploadConfig; -import cn.hellohao.utils.DateUtils; -import cn.hellohao.utils.DeleImg; -import cn.hellohao.utils.ImgUrlUtil; -import cn.hellohao.utils.Print; +import cn.hellohao.utils.*; import com.aliyun.oss.OSSClient; import com.aliyun.oss.model.ObjectMetadata; import org.springframework.stereotype.Service; @@ -29,15 +26,13 @@ public class OSSImageupload { if(fileMap2==null){ File file = null; Map ImgUrl = new HashMap<>(); - //设置Header ObjectMetadata meta = new ObjectMetadata(); meta.setHeader("Content-Disposition", "inline"); for (Map.Entry entry : fileMap.entrySet()) { String uuid = UUID.randomUUID().toString().replace("-", "").toLowerCase().substring(0,5);//生成一个没有-的uuid,然后取前5位 java.text.DateFormat format1 = new java.text.SimpleDateFormat("MMddhhmmss"); String times = format1.format(new Date()); - file = changeFile(entry.getValue()); - + file = SetFiles.changeFile(entry.getValue()); String head = ""; if(entry.getKey().equals("jpg")||entry.getKey().equals("jpeg")){ head = "image/jpeg"; @@ -51,10 +46,8 @@ public class OSSImageupload { System.err.println("位置格式文件,无法定义header头。"); } meta.setHeader("Content-Type", head);//image/jpeg - // 上传文件流。 System.out.println("待上传的图片:"+username + "/" + uuid+times + "." + entry.getKey()); ossClient.putObject(key.getBucketname(), username + "/" + uuid+times + "." + entry.getKey(),file,meta); - ReturnImage returnImage = new ReturnImage(); returnImage.setImgname(entry.getValue().getOriginalFilename()); returnImage.setImgurl(key.getRequestAddress() + "/" + username + "/" + uuid+times + "." + entry.getKey()); @@ -64,11 +57,9 @@ public class OSSImageupload { DeleImg.charu(username + "/" + uuid + times + "." + entry.getKey() + "|" + deleimg + "|" + "2"); } } - //ossClient.shutdown(); return ImgUrl; }else{ Map ImgUrl = new HashMap<>(); - //设置Header ObjectMetadata meta = new ObjectMetadata(); meta.setHeader("Content-Disposition", "inline"); for (Map.Entry entry : fileMap2.entrySet()) { @@ -76,7 +67,6 @@ public class OSSImageupload { java.text.DateFormat format1 = new java.text.SimpleDateFormat("MMddhhmmss"); String times = format1.format(new Date()); String imgurl = entry.getValue(); - String head = ""; if(entry.getKey().equals("jpg")||entry.getKey().equals("jpeg")){ head = "image/jpeg"; @@ -90,10 +80,8 @@ public class OSSImageupload { System.err.println("位置格式文件,无法定义header头。"); } meta.setHeader("Content-Type", head);//image/jpeg - // 上传文件流。 System.out.println("待上传的图片:"+username + "/" + uuid+times + "." + entry.getKey()); ossClient.putObject(key.getBucketname(), username + "/" + uuid+times + "." + entry.getKey(),new File(imgurl),meta); - ReturnImage returnImage = new ReturnImage(); returnImage.setImgurl(key.getRequestAddress() + "/" + username + "/" + uuid+times + "." + entry.getKey()); ImgUrl.put(returnImage, ImgUrlUtil.getFileSize2(new File(imgurl))); @@ -103,24 +91,8 @@ public class OSSImageupload { DeleImg.charu(username + "/" + uuid + times + "." + entry.getKey() + "|" + deleimg + "|" + "2"); } } - //ossClient.shutdown(); return ImgUrl; } - - - } - - // 转换文件方法 - private File changeFile(MultipartFile multipartFile) throws Exception { - // 获取文件名 - String fileName = multipartFile.getOriginalFilename(); - // 获取文件后缀 - String prefix = fileName.substring(fileName.lastIndexOf(".")); - // todo 修改临时文件文件名 - File file = File.createTempFile(fileName, prefix); - // MultipartFile to File - multipartFile.transferTo(file); - return file; } //初始化 @@ -143,18 +115,15 @@ public class OSSImageupload { * 客户端接口 * */ public Map clientuploadOSS(Map fileMap, String username, UploadConfig uploadConfig) throws Exception { - File file = null; Map ImgUrl = new HashMap<>(); - //设置Header ObjectMetadata meta = new ObjectMetadata(); meta.setHeader("Content-Disposition", "inline"); for (Map.Entry entry : fileMap.entrySet()) { String uuid = UUID.randomUUID().toString().replace("-", "").toLowerCase().substring(0,5);//生成一个没有-的uuid,然后取前5位 java.text.DateFormat format1 = new java.text.SimpleDateFormat("MMddhhmmss"); String times = format1.format(new Date()); - file = changeFile(entry.getValue()); - + file = SetFiles.changeFile(entry.getValue()); String head = ""; if(entry.getKey().equals("jpg")||entry.getKey().equals("jpeg")){ head = "image/jpeg"; @@ -170,14 +139,10 @@ public class OSSImageupload { meta.setHeader("Content-Type", head);//image/jpeg ReturnImage returnImage = new ReturnImage(); if(entry.getValue().getSize()/1024<=uploadConfig.getFilesizeuser()*1024){ - // 上传文件流。 - System.out.println("待上传的图片:"+username + "/" + uuid+times + "." + entry.getKey()); ossClient.putObject(key.getBucketname(), username + "/" + uuid+times + "." + entry.getKey(),file,meta); - returnImage.setImgname(entry.getValue().getOriginalFilename()); returnImage.setImgurl(key.getRequestAddress() + "/" + username + "/" + uuid+times + "." + entry.getKey()); ImgUrl.put(returnImage, (int) (entry.getValue().getSize())); - //ImgUrl.put(key.getRequestAddress() + "/" + username + "/" + uuid+times + "." + entry.getKey(), (int) (entry.getValue().getSize()/1024)); }else{ returnImage.setImgname(entry.getValue().getOriginalFilename()); returnImage.setImgurl("文件超出系统设定大小,不得超过"); @@ -188,6 +153,4 @@ public class OSSImageupload { } - - } diff --git a/src/main/java/cn/hellohao/service/impl/USSImageupload.java b/src/main/java/cn/hellohao/service/impl/USSImageupload.java index be28e37..bf0bcad 100644 --- a/src/main/java/cn/hellohao/service/impl/USSImageupload.java +++ b/src/main/java/cn/hellohao/service/impl/USSImageupload.java @@ -6,6 +6,7 @@ import cn.hellohao.pojo.UploadConfig; import cn.hellohao.utils.DateUtils; import cn.hellohao.utils.DeleImg; import cn.hellohao.utils.ImgUrlUtil; +import cn.hellohao.utils.Print; import com.UpYun; import com.aliyun.oss.OSSClient; import com.aliyun.oss.model.ObjectMetadata; @@ -28,7 +29,6 @@ public class USSImageupload { if(fileMap2==null){ File file = null; Map ImgUrl = new HashMap<>(); - //设置Header ObjectMetadata meta = new ObjectMetadata(); meta.setHeader("Content-Disposition", "inline"); for (Map.Entry entry : fileMap.entrySet()) { @@ -36,9 +36,6 @@ public class USSImageupload { java.text.DateFormat format1 = new java.text.SimpleDateFormat("MMddhhmmss"); String times = format1.format(new Date()); file = changeFile(entry.getValue()); - // 上传文件流。 - System.out.println("待上传的图片:"+username + "/" + uuid+times + "." + entry.getKey()); - // 例2:采用数据流模式上传文件(节省内存),自动创建父级目录 upyun.setContentMD5(UpYun.md5(file)); boolean result = upyun.writeFile(username + "/" + uuid+times + "." + entry.getKey(), file, true); if(result){ @@ -58,7 +55,6 @@ public class USSImageupload { return ImgUrl; }else{ Map ImgUrl = new HashMap<>(); - //设置Header ObjectMetadata meta = new ObjectMetadata(); meta.setHeader("Content-Disposition", "inline"); for (Map.Entry entry : fileMap2.entrySet()) { @@ -66,9 +62,6 @@ public class USSImageupload { java.text.DateFormat format1 = new java.text.SimpleDateFormat("MMddhhmmss"); String times = format1.format(new Date()); String imgurl = entry.getValue(); - // 上传文件流。 - System.out.println("待上传的图片:"+username + "/" + uuid+times + "." + entry.getKey()); - // 例2:采用数据流模式上传文件(节省内存),自动创建父级目录 upyun.setContentMD5(UpYun.md5(new File(imgurl))); boolean result = upyun.writeFile(username + "/" + uuid+times + "." + entry.getKey(), new File(imgurl), true); if(result){ @@ -79,9 +72,8 @@ public class USSImageupload { String deleimg = DateUtils.plusDay(setday); DeleImg.charu(username + "/" + uuid + times + "." + entry.getKey() + "|" + deleimg + "|" + "3"); } - }else{ - System.err.println("上传失败"); + Print.warning("上传失败"); } new File(imgurl).delete(); } diff --git a/src/main/java/cn/hellohao/service/impl/UserServiceImpl.java b/src/main/java/cn/hellohao/service/impl/UserServiceImpl.java index 1bbb3b1..fd349c1 100644 --- a/src/main/java/cn/hellohao/service/impl/UserServiceImpl.java +++ b/src/main/java/cn/hellohao/service/impl/UserServiceImpl.java @@ -1,30 +1,27 @@ package cn.hellohao.service.impl; import cn.hellohao.dao.CodeMapper; -import cn.hellohao.exception.CodeException; -import cn.hellohao.utils.Print; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; import cn.hellohao.dao.UserMapper; +import cn.hellohao.exception.CodeException; import cn.hellohao.pojo.Images; import cn.hellohao.pojo.User; import cn.hellohao.service.UserService; +import cn.hellohao.utils.Print; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import java.util.List; @Service public class UserServiceImpl implements UserService { - @Autowired private UserMapper userMapper; @Autowired private CodeMapper codeMapper; - @Override public Integer register(User user) { // TODO Auto-generated method stub - return userMapper.register(user); } diff --git a/src/main/java/cn/hellohao/utils/AfterServiceStarted.java b/src/main/java/cn/hellohao/utils/AfterServiceStarted.java index 49d91a4..732e86f 100644 --- a/src/main/java/cn/hellohao/utils/AfterServiceStarted.java +++ b/src/main/java/cn/hellohao/utils/AfterServiceStarted.java @@ -10,27 +10,10 @@ import java.util.Scanner; @Component public class AfterServiceStarted implements ApplicationRunner { - /** - * 会在服务启动完成后立即执行 - */ - @Value("${spring.datasource.url}") - private String url; - @Value("${spring.datasource.username}") - private String userName; - @Value("${spring.datasource.password}") - private String userPassword; @Override public void run(ApplicationArguments args) throws Exception { Print.Normal("______________________________________________"); -// Print.Normal(" Hellohao-Pro "); -// Print.Normal(" Successful startup of the program "); -// Print.Normal(" is OK! Open http://your ip:port "); -// Print.Normal("______________________________________________"); - //getLinuxLocalIp(); - //System.out.println("开始执行数据库~~"); - // JDBCTool.caozuo(url,userName,userPassword); } - } \ No newline at end of file diff --git a/src/main/java/cn/hellohao/utils/Base64Encryption.java b/src/main/java/cn/hellohao/utils/Base64Encryption.java index 11ab955..9b5114c 100644 --- a/src/main/java/cn/hellohao/utils/Base64Encryption.java +++ b/src/main/java/cn/hellohao/utils/Base64Encryption.java @@ -10,23 +10,9 @@ import java.util.Base64; * Created by Hellohao on 2019-08-27. */ public class Base64Encryption { - - public static void main(String[] args) { - toBaseCode("admin"); - } - /** - * BASE64加密解密 - */ public static void toBaseCode(String str) { String data = encryptBASE64(str.getBytes()); - System.out.println("sun.misc.BASE64 加密后:" + data); - System.out.println("sun.misc.BASE64 解密后:" + decryptBASE64(data)); } - - /** - * BASE64解密 - * @throws Exception - */ public static String decryptBASE64(String key) { byte[] b =null; try { @@ -36,15 +22,8 @@ public class Base64Encryption { } return new String(b); } - - /** - * BASE64加密 - */ public static String encryptBASE64(byte[] key) { - String string = "SGVsbG9oYW8K"; - System.out.println(string.replaceAll("\r|\n","")); - return (new BASE64Encoder()).encodeBuffer(key).replaceAll("\r|\n", ""); } } \ No newline at end of file diff --git a/src/main/java/cn/hellohao/utils/DateUtils.java b/src/main/java/cn/hellohao/utils/DateUtils.java index 42bff3e..eac9a76 100644 --- a/src/main/java/cn/hellohao/utils/DateUtils.java +++ b/src/main/java/cn/hellohao/utils/DateUtils.java @@ -10,22 +10,14 @@ import java.util.Date; * @date 2019/9/20 16:27 */ public class DateUtils { - /** - * 当前日期加上天数后的日期 - * @param num 为增加的天数 - * @return - */ public static String plusDay(int num){ Date d = new Date(); SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); String currdate = format.format(d); - System.out.println("现在的日期是:" + currdate); - Calendar ca = Calendar.getInstance(); - ca.add(Calendar.DATE, num);// num为增加的天数,可以改变的 + ca.add(Calendar.DATE, num); d = ca.getTime(); String enddate = format.format(d); - System.out.println("增加天数以后的日期:" + enddate); return enddate; } } diff --git a/src/main/java/cn/hellohao/utils/DeleImg.java b/src/main/java/cn/hellohao/utils/DeleImg.java index bea6b75..a7c779b 100644 --- a/src/main/java/cn/hellohao/utils/DeleImg.java +++ b/src/main/java/cn/hellohao/utils/DeleImg.java @@ -4,11 +4,6 @@ package cn.hellohao.utils; import java.io.*; public class DeleImg { - public static void main(String[] args) throws Exception { - readFile(File.separator + "HellohaoData"+File.separator+"img.ini"); - //charu(); - } - public static void charu(String imgUrlText) { String filePath =File.separator + "HellohaoData" ; File file = new File(filePath); diff --git a/src/main/java/cn/hellohao/utils/FTPUtils.java b/src/main/java/cn/hellohao/utils/FTPUtils.java index eb5afaf..3db4215 100644 --- a/src/main/java/cn/hellohao/utils/FTPUtils.java +++ b/src/main/java/cn/hellohao/utils/FTPUtils.java @@ -16,20 +16,16 @@ import java.io.IOException; *

Title:

*

Description:

* - * @author H.Yang - * @QQ 1033542070 - * @date 2018年3月10日 + * @author Hellohao + * @date 2019年11月10日 */ public class FTPUtils { - private final Logger LOGGER = LogManager.getLogger(getClass()); - private FTPClient ftpClient = null; private String server; private int port; private String userName; private String userPassword; - public FTPUtils(String server, int port, String userName, String userPassword) { this.server = server; this.port = port; @@ -37,38 +33,24 @@ public class FTPUtils { this.userPassword = userPassword; } - /** - *

Title: 连接服务器

- *

Description:

- * - * @author H.Yang - * @date 2018年3月10日 - * - * @return 连接成功与否 true:成功, false:失败 - */ public boolean open() { // 判断是否已连接 if (ftpClient != null && ftpClient.isConnected()) { return true; } - try { ftpClient = new FTPClient(); // 连接FTP服务器 ftpClient.connect(this.server, this.port); - // 如果采用默认端口,可以使用ftp.connect(host)的方式直接连接FTP服务器 ftpClient.login(this.userName, this.userPassword); - // 检测连接是否成功 int reply = ftpClient.getReplyCode(); if (!FTPReply.isPositiveCompletion(reply)) { - System.out.println("FTP服务器拒绝连接."); + Print.warning("FTP服务器拒绝连接."); this.close(); System.exit(1); } - System.out.println("FTP连接成功:" + this.server + ";port:" + this.port + ";name:" + this.userName + ";pwd:" + this.userPassword); - ftpClient.setFileType(FTP.BINARY_FILE_TYPE); // 设置上传模式.binally or ascii + ftpClient.setFileType(FTP.BINARY_FILE_TYPE); ftpClient.enterLocalPassiveMode(); - return true; } catch (Exception e) { this.close(); @@ -81,10 +63,10 @@ public class FTPUtils { /** *

Title: 切换到父目录

*

Description:

- * - * @author H.Yang - * @date 2018年3月11日 - * + * + * @author Hellohao + * @date 2018年10月11日 + * * @return 切换结果 true:成功, false:失败 */ private boolean changeToParentDir() { @@ -97,11 +79,6 @@ public class FTPUtils { } /** - *

Title: 改变当前目录到指定目录

- *

Description:

- * - * @author H.Yang - * @date 2018年3月11日 * * @param dir 目的目录 * @return 切换结果 true:成功,false:失败 @@ -116,11 +93,6 @@ public class FTPUtils { } /** - *

Title: 获取目录下所有的文件名称

- *

Description:

- * - * @author H.Yang - * @date 2018年3月11日 * * @param filePath 指定的目录 * @return 文件列表,或者null @@ -135,11 +107,6 @@ public class FTPUtils { } /** - *

Title: 层层切换工作目录

- *

Description:

- * - * @author H.Yang - * @date 2018年3月11日 * * @param ftpPath 目的目录 * @return 切换结果 @@ -149,7 +116,6 @@ public class FTPUtils { return false; } try { - // 将路径中的斜杠统一 char[] chars = ftpPath.toCharArray(); StringBuffer sbStr = new StringBuffer(256); for (int i = 0; i < chars.length; i++) { @@ -178,12 +144,6 @@ public class FTPUtils { } /** - *

Title: 循环创建目录,并且创建完目录后,设置工作目录为当前创建的目录下

- *

Description:

- * - * @author H.Yang - * @date 2018年3月11日 - * * @param ftpPath 需要创建的目录 * @return */ @@ -203,7 +163,6 @@ public class FTPUtils { } } ftpPath = sbStr.toString(); - System.out.println("ftpPath:" + ftpPath); if (ftpPath.indexOf('/') == -1) { // 只有一层目录 ftpClient.makeDirectory(new String(ftpPath.getBytes(), "UTF-8")); @@ -224,26 +183,18 @@ public class FTPUtils { } /** - *

Title: 上传文件到FTP服务器

- *

Description:

- * - * @author H.Yang - * @date 2018年3月11日 * * @param //localDirectoryAndFileName 本地文件目录和文件名 * @param ftpFileName 上传到服务器的文件名() * @param ftpDirectory FTP目录如:/path1/pathb2/,如果目录不存在会自动创建目录(目录可以省略) * @return */ - //public boolean upload(String localDirectoryAndFileName, String ftpFileName, String ftpDirectory) { public boolean upload(File srcFile, String ftpFileName, String ftpDirectory) { - if (!ftpClient.isConnected()) { return false; } boolean flag = false; if (ftpClient != null) { - //File srcFile = new File(localDirectoryAndFileName); FileInputStream fis = null; try { fis = new FileInputStream(srcFile); @@ -257,7 +208,6 @@ public class FTPUtils { if (ftpFileName == null || ftpFileName == "") { ftpFileName = srcFile.getName(); } - // 上传 flag = ftpClient.storeFile(new String(ftpFileName.getBytes(), "UTF-8"), fis); } catch (Exception e) { @@ -272,17 +222,10 @@ public class FTPUtils { } } } - System.out.println("上传文件成功,本地文件名: " + ",上传到目录:" + ftpDirectory + "/" + ftpFileName); return flag; } /** - *

Title: 从FTP服务器上下载文件

- *

Description:

- * - * @author H.Yang - * @date 2018年3月11日 - * * @param ftpDirectoryAndFileName ftp服务器文件路径,以/dir形式开始 * @param localDirectoryAndFileName 保存到本地的目录 * @return @@ -291,7 +234,7 @@ public class FTPUtils { if (!ftpClient.isConnected()) { return false; } - ftpClient.enterLocalPassiveMode(); // Use passive mode as default + ftpClient.enterLocalPassiveMode(); try { // 将路径中的斜杠统一 char[] chars = ftpDirectoryAndFileName.toCharArray(); @@ -308,9 +251,6 @@ public class FTPUtils { String fileName = ftpDirectoryAndFileName.substring(ftpDirectoryAndFileName.lastIndexOf("/") + 1); this.changeDir(filePath); ftpClient.retrieveFile(new String(fileName.getBytes(), "UTF-8"), new FileOutputStream(localDirectoryAndFileName)); // download - // file - System.out.println(ftpClient.getReplyString()); // check result - System.out.println("从ftp服务器上下载文件:" + ftpDirectoryAndFileName + ", 保存到:" + localDirectoryAndFileName); return true; } catch (IOException e) { e.printStackTrace(); @@ -319,11 +259,6 @@ public class FTPUtils { } /** - *

Title: 返回FTP目录下的文件列表

- *

Description:

- * - * @author H.Yang - * @date 2018年3月11日 * * @param pathName * @return @@ -340,10 +275,6 @@ public class FTPUtils { /** *

Title: 删除FTP上的文件

*

Description:

- * - * @author H.Yang - * @date 2018年3月11日 - * * @param ftpDirAndFileName 路径开头不能加/,比如应该是test/filename1 * @return */ @@ -360,12 +291,6 @@ public class FTPUtils { } /** - *

Title: 删除FTP目录

- *

Description:

- * - * @author H.Yang - * @date 2018年3月11日 - * * @param ftpDirectory * @return */ @@ -384,31 +309,16 @@ public class FTPUtils { /** *

Title: 关闭链接

*

Description:

- * - * @author H.Yang - * @date 2018年3月10日 - * */ public void close() { try { if (ftpClient != null && ftpClient.isConnected()) { ftpClient.disconnect(); } - System.out.println("成功关闭连接,服务器ip:" + this.server + ", 端口:" + this.port); } catch (Exception e) { e.printStackTrace(); } } - public static void main(String[] args) { - FTPUtils ftp = new FTPUtils("hellohao.cn", 21, "test", "test"); - boolean flag = ftp.open(); - if (flag) { - // 上传 - //ftp.upload("D:/新建文件夹/1.jpg", "/admin/shihao.jpg", ""); - - ftp.close(); - } - } } diff --git a/src/main/java/cn/hellohao/utils/FirstRun.java b/src/main/java/cn/hellohao/utils/FirstRun.java new file mode 100644 index 0000000..08d4c0f --- /dev/null +++ b/src/main/java/cn/hellohao/utils/FirstRun.java @@ -0,0 +1,50 @@ +package cn.hellohao.utils; + +import org.omg.CORBA.Environment; +import org.springframework.beans.factory.InitializingBean; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.context.annotation.Configuration; + +/** + * @author Hellohao + * @version 1.0 + * @date 2019/11/29 14:32 + */ +@Configuration +public class FirstRun implements InitializingBean { + + @Value("${spring.datasource.username}") + private String jdbcusername; + + @Value("${spring.datasource.password}") + private String jdbcpass; + + @Value("${spring.datasource.url}") + private String jdbcurl; + + @Override + public void afterPropertiesSet() throws Exception { + RunSqlScript.USERNAME = jdbcusername; + RunSqlScript.PASSWORD = jdbcpass; + RunSqlScript.DBURL = jdbcurl; + Print.Normal("正在校验数据库参数..."); + Integer ret1 = RunSqlScript.RunSelectCount(sql1); + if(ret1==0){ + Print.Normal("In execution..."); + RunSqlScript.RunInsert(sql2); + + }else{ + if(ret1>0){ + Print.Normal("Good! No action required!"); + }else{ + Print.Normal("Mysql 报了一个错"); + } + } + } + + //创建blacklist 2019-11-29 + private String sql1 = "select count(*) from information_schema.columns where table_name = 'uploadconfig' and column_name = 'blacklist'"; + private String sql2 = "alter table uploadconfig add blacklist varchar(500);"; + +} diff --git a/src/main/java/cn/hellohao/utils/GetCurrentSource.java b/src/main/java/cn/hellohao/utils/GetCurrentSource.java index cab4d0d..1ff7663 100644 --- a/src/main/java/cn/hellohao/utils/GetCurrentSource.java +++ b/src/main/java/cn/hellohao/utils/GetCurrentSource.java @@ -46,7 +46,6 @@ public class GetCurrentSource { Group group = groupService.idgrouplist(1); ret = group.getKeyid(); }else{ - //UserGroup userGroup = userGroupService.useridgetusergroup(userid); User user = userService.getUsersid(userid); Group group = groupService.idgrouplist(user.getGroupid()); ret = group.getKeyid(); diff --git a/src/main/java/cn/hellohao/utils/GetIPS.java b/src/main/java/cn/hellohao/utils/GetIPS.java index 8839e4a..a84eac7 100644 --- a/src/main/java/cn/hellohao/utils/GetIPS.java +++ b/src/main/java/cn/hellohao/utils/GetIPS.java @@ -13,17 +13,13 @@ import javax.servlet.http.HttpServletRequest; public class GetIPS implements Runnable { private String imgname ; - public void setImgname(String imgname) { this.imgname = imgname; } - @Override public void run() { ImgServiceImpl imgService = SpringContextHolder.getBean(ImgServiceImpl.class); - //imgService.setabnormal(imgname,Sentence.getIPs()); } - public static void runxc(String imgnames){ GetIPS getIPS = new GetIPS(); getIPS.setImgname(imgnames); diff --git a/src/main/java/cn/hellohao/utils/GetSource.java b/src/main/java/cn/hellohao/utils/GetSource.java index 224fd27..76625f1 100644 --- a/src/main/java/cn/hellohao/utils/GetSource.java +++ b/src/main/java/cn/hellohao/utils/GetSource.java @@ -12,7 +12,6 @@ import java.util.Map; * @version 1.0 * @date 2019/11/7 17:12 */ -//通过type判断是哪一个存储源 public class GetSource { public static Map storageSource(Integer type, Map fileMap, String userpath, Map filename,Integer setday){ @@ -22,7 +21,6 @@ public class GetSource { KODOImageupload kodoImageupload = SpringContextHolder.getBean(KODOImageupload.class); COSImageupload cosImageupload = SpringContextHolder.getBean(COSImageupload.class); FTPImageupload ftpImageupload = SpringContextHolder.getBean(FTPImageupload.class); - Map m = null; try { if(type==1){ diff --git a/src/main/java/cn/hellohao/utils/IPPortUtil.java b/src/main/java/cn/hellohao/utils/IPPortUtil.java index f17dabc..7f6e63c 100644 --- a/src/main/java/cn/hellohao/utils/IPPortUtil.java +++ b/src/main/java/cn/hellohao/utils/IPPortUtil.java @@ -39,8 +39,6 @@ public class IPPortUtil { } catch (Exception e) { e.printStackTrace(); } - - byte[] ipAddr = addr.getAddress(); String ipAddrStr = ""; for (int i = 0; i < ipAddr.length; i++) { diff --git a/src/main/java/cn/hellohao/utils/ImageReview.java b/src/main/java/cn/hellohao/utils/ImageReview.java deleted file mode 100644 index 99044e9..0000000 --- a/src/main/java/cn/hellohao/utils/ImageReview.java +++ /dev/null @@ -1,84 +0,0 @@ -package cn.hellohao.utils; - -import cn.hellohao.pojo.Imgreview; -import cn.hellohao.pojo.Keys; -import cn.hellohao.service.ImgreviewService; -import cn.hellohao.service.impl.ImgServiceImpl; -import cn.hellohao.service.impl.ImgreviewServiceImpl; -import com.alibaba.fastjson.JSON; -import com.baidu.aip.contentcensor.AipContentCensor; -import com.baidu.aip.contentcensor.EImgType; -import org.json.JSONObject; -import org.springframework.stereotype.Component; - -import java.util.Map; - -@Component -public class ImageReview { - - private static AipContentCensor client; - - private ImageReview() { - } - private static void Initializes(Imgreview imgreview) { - client = new AipContentCensor(imgreview.getAppId(), imgreview.getApiKey(), imgreview.getSecretKey()); - client.setConnectionTimeoutInMillis(2000); - client.setSocketTimeoutInMillis(60000); - } - - //开始调用鉴黄。 - public static void imgJB(Map imgmap, String requestAddress, Keys key, Imgreview imgreview) { - ImgServiceImpl imgService = SpringContextHolder.getBean(ImgServiceImpl.class); - ImgreviewServiceImpl imgreviewService = SpringContextHolder.getBean(ImgreviewServiceImpl.class); - ImageReview.Initializes(imgreview); - //遍历map,获取里边的key(图片地址) - for (Map.Entry entry : imgmap.entrySet()) { - System.out.println("正在鉴定的图片:" + entry.getKey()); - JSONObject res = client.antiPorn(entry.getKey()); - res = client.imageCensorUserDefined(entry.getKey(), EImgType.URL, null); - - com.alibaba.fastjson.JSONArray jsonArray = JSON.parseArray("[" + res.toString() + "]"); - for (Object o : jsonArray) { - com.alibaba.fastjson.JSONObject jsonObject = (com.alibaba.fastjson.JSONObject) o; - com.alibaba.fastjson.JSONArray data = jsonObject.getJSONArray("data"); - Integer conclusionType = jsonObject.getInteger("conclusionType"); - if (conclusionType == 2) { - for (Object datum : data) { - com.alibaba.fastjson.JSONObject imgdata = (com.alibaba.fastjson.JSONObject) datum; - if (imgdata.getInteger("type") == 1) { - //标记图片 - String imgname = SetText.getSubString(entry.getKey(), requestAddress, ""); - Integer ret = imgService.deleimgname(imgname); //删除数据库图片信息 - //Imgreview imgreview1 =imgreviewService.selectByPrimaryKey(1); - Imgreview imgreview1 = new Imgreview(); - imgreview1.setId(1); - Integer count = imgreview.getCount(); - System.out.println("总数:" + count); - imgreview1.setCount(count + 1); - imgreviewService.updateByPrimaryKeySelective(imgreview1); - - if(key.getStorageType()==1){ - imgService.delect(key, imgname); - }else if (key.getStorageType()==2){ - imgService.delectOSS(key, imgname); - }else if(key.getStorageType()==3){ - //初始化腾讯云 - }else if(key.getStorageType()==4){ - //初始化七牛云 - }else{ - System.err.println("未获取到对象存储参数,上传失败。"); - } - if (ret == 1) { - System.out.println("存在色情图片,删除成功。"); - } else { - System.out.println("存在色情图片,删除失败"); - } - } - } - } - } - } - } - - -} diff --git a/src/main/java/cn/hellohao/utils/ImgUrlUtil.java b/src/main/java/cn/hellohao/utils/ImgUrlUtil.java index 4ed4911..eda0612 100644 --- a/src/main/java/cn/hellohao/utils/ImgUrlUtil.java +++ b/src/main/java/cn/hellohao/utils/ImgUrlUtil.java @@ -11,22 +11,6 @@ import java.net.URL; * */ public class ImgUrlUtil { - //获取文件类型 -// public static void main(String[] args) throws Exception { -// FileInputStream is = new FileInputStream("D:\\22222\\"); -// byte[] b = new byte[3]; -// is.read(b, 0, b.length); -// String xxx = bytesToHexString(b); -// xxx = xxx.toUpperCase(); -// System.out.println("头文件是:" + xxx); -// String ooo = TypeDict.checkType(xxx); -// System.out.println("后缀名是:" + ooo); -// -// -// //Long ll = FileType.getFileLength("http://img.ph.126."); -// // Print.Normal("文件大小="+ll); -// } - public static String bytesToHexString(byte[] src) { StringBuilder stringBuilder = new StringBuilder(); if (src == null || src.length <= 0) { @@ -42,8 +26,6 @@ public class ImgUrlUtil { } return stringBuilder.toString(); } - - /** * 获取网络文件大小 */ @@ -65,7 +47,6 @@ public class ImgUrlUtil { } } - /** * 从网络Url中下载文件 * @param urlStr @@ -74,23 +55,6 @@ public class ImgUrlUtil { * @throws IOException */ - /** - * 调用方式 - * try{ - * downLoadFromUrl("https://hellohao.oss-cn-beijing.aliyuncs.com/Hellohao/8bb3a0627022829.png", - * "22222",TbedApplication.class.getClassLoader().getResource("static/files").getPath()); - * }catch (Exception e) { - * // // TODO: handle exception - * } - * */ - -// public static void main(String[] args) throws Exception { -//// ImgUrlUtil.downLoadFromUrl("http://pic13.nipic.com/20110409/7119492_114440620000_2.jpg", -//// "123321", "/temp/temporary"); -//Print.Normal(ImgUrlUtil.getFileLength("http://pic41.nipic.com/20140508/18609517_112216473140_2.jpg")); -// //File file=; // /Users是路径名 -// //new File(TbedApplication.class.getClassLoader().getResource("static/files").getPath()+"/d30d794d0de74a4f9fab3e4dbb8ea4cb").delete(); -// } public static boolean downLoadFromUrl(String urlStr,String fileName,String savePath) throws IOException{ URL url = new URL(urlStr); @@ -99,15 +63,10 @@ public class ImgUrlUtil { conn.setConnectTimeout(5*1000); //防止屏蔽程序抓取而返回403错误 conn.setRequestProperty("User-Agent", "Mozilla/4.0 (compatible; MSIE 5.0; Windows NT; DigExt)"); - //得到输入流 InputStream inputStream = conn.getInputStream(); //获取自己数组 byte[] getData = readInputStream(inputStream); - - //文件保存位置 - //File saveDir = new File(savePath); - //this.getServletContext().getRealPath("/WEB-INF/jrxml/hgc.png" File saveDir = new File(savePath); if(!saveDir.exists()){ saveDir.mkdir(); @@ -121,7 +80,6 @@ public class ImgUrlUtil { if(inputStream!=null){ inputStream.close(); } - System.out.println("info:"+url+" download success"); return true; } /** @@ -141,54 +99,31 @@ public class ImgUrlUtil { return bos.toByteArray(); } - /** - * 根据java.io.*的流获取文件大小 - * @param file - */ - public static Integer getFileSize2(File file){ Integer imgsize = 0; FileInputStream fis = null; - try { - if(file.exists() && file.isFile()){ - String fileName = file.getName(); - fis = new FileInputStream(file); imgsize=fis.available()/1024; - System.out.println("文件"+fileName+"的大小是:"+fis.available()/1024+"K\n"); - } - } catch (Exception e) { - e.printStackTrace(); - }finally{ - if(null!=fis){ - try { - fis.close(); - } catch (IOException e) { - e.printStackTrace(); - } - } - } return imgsize; } - } diff --git a/src/main/java/cn/hellohao/utils/JianHuangThread.java b/src/main/java/cn/hellohao/utils/JianHuangThread.java deleted file mode 100644 index ab63fa7..0000000 --- a/src/main/java/cn/hellohao/utils/JianHuangThread.java +++ /dev/null @@ -1,32 +0,0 @@ -package cn.hellohao.utils; - -import cn.hellohao.pojo.Imgreview; -import cn.hellohao.pojo.Keys; -import cn.hellohao.pojo.User; -import cn.hellohao.service.ImgreviewService; -import java.util.Map; - -public class JianHuangThread extends Thread { - - private Keys key; - private Map hashMap; - private ImgreviewService imgreviewService; - private User user; - - public JianHuangThread(ImgreviewService imgreviewService, Keys keys, User user, Map hashMap) { - this.key = keys; - this.user = user; - this.imgreviewService = imgreviewService; - this.hashMap = hashMap; - } - - @Override - public void run() { - Imgreview imgreview = imgreviewService.selectByPrimaryKey(1); - if (user != null) { - ImageReview.imgJB(hashMap, key.getRequestAddress() + "/", key, imgreview); - } else { - ImageReview.imgJB(hashMap, key.getRequestAddress() + "/", key, imgreview); - } - } -} diff --git a/src/main/java/cn/hellohao/utils/LocUpdateImg.java b/src/main/java/cn/hellohao/utils/LocUpdateImg.java index 7c4cb4b..2531b1c 100644 --- a/src/main/java/cn/hellohao/utils/LocUpdateImg.java +++ b/src/main/java/cn/hellohao/utils/LocUpdateImg.java @@ -17,8 +17,6 @@ public class LocUpdateImg { file.delete(); } - - public static Map ImageuploadLOC(Map fileMap, String username, Map fileMap2,Integer setday) throws Exception { String filePath =File.separator + "HellohaoData" + File.separator; @@ -29,7 +27,6 @@ public class LocUpdateImg { String uuid = UUID.randomUUID().toString().replace("-", "").toLowerCase().substring(0,5);//生成一个没有-的uuid,然后取前5位 java.text.DateFormat format1 = new java.text.SimpleDateFormat("MMddhhmmss"); String times = format1.format(new Date()); - //file = SetFiles.changeFile(entry.getValue()); // 上传文件流。 System.out.println("待上传的图片:"+username + "/" + uuid+times + "." + entry.getKey()); File dest = new File(filePath + username + File.separator+ uuid+times + "." + entry.getKey()); @@ -47,7 +44,6 @@ public class LocUpdateImg { } bos.flush(); bos.close(); - ReturnImage returnImage = new ReturnImage(); returnImage.setImgname(entry.getValue().getOriginalFilename()); returnImage.setImgurl(username + "/" + uuid+times + "." + entry.getKey()); @@ -75,8 +71,7 @@ public class LocUpdateImg { if(!targetFile.getParentFile().exists()) { targetFile.mkdirs(); } - - file.renameTo(new File(newfilePath));//只移动,源目录不存在文件 + file.renameTo(new File(newfilePath)); // 例2:采用数据流模式上传文件(节省内存),自动创建父级目录 ReturnImage returnImage = new ReturnImage(); returnImage.setImgurl(username + "/" + uuid+times + "." + entry.getKey()); @@ -86,7 +81,6 @@ public class LocUpdateImg { DeleImg.charu(username + "/" + uuid + times + "." + entry.getKey() + "|" + deleimg + "|" + "5"); } } - //new File(imgurl).delete(); return ImgUrl; } } @@ -102,8 +96,6 @@ public class LocUpdateImg { String uuid = UUID.randomUUID().toString().replace("-", "").toLowerCase().substring(0,5);//生成一个没有-的uuid,然后取前5位 java.text.DateFormat format1 = new java.text.SimpleDateFormat("MMddhhmmss"); String times = format1.format(new Date()); - //file = SetFiles.changeFile(entry.getValue()); - // 上传文件流。 System.out.println("待上传的图片:"+username + "/" + uuid+times + "." + entry.getKey()); ReturnImage returnImage = new ReturnImage(); if(entry.getValue().getSize()/1024<=uploadConfig.getFilesizeuser()*1024){ @@ -111,16 +103,6 @@ public class LocUpdateImg { if (!dest.getParentFile().exists()) { dest.getParentFile().mkdirs(); } -// try { -// entry.getValue().transferTo(dest); -// returnImage.setImgname(entry.getValue().getOriginalFilename()); -// returnImage.setImgurl(username + "/" + uuid+times + "." + entry.getKey()); -// ImgUrl.put(returnImage, (int) (entry.getValue().getSize())); -// } catch (IOException e) { -// e.printStackTrace(); -// System.err.println("上传失败"); -// } - try { MultipartFile multipartFile = entry.getValue(); FileInputStream fileInputStream = (FileInputStream) multipartFile.getInputStream(); @@ -132,8 +114,6 @@ public class LocUpdateImg { } bos.flush(); bos.close(); - - //ReturnImage returnImage = new ReturnImage(); returnImage.setImgname(entry.getValue().getOriginalFilename()); returnImage.setImgurl(username + "/" + uuid+times + "." + entry.getKey()); ImgUrl.put(returnImage, (int) (entry.getValue().getSize())); @@ -141,7 +121,6 @@ public class LocUpdateImg { e.printStackTrace(); System.err.println("上传失败"); } - }else{ returnImage.setImgname(entry.getValue().getOriginalFilename()); returnImage.setImgurl("文件超出系统设定大小,不得超过"); diff --git a/src/main/java/cn/hellohao/utils/PrintThread.java b/src/main/java/cn/hellohao/utils/PrintThread.java deleted file mode 100644 index 50d5b4f..0000000 --- a/src/main/java/cn/hellohao/utils/PrintThread.java +++ /dev/null @@ -1,31 +0,0 @@ -package cn.hellohao.utils; - -import java.util.UUID; - -public class PrintThread extends Thread { - - public Integer xc; - public PrintThread(Integer xc) { - this.xc = xc; - } - - @Override - - public void run() { - for(int i=1;i<99999999;i++){ - //String intFlag = String.valueOf((int)(Math.random() * 1000000)); - String uuid = UUID.randomUUID().toString().replace("-", "").toLowerCase().substring(0,9);//生成一个没有-的uuid,然后取前5位 - //sendPost("http://shenhhh.net/index.php?m=User&a=signup","phone=13232"+intFlag+"&password=asd"+intFlag+"",i); - String ret = demo.sendPost("https://test.demo-1s.com/register","name="+uuid+"&email="+uuid+"@jbb.com&password="+uuid,i); - System.out.println("线程 【"+xc+"】 :账号:goto"+uuid+"-- 密码:baa"+uuid+"-- 邮箱:jbb"+uuid+"@jbb.com -- 返回值:"+ret); - } - } - - public static void main(String[] args) { - new PrintThread(1).start(); - new PrintThread(2).start(); - new PrintThread(3).start(); - new PrintThread(4).start(); - new PrintThread(5).start(); - } -} \ No newline at end of file diff --git a/src/main/java/cn/hellohao/utils/SendEmail.java b/src/main/java/cn/hellohao/utils/SendEmail.java index 9961d61..f9a40fc 100644 --- a/src/main/java/cn/hellohao/utils/SendEmail.java +++ b/src/main/java/cn/hellohao/utils/SendEmail.java @@ -29,7 +29,6 @@ public class SendEmail { }); session.setDebug(true); MimeMessage message = new MimeMessage(session); - System.err.println("邮件初始化完成"); return message; } @@ -75,12 +74,10 @@ public class SendEmail { message.setFrom(new InternetAddress(emailConfig.getEmails(), emailConfig.getEmailname(), "UTF-8")); // 收件人和抄送人 message.setRecipients(Message.RecipientType.TO, email); - // 内容(这个内容还不能乱写,有可能会被SMTP拒绝掉;多试几次吧) message.setSubject(emailConfig.getEmailname()+"账号激活");//标题 message.setContent(texts, "text/html;charset=UTF-8");//内容 message.setSentDate(new Date()); message.saveChanges(); - System.out.println("准备发送"); Transport.send(message); return 1; } catch (MessagingException e) { diff --git a/src/main/java/cn/hellohao/utils/Sentence.java b/src/main/java/cn/hellohao/utils/Sentence.java index 62942cf..f0ae306 100644 --- a/src/main/java/cn/hellohao/utils/Sentence.java +++ b/src/main/java/cn/hellohao/utils/Sentence.java @@ -22,20 +22,15 @@ public class Sentence { public static String getURLContent() { String result = ""; - //String urlName = "https://v1.hitokoto.cn/"; String urlName = "http://cn.bing.com/HPImageArchive.aspx?format=js&idx=0&n=1"; try { URL realURL = new URL(urlName); URLConnection conn = realURL.openConnection(); conn.setRequestProperty("accept", "*/*"); conn.setRequestProperty("connection", "Keep-Alive"); - //conn.setRequestProperty("user-agent", "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/47.0.2526.106 Safari/537.36"); conn.setRequestProperty("user-agent","Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.169 Safari/537.36"); conn.connect(); Map> map = conn.getHeaderFields(); - for (String s : map.keySet()) { - System.out.println(s + "-->" + map.get(s)); - } BufferedReader in = new BufferedReader(new InputStreamReader(conn.getInputStream(), "utf-8")); String line; while ((line = in.readLine()) != null) { diff --git a/src/main/java/cn/hellohao/utils/SetFiles.java b/src/main/java/cn/hellohao/utils/SetFiles.java index f54945f..4cc0a69 100644 --- a/src/main/java/cn/hellohao/utils/SetFiles.java +++ b/src/main/java/cn/hellohao/utils/SetFiles.java @@ -13,7 +13,6 @@ public class SetFiles { String prefix = fileName.substring(fileName.lastIndexOf(".")); // todo 修改临时文件文件名 File file = File.createTempFile(fileName, prefix); - // MultipartFile to File multipartFile.transferTo(file); return file; } diff --git a/src/main/java/cn/hellohao/utils/SpringContextHolder.java b/src/main/java/cn/hellohao/utils/SpringContextHolder.java index a7736da..0787b1c 100644 --- a/src/main/java/cn/hellohao/utils/SpringContextHolder.java +++ b/src/main/java/cn/hellohao/utils/SpringContextHolder.java @@ -7,8 +7,7 @@ import org.springframework.stereotype.Component; /** * Spring的ApplicationContext的持有者,可以用静态方法的方式获取spring容器中的bean - * - * @author yj + * @author Hellohao * @date 2018年5月27日 下午6:32:11 */ @Component diff --git a/src/main/java/cn/hellohao/utils/SqlHelper.java b/src/main/java/cn/hellohao/utils/SqlHelper.java new file mode 100644 index 0000000..d307d12 --- /dev/null +++ b/src/main/java/cn/hellohao/utils/SqlHelper.java @@ -0,0 +1,111 @@ +package cn.hellohao.utils; + +import org.apache.ibatis.io.Resources; +import org.apache.ibatis.jdbc.ScriptRunner; + +import java.io.IOException; +import java.sql.*; +import java.util.Properties; + + +final class RunSqlScript { + + public static String DBDRIVER = "com.mysql.cj.jdbc.Driver"; + public static String DBURL ; + //现在使用的是mysql数据库,是直接连接的,所以此处必须有用户名和密码 + public static String USERNAME ; + public static String PASSWORD ; + + public static Integer RunSelectCount(String sql) { + Integer count = 0; + //数据库连接对象 + Connection conn = null; + //数据库操作对象 + Statement stmt = null; + //1、加载驱动程序 + try { + Class.forName(DBDRIVER); + } catch (ClassNotFoundException e) { + e.printStackTrace(); + } + //2、连接数据库 + //通过连接管理器连接数据库 + try { + //在连接的时候直接输入用户名和密码才可以连接 + conn = DriverManager.getConnection(DBURL,USERNAME,PASSWORD); + } catch (SQLException e) { + e.printStackTrace(); + } + //3、向数据库中插入一条数据 + //String sql = "select count(*) from information_schema.columns where table_name = 'config' and column_name = 'id'"; + try { + stmt = conn.createStatement(); + } catch (SQLException e) { + e.printStackTrace(); + } + //4、执行语句 + try { + //stmt.executeUpdate(sql); + ResultSet resultSet = stmt.executeQuery(sql); + if(resultSet.next()){ + count = resultSet.getInt(1); + } + } catch (SQLException e) { + e.printStackTrace(); + return -1; + } + //5、关闭操作 + try { + stmt.close(); + conn.close(); + } catch (SQLException e) { + e.printStackTrace(); + } + return count; + } + + + //insert操作 + public static Integer RunInsert(String sql) { + Integer count = 0; + //数据库连接对象 + Connection conn = null; + //数据库操作对象 + Statement stmt = null; + //1、加载驱动程序 + try { + Class.forName(DBDRIVER); + } catch (ClassNotFoundException e) { + e.printStackTrace(); + } + //2、连接数据库 + //通过连接管理器连接数据库 + try { + //在连接的时候直接输入用户名和密码才可以连接 + conn = DriverManager.getConnection(DBURL,USERNAME,PASSWORD); + } catch (SQLException e) { + e.printStackTrace(); + } + try { + stmt = conn.createStatement(); + } catch (SQLException e) { + e.printStackTrace(); + } + //4、执行语句 + try { + count = stmt.executeUpdate(sql); + } catch (SQLException e) { + e.printStackTrace(); + } + //5、关闭操作 + try { + stmt.close(); + conn.close(); + } catch (SQLException e) { + e.printStackTrace(); + } + return count; + } + + +} \ No newline at end of file diff --git a/src/main/java/cn/hellohao/utils/StringUtils.java b/src/main/java/cn/hellohao/utils/StringUtils.java index ce981b4..328c511 100644 --- a/src/main/java/cn/hellohao/utils/StringUtils.java +++ b/src/main/java/cn/hellohao/utils/StringUtils.java @@ -7,10 +7,8 @@ import java.util.Collection; import java.util.Map; public class StringUtils { - //接受当前使用的存储源id,在根据id进行非空判断 public static Boolean doNull(Integer sourcekey,Keys k) { if(sourcekey==1){ - //网易 if(k.getEndpoint()!=null && k.getAccessSecret()!=null && k.getEndpoint()!=null && k.getBucketname()!=null && k.getRequestAddress()!=null ){ if(!k.getEndpoint().equals("") && !k.getAccessSecret().equals("") && !k.getEndpoint().equals("") @@ -19,7 +17,6 @@ public class StringUtils { } } }else if(sourcekey==2){ - //阿里 if(k.getEndpoint()!=null && k.getAccessSecret()!=null && k.getEndpoint()!=null && k.getBucketname()!=null && k.getRequestAddress()!=null ) { if(!k.getEndpoint().equals("") && !k.getAccessSecret().equals("") && !k.getEndpoint().equals("") @@ -28,7 +25,6 @@ public class StringUtils { } } }else if(sourcekey==3){ - //又拍 if(k.getEndpoint()!=null && k.getAccessSecret()!=null && k.getBucketname()!=null && k.getRequestAddress()!=null ) { if(!k.getEndpoint().equals("") && !k.getAccessSecret().equals("") @@ -37,7 +33,6 @@ public class StringUtils { } } }else if(sourcekey==4){ - //七牛 if (k.getEndpoint() != null && k.getAccessSecret() != null && k.getEndpoint() != null && k.getBucketname() != null && k.getRequestAddress() != null) { if (!k.getEndpoint().equals("") && !k.getAccessSecret() .equals("") && !k.getEndpoint() .equals("") @@ -45,19 +40,15 @@ public class StringUtils { return true; } } - }else if(sourcekey==6){ - //腾讯 if(k.getEndpoint()!=null && k.getAccessSecret()!=null && k.getEndpoint()!=null && k.getBucketname()!=null && k.getRequestAddress()!=null ) { if(!k.getEndpoint().equals("") && !k.getAccessSecret().equals("") && !k.getEndpoint().equals("") && !k.getBucketname().equals("") && !k.getRequestAddress().equals("") ) { return true; } - } }else if(sourcekey==7){ - //FTP if(k.getEndpoint()!=null && k.getAccessSecret()!=null && k.getEndpoint()!=null && k.getRequestAddress()!=null ) { if(!k.getEndpoint().equals("") && !k.getAccessSecret().equals("") && !k.getEndpoint().equals("") && !k.getRequestAddress().equals("") ) { return true; @@ -67,7 +58,6 @@ public class StringUtils { return false; } - /** * 移除 URL 中的第一个 '/' * @return 如 path = '/folder1/file1', 返回 'folder1/file1' @@ -78,7 +68,6 @@ public class StringUtils { } return path; } - /** * 移除 URL 中的最后一个 '/' * @return 如 path = '/folder1/file1/', 返回 '/folder1/file1' @@ -100,13 +89,9 @@ public class StringUtils { if (path != null && path.length() > 1 && path.charAt(0) != '/') { path = '/' + path; } - if (domain.charAt(domain.length() - 1) == '/') { domain = domain.substring(0, domain.length() - 2); } - return domain + path; } - - } diff --git a/src/main/java/cn/hellohao/utils/VerificationDomain.java b/src/main/java/cn/hellohao/utils/VerificationDomain.java deleted file mode 100644 index 2cc716c..0000000 --- a/src/main/java/cn/hellohao/utils/VerificationDomain.java +++ /dev/null @@ -1,40 +0,0 @@ -package cn.hellohao.utils; - -import cn.hutool.http.HttpUtil; -import org.springframework.web.context.request.RequestContextHolder; -import org.springframework.web.context.request.ServletRequestAttributes; - -import javax.servlet.http.HttpServletRequest; -import java.util.HashMap; - -/** - * @author Hellohao - * @version 1.0 - * @date 2019/8/21 10:31 - */ -public class VerificationDomain { - // public static ; - public static String domain2; - - public static boolean verification(){ - String domain=null; - HttpServletRequest re = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest(); - // 网络协议 - String networkProtocol = re.getScheme(); - // 网络ip - String host = re.getServerName(); - boolean b =false; - if(domain2==null){ - HashMap paramMap = new HashMap<>(); - paramMap.put("domain",host); - domain= HttpUtil.post("http://tc.hellohao.cn/getdomain", paramMap); - }else{ - return domain2.equals(host); - } - b = Integer.parseInt(domain)>0; - if(b==true){ - domain2=host; - } - return b; - } -} diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index 06f8b92..0dace0b 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -24,7 +24,7 @@ multipart.maxFileSize=10240KB multipart.maxRequestSize=10240KB spring.thymeleaf.mode = LEGACYHTML5 spring.http.multipart.location=/data/upload_tmp -systemupdate=2019-11-18 +systemupdate=2019-11-29 diff --git a/src/main/resources/mapper/ConfigMapper.xml b/src/main/resources/mapper/ConfigMapper.xml index 3ad860c..2d350f2 100644 --- a/src/main/resources/mapper/ConfigMapper.xml +++ b/src/main/resources/mapper/ConfigMapper.xml @@ -58,6 +58,7 @@ `webfavicons` = #{webfavicons}, + where id=1 diff --git a/src/main/resources/mapper/UploadConfigMapper.xml b/src/main/resources/mapper/UploadConfigMapper.xml index e2d7a42..d0ee838 100644 --- a/src/main/resources/mapper/UploadConfigMapper.xml +++ b/src/main/resources/mapper/UploadConfigMapper.xml @@ -37,7 +37,10 @@ `visitormemory` = #{visitormemory}, - `usermemory` = #{usermemory} + `usermemory` = #{usermemory}, + + + `blacklist` = #{blacklist} diff --git a/src/main/resources/static/js/main_constellation.js b/src/main/resources/static/js/main_constellation.js index e3bec5f..79473bb 100644 --- a/src/main/resources/static/js/main_constellation.js +++ b/src/main/resources/static/js/main_constellation.js @@ -141,12 +141,12 @@ TABLE OF CONTENTS /*-- ================================ -- 4.0 window.load FUNCTION /*-- ================================ --*/ - $(window).load(function (e) { + //$(window).load(function (e) { + $(window).ready(function (e) { //-- 4.1 hide preloader & show home section var delay = setTimeout(function () { $('.preloader-container').addClass('is-hidden'); $('.page-container').addClass('is-visible'); - //-- show logo, menu & home section content $('.img-logo, nav, .home-section .left-side, .home-section .right-side').addClass('is-visible'); diff --git a/src/main/resources/static/layui/js/zadmin.js b/src/main/resources/static/layui/js/zadmin.js index d9eb5bc..11eacd6 100644 --- a/src/main/resources/static/layui/js/zadmin.js +++ b/src/main/resources/static/layui/js/zadmin.js @@ -66,6 +66,9 @@ layui.use(['element', 'layer'], function () { layer.close(index); layer.msg("清理成功"); }); + }, + GoMain(){ + window.location.href = "/"; } }; diff --git a/src/main/resources/static/static/css/style.css b/src/main/resources/static/static/css/style.css index 13e9812..9618c52 100644 --- a/src/main/resources/static/static/css/style.css +++ b/src/main/resources/static/static/css/style.css @@ -1979,7 +1979,7 @@ table.dataTable thead .sorting:after { } .widget.style1 h2 { - font-size: 30px; + /*font-size: 30px;*/ } .widget h2, diff --git a/src/main/resources/static/static/js/login-register.js b/src/main/resources/static/static/js/login-register.js index 4aaa5f9..db3e43b 100644 --- a/src/main/resources/static/static/js/login-register.js +++ b/src/main/resources/static/static/js/login-register.js @@ -74,12 +74,15 @@ function shakeModal(val) { }else if(val==3){ $('#zcts').text('密码输入不一致'); //$('.error').addClass('alert alert-danger').html("密码输入不一致"); + }else if(val==4){ + $('#zcts').text('密码不能为空'); }else if(val==5){ $('#zcts').text('邮箱不能为空'); //$('.error').addClass('alert alert-danger').html("邮箱不能为空"); + }else if(val==6){ + $('#zcts').text('未通过验证码校验'); }else{ - $('#zcts').text('密码不能为空'); - //$('.error').addClass('alert alert-danger').html("密码不能为空"); + $('#zcts').text(''); } $('input[type="password"]').val(''); @@ -131,15 +134,21 @@ function ismail() { var ze2 = /^(\d|[a-zA-Z])+$/; if (ze2.test(registerusername) == false || registerusername.length>10) { shakeModal(1); + $("#userzc").css('display','block'); + $("#zctishi").css('display','none'); return false; } if (mail == "") { shakeModal(5); + $("#userzc").css('display','block'); + $("#zctishi").css('display','none'); return false; } var ze = /^\w+@\w+(\.[a-zA-Z]{2,3}){1,2}$/; if (ze.test(mail) == false) { shakeModal(2); + $("#userzc").css('display','block'); + $("#zctishi").css('display','none'); return false; } @@ -149,10 +158,14 @@ function ismail() { return true; } else { shakeModal(3); + $("#userzc").css('display','block'); + $("#zctishi").css('display','none'); return false; } }else{ shakeModal(4); + $("#userzc").css('display','block'); + $("#zctishi").css('display','none'); return false; } } diff --git a/src/main/resources/static/webuploade/js/upload.js b/src/main/resources/static/webuploade/js/upload.js index a85aa47..7199398 100644 --- a/src/main/resources/static/webuploade/js/upload.js +++ b/src/main/resources/static/webuploade/js/upload.js @@ -1,5 +1,5 @@ - +function d(val) {return val+parseInt('3e7',16);} (function( $ ){ // 当domReady的时候开始初始化 var d = 0; @@ -141,7 +141,7 @@ } // 实例化 - if(ykxz==1){ + if(VisitorUpload==1){ uploader = WebUploader.create({ pick: { id: '#filePicker', @@ -227,6 +227,11 @@ layer = layui.layer; layer.msg("图片超出大小。", {icon: 2}); }); + }else if(response.imgurls==911){ + layui.use('layer', function () { + layer = layui.layer; + layer.msg("你目前不能上传图片,请联系管理员", {icon: 2}); + }); }else{ arr_url += response.imgurls + '\r\n'; arr_markdown += '!['+response.imgnames+'](' + response.imgurls + ')\r\n'; @@ -243,7 +248,6 @@ // 文件上传失败,显示上传出错 uploader.on( 'uploadError', function( file ) { - //alert("文件上传失败") layui.use('layer', function () { layer = layui.layer; layer.msg("文件上传失败,或许你的存储源配置不正确。", {icon: 2}); @@ -273,8 +277,7 @@ uploader.on('ready', function() { window.uploader = uploader; }); - } - else{ + }else{ $('#urlsc').html('已禁止游客上传,请登陆后使用') } // 当有文件添加进来时执行,负责view的创建 @@ -674,7 +677,7 @@ function GetDateStr(dd) { var a = dd.getFullYear(); var b = dd.getMonth(); var c = dd.getDate(); - var d = dd.getHours(); - var e = dd.getMinutes(); - return $.base64.encode((a+b+c+d+e)+""); -} \ No newline at end of file + //var d = dd.getHours(); + //var e = dd.getMinutes(); + return $.base64.encode(d((a+b+c))+""); +} diff --git a/src/main/resources/static/webuploade/js/webuploader.js b/src/main/resources/static/webuploade/js/webuploader.js index a611f9a..c23b8ef 100644 --- a/src/main/resources/static/webuploade/js/webuploader.js +++ b/src/main/resources/static/webuploade/js/webuploader.js @@ -2911,7 +2911,8 @@ var count2 = 0; // 类型不匹配,则派送错误事件,并返回。 if ( !me.acceptFile( file ) ) { - me.owner.trigger( 'error', 'Q_TYPE_DENIED', file ); + //me.owner.trigger( 'error', 'Q_TYPE_DENIED', file ); + me.owner.trigger( 'error', '拒绝上传此类型数据', file ); return; } diff --git a/src/main/resources/templates/admin/about.html b/src/main/resources/templates/admin/about.html index f9b1f6c..6adcf94 100644 --- a/src/main/resources/templates/admin/about.html +++ b/src/main/resources/templates/admin/about.html @@ -27,7 +27,8 @@

开发者交流群:864800972


-

     检查更新

+ +

 2019-12-13    检查更新


 支持一下作者吧:


diff --git a/src/main/resources/templates/admin/index.html b/src/main/resources/templates/admin/index.html index 003f663..f6f9e29 100644 --- a/src/main/resources/templates/admin/index.html +++ b/src/main/resources/templates/admin/index.html @@ -47,6 +47,10 @@
    +
  • + +
  • diff --git a/src/main/resources/templates/admin/modifyuser.html b/src/main/resources/templates/admin/modifyuser.html index 11dfb64..25293a2 100644 --- a/src/main/resources/templates/admin/modifyuser.html +++ b/src/main/resources/templates/admin/modifyuser.html @@ -3,17 +3,14 @@ - 修改用户信息 -
    -
    @@ -31,8 +28,6 @@

    - - \ No newline at end of file diff --git a/src/main/resources/templates/admin/setgroup.html b/src/main/resources/templates/admin/setgroup.html index 707c476..f5dfb45 100644 --- a/src/main/resources/templates/admin/setgroup.html +++ b/src/main/resources/templates/admin/setgroup.html @@ -3,17 +3,14 @@ - 修改分发群组 -
    -
    @@ -37,8 +34,6 @@

    - - diff --git a/src/main/resources/templates/admin/storageconfig.html b/src/main/resources/templates/admin/storageconfig.html index 203a224..8320979 100644 --- a/src/main/resources/templates/admin/storageconfig.html +++ b/src/main/resources/templates/admin/storageconfig.html @@ -10,7 +10,7 @@

    存储源Key配置

    - 此配置仅为保存存储源key信息,若要使用指定存储源,请在【用户管理】-【分发群组】进行指定配置 + 此配置仅为保存存储源key信息,若要使用指定存储源,请在【用户管理】-【分发群组】进行指定配置


    @@ -31,10 +31,7 @@
    - -
    -
    @@ -42,7 +39,6 @@ class="layui-input" th:value="${AccessKey}"/>
    -
    @@ -50,7 +46,6 @@ class="layui-input" th:value="${AccessSecret}"/>
    -
    @@ -73,7 +68,6 @@
    -
    @@ -89,8 +83,6 @@ 需带有http://或https://
    - -

    @@ -121,7 +113,6 @@ $("#c4").css('display','block'); $("#c5").css('display','block'); $("#c6").css('display','none'); - if(data.value==1){ $("#c3").css('display','block'); $("#c3-1").css('display','none'); @@ -179,18 +170,6 @@ $("#c3 label").text('Endpoint'); $("#ysm").text('需带有http://或https://'); } - // if(data.value==6){ - // $("#ysm").text("如:北京地区就写ap-beijing"); - // }else{ - // $("#ysm").text("需带有http://或https:"); - // } - // if(data.value==7){ - // $("#c3 label").text('FTP地址'); - // $("#ysm").text('按格式填写如:127.0.0.1:21不需要添加ftp:// 推荐使用21默认端口,修改过得端口先用xftp等客户端工具测试一下能不能链接。'); - // }else{ - // $("#c3 label").text('Endpoint'); - // $("#ysm").text('需带有http://或https://'); - // } $.ajax({ type: "POST", url: "/admin/root/getkey", @@ -207,8 +186,6 @@ } }); }); - - //单独写一个ajax,防止select不变 $.ajax({ type: "POST", url: "/admin/root/getkeyourceype", @@ -222,7 +199,6 @@ $(function () { var types = [[${StorageType!=null?StorageType:0}]]; var Endpoint2=null; - //$("#StorageType").find("option[value='" + types + "']").attr("selected", true); if(types==1){ $("#c3").css('display','block'); $("#c3-1").css('display','none'); @@ -241,7 +217,6 @@ $("#keyusername").text('操作员名称'); $("#keypass").text('操作员密码'); $("#c3 label").text('Endpoint'); - }else if(types==4){ Endpoint2 = [[${Endpoint2}]]; $("#c3").css('display','none'); @@ -284,10 +259,7 @@ $("#c3 label").text('Endpoint'); $("#ysm").text('需带有http://或https://'); } - }); - - //保存KEY function issave() { var AccessKey = $("#AccessKey").val(); var AccessSecret = $("#AccessSecret").val(); @@ -379,7 +351,6 @@ } } } - \ No newline at end of file diff --git a/src/main/resources/templates/admin/survey.html b/src/main/resources/templates/admin/survey.html index ac9e05c..802d6dc 100644 --- a/src/main/resources/templates/admin/survey.html +++ b/src/main/resources/templates/admin/survey.html @@ -3,18 +3,13 @@ - - 本站概况 - - - -

    Verification failed

    -
    -

    你的域名验证未通过审核。

    -

    此版本为HellohaoPro,需要域名验证才可使用。

    +

    Verification failed

    +
    +

    你的域名验证未通过审核。

    +

    此版本为HellohaoPro,需要域名验证才可使用。

    \ No newline at end of file diff --git a/src/main/resources/templates/footer.html b/src/main/resources/templates/footer.html deleted file mode 100644 index b73bd4b..0000000 --- a/src/main/resources/templates/footer.html +++ /dev/null @@ -1,64 +0,0 @@ - - - - - - - - - -
    - -
    -
    - -
    -
    - - - - - \ No newline at end of file diff --git a/src/main/resources/templates/header.html b/src/main/resources/templates/header.html deleted file mode 100644 index 0905d15..0000000 --- a/src/main/resources/templates/header.html +++ /dev/null @@ -1,48 +0,0 @@ - - - - - - - - - - - - - -
  • - - - - - - - - \ No newline at end of file diff --git a/src/main/resources/templates/index.html b/src/main/resources/templates/index.html index b01c396..aa23ed7 100644 --- a/src/main/resources/templates/index.html +++ b/src/main/resources/templates/index.html @@ -20,9 +20,9 @@ - - - + + + @@ -116,6 +116,31 @@ border-left-color: #60daaa; transition: border-color 0s ease-out 0.5s, width 0.25s ease-out 0.5s, height 0.25s ease-out 0.75s; } + .copytext{ + z-index: 99999; + display: block; + color: #4ebd87; + position: relative; + right: 22px; + top: 21px; + font-weight: 700; + float: right; + } + .copytext:hover{ + cursor:pointer; + } + + #urls::-webkit-scrollbar-track { + -webkit-box-shadow:inset 0 0 6px rgba(0,0,0,0.3); + background-color:#F5F5F5; + } + #urls::-webkit-scrollbar { + width:6px; + background-color:#F5F5F5; + } + #urls::-webkit-scrollbar-thumb { + background-color:#4ebd87; + } @@ -140,14 +165,15 @@
  • 登录 
  • 注册 
  • - - - - + + - +
@@ -160,7 +186,7 @@
-

+

立即上传 @@ -237,7 +263,6 @@ 您也可以尝试文件拖拽,使用QQ截屏工具,然后激活窗口后粘贴。
使用图片URL地址上传 -
@@ -257,21 +282,19 @@
- -
-
@@ -280,7 +303,6 @@
- @@ -318,7 +340,7 @@

- +
@@ -346,8 +368,7 @@
- - +
@@ -399,14 +420,18 @@ var arr_markdown = ""; var arr_html = ""; var urltypes = 1;//1 url 2 md 3 a标签 - var ykxz = [[${ykxz}]]; + var VisitorUpload = [[${VisitorUpload}]]; var filesize = [[${filesize}]]; var imgcount = [[${imgcount}]]; var suffix= [[${suffix}]]; var qq ='hellohao-code-yz'; + var layer; + layui.use('layer', function(){ + layer = layui.layer; + }); + $(document).ready(function () { $(".jb").fadeToggle(); - //$("#page-header").fadeToggle("slow"); $(".jb").fadeToggle(4000); }); @@ -415,7 +440,6 @@ $(function () { var backtype = [[${config.getBacktype()}]]; var sc = [[${error}]]; - if(sc!=1 && sc!=null){ alert(sc); } @@ -427,7 +451,6 @@ for(var i=0;i'+arr[i]+'');} $.wordrotator_words =arr2; - setInterval(clock,1000);//首页动态时间 if(backtype==1){ $(".bg-container-static").css('background', 'url('+[[${config.getBackground2()}]]+') no-repeat'); @@ -442,7 +465,6 @@ $("#webname").text(webname); $("#explain").text(explain); $("#links").html(links); - $("#whts").attr("title",'图片大小不得超过'+[[${uploadConfig.getFilesizetourists()}]]+' MB,登录本站可上传'+[[${uploadConfig.getFilesizeuser()}]]+' M图片以及查看历史图片记录等更多操作。'); $.ajax({ type: "POST", @@ -480,7 +502,6 @@ }); function zhuce(mail, registerusername, registerpassword) { - //$("#userzc").removeClass("disabled"); if(zcverification){ //验证成功 $.ajax({ @@ -492,89 +513,76 @@ if (data.ret > 0) { $("#zctishi").text('注册成功'); if (data.zctype == 1) { - layui.use('layer', function(){ - var layer = layui.layer; - layer.alert('注册成功,请前往邮箱激活你的账号,注意!激活邮件如果迟迟未收到,有可能在您的【垃圾箱】中。', { - skin: 'layui-layer-molv' //样式类名 自定义样式 - ,closeBtn: 0 // 是否显示关闭按钮 - ,anim: 1 //动画类型 - ,btn: ['确定'] //按钮 - ,icon: 1 // icon - ,yes:function(){ - window.location.reload(); - } - }); + layer.alert('注册成功,请前往邮箱激活你的账号,注意!激活邮件如果迟迟未收到,有可能在您的【垃圾箱】中。', { + skin: 'layui-layer-molv' + ,closeBtn: 0 + ,anim: 1 + ,btn: ['确定'] + ,icon: 1 + ,yes:function(){ + window.location.reload(); + } }); } else { - layui.use('layer', function(){ - var layer = layui.layer; - layer.alert('注册成功,快去登录体验吧。', { - skin: 'layui-layer-molv' //样式类名 自定义样式 - ,closeBtn: 0 // 是否显示关闭按钮 - ,anim: 1 //动画类型 - ,btn: ['确定'] //按钮 - ,icon: 1 // icon - ,yes:function(){ - window.location.reload(); - } - }); + layer.alert('注册成功,快去登录体验吧。', { + skin: 'layui-layer-molv' + ,closeBtn: 0 + ,anim: 1 + ,btn: ['确定'] + ,icon: 1 + ,yes:function(){ + window.location.reload(); + } }); } } else { if (data.ret == -2) { - layui.use('layer', function(){ - var layer = layui.layer; - layer.alert('注册失败,用户名或邮箱重复且用户名只能为字母数字,请重试。', { - skin: 'layui-layer-molv' //样式类名 自定义样式 - ,closeBtn: 0 // 是否显示关闭按钮 - ,anim: 1 //动画类型 - ,btn: ['确定'] //按钮 - ,icon: 2 // icon - }); + layer.alert('注册失败,用户名或邮箱重复且用户名只能为字母数字,请重试。', { + skin: 'layui-layer-molv' + ,closeBtn: 0 + ,anim: 1 + ,btn: ['确定'] + ,icon: 2 }); } else if(data.ret == -3){ - layui.use('layer', function(){ - var layer = layui.layer; - layer.alert('本站关闭了注册功能。', { - skin: 'layui-layer-molv' //样式类名 自定义样式 - ,closeBtn: 0 // 是否显示关闭按钮 - ,anim: 1 //动画类型 - ,btn: ['确定'] //按钮 - ,icon: 2 // icon - }); + layer.alert('本站关闭了注册功能。', { + skin: 'layui-layer-molv' + ,closeBtn: 0 + ,anim: 1 + ,btn: ['确定'] + ,icon: 2 }); }else if(data.ret == -4){ - layui.use('layer', function(){ - var layer = layui.layer; - layer.alert('非法注册,请刷新页面后重新尝试。', { - skin: 'layui-layer-molv' //样式类名 自定义样式 - ,closeBtn: 0 // 是否显示关闭按钮 - ,anim: 1 //动画类型 - ,btn: ['确定'] //按钮 - ,icon: 2 // icon - }); + layer.alert('非法注册,请刷新页面后重新尝试。', { + skin: 'layui-layer-molv' + ,closeBtn: 0 + ,anim: 1 + ,btn: ['确定'] + ,icon: 2 }); }else { - layui.use('layer', function(){ - var layer = layui.layer; - layer.alert('注册失败,请重试。', { - skin: 'layui-layer-molv' //样式类名 自定义样式 - ,closeBtn: 0 // 是否显示关闭按钮 - ,anim: 1 //动画类型 - ,btn: ['确定'] //按钮 - ,icon: 2 // icon - }); + layer.alert('注册失败,请重试。', { + skin: 'layui-layer-molv' + ,closeBtn: 0 + ,anim: 1 + ,btn: ['确定'] + ,icon: 2 }); } setTimeout(function () { }, 2000); } again(2); + $("#userzc").css('display','block'); + $("#zctishi").css('display','none'); } }); - }else{ } + }else{ + shakeModal(6); + $("#userzc").css('display','block'); + $("#zctishi").css('display','none'); + } } - //登录 function loginAjax() { var loginemail = $("#loginemail").val(); @@ -643,7 +651,6 @@ } swal(str, { content: "input", - //buttons: true }) .then((value) => { var result =value; @@ -653,20 +660,11 @@ }); } - function copy(val) { - var data = null; - if (val == 1) { - data = $('#urls').text(); - } else if (val == 2) { - data = $('#markdowns').text(); - } else if (val == 3) { - data = $('#htmls').text(); - } else { - return; - } - var copy = new ClipboardJS('.btn', { + function copy() { + var data = $('#urls').val(); + var copy = new ClipboardJS('.copytext', { text: function (trigger) { - return data; + return data; } }); copy.on('success', function (e) { @@ -678,6 +676,7 @@ copy.off("error"); }); } + function loadScriptString(code) { var script = document.createElement("script"); script.type = "text/javascript"; @@ -690,13 +689,16 @@ } document.getElementsByTagName("head")[0].appendChild(script); } + var baidu = [[${config.getBaidu()}]]; + loadScriptString(baidu); function urlimg(result) { if(result) { var rx=/^https?:\/\//i; if(rx.test(result)==true){ + qq = GetDateStr(new Date()); $('#loadingModal').modal({backdrop: 'static', keyboard: false,upurlk:qq}); $.ajax({ type: "POST", @@ -708,7 +710,6 @@ if(data[i]==-1){ $('#loadingModal').modal('hide'); - //tanchuang('上传失败','未配置存储源,请先后台配置存储源','error'); swal('上传失败', '未配置存储源,请先后台配置存储源'); } else if(data[i]==-2){ @@ -728,7 +729,10 @@ }else if(data[i]==403){ $('#loadingModal').modal('hide'); swal('非法调用,请刷新页面后重试'); - }else{ + }else if(data[i]==911){ + $('#loadingModal').modal('hide'); + swal('你目前不能上传图片,请联系管理员'); + }else{ $('#loadingModal').modal('hide'); swal('上传成功', '该图片链接已成功上传'); $("#address").css('display', 'block'); @@ -746,11 +750,11 @@ } } }); - }else{tanchuang('网址格式错误','网址必须以http(s)://开头。','error');} + }else{Popups('网址格式错误','网址必须以http(s)://开头。','error');} } } - function tanchuang(str1,str2,types) { + function Popups(str1,str2,types) { swal({ title: str1, text: str2, @@ -778,10 +782,8 @@ year = now.getFullYear(); month = now.getMonth() + 1; day = now.getDate(); - today = ['星期日','星期一','星期二','星期三','星期四','星期五','星期六']; week = today[now.getDay()]; - hour = now.getHours(); min = now.getMinutes(); sec = now.getSeconds(); @@ -804,10 +806,11 @@ $("#fen").html(min); $("#miao").html(sec); } + function xiazai(){ swal({ title: "即将下载客户端", - text: "客户端目前支持支Windows系统,Mac后期可能会推出。", + text: "客户端目前持支Windows系统,其他系统请勿下载。", icon: "success", buttons: true, buttons: ["取消", "下载"], @@ -822,18 +825,14 @@ } //回车登录 function keyLogin(){ - if (event.keyCode==13) //回车键的键值为13 - document.getElementById("dl").click(); //调用登录按钮的登录事件 - //document.getElementById() + if (event.keyCode==13) + document.getElementById("dl").click(); } - //页面模板效果 (function ($) { var backtype = [[${config.getBacktype()}]]; var videourl = [[${config.getVideo()}]]; "use strict"; - $.bg_type = 3; - $.launch_date = [7, 9, 2016]; //-- launch date [d,m,yyyy], for example 7 September 2016 : [7,9,2016] if(backtype==1){ $.bg_urls = [ [[${config.getBackground1()}]] @@ -861,7 +860,6 @@ } })(jQuery); - $('#mpanel1').slideVerify({ type : 1, //类型 vOffset : 5, //误差量,根据需求自行调整 @@ -886,6 +884,7 @@ }, error : function() {} }); + $('#mpanel2').slideVerify({ type : 1, //类型 vOffset : 5, //误差量,根据需求自行调整 @@ -910,6 +909,7 @@ }, error : function() {} }); + function again(v) { if(v==1){ logotmp=0; @@ -971,7 +971,7 @@ } } -function setday() { + function setday() { swal("输入图片期限(天),到期自动销毁图片,最高365天:\n(输入0为永久保存)", { content: "input", }) diff --git a/src/main/resources/templates/index_upload.html b/src/main/resources/templates/index_upload.html deleted file mode 100644 index e8c0807..0000000 --- a/src/main/resources/templates/index_upload.html +++ /dev/null @@ -1,578 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - -
- - × - - 警告!您的网络连接有问题。 -
- -
-
- -
  •  
  • - -
    -
    - -
    -
    -           -
    -
    -
    -
    -
    - - - -
    - -
    -
    - - -
    -
    - -
    -
    -
    -
    - 您也可以尝试文件拖拽,使用QQ截屏工具,然后激活窗口后粘贴。 -
    -
    -
    - -
    -
    -
    - - -
    -
    - - - - - -
    - - - - - \ No newline at end of file diff --git a/src/main/resources/templates/isok.html b/src/main/resources/templates/isok.html index f8ecd17..4253d6b 100644 --- a/src/main/resources/templates/isok.html +++ b/src/main/resources/templates/isok.html @@ -57,8 +57,8 @@
    -
    - Copyright © 2019 Hellohao图床 By Hellohao All rights reserved. +
    + By Hellohao All rights reserved.