public object RemoveLogin()
        {
            string neiw = ConfigurationManager.AppSettings["key"];
            string Str  = Request.Cookies.GetAdmin();

            if (Str.IsNullOrEmpty())
            {
                return(Redirect("/manage/login.html"));
            }
            string[] UArr = LokFuEncode.LokFuAuthcodeDecode(Str, neiw).Split('|');
            if (UArr.Length == 4)
            {
                int      Id    = Int32.Parse(UArr[0]);
                string   UName = UArr[1];
                string   DTStr = UArr[2];
                SysAdmin user  = Entity.SysAdmin.Where(n => n.UserName == UName && n.Id == Id).FirstOrDefault();
                if (user != null)
                {
                    DateTime now = (DateTime)user.LastTime;
                    if (DTStr == now.ToString("yyyy-MM-dd HH:mm:ss"))
                    {
                        user.QQState = 0;
                        Entity.SaveChanges();
                    }
                }
            }
            Response.Cookies.SetAdmin(string.Empty);
            return(Redirect("/manage/login.html"));
        }
        public SysAdmin GetAdmin()
        {
            SysAdmin user = null;
            string   neiw = System.Configuration.ConfigurationManager.AppSettings["key"];
            string   Str  = System.Web.HttpContext.Current.Request.Cookies.GetAdmin();

            if (Str.IsNullOrEmpty())
            {
                return(user);
            }
            string[] UArr = LokFuEncode.LokFuAuthcodeDecode(Str, neiw).Split('|');
            if (UArr.Length == 4)
            {
                IsLockScreen = UArr[3];
                int    Id    = Int32.Parse(UArr[0]);
                string UName = UArr[1];
                string DTStr = UArr[2];
                user = Entity.SysAdmin.Where(n => n.UserName == UName && n.Id == Id).FirstOrDefault();
                if (user != null)
                {
                    DateTime now = (DateTime)user.LastTime;
                    if (DTStr == now.ToString("yyyy-MM-dd HH:mm:ss"))
                    {
                        return(user);
                    }
                    else
                    {
                        user = null;
                    }
                }
            }
            return(user);
        }
Esempio n. 3
0
        public Users GetUsers()
        {
            Users  user = null;
            string Str  = System.Web.HttpContext.Current.Request.Cookies.GetUsers();

            if (Str.IsNullOrEmpty())
            {
                return(user);
            }
            string neiw = System.Configuration.ConfigurationManager.AppSettings["key"];

            string[] UArr = LokFuEncode.LokFuAuthcodeDecode(Str, neiw).Split('|');
            if (UArr.Length == 3)//id|username|md5
            {
                int    Id    = Int32.Parse(UArr[0]);
                string UName = UArr[1];
                string DTStr = UArr[2];
                user = Entity.Users.Where(n => n.UserName == UName && n.Id == Id && n.PassWord == DTStr).FirstOrDefault();
            }
            return(user);
        }