check_login.php 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. <?php
  2. require_once "../path.php";
  3. require_once "../public/load_lang.php";
  4. require_once "../pcdl/html_head.php";
  5. echo "<body>";
  6. if(!isset($_COOKIE["sync_userid"])){
  7. #未登录
  8. ?>
  9. <script language="javascript" src="sync.js"></script>
  10. <h2>数据同步-登录</h2>
  11. <h3>远程服务器地址</h3>
  12. <div>
  13. <input id="sync_server_address" type="input" placeholder="server address" value="https://www.wikipali.org" style="width:30em;" />
  14. </div>
  15. <h3>用户名:<?php echo $_COOKIE["username"];?></h3>
  16. <div>
  17. <input id="userid" type="hidden" name="userid" value="<?php echo $_COOKIE["user_uid"];?>" style="width:30em;" />
  18. <input id="password" type="password" name="password" placeholder="password" value="" style="width:30em;" />
  19. <br>
  20. 本地地址:<input id="local" type="input" readonly name="local" value="" style="width:30em;" />
  21. </div>
  22. <div>
  23. <button onclick="login()"> 登录</button>
  24. </div>
  25. <div id="server_msg">
  26. </div>
  27. <script>
  28. let localhost;
  29. let base = "/app/sync/";
  30. let path="";
  31. if(location.pathname.indexOf(base)>=0){
  32. path = location.pathname.slice(0,location.pathname.indexOf(base));
  33. }
  34. localhost=location.protocol +"//"+ location.hostname + location.port + path;
  35. $("#local").val(localhost);
  36. </script>
  37. <?php
  38. }
  39. else{
  40. #已经登录
  41. ?>
  42. <h3>远程服务器地址:<?php echo $_COOKIE["sync_server"]?></h3>
  43. <h3>用户名:<?php echo $_COOKIE["username"]?></h3>
  44. <?php
  45. }
  46. ?>
  47. </body>
  48. </html>