index.aspx.cs 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  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.UserCenter
  20. {
  21. public partial class index : BasePage
  22. {
  23. protected void Page_Load(object sender, EventArgs e)
  24. {
  25. //Response.Write(DateTime.Parse(DateTime.Now.ToString("o")).ToString());
  26. string rPage;
  27. rPage = Request.QueryString["page"];
  28. int vPage = 1;
  29. if (rPage != string.Empty && rPage != null && Command.Command_Validate.IsNumber(rPage))
  30. {
  31. vPage = Convert.ToInt32(rPage);
  32. }
  33. string vHtml = "";
  34. bool vWebPageCache = Command.Command_Configuration.GetConfigBool("WebPageCache"); //判断是否启用了页面缓存
  35. if (vWebPageCache == false)
  36. {
  37. vHtml = Fun_GetIndexContent(vPage);
  38. }
  39. else
  40. {
  41. int vCacheTime = Command.Command_Configuration.GetConfigInt("CacheTime");
  42. string indexCacheKey = Command.Command_Configuration.GetConfigString("CacheKey") + "_IndexCache_" + vPage;
  43. object indexCacheInfo = Command.Command_DataCache.GetCache(indexCacheKey);
  44. //判断缓存是否存在
  45. if (indexCacheInfo == null)
  46. {
  47. vHtml = Fun_GetIndexContent(vPage);
  48. Command.Command_DataCache.SetCache(indexCacheKey, (object)vHtml, DateTime.Now.AddSeconds(vCacheTime), TimeSpan.Zero);
  49. }
  50. else
  51. {
  52. vHtml = indexCacheInfo.ToString();
  53. }
  54. }
  55. vHtml = WebUI_Function.Fun_UrlRewriter(vHtml);
  56. Response.Write(vHtml);
  57. }
  58. private string Fun_GetIndexContent(int byPage)
  59. {
  60. string vTemplateUrl = (siteConfig.IndexTemplateName);
  61. WebUI_Template wt = new WebUI_Template();
  62. wt.Load_Template(WebUI_Template.UserCenterPath+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. }