Login.php 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. <?php
  2. session_start();
  3. include_once("../../untils/conn.php");
  4. mysqli_query($con, "set names utf8");
  5. // 判断session中是否存在账号信息
  6. if (isset($_SESSION["account"])) {
  7. $proxy_acc = mysqli_real_escape_string($con, $_SESSION["account"]);
  8. $sql = "select proxy_acc,proxy_pass from proxy where proxy_acc='$proxy_acc';";
  9. $result = mysqli_query($con, $sql);
  10. $row = mysqli_num_rows($result);
  11. if ($row) {
  12. echo json_encode([
  13. "code" => 2,
  14. "msg" => '已登录',
  15. "data" => $_SESSION["account"]
  16. ]);
  17. exit;
  18. }
  19. }
  20. // 判断账号和密码是否都已输入
  21. if (empty($_POST['account']) || empty($_POST['password'])) {
  22. echo json_encode([
  23. "code" => 401,
  24. "msg" => '请输入账号和密码',
  25. ]);
  26. exit;
  27. }
  28. $proxy_acc = mysqli_real_escape_string($con, $_POST['account']);
  29. $proxy_pass = mysqli_real_escape_string($con, $_POST['password']);
  30. $sql = "select proxy_acc,proxy_pass,proxy_sta,state_ban from proxy where proxy_acc='$proxy_acc';";
  31. $result = mysqli_query($con, $sql);
  32. $row = mysqli_fetch_assoc($result);
  33. // 判断账号是否存在
  34. if (!$row) {
  35. echo json_encode([
  36. "code" => 400,
  37. "msg" => '账号不存在',
  38. ]);
  39. exit;
  40. }
  41. if ($row['proxy_sta'] == 0) {
  42. echo json_encode([
  43. "code" => 400,
  44. "msg" => "您的账号已被封禁!请联系平台客服处理!\n封禁原因:" . $row['state_ban'],
  45. ]);
  46. exit;
  47. }
  48. // 验证密码
  49. if ($row['proxy_pass'] != $proxy_pass) {
  50. echo json_encode([
  51. "code" => 400,
  52. "msg" => '账号密码错误',
  53. ]);
  54. exit;
  55. }
  56. // 登录成功
  57. $_SESSION["account"] = $proxy_acc;
  58. echo json_encode([
  59. "code" => 200,
  60. "msg" => '登录成功',
  61. ]);
  62. ?>