예제 #1
0
파일: EX_Admin.cs 프로젝트: zwkjgs/LebiShop
 /// <summary>
 /// 判断登录状态
 /// </summary>
 /// <returns></returns>
 public static bool LoginStatus()
 {
     if (HttpContext.Current.Session["admin"] == null)
     {
         var    nv    = CookieTool.GetCookie("Master");
         int    uid   = 0;
         string uhash = "";
         string uname = "";
         if (nv.Count > 1)
         {
             if (!string.IsNullOrEmpty(nv.Get("id")) && !string.IsNullOrEmpty(nv.Get("hash")) && !string.IsNullOrEmpty(nv.Get("name")))
             {
                 //uid = StringUtils.StrToInt(nv.Get("id"), 0);
                 int.TryParse(nv.Get("id"), out uid);
                 uhash = nv.Get("hash");
                 uname = nv.Get("name");
                 Lebi_Administrator master = B_Lebi_Administrator.GetModel(uid);
                 if (CheckAdmin(master, uhash, uname, true))
                 {
                     SetSession(master);
                     return(true);
                 }
                 else
                 {
                     return(false);
                 }
             }
             return(false);
         }
         return(false);
     }
     return(true);
 }
예제 #2
0
        /// <summary>
        /// 管理员用户名称
        /// </summary>
        /// <param name="siteid"></param>
        /// <returns></returns>
        public string AdminName(int id)
        {
            Lebi_Administrator model = B_Lebi_Administrator.GetModel(id);

            if (model == null)
            {
                return("");
            }
            Lebi_Admin_Group group = B_Lebi_Admin_Group.GetModel(model.Admin_Group_id);

            if (group == null)
            {
                return(model.RealName);
            }
            return("[" + Lang(group.Name) + "]" + model.RealName);
        }
예제 #3
0
파일: EX_Admin.cs 프로젝트: zwkjgs/LebiShop
        /// <summary>
        /// 管理员登录
        /// </summary>
        /// <param name="MasterName"></param>
        /// <param name="PWD"></param>
        /// <returns></returns>
        public static bool AdminLogin(string AdminName, string PWD)
        {
            string SafeAdminLogin = RequestTool.GetConfigKey("SafeAdminLogin").Trim();

            if (SafeAdminLogin == "")
            {
                SafeAdminLogin = "******";
            }
            bool ret = false;
            Lebi_Administrator master = B_Lebi_Administrator.GetModel("UserName=lbsql{'" + AdminName + "'} and Type_id_AdminStatus=230");

            if (CheckAdmin(master, PWD, AdminName, false))
            {
                Random Random  = new Random();
                int    RandNum = Random.Next(100000000, 999999999);
                if (SafeAdminLogin == "1")
                {
                    master.RandNum = RandNum;
                    B_Lebi_Administrator.Update(master);
                }
                else
                {
                    RandNum = master.RandNum;
                }
                NameValueCollection nvs = new NameValueCollection();
                nvs.Add("id", master.id.ToString());
                nvs.Add("hash", MD5(RandNum + PWD));
                nvs.Add("name", AdminName);
                CookieTool.WriteCookie("Master", nvs, 365);
                SetSession(master);
                HttpContext.Current.Session["checkCode"] = null;
                ret = true;
                //开启一个线程提交最后登录记录
                Thread thread = new Thread(new ThreadStart(UserLastUse));
                thread.IsBackground = true;//这样能随主程序一起结束
                thread.Start();
            }
            return(ret);
        }
예제 #4
0
파일: EX_Admin.cs 프로젝트: zwkjgs/LebiShop
        public static bool CheckAdmin(int id, string PWD, string NAME)
        {
            Lebi_Administrator master = B_Lebi_Administrator.GetModel(id);

            return(CheckAdmin(master, PWD, NAME));
        }