-
Notifications
You must be signed in to change notification settings - Fork 5
/
profile.php
171 lines (163 loc) · 8.12 KB
/
profile.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
<?php
require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/global.inc.php";
require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/profile.inc.php";
connectToDatabase();
if(!isset($_SESSION['role'])) {
unauthorized();
}
if(isset($_SESSION['role']) && $_SESSION['role'] === ADMIN_ROLE) {
ipAddrFilter();
}
if(isset($_POST['updateProfile']) && $_POST['updateProfile'] === "updateProfile") {
updateProfile($_POST['firstname'], $_POST['lastname'], $_POST['email'], $_POST['csrf_token']);
}
if(isset($_POST['changePassword']) && $_POST['changePassword'] === "changePassword") {
changePassword($_POST['oldPassword'], $_POST['newPassword'], $_POST['confirmPassword'], $_POST['csrf_token']);
}
$userInfo = retrieveUserInformation();
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<link rel="stylesheet" href="/css/bootstrap.css"/>
<link rel="stylesheet" href="/css/style.css"/>
<title>Futura Business Informatique GROUPE - Conseil en ingénierie</title>
<link rel="icon" type="image/png" sizes="32x32" href="/img/favicon-32x32.png">
</head>
<body>
<div class="container-fluid">
<?php
include_once $_SERVER['DOCUMENT_ROOT'] . "/includes/header.inc.php";
include_once $_SERVER['DOCUMENT_ROOT'] . "/includes/messages_dialog.inc.php";
?>
</div>
<div class="container">
<div class="row">
<div class="col-md-12">
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title">Edit your profile</h3>
</div>
<div class="panel-body">
<form class="col-md-4 col-md-offset-4">
<fieldset>
<legend>Your professional information</legend>
<div class="form-group">
<label for="username">Username : </label>
<?php
if(isset($userInfo['username']) && !empty($userInfo['username'])) {
echo '<input id="role" type="text" name="role" class="form-control" value="' . htmlspecialchars($userInfo['username']) . '" disabled>';
}
else {
echo '<input id="role" type="text" name="role" class="form-control" disabled>';
}
?>
</div>
<div class="form-group">
<label for="role">Role : </label>
<?php
if(isset($userInfo['role']) && !empty($userInfo['role'])) {
echo '<input id="role" type="text" name="role" class="form-control" value="' . htmlspecialchars($userInfo['role']) . '" disabled>';
}
else {
echo '<input id="role" type="text" name="role" class="form-control" disabled>';
}
?>
</div>
<div class="form-group">
<label for="Site">Site : </label>
<?php
if(isset($userInfo['city']) && !empty($userInfo['city'])) {
echo '<input id="site" type="text" name="site" class="form-control" value="' . htmlspecialchars($userInfo['city']) . '" disabled>';
}
else {
echo '<input id="site" type="text" name="site" class="form-control" disabled>';
}
?>
</div>
<div class="form-group">
<label for="manager">Manager : </label>
<?php
if(isset($userInfo['firstname_manager']) && !empty($userInfo['firstname_manager']) && isset($userInfo['lastname_manager']) && !empty($userInfo['lastname_manager'])) {
echo '<input id="manager" type="text" name="manager" class="form-control" value="' . htmlspecialchars($userInfo['firstname_manager'] . ' ' . $userInfo['lastname_manager']) . '" disabled>';
}
else {
echo '<input id="role" type="text" name="role" class="form-control" disabled>';
}
?>
</div>
</fieldset>
</form>
</div>
<div class="panel-body">
<form class="col-md-4 col-md-offset-4" action="/profile.php" method="POST">
<fieldset>
<legend>Your personnal information</legend>
<div class="form-group">
<label for="firstname">Firstname : </label>
<?php
if(isset($userInfo['firstname']) && !empty($userInfo['firstname'])) {
echo '<input id="firstname" type="text" name="firstname" class="form-control" value="' . htmlspecialchars($userInfo['firstname']) . '">';
}
else {
echo '<input id="firstname" type="text" name="firstname" class="form-control">';
}
?>
</div>
<div class="form-group">
<label for="lastname">Lastname : </label>
<?php
if(isset($userInfo['lastname']) && !empty($userInfo['lastname'])) {
echo '<input id="lastname" type="text" name="lastname" class="form-control" value="' . htmlspecialchars($userInfo['lastname']) . '">';
}
else {
echo '<input id="lastname" type="text" name="lastname" class="form-control">';
}
?>
</div>
<div class="form-group">
<label for="email">Email address : </label>
<?php
if(isset($userInfo['email']) && !empty($userInfo['email'])) {
echo '<input id="email" type="text" name="email" class="form-control" value="' . htmlspecialchars($userInfo['email']) . '">';
}
else {
echo '<input id="email" type="text" name="email" class="form-control">';
}
echo '<input id="csrf_token" type="hidden" name="csrf_token" value=' . $_SESSION['csrf_token'] . ' autocomplete="off">';
?>
</div>
<button type="submit" class="btn btn-primary btn-block" name="updateProfile" value="updateProfile">Update profile</button>
</fieldset>
</form>
</div>
<div class="panel-body">
<form class="col-md-4 col-md-offset-4" action="/profile.php" method="POST">
<fieldset>
<legend>Change your password</legend>
<div class="form-group">
<label for="oldPassword">Old password : </label>
<input id="oldPassword" type="password" name="oldPassword" class="form-control" autocomplete="off">
</div>
<div class="form-group">
<label for="newPassword">New password : </label>
<input id="newPassword" type="password" name="newPassword" class="form-control" autocomplete="off">
</div>
<div class="form-group">
<label for="confirmPassword">Confirm password : </label>
<input id="confirmPassword" type="password" name="confirmPassword" class="form-control" autocomplete="off">
</div>
<?php
echo '<input id="csrf_token" type="hidden" name="csrf_token" value=' . $_SESSION['csrf_token'] . ' autocomplete="off">';
?>
<button type="submit" class="btn btn-primary btn-block" name="changePassword" value="changePassword">Change password</button>
</fieldset>
</form>
</div>
</div>
</div>
</div>
</div>
</body>
</html>