PageRenderTime 41ms CodeModel.GetById 14ms RepoModel.GetById 0ms app.codeStats 0ms

/DesktopModules/Admin/HostSettings/HostSettings.ascx.cs

https://github.com/mailekah/AgapeConnect1
C# | 820 lines | 655 code | 76 blank | 89 comment | 63 complexity | e83c71d1d5196cae6a157b52cbe8d0f1 MD5 | raw file
Possible License(s): BSD-3-Clause, Apache-2.0
  1. #region Copyright
  2. //
  3. // DotNetNukeĊ½ - http://www.dotnetnuke.com
  4. // Copyright (c) 2002-2012
  5. // by DotNetNuke Corporation
  6. //
  7. // Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
  8. // documentation files (the "Software"), to deal in the Software without restriction, including without limitation
  9. // the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and
  10. // to permit persons to whom the Software is furnished to do so, subject to the following conditions:
  11. //
  12. // The above copyright notice and this permission notice shall be included in all copies or substantial portions
  13. // of the Software.
  14. //
  15. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
  16. // TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
  17. // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
  18. // CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
  19. // DEALINGS IN THE SOFTWARE.
  20. #endregion
  21. #region Usings
  22. using System;
  23. using System.Collections;
  24. using System.Collections.Generic;
  25. using System.IO;
  26. using System.Linq;
  27. using System.Net;
  28. using System.Security.Principal;
  29. using System.Text;
  30. using System.Threading;
  31. using System.Web.UI.WebControls;
  32. using System.Xml;
  33. using System.Xml.XPath;
  34. using DotNetNuke.Application;
  35. using DotNetNuke.Common;
  36. using DotNetNuke.Common.Lists;
  37. using DotNetNuke.Common.Utilities;
  38. using DotNetNuke.ComponentModel;
  39. using DotNetNuke.Data;
  40. using DotNetNuke.Entities.Controllers;
  41. using DotNetNuke.Entities.Modules;
  42. using DotNetNuke.Entities.Portals;
  43. using DotNetNuke.Framework;
  44. using DotNetNuke.Framework.Providers;
  45. using DotNetNuke.Security;
  46. using DotNetNuke.Services.Cache;
  47. using DotNetNuke.Services.Exceptions;
  48. using DotNetNuke.Services.Installer;
  49. using DotNetNuke.Services.Localization;
  50. using DotNetNuke.Services.Log.EventLog;
  51. using DotNetNuke.Services.Mail;
  52. using DotNetNuke.Services.ModuleCache;
  53. using DotNetNuke.Services.OutputCache;
  54. using DotNetNuke.Services.Scheduling;
  55. using DotNetNuke.Services.Upgrade;
  56. using DotNetNuke.UI.Skins;
  57. using DotNetNuke.UI.Skins.Controls;
  58. using DotNetNuke.Web.UI.WebControls.Extensions;
  59. #endregion
  60. namespace DotNetNuke.Modules.Admin.Host
  61. {
  62. using System.Globalization;
  63. using System.Web;
  64. using Web.Client;
  65. /// -----------------------------------------------------------------------------
  66. /// <summary>
  67. /// The HostSettings PortalModuleBase is used to edit the host settings
  68. /// for the application.
  69. /// </summary>
  70. /// <remarks>
  71. /// </remarks>
  72. /// <history>
  73. /// [cnurse] 9/27/2004 Updated to reflect design changes for Help, 508 support
  74. /// and localisation
  75. /// </history>
  76. /// -----------------------------------------------------------------------------
  77. public partial class HostSettings : PortalModuleBase
  78. {
  79. #region Private Methods
  80. /// -----------------------------------------------------------------------------
  81. /// <summary>
  82. /// BindData fetches the data from the database and updates the controls
  83. /// </summary>
  84. /// <history>
  85. /// [cnurse] 9/27/2004 Updated to reflect design changes for Help, 508 support
  86. /// and localisation
  87. /// </history>
  88. /// -----------------------------------------------------------------------------
  89. private void BindConfiguration()
  90. {
  91. lblProduct.Text = DotNetNukeContext.Current.Application.Description;
  92. lblVersion.Text = Globals.FormatVersion(DotNetNukeContext.Current.Application.Version, true);
  93. betaRow.Visible = (DotNetNukeContext.Current.Application.Status != ReleaseMode.Stable);
  94. chkBetaNotice.Checked = Entities.Host.Host.DisplayBetaNotice;
  95. chkUpgrade.Checked = Entities.Host.Host.CheckUpgrade;
  96. hypUpgrade.ImageUrl = Upgrade.UpgradeIndicator(DotNetNukeContext.Current.Application.Version, Request.IsLocal, Request.IsSecureConnection);
  97. if (String.IsNullOrEmpty(hypUpgrade.ImageUrl))
  98. {
  99. hypUpgrade.Visible = false;
  100. }
  101. else
  102. {
  103. hypUpgrade.NavigateUrl = Upgrade.UpgradeRedirect();
  104. }
  105. lblDataProvider.Text = ProviderConfiguration.GetProviderConfiguration("data").DefaultProvider;
  106. lblFramework.Text = Globals.NETFrameworkVersion.ToString(2);
  107. if (!Upgrade.IsNETFrameworkCurrent("3.5"))
  108. {
  109. UI.Skins.Skin.AddModuleMessage(this, Localization.GetString("FrameworkDownLevel", LocalResourceFile), ModuleMessage.ModuleMessageType.YellowWarning);
  110. }
  111. if (WindowsIdentity.GetCurrent() != null)
  112. {
  113. // ReSharper disable PossibleNullReferenceException
  114. lblIdentity.Text = WindowsIdentity.GetCurrent().Name;
  115. // ReSharper restore PossibleNullReferenceException
  116. }
  117. lblHostName.Text = Dns.GetHostName();
  118. lblIPAddress.Text = Dns.GetHostEntry(lblHostName.Text).AddressList[0].ToString();
  119. lblPermissions.Text = SecurityPolicy.Permissions;
  120. if (string.IsNullOrEmpty(lblPermissions.Text))
  121. {
  122. lblPermissions.Text = Localization.GetString("None", LocalResourceFile);
  123. }
  124. lblApplicationPath.Text = string.IsNullOrEmpty(Globals.ApplicationPath) ? "/" : Globals.ApplicationPath;
  125. lblApplicationMapPath.Text = Globals.ApplicationMapPath;
  126. lblServerTime.Text = DateTime.Now.ToString();
  127. lblGUID.Text = Entities.Host.Host.GUID;
  128. chkWebFarm.Checked = CachingProvider.Instance().IsWebFarm();
  129. }
  130. private void BindFriendlyUrlsRequestFilters()
  131. {
  132. chkUseFriendlyUrls.Checked = Entities.Host.Host.UseFriendlyUrls;
  133. chkEnableRequestFilters.Checked = Entities.Host.Host.EnableRequestFilters;
  134. }
  135. private void BindHostDetails()
  136. {
  137. var objPortals = new PortalController();
  138. hostPortalsCombo.DataSource = objPortals.GetPortals();
  139. hostPortalsCombo.DataBind(Entities.Host.Host.HostPortalID.ToString());
  140. txtHostTitle.Text = Entities.Host.Host.HostTitle;
  141. txtHostURL.Text = Entities.Host.Host.HostURL;
  142. txtHostEmail.Text = Entities.Host.Host.HostEmail;
  143. valHostEmail.ValidationExpression = Globals.glbEmailRegEx;
  144. //Load DocTypes
  145. var docTypes = new Dictionary<string, string>
  146. {
  147. { LocalizeString("LegacyDoctype"), "0" },
  148. { LocalizeString("TransDoctype"), "1" },
  149. { LocalizeString("StrictDoctype"), "2" },
  150. { LocalizeString("Html5Doctype"), "3" }
  151. };
  152. docTypeCombo.DataSource = docTypes;
  153. docTypeCombo.DataBind();
  154. string docTypesetting = string.Empty;
  155. if (Globals.DataBaseVersion != null)
  156. {
  157. HostController.Instance.GetSettingsDictionary().TryGetValue("DefaultDocType", out docTypesetting);
  158. }
  159. if (string.IsNullOrEmpty(docTypesetting))
  160. {
  161. docTypesetting = "0";
  162. }
  163. docTypeCombo.DataBind(docTypesetting);
  164. chkRemember.Checked = Entities.Host.Host.RememberCheckbox;
  165. }
  166. private void BindJQuery()
  167. {
  168. jQueryVersion.Text = jQuery.Version;
  169. jQueryUIVersion.Text = jQuery.UIVersion;
  170. chkJQueryDebugVersion.Checked = jQuery.UseDebugScript;
  171. chkJQueryUseHosted.Checked = jQuery.UseHostedScript;
  172. txtJQueryHostedUrl.Text = jQuery.HostedUrl;
  173. txtJQueryUIHostedUrl.Text = jQuery.HostedUIUrl;
  174. }
  175. private void BindPerformance()
  176. {
  177. cboPageState.Items.FindByValue(Entities.Host.Host.PageStatePersister).Selected = true;
  178. BindModuleCacheProviderList();
  179. BindPageCacheProviderList();
  180. if (cboPerformance.Items.FindByValue(((int)Entities.Host.Host.PerformanceSetting).ToString()) != null)
  181. {
  182. cboPerformance.Items.FindByValue(((int)Entities.Host.Host.PerformanceSetting).ToString()).Selected = true;
  183. }
  184. else
  185. {
  186. cboPerformance.Items.FindByValue("3").Selected = true;
  187. }
  188. cboCacheability.Items.FindByValue(Entities.Host.Host.AuthenticatedCacheability).Selected = true;
  189. }
  190. private void BindPaymentProcessor()
  191. {
  192. var listController = new ListController();
  193. processorCombo.DataSource = listController.GetListEntryInfoItems("Processor", "");
  194. processorCombo.DataBind();
  195. processorCombo.InsertItem(0, "<" + Localization.GetString("None_Specified") + ">", "");
  196. processorCombo.Select(Entities.Host.Host.PaymentProcessor, true);
  197. processorLink.NavigateUrl = Globals.AddHTTP(processorCombo.SelectedItem.Value);
  198. txtUserId.Text = Entities.Host.Host.ProcessorUserId;
  199. txtPassword.Attributes.Add("value", Entities.Host.Host.ProcessorPassword);
  200. txtHostFee.Text = Entities.Host.Host.HostFee.ToString();
  201. currencyCombo.DataSource = listController.GetListEntryInfoItems("Currency", "");
  202. var currency = Entities.Host.Host.HostCurrency;
  203. if (String.IsNullOrEmpty(currency))
  204. {
  205. currency = "USD";
  206. }
  207. currencyCombo.DataBind(currency);
  208. txtHostSpace.Text = Entities.Host.Host.HostSpace.ToString();
  209. txtPageQuota.Text = Entities.Host.Host.PageQuota.ToString();
  210. txtUserQuota.Text = Entities.Host.Host.UserQuota.ToString();
  211. txtDemoPeriod.Text = Entities.Host.Host.DemoPeriod.ToString();
  212. chkDemoSignup.Checked = Entities.Host.Host.DemoSignup;
  213. }
  214. private void BindProxyServer()
  215. {
  216. txtProxyServer.Text = Entities.Host.Host.ProxyServer;
  217. txtProxyPort.Text = Entities.Host.Host.ProxyPort.ToString();
  218. txtProxyUsername.Text = Entities.Host.Host.ProxyUsername;
  219. txtProxyPassword.Attributes.Add("value", Entities.Host.Host.ProxyPassword);
  220. txtWebRequestTimeout.Text = Entities.Host.Host.WebRequestTimeout.ToString();
  221. }
  222. private void BindSkins()
  223. {
  224. var skins = SkinController.GetSkins(null, SkinController.RootSkin, SkinScope.Host)
  225. .ToDictionary(skin => skin.Key, skin => skin.Value);
  226. var containers = SkinController.GetSkins(null, SkinController.RootContainer, SkinScope.Host)
  227. .ToDictionary(skin => skin.Key, skin => skin.Value);
  228. hostSkinCombo.DataSource = skins;
  229. hostSkinCombo.DataBind(Entities.Host.Host.DefaultPortalSkin);
  230. hostContainerCombo.DataSource = containers;
  231. hostContainerCombo.DataBind(Entities.Host.Host.DefaultPortalContainer);
  232. editSkinCombo.DataSource = skins;
  233. editSkinCombo.DataBind(Entities.Host.Host.DefaultAdminSkin);
  234. editContainerCombo.DataSource = containers;
  235. editContainerCombo.DataBind(Entities.Host.Host.DefaultAdminContainer);
  236. uploadSkinLink.NavigateUrl = Util.InstallURL(ModuleContext.TabId, "");
  237. if (PortalSettings.EnablePopUps)
  238. {
  239. uploadSkinLink.Attributes.Add("onclick", "return " + UrlUtils.PopUpUrl(uploadSkinLink.NavigateUrl, this, PortalSettings, true, false));
  240. }
  241. }
  242. private void BindSmtpServer()
  243. {
  244. txtSMTPServer.Text = Entities.Host.Host.SMTPServer;
  245. if (!string.IsNullOrEmpty(Entities.Host.Host.SMTPAuthentication))
  246. {
  247. optSMTPAuthentication.Items.FindByValue(Entities.Host.Host.SMTPAuthentication).Selected = true;
  248. }
  249. else
  250. {
  251. optSMTPAuthentication.Items.FindByValue("0").Selected = true;
  252. }
  253. chkSMTPEnableSSL.Checked = Entities.Host.Host.EnableSMTPSSL;
  254. txtSMTPUsername.Text = Entities.Host.Host.SMTPUsername;
  255. txtSMTPPassword.Attributes.Add("value", Entities.Host.Host.SMTPPassword);
  256. }
  257. private void BindUpgradeLogs()
  258. {
  259. ProviderConfiguration objProviderConfiguration = ProviderConfiguration.GetProviderConfiguration("data");
  260. string strProviderPath = DataProvider.Instance().GetProviderPath();
  261. var arrScriptFiles = new ArrayList();
  262. string[] arrFiles = Directory.GetFiles(strProviderPath, "*." + objProviderConfiguration.DefaultProvider);
  263. foreach (string strFile in arrFiles)
  264. {
  265. arrScriptFiles.Add(Path.GetFileNameWithoutExtension(strFile));
  266. }
  267. arrScriptFiles.Sort();
  268. cboVersion.DataSource = arrScriptFiles;
  269. cboVersion.DataBind();
  270. }
  271. private void BindData()
  272. {
  273. BindConfiguration();
  274. BindHostDetails();
  275. chkCopyright.Checked = Entities.Host.Host.DisplayCopyright;
  276. chkUseCustomErrorMessages.Checked = Entities.Host.Host.UseCustomErrorMessages;
  277. chkUseCustomModuleCssClass.Checked = Entities.Host.Host.EnableCustomModuleCssClass;
  278. BindSkins();
  279. BindPaymentProcessor();
  280. BindFriendlyUrlsRequestFilters();
  281. BindProxyServer();
  282. BindSmtpServer();
  283. BindPerformance();
  284. BindJQuery();
  285. BindClientResourceManagement();
  286. ManageMinificationUi();
  287. foreach (KeyValuePair<string, ModuleControlInfo> kvp in ModuleControlController.GetModuleControlsByModuleDefinitionID(Null.NullInteger))
  288. {
  289. if (kvp.Value.ControlType == SecurityAccessLevel.ControlPanel)
  290. {
  291. cboControlPanel.Items.Add(new ListItem(kvp.Value.ControlKey.Replace("CONTROLPANEL:", ""), kvp.Value.ControlSrc));
  292. }
  293. }
  294. if (string.IsNullOrEmpty(Entities.Host.Host.ControlPanel))
  295. {
  296. if (cboControlPanel.Items.FindByValue(Globals.glbDefaultControlPanel) != null)
  297. {
  298. cboControlPanel.Items.FindByValue(Globals.glbDefaultControlPanel).Selected = true;
  299. }
  300. }
  301. else
  302. {
  303. if (cboControlPanel.Items.FindByValue(Entities.Host.Host.ControlPanel) != null)
  304. {
  305. cboControlPanel.Items.FindByValue(Entities.Host.Host.ControlPanel).Selected = true;
  306. }
  307. }
  308. if (String.IsNullOrEmpty(Entities.Host.Host.SiteLogStorage))
  309. {
  310. optSiteLogStorage.Items.FindByValue("D").Selected = true;
  311. }
  312. else
  313. {
  314. optSiteLogStorage.Items.FindByValue(Entities.Host.Host.SiteLogStorage).Selected = true;
  315. }
  316. txtSiteLogBuffer.Text = Entities.Host.Host.SiteLogBuffer.ToString();
  317. txtSiteLogHistory.Text = Entities.Host.Host.SiteLogHistory.ToString();
  318. chkUsersOnline.Checked = Entities.Host.Host.EnableUsersOnline;
  319. txtUsersOnlineTime.Text = Entities.Host.Host.UsersOnlineTimeWindow.ToString();
  320. txtAutoAccountUnlock.Text = Entities.Host.Host.AutoAccountUnlockDuration.ToString();
  321. txtFileExtensions.Text = Entities.Host.Host.AllowedExtensionWhitelist.ToStorageString();
  322. if (cboSchedulerMode.Items.FindByValue(((int)Entities.Host.Host.SchedulerMode).ToString()) != null)
  323. {
  324. cboSchedulerMode.Items.FindByValue(((int)Entities.Host.Host.SchedulerMode).ToString()).Selected = true;
  325. }
  326. else
  327. {
  328. cboSchedulerMode.Items.FindByValue("1").Selected = true;
  329. }
  330. chkLogBuffer.Checked = Entities.Host.Host.EventLogBuffer;
  331. txtHelpURL.Text = Entities.Host.Host.HelpURL;
  332. chkEnableHelp.Checked = Entities.Host.Host.EnableModuleOnLineHelp;
  333. chkAutoSync.Checked = Entities.Host.Host.EnableFileAutoSync;
  334. chkEnableContentLocalization.Checked = Entities.Host.Host.EnableContentLocalization;
  335. txtBatch.Text = Entities.Host.Host.MessageSchedulerBatchSize.ToString();
  336. ViewState["SelectedSchedulerMode"] = cboSchedulerMode.SelectedItem.Value;
  337. ViewState["SelectedLogBufferEnabled"] = chkLogBuffer.Checked;
  338. ViewState["SelectedUsersOnlineEnabled"] = chkUsersOnline.Checked;
  339. BindUpgradeLogs();
  340. }
  341. private void BindClientResourceManagement()
  342. {
  343. DebugEnabledRow.Visible = HttpContext.Current.IsDebuggingEnabled;
  344. CrmVersion.Text = Entities.Host.Host.CrmVersion.ToString(CultureInfo.InvariantCulture);
  345. chkCrmEnableCompositeFiles.Checked = Entities.Host.Host.CrmEnableCompositeFiles;
  346. chkCrmMinifyCss.Checked = Entities.Host.Host.CrmMinifyCss;
  347. chkCrmMinifyJs.Checked = Entities.Host.Host.CrmMinifyJs;
  348. }
  349. private void BindModuleCacheProviderList()
  350. {
  351. cboModuleCacheProvider.DataSource = GetFilteredProviders(ModuleCachingProvider.GetProviderList(), "ModuleCachingProvider");
  352. cboModuleCacheProvider.DataBind();
  353. if (cboModuleCacheProvider.Items.Count > 0)
  354. {
  355. var defaultModuleCache = ComponentFactory.GetComponent<ModuleCachingProvider>();
  356. string providerKey = (from provider in ModuleCachingProvider.GetProviderList() where provider.Value.Equals(defaultModuleCache) select provider.Key).SingleOrDefault();
  357. if (!string.IsNullOrEmpty(Entities.Host.Host.ModuleCachingMethod))
  358. {
  359. if (cboModuleCacheProvider.Items.FindByValue(Entities.Host.Host.ModuleCachingMethod) != null)
  360. {
  361. cboModuleCacheProvider.Items.FindByValue(Entities.Host.Host.ModuleCachingMethod).Selected = true;
  362. }
  363. else
  364. {
  365. cboModuleCacheProvider.Items.FindByValue(providerKey).Selected = true;
  366. }
  367. }
  368. else
  369. {
  370. cboModuleCacheProvider.Items.FindByValue(providerKey).Selected = true;
  371. }
  372. }
  373. }
  374. private void BindPageCacheProviderList()
  375. {
  376. cboPageCacheProvider.DataSource = GetFilteredProviders(OutputCachingProvider.GetProviderList(), "OutputCachingProvider");
  377. cboPageCacheProvider.DataBind();
  378. if (cboPageCacheProvider.Items.Count > 0)
  379. {
  380. var defaultPageCache = ComponentFactory.GetComponent<OutputCachingProvider>();
  381. var providerKey = (from provider in OutputCachingProvider.GetProviderList() where provider.Value.Equals(defaultPageCache) select provider.Key).SingleOrDefault();
  382. if (defaultPageCache != null)
  383. {
  384. PageCacheRow.Visible = true;
  385. if (!string.IsNullOrEmpty(Entities.Host.Host.PageCachingMethod))
  386. {
  387. if (cboPageCacheProvider.Items.FindByValue(Entities.Host.Host.PageCachingMethod) != null)
  388. {
  389. cboPageCacheProvider.Items.FindByValue(Entities.Host.Host.PageCachingMethod).Selected = true;
  390. }
  391. else
  392. {
  393. cboPageCacheProvider.Items.FindByValue(providerKey).Selected = true;
  394. }
  395. }
  396. else
  397. {
  398. cboPageCacheProvider.Items.FindByValue(providerKey).Selected = true;
  399. }
  400. }
  401. }
  402. else
  403. {
  404. PageCacheRow.Visible = false;
  405. }
  406. }
  407. private void CheckSecurity()
  408. {
  409. //Verify that the current user has access to access this page
  410. if (!UserInfo.IsSuperUser)
  411. {
  412. Response.Redirect(Globals.NavigateURL("Access Denied"), true);
  413. }
  414. }
  415. private static IEnumerable GetFilteredProviders<T>(Dictionary<string, T> providerList, string keyFilter)
  416. {
  417. var providers = from provider in providerList let filteredkey = provider.Key.Replace(keyFilter, String.Empty) select new { filteredkey, provider.Key };
  418. return providers;
  419. }
  420. #endregion
  421. #region Protected Methods
  422. protected override void OnInit(EventArgs e)
  423. {
  424. base.OnInit(e);
  425. jQuery.RequestDnnPluginsRegistration();
  426. }
  427. /// -----------------------------------------------------------------------------
  428. /// <summary>
  429. /// Page_Load runs when the control is loaded.
  430. /// </summary>
  431. /// <remarks>
  432. /// </remarks>
  433. /// <history>
  434. /// [cnurse] 9/27/2004 Updated to reflect design changes for Help, 508 support
  435. /// and localisation
  436. /// [VMasanas] 9/28/2004 Changed redirect to Access Denied
  437. /// </history>
  438. /// -----------------------------------------------------------------------------
  439. protected override void OnLoad(EventArgs e)
  440. {
  441. base.OnLoad(e);
  442. cmdEmail.Click += TestEmail;
  443. cmdRestart.Click += RestartApplication;
  444. cmdUpdate.Click += UpdateSettings;
  445. cmdUpgrade.Click += OnUpgradeClick;
  446. cmdCache.Click += ClearCache;
  447. IncrementCrmVersionButton.Click += IncrementCrmVersion;
  448. chkCrmEnableCompositeFiles.CheckedChanged += EnableCompositeFilesChanged;
  449. try
  450. {
  451. CheckSecurity();
  452. //If this is the first visit to the page, populate the site data
  453. if (Page.IsPostBack == false)
  454. {
  455. BindData();
  456. }
  457. }
  458. catch (Exception exc)
  459. {
  460. Exceptions.ProcessModuleLoadException(this, exc);
  461. }
  462. }
  463. private void EnableCompositeFilesChanged(object sender, EventArgs e)
  464. {
  465. ManageMinificationUi();
  466. }
  467. private void ManageMinificationUi()
  468. {
  469. var enableCompositeFiles = chkCrmEnableCompositeFiles.Checked;
  470. if (!enableCompositeFiles)
  471. {
  472. chkCrmMinifyCss.Checked = false;
  473. chkCrmMinifyJs.Checked = false;
  474. }
  475. chkCrmMinifyCss.Enabled = enableCompositeFiles;
  476. chkCrmMinifyJs.Enabled = enableCompositeFiles;
  477. }
  478. private void IncrementCrmVersion(object sender, EventArgs e)
  479. {
  480. var currentVersion = Entities.Host.Host.CrmVersion;
  481. var newVersion = currentVersion + 1;
  482. HostController.Instance.Update(ClientResourceSettings.VersionKey, newVersion.ToString(CultureInfo.InvariantCulture), true);
  483. Response.Redirect(Request.RawUrl, true); // reload page
  484. }
  485. protected void OnUpgradeClick(object sender, EventArgs e)
  486. {
  487. try
  488. {
  489. var strProviderPath = DataProvider.Instance().GetProviderPath();
  490. if (File.Exists(strProviderPath + cboVersion.SelectedItem.Text + ".log.resources"))
  491. {
  492. var objStreamReader = File.OpenText(strProviderPath + cboVersion.SelectedItem.Text + ".log.resources");
  493. var upgradeText = objStreamReader.ReadToEnd();
  494. if (String.IsNullOrEmpty(upgradeText.Trim()))
  495. {
  496. upgradeText = Localization.GetString("LogEmpty", LocalResourceFile);
  497. }
  498. lblUpgrade.Text = upgradeText.Replace("\n", "<br>");
  499. objStreamReader.Close();
  500. }
  501. else
  502. {
  503. lblUpgrade.Text = Localization.GetString("NoLog", LocalResourceFile);
  504. }
  505. }
  506. catch (Exception exc)
  507. {
  508. Exceptions.ProcessModuleLoadException(this, exc);
  509. }
  510. }
  511. /// -----------------------------------------------------------------------------
  512. /// <summary>
  513. /// ClearCache runs when the clear cache button is clicked
  514. /// </summary>
  515. /// <remarks>
  516. /// </remarks>
  517. /// <history>
  518. /// [cnurse] 9/27/2004 Updated to reflect design changes for Help, 508 support
  519. /// and localisation
  520. /// </history>
  521. /// -----------------------------------------------------------------------------
  522. protected void ClearCache(object sender, EventArgs e)
  523. {
  524. DataCache.ClearCache();
  525. Response.Redirect(Request.RawUrl, true);
  526. }
  527. protected void RestartApplication(object sender, EventArgs e)
  528. {
  529. var objEv = new EventLogController();
  530. var objEventLogInfo = new LogInfo { BypassBuffering = true, LogTypeKey = EventLogController.EventLogType.HOST_ALERT.ToString() };
  531. objEventLogInfo.AddProperty("Message", Localization.GetString("UserRestart", LocalResourceFile));
  532. objEv.AddLog(objEventLogInfo);
  533. Config.Touch();
  534. Response.Redirect(Globals.NavigateURL(), true);
  535. }
  536. /// -----------------------------------------------------------------------------
  537. /// <summary>
  538. /// TestEmail runs when the test email button is clicked
  539. /// </summary>
  540. /// <remarks>
  541. /// </remarks>
  542. /// <history>
  543. /// [cnurse] 9/27/2004 Updated to reflect design changes for Help, 508 support
  544. /// and localisation
  545. /// </history>
  546. /// -----------------------------------------------------------------------------
  547. protected void TestEmail(object sender, EventArgs e)
  548. {
  549. try
  550. {
  551. if (!String.IsNullOrEmpty(txtHostEmail.Text))
  552. {
  553. txtSMTPPassword.Attributes.Add("value", txtSMTPPassword.Text);
  554. string strMessage = Mail.SendMail(txtHostEmail.Text,
  555. txtHostEmail.Text,
  556. "",
  557. "",
  558. MailPriority.Normal,
  559. Localization.GetSystemMessage(PortalSettings, "EMAIL_SMTP_TEST_SUBJECT"),
  560. MailFormat.Text,
  561. Encoding.UTF8,
  562. "",
  563. "",
  564. txtSMTPServer.Text,
  565. optSMTPAuthentication.SelectedItem.Value,
  566. txtSMTPUsername.Text,
  567. txtSMTPPassword.Text,
  568. chkSMTPEnableSSL.Checked);
  569. if (!String.IsNullOrEmpty(strMessage))
  570. {
  571. UI.Skins.Skin.AddModuleMessage(this, "", String.Format(Localization.GetString("EmailErrorMessage", LocalResourceFile), strMessage), ModuleMessage.ModuleMessageType.RedError);
  572. }
  573. else
  574. {
  575. UI.Skins.Skin.AddModuleMessage(this, "", Localization.GetString("EmailSentMessage", LocalResourceFile), ModuleMessage.ModuleMessageType.GreenSuccess);
  576. }
  577. }
  578. else
  579. {
  580. UI.Skins.Skin.AddModuleMessage(this, "", Localization.GetString("SpecifyHostEmailMessage", LocalResourceFile), ModuleMessage.ModuleMessageType.RedError);
  581. }
  582. }
  583. catch (Exception exc) //Module failed to load
  584. {
  585. Exceptions.ProcessModuleLoadException(this, exc);
  586. }
  587. }
  588. protected void UpdateSchedule()
  589. {
  590. bool restartSchedule = false;
  591. bool usersOnLineChanged = (Convert.ToBoolean(ViewState["SelectedUsersOnlineEnabled"]) != chkUsersOnline.Checked);
  592. if (usersOnLineChanged)
  593. {
  594. ScheduleItem scheduleItem = SchedulingProvider.Instance().GetSchedule("DotNetNuke.Entities.Users.PurgeUsersOnline, DOTNETNUKE", Null.NullString);
  595. if (scheduleItem != null)
  596. {
  597. scheduleItem.Enabled = chkUsersOnline.Checked;
  598. SchedulingProvider.Instance().UpdateSchedule(scheduleItem);
  599. restartSchedule = true;
  600. }
  601. }
  602. bool logBufferChanged = (Convert.ToBoolean(ViewState["SelectedLogBufferEnabled"]) != chkLogBuffer.Checked);
  603. if (logBufferChanged)
  604. {
  605. var scheduleItem = SchedulingProvider.Instance().GetSchedule("DotNetNuke.Services.Log.EventLog.PurgeLogBuffer, DOTNETNUKE", Null.NullString);
  606. if (scheduleItem != null)
  607. {
  608. scheduleItem.Enabled = chkLogBuffer.Checked;
  609. SchedulingProvider.Instance().UpdateSchedule(scheduleItem);
  610. restartSchedule = true;
  611. }
  612. }
  613. var originalSchedulerMode = (SchedulerMode)Convert.ToInt32(ViewState["SelectedSchedulerMode"]);
  614. var newSchedulerMode = (SchedulerMode) Enum.Parse(typeof (SchedulerMode), cboSchedulerMode.SelectedItem.Value);
  615. if(originalSchedulerMode != newSchedulerMode)
  616. {
  617. switch (newSchedulerMode)
  618. {
  619. case SchedulerMode.DISABLED:
  620. SchedulingProvider.Instance().Halt("Host Settings");
  621. break;
  622. case SchedulerMode.TIMER_METHOD:
  623. var newThread = new Thread(SchedulingProvider.Instance().Start) { IsBackground = true };
  624. newThread.Start();
  625. break;
  626. default:
  627. SchedulingProvider.Instance().Halt("Host Settings");
  628. break;
  629. }
  630. }
  631. if (restartSchedule && newSchedulerMode == SchedulerMode.TIMER_METHOD)
  632. {
  633. SchedulingProvider.Instance().ReStart("Host Settings");
  634. }
  635. }
  636. /// -----------------------------------------------------------------------------
  637. /// <summary>
  638. /// cmdUpdate_Click runs when the Upgrade button is clicked
  639. /// </summary>
  640. /// <remarks>
  641. /// </remarks>
  642. /// <history>
  643. /// [cnurse] 9/27/2004 Updated to reflect design changes for Help, 508 support
  644. /// and localisation
  645. /// </history>
  646. /// -----------------------------------------------------------------------------
  647. protected void UpdateSettings(object sender, EventArgs e)
  648. {
  649. if (Page.IsValid)
  650. {
  651. try
  652. {
  653. var smtpServer = txtSMTPServer.Text;
  654. if (!string.IsNullOrEmpty(smtpServer)
  655. && smtpServer.Contains(":")
  656. && smtpServer.Split(':')[1] != "25"
  657. && !SecurityPolicy.HasAspNetHostingPermission())
  658. {
  659. UI.Skins.Skin.AddModuleMessage(this, Localization.GetString("SmtpServerInvalid", LocalResourceFile), ModuleMessage.ModuleMessageType.RedError);
  660. return;
  661. }
  662. HostController.Instance.Update("CheckUpgrade", chkUpgrade.Checked ? "Y" : "N", false);
  663. HostController.Instance.Update("DisplayBetaNotice", chkBetaNotice.Checked ? "Y" : "N", false);
  664. HostController.Instance.Update("HostPortalId", hostPortalsCombo.SelectedValue);
  665. HostController.Instance.Update("HostTitle", txtHostTitle.Text, false);
  666. HostController.Instance.Update("HostURL", txtHostURL.Text, false);
  667. HostController.Instance.Update("HostEmail", txtHostEmail.Text.Trim(), false);
  668. HostController.Instance.Update("PaymentProcessor", processorCombo.SelectedItem.Text, false);
  669. HostController.Instance.Update("ProcessorUserId", txtUserId.Text, false);
  670. HostController.Instance.Update("ProcessorPassword", txtPassword.Text, false);
  671. HostController.Instance.Update("HostFee", txtHostFee.Text, false);
  672. HostController.Instance.Update("HostCurrency", currencyCombo.SelectedValue, false);
  673. HostController.Instance.Update("HostSpace", txtHostSpace.Text, false);
  674. HostController.Instance.Update("PageQuota", txtPageQuota.Text, false);
  675. HostController.Instance.Update("UserQuota", txtUserQuota.Text, false);
  676. HostController.Instance.Update("SiteLogStorage", optSiteLogStorage.SelectedItem.Value, false);
  677. HostController.Instance.Update("SiteLogBuffer", txtSiteLogBuffer.Text, false);
  678. HostController.Instance.Update("SiteLogHistory", txtSiteLogHistory.Text, false);
  679. HostController.Instance.Update("DemoPeriod", txtDemoPeriod.Text, false);
  680. HostController.Instance.Update("DemoSignup", chkDemoSignup.Checked ? "Y" : "N", false);
  681. HostController.Instance.Update("Copyright", chkCopyright.Checked ? "Y" : "N", false);
  682. HostController.Instance.Update("DefaultDocType", docTypeCombo.SelectedValue, false);
  683. HostController.Instance.Update("RememberCheckbox", chkRemember.Checked ? "Y" : "N", false);
  684. HostController.Instance.Update("EnableCustomModuleCssClass", chkUseCustomModuleCssClass.Checked ? "Y" : "N", false);
  685. HostController.Instance.Update("DisableUsersOnline", chkUsersOnline.Checked ? "N" : "Y", false);
  686. HostController.Instance.Update("AutoAccountUnlockDuration", txtAutoAccountUnlock.Text, false);
  687. HostController.Instance.Update("UsersOnlineTime", txtUsersOnlineTime.Text, false);
  688. HostController.Instance.Update("ProxyServer", txtProxyServer.Text, false);
  689. HostController.Instance.Update("ProxyPort", txtProxyPort.Text, false);
  690. HostController.Instance.Update("ProxyUsername", txtProxyUsername.Text, false);
  691. HostController.Instance.Update("ProxyPassword", txtProxyPassword.Text, false);
  692. HostController.Instance.Update("WebRequestTimeout", txtWebRequestTimeout.Text, false);
  693. HostController.Instance.Update("SMTPServer", txtSMTPServer.Text, false);
  694. HostController.Instance.Update("SMTPAuthentication", optSMTPAuthentication.SelectedItem.Value, false);
  695. HostController.Instance.Update("SMTPUsername", txtSMTPUsername.Text, false);
  696. HostController.Instance.Update("SMTPPassword", txtSMTPPassword.Text, false);
  697. HostController.Instance.Update("SMTPEnableSSL", chkSMTPEnableSSL.Checked ? "Y" : "N", false);
  698. HostController.Instance.Update("FileExtensions", txtFileExtensions.Text, false);
  699. HostController.Instance.Update("UseCustomErrorMessages", chkUseCustomErrorMessages.Checked ? "Y" : "N", false);
  700. HostController.Instance.Update("UseFriendlyUrls", chkUseFriendlyUrls.Checked ? "Y" : "N", false);
  701. HostController.Instance.Update("EnableRequestFilters", chkEnableRequestFilters.Checked ? "Y" : "N", false);
  702. HostController.Instance.Update("ControlPanel", cboControlPanel.SelectedItem.Value, false);
  703. HostController.Instance.Update("SchedulerMode", cboSchedulerMode.SelectedItem.Value, false);
  704. HostController.Instance.Update("PerformanceSetting", cboPerformance.SelectedItem.Value, false);
  705. HostController.Instance.Update("AuthenticatedCacheability", cboCacheability.SelectedItem.Value, false);
  706. HostController.Instance.Update("PageStatePersister", cboPageState.SelectedItem.Value);
  707. HostController.Instance.Update("ModuleCaching", cboModuleCacheProvider.SelectedItem.Value, false);
  708. if (PageCacheRow.Visible)
  709. {
  710. HostController.Instance.Update("PageCaching", cboPageCacheProvider.SelectedItem.Value, false);
  711. }
  712. HostController.Instance.Update("EnableModuleOnLineHelp", chkEnableHelp.Checked ? "Y" : "N", false);
  713. HostController.Instance.Update("EnableFileAutoSync", chkAutoSync.Checked ? "Y" : "N", false);
  714. HostController.Instance.Update("HelpURL", txtHelpURL.Text, false);
  715. HostController.Instance.Update("EnableContentLocalization", chkEnableContentLocalization.Checked ? "Y" : "N", false);
  716. HostController.Instance.Update("MessageSchedulerBatchSize", txtBatch.Text, false);
  717. HostController.Instance.Update("EventLogBuffer", chkLogBuffer.Checked ? "Y" : "N", false);
  718. HostController.Instance.Update("DefaultPortalSkin", hostSkinCombo.SelectedValue, false);
  719. HostController.Instance.Update("DefaultAdminSkin", editSkinCombo.SelectedValue, false);
  720. HostController.Instance.Update("DefaultPortalContainer", hostContainerCombo.SelectedValue, false);
  721. HostController.Instance.Update("DefaultAdminContainer", editContainerCombo.SelectedValue, false);
  722. HostController.Instance.Update("jQueryDebug", chkJQueryDebugVersion.Checked ? "Y" : "N", false);
  723. HostController.Instance.Update("jQueryHosted", chkJQueryUseHosted.Checked ? "Y" : "N", false);
  724. HostController.Instance.Update("jQueryUrl", txtJQueryHostedUrl.Text, false);
  725. HostController.Instance.Update("jQueryUIUrl", txtJQueryUIHostedUrl.Text, false);
  726. HostController.Instance.Update(ClientResourceSettings.EnableCompositeFilesKey, chkCrmEnableCompositeFiles.Checked.ToString(CultureInfo.InvariantCulture));
  727. HostController.Instance.Update(ClientResourceSettings.MinifyCssKey, chkCrmMinifyCss.Checked.ToString(CultureInfo.InvariantCulture));
  728. HostController.Instance.Update(ClientResourceSettings.MinifyJsKey, chkCrmMinifyJs.Checked.ToString(CultureInfo.InvariantCulture));
  729. UpdateSchedule();
  730. Response.Redirect(Request.RawUrl, true);
  731. }
  732. catch (Exception exc)
  733. {
  734. Exceptions.ProcessModuleLoadException(this, exc);
  735. }
  736. finally
  737. {
  738. DataCache.ClearHostCache(false);
  739. }
  740. }
  741. }
  742. #endregion
  743. }
  744. }