protected void Page_Load(object sender, EventArgs e) { XabaraCom xc = new XabaraCom(); xc.CheckAdminLogin("|adminPW|"); string idTemp = xc.SafeNum(Request["id"].Trim()).ToString(); string dimStr = "@UserPW"; string[] strValue = new string[1]; string strVlaueTemp = xc.GetRnd("abc", 1) + xc.GetRnd("abc123", 7).ToLower(); strValue[0] = xc.GetMd5(strVlaueTemp).ToString(); if (new dbDataFunction().InsertUpdateDB("AdminUser", dimStr, strValue, "Uid=" + idTemp + " and UserId<>'" + xc.adminID + "'").Equals("更新成功")) { xc.insertMyLog(xc.adminID, "admin", "管理员密码初始化"); xc.divError("", "新密码:" + strVlaueTemp, 350, 150, "userList.aspx", "goto"); } else { xc.divError("", "不能给自己密码初始化或操作错误!", 350, 150, "userList.aspx", "goto"); } }
protected void imgLogin_Click(object sender, ImageClickEventArgs e) { string uid = UID.Text.Trim().ToLower().ToString(); string pw = xc.GetMd5(PW.Text.ToString()); string strSql = "select * from AdminUser where userID='" + uid + "' and UserPW='" + pw + "' and loginFlag=2 "; DataTable dt = db.getDataTable(strSql); if (dt.Rows.Count < 1) { xc.divError("登陆提示", "您的帐号或密码不正确!", 350, 150, xc.AdminFileName, "top"); } else { long lgNums = xc.SafeNum(dt.Rows[0]["LoginNum"].ToString()) + 1; string strDim = "@SessionError,@LoginNum,@LoginDate,@LoginIP"; string rndNums = xc.GetRnd("abc", 8); Session.Add("AdminRndNums", rndNums); string[] strValue = new string[5]; strValue[0] = xc.GetMd5(rndNums); strValue[1] = lgNums.ToString(); strValue[2] = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); strValue[3] = xc.GetIP(); db.InsertUpdateDB("AdminUser", strDim, strValue, "userID='" + uid + "'"); xc.insertMyLog(uid, "admin", "管理员登录"); HttpCookie XabaraAdminCookies = new HttpCookie("XabaraAdmin"); //cookies写入磁盘 XabaraAdminCookies.Values.Add("AdminID", uid); XabaraAdminCookies.Values.Add("AdminName", HttpUtility.UrlEncode(dt.Rows[0]["UserName"].ToString().Trim())); XabaraAdminCookies.Values.Add("AdminLgNums", lgNums.ToString()); XabaraAdminCookies.Values.Add("AdminLgDate", dt.Rows[0]["LoginDate"].ToString().Trim()); XabaraAdminCookies.Values.Add("AdminLgIP", dt.Rows[0]["LoginIP"].ToString().Trim()); XabaraAdminCookies.Expires = DateTime.Now.AddDays(15d); Response.Cookies.Add(XabaraAdminCookies); dt.Dispose(); Response.Redirect("admin.aspx", true); } }
/// <summary> /// js方式输出 /// </summary> /// <param name="str">js代码</param> /// <returns></returns> private void js() { string str = "<script>window.setTimeout(\"window.location.href='taobaoke.aspx?tmp=" + xc.GetRnd("123", 6) + "'\",5000)</script>"; ClientScriptManager cs = ((Page)HttpContext.Current.CurrentHandler).ClientScript; cs.RegisterClientScriptBlock(this.GetType(), "ClientScriptBlock", str); }