1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
require_once (dirname(__DIR__).'/vendor/autoload.php'); |
4
|
|
|
use ChatApp\User; |
5
|
|
|
use ChatApp\Profile; |
6
|
|
|
use ChatApp\Session; |
7
|
|
|
use Dotenv\Dotenv; |
8
|
|
|
$dotenv = new Dotenv(dirname(__DIR__)); |
9
|
|
|
$dotenv->load(); |
10
|
|
|
// die("Hello"); |
11
|
|
|
|
12
|
|
|
$user = explode("/", $_SERVER['REQUEST_URI']); |
13
|
|
|
$user = $user[count($user) - 1]; |
14
|
|
|
$userId = Session::get('start'); |
15
|
|
|
if ($userId != null && $user == "account.php") { |
16
|
|
|
$obUser = new User(); |
17
|
|
|
$row = $obUser->userDetails($userId, True); |
|
|
|
|
18
|
|
|
|
19
|
|
View Code Duplication |
if ($row != NULL) { |
|
|
|
|
20
|
|
|
$location = getenv('APP_URL')."/views/account.php/".$row['username']; |
21
|
|
|
header("Location:".$location); |
22
|
|
|
} |
23
|
|
|
} elseif ($user != "account.php") { |
24
|
|
|
$obUser = new User(); |
25
|
|
|
$row = $obUser->userDetails($user, False); |
|
|
|
|
26
|
|
|
if ($row != NULL) { |
27
|
|
|
$userId = $row['login_id']; |
28
|
|
|
$details = Profile::getProfile($userId); |
29
|
|
View Code Duplication |
if ($details != NULL) { |
|
|
|
|
30
|
|
|
$row = array_merge($row, $details); |
31
|
|
|
} else { |
32
|
|
|
header("Location:".getenv('APP_URL')."/views/error.php"); |
33
|
|
|
} |
34
|
|
|
?> |
35
|
|
|
|
36
|
|
|
<!Doctype html> |
37
|
|
|
<html> |
38
|
|
|
<head> |
39
|
|
|
<title>OpenChat || Profile</title> |
40
|
|
|
<link rel="stylesheet" href="../../public/assests/css/profile.css"> |
41
|
|
|
</head> |
42
|
|
|
<body> |
43
|
|
|
|
44
|
|
|
<div class="header"> |
45
|
|
|
<a id="brand" href="">OpenChat</a> |
46
|
|
|
<ul class="nav-right"> |
47
|
|
|
<li><a href="../../index.php">About</a></li> |
48
|
|
|
<?php if (Session::get('start') != null) { ?> |
49
|
|
|
<li><a href="../message.php">Message</a></li> |
50
|
|
|
<li><a href="../logout.php">Log out</a></li> |
51
|
|
|
<?php } else { ?> |
52
|
|
|
<li><a href="../login.php">Login</a></li> |
53
|
|
|
<li><a href="../register.php">Register</a></li> |
54
|
|
|
<?php } ?> |
55
|
|
|
</ul> |
56
|
|
|
</div> |
57
|
|
|
|
58
|
|
|
<div class="main"> |
59
|
|
|
<div class="boxx" > |
60
|
|
|
|
61
|
|
|
<div class="pic"> |
62
|
|
|
<img src="../../public/assests/img/ankit.png"> |
63
|
|
|
</div> |
64
|
|
|
|
65
|
|
|
<div class="brief"> |
66
|
|
|
<h1 id="name">Name: <?php echo $row['name']; ?></h1><br> |
67
|
|
|
<?php foreach ($row as $key => $value) { |
68
|
|
|
if ($key == 'username' && $value != null) { |
69
|
|
|
echo '<p>Username: '.$row["username"].'</p><br>'; |
70
|
|
|
} |
71
|
|
|
if ($key == 'email' && $value != null) { |
72
|
|
|
echo '<p>Email Id: '.$row["email"].'</p><br>'; |
73
|
|
|
} |
74
|
|
|
if ($key == 'status' && $value != null) { |
75
|
|
|
echo '<p>Status: '.$row["status"].'</p><br>'; |
76
|
|
|
} |
77
|
|
|
if ($key == 'education' && $value != null) { |
78
|
|
|
echo '<p>Education: '.$row["education"].'</p><br>'; |
79
|
|
|
} |
80
|
|
|
if ($key == 'gender' && $value != null) { |
81
|
|
|
echo '<p>Gender: '.$row["gender"].'</p><br>'; |
82
|
|
|
} |
83
|
|
|
} |
84
|
|
|
?> |
85
|
|
|
</div> |
86
|
|
|
<?php if (Session::get('start') == $row['login_id']) { ?> |
87
|
|
|
<div class="edit"> |
88
|
|
|
<a href="#">Edit Profile</a> |
89
|
|
|
</div> |
90
|
|
|
<?php } ?> |
91
|
|
|
</div> |
92
|
|
|
|
93
|
|
|
<?php |
94
|
|
|
if (Session::get('start') == $row['login_id']) { |
95
|
|
|
?> |
96
|
|
|
|
97
|
|
|
<div class="boxx" id="profile"> |
98
|
|
|
<form method="post" action="../profile_generate.php"> |
99
|
|
|
<label>Status : </label> |
100
|
|
|
<textarea name="status" id="status"><?php echo $row['status']; ?></textarea> |
101
|
|
|
<label>Education : </label> |
102
|
|
|
<input type="text" name="education" id="education" value="<?php echo $row['education']; ?>"></input> |
103
|
|
|
<label>Gender : </label><br> |
104
|
|
|
<input type="radio" name="gender" id="gender" value="Male" <?php echo ($row['gender'] == 'Male') ? 'checked' : '' ?>> Male<br> |
105
|
|
|
<input type="radio" name="gender" id="gender" value="Female" <?php echo ($row['gender'] == 'Female') ? 'checked' : '' ?>> Female<br> |
106
|
|
|
<input type="submit" name="submit" value="Done" id="submit"> |
107
|
|
|
</form> |
108
|
|
|
</div> |
109
|
|
|
<?php } ?> |
110
|
|
|
</div> |
111
|
|
|
|
112
|
|
|
<div class="footer"> |
113
|
|
|
<h3 class="footer_text">Made with love by <a href="#">Ankit Jain</a></h3> |
114
|
|
|
</div> |
115
|
|
|
|
116
|
|
|
<script type="text/javascript" src="../../public/assests/js/jquery-3.0.0.min.js"></script> |
117
|
|
|
<script type="text/javascript" src="../../public/assests/js/profile.js"></script> |
118
|
|
|
<script type="text/javascript" src="../../node_modules/place-holder.js/place-holder.min.js"></script> |
119
|
|
|
</body> |
120
|
|
|
</html> |
121
|
|
|
<?php |
122
|
|
|
} else { |
123
|
|
|
header("Location:".getenv('APP_URL')."/views/error.php"); |
124
|
|
|
} |
125
|
|
|
} else { |
126
|
|
|
header("Location: ".getenv('APP_URL')."/views/"); |
127
|
|
|
} |
128
|
|
|
?> |
129
|
|
|
|
130
|
|
|
|
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: