-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.php
More file actions
473 lines (404 loc) · 14.6 KB
/
index.php
File metadata and controls
473 lines (404 loc) · 14.6 KB
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
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
<?php
session_start();
require_once 'classes/UserManager.php';
$error = '';
$success = '';
// Si l'utilisateur est déjà connecté, rediriger vers le dashboard
if (isset($_SESSION['user_id']) && isset($_SESSION['session_token'])) {
$userManager = new UserManager();
if ($userManager->validateSession($_SESSION['session_token'])) {
header('Location: dashboard.php');
exit;
}
}
// Traitement du formulaire de connexion
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$username = trim($_POST['username'] ?? '');
$password = $_POST['password'] ?? '';
if (empty($username) || empty($password)) {
$error = 'Veuillez remplir tous les champs';
} else {
$userManager = new UserManager();
$result = $userManager->authenticate($username, $password);
if ($result['success']) {
// Stocker les informations de session
$_SESSION['user_id'] = $result['user']['id'];
$_SESSION['session_token'] = $result['session_token'];
$_SESSION['username'] = $result['user']['username'];
$_SESSION['role'] = $result['user']['role_name'];
$_SESSION['employee_id'] = $result['user']['employee_id'];
$_SESSION['full_name'] = trim($result['user']['first_name'] . ' ' . $result['user']['last_name']);
// Rediriger vers le dashboard ou la page demandée
$redirectTo = $_GET['redirect'] ?? 'dashboard.php';
header('Location: ' . $redirectTo);
exit;
} else {
$error = $result['message'];
}
}
}
// Traitement de la déconnexion
if (isset($_GET['logout'])) {
session_unset();
session_destroy();
$success = 'Vous avez été déconnecté avec succès';
}
?>
<!DOCTYPE html>
<html lang="fr">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Connexion - Système de Gestion Sinfinity</title>
<style>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
background: #f5f5f5;
min-height: 100vh;
display: flex;
align-items: center;
justify-content: center;
padding: 20px;
position: relative;
}
.login-wrapper {
background: #ffffff;
border-radius: 0;
box-shadow: none;
overflow: hidden;
width: 100%;
max-width: 1200px;
min-height: 100vh;
display: grid;
grid-template-columns: 1fr 1fr;
position: relative;
}
.header-logo {
position: absolute;
top: 30px;
left: 30px;
z-index: 10;
}
.header-logo img {
height: 40px;
}
.header-logo-text {
font-size: 24px;
font-weight: 700;
color: #e53e3e;
font-family: 'Arial', sans-serif;
}
.login-left {
padding: 80px 60px;
display: flex;
flex-direction: column;
justify-content: center;
position: relative;
background: #ffffff;
}
.login-form-container {
max-width: 400px;
margin: 0 auto;
}
.welcome-title {
font-size: 32px;
font-weight: 400;
color: #333333;
margin-bottom: 10px;
line-height: 1.2;
}
.welcome-subtitle {
color: #666666;
margin-bottom: 40px;
line-height: 1.5;
font-size: 14px;
}
.form-group {
margin-bottom: 20px;
position: relative;
}
.form-group label {
display: block;
margin-bottom: 8px;
color: #333333;
font-size: 14px;
font-weight: 400;
}
.form-group input {
width: 100%;
padding: 12px 40px 12px 15px;
border: 1px solid #ddd;
border-radius: 4px;
font-size: 14px;
transition: all 0.3s ease;
background: #ffffff;
color: #333333;
}
.form-group input:focus {
outline: none;
border-color: #e53e3e;
box-shadow: 0 0 0 2px rgba(229, 62, 62, 0.1);
}
.form-group .input-icon {
position: absolute;
right: 15px;
top: 38px;
color: #999;
font-size: 16px;
}
.form-options {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 25px;
}
.remember-me {
display: flex;
align-items: center;
gap: 8px;
color: #666666;
font-size: 13px;
}
.remember-me input[type="checkbox"] {
width: auto;
margin: 0;
}
.forgot-password {
color: #e53e3e;
text-decoration: none;
font-size: 13px;
transition: color 0.3s ease;
}
.forgot-password:hover {
color: #c53030;
}
.btn-login {
width: 100%;
padding: 12px 30px;
background: #e53e3e;
color: #ffffff;
border: none;
border-radius: 4px;
font-size: 14px;
font-weight: 500;
cursor: pointer;
transition: all 0.3s ease;
margin-bottom: 20px;
}
.btn-login:hover {
background: #c53030;
}
.login-right {
background: linear-gradient(135deg, #000000 0%, #333333 100%);
position: relative;
overflow: hidden;
display: flex;
align-items: center;
justify-content: center;
}
.tropical-bg {
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
background-image:
url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 400 400"><defs><pattern id="leaves" x="0" y="0" width="100" height="100" patternUnits="userSpaceOnUse"><path d="M20,20 Q30,10 40,20 Q50,30 40,40 Q30,50 20,40 Q10,30 20,20 Z" fill="%23a8c66c" opacity="0.3"/><path d="M60,60 Q70,50 80,60 Q90,70 80,80 Q70,90 60,80 Q50,70 60,60 Z" fill="%23a8c66c" opacity="0.2"/></pattern></defs><rect width="400" height="400" fill="url(%23leaves)"/></svg>');
opacity: 0.1;
}
.right-logo {
position: relative;
z-index: 2;
text-align: center;
color: white;
}
.right-logo-icon {
width: 80px;
height: 80px;
background: rgba(255, 255, 255, 0.2);
margin: 0 auto 20px;
border-radius: 8px;
backdrop-filter: blur(10px);
}
.right-logo-text {
font-size: 32px;
font-weight: 600;
margin-bottom: 8px;
}
.right-logo-tagline {
font-size: 14px;
opacity: 0.8;
letter-spacing: 2px;
text-transform: uppercase;
}
.alert {
padding: 15px;
border-radius: 8px;
margin-bottom: 20px;
font-size: 14px;
}
.alert-error {
background: #f8d7da;
color: #721c24;
border: 1px solid #f5c6cb;
}
.alert-success {
background: #d4edda;
color: #155724;
border: 1px solid #c3e6cb;
}
/* Responsive Design */
@media (max-width: 768px) {
.login-wrapper {
grid-template-columns: 1fr;
max-width: 400px;
}
.login-right {
display: none;
}
.login-left {
padding: 40px 30px;
}
.welcome-title {
font-size: 28px;
}
.btn-group {
flex-direction: column;
}
}
@media (max-width: 480px) {
body {
padding: 10px;
}
.login-left {
padding: 30px 20px;
}
.welcome-title {
font-size: 24px;
}
.form-group input {
padding: 12px 15px;
font-size: 14px;
}
.btn {
padding: 12px 20px;
font-size: 14px;
}
}
</style>
</head>
<body>
<!-- Logo en haut à gauche -->
<div class="header-logo">
<div class="header-logo-text">Sinfinity</div>
</div>
<div class="login-wrapper">
<!-- Partie gauche - Formulaire -->
<div class="login-left">
<div class="login-form-container">
<!-- Titre de bienvenue -->
<h1 class="welcome-title">Connexion</h1>
<p class="welcome-subtitle">Entrez vos identifiants pour accéder à votre compte</p>
<!-- Messages d'erreur/succès -->
<?php if ($error): ?>
<div class="alert alert-error">
<?php echo htmlspecialchars($error); ?>
</div>
<?php endif; ?>
<?php if ($success): ?>
<div class="alert alert-success">
<?php echo htmlspecialchars($success); ?>
</div>
<?php endif; ?>
<!-- Formulaire -->
<form method="POST" action="">
<div class="form-group">
<label for="username">Nom d'utilisateur ou Email :</label>
<input type="text" id="username" name="username" required
value="<?php echo htmlspecialchars($_POST['username'] ?? ''); ?>"
placeholder="Email">
<div class="input-icon">👤</div>
</div>
<div class="form-group">
<label for="password">Mot de passe :</label>
<input type="password" id="password" name="password" required
placeholder="Mot de passe utilisé ?">
<div class="input-icon">🔒</div>
</div>
<!-- Options -->
<div class="form-options">
<label class="remember-me">
<input type="checkbox" name="remember_me">
Se souvenir de moi
</label>
<a href="#" class="forgot-password" onclick="showDemoAccounts(); return false;">Comptes</a>
</div>
<!-- Bouton de connexion -->
<button type="submit" class="btn-login">Se connecter</button>
</form>
</div>
</div>
</div>
<!-- Modal pour les comptes de démonstration -->
<div id="demoModal" style="display: none; position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,0.5); z-index: 1000; align-items: center; justify-content: center;">
<div style="background: white; padding: 30px; border-radius: 15px; max-width: 500px; width: 90%; max-height: 80vh; overflow-y: auto;">
<h3 style="margin-bottom: 20px; color: #2d5a3d;">🧪 Comptes de démonstration</h3>
<div style="display: grid; gap: 15px; margin-bottom: 20px;">
<div style="background: #f8f9fa; padding: 15px; border-radius: 8px; border-left: 4px solid #2d5a3d;">
<strong style="color: #2d5a3d; display: block; margin-bottom: 5px;">admin</strong>
<span style="color: #666; font-size: 14px;">Super Administrateur - Accès complet</span>
</div>
<div style="background: #f8f9fa; padding: 15px; border-radius: 8px; border-left: 4px solid #2d5a3d;">
<strong style="color: #2d5a3d; display: block; margin-bottom: 5px;">marie.dubois</strong>
<span style="color: #666; font-size: 14px;">Responsable RH - Gestion employés et congés</span>
</div>
<div style="background: #f8f9fa; padding: 15px; border-radius: 8px; border-left: 4px solid #2d5a3d;">
<strong style="color: #2d5a3d; display: block; margin-bottom: 5px;">pierre.martin</strong>
<span style="color: #666; font-size: 14px;">Manager IT - Gestion équipe et équipements</span>
</div>
<div style="background: #f8f9fa; padding: 15px; border-radius: 8px; border-left: 4px solid #2d5a3d;">
<strong style="color: #2d5a3d; display: block; margin-bottom: 5px;">sophie.bernard</strong>
<span style="color: #666; font-size: 14px;">Employé - Consultation personnelle</span>
</div>
</div>
<p style="text-align: center; color: #666; margin-bottom: 20px;">
<strong>Mot de passe pour tous :</strong> password123
</p>
<div style="text-align: center;">
<button onclick="closeDemoModal()" style="background: #2d5a3d; color: white; border: none; padding: 10px 20px; border-radius: 5px; cursor: pointer;">Fermer</button>
</div>
</div>
</div>
<script>
function showDemoAccounts() {
document.getElementById('demoModal').style.display = 'flex';
}
function closeDemoModal() {
document.getElementById('demoModal').style.display = 'none';
}
// Fermer la modal en cliquant à l'extérieur
document.getElementById('demoModal').addEventListener('click', function(e) {
if (e.target === this) {
closeDemoModal();
}
});
// Auto-focus sur le premier champ
document.querySelector('#username').focus();
// Animation des champs au focus
document.querySelectorAll('input').forEach(input => {
input.addEventListener('focus', function() {
this.style.transform = 'scale(1.02)';
this.style.transition = 'transform 0.2s ease';
});
input.addEventListener('blur', function() {
this.style.transform = 'scale(1)';
});
});
</script>
</body>
</html>