Completed
Push — master ( 32309e...c5e908 )
by Ankit
02:57
created

account.php (1 issue)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
3
require_once (__DIR__ . '/vendor/autoload.php');
4
use ChatApp\User;
5
use ChatApp\Profile;
6
use ChatApp\Session;
7
use Dotenv\Dotenv;
8
$dotenv = new Dotenv(__DIR__);
9
$dotenv->load();
10
// die("Hello");
0 ignored issues
show
Unused Code Comprehensibility introduced by
84% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
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
{
17
	$obUser = new User();
18
	$row = $obUser->userDetails($userId, True);
19
20 View Code Duplication
	if($row != NULL)
21
	{
22
		$location = getenv('APP_URL') . "/account.php/". $row['username'];
23
		header("Location:".$location);
24
	}
25
}
26
elseif ($user != "account.php")
27
{
28
	$obUser = new User();
29
	$row = $obUser->userDetails($user, False);
30
	if($row != NULL):
31
		$userId = $row['login_id'];
32
		$details = Profile::getProfile($userId);
33 View Code Duplication
		if($details != NULL)
34
			$row = array_merge($row, $details);
35
		else
36
			header("Location:".getenv('APP_URL')."/error.php");
37
?>
38
39
		<!Doctype html>
40
		<html>
41
			<head>
42
				<title>OpenChat || Profile</title>
43
		        <link rel="stylesheet" href="../css/profile.css">
44
			</head>
45
			<body>
46
47
				<div class="header">
48
		            <a id="brand" href="">OpenChat</a>
49
		            <ul class="nav-right">
50
		                <li><a href="../index.php">About</a></li>
51
		                <?php if(Session::get('start') != null): ?>
52
							<li><a href="../message.php">Message</a></li>
53
							<li><a href="../logout.php">Log out</a></li>
54
						<?php else: ?>
55
							<li><a href="../login.php">Login</a></li>
56
							<li><a href="../register.php">Register</a></li>
57
						<?php endif; ?>
58
		            </ul>
59
		        </div>
60
61
		        <div class="main">
62
					<div class="boxx" >
63
64
						<div class="pic">
65
							<img src="../assests/ankit.png">
66
						</div>
67
68
						<div class="brief">
69
							<h1 id="name">Name: <?php echo $row['name']; ?></h1><br>
70
							<?php foreach ($row as $key => $value) {
71
								if($key =='username' && $value != null)
72
									echo '<p>Username: '.$row["username"] .'</p><br>';
73
								if($key == 'email' && $value != null)
74
									echo '<p>Email Id: '.$row["email"] .'</p><br>';
75
								if($key == 'status' && $value != null)
76
									echo '<p>Status: '.$row["status"] .'</p><br>';
77
								if($key == 'education' && $value != null)
78
									echo '<p>Education: '.$row["education"] .'</p><br>';
79
								if($key == 'gender' && $value != null)
80
									echo '<p>Gender: 	'.$row["gender"] .'</p><br>';
81
							}
82
							?>
83
						</div>
84
						<?php if(Session::get('start') == $row['login_id']): ?>
85
							<div class="edit">
86
								<a href="#">Edit Profile</a>
87
							</div>
88
						<?php endif; ?>
89
					</div>
90
91
					<?php
92
						if(Session::get('start') == $row['login_id']):
93
					?>
94
95
					<div class="boxx" id="profile">
96
						<form method="post" action="../profile_generate.php">
97
							<label>Status : </label>
98
							<textarea name="status" id="status"><?php echo $row['status']; ?></textarea>
99
							<label>Education : </label>
100
							<input type="text" name="education" id="education" value="<?php echo $row['education']; ?>"></input>
101
							<label>Gender : </label><br>
102
							<input type="radio" name="gender" id="gender" value="Male" <?php echo ($row['gender']=='Male')?'checked':'' ?>> Male<br>
103
							<input type="radio" name="gender" id="gender" value="Female" <?php echo ($row['gender']=='Female')?'checked':'' ?>> Female<br>
104
							<input type="submit" name="submit" value="Done" id="submit">
105
						</form>
106
					</div>
107
					<?php
108
						endif;
109
					?>
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="../js/jquery-3.0.0.min.js"></script>
117
				<script type="text/javascript" src="../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')."/error.php");
124
	endif;
125
}
126
else
127
{
128
	header("Location: ".getenv('APP_URL'));
129
}
130
?>
131
132