Exemplo n.º 1
0
        public UserProxy User_GetByUsername(string username)
        {
            if (!CheckClient())
            {
                return(null);
            }
            User user = UserBO.Instance.GetUser(username);

            if (user == null)
            {
                return(null);
            }
            return(ProxyConverter.GetUserProxy(user));
        }
Exemplo n.º 2
0
        public UserProxy User_GetUser(int userID)
        {
            if (!CheckClient())
            {
                return(null);
            }

            User user = UserBO.Instance.GetUser(userID);

            if (user == null)
            {
                return(null);
            }
            UserProxy userProxy = ProxyConverter.GetUserProxy(user);

            return(userProxy);
        }
Exemplo n.º 3
0
        protected void Application_BeginRequest(object sender, EventArgs e)
        {
            if (inited == false)
            {
                #region 初始化

                lock (initLocker)
                {
                    if (inited == false)
                    {
                        LogHelper.CreateDebugLog("bbsmax 开始初始化");

                        Config.Current = new WebEngineConfig();
                        TemplateManager.Init(false); //TODO:重复执行会出错

                        //初始化系统并载入设置
                        Globals.Init();
                        Booter.Init();  //TODO:重复执行会出错

                        //初始化插件
                        PluginManager.Init();

#if !Passport
                        //将最后一次备份的在线信息恢复至内存
                        OnlineUserPool.Instance.Restore();
#endif

                        //初始化路由
                        BbsRouter.Init();

                        inited = true;
                    }
                }

                #endregion
            }

            if (Request.RequestType == "POST")
            {
                #region 处理大文件上传

                if (StringUtil.StartsWithIgnoreCase(Request.RawUrl, Globals.AppRoot + "/default.aspx?uploadtempfile.aspx"))
                {
                    string query = Request.RawUrl.Substring(Globals.AppRoot.Length + 33);

                    new MaxLabs.bbsMax.AppHandlers.UploadTempFileHandler().ProcessRequest(HttpContext.Current, HttpUtility.ParseQueryString(query));

                    Response.End();
                }

                #endregion
            }

            if (RequestUtil.CompressStaticContent(Context))
            {
                return;
            }

            MaxLabs.WebEngine.Context.Init();

            if (BbsRouter.Route())
            {
                Context.Items.Add("need-compress", true);

                JobManager.ExecuteBeforeRequestJobs();

                MaxLabs.bbsMax.Entities.User user = MaxLabs.bbsMax.Entities.User.Current;

                if (user != null && user.UserID > 0)
                {
                    string ip = IPUtil.GetCurrentIP();

                    if (ip != user.LastVisitIP)
                    {
                        LogManager.LogUserIPChanged(new UserIPLog(user.UserID, user.Username, ip, user.LastVisitIP, Request.RawUrl));

//                        MaxLabs.bbsMax.Logs.LogManager.LogOperation(new Logs.User_IPChange(user.UserID, user.Username, user.LastVisitIP == null ? string.Empty : user.LastVisitIP, ip));

                        UserBO.Instance.UpdateLastVisitIP(user.UserID, ip);
                    }
                }

                Stopwatch processTimer = new Stopwatch();

                processTimer.Start();

                HttpContext.Current.Items["MaxLabs.bbsMax.ProcessTimer"] = processTimer;
            }
            else
            {
                #region 根据路径来决定是否允许请求。例如某些文件夹只允许请求图片而某些文件夹什么都不允许请求

                string path = Request.Url.AbsolutePath.Substring(Globals.AppRoot.Length).Trim('/', '\\');
                string file = Request.Url.LocalPath;

                //max-templates目录、max-spacestyles目录和max-assets目录禁止可执行文件
                if (StringUtil.StartsWithIgnoreCase(path, "max-templates/") || StringUtil.StartsWithIgnoreCase(path, "max-spacestyles/") || StringUtil.StartsWithIgnoreCase(path, "max-assets/"))
                {
                    if (IsExecuteableFile(file))
                    {
                        Response.Redirect("~/");
                        return;
                    }
                }

                //max-temp和UserFiles目录只允许访问图片
                else if (StringUtil.StartsWithIgnoreCase(path, "max-temp/") || StringUtil.StartsWithIgnoreCase(path, "UserFiles/"))
                {
                    if (IsImageFile(file) == false)
                    {
                        Response.Redirect("~/");
                        return;
                    }
                }

                else if (StringUtil.EndsWithIgnoreCase(file, ".aspx"))
                {
                    Context.Items.Add("need-compress", true);
                }

                #endregion
            }
        }
Exemplo n.º 4
0
        protected override void OnLoadComplete(EventArgs e)
        {
            MaxLabs.bbsMax.Entities.User user = UserBO.Instance.GetUser(SpaceOwnerID);

            if (user != null)
            {
                if (IsSpaceOwnerFullSiteBanned)
                {
                    if (VisitorIsAdmin)
                    {
                        m_SpaceCanAccess        = true;
                        m_SpaceDisplayAdminNote = true;
                    }
                    else
                    {
                        m_SpaceCanAccess = false;
                    }
                }
                else if (SpaceOwnerID == MyUserID)
                {
                    m_SpaceCanAccess = true;
                }
                else if (VisitorInBlackList)
                {
                    m_SpaceCanAccess = false;
                }
                else if (SpaceOwner.SpacePrivacy == SpacePrivacyType.All)
                {
                    m_SpaceCanAccess = true;
                }
                else if (SpaceOwner.SpacePrivacy == SpacePrivacyType.Self)
                {
                    m_SpaceCanAccess = SpaceOwnerID == MyUserID;
                }
                else if (SpaceOwner.SpacePrivacy == SpacePrivacyType.Friend)
                {
                    m_SpaceCanAccess = VisitorIsFriend;
                }

                if (m_SpaceCanAccess == false)
                {
                    if (VisitorIsAdmin)
                    {
                        m_SpaceCanAccess        = true;
                        m_SpaceDisplayAdminNote = true;
                    }
                }

                if (IsSpaceOwnerFullSiteBanned)
                {
                    if (VisitorIsAdmin)
                    {
                        m_FunctionCanAccess        = true;
                        m_FunctionDisplayAdminNote = true;
                    }
                    else
                    {
                        m_FunctionCanAccess = false;
                    }
                }
                if (SpaceOwnerID == MyUserID)
                {
                    m_FunctionCanAccess = true;
                }
                else if (VisitorInBlackList)
                {
                    m_FunctionCanAccess = false;
                }
                else if (FunctionPrivacy == SpacePrivacyType.All)
                {
                    m_FunctionCanAccess = true;
                }
                else if (FunctionPrivacy == SpacePrivacyType.Self)
                {
                    m_FunctionCanAccess = SpaceOwnerID == MyUserID;
                }
                else if (FunctionPrivacy == MaxLabs.bbsMax.Enums.SpacePrivacyType.Friend)
                {
                    m_FunctionCanAccess = VisitorIsFriend;
                }

                if (m_FunctionCanAccess == false)
                {
                    if (VisitorIsAdmin)
                    {
                        m_FunctionCanAccess     = true;
                        m_SpaceDisplayAdminNote = true;
                    }
                }

                m_SpaceName = user.Name + "的个人空间";                 //TODO:在User表加上SpaceName字段,并在用户中心提供设置

                if (SpaceCanAccess && FunctionCanAccess && !My.IsInvisible)
                {
                    SpaceBO.Instance.VisitSpace(MyUserID, SpaceOwnerID, _Request.IpAddress);
                }
            }

            base.OnLoadComplete(e);
        }