page-login.php 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. <?php
  2. /**
  3. * Template Name: 登录页面模版
  4. */
  5. get_header();
  6. ?>
  7. <div id="primary" class="content-area">
  8. <main id="main" class="site-main" role="main">
  9. <?php if(!is_user_logged_in()){ ?>
  10. <div class="ex-login">
  11. <div class="ex-login-title">
  12. <p><img src="<?php echo iro_opt('unlisted_avatar'); ?>"></p>
  13. </div>
  14. <form action="<?php echo home_url(); ?>/wp-login.php" method="post">
  15. <p><input type="text" name="log" id="log" value="<?php echo $_POST['log'] ?? null; ?>" size="25" placeholder="Name" required /></p>
  16. <p><input type="password" name="pwd" id="pwd" value="<?php echo $_POST['pwd'] ?? null; ?>" size="25" placeholder="Password" required /></p>
  17. <p class="forgetmenot"><label for="rememberme"><input name="rememberme" type="checkbox" id="rememberme" value="forever" /> <?php esc_html_e( 'Remember_Me' ); ?></label></p>
  18. <input type="hidden" name="redirect_to" value="<?php echo $_SERVER['REQUEST_URI']; ?>" />
  19. <input class="button login-button" name="submit" type="submit" value="登 入">
  20. </form>
  21. <div class="ex-new-account" style="padding: 0;"><p>请先注册!Register first, plz!</p><p><a href="<?php echo iro_opt('exregister_url') ?? bloginfo('url'); ?>" target="_blank">Register</a>|<a href="<?php echo site_url(); ?>/wp-login.php?action=lostpassword" target="_blank">Lost your password?</a></p></div>
  22. </div>
  23. <?php if (iro_opt('captcha_select') === 'iro_captcha') {?>
  24. <script>
  25. if(!'get_captcha' in window){
  26. var get_captcha = ele=>fetch("<?php echo rest_url('sakura/v1/captcha/create')?>")
  27. .then(async res=>{
  28. if (res.ok){
  29. const json = await res.json();
  30. ele.src = json['data'];
  31. document.querySelector("input[name='timestamp']").value = json["time"];
  32. document.querySelector("input[name='id']").value = json["id"];
  33. }else{
  34. //TODO: 错误处理
  35. }
  36. });
  37. const captcha = document.getElementById("captchaimg");
  38. if(captcha){
  39. captcha.addEventListener("click",e=>get_captcha(e.target));
  40. get_captcha(captcha);
  41. }
  42. }
  43. </script>
  44. <?php } ?>
  45. <?php }else{ echo Exuser_center(); } ?>
  46. </main><!-- #main -->
  47. </div><!-- #primary -->
  48. <?php
  49. get_footer();