示例#1
0
        public void OnStartupApp()
        {
            if (sBooters != null)
            {
                foreach (IBooter booter in sBooters)
                {
                    try
                    {
                        BooterLogger.AddTrace("Try: " + booter.ToString());

                        booter.Perform(true);
                    }
                    catch (Exception e)
                    {
                        Common.Exception(booter.ToString(), e);
                    }
                }
            }

            Booter.ClearFiles();
        }
示例#2
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
            }
        }
示例#3
0
 public Loader(Booter booter, string field)
 {
     mBooter = booter;
     mField  = field;
 }
示例#4
0
 public Loader(Booter booter, string field)
 {
     mBooter = booter;
     mField = field;
 }