-
Notifications
You must be signed in to change notification settings - Fork 0
/
login.php
145 lines (136 loc) · 5.28 KB
/
login.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
<section class="section-login">
<div class="section-login__inner box-default">
<div class="container-fluid">
<div class="row">
<div class="col-md-6">
<div class="padding__inner">
<h1>Login</h1>
<form id="login-form" class="form" accept-charset="ISO-8859-1">
<p class="error_message" id="error_message"></p>
<div class="form-group">
<div class="input-group input-group__transparent">
<div class="input-group-prepend">
<div class="input-group-text"><i class="far fa-envelope-open"></i></div>
</div>
<input class="form-control" type="email" name="email" id="email_input" value="<?= $cookie_email ?>" placeholder="<?= txt('email') ?>">
</div>
</div>
<div class="form-group">
<div class="input-group input-group__transparent">
<div class="input-group-prepend">
<div class="input-group-text"><i class="fas fa-key"></i></div>
</div>
<input class="form-control" type="password" name="password" id="password_input" placeholder="<?= txt('password_o') ?>">
</div>
</div>
<button class="btn btn-primary pull-right" type="submit"><?= txt('acceder')?></button>
<p class="my-4">
<a href="javascript:void(0);" class="link-stats" data-toggle="modal" data-target="#modalRecoverPassword">
<?= txt('olvidadomiclave') ?>
</a>
</p>
<hr>
<h5 class="title-smaller my-4"><?= txt('notengo') ?></h5>
<?php if ($language_name != "en") { ?>
<a href="/home/crear-cuenta" class="btn btn-light-gray"><?= txt('create_account') ?></a>
<?php }else{ ?>
<a href="/home/crear-cuenta?lang=en" class="btn btn-light-gray"><?= txt('create_account') ?></a>
<?php } ?>
</form>
</div>
</div>
<div class="col-md-6 bg-login bg-cover">
<div class="padding__inner">
<h2><?= txt('nuncaduermen') ?></h2>
<p><strong><?= txt('optimizadas247') ?></strong> <?= txt('pornuestrosrobo') ?></p>
<p><strong><?= txt('alertaspanda') ?></strong> <?= txt('porcorreoelectronico') ?></p>
</div>
</div>
</div>
</div>
</div>
</section>
<!-- MODAL RECOVER PASSWORD -->
<!-- Modal -->
<div class="modal fade" id="modalRecoverPassword" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content ">
<div class="modal-header">
<h5 class="modal-title" id="exampleModalLabel"><?= txt('resetpassword') ?></h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
<p><?= txt('introducetucorreo') ?></p>
<form>
<div class="form-group">
<div class="input-group input-group__transparent">
<div class="input-group-prepend">
<div class="input-group-text"><i class="far fa-envelope-open"></i></div>
</div>
<input type="text" class="form-control" id="inlineFormInputGroupUsername" placeholder="Email">
</div>
</div>
<!-- <button type="submit" class="btn btn-primary">Entrar</button> -->
<a href="dashboard.html" class="btn btn-primary"><?= txt('enviarcorreo') ?></a>
</form>
</div>
</div>
</div>
</div>
<script>
var $email = '';
var $lang = "<?= $language_name ?>";
var debug = function(msg) { console.log(msg); };
var validate_email = function(email) {
return (email.length > 0) && (email.indexOf("@")>0);
};
var show_error = function($source) {
//$('#'+$input).css('border-color','#ff3200');
$('#error_message').html($('#'+$source).html());
$('#error_message').fadeIn(300);
};
$("#login-form").on('submit', function(e) {
debug('You want to login');
e.preventDefault();
$email = document.getElementById("email_input").value;
$pass = document.getElementById("password_input").value;
debug('Login...');
debug('email='+$email);
debug('pass='+$pass);
debug('lang='+$lang);
debug('validate email='+validate_email($email));
if (validate_email($email)) {
debug('Using AJAX to check login...');
$.post( "/users/ajax_login.json",
{ email: $email, pass: $pass, lang: $lang },
function( $result ) {
debug("Data arrived at login_checker AJAX callback");
debug(JSON.stringify($result));
debug('result='+$result['result']);
if ($result['result'] == "NEW!") {
$('#new-free-account-prompt').html("<?= txt('create_new_account1') ?>"+$email+"<?= txt('create_new_account2') ?>");
$("#new-account").modal("show");
}
else if ($result['result'] == "NC!") {
$('#confirm-account-prompt').html("<?= txt('confirm_account1') ?>"+$email+"<?= txt('confirm_account2') ?>");
$('#confirm-account-prompt2').html("<?= txt('confirm_check_email') ?>");
$("#confirm-account-modal").modal("show");
}
else if ($result['result'] == "OK!") {
window.top.location.href = $result['url'];
}
else {
show_error("bad-login-text");
}
},
"json"
);
}
else {
show_error("bad-email-text");
}
return false; // Don't submit the form automatically
});
</script>