protected void CmdSwitchClick(object sender, EventArgs e) { try { if ((!string.IsNullOrEmpty(SitesLst.SelectedValue))) { int selectedPortalID = int.Parse(SitesLst.SelectedValue); var portalAliasCtrl = new PortalAliasController(); ArrayList portalAliases = portalAliasCtrl.GetPortalAliasArrayByPortalID(selectedPortalID); if (((portalAliases != null) && portalAliases.Count > 0 && (portalAliases[0] != null))) { 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); } }
private void BindData() { ArrayList arr; PortalAliasController p = new PortalAliasController(); arr = p.GetPortalAliasArrayByPortalID( intPortalID ); dgPortalAlias.DataSource = arr; dgPortalAlias.DataBind(); }
/// <summary> /// FormatExpiryDate formats the format name as an <a> tag /// </summary> /// <history> /// [cnurse] 9/28/2004 Updated to reflect design changes for Help, 508 support /// and localisation /// </history> public string FormatPortalAliases( int PortalID ) { StringBuilder str = new StringBuilder(); try { PortalAliasController objPortalAliasController = new PortalAliasController(); ArrayList arr = objPortalAliasController.GetPortalAliasArrayByPortalID( PortalID ); for( int i = 0; i < arr.Count; i++ ) { PortalAliasInfo objPortalAliasInfo = (PortalAliasInfo)arr[i]; str.Append( "<a href=\"" + Globals.AddHTTP( objPortalAliasInfo.HTTPAlias ) + "\">" + objPortalAliasInfo.HTTPAlias + "</a>" + "<BR>" ); } } catch( Exception exc ) //Module failed to load { Exceptions.ProcessModuleLoadException( this, exc ); } return str.ToString(); }
/// ----------------------------------------------------------------------------- /// <summary> /// FormatExpiryDate formats the format name as an a tag /// </summary> /// <remarks> /// </remarks> /// <history> /// [cnurse] 9/28/2004 Updated to reflect design changes for Help, 508 support /// and localisation /// </history> /// ----------------------------------------------------------------------------- public string FormatPortalAliases(int portalID) { var str = new StringBuilder(); try { var objPortalAliasController = new PortalAliasController(); var arr = objPortalAliasController.GetPortalAliasArrayByPortalID(portalID); PortalAliasInfo objPortalAliasInfo; int i; for (i = 0; i <= arr.Count - 1; i++) { objPortalAliasInfo = (PortalAliasInfo) arr[i]; var httpAlias = Globals.AddHTTP(objPortalAliasInfo.HTTPAlias); var originalUrl = HttpContext.Current.Items["UrlRewrite:OriginalUrl"].ToString().ToLowerInvariant(); httpAlias = Globals.AddPort(httpAlias, originalUrl); str.Append("<a href=\"" + httpAlias + "\">" + objPortalAliasInfo.HTTPAlias + "</a>" + "<BR>"); } } catch (Exception exc) //Module failed to load { Exceptions.ProcessModuleLoadException(this, exc); } return str.ToString(); }
BlogInfo[] IMetaWeblog.GetUsersBlogs(string key, string username, string password) { LocatePortal(Context.Request); DotNetNuke.Entities.Users.UserInfo ui = Authenticate(username, password); if (ui.UserID > 0) { //todo: configure blog info for users var infoList = new List<BlogInfo>(); var bi = new BlogInfo {blogid = "0"}; var pac = new PortalAliasController(); foreach (PortalAliasInfo api in pac.GetPortalAliasArrayByPortalID(PortalId)) { bi.url = "http://" + api.HTTPAlias; break; } bi.blogName = ui.Username; infoList.Add(bi); return infoList.ToArray(); } throw new XmlRpcFaultException(0, Localization.GetString("FailedAuthentication.Text", LocalResourceFile)); }
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; returnValue.AppendFormat("<a href=\"{0}\">{1}</a>", url, t.LocalizedTabName); } else { returnValue.AppendFormat("{0}", t.LocalizedTabName); } index = index + 1; } } } return returnValue.ToString(); }
private void BindMarketing(PortalInfo portal) { //Load DocTypes var searchEngines = new Dictionary<string, string> { { "Google", "http://www.google.com/addurl?q=" + Globals.HTTPPOSTEncode(Globals.AddHTTP(Globals.GetDomainName(Request))) }, { "Yahoo", "http://siteexplorer.search.yahoo.com/submit" }, { "Microsoft", "http://search.msn.com.sg/docs/submit.aspx" } }; cboSearchEngine.DataSource = searchEngines; cboSearchEngine.DataBind(); var portalAliasController = new PortalAliasController(); var aliases = portalAliasController.GetPortalAliasArrayByPortalID(portal.PortalID); if (PortalController.IsChildPortal(portal, Globals.GetAbsoluteServerPath(Request))) { txtSiteMap.Text = Globals.AddHTTP(Globals.GetDomainName(Request)) + @"/SiteMap.aspx?portalid=" + portal.PortalID; } else { if (aliases.Count > 0) { //Get the first Alias var objPortalAliasInfo = (PortalAliasInfo)aliases[0]; txtSiteMap.Text = Globals.AddHTTP(objPortalAliasInfo.HTTPAlias) + @"/SiteMap.aspx"; } else { txtSiteMap.Text = Globals.AddHTTP(Globals.GetDomainName(Request)) + @"/SiteMap.aspx"; } } optBanners.SelectedIndex = portal.BannerAdvertising; if (UserInfo.IsSuperUser) { lblBanners.Visible = false; } else { optBanners.Enabled = portal.BannerAdvertising != 2; lblBanners.Visible = portal.BannerAdvertising == 2; } }
private void BindAliases(PortalInfo portal) { var portalSettings = new PortalSettings(portal); var portalAliasController = new PortalAliasController(); var aliases = portalAliasController.GetPortalAliasArrayByPortalID(portal.PortalID); var portalAliasMapping = portalSettings.PortalAliasMappingMode.ToString().ToUpper(); if (String.IsNullOrEmpty(portalAliasMapping)) { portalAliasMapping = "CANONICALURL"; } portalAliasModeButtonList.Select(portalAliasMapping, false); BindDefaultAlias(aliases); //Auto Add Portal Alias if (new PortalController().GetPortals().Count > 1) { chkAutoAddPortalAlias.Enabled = false; chkAutoAddPortalAlias.Checked = false; } else { chkAutoAddPortalAlias.Checked = HostController.Instance.GetBoolean("AutoAddPortalAlias"); } }
public static string DeletePortal( PortalInfo portal, string serverPath ) { string strPortalName = null; string strMessage = string.Empty; // check if this is the last portal int portalCount = DataProvider.Instance().GetPortalCount(); if( portalCount > 1 ) { if( portal != null ) { // delete custom resource files Globals.DeleteFilesRecursive( serverPath, ".Portal-" + portal.PortalID.ToString() + ".resx" ); //If child portal delete child folder PortalAliasController objPortalAliasController = new PortalAliasController(); ArrayList arr = objPortalAliasController.GetPortalAliasArrayByPortalID( portal.PortalID ); PortalAliasInfo objPortalAliasInfo = (PortalAliasInfo)( arr[0] ); strPortalName = Globals.GetPortalDomainName( objPortalAliasInfo.HTTPAlias, null, true ); if( Convert.ToBoolean( ( objPortalAliasInfo.HTTPAlias.IndexOf( "/", 0 ) + 1 ) ) ) { strPortalName = objPortalAliasInfo.HTTPAlias.Substring( ( objPortalAliasInfo.HTTPAlias.LastIndexOf( "/" ) + 1 ) ); } if( strPortalName != "" && Directory.Exists( serverPath + strPortalName ) ) { Globals.DeleteFolderRecursive( serverPath + strPortalName ); } // delete upload directory Globals.DeleteFolderRecursive( serverPath + "Portals\\" + portal.PortalID.ToString() ); string HomeDirectory = portal.HomeDirectoryMapPath; if( Directory.Exists( HomeDirectory ) ) { Globals.DeleteFolderRecursive( HomeDirectory ); } // remove database references PortalController objPortalController = new PortalController(); objPortalController.DeletePortalInfo( portal.PortalID ); } } else { strMessage = Localization.GetString( "LastPortal" ); } return strMessage; }
private bool IsChildPortal(PortalSettings ps, HttpContext context) { var isChild = false; var aliasController = new PortalAliasController(); var arr = aliasController.GetPortalAliasArrayByPortalID(ps.PortalId); var serverPath = Globals.GetAbsoluteServerPath(context.Request); if (arr.Count > 0) { var portalAlias = (PortalAliasInfo)arr[0]; var portalName = Globals.GetPortalDomainName(ps.PortalAlias.HTTPAlias, Request, true); if (portalAlias.HTTPAlias.IndexOf("/") > -1) { portalName = PortalController.GetPortalFolder(portalAlias.HTTPAlias); } if (!string.IsNullOrEmpty(portalName) && Directory.Exists(serverPath + portalName)) { isChild = true; } } return isChild; }
private void BindAliases(PortalInfo portal) { var portalSettings = new PortalSettings(portal); var portalAliasController = new PortalAliasController(); var aliases = portalAliasController.GetPortalAliasArrayByPortalID(portal.PortalID); var portalAliasMapping = portalSettings.PortalAliasMappingMode.ToString().ToUpper(); if (String.IsNullOrEmpty(portalAliasMapping)) { portalAliasMapping = "CANONICALURL"; } portalAliasModeButtonList.Select(portalAliasMapping, false); if (portalAliasMapping.ToUpperInvariant() == "NONE") { defaultAliasRow.Visible = false; } else { defaultAliasRow.Visible = true; defaultAliasDropDown.DataSource = aliases; defaultAliasDropDown.DataBind(); var defaultAlias = PortalController.GetPortalSetting("DefaultPortalAlias", portal.PortalID, ""); if (defaultAliasDropDown.Items.FindByValue(defaultAlias) != null) { defaultAliasDropDown.Items.FindByValue(defaultAlias).Selected = true; } } //Auto Add Portal Alias if (new PortalController().GetPortals().Count > 1) { chkAutoAddPortalAlias.Enabled = false; chkAutoAddPortalAlias.Checked = false; } else { chkAutoAddPortalAlias.Checked = HostController.Instance.GetBoolean("AutoAddPortalAlias"); } }
/// <summary> /// UpgradeApplication - This overload is used for general application upgrade operations. /// </summary> /// <remarks> /// Since it is not version specific and is invoked whenever the application is /// restarted, the operations must be re-executable. /// </remarks> private static string UpgradeApplication() { string strExceptions = ""; try { // remove the system message module from the admin tab // System Messages are now managed through Localization if (CoreModuleExists("System Messages")) { RemoveCoreModule("System Messages", "Admin", "Site Settings", false); } // add the log viewer module to the admin tab int moduleDefId; if (CoreModuleExists("Log Viewer") == false) { moduleDefId = AddModuleDefinition("Log Viewer", "Allows you to view log entries for portal events.", "Log Viewer"); AddModuleControl(moduleDefId, "", "", "Admin/Logging/LogViewer.ascx", "", SecurityAccessLevel.Admin, 0); AddModuleControl(moduleDefId, "Edit", "Edit Log Settings", "Admin/Logging/EditLogTypes.ascx", "", SecurityAccessLevel.Host, 0); //Add the Module/Page to all configured portals AddAdminPages("Log Viewer", "icon_viewstats_16px.gif", true, moduleDefId, "Log Viewer", "icon_viewstats_16px.gif"); } if (CoreModuleExists("Authentication") == false) { moduleDefId = AddModuleDefinition("Windows Authentication", "Allows you to manage authentication settings for sites using Windows Authentication.", "Windows Authentication"); AddModuleControl(moduleDefId, "", "", "Admin/Security/AuthenticationSettings.ascx", "", SecurityAccessLevel.Admin, 0); //Add the Module/Page to all configured portals AddAdminPages("Authentication", "icon_authentication_16px.gif", true, moduleDefId, "Authentication", "icon_authentication_16px.gif"); } // add the schedule module to the host tab TabInfo newPage; if (CoreModuleExists("Schedule") == false) { moduleDefId = AddModuleDefinition("Schedule", "Allows you to schedule tasks to be run at specified intervals.", "Schedule"); AddModuleControl(moduleDefId, "", "", "Admin/Scheduling/ViewSchedule.ascx", "", SecurityAccessLevel.Admin, 0); AddModuleControl(moduleDefId, "Edit", "Edit Schedule", "Admin/Scheduling/EditSchedule.ascx", "", SecurityAccessLevel.Host, 0); AddModuleControl(moduleDefId, "History", "Schedule History", "Admin/Scheduling/ViewScheduleHistory.ascx", "", SecurityAccessLevel.Host, 0); AddModuleControl(moduleDefId, "Status", "Schedule Status", "Admin/Scheduling/ViewScheduleStatus.ascx", "", SecurityAccessLevel.Host, 0); //Create New Host Page (or get existing one) newPage = AddHostPage("Schedule", "icon_scheduler_16px.gif", true); //Add Module To Page AddModuleToPage(newPage, moduleDefId, "Schedule", "icon_scheduler_16px.gif"); } // add the skins module to the admin tab if (CoreModuleExists("Skins") == false) { moduleDefId = AddModuleDefinition("Skins", "Allows you to manage your skins and containers.", "Skins"); AddModuleControl(moduleDefId, "", "", "Admin/Skins/EditSkins.ascx", "", SecurityAccessLevel.Admin, 0); //Add the Module/Page to all configured portals AddAdminPages("Skins", "icon_skins_16px.gif", true, moduleDefId, "Skins", "icon_skins_16px.gif"); } // add the language editor module to the host tab if (!CoreModuleExists("Languages")) { moduleDefId = AddModuleDefinition("Languages", "The Super User can manage the suported languages installed on the system.", "Languages"); AddModuleControl(moduleDefId, "", "", "Admin/Localization/Languages.ascx", "", SecurityAccessLevel.Host, 0); AddModuleControl(moduleDefId, "TimeZone", "TimeZone Editor", "Admin/Localization/TimeZoneEditor.ascx", "", SecurityAccessLevel.Host, 0); AddModuleControl(moduleDefId, "Language", "Language Editor", "Admin/Localization/LanguageEditor.ascx", "", SecurityAccessLevel.Host, 0); AddModuleControl(moduleDefId, "FullEditor", "Language Editor", "Admin/Localization/LanguageEditorExt.ascx", "", SecurityAccessLevel.Host, 0); AddModuleControl(moduleDefId, "Verify", "Resource File Verifier", "Admin/Localization/ResourceVerifier.ascx", "", SecurityAccessLevel.Host, 0); AddModuleControl(moduleDefId, "Package", "Create Language Pack", "Admin/Localization/LanguagePack.ascx", "", SecurityAccessLevel.Host, 0); //Create New Host Page (or get existing one) newPage = AddHostPage("Languages", "icon_language_16px.gif", true); //Add Module To Page AddModuleToPage(newPage, moduleDefId, "Languages", "icon_language_16px.gif"); moduleDefId = AddModuleDefinition("Custom Locales", "Administrator can manage custom translations for portal.", "Custom Portal Locale"); AddModuleControl(moduleDefId, "", "", "Admin/Localization/LanguageEditor.ascx", "", SecurityAccessLevel.Admin, 0); AddModuleControl(moduleDefId, "FullEditor", "Language Editor", "Admin/Localization/LanguageEditorExt.ascx", "", SecurityAccessLevel.Admin, 0); //Add the Module/Page to all configured portals AddAdminPages("Languages", "icon_language_16px.gif", true, moduleDefId, "Languages", "icon_language_16px.gif"); } // add the Search Admin module to the host tab if (CoreModuleExists("Search Admin") == false) { moduleDefId = AddModuleDefinition("Search Admin", "The Search Admininstrator provides the ability to manage search settings.", "Search Admin"); AddModuleControl(moduleDefId, "", "", "Admin/Search/SearchAdmin.ascx", "", SecurityAccessLevel.Host, 0); //Create New Host Page (or get existing one) newPage = AddHostPage("Search Admin", "icon_search_16px.gif", true); //Add Module To Page AddModuleToPage(newPage, moduleDefId, "Search Admin", "icon_search_16px.gif"); //Add the Module/Page to all configured portals //AddAdminPages("Search Admin", "icon_search_16px.gif", True, ModuleDefID, "Search Admin", "icon_search_16px.gif") } // add the Search Input module if (CoreModuleExists("Search Input") == false) { moduleDefId = AddModuleDefinition("Search Input", "The Search Input module provides the ability to submit a search to a given search results module.", "Search Input", false, false); AddModuleControl(moduleDefId, "", "", "DesktopModules/SearchInput/SearchInput.ascx", "", SecurityAccessLevel.Anonymous, 0); AddModuleControl(moduleDefId, "Settings", "Search Input Settings", "DesktopModules/SearchInput/Settings.ascx", "", SecurityAccessLevel.Edit, 0); } // add the Search Results module if (CoreModuleExists("Search Results") == false) { moduleDefId = AddModuleDefinition("Search Results", "The Search Reasults module provides the ability to display search results.", "Search Results", false, false); AddModuleControl(moduleDefId, "", "", "DesktopModules/SearchResults/SearchResults.ascx", "", SecurityAccessLevel.Anonymous, 0); AddModuleControl(moduleDefId, "Settings", "Search Results Settings", "DesktopModules/SearchResults/Settings.ascx", "", SecurityAccessLevel.Edit, 0); //Add the Search Module/Page to all configured portals AddSearchResults(moduleDefId); } // add the site wizard module to the admin tab if (CoreModuleExists("Site Wizard") == false) { moduleDefId = AddModuleDefinition("Site Wizard", "The Administrator can use this user-friendly wizard to set up the common features of the Portal/Site.", "Site Wizard"); AddModuleControl(moduleDefId, "", "", "Admin/Portal/Sitewizard.ascx", "", SecurityAccessLevel.Admin, 0); AddAdminPages("Site Wizard", "icon_sitesettings_16px.gif", true, moduleDefId, "Site Wizard", "icon_sitesettings_16px.gif"); } // add portal alias module if (CoreModuleExists("Portal Aliases") == false) { moduleDefId = AddModuleDefinition("Portal Aliases", "Allows you to view portal aliases.", "Portal Aliases"); AddModuleControl(moduleDefId, "", "", "Admin/Portal/PortalAlias.ascx", "", SecurityAccessLevel.Host, 0); AddModuleControl(moduleDefId, "Edit", "Portal Aliases", "Admin/Portal/EditPortalAlias.ascx", "", SecurityAccessLevel.Host, 0); //Add the Module/Page to all configured portals (with InheritViewPermissions = False) AddAdminPages("Site Settings", "icon_sitesettings_16px.gif", false, moduleDefId, "Portal Aliases", "icon_sitesettings_16px.gif", false); } //add Lists module and tab if (HostTabExists("Lists") == false) { moduleDefId = AddModuleDefinition("Lists", "Allows you to edit common lists.", "Lists"); AddModuleControl(moduleDefId, "", "", "Admin/Lists/ListEditor.ascx", "", SecurityAccessLevel.Host, 0); //Create New Host Page (or get existing one) newPage = AddHostPage("Lists", "icon_lists_16px.gif", true); //Add Module To Page AddModuleToPage(newPage, moduleDefId, "Lists", "icon_lists_16px.gif"); } // add the feedback settings control if (CoreModuleExists("Feedback")) { moduleDefId = GetModuleDefinition("Feedback", "Feedback"); AddModuleControl(moduleDefId, "Settings", "Feedback Settings", "DesktopModules/Feedback/Settings.ascx", "", SecurityAccessLevel.Edit, 0); } if (HostTabExists("Superuser Accounts") == false) { //add SuperUser Accounts module and tab DesktopModuleController objDesktopModuleController = new DesktopModuleController(); DesktopModuleInfo objDesktopModuleInfo; objDesktopModuleInfo = objDesktopModuleController.GetDesktopModuleByName("User Accounts"); ModuleDefinitionController objModuleDefController = new ModuleDefinitionController(); moduleDefId = objModuleDefController.GetModuleDefinitionByName(objDesktopModuleInfo.DesktopModuleID, "User Accounts").ModuleDefID; //Create New Host Page (or get existing one) newPage = AddHostPage("Superuser Accounts", "icon_users_16px.gif", true); //Add Module To Page AddModuleToPage(newPage, moduleDefId, "Superuser Accounts", "icon_users_32px.gif"); } //add Skins module and tab to Host menu if (HostTabExists("Skins") == false) { DesktopModuleController objDesktopModuleController = new DesktopModuleController(); DesktopModuleInfo objDesktopModuleInfo; objDesktopModuleInfo = objDesktopModuleController.GetDesktopModuleByName("Skins"); ModuleDefinitionController objModuleDefController = new ModuleDefinitionController(); moduleDefId = objModuleDefController.GetModuleDefinitionByName(objDesktopModuleInfo.DesktopModuleID, "Skins").ModuleDefID; //Create New Host Page (or get existing one) newPage = AddHostPage("Skins", "icon_skins_16px.gif", true); //Add Module To Page AddModuleToPage(newPage, moduleDefId, "Skins", ""); } //Add Search Skin Object AddModuleControl(Null.NullInteger, "SEARCH", Null.NullString, "Admin/Skins/Search.ascx", "", SecurityAccessLevel.SkinObject, Null.NullInteger); //Add TreeView Skin Object AddModuleControl(Null.NullInteger, "TREEVIEW", Null.NullString, "Admin/Skins/TreeViewMenu.ascx", "", SecurityAccessLevel.SkinObject, Null.NullInteger); //Add Private Assembly Packager moduleDefId = GetModuleDefinition("Module Definitions", "Module Definitions"); AddModuleControl(moduleDefId, "Package", "Create Private Assembly", "Admin/ModuleDefinitions/PrivateAssembly.ascx", "icon_moduledefinitions_32px.gif", SecurityAccessLevel.Edit, Null.NullInteger); //Add Edit Role Groups moduleDefId = GetModuleDefinition("Security Roles", "Security Roles"); AddModuleControl(moduleDefId, "EditGroup", "Edit Role Groups", "Admin/Security/EditGroups.ascx", "icon_securityroles_32px.gif", SecurityAccessLevel.Edit, Null.NullInteger); AddModuleControl(moduleDefId, "UserSettings", "Manage User Settings", "Admin/Users/UserSettings.ascx", "~/images/settings.gif", SecurityAccessLevel.Edit, Null.NullInteger); //Add User Accounts Controls moduleDefId = GetModuleDefinition("User Accounts", "User Accounts"); AddModuleControl(moduleDefId, "ManageProfile", "Manage Profile Definition", "Admin/Users/ProfileDefinitions.ascx", "icon_users_32px.gif", SecurityAccessLevel.Edit, Null.NullInteger); AddModuleControl(moduleDefId, "EditProfileProperty", "Edit Profile Property Definition", "Admin/Users/EditProfileDefinition.ascx", "icon_users_32px.gif", SecurityAccessLevel.Edit, Null.NullInteger); AddModuleControl(moduleDefId, "UserSettings", "Manage User Settings", "Admin/Users/UserSettings.ascx", "~/images/settings.gif", SecurityAccessLevel.Edit, Null.NullInteger); AddModuleControl(Null.NullInteger, "Profile", "Profile", "Admin/Users/ManageUsers.ascx", "icon_users_32px.gif", SecurityAccessLevel.Anonymous, Null.NullInteger); AddModuleControl(Null.NullInteger, "SendPassword", "Send Password", "Admin/Security/SendPassword.ascx", "", SecurityAccessLevel.Anonymous, Null.NullInteger); AddModuleControl(Null.NullInteger, "ViewProfile", "View Profile", "Admin/Users/ViewProfile.ascx", "icon_users_32px.gif", SecurityAccessLevel.Anonymous, Null.NullInteger); //Update Child Portal subHost.aspx PortalAliasController objAliasController = new PortalAliasController(); ArrayList arrAliases = objAliasController.GetPortalAliasArrayByPortalID(Null.NullInteger); foreach (PortalAliasInfo objAlias in arrAliases) { //For the alias to be for a child it must be of the form ...../child if (objAlias.HTTPAlias.LastIndexOf("/") != -1) { string childPath = Globals.ApplicationMapPath + "\\" + objAlias.HTTPAlias.Substring(objAlias.HTTPAlias.LastIndexOf("/") + 1); if (Directory.Exists(childPath)) { //Folder exists App/child so upgrade //Rename existing file File.Copy(childPath + "\\" + Globals.glbDefaultPage, childPath + "\\old_" + Globals.glbDefaultPage, true); // create the subhost default.aspx file File.Copy(Globals.HostMapPath + "subhost.aspx", childPath + "\\" + Globals.glbDefaultPage, true); } } } } catch (Exception ex) { strExceptions += "Error: " + ex.Message + "\r\n"; try { Exceptions.Exceptions.LogException(ex); } catch { // ignore } } return strExceptions; }
public void OnBeginRequest( object s, EventArgs e ) { HttpApplication app = (HttpApplication)s; HttpServerUtility Server = app.Server; HttpRequest Request = app.Request; HttpResponse Response = app.Response; string requestedPath = app.Request.Url.AbsoluteUri; // 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 string strURL = Request.Url.AbsolutePath; string strDoubleDecodeURL = Server.UrlDecode( Server.UrlDecode( Request.RawUrl ) ); if( strURL.IndexOf( ".." ) != - 1 || strDoubleDecodeURL.IndexOf( ".." ) != - 1 ) { throw ( new HttpException( 404, "Not Found" ) ); } //fix for ASP.NET canonicalization issues http://support.microsoft.com/?kbid=887459 if( Request.Path.IndexOf( '\u005C' ) >= 0 || Path.GetFullPath( Request.PhysicalPath ) != Request.PhysicalPath ) { throw ( new HttpException( 404, "Not Found" ) ); } //check if we are upgrading/installing if( Request.Url.LocalPath.ToLower().EndsWith( "install.aspx" ) ) { return; } // save original url in context app.Context.Items.Add( "UrlRewrite:OriginalUrl", app.Request.Url.AbsoluteUri ); // Friendly URLs are exposed externally using the following format // http://www.domain.com/tabid/###/mid/###/ctl/xxx/default.aspx // and processed internally using the following format // http://www.domain.com/default.aspx?tabid=###&mid=###&ctl=xxx // The system for accomplishing this is based on an extensible Regex rules definition stored in /SiteUrls.config string sendTo = ""; // save and remove the querystring as it gets added back on later // path parameter specifications will take precedence over querystring parameters string strQueryString = ""; if( !String.IsNullOrEmpty(app.Request.Url.Query) ) { strQueryString = Request.QueryString.ToString(); requestedPath = requestedPath.Replace( app.Request.Url.Query, "" ); } // get url rewriting rules RewriterRuleCollection rules = RewriterConfiguration.GetConfig().Rules; // iterate through list of rules int intMatch = - 1; for( int intRule = 0; intRule <= rules.Count - 1; intRule++ ) { // check for the existence of the LookFor value string strLookFor = "^" + RewriterUtils.ResolveUrl( app.Context.Request.ApplicationPath, rules[intRule].LookFor ) + "$"; Regex objLookFor = new Regex( strLookFor, RegexOptions.IgnoreCase ); // if there is a match if( objLookFor.IsMatch( requestedPath ) ) { // create a new URL using the SendTo regex value sendTo = RewriterUtils.ResolveUrl( app.Context.Request.ApplicationPath, objLookFor.Replace( requestedPath, rules[intRule].SendTo ) ); // obtain the RegEx match group which contains the parameters Match objMatch = objLookFor.Match( requestedPath ); string strParameters = objMatch.Groups[2].Value; // process the parameters if( strParameters.Trim( null ).Length > 0 ) { // split the value into an array based on "/" ( ie. /tabid/##/ ) strParameters = strParameters.Replace( "\\", "/" ); string[] arrParameters = strParameters.Split( '/' ); string strParameterDelimiter; string strParameterName; string strParameterValue; // icreate a well formed querystring based on the array of parameters for( int intParameter = 1; intParameter <= arrParameters.Length - 1; intParameter++ ) { // ignore the page name if( arrParameters[intParameter].ToLower().IndexOf( ".aspx" ) == - 1 ) { // get parameter name strParameterName = arrParameters[intParameter].Trim( null ); if( strParameterName.Length > 0 ) { // add parameter to SendTo if it does not exist already if( sendTo.ToLower().IndexOf( "?" + strParameterName.ToLower() ) == - 1 && sendTo.ToLower().IndexOf( "&" + strParameterName.ToLower() ) == - 1 ) { // get parameter delimiter if( sendTo.IndexOf( "?" ) != - 1 ) { strParameterDelimiter = "&"; } else { strParameterDelimiter = "?"; } sendTo = sendTo + strParameterDelimiter + strParameterName; // get parameter value strParameterValue = ""; if( intParameter < ( arrParameters.Length - 1 ) ) { intParameter++; if( arrParameters[intParameter].Trim() != "" ) { strParameterValue = arrParameters[intParameter].Trim( null ); } } // add the parameter value if( strParameterValue.Length > 0 ) { sendTo = sendTo + "=" + strParameterValue; } } } } } } intMatch = intRule; break; // exit as soon as it processes the first match } } // add querystring parameters back to SendTo if( !String.IsNullOrEmpty(strQueryString) ) { string[] arrParameters = strQueryString.Split( '&' ); // iterate through the array of parameters for( int intParameter = 0; intParameter <= arrParameters.Length - 1; intParameter++ ) { // get parameter name string strParameterName = arrParameters[intParameter]; if( strParameterName.IndexOf( "=" ) != - 1 ) { strParameterName = strParameterName.Substring( 0, strParameterName.IndexOf( "=" ) ); } // check if parameter already exists if( sendTo.ToLower().IndexOf( "?" + strParameterName.ToLower() ) == - 1 && sendTo.ToLower().IndexOf( "&" + strParameterName.ToLower() ) == - 1 ) { // add parameter to SendTo value if( sendTo.IndexOf( "?" ) != - 1 ) { sendTo = sendTo + "&" + arrParameters[intParameter]; } else { sendTo = sendTo + "?" + arrParameters[intParameter]; } } } } // if a match was found to the urlrewrite rules if( intMatch != - 1 ) { if( rules[intMatch].SendTo.StartsWith( "~" ) ) { // rewrite the URL for internal processing RewriterUtils.RewriteUrl( app.Context, sendTo ); } else { // it is not possible to rewrite the domain portion of the URL so redirect to the new URL Response.Redirect( sendTo, true ); } } // *Note: from this point on we are dealing with a "standard" querystring ( ie. http://www.domain.com/default.aspx?tabid=## ) int TabId = - 1; int PortalId = - 1; string DomainName = null; string PortalAlias = null; PortalAliasInfo objPortalAliasInfo; // get TabId from querystring ( this is mandatory for maintaining portal context for child portals ) try { if( !( Request.QueryString["tabid"] == null ) ) { TabId = int.Parse( Request.QueryString["tabid"] ); } // get PortalId from querystring ( this is used for host menu options as well as child portal navigation ) if( !( Request.QueryString["portalid"] == null ) ) { PortalId = int.Parse( Request.QueryString["portalid"] ); } } catch( Exception ) { //The tabId or PortalId are incorrectly formatted (potential DOS) throw ( new HttpException( 404, "Not Found" ) ); } // alias parameter can be used to switch portals if( !( Request.QueryString["alias"] == null ) ) { // check if the alias is valid if( PortalSettings.GetPortalAliasInfo( Request.QueryString["alias"] ) != null ) { // check if the domain name contains the alias if( Strings.InStr( 1, Request.QueryString["alias"], DomainName, CompareMethod.Text ) == 0 ) { // redirect to the url defined in the alias Response.Redirect( Globals.GetPortalDomainName( Request.QueryString["alias"], Request, true ) ); } else // the alias is the same as the current domain { PortalAlias = Request.QueryString["alias"]; } } } // parse the Request URL into a Domain Name token DomainName = Globals.GetDomainName( Request ); // PortalId identifies a portal when set if( PortalAlias == null ) { if( PortalId != - 1 ) { PortalAlias = PortalSettings.GetPortalByID( PortalId, DomainName ); } } // TabId uniquely identifies a Portal if( PortalAlias == null ) { if( TabId != - 1 ) { // get the alias from the tabid, but only if it is for a tab in that domain PortalAlias = PortalSettings.GetPortalByTab( TabId, DomainName ); if( PortalAlias == null || PortalAlias == "" ) { //if the TabId is not for the correct domain //see if the correct domain can be found and redirect it objPortalAliasInfo = PortalSettings.GetPortalAliasInfo( DomainName ); if( objPortalAliasInfo != null ) { if( app.Request.Url.AbsoluteUri.ToLower().StartsWith( "https://" ) ) { strURL = "https://" + objPortalAliasInfo.HTTPAlias.Replace( "*.", "" ); } else { strURL = "http://" + objPortalAliasInfo.HTTPAlias.Replace( "*.", "" ); } if( strURL.ToLower().IndexOf( DomainName.ToLower() ) == - 1 ) { strURL += app.Request.Url.PathAndQuery; } Response.Redirect( strURL, true ); } } } } // else use the domain name if( PortalAlias == null || 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 objPortalAliasInfo = PortalSettings.GetPortalAliasInfo( PortalAlias ); if( objPortalAliasInfo != null ) { PortalId = objPortalAliasInfo.PortalID; } // if the portalid is not known if( PortalId == - 1 ) { if( !Request.Url.LocalPath.ToLower().EndsWith( Globals.glbDefaultPage.ToLower() ) ) { // allows requests for aspx pages in custom folder locations to be processed return; } else { //the domain name was not found so try using the host portal's first alias if( Convert.ToString( Globals.HostSettings["HostPortalId"] ) != "" ) { PortalId = Convert.ToInt32( Globals.HostSettings["HostPortalId"] ); // use the host portal PortalAliasController objPortalAliasController = new PortalAliasController(); ArrayList arrPortalAliases; arrPortalAliases = objPortalAliasController.GetPortalAliasArrayByPortalID( int.Parse( Convert.ToString( Globals.HostSettings["HostPortalId"] ) ) ); if( arrPortalAliases.Count > 0 ) { //Get the first Alias objPortalAliasInfo = (PortalAliasInfo)arrPortalAliases[0]; if( app.Request.Url.AbsoluteUri.ToLower().StartsWith( "https://" ) ) { strURL = "https://" + objPortalAliasInfo.HTTPAlias.Replace( "*.", "" ); } else { strURL = "http://" + objPortalAliasInfo.HTTPAlias.Replace( "*.", "" ); } if( TabId != - 1 ) { strURL += app.Request.Url.Query; } Response.Redirect( strURL, true ); } } } } if( PortalId != - 1 ) { // load the PortalSettings into current context PortalSettings _portalSettings = new PortalSettings( TabId, objPortalAliasInfo ); app.Context.Items.Add( "PortalSettings", _portalSettings ); } 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 StreamReader objStreamReader; objStreamReader = File.OpenText( Server.MapPath( "~/404.htm" ) ); string strHTML = objStreamReader.ReadToEnd(); objStreamReader.Close(); strHTML = strHTML.Replace( "[DOMAINNAME]", DomainName ); Response.Write( strHTML ); Response.End(); } }
/// <summary> /// Determines whether the portal is child portal. /// </summary> /// <param name="portal">The portal.</param> /// <param name="serverPath">The server path.</param> /// <returns> /// <c>true</c> if the portal is child portal; otherwise, <c>false</c>. /// </returns> public static bool IsChildPortal(PortalInfo portal, string serverPath) { bool isChild = Null.NullBoolean; string portalName; PortalAliasController aliasController = new PortalAliasController(); ArrayList arr = aliasController.GetPortalAliasArrayByPortalID(portal.PortalID); if (arr.Count > 0) { PortalAliasInfo portalAlias = (PortalAliasInfo)arr[0]; portalName = Globals.GetPortalDomainName(portalAlias.HTTPAlias, null, true); if (portalAlias.HTTPAlias.IndexOf("/") > -1) { portalName = GetPortalFolder(portalAlias.HTTPAlias); } if (!String.IsNullOrEmpty(portalName) && Directory.Exists(serverPath + portalName)) { isChild = true; } } return isChild; }
private static void UpdateChildPortalsDefaultPage() { //Update Child Portal subHost.aspx var portalAliasController = new PortalAliasController(); ArrayList aliases = portalAliasController.GetPortalAliasArrayByPortalID(Null.NullInteger); foreach (PortalAliasInfo aliasInfo in aliases) { //For the alias to be for a child it must be of the form ...../child int intChild = aliasInfo.HTTPAlias.IndexOf("/"); if (intChild != -1 && intChild != (aliasInfo.HTTPAlias.Length - 1)) { var childPath = Globals.ApplicationMapPath + "\\" + aliasInfo.HTTPAlias.Substring(intChild + 1); if (!string.IsNullOrEmpty(Globals.ApplicationPath)) { childPath = childPath.Replace("\\", "/"); childPath = childPath.Replace(Globals.ApplicationPath, ""); } childPath = childPath.Replace("/", "\\"); // check if File exists and make sure it's not the site's main default.aspx page string childDefaultPage = childPath + "\\" + Globals.glbDefaultPage; if (childPath != Globals.ApplicationMapPath && File.Exists(childDefaultPage)) { var objDefault = new System.IO.FileInfo(childDefaultPage); var objSubHost = new System.IO.FileInfo(Globals.HostMapPath + "subhost.aspx"); // check if upgrade is necessary if (objDefault.Length != objSubHost.Length) { //check file is readonly bool wasReadonly = false; FileAttributes attributes = File.GetAttributes(childDefaultPage); if ((attributes & FileAttributes.ReadOnly) == FileAttributes.ReadOnly) { wasReadonly = true; //remove readonly attribute File.SetAttributes(childDefaultPage, FileAttributes.Normal); } //Rename existing file File.Copy(childDefaultPage, childPath + "\\old_" + Globals.glbDefaultPage, true); //copy file File.Copy(Globals.HostMapPath + "subhost.aspx", childDefaultPage, true); //set back the readonly attribute if (wasReadonly) { File.SetAttributes(childDefaultPage, FileAttributes.ReadOnly); } } } } } }
/// <summary> /// check whether have conflict between tab path and portal alias. /// </summary> /// <param name="portalId">portal id.</param> /// <param name="tabPath">tab path.</param> /// <returns></returns> public static bool IsDuplicateWithPortalAlias(int portalId, string tabPath) { var aliasController = new PortalAliasController(); var aliasLookup = aliasController.GetPortalAliases().Values.Cast<PortalAliasInfo>(); foreach (PortalAliasInfo alias in aliasController.GetPortalAliasArrayByPortalID(portalId)) { var checkAlias = string.Format("{0}{1}", alias.HTTPAlias, tabPath.Replace("//", "/")); if(aliasLookup.Any(a => a.HTTPAlias.Equals(checkAlias, StringComparison.InvariantCultureIgnoreCase))) { return true; } } return false; }