Ejemplo n.º 1
0
        /// <summary>
        /// 缓存权限列表
        /// </summary>
        /// <returns></returns>
        public static DataTable GetUserPopedom()
        {
            Yannyo.Cache.YannyoCache cache = Yannyo.Cache.YannyoCache.GetCacheService();
            DataTable x = cache.RetrieveObject("/Sys/UserPopedom") as DataTable;

            if (x == null)
            {
                x = UsersUtils.GetUserPopedom();
                cache.AddObject("/Sys/UserPopedom", x);
            }
            return(x);
        }
Ejemplo n.º 2
0
 /// <summary>
 /// 从cookie中获取转向页
 /// </summary>
 /// <returns>string</returns>
 public static string GetReUrl()
 {
     if (HTTPRequest.GetString("reurl").Trim() != "")
     {
         UsersUtils.WriteCookie("reurl", HTTPRequest.GetString("reurl").Trim());
         return(HTTPRequest.GetString("reurl").Trim());
     }
     else
     {
         if (UsersUtils.GetCookie("reurl") == "")
         {
             return("default.aspx");
         }
         else
         {
             return(UsersUtils.GetCookie("reurl"));
         }
     }
 }
Ejemplo n.º 3
0
        /// <summary>
        /// 增加一个会员信息到在线列表中。用户login.aspx或在线用户信息超时,但用户仍在线的情况下重新生成用户在线列表
        /// </summary>
        /// <param name="uid"></param>
        private static OnlineUserInfo CreateUser(int UserID, int timeout)
        {
            OnlineUserInfo onlineuserinfo = new OnlineUserInfo();

            if (UserID > 0)
            {
                UserInfo ui = BLL.tbUserInfo.GetUserInfoModel(UserID);
                if (ui != null)
                {
                    onlineuserinfo.UserID    = UserID;
                    onlineuserinfo.oUserName = ui.uName.Trim();

                    onlineuserinfo.oIP         = HTTPRequest.GetIP();
                    onlineuserinfo.oAppendTime = DateTime.Parse(Utils.GetDateTime());
                    onlineuserinfo.oLastTime   = DateTime.Parse(Utils.GetDateTime());

                    int olid = Add(onlineuserinfo, timeout);
                    onlineuserinfo.olID = olid;

                    HttpCookie cookie = HttpContext.Current.Request.Cookies["Yannyo"];
                    if (cookie != null)
                    {
                        if (HttpContext.Current.Request.Cookies["Yannyo"]["expires"] != null)
                        {
                            int expires = Utils.StrToInt(HttpContext.Current.Request.Cookies["Yannyo"]["expires"].ToString(), 0);
                            if (expires > 0)
                            {
                                cookie.Expires = DateTime.Now.AddMinutes(Utils.StrToInt(HttpContext.Current.Request.Cookies["Yannyo"]["expires"].ToString(), 0));
                            }
                        }
                    }

                    string cookieDomain = GeneralConfigs.GetConfig().CookieDomain.Trim();
                    if (cookieDomain != string.Empty && HttpContext.Current.Request.Url.Host.IndexOf(cookieDomain) > -1 && UsersUtils.IsValidDomain(HttpContext.Current.Request.Url.Host))
                    {
                        cookie.Domain = cookieDomain;
                    }
                    HttpContext.Current.Response.AppendCookie(cookie);
                }
            }
            else
            {
                onlineuserinfo = CreateGuestUser(timeout);
            }
            return(onlineuserinfo);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// 用户在线信息维护。判断当前用户的身份(会员还是游客),是否在在线列表中存在,如果存在则更新会员的当前动,不存在则建立.
        /// </summary>
        /// <param name="passwordkey">系统passwordkey</param>
        /// <param name="timeout">在线超时时间</param>
        /// <param name="passwd">用户密码</param>
        public static OnlineUserInfo UpdateInfo(string passwordkey, int timeout, int uid, string passwd)
        {
            lock (SynObject)
            {
                OnlineUserInfo onlineuser = new OnlineUserInfo();

                string ip       = HTTPRequest.GetIP();
                int    userid   = Utils.StrToInt(UsersUtils.GetCookie("UserID"), uid);
                string password = (passwd == string.Empty ? UsersUtils.GetCookiePassword(passwordkey) : UsersUtils.GetCookiePassword(passwd, passwordkey));

                if (password.Length == 0)
                {
                    userid = -1;
                }
                // 如果密码非Base64编码字符串则怀疑被非法篡改, 直接置身份为游客
                else if (!Utils.IsBase64String(password))
                {
                    userid = -1;
                }

                if (userid != -1)
                {
                    onlineuser = GetOnlineUserInfo(userid);

                    if (onlineuser != null)
                    {
                        if (onlineuser.oIP != ip)
                        {
                            UpdateIP(onlineuser.olID, ip);

                            onlineuser.oIP = ip;

                            return(onlineuser);
                        }
                    }
                    else
                    {
                        // 判断密码是否正确
                        userid = BLL.tbUserInfo.CheckPassword(userid, password, false);
                        if (userid != -1)
                        {
                            DeleteRowsByIP(ip);
                            return(CreateUser(userid, timeout));
                        }
                        else
                        {
                            // 如密码错误则在在线表中创建游客
                            onlineuser = GetOnlineUserByIP(-1, ip);
                            if (onlineuser == null)
                            {
                                return(CreateGuestUser(timeout));
                            }
                        }
                    }
                }
                else
                {
                    onlineuser = GetOnlineUserByIP(-1, ip);

                    if (onlineuser == null)
                    {
                        return(CreateGuestUser(timeout));
                    }
                }

                //UpdateLastTime(onlineuser.Olid);

                onlineuser.oLastTime = DateTime.Now;    // DateTime.Parse(Utils.GetDateTime());
                return(onlineuser);
            }
        }
Ejemplo n.º 5
0
 /// <summary>
 /// 获取所有父列表
 /// </summary>
 public static string GetRegionPaterStr(int RegionID)
 {
     return(UsersUtils.GetDataFieldStr("tbRegionInfo", "rName", "rUpID", "RegionID", RegionID, ""));
 }