private void FixAllowedExtensions()
		{

			bool blnHTML = true;

			string validExtensions = DotNetNuke.Entities.Host.Host.FileExtensions.ToLowerInvariant();

			if (("," + validExtensions + ",").IndexOf(",html,") == -1)
			{
				blnHTML = false;
			}

			if (blnHTML == false)
			{
				validExtensions = (string)AddComma(validExtensions).ToString() + "html";
				HostSettingsController ctl = new HostSettingsController();
				ctl.UpdateHostSetting("FileExtensions", validExtensions);
				Config.Touch();
			}

		}
        /// <summary>
        /// Updates the settings.
        /// </summary>
        public override void UpdateSettings()
        {
            if (!this.Page.IsValid)
            {
                return;
            }

            try
            {
                ModuleController objModules = new ModuleController();
                objModules.UpdateTabModuleSetting(this.TabModuleId, "SearchTitle", this.txtSearchTitle.Text);
                objModules.UpdateTabModuleSetting(this.TabModuleId, "Country", this.SearchRestrictionsRadioButtonList.Items.FindByValue("Country").Selected.ToString(CultureInfo.InvariantCulture));
                objModules.UpdateTabModuleSetting(this.TabModuleId, "Radius", this.SearchRestrictionsRadioButtonList.Items.FindByValue("Radius").Selected.ToString(CultureInfo.InvariantCulture));
                objModules.UpdateTabModuleSetting(this.TabModuleId, "DisplayProvider", this.ProviderTypeRadioButtonList.SelectedItem.Text);
                objModules.UpdateTabModuleSetting(this.TabModuleId, this.ProviderTypeRadioButtonList.SelectedValue + ".ApiKey", this.txtApiKey.Text);
                objModules.UpdateTabModuleSetting(this.TabModuleId, "DefaultCountry", this.ddlLocatorCountry.SelectedValue);
                objModules.UpdateTabModuleSetting(this.TabModuleId, "MapType", this.rblMapDisplayType.SelectedValue);
                objModules.UpdateTabModuleSetting(this.TabModuleId, "LocationsPerPage", int.Parse(this.LocationsPerPageTextBox.Text, CultureInfo.CurrentCulture).ToString(CultureInfo.InvariantCulture));
                objModules.UpdateTabModuleSetting(this.TabModuleId, "DisplayTypes", this.GetLocationTypeList());
                objModules.UpdateTabModuleSetting(this.TabModuleId, "ShowDefaultDisplay", this.rbDisplayAll.Checked.ToString(CultureInfo.InvariantCulture));
                objModules.UpdateTabModuleSetting(this.TabModuleId, "ShowMapDefaultDisplay", this.rbShowMap.Checked.ToString(CultureInfo.InvariantCulture));
                objModules.UpdateTabModuleSetting(this.TabModuleId, "AlwaysShowSearch", this.AlwaysShowSearchCheckBox.Checked.ToString(CultureInfo.InvariantCulture));
                objModules.UpdateTabModuleSetting(this.TabModuleId, "SearchAddress", this.chkAddress.Checked.ToString(CultureInfo.InvariantCulture));
                objModules.UpdateTabModuleSetting(this.TabModuleId, "SearchCityRegion", this.chkCityRegion.Checked.ToString(CultureInfo.InvariantCulture));
                objModules.UpdateTabModuleSetting(this.TabModuleId, "SearchPostalCode", this.chkPostalCode.Checked.ToString(CultureInfo.InvariantCulture));
                objModules.UpdateTabModuleSetting(this.TabModuleId, "SearchCountry", this.chkCountry.Checked.ToString(CultureInfo.InvariantCulture));
                objModules.UpdateTabModuleSetting(this.TabModuleId, "IncludeUnlimitedMilesRadius", this.IncludeUnlimitedMilesRadiusCheckBox.Checked.ToString(CultureInfo.InvariantCulture));
                objModules.UpdateTabModuleSetting(this.TabModuleId, "DefaultRadius", this.DefaultRadiusDropDownList.SelectedValue.ToString(CultureInfo.InvariantCulture));

                if (this.NoLocationDetailsRadioButton.Checked)
                {
                    objModules.UpdateTabModuleSetting(this.TabModuleId, "ShowLocationDetails", "NoDetails");
                }
                else if (this.LocationDetailsSamePageRadioButton.Checked)
                {
                    objModules.UpdateTabModuleSetting(this.TabModuleId, "ShowLocationDetails", "SamePage");
                }
                else if (this.LocationDetailSeparatePageRadioButton.Checked)
                {
                    objModules.UpdateTabModuleSetting(this.TabModuleId, "ShowLocationDetails", "DetailsPage");
                }

                HostSettingsController hsc = new HostSettingsController();
                hsc.UpdateHostSetting("LocatorAllowSubmissions" + this.PortalId.ToString(CultureInfo.InvariantCulture), this.AllowLocationSubmissionsCheckBox.Checked.ToString(CultureInfo.InvariantCulture));
                hsc.UpdateHostSetting("LocatorSubmissionModeration" + this.PortalId.ToString(CultureInfo.InvariantCulture), this.chkModerateLocations.Checked.ToString(CultureInfo.InvariantCulture));
                hsc.UpdateHostSetting("LocatorAllowRatings" + this.PortalId.ToString(CultureInfo.InvariantCulture), this.AllowRatingsCheckBox.Checked.ToString(CultureInfo.InvariantCulture));
                hsc.UpdateHostSetting("LocatorAllowComments" + this.PortalId.ToString(CultureInfo.InvariantCulture), this.AllowCommentsCheckBox.Checked.ToString(CultureInfo.InvariantCulture));
                hsc.UpdateHostSetting("LocatorCommentModeration" + this.PortalId.ToString(CultureInfo.InvariantCulture), this.ModerateCommentsCheckBox.Checked.ToString(CultureInfo.InvariantCulture));

                foreach (GridViewRow dr in this.gvTabModules.Rows)
                {
                    RadioButton locatorModuleRadioButton = (RadioButton)dr.FindControl("LocatorModuleRadioButton");
                    Label lblTabId = (Label)dr.FindControl("lblTabId");
                    if (locatorModuleRadioButton.Checked)
                    {
                        objModules.UpdateTabModuleSetting(this.TabModuleId, "DisplayResultsTabId", lblTabId.Text);
                        break;
                    }
                }
            }
            catch (Exception exc)
            {
                // Module failed to load
                Exceptions.ProcessModuleLoadException(this, exc);
            }
        }
Example #3
0
        /// <summary>
        /// ParseSettings parses the Host Template's Settings node
        /// </summary>
        /// <remarks>
        /// </remarks>
        ///	<param name="node">The settings node</param>
        private static void ParseSettings(XmlNode node)
        {
            HostSettingsController objController = new HostSettingsController();

            //Parse the Settings nodes
            foreach (XmlNode tempLoopVar_settingNode in node.ChildNodes)
            {
                XmlNode settingNode = tempLoopVar_settingNode;
                string strSettingName = settingNode.Name;
                string strSettingValue = settingNode.InnerText;
                XmlAttribute SecureAttrib = settingNode.Attributes["Secure"];
                bool SettingIsSecure = false;
                if (SecureAttrib != null)
                {
                    if (SecureAttrib.Value.ToLower() == "true")
                    {
                        SettingIsSecure = true;
                    }
                }

                string strDomainName = Globals.GetDomainName(HttpContext.Current.Request);

                switch (strSettingName)
                {
                    case "HostURL":

                        if (strSettingValue == "")
                        {
                            strSettingValue = strDomainName;
                        }
                        break;
                    case "HostEmail":

                        if (strSettingValue == "")
                        {
                            strSettingValue = "support@" + strDomainName;

                            //Remove any folders
                            strSettingValue = strSettingValue.Substring(0, strSettingValue.IndexOf("/"));
                        }
                        break;
                }

                objController.UpdateHostSetting(strSettingName, strSettingValue, SettingIsSecure);
            }
            //Need to clear the cache to pick up new HostSettings from the SQLDataProvider script
            DataCache.RemoveCache("GetHostSettings");
        }
        /// <summary>
        /// cmdUpdate_Click runs when the Upgrade button is clicked
        /// </summary>
        /// <history>
        /// 	[cnurse]	9/27/2004	Updated to reflect design changes for Help, 508 support
        ///                       and localisation
        /// </history>
        protected void cmdUpdate_Click( object sender, EventArgs e )
        {
            try
            {
                HostSettingsController objHostSettings = new HostSettingsController();

                objHostSettings.UpdateHostSetting( "CheckUpgrade", Convert.ToString( chkUpgrade.Checked ? "Y" : "N" ) );
                objHostSettings.UpdateHostSetting( "HostPortalId", cboHostPortal.SelectedItem.Value );
                objHostSettings.UpdateHostSetting( "HostTitle", txtHostTitle.Text );
                objHostSettings.UpdateHostSetting( "HostURL", txtHostURL.Text );
                objHostSettings.UpdateHostSetting( "HostEmail", txtHostEmail.Text );
                objHostSettings.UpdateHostSetting( "PaymentProcessor", cboProcessor.SelectedItem.Text );
                objHostSettings.UpdateHostSetting( "ProcessorUserId", txtUserId.Text, true );
                objHostSettings.UpdateHostSetting( "ProcessorPassword", txtPassword.Text, true );
                objHostSettings.UpdateHostSetting( "HostFee", txtHostFee.Text );
                objHostSettings.UpdateHostSetting( "HostCurrency", cboHostCurrency.SelectedItem.Value );
                objHostSettings.UpdateHostSetting( "HostSpace", txtHostSpace.Text );
                objHostSettings.UpdateHostSetting("PageQuota", txtPageQuota.Text);
                objHostSettings.UpdateHostSetting("UserQuota", txtUserQuota.Text);
                objHostSettings.UpdateHostSetting( "SiteLogStorage", optSiteLogStorage.SelectedItem.Value );
                objHostSettings.UpdateHostSetting( "SiteLogBuffer", txtSiteLogBuffer.Text );
                objHostSettings.UpdateHostSetting( "SiteLogHistory", txtSiteLogHistory.Text );
                objHostSettings.UpdateHostSetting( "DemoPeriod", txtDemoPeriod.Text );
                objHostSettings.UpdateHostSetting( "DemoSignup", Convert.ToString( chkDemoSignup.Checked ? "Y" : "N" ) );
                objHostSettings.UpdateHostSetting( "Copyright", Convert.ToString( chkCopyright.Checked ? "Y" : "N" ) );

                bool OriginalUsersOnline;
                OriginalUsersOnline = Convert.ToBoolean( ViewState["SelectedUsersOnlineEnabled"] );
                if( OriginalUsersOnline != chkUsersOnline.Checked )
                {
                    ScheduleItem objScheduleItem;
                    objScheduleItem = SchedulingProvider.Instance().GetSchedule( "DotNetNuke.Entities.Users.PurgeUsersOnline, DOTNETNUKE", Null.NullString );
                    if( objScheduleItem != null )
                    {
                        if( ! chkUsersOnline.Checked )
                        {
                            if( ! objScheduleItem.Enabled )
                            {
                                objScheduleItem.Enabled = true;
                                SchedulingProvider.Instance().UpdateSchedule( objScheduleItem );
                                SchedulerMode mode = (SchedulerMode)Enum.Parse( typeof( SchedulerMode ), cboSchedulerMode.SelectedItem.Value );
                                if (mode == SchedulerMode.TIMER_METHOD)
                                {
                                    SchedulingProvider.Instance().ReStart( "Host Settings" );
                                }
                            }
                        }
                        else
                        {
                            if( objScheduleItem.Enabled )
                            {
                                objScheduleItem.Enabled = false;
                                SchedulingProvider.Instance().UpdateSchedule( objScheduleItem );
                                SchedulerMode mode = (SchedulerMode)Enum.Parse(typeof(SchedulerMode), cboSchedulerMode.SelectedItem.Value);
                                if( mode == SchedulerMode.TIMER_METHOD )
                                {
                                    SchedulingProvider.Instance().ReStart( "Host Settings" );
                                }
                            }
                        }
                    }
                }
                objHostSettings.UpdateHostSetting( "DisableUsersOnline", Convert.ToString( chkUsersOnline.Checked ? "Y" : "N" ) );

                objHostSettings.UpdateHostSetting( "AutoAccountUnlockDuration", txtAutoAccountUnlock.Text );
                objHostSettings.UpdateHostSetting( "UsersOnlineTime", txtUsersOnlineTime.Text );
                objHostSettings.UpdateHostSetting( "ProxyServer", txtProxyServer.Text );
                objHostSettings.UpdateHostSetting( "ProxyPort", txtProxyPort.Text );
                objHostSettings.UpdateHostSetting( "ProxyUsername", txtProxyUsername.Text, true );
                objHostSettings.UpdateHostSetting( "ProxyPassword", txtProxyPassword.Text, true );
                objHostSettings.UpdateHostSetting( "SMTPServer", txtSMTPServer.Text );
                objHostSettings.UpdateHostSetting( "SMTPAuthentication", optSMTPAuthentication.SelectedItem.Value );
                objHostSettings.UpdateHostSetting( "SMTPUsername", txtSMTPUsername.Text, true );
                objHostSettings.UpdateHostSetting( "SMTPPassword", txtSMTPPassword.Text, true );
                objHostSettings.UpdateHostSetting("SMTPEnableSSL", Convert.ToString((chkSMTPEnableSSL.Checked ? "Y" : "N")));
                objHostSettings.UpdateHostSetting( "FileExtensions", txtFileExtensions.Text );
                objHostSettings.UpdateHostSetting( "SkinUpload", optSkinUpload.SelectedItem.Value );
                objHostSettings.UpdateHostSetting( "UseCustomErrorMessages", Convert.ToString( chkUseCustomErrorMessages.Checked ? "Y" : "N" ) );
                objHostSettings.UpdateHostSetting( "UseFriendlyUrls", Convert.ToString( chkUseFriendlyUrls.Checked ? "Y" : "N" ) );
                objHostSettings.UpdateHostSetting( "ControlPanel", cboControlPanel.SelectedItem.Value );
                objHostSettings.UpdateHostSetting( "SchedulerMode", cboSchedulerMode.SelectedItem.Value );
                objHostSettings.UpdateHostSetting("PerformanceSetting", cboPerformance.SelectedItem.Value);
                objHostSettings.UpdateHostSetting("AuthenticatedCacheability", cboCacheability.SelectedItem.Value);
                objHostSettings.UpdateHostSetting("PageStatePersister", cboPageState.SelectedItem.Value);
                objHostSettings.UpdateHostSetting("ModuleCaching", cboCacheMethod.SelectedItem.Value);
                objHostSettings.UpdateHostSetting("HttpCompression", cboCompression.SelectedItem.Value);
                objHostSettings.UpdateHostSetting("HttpCompressionLevel", cboLevel.SelectedItem.Value);
                objHostSettings.UpdateHostSetting("WhitespaceFilter", Convert.ToString((chkWhitespace.Checked ? "Y" : "N")));
                objHostSettings.UpdateHostSetting( "EnableModuleOnLineHelp", Convert.ToString( chkEnableHelp.Checked ? "Y" : "N" ) );
                objHostSettings.UpdateHostSetting( "EnableFileAutoSync", Convert.ToString( chkAutoSync.Checked ? "Y" : "N" ) );
                objHostSettings.UpdateHostSetting( "HelpURL", txtHelpURL.Text );

                bool originalLogBuffer = Convert.ToBoolean( ViewState["SelectedLogBufferEnabled"] );
                if( originalLogBuffer != chkLogBuffer.Checked )
                {
                    ScheduleItem scheduleItem = SchedulingProvider.Instance().GetSchedule( "DotNetNuke.Services.Log.EventLog.PurgeLogBuffer, DOTNETNUKE", Null.NullString );
                    if( scheduleItem != null )
                    {
                        if( chkLogBuffer.Checked )
                        {
                            if( ! scheduleItem.Enabled )
                            {
                                scheduleItem.Enabled = true;
                                SchedulingProvider.Instance().UpdateSchedule( scheduleItem );
                                SchedulerMode mode = (SchedulerMode)Enum.Parse(typeof(SchedulerMode), cboSchedulerMode.SelectedItem.Value);
                                if( mode == SchedulerMode.TIMER_METHOD )
                                {
                                    SchedulingProvider.Instance().ReStart( "Host Settings" );
                                }
                            }
                        }
                        else
                        {
                            if( scheduleItem.Enabled )
                            {
                                scheduleItem.Enabled = false;
                                SchedulingProvider.Instance().UpdateSchedule( scheduleItem );
                                SchedulerMode mode = (SchedulerMode)Enum.Parse(typeof(SchedulerMode), cboSchedulerMode.SelectedItem.Value);
                                if( mode == SchedulerMode.TIMER_METHOD )
                                {
                                    SchedulingProvider.Instance().ReStart( "Host Settings" );
                                }
                            }
                        }
                    }
                }
                objHostSettings.UpdateHostSetting( "EventLogBuffer", Convert.ToString( chkLogBuffer.Checked ? "Y" : "N" ) );

                //SkinController objSkins = new SkinController();
                //bool blnAdminSkinChanged = SkinChanged( SkinInfo.RootSkin, Null.NullInteger, SkinType.Admin, ctlAdminSkin.SkinSrc ) || SkinChanged( SkinInfo.RootContainer, Null.NullInteger, SkinType.Admin, ctlAdminContainer.SkinSrc );
                SkinController.SetSkin( SkinInfo.RootSkin, Null.NullInteger, SkinType.Portal, ctlHostSkin.SkinSrc );
                SkinController.SetSkin( SkinInfo.RootContainer, Null.NullInteger, SkinType.Portal, ctlHostContainer.SkinSrc );
                SkinController.SetSkin( SkinInfo.RootSkin, Null.NullInteger, SkinType.Admin, ctlAdminSkin.SkinSrc );
                SkinController.SetSkin( SkinInfo.RootContainer, Null.NullInteger, SkinType.Admin, ctlAdminContainer.SkinSrc );

                // clear host settings cache
                DataCache.ClearHostCache( true );

                if (ViewState["SelectedSchedulerMode"] != null)
                {
                    SchedulerMode originalSchedulerMode = (SchedulerMode)Enum.Parse(typeof(SchedulerMode), (string)ViewState["SelectedSchedulerMode"]);

                    SchedulerMode smode = (SchedulerMode)Enum.Parse( typeof( SchedulerMode ), cboSchedulerMode.SelectedItem.Value );

                    if( smode == SchedulerMode.DISABLED )
                    {
                        if( originalSchedulerMode != SchedulerMode.DISABLED )
                        {
                            SchedulingProvider.Instance().Halt( "Host Settings" );
                        }
                    }
                    else if( smode == SchedulerMode.TIMER_METHOD )
                    {
                        if( originalSchedulerMode == SchedulerMode.DISABLED || originalSchedulerMode == SchedulerMode.REQUEST_METHOD )
                        {
                            Thread newThread = new Thread( new ThreadStart( SchedulingProvider.Instance().Start ) );
                            newThread.IsBackground = true;
                            newThread.Start();
                        }
                    }
                    else if( smode != SchedulerMode.TIMER_METHOD )
                    {
                        if( originalSchedulerMode == SchedulerMode.TIMER_METHOD )
                        {
                            SchedulingProvider.Instance().Halt( "Host Settings" );
                        }
                    }
                }

                // this is needed in order to fully flush the cache after changing FriendlyURL
                Response.Redirect( Request.RawUrl, true );

                // Redirect to this site to refresh only if admin skin changed
                //If blnAdminSkinChanged Then Response.Redirect(Request.RawUrl, True)
            }
            catch( Exception exc ) //Module failed to load
            {
                Exceptions.ProcessModuleLoadException( this, exc );
            }
        }
        /// <summary>
        /// cmdUpdate_Click runs when the Update LinkButton is clicked.
        /// It saves the current Search Settings
        /// </summary>
        /// <remarks>
        /// </remarks>
        /// <history>
        /// 	[cnurse]	9/9/2004	Modified
        /// </history>
        protected void cmdUpdate_Click( object sender, EventArgs e )
        {
            try
            {
                if( PortalSettings.ActiveTab.ParentId == PortalSettings.SuperTabId )
                {
                    HostSettingsController objHostSettings = new HostSettingsController();
                    objHostSettings.UpdateHostSetting( "MaxSearchWordLength", txtMaxWordLength.Text );
                    objHostSettings.UpdateHostSetting( "MinSearchWordLength", txtMinWordLength.Text );
                    objHostSettings.UpdateHostSetting( "SearchIncludeCommon", Convert.ToString( chkIncludeCommon.Checked ? "Y" : "N" ) );
                    objHostSettings.UpdateHostSetting( "SearchIncludeNumeric", Convert.ToString( chkIncludeNumeric.Checked ? "Y" : "N" ) );

                    // clear host settings cache
                    DataCache.ClearHostCache( false );
                }
                else
                {
                    ModuleController objModules = new ModuleController();
                    objModules.UpdateModuleSetting( ModuleId, "MaxSearchWordLength", txtMaxWordLength.Text );
                    objModules.UpdateModuleSetting( ModuleId, "MinSearchWordLength", txtMinWordLength.Text );
                    objModules.UpdateModuleSetting( ModuleId, "SearchIncludeCommon", Convert.ToString( chkIncludeCommon.Checked ? "Y" : "N" ) );
                    objModules.UpdateModuleSetting( ModuleId, "SearchIncludeNumeric", Convert.ToString( chkIncludeNumeric.Checked ? "Y" : "N" ) );
                }
            }
            catch( Exception exc ) //Module failed to load
            {
                Exceptions.ProcessModuleLoadException( this, exc );
            }
        }