Test Setup Failed
Push — master ( 976b69...15356d )
by Ankit
02:31
created
src/Register.php 3 patches
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -3,7 +3,7 @@  discard block
 block discarded – undo
3 3
 namespace ChatApp;
4 4
 use ChatApp\Validate;
5 5
 use ChatApp\Session;
6
-require_once (dirname(__DIR__) . '/config/database.php');
6
+require_once (dirname(__DIR__).'/config/database.php');
7 7
 
8 8
 class Register
9 9
 {
@@ -36,45 +36,45 @@  discard block
 block discarded – undo
36 36
 			$this->onError(["name" => " *Enter the name"]);
37 37
 		}
38 38
 
39
-		if(empty($email)) {
39
+		if (empty($email)) {
40 40
 			$this->onError(["email" => " *Enter the email address"]);
41 41
 		}
42
-		elseif(filter_var($email, FILTER_VALIDATE_EMAIL) == false) {
42
+		elseif (filter_var($email, FILTER_VALIDATE_EMAIL) == false) {
43 43
 			$this->onError(["email" => " *Enter correct Email address"]);
44 44
 		}
45 45
 		else
46 46
 		{
47
-			if($this->obValidate->validateEmailInDb($email) === 1)
47
+			if ($this->obValidate->validateEmailInDb($email) === 1)
48 48
 			{
49 49
 
50 50
 				$this->onError(["email" => " *Email is already registered"]);
51 51
 			}
52 52
 		}
53 53
 
54
-		if(empty($username)) {
54
+		if (empty($username)) {
55 55
 			$this->onError(["username" => " *Enter the username"]);
56 56
 		}
57 57
 		else
58 58
 		{
59
-			if($this->obValidate->validateUsernameInDb($username) === 1)
59
+			if ($this->obValidate->validateUsernameInDb($username) === 1)
60 60
 			{
61 61
 
62 62
 				$this->onError(["username" => " *Username is already registered"]);
63 63
 			}
64 64
 		}
65 65
 
66
-		if(empty($password)) {
66
+		if (empty($password)) {
67 67
 			$this->onError(["password" => " *Enter the password"]);
68 68
 		}
69 69
 
70
-		if(empty($mob)) {
70
+		if (empty($mob)) {
71 71
 			$this->onError(["mob" => " *Enter the Mobile Number"]);
72 72
 		}
73 73
 		elseif (!preg_match("/^[0-9]{10}$/", $mob)) {
74 74
 			$this->onError(["mob" => " *Enter correct Mobile Number"]);
75 75
 		}
76 76
 
77
-		if($this->key == 1)
77
+		if ($this->key == 1)
78 78
 		{
79 79
 			return json_encode($this->error);
80 80
 		}
@@ -83,19 +83,19 @@  discard block
 block discarded – undo
83 83
 			$this->key = 0;
84 84
 			$pass = md5($password);
85 85
 			$query = "INSERT INTO register VALUES(null, '$email', '$username', '$pass')";
86
-			if(!$this->connect->query($query)) {
86
+			if (!$this->connect->query($query)) {
87 87
 				$this->key = 1;
88 88
 				echo "You are not registered || Error in registration2";
89 89
 			}
90 90
 			else
91 91
 			{
92 92
 				$query = "SELECT id FROM register WHERE email = '$email'";
93
-				if($result = $this->connect->query($query)) {
93
+				if ($result = $this->connect->query($query)) {
94 94
 					$row = $result->fetch_assoc();
95 95
 					$userId = $row['id'];
96 96
 
97 97
 					$query = "INSERT INTO login VALUES('$userId', '$name', '$email', '$username', '$mob', 0)";
98
-					if(!$this->connect->query($query)) {
98
+					if (!$this->connect->query($query)) {
99 99
 						$this->key = 1;
100 100
 						echo "You are not registered || Error in registration1";
101 101
 					}
Please login to merge, or discard this patch.
Braces   +7 added lines, -14 removed lines patch added patch discarded remove patch
@@ -38,11 +38,9 @@  discard block
 block discarded – undo
38 38
 
39 39
 		if(empty($email)) {
40 40
 			$this->onError(["email" => " *Enter the email address"]);
41
-		}
42
-		elseif(filter_var($email, FILTER_VALIDATE_EMAIL) == false) {
41
+		} elseif(filter_var($email, FILTER_VALIDATE_EMAIL) == false) {
43 42
 			$this->onError(["email" => " *Enter correct Email address"]);
44
-		}
45
-		else
43
+		} else
46 44
 		{
47 45
 			if($this->obValidate->validateEmailInDb($email) === 1)
48 46
 			{
@@ -53,8 +51,7 @@  discard block
 block discarded – undo
53 51
 
54 52
 		if(empty($username)) {
55 53
 			$this->onError(["username" => " *Enter the username"]);
56
-		}
57
-		else
54
+		} else
58 55
 		{
59 56
 			if($this->obValidate->validateUsernameInDb($username) === 1)
60 57
 			{
@@ -69,16 +66,14 @@  discard block
 block discarded – undo
69 66
 
70 67
 		if(empty($mob)) {
71 68
 			$this->onError(["mob" => " *Enter the Mobile Number"]);
72
-		}
73
-		elseif (!preg_match("/^[0-9]{10}$/", $mob)) {
69
+		} elseif (!preg_match("/^[0-9]{10}$/", $mob)) {
74 70
 			$this->onError(["mob" => " *Enter correct Mobile Number"]);
75 71
 		}
76 72
 
77 73
 		if($this->key == 1)
78 74
 		{
79 75
 			return json_encode($this->error);
80
-		}
81
-		else
76
+		} else
82 77
 		{
83 78
 			$this->key = 0;
84 79
 			$pass = md5($password);
@@ -86,8 +81,7 @@  discard block
 block discarded – undo
86 81
 			if(!$this->connect->query($query)) {
87 82
 				$this->key = 1;
88 83
 				echo "You are not registered || Error in registration2";
89
-			}
90
-			else
84
+			} else
91 85
 			{
92 86
 				$query = "SELECT id FROM register WHERE email = '$email'";
93 87
 				if($result = $this->connect->query($query)) {
@@ -107,8 +101,7 @@  discard block
 block discarded – undo
107 101
 			return json_encode([
108 102
 				"location" => URL."/account.php"
109 103
 			]);
110
-		}
111
-		else
104
+		} else
112 105
 		{
113 106
 			return json_encode($this->error);
114 107
 		}
Please login to merge, or discard this 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.
src/Online.php 1 patch
Spacing   +3 added lines, -3 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__) . '/config/database.php');
4
+require_once (dirname(__DIR__).'/config/database.php');
5 5
 
6 6
 /**
7 7
 * For checking online status
@@ -13,7 +13,7 @@  discard block
 block discarded – undo
13 13
     {
14 14
         $connect = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME);
15 15
         $query = "Update login set login_status = 1 where login_id = '$userId'";
16
-        if(!$connect->query($query));
16
+        if (!$connect->query($query));
17 17
             echo $connect->error;
18 18
         $connect->close();
19 19
     }
@@ -22,7 +22,7 @@  discard block
 block discarded – undo
22 22
     {
23 23
         $connect = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME);
24 24
         $query = "Update login set login_status = 0 where login_id = '$userId'";
25
-        if(!$connect->query($query));
25
+        if (!$connect->query($query));
26 26
             echo $connect->error;
27 27
         $connect->close();
28 28
     }
Please login to merge, or discard this patch.
src/Profile.php 2 patches
Spacing   +2 added lines, -2 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__) . '/config/database.php');
4
+require_once (dirname(__DIR__).'/config/database.php');
5 5
 
6 6
 /**
7 7
 * For retreiving User Profile
@@ -14,7 +14,7 @@  discard block
 block discarded – undo
14 14
         $connect = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME);
15 15
         $query = "SELECT * from profile where login_id = '$userId'";
16 16
         $result = $connect->query($query);
17
-        if($result->num_rows > 0)                   // if true
17
+        if ($result->num_rows > 0)                   // if true
18 18
         {
19 19
             $details = $result->fetch_assoc();
20 20
             return $details;
Please login to merge, or discard this patch.
Braces   +4 added lines, -3 removed lines patch added patch discarded remove patch
@@ -14,12 +14,13 @@
 block discarded – undo
14 14
         $connect = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME);
15 15
         $query = "SELECT * from profile where login_id = '$userId'";
16 16
         $result = $connect->query($query);
17
-        if($result->num_rows > 0)                   // if true
17
+        if($result->num_rows > 0) {
18
+            // if true
18 19
         {
19 20
             $details = $result->fetch_assoc();
20
-            return $details;
21 21
         }
22
-        else
22
+            return $details;
23
+        } else
23 24
         {
24 25
             return NULL;
25 26
         }
Please login to merge, or discard this patch.
logout.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -1,9 +1,9 @@
 block discarded – undo
1 1
 <?php
2 2
 
3
-require (__DIR__ . '/vendor/autoload.php');
3
+require (__DIR__.'/vendor/autoload.php');
4 4
 use ChatApp\Session;
5 5
 
6
-if(Session::get('start') != null)
6
+if (Session::get('start') != null)
7 7
 {
8 8
     Session::forget('start');
9 9
     header('Location: index.php');
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -12,8 +12,7 @@
 block discarded – undo
12 12
         header('Location: ../../index.php');
13 13
     }
14 14
 
15
-}
16
-else
15
+} else
17 16
 {
18 17
 	echo "Please Login";
19 18
 }
Please login to merge, or discard this patch.
ajax/validate_login.php 3 patches
Indentation   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -5,13 +5,13 @@
 block discarded – undo
5 5
 
6 6
 if(isset($_POST['q']))
7 7
 {
8
-	$loginField = json_decode($_POST['q']);
9
-	$login = $loginField->login;
10
-	$password = $loginField->password;
11
-	$obLogin = new Login();
12
-	$result = $obLogin->authLogin($login, $password);
13
-	if(isset($result))
14
-		echo $result;
15
-	else
16
-		echo json_encode([]);
8
+    $loginField = json_decode($_POST['q']);
9
+    $login = $loginField->login;
10
+    $password = $loginField->password;
11
+    $obLogin = new Login();
12
+    $result = $obLogin->authLogin($login, $password);
13
+    if(isset($result))
14
+        echo $result;
15
+    else
16
+        echo json_encode([]);
17 17
 }
18 18
\ No newline at end of file
Please login to merge, or discard this patch.
Braces   +6 added lines, -5 removed lines patch added patch discarded remove patch
@@ -10,8 +10,9 @@
 block discarded – undo
10 10
 	$password = $loginField->password;
11 11
 	$obLogin = new Login();
12 12
 	$result = $obLogin->authLogin($login, $password);
13
-	if(isset($result))
14
-		echo $result;
15
-	else
16
-		echo json_encode([]);
17
-}
18 13
\ No newline at end of file
14
+	if(isset($result)) {
15
+			echo $result;
16
+	} else {
17
+			echo json_encode([]);
18
+	}
19
+	}
19 20
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -1,9 +1,9 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-require (dirname(__DIR__) . '/vendor/autoload.php');
3
+require (dirname(__DIR__).'/vendor/autoload.php');
4 4
 use ChatApp\Register;
5 5
 
6
-if(isset($_POST['q']))
6
+if (isset($_POST['q']))
7 7
 {
8 8
 	$registerField = json_decode($_POST['q']);
9 9
 	$name = $registerField->name;
@@ -13,7 +13,7 @@  discard block
 block discarded – undo
13 13
 	$password = $registerField->password;
14 14
 	$obRegister = new Register();
15 15
 	$result = $obRegister->authRegister($name, $email, $username, $password, $mob);
16
-	if(isset($result))
16
+	if (isset($result))
17 17
 		echo $result;
18 18
 	else
19 19
 		echo json_encode([]);
Please login to merge, or discard this patch.
ajax/validate_register.php 3 patches
Indentation   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -5,17 +5,17 @@
 block discarded – undo
5 5
 
6 6
 if(isset($_POST['q']))
7 7
 {
8
-	$registerField = json_decode($_POST['q']);
9
-	$name = $registerField->name;
10
-	$email = $registerField->email;
11
-	$username = $registerField->username;
12
-	$mob = $registerField->mob;
13
-	$password = $registerField->password;
14
-	$obRegister = new Register();
15
-	$result = $obRegister->authRegister($name, $email, $username, $password, $mob);
16
-	if(isset($result))
17
-		echo $result;
18
-	else
19
-		echo json_encode([]);
8
+    $registerField = json_decode($_POST['q']);
9
+    $name = $registerField->name;
10
+    $email = $registerField->email;
11
+    $username = $registerField->username;
12
+    $mob = $registerField->mob;
13
+    $password = $registerField->password;
14
+    $obRegister = new Register();
15
+    $result = $obRegister->authRegister($name, $email, $username, $password, $mob);
16
+    if(isset($result))
17
+        echo $result;
18
+    else
19
+        echo json_encode([]);
20 20
 }
21 21
 
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -1,9 +1,9 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-require (dirname(__DIR__) . '/vendor/autoload.php');
3
+require (dirname(__DIR__).'/vendor/autoload.php');
4 4
 use ChatApp\Register;
5 5
 
6
-if(isset($_POST['q']))
6
+if (isset($_POST['q']))
7 7
 {
8 8
 	$registerField = json_decode($_POST['q']);
9 9
 	$name = $registerField->name;
@@ -13,7 +13,7 @@  discard block
 block discarded – undo
13 13
 	$password = $registerField->password;
14 14
 	$obRegister = new Register();
15 15
 	$result = $obRegister->authRegister($name, $email, $username, $password, $mob);
16
-	if(isset($result))
16
+	if (isset($result))
17 17
 		echo $result;
18 18
 	else
19 19
 		echo json_encode([]);
Please login to merge, or discard this patch.
Braces   +6 added lines, -5 removed lines patch added patch discarded remove patch
@@ -13,9 +13,10 @@
 block discarded – undo
13 13
 	$password = $registerField->password;
14 14
 	$obRegister = new Register();
15 15
 	$result = $obRegister->authRegister($name, $email, $username, $password, $mob);
16
-	if(isset($result))
17
-		echo $result;
18
-	else
19
-		echo json_encode([]);
20
-}
16
+	if(isset($result)) {
17
+			echo $result;
18
+	} else {
19
+			echo json_encode([]);
20
+	}
21
+	}
21 22
 
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.