<%@ Page language="c#" Codebehind="Login.aspx.cs" AutoEventWireup="false" Inherits="HyeyBussiness.MemberServices.NewLogin" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <HTML> <HEAD> <title>会员登录</title> <meta name="GENERATOR" content="Microsoft Visual Studio .NET 7.1"> <meta name="CODE_LANGUAGE" content="C#"> <meta name="vs_defaultClientScript" content="JavaScript"> <meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5"> <LINK rel="stylesheet" type="text/css" href="NewLogin/css/Newlogin.css"> <script type="text/javascript" src="NewLogin/js/jquery-1.3.2.min.js"></script> <script type="text/javascript" src="NewLogin/js/jquery-1.3.2-vsdoc.js"></script> <script language="javascript"> //login function CheckLogin() { if(document.all("TxtUser").value=="") { alert("请输入用户名!"); document.all("TxtUser").focus(); return false; } else { if( CheckUserName(document.all("TxtUser").value)==false ) { alert("用户名必须是字母数字和下滑线"); return false; } } if(document.all("TxtPass").value=="") { alert("请输入密码!"); document.all("TxtPass").focus(); return false; } } //clear text function Cleartext() { document.all("TxtUser").value = ""; document.all("TxtPass").value = ""; document.all("txtValidte").value = ""; } //check username function CheckUserName( str ) { var reg = /^\w+$/ ; return Check( reg, str); } //check function Check( reg, str ) { if( reg.test( str ) ) { return true; } return false; } function change(img) { //var img =document.getElementById("CodeImg"); img.src=img.src+"?"+new Date; } //回车 function CheckGo() { if(window.event.keyCode == '13') { $("#<%=ButtnLogin.ClientID %>").click(); event.keyCode=0; event.returnValue=false; } } </script> </HEAD> <body onload="javascript:document.all('TxtUser').focus();" MS_POSITIONING="FlowLayout"> <form style="TEXT-ALIGN: center" id="Form1" method="post" runat="server"> <div style="DISPLAY: none"> <OBJECT id="MyActiveY" name="MyActiveY" classid="clsid:5026F394-8B92-477F-A078-8A1BD56F96F2" VIEWASTEXT> <PARAM NAME="_ExtentX" VALUE="10795"> <PARAM NAME="_ExtentY" VALUE="1640"> </OBJECT> </div> <div id="top"> <ul> <li> <A href="/index.html" target="_blank"><IMG border="0" src="NewLogin/images/logo.gif"></A> </li> <li style="FLOAT: right; PADDING-TOP: 50px"> 如遇注册问题请拨打0558-8611768 </li> </ul> </div> <div class="clear"></div> <div class="zc"> <div class="zc1"> <div class="t"><strong><A style="COLOR: #ea5712" href="#" target="_blank">华源产品促销</A></strong></div> <div class="c"> <table border="0" cellSpacing="4" cellPadding="0" width="100%"> <tr> <asp:repeater id="repUrlOne" Runat="server"> <ItemTemplate> <td align="center"><a href='/ProductPromotions/Details.aspx?id=<%# DataBinder.Eval(Container.DataItem,"id")%>' target="_blank"> <img src='<%# DataBinder.Eval(Container.DataItem,"img")%>' width="150px" height="106px" style="border:0px;" /></a></td> </ItemTemplate> </asp:repeater></tr> <tr> <asp:repeater id="repNameOne" Runat="server"> <ItemTemplate> <td height="20" align="center" bgcolor="#dcdcdc"><a href='/ProductPromotions/Details.aspx?id=<%# DataBinder.Eval(Container.DataItem,"id")%>' target="_blank"> <%# DataBinder.Eval(Container.DataItem,"ypmc")%> </a> </td> </ItemTemplate> </asp:repeater></tr> </table> <table border="0" cellSpacing="4" cellPadding="0" width="100%"> <tr> <asp:repeater id="repUrlTwo" Runat="server"> <ItemTemplate> <td align="center"><a href='/ProductPromotions/Details.aspx?id=<%# DataBinder.Eval(Container.DataItem,"id")%>' target="_blank"> <img src='<%# DataBinder.Eval(Container.DataItem,"img")%>' width="150px" height="106px" style="border:0px;" /></a></td> </ItemTemplate> </asp:repeater></tr> <tr> <asp:repeater id="repNameTwo" Runat="server"> <ItemTemplate> <td height="20" align="center" bgcolor="#dcdcdc"><a href='/ProductPromotions/Details.aspx?id=<%# DataBinder.Eval(Container.DataItem,"id")%>' target="_blank"> <%# DataBinder.Eval(Container.DataItem,"ypmc")%> </a> </td> </ItemTemplate> </asp:repeater></tr> </table> <table border="0" cellSpacing="4" cellPadding="0" width="100%"> <tr> <asp:repeater id="repUrlThree" Runat="server"> <ItemTemplate> <td align="center"><a href='/ProductPromotions/Details.aspx?id=<%# DataBinder.Eval(Container.DataItem,"id")%>' target="_blank"> <img src='<%# DataBinder.Eval(Container.DataItem,"img")%>' width="150px" height="106px" style="border:0px;" /></a></td> </ItemTemplate> </asp:repeater></tr> <tr> <asp:repeater id="repNameThree" Runat="server"> <ItemTemplate> <td height="20" align="center" bgcolor="#dcdcdc"><a href='/ProductPromotions/Details.aspx?id=<%# DataBinder.Eval(Container.DataItem,"id")%>' target="_blank"> <%# DataBinder.Eval(Container.DataItem,"ypmc")%> </a> </td> </ItemTemplate> </asp:repeater></tr> </table> </div> </div> <div class="zc2"> <h1>华源网会员登录</h1> <h4>请输入会员名和密码,按“登录”即可</h4> <div class="pwd">会员名:<asp:textbox id="TxtUser" tabIndex="1" Runat="server" BorderStyle="Groove" MaxLength="20" Width="120px" Height="22px" onkeydown="CheckGo();"></asp:textbox></div> <div class="pwd">密 码:<asp:textbox id="TxtPass" tabIndex="2" Runat="server" BorderStyle="Groove" MaxLength="20" Width="120px" Height="22px" TextMode="Password" onkeydown="CheckGo();" ></asp:textbox></div> <div class="pwdma">验证码:<asp:textbox id="txtValidte" tabIndex="3" Runat="server" MaxLength="10" Width="70px" Height="22px" CssClass="cssText" onkeydown="CheckGo();"></asp:textbox> <img style="CURSOR: pointer" id="CodeImg" class=".imgvalid" title="看不清楚?换一张" onclick="javascript:change(this);" name="CodeImg" alt="点击获取验证码" align="middle" src="MyCheckCode.aspx" width="60" height="25"> </div> <div style="TEXT-ALIGN: center; PADDING-TOP: 20px"> <asp:imagebutton id="ButtnLogin" Runat="server" CssClass="imagebtn" ImageUrl="NewLogin/images/dl.gif"></asp:imagebutton> <asp:imagebutton id="imgCancel" Runat="server" CssClass="imagebtn" ImageUrl="NewLogin/images/cz.gif"></asp:imagebutton></div> <div style="FLOAT: right; MARGIN-RIGHT: 20px; PADDING-TOP: 10px"><A href="/getPassword/" target="_blank">忘记密码</A>?</div> <div style="HEIGHT: 33px; CLEAR: both"></div> <div class="kk">如果您还不是会员?请立即<A style="COLOR: #ff0000" href="/bussiness/register_step1.aspx" target="_self">免费注册</A><br> <A href="/bussiness/Register_step1.aspx" target="_blank"><IMG src="NewLogin/images/zc.gif"></A></div> <table border="0" cellSpacing="5" cellPadding="5" width="100%"> <tr> <td bgColor="#efefef" align="center"><strong><a href="http://www.hyey.com/data/zuixin/" target="_blank">信息情报</a></strong></td> <td bgColor="#efefef" align="center"><strong><a href="http://www.hyey.com/infos/exhibit/" target="_blank">网上展厅</a></strong></td> </tr> <tr> <td bgColor="#efefef" align="center"><strong><a href="http://www.hyey.com/mymed/public/pircechange.aspx" target="_blank">今日涨跌</a></strong></td> <td bgColor="#efefef" align="center"><strong><a href="http://www.hyey.com/mymed/public/salesorder.aspx" target="_blank">销售排行</a></strong></td> </tr> <tr> <td bgColor="#efefef" align="center"><strong><a href="http://www.hyey.com/mymed/public/goodstrans.aspx" target="_blank">物流配送</a></strong></td> <td bgColor="#efefef" align="center"><strong><a href="http://www.hyey.com/mymed/public/newdrug.aspx" target="_blank">上柜新品</a></strong></td> </tr> <tr> <td bgColor="#efefef" align="center"><strong><a href="http://www.hyey.com/memberservices/OfficeHelp/Litigate.aspx" target="_blank">投诉管理</a></strong></td> <td bgColor="#efefef" align="center"><strong><a href="http://www.hyey.com/memberservices/OfficeHelp/MailInfo.aspx" target="_blank">信件查询</a></strong></td> </tr> </table> </div> </div> <div class="clear"></div> <div class="gg"><IMG style="FLOAT: left" align="absMiddle" src="NewLogin/images/gg.gif"> <MARQUEE onmouseover="this.stop();" onmouseout="this.start();" width="850" scrollAmount="3"><asp:literal id="litOne" Runat="server">必须重申:香港是个法治社会,法律是民主的边界。香港是在「一国」前提下实行原有的资本主义社会经济制度和生活方式。 因此,香港就是「鸟笼政治」。「一国」是「笼」,「港人治港」是「鸟」;法律是「笼」,民主是「鸟」。「鸟」只能在「笼」中飞。想破「笼」把香港脱离「一国」成为独立政治实体?绝不可能!请反对派在政改争拗中记住这一点!</asp:literal></MARQUEE> </div> <div class="bottom">华源网版权所有 © 2009</div> <INPUT style="Z-INDEX: 101; POSITION: absolute; TOP: 736px; LEFT: 240px" id="MacAddress" type="hidden" name="Hidden1" runat="server"><INPUT style="Z-INDEX: 102; POSITION: absolute; TOP: 736px; LEFT: 48px" id="IsNoteBook" type="hidden" name="Hidden2" runat="server"> </form> <div id="divLogin" runat="server"></div> <script type="text/javascript"> try { var data; data = document.getElementById("MyActiveY").GetMacaddress(); document.getElementById("MacAddress").value = data; data = document.getElementById("MyActiveY").IsNetBook(); document.getElementById("IsNoteBook").value = data; } catch(e) {} </script> </body> </HTML>
后台cs:
using System; using System.Collections; using System.ComponentModel; using System.Data; using System.Drawing; using System.Web; using System.Web.SessionState; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.HtmlControls; using Microsoft.ApplicationBlocks.Data; using GotDotNet.ApplicationBlocks.Data; using System.Data.SqlClient; using HyeyClass.Web; using System.Text; using System.Net; namespace HyeyBussiness.MemberServices { #region Class /// <summary> /// ClassName:New Login /// Auther:Hyey.wl /// Time:2010-04-30 /// NewLogin 的摘要说明。 /// </summary> public class NewLogin : System.Web.UI.Page { #region init protected System.Web.UI.WebControls.Repeater repUrlOne; protected System.Web.UI.WebControls.Repeater repNameOne; protected System.Web.UI.WebControls.Repeater repUrlTwo; protected System.Web.UI.WebControls.Repeater repNameTwo; protected System.Web.UI.WebControls.Repeater repUrlThree; protected System.Web.UI.WebControls.Repeater repNameThree; protected System.Web.UI.WebControls.Repeater repProducts; protected System.Web.UI.WebControls.Literal litOne; protected System.Web.UI.WebControls.ImageButton ButtnLogin; protected System.Web.UI.WebControls.TextBox TxtUser; protected System.Web.UI.WebControls.TextBox TxtPass; protected System.Web.UI.HtmlControls.HtmlInputHidden MacAddress; protected System.Web.UI.HtmlControls.HtmlInputHidden IsNoteBook; protected System.Web.UI.HtmlControls.HtmlGenericControl divLogin; protected System.Web.UI.WebControls.TextBox txtValidte; private static readonly string connString = ConfigHelper.GetConfigString("SqlServerConnectionString"); protected System.Web.UI.HtmlControls.HtmlImage mybt; protected System.Web.UI.WebControls.ImageButton imgCancel; protected HttpCookie LoginCookie; #endregion #region Page Load private void Page_Load(object sender, System.EventArgs e) { // 在此处放置用户代码以初始化页面 if(Page.IsPostBack == false) { LoginCookie = new HttpCookie("LogNum"); LoginCookie.Value = "1"; LoginCookie.Expires = DateTime.Now.AddMinutes(30.0); //if(Int32.Parse(Request.Cookies["LogNum"].Value.ToString())<2) //{ Response.Cookies.Add(LoginCookie); //} string strWhere = this.Org_where; string info = string.Empty; DataSet ds = GetListProducts(12 ,strWhere,out info); LoadDataDrugPic(ds); this.litOne.Text = info; } this.ButtnLogin.Attributes.Add("onclick","javascript:return CheckLogin();"); this.imgCancel.Attributes.Add("onclick","javascript:Cleartext();"); } #endregion #region Web 窗体设计器生成的代码 override protected void OnInit(EventArgs e) { // // CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。 // InitializeComponent(); base.OnInit(e); } /// <summary> /// 设计器支持所需的方法 - 不要使用代码编辑器修改 /// 此方法的内容。 /// </summary> private void InitializeComponent() { this.ButtnLogin.Click += new System.Web.UI.ImageClickEventHandler(this.ButtnLogin_Click); this.Load += new System.EventHandler(this.Page_Load); } #endregion #region -----------------------where---------------------- /// <summary> /// Gets or sets the org_where. /// </summary> /// <value>The org_where.</value> string Org_where { get { if (ViewState["where"] == null || ViewState["where"].ToString() == String.Empty) { System.Text.StringBuilder mySB = new System.Text.StringBuilder(); mySB.Append(" 1=1 AND InsertDate IN (SELECT MAX(InsertDate) AS InsertDate "); mySB.Append(" FROM ReleaseDrugs GROUP BY UserID ) AND UserName NOT IN ( SELECT boss FROM Csales WHERE ViewFlag ='1') "); mySB.Append(" UNION ALL (SELECT ReleaseDrugs.* FROM ReleaseDrugs LEFT OUTER JOIN Csales ON "); mySB.Append(" ReleaseDrugs.YPMC = Csales.YPMC AND ReleaseDrugs.CDMC = Csales.CDMC AND ReleaseDrugs.GG = Csales.GG WHERE Csales.ViewFlag ='1') "); ViewState["where"] = mySB.ToString().Trim(); //ViewState["where"] = " 1=1 AND InsertDate IN (SELECT MAX(InsertDate) AS InsertDate FROM ReleaseDrugs GROUP BY UserID ) "; // 1=1 and id IN ( select max(id) AS ID from ReleaseDrugs group by UserID ) } return ViewState["where"].ToString(); } set { ViewState["where"] = value; } } #endregion #region -----------------------getData---------------------- /// <summary> /// Gets the list products. /// </summary> /// <param name="top">The top.</param> /// <param name="strWhere">The STR where.</param> /// <param name="DrugsPromtionsInfo">The drugs promtions info.</param> /// <returns></returns> public DataSet GetListProducts(int top,string strWhere ,out string DrugsPromtionsInfo) { DrugsPromtionsInfo = string.Empty; DataSet myDS = null; StringBuilder strSql=new StringBuilder(); strSql.Append("SELECT ROW_NUMBER() OVER(ORDER BY id DESC) AS RowNumber,* FROM ( SELECT TOP "+top.ToString()+" * FROM ( SELECT * FROM ReleaseDrugs "); if(strWhere.Trim()!="") { strSql.Append(" where "+strWhere ); strSql.Append(" ) AS C ORDER BY NEWID() ) AS E "); myDS = SqlHelper.ExecuteDataset(connString, CommandType.Text, strSql.ToString()); } if(myDS != null && myDS.Tables[0].Rows.Count > 0) { System.Text.StringBuilder mySB = new System.Text.StringBuilder(); foreach(DataRow dr in myDS.Tables[0].Rows) { string myYPMC = dr["Ypmc"].ToString(); string myCdmc = dr["Cdmc"].ToString(); string myGG = dr["GG"].ToString(); string myUserID = dr["UserID"].ToString(); DataSet MyDatas = GetInitDataCsaInfo(myYPMC,myCdmc,myGG,myUserID); if(MyDatas != null && MyDatas.Tables[0].Rows.Count > 0) { mySB.Append(" "); mySB.Append(MyDatas.Tables[0].Rows[0]["Title"].ToString()); mySB.Append("--"); mySB.Append(MyDatas.Tables[0].Rows[0]["Detail"].ToString()); mySB.Append(" "); } } DrugsPromtionsInfo = mySB.ToString(); } return myDS; } /// <summary> /// Gets the init data info. /// </summary> /// <param name="YPMC">The YPMC.</param> /// <param name="CDMC">The CDMC.</param> /// <param name="GG">The GG.</param> /// <returns></returns> public DataSet GetInitDataCsaInfo(string YPMC ,string CDMC , string GG ,string UserID) { DataSet myDS = null; StringBuilder strSql=new StringBuilder(); strSql.Append("select "); strSql.Append(" id,DrugID,UserID,ypbh,boss,ypmc,ypdm,gg,cdmc,ph,sl,bz,zbz,dw,jj,dj,xdj,pfj,lsj,rq,img,Title,Detail,innertime,StartTime,EndTime,State,VisitCount,SalesCompanyId,PartnerCode "); strSql.Append(" FROM Csales "); if(YPMC != null && YPMC.Length > 0) { strSql.Append(" where Ypmc = '"); strSql.Append(YPMC); } if(CDMC != null && CDMC.Length > 0) { strSql.Append("' and Cdmc = '"); strSql.Append(CDMC); } if(GG != null && GG.Length > 0) { strSql.Append("' and Gg = '"); strSql.Append(GG); } if(UserID != null && UserID.Length > 0) { strSql.Append("' and UserID='"); strSql.Append(UserID); strSql.Append("' "); } myDS = SqlHelper.ExecuteDataset(connString, CommandType.Text, strSql.ToString()); return myDS; } #endregion #region -----------------------Init Data ------------------- /// <summary> /// Loads the data drug pic. /// </summary> public void LoadDataDrugPic(DataSet DS) { if(DS!= null && DS.Tables[0].Rows.Count > 0) { DataView dv = DS.Tables[0].DefaultView; dv.RowFilter = " RowNumber < '5'"; if(dv.Count > 0) { this.repUrlOne.DataSource = dv; this.repUrlOne.DataBind(); this.repNameOne.DataSource = dv; this.repNameOne.DataBind(); } dv.RowFilter = " RowNumber > '4' and RowNumber < '9'"; if(dv.Count > 0) { this.repNameTwo.DataSource = dv; this.repNameTwo.DataBind(); this.repUrlTwo.DataSource = dv; this.repUrlTwo.DataBind(); } dv.RowFilter = "RowNumber > '8' and RowNumber < '13'"; if(dv.Count > 0) { this.repUrlThree.DataSource = dv; this.repUrlThree.DataBind(); this.repNameThree.DataSource = dv; this.repNameThree.DataBind(); } } } #endregion # region login button /// <summary> /// Handles the Click event of the ButtnLogin control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="System.Web.UI.ImageClickEventArgs"/> instance containing the event data.</param> private void ButtnLogin_Click(object sender, System.Web.UI.ImageClickEventArgs e) { if(Request.Cookies["MyCheckCode"] == null) { Response.Write("<script defer>alert('您的浏览器设置已被禁用 Cookies,您必须设置浏览器允许使用 Cookies 选项后才能使用本系统。');</script>"); return; } else { int LoginNum=0; try { LoginNum = Int32.Parse(Request.Cookies["LogNum"].Value.ToString()); LoginNum++; Response.Cookies["LogNum"].Value = LoginNum.ToString(); } catch(Exception ex) { Response.Write(ex.Message); Response.End(); } if(LoginNum>6) { Response.Write("<script defer>alert('你的账号已被锁定!请稍后重试');</script>"); } else { Logining(); } } } /// <summary> /// Loginings this instance. /// </summary> void Logining() { //DES解密 HyeyClass.Common.DES myDES = new HyeyClass.Common.DES(); string DecryptStrTime = myDES.Decrypt(Request.Cookies["MyTime"].Value); System.DateTime timenew = Convert.ToDateTime(System.DateTime.Now.ToString()); System.DateTime timeold = Convert.ToDateTime(DecryptStrTime); System.TimeSpan sta = System.TimeSpan.FromMinutes(20); //大于20分钟 if ((timenew - timeold) > sta) { //验证码过时. Response.Write("<script>alert('验证码超时,请重新输入验证码!');</script>"); return; } else { string DecryptStr = myDES.Decrypt(Request.Cookies["MyCheckCode"].Value); if(String.Compare( DecryptStr, txtValidte.Text.Trim(), true) != 0) { Response.Write("<script>alert('验证码错误,请输入正确的验证码!');</script>"); return; } else { #region validate is corret string Url = Request.Url.ToString(); if(Url.ToLower().IndexOf("hyey")<0 && Url.IndexOf("192.168.1.2")<0 && Url.IndexOf("211.100.242.35")<0 && Url.IndexOf("cnhney")<0) return; string userName,userPassword,macaddress,isnotebook; userName = HyeyClass.Web.PageValidate.ReplaceStr(this.TxtUser.Text.Trim()); userPassword = HyeyClass.Web.PageValidate.ReplaceStr(this.TxtPass.Text.Trim()); //前台验证合法性 macaddress = ""+MacAddress.Value.Trim().Replace("'","").Replace(";","").Replace("(",""); //检查mac地址是否正确,排除未装插件传过来的undefined if(macaddress !="" && macaddress.IndexOf("-") == -1) { macaddress = ""; } isnotebook = HyeyClass.Web.PageValidate.ReplaceStr(IsNoteBook.Value.Trim()); string reValue = HyeyClass.Common.SysCode.HyeyCheckUser(userName,userPassword,macaddress,isnotebook); if( reValue == "locked" ) { Response.Write("<script>alert('抱歉,您的用户名未被激活!');</script>"); return; } else if( reValue == "expire" ) { Response.Write("<script>alert('抱歉,您的用户名已经过期!');</script>"); return; } else if( reValue == "wrongpass" || reValue == "noexist" ) { Response.Write("<script>alert('用户名或密码错误!');</script>"); return; } else if( reValue == "true") { if(Url.IndexOf("=")>0) { Url = Url.Substring(Url.IndexOf("=")+1,Url.Length-1-Url.IndexOf("=")); } else { Url = "/MemberServices/index.aspx"; } Response.Redirect(Url,true); } else { Response.Write(reValue); Response.End(); } #endregion } } } #endregion } #endregion }