Test Setup Failed
Push — master ( 976b69...15356d )
by Ankit
02:31
created
account.php 2 patches
Indentation   +36 added lines, -36 removed lines patch added patch discarded remove patch
@@ -11,26 +11,26 @@  discard block
 block discarded – undo
11 11
 $userId = Session::get('start');
12 12
 if($userId != null and $user == "account.php")
13 13
 {
14
-	$obUser = new User();
15
-	$row = $obUser->UserDetails($userId, True);
14
+    $obUser = new User();
15
+    $row = $obUser->UserDetails($userId, True);
16 16
 
17
-	if($row != NULL)
18
-	{
19
-		$location = URL . "/account.php/". $row['username'];
20
-		header("Location:".$location);
21
-	}
17
+    if($row != NULL)
18
+    {
19
+        $location = URL . "/account.php/". $row['username'];
20
+        header("Location:".$location);
21
+    }
22 22
 }
23 23
 elseif ($user != "account.php")
24 24
 {
25
-	$obUser = new User();
26
-	$row = $obUser->UserDetails($user, False);
27
-	if($row != NULL):
28
-		$userId = $row['login_id'];
29
-		$details = Profile::getProfile($userId);
30
-		if($details != NULL)
31
-			$row = array_merge($row, $details);
32
-		else
33
-			header("Location:".URL."/error.php");
25
+    $obUser = new User();
26
+    $row = $obUser->UserDetails($user, False);
27
+    if($row != NULL):
28
+        $userId = $row['login_id'];
29
+        $details = Profile::getProfile($userId);
30
+        if($details != NULL)
31
+            $row = array_merge($row, $details);
32
+        else
33
+            header("Location:".URL."/error.php");
34 34
 ?>
35 35
 
36 36
 		<!Doctype html>
@@ -65,18 +65,18 @@  discard block
 block discarded – undo
65 65
 						<div class="brief">
66 66
 							<h1 id="name">Name: <?php echo $row['name']; ?></h1><br>
67 67
 							<?php foreach ($row as $key => $value) {
68
-								if($key =='username' and $value != null)
69
-									echo '<p>Username: '.$row["username"] .'</p><br>';
70
-								if($key == 'email' and $value != null)
71
-									echo '<p>Email Id: '.$row["email"] .'</p><br>';
72
-								if($key == 'status' and $value != null)
73
-									echo '<p>Status: '.$row["status"] .'</p><br>';
74
-								if($key == 'education' and $value != null)
75
-									echo '<p>Education: '.$row["education"] .'</p><br>';
76
-								if($key == 'gender' and $value != null)
77
-									echo '<p>Gender: 	'.$row["gender"] .'</p><br>';
78
-							}
79
-							?>
68
+                                if($key =='username' and $value != null)
69
+                                    echo '<p>Username: '.$row["username"] .'</p><br>';
70
+                                if($key == 'email' and $value != null)
71
+                                    echo '<p>Email Id: '.$row["email"] .'</p><br>';
72
+                                if($key == 'status' and $value != null)
73
+                                    echo '<p>Status: '.$row["status"] .'</p><br>';
74
+                                if($key == 'education' and $value != null)
75
+                                    echo '<p>Education: '.$row["education"] .'</p><br>';
76
+                                if($key == 'gender' and $value != null)
77
+                                    echo '<p>Gender: 	'.$row["gender"] .'</p><br>';
78
+                            }
79
+                            ?>
80 80
 						</div>
81 81
 						<?php if(Session::get('start') == $row['login_id']): ?>
82 82
 							<div class="edit">
@@ -86,8 +86,8 @@  discard block
 block discarded – undo
86 86
 					</div>
87 87
 
88 88
 					<?php
89
-						if(Session::get('start') == $row['login_id']):
90
-					?>
89
+                        if(Session::get('start') == $row['login_id']):
90
+                    ?>
91 91
 
92 92
 					<div class="boxx" id="profile">
93 93
 						<form method="post" action="../profile_generate.php">
@@ -102,8 +102,8 @@  discard block
 block discarded – undo
102 102
 						</form>
103 103
 					</div>
104 104
 					<?php
105
-						endif;
106
-					?>
105
+                        endif;
106
+                    ?>
107 107
 				</div>
108 108
 
109 109
 				<div class="footer">
@@ -116,13 +116,13 @@  discard block
 block discarded – undo
116 116
 			</body>
117 117
 		</html>
118 118
 <?php
119
-	else:
120
-		header("Location:".URL."/error.php");
121
-	endif;
119
+    else:
120
+        header("Location:".URL."/error.php");
121
+    endif;
122 122
 }
123 123
 else
124 124
 {
125
-	header("Location: ".URL);
125
+    header("Location: ".URL);
126 126
 }
127 127
 ?>
128 128
 
Please login to merge, or discard this patch.
Spacing   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -1,22 +1,22 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-require_once (__DIR__ . '/vendor/autoload.php');
4
-require_once (__DIR__ . '/config/database.php');
3
+require_once (__DIR__.'/vendor/autoload.php');
4
+require_once (__DIR__.'/config/database.php');
5 5
 use ChatApp\User;
6 6
 use ChatApp\Profile;
7 7
 use ChatApp\Session;
8 8
 
9 9
 $user = explode("/", $_SERVER['REQUEST_URI']);
10
-$user = $user[count($user)-1];
10
+$user = $user[count($user) - 1];
11 11
 $userId = Session::get('start');
12
-if($userId != null and $user == "account.php")
12
+if ($userId != null and $user == "account.php")
13 13
 {
14 14
 	$obUser = new User();
15 15
 	$row = $obUser->UserDetails($userId, True);
16 16
 
17
-	if($row != NULL)
17
+	if ($row != NULL)
18 18
 	{
19
-		$location = URL . "/account.php/". $row['username'];
19
+		$location = URL."/account.php/".$row['username'];
20 20
 		header("Location:".$location);
21 21
 	}
22 22
 }
@@ -24,10 +24,10 @@  discard block
 block discarded – undo
24 24
 {
25 25
 	$obUser = new User();
26 26
 	$row = $obUser->UserDetails($user, False);
27
-	if($row != NULL):
27
+	if ($row != NULL):
28 28
 		$userId = $row['login_id'];
29 29
 		$details = Profile::getProfile($userId);
30
-		if($details != NULL)
30
+		if ($details != NULL)
31 31
 			$row = array_merge($row, $details);
32 32
 		else
33 33
 			header("Location:".URL."/error.php");
@@ -45,7 +45,7 @@  discard block
 block discarded – undo
45 45
 		            <a id="brand" href="">OpenChat</a>
46 46
 		            <ul class="nav-right">
47 47
 		                <li><a href="../index.php">About</a></li>
48
-		                <?php if(Session::get('start') != null): ?>
48
+		                <?php if (Session::get('start') != null): ?>
49 49
 							<li><a href="../message.php">Message</a></li>
50 50
 							<li><a href="../logout.php">Log out</a></li>
51 51
 						<?php else: ?>
@@ -65,20 +65,20 @@  discard block
 block discarded – undo
65 65
 						<div class="brief">
66 66
 							<h1 id="name">Name: <?php echo $row['name']; ?></h1><br>
67 67
 							<?php foreach ($row as $key => $value) {
68
-								if($key =='username' and $value != null)
69
-									echo '<p>Username: '.$row["username"] .'</p><br>';
70
-								if($key == 'email' and $value != null)
71
-									echo '<p>Email Id: '.$row["email"] .'</p><br>';
72
-								if($key == 'status' and $value != null)
73
-									echo '<p>Status: '.$row["status"] .'</p><br>';
74
-								if($key == 'education' and $value != null)
75
-									echo '<p>Education: '.$row["education"] .'</p><br>';
76
-								if($key == 'gender' and $value != null)
77
-									echo '<p>Gender: 	'.$row["gender"] .'</p><br>';
68
+								if ($key == 'username' and $value != null)
69
+									echo '<p>Username: '.$row["username"].'</p><br>';
70
+								if ($key == 'email' and $value != null)
71
+									echo '<p>Email Id: '.$row["email"].'</p><br>';
72
+								if ($key == 'status' and $value != null)
73
+									echo '<p>Status: '.$row["status"].'</p><br>';
74
+								if ($key == 'education' and $value != null)
75
+									echo '<p>Education: '.$row["education"].'</p><br>';
76
+								if ($key == 'gender' and $value != null)
77
+									echo '<p>Gender: 	'.$row["gender"].'</p><br>';
78 78
 							}
79 79
 							?>
80 80
 						</div>
81
-						<?php if(Session::get('start') == $row['login_id']): ?>
81
+						<?php if (Session::get('start') == $row['login_id']): ?>
82 82
 							<div class="edit">
83 83
 								<a href="#">Edit Profile</a>
84 84
 							</div>
@@ -86,7 +86,7 @@  discard block
 block discarded – undo
86 86
 					</div>
87 87
 
88 88
 					<?php
89
-						if(Session::get('start') == $row['login_id']):
89
+						if (Session::get('start') == $row['login_id']):
90 90
 					?>
91 91
 
92 92
 					<div class="boxx" id="profile">
@@ -96,8 +96,8 @@  discard block
 block discarded – undo
96 96
 							<label>Education : </label>
97 97
 							<input type="text" name="education" id="education" value="<?php echo $row['education']; ?>"></input>
98 98
 							<label>Gender : </label><br>
99
-							<input type="radio" name="gender" id="gender" value="Male" <?php echo ($row['gender']=='Male')?'checked':'' ?>> Male<br>
100
-							<input type="radio" name="gender" id="gender" value="Female" <?php echo ($row['gender']=='Female')?'checked':'' ?>> Female<br>
99
+							<input type="radio" name="gender" id="gender" value="Male" <?php echo ($row['gender'] == 'Male') ? 'checked' : '' ?>> Male<br>
100
+							<input type="radio" name="gender" id="gender" value="Female" <?php echo ($row['gender'] == 'Female') ? 'checked' : '' ?>> Female<br>
101 101
 							<input type="submit" name="submit" value="Done" id="submit">
102 102
 						</form>
103 103
 					</div>
Please login to merge, or discard this patch.
src/Session.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -6,15 +6,15 @@
 block discarded – undo
6 6
 class Session
7 7
 {
8 8
 
9
-    public static function put($key, $value){
9
+    public static function put($key, $value) {
10 10
         $_SESSION[$key] = $value;
11 11
     }
12 12
 
13
-    public static function get($key){
13
+    public static function get($key) {
14 14
         return (isset($_SESSION[$key]) ? $_SESSION[$key] : null);
15 15
     }
16 16
 
17
-    public static function forget($key){
17
+    public static function forget($key) {
18 18
         unset($_SESSION[$key]);
19 19
     }
20 20
 }
Please login to merge, or discard this patch.
src/Login.php 1 patch
Indentation   +73 added lines, -73 removed lines patch added patch discarded remove patch
@@ -7,83 +7,83 @@
 block discarded – undo
7 7
 class Login
8 8
 {
9 9
 
10
-	protected $key;
11
-	protected $error;
12
-	protected $connect;
10
+    protected $key;
11
+    protected $error;
12
+    protected $connect;
13 13
 
14
-	public function __construct()
15
-	{
16
-		$this->key = 0;
17
-		$this->connect = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME);
18
-		$this->error = array();
19
-	}
14
+    public function __construct()
15
+    {
16
+        $this->key = 0;
17
+        $this->connect = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME);
18
+        $this->error = array();
19
+    }
20 20
 
21
-	public function authLogin($login, $password)
22
-	{
21
+    public function authLogin($login, $password)
22
+    {
23 23
 
24
-		$login = trim($login);
25
-		$password = trim($password);
24
+        $login = trim($login);
25
+        $password = trim($password);
26 26
 
27
-		if(empty($login))
28
-		{
29
-			$this->key = 1;
30
-			$this->error = array_merge($this->error, ["login" => " *Enter the login field"]);
31
-		}
32
-		elseif (preg_match("/^[@]{1}$/", $login))
33
-		{
34
-			if(filter_var($login, FILTER_VALIDATE_EMAIL) == false)
35
-			{
36
-			$this->key = 1;
37
-			$this->error = array_merge($this->error, ["login" => " *Enter correct Email address"]);
38
-			}
39
-		}
40
-		if(empty($password)) {
41
-			$this->key = 1;
42
-			$this->error = array_merge($this->error, ["password" => " *Enter the password"]);
43
-		}
44
-		else
45
-		{
46
-			$password = md5($password);
47
-		}
27
+        if(empty($login))
28
+        {
29
+            $this->key = 1;
30
+            $this->error = array_merge($this->error, ["login" => " *Enter the login field"]);
31
+        }
32
+        elseif (preg_match("/^[@]{1}$/", $login))
33
+        {
34
+            if(filter_var($login, FILTER_VALIDATE_EMAIL) == false)
35
+            {
36
+            $this->key = 1;
37
+            $this->error = array_merge($this->error, ["login" => " *Enter correct Email address"]);
38
+            }
39
+        }
40
+        if(empty($password)) {
41
+            $this->key = 1;
42
+            $this->error = array_merge($this->error, ["password" => " *Enter the password"]);
43
+        }
44
+        else
45
+        {
46
+            $password = md5($password);
47
+        }
48 48
 
49
-		if($this->key == 0)
50
-		{
51
-			$query = "SELECT * FROM login WHERE email = '$login' or username = '$login'";
52
-			if ($result = $this->connect->query($query))
53
-			{
54
-				if ($result->num_rows > 0)
55
-				{
56
-					$row = $result->fetch_assoc();
57
-					$loginID = $row['login_id'];
58
-					$query = "SELECT id FROM register WHERE id = '$loginID' and password = '$password'";
59
-					if($result = $this->connect->query($query))
60
-					{
61
-						if ($result->num_rows > 0)
62
-						{
63
-							Session::put('start', $loginID);
64
-							return json_encode([
65
-								"location" => URL."/account.php"
66
-							]);
67
-						}
68
-						else
69
-						{
70
-							$this->error = array_merge($this->error, ["password" => " *Invalid password"]);
71
-							return json_encode($this->error);
72
-						}
73
-					}
74
-				}
75
-				else
76
-				{
77
-					$this->error = array_merge($this->error, ["login" => " *Invalid username or email"]);
78
-					return json_encode($this->error);
79
-				}
80
-			}
49
+        if($this->key == 0)
50
+        {
51
+            $query = "SELECT * FROM login WHERE email = '$login' or username = '$login'";
52
+            if ($result = $this->connect->query($query))
53
+            {
54
+                if ($result->num_rows > 0)
55
+                {
56
+                    $row = $result->fetch_assoc();
57
+                    $loginID = $row['login_id'];
58
+                    $query = "SELECT id FROM register WHERE id = '$loginID' and password = '$password'";
59
+                    if($result = $this->connect->query($query))
60
+                    {
61
+                        if ($result->num_rows > 0)
62
+                        {
63
+                            Session::put('start', $loginID);
64
+                            return json_encode([
65
+                                "location" => URL."/account.php"
66
+                            ]);
67
+                        }
68
+                        else
69
+                        {
70
+                            $this->error = array_merge($this->error, ["password" => " *Invalid password"]);
71
+                            return json_encode($this->error);
72
+                        }
73
+                    }
74
+                }
75
+                else
76
+                {
77
+                    $this->error = array_merge($this->error, ["login" => " *Invalid username or email"]);
78
+                    return json_encode($this->error);
79
+                }
80
+            }
81 81
 
82
-		}
83
-		else
84
-		{
85
-			return json_encode($this->error);
86
-		}
87
-		$this->connect->close();
88
-	}
82
+        }
83
+        else
84
+        {
85
+            return json_encode($this->error);
86
+        }
87
+        $this->connect->close();
88
+    }
89 89
 }
Please login to merge, or discard this patch.
src/Register.php 1 patch
Indentation   +97 added lines, -97 removed lines patch added patch discarded remove patch
@@ -7,114 +7,114 @@
 block discarded – undo
7 7
 
8 8
 class Register
9 9
 {
10
-	protected $error;
11
-	protected $key;
12
-	protected $obValidate;
13
-	protected $connect;
10
+    protected $error;
11
+    protected $key;
12
+    protected $obValidate;
13
+    protected $connect;
14 14
 
15
-	public function __construct()
16
-	{
17
-		$this->error = array();
18
-		$this->key = 0;
19
-		$this->connect = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME);
20
-		$this->obValidate = new Validate();
15
+    public function __construct()
16
+    {
17
+        $this->error = array();
18
+        $this->key = 0;
19
+        $this->connect = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME);
20
+        $this->obValidate = new Validate();
21 21
 
22
-	}
22
+    }
23 23
 
24
-	public function authRegister($name, $email, $username, $password, $mob)
25
-	{
26
-		$name = trim($name);
27
-		$email = trim($email);
28
-		$username = trim($username);
29
-		$password = trim($password);
30
-		$mob = trim($mob);
31
-		$userId = '';
24
+    public function authRegister($name, $email, $username, $password, $mob)
25
+    {
26
+        $name = trim($name);
27
+        $email = trim($email);
28
+        $username = trim($username);
29
+        $password = trim($password);
30
+        $mob = trim($mob);
31
+        $userId = '';
32 32
 
33
-		if (empty($name)) {
34
-			$this->onError(["name" => " *Enter the name"]);
35
-		}
33
+        if (empty($name)) {
34
+            $this->onError(["name" => " *Enter the name"]);
35
+        }
36 36
 
37
-		if(empty($email)) {
38
-			$this->onError(["email" => " *Enter the email address"]);
39
-		}
40
-		elseif(filter_var($email, FILTER_VALIDATE_EMAIL) == false) {
41
-			$this->onError(["email" => " *Enter correct Email address"]);
42
-		}
43
-		else
44
-		{
45
-			if($this->obValidate->validateEmailInDb($email) === 1)
46
-			{
37
+        if(empty($email)) {
38
+            $this->onError(["email" => " *Enter the email address"]);
39
+        }
40
+        elseif(filter_var($email, FILTER_VALIDATE_EMAIL) == false) {
41
+            $this->onError(["email" => " *Enter correct Email address"]);
42
+        }
43
+        else
44
+        {
45
+            if($this->obValidate->validateEmailInDb($email) === 1)
46
+            {
47 47
 
48
-				$this->onError(["email" => " *Email is already registered"]);
49
-			}
50
-		}
48
+                $this->onError(["email" => " *Email is already registered"]);
49
+            }
50
+        }
51 51
 
52
-		if(empty($username)) {
53
-			$this->onError(["username" => " *Enter the username"]);
54
-		}
55
-		else
56
-		{
57
-			if($this->obValidate->validateUsernameInDb($username) === 1)
58
-			{
52
+        if(empty($username)) {
53
+            $this->onError(["username" => " *Enter the username"]);
54
+        }
55
+        else
56
+        {
57
+            if($this->obValidate->validateUsernameInDb($username) === 1)
58
+            {
59 59
 
60
-				$this->onError(["username" => " *Username is already registered"]);
61
-			}
62
-		}
60
+                $this->onError(["username" => " *Username is already registered"]);
61
+            }
62
+        }
63 63
 
64
-		if(empty($password)) {
65
-			$this->onError(["password" => " *Enter the password"]);
66
-		}
64
+        if(empty($password)) {
65
+            $this->onError(["password" => " *Enter the password"]);
66
+        }
67 67
 
68
-		if(empty($mob)) {
69
-			$this->onError(["mob" => " *Enter the Mobile Number"]);
70
-		}
71
-		elseif (!preg_match("/^[0-9]{10}$/", $mob)) {
72
-			$this->onError(["mob" => " *Enter correct Mobile Number"]);
73
-		}
68
+        if(empty($mob)) {
69
+            $this->onError(["mob" => " *Enter the Mobile Number"]);
70
+        }
71
+        elseif (!preg_match("/^[0-9]{10}$/", $mob)) {
72
+            $this->onError(["mob" => " *Enter correct Mobile Number"]);
73
+        }
74 74
 
75
-		if($this->key == 1)
76
-		{
77
-			return json_encode($this->error);
78
-		}
79
-		else
80
-		{
81
-			$this->key = 0;
82
-			$pass = md5($password);
83
-			$query = "INSERT INTO register VALUES(null, '$email', '$username', '$pass')";
84
-			if(!$this->connect->query($query)) {
85
-				$this->key = 1;
86
-				echo "You are not registered || Error in registration2";
87
-			}
88
-			else
89
-			{
90
-				$query = "SELECT id FROM register WHERE email = '$email'";
91
-				if($result = $this->connect->query($query)) {
92
-					$row = $result->fetch_assoc();
93
-					$userId = $row['id'];
75
+        if($this->key == 1)
76
+        {
77
+            return json_encode($this->error);
78
+        }
79
+        else
80
+        {
81
+            $this->key = 0;
82
+            $pass = md5($password);
83
+            $query = "INSERT INTO register VALUES(null, '$email', '$username', '$pass')";
84
+            if(!$this->connect->query($query)) {
85
+                $this->key = 1;
86
+                echo "You are not registered || Error in registration2";
87
+            }
88
+            else
89
+            {
90
+                $query = "SELECT id FROM register WHERE email = '$email'";
91
+                if($result = $this->connect->query($query)) {
92
+                    $row = $result->fetch_assoc();
93
+                    $userId = $row['id'];
94 94
 
95
-					$query = "INSERT INTO login VALUES('$userId', '$name', '$email', '$username', '$mob', 0)";
96
-					if(!$this->connect->query($query)) {
97
-						$this->key = 1;
98
-						echo "You are not registered || Error in registration1";
99
-					}
100
-				}
101
-			}
102
-		}
103
-		if ($this->key == 0) {
104
-			Session::put('start', $userId);
105
-			return json_encode([
106
-				"location" => URL."/account.php"
107
-			]);
108
-		}
109
-		else
110
-		{
111
-			return json_encode($this->error);
112
-		}
113
-	}
95
+                    $query = "INSERT INTO login VALUES('$userId', '$name', '$email', '$username', '$mob', 0)";
96
+                    if(!$this->connect->query($query)) {
97
+                        $this->key = 1;
98
+                        echo "You are not registered || Error in registration1";
99
+                    }
100
+                }
101
+            }
102
+        }
103
+        if ($this->key == 0) {
104
+            Session::put('start', $userId);
105
+            return json_encode([
106
+                "location" => URL."/account.php"
107
+            ]);
108
+        }
109
+        else
110
+        {
111
+            return json_encode($this->error);
112
+        }
113
+    }
114 114
 
115
-	public function onError($value)
116
-	{
117
-		$this->key = 1;
118
-		$this->error = array_merge($this->error, $value);
119
-	}
115
+    public function onError($value)
116
+    {
117
+        $this->key = 1;
118
+        $this->error = array_merge($this->error, $value);
119
+    }
120 120
 }
Please login to merge, or discard this patch.