protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            jQuery.RequestRegistration();
            AJAX.RegisterScriptManager();

            cboSearchEngine.SelectedIndexChanged += OnSearchEngineIndexChanged;
            grdProviders.UpdateCommand           += ProvidersUpdateCommand;
            grdProviders.ItemCommand             += ProvidersItemCommand;
            lnkResetCache.Click   += OnResetCacheClick;
            lnkSaveAll.Click      += OnSaveAllClick;
            cmdVerification.Click += OnVerifyClick;
            try
            {
                if (Page.IsPostBack == false)
                {
                    LoadConfiguration();

                    if (IsChildPortal(PortalSettings, Context))
                    {
                        lnkSiteMapUrl.Text = Globals.AddHTTP(Globals.GetDomainName(Request)) + @"/SiteMap.aspx?portalid=" + PortalId;
                    }
                    else
                    {
                        lnkSiteMapUrl.Text = Globals.AddHTTP(PortalSettings.PortalAlias.HTTPAlias) + @"/SiteMap.aspx";
                    }

                    lnkSiteMapUrl.NavigateUrl = lnkSiteMapUrl.Text;

                    BindProviders();
                    SetSearchEngineSubmissionURL();
                }

                GrdProvidersNeedDataSorce();

                grdProviders.NeedDataSource += OnGridNeedDataSource;
            }
            catch (Exception exc)
            {
                Exceptions.ProcessModuleLoadException(this, exc);
            }
        }
Exemple #2
0
        public void CreateVerification(string verification)
        {
            if (!string.IsNullOrEmpty(verification) && verification.EndsWith(".html"))
            {
                if (!File.Exists(Globals.ApplicationMapPath + "\\" + verification))
                {
                    string portalAlias = !String.IsNullOrEmpty(_portalSettings.DefaultPortalAlias)
                                        ? _portalSettings.DefaultPortalAlias
                                        : _portalSettings.PortalAlias.HTTPAlias;

                    //write SiteMap verification file
                    var objStream = File.CreateText(Globals.ApplicationMapPath + "\\" + verification);
                    objStream.WriteLine("Google SiteMap Verification File");
                    objStream.WriteLine(" - " + Globals.AddHTTP(portalAlias) + @"/SiteMap.aspx");
                    objStream.WriteLine(" - " + UserController.Instance.GetCurrentUserInfo().DisplayName);
                    objStream.Close();
                }
            }
        }
        /// <summary>
        ///   Generates a sitemapindex file.
        /// </summary>
        /// <param name = "output">The output stream.</param>
        /// <param name = "totalFiles">Number of files that are included in the sitemap index.</param>
        private void WriteSitemapIndex(TextWriter output, int totalFiles)
        {
            TextWriter sitemapOutput;

            using (sitemapOutput = new StreamWriter(this.PortalSettings.HomeSystemDirectoryMapPath + "Sitemap\\" + this.CacheFileName, false, Encoding.UTF8))
            {
                // Initialize writer
                var settings = new XmlWriterSettings();
                settings.Indent             = true;
                settings.Encoding           = Encoding.UTF8;
                settings.OmitXmlDeclaration = false;

                using (var writer = XmlWriter.Create(sitemapOutput, settings))
                {
                    // build header
                    writer.WriteStartElement("sitemapindex", "http://www.sitemaps.org/schemas/sitemap/" + SITEMAP_VERSION);

                    // write urls to output
                    for (int index = 1; index <= totalFiles; index++)
                    {
                        string url = null;

                        url = "~/Sitemap.aspx?i=" + index;
                        if (this.IsChildPortal(this.PortalSettings, HttpContext.Current))
                        {
                            url += "&portalid=" + this.PortalSettings.PortalId;
                        }

                        writer.WriteStartElement("sitemap");
                        writer.WriteElementString("loc", Globals.AddHTTP(HttpContext.Current.Request.Url.Host + Globals.ResolveUrl(url)));
                        writer.WriteElementString("lastmod", DateTime.Now.ToString("yyyy-MM-dd"));
                        writer.WriteEndElement();
                    }

                    writer.WriteEndElement();
                    writer.Close();
                }

                sitemapOutput.Flush();
                sitemapOutput.Close();
            }
        }
 /// <summary>
 /// Validates the alias.
 /// </summary>
 /// <param name="portalAlias">The portal alias.</param>
 /// <param name="ischild">if set to <c>true</c> [ischild].</param>
 /// <returns><c>true</c> if the alias is a valid url format; otherwise return <c>false</c>.</returns>
 public static bool ValidateAlias(string portalAlias, bool ischild)
 {
     if (ischild)
     {
         return(ValidateAlias(portalAlias, ischild, false));
     }
     else
     {
         //validate the domain
         Uri result;
         if (Uri.TryCreate(Globals.AddHTTP(portalAlias), UriKind.Absolute, out result))
         {
             return(ValidateAlias(result.Host, false, true) && ValidateAlias(portalAlias, false, false));
         }
         else
         {
             return(false);
         }
     }
 }
Exemple #5
0
        private string GetRedirectUrl(bool checkSetting = true)
        {
            var redirectUrl = "";
            var redirectAfterRegistration = PortalSettings.Registration.RedirectAfterRegistration;

            if (checkSetting && redirectAfterRegistration > 0)             //redirect to after registration page
            {
                redirectUrl = Globals.NavigateURL(redirectAfterRegistration);
            }
            else
            {
                if (Request.QueryString["returnurl"] != null)
                {
                    //return to the url passed to register
                    redirectUrl = HttpUtility.UrlDecode(Request.QueryString["returnurl"]);
                    //redirect url should never contain a protocol ( if it does, it is likely a cross-site request forgery attempt )
                    if (redirectUrl.Contains("://") &&
                        !redirectUrl.StartsWith(Globals.AddHTTP(PortalSettings.PortalAlias.HTTPAlias),
                                                StringComparison.InvariantCultureIgnoreCase))
                    {
                        redirectUrl = "";
                    }
                    if (redirectUrl.Contains("?returnurl"))
                    {
                        string baseURL = redirectUrl.Substring(0,
                                                               redirectUrl.IndexOf("?returnurl", StringComparison.Ordinal));
                        string returnURL =
                            redirectUrl.Substring(redirectUrl.IndexOf("?returnurl", StringComparison.Ordinal) + 11);

                        redirectUrl = string.Concat(baseURL, "?returnurl", HttpUtility.UrlEncode(returnURL));
                    }
                }
                if (String.IsNullOrEmpty(redirectUrl))
                {
                    //redirect to current page
                    redirectUrl = Globals.NavigateURL();
                }
            }

            return(redirectUrl);
        }
        public HttpResponseMessage GetContentUrl()
        {
            var request = HttpContext.Current.Request;

            var builder = new UriBuilder
            {
                Scheme = request.Url.Scheme,
                Host   = "www.dnnsoftware.com",
                Path   = String.Format("DesktopModules/DNNCorp/GettingStarted/{0}/{1}/index.html",
                                       DotNetNukeContext.Current.Application.Name.Replace(".", "_"),
                                       DotNetNukeContext.Current.Application.Version.ToString(3)),
                Query = String.Format("locale={0}", Thread.CurrentThread.CurrentUICulture)
            };
            var contentUrl = builder.Uri.AbsoluteUri;

            var fallbackUrl = Globals.AddHTTP(PortalController.GetCurrentPortalSettings().DefaultPortalAlias) + "/Portals/_default/GettingStartedFallback.htm";

            var isValid = IsValidUrl(contentUrl);

            return(Request.CreateResponse(HttpStatusCode.OK, new { Url = isValid ? contentUrl : fallbackUrl }));
        }
 protected override void OnLoad(EventArgs e)
 {
     base.OnLoad(e);
     try
     {
         if (!String.IsNullOrEmpty(BorderWidth))
         {
             imgLogo.BorderWidth = Unit.Parse(BorderWidth);
         }
         bool logoVisible = false;
         if (!String.IsNullOrEmpty(PortalSettings.LogoFile))
         {
             var fileInfo = GetLogoFileInfo();
             if (fileInfo != null)
             {
                 string imageUrl = FileManager.Instance.GetUrl(fileInfo);
                 if (!String.IsNullOrEmpty(imageUrl))
                 {
                     imgLogo.ImageUrl = imageUrl;
                     logoVisible      = true;
                 }
             }
         }
         imgLogo.Visible       = logoVisible;
         imgLogo.AlternateText = PortalSettings.PortalName;
         hypLogo.ToolTip       = PortalSettings.PortalName;
         if (PortalSettings.HomeTabId != -1)
         {
             hypLogo.NavigateUrl = Globals.NavigateURL(PortalSettings.HomeTabId);
         }
         else
         {
             hypLogo.NavigateUrl = Globals.AddHTTP(PortalSettings.PortalAlias.HTTPAlias);
         }
     }
     catch (Exception exc)
     {
         Exceptions.ProcessModuleLoadException(this, exc);
     }
 }
Exemple #8
0
        /// <summary>
        ///   Return the sitemap url node for the page
        /// </summary>
        /// <param name = "objTab">The page being indexed</param>
        /// <param name="language">Culture code to use in the URL</param>
        /// <returns>A SitemapUrl object for the current page</returns>
        /// <remarks>
        /// </remarks>
        private SitemapUrl GetPageUrl(TabInfo objTab, string language)
        {
            var pageUrl = new SitemapUrl();

            pageUrl.Url = Globals.NavigateURL(objTab.TabID, objTab.IsSuperTab, ps, "", language);

            string portalAlias = !String.IsNullOrEmpty(ps.DefaultPortalAlias)
                                ? ps.DefaultPortalAlias
                                : ps.PortalAlias.HTTPAlias;

            if (pageUrl.Url.ToLower().IndexOf(portalAlias.ToLower(), StringComparison.Ordinal) == -1)
            {
                // code to fix a bug in dnn5.1.2 for navigateurl
                if ((HttpContext.Current != null))
                {
                    pageUrl.Url = Globals.AddHTTP(HttpContext.Current.Request.Url.Host + pageUrl.Url);
                }
                else
                {
                    // try to use the portalalias
                    pageUrl.Url = Globals.AddHTTP(portalAlias.ToLower()) + pageUrl.Url;
                }
            }

            pageUrl.Priority     = GetPriority(objTab);
            pageUrl.LastModified = objTab.LastModifiedOnDate;
            var modCtrl = new ModuleController();

            foreach (ModuleInfo m in modCtrl.GetTabModules(objTab.TabID).Values)
            {
                if (m.LastModifiedOnDate > objTab.LastModifiedOnDate)
                {
                    pageUrl.LastModified = m.LastModifiedOnDate;
                }
            }
            pageUrl.ChangeFrequency = SitemapChangeFrequency.Daily;

            return(pageUrl);
        }
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            JavaScript.RequestRegistration(CommonJs.jQuery);
            AJAX.RegisterScriptManager();

            cboSearchEngine.SelectedIndexChanged += OnSearchEngineIndexChanged;
            grdProviders.UpdateCommand           += ProvidersUpdateCommand;
            grdProviders.ItemCommand             += ProvidersItemCommand;
            lnkResetCache.Click   += OnResetCacheClick;
            lnkSaveAll.Click      += OnSaveAllClick;
            cmdVerification.Click += OnVerifyClick;
            try
            {
                if (Page.IsPostBack == false)
                {
                    LoadConfiguration();

                    string portalAlias = !String.IsNullOrEmpty(PortalSettings.DefaultPortalAlias)
                                        ? PortalSettings.DefaultPortalAlias
                                        : PortalSettings.PortalAlias.HTTPAlias;
                    lnkSiteMapUrl.Text = Globals.AddHTTP(portalAlias) + @"/SiteMap.aspx";

                    lnkSiteMapUrl.NavigateUrl = lnkSiteMapUrl.Text;

                    BindProviders();
                    SetSearchEngineSubmissionURL();
                }

                GrdProvidersNeedDataSorce();

                grdProviders.NeedDataSource += OnGridNeedDataSource;
            }
            catch (Exception exc)
            {
                Exceptions.ProcessModuleLoadException(this, exc);
            }
        }
Exemple #10
0
            public static ActionResult GetSitemapSettings()
            {
                ActionResult actionResult = new ActionResult();

                try
                {
                    string portalAlias = !string.IsNullOrEmpty(PortalSettings.Current.DefaultPortalAlias)
                                    ? PortalSettings.Current.DefaultPortalAlias
                                    : PortalSettings.Current.PortalAlias.HTTPAlias;

                    string str = PortalController.GetPortalSetting("SitemapMinPriority", PortalSettings.Current.PortalId, "0.1");
                    if (!float.TryParse(str, out float sitemapMinPriority))
                    {
                        sitemapMinPriority = 0.1f;
                    }

                    str = PortalController.GetPortalSetting("SitemapExcludePriority", PortalSettings.Current.PortalId, "0.1");
                    if (!float.TryParse(str, out float sitemapExcludePriority))
                    {
                        sitemapExcludePriority = 0.1f;
                    }

                    var Settings = new
                    {
                        SitemapUrl             = Globals.AddHTTP(portalAlias) + @"/SiteMap.aspx",
                        SitemapLevelMode       = PortalController.GetPortalSettingAsBoolean("SitemapLevelMode", PortalSettings.Current.PortalId, false),
                        SitemapMinPriority     = sitemapMinPriority,
                        SitemapIncludeHidden   = PortalController.GetPortalSettingAsBoolean("SitemapIncludeHidden", PortalSettings.Current.PortalId, false),
                        SitemapExcludePriority = sitemapExcludePriority,
                        SitemapCacheDays       = PortalController.GetPortalSettingAsInteger("SitemapCacheDays", PortalSettings.Current.PortalId, 1)
                    };
                    actionResult.Data = Settings;
                }
                catch (Exception exc)
                {
                    actionResult.AddError(HttpStatusCode.InternalServerError.ToString(), exc.Message);
                }
                return(actionResult);
            }
Exemple #11
0
        private string FormatPortalAliases(int PortalID, int TabId)
        {
            var str = new StringBuilder();

            try
            {
                var             objPortalAliasController = new PortalAliasController();
                ArrayList       arr = objPortalAliasController.GetPortalAliasArrayByPortalID(PortalID);
                PortalAliasInfo objPortalAliasInfo;
                int             i;
                for (i = 0; i <= arr.Count - 1; i++)
                {
                    objPortalAliasInfo = (PortalAliasInfo)arr[i];
                    str.Append("<a href=\"" + Globals.AddHTTP(objPortalAliasInfo.HTTPAlias) + "\">" + objPortalAliasInfo.HTTPAlias + "</a>");
                }
            }
            catch (Exception exc) //Module failed to load
            {
                Exceptions.ProcessModuleLoadException(this, exc);
            }
            return(str.ToString());
        }
        protected string GetFormattedLink(object dataItem)
        {
            var returnValue = new StringBuilder();

            if ((dataItem is TabInfo))
            {
                var tab = (TabInfo)dataItem;
                if ((tab != null))
                {
                    int index = 0;
                    TabCtrl.PopulateBreadCrumbs(ref tab);
                    foreach (TabInfo t in tab.BreadCrumbs)
                    {
                        if ((index > 0))
                        {
                            returnValue.Append(" > ");
                        }
                        if ((tab.BreadCrumbs.Count - 1 == index))
                        {
                            string    url;
                            var       objPortalAliasController = new PortalAliasController();
                            ArrayList arr = objPortalAliasController.GetPortalAliasArrayByPortalID(t.PortalID);
                            var       objPortalAliasInfo = (PortalAliasInfo)arr[0];
                            //url = Globals.AddHTTP(objPortalAliasInfo.HTTPAlias) + "/Default.aspx?tabId=" + t.TabID;
                            //Fariborz Khosravi
                            url = Globals.AddHTTP(objPortalAliasInfo.HTTPAlias) + "/" + Globals.glbDefaultPage + "?tabId=" + t.TabID;
                            returnValue.AppendFormat("<a href=\"{0}\">{1}</a>", url, t.LocalizedTabName);
                        }
                        else
                        {
                            returnValue.AppendFormat("{0}", t.LocalizedTabName);
                        }
                        index = index + 1;
                    }
                }
            }
            return(returnValue.ToString());
        }
Exemple #13
0
        public static string ValidReturnUrl(string url)
        {
            if (string.IsNullOrEmpty(url))
            {
                return(url);
            }

            //clean the return url to avoid possible XSS attack.
            var cleanUrl = new PortalSecurity().InputFilter(url, PortalSecurity.FilterFlag.NoScripting);

            if (url != cleanUrl)
            {
                url = string.Empty;
            }

            //redirect url should never contain a protocol ( if it does, it is likely a cross-site request forgery attempt )
            if (url.Contains("://"))
            {
                var portalSettings = PortalSettings.Current;
                if (portalSettings == null ||
                    !url.StartsWith(Globals.AddHTTP(portalSettings.PortalAlias.HTTPAlias), StringComparison.InvariantCultureIgnoreCase))
                {
                    url = string.Empty;
                }
            }

            if (url.StartsWith("//"))
            {
                var urlWithNoProtocol = url.Substring(2);
                var portalSettings    = PortalSettings.Current;
                if (portalSettings == null ||
                    !urlWithNoProtocol.StartsWith(portalSettings.PortalAlias.HTTPAlias, StringComparison.InvariantCultureIgnoreCase))
                {
                    url = string.Empty;
                }
            }
            return(url);
        }
        public string GetTabUrl(TabInfo tab)
        {
            var url = string.Empty;

            if (tab.IsSuperTab || (Config.GetFriendlyUrlProvider() != "advanced"))
            {
                return(url);
            }

            if (tab.TabUrls.Count > 0)
            {
                var tabUrl = tab.TabUrls.SingleOrDefault(t => t.IsSystem && t.HttpStatus == "200" && t.SeqNum == 0);

                if (tabUrl != null)
                {
                    url = tabUrl.Url;
                }
            }

            if (string.IsNullOrEmpty(url) && tab.TabID > -1 && !tab.IsSuperTab)
            {
                var friendlyUrlSettings = new FriendlyUrlSettings(PortalSettings.Current.PortalId);
                var baseUrl             = Globals.AddHTTP(PortalSettings.Current.PortalAlias.HTTPAlias) + "/Default.aspx?TabId=" + tab.TabID;
                var path = AdvancedFriendlyUrlProvider.ImprovedFriendlyUrl(tab,
                                                                           baseUrl,
                                                                           Globals.glbDefaultPage,
                                                                           PortalSettings.Current.PortalAlias.HTTPAlias,
                                                                           false,  // dnndev-27493 :we want any custom Urls that apply
                                                                           friendlyUrlSettings,
                                                                           Guid.Empty);

                url = path.Replace(Globals.AddHTTP(PortalSettings.Current.PortalAlias.HTTPAlias), "");
            }

            return(url);
        }
        protected void ddlPage_SelectionChanged(object sender, EventArgs e)
        {
            gvCustomUrls.MasterTableView.IsItemInserted = false;
            gvCustomUrls.Rebind();

            int           tabID = ddlPage.SelectedItemValueAsInt;
            TabController tc    = new TabController();
            TabInfo       tab   = tc.GetTab(tabID, PortalId, false);

            if (tab != null)
            {
                var baseUrl = Globals.AddHTTP(PortalAlias.HTTPAlias) + "/Default.aspx?TabId=" + tab.TabID;
                var path    = AdvancedFriendlyUrlProvider.ImprovedFriendlyUrl(tab,
                                                                              baseUrl,
                                                                              Globals.glbDefaultPage,
                                                                              PortalAlias.HTTPAlias,
                                                                              true,
                                                                              new DotNetNuke.Entities.Urls.FriendlyUrlSettings(PortalId),
                                                                              Guid.Empty);

                hypSystemUrl.NavigateUrl = path;
                hypSystemUrl.Text        = path;
            }
        }
Exemple #16
0
        /// <summary>
        /// Creates an RSS Item
        /// </summary>
        /// <param name="searchResult"></param>
        /// <returns></returns>
        /// <remarks></remarks>
        private GenericRssElement GetRssItem(SearchResult searchResult)
        {
            var item = new GenericRssElement();
            var url  = searchResult.Url;

            if (url.Trim() == "")
            {
                url = Globals.NavigateURL(searchResult.TabId);
                if (url.ToLower().IndexOf(HttpContext.Current.Request.Url.Host.ToLower()) == -1)
                {
                    url = Globals.AddHTTP(HttpContext.Current.Request.Url.Host) + url;
                }
            }

            item["title"]       = searchResult.Title;
            item["description"] = searchResult.Description;
            item["pubDate"]     = searchResult.ModifiedTimeUtc.ToUniversalTime().ToString("r");
            item["link"]        = url;
            item["guid"]        = url;
            //TODO:  JMB: We need to figure out how to persist the dc prefix in the XML output.  See the Render method below.
            //item("dc:creator") = SearchItem.AuthorName

            return(item);
        }
Exemple #17
0
        protected void CmdSwitchClick(object sender, EventArgs e)
        {
            try
            {
                if (!string.IsNullOrEmpty(this.SitesLst.SelectedValue))
                {
                    int selectedPortalID = int.Parse(this.SitesLst.SelectedValue);
                    var portalAliases    = PortalAliasController.Instance.GetPortalAliasesByPortalId(selectedPortalID).ToList();

                    if (portalAliases.Count > 0 && (portalAliases[0] != null))
                    {
                        this.Response.Redirect(Globals.AddHTTP(((PortalAliasInfo)portalAliases[0]).HTTPAlias));
                    }
                }
            }
            catch (ThreadAbortException)
            {
                // Do nothing we are not logging ThreadAbortxceptions caused by redirects
            }
            catch (Exception ex)
            {
                Exceptions.LogException(ex);
            }
        }
Exemple #18
0
        public static string ValidReturnUrl(string url)
        {
            try
            {
                if (string.IsNullOrEmpty(url))
                {
                    // DNN-10193: returns the same value as passed in rather than empty string
                    return(url);
                }

                url = url.Replace("\\", "/");
                if (url.ToLowerInvariant().Contains("data:"))
                {
                    return(string.Empty);
                }

                // clean the return url to avoid possible XSS attack.
                var cleanUrl = PortalSecurity.Instance.InputFilter(url, PortalSecurity.FilterFlag.NoScripting);
                if (url != cleanUrl)
                {
                    return(string.Empty);
                }

                // redirect url should never contain a protocol ( if it does, it is likely a cross-site request forgery attempt )
                var urlWithNoQuery = url;
                if (urlWithNoQuery.Contains("?"))
                {
                    urlWithNoQuery = urlWithNoQuery.Substring(0, urlWithNoQuery.IndexOf("?", StringComparison.InvariantCultureIgnoreCase));
                }

                if (urlWithNoQuery.Contains("://"))
                {
                    var portalSettings = PortalSettings.Current;
                    var aliasWithHttp  = Globals.AddHTTP(portalSettings.PortalAlias.HTTPAlias);
                    var uri1           = new Uri(url);
                    var uri2           = new Uri(aliasWithHttp);

                    // protocol switching (HTTP <=> HTTPS) is allowed by not being checked here
                    if (!string.Equals(uri1.DnsSafeHost, uri2.DnsSafeHost, StringComparison.CurrentCultureIgnoreCase))
                    {
                        return(string.Empty);
                    }

                    // this check is mainly for child portals
                    if (!uri1.AbsolutePath.StartsWith(uri2.AbsolutePath, StringComparison.InvariantCultureIgnoreCase))
                    {
                        return(string.Empty);
                    }
                }

                while (url.StartsWith("///"))
                {
                    url = url.Substring(1);
                }

                if (url.StartsWith("//"))
                {
                    var urlWithNoProtocol = url.Substring(2);
                    var portalSettings    = PortalSettings.Current;

                    // note: this can redirict from parent to childe and vice versa
                    if (!urlWithNoProtocol.StartsWith(portalSettings.PortalAlias.HTTPAlias + "/", StringComparison.InvariantCultureIgnoreCase))
                    {
                        return(string.Empty);
                    }
                }

                return(url);
            }
            catch (UriFormatException)
            {
                return(string.Empty);
            }
        }
Exemple #19
0
        public string GetProperty(string propertyName, string format, CultureInfo formatProvider, UserInfo accessingUser, Scope accessLevel, ref bool propertyNotFound)
        {
            var outputFormat = string.Empty;

            if (format == string.Empty)
            {
                outputFormat = "g";
            }
            var lowerPropertyName = propertyName.ToLowerInvariant();

            if (accessLevel == Scope.NoSettings)
            {
                propertyNotFound = true;
                return(PropertyAccess.ContentLocked);
            }
            propertyNotFound = true;
            var result   = string.Empty;
            var isPublic = true;

            switch (lowerPropertyName)
            {
            case "url":
                propertyNotFound = false;
                result           = PropertyAccess.FormatString(PortalAlias.HTTPAlias, format);
                break;

            case "fullurl":     //return portal alias with protocol
                propertyNotFound = false;
                result           = PropertyAccess.FormatString(Globals.AddHTTP(PortalAlias.HTTPAlias), format);
                break;

            case "passwordreminderurl":     //if regsiter page defined in portal settings, then get that page url, otherwise return home page.
                propertyNotFound = false;
                var reminderUrl = Globals.AddHTTP(PortalAlias.HTTPAlias);
                if (RegisterTabId > Null.NullInteger)
                {
                    reminderUrl = Globals.RegisterURL(string.Empty, string.Empty);
                }
                result = PropertyAccess.FormatString(reminderUrl, format);
                break;

            case "portalid":
                propertyNotFound = false;
                result           = (PortalId.ToString(outputFormat, formatProvider));
                break;

            case "portalname":
                propertyNotFound = false;
                result           = PropertyAccess.FormatString(PortalName, format);
                break;

            case "homedirectory":
                propertyNotFound = false;
                result           = PropertyAccess.FormatString(HomeDirectory, format);
                break;

            case "homedirectorymappath":
                isPublic         = false;
                propertyNotFound = false;
                result           = PropertyAccess.FormatString(HomeDirectoryMapPath, format);
                break;

            case "logofile":
                propertyNotFound = false;
                result           = PropertyAccess.FormatString(LogoFile, format);
                break;

            case "footertext":
                propertyNotFound = false;
                var footerText = FooterText.Replace("[year]", DateTime.Now.Year.ToString());
                result = PropertyAccess.FormatString(footerText, format);
                break;

            case "expirydate":
                isPublic         = false;
                propertyNotFound = false;
                result           = (ExpiryDate.ToString(outputFormat, formatProvider));
                break;

            case "userregistration":
                isPublic         = false;
                propertyNotFound = false;
                result           = (UserRegistration.ToString(outputFormat, formatProvider));
                break;

            case "banneradvertising":
                isPublic         = false;
                propertyNotFound = false;
                result           = (BannerAdvertising.ToString(outputFormat, formatProvider));
                break;

            case "currency":
                propertyNotFound = false;
                result           = PropertyAccess.FormatString(Currency, format);
                break;

            case "administratorid":
                isPublic         = false;
                propertyNotFound = false;
                result           = (AdministratorId.ToString(outputFormat, formatProvider));
                break;

            case "email":
                propertyNotFound = false;
                result           = PropertyAccess.FormatString(Email, format);
                break;

            case "hostfee":
                isPublic         = false;
                propertyNotFound = false;
                result           = (HostFee.ToString(outputFormat, formatProvider));
                break;

            case "hostspace":
                isPublic         = false;
                propertyNotFound = false;
                result           = (HostSpace.ToString(outputFormat, formatProvider));
                break;

            case "pagequota":
                isPublic         = false;
                propertyNotFound = false;
                result           = (PageQuota.ToString(outputFormat, formatProvider));
                break;

            case "userquota":
                isPublic         = false;
                propertyNotFound = false;
                result           = (UserQuota.ToString(outputFormat, formatProvider));
                break;

            case "administratorroleid":
                isPublic         = false;
                propertyNotFound = false;
                result           = (AdministratorRoleId.ToString(outputFormat, formatProvider));
                break;

            case "administratorrolename":
                isPublic         = false;
                propertyNotFound = false;
                result           = PropertyAccess.FormatString(AdministratorRoleName, format);
                break;

            case "registeredroleid":
                isPublic         = false;
                propertyNotFound = false;
                result           = (RegisteredRoleId.ToString(outputFormat, formatProvider));
                break;

            case "registeredrolename":
                isPublic         = false;
                propertyNotFound = false;
                result           = PropertyAccess.FormatString(RegisteredRoleName, format);
                break;

            case "description":
                propertyNotFound = false;
                result           = PropertyAccess.FormatString(Description, format);
                break;

            case "keywords":
                propertyNotFound = false;
                result           = PropertyAccess.FormatString(KeyWords, format);
                break;

            case "backgroundfile":
                propertyNotFound = false;
                result           = PropertyAccess.FormatString(BackgroundFile, format);
                break;

            case "admintabid":
                isPublic         = false;
                propertyNotFound = false;
                result           = AdminTabId.ToString(outputFormat, formatProvider);
                break;

            case "supertabid":
                isPublic         = false;
                propertyNotFound = false;
                result           = SuperTabId.ToString(outputFormat, formatProvider);
                break;

            case "splashtabid":
                isPublic         = false;
                propertyNotFound = false;
                result           = SplashTabId.ToString(outputFormat, formatProvider);
                break;

            case "hometabid":
                isPublic         = false;
                propertyNotFound = false;
                result           = HomeTabId.ToString(outputFormat, formatProvider);
                break;

            case "logintabid":
                isPublic         = false;
                propertyNotFound = false;
                result           = LoginTabId.ToString(outputFormat, formatProvider);
                break;

            case "registertabid":
                isPublic         = false;
                propertyNotFound = false;
                result           = RegisterTabId.ToString(outputFormat, formatProvider);
                break;

            case "usertabid":
                isPublic         = false;
                propertyNotFound = false;
                result           = UserTabId.ToString(outputFormat, formatProvider);
                break;

            case "defaultlanguage":
                propertyNotFound = false;
                result           = PropertyAccess.FormatString(DefaultLanguage, format);
                break;

            case "users":
                isPublic         = false;
                propertyNotFound = false;
                result           = Users.ToString(outputFormat, formatProvider);
                break;

            case "pages":
                isPublic         = false;
                propertyNotFound = false;
                result           = Pages.ToString(outputFormat, formatProvider);
                break;

            case "contentvisible":
                isPublic = false;
                break;

            case "controlpanelvisible":
                isPublic         = false;
                propertyNotFound = false;
                result           = PropertyAccess.Boolean2LocalizedYesNo(ControlPanelVisible, formatProvider);
                break;
            }
            if (!isPublic && accessLevel != Scope.Debug)
            {
                propertyNotFound = true;
                result           = PropertyAccess.ContentLocked;
            }
            return(result);
        }
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            this.cmdDisplay.Click += this.cmdDisplay_Click;

            try
            {
                // this needs to execute always to the client script code is registred in InvokePopupCal
                this.cmdStartCalendar.NavigateUrl = Calendar.InvokePopupCal(this.txtStartDate);
                this.cmdEndCalendar.NavigateUrl   = Calendar.InvokePopupCal(this.txtEndDate);
                if (!this.Page.IsPostBack)
                {
                    if (!string.IsNullOrEmpty(this._URL))
                    {
                        this.lblLogURL.Text = this.URL; // saved for loading Log grid
                        TabType URLType = Globals.GetURLType(this._URL);
                        if (URLType == TabType.File && this._URL.StartsWith("fileid=", StringComparison.InvariantCultureIgnoreCase) == false)
                        {
                            // to handle legacy scenarios before the introduction of the FileServerHandler
                            var fileName = Path.GetFileName(this._URL);

                            var folderPath = this._URL.Substring(0, this._URL.LastIndexOf(fileName));
                            var folder     = FolderManager.Instance.GetFolder(this.PortalSettings.PortalId, folderPath);

                            var file = FileManager.Instance.GetFile(folder, fileName);

                            this.lblLogURL.Text = "FileID=" + file.FileId;
                        }

                        var             objUrls        = new UrlController();
                        UrlTrackingInfo objUrlTracking = objUrls.GetUrlTracking(this.PortalSettings.PortalId, this.lblLogURL.Text, this.ModuleID);
                        if (objUrlTracking != null)
                        {
                            if (string.IsNullOrEmpty(this._FormattedURL))
                            {
                                this.lblURL.Text = Globals.LinkClick(this.URL, this.PortalSettings.ActiveTab.TabID, this.ModuleID, false);
                                if (!this.lblURL.Text.StartsWith("http") && !this.lblURL.Text.StartsWith("mailto"))
                                {
                                    this.lblURL.Text = Globals.AddHTTP(this.Request.Url.Host) + this.lblURL.Text;
                                }
                            }
                            else
                            {
                                this.lblURL.Text = this._FormattedURL;
                            }

                            this.lblCreatedDate.Text = objUrlTracking.CreatedDate.ToString();

                            if (objUrlTracking.TrackClicks)
                            {
                                this.pnlTrack.Visible = true;
                                if (string.IsNullOrEmpty(this._TrackingURL))
                                {
                                    if (!this.URL.StartsWith("http"))
                                    {
                                        this.lblTrackingURL.Text = Globals.AddHTTP(this.Request.Url.Host);
                                    }

                                    this.lblTrackingURL.Text += Globals.LinkClick(this.URL, this.PortalSettings.ActiveTab.TabID, this.ModuleID, objUrlTracking.TrackClicks);
                                }
                                else
                                {
                                    this.lblTrackingURL.Text = this._TrackingURL;
                                }

                                this.lblClicks.Text = objUrlTracking.Clicks.ToString();
                                if (!Null.IsNull(objUrlTracking.LastClick))
                                {
                                    this.lblLastClick.Text = objUrlTracking.LastClick.ToString();
                                }
                            }

                            if (objUrlTracking.LogActivity)
                            {
                                this.pnlLog.Visible = true;

                                this.txtStartDate.Text = DateTime.Today.AddDays(-6).ToShortDateString();
                                this.txtEndDate.Text   = DateTime.Today.AddDays(1).ToShortDateString();
                            }
                        }
                    }
                    else
                    {
                        this.Visible = false;
                    }
                }
            }
            catch (Exception exc) // Module failed to load
            {
                Exceptions.ProcessModuleLoadException(this, exc);
            }
        }
Exemple #21
0
        /// <summary>
        /// This method.
        /// </summary>
        /// <param name="channelName"></param>
        /// <param name="userName"></param>
        /// <remarks></remarks>
        protected override void PopulateChannel(string channelName, string userName)
        {
            ModuleInfo objModule;

            if (this.Request == null || this.Settings == null || this.Settings.ActiveTab == null || this.ModuleId == Null.NullInteger)
            {
                return;
            }

            this.Channel["title"] = this.Settings.PortalName;
            this.Channel["link"]  = Globals.AddHTTP(Globals.GetDomainName(this.Request));
            if (!string.IsNullOrEmpty(this.Settings.Description))
            {
                this.Channel["description"] = this.Settings.Description;
            }
            else
            {
                this.Channel["description"] = this.Settings.PortalName;
            }

            this.Channel["language"]  = this.Settings.DefaultLanguage;
            this.Channel["copyright"] = !string.IsNullOrEmpty(this.Settings.FooterText) ? this.Settings.FooterText.Replace("[year]", DateTime.Now.Year.ToString()) : string.Empty;
            this.Channel["webMaster"] = this.Settings.Email;

            IList <SearchResult> searchResults = null;
            var query = new SearchQuery();

            query.PortalIds     = new[] { this.Settings.PortalId };
            query.TabId         = this.TabId;
            query.ModuleId      = this.ModuleId;
            query.SearchTypeIds = new[] { SearchHelper.Instance.GetSearchTypeByName("module").SearchTypeId };

            try
            {
                searchResults = SearchController.Instance.ModuleSearch(query).Results;
            }
            catch (Exception ex)
            {
                Exceptions.Exceptions.LogException(ex);
            }

            if (searchResults != null)
            {
                foreach (var result in searchResults)
                {
                    if (!result.UniqueKey.StartsWith(Constants.ModuleMetaDataPrefixTag) && TabPermissionController.CanViewPage())
                    {
                        if (this.Settings.ActiveTab.StartDate < DateTime.Now && this.Settings.ActiveTab.EndDate > DateTime.Now)
                        {
                            objModule = ModuleController.Instance.GetModule(result.ModuleId, query.TabId, false);
                            if (objModule != null && objModule.DisplaySyndicate && objModule.IsDeleted == false)
                            {
                                if (ModulePermissionController.CanViewModule(objModule))
                                {
                                    if (Convert.ToDateTime(objModule.StartDate == Null.NullDate ? DateTime.MinValue : objModule.StartDate) < DateTime.Now &&
                                        Convert.ToDateTime(objModule.EndDate == Null.NullDate ? DateTime.MaxValue : objModule.EndDate) > DateTime.Now)
                                    {
                                        this.Channel.Items.Add(this.GetRssItem(result));
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
Exemple #22
0
        public HttpResponseMessage SwitchSite(SwitchSiteDTO dto)
        {
            if (UserController.GetCurrentUserInfo().IsSuperUser)
            {
                try
                {
                    if ((!string.IsNullOrEmpty(dto.Site)))
                    {
                        int selectedPortalID = int.Parse(dto.Site);
                        var portalAliases    = TestablePortalAliasController.Instance.GetPortalAliasesByPortalId(selectedPortalID).ToList();

                        if ((portalAliases.Count > 0 && (portalAliases[0] != null)))
                        {
                            return(Request.CreateResponse(HttpStatusCode.OK, new { RedirectURL = Globals.AddHTTP(((PortalAliasInfo)portalAliases[0]).HTTPAlias) }));
                        }
                    }
                }
                catch (System.Threading.ThreadAbortException)
                {
                    //Do nothing we are not logging ThreadAbortxceptions caused by redirects
                }
                catch (Exception ex)
                {
                    Exceptions.LogException(ex);
                }
            }

            return(Request.CreateResponse(HttpStatusCode.InternalServerError));
        }
        private void RazorDisplayDataEntry(String entryId)
        {
            var productData = new ProductData();

            if (Utils.IsNumeric(entryId))
            {
                productData = ProductUtils.GetProductData(Convert.ToInt32(entryId), Utils.GetCurrentCulture(), true, EntityTypeCode);
            }

            if (productData.Exists && (productData.Info.PortalId == -1 || productData.Info.PortalId == PortalId))
            {
                if (PortalSettings.HomeTabId == TabId)
                {
                    PageIncludes.IncludeCanonicalLink(Page, Globals.AddHTTP(PortalSettings.PortalAlias.HTTPAlias)); //home page always default of site.
                }
                else
                {
                    PageIncludes.IncludeCanonicalLink(Page, NBrightBuyUtils.GetEntryUrl(PortalId, _eid, "", productData.SEOName, TabId.ToString("")));
                }

                // overwrite SEO data
                if (productData.SEOName != "")
                {
                    BasePage.Title = productData.SEOTitle;
                }
                else
                {
                    BasePage.Title = productData.ProductName;
                }

                if (productData.SEODescription != "")
                {
                    BasePage.Description = productData.SEODescription;
                }

                // if debug , output the xml used.
                if (DebugMode)
                {
                    productData.Info.XMLDoc.Save(PortalSettings.HomeDirectoryMapPath + "debug_entry.xml");
                }
                // insert page header text
                NBrightBuyUtils.RazorIncludePageHeader(ModuleId, Page, Path.GetFileNameWithoutExtension(_templD) + "_seohead" + Path.GetExtension(_templD), _controlPath, ModSettings.ThemeFolder, ModSettings.Settings(), productData);

                #region "do razor template"

                var strOut = NBrightBuyUtils.RazorTemplRender(_templD, ModuleId, "productdetailrazor" + ModuleId.ToString() + "*" + entryId, productData, _controlPath, ModSettings.ThemeFolder, Utils.GetCurrentCulture(), ModSettings.Settings());
                var lit    = new Literal();
                lit.Text = strOut;
                phData.Controls.Add(lit);

                #endregion
            }
            else
            {
                _404code = true;

                // insert page header text
                NBrightBuyUtils.RazorIncludePageHeader(ModuleId, Page, "ProductNotFound_head.cshtml", _controlPath, ModSettings.ThemeFolder, ModSettings.Settings(), productData);

                var strOut = NBrightBuyUtils.RazorTemplRender("ProductNotFound.cshtml", ModuleId, "", productData, _controlPath, ModSettings.ThemeFolder, Utils.GetCurrentCulture(), ModSettings.Settings());
                var lit    = new Literal();
                lit.Text = strOut;
                phData.Controls.Add(lit);
            }
        }
        private string GetLinkUrl(ref DialogParams dialogParams, string link)
        {
            var aliasList = _portalAliasController.GetPortalAliasesByPortalId(dialogParams.PortalId);

            if (dialogParams.LinkUrl.Contains(dialogParams.HomeDirectory))
            {
                string filePath     = dialogParams.LinkUrl.Substring(dialogParams.LinkUrl.IndexOf(dialogParams.HomeDirectory)).Replace(dialogParams.HomeDirectory, "");
                var    linkedFileId = FileManager.Instance.GetFile(dialogParams.PortalId, HttpUtility.UrlDecode(filePath)).FileId;
                link = string.Format("fileID={0}", linkedFileId);
            }
            else
            {
                foreach (PortalAliasInfo portalAlias in aliasList)
                {
                    dialogParams.LinkUrl = dialogParams.LinkUrl.Replace(Globals.AddHTTP(portalAlias.HTTPAlias), "");
                }

                string tabPath     = dialogParams.LinkUrl.Replace("http://", "").Replace("/", "//").Replace(".aspx", "");
                string cultureCode = Localization.SystemLocale;
                //get language info from url.
                var dicLocales = LocaleController.Instance.GetLocales(dialogParams.PortalId);
                foreach (var part in tabPath.Split(new char[] { '/' }, StringSplitOptions.RemoveEmptyEntries))
                {
                    if (dicLocales != null && part.IndexOf("-") > -1)
                    {
                        foreach (KeyValuePair <string, Locale> key in dicLocales)
                        {
                            if (key.Key.ToLower().Equals(part.ToLower()))
                            {
                                cultureCode = key.Value.Code;
                                tabPath     = tabPath.Replace("//" + part, string.Empty);
                                break;
                            }
                        }
                    }
                }

                //Try HumanFriendlyUrl TabPath
                link = TabController.GetTabByTabPath(dialogParams.PortalId, tabPath, cultureCode).ToString();

                if (link == Null.NullInteger.ToString())
                {
                    //Try getting the tabId from the querystring
                    string[] arrParams = dialogParams.LinkUrl.Split('/');
                    for (int i = 0; i < arrParams.Length; i++)
                    {
                        if (arrParams[i].ToLowerInvariant() == "tabid")
                        {
                            link = arrParams[i + 1];
                            break;
                        }
                    }
                    if (link == Null.NullInteger.ToString())
                    {
                        link = dialogParams.LinkUrl;
                    }
                }
            }

            return(link);
        }
        private void SetSearchEngineSubmissionURL()
        {
            try
            {
                if ((cboSearchEngine.SelectedItem != null))
                {
                    var strURL = "";
                    switch (cboSearchEngine.SelectedItem.Text.ToLower().Trim())
                    {
                    case "google":
                        strURL += "http://www.google.com/addurl?q=" + Globals.HTTPPOSTEncode(Globals.AddHTTP(Globals.GetDomainName(Request)));
                        strURL += "&dq=";
                        if (!string.IsNullOrEmpty(PortalSettings.PortalName))
                        {
                            strURL += Globals.HTTPPOSTEncode(PortalSettings.PortalName);
                        }
                        if (!string.IsNullOrEmpty(PortalSettings.Description))
                        {
                            strURL += Globals.HTTPPOSTEncode(PortalSettings.Description);
                        }
                        if (!string.IsNullOrEmpty(PortalSettings.KeyWords))
                        {
                            strURL += Globals.HTTPPOSTEncode(PortalSettings.KeyWords);
                        }
                        strURL += "&submit=Add+URL";
                        break;

                    case "yahoo!":
                        strURL = "http://siteexplorer.search.yahoo.com/submit";
                        break;

                    case "bing":
                        strURL = "http://www.bing.com/webmaster";
                        break;
                    }

                    cmdSubmitSitemap.NavigateUrl = strURL;

                    cmdSubmitSitemap.Target = "_blank";
                }
            }
            catch (Exception exc)
            {
                Exceptions.ProcessModuleLoadException(this, exc);
            }
        }
 public string AddHTTP(string strURL)
 {
     return(Globals.AddHTTP(strURL));
 }
 private string GetPortalHomePageUrl(PortalSettings portalSettings)
 {
     return(Globals.AddHTTP(portalSettings.DefaultPortalAlias));
 }
        /// -----------------------------------------------------------------------------
        /// <summary>
        /// GetFriendlyAlias gets the Alias root of the friendly url
        /// </summary>
        /// <remarks>
        /// </remarks>
        /// <param name="path">The path to format.</param>
        /// <param name="portalAlias">The portal alias of the site.</param>
        /// <param name="isPagePath">Whether is a relative page path.</param>
        /// <returns>The formatted url</returns>
        private string GetFriendlyAlias(string path, string portalAlias, bool isPagePath)
        {
            string friendlyPath = path;
            string matchString  = "";

            if (string.IsNullOrEmpty(portalAlias) == false)
            {
                string httpAlias = Globals.AddHTTP(portalAlias).ToLowerInvariant();
                if (HttpContext.Current?.Items["UrlRewrite:OriginalUrl"] != null)
                {
                    string originalUrl =
                        HttpContext.Current.Items["UrlRewrite:OriginalUrl"].ToString().ToLowerInvariant();
                    httpAlias = Globals.AddPort(httpAlias, originalUrl);
                    if (originalUrl.StartsWith(httpAlias))
                    {
                        matchString = httpAlias;
                    }
                    if ((String.IsNullOrEmpty(matchString)))
                    {
                        //Manage the special case where original url contains the alias as
                        //http://www.domain.com/Default.aspx?alias=www.domain.com/child"
                        Match portalMatch = Regex.Match(originalUrl, "^?alias=" + portalAlias, RegexOptions.IgnoreCase);
                        if (!ReferenceEquals(portalMatch, Match.Empty))
                        {
                            matchString = httpAlias;
                        }
                    }

                    if ((String.IsNullOrEmpty(matchString)))
                    {
                        //Manage the special case of child portals
                        //http://www.domain.com/child/default.aspx
                        string tempurl = HttpContext.Current.Request.Url.Host + Globals.ResolveUrl(friendlyPath);
                        if (!tempurl.Contains(portalAlias))
                        {
                            matchString = httpAlias;
                        }
                    }

                    if ((String.IsNullOrEmpty(matchString)))
                    {
                        // manage the case where the current hostname is www.domain.com and the portalalias is domain.com
                        // (this occurs when www.domain.com is not listed as portal alias for the portal, but domain.com is)
                        string wwwHttpAlias = Globals.AddHTTP("www." + portalAlias);
                        if (originalUrl.StartsWith(wwwHttpAlias))
                        {
                            matchString = wwwHttpAlias;
                        }
                    }
                }
                else
                {
                    matchString = httpAlias;
                }
            }
            if ((!String.IsNullOrEmpty(matchString)))
            {
                if ((path.IndexOf("~", StringComparison.Ordinal) != -1))
                {
                    friendlyPath = friendlyPath.Replace(matchString.EndsWith("/") ? "~/" : "~", matchString);
                }
                else
                {
                    friendlyPath = matchString + friendlyPath;
                }
            }
            else
            {
                friendlyPath = Globals.ResolveUrl(friendlyPath);
            }
            if (friendlyPath.StartsWith("//") && isPagePath)
            {
                friendlyPath = friendlyPath.Substring(1);
            }
            return(friendlyPath);
        }
        internal override void RewriteUrl(object sender, EventArgs e)
        {
            var app = (HttpApplication)sender;
            HttpServerUtility server        = app.Server;
            HttpRequest       request       = app.Request;
            HttpResponse      response      = app.Response;
            HttpContext       context       = app.Context;
            string            requestedPath = app.Request.Url.AbsoluteUri;

            if (RewriterUtils.OmitFromRewriteProcessing(request.Url.LocalPath))
            {
                return;
            }

            // 'Carry out first time initialization tasks
            Initialize.Init(app);
            if (!Initialize.ProcessHttpModule(request, false, false))
            {
                return;
            }

            // URL validation
            // check for ".." escape characters commonly used by hackers to traverse the folder tree on the server
            // the application should always use the exact relative location of the resource it is requesting
            var strURL             = request.Url.AbsolutePath;
            var strDoubleDecodeURL = server.UrlDecode(server.UrlDecode(request.RawUrl)) ?? string.Empty;

            if (Globals.FileEscapingRegex.Match(strURL).Success || Globals.FileEscapingRegex.Match(strDoubleDecodeURL).Success)
            {
                DotNetNuke.Services.Exceptions.Exceptions.ProcessHttpException(request);
            }

            try
            {
                // fix for ASP.NET canonicalization issues http://support.microsoft.com/?kbid=887459
                if (request.Path.IndexOf("\\", StringComparison.Ordinal) >= 0 || Path.GetFullPath(request.PhysicalPath) != request.PhysicalPath)
                {
                    DotNetNuke.Services.Exceptions.Exceptions.ProcessHttpException(request);
                }
            }
            catch (Exception exc)
            {
                // DNN 5479
                // request.physicalPath throws an exception when the path of the request exceeds 248 chars.
                // example to test: http://localhost/dotnetnuke_2/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx/default.aspx
                Logger.Error(exc);
            }

            string domainName;

            this.RewriteUrl(app, out domainName);

            // blank DomainName indicates RewriteUrl couldn't locate a current portal
            // reprocess url for portal alias if auto add is an option
            if (domainName == string.Empty && CanAutoAddPortalAlias())
            {
                domainName = Globals.GetDomainName(app.Request, true);
            }

            // from this point on we are dealing with a "standard" querystring ( ie. http://www.domain.com/default.aspx?tabid=## )
            // if the portal/url was succesfully identified
            int             tabId           = Null.NullInteger;
            int             portalId        = Null.NullInteger;
            string          portalAlias     = null;
            PortalAliasInfo portalAliasInfo = null;
            bool            parsingError    = false;

            // get TabId from querystring ( this is mandatory for maintaining portal context for child portals )
            if (!string.IsNullOrEmpty(request.QueryString["tabid"]))
            {
                if (!int.TryParse(request.QueryString["tabid"], out tabId))
                {
                    tabId        = Null.NullInteger;
                    parsingError = true;
                }
            }

            // get PortalId from querystring ( this is used for host menu options as well as child portal navigation )
            if (!string.IsNullOrEmpty(request.QueryString["portalid"]))
            {
                if (!int.TryParse(request.QueryString["portalid"], out portalId))
                {
                    portalId     = Null.NullInteger;
                    parsingError = true;
                }
            }

            if (parsingError)
            {
                // The tabId or PortalId are incorrectly formatted (potential DOS)
                DotNetNuke.Services.Exceptions.Exceptions.ProcessHttpException(request);
            }

            try
            {
                // alias parameter can be used to switch portals
                if (request.QueryString["alias"] != null)
                {
                    // check if the alias is valid
                    string childAlias = request.QueryString["alias"];
                    if (!Globals.UsePortNumber())
                    {
                        childAlias = childAlias.Replace(":" + request.Url.Port, string.Empty);
                    }

                    if (PortalAliasController.Instance.GetPortalAlias(childAlias) != null)
                    {
                        // check if the domain name contains the alias
                        if (childAlias.IndexOf(domainName, StringComparison.OrdinalIgnoreCase) == -1)
                        {
                            // redirect to the url defined in the alias
                            response.Redirect(Globals.GetPortalDomainName(childAlias, request, true), true);
                        }
                        else // the alias is the same as the current domain
                        {
                            portalAlias = childAlias;
                        }
                    }
                }

                // PortalId identifies a portal when set
                if (portalAlias == null)
                {
                    if (portalId != Null.NullInteger)
                    {
                        portalAlias = PortalAliasController.GetPortalAliasByPortal(portalId, domainName);
                    }
                }

                // TabId uniquely identifies a Portal
                if (portalAlias == null)
                {
                    if (tabId != Null.NullInteger)
                    {
                        // get the alias from the tabid, but only if it is for a tab in that domain
                        portalAlias = PortalAliasController.GetPortalAliasByTab(tabId, domainName);
                        if (string.IsNullOrEmpty(portalAlias))
                        {
                            // if the TabId is not for the correct domain
                            // see if the correct domain can be found and redirect it
                            portalAliasInfo = PortalAliasController.Instance.GetPortalAlias(domainName);
                            if (portalAliasInfo != null && !request.Url.LocalPath.ToLowerInvariant().EndsWith("/linkclick.aspx"))
                            {
                                if (app.Request.Url.AbsoluteUri.StartsWith("https://", StringComparison.InvariantCultureIgnoreCase))
                                {
                                    strURL = "https://" + portalAliasInfo.HTTPAlias.Replace("*.", string.Empty);
                                }
                                else
                                {
                                    strURL = "http://" + portalAliasInfo.HTTPAlias.Replace("*.", string.Empty);
                                }

                                if (strURL.IndexOf(domainName, StringComparison.InvariantCultureIgnoreCase) == -1)
                                {
                                    strURL += app.Request.Url.PathAndQuery;
                                }

                                response.Redirect(strURL, true);
                            }
                        }
                    }
                }

                // else use the domain name
                if (string.IsNullOrEmpty(portalAlias))
                {
                    portalAlias = domainName;
                }

                // using the DomainName above will find that alias that is the domainname portion of the Url
                // ie. dotnetnuke.com will be found even if zzz.dotnetnuke.com was entered on the Url
                portalAliasInfo = PortalAliasController.Instance.GetPortalAlias(portalAlias);
                if (portalAliasInfo != null)
                {
                    portalId = portalAliasInfo.PortalID;
                }

                // if the portalid is not known
                if (portalId == Null.NullInteger)
                {
                    bool autoAddPortalAlias = CanAutoAddPortalAlias();

                    if (!autoAddPortalAlias && !request.Url.LocalPath.EndsWith(Globals.glbDefaultPage, StringComparison.InvariantCultureIgnoreCase))
                    {
                        // allows requests for aspx pages in custom folder locations to be processed
                        return;
                    }

                    if (autoAddPortalAlias)
                    {
                        AutoAddAlias(context);
                    }
                }
            }
            catch (ThreadAbortException exc)
            {
                // Do nothing if Thread is being aborted - there are two response.redirect calls in the Try block
                Logger.Debug(exc);
            }
            catch (Exception ex)
            {
                // 500 Error - Redirect to ErrorPage
                Logger.Error(ex);

                strURL = "~/ErrorPage.aspx?status=500&error=" + server.UrlEncode(ex.Message);
                HttpContext.Current.Response.Clear();
                HttpContext.Current.Server.Transfer(strURL);
            }

            if (portalId != -1)
            {
                // load the PortalSettings into current context
                var portalSettings = new PortalSettings(tabId, portalAliasInfo);
                app.Context.Items.Add("PortalSettings", portalSettings);

                // load PortalSettings and HostSettings dictionaries into current context
                // specifically for use in DotNetNuke.Web.Client, which can't reference DotNetNuke.dll to get settings the normal way
                app.Context.Items.Add("PortalSettingsDictionary", PortalController.Instance.GetPortalSettings(portalId));
                app.Context.Items.Add("HostSettingsDictionary", HostController.Instance.GetSettingsDictionary());

                if (portalSettings.PortalAliasMappingMode == PortalSettings.PortalAliasMapping.Redirect &&
                    portalAliasInfo != null && !portalAliasInfo.IsPrimary &&
                    !string.IsNullOrWhiteSpace(portalSettings.DefaultPortalAlias))    // don't redirect if no primary alias is defined
                {
                    // Permanently Redirect
                    response.StatusCode = 301;

                    var redirectAlias = Globals.AddHTTP(portalSettings.DefaultPortalAlias);
                    var checkAlias    = Globals.AddHTTP(portalAliasInfo.HTTPAlias);
                    var redirectUrl   = string.Concat(redirectAlias, request.RawUrl);
                    if (redirectUrl.StartsWith(checkAlias, StringComparison.InvariantCultureIgnoreCase))
                    {
                        redirectUrl = string.Concat(redirectAlias, redirectUrl.Substring(checkAlias.Length));
                    }

                    response.AppendHeader("Location", redirectUrl);
                }

                // manage page URL redirects - that reach here because they bypass the built-in navigation
                // ie Spiders, saved favorites, hand-crafted urls etc
                if (!string.IsNullOrEmpty(portalSettings.ActiveTab.Url) && request.QueryString["ctl"] == null &&
                    request.QueryString["fileticket"] == null)
                {
                    // Target Url
                    string redirectUrl = portalSettings.ActiveTab.FullUrl;
                    if (portalSettings.ActiveTab.PermanentRedirect)
                    {
                        // Permanently Redirect
                        response.StatusCode = 301;
                        response.AppendHeader("Location", redirectUrl);
                    }
                    else
                    {
                        // Normal Redirect
                        response.Redirect(redirectUrl, true);
                    }
                }

                // manage secure connections
                if (request.Url.AbsolutePath.EndsWith(".aspx", StringComparison.InvariantCultureIgnoreCase))
                {
                    // request is for a standard page
                    strURL = string.Empty;

                    // if SSL is enabled
                    if (portalSettings.SSLEnabled)
                    {
                        // if page is secure and connection is not secure orelse ssloffload is enabled and server value exists
                        if ((portalSettings.ActiveTab.IsSecure && !request.IsSecureConnection) &&
                            (UrlUtils.IsSslOffloadEnabled(request) == false))
                        {
                            // switch to secure connection
                            strURL = requestedPath.Replace("http://", "https://");
                            strURL = this.FormatDomain(strURL, portalSettings.STDURL, portalSettings.SSLURL);
                        }
                    }

                    // if SSL is enforced
                    if (portalSettings.SSLEnforced)
                    {
                        // if page is not secure and connection is secure
                        if (!portalSettings.ActiveTab.IsSecure && request.IsSecureConnection)
                        {
                            // check if connection has already been forced to secure orelse ssloffload is disabled
                            if (request.QueryString["ssl"] == null)
                            {
                                strURL = requestedPath.Replace("https://", "http://");
                                strURL = this.FormatDomain(strURL, portalSettings.SSLURL, portalSettings.STDURL);
                            }
                        }
                    }

                    // if a protocol switch is necessary
                    if (!string.IsNullOrEmpty(strURL))
                    {
                        if (strURL.StartsWith("https://", StringComparison.InvariantCultureIgnoreCase))
                        {
                            // redirect to secure connection
                            response.RedirectPermanent(strURL);
                        }
                        else

                        // when switching to an unsecure page, use a clientside redirector to avoid the browser security warning
                        {
                            response.Clear();

                            // add a refresh header to the response
                            response.AddHeader("Refresh", "0;URL=" + strURL);

                            // add the clientside javascript redirection script
                            response.Write("<html><head><title></title>");
                            response.Write("<!-- <script language=\"javascript\">window.location.replace(\"" + strURL +
                                           "\")</script> -->");
                            response.Write("</head><body></body></html>");

                            // send the response
                            response.End();
                        }
                    }
                }
            }
            else
            {
                // alias does not exist in database
                // and all attempts to find another have failed
                // this should only happen if the HostPortal does not have any aliases
                // 404 Error - Redirect to ErrorPage
                strURL = "~/ErrorPage.aspx?status=404&error=" + domainName;
                HttpContext.Current.Response.Clear();
                HttpContext.Current.Server.Transfer(strURL);
            }

            if (app.Context.Items["FirstRequest"] != null)
            {
                app.Context.Items.Remove("FirstRequest");

                // Process any messages in the EventQueue for the Application_Start_FirstRequest event
                EventQueueController.ProcessMessages("Application_Start_FirstRequest");
            }
        }
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            // Position in breadcrumb list
            var position = 1;

            //resolve image path in separator content
            ResolveSeparatorPaths();

            // If we have enabled hiding when there are no breadcrumbs, simply return
            if (HideWithNoBreadCrumb && PortalSettings.ActiveTab.BreadCrumbs.Count == (_rootLevel + 1))
            {
                return;
            }

            // Without checking if the current tab is the home tab, we would duplicate the root tab
            if (_showRoot && PortalSettings.ActiveTab.TabID != PortalSettings.HomeTabId)
            {
                // Add the current protocal to the current URL
                _homeUrl = Globals.AddHTTP(PortalSettings.PortalAlias.HTTPAlias);

                // Make sure we have a home tab ID set
                if (PortalSettings.HomeTabId != -1)
                {
                    _homeUrl = _navigationManager.NavigateURL(PortalSettings.HomeTabId);

                    var tc      = new TabController();
                    var homeTab = tc.GetTab(PortalSettings.HomeTabId, PortalSettings.PortalId, false);
                    _homeTabName = homeTab.LocalizedTabName;

                    // Check if we should use the tab's title instead
                    if (UseTitle && !string.IsNullOrEmpty(homeTab.Title))
                    {
                        _homeTabName = homeTab.Title;
                    }
                }

                // Append all of the HTML for the root breadcrumb
                _breadcrumb.Append("<span itemprop=\"itemListElement\" itemscope itemtype=\"http://schema.org/ListItem\">");
                _breadcrumb.Append("<a href=\"" + _homeUrl + "\" class=\"" + _cssClass + "\" itemprop=\"item\" ><span itemprop=\"name\">" + _homeTabName + "</span></a>");
                _breadcrumb.Append("<meta itemprop=\"position\" content=\"" + position++ + "\" />"); // Notice we post-increment the position variable
                _breadcrumb.Append("</span>");

                // Add a separator
                _breadcrumb.Append(_separator);
            }

            //process bread crumbs
            for (var i = _rootLevel; i < PortalSettings.ActiveTab.BreadCrumbs.Count; ++i)
            {
                // Only add separators if we're past the root level
                if (i > _rootLevel)
                {
                    _breadcrumb.Append(_separator);
                }

                // Grab the current tab
                var tab = (TabInfo)PortalSettings.ActiveTab.BreadCrumbs[i];

                var tabName = tab.LocalizedTabName;

                // Determine if we should use the tab's title instead of tab name
                if (UseTitle && !string.IsNullOrEmpty(tab.Title))
                {
                    tabName = tab.Title;
                }

                // Get the absolute URL of the tab
                var tabUrl = tab.FullUrl;

                //
                if (ProfileUserId > -1)
                {
                    tabUrl = _navigationManager.NavigateURL(tab.TabID, "", "UserId=" + ProfileUserId);
                }

                //
                if (GroupId > -1)
                {
                    tabUrl = _navigationManager.NavigateURL(tab.TabID, "", "GroupId=" + GroupId);
                }

                // Begin breadcrumb
                _breadcrumb.Append("<span itemprop=\"itemListElement\" itemscope itemtype=\"http://schema.org/ListItem\">");

                // Is this tab disabled? If so, only render the text
                if (tab.DisableLink)
                {
                    _breadcrumb.Append("<span class=\"" + _cssClass + "\" itemprop=\"name\">" + tabName + "</span>");
                }
                else
                {
                    _breadcrumb.Append("<a href=\"" + tabUrl + "\" class=\"" + _cssClass + "\" itemprop=\"item\"><span itemprop=\"name\">" + tabName + "</span></a>");
                }

                _breadcrumb.Append("<meta itemprop=\"position\" content=\"" + position++ + "\" />"); // Notice we post-increment the position variable
                _breadcrumb.Append("</span>");
            }

            _breadcrumb.Append("</span>"); //End of BreadcrumbList

            lblBreadCrumb.Text = _breadcrumb.ToString();
        }