manage.aspx.cs 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  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 iNethinkCMS.Helper;
  18. using iNethinkCMS.Command;
  19. using iNethinkCMS.Web.UI;
  20. namespace iNethinkCMS.Web.plugs.guestbook
  21. {
  22. public partial class manage : Admin_BasePage
  23. {
  24. private string vXmlPath = @"/plugs/guestbook/setting.xml";
  25. private string vState;
  26. private string vTemplatepath;
  27. private string vTimeinterval;
  28. private string vContentlength;
  29. private string vContentclearhtml;
  30. private string vSecuritycode;
  31. protected void Page_Load(object sender, EventArgs e)
  32. {
  33. CheckUserPower("c");
  34. if (!IsPostBack)
  35. {
  36. if (Request.UrlReferrer != null)
  37. {
  38. ViewState["reJumpUrl"] = Request.UrlReferrer.AbsoluteUri;
  39. }
  40. else
  41. {
  42. ViewState["reJumpUrl"] = Request.Url.AbsoluteUri;
  43. }
  44. vState = XMLHelper.GetXmlAttribute(Server.MapPath(vXmlPath), "//plugs//config//key[@name=\"state\"]", "value").Value.Trim();
  45. vTemplatepath = XMLHelper.GetXmlAttribute(Server.MapPath(vXmlPath), "//plugs//config//key[@name=\"templatepath\"]", "value").Value.Trim();
  46. vTimeinterval = XMLHelper.GetXmlAttribute(Server.MapPath(vXmlPath), "//plugs//config//key[@name=\"timeinterval\"]", "value").Value.Trim();
  47. vContentlength = XMLHelper.GetXmlAttribute(Server.MapPath(vXmlPath), "//plugs//config//key[@name=\"contentlength\"]", "value").Value.Trim();
  48. vContentclearhtml = XMLHelper.GetXmlAttribute(Server.MapPath(vXmlPath), "//plugs//config//key[@name=\"contentclearhtml\"]", "value").Value.Trim();
  49. vSecuritycode = XMLHelper.GetXmlAttribute(Server.MapPath(vXmlPath), "//plugs//config//key[@name=\"securitycode\"]", "value").Value.Trim();
  50. this.txtState.SelectedValue = vState;
  51. this.txtTemplatepath.Text = vTemplatepath;
  52. this.txtTimeinterval.Text = vTimeinterval;
  53. this.txtContentlength.Text = vContentlength;
  54. this.txtContentclearhtml.SelectedValue = vContentclearhtml;
  55. this.txtSecuritycode.SelectedValue = vSecuritycode;
  56. }
  57. }
  58. protected void Button_Submit_Click(object sender, EventArgs e)
  59. {
  60. vState = this.txtState.SelectedValue;
  61. vTemplatepath = this.txtTemplatepath.Text.Trim();
  62. vTimeinterval = this.txtTimeinterval.Text.Trim();
  63. vContentlength = this.txtContentlength.Text.Trim();
  64. vContentclearhtml = this.txtContentclearhtml.SelectedValue;
  65. vSecuritycode = this.txtSecuritycode.SelectedValue;
  66. if (this.vTemplatepath.Length == 0)
  67. {
  68. MessageBox.Show(this, "请输入模板路径!");
  69. return;
  70. }
  71. if (!Command_Validate.IsNumber(vTimeinterval))
  72. {
  73. MessageBox.Show(this, "时间间隔只能为数字!");
  74. return;
  75. }
  76. if (!Command_Validate.IsNumber(vContentlength))
  77. {
  78. MessageBox.Show(this, "留言内容长度只能为数字!");
  79. return;
  80. }
  81. XMLHelper.CreateOrUpdateXmlAttributeByXPath(Server.MapPath(vXmlPath), "//plugs//config//key[@name=\"state\"]", "value", vState);
  82. XMLHelper.CreateOrUpdateXmlAttributeByXPath(Server.MapPath(vXmlPath), "//plugs//config//key[@name=\"templatepath\"]", "value", vTemplatepath);
  83. XMLHelper.CreateOrUpdateXmlAttributeByXPath(Server.MapPath(vXmlPath), "//plugs//config//key[@name=\"timeinterval\"]", "value", vTimeinterval);
  84. XMLHelper.CreateOrUpdateXmlAttributeByXPath(Server.MapPath(vXmlPath), "//plugs//config//key[@name=\"contentlength\"]", "value", vContentlength);
  85. XMLHelper.CreateOrUpdateXmlAttributeByXPath(Server.MapPath(vXmlPath), "//plugs//config//key[@name=\"contentclearhtml\"]", "value", vContentclearhtml);
  86. XMLHelper.CreateOrUpdateXmlAttributeByXPath(Server.MapPath(vXmlPath), "//plugs//config//key[@name=\"securitycode\"]", "value", vSecuritycode);
  87. Response.Redirect(ViewState["reJumpUrl"].ToString());
  88. }
  89. }
  90. }