-
Notifications
You must be signed in to change notification settings - Fork 1
/
connection.php
executable file
·101 lines (97 loc) · 3.69 KB
/
connection.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
<?php
$isConnect = false;
require_once('./include/page.php');
$page = new Page("connect");
$message = "";
$wrongResult = false;
if(isset($_POST["pseudo"]) AND isset($_POST["password"])){
$pseudo = $_POST["pseudo"];
$password = $_POST["password"];
$allUser = $page->run_query();
foreach ($allUser as $userContent) {
if ($userContent["username"] == $pseudo) {
if (hash('sha256', $password) == $userContent["password"]) {
if(session_status() == PHP_SESSION_NONE)
session_start();
$_SESSION = array();
$_SESSION["name"] = $pseudo;
$_SESSION["is_admin"] = $userContent["admin"];
$_SESSION["role"] = $userContent["role"];
$isConnect = true;
header('Location: ./');
exit();
//$message = $page->msg("connection.well");
} else {
$message = $page->msg("connection.wrong_pass");
}
}
}
if($message == "") {
$message = $page->msg("connection.wrong_name");
$wrongResult = true;
}
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<?php $page->print_common_head(); ?>
<title>Positivity - Connection</title>
<link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons">
<script>
function togglePasswordVisibility() {
var x = document.getElementById("password");
if (x.type === "password") {
x.type = "text";
} else {
x.type = "password";
}
}
</script>
</head>
<body>
<div class="container solo">
<?php
if($message != ""){
?>
<div class="negativity-index negativity-index-sub" <?php if($wrongResult) echo 'style="color: red;"'; ?>><h2><?php echo $message; ?></h2></div>
<?php
}
if($isConnect){
?>
<a href="./">
<div class="negativity-index negativity-index-sub">
<p><?php echo $page->msg("connection.back"); ?></p>
</div>
</a>
<?php
} else {
?>
<div class="negativity-index negativity-index-main">
<h1><?php echo $page->msg("connection.name"); ?></h1>
</div>
<form action="./connection.php" method="post" id="connection" class="text-center">
<div class="table-center">
<div class="row">
<div class="input" style="display: flex; width: 100%;">
<i class="material-icons">person</i>
<input style="border: none;" type="text" name="pseudo" id="pseudo" placeholder="<?php echo $page->msg("connection.form.login"); ?>" required />
</div>
</div>
<div class="row">
<div class="input" style="display: flex; width: 100%;">
<i class="material-icons">lock</i>
<input style="border: none;" type="password" name="password" id="password" placeholder="<?php echo $page->msg("connection.form.password"); ?>" required />
<i class="material-icons" onclick="togglePasswordVisibility()" style="cursor: pointer;">visibility</i>
</div>
</div>
</div>
<br/>
<button type="Submit" value="Submit" name="" id="formsend" class="btn-outline"><div class="text"><?php echo $page->msg("connection.form.confirm"); ?></div></button>
</form>
<?php
}
?>
</div>
</body>
</html>