-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
235 lines (182 loc) · 7.4 KB
/
index.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
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
<?php
include 'includes/pre-head.php';
if (isset($_SESSION['user'])) {
header("Location: home.php");
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<!-- Header include -->
<?php include 'includes/head.php';?>
<!-- END Header include -->
</head>
<body>
<!-- NAV bar include -->
<?php include 'includes/navbar.php'; ?>
<!-- END NAV bar include -->
<!-- Alert include -->
<?php include 'includes/alert-header.php' ?>
<!-- END Alert include -->
<!-- Bootstrap Modals -->
<!--Login, Signup, Forgot Password Modal -->
<div id="login-signup-modal" class="modal fade" tabindex="-1" role="dialog">
<div class="modal-dialog" role="document">
<!-- login modal content -->
<div class="modal-content" id="login-modal-content">
<div class="modal-header">
<!-- <button type="button" class="close" data-dismiss="modal" ><span aria-hidden="true">×</span></button> -->
<h4 class="modal-title"><span class="fa fa-lock"></span> Login Now!</h4>
</div>
<div class="modal-body">
<form method="post" id="login-form" role="form" data-parsley-validate>
<div class="form-group">
<label for="login">Login</label>
<div class="input-group">
<div class="input-group-addon"><span class="fa fa-user"></span></div>
<input type="text" class="form-control" name="login" id="login" placeholder="login name" aria-describedby="loginHelp" placeholder="Enter login" data-parsley-required data-parsley-trigger="change" autocomplete="off" spellcheck="false" data-parsley-errors-messages-disabled>
</div>
</div>
<div class="form-group">
<label for="login-password">Password</label>
<div class="input-group">
<div class="input-group-addon"><span class="fa fa-lock"></span></div>
<input type="password" class="form-control" name="password" id="login-password" placeholder="Password" data-parsley-required autocomplete="off" data-parsley-errors-messages-disabled data-parsley-trigger="change">
</div>
</div>
<div class="collapse" id="collapse-callout">
<div class="card card-block bs-callout bs-callout-danger" id="callout-login-error">
<!-- error will be shown here ! -->
</div>
<div class="card card-block bs-callout bs-callout-warning" id="callout-form-error">
<h4>Oh snap!</h4>
<p>Invalid email/password combination.</p>
</div>
</div>
<button type="submit" class="btn btn-success btn-block btn-lg" name="btn-login" id="btn-login" onclick="console.log('btn-login clicked');">LOGIN</button>
</form>
</div>
<div class="modal-footer">
<!--<p>
<a id="FPModal" href="javascript:void(0)">Forgot Password?</a> |
<a id="signupModal" href="javascript:void(0)">Request Access!</a>
</p>-->
</div>
</div>
<!-- login modal content -->
<!-- /.modal-content -->
</div>
<!-- /.modal-dialog -->
</div>
<!--Login, Signup, Forgot Password Modal -->
<?php include 'includes/script-include.php'; ?>
<script type="text/javascript">
$(document).ready(function(){
//$('#Login-Form').parsley();
//$('#Signin-Form').parsley();
//$('#Forgot-Password-Form').parsley();
$('#signupModal').click(function(){
$('#login-modal-content').fadeOut('fast', function(){
$('#signup-modal-content').fadeIn('fast');
});
});
$('#loginModal').click(function(){
$('#signup-modal-content').fadeOut('fast', function(){
$('#login-modal-content').fadeIn('fast');
});
});
$('#FPModal').click(function(){
$('#login-modal-content').fadeOut('fast', function(){
$('#forgot-password-modal-content').fadeIn('fast');
});
});
$('#loginModal1').click(function(){
$('#forgot-password-modal-content').fadeOut('fast', function(){
$('#login-modal-content').fadeIn('fast');
});
});
});
</script>
<!-- on document ready, call login modal if not logged in. -->
<?php if (!isset($_SESSION['user'])) { ?>
<script type="text/javascript">
$(document).ready(function () {
$('#login-signup-modal').modal({ backdrop: 'static', keyboard: false })
$('#login-signup-modal').modal('show');
});
</script>
<?php } ?>
<script type="text/javascript">
var debug = true;
$(function () {
$('#callout-login-error').hide();
$('#callout-form-error').hide();
$('#login-form').parsley({errorClass: "form-control-danger", successClass: "form-control-success"})
.on('field:validated', function (e) {
if (e.validationResult.constructor!==Array) {
try {
if ( $('#collapse-callout').hasClass('show') && !$('#collapse-callout').hasClass('collapsing')) {
$('#collapse-callout').collapse('show');
}
}
catch (err) {
if (debug) { console.log(err); }
}
$('#callout-form-error').fadeOut('fast');
$('#callout-login-error').fadeOut('fast');
this.$element.closest('.form-group').removeClass('has-danger').addClass('has-success');
} else {
$('#callout-login-error').hide();
$('#callout-form-error').fadeIn('fast');
try {
if ( !$('#collapse-callout').hasClass('show') && !$('#collapse-callout').hasClass('collapsing')) {
$('#collapse-callout').collapse('show');
}
}
catch (err) {
if (debug) { console.log(err); }
}
this.$element.closest('.form-group').removeClass('has-success').addClass('has-danger');
}
})
.on('form:submit', function () {
var data = $("#login-form").serialize();
$.ajax({
type: 'POST',
url: 'resource/get_login.php',
data: data + '&btn-login=1',
beforeSend: function () {
$("#btn-login").html('<span class="fa fa-transfer"></span> Sending ...');
},
success: function (response) {
if (response == "ok") {
$("#btn-login").html('<span class="fa fa-check"></span> Signing In ...');
setTimeout(' window.location.href = "home.php"; ', 1000);
}
else {
$("#callout-login-error").html('<h4><span class="fa fa-info-circle"></span></h4>\r\n<p>' + response + '!</p>');
$('#callout-form-error').hide();
$('#callout-login-error').fadeIn('fast');
try {
if ( !$('#collapse-callout').hasClass('show') && !$('#collapse-callout').hasClass('collapsing')) {
$('#collapse-callout').collapse('show');
}
}
catch (err) {
if (debug) { console.log(err); }
}
$("#login-email").closest('.form-group').removeClass('has-success').addClass('has-danger');
$("#login-email").removeClass('form-control-success').addClass('form-control-danger');
$("#login-password").closest('.form-group').removeClass('has-success').addClass('has-danger');
$("#login-password").removeClass('form-control-success').addClass('form-control-danger');
$("#btn-login").html('LOGIN');
}
}
});
return false;
});
});
</script>
<?php include 'includes/footer.php'; ?>
</body>
</html>