-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
87 lines (82 loc) · 2.9 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
<?php
$title = '«Παρουσιολόγιο ΣΠΗΥ» | Σύνδεση';
include('templates/header.inc.php');
print '<link rel="stylesheet" type="text/css" href="css/main.css">';
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
$errors = [];
if (!($username = filter_input(INPUT_POST, 'username'))) {
$username = NULL;
$errors[] = 'Παρακαλώ εισάγετε όνομα χρήστη';
}
if (!($password = filter_input(INPUT_POST, 'password'))) {
$password = NULL;
$errors[] = 'Παρακαλώ εισάγετε κωδικό';
}
if (!empty($errors)) {
print_error_messages($errors);
} else {
$success = false;
require_once('includes/mysqli_connect.php');
$q = "SELECT password FROM roles WHERE username=?";
$stmt = my_mysqli_prepare($dbc, $q);
my_mysqli_stmt_bind_param($stmt, 's', $username);
my_mysqli_stmt_execute($stmt);
my_mysqli_stmt_store_result($stmt);
if (my_mysqli_stmt_num_rows($stmt) == 1) {
my_mysqli_stmt_bind_result($stmt, $password_hashdb);
my_mysqli_stmt_fetch($stmt);
if (password_verify($password, $password_hashdb)) {
$success = true;
}
}
if ($success) {
$_SESSION['username'] = $username;
$_SESSION['loggedin'] = time();
$_SESSION['agent'] = sha1($_SERVER['HTTP_USER_AGENT']);
} else {
print "<p class='alert alert-warning'>Το ονομα και ο κωδικός χρήστη δεν αντιστοιχούν σε υφιστάμενο χρήστη.</p>\n";
}
}
}
if (is_loggedin()) {
print '<link rel="stylesheet" type="text/css" href="css/util.css">';
print "<p>Είστε συνδεδεμένος!</p>\n";
if (is_administrator()) {
header("Location: apousies.php");
} else {
header("Location: apousiologio.php");
}
exit();
} else {
?>
<div class="container-login100" style="background-image: url('images/aithoysa_a.jpg');">
<div class="wrap-login100 p-t-30 p-b-50">
<span class="login100-form-title p-b-41">
ΕΙΣΟΔΟΣ ΣΤΗΝ ΕΦΑΡΜΟΓΗ<br>«ΠΑΡΟΥΣΙΟΛΟΓΙΟ ΣΠΗΥ»
</span>
<form class="login100-form validate-form p-b-33 p-t-5" action="" method="post">
<div class="wrap-input100 validate-input" data-validate="Enter username">
<input class="input100" type="text" name="username" placeholder="Όνομα Χρήστη">
<span class="focus-input100" data-placeholder=""></span>
</div>
<div class="wrap-input100 validate-input" data-validate="Enter password">
<input class="input100" type="password" name="password" placeholder="Κωδικός">
<span class="focus-input100" data-placeholder=""></span>
</div>
<div class="container-login100-form-btn m-t-32">
<button class="login100-form-btn">
ΕΙΣΟΔΟΣ
</button>
</div>
</form>
</div>
</div>
<?php
}
include('templates/footer.inc.php');
?>
</body>
</html>
<?php
ob_end_flush(); // Αποστολή του buffer στον browser και απενεργοποίηση output buffering
?>