pwd.php 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. <?php
  2. include "conn.php";
  3. checkLogin("");
  4. ?>
  5. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  6. <html xmlns="http://www.w3.org/1999/xhtml">
  7. <head>
  8. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  9. <title>管理区域</title>
  10. <link rel="stylesheet" href="css/common.css" type="text/css" />
  11. <script language="javascript" src="js/jquery-1.7.2.min.js"></script>
  12. <script type="text/javascript" src="js/js.js"></script>
  13. <script>
  14. function chkpwdform(){
  15. _loginpwd = document.getElementById("loginpwd"),
  16. _loginpwd1 = document.getElementById("loginpwd1"),
  17. _loginpwd2 = document.getElementById("loginpwd2"),
  18. _loginname = document.getElementById("loginname");
  19. _save = document.getElementById("save");
  20. if(_save.disabled) return false;
  21. if(_loginpwd.value ==''){
  22. alert('请输入原密码');
  23. _loginpwd.focus();
  24. return false;
  25. }
  26. if(_loginname.value ==''){
  27. alert('请输入用户昵称');
  28. _loginname.focus();
  29. return false;
  30. }
  31. if(_loginpwd1.value != _loginpwd2.value){
  32. alert('新密码两次密码输入不相同\n不修改请留空');
  33. _loginpwd2.focus();
  34. return false;
  35. }
  36. _save.disabled = true;
  37. }
  38. </script>
  39. </head>
  40. <body>
  41. <div id="man_zone">
  42. <?php
  43. $act = $_GET['act'] ?? '';
  44. if ($act == "save") {
  45. $loginpwd = textEncode($_POST['loginpwd'] ?? '');
  46. $loginpwd1 = textEncode($_POST['loginpwd1'] ?? '');
  47. $loginname = textEncode($_POST['loginname'] ?? '');
  48. $sql = "Select loginpwd,loginname From login Where id=" . loadSession("loginid");
  49. $rs = $conn->query($sql);
  50. if ($row = $rs->fetch_assoc()) {
  51. if (md5($loginpwd) != $row['loginpwd']) {
  52. echo "<script>alert('原密码输入错误');history.back()</script>";
  53. exit;
  54. }
  55. if ($loginpwd1 != "") {
  56. $sql = "UPDATE login SET loginpwd = '" . md5($loginpwd1) . "', loginname = '" . $loginname . "'
  57. WHERE id = " . loadSession("loginid");
  58. $conn->query($sql);
  59. addSession("loginname", $loginname);
  60. }
  61. } else {
  62. echo "<script>alert('好像找不到您的资料呀?还是请您重新登陆一下吧');top.location.href='login.php'</script>";
  63. exit;
  64. }
  65. echo "<script>alert('更新成功');top.location.href='index.php'</script>";
  66. exit;
  67. }
  68. $sql = "Select loginlasttime,loginlastip,loginthistime,loginthisip,powercontent,logincount
  69. From login Left Join power On power.id=login.loginpower
  70. Where login.id=" . loadSession("loginid");
  71. $rs = $conn->query($sql);
  72. if ($row = $rs->fetch_assoc()) {
  73. $loginlasttime = $row['loginlasttime'];
  74. $loginlastip = $row['loginlastip'];
  75. $loginthistime = $row['loginthistime'];
  76. $loginthisip = $row['loginthisip'];
  77. $powercontent = $row['powercontent'];
  78. $logincount = $row['logincount'];
  79. } else {
  80. echo "<script>alert('好像找不到您的资料呀?还是请您重新登陆一下吧');top.location.href='login.php'</script>";
  81. exit;
  82. }
  83. ?>
  84. <form name="form1" method="post" action="?act=save" onSubmit="return chkpwdform()">
  85. <table width="100%" border="0" cellpadding="3" cellspacing="1" class="table1">
  86. <tbody>
  87. <tr>
  88. <th width="15%">用户帐号</th>
  89. <td><input type="text" id="loginuser" name="loginuser" value="<?php echo loadSession("loginuser"); ?>" class="txt1" disabled="disabled" style="width:300px;" /></td>
  90. </tr>
  91. <tr>
  92. <th width="15%">原密码</th>
  93. <td><input type="password" id="loginpwd" name="loginpwd" class="txt1" style="width:300px;" /></td>
  94. </tr>
  95. <tr>
  96. <th width="15%">用户昵称</th>
  97. <td><input type="text" id="loginname" name="loginname" value="<?php echo loadSession("loginname"); ?>" class="txt1" style="width:300px;" /></td>
  98. </tr>
  99. <tr>
  100. <th width="15%">新密码</th>
  101. <td><input type="password" id="loginpwd1" name="loginpwd1" class="txt1" style="width:300px;" /><span style="color:red">(不修改请留空)</span></td>
  102. </tr>
  103. <tr>
  104. <th width="15%">密码确认</th>
  105. <td><input type="password" id="loginpwd2" name="loginpwd2" class="txt1" style="width:300px;" /></td>
  106. </tr>
  107. <tr>
  108. <th width="15%">上次登陆时间</th>
  109. <td><input type="text" value="<?php echo $loginlasttime; ?>" class="txt1" disabled="disabled" style="width:300px;" /></td>
  110. </tr>
  111. <tr>
  112. <th width="15%">上次登陆IP</th>
  113. <td><input type="text" value="<?php echo $loginlastip; ?>" class="txt1" disabled="disabled" style="width:300px;" /></td>
  114. </tr>
  115. <tr>
  116. <th width="15%">当前登陆时间</th>
  117. <td><input type="text" value="<?php echo $loginthistime; ?>" class="txt1" disabled="disabled" style="width:300px;" /></td>
  118. </tr>
  119. <tr>
  120. <th width="15%">当前登陆IP</th>
  121. <td><input type="text" value="<?php echo $loginthisip; ?>" class="txt1" disabled="disabled" style="width:300px;" /></td>
  122. </tr>
  123. <tr>
  124. <th width="15%">登陆次数</th>
  125. <td><input type="text" value="<?php echo $logincount; ?>" class="txt1" disabled="disabled" style="width:300px;" /></td>
  126. </tr>
  127. <tr>
  128. <th width="15%">可用权限</th>
  129. <td><?php echo $powercontent; ?></td>
  130. </tr>
  131. <tr>
  132. <th></th>
  133. <td><input type="submit" name="save" id="save" value="确定" class="btn1" /> <input type="reset" name="save" id="save" value="重置" class="btn1" /></td>
  134. </tr>
  135. </tbody>
  136. </table>
  137. </form>
  138. </div>
  139. </body>
  140. </html>