|
Server : Microsoft-IIS/10.0 System : Windows NT EBS-6136 10.0 build 17763 (Windows Server 2016) i586 User : jxgj ( 0) PHP Version : 7.0.33 Disable Function : passthru,exec,system,shell_exec,proc_open,popen,pcntl_exec,socket_bind,stream_socket_server Directory : D:/tmp_aspnet/root/6b11be23/e503b68d/ |
?#pragma checksum "D:\wwwroot\keman\wwwroot\Back\admin-login.aspx.cs" "{406ea660-64cf-4c82-b6f0-42d48172a799}" "2932CC4A81A2B2F2906D3DF8F14F25FA"
#line 1 "D:\wwwroot\keman\wwwroot\Back\admin-login.aspx.cs"
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Data.OleDb;
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 CoreClass;
namespace Back
{
/// <summary>
/// admin_login 的提要注明。
/// </summary>
///
public partial class admin_login : System.Web.UI.Page
{
protected CoreClass.PublicFunction pubfun = new PublicFunction();
protected CoreClass.DBCommon dbc = new DBCommon();
protected void Page_Load(object sender, System.EventArgs e)
{
if(Session["adminLogDate"]==null)
{
Session["adminLogDate"] = DateTime.Now.AddSeconds(-5.0);
}
if(Session["TeacherLogDate"]==null)
{
Session["TeacherLogDate"] = DateTime.Now.AddSeconds(-5.0);
}
}
#region Web 窗体设计器天生的代码
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: 该挪用是 ASP.NET Web 窗体设计器所必须的。
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// 设计器支持所需的步骤 - 不要使用代码编纂器批改
/// 此步骤的内容。
/// </summary>
private void InitializeComponent()
{
}
#endregion
#region 治理员登陆
private void AdminLogin()
{
//页面5秒防刷新
DateTime time1 = Convert.ToDateTime(Session["adminLogDate"].ToString());
DateTime time2 = DateTime.Now;
TimeSpan ts = time2 - time1;
if (ts.TotalSeconds < 5.0)
{
Response.AddHeader("refresh", "5");
Response.Write("<html><head></head><body><span style=\"color:red;\">本页不能在5秒内陆续刷新!请稍候...</span></body></html>");
Response.End();
return;
}
//登录处置
this.ipt1.Text = this.pubfun.SubStringByByte(this.ipt1.Text.Trim(), 50);
OleDbCommand cmd = this.dbc.GetCommandBySql("Select top 1 * From Admins Where passport=@passport");
cmd.Parameters.Add("@passport", OleDbType.VarChar, 50).Value = this.ipt1.Text.Trim();
cmd.Connection.Open();
OleDbDataReader dr = cmd.ExecuteReader();
if (dr.Read())
{
string pass = System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(this.ipt2.Text, "md5");
if (dr["Passkey"].ToString().ToUpper() != pass.ToUpper())
{
this.lblErrMsg.Text = "密码不正确!";
goto Exit;
}
if (Convert.ToBoolean(dr["Stop"].ToString()))
{
this.lblErrMsg.Text = "对不起,该帐号未启用!";
goto Exit;
}
int roleid = Int32.Parse(dr["RoleId"].ToString());
int adminid = Int32.Parse(dr["Id"].ToString());
Session["AdminLogId"] = Session.SessionID;
Session["AdminId"] = adminid;
Session["AdminPassport"] = dr["passport"].ToString();
Session["AdminRoleId"] = roleid;
System.Web.HttpCookie cookie1 = new HttpCookie("AdminId", Session["AdminId"].ToString());
System.Web.HttpCookie cookie2 = new HttpCookie("AdminPassport", Session["AdminPassport"].ToString());
this.Response.Cookies.Add(cookie1);
this.Response.Cookies.Add(cookie2);
this.Response.Cookies["AdminLogId"].Value = Session["AdminLogId"].ToString();
if (roleid < 0)
{
Session["AdminIsAdmin"] = true;
}
else
{
Session["AdminIsAdmin"] = false;
System.Collections.Hashtable hash = new Hashtable();
DataTable dt = this.dbc.GetDataTableBySql("Select * From AdminsRights Where Id=" + adminid.ToString());
foreach (DataRow row in dt.Rows)
{
hash.Add(row["rights"].ToString().ToLower(), adminid.ToString());
}
if (roleid > 0)
{
OleDbDataReader dr2 = this.dbc.GetDataReaderBySql("select * from AdminRoleRights Where RoleId = " + roleid.ToString());
while (dr2.Read())
{
if (!hash.ContainsKey(dr2["Rights"].ToString().ToLower()))
{
hash.Add(dr2["Rights"].ToString().ToLower(), adminid.ToString());
}
}
dr2.Close();
}
Session["AdminRights"] = hash;
}
yingshi dy = new yingshi();
// dy.user("insert into rizhi(rz_bt,rz_nr,rz_czr,rz_time) values('登陆成功','登陆成功','" + ipt1.Text.Replace("'","") + "','"+ System.DateTime.Now.ToString() +"' )");
Response.Redirect("index.aspx");
}
else
{
this.lblErrMsg.Text = "对不起,帐号不存在!";
}
Exit:
dr.Close();
cmd.Connection.Close();
cmd.Connection.Dispose();
cmd.Dispose();
Session["adminLogDate"] = DateTime.Now;
return;
}
#endregion
protected void btnLogin_Click(object sender, System.Web.UI.ImageClickEventArgs e)
{
AdminLogin();
}
}
}
#line default
#line hidden