public ActionResult Index1(string errMessage = "", string returnUrl = "") { ViewBag.ErrorMessage = UrlParameterHelper.UrlDecode(errMessage); ViewBag.ReturnUrl = UrlParameterHelper.UrlDecode(returnUrl); return(View("/Views/Shared/Error.cshtml")); }
public ActionResult Open() { string url = ""; bool isMicromessenger = StringHelper.GetUserAgent().ToLower().Contains("micromessenger"); int payType = 0; string pt = UrlParameterHelper.GetParams("pt"); if (!string.IsNullOrEmpty(pt) && int.TryParse(pt, out payType) && payType == 13) { if (isMicromessenger) //微信支付(公众号) { url = "/user/order/paynow/open1"; } else //微信支付(手机网页) { url = "/user/order/paynow/index2"; } } else //其它支付 { url = "/user/order/paynow/index"; } return(Redirect(GetPayUrl(url, pt))); }
private IEnumerable <AD> GetADList(int classId, int novelId, int pageSize) { string where = "and a.ClassId = @classId and a.fid <> @novelId"; string orderby = " order by a.onlinetime desc, a.sortid desc "; int adIndex = UrlParameterHelper.GetParams("dx").ToInt(); adIndex = (adIndex > 0) ? adIndex : 1; int rowCount = 0; var adList = DataContext.TryCache <IEnumerable <AD> >(string.Format("{0}{1}{2}_ChapterDetail_AD", classId, pageSize, adIndex), () => { return(_adService.GetPagerList(where, orderby, adIndex, pageSize, out rowCount, new { classId, novelId })); }, 60); rowCount = DataContext.TryCache <int>(string.Format("{0}{1}{2}_ChapterDetail_AD_RowCount", classId, pageSize, adIndex), () => { return(rowCount); }, 60); if (!adList.IsNullOrEmpty <AD>()) { ViewBag.AdIndex = (adIndex >= (int)Math.Ceiling((double)rowCount / pageSize)) ? 1 : adIndex + 1; } return(adList); }
protected bool VerifyRedirectToken(string novelId, out int code, out Constants.Novel.ChapterDirection direction, int timeout = 0) { if (ChapterContext.IsToken) { code = 0; direction = Constants.Novel.ChapterDirection.none; string token = UrlParameterHelper.GetParams("t"); string timeStamp = UrlParameterHelper.GetParams("s"); string random = UrlParameterHelper.GetParams("r"); if (string.IsNullOrEmpty(token) || string.IsNullOrEmpty(timeStamp) || string.IsNullOrEmpty(random)) { return(false); } return(ChapterContext.VerifyRedirectToken(token, novelId, timeStamp, random, out code, out direction, timeout)); } else { code = StringHelper.ToInt(UrlParameterHelper.GetParams("chapterCode")); if (!EnumHelper.TryParsebyName <Constants.Novel.ChapterDirection>(UrlParameterHelper.GetParams("direction"), out direction)) { direction = Constants.Novel.ChapterDirection.none; } return(true); } }
public ActionResult Pay(int?pt = 0, int?money = 0, string fpt = "", int?fcid = 0, int?ut = 0) { string url = string.Empty; ErrorMessage errorMessage = ErrorMessage.失败; BindPayType(pt.ToInt(), money.ToInt(), out url, out errorMessage, fpt, fcid.ToInt(), userType: ut.ToInt()); if (errorMessage == ErrorMessage.成功) { string returnUrl = UrlParameterHelper.GetDecodingParams("returnUrl"); if (!string.IsNullOrEmpty(returnUrl)) { url = StringHelper.GetReturnUrl(url, returnUrl); } return(Redirect(url)); } //else if (errorMessage == ErrorMessage.支付参数错误) //{ // //} //else if (errorMessage == ErrorMessage.生成订单号失败) //{ // //} else { return(Redirect(string.Format("/error/index?errCode={0}&returnUrl=", (int)errorMessage).GetChannelRouteUrl(RouteChannelId))); } }
protected override void Initialize(System.Web.Routing.RequestContext requestContext) { base.Initialize(requestContext); Code = UrlParameterHelper.GetParams("code"); State = UrlParameterHelper.GetParams("state"); ReturnUrl = UrlParameterHelper.GetDecodingParams("returnurl"); }
public ActionResult Index() { Com.WxPayAPI.Log.Info(this.GetType().ToString(), "WxPayController Index"); string wxJsApiParam = ""; ErrorMessage errorMessage = ErrorMessage.失败; int payType = 0; string orderId = ""; int money = 0; int userType = 0; if (PayContext.VerifyPayOrderInfo(1, out errorMessage, out payType, out orderId, out money, out userType)) { string host = StringHelper.GetHost(); string path = Request.Path; string queryString = Request.Url.Query; Com.WxPayAPI.JsApiPay jsApiPay = new Com.WxPayAPI.JsApiPay(host, path, queryString); string openid = UrlParameterHelper.GetParams("openid"); //检测是否给当前页面传递了相关参数 if (string.IsNullOrEmpty(openid) || money <= 0) { Response.Write("<span style='color:#FF0000;font-size:20px'>" + "页面传参出错,请返回重试" + "</span>"); Com.WxPayAPI.Log.Error(this.GetType().ToString(), "This page have not get params, cannot be inited, exit..."); return(View()); } //若传递了相关参数,则调统一下单接口,获得后续相关接口的入口参数 jsApiPay.OpenId = openid; jsApiPay.Total_Fee = money; //JSAPI支付预处理 try { string body = string.Concat(SiteSection.Html.SiteName, "-", SiteSection.Html.FeeName); Com.WxPayAPI.WxPayData unifiedOrderResult = jsApiPay.GetUnifiedOrderResult(body, orderId); wxJsApiParam = jsApiPay.GetJsApiParameters();//获取H5调起JS API参数 Com.WxPayAPI.Log.Debug(this.GetType().ToString(), "wxJsApiParam : " + wxJsApiParam); //在页面上显示订单信息 //Response.Write("<span style='color:#00CD00;font-size:20px'>订单详情:</span><br/>"); //Response.Write("<span style='color:#00CD00;font-size:20px'>" + unifiedOrderResult.ToPrintStr() + "</span>"); } catch { Response.Write("<span style='color:#FF0000;font-size:20px'>" + "下单失败,请返回重试" + "</span>"); } } ViewData.Model = wxJsApiParam; return(View()); }
public ActionResult Login(string returnUrl) { if (!string.IsNullOrEmpty(returnUrl)) { returnUrl = UrlParameterHelper.UrlEncode(returnUrl); } ViewData.Model = returnUrl; return(View()); }
public static bool VerifyRedirectToken(string token, string id, string timeStamp, string random, out int code, out Constants.Novel.ChapterDirection direction, int timeout = 0) { code = 0; direction = Constants.Novel.ChapterDirection.none; if (string.IsNullOrEmpty(token) || string.IsNullOrEmpty(id) || string.IsNullOrEmpty(timeStamp) || string.IsNullOrEmpty(random)) { return(false); } bool flag = false; try { token = UrlParameterHelper.UrlDecode(token); string txt = SecurityHelper.DecryptBase64XorBase64Url(token, RedirectKey); if (!string.IsNullOrEmpty(txt)) { string[] list = txt.Split('_'); if (!StringHelper.IsNullOrEmpty(list)) { if (timeout == 0 || ((DateTime.Now - StringHelper.ConvertDateTime(timeStamp)).TotalMinutes < timeout)) { code = StringHelper.ToInt(list[0]); if (list.Length <= 3) { flag = (string.Compare(id, list[1], true) == 0 && string.Compare(string.Concat(random, timeStamp), list[2], true) == 0); } else { flag = (EnumHelper.TryParsebyName <Constants.Novel.ChapterDirection>(list[1], out direction) && string.Compare(id, list[2], true) == 0 && string.Compare(string.Concat(random, timeStamp), list[3], true) == 0); } } } } } catch { } finally { //if (!flag) //{ // code = 0; // direction = Constants.ChapterDirection.none; // flag = true; //} } return(flag); }
public ActionResult AllAudioPackage() { string url = ""; ErrorMessage errorMessage = ErrorMessage.失败; PackageOrderInfo model = new PackageOrderInfo(); model = GetLogInfo(model) as PackageOrderInfo; model.UserName = currentUser.UserName; model.Fee = SiteSection.Audio.AllPackageFee; model.Cash = SiteSection.Audio.AllPackageFee; model.Status = (int)Constants.Status.yes; model.OrderTime = DateTime.Now; model.AutoRenew = 0; model.Balance = 0; model.BeginTime = DateTime.Now; model.EndTime = DateTime.Now; model.FeeId = 0; model.Integral = 0; model.OrderCode = ""; model.OrderContentType = 2; model.PackageId = 0; model.PackageTitle = ""; model.PayChannel = 0; model.Rebate = 0; model.RebateExpression = ""; model.RebateFee = 0; model.CancelTime = DateTime.Now; int result = _orderService.OrderPackage(model); if (EnumHelper.TryParsebyValue <ErrorMessage>(result, out errorMessage)) { switch (errorMessage) { case ErrorMessage.成功: url = NovelId > 0 ? ChapterContext.GetUrl("/chapter/detail", NovelId, ChapterCode, channelId: RouteChannelId) : "/"; break; case ErrorMessage.余额不足: url = StringHelper.GetReturnUrl("/order/recharge", UrlParameterHelper.GetParams("returnUrl"), channelId: RouteChannelId); break; case ErrorMessage.已包月: url = ChapterContext.GetUrl("/chapter/detail", NovelId, ChapterCode, channelId: RouteChannelId); break; case ErrorMessage.用户不存在: url = DataContext.GetErrorUrl(ErrorMessage.用户不存在, channelId: RouteChannelId); break; } } return(Redirect(url)); }
protected override void Initialize(System.Web.Routing.RequestContext requestContext) { base.Initialize(requestContext); NovelId = StringHelper.ToInt(UrlParameterHelper.GetParams("novelId")); if (!VerifyRedirectToken(StringHelper.ToString(NovelId), out ChapterCode, out ChapterDirection) || NovelId <= 0 || ChapterCode < 0) { ChapterCode = 0; ChapterDirection = Constants.Novel.ChapterDirection.none; } }
public ChapterRedirectManage(int chapterRedirectTimeout = 0) { string nid = UrlParameterHelper.GetParams("novelId"); if (!string.IsNullOrEmpty(nid) && !VerifyRedirectToken(nid, out _chapterCode, out _chapterDirection, chapterRedirectTimeout) || _chapterCode < 0) { _chapterCode = 0; _chapterDirection = Constants.Novel.ChapterDirection.none; } _novelId = StringHelper.ToInt(nid); }
private string GetReplyTextUrl(string url, out string replyText) { replyText = ""; string rp = UrlParameterHelper.GetParams("rp"); if (!string.IsNullOrEmpty(rp) && ChapterContext.VerifyReplyText(rp, out replyText)) { url = StringHelper.SpliceUrl(url, "rp", rp); } return(url); }
protected void InitializeChapterPager() { MinMaxChapterCode = UrlParameterHelper.GetParams("c"); if (!string.IsNullOrEmpty(MinMaxChapterCode) && ChapterContext.VerifyRangeToken(MinMaxChapterCode, out MinChapterCode, out MaxChapterCode, ChapterCodeRangeTimeout) && MinChapterCode >= 0 && MaxChapterCode >= MinChapterCode) { ResetChapterCode(ChapterDirection); } else { SetChapterCodeRange(); } }
private string GetReplyTextUrl(string url, out string replyText) { replyText = ""; string rp = UrlParameterHelper.GetParams("rp"); if (!string.IsNullOrEmpty(rp)) { ChapterContext.VerifyReplyText(rp, out replyText); IDictionary <string, object> dict = new Dictionary <string, object>(); dict.Add("rp", rp); url = StringHelper.SpliceUrl(url, dict); } return(url); }
public static bool VerifyRangeToken(string value, out int minChapterCode, out int maxChapterCode, int timeout = 0) { minChapterCode = 0; maxChapterCode = 0; if (string.IsNullOrEmpty(value)) { return(false); } bool flag = false; try { value = UrlParameterHelper.UrlDecode(value); string txt = SecurityHelper.DecryptBase64XorBase64Url(value, RangeKey); if (!string.IsNullOrEmpty(txt)) { string[] list = txt.Split('@'); if (!StringHelper.IsNullOrEmpty(list) && list.Length == 2) { string timeStamp = list[1]; if (!string.IsNullOrEmpty(timeStamp)) { if (timeout == 0 || ((DateTime.Now - StringHelper.ConvertDateTime(timeStamp)).TotalMinutes < timeout)) { if (!string.IsNullOrEmpty(list[0])) { string[] chapterCodeList = list[0].Split('_'); if (!StringHelper.IsNullOrEmpty(chapterCodeList)) { minChapterCode = StringHelper.ToInt(chapterCodeList[0]); maxChapterCode = StringHelper.ToInt(chapterCodeList[1]); flag = (minChapterCode <= maxChapterCode && minChapterCode >= 0); } } } } } } } catch { } finally { } return(flag); }
/// <summary> /// 获取头信息 /// </summary> /// <param name="name"></param> /// <param name="value"></param> /// <param name="paramType"></param> /// <returns></returns> protected bool IsHeader(string name, out string value, out ParamType paramType) { value = ""; paramType = ParamType.none; if (string.IsNullOrEmpty(name)) { return(false); } try { value = StringHelper.FilterIllegalParameter(HttpContext.Request.Headers[name]); if (!string.IsNullOrEmpty(value)) { paramType = ParamType.header; } } catch { } if (string.IsNullOrEmpty(value)) { try { value = GetRouteData(name); if (!string.IsNullOrEmpty(value)) { paramType = ParamType.route; } } catch { } } if (string.IsNullOrEmpty(value)) { try { value = UrlParameterHelper.GetParams(name); if (!string.IsNullOrEmpty(value)) { paramType = ParamType.param; } } catch { } } return(!string.IsNullOrEmpty(value) && paramType != ParamType.none); }
private string GetPayUrl(string url, string pt) { string userType = UrlParameterHelper.GetParams("ut"); string money = UrlParameterHelper.GetParams("money"); string otn = UrlParameterHelper.GetParams("otn"); //string returnUrl = UrlParameterHelper.GetDecodingParams("returnUrl"); //string state = ""; //if (!string.IsNullOrEmpty(returnUrl)) //{ // state = Guid.NewGuid().ToString("N"); // ReturnUrlHelper.SetSession("NowPay_ReturnUrl", state, returnUrl); //} //return string.Format("{0}?ut={1}&money={2}&pt={3}&otn={4}&st={5}", url, userType, money, pt, otn, state); return(string.Format("{0}?ut={1}&money={2}&pt={3}&otn={4}", url, userType, money, pt, otn)); }
/// <summary> /// 搜索结果页 /// </summary> /// <returns></returns> public ActionResult SearchList(string keyword, int pageIndex = 1, int pageSize = 10) { string where = GetSearchWhere(null, 0, 0, 0, keyword, Constants.Novel.ShowLocation.searchlist); string orderby = " order by n.Hits desc, n.FavCount desc, n.id desc"; int rowCount; var bookList = _bookService.GetPagerList(where, orderby, out rowCount, pageIndex, pageSize, new { keyword = UrlParameterHelper.GetDecodingParams("keyword") }, "[dbo].[Novel] as n inner join [dbo].[NovelClass] nc on nc.Id = n.ClassId", "n.Id, n.Title, n.LargeCover, n.ThumbCover, n.SmallCover, n.UpdateStatus, nc.ClassName,n.Author,n.ShortDescription,n.ShortWordSize,n.ContentType, n.IsHideAuthor"); ViewBag.TotalCount = rowCount; ViewBag.Keyword = keyword; var model = new SimpleResponse <IEnumerable <NovelView> >(!bookList.IsNullOrEmpty(), bookList); return(View(model)); }
protected override void SetChapterCodeRange() { string MinMaxChapterCode = UrlParameterHelper.GetParams("cc"); if (!string.IsNullOrEmpty(MinMaxChapterCode)) { int min = 0; int max = 0; string[] chapterCode = MinMaxChapterCode.Split('_'); if (chapterCode != null && chapterCode.Length == 2 && int.TryParse(chapterCode[0], out min) && min >= 0 && int.TryParse(chapterCode[1], out max) && max >= 0) { SetChapterCode(min, max); } } }
protected string Login(string AppId, string AppKey, string CallbackUrl) { string url = ""; currentUser.State = Guid.NewGuid().ToString("N"); SetReturnUrl(currentUser.State, ReturnUrl); QQConnect connect = new QQConnect(AppId, AppKey, currentUser.State, UrlParameterHelper.UrlEncode(CallbackUrl)); if (connect != null) { SaveUserInfo(currentUser); url = connect.GetAuthorizationCodeUrl("get_user_info"); } return(url); }
public ChapterPagerManage(Func <int, ChapterCodeRange> func, bool isCustomRange = false, int chapterCodeRangeTimeout = 0, int chapterRedirectTimeout = 0) : base(chapterRedirectTimeout) { if (NovelId <= 0) { return; } string chapterCodeRange = string.Empty; if (isCustomRange && !string.IsNullOrEmpty(chapterCodeRange = UrlParameterHelper.GetParams("cc"))) { int min = 0; int max = 0; string[] range = chapterCodeRange.Split('_'); if (!range.IsNullOrEmpty() && range.Length == 2 && int.TryParse(range[0], out min) && min >= 0 && int.TryParse(range[1], out max) && max >= 0) { Set(min, max); } } else { _chapterCodeRange = UrlParameterHelper.GetParams("c"); if (!string.IsNullOrEmpty(_chapterCodeRange) && ChapterContext.VerifyRangeToken(_chapterCodeRange, out _minChapterCode, out _maxChapterCode, chapterCodeRangeTimeout)) { Reset(); } else { if (func != null) { ChapterCodeRange range = func(NovelId); if (!range.IsNullOrEmpty <ChapterCodeRange>()) { Set(range.MinChapterCode, range.MaxChapterCode); } } } } }
private string GetChannelId(AuthorizationContext filterContext, string name) { if (string.IsNullOrEmpty(name)) { return(""); } string value = string.Empty; try { value = StringHelper.FilterIllegalParameter(filterContext.HttpContext.Request.Headers[name]); } catch { } if (string.IsNullOrEmpty(value)) { try { value = UrlParameterHelper.GetParams(name); } catch { } } if (string.IsNullOrEmpty(value)) { try { RouteData data = filterContext.RouteData; if (data != null) { RouteValueDictionary values = data.Values; if (values != null && values.Count > 0) { value = StringHelper.ToString(values[name]); } } } catch { } } return(value); }
public ActionResult Open() { string url = ""; try { string host = StringHelper.GetHost(); string path = Request.Path; string queryString = Request.Url.Query; string code = UrlParameterHelper.GetQueryString("code"); string query = ""; string state = ""; if (!string.IsNullOrEmpty(code)) { query = UrlParameterHelper.GetDecodingParams("state"); } else { state = UrlParameterHelper.UrlEncode(queryString); } Com.WxPayAPI.JsApiPay jsApiPay = new Com.WxPayAPI.JsApiPay(host, path, queryString); jsApiPay.GetOpenidAndAccessToken(state, out url, code); string openid = jsApiPay.OpenId; if (string.IsNullOrEmpty(url)) { if (!string.IsNullOrEmpty(openid) && !string.IsNullOrEmpty(query)) { IDictionary <string, object> dict = new Dictionary <string, object>(); dict.Add("openid", openid); url = StringHelper.SpliceUrl(string.Concat("/user/order/wechat/js/index.aspx", query), dict); } } } catch { url = "/error/notfound".GetChannelRouteUrl(RouteChannelId); } return(Redirect(url)); }
public ActionResult Login(string returnUrl) { #region string absoluteUrl = ""; if (EnvSettings.Domain.IsInvalid(out absoluteUrl)) { return(Redirect(absoluteUrl)); } #endregion if (!string.IsNullOrEmpty(returnUrl)) { returnUrl = UrlParameterHelper.UrlEncode(returnUrl); } ViewData.Model = returnUrl; return(View()); }
public static string GetReplyText(string replyText) { if (string.IsNullOrEmpty(replyText)) { return(""); } string result = string.Empty; try { result = SecurityHelper.EncryptBase64XorBase64Url(replyText, ReplyTextKey); if (!string.IsNullOrEmpty(result)) { result = UrlParameterHelper.UrlEncode(result); } } catch { } return(result); }
public static string CreateRedirectToken(int id, int code, Constants.Novel.ChapterDirection direction, out int timeStamp, out int random) { timeStamp = 0; random = 0; if (id <= 0 || code < 0) { return(""); } timeStamp = StringHelper.ConvertTimeStamp(DateTime.Now); random = rd.Next(1000, 10000); string txt = string.Concat(code, "_", StringHelper.ToString(direction), "_", StringHelper.ToString(id), "_", string.Concat(random, timeStamp)); string result = SecurityHelper.EncryptBase64XorBase64Url(txt, RedirectKey); if (!string.IsNullOrEmpty(result)) { result = UrlParameterHelper.UrlEncode(result); } return(result); }
public static string GetRangeToken(int minChapterCode, int maxChapterCode) { if (minChapterCode < 0 || minChapterCode > maxChapterCode) { return(""); } string result = string.Empty; try { int timeStamp = StringHelper.ConvertTimeStamp(DateTime.Now); string txt = string.Concat(minChapterCode, "_", maxChapterCode, "@", timeStamp); result = SecurityHelper.EncryptBase64XorBase64Url(txt, RangeKey); if (!string.IsNullOrEmpty(result)) { result = UrlParameterHelper.UrlEncode(result); } } catch { } return(result); }
/// <summary> /// 验证充值订单信息 /// </summary> /// <param name="minMoney">最低充值金额(如:0.1元、0.01元)</param> /// <param name="errorMessage">错误信息</param> /// <param name="payType">充值类型</param> /// <param name="orderId">订单号</param> /// <param name="money">充值金额</param> /// <param name="userType"></param> /// <returns></returns> public static bool VerifyPayOrderInfo(int minMoney, out ErrorMessage errorMessage, out int payType, out string orderId, out int money, out int userType) { errorMessage = ErrorMessage.成功; payType = 0; orderId = string.Empty; money = StringHelper.ToInt(UrlParameterHelper.GetParams("money")); //单位:分 userType = StringHelper.ToInt(UrlParameterHelper.GetParams("ut")); //默认:至少20元;大于0:任意金额; string pt = UrlParameterHelper.GetParams("pt"); string otn = UrlParameterHelper.GetParams("otn"); int orderMoney = 0; if (!VerifyOrderId(otn, money, out orderId, out orderMoney)) { errorMessage = ErrorMessage.支付参数错误; } else if (!string.IsNullOrEmpty(pt) && int.TryParse(pt, out payType) && payType <= 0) { errorMessage = ErrorMessage.支付类型为空; } else if (money <= 0) { errorMessage = ErrorMessage.金额为空; } else if (money <= 1999) { errorMessage = ErrorMessage.最低充值20元; } else { money = (userType == 0 ? money : minMoney); } return(errorMessage == ErrorMessage.成功); }
protected void SetSessionHeaderInfo() { ReadSessionHeaderInfo(); string channelId = ""; ParamType paramType = ParamType.none; if (IsHeader(Constants.HttpHeader.CHANNEL_ID, out channelId, out paramType)) { if (paramType == ParamType.route) { SaveSessionHeaderInfoFromRoute(channelId); } else { #region HeaderInfo Session string promotionCode = UrlParameterHelper.GetParams("pmc"); if (!string.IsNullOrEmpty(promotionCode)) { SaveSessionHeaderInfo(channelId, promotionCode); } else { SaveSessionHeaderInfo(channelId, ""); } #endregion HeaderInfo Session } } #region SetHeaderInfo(); #endregion }