Test Setup Failed
Push — master ( 15356d...37eca5 )
by Ankit
02:27
created
profile_generate.php 1 patch
Indentation   +29 added lines, -29 removed lines patch added patch discarded remove patch
@@ -5,36 +5,36 @@
 block discarded – undo
5 5
 $login_id=$_SESSION['start'];
6 6
 if(isset($_POST['submit']))
7 7
 {
8
-	$query="SELECT * from profile where login_id='$login_id'";
9
-	if($result=$connect->query($query))
10
-	{
11
-		if($result->num_rows>0)
12
-		{
13
-			$row=$result->fetch_assoc();
14
-		}
15
-	}
16
-	if(trim($_POST['status']))
17
-		$status=$_POST['status'];
18
-	else
19
-		$status=$row['status'];
20
-	if(trim($_POST['education']))
21
-		$edu=$_POST['education'];
22
-	else
23
-		$edu=$row['education'];
24
-	if(isset($_POST['gender']))
25
-		$gender=$_POST['gender'];
26
-	else
27
-		$gender=$row['gender'];
8
+    $query="SELECT * from profile where login_id='$login_id'";
9
+    if($result=$connect->query($query))
10
+    {
11
+        if($result->num_rows>0)
12
+        {
13
+            $row=$result->fetch_assoc();
14
+        }
15
+    }
16
+    if(trim($_POST['status']))
17
+        $status=$_POST['status'];
18
+    else
19
+        $status=$row['status'];
20
+    if(trim($_POST['education']))
21
+        $edu=$_POST['education'];
22
+    else
23
+        $edu=$row['education'];
24
+    if(isset($_POST['gender']))
25
+        $gender=$_POST['gender'];
26
+    else
27
+        $gender=$row['gender'];
28 28
 
29
-	$query="UPDATE profile set status='$status', education='$edu', gender='$gender' where login_id='$login_id'";
30
-	if($result=$connect->query($query))
31
-	{
32
-		header('Location: account.php');
33
-	}
34
-	else
35
-	{
36
-		die("error");
37
-	}
29
+    $query="UPDATE profile set status='$status', education='$edu', gender='$gender' where login_id='$login_id'";
30
+    if($result=$connect->query($query))
31
+    {
32
+        header('Location: account.php');
33
+    }
34
+    else
35
+    {
36
+        die("error");
37
+    }
38 38
 }
39 39
 
40 40
 ?>
41 41
\ No newline at end of file
Please login to merge, or discard this patch.
config/database.php 1 patch
Indentation   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -1,13 +1,13 @@  discard block
 block discarded – undo
1 1
 <?php
2
-  // Define database connection constants
3
-  define('DB_HOST', 'localhost');
4
-  define('DB_USER', 'root');
5
-  define('DB_PASSWORD','');
6
-  define('DB_NAME', 'openchat');
7
-  define('URL', URL());
2
+    // Define database connection constants
3
+    define('DB_HOST', 'localhost');
4
+    define('DB_USER', 'root');
5
+    define('DB_PASSWORD','');
6
+    define('DB_NAME', 'openchat');
7
+    define('URL', URL());
8 8
 
9
-   function URL()
10
-  {
9
+    function URL()
10
+    {
11 11
     $http = "http://";
12 12
     $host = $_SERVER['SERVER_NAME'];
13 13
     $port = $_SERVER['SERVER_PORT'];
@@ -18,5 +18,5 @@  discard block
 block discarded – undo
18 18
     }
19 19
     $url = $http.$host.":".$port.$fol;
20 20
     return $url;
21
-  }
21
+    }
22 22
 ?>
Please login to merge, or discard this patch.
message.php 1 patch
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -131,6 +131,6 @@
 block discarded – undo
131 131
 <?php
132 132
 }
133 133
 else{
134
-	header('Location:http://localhost/openchat');
134
+    header('Location:http://localhost/openchat');
135 135
 }
136 136
 ?>
Please login to merge, or discard this patch.
src/Validate.php 1 patch
Indentation   +28 added lines, -28 removed lines patch added patch discarded remove patch
@@ -4,35 +4,35 @@
 block discarded – undo
4 4
 
5 5
 class Validate
6 6
 {
7
-	protected $connect;
7
+    protected $connect;
8 8
 
9
-	public function __construct()
10
-	{
11
-		$this->connect = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME);
12
-	}
9
+    public function __construct()
10
+    {
11
+        $this->connect = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME);
12
+    }
13 13
 
14
-	public function validateEmailInDb($email)
15
-	{
16
-		$query = "SELECT login_id FROM login WHERE email = '$email'";
17
-		if ($result = $this->connect->query($query))
18
-		{
19
-			if ($result->num_rows > 0) {
20
-				return 1;
21
-			}
22
-			else
23
-				return 0;
24
-		}
25
-	}
14
+    public function validateEmailInDb($email)
15
+    {
16
+        $query = "SELECT login_id FROM login WHERE email = '$email'";
17
+        if ($result = $this->connect->query($query))
18
+        {
19
+            if ($result->num_rows > 0) {
20
+                return 1;
21
+            }
22
+            else
23
+                return 0;
24
+        }
25
+    }
26 26
 
27
-	function validateUsernameInDb($username)
28
-	{
29
-		$query = "SELECT login_id FROM login WHERE username = '$username'";
30
-		if ($result = $this->connect->query($query)) {
31
-			if ($result->num_rows > 0) {
32
-				return 1;
33
-			}
34
-			else
35
-				return 0;
36
-		}
37
-	}
27
+    function validateUsernameInDb($username)
28
+    {
29
+        $query = "SELECT login_id FROM login WHERE username = '$username'";
30
+        if ($result = $this->connect->query($query)) {
31
+            if ($result->num_rows > 0) {
32
+                return 1;
33
+            }
34
+            else
35
+                return 0;
36
+        }
37
+    }
38 38
 }
Please login to merge, or discard this patch.
ajax/validate_login.php 1 patch
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.
ajax/validate_register.php 1 patch
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.
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.
cmd.php 1 patch
Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -8,12 +8,12 @@
 block discarded – undo
8 8
 use ChatApp\Chat;
9 9
 
10 10
 $server =IoServer::factory(
11
-	new HttpServer(
12
-		new WsServer(
13
-			new Chat()
14
-			)
15
-		)
16
-	,
17
-	8080
18
-	);
11
+    new HttpServer(
12
+        new WsServer(
13
+            new Chat()
14
+            )
15
+        )
16
+    ,
17
+    8080
18
+    );
19 19
 $server->run();
Please login to merge, or discard this patch.