-
Notifications
You must be signed in to change notification settings - Fork 1
/
profile.php
107 lines (102 loc) · 3.8 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
<!DOCTYPE html>
<html>
<?php
require 'script/php/universal.php';
require 'script/php/header.php';
$fail=FALSE;
$site= new db("site");
common($site);
$page= filter_input(INPUT_GET, 'u', FILTER_SANITIZE_STRING);
$userdb=new db("user");
$con=$userdb->start();
if($userdb->status){ //if database connection
$query="SELECT * FROM user where username='$page'";
if($result= mysqli_query($con, $query)){
$status=FALSE;
while ($row = mysqli_fetch_array($result)) {
$status=TRUE;
$gid=$row['groupId'];
$mail=$row['email'];
}
if($status){
$status=FALSE;
$query="SELECT * FROM user_$gid WHERE email='$mail'";
if($result=mysqli_query($con, $query)){
while ($row = mysqli_fetch_array($result)) {
$status=TRUE;
$fname=$row['firstName'];
$lname=$row['lastName'];
$day=$row['day'];
$month=$row['month'];
$year=$row['year'];
$key=$row['keyId'];
$uid=$row['userId'];
}
if($status){
$query="SELECT `url` from `photos` WHERE `owner`='$key.$uid' AND `type`='profile_pic'";
if($result= mysqli_query($con, $query) ){
while ($row= mysqli_fetch_array($result)) {
$profile_pic=$row['url'];
}
$userinfo= array('fname'=>$fname,'lname'=>$lname,'mail'=>$mail,'day'=>$day,'month'=>$month,'year'=>$year,'key'=>$key,'url'=>$profile_pic);
}
}
}
}
else{
$fail=TRUE;
}
}
else{
$fail=TRUE;
}
}
?>
<head>
<meta charset="UTF-8">
<title id="ptitle"><?php if(!$fail){echo $userinfo['fname']." ".$userinfo['lname']; }else{
echo 'Not found!';}?></title>
<link type="text/css" href="script/css/common.css" rel="stylesheet" >
</head>
<body class="bodyMain text">
<?php
printHeader();
//terminates
$site->close();
echo '</div><br/>';
?>
<div class="maincontent">
<?php
if(!$fail){
printprofile($userinfo);
}
else{
echo 'The page you are looking is not found or may have been removed!';
}
/**
*
* @param array $userinfo
*/
function printprofile($userinfo)
{
echo '<div id="profile-tab">';
if(isset($userinfo['url'])){
echo '<img src="'.$userinfo['url'].'" width="100px" height="100px" alt="'.$userinfo['fname'].' '.$userinfo['lname'].'"/>';
}else{
echo '<img src=site/img/user/default.jpg width="100px" height="100px" alt="'.$userinfo['fname'].' '.$userinfo['lname'].'"/>';
}
echo '<div><h3>'.
$userinfo['fname'].' '.$userinfo['lname']
.'</h3>';
echo '<h4>Info</h4>'
. '<span style="padding-left:40px;">He was born on '.$userinfo['month'].' '.$userinfo['day'].' '.$userinfo['year'].'</span>' ;
echo '</div>';
}
?>
</div>
<?php
printFooter();
$userdb->close();
?>
</body>
</html>