Java Code Examples for com.xnx3.DateUtil#timeForUnix10()

The following examples show how to use com.xnx3.DateUtil#timeForUnix10() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Log.java    From wangmarket with Apache License 2.0 6 votes vote down vote up
public static void requestLog(HttpServletRequest request, RequestInfo requestInfo, SImpleSiteVO simpleSiteVO){
	//未开启日志记录
	if(aliyunLogUtil == null){
		return;
	}
	if(simpleSiteVO.getResult() - SImpleSiteVO.FAILURE == 0){
		//失败的,没有访问正规站点的,可能是ip直接访问的,或者访问的未绑定上的域名过来的。这样的不与记录。
		return;
	}
	
	LogItem logItem = new LogItem(DateUtil.timeForUnix10());
	logItem.PushBack("ip", requestInfo.getIp());
	logItem.PushBack("referer", requestInfo.getReferer());
	logItem.PushBack("userAgent", requestInfo.getUserAgent());
	logItem.PushBack("htmlFile", requestInfo.getHtmlFile());
	logItem.PushBack("siteid", simpleSiteVO.getSimpleSite().getId()+"");
	logItem.PushBack("serverName", requestInfo.getServerName());
	
	try {
		aliyunLogUtil.cacheLog(logItem);
	} catch (LogException e1) {
		e1.printStackTrace();
	}
}
 
Example 2
Source File: AliyunLogUtil.java    From xnx3 with Apache License 2.0 6 votes vote down vote up
/**
 * 手动将 {@link #cacheLog(LogItem)} 缓存中的数据提交到阿里云日志服务中去。若提交成功,便清空缓存。
 * <br/>此方法会在 {@link #cacheLog(LogItem)} 向缓存中添加日志时,当达到 {@link #setCacheLogMaxNumber(int)} 设置的缓存最大条数后会自动触发。
 * <br/>当然,比如Tomcat停止时,或者其他意外情况,也可以手动调用此处方法触发提交到阿里云日志服务中的命令
 * @return {@link PutLogsResponse} 提交返回的结果
 * @throws LogException
 */
public PutLogsResponse cacheCommit() throws LogException{
	PutLogsResponse r = saveByGroup("", "", logGroupCache);
	if(r != null && r.GetRequestId() != null && r.GetRequestId().length() > 0){
		//数据提交成功

		//清空日志缓存及条数
		logGroupCache.clear();
		//同步最后提交时间
		int currentTime = DateUtil.timeForUnix10();	//当前时间
		if(lastSubmitTime < currentTime){
			lastSubmitTime = currentTime;
		}
	}
       return r;
}
 
Example 3
Source File: TemplateCMS.java    From wangmarket with Apache License 2.0 6 votes vote down vote up
private void templateCMS(Site site, com.xnx3.wangmarket.admin.entity.Template template){
	linuxTime = DateUtil.timeForUnix10();
	this.site = site;
	
	this.template = template;
	
	if(Global.get("MASTER_SITE_URL") != null && Global.get("MASTER_SITE_URL").equals("http://wang.market/")){
		if(site.getId() - 255 > 0){
			//site.id < 255 的站点,是code模式
			generateUrlRule = "code";
		}
		if(site.getId() - 218 == 0){
			//site.id 218 是qiye1,作为调试使用
			generateUrlRule = "code";
		}
	}else{
		//后台主域名不是wang.market,那可能就是别人在使用这个程序,直接使用code模式生成html文件
		generateUrlRule = "code";
	}
	
}
 
Example 4
Source File: ImController.java    From wangmarket with Apache License 2.0 6 votes vote down vote up
/**
 * 历史聊天人列表,会话列表,每一项都是一个人
 */
@RequestMapping("hostoryChatList${url.suffix}")
public String hostoryChatList(HttpServletRequest request,Model model){
	if(Global.aliyunLogUtil == null){
		return error(model, "您未开启IM客服访问相关的日志服务!");
	}
	User user = getUser();
	int currentTime = DateUtil.timeForUnix10();
	int startTime = currentTime - 86400*30;	//30天内有效
	try {
		AliyunLogPageUtil log = new AliyunLogPageUtil(Global.aliyunLogUtil);
		JSONArray jsonArray = log.listForJSONArray("receiveId = "+user.getId()+" | select max(sendId) , map_agg('array',sendUserName) as sendUserName,max(sendId) as sendIds, count(*) as count, max(__time__) as time group by sendId order by time desc limit 100", "", false, startTime, currentTime, 100, request);
		model.addAttribute("list", jsonArray);
	} catch (LogException e) {
		e.printStackTrace();
	}
	
	return "im/hostoryChatList";
}
 
Example 5
Source File: WeiXinUtil.java    From xnx3 with Apache License 2.0 5 votes vote down vote up
/**
 * 获取最新的普通access_token
 * @return AccessToken 若返回null,则获取access_token失败
 */
public AccessToken getAccessToken(){
	boolean refreshToken = false;	//需重新刷新获取token,默认是不需要
	
	if(accessToken == null){
		accessToken = new AccessToken();
		refreshToken = true;
	}
	
	//是否过时,需要重新获取token
	if(DateUtil.timeForUnix10()>accessToken.getGainTime()+ACCESS_TOKEN_DELAY_TIME){
		refreshToken = true;
	}
	
	//避免一次可能网络中断,连续获取三次,减小误差
	boolean success = !refreshToken;
	int i = 0;
	for (; i < 3 && !success ; i++) {
		success = refreshAccessToken();
	}
	
	if(!success){
		debug("连续获取"+i+"次access_token,均失败!" );
		return null;
	}else{
		return accessToken;
	}
}
 
Example 6
Source File: BaseGenerate.java    From wangmarket with Apache License 2.0 5 votes vote down vote up
/**
 * 生成js缓存文件保存
 */
public void generateCacheFile(){
	addCommonJsFunction();
	initCacheFolder();
	String filePath = Global.getProjectPath()+Global.CACHE_FILE+getClass().getSimpleName()+"_"+objName+".js"; 
	try {
		content = content + " var xnx3_r"+DateUtil.timeForUnix10()+" = '"+getRandomValue()+"';";
		FileUtil.write(filePath, content,FileUtil.UTF8);
		com.xnx3.j2ee.func.Log.info("create cache js file success ! file path : "+filePath);
	} catch (IOException e) {
		e.printStackTrace();
	}
	this.content=null;
}
 
Example 7
Source File: SmsLogServiceImpl.java    From wangmarket with Apache License 2.0 5 votes vote down vote up
/**
 * 通用手机验证码验证方法。输入手机号、动态验证码,验证是否成功
 * @param phone 目标手机号
 * @param code 六位数动态验证码
 * @param type 发送类型,位于 {@link SmsLog}, {@link SmsLog}.type的值
 * 				<ul>
 * 					<li>1:{@link SmsLog#TYPE_LOGIN}登录 </li>,若是使用此类型,则后面的overdue过期时间无用
 * 					<li>2:{@link SmsLog#TYPE_FIND_PASSWORD}找回密码 </li>
 * 					<li>3:{@link SmsLog#TYPE_BIND_PHONE}绑定手机 </li>
 * 				</ul>
 * @param overdue 验证码过期时间,单位为秒。除了type为{@link SmsLog#TYPE_LOGIN}以外都有效
 * @return {@link BaseVO}
 */
public BaseVO verifyPhoneAndCode(String phone, String code, Short type, int overdue) {
	BaseVO baseVO = new BaseVO();
	if(phone==null || phone.length() != 11){
		baseVO.setBaseVO(BaseVO.FAILURE, Language.show("sms_sendSmsPhoneNumberFailure"));
		return baseVO;
	}
	if(code==null || code.length() != 6){
		baseVO.setBaseVO(BaseVO.FAILURE, Language.show("user_loginByPhoneAndCodeCodeFailure"));
		return baseVO;
	}
	
	int queryAddtime = 0;
	if(type - SmsLog.TYPE_LOGIN ==0){
		//登录,传入的过期时间无效,使用xml中配置的登录的过期时间
		overdue = SmsLog.codeValidity;
	}
	if(overdue > 0){
		int currentTime = DateUtil.timeForUnix10();
		queryAddtime = currentTime-overdue;
	}
	
	SmsLog smsLog = findByPhoneAddtimeUsedTypeCode(phone, queryAddtime, SmsLog.USED_FALSE, type, code);
   	
   	if(smsLog != null){
   		/****更改SmsLog状态*****/
   		smsLog.setUserid(0);
   		smsLog.setUsed(SmsLog.USED_TRUE);
   		sqlDAO.save(smsLog);
   		
		baseVO.setResult(BaseVO.SUCCESS);
		return baseVO;
   	}else{
   		baseVO.setBaseVO(BaseVO.FAILURE, Language.show("user_loginByPhoneAndCodeCodeNotFind"));
   		return baseVO;
   	}
}
 
Example 8
Source File: LogAdminController_.java    From wangmarket with Apache License 2.0 5 votes vote down vote up
/**
 * 折线图,当月(最近30天),每天的访问情况
 */
@RequiresPermissions("adminLogCartogram")
@RequestMapping("dayLineForCurrentMonth${url.suffix}")
@ResponseBody
public LogLineGraphVO dayLineForCurrentMonth(HttpServletRequest request) throws LogException{
	LogLineGraphVO vo = new LogLineGraphVO();
	
	//当前10位时间戳
	int currentTime = DateUtil.timeForUnix10();
	String query = "Mozilla | timeslice 24h | count as c";
	
	//当月访问量统计
	ArrayList<QueriedLog> jinriQlList = ActionLogCache.aliyunLogUtil.queryList(query, "", DateUtil.getDateZeroTime(currentTime - 2592000), currentTime, 0, 100, true);
	
	JSONArray jsonArrayDate = new JSONArray();	//天数
	JSONArray jsonArrayFangWen = new JSONArray();	//某天访问量,pv
	for (int i = 0; i < jinriQlList.size(); i++) {
		LogItem li = jinriQlList.get(i).GetLogItem();
		JSONObject json = JSONObject.fromObject(li.ToJsonString());
		try {
			jsonArrayDate.add(DateUtil.dateFormat(json.getInt("logtime"), "MM-dd"));
		} catch (NotReturnValueException e) {
			e.printStackTrace();
		}
		jsonArrayFangWen.add(json.getInt("c"));
	}
	vo.setDataArray(jsonArrayFangWen);
	vo.setNameArray(jsonArrayDate);
	
	return vo;
}
 
Example 9
Source File: JavaMQUtils.java    From wangmarket with Apache License 2.0 5 votes vote down vote up
public void run() {
	System.out.println("start domain update thread -- javamq");
	Log.info("start domain update thread -- javamq");
	
	while(true){
		try {
			Thread.sleep(EXPIRE_TIME*1000);
		} catch (InterruptedException e) {
			e.printStackTrace();
		}
		
		int currentTime = DateUtil.timeForUnix10();	//当前时间
		for (Map.Entry<String, List<JavaQueueBean>> entry : cacheMap.entrySet()) {
			List<JavaQueueBean> list = entry.getValue();
			if(list != null && list.size() > 0){
				//取最上面的一个,也就是最早加入的,因为即使过期,肯定是最早加入的开始过期。一直从最早加入的开始遍历,直到遍历到不过期的信息为止
				JavaQueueBean queue = list.get(0);
				while(queue != null && currentTime - queue.getAddtime() > EXPIRE_TIME){
					//已过期,那么就将其删除掉
					list.remove(0);
					//将指针指向删除后的第一个,也就是 queue
					if(list.size() > 0){
						queue = list.get(0);
					}else{
						queue = null;
					}
				}
				//遍历完之后,重新将其赋予 cacheMap
				cacheMap.put(entry.getKey(), list);
			}
		}
	}
}
 
Example 10
Source File: AliyunLogPageUtil.java    From xnx3 with Apache License 2.0 5 votes vote down vote up
/**
 * 列出日志服务的列表记录
 * <br/>获取当前生成得分页信息可用 {@link #getPage()} 得到
 * @param query 查询条件。若divQuery为true,开启用户自定义检索,这里会先将query的查询条件作为首要查询。总之查询时无论是用户传入什么条件,都会加上此指定的查询条件一并 and 查询。(<a href="https://help.aliyun.com/document_detail/29060.html">查询语法参考</a>)
 * @param topic topic主题,若不指定查询主题,可为空字符串""
 * @param divQuery 是否开启用户自定义检索。若是开启,则用户可以通过<a href="https://help.aliyun.com/document_detail/29060.html">查询语法</a>进行自定义查询。GET或者POST传入queryString=查询条件
 * @param startTime 筛选日志的开始时间,10位时间戳,若为0,则为结束时间以前1000天的时刻
 * @param endTime 筛选日志的结束时间,10位时间戳,若为0,则为当前时间
 * @param everyPageNumber 分页列表每页显示的条数
 * @param request 主要用于获取当前url中的get传递的参数。分页数都是通过get传递的。同样,分页的参数也是自动根据这个计算出来的
 * @return 返回查询的结果。
 * @throws LogException
 */
public ArrayList<QueriedLog> list(String query, String topic, boolean divQuery, int startTime, int endTime, int everyPageNumber, HttpServletRequest request) throws LogException{
	if(endTime == 0){
		endTime = DateUtil.timeForUnix10();
	}
	if(startTime == 0){
		startTime = DateUtil.getDateZeroTime(endTime - 86400000);	
	}
	
	if(divQuery){
		String queryStringRequest = request.getParameter("queryString");	//查询的关键词,可模糊查询
		if(queryStringRequest == null || queryStringRequest.length() == 0){
		}else{
			if(query != null && query.length() > 0){
				query = query + " and "+queryStringRequest;
			}else{
				query = queryStringRequest;
			}
		}
	}
	
	//统计1000天内的符合条件的总数量
	int count = (int) aliyunLogUtil.queryCount(query, "", startTime, endTime);
	
	page = new Page(count, everyPageNumber, request);
	
	//最近三个月访问量统计
	ArrayList<QueriedLog> logList = aliyunLogUtil.queryList(query, "", startTime, endTime, page.getLimitStart(), page.getEveryNumber(), true);
	return logList;
}
 
Example 11
Source File: GenerateHTML.java    From wangmarket with Apache License 2.0 5 votes vote down vote up
public GenerateHTML(Site site) {
	linuxTime = DateUtil.timeForUnix10();
	if(site.getTemplateId() != null){
		this.templateId = site.getTemplateId();
	}else{
		this.templateId = 0;
	}
	this.site = site;
	this.editMode = false;
}
 
Example 12
Source File: BaseCache.java    From wangmarket with Apache License 2.0 5 votes vote down vote up
/**
 * 生成js缓存文件保存
 * @param siteid 站点id
 * @param fileName 生成的js文件名字,只写文件名,不传入".js"后缀
 */
public void generateCacheFile(com.xnx3.wangmarket.admin.entity.Site site){
	try {
		content = content + " var xnx3_r"+DateUtil.timeForUnix10()+" = '"+getRandomValue()+"';";
		AttachmentFile.put("site/"+site.getId()+"/data/"+objName+".js", new ByteArrayInputStream(content.getBytes("UTF-8")));
	} catch (UnsupportedEncodingException e) {
		e.printStackTrace();
	}
}
 
Example 13
Source File: MessageReply.java    From xnx3 with Apache License 2.0 5 votes vote down vote up
/**
 * 向微信服务器进行文字回复(MsgType=text)的XML格式字符串,可以将此直接回复微信服务器即可达到回复效果。
 * <br/>此项即向微信服务器自动回复xml
 * @param response {@link HttpServletResponse}响应,输出返回值给微信服务器。
 * @param content 微信自动回复用户的内容
 */
public void replyText(HttpServletResponse response, String content){
	String text = "<xml>"
			+ "<ToUserName><![CDATA["+this.toUserName+"]]></ToUserName>"
			+ "<FromUserName><![CDATA["+this.fromUserName+"]]></FromUserName>"
			+ "<CreateTime>"+DateUtil.timeForUnix10()+"</CreateTime>"
			+ "<MsgType><![CDATA[text]]></MsgType>"
			+ "<Content><![CDATA["+content+"]]></Content>"
			+ "</xml>";
	reply(response, text);
}
 
Example 14
Source File: PingxxUtil.java    From xnx3 with Apache License 2.0 4 votes vote down vote up
/**
   * 生成12位全数字的订单号,10位时间戳+2位随机数
   * @return
   */
  public static String generateOrderNo(){
  	Random random = new Random();
return random.nextInt(10)+""+random.nextInt(10)+DateUtil.timeForUnix10();
  }
 
Example 15
Source File: LoginController.java    From wangmarket with Apache License 2.0 4 votes vote down vote up
/**
	 * 通过手机验证注册开通网站
	 * @param inviteid 上级id,推荐者id,user.id
	 */
	@RequestMapping("loginApi${url.suffix}")
	public String loginApi(HttpServletRequest request, Model model,
			@RequestParam(value = "key", required = false , defaultValue="") String key){
		if(getUser() != null){
			//已登陆
			return redirect(com.xnx3.wangmarket.admin.Func.getConsoleRedirectUrl());
		}
		
		UserVO vo = apiService.identityVerifyAndSession(key);
		if(vo.getResult() - UserVO.FAILURE == 0){
			return error(model, vo.getInfo());
		}
		
		//用于缓存入Session,用户的一些基本信息,比如用户的站点信息、用户的上级代理信息、如果当前用户是代理,还包含当前用户的代理信息等
		UserBean userBean = new UserBean();
		
		//得到上级的代理信息
		Agency parentAgency = sqlService.findAloneBySqlQuery("SELECT * FROM agency WHERE userid = " + getUser().getReferrerid(), Agency.class);
		userBean.setParentAgency(parentAgency);
		if(parentAgency != null){
			//得到上级代理的变长表信息
			AgencyData parentAgencyData = sqlService.findAloneBySqlQuery("SELECT * FROM agency_data WHERE id = " + parentAgency.getId(), AgencyData.class);
			userBean.setParentAgencyData(parentAgencyData);
		}
		
		//当前时间
		int currentTime = DateUtil.timeForUnix10();	

		//得到当前用户站点的相关信息,加入userBean,以存入Session缓存起来
		Site site = sqlService.findAloneBySqlQuery("SELECT * FROM site WHERE userid = "+getUserId()+" ORDER BY id DESC", Site.class);
		if(site != null){
			userBean.setSite(site);
		}
		
		//判断网站用户是否是已过期,使用期满,将无法使用
		if(site != null && site.getExpiretime() != null && site.getExpiretime() < currentTime){
			return error(model, "您的网站已到期。若要继续使用,请续费");
		}
		
		//计算其网站所使用的资源,比如OSS已占用了多少资源。下个版本修改
//		loginSuccessComputeUsedResource();
		
		ActionLogCache.insert(request, "api模式登录成功","进入网站管理后台");
		//将用户相关信息加入Shiro缓存
		ShiroFunc.getCurrentActiveUser().setObj(userBean);
		
		return redirect(com.xnx3.wangmarket.admin.Func.getConsoleRedirectUrl());
	}
 
Example 16
Source File: FormManagePluginController.java    From wangmarket with Apache License 2.0 4 votes vote down vote up
/**
 * 提交反馈信息,只限 post 提交
 * @param id 要删除的输入模型的id,对应 {@link InputModel}.id
 */
@RequestMapping(value="formAdd${url.suffix}", method = RequestMethod.POST)
@ResponseBody
public BaseVO formAdd(HttpServletRequest request, Model model,
		@RequestParam(value = "siteid", required = false , defaultValue="0") int siteid,
		@RequestParam(value = "title", required = false , defaultValue="") String title){
	String ip = IpUtil.getIpAddress(request);
	Frequency frequency = frequencyMap.get(ip);
	int currentTime = DateUtil.timeForUnix10();	//当前10位时间戳
	//今天尚未提交过,那么创建一个记录
	if(frequency == null){
		frequency = new Frequency();
		frequency.setIp(ip);
	}
	
	//判断当前是否允许提交反馈信息,如果不允许,需要记录,并返回不允许的提示。
	if(frequency.getForbidtime() > currentTime){
		//间隔时间太短,不允许提交反馈信息
		frequency.setErrorNumber(frequency.getErrorNumber()+1);
		frequencyMap.put(ip, frequency);	//临时存储,这个存储时间是一天,每天清除一次
		return error("距离上次提交时间太短,等会再试试吧");
	}
	
	/** 下面就是允许提交的逻辑处理了 **/
	frequency.setLasttime(currentTime);	//设置当前为最后一次提交的时间
	frequency.setForbidtime(currentTime + FeedbackTimeInterval);	//设置下次允许提交反馈的时间节点,这个时间节点之前是不允许在此提交的
	frequencyMap.put(ip, frequency);	//临时存储,这个存储时间是一天,每天清除一次
	
	
	title = StringUtil.filterXss(title);
	if(siteid <= 0){
		return error("请传入您的站点id(siteid),不然,怎么知道此反馈表单是属于哪个网站的呢?");
	}
	
	Form form = new Form();
	form.setAddtime(DateUtil.timeForUnix10());
	form.setSiteid(siteid);
	form.setState(Form.STATE_UNREAD);
	form.setTitle(title);
	sqlService.save(form);
	if(form.getId() != null && form.getId() > 0){
		//成功,进而存储具体内容。存储内容时,首先要从提交的数据中,便利出所有表单数据.这里是原始提交的结果,需要进行xss过滤
		Map<String, String[]> params = new HashMap<String, String[]>();
		params.putAll(request.getParameterMap());
		//删除掉siteid、title的参数
		params.remove("siteid");
		if(params.get("title") != null){
			params.remove("title");
		}
		
		JSONArray jsonArray = new JSONArray();	//text文本框所存储的内容
		for (Map.Entry<String, String[]> entry : params.entrySet()) { 
			JSONObject json = new JSONObject();
			JSONArray valueJsonArray = new JSONArray();
			
			for (int i = 0; i < entry.getValue().length; i++) {
				valueJsonArray.add(StringUtil.filterXss(entry.getValue()[i]));
			}
			json.put(StringUtil.filterXss(entry.getKey()), valueJsonArray);
			jsonArray.add(json);
		}
		String text = jsonArray.toString();
		if(text.length() > textMaxLength){
			return error("信息太长,非法提交!");
		}
		
		FormData formData = new FormData();
		formData.setId(form.getId());
		formData.setText(text);
		sqlService.save(formData);
		
		//记录日志
		AliyunLog.addActionLog(form.getId(), "提交表单反馈", form.getTitle());
		
		return success();
	}else{
		return error("保存失败");
	}
	
}
 
Example 17
Source File: InstallController_.java    From wangmarket with Apache License 2.0 4 votes vote down vote up
/**
 * 第三步,验证AccessKey的id、screct的有效性,并初始化创建OSS
 */
@RequestMapping("/accessKeySave${url.suffix}")
@ResponseBody
public BaseVO accessKeySave(
		@RequestParam(value = "id", required = false, defaultValue="") String id,
		@RequestParam(value = "secret", required = false, defaultValue="") String secret
		){
	if(!Global.get("IW_AUTO_INSTALL_USE").equals("true")){
		return error("系统已禁止使用此!");
	}
	if(id.length() == 0){
		return error("请输入 Access Key ID");
	}
	if(secret.length() == 0){
		return error("请输入 Access Key Secret");
	}
	
	//进行自动创建OSS测试
	String bucketName = Global.get("ALIYUN_OSS_BUCKETNAME");
	if(bucketName == null){
		return error("数据表system中没有ALIYUN_OSS_BUCKETNAME,数据表有缺,初始化OSS失败!");
	}else{
		if(bucketName.equals("auto")){
			//若是为auto,则是第一次刚开始用,自动创建
			bucketName = "wangmarket"+DateUtil.timeForUnix10();
		}
	}
	
	OSSUtil.accessKeyId = id;
	OSSUtil.accessKeySecret = secret;
	OSSUtil.bucketName = bucketName;
	OSSUtil.endpoint = ConfigManagerUtil.getSingleton("xnx3Config.xml").getValue("aliyunOSS.endpoint");
	OSSUtil.refreshUrl();
	
	try {
		//判断这个bucketName是否存在
		boolean have = OSSUtil.getOSSClient().doesBucketExist(bucketName);
		if(!have){
			//如果不存在这个bucketName,则自动创建一个
			CreateBucketRequest createBucketRequest= new CreateBucketRequest(bucketName);
			createBucketRequest.setCannedACL(CannedAccessControlList.PublicRead);	// 设置bucket权限为公共读,默认是私有读写
			OSSUtil.getOSSClient().createBucket(createBucketRequest);
			System.out.println("自动创建buckname: "+bucketName);
		}else{
			System.out.println("OSS未自动创建!因为检测到BucketName已存在!若不是您手动创建的,则建议您按照以下两点进行操作,然后再来创建。");
			System.out.println("1.将/src/xnx3Config.xml文件中,aliyunOSS节点下的bucketName设置为空,即将其中配置的数据删除掉");
			System.out.println("2.将数据表system中,name为ALIYUN_OSS_BUCKETNAME的这一列,将其值改为auto");
			return error("OSS未自动创建!因为检测到BucketName已存在!若不是您手动创建的,则建议您按照以下两点进行操作,然后再来创建。");
		}
	} catch (Exception e) {
		return error("操作失败!错误代码:"+e.getMessage().toString());
	}
	
	//将其存入system数据表
	sqlService.executeSql("update system set value = '"+id+"' WHERE name = 'ALIYUN_ACCESSKEYID'");
	sqlService.executeSql("update system set value = '"+secret+"' WHERE name = 'ALIYUN_ACCESSKEYSECRET'");
	sqlService.executeSql("update system set value = '"+bucketName+"' WHERE name = 'ALIYUN_OSS_BUCKETNAME'");
	
	//设置为禁止安装
	sqlService.executeSql("update system set value = 'false' WHERE name = 'IW_AUTO_INSTALL_USE'");
	
	//更新缓存
	systemService.refreshSystemCache();
	
	return success();
}
 
Example 18
Source File: UserServiceImpl.java    From wangmarket with Apache License 2.0 4 votes vote down vote up
/**
	 * 手机号+动态验证码登陆
	 * @param request {@link HttpServletRequest} 
	 * 		<br/>登陆时form表单需提交两个参数:phone(手机号)、code(手机收到的动态验证码)
	 * @return {@link BaseVO}
	 */
	public BaseVO loginByPhoneAndCode(HttpServletRequest request) {
		BaseVO baseVO = new BaseVO();
		String phone = Safety.filter(request.getParameter("phone"));
		String code = Safety.filter(request.getParameter("code"));
		if(phone==null || phone.length() != 11){
			baseVO.setBaseVO(BaseVO.FAILURE, Language.show("user_loginByPhoneAndCodePhoneFailure"));
			return baseVO;
		}
		if(code==null || code.length() != 6){
			baseVO.setBaseVO(BaseVO.FAILURE, Language.show("user_loginByPhoneAndCodeCodeFailure"));
			return baseVO;
		}
		
		int queryAddtime = 0;
		if(SmsLog.codeValidity > 0){
			int currentTime = DateUtil.timeForUnix10();
			queryAddtime = currentTime-SmsLog.codeValidity;
		}
		SmsLog smsLog = findByPhoneAddtimeUsedTypeCode(phone, queryAddtime, SmsLog.USED_FALSE, SmsLog.TYPE_LOGIN,code);
    	if(smsLog != null){
    		User user = findByPhone(phone);
    		int userid = 0;
    		if(user != null && user.getId() != null){
    			userid = user.getId();
    		}
    		
    		/****更改SmsLog状态*****/
    		smsLog.setUserid(userid);
    		smsLog.setUsed(SmsLog.USED_TRUE);
    		sqlDAO.save(smsLog);
    		
    		//如果没有用户,则直接返回失败提示
    		if(user == null){
    			baseVO.setBaseVO(BaseVO.FAILURE, Language.show("user_loginByPhoneAndCodeRegFailure"));
    			return baseVO;
    		}
    		
    		//检验此用户状态是否正常,是否被冻结
			if(user.getIsfreeze() == User.ISFREEZE_FREEZE){
				baseVO.setBaseVO(BaseVO.FAILURE, Language.show("user_loginUserFreeze"));
				return baseVO;
			}
    		
    		
    		/*******更改User状态******/
    		user.setLasttime(DateUtil.timeForUnix10());
    		user.setLastip(IpUtil.getIpAddress(request));
    		sqlDAO.save(user);
    		
			UsernamePasswordToken token = new UsernamePasswordToken(user.getUsername(), user.getUsername());
	        token.setRememberMe(false);
			Subject currentUser = SecurityUtils.getSubject();  
			
			try {  
				currentUser.login(token);  
			} catch ( UnknownAccountException uae ) {
				uae.printStackTrace();
			} catch ( IncorrectCredentialsException ice ) {
				ice.printStackTrace();
			} catch ( LockedAccountException lae ) {
				lae.printStackTrace();
			} catch ( ExcessiveAttemptsException eae ) {
				eae.printStackTrace();
			} catch ( org.apache.shiro.authc.AuthenticationException ae ) { 
				ae.printStackTrace();
			}
			
//			logDao.insert("USER_LOGIN_SUCCESS");
			baseVO.setBaseVO(BaseVO.SUCCESS, Language.show("user_loginSuccess"));
			return baseVO;
    	}else{
    		baseVO.setBaseVO(BaseVO.FAILURE, Language.show("user_loginByPhoneAndCodeCodeNotFind"));
    		return baseVO;
    	}
	}
 
Example 19
Source File: AgencyUserController.java    From wangmarket with Apache License 2.0 4 votes vote down vote up
/**
	 * 给某个代理延长使用期限
	 * @param agencyId 要续费的代理id,agency.id
	 * @param year 要续费的年数,支持1~10,最大续费10年
	 */
	@RequiresPermissions("agencyYanQi")
	@RequestMapping("agencyYanQi${url.suffix}")
	@ResponseBody
	public BaseVO agencyYanQi(HttpServletRequest request, Model model,
			@RequestParam(value = "agencyId", required = true) int agencyId,
			@RequestParam(value = "year", required = false, defaultValue = "0") int year){
		if(year < 1){
			return error("请输入要续费的年数,1~10");
		}
		if(year > 10){
			return error("请输入要续费的年数,1~10,最大可往后续费10年");
		}
		
		//我的代理信息
		Agency myAgency = sqlService.findById(Agency.class, getMyAgency().getId());
		
		//续费所需的站币
		int xufeiZhanBi = year * 20;
		
		if(myAgency.getSiteSize() - xufeiZhanBi <= 0){
			return error("您当前只拥有"+myAgency.getSiteSize()+"站币!续费花费的金额超出,续费失败!");
		}
		
		//我的下级的代理信息,要给他延期的,代理的信息
		Agency subAgency = sqlService.findById(Agency.class, agencyId);
		//我的下级代理,所属人的信息
		User subUser = sqlService.findById(User.class, subAgency.getUserid());
		if(subUser.getReferrerid() - myAgency.getUserid() != 0){
			return error("要延期的代理不是您的直属下级,为其延期失败");
		}
		
		//判断延期后的代理使用期限是否超过了10年 ,当前时间 + 3660天
		if((subAgency.getExpiretime() + (year * 31622400)) > (DateUtil.timeForUnix10() + 316224000)){
			return error("代理资格往后延期的最大期限为10年!");
		}
		
		//当前我的IP地址
		String ip = IpUtil.getIpAddress(request);
		
		
		/**** 进行数据保存 ****/
		
		//我的代理信息里,减去续费花费的站币
		myAgency.setSiteSize(myAgency.getSiteSize() - xufeiZhanBi);
		sqlService.save(myAgency);
		//数据库保存我的消费记录
		SiteSizeChange ssc = new SiteSizeChange();
		ssc.setAddtime(DateUtil.timeForUnix10());
		ssc.setAgencyId(myAgency.getId());
		ssc.setChangeAfter(myAgency.getSiteSize());
		ssc.setChangeBefore(myAgency.getSiteSize() + xufeiZhanBi);
		ssc.setGoalid(subAgency.getId());
		ssc.setSiteSizeChange(0-xufeiZhanBi);
		ssc.setUserid(myAgency.getUserid());
		sqlService.save(ssc);
		//记录我的资金消费记录
		SiteSizeChangeLog.xiaofei(myAgency.getName(), "给代理"+subAgency.getName()+"延长使用期限"+year+"年", ssc.getSiteSizeChange(), ssc.getChangeBefore(), ssc.getChangeAfter(), ssc.getGoalid(), ip);
		
		//对方代理平台延长使用过期时间
		subAgency.setExpiretime(subAgency.getExpiretime() + (year * 31622400));
		sqlService.save(subAgency);
		
		//到期时间
		String daoqishijian = "";
		try {
			daoqishijian = DateUtil.dateFormat(subAgency.getExpiretime(), "yyyy年MM月dd日");
		} catch (NotReturnValueException e) {
			e.printStackTrace();
		}
		
		//记录操作日志
		AliyunLog.addActionLog(ssc.getId(), "给代理"+subAgency.getName()+"延长使用期限"+year+"年。代理资格延期后,日期到"+daoqishijian);
		
		//发送短信通知对方
		//这里等转为公司模式后,用公司资格申请短信发送资格
//		G.aliyunSMSUtil.send(G.AliyunSMS_SignName, G.AliyunSMS_siteYanQi_templateCode, "{\"siteName\":\""+site.getName()+"\", \"year\":\""+year+"\", \"time\":\""+daoqishijian+"\"}", site.getPhone());
		
		//刷新Session中我的代理信息缓存
		Func.getUserBeanForShiroSession().setMyAgency(myAgency);
		
		return success();
	}
 
Example 20
Source File: TemplateCMS.java    From wangmarket with Apache License 2.0 2 votes vote down vote up
/**
 * @param editMode 是否为编辑模式
 * 		<ul>
 * 			<li>true:为编辑模式,编辑模版页面时使用,不会进行模版变量的通用标签替换等,调用模版变量会输出原始的保存的代码</li>
 * 			<li>false:为生成模式,调用装载模版变量时,会一次性对其进行通用标签等替换,装载模版变量会生成新的替换好的代码</li>
 * 		</ul>
 * @param site
 */
public TemplateCMS(Site site, boolean editMode) {
	linuxTime = DateUtil.timeForUnix10();
	this.site = site;
	this.editMode = editMode;
}