reset.php 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295
  1. <?php
  2. #重置密码
  3. require_once '../config.php';
  4. require_once "../public/load_lang.php";
  5. require_once "../public/function.php";
  6. if (!isset($_GET["token"])) {
  7. }
  8. ?>
  9. <!DOCTYPE html>
  10. <html>
  11. <head>
  12. <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
  13. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  14. <link type="text/css" rel="stylesheet" href="../studio/css/font.css"/>
  15. <link type="text/css" rel="stylesheet" href="../studio/css/style.css"/>
  16. <link type="text/css" rel="stylesheet" href="../studio/css/color_day.css" id="colorchange" />
  17. <title>wikipali reset password</title>
  18. <script src="../public/js/comm.js"></script>
  19. <script src="../studio/js/jquery-3.3.1.min.js"></script>
  20. <script src="../studio/js/fixedsticky.js"></script>
  21. <script src="../ucenter/sign.js"></script>
  22. <style>
  23. #login_body{
  24. display: flex;
  25. padding: 2em;
  26. margin: auto;
  27. }
  28. #login_left {
  29. padding-right: 12em;
  30. padding-top: 5em;
  31. }
  32. .title{
  33. font-size: 150%;
  34. margin-top: 1em;
  35. margin-bottom: 0.5em;
  36. }
  37. #login_form{
  38. padding: 2em 0 1em 0;
  39. }
  40. #tool_bar {
  41. padding: 1em;
  42. display: flex;
  43. justify-content: space-between;
  44. }
  45. #login_shortcut {
  46. display: flex;
  47. flex-direction: column;
  48. padding: 2em 0;
  49. }
  50. #login_shortcut button{
  51. height:3em;
  52. }
  53. #button_area{
  54. text-align: right;
  55. padding: 1em 0;
  56. }
  57. .form_help{
  58. font-weight: 400;
  59. color: var(--bookx);
  60. }
  61. .login_form input{
  62. margin-top:2em;
  63. padding:0.5em 0.5em;
  64. }
  65. .login_form select{
  66. margin-top:2em;
  67. padding:0.5em 0.5em;
  68. }
  69. .login_form input[type="submit"]{
  70. margin-top:2em;
  71. padding:0.1em 0.5em;
  72. }
  73. .form_error{
  74. color:var(--error-text);
  75. }
  76. #login_form_div{
  77. width:30em;
  78. }
  79. #ucenter_body {
  80. display: flex;
  81. flex-direction: column;
  82. margin: 0;
  83. padding: 0;
  84. background-color: var(--tool-bg-color3);
  85. color: var(--btn-color);
  86. }
  87. .icon_big {
  88. height: 2em;
  89. width: 2em;
  90. fill: var(--btn-color);
  91. transition: all 0.2s ease;
  92. }
  93. .form_field_name{
  94. position: absolute;
  95. margin-left: 7px;
  96. margin-top: 2em;
  97. color: var(--btn-border-line-color);
  98. -webkit-transition-duration: 0.4s;
  99. -moz-transition-duration: 0.4s;
  100. transition-duration: 0.4s;
  101. transform: translateY(0.5em);
  102. }
  103. .viewswitch_on {
  104. position: absolute;
  105. margin-left: 7px;
  106. margin-top: 1.5em;
  107. color: var(--bookx);
  108. -webkit-transition-duration: 0.4s;
  109. -moz-transition-duration: 0.4s;
  110. transition-duration: 0.4s;
  111. transform: translateY(-15px);
  112. }
  113. </style>
  114. <script>
  115. function login_init(){
  116. $("input").focus(function(){
  117. let name = $(this).attr("name");
  118. var objNave = document.getElementById("tip_"+name);
  119. objNave.className = "viewswitch_on";
  120. });
  121. $(".form_field_name").click(function(){
  122. let id = $(this).attr("id");
  123. var objNave = document.getElementById(id);
  124. objNave.className = "viewswitch_on";
  125. let arrId=id.split("_");
  126. document.getElementById('input_'+arrId[1]).focus();
  127. });
  128. }
  129. </script>
  130. <link type="text/css" rel="stylesheet" href="mobile.css" media="screen and (max-width:800px)">
  131. </head>
  132. <body id="ucenter_body" onload="login_init()">
  133. <div id="tool_bar">
  134. <div>
  135. </div>
  136. <div>
  137. <?php
  138. require_once '../lang/lang.php';
  139. ?>
  140. </div>
  141. </div>
  142. <div id="login_body" >
  143. <div id="login_left">
  144. <div >
  145. <svg style="height: 8em;width: 25em;">
  146. <use xlink:href="../public/images/svg/wikipali_login_page.svg#logo_login"></use>
  147. </svg>
  148. </div>
  149. <div style=" padding: 1em 0 0 3.5em;font-weight: 400;">
  150. <?php echo $_local->gui->pali_literature_platform; ?>
  151. <ul style="padding-left: 1.2em;">
  152. <li><?php echo $_local->gui->online_dict_db; ?></li>
  153. <li><?php echo $_local->gui->user_data_share; ?></li>
  154. <li><?php echo $_local->gui->cooperate_edit; ?></li>
  155. </ul>
  156. </div>
  157. </div>
  158. <div id="login_right">
  159. <div id = "login_form_div" class="fun_block" >
  160. <div class="title">
  161. 重置密码
  162. </div>
  163. <div class="login_new">
  164. <span class="form_help"><?php echo $_local->gui->have_account; ?> ?</span><a href="index.php?language=<?php echo $currLanguage; ?>">&nbsp;&nbsp;&nbsp;&nbsp;<?php echo $_local->gui->login; //登入账户 ?></a>
  165. </div>
  166. <?php
  167. if (!isset($_GET["token"])) {
  168. echo '<div class="form_error">';
  169. echo "无效的密钥";
  170. echo '</div>';
  171. }else{
  172. ?>
  173. <div class="login_form" style=" padding: 3em 0 3em 0;">
  174. <div class="form_help" id="message"> </div>
  175. <div id="form_div">
  176. <form action="index.php" method="post">
  177. <div>
  178. <div>
  179. <span id='tip_username' class='form_field_name'><?php echo $_local->gui->account; ?></span>
  180. <input type="input" maxlength="32" id="username" name="username" value="" />
  181. </div>
  182. <div id="error_username" class="form_error"> </div>
  183. <div class="form_help"></div>
  184. </div>
  185. <div>
  186. <div>
  187. <span id='tip_password' class='form_field_name'><?php echo $_local->gui->password; ?></span>
  188. <input type="password" id="password" maxlength="32" name="password" placeholder="<?php echo $_local->gui->password; ?>" value="" />
  189. <input type="password" id="repassword" maxlength="32" name="repassword" placeholder="<?php echo $_local->gui->password_again; ?>" value="" />
  190. </div>
  191. <div class="form_help">至少6个字符</div>
  192. <div id="error_password" class="form_error"></div>
  193. </div>
  194. <input type="hidden" id="token" name="token" value="<?php echo $_REQUEST["token"]; ?>" />
  195. </form>
  196. <div id="button_area">
  197. <button onclick="reset_submit()" style="background-color: var(--link-hover-color);border-color: var(--link-hover-color);" >
  198. <?php echo $_local->gui->continue; ?>
  199. </button>
  200. </div>
  201. </div>
  202. </div>
  203. <?php
  204. }
  205. ?>
  206. </div>
  207. </div>
  208. </div>
  209. <script>
  210. login_init();
  211. function reset_submit(){
  212. let hasError = false;
  213. if($("#password").val()!==$("#repassword").val()){
  214. $("#error_password").text("两次密码输入不一致");
  215. hasError = true;
  216. }
  217. if(isValidPassword($("#password").val())==false){
  218. $("#error_password").text("密码包含无效字符。 ' / , 空格 '");
  219. hasError = true;
  220. }
  221. if(hasError){
  222. return;
  223. }
  224. $.ajax({
  225. type: 'POST',
  226. url:"../api/user.php?_method=reset_pwd",
  227. contentType:"application/json; charset=utf-8",
  228. data:JSON.stringify(
  229. {
  230. username:$("#username").val(),
  231. password:$("#password").val(),
  232. reset_password_token:$("#token").val()
  233. }),
  234. dataType:"json"
  235. }).done(function (data) {
  236. if(data.ok){
  237. $("#form_div").hide();
  238. $("#message").removeClass("form_error");
  239. $("#message").html("密码修改成功。<a href='index.php?op=login'>登录</a>");
  240. }else{
  241. $("#message").addClass("form_error");
  242. $("#message").text(data.message);
  243. }
  244. }).fail(function(jqXHR, textStatus, errorThrown){
  245. $("#message").removeClass("form_error");
  246. $("#message").text(textStatus);
  247. switch (textStatus) {
  248. case "timeout":
  249. break;
  250. case "error":
  251. switch (jqXHR.status) {
  252. case 404:
  253. break;
  254. case 500:
  255. break;
  256. default:
  257. break;
  258. }
  259. break;
  260. case "abort":
  261. break;
  262. case "parsererror":
  263. console.log("delete-parsererror",jqXHR.responseText);
  264. break;
  265. default:
  266. break;
  267. }
  268. });
  269. }
  270. </script>
  271. </body>
  272. </html>