public override void OnAuthorization(HttpActionContext actionContext) { //如果用户方位的Action带有AllowAnonymousAttribute,则不进行授权验证 if (actionContext.ActionDescriptor.GetCustomAttributes <AllowAnonymousAttribute>().Any()) { return; } string userid = CRequest.GetString("userid"); string token = CRequest.GetString("token"); string openid = CRequest.GetString("openid"); if (userid == "" || token == "" || openid == "") { actionContext.Response = ResponseStr.ToJsonError("9", "未登陆"); } else { Log.WriterLog(userid + "--" + token + "--" + openid); openid = CTools.GetOpenId(openid); if (!token.Equals(CTools.GetMD5FromString(userid + openid + "SSXXCJYXGS"))) { actionContext.Response = ResponseStr.ToJsonError("9", "非法请求"); } } }
/// <summary> /// 报价 /// </summary> private void AddPrice() { int num = 0; string price = CRequest.GetString("price"); string productId = CRequest.GetString("productId"); if (price != "" && productId != "") { UserInfo user = Session["user"] as UserInfo; if (user != null) { AddPrice ad = new AddPrice(); ad.productId = Convert.ToInt32(productId); ad.price = Convert.ToDouble(price); ad.addUser = user.id; ad.addTime = DateTime.Now; ad.status = 0; ad.remark = ""; ad.infoType = 0; num = AddPriceService.Add(ad); } } if (num > 0) { Response.Write("success"); } else { Response.Write("fail"); } }
/// <summary> /// 修改连接信息 /// </summary> private void ModLink() { int id = CRequest.GetInt("id", 0); string name = CRequest.GetString("name"); string title = CRequest.GetString("title"); string path = CRequest.GetString("path"); int place = CRequest.GetInt("place", 0); Links item = LinksService.GetModel(id); if (item != null) { item.linkname = name; item.linktitle = title; item.linkurl = path; item.istj = place; int num = LinksService.Update(item); if (num > 0) { Response.Write("success"); } else { Response.Write("fail"); } } }
/// <summary> /// 登陆 /// </summary> private void Login() { string loginname = CRequest.GetString("username"); string loginpass = CRequest.GetString("pass"); string loginT = CRequest.GetString("cookeT"); UserInfo user = UserInfoService.GetModel(loginname, encrypt.EncryptMd5(loginpass)); if (user != null) { if (user.status == 100) { Response.Write("stop"); } else { Session["user"] = user; if (loginT != "0") { HttpCookie cookie = new HttpCookie("user"); cookie.Value = user.id.ToString(); cookie.Expires = DateTime.Now.AddDays(14); Response.Cookies.Add(cookie); } Response.Write("success"); } } else { Response.Write("fail"); } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { HttpCookie aCookie; string cookieName; int limit = Request.Cookies.Count; for (int i = 0; i < limit; i++) { cookieName = Request.Cookies[i].Name; aCookie = new HttpCookie(cookieName); aCookie.Expires = DateTime.Now.AddDays(-1); Response.Cookies.Add(aCookie); } //Session.RemoveAll(); //Session.Clear(); if (CRequest.GetString("action").Equals("sysback")) { Session["loginUser"] = null; Response.Redirect("/admin/login.aspx"); } else { Session["user"] = null; Response.Redirect("login.html"); } // Jscript.AlertAndRedirect("安全Log Out成功", "/"); // Jscript.AlertAndRedirectJstr("安全Log Out成功", "window.parent.location.href='login.html'");//.Response.Write("ok"); } }
protected void Page_Load(object sender, EventArgs e) { string auth = CRequest.GetString("auth"); int type = CRequest.GetInt("type"); if (!IsPostBack && auth == "1") { string reurl = ""; //传递参数,获取用户信息后,可跳转到自己定义的页面,想怎么处理就怎么处理 if (Request.QueryString["reurl"] != null && Request.QueryString["reurl"] != "") { reurl = Request.QueryString["reurl"].ToString(); } else { reurl = host + "/html/custom/custom_join.html"; } //弹出授权页面(如在不弹出授权页面基础下未获得openid,则弹出授权页面,提示用户授权) if (Request.QueryString["auth"] != null && Request.QueryString["auth"] != "" && Request.QueryString["auth"] == "1") { Response.Redirect("https://open.weixin.qq.com/connect/oauth2/authorize?appid=" + appid + "&redirect_uri=" + Server.UrlEncode(host + "/SSXXRedirect.aspx?type=" + type + "&reurl=" + reurl) + "&response_type=code&scope=snsapi_userinfo&state=1#wechat_redirect"); } else { //不弹出授权页面 Response.Redirect("https://open.weixin.qq.com/connect/oauth2/authorize?appid=" + appid + "&redirect_uri=" + Server.UrlEncode(host + "/wechat/SSXXRedirect.aspx?type=" + type + "&reurl=" + reurl) + "&response_type=code&scope=snsapi_base&state=1#wechat_redirect"); } } }
/// <summary> /// 资讯的浏览量 /// </summary> private void UpdateViews() { int typeId = CRequest.GetInt("typeId", 0); string pageName = CRequest.GetString("pageName"); string pageValue = CRequest.GetString("pageValue"); //Pv统计 #region Pv pv = new Pv(); pv.pageName = pageName; pv.pageValue = pageValue; pv.viewsCount = 1; string sUserAgent = Request.UserAgent.ToLower(); bool bIsIpad = Regex.IsMatch(sUserAgent, "ipad"); bool bIsIphoneOs = Regex.IsMatch(sUserAgent, "iphone"); bool bIsAndroid = Regex.IsMatch(sUserAgent, "android"); bool bIsWP = Regex.IsMatch(sUserAgent, "windows phone"); if (bIsAndroid || bIsIphoneOs || bIsIpad || bIsWP) { pv.viewsCount = 2; } pv.addTime = DateTime.Now; pv.ip = IpSearch.GetIp(); pv.status = 0; pv.remark = ""; pv.infoType = typeId; UserInfo user = Session["user"] as UserInfo; if (user != null) { pv.status = user.id; pv.remark = user.mobile; } PvService.Add(pv); #endregion }
/// <summary> /// 获取跳转路径 /// </summary> private void JumpURL() { string weburl = BaseConfigService.GetById(12); string src = CRequest.GetString("src").Replace(weburl, ""); string url = FriendsInfoService.GetUrl(src); Response.Write(url); }
/// <summary> /// 功能方法 /// </summary> private void MobileHeadImg() { string dataURL = CRequest.GetString("dataURL").Trim(); try { if (dataURL.IndexOf("data") != -1) { var imgData = dataURL.Replace("data:image/jpeg;base64,", ""); //过滤特殊字符即可 string dummyData = imgData.Trim().Replace("%", "").Replace(",", "").Replace(" ", "+"); if (dummyData.Length % 4 > 0) { dummyData = dummyData.PadRight(dummyData.Length + 4 - dummyData.Length % 4, '='); } byte[] imageBytes = Convert.FromBase64String(dummyData); //读入MemoryStream对象 MemoryStream memoryStream = new MemoryStream(imageBytes, 0, imageBytes.Length); memoryStream.Write(imageBytes, 0, imageBytes.Length); //二进制转成图片Save System.Drawing.Image image = System.Drawing.Image.FromStream(memoryStream); if (!Directory.Exists(Server.MapPath(Global_Upload.FriendImgPath))) //判断目录是否存在 { Directory.CreateDirectory(Server.MapPath(Global_Upload.FriendImgPath)); //创建目录 } UserInfo user = Session["user"] as UserInfo; if (user != null) { string path = Global_Upload.FriendImgPath + user.id + DateTime.Now.ToString("yyyyMMddHH") + ".jpg"; image.Save(Server.MapPath(path)); user.imgUrl = path; int rows = UserInfoService.UpdateImg(user, 5); if (rows > 0) { Session["user"] = user; } } } } catch (System.Exception exp) { //// Error creating stream or reading from it. //System.Console.WriteLine("{0}", exp.Message); //return; } finally { Response.Write("success"); } }
protected void Page_Load(object sender, EventArgs e) { int wxType = CRequest.GetInt("type"); string wxReurl = CRequest.GetString("reurl"); string wxCode = CRequest.GetString("code"); if (!Page.IsPostBack) { if (wxCode != "") { //获取全局token if (!WxLoginBLL.SaveXMLByApplactionToken()) { Log.WriterLog("获取全局token失败"); } WxAccessToken wx = WxLoginBLL.GetToken(wxCode); if (wx.openid != null) { WxUserInfo userInfo = WxLoginBLL.GetWxUserInfo(wx, wxCode); if (userInfo.openid != null) { object obj; WxUserInfoBLL uill = new WxUserInfoBLL(); uill.CheckUserInfo(userInfo); List <WxUserInfo> users = uill.QueryUserInfoByID(wx.openid); if (users != null && users.Count > 0) { string openId = CTools.SetOpenId(users[0].openid); obj = new { userid = users[0].u_id, openid = openId, token = CTools.GetMD5FromString(users[0].u_id + openId + "SSXXCJYXGS") }; Session["UserInfo"] = users[0]; Cookies.SetCookie("UserInfo", JsonHelper.ObjToJsonString <object>(obj), 90); Response.Redirect(WxConfig.WxHost); } } else { Response.Write("获取用户信息失败"); } } else { Response.Write("获取用户token失败"); } } } }
/// <summary> /// 更新昵称信息 /// </summary> private void UpdateNiCheng() { UserInfo user = Session["user"] as UserInfo; string relName = CRequest.GetString("relName"); if (user != null) { int num = UserInfoService.UpdateNiCheng(user, relName); Response.Write("success"); } else { Response.Write("fail"); } }
/// <summary> /// 回复评价信息 /// </summary> private void ReplyComment() { UserInfo user = Session["user"] as UserInfo; if (user == null) { Response.Write("login"); } else { int id = CRequest.GetInt("id", 0); string replyContent = CRequest.GetString("replyContent"); Reply item = new Reply(); item.commentId = id; Comment comItem = CommentService.GetModel(id); if (comItem.addUser == user.id) { Response.Write("self"); return; } item.replyContent = replyContent; item.status = 0; item.remark = ""; item.addTime = DateTime.Now; item.addUser = user.id; item.infoType = 0; int num = ReplyService.Add(item); StringBuilder sb = new StringBuilder(); if (num > 0) { DataSet ds = ReplyService.GetList("commentId = " + id); if (ds.Tables[0].Rows.Count > 0) { foreach (DataRow dr in ds.Tables[0].Rows) { UserInfo replyUser = UserInfoService.GetModel(Convert.ToInt32(dr["addUser"])); if (replyUser != null) { sb.Append(replyUser.username + ":" + dr["replyContent"].ToString() + "<br/>"); } } } } Response.Write(sb.ToString()); } }
public void ProcessRequest(HttpContext context) { HttpRequest requ = context.Request; HttpResponse res = context.Response; string filename = CRequest.GetString("fn"); if (!File.Exists(context.Server.MapPath(filename))) { context.Response.Write("文件不存在,或者已经被管理员Delete!"); context.Response.End(); } if (filename != "" && filename.IndexOf("/") >= 0) { DoFile.ResponseFile(requ, res, filename.Substring(filename.LastIndexOf("/") + 1), context.Server.MapPath(filename), 10233); } }
/// <summary> /// 获取子级信息 /// </summary> private void GetMoreAreaInfo() { StringBuilder sb = new StringBuilder(); string areaId = CRequest.GetString("areaId"); DataSet ds = UserBaseService.GetList("regCode = '" + areaId + "'"); if (ds.Tables[0].Rows.Count > 0) { foreach (DataRow dr in ds.Tables[0].Rows) { if (dr["fullName"].ToString().Length > 12) { sb.Append("<li style=\"float:left; width:18%; line-height:35px; text-align:center; padding:5px; margin-bottom:5px; border:1px #eee solid;\"><a href=\"/comDetail_client_" + dr["userId"] + "_1.html\" title=\"" + dr["fullName"] + "\">" + dr["fullName"].ToString().Substring(0, 12) + "</a></li> "); } else { sb.Append("<li style=\"float:left; width:18%; line-height:35px; text-align:center; padding:5px; margin-bottom:5px; border:1px #eee solid;\"><a href=\"/comDetail_client_" + dr["userId"] + "_1.html\" title=\"" + dr["fullName"] + "\">" + dr["fullName"] + "</a></li> "); } } sb.Append("<li style=\"float:left; width:18%; line-height:35px; text-align:center; padding:5px; margin-bottom:5px; border:1px #eee solid;\"><a href='javascript:collapseInfo(" + areaId + ")'>收起 <<</a></li> "); } Response.Write(sb.ToString()); }
/// <summary> /// 用户Join /// </summary> private void UserReg() { string userType = CRequest.GetString("userType"); string username = CRequest.GetString("username"); string pass = CRequest.GetString("pass"); string code = CRequest.GetString("code"); if (Session["code"].ToString() != code) { Response.Write("codeError"); return; } UserInfo item = new UserInfo(); #region 封装数据 item.username = username; if (username.Length == 11 && username.Substring(0, 1) == "1") { item.mobile = username; item.isBindMobile = 1; } else { item.mobile = ""; item.isBindMobile = 0; } if (username.IndexOf("@") != -1 && username.IndexOf(".") != -1) { item.email = username; item.isBindEmail = 1; } else { item.email = ""; item.isBindEmail = 0; } item.password = pass; item.md5Pass = encrypt.EncryptMd5(pass); item.relName = ""; item.bodyCode = ""; item.comName = ""; item.pid = 0; item.cid = 0; item.regionId = 0; item.address = ""; item.zipCode = ""; item.qq = ""; item.weixin = ""; item.isBindWeiXin = 0; item.weibo = ""; item.isBindWeiBo = 0; item.shopType = 0; item.shopTypeName = ""; if (userType != "") { item.shopType = Convert.ToInt32(userType); if (item.shopType == 1) { item.shopTypeName = "品牌商"; } else if (item.shopType == 2) { item.shopTypeName = "经销商"; } else if (item.shopType == 3) { item.shopTypeName = "一般用户"; } } item.imgUrl = ""; item.comInfo = ""; item.remark = ""; item.status = 0; item.addTime = DateTime.Now; item.mobileCode = ""; item.activeCode = ""; item.infoType = 0; #endregion if (UserInfoService.Exists(item.username)) { Response.Write("exists"); } else { int maxId = UserInfoService.Add(item); if (maxId > 0) { item.id = maxId; Session["user"] = item; Response.Write("success"); } else { Response.Write("fail"); } } }
/// <summary> /// Q登陆 /// </summary> private void QLogin() { string loginname = CRequest.GetString("username"); string loginpass = CRequest.GetString("pass"); string loginT = CRequest.GetString("cookeT"); UserInfo user = UserInfoService.GetModel(loginname, encrypt.EncryptMd5(loginpass)); if (user != null) { Session["Quser"] = user; if (loginT != "0") { HttpCookie cookie = new HttpCookie("Quser"); cookie.Value = user.id.ToString(); cookie.Expires = DateTime.Now.AddDays(14); Response.Cookies.Add(cookie); } Response.Write("success"); } else { user = new UserInfo(); #region 封装对象进行Join并Log In user.username = loginname; user.mobile = ""; user.isBindMobile = 0; user.email = ""; user.isBindEmail = 0; user.password = loginpass; user.md5Pass = encrypt.EncryptMd5(loginpass); user.relName = ""; user.bodyCode = ""; user.comName = ""; user.pid = 0; user.cid = 0; user.regionId = 0; user.address = ""; user.zipCode = ""; user.qq = ""; user.weixin = ""; user.isBindWeiXin = 0; user.weibo = ""; user.isBindWeiBo = 0; user.shopType = 0; user.shopTypeName = ""; user.imgUrl = ""; user.comInfo = ""; user.remark = ""; user.status = 0; user.addTime = DateTime.Now; user.mobileCode = ""; user.activeCode = ""; user.infoType = 1; int maxId = UserInfoService.Add(user); if (maxId > 0) { user.id = maxId; Session["Quser"] = user; if (loginT != "0") { HttpCookie cookie = new HttpCookie("Quser"); cookie.Value = user.id.ToString(); cookie.Expires = DateTime.Now.AddDays(14); Response.Cookies.Add(cookie); } Response.Write("success"); } else { Response.Write("fail"); } #endregion } }
/// <summary> /// qq授权代理Save /// </summary> private void qqLogin() { string openId = CRequest.GetString("openId"); string accessToken = CRequest.GetString("accessToken"); string nickname = CRequest.GetString("nickname"); UserInfo user = UserInfoService.GetModel(openId, accessToken, 2); if (user == null) { user = new UserInfo(); #region 封装对象进行Join并Log In user.username = ""; user.mobile = ""; user.isBindMobile = 0; user.email = ""; user.isBindEmail = 0; user.password = ""; user.md5Pass = encrypt.EncryptMd5(accessToken); user.relName = nickname; user.bodyCode = openId; user.comName = accessToken; user.pid = 0; user.cid = 0; user.regionId = 0; user.address = ""; user.zipCode = ""; user.qq = ""; user.weixin = ""; user.isBindWeiXin = 0; user.weibo = ""; user.isBindWeiBo = 0; user.shopType = 0; user.shopTypeName = ""; user.imgUrl = ""; user.comInfo = ""; user.remark = ""; user.status = 0; user.addTime = DateTime.Now; user.mobileCode = ""; user.activeCode = ""; user.infoType = 2; int maxId = UserInfoService.Add(user); if (maxId > 0) { user.id = maxId; Session["user"] = user; Response.Write("success"); } else { Response.Write("fail"); } #endregion } else { Session["user"] = user; Response.Write("success"); } }