public string CreateChannel(string chId) { B_SiteInfo SiteBll = new B_SiteInfo(); B_Channel ChannelBll = new B_Channel(); M_Site SiteModel = SiteBll.GetSiteModel(); if (!SiteModel.IsStaticType) { return "fail$全站参数设置没有开启生成静态页面功能"; } string chIdStr = ""; M_Channel channelModel = ChannelBll.GetChannel(int.Parse(chId)); if (channelModel != null && channelModel.IsStaticType) { chIdStr = chIdStr + chId + ","; } if (chIdStr == string.Empty) { return "fail$所选频道没有开启生成静态页面功能"; } chIdStr = chIdStr.Substring(0, (chIdStr.Length - 1)); Session["createchid"] = chIdStr; return "succ$" + chIdStr; }
protected void Page_Load(object sender, EventArgs e) { InfoTable.Visible = false; B_User user = new B_User(); M_User userModel = user.GetUser(user.GetCookie().UserID); B_SiteInfo site = new B_SiteInfo(); M_Site siteModel = site.GetSiteModel(); if (userModel != null) { if (siteModel.IsOpenInvite) { B_UserGroup groupBll = new B_UserGroup(); string integral = groupBll.Power_UserGroup("Invite", 0, groupBll.GetModel(userModel.GroupID).GroupPower); lbIntegral.Text = integral; if (siteModel.Domain.EndsWith("/")) { txtUrl.Text = siteModel.Domain + "user/Reg.aspx?TypeId=" + userModel.TypeId + "&recmd_uid=" + userModel.UserID; } else { txtUrl.Text = siteModel.Domain + "/user/Reg.aspx?TypeId=" + userModel.TypeId + "&recmd_uid=" + userModel.UserID; } } else { InfoTable.Visible = true; MainTable.Visible = false; } } else { Response.Redirect("Login.aspx"); } }
protected void Page_Load(object sender, EventArgs e) { B_SiteInfo bll = new B_SiteInfo(); M_Site model = bll.GetSiteModel(); if (model != null) { IsOpenRZM = model.IsOpenRZM; } }
public string LetterWaterMark(HtmlInputFile FilePicName, string FilePicPath, string UpLoadPicPath) { Font font; B_SiteInfo info = new B_SiteInfo(); M_Site siteModel = new M_Site(); siteModel = info.GetSiteModel(); string str = ""; if (UpLoadPicPath == "") { str = this.NotWaterMark_NotNewSize(FilePicName, FilePicPath); } else { str = UpLoadPicPath; } string waterMarkStr = siteModel.WaterMarkStr; int waterMarkFontSize = siteModel.WaterMarkFontSize; string waterMarkFontName = siteModel.WaterMarkFontName; string waterMarkFontColor = siteModel.WaterMarkFontColor; bool waterMarkIsBold = siteModel.WaterMarkIsBold; string path = HttpContext.Current.Server.MapPath(FilePicPath) + str; string[] strArray = str.Split(new char[] { '/' }); string[] strArray2 = strArray[1].Split(new char[] { '.' }); string destFileName = HttpContext.Current.Server.MapPath(FilePicPath) + strArray[0] + strArray2[0] + "_1" + strArray2[1]; if (File.Exists(path)) { File.Copy(path, destFileName); } Image image = Image.FromFile(destFileName); Graphics graphics = Graphics.FromImage(image); graphics.CompositingQuality = CompositingQuality.HighQuality; graphics.SmoothingMode = SmoothingMode.HighQuality; graphics.InterpolationMode = InterpolationMode.HighQualityBicubic; graphics.DrawImage(image, 0, 0, image.Width, image.Height); if (waterMarkIsBold) { font = new Font(waterMarkFontName, (float) waterMarkFontSize, FontStyle.Bold); } else { font = new Font(waterMarkFontName, (float) waterMarkFontSize); } Brush brush = new SolidBrush(ColorTranslator.FromHtml("#" + waterMarkFontColor)); string s = waterMarkStr; graphics.DrawString(s, font, brush, (float) 0f, (float) 0f); graphics.Dispose(); image.Save(path); image.Dispose(); if (File.Exists(destFileName)) { File.Delete(destFileName); } return str; }
protected void btnQuestion_Click(object sender, EventArgs e) { M_User model = bll.GetUser(txtUserName.Text); if (model != null) { if (Function.MD5Encrypt(txtAnswer.Text.Trim()) == model.Answer) { B_SiteInfo site = new B_SiteInfo(); M_Site siteModel = site.GetSiteModel(); //产生随机密码 //更新数据库 string Pwd = Function.GetRndNum(8); string newPwd = Function.MD5Encrypt(Pwd); bll.ModifyPwd(model.UserID, newPwd); if (siteModel != null) { StringBuilder sb = new StringBuilder(); sb.Append(txtUserName.Text + ",您好!您在本站 ("); sb.Append(siteModel.SiteName + ")"); sb.Append("使用了找回密码功能.这是您的新密码:"); sb.Append(Pwd); sb.Append("祝您健康愉快!"); sb.Append(siteModel.SiteName); sb.Append(DateTime.Now); try { B_SendMail mail = new B_SendMail(siteModel.EmailServerAddress, model.Email, txtUserName.Text + "您好!这是您的新密码", sb.ToString(), true, System.Text.Encoding.UTF8); mail.Send(); Function.ShowMsg(1, "<li>恭喜!找回密码成功。您的新密码已经发送到您的邮箱,请注意查收!</li><li><a href='Login.aspx'>登录</a></li><li><a href='" + IndexUrl + "'>返回网站首页</a></li>"); } catch { Function.ShowMsg(1, "<li>恭喜!找回密码成功。这是您的新密码:"+Pwd+"</li><li><a href='Login.aspx'>登录</a></li><li><a href='" + IndexUrl + "'>返回网站首页</a></li>"); } } } else { Function.ShowMsg(0, "<li>对不起,您的答案不正确!</li><li><a href='javascript:window.history.back()'>返回上一步</a></li>"); } } else { //无此用户 Function.ShowMsg(0, "<li>无此用户</li><li><a href='Reg.aspx'>注册一个新帐户</a></li><li><a href='" + IndexUrl + "'>返回网站首页</a></li>"); } }
protected void Page_Load(object sender, EventArgs e) { Response.Cache.SetNoStore(); string refer = "Main.aspx"; B_SiteInfo siteBll = new B_SiteInfo(); if (siteBll.GetSiteModel().IsLoginValidate) { TrValidCode.Visible = true; imgCode.Visible = true; } if (!string.IsNullOrEmpty(Request.QueryString["ReturnUrl"])) { refer = Request.QueryString["ReturnUrl"].ToString(); } btnLogin.PostBackUrl = "DoLogin.aspx?ReturnUrl=" + Server.UrlEncode(refer); }
public string CreateInfoByColId(string colId) { B_SiteInfo SiteBll = new B_SiteInfo(); B_Channel ChannelBll = new B_Channel(); M_Site SiteModel = SiteBll.GetSiteModel(); if (!SiteModel.IsStaticType) { return "fail$全站参数设置没有开启生成静态页面功能"; } B_Column columnBll = new B_Column(); M_Column columnModel = columnBll.GetColumn(int.Parse(colId)); M_Channel channelModel = ChannelBll.GetChannel(columnModel.ChId); if (channelModel == null || !channelModel.IsStaticType) { return "fail$所属频道没有开启生成静态页面功能"; } Session["newscolumnid"] = colId; return "succ$" + channelModel.ModelType; }
public string GetUpLoadPicPath(HtmlInputFile FilePicName, string FilePicPath, bool WaterMark, bool NewSize, int MaxWidth, int MaxHeight, bool BiLi, int BiLiValue, int FileSize) { string fileName = Path.GetFileName(FilePicName.PostedFile.FileName); string str2 = Path.GetExtension(FilePicName.PostedFile.FileName).ToString(); bool flag = false; if ((FileSize != 0) && (FilePicName.PostedFile.ContentLength > (FileSize * 0x400))) { HttpContext.Current.Response.Write("<script>alert('上传图片大小超出了限制');window.close();</script>"); HttpContext.Current.Response.End(); } B_SiteInfo info = new B_SiteInfo(); string imgUploadType = info.GetInfoModel().ImgUploadType; string[] strArray = imgUploadType.Split(new char[] { '|' }); for (int i = 0; i < strArray.Length; i++) { if (strArray[i].ToLower() == str2.ToLower()) { flag = true; break; } } if (!flag) { HttpContext.Current.Response.Write("<script>alert('上传图片格式只能够是:" + imgUploadType + "!');window.close();</script>"); HttpContext.Current.Response.End(); } M_Site siteModel = new M_Site(); siteModel = info.GetSiteModel(); if (NewSize) { return this.PicNewSize(FilePicName, FilePicPath, WaterMark, MaxWidth, MaxHeight, BiLi, BiLiValue); } if (WaterMark) { if (siteModel.IsImgWaterMark) { return this.PicWaterMark(FilePicName, FilePicPath, ""); } return this.LetterWaterMark(FilePicName, FilePicPath, ""); } return this.NotWaterMark_NotNewSize(FilePicName, FilePicPath); }
protected void Page_Load(object sender, EventArgs e) { userBll.CheckIsLogin(); userInfo = userBll.GetCookie(); M_Site siteModel = null; B_SiteInfo siteBll = new B_SiteInfo(); siteModel = siteBll.GetSiteModel(); int count = userBll.GetUserCateCount(userInfo.UserID); if (!string.IsNullOrEmpty(Request["UCId"])) { try { UCId = int.Parse(Request["UCId"]); } catch { } } if (count >= siteModel.UserClassCount && siteModel.UserClassCount != 0 && UCId <= 0) { Function.ShowMsg(0, "<li>您创建的专栏数已达到上限,请联系系统管理员</li><li><a href='javascript:history.back()'>返回上一级</a></li>"); return; } if (!IsPostBack) { if (UCId > 0) { ShowInfo(); } lbUserName.Text = userInfo.LogName; ltMsg.Text = ""; DataTable dt = InfoModelBll.GetList(); ddlCateType.DataTextField = "ModelName"; ddlCateType.DataValueField = "ModelId"; ddlCateType.DataSource = dt.DefaultView; ddlCateType.DataBind(); dt.Dispose(); } }
protected void Page_Load(object sender, EventArgs e) { IndexUrl = CreateBll.GetIndexUrl(); string logName = ""; string pwd = ""; string cookieType = ""; string valideCode = ""; if (Request.Form["txtUserName"] != null && Request.Form["txtPwd"] != null && Request.Form["rbCookie"] != null) { logName = Function.UrlDecode(Request.Form["txtUserName"].ToString()); //pwd = Function.MD5Encrypt(Request.Form["txtPwd"].ToString()); pwd = Request.Form["txtPwd"]; cookieType = Request.Form["rbCookie"].ToString(); } if (siteBll.GetSiteModel().IsLoginValidate) { if (Request.Form["txtValidateCode"] == null) { Function.ShowMsg(0, "<li>请输入验证码</li><li><a href='login.aspx'>重新登录</a></li><li><a href='" + IndexUrl + "'>返回网站首页</a></li>"); } else { valideCode = Request.Form["txtValidateCode"].ToString().ToLower(); } if (valideCode != Session["ValidateCode"].ToString()) { Function.ShowMsg(0, "<li>对不起,输入的验证码错误.请重新输入</li><li><a href='login.aspx'>重新登录</a></li><li><a href='" + IndexUrl + "'>返回网站首页</a></li>"); } } if ((!string.IsNullOrEmpty(logName)) && (!string.IsNullOrEmpty(pwd))) { B_SiteInfo siteInfo = new B_SiteInfo(); M_Site siteModel = siteInfo.GetSiteModel(); M_User model = userBll.GetUser(logName); if (model != null && siteModel != null) { //用户被锁定 if (model.IsLock == true) { Function.ShowMsg(0, "<li>对不起,您已经被锁定,不能登录.</li><li>如果您是新注册用户,您可能需要先激活帐号</li><li><a href='" + IndexUrl + "'>返回网站首页</a></li>"); } if (model.Status == 0) { Function.ShowMsg(0, "<li>对不起,您还未通过管理员认证,不能登录.</li><li><a href='" + IndexUrl + "'>返回网站首页</a></li>"); } //用户还在禁止登录时间内 if (model.ErrorTime > DateTime.Now) { Function.ShowMsg(0, "<li>对不起,您已经登录错误 " + siteModel.LogErrorNum + " 次,将被禁止登录 " + siteModel.DisabledLoginTime + " 分钟.</li><li><a href='" + IndexUrl + "'>返回网站首页</a></li>"); } else { //用户登录 bool flag = userBll.Login(logName, pwd); if (flag && (!string.IsNullOrEmpty(cookieType))) { HttpCookie cookie = new HttpCookie("User"); cookie["uId"] = model.UserID.ToString(); cookie["logN"] = Function.UrlEncode(model.LogName); cookie["pd"] = model.UserPwd; switch (cookieType) { case "onehour": cookie.Expires = DateTime.Now.AddHours(1); break; case "oneday": cookie.Expires = DateTime.Now.AddDays(1); break; case "oneweek": cookie.Expires = DateTime.Now.AddDays(7); break; case "onemounth": cookie.Expires = DateTime.Now.AddMonths(1); break; case "oneyear": cookie.Expires = DateTime.Now.AddYears(1); break; case "No": default: break; } cookie.Domain = WebConfigurationManager.AppSettings["KYCMS_CookieDomain"]; Response.Cookies.Add(cookie); string bbsCookieValue = bbsUserBll.GetUserCookie(Request.Form["txtUserName"],Request.Form["txtPwd"]); bbsUserBll.WriteUserCookie(bbsCookieValue); lbUserName.Text = logName; if (Request.UrlReferrer != null) { ReferUrl = Request.UrlReferrer.ToString(); } if (!string.IsNullOrEmpty(Request.QueryString["ReturnUrl"])) { ReferUrl = Request.QueryString["ReturnUrl"].ToString(); } //设置自动转向 HtmlMeta meta = new HtmlMeta(); meta.HttpEquiv = "Refresh"; meta.Content = "3;url=" + Server.UrlDecode(ReferUrl); Header.Controls.Add(meta); hyMain.NavigateUrl = "Main.aspx"; hyRefer.NavigateUrl = ReferUrl; hyRefer.Text = ReferUrl; hyIndex.NavigateUrl = IndexUrl; //更新登录信息 string lastLoginIP = string.Empty; if(Request.UserHostAddress!=null) { lastLoginIP = Request.UserHostAddress; } DateTime currLoginTime = DateTime.Now; DateTime oldLoginTime = model.LastLoginTime; userBll.LoginSuccess(model.UserID, lastLoginIP, currLoginTime); if (oldLoginTime.Date != currLoginTime.Date) { B_Money moneyBll = new B_Money(); moneyBll.Integral(siteModel.LoginScore, model.UserID); } } //登录失败 //检查错误次数,如果达到设定次数, //则更新禁止登录时间 else { //修改时间 if (model.ErrorNum >= (siteModel.LogErrorNum - 1)) { DateTime errorTime = DateTime.Now.AddMinutes(siteModel.DisabledLoginTime); userBll.LoginFailOnErrorNum(model.UserID, errorTime); Function.ShowMsg(0, "<li>对不起,您已经登录错误 " + siteModel.LogErrorNum + " 次,将被禁止登录 " + siteModel.DisabledLoginTime + " 分钟.</li><li><a href='" + IndexUrl + "'>返回网站首页</a></li>"); } // 修改次数 else { userBll.LoginFailError(model.UserID); Function.ShowMsg(0, "<li>对不起,登录失败!请检查您的用户名和密码.</li><li><a href='Login.aspx'>重新登录</a>(您还有" + (siteModel.LogErrorNum - model.ErrorNum) + "次机会)</li><li><a href='" + IndexUrl + "'>返回网站首页</a></li>"); } } } } //用户不存在 else { Function.ShowMsg(0,"<li>对不起,此用户不存在</li><li><a href='Reg.aspx'>注册新用户</a></li><li><a href='Login.aspx'>重新登录</a></li>"); } } //post过来的数据不合法 else { Response.Redirect("Login.aspx"); } }
protected void Page_Load(object sender, EventArgs e) { Response.Cache.SetNoStore(); if (!string.IsNullOrEmpty(Request.QueryString["ColorId"])) { ColorId = Convert.ToInt32(Request.QueryString["ColorId"]); } if (!string.IsNullOrEmpty(Request.QueryString["UserName"])) { UserName = Request.QueryString["UserName"]; } UserModel = UserBll.GetUser(UserName); if (UserModel == null) { Function.ShowMsg(0, "<li>用户空间参数错误</li><li><a href='javascript:history.back();'>返回上一级</a></li>"); } UserInfoDr = UserBll.GetUserAllInfo(UserModel.UserID); if(UserInfoDr==null) { Function.ShowMsg(0, "<li>用户空间参数错误</li><li><a href='javascript:history.back();'>返回上一级</a></li>"); } int spaceTypeId = int.Parse(UserInfoDr["spacetypeid"].ToString()); if (spaceTypeId != 1) Function.ShowMsg(0, "<li>用户空间参数错误</li><li><a href='javascript:history.back();'>返回上一级</a></li>"); B_UserSpace.IsActive(UserModel.UserID, 2); UserGroupModel = UserGroupBll.GetModel(UserModel.GroupID); GroupName = UserGroupModel.UserGroupName; if (Request.Cookies["SpacePwd"] != null) { if (Request.Cookies["SpacePwd"]["UserId"] != UserModel.UserID.ToString()) { Response.Cookies["SpacePwd"].Expires = DateTime.Now.AddDays(-1); } } SpaceModel = SpaceBll.GetUserSpaceById(UserModel.UserID); if (SpaceModel.TemplateId >= 18 && SpaceModel.TemplateId <= 24) StyleCss = "<link rel='stylesheet' type='text/css' href='skin/Space" + SpaceModel.TemplateId + ".css' />"; else StyleCss = "<link rel='stylesheet' type='text/css' href='skin/Space18.css' />"; SpaceName = SpaceModel.SpaceName; if (!IsPostBack) { SpacePrevPower(); B_SiteInfo siteInfo = new B_SiteInfo(); M_Site siteModel = siteInfo.GetSiteModel(); lbCopyRight.Text = siteModel.CopyRight; repMyInfoBind(); repMessageBind(); repFriendBind(); repAlbum(); } AjaxPro.Utility.RegisterTypeForAjax(typeof(userspace_SpaceTemplate)); }
protected void Page_Load(object sender, EventArgs e) { Response.Cache.SetNoStore(); bool reviewIsCheck = false; B_Review bll = new B_Review(); B_SiteInfo SiteBll = new B_SiteInfo(); B_User bllUser = new B_User(); M_Review model = new M_Review(); M_User userModel = null; if (Request.Form["txtIsLogin"] == "False") { if (Request.Form["btnSubmit"] == "登录") { bool flaglogin = true; string msgBox = string.Empty; if (Request.Form["UserName"].ToString().Trim() == "") { flaglogin = false; msgBox = "<script>alert('用户名必须填写');window.location.href('" + Request.UrlReferrer.ToString() + "');</script>"; } else if (Request.Form["userPwd"].ToString().Trim() == "") { flaglogin = false; msgBox = "<script>alert('密码必须填写');window.location.href('" + Request.UrlReferrer.ToString() + "');</script>"; } if (flaglogin) { ltMsg.Text = ""; string logName = ""; string pwd = ""; string cookieType = ""; logName = Function.UrlDecode(Request.Form["UserName"].ToString()); pwd = Function.MD5Encrypt(Request.Form["userPwd"].ToString()); cookieType = "No"; if ((!string.IsNullOrEmpty(logName)) && (!string.IsNullOrEmpty(pwd))) { B_SiteInfo siteInfo = new B_SiteInfo(); M_Site siteModel = siteInfo.GetSiteModel(); M_User modelLogin = bllUser.GetUser(logName); if (modelLogin != null && siteModel != null) { //用户登录 bool flag = bllUser.Login(logName, pwd); if (flag && (!string.IsNullOrEmpty(cookieType))) { HttpCookie cookie = new HttpCookie("User"); cookie["uId"] = modelLogin.UserID.ToString(); cookie["logN"] = modelLogin.LogName; cookie["pd"] = modelLogin.UserPwd; switch (cookieType) { case "onehour": cookie.Expires = DateTime.Now.AddHours(1); break; case "oneday": cookie.Expires = DateTime.Now.AddDays(1); break; case "oneweek": cookie.Expires = DateTime.Now.AddDays(7); break; case "onemounth": cookie.Expires = DateTime.Now.AddMonths(1); break; case "oneyear": cookie.Expires = DateTime.Now.AddYears(1); break; case "No": default: break; } Response.Cookies.Add(cookie); string lastLoginIP = string.Empty; if (Request.UserHostAddress != null) { lastLoginIP = Request.UserHostAddress; } DateTime currLoginTime = DateTime.Now; DateTime oldLoginTime = modelLogin.LastLoginTime; bllUser.LoginSuccess(modelLogin.UserID, lastLoginIP, currLoginTime); if (oldLoginTime.Date != currLoginTime.Date) { B_Money moneyBll = new B_Money(); moneyBll.Integral(siteModel.LoginScore, modelLogin.UserID); } msgBox = "<script>alert('登录成功');window.location.href('" + Request.UrlReferrer.ToString() + "');</script>"; } else { msgBox = "<script>alert('登录失败');window.location.href('" + Request.UrlReferrer.ToString() + "');</script>"; } } else { msgBox = "<script>alert('登录失败');window.location.href('" + Request.UrlReferrer.ToString() + "');</script>"; } } } ltMsg.Text = msgBox; } else { if (Request.Form["hidNoName"].ToString() == "False") { ltMsg.Text = "<script>alert('本系统设置了不允许匿名评论,请先登录');window.location.href('" + Request.UrlReferrer.ToString() + "');</script>"; } else { //根据栏目的设置,对论评论审核进行初始化 if (Request.Form["hidColCommentSet"].ToString() == "True") reviewIsCheck = false; else reviewIsCheck = true; string validateCode = string.Empty; string flag = Request.Form["hidValidate"]; if (flag == "True") { if (Session["ValidateCode"] == null) { Response.Write("<script language='javascript'>alert('你在登陆页面停留的时间过长,验证码已经失效');window.history.back();</script>"); Response.End(); } //验证码错误 validateCode = Session["ValidateCode"].ToString().ToLower(); if (validateCode.ToLower() != Request.Form["txtValidate"].ToString().Trim().ToLower()) { Response.Write("<script language='javascript'>alert('验证码错误');window.history.back();</script>"); Response.End(); } } if (bllUser.IsLogin()) { M_User loginUserModel = bllUser.GetCookie(); userModel = bllUser.GetUser(loginUserModel.LogName); } model.ModelType = int.Parse(Request.Form["hidModeType"].ToString()); model.InfoId = Request.Form["hidNewsId"].ToString(); if (Request.Form["hidUserGroupViewIsCheck"] == "True" && bllUser.IsLogin()) reviewIsCheck = true; model.IsCheck = reviewIsCheck; model.ReviewTitle = ""; //评论标题 model.IsArgue = false; model.IsSquare = 3; model.BrarNum = 0; model.FightNum = 0; model.IsElite = false; model.ReviewContent = SiteBll.GetFiltering(Request.Form["txtContent"].ToString()); //评论内容 model.ReviewTime = DateTime.Now; //评论时间 if (bllUser.IsLogin()) //是否是登录用户 model.UserNum = userModel.UserID.ToString(); else model.UserNum = "0"; model.ReviewIP = Request.UserHostAddress; //评论用户的IP if (bll.Add(model)) { if (!reviewIsCheck) ltMsg.Text = "<script>alert('评论成功,将在审核后显示出来');window.location.href('" + Request.UrlReferrer.ToString() + "');</script>"; else ltMsg.Text = "<script>window.location.href('" + Request.UrlReferrer.ToString() + "');</script>"; } } } } else { if (Request.Form["hidNoName"].ToString() == "False") { ltMsg.Text = "<script>alert('本系统设置了不允许匿名评论,请先登录');window.location.href('" + Request.UrlReferrer.ToString() + "');</script>"; } else { //根据栏目的设置,对论评论审核进行初始化 if (Request.Form["hidColCommentSet"].ToString() == "True") reviewIsCheck = false; else reviewIsCheck = true; string validateCode = string.Empty; string flag = Request.Form["hidValidate"]; if (flag == "True") { if (Session["ValidateCode"] == null) { Response.Write("<script language='javascript'>alert('你在登陆页面停留的时间过长,验证码已经失效');window.history.back();</script>"); Response.End(); } //验证码错误 validateCode = Session["ValidateCode"].ToString().ToLower(); if (validateCode.ToLower() != Request.Form["txtValidate"].ToString().Trim().ToLower()) { Response.Write("<script language='javascript'>alert('验证码错误');window.history.back();</script>"); Response.End(); } } if (bllUser.IsLogin()) { M_User loginUserModel = bllUser.GetCookie(); userModel = bllUser.GetUser(loginUserModel.LogName); } model.ModelType = int.Parse(Request.Form["hidModeType"].ToString()); model.InfoId = Request.Form["hidNewsId"].ToString(); if (Request.Form["hidUserGroupViewIsCheck"] == "True" && bllUser.IsLogin()) reviewIsCheck = true; model.IsCheck = reviewIsCheck; model.ReviewTitle = ""; //评论标题 model.IsArgue = false; model.IsSquare = 3; model.BrarNum = 0; model.FightNum = 0; model.IsElite = false; model.ReviewContent = SiteBll.GetFiltering(Request.Form["txtContent"].ToString()); //评论内容 model.ReviewTime = DateTime.Now; //评论时间 if (bllUser.IsLogin()) //是否是登录用户 model.UserNum = userModel.UserID.ToString(); else model.UserNum = "0"; model.ReviewIP = Request.UserHostAddress; //评论用户的IP if (bll.Add(model)) { if (!reviewIsCheck) ltMsg.Text = "<script>alert('评论成功,将在审核后显示出来');window.location.href('" + Request.UrlReferrer.ToString() + "');</script>"; else ltMsg.Text = "<script>window.location.href('" + Request.UrlReferrer.ToString() + "');</script>"; } } } }
protected void btnLogin_Click(object sender, EventArgs e) { string valideCode = ""; lbMsg.Text = ""; if (Request.Form["txtUserName"] != null && Request.Form["txtPwd"] != null) { logName = Function.UrlDecode(Request.Form["txtUserName"].ToString()); pwd = Function.MD5Encrypt(Request.Form["txtPwd"].ToString()); } if (siteBll.GetSiteModel().IsLoginValidate) { if (Request.Form["txtValidateCode"] == null) { lbMsg.Text = "<script>alert('请输入验证码')</script>"; return; } else { valideCode = Request.Form["txtValidateCode"].ToString().ToLower(); } if (Session["ValidateCode"] != null) { if (valideCode != Session["ValidateCode"].ToString()) { lbMsg.Text = "<script>alert('对不起,输入的验证码错误.请重新输入');</script>"; imgCode.ImageUrl = "~/common/Code.aspx"; } } else { lbMsg.Text = "<script>alert('对不起,您在本页停留时间太长,请退出');hiddenIframe();</script>"; } } B_SiteInfo siteInfo = new B_SiteInfo(); M_Site siteModel = siteInfo.GetSiteModel(); M_User model = userBll.GetUser(logName); if (model != null && siteModel != null) { //用户被锁定 if (model.IsLock == true) { lbMsg.Text = "<script>alert('对不起,您已经被锁定,不能登录.')</script>"; return; } //用户还在禁止登录时间内 if (model.ErrorTime > DateTime.Now) { lbMsg.Text = "<script>alert('对不起,您已经登录错误 " + siteModel.LogErrorNum + " 次,将被禁止登录 " + siteModel.DisabledLoginTime + " 分钟.')</script>"; return; } else { //用户登录 bool flag = userBll.Login(logName, pwd); if (flag) { HttpCookie cookie = new HttpCookie("User"); cookie["uId"] = model.UserID.ToString(); cookie["logN"] = model.LogName; cookie["pd"] = model.UserPwd; //cookie过期时间20分钟 cookie.Expires = DateTime.Now.AddMinutes(20); Response.Cookies.Add(cookie); //更新登录信息 string lastLoginIP = string.Empty; if (Request.UserHostAddress != null) { lastLoginIP = Request.UserHostAddress; } DateTime currLoginTime = DateTime.Now; DateTime oldLoginTime = model.LastLoginTime; userBll.LoginSuccess(model.UserID, lastLoginIP, currLoginTime); if (currLoginTime.Date != oldLoginTime.Date) { B_Money moneyBll = new B_Money(); moneyBll.Integral(siteModel.LoginScore, model.UserID); } //lbMsg.Text = "<script>hiddenIframe();parent.divLoginInfo.innerHTML=\"" + userBll.GetCookie().LogName + " 您好!┆<a href='../user/main.aspx' target='_blank' target='_blank'>发表文章</a>┆<a href='SignOut.aspx'>安全退出</a>\";</script>"; lbMsg.Text = "<script>hiddenIframe();parent.location.reload()</script>"; } //登录失败 //检查错误次数,如果达到设定次数, //则更新禁止登录时间 else { //修改时间 if (model.ErrorNum >= (siteModel.LogErrorNum - 1)) { DateTime errorTime = DateTime.Now.AddMinutes(siteModel.DisabledLoginTime); userBll.LoginFailOnErrorNum(model.UserID, errorTime); lbMsg.Text = "<script>alert('对不起,您已经登录错误 " + siteModel.LogErrorNum + " 次,将被禁止登录 " + siteModel.DisabledLoginTime + " 分钟.')</script>"; return; } // 修改次数 else { userBll.LoginFailError(model.UserID); lbMsg.Text = "<script>alert('对不起,登录失败!请检查您的用户名和密码.')</script>"; return; } } } } //用户不存在 else { lbMsg.Text = "<script>alert('对不起,此用户不存在')</script>"; return; } }
public string PicWaterMark(HtmlInputFile FilePicName, string FilePicPath, string UpLoadPicPath) { B_SiteInfo info = new B_SiteInfo(); M_Site siteModel = new M_Site(); siteModel = info.GetSiteModel(); string[] strArray = siteModel.WaterMarkHW.Split(new char[] { '|' }); string path = Param.ApplicationRootPath + siteModel.WaterMarkPath; int srcHeight = int.Parse(strArray[0]); int srcWidth = int.Parse(strArray[1]); int waterMarkLight = siteModel.WaterMarkLight; int waterMarkPos = siteModel.WaterMarkPos; string str2 = ""; if (UpLoadPicPath == "") { str2 = this.NotWaterMark_NotNewSize(FilePicName, FilePicPath); } else { str2 = UpLoadPicPath; } string str3 = HttpContext.Current.Server.MapPath(FilePicPath) + str2; string[] strArray2 = str2.Split(new char[] { '/' }); string[] strArray3 = strArray2[1].Split(new char[] { '.' }); string destFileName = HttpContext.Current.Server.MapPath(FilePicPath) + strArray2[0] + strArray3[0] + "_1" + strArray3[1]; if (File.Exists(str3)) { File.Copy(str3, destFileName); } Image image = Image.FromFile(destFileName); Image image2 = Image.FromFile(HttpContext.Current.Server.MapPath(path)); float[][] numArray = new float[5][]; float[] numArray2 = new float[5]; numArray2[0] = 1f; numArray[0] = numArray2; float[] numArray3 = new float[5]; numArray3[1] = 1f; numArray[1] = numArray3; float[] numArray4 = new float[5]; numArray4[2] = 1f; numArray[2] = numArray4; float[] numArray5 = new float[5]; numArray5[3] = ((float) waterMarkLight) / 100f; numArray[3] = numArray5; float[] numArray6 = new float[5]; numArray6[4] = 1f; numArray[4] = numArray6; float[][] newColorMatrix = numArray; ColorMatrix matrix = new ColorMatrix(newColorMatrix); ImageAttributes imageAttr = new ImageAttributes(); imageAttr.SetColorMatrix(matrix, ColorMatrixFlag.Default, ColorAdjustType.Bitmap); Graphics graphics = Graphics.FromImage(image); switch (waterMarkPos) { case 1: graphics.DrawImage(image2, new Rectangle(0, 0, srcWidth, srcHeight), 0, 0, srcWidth, srcHeight, GraphicsUnit.Pixel, imageAttr); break; case 2: graphics.DrawImage(image2, new Rectangle(image.Width - srcWidth, 0, srcWidth, srcHeight), 0, 0, srcWidth, srcHeight, GraphicsUnit.Pixel, imageAttr); break; case 3: graphics.DrawImage(image2, new Rectangle(image.Width - srcWidth, image.Height - srcHeight, srcWidth, srcHeight), 0, 0, srcWidth, srcHeight, GraphicsUnit.Pixel, imageAttr); break; case 4: graphics.DrawImage(image2, new Rectangle(0, image.Height - srcHeight, srcWidth, srcHeight), 0, 0, srcWidth, srcHeight, GraphicsUnit.Pixel, imageAttr); break; } graphics.Dispose(); image.Save(str3); image.Dispose(); if (File.Exists(destFileName)) { File.Delete(destFileName); } return str2; }
public string PicNewSize(HtmlInputFile FilePicName, string FilePicPath, bool WaterMark, int MaxWidth, int MaxHeight, bool BiLi, int BiLiValue) { Size size; string upLoadPicPath = this.NotWaterMark_NotNewSize(FilePicName, FilePicPath); string path = HttpContext.Current.Server.MapPath(FilePicPath) + upLoadPicPath; string[] strArray = upLoadPicPath.Split(new char[] { '/' }); string[] strArray2 = strArray[1].Split(new char[] { '.' }); string destFileName = HttpContext.Current.Server.MapPath(FilePicPath) + strArray[0] + strArray2[0] + "_1" + strArray2[1]; if (File.Exists(path)) { File.Copy(path, destFileName); } Image image = Image.FromFile(destFileName); if (BiLi) { size = NewSize((image.Width * BiLiValue) / 100, (image.Height * BiLiValue) / 100, image.Width, image.Height); } else { size = NewSize(MaxWidth, MaxHeight, image.Width, image.Height); } Bitmap bitmap = new Bitmap(size.Width, size.Height); Graphics graphics = Graphics.FromImage(bitmap); graphics.CompositingQuality = CompositingQuality.HighQuality; graphics.SmoothingMode = SmoothingMode.HighQuality; graphics.InterpolationMode = InterpolationMode.HighQualityBicubic; graphics.DrawImage(image, new Rectangle(0, 0, size.Width, size.Height), 0, 0, image.Width, image.Height, GraphicsUnit.Pixel); graphics.Dispose(); bitmap.Save(path); bitmap.Dispose(); image.Dispose(); if (File.Exists(destFileName)) { File.Delete(destFileName); } B_SiteInfo info = new B_SiteInfo(); M_Site siteModel = new M_Site(); siteModel = info.GetSiteModel(); if (!WaterMark) { return upLoadPicPath; } if (siteModel.IsImgWaterMark) { return this.PicWaterMark(FilePicName, FilePicPath, upLoadPicPath); } return this.LetterWaterMark(FilePicName, FilePicPath, upLoadPicPath); }