Java Code Examples for com.xnx3.Lang#stringToInt()

The following examples show how to use com.xnx3.Lang#stringToInt() . 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: StringDiff.java    From templatespider with Apache License 2.0 6 votes vote down vote up
public String previewChangDiff(){
	Map<Integer, String> map = new HashMap<Integer, String>();
	for (Map.Entry<Integer, String> entry : this.equalMap.entrySet()) {
		String html = entry.getValue().replaceAll("<", "&lt;").replaceAll(">", "&gt;");
		map.put(entry.getKey(), html);
	}
	
	Pattern pattern = Pattern.compile("\\{xnx3=([0-9]*)\\}");
	Matcher matcher = pattern.matcher(chang);
	String changStr = this.chang+" ";
	changStr = changStr.replaceAll("<", "&lt;").replaceAll(">", "&gt;");
	System.out.println("------changStr");
	System.out.println(changStr);
	while (matcher.find()) {
       	String m = matcher.group(1);	//模版变量的id
       	int key = Lang.stringToInt(m, -1);
       	String k = "{xnx3="+key+"}";
       	changStr = changStr.replace(k, "<font color=\"#dddddd;\">"+map.get(key)+"</font>");
	}
	return changStr;
}
 
Example 2
Source File: StringDiff.java    From templatespider with Apache License 2.0 6 votes vote down vote up
public String previewDuanDiff(){
	Map<Integer, String> map = new HashMap<Integer, String>();
	for (Map.Entry<Integer, String> entry : this.equalMap.entrySet()) {
		String html = entry.getValue().replaceAll("<", "&lt;").replaceAll(">", "&gt;");
		map.put(entry.getKey(), html);
	}
	
	Pattern pattern = Pattern.compile("\\{xnx3=([0-9]*)\\}");
	Matcher matcher = pattern.matcher(duan);
	String duanStr = this.duan+" ";
	duanStr = duanStr.replaceAll("<", "&lt;").replaceAll(">", "&gt;");
	while (matcher.find()) {
       	String m = matcher.group(1);	//模版变量的id
       	int key = Lang.stringToInt(m, -1);
       	String k = "{xnx3="+key+"}";
       	duanStr = duanStr.replace(k, "<font color=\"#dddddd;\">"+map.get(key)+"</font>");
	}
	return duanStr;
}
 
Example 3
Source File: MessageServiceImpl.java    From wangmarket with Apache License 2.0 5 votes vote down vote up
public BaseVO sendMessage(HttpServletRequest request) {
	BaseVO baseVO = new BaseVO();
	int recipientid = Lang.stringToInt(request.getParameter("recipientid"), 0);
	String content = request.getParameter("content");
	
	return sendMessage(recipientid, content);
}
 
Example 4
Source File: Log.java    From wangmarket with Apache License 2.0 5 votes vote down vote up
/**
 * log.type 值-描述 缓存
 */
public void type(List<String> list){
	createCacheObject("type");
	
	for (int i = 0; i < list.size(); i++) {
   		String[] array = list.get(i).split("#");
   		String name = array[0];
   		Short value = (short) Lang.stringToInt(array[1], 0);
   		String description = array[2];
   		cacheAdd(value, description);
	}
	generateCacheFile();
}
 
Example 5
Source File: AttachmentFile.java    From wangmarket with Apache License 2.0 5 votes vote down vote up
/**
 * 获取当前限制的上传文件最大的大小限制。单位是KB
 * @return 单位KB
 */
public static int getMaxFileSizeKB(){
	if(maxFileSizeKB == -1){
		//未初始化,那么进行初始化
		maxFileSize = getMaxFileSize();
		
		if(maxFileSize.indexOf("KB") > 0){
			//使用KB单位
			maxFileSizeKB = Lang.stringToInt(maxFileSize.replace("KB", "").trim(), 0);
			if(maxFileSizeKB == 0){
				Log.error("application.properties --> spring.servlet.multipart.max-file-size use KB, but !!! string to int failure !");
			}
		}else if (maxFileSize.indexOf("MB") > 0) {
			//使用MB
			maxFileSizeKB = Lang.stringToInt(maxFileSize.replace("MB", "").trim(), 0) * 1024;
			if(maxFileSizeKB == 0){
				Log.error("application.properties --> spring.servlet.multipart.max-file-size use MB, but !!! string to int failure !");
			}
		}else if (maxFileSize.indexOf("GB") > 0) {
			//使用 GB
			maxFileSizeKB = Lang.stringToInt(maxFileSize.replace("GB", "").trim(), 0) * 1024 * 1024;
			if(maxFileSizeKB == 0){
				Log.error("application.properties --> spring.servlet.multipart.max-file-size use GB, but !!! string to int failure !");
			}
		}else{
			//没有找到合适单位,报错
			Log.error("application.properties --> spring.servlet.multipart.max-file-size not find unit,your are KB ? MB ? GB ? Please use one of them");
		}
	}
	return maxFileSizeKB;
}
 
Example 6
Source File: UserServiceImpl.java    From wangmarket with Apache License 2.0 5 votes vote down vote up
/**
 * 注册
 * @param user {@link User} 
 * 		<br/>表单的用户名(username)、 密码(password)为必填项
 * @param request {@link HttpServletRequest}
 * @return {@link BaseVO}
 */
public void regInit(HttpServletRequest request) {
	String inviteid_ = request.getParameter("inviteid");
	if(inviteid_!=null&&inviteid_.length()>0){
		int inviteid = Lang.stringToInt(inviteid_, 0);
		
		User user = sqlDAO.findById(User.class, inviteid);
		if(user!=null){
			request.getSession().setAttribute("inviteid", inviteid); 	//邀请人id
		}
	}
}
 
Example 7
Source File: UserServiceImpl.java    From wangmarket with Apache License 2.0 5 votes vote down vote up
/**
	 * 注册成功后下线充值奖励
	 * @param user 要充值的下线user
	 * @param addCurrency_ 增加的货币值
	 * @param regUser 注册的用户的用户名
	 */
	private void referrerAddAward(User user,String addCurrency_,User regUser){
		int addCurrency = Lang.stringToInt(addCurrency_, 0);
		if(addCurrency>0){
			user.setCurrency(user.getCurrency()+addCurrency);
			sqlDAO.save(user);
//			logDao.insert(regUser.getId(), "USER_INVITEREG_AWARD", addCurrency+"");
		}
	}
 
Example 8
Source File: RabbitUtil.java    From wangmarket with Apache License 2.0 5 votes vote down vote up
public RabbitUtil() {
	String host = ApplicationProperties.getProperty("spring.rabbitmq.host");
	if(host == null){
		isUse = false;
		return;
	}
	int port = Lang.stringToInt(ApplicationProperties.getProperty("spring.rabbitmq.port"), 5672);
	String username = ApplicationProperties.getProperty("spring.rabbitmq.username");
	String password = ApplicationProperties.getProperty("spring.rabbitmq.password");
	
	rabbitMQTopicUtil = new RabbitMQTopicUtil(host, username, password, port);
	isUse = true;
}
 
Example 9
Source File: InitLoadDomainByDB.java    From wangmarket with Apache License 2.0 4 votes vote down vote up
/**
	 * 启动项目时,进行域名绑定,从数据库中取域名相关数据
	 */
	public void domainBind(){
		if(cache){
			//已缓存,无需再缓存了
			return;
		}
		InitLoadDomainByDB.cache = true;
		
		List<Map<String, Object>> list = com.xnx3.j2ee.func.Sql.getSqlService().findMapBySqlQuery("SELECT id,client,domain,bind_domain,state,template_id FROM site");
		for (int i = 0; i < list.size(); i++) {
			Map<String, Object> map = list.get(i);
			
			SimpleSite ss = new SimpleSite();
			ss.setBindDomain(map.get("bind_domain") != null? map.get("bind_domain").toString():"");
			ss.setClient(map.get("client") != null? Lang.stringToInt(map.get("client").toString(), 1):1);
			ss.setDomain(map.get("domain") != null? map.get("domain").toString():"");
			ss.setId(map.get("id") != null? Lang.stringToInt(map.get("id").toString(), 0) : 0);
			ss.setState((short) (map.get("state") == null ? Lang.stringToInt(map.get("state").toString(), 1) : 1));
			
			Object templateIdObj = map.get("template_id");
			int templateId = 0;
			if(templateIdObj != null){
				String ti = templateIdObj.toString();
				if(ti.length() > 0){
					templateIdObj = Lang.stringToInt(map.get("template_id").toString(), 0);
				}
			}
			ss.setTemplateId(templateId);
			
			if(ss.getDomain() != null && ss.getDomain().length() > 0){
				G.putDomain(ss.getDomain(), ss);
			}
			if(ss.getBindDomain() != null && ss.getBindDomain().length() > 2){
				G.putBindDomain(ss.getBindDomain(), ss);
			}
		}
		
		
		
//		ResultSet rs;
//		try {
//			rs = com.xnx3.j2ee.func.DB.getResultSet("SELECT id,client,domain,bind_domain,state,template_id FROM site");
//			//如果有这行存在
//	        while(rs.next()){
//	        	SimpleSite ss = new SimpleSite();
//	        	ss.setBindDomain(rs.getString("bind_domain"));
//	        	ss.setClient(rs.getInt("client"));
//	        	ss.setDomain(rs.getString("domain"));
//	        	ss.setId(rs.getInt("id"));
//	        	ss.setState(rs.getShort("state"));
//	        	ss.setTemplateId(rs.getInt("template_id"));
//	        	
//	        	if(ss.getDomain() != null && ss.getDomain().length() > 0){
//					G.putDomain(ss.getDomain(), ss);
//				}
//				if(ss.getBindDomain() != null && ss.getBindDomain().length() > 2){
//					G.putBindDomain(ss.getBindDomain(), ss);
//				}
//	        }
//	        
//		} catch (SQLException e) {
//			e.printStackTrace();
//		}
		
		Log.info("共缓存二级域名:"+G.getDomainSize()+"个, 绑定域名:"+G.getBindDomainSize()+"个");
	}
 
Example 10
Source File: Action.java    From templatespider with Apache License 2.0 4 votes vote down vote up
/**
 * 第3步,提取模版变量,对提取的模版变量进行过滤,如过滤其字符串长度、相似度文件占的比例
 */
public static void templateVarListFilter(){
	//得到模版变量过滤的最长字符数
	int len = Lang.stringToInt(Global.templateVarGainJframe.getVarTextLengthtextField().getText(), 0);
	System.out.println("len -- >"+len);
	
	//相似度百分比,不过这里是整数, 如相似度70%,这里的数字是 70
	int percent = Lang.stringToInt(Global.templateVarGainJframe.getXiangsiduPercentTextField().getText(), 0);
	
	/*
	 * 进行筛选
	 */
	//要删除的列表。 item: map.key
	List<String> removeMapList = new ArrayList<String>();
	//从map中找到要删除的key,放入list
	for (Map.Entry<String, ElementDiffRecord> entry : Global.templateVarMap.entrySet()) {
		ElementDiffRecord record = entry.getValue();
		
		//进行长度筛选
		String html = record.getElementDiffVO().getDiffElement().html();
		System.out.println("---------html---------"+html);
		if(html.length() < len){
			removeMapList.add(entry.getKey());
		}
		
		//进行相似度筛选
		int[] diff = Action.isPreviewDiff(record.getElementDiffListVO());
		int findNum = diff[0]+diff[1];	//发现相同的条数,等于 完全相同的数量+相似度达标的数量
		double baifenbi= Math.ceil(findNum*100/Global.templateMap.size());
		System.out.println("模版变量数目:"+Global.templateMap.size()+", 相同条数:"+findNum+", 相似度达标的条数,占模版页面总条数的百分比:"+baifenbi);
		if(baifenbi < percent){
			//百分比跟模版变量-高级设置中的百分比还小,那么舍弃,删除(过滤掉)这个模版变量
			removeMapList.add(entry.getKey());
			System.out.println("----------删除掉这个模版变量:"+record);
		}
		
	}
	//从map中删除
	for (int i = 0; i < removeMapList.size(); i++) {
		Global.templateVarMap.remove(removeMapList.get(i));
	}
	
	Global.log("模版变量提取完毕!");
	showUITemplateVarJTabel();
}
 
Example 11
Source File: LoginController.java    From wangmarket with Apache License 2.0 4 votes vote down vote up
/**
	 * 用户开通账户并创建网站,进行提交保存
	 * @param username 用户名
	 * @param email 邮箱,可为空
	 * @param password 密码
	 * @param phone 手机号
	 * @param code 手机验证码
	 * @param clilent 网站类型
	 */
	@RequestMapping(value="userCreateSite${url.suffix}", method = RequestMethod.POST)
	@ResponseBody
	public BaseVO userCreateSite(HttpServletRequest request,
			@RequestParam(value = "username", required = false , defaultValue="") String username,
			@RequestParam(value = "email", required = false , defaultValue="") String email,
			@RequestParam(value = "password", required = false , defaultValue="") String password,
			@RequestParam(value = "phone", required = false , defaultValue="") String phone,
			@RequestParam(value = "code", required = false , defaultValue="") String code
//			@RequestParam(value = "clilent", required = false , defaultValue="3") Short client
			){
		if(Global.getInt("ALLOW_USER_REG") == 0){
			return error("抱歉,当前禁止用户自行注册开通网站!");
		}
		username = StringUtil.filterXss(username);
		email = filter(email);
		phone = filter(phone);
		code = filter(code);
		
		//判断用户的短信验证码
//		BaseVO verifyVO = smsLogService.verifyPhoneAndCode(phone, code, SmsLog.TYPE_REG, 300);
//		if(verifyVO.getResult() - BaseVO.FAILURE == 0){
//			return verifyVO;
//		}
		
		//注册用户
		User user = new User();
		user.setUsername(username);
		user.setPhone(phone);
		user.setEmail(email);
		user.setPassword(password);
		user.setOssSizeHave(G.REG_GENERAL_OSS_HAVE);
		BaseVO userVO = userService.reg(user, request);
		if(userVO.getResult() - BaseVO.FAILURE == 0){
			return userVO;
		}
		
		//为此用户设置其自动登录成功
		int userid = Lang.stringToInt(userVO.getInfo(), 0);
		if(userid == 0){
			ActionLogCache.insert(request, "warn", "自助开通网站,自动创建账号出现问题。info:"+userVO.getInfo());
			return error("自动创建账号出现问题");
		}
		BaseVO loginVO = userService.loginByUserid(request,userid);
		if(loginVO.getResult() - BaseVO.FAILURE == 0){
			return loginVO;
		}
		UserBean userBean = new UserBean();
		//将拥有所有功能的管理权限,将功能菜单全部遍历出来,赋予这个用户
		Map<String, String> menuMap = new HashMap<String, String>();
		for (TemplateMenuEnum e : TemplateMenuEnum.values()) {
			menuMap.put(e.id, "1");
		}
		userBean.setSiteMenuRole(menuMap);
		ShiroFunc.getCurrentActiveUser().setObj(userBean);
		
		//开通网站
		Site site = new Site();
		site.setExpiretime(DateUtil.timeForUnix10() + 31622400);	//到期,一年后,366天后
		site.setClient(Site.CLIENT_CMS);	// v4.11更新 创建网站默认是 CMS 类型
		site.setPhone(phone);
		site.setName("网站名字");
		SiteVO siteVO = siteService.saveSite(site, userid, request);
		AliyunLog.addActionLog(userid, "自助创建网站提交保存",(siteVO.getResult() - SiteVO.SUCCESS == 0 ? "成功":"失败")+",username:"+user.getUsername());
		if(siteVO.getResult() - SiteVO.SUCCESS == 0){
			/**
			 * 免费通道
			 */
			
			return success();
		}else{
			return error(siteVO.getInfo());
		}
	}
 
Example 12
Source File: ApiServiceImpl.java    From wangmarket with Apache License 2.0 4 votes vote down vote up
public UserVO identityVerify(String key) {
	UserVO vo = new UserVO();
	/*
	 * 验证Key的格式
	 */
	if(key.length() < 128 || key.indexOf("_") == -1){
		vo.setBaseVO(UserVO.FAILURE, "key错误1");
		return vo;
	}
	
	String[] ks = key.split("_");
	if(ks[0].length() == 0 || ks[1].length() == 0){
		vo.setBaseVO(UserVO.FAILURE, "key错误2");
		return vo;
	}
	
	int userid = Lang.stringToInt(ks[0], 0);
	if(userid == 0){
		vo.setBaseVO(UserVO.FAILURE, "key错误3");
		return vo;
	}
	String pwd = StringUtil.removeBlank(ks[1]);
	if(pwd.length() != 128){
		vo.setBaseVO(UserVO.FAILURE, "key错误4");
		return vo;
	}
	
	/*
	 * 验证Key是否存在
	 * 获取代理商的user信息
	 */
	User user = sqlDAO.findById(User.class, userid);
	if(user == null){
		//统一提示,避免被利用
		vo.setBaseVO(UserVO.FAILURE, "key错误5");
		return vo;	
	}
	if(!passwordMD5(user.getPassword()).equals(pwd)){
		vo.setBaseVO(UserVO.FAILURE, "key错误6");
		return vo;
	}
	
	vo.setUser(user);
	return vo;
}
 
Example 13
Source File: KeyManageServiceImpl.java    From wangmarket with Apache License 2.0 4 votes vote down vote up
public UserBeanVO verify(String key) {
	UserBeanVO vo = new UserBeanVO();
	/*
	 * 验证Key的格式
	 */
	if(key.length() < 128 || key.indexOf("_") == -1){
		vo.setBaseVO(UserVO.FAILURE, "key格式错误1");
		return vo;
	}
	
	String[] ks = key.split("_");
	if(ks[0].length() == 0 || ks[1].length() == 0){
		vo.setBaseVO(UserVO.FAILURE, "key格式错误");
		return vo;
	}
	
	int userid = Lang.stringToInt(ks[0], 0);
	if(userid == 0){
		vo.setBaseVO(UserVO.FAILURE, "key错误3");
		return vo;
	}
	String pwd = StringUtil.removeBlank(ks[1]);
	if(pwd.length() != 128){
		vo.setBaseVO(UserVO.FAILURE, "key位处出错");
		return vo;
	}
	
	/*
	 * 验证Key是否存在
	 * 获取代理商的user信息
	 */
	//先从内存找
	vo = keyUserMap.get(key);
	if(vo != null){
		return vo;
	}
	//userBeanVO为空,那么new一个新的,下面查询数据库,将结果加入 userBeanVO ,加入持久缓存Map
	vo = new UserBeanVO();
	
	//内存中没有,找数据库
	User user = sqlDAO.findById(User.class, userid);
	if(user == null){
		vo.setBaseVO(UserVO.FAILURE, "用户不存在");
		return vo;	
	}
	if(!passwordMD5(user.getPassword()).equals(pwd)){
		vo.setBaseVO(UserVO.FAILURE, "key校验密码错误");
		return vo;
	}
	vo.setUser(user);
	
	/*
	 * 根据 用户的权限,判断取用户的哪方面信息
	 */
	if(Func.isAuthorityBySpecific(user.getAuthority(), Global.get("ROLE_USER_ID"))){
		//是建站用户,那么取 Site 信息
		Site site = sqlDAO.findAloneBySqlQuery("SELECT * FROM site WHERE userid = "+user.getId(), Site.class);
		if(site == null){
			vo.setBaseVO(UserBeanVO.FAILURE, "站点不存在");
			return vo;	
		}
		vo.setSite(site);
	}else if (Func.isAuthorityBySpecific(user.getAuthority(), Global.get("AGENCY_ROLE"))) {
		//用户是代理商
		Agency agency = sqlDAO.findAloneBySqlQuery("SELECT * FROM agency WHERE userid = "+user.getId(), Agency.class);
		if(agency == null){
			vo.setBaseVO(UserBeanVO.FAILURE, "代理上信息不存在");
			return vo;	
		}
		vo.setAgency(agency);
	}
	
	
	//到这一步,便是找到了,那么将其key-User 进行缓存,避免下次还从数据库取
	keyUserMap.put(key, vo);
	
	return vo;
}
 
Example 14
Source File: AgencyUserController.java    From wangmarket with Apache License 2.0 4 votes vote down vote up
/**
 * api接口身份校验
 * @param key 要校验的key, id_password的4次加密,128长度的字符
 * @return {@link UserVO} 成功:vo.getResult = success
 */
private UserVO apiIdentityVerify(String key){
	UserVO vo = new UserVO();
	/*
	 * 验证Key的格式
	 */
	if(key.length() < 128 || key.indexOf("_") == -1){
		vo.setBaseVO(UserVO.FAILURE, "key错误1");
		return vo;
	}
	
	String[] ks = key.split("_");
	if(ks[0].length() == 0 || ks[1].length() == 0){
		vo.setBaseVO(UserVO.FAILURE, "key错误2");
		return vo;
	}
	
	int userid = Lang.stringToInt(ks[0], 0);
	if(userid == 0){
		vo.setBaseVO(UserVO.FAILURE, "key错误3");
		return vo;
	}
	String pwd = StringUtil.removeBlank(ks[1]);
	if(pwd.length() != 128){
		vo.setBaseVO(UserVO.FAILURE, "key错误4");
		return vo;
	}
	
	/*
	 * 验证Key是否存在
	 * 获取代理商的user信息
	 */
	User user = sqlService.findById(User.class, userid);
	if(user == null){
		//统一提示,避免被利用
		vo.setBaseVO(UserVO.FAILURE, "key错误5");
		return vo;	
	}
	if(!passwordMD5(user.getPassword()).equals(pwd)){
		vo.setBaseVO(UserVO.FAILURE, "key错误6");
		return vo;
	}
		
	vo.setUser(user);
	return vo;
}
 
Example 15
Source File: SendPhoneMsgUtil.java    From xnx3 with Apache License 2.0 4 votes vote down vote up
/**
 * 发送短信
 * @param phone 发送到的手机号
 * @param content 发送内容,编码为UTF-8编码,70个文字以内,超过70个字会发送多条信息
 * @return String <li>返回空字符null,为发送成功
 * 				  <li>返回字符串,非null,则发送失败,返回出错信息
 */
public static String send(String phone,String content){
	String result=null;
	
	if(passwordMd5 == null){
		System.out.println("请先执行  SendPhoneMsgUtil.setUserPassword(); 设置账号密码");
		return "请先执行  SendPhoneMsgUtil.setUserPassword(); 设置账号密码";
	}
	
	try {
		content=java.net.URLEncoder.encode(content, "utf-8");
	} catch (UnsupportedEncodingException e) {
		e.printStackTrace();
	}
	
	com.xnx3.net.HttpUtil httpUtil=new com.xnx3.net.HttpUtil();
	String url="http://"+requestIp+":9011/hy?uid="+uid+"&auth="+passwordMd5+"&mobile="+phone+"&msg="+content+"&encode=utf-8&expid=0";
	String requestResult=httpUtil.get(url).getContent();
	if(requestResult!=null&&requestResult.split(",")[0].equals("0")){
		result=null;
	}else{
		//send failure
		if(requestResult.indexOf("-")>0){
			int state=Lang.stringToInt(requestResult, 0);
			switch (state) {
				case 0:
					result=requestResult;
					break;
				case -1: 
					result="签权失败";
					break;
				case -2:
					result="未检索到被叫号码";
					break;
				case -3:
					result="被叫号码过多";
					break;
				case -4:
					result="内容未签名";
					break;
				case -5:
					result="内容过长";
					break;
				case -6:
					result="余额不足";
					break;
				case -7:
					result="暂停发送";
					break;
				case -8:
					result="保留";
					break;
				case -9:
					result="定时发送时间格式错误";
					break;
				case -10:
					result="下发内容为空";
					break;
				case -11:
					result="账户无效";
					break;
				case -12:
					result="Ip地址非法";
					break;
				case -13:
					result="操作频率快";
					break;
				case -14:
					result="'操作失败";
					break;
				case -15:
					result="拓展码无效(1-999)";
					break;
			default:
				result="未知错误";
				break;
			}
		}else{
			result=requestResult;
		}
	}
	
	httpUtil=null;
	return result;
}
 
Example 16
Source File: SMSUtil.java    From xnx3 with Apache License 2.0 4 votes vote down vote up
/**
 * 发送短信
 * @param phone 发送到的手机号
 * @param content 发送内容,编码为UTF-8编码,70个文字以内,超过70个字会发送多条信息
 * @return String <li>返回空字符null,为发送成功
 * 				  <li>返回字符串,非null,则发送失败,返回出错信息
 */
public static String send(String phone,String content){
	String result=null;
	
	if(passwordMd5 == null){
		System.out.println("请先执行  SMSUtil.setUserPassword(); 设置账号密码");
		return "请先执行  SMSUtil.setUserPassword(); 设置账号密码";
	}
	
	try {
		content=java.net.URLEncoder.encode(content, "utf-8");
	} catch (UnsupportedEncodingException e) {
		e.printStackTrace();
	}
	
	com.xnx3.net.HttpUtil httpUtil=new com.xnx3.net.HttpUtil();
	String url="http://"+requestIp+":9011/hy?uid="+uid+"&auth="+passwordMd5+"&mobile="+phone+"&msg="+content+"&encode=utf-8&expid=0";
	String requestResult=httpUtil.get(url).getContent();
	if(requestResult!=null&&requestResult.split(",")[0].equals("0")){
		result=null;
	}else{
		//send failure
		if(requestResult.indexOf("-")>0){
			int state=Lang.stringToInt(requestResult, 0);
			switch (state) {
				case 0:
					result=requestResult;
					break;
				case -1: 
					result="签权失败";
					break;
				case -2:
					result="未检索到被叫号码";
					break;
				case -3:
					result="被叫号码过多";
					break;
				case -4:
					result="内容未签名";
					break;
				case -5:
					result="内容过长";
					break;
				case -6:
					result="余额不足";
					break;
				case -7:
					result="暂停发送";
					break;
				case -8:
					result="保留";
					break;
				case -9:
					result="定时发送时间格式错误";
					break;
				case -10:
					result="下发内容为空";
					break;
				case -11:
					result="账户无效";
					break;
				case -12:
					result="Ip地址非法";
					break;
				case -13:
					result="操作频率快";
					break;
				case -14:
					result="'操作失败";
					break;
				case -15:
					result="拓展码无效(1-999)";
					break;
			default:
				result="未知错误";
				break;
			}
		}else{
			result=requestResult;
		}
	}
	
	httpUtil=null;
	return result;
}
 
Example 17
Source File: Page.java    From xnx3 with Apache License 2.0 4 votes vote down vote up
/**
 * @param allRecordNumber 共多少条
 * @param everyNumber 每页多少条
 * @param request HttpServletRequest
 * 			get方式传入值:
 * 			<ul>
 * 				<li>currentPage:请求第几页。若不传,默认请求第一页</li>
 * 				<li>orderBy:排序方式,如"user.id_DESC",若不传则sql不会拼接上ORDER BY</li>
 * 			</ul>
 * @return
 */
public Page(int allRecordNumber , int everyNumber  ,HttpServletRequest request){
	upList = new ArrayList<TagA>();
	nextList = new ArrayList<TagA>();
	this.allRecordNumber = allRecordNumber;
	this.everyNumber = everyNumber;
	setUrl(request);
	
	//当前第几页
	int currentPage = 0;
	String currentPageString = request.getParameter(CURRENTPAGENAME);
	if(!(currentPageString==null || currentPageString.length()==0)){
		currentPage = Lang.stringToInt(currentPageString, 0);
	}
	if(currentPage == 0){
		currentPage = 1;
	}
	this.currentPageNumber = currentPage;
	
	//计算一共有多少页,最后一页是第几页
	if(allRecordNumber == 0){
		this.lastPageNumber = 1;
	}else{
		this.lastPageNumber = (int) Math.ceil((float)allRecordNumber/everyNumber);
	}
	
	this.limitStart = (this.currentPageNumber-1)*this.everyNumber;	//开始的limit
	
	this.lastPage=generateUrl(lastPageNumber);	//生成尾页url
	this.firstPage=generateUrl(1);	//生成首页,第一页URL
	
	//上一页的链接URL
	if(currentPage>1){
		this.upPageNumber = currentPage-1;
		this.upPage = generateUrl(this.upPageNumber);
	}else{
		this.upPageNumber = 1;
		this.upPage = this.firstPage;
	}
	
	//生成下一页的URL
	if(currentPage<lastPageNumber){
		this.nextPageNumber = currentPage+1;
		this.nextPage=generateUrl(this.nextPageNumber);
	}else{
		this.nextPage=this.lastPage;
		this.nextPageNumber = this.lastPageNumber;
	}
	
	this.haveNextPage = currentPage<lastPageNumber;	//是否还有下一页
	this.haveUpPage = currentPage>1;		//是否还有上一页
	
	this.currentFirstPage = currentPage == 1;		//当前页是否是第一页
	this.currentLastPage = currentPage == this.lastPageNumber;		//当前页是否是最后一页
}
 
Example 18
Source File: Template.java    From wangmarket with Apache License 2.0 2 votes vote down vote up
/**
 * 获取HTML注释中的指定配置名的数字内容
 * @param sourceText 指定的HTML内容
 * @param configName 参数名
 * @param defaultValue 若转换出错会用的数值
 * @return 值
 */
public static int getConfigValue(String sourceText,String configName, int defaultValue){
	return Lang.stringToInt(getConfigValue(sourceText, configName), defaultValue);
}