Exemplo n.º 1
0
        public static void ParseUrl(BASEApplication app)
        {
            //TODO: Add in code. Move from the BeginRequest to here. Let that call this.


            ////TODOH: Change UrlParsers to use and return Uri's
            Uri         url = app.Request.Url;
            BASERequest req = app.BASERequest;

            foreach (IUrlParserPlugin plugin in _plugins)
            {
                plugin.ProcessUrl(app);
            }

            //If SIteUID == 0, then we need to set it to the default site as per the BASE.config
            if (req._siteUID == 0)
            {
                req._siteUID = SystemManager.Current.DefaultSiteUID;
            }

            ////TODOH: Write back url to the request to continue processing.
            //SOLVED. Each plugin writes the url back itself.

            req._isRequestFinal = true;
            req._finalUrl       = app.Request.Url;
        }
Exemplo n.º 2
0
        public void ProcessUrl(BASEApplication app)
        {
            int tempsectionUID = WebUtils.QS.ToInt32ElseMin(app.Request.QueryString[BASEQS.SectionUID]);

            if (tempsectionUID != int.MinValue)
            {
                app.BASERequest._sectionUID = tempsectionUID;
                return;
            }

            Logging.Logger.Log("SectionNameResolver.ProcessUrl: " + app.Request.Url.OriginalString);
            //TODO: This will not properly resolve if no page is given and the last segment is not setup with a default page (in IIS) which it wont be. Need a detector for default pages possibly.
            //^FIXED^ Just parse the final segment and dont assume its always a page. A section should not be named same as page anyways. So it will properly resolve sites/sections.
            string[] segments = app.Request.Url.Segments;
            int      length   = segments.Length;

            //loop thru segments and search for subsites.
            int sectionUID   = 0;
            int segmentcount = 2;

            //make sure there is a subfolder in url, if so process (The segment[0] will always be '/'
            if (length > 1 && !app.BASERequest.IsRootExclusion)
            {
                //firsct segment is first subfolder in url
                sectionUID = SectionDataHelper.SelectUIDByNameSiteUID(segments[1].TrimEnd("/".ToCharArray()), app.BASERequest._siteUID);
                //if that subfolder was actually a site, and there are more of them, loop
                if (sectionUID != 0 && length > 2)
                {
                    app.BASERequest.AddSectionToList(segments[1].TrimEnd("/".ToCharArray()), sectionUID);
                    //TODO: Add stripping of subsite HERE ALSO
                    for (segmentcount = 2; segmentcount < segments.Length; segmentcount++)
                    {
                        //Check if there is a subsite with the previous site as a parent
                        int subsectionUID = SectionDataHelper.SelectUIDByNameParentSectionUID(segments[segmentcount].TrimEnd("/".ToCharArray()), sectionUID);
                        //if not found, break without assigning a new site uid
                        if (subsectionUID == 0)
                        {
                            break;
                        }
                        //if found, assign new siteuid, and check next.
                        //TODO: Add stripping of subsite HERE ALSO
                        sectionUID = subsectionUID;
                        app.BASERequest.AddSectionToList(segments[segmentcount].TrimEnd("/".ToCharArray()), sectionUID);
                    }
                }
            }

            //if subsite found, assign it, and strip the subsites out of the URL.
            if (sectionUID != 0)
            {
                app.BASERequest._sectionUID = sectionUID;
                StringBuilder sb = new StringBuilder("/", 30);
                for (int i = segmentcount; i < segments.Length; i++)
                {
                    sb.Append(segments[i]);
                }
                sb.Append(app.Request.Url.Query);
                app.Context.RewritePath(sb.ToString());
            }
        }
Exemplo n.º 3
0
        public void ProcessUrl(BASEApplication app)
        {
            int overridepageUID = WebUtils.QS.ToInt32ElseMin(app.Request.QueryString[BASEQS.PageUID]);

            if (overridepageUID != int.MinValue)
            {
                app.BASERequest._pageUID = overridepageUID;
                return;
            }

            Logging.Logger.Log("EndPointResolver.ProcessUrl: " + app.Request.Url.OriginalString, BASE.Logging.LogPriority.Info);

            string path = app.Request.Url.AbsolutePath;

            EndPointAliasEntity epa = EndPointAliasDataHalper.SelectSingle(path.Trim(new char[1] {
                '/'
            }), app.BASERequest.SectionUID);


            if (epa == null)
            {
                return;
            }

            //This code is temporary only.
            //TODO: USE StringBuilder
            string newurl = "/";

            switch (epa.EndPointType)
            {
            case (int)EndPointAliasType.Virtual:                     //Virtual
                newurl += "VirtualPage.aspx";
                app.BASERequest._pageUID = epa.PageUID.Value;
                app.Context.RewritePath(newurl + app.Request.Url.Query);
                break;

            default:
                app.Response.Write("EndPointAlias not resolved");
                app.Response.Flush();
                app.Response.End();
                break;
            }



            //TODO: Change the path.

            //All sucsite and sections should be already stripped at this point.
            //We can now take the final segment(s) and do a lookup in the alias table.
            //If there is not an alias, we assume it is a physical location being accesses. This will be handled by the BASE handler for physical file mapping
            //If it is an alias, we check which type, and setup the actual page, pageUID, and/or query string info.
        }
Exemplo n.º 4
0
        protected override void OnPreRenderComplete(EventArgs e)
        {
            //TODO: Add in an overridable crosspage post back here!
            base.OnPreRenderComplete(e);

            //this.IsCrossPagePostBack
            if (this.Form is BASEForm)
            {
                BASEForm        frm = (BASEForm)this.Form;
                BASEApplication app = (BASEApplication)HttpContext.Current.ApplicationInstance;
                frm.Action = app.BASERequest._originalUrl.PathAndQuery;
            }
        }
Exemplo n.º 5
0
        void _context_BeginRequest(object sender, EventArgs e)
        {
            Logging.Logger.Log(String.Format("UrlParserHttpModule BeginRequest URL={0}, Referrer={1}", _context.Request.Url.OriginalString, _context.Request.UrlReferrer),
                               BASE.Logging.LogPriority.Debug, "URLPARSING");
            //Get all IUrlParsers
            if (!SystemManager.IsInitialized)
            {
                return;
            }

            BASEApplication app = (BASEApplication)sender;

            ParseUrl(app);
        }
Exemplo n.º 6
0
        void SkinnedEndPoint_SkinPage(object sender, EndPointEventArgs e)
        {
            //Setup needed objects
            SkinnedEndPoint ep  = (SkinnedEndPoint)sender;
            BASEApplication app = (BASEApplication)HttpContext.Current.ApplicationInstance;
            //Used to indicate if the default region for a page has been merged yet.
            bool defaultAdded = false;
            //Get template chunks for sites template.

            //Find the Region panel.


            //TODO: Add in more comprehensive checking for valid sites, default system site, etc.
            SiteVirtualInfoEntity site = BASE.Data.Helpers.SiteVirtualInfoDataHelper.SelectSingle(app.BASERequest.SiteUID);

            if (site == null)
            {
                throw new PageSkinningException("A Default site is required to skin a page with a template");
            }

            //TODO: Add in checks for a valid TemplateGUid
            EntityCollection <TemplateChunksEntity> chunks = TemplateChunkDataHelper.Select(site.TemplateGUID.Value, true);

            List <HtmlChunk> htmlchunks = new HtmlParser().ParseToChunks(chunks, "bml");

            Control[] controls = new HtmlParser().ParseToControls(ep, htmlchunks, "bml");

            foreach (RegionPanel reg in ep.RegionPanels.Values)
            {
                ep.Form.Controls.Remove(reg);
            }

            foreach (Control c in controls)
            {
                if (c is RegionPlaceHolder)
                {
                    RegionPlaceHolder plc = (RegionPlaceHolder)c;
                    foreach (RegionPanel reg in ep.RegionPanels.Values)
                    {
                        //Make sure that we have a matching ID for proper merging of regions.
                        if (reg.RegionID == plc.RegionID)
                        {
                            plc.AddRegionPanel(reg);
                        }
                    }
                    //TODO We need to figure a way to Log any regions that are orphaned and never merge.
                }
                ep.Form.Controls.Add(c);
            }
        }
        public void ProcessUrl(BASEApplication app)
        {
            int tempsiteUID = WebUtils.QS.ToInt32ElseMin(app.Request.QueryString[BASEQS.SiteUID]);

            if (tempsiteUID != int.MinValue)
            {
                app.BASERequest._siteUID = tempsiteUID;
                return;
            }

            Logging.Logger.Log("DomainAliasResolver.ProcessUrl: " + app.Request.Url.OriginalString);
            app.BASERequest.SiteUID = SiteDataHelper.SelectSiteUIDByDomainName(app.Request.Url.Host);
            //if (app.BASERequest.SiteUID != 0)
            //    app.BASERequest.AddSiteToList(app.Request.Url.Host, app.BASERequest.SiteUID);
        }
        public void ProcessRequest(HttpContext context)
        {
            FileInfo        file = null;
            BASEApplication app  = (BASEApplication)context.ApplicationInstance;
            Uri             url  = app.Request.Url;

            // get the filename from the querystring
            string filename = url.AbsolutePath;


            // Obviously, if we had to check for filename exclusion, it would be done in here
            // before the physical or dynamic check get processed.
            // We need to check only the first level of subnames in a URL.
            // Segments are like this: mattlant.com/dev/hello/world.htm: [0] = '/' [1] = 'dev/' [2] = 'hello/' [3] = 'world.htm'
            if (url.Segments.Length > 1 && !app.BASERequest.IsRootExclusion && !BASE.Configuration.ConfigurationManager.Current.IsSubExclusion(url.Segments[1]))
            {
                // The filename is NOT excluded. SO WE NEED TO TRANSLATE IT to use the current PHYSICAL SITES SECTION path
                file = new FileInfo(app.BASERequest.PhysicalSectionPath + filename);

                // Log this request.
                Logging.Logger.Log(string.Format("DefaultFileHandler: URL REMAPPED: {0}, {1}", url.ToString(), file.FullName));
            }
            else                                // If its still an exclusion we still resolve to the physical location in the root folder.
            {
                // The file is a exclusion. Let process this exclusion as needed.
                //TODO: We only return the file this points to if not excluded.
                //Exclusions are just indicators if we are to remap the URL to the Sites directory, or leave as the original.
                //This helps oin cases like CuteEditor, which will always be in the systems root folder, rather than in each sites home directory.
                file = new FileInfo(app.Request.PhysicalApplicationPath + filename);

                // Log this request.
                Logging.Logger.Log(string.Format("DefaultFileHandler: URL NOT REMAPPED: {0}, {1}", url.ToString(), file.FullName));
            }
            if (!file.Exists)
            {
                context.Response.Write(string.Format("DefaultFileHandler: NOT FOUND(url)(phys): {0}, {1}", url.ToString(), file.FullName));
                Logging.Logger.Log(string.Format("DefaultFileHandler: NOT FOUND(url)(phys): {0}, {1}", url.ToString(), file.FullName));
                context.Response.StatusCode = 200;
                return;
            }
            // write it to the browser
            context.Response.Clear();
            context.Response.WriteFile(file.FullName);
            context.Response.End();
        }
Exemplo n.º 9
0
        public void ProcessUrl(BASEApplication app)
        {
            //LOG Paths, Urls etc
            HttpRequest req = app.Request;

            Logger.Log(string.Format("UrlDiagEnd - Request.ApplicationPath: {0}", req.ApplicationPath));
            Logger.Log(string.Format("UrlDiagEnd - Request.FilePath: {0}", req.FilePath));
            Logger.Log(string.Format("UrlDiagEnd - Request.HttpMethod: {0}", req.HttpMethod));
            Logger.Log(string.Format("UrlDiagEnd - Request.PathInfo: {0}", req.PathInfo));
            Logger.Log(string.Format("UrlDiagEnd - Request.PhysicalApplicationPath: {0}", req.PhysicalApplicationPath));
            Logger.Log(string.Format("UrlDiagEnd - Request.PhysicalPath: {0}", req.PhysicalPath));
            Logger.Log(string.Format("UrlDiagEnd - Request.Path: {0}", req.Path));
            Logger.Log(string.Format("UrlDiagEnd - Request.RawUrl: {0}", req.RawUrl));
            StringBuilder sb = new StringBuilder(40);

            string[] segs = req.Url.Segments;
            for (int i = 0; i < req.Url.Segments.Length; i++)
            {
                sb.Append(i.ToString());
                sb.Append(")  ");
                sb.Append(segs[i]);
                if (i < segs.Length - 1)
                {
                    sb.Append(" --- ");
                }
            }

            Logger.Log(string.Format("UrlDiagEnd - Request.Url.Segments: {0}", sb));
            Logger.Log(string.Format("UrlDiagEnd - Request.RequestType: {0}", req.RequestType));
            Logger.Log(string.Format("UrlDiagEnd - Request.Url.OriginalString: {0}", req.Url.OriginalString));
            Logger.Log(string.Format("UrlDiagEnd - Request.Url.AbsolutePath: {0}", req.Url.AbsolutePath));
            Logger.Log(string.Format("UrlDiagEnd - Request.Url.AbsoluteUri: {0}", req.Url.AbsoluteUri));
            if (req.UrlReferrer == null)
            {
                Logger.Log("UrlDiagEnd - Request.UrlReferrer.OriginalString: NO REFERRER");
            }
            else
            {
                Logger.Log(string.Format("UrlDiagEnd - Request.UrlReferrer.OriginalString: {0}", req.UrlReferrer.OriginalString));
            }
        }
        void VirtualSkinnedEndPoint_MergeRegion(object sender, EndPointEventArgs e)
        {
            //Get ref to BASEApp
            BASEApplication        app = (BASEApplication)HttpContext.Current.ApplicationInstance;
            VirtualSkinnedEndPoint ep  = (VirtualSkinnedEndPoint)sender;

            //Get the Page info
            int        pageID = app.BASERequest._pageUID;
            PageEntity page   = PageDataHelper.SelectSingle(pageID);

            if (page == null)
            {
                throw new ContentMergingException("Page not found. TODO: This needs to change!");                 //TODO: Need to change for better handling, as well as default management
            }
            //TODO: Page entity/table needs to be modified to be preparsed just like templates.
            //page.HTMLContent
            //Grab PageRegions
            EntityCollection <PageRegionEntity> regions = new EntityCollection <PageRegionEntity>();
            RelationPredicateBucket             filter  = new RelationPredicateBucket();

            filter.PredicateExpression.Add(PageRegionFields.PageUID == pageID);
            DataAccessAdapter da = new DataAccessAdapter();

            da.FetchEntityCollection(regions, filter);

            foreach (PageRegionEntity region in regions)
            {
                Control[]   controls = new HtmlParser().ParseToControls(ep, region.RegionContent);
                RegionPanel regPanel = new RegionPanel(RegionPanelType.PlaceHolder);
                regPanel.RegionID = region.RegionId;
                foreach (Control c in controls)
                {
                    regPanel.Controls.Add(c);
                }
                ep.RegionPanels.Add(regPanel.RegionID, regPanel);
            }

            //Add content to RegionPanel

            //Add region panels to RegionList
        }
        public void ProcessUrl(BASEApplication context)
        {
            //FileInfo file = null;
            BASEApplication app = (BASEApplication)context;
            Uri             url = app.Request.Url;

            // get the filename from the querystring
            string path = url.AbsolutePath;


            // Obviously, if we had to check for filename exclusion, it would be done in here
            // before the physical or dynamic check get processed.
            // We need to check only the first level of subnames in a URL.
            // Segments are like this: mattlant.com/dev/hello/world.htm: [0] = '/' [1] = 'dev/' [2] = 'hello/' [3] = 'world.htm'
            if (url.Segments.Length > 1 && !BASE.Configuration.ConfigurationManager.Current.IsSubExclusion(url.Segments[1]))
            {
                path = app.BASERequest.RealSectionPath.TrimEnd(new char[] { '/' }) + path;
                app.Context.RewritePath(path + url.Query);
                Logging.Logger.Log(string.Format("NonExclusionSiteTranslator: URL REMAPPED: {0}, {1}", url.ToString(), path));
            }
        }
        public void ProcessUrl(BASEApplication app)
        {
            HttpRequest req     = app.Request;
            BASERequest baseReq = app.BASERequest;

            string[] segments = req.Url.Segments;

            //Check the exclusion list first.
            bool   qsOverride = false;
            string urlrw      = req.QueryString["URLRW"];

            if (!string.IsNullOrEmpty(urlrw))
            {
                qsOverride = urlrw == "0" ? true : false;
            }

            if (qsOverride || BASE.Configuration.ConfigurationManager.Current.IsRootExclusion(segments[1]))
            {
                baseReq._isRootExclusion = true;
            }
        }
Exemplo n.º 13
0
 public void Init(System.Web.HttpApplication context)
 {
     _context = (BASEApplication)context;
     _context.BeginRequest += new EventHandler(_context_BeginRequest);
     Logging.Logger.Log("UrlParserHttpModule Init()");
 }