-
Notifications
You must be signed in to change notification settings - Fork 15
/
index.php
345 lines (331 loc) · 19.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
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
<?php session_start();
if(isset($_SESSION['start_time']) && (time() - $_SESSION['start_time'] > 21600)){
session_destroy();
session_start();
}
else {
$_SESSION['start_time'] = time();
session_regenerate_id(true);
}
if(isset($_SESSION['start_time'])){
if(time() - $_SESSION['start_time'] > 180) {
session_regenerate_id(true);
}
}
if(isset($_SESSION['user_mail'])){
header("Location: /user-dashboard");
exit();
}
if(isset($_SESSION['manager_mail'])){
header("Location: /admin-dashboard");
exit();
}
?>
<!DOCTYPE html>
<html lang="fa" dir="rtl">
<head>
<title>ورود / ثبت نام | EMX</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="shortcut icon" href="assets/images/favicon.png">
<!-- BEGIN CSS -->
<link href="assets/plugins/bootstrap/bootstrap5/css/bootstrap.rtl.min.css" rel="stylesheet">
<link href="assets/plugins/simple-line-icons/css/simple-line-icons.min.css" rel="stylesheet">
<link href="assets/plugins/sweetalert2/dist/sweetalert2.min.css" rel="stylesheet">
<link href="assets/plugins/paper-ripple/dist/paper-ripple.min.css" rel="stylesheet">
<link href="assets/plugins/iCheck/skins/square/_all.css" rel="stylesheet">
<link href="assets/css/style.css" rel="stylesheet">
<link href="assets/css/colors.css" rel="stylesheet">
<!-- END CSS -->
<!-- BEGIN PAGE CSS -->
<link href="assets/plugins/ladda/dist/ladda-themeless.min.css" rel="stylesheet">
<!-- END PAGE CSS -->
<style>
::placeholder{
opacity: .5 !important;
}
</style>
</head>
<body class="fix-header active-ripple theme-blue">
<!-- BEGIN LOEADING -->
<div id="loader">
<div class="spinner"></div>
</div><!-- /loader -->
<!-- END LOEADING -->
<!-- BEGIN WRAPPER -->
<div class="fixed-modal-bg"></div>
<a href="#" class="btn btn-info btn-icon btn-round btn-lg" id="toggle-dark-mode">
<i class="icon-bulb"></i>
</a>
<div class="modal-page shadow">
<div class="container-fluid">
<div class="row">
<div class="col-md-12">
<div class="logo-con m-t-10 m-b-10">
<img src="assets/images/logo-dark.png" class="dark-logo center-block img-responsive" alt="logo">
<img src="assets/images/logo.png" class="light-logo center-block img-responsive" alt="logo">
</div>
<hr>
<h2 class="text-center m-b-20 n-def">برای ورود یا ثبت نام ایمیل خود را وارد نمایید</h2>
<h2 class="text-center m-b-20 n-login" style="display:none;">کد تایید ارسال شده به ایمیل خود را وارد نمایید</h2>
<h4 class="text-center m-b-20 n-spam" style="display:none;">(پوشه اسپم ایمیل خود را بررسی کنید)</h4>
<div class="alert alert-danger fill text-center err1" style="display:none;" >
پر کردن فیلد های ستاره دار ضروریست.
</div>
<div class="alert alert-danger fill text-center err2" style="display:none;" >
کد تایید قبلا به ایمیل شما ارسال شده ، لطفا ایمیل خود را چک کنید.
</div>
<div class="alert alert-danger fill text-center err3" style="display:none;" >
فرمت ایمیل وارد شده نادرست میباشد.
</div>
<div class="alert alert-danger fill text-center err4" style="display:none;" >
مشکل در اتصال به دیتابیس ، با برنامه نویس تماس بگیرید.
</div>
<div class="alert alert-danger fill text-center err5" style="display:none;" >
کد وارد شده اشتباه است.
</div>
<div class="alert alert-danger fill text-center err-u" style="display:none;" >
اروری نامشخص بوجود آمده ، با برنامه نویس تماس بگیرید.
</div>
<div class="form-group mail-sec">
<hr class="m-b-10">
<div class="input-group round">
<span class="input-group-addon">
<i class="icon-envelope"></i>
</span>
<input class="form-control ltr text-left mail" name="mail" placeholder="[email protected]" autocomplete="on">
</div>
</div>
<div class="form-group name-sec" style="display:none;">
<hr>
<div class="input-group round">
<span class="input-group-addon">
<i class="icon-user"></i>
</span>
<input class="form-control text-left name" placeholder="* نام و نام خانوادگی">
</div>
</div>
<div class="form-group tel-sec" style="display:none;">
<div class="input-group round">
<span class="input-group-addon">
<i class="icon-phone"></i>
</span>
<input class="form-control text-left tel" placeholder="شماره موبایل - اختیاری">
</div>
</div>
<div class="token-sec" style="display:none;">
<hr>
<input class="form-control text-center token" placeholder="** کد ارسال شده **">
</div>
<button class="btn btn-info btn-round btn-block ladda-button ld1 m-t-20" data-style="slide-right" >
<span class="ladda-label">ورود | ثبت نام</span>
<span class="ladda-spinner"></span>
</button>
<button class="btn btn-success btn-round btn-block ladda-button ld2 m-t-20" style="display:none;" data-style="slide-right" >
<span class="ladda-label">تایید</span>
<span class="ladda-spinner"></span>
</button>
</div><!-- /.col-md-12 -->
</div><!-- /.row -->
</div><!-- /.container-fluid -->
</div><!-- /.modal-page -->
<!-- END WRAPPER -->
<!-- BEGIN JS -->
<script src="assets/plugins/jquery/dist/jquery-3.1.0.js"></script>
<script src="assets/plugins/jquery-migrate/jquery-migrate-1.2.1.min.js"></script>
<script src="assets/plugins/bootstrap/bootstrap5/js/bootstrap.bundle.min.js"></script>
<script src="assets/plugins/paper-ripple/dist/PaperRipple.min.js"></script>
<script src="assets/plugins/sweetalert2//dist/sweetalert2.min.js"></script>
<script src="assets/plugins/iCheck/icheck.min.js"></script>
<script src="assets/plugins/iCheck/icheck.min.js"></script>
<script src="assets/plugins/jquery-validation/dist/jquery.validate.min.js"></script>
<script src="assets/plugins/jquery-validation/src/localization/messages_fa.js"></script>
<script src="assets/js/core.js"></script>
<!-- BEGIN PAGE JAVASCRIPT -->
<script src="assets/plugins/ladda/dist/spin.min.js"></script>
<script src="assets/plugins/ladda/dist/ladda.min.js"></script>
<script>
Ladda.bind('.ld1');
Ladda.bind('.ld2');
document.querySelector(".ld1").addEventListener("click",function(){
let mail = document.querySelector(".mail").value;
$.ajax({
url: "login-controllers/login.php",
data: {
step: "one",
mail: mail
},
type: "post",
success: function(res1){
if(res1 == "success-login"){
document.querySelector(".mail-sec").style.display = "none";
document.querySelector(".ld1").style.display = "none";
document.querySelector(".n-def").style.display = "none";
document.querySelector(".token-sec").style.display = "block";
document.querySelector(".ld2").style.display = "block";
document.querySelector(".n-login").style.display = "block";
document.querySelector(".n-spam").style.display = "block";
document.querySelector(".ld2").addEventListener("click",function(){
$.ajax({
url: "login-controllers/login.php",
data: {
step: "two",
mail: mail ,
token: document.querySelector(".token").value
},
type: "post",
success: function(res2){
if(res2 == "success-admin"){
window.location.href = "/admin-dashboard";
Ladda.stopAll();
}
else if(res2 == "success-user"){
window.location.href = "/user-dashboard";
Ladda.stopAll();
}
else if(res2 == "emptyField"){
document.querySelector(".err1").style.display = "block";
setTimeout(() => {
document.querySelector(".err1").style.display = "none";
}, 4000);
Ladda.stopAll();
}
else if (res2 == "wrongFormat"){
document.querySelector(".err3").style.display = "block";
setTimeout(() => {
document.querySelector(".err3").style.display = "none";
}, 4000);
Ladda.stopAll();
}
else if (res2 == "SQLNotPrepare"){
document.querySelector(".err4").style.display = "block";
setTimeout(() => {
document.querySelector(".err4").style.display = "none";
}, 4000);
Ladda.stopAll();
}
else if (res2 == "wrongToken"){
document.querySelector(".err5").style.display = "block";
setTimeout(() => {
document.querySelector(".err5").style.display = "none";
}, 4000);
Ladda.stopAll();
}
else{
document.querySelector(".err-u").style.display = "block";
setTimeout(() => {
document.querySelector(".err-u").style.display = "none";
}, 4000);
Ladda.stopAll();
}
}
});
});
}
else if(res1 == "success-register"){
document.querySelector(".mail-sec").style.display = "none";
document.querySelector(".ld1").style.display = "none";
document.querySelector(".n-def").style.display = "none";
document.querySelector(".name-sec").style.display = "block";
document.querySelector(".tel-sec").style.display = "block";
document.querySelector(".token-sec").style.display = "block";
document.querySelector(".ld2").style.display = "block";
document.querySelector(".n-login").style.display = "block";
document.querySelector(".n-spam").style.display = "block";
document.querySelector(".ld2").addEventListener("click",function(){
$.ajax({
url: "login-controllers/login.php",
data: {
step: "two",
mail: mail ,
name: document.querySelector(".name").value,
tel: document.querySelector(".tel").value,
token: document.querySelector(".token").value
},
type: "post",
success: function(res2){
if(res2 == "success-user"){
window.location.href = "/user-dashboard";
Ladda.stopAll();
}
else if(res2 == "emptyField"){
document.querySelector(".err1").style.display = "block";
setTimeout(() => {
document.querySelector(".err1").style.display = "none";
}, 4000);
Ladda.stopAll();
}
else if (res2 == "wrongFormat"){
document.querySelector(".err3").style.display = "block";
setTimeout(() => {
document.querySelector(".err3").style.display = "none";
}, 4000);
Ladda.stopAll();
}
else if (res2 == "SQLNotPrepare"){
document.querySelector(".err4").style.display = "block";
setTimeout(() => {
document.querySelector(".err4").style.display = "none";
}, 4000);
Ladda.stopAll();
}
else if (res2 == "wrongToken"){
document.querySelector(".err5").style.display = "block";
setTimeout(() => {
document.querySelector(".err5").style.display = "none";
}, 4000);
Ladda.stopAll();
}
else{
document.querySelector(".err-u").style.display = "block";
setTimeout(() => {
document.querySelector(".err-u").style.display = "none";
}, 4000);
Ladda.stopAll();
}
}
});
});
}
else if(res1 == "emptyField"){
document.querySelector(".err1").style.display = "block";
setTimeout(() => {
document.querySelector(".err1").style.display = "none";
}, 4000);
Ladda.stopAll();
}
else if(res1 == "mailAlreadySent"){
document.querySelector(".err2").style.display = "block";
setTimeout(() => {
document.querySelector(".err2").style.display = "none";
}, 4000);
Ladda.stopAll();
}
else if (res1 == "wrongFormat"){
document.querySelector(".err3").style.display = "block";
setTimeout(() => {
document.querySelector(".err3").style.display = "none";
}, 4000);
Ladda.stopAll();
}
else if (res1 == "SQLNotPrepare"){
document.querySelector(".err4").style.display = "block";
setTimeout(() => {
document.querySelector(".err4").style.display = "none";
}, 4000);
Ladda.stopAll();
}
else{
document.querySelector(".err-u").style.display = "block";
setTimeout(() => {
document.querySelector(".err-u").style.display = "none";
}, 4000);
Ladda.stopAll();
}
}
});
});
</script>
<!-- END PAGE JAVASCRIPT -->
</body>
</html>