Test Setup Failed
Branch master (f3ea8f)
by Ankit
03:00
created
register.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@
 block discarded – undo
1 1
 <?php
2 2
 session_start();
3
-if(isset($_SESSION['start']))
3
+if (isset($_SESSION['start']))
4 4
 {
5 5
     header("Location: account.php");
6 6
 }
Please login to merge, or discard this patch.
login.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@
 block discarded – undo
1 1
 <?php
2 2
 session_start();
3
-if(isset($_SESSION['start']))
3
+if (isset($_SESSION['start']))
4 4
 {
5 5
     header("Location: account.php");
6 6
 }
Please login to merge, or discard this patch.
database.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -2,6 +2,6 @@
 block discarded – undo
2 2
   // Define database connection constants
3 3
   define('DB_HOST', 'localhost');
4 4
   define('DB_USER', 'root');
5
-  define('DB_PASSWORD','');
5
+  define('DB_PASSWORD', '');
6 6
   define('DB_NAME', 'openchat');
7 7
 ?>
Please login to merge, or discard this patch.
index.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -15,7 +15,7 @@
 block discarded – undo
15 15
 		<div class="header">
16 16
 			<a id="brand" href="#">OpenChat</a>
17 17
 			<ul class="nav-right">
18
-				<?php if(isset($_SESSION['start']))
18
+				<?php if (isset($_SESSION['start']))
19 19
 				{
20 20
 				?>
21 21
 				<li><a href="account.php">Account</a></li>
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -22,8 +22,7 @@
 block discarded – undo
22 22
 				<li><a href="message.php">Message</a></li>
23 23
 				<li><a href="registration-module/source/class.logout.php">Log out</a></li>
24 24
 				<?php 
25
-				}
26
-				else
25
+				} else
27 26
 				{
28 27
 				?>
29 28
 				<li><a href="login.php">Login</a></li>
Please login to merge, or discard this patch.
account.php 2 patches
Spacing   +34 added lines, -34 removed lines patch added patch discarded remove patch
@@ -6,40 +6,40 @@  discard block
 block discarded – undo
6 6
 session_start();
7 7
 include 'database.php';
8 8
 $connect = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME);
9
-$user=substr($_SERVER['REQUEST_URI'],22);
9
+$user = substr($_SERVER['REQUEST_URI'], 22);
10 10
 // var_dump($user);
11
-if(isset($_SESSION['start']) and !$user)
11
+if (isset($_SESSION['start']) and !$user)
12 12
 {
13
-	$login_id=$_SESSION['start'];
14
-	$query="SELECT username from login where login_id='$login_id'";
15
-	if($result=$connect->query($query))
13
+	$login_id = $_SESSION['start'];
14
+	$query = "SELECT username from login where login_id='$login_id'";
15
+	if ($result = $connect->query($query))
16 16
 	{
17
-		if($result->num_rows >0)
17
+		if ($result->num_rows > 0)
18 18
 		{
19
-			$row=$result->fetch_assoc();
20
-			$location="http://localhost/openchat/account.php/".$row['username'];
19
+			$row = $result->fetch_assoc();
20
+			$location = "http://localhost/openchat/account.php/".$row['username'];
21 21
 			header("Location:".$location);
22 22
 		}
23 23
 	}
24 24
 
25 25
 }
26 26
 
27
-else if($user)
27
+else if ($user)
28 28
 {
29
-	$query="SELECT * from login where username='$user'";
30
-	if($result=$connect->query($query))
29
+	$query = "SELECT * from login where username='$user'";
30
+	if ($result = $connect->query($query))
31 31
 	{
32
-		if($result->num_rows >0)
32
+		if ($result->num_rows > 0)
33 33
 		{
34
-			$row=$result->fetch_assoc();
35
-			$id=$row['login_id'];
36
-			$query="SELECT * from profile where login_id='$id'";
37
-			if($result=$connect->query($query))
34
+			$row = $result->fetch_assoc();
35
+			$id = $row['login_id'];
36
+			$query = "SELECT * from profile where login_id='$id'";
37
+			if ($result = $connect->query($query))
38 38
 			{
39
-				if($result->num_rows>0)
39
+				if ($result->num_rows > 0)
40 40
 				{
41
-					$r=$result->fetch_assoc();
42
-					$row=array_merge($row,$r);
41
+					$r = $result->fetch_assoc();
42
+					$row = array_merge($row, $r);
43 43
 					// var_dump($row);
44 44
 				}
45 45
 			}
@@ -61,7 +61,7 @@  discard block
 block discarded – undo
61 61
             <a id="brand" href="">OpenChat</a>
62 62
             <ul class="nav-right">
63 63
                 <li><a href="../index.php">About</a></li>
64
-                <?php if(isset($_SESSION['start']))
64
+                <?php if (isset($_SESSION['start']))
65 65
 				{
66 66
 				?>
67 67
 				<li><a href="../message.php">Message</a></li>
@@ -92,20 +92,20 @@  discard block
 block discarded – undo
92 92
 				<div class="brief">
93 93
 					<h1 id="name">Name: <?php echo $row['name']; ?></h1><br>
94 94
 					<?php foreach ($row as $key => $value) {
95
-						if($key=='username' and $value!=null)
96
-							echo '<p>Username: '.$row["username"] .'</p><br>';
97
-						if($key=='email' and $value!=null)
98
-							echo '<p>Email Id: '.$row["email"] .'</p><br>';
99
-						if($key=='status' and $value!=null)
100
-							echo '<p>Status: '.$row["status"] .'</p><br>';
101
-						if($key=='education' and $value!=null)
102
-							echo '<p>Education: '.$row["education"] .'</p><br>';
103
-						if($key=='gender' and $value!=null)
104
-							echo '<p>Gender: 	'.$row["gender"] .'</p><br>';
95
+						if ($key == 'username' and $value != null)
96
+							echo '<p>Username: '.$row["username"].'</p><br>';
97
+						if ($key == 'email' and $value != null)
98
+							echo '<p>Email Id: '.$row["email"].'</p><br>';
99
+						if ($key == 'status' and $value != null)
100
+							echo '<p>Status: '.$row["status"].'</p><br>';
101
+						if ($key == 'education' and $value != null)
102
+							echo '<p>Education: '.$row["education"].'</p><br>';
103
+						if ($key == 'gender' and $value != null)
104
+							echo '<p>Gender: 	'.$row["gender"].'</p><br>';
105 105
 					}
106 106
 					?>
107 107
 				</div>	
108
-				<?php if($_SESSION['start']==$row['login_id'])
108
+				<?php if ($_SESSION['start'] == $row['login_id'])
109 109
 				{
110 110
 					?>
111 111
 				<div class="edit"><a href="#">Edit Profile</a></div>
@@ -115,7 +115,7 @@  discard block
 block discarded – undo
115 115
 			</div>	
116 116
 	
117 117
 			<?php 
118
-			if($_SESSION['start']==$row['login_id'])
118
+			if ($_SESSION['start'] == $row['login_id'])
119 119
 			{
120 120
 				?>
121 121
 		
@@ -126,8 +126,8 @@  discard block
 block discarded – undo
126 126
 					<label>Education : </label>
127 127
 					<input type="text" name="education" id="education" value="<?php echo $row['education']; ?>"></input>
128 128
 					<label>Gender : </label><br>
129
-					<input type="radio" name="gender" id="gender" value="Male" <?php echo ($row['gender']=='Male')?'checked':'' ?>> Male<br>
130
-					<input type="radio" name="gender" id="gender" value="Female" <?php echo ($row['gender']=='Female')?'checked':'' ?>> Female<br>
129
+					<input type="radio" name="gender" id="gender" value="Male" <?php echo ($row['gender'] == 'Male') ? 'checked' : '' ?>> Male<br>
130
+					<input type="radio" name="gender" id="gender" value="Female" <?php echo ($row['gender'] == 'Female') ? 'checked' : '' ?>> Female<br>
131 131
 					<input type="submit" name="submit" value="Done" id="submit">
132 132
 				</form>
133 133
 			</div>
Please login to merge, or discard this patch.
Braces   +21 added lines, -23 removed lines patch added patch discarded remove patch
@@ -22,9 +22,7 @@  discard block
 block discarded – undo
22 22
 		}
23 23
 	}
24 24
 
25
-}
26
-
27
-else if($user)
25
+} else if($user)
28 26
 {
29 27
 	$query="SELECT * from login where username='$user'";
30 28
 	if($result=$connect->query($query))
@@ -42,8 +40,7 @@  discard block
 block discarded – undo
42 40
 					$row=array_merge($row,$r);
43 41
 					// var_dump($row);
44 42
 				}
45
-			}
46
-			else
43
+			} else
47 44
 			{
48 45
 				die("error");
49 46
 			}
@@ -67,8 +64,7 @@  discard block
 block discarded – undo
67 64
 				<li><a href="../message.php">Message</a></li>
68 65
 				<li><a href="../registration-module/source/class.logout.php">Log out</a></li>
69 66
 				<?php 
70
-				}
71
-				else
67
+				} else
72 68
 				{
73 69
 				?>
74 70
 				<li><a href="../login.php">Login</a></li>
@@ -92,16 +88,21 @@  discard block
 block discarded – undo
92 88
 				<div class="brief">
93 89
 					<h1 id="name">Name: <?php echo $row['name']; ?></h1><br>
94 90
 					<?php foreach ($row as $key => $value) {
95
-						if($key=='username' and $value!=null)
96
-							echo '<p>Username: '.$row["username"] .'</p><br>';
97
-						if($key=='email' and $value!=null)
98
-							echo '<p>Email Id: '.$row["email"] .'</p><br>';
99
-						if($key=='status' and $value!=null)
100
-							echo '<p>Status: '.$row["status"] .'</p><br>';
101
-						if($key=='education' and $value!=null)
102
-							echo '<p>Education: '.$row["education"] .'</p><br>';
103
-						if($key=='gender' and $value!=null)
104
-							echo '<p>Gender: 	'.$row["gender"] .'</p><br>';
91
+						if($key=='username' and $value!=null) {
92
+													echo '<p>Username: '.$row["username"] .'</p><br>';
93
+						}
94
+						if($key=='email' and $value!=null) {
95
+													echo '<p>Email Id: '.$row["email"] .'</p><br>';
96
+						}
97
+						if($key=='status' and $value!=null) {
98
+													echo '<p>Status: '.$row["status"] .'</p><br>';
99
+						}
100
+						if($key=='education' and $value!=null) {
101
+													echo '<p>Education: '.$row["education"] .'</p><br>';
102
+						}
103
+						if($key=='gender' and $value!=null) {
104
+													echo '<p>Gender: 	'.$row["gender"] .'</p><br>';
105
+						}
105 106
 					}
106 107
 					?>
107 108
 				</div>	
@@ -152,18 +153,15 @@  discard block
 block discarded – undo
152 153
 
153 154
 
154 155
 <?php
155
-		}
156
-		else
156
+		} else
157 157
 		{
158 158
 			die("Invalid User");
159 159
 		}
160
-	}
161
-	else
160
+	} else
162 161
 	{
163 162
 		die("invalid");
164 163
 	}
165
-}
166
-else
164
+} else
167 165
 {
168 166
 	header("Location:http://localhost/openchat/index.php");
169 167
 }
Please login to merge, or discard this patch.
src/Compose.php 2 patches
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3 3
 namespace ChatApp;
4
-require_once (dirname(__DIR__) . '/database.php');
4
+require_once (dirname(__DIR__).'/database.php');
5 5
 
6 6
 /**
7 7
 *
@@ -23,18 +23,18 @@  discard block
 block discarded – undo
23 23
     public function SelectUser($msg)
24 24
     {
25 25
         $msg = $msg->value;
26
-        if(isset($_SESSION['start']) && isset($msg))
26
+        if (isset($_SESSION['start']) && isset($msg))
27 27
         {
28 28
             $id = $_SESSION['start'];
29 29
             $suggestion = trim($msg);
30
-            if($suggestion != "" )
30
+            if ($suggestion != "")
31 31
             {
32 32
                 $query = "SELECT * FROM login where login_id != '$id' and name like '$suggestion%' ORDER BY name DESC";
33
-                if($result = $this->connect->query($query))
33
+                if ($result = $this->connect->query($query))
34 34
                 {
35
-                    if($result->num_rows > 0)
35
+                    if ($result->num_rows > 0)
36 36
                     {
37
-                        while($row = $result->fetch_assoc())
37
+                        while ($row = $result->fetch_assoc())
38 38
                         {
39 39
                             $this->array = array_merge($this->array, [$row]);
40 40
                         }
Please login to merge, or discard this patch.
Braces   +3 added lines, -6 removed lines patch added patch discarded remove patch
@@ -40,18 +40,15 @@
 block discarded – undo
40 40
                         }
41 41
                         $this->array = array_merge([], ["Compose" => $this->array]);
42 42
                         return json_encode($this->array);
43
-                    }
44
-                    else
43
+                    } else
45 44
                     {
46 45
                         return json_encode(["Compose" => "Not Found"]);
47 46
                     }
48
-                }
49
-                else
47
+                } else
50 48
                 {
51 49
                     return json_encode(["Compose" => "Query Failed"]);
52 50
                 }
53
-            }
54
-            else
51
+            } else
55 52
             {
56 53
                 return json_encode(["Compose" => "Not Found"]);
57 54
             }
Please login to merge, or discard this patch.
src/Time.php 2 patches
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -16,14 +16,14 @@
 block discarded – undo
16 16
     function TimeConversion($time)
17 17
     {
18 18
 
19
-        if(substr($time,4,11) == date("d M Y", time() + 16200))
20
-            $time = substr($time,16,5);
21
-        else if(substr($time,7,8) == date("M Y", time() + 16200) && substr($time, 4,2) - date("d") < 7)
22
-            $time = substr($time,0,3);
23
-        else if(substr($time,11,4) == date("Y", time() + 16200))
24
-            $time = substr($time,4,6);
19
+        if (substr($time, 4, 11) == date("d M Y", time() + 16200))
20
+            $time = substr($time, 16, 5);
21
+        else if (substr($time, 7, 8) == date("M Y", time() + 16200) && substr($time, 4, 2) - date("d") < 7)
22
+            $time = substr($time, 0, 3);
23
+        else if (substr($time, 11, 4) == date("Y", time() + 16200))
24
+            $time = substr($time, 4, 6);
25 25
         else
26
-            $time = substr($time,4,11);
26
+            $time = substr($time, 4, 11);
27 27
 
28 28
         return $time;
29 29
     }
Please login to merge, or discard this patch.
Braces   +9 added lines, -8 removed lines patch added patch discarded remove patch
@@ -16,14 +16,15 @@
 block discarded – undo
16 16
     function TimeConversion($time)
17 17
     {
18 18
 
19
-        if(substr($time,4,11) == date("d M Y", time() + 16200))
20
-            $time = substr($time,16,5);
21
-        else if(substr($time,7,8) == date("M Y", time() + 16200) && substr($time, 4,2) - date("d") < 7)
22
-            $time = substr($time,0,3);
23
-        else if(substr($time,11,4) == date("Y", time() + 16200))
24
-            $time = substr($time,4,6);
25
-        else
26
-            $time = substr($time,4,11);
19
+        if(substr($time,4,11) == date("d M Y", time() + 16200)) {
20
+                    $time = substr($time,16,5);
21
+        } else if(substr($time,7,8) == date("M Y", time() + 16200) && substr($time, 4,2) - date("d") < 7) {
22
+                    $time = substr($time,0,3);
23
+        } else if(substr($time,11,4) == date("Y", time() + 16200)) {
24
+                    $time = substr($time,4,6);
25
+        } else {
26
+                    $time = substr($time,4,11);
27
+        }
27 28
 
28 29
         return $time;
29 30
     }
Please login to merge, or discard this patch.
src/Models/message.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@
 block discarded – undo
8 8
 
9 9
 class Message extends Model
10 10
 {
11
-    protected $table='message';
11
+    protected $table = 'message';
12 12
 
13 13
     protected $fillable = ['identifier_message_number', 'message', 'sent_by', 'time'];
14 14
 }
Please login to merge, or discard this patch.
src/User.php 2 patches
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -2,7 +2,7 @@  discard block
 block discarded – undo
2 2
 
3 3
 
4 4
 namespace ChatApp;
5
-require_once (dirname(__DIR__) . '/database.php');
5
+require_once (dirname(__DIR__).'/database.php');
6 6
 
7 7
 /**
8 8
 * For retreiving User Information
@@ -21,12 +21,12 @@  discard block
 block discarded – undo
21 21
 
22 22
     function UserDetails($id, $para)
23 23
     {
24
-        if($para == True)
24
+        if ($para == True)
25 25
             $this->query = "SELECT * from login where login_id = '$id'";
26 26
         else
27 27
             $this->query = "SELECT * from login where username = '$id'";
28 28
         $this->result = $this->connect->query($this->query);
29
-        if($this->result->num_rows > 0)                   // if true
29
+        if ($this->result->num_rows > 0)                   // if true
30 30
         {
31 31
             $this->details = $this->result->fetch_assoc();
32 32
             return $this->details;
Please login to merge, or discard this patch.
Braces   +9 added lines, -7 removed lines patch added patch discarded remove patch
@@ -21,17 +21,19 @@
 block discarded – undo
21 21
 
22 22
     function UserDetails($id, $para)
23 23
     {
24
-        if($para == True)
25
-            $this->query = "SELECT * from login where login_id = '$id'";
26
-        else
27
-            $this->query = "SELECT * from login where username = '$id'";
24
+        if($para == True) {
25
+                    $this->query = "SELECT * from login where login_id = '$id'";
26
+        } else {
27
+                    $this->query = "SELECT * from login where username = '$id'";
28
+        }
28 29
         $this->result = $this->connect->query($this->query);
29
-        if($this->result->num_rows > 0)                   // if true
30
+        if($this->result->num_rows > 0) {
31
+            // if true
30 32
         {
31 33
             $this->details = $this->result->fetch_assoc();
32
-            return $this->details;
33 34
         }
34
-        else
35
+            return $this->details;
36
+        } else
35 37
         {
36 38
             return NULL;
37 39
         }
Please login to merge, or discard this patch.