-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathprofilePage.php
More file actions
408 lines (377 loc) · 11.7 KB
/
profilePage.php
File metadata and controls
408 lines (377 loc) · 11.7 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
<?php
session_start();
?>
<?php
$image="images/".$_SESSION["id"].".jpg";
if (file_exists($image)) {
}else{
$image="images/".$_SESSION["id"].".png";
if (file_exists($image)) {
}else{
$image="images/".$_SESSION["id"].".jpeg";
if (file_exists($image)) {
}else{
$image="images/avatar.png";
}
}
}
if(isset($_POST['uploadSubmit'])){
$image_name=$_FILES['fileToUpload']['name'];
$image_type=$_FILES['fileToUpload']['type'];
$image_size=$_FILES['fileToUpload']['size'];
$image_tmp_name=$_FILES['fileToUpload']['tmp_name'];
$ext = end((explode(".", $image_name)));
if($image_name==' '){
echo '<script language="javascript">';
echo 'alert("no File selected")';
echo '</script>';
exit();
}else{
if($ext != "jpg" && $ext != "png" && $ext != "jpeg" ){
echo '<script language="javascript">';
echo 'alert("file must be .jpg .jpeg .png only")';
echo '</script>';
}
else{
if ($image_size > 500000) {
echo '<script language="javascript">';
echo 'alert("Sorry, your file is too large.")';
echo '</script>';
}else{
$image="images/".$_SESSION["id"].".jpg";
if (file_exists($image)) {
unlink($image);
}
$image="images/".$_SESSION["id"].".png";
if (file_exists($image)) {
unlink($image);
}
$image="images/".$_SESSION["id"].".jpeg";
if (file_exists($image)) {
unlink($image);
}
move_uploaded_file($image_tmp_name,"images/".$_SESSION["id"].".".$ext);
$image="images/".$_SESSION["id"].".".$ext;
echo '<script language="javascript">';
echo 'alert("avatar updated")';
echo '</script>';
}
}
}
}
?>
<?php
if(empty($_SESSION["id"])){
header("Location: /Project/restrict.php");
}
if(isset($_POST['submit'])){
addUser();
}
function addUser() {
if(isset($_POST['username'])&&!empty($_POST['username'])){
include 'Mysql_connect.php';
$sql = "update user set Username='".$_POST['username']."',language='".$_POST['lang']."',number=".$_POST['pnumber'].",email='".$_POST['email']."' where id = ".$_SESSION['id'];
$result = $conn->query($sql);
echo '<script language="javascript">';
echo 'alert("User updated")';
echo '</script>';
}
}
include 'Mysql_connect.php';
$username="";
$post="";
$no=0;
$id="";
$lang="";
$email="";
$sql = "select * from user where id=".$_SESSION['id'];
$result = $conn->query($sql);
if ($result->num_rows > 0) {
$row = $result->fetch_assoc();
$username=$row['Username'];
$post=$row['post'];
$no=$row['number'];
$id=$row['id'];
$lang=$row['language'];
$email=$row['email'];
}
?>
<!doctype html>
<html lang="en-US">
<head>
<meta charset="utf-8">
<meta http-equiv="Content-Type" content="text/html">
<link rel="shortcut icon" href="http://designshack.net/favicon.ico">
<link rel="icon" href="http://designshack.net/favicon.ico">
<link rel="stylesheet" type="text/css" media="all" href="css/styles.css">
<script type="text/javascript" src="js/jquery-1.10.2.min.js"></script>
</head>
<style>
table{
border-collapse: collapse;
border: 1px solid steelblue;
width:80%;
height:20%;
}
th{background-color:steelblue;
align:center;
color:white;
font-size:25px;
}
tr{
border-bottom: 1px solid steelblue;
}
tr:hover{
background-color:lightgrey;
}
td{
width:40%;
}
span{
font-size:20px;
color:black;
text-shadow: 0 1px 0 #38678f;
border-left: 6px solid steelblue;
}
</style>
<body>
<div id="w">
<div id="content" class="clearfix">
<div id="userphoto"><img src="<?php echo $image ?>" alt="default avatar" width="150" height="150"></div>
<nav id="profiletabs">
<ul class="clearfix">
<li><a href="#activity">Projects</a></li>
<li><a href="#settings">Settings</a></li>
<li><a href="#password">Manage Password</a></li>
<li><a href="#avtar">Change Avatar</a></li>
</ul>
</nav>
<section id="password" class="hidden">
<?php
if(isset($_POST['changeSubmit'])){
include 'Mysql_connect.php';
$emp_id=$_SESSION['id'];
$sql = "select password from user where id=".$_SESSION["id"] ." and password ='".md5($_POST['oldPass'])."'";
$result = $conn->query($sql);
echo $sql;
if ($result->num_rows> 0) {
if(!empty($_POST['newPass'])){
if($_POST['newPass']==$_POST['reNewPass']){
$sql = "update user set password='".md5($_POST['newPass'])."' where id=".$_SESSION["id"];
if($conn->query($sql)){
echo '<script language="javascript">';
echo 'alert("password updated")';
echo '</script>';
}else{
echo '<script language="javascript">';
echo 'alert("password not updated")';
echo '</script>';
}
}else{
echo '<script language="javascript">';
echo 'alert("new password not same")';
echo '</script>';
}
}else{
echo '<script language="javascript">';
echo 'alert("new password empty")';
echo '</script>';
}
}
else{
echo '<script language="javascript">';
echo 'alert("old password not same")';
echo '</script>';
}
//select password
}
?>
<form action="profilePage.php" method="post">
<p>Enter old password <input type="password" name="oldPass" style="margin-left:29px;"><p>
<p>Enter New password <input type="password" name="newPass" style="margin-left:22px;"><p>
<p>Re-Enter New password:<input type="password" name="reNewPass"><p>
<p><input type="submit" name="changeSubmit" value="Change Password" style="margin-left:100px; border-radius:5px; height:25%; width:25%;"><p>
</form>
</section>
<section id="avtar" class="hidden">
<form action="profilePage.php" method="post" enctype="multipart/form-data">
<h1>Select an Image</h1><input type="file" name="fileToUpload" id="fileToUpload"><br>
<input type="submit" value="Upload Image" name="uploadSubmit" >
</form>
</section>
<section id="activity" class="hidden">
<?php
switch(strlen($_SESSION["id"])){
case 1:
echo "<h1> Admin </h1>";
echo '<script type="text/javascript">',
'var i=1;',
'</script>';
break;
case 2:
echo "<h1> Manager:- </h1>";
echo '<script type="text/javascript">',
'var i=0;',
'</script>';
break;
case 4:
echo "<h1> Tead Lead:- </h1>";
echo '<script type="text/javascript">',
'var i=0;',
'</script>';
break;
case 5:
echo "<h1> Developer:- </h1>";
echo '<script type="text/javascript">',
'var i=0;',
'</script>';
break;
}
?>
<table id="AllProjects" style="height:100%; width:70%;">
<tr>
<th height="10gmail0%" id='dis'>Project Name</th>
<th>Module Name</th>
</tr>
<script>
if(i==1){
function dis(){
document.getElementById("AllProjects").style.display="none";
}
dis();
}
function addOneProject(ProName,ModName) {
var table = document.getElementById("AllProjects");
var x = document.getElementById("AllProjects").rows.length;
var row = table.insertRow(x);
var cell1 = row.insertCell(0);
var cell2 = row.insertCell(1);
cell1.innerHTML = ProName;
cell2.innerHTML = ModName;
}
</script>
</table>
<?php
function developer(){
include 'Mysql_connect.php';
$emp_id=$_SESSION['id'];
$sql = "select t1.project_name , t2.module_name,t2.emp_list from projectall t1,project_instance t2 where t1.pid=t2.pid and t2.emp_list in (select emp_list from employee_list where emp_id=".$emp_id.")";
$result = $conn->query($sql);
$proName="";
$ModName="";
if ($result->num_rows> 0) {
while($row = $result->fetch_assoc()) {
$proName=$row['project_name'];
$ModName=$row['module_name'];
echo '<script type="text/javascript">',
'addOneProject("'.$proName.'","'.$ModName.'");',
'</script>';
}
} else {
echo "0 results";
}
$conn->close();
}
function teadL(){
include 'Mysql_connect.php';
$emp_id=$_SESSION['id'];
$sql = "select t1.project_name , t2.module_name from projectall t1,project_instance t2 where t1.pid=t2.pid and t2.leaderID =".$emp_id;
$result = $conn->query($sql);
$proName="";
$ModName="";
if ($result->num_rows> 0) {
while($row = $result->fetch_assoc()) {
$proName=$row['project_name'];
$ModName=$row['module_name'];
echo '<script type="text/javascript">',
'addOneProject("'.$proName.'","'.$ModName.'");',
'</script>';
}
} else {
echo "0 results";
}
$conn->close();
}
function mamager(){
include 'Mysql_connect.php';
//echo "<h2> Project Name </h2>";
$emp_id=$_SESSION['id'];
$sql = "select project_name from projectall where managerID=".$emp_id;
$result = $conn->query($sql);
$proName="";
$ModName="";
if ($result->num_rows> 0) {
while($row = $result->fetch_assoc()) {
$proName=$row['project_name'];
//echo "<h2>".$proName."</h2>"; AllProjects h2
echo '<script type="text/javascript">',
'addOneProject("'.$proName.'"," ");',
'</script>';
}
} else {
echo "0 results";
}
$conn->close();
}
function admin(){
include 'Mysql_connect.php';
echo "<div style='float:left;'>";
echo "<h2 style='background-color:steelblue;color:white;'>Roles</h2>";
echo "<h2 style=''>Add User</h2>";
echo "<h2 style=''>Change Post</h2>";
echo "<h2 style=''>Delete User</h2><br>";
echo "</div>";
}
switch(strlen($_SESSION["id"])){
case 1:
admin();
break;
case 2:
mamager();
break;
case 4:
teadL();
break;
case 5:
developer();
break;
}
?>
</section>
<form action="profilePage.php" method="post">
<section id="settings" class="hidden">
<p>Edit your user settings:</p>
<p class="setting">Name: <input type="text" name="username" value="<?php echo $username;?>"></p>
<p class="setting">Employee ID: <input type="text" name="id" value="<?php echo $id;?>" onkeydown="Check(event);"></p>
<p class="setting">Designation: <input type="text" name="post" value="<?php echo $post;?>" onkeydown="Check(event);"></p>
<p class="setting">Language: <input type="text" name="lang" value="<?php echo $lang;?>"></p>
<p class="setting">Phone Number: <input type="text" name="pnumber" value="<?php echo $no;?>"></p>
<p class="setting">Email: <input type="text" name="email" value="<?php echo $email;?>"></p>
<center><input type="submit" name="submit" value="Update"></center>
</section>
<script>
function Check(e) {
var keyCode = (e.keyCode ? e.keyCode : e.which);
e.preventDefault();
}
</script>
</form>
</div>
</div>
<h1><a href="index.php">Back to Main Page</a></h1>
<script type="text/javascript">
$(function(){
$('#profiletabs ul li a').on('click', function(e){
e.preventDefault();
var newcontent = $(this).attr('href');
$('#profiletabs ul li a').removeClass('sel');
$(this).addClass('sel');
$('#content section').each(function(){
if(!$(this).hasClass('hidden')) { $(this).addClass('hidden'); }
});
$(newcontent).removeClass('hidden');
});
});
</script>
</body>
</html>