index.aspx.cs 3.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. /*******************************************************************************
  2. * iNethinkCMS - 网站内容管理系统
  3. * Copyright (C) 2012-2013 inethink.com
  4. *
  5. * @author jackyang <69991000@qq.com>
  6. * @website http://cms.inethink.com
  7. * @version 1.3.6.0 (2013-08-14)
  8. *
  9. * This is licensed under the GNU LGPL, version 3.0 or later.
  10. * For details, see: http://www.gnu.org/licenses/gpl-3.0.html
  11. *******************************************************************************/
  12. using System;
  13. using System.Collections.Generic;
  14. using System.Web;
  15. using System.Web.UI;
  16. using System.Web.UI.WebControls;
  17. using System.Text.RegularExpressions;
  18. using iNethinkCMS.Web.UI;
  19. namespace iNethinkCMS.Web
  20. {
  21. public partial class index : BasePage
  22. {
  23. protected void Page_Load(object sender, EventArgs e)
  24. {
  25. string rPage;
  26. rPage = Request.QueryString["page"];
  27. int vPage = 1;
  28. if (rPage != string.Empty && rPage != null && Command.Command_Validate.IsNumber(rPage))
  29. {
  30. vPage = Convert.ToInt32(rPage);
  31. }
  32. string vHtml = "";
  33. bool vWebPageCache = Command.Command_Configuration.GetConfigBool("WebPageCache"); //判断是否启用了页面缓存
  34. if (vWebPageCache == false)
  35. {
  36. vHtml = Fun_GetIndexContent(vPage);
  37. }
  38. else
  39. {
  40. int vCacheTime = Command.Command_Configuration.GetConfigInt("CacheTime");
  41. string indexCacheKey = Command.Command_Configuration.GetConfigString("CacheKey") + "_IndexCache_" + vPage;
  42. object indexCacheInfo = Command.Command_DataCache.GetCache(indexCacheKey);
  43. //判断缓存是否存在
  44. if (indexCacheInfo == null)
  45. {
  46. vHtml = Fun_GetIndexContent(vPage);
  47. Command.Command_DataCache.SetCache(indexCacheKey, (object)vHtml, DateTime.Now.AddSeconds(vCacheTime), TimeSpan.Zero);
  48. }
  49. else
  50. {
  51. vHtml = indexCacheInfo.ToString();
  52. }
  53. }
  54. vHtml = WebUI_Function.Fun_UrlRewriter(vHtml);
  55. Response.Write(vHtml);
  56. }
  57. private string Fun_GetIndexContent(int byPage)
  58. {
  59. string vTemplateUrl = (siteConfig.IndexTemplateName);
  60. vTemplateUrl = isMobile() ? "Mobile/" + vTemplateUrl : vTemplateUrl;
  61. WebUI_Template wt = new WebUI_Template();
  62. wt.Load_Template(vTemplateUrl);
  63. wt.vPage = byPage;
  64. wt.vContent = Regex.Replace(wt.vContent, Regex.Escape("{sys:title}"), siteConfig.WebName, RegexOptions.IgnoreCase);
  65. wt.vContent = Regex.Replace(wt.vContent, Regex.Escape("{sys:seotitle}"), seoConfig.SeoTitle, RegexOptions.IgnoreCase);
  66. wt.vContent = Regex.Replace(wt.vContent, Regex.Escape("{sys:keywords}"), seoConfig.IndexKeywords, RegexOptions.IgnoreCase);
  67. wt.vContent = Regex.Replace(wt.vContent, Regex.Escape("{sys:description}"), seoConfig.IndexDescription, RegexOptions.IgnoreCase);
  68. wt.vContent = Regex.Replace(wt.vContent, Regex.Escape("{sys:sitepath}"), "<a href=\"/\">首页</a>", RegexOptions.IgnoreCase);
  69. wt.Parser_MyTag();
  70. wt.Parser_List();
  71. wt.Parser_Page();
  72. wt.Parser_IF();
  73. return wt.vContent;
  74. }
  75. }
  76. }