Guest User

Untitled

a guest
Oct 23rd, 2017
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.94 KB | None | 0 0
  1. <script>
  2. var working = false;
  3. var $this = $('#login');
  4. var $state = $this.find('button > .state');
  5. var login_button_text = '<i class="fa fa-sign-in"></i> Login';
  6. $(function () {
  7. $('#login').ajaxForm({
  8. url: 'https://ghender.com/requests.php?f=login',
  9. beforeSend: function () {
  10. working = true;
  11. $this.addClass('loading');
  12. $state.html('autenticação');
  13. },
  14. success: function (data) {
  15. console.log(data);
  16. if (data.status == 200 || data.status == 600) {
  17. $this.addClass('ok');
  18. $state.html('Bem vindo de volta!');
  19. setTimeout(function () {
  20. window.location.href = "https://ghender.com";
  21. //window.location.href = data.location;
  22. }, 1000);
  23. } else {
  24. var errors = data.errors.join("<br>");
  25. $state.html(login_button_text);
  26. $this.removeClass('ok loading', function () {
  27. $state.html(errors);
  28. });
  29. }
  30. working = false;
  31. }
  32. });
  33. $('#login input').on('click', function (e) {
  34. $state.html(login_button_text);
  35. });
  36. });
  37.  
  38. if ($f == 'login') {
  39. $data_ = array();
  40. $phone = 0;
  41. if (isset($_POST['username']) && isset($_POST['password'])) {
  42. $username = Wo_Secure($_POST['username']);
  43. $password = Wo_Secure($_POST['password']);
  44. $result = Wo_Login($username, $password);
  45. if ($result === false) {
  46. $errors[] = $error_icon . $wo['lang']['incorrect_username_or_password_label'];
  47. } else if (Wo_UserInactive($_POST['username']) === true) {
  48. $errors[] = $error_icon . $wo['lang']['account_disbaled_contanct_admin_label'];
  49. } else if (Wo_UserActive($_POST['username']) === false) {
  50. $_SESSION['code_id'] = Wo_UserIdForLogin($username);
  51. $data_ = array(
  52. 'status' => 600,
  53. 'location' => Wo_SeoLink('index.php?link1=user-activation')
  54. );
  55. $phone = 1;
  56. }
  57. if (empty($errors) && $phone == 0) {
  58. $userid = Wo_UserIdForLogin($username);
  59. $ip = Wo_Secure(get_ip_address());
  60. $update = mysqli_query($sqlConnect, "UPDATE " . T_USERS . " SET `ip_address` = '{$ip}' WHERE `user_id` = '{$userid}'");
  61. $session = Wo_CreateLoginSession(Wo_UserIdForLogin($username));
  62. $_SESSION['user_id'] = $session;
  63. setcookie(
  64. "user_id", $session, time() + (10 * 365 * 24 * 60 * 60)
  65. );
  66. $data = array(
  67. 'status' => 200
  68. );
  69. if (!empty($_POST['last_url'])) {
  70. $data['location'] = $_POST['last_url'];
  71. } else {
  72. $data['location'] = $wo['config']['site_url'];
  73. }
  74. }
  75. }
  76. header("Content-type: application/json");
  77. if (!empty($errors)) {
  78. echo json_encode(array(
  79. 'errors' => $errors
  80. ));
  81. } else if (!empty($data_)) {
  82. echo json_encode($data_);
  83. } else {
  84. echo json_encode($data);
  85. }
  86. exit();
Add Comment
Please, Sign In to add comment