index.aspx.cs 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  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.Web.Security;
  18. using iNethinkCMS.Command;
  19. using iNethinkCMS.Web.UI;
  20. namespace iNethinkCMS.Web.admin
  21. {
  22. public partial class index : BasePage
  23. {
  24. protected void Page_Load(object sender, EventArgs e)
  25. {
  26. this.Title = siteConfig.WebName + "利亚方舟_管理中心_";
  27. string vAct = Request.QueryString["Act"] != null ? Request.QueryString["Act"] : "";
  28. if (vAct == "loginout")
  29. {
  30. Command_Session.Del("admin_username");
  31. Command_Session.Del("admin_usertruename");
  32. Command_Session.Del("admin_userpass");
  33. Command_Session.Del("admin_userpower");
  34. Command_Session.Del("admin_userchannelpower");
  35. Command_Session.Del("admin_loginuserid");
  36. Command_Cookie.ClearCookie("cookie_admin_username");
  37. Command_Cookie.ClearCookie("cookie_admin_password");
  38. if (Command_Session.Get("admin_loginusertype") != null && Command_Session.Get("admin_loginusertype") == "1")
  39. {
  40. Command_Session.Del("admin_loginusertype");
  41. Response.Redirect(this.Request.Path);
  42. }
  43. else {
  44. Command_Session.Del("admin_loginusertype");
  45. Response.Redirect("~/login.aspx");
  46. }
  47. }
  48. }
  49. protected void Button_Login_Click(object sender, EventArgs e)
  50. {
  51. #if DEBUG
  52. // this.txtUserName.Text = "admin";
  53. // this.txtUserPass.TextMode = TextBoxMode.SingleLine;
  54. // this.txtUserPass.Text = "111111";
  55. // this.txtVerificationCode.Text = Command.Command_Session.Get("verificationcode");
  56. #endif
  57. if (this.txtUserName.Text.Trim().Length == 0)
  58. {
  59. MessageBox.Show(this, "请输入用户名!");
  60. return;
  61. }
  62. if (this.txtUserPass.Text.Trim().Length == 0)
  63. {
  64. MessageBox.Show(this, "请输入密码!");
  65. return;
  66. }
  67. if (this.txtVerificationCode.Text.Trim().Length == 0)
  68. {
  69. MessageBox.Show(this, "请输入验证码!");
  70. return;
  71. }
  72. string UserName = this.txtUserName.Text.Trim();
  73. string UserPass = FormsAuthentication.HashPasswordForStoringInConfigFile(this.txtUserPass.Text.Trim(), "MD5").ToLower();
  74. string vVerificationCode = this.txtVerificationCode.Text.Trim().ToLower();
  75. //判断验证码是否输入正确
  76. if (vVerificationCode != Command.Command_Session.Get("verificationcode"))
  77. {
  78. this.txtVerificationCode.Text = "";
  79. MessageBox.Show(this, "验证码输入错误!");
  80. return;
  81. }
  82. iNethinkCMS.BLL.BLL_iNethinkCMS_User bll = new iNethinkCMS.BLL.BLL_iNethinkCMS_User();
  83. if (bll.Exists(1, UserName, UserPass) == true)
  84. {
  85. //写入Seesion
  86. iNethinkCMS.Model.Model_iNethinkCMS_User model = new iNethinkCMS.Model.Model_iNethinkCMS_User();
  87. model = bll.GetModel(UserName);
  88. Command_Session.Add("admin_username", model.UserName);
  89. Command_Session.Add("admin_usertruename", model.UserTrueName);
  90. Command_Session.Add("admin_userpass", model.UserPass);
  91. Command_Session.Add("admin_userpower", model.UserPower);
  92. Command_Session.Add("admin_userchannelpower", model.UserChannelPower);
  93. Command_Session.Add("admin_loginuserid", model.ID.ToString());
  94. Command_Session.Add("admin_loginusertype", model.UserType.ToString());
  95. //写入COOKIE
  96. string vRndStr = Command_MD5.md5(Command_StringPlus.RandomCode("all", 8) + model.UserName);
  97. string vSecurityCode = Command_MD5.md5(siteConfig.CacheKey + Command_Function.GetUserIp() + vRndStr);
  98. Command_Cookie.SaveCookie("cookie_admin_username", model.UserName, 0);
  99. Command_Cookie.SaveCookie("cookie_admin_password", vSecurityCode, 0);
  100. iNethinkCMS.Helper.SQLHelper.ExecuteSql("Update [iNethinkCMS_User] Set SecurityCode='" + vRndStr + "' Where UserName='" + model.UserName + "'");
  101. Response.Redirect("main.aspx");
  102. }
  103. else
  104. {
  105. MessageBox.Show(this, "用户名或密码输入错误!\\n请检查后重新进行登陆!");
  106. return;
  107. }
  108. }
  109. }
  110. }