Completed
Push — master ( 3bdd73...3b96a7 )
by Ankit
02:28
created

account.php (2 issues)

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
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)
0 ignored issues
show
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
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)
0 ignored issues
show
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
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