Test Setup Failed
Push — master ( f3ea8f...027aaa )
by Ankit
02:16
created
index.php 1 patch
Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -16,21 +16,21 @@
 block discarded – undo
16 16
 			<a id="brand" href="#">OpenChat</a>
17 17
 			<ul class="nav-right">
18 18
 				<?php if(isset($_SESSION['start']))
19
-				{
20
-				?>
19
+                {
20
+                ?>
21 21
 				<li><a href="account.php">Account</a></li>
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
27
-				{
28
-				?>
25
+                }
26
+                else
27
+                {
28
+                ?>
29 29
 				<li><a href="login.php">Login</a></li>
30 30
 				<li><a href="register.php">Register</a></li>
31 31
 				<?php
32
-				}
33
-				?>
32
+                }
33
+                ?>
34 34
 			</ul>
35 35
 		</div>
36 36
 
Please login to merge, or discard this patch.
cmd.php 1 patch
Indentation   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -8,16 +8,16 @@
 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();
20 20
 
21 21
 
22 22
 
23
- ?>
24 23
\ No newline at end of file
24
+    ?>
25 25
\ No newline at end of file
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://www.localhost/openchat/login.php');
134
+    header('Location:http://www.localhost/openchat/login.php');
135 135
 }
136 136
 ?>
Please login to merge, or discard this patch.
registration-module/ajax/validate_register.php 1 patch
Indentation   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -3,17 +3,17 @@
 block discarded – undo
3 3
 require_once '../source/class.register.php';
4 4
 if(isset($_POST['q']))
5 5
 {
6
-	$register_field=json_decode($_POST['q']);
7
-	$name=$register_field->name;
8
-	$email=$register_field->email;
9
-	$username=$register_field->username;
10
-	$mob=$register_field->mob;
11
-	$password=$register_field->password;
12
-	$ob = new register();
13
-	$result=$ob->_register($name,$email,$username,$password,$mob);
14
-	if(isset($result))
15
-		echo $result;
16
-	else
17
-		echo json_encode([]);
6
+    $register_field=json_decode($_POST['q']);
7
+    $name=$register_field->name;
8
+    $email=$register_field->email;
9
+    $username=$register_field->username;
10
+    $mob=$register_field->mob;
11
+    $password=$register_field->password;
12
+    $ob = new register();
13
+    $result=$ob->_register($name,$email,$username,$password,$mob);
14
+    if(isset($result))
15
+        echo $result;
16
+    else
17
+        echo json_encode([]);
18 18
 }
19 19
 ?>
20 20
\ No newline at end of file
Please login to merge, or discard this patch.
registration-module/ajax/validate_login.php 1 patch
Indentation   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -3,14 +3,14 @@
 block discarded – undo
3 3
 require_once '../source/class.login.php';
4 4
 if(isset($_POST['q']))
5 5
 {
6
-	$login_field=json_decode($_POST['q']);
7
-	$login=$login_field->login;
8
-	$password=$login_field->password;
9
-	$ob = new login();
10
-	$result=$ob->_login($login,$password);
11
-	if(isset($result))
12
-		echo $result;
13
-	else
14
-		echo json_encode([]);
6
+    $login_field=json_decode($_POST['q']);
7
+    $login=$login_field->login;
8
+    $password=$login_field->password;
9
+    $ob = new login();
10
+    $result=$ob->_login($login,$password);
11
+    if(isset($result))
12
+        echo $result;
13
+    else
14
+        echo json_encode([]);
15 15
 }
16 16
 ?>
17 17
\ No newline at end of file
Please login to merge, or discard this patch.
registration-module/source/class.register.php 1 patch
Indentation   +132 added lines, -132 removed lines patch added patch discarded remove patch
@@ -5,36 +5,36 @@  discard block
 block discarded – undo
5 5
 
6 6
 class register
7 7
 {
8
-	private $array_error;
9
-	private $name;
10
-	private $email;
11
-	private $username;
12
-	private $password;
13
-	private $mob;
14
-	private $key;
15
-	private $ob;
16
-	private $connect;
17
-
18
-	function __construct()
19
-	{
20
-		$this->array_error=array();
21
-		$this->key=0;
22
-		$this->connect = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME);
23
-		$this->ob=new validate();
24
-
25
-
26
-		$query="CREATE TABLE IF NOT EXISTS register (
8
+    private $array_error;
9
+    private $name;
10
+    private $email;
11
+    private $username;
12
+    private $password;
13
+    private $mob;
14
+    private $key;
15
+    private $ob;
16
+    private $connect;
17
+
18
+    function __construct()
19
+    {
20
+        $this->array_error=array();
21
+        $this->key=0;
22
+        $this->connect = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME);
23
+        $this->ob=new validate();
24
+
25
+
26
+        $query="CREATE TABLE IF NOT EXISTS register (
27 27
 			id int primary key auto_increment unique not null,
28 28
 			email varchar(255) unique not null,
29 29
 			username varchar(255) unique not null,
30 30
 			password varchar(255) not null
31 31
 			) ENGINE=INNODB;";
32 32
 
33
-		if (!$this->connect->query($query)) {
34
-			echo "Table is not created || Query failed";
35
-		}
33
+        if (!$this->connect->query($query)) {
34
+            echo "Table is not created || Query failed";
35
+        }
36 36
 
37
-			$query="CREATE TABLE IF NOT EXISTS login (
37
+            $query="CREATE TABLE IF NOT EXISTS login (
38 38
 			login_id int primary key not null,
39 39
 			name varchar(255) not null,
40 40
 			email varchar(255) unique not null,
@@ -44,121 +44,121 @@  discard block
 block discarded – undo
44 44
 			FOREIGN KEY (login_id) REFERENCES register(id)
45 45
 			) ENGINE=INNODB;";
46 46
 
47
-		if (!$this->connect->query($query)) {
48
-			echo "Table is not created || Query failed";
49
-		}
47
+        if (!$this->connect->query($query)) {
48
+            echo "Table is not created || Query failed";
49
+        }
50 50
 
51
-		$query="CREATE TABLE IF NOT EXISTS profile (
51
+        $query="CREATE TABLE IF NOT EXISTS profile (
52 52
 		login_id int primary key not null unique,
53 53
 		status text,
54 54
 		education text,
55 55
 		gender varchar(10)
56 56
 		) ENGINE=INNODB;";
57 57
 
58
-		if (!$this->connect->query($query)) {
59
-			echo "Table is not created || Query failed";
60
-		}
61
-
62
-	}
63
-
64
-	function _register($name,$email,$username,$password,$mob)
65
-	{
66
-		$this->name=trim($name);
67
-		$this->email=trim($email);
68
-		$this->username=trim($username);
69
-		$this->password=trim($password);
70
-		$this->mob=trim($mob);
71
-		if (empty($this->name)) {
72
-			$this->key=1;
73
-			$this->array_error=array_merge($this->array_error,["name"=>"Enter the name"]);
74
-		}
75
-
76
-		if(empty($this->email)) {
77
-			$this->key=1;
78
-			$this->array_error=array_merge($this->array_error,["email"=>"Enter the email address"]);
79
-		}
80
-		elseif(filter_var($this->email,FILTER_VALIDATE_EMAIL)== false) {
81
-			$this->key=1;
82
-			$this->array_error=array_merge($this->array_error,["email"=>"Enter correct Email address"]);
83
-		}
84
-		else
85
-		{
86
-			if($this->ob->validate_email_in_db($this->email))
87
-			{
88
-				$this->key=1;
89
-				$this->array_error=array_merge($this->array_error,["email"=>"Email is already registered"]);
90
-			}
91
-		}
92
-
93
-		if(empty($this->username)) {
94
-			$this->key=1;
95
-			$this->array_error=array_merge($this->array_error,["username"=>"Enter the username"]);
96
-		}
97
-		else
98
-		{
99
-			if($this->ob->validate_username_in_db($this->username))
100
-			{
101
-				$this->key=1;
102
-				$this->array_error=array_merge($this->array_error,["username"=>"Username is already registered"]);
103
-			}
104
-		}
105
-
106
-		if(empty($this->password)) {
107
-			$this->key=1;
108
-			$this->array_error=array_merge($this->array_error,["password"=>"Enter the password"]);
109
-		}
110
-
111
-		if(empty($this->mob)) {
112
-			$this->key=1;
113
-			$this->array_error=array_merge($this->array_error,["mob"=>"Enter the Mobile Number"]);
114
-		}
115
-		elseif (!preg_match("/^[0-9]{10}$/",$this->mob)) {
116
-			$this->key=1;
117
-			$this->array_error=array_merge($this->array_error,["mob"=>"Enter correct Mobile Number"]);
118
-		}
119
-
120
-		if($this->key==1)
121
-		{
122
-			return json_encode($this->array_error);
123
-		}
124
-		else
125
-		{
126
-			$this->key=0;
127
-			$pass=md5($this->password);
128
-			$query="INSERT INTO register VALUES(null,'$this->email','$this->username','$pass')";
129
-			if(!$this->connect->query($query)) {
130
-				$this->key=1;
131
-				echo "You are not registered || Error in registration2";
132
-			}
133
-			else
134
-			{
135
-				$query="SELECT id FROM register WHERE email='$this->email'";
136
-				if($result=$this->connect->query($query)) {
137
-					$row=$result->fetch_assoc();
138
-					$id=$row['id'];
139
-
140
-					$query="INSERT INTO login VALUES('$id','$this->name','$this->email','$this->username','$this->mob','1')";
141
-					if(!$this->connect->query($query)) {
142
-						$this->key=1;
143
-						echo "You are not registered || Error in registration1";
144
-					}
145
-					$join="Joined OpenChat";
146
-					$query="INSERT INTO profile VALUES('$id','$join','$join','')";
147
-					if(!$this->connect->query($query)) {
148
-						$this->key=1;
149
-						echo "You are not updated || Error in profile";
150
-					}
151
-				}
152
-			}
153
-		}
154
-		if ($this->key==0) {
155
-			$_SESSION['start']=$id;
156
-			return json_encode(["location"=>"http://localhost/openchat/account.php"]);
157
-		}
158
-		else
159
-		{
160
-			return json_encode($this->array_error);
161
-		}
162
-	}
58
+        if (!$this->connect->query($query)) {
59
+            echo "Table is not created || Query failed";
60
+        }
61
+
62
+    }
63
+
64
+    function _register($name,$email,$username,$password,$mob)
65
+    {
66
+        $this->name=trim($name);
67
+        $this->email=trim($email);
68
+        $this->username=trim($username);
69
+        $this->password=trim($password);
70
+        $this->mob=trim($mob);
71
+        if (empty($this->name)) {
72
+            $this->key=1;
73
+            $this->array_error=array_merge($this->array_error,["name"=>"Enter the name"]);
74
+        }
75
+
76
+        if(empty($this->email)) {
77
+            $this->key=1;
78
+            $this->array_error=array_merge($this->array_error,["email"=>"Enter the email address"]);
79
+        }
80
+        elseif(filter_var($this->email,FILTER_VALIDATE_EMAIL)== false) {
81
+            $this->key=1;
82
+            $this->array_error=array_merge($this->array_error,["email"=>"Enter correct Email address"]);
83
+        }
84
+        else
85
+        {
86
+            if($this->ob->validate_email_in_db($this->email))
87
+            {
88
+                $this->key=1;
89
+                $this->array_error=array_merge($this->array_error,["email"=>"Email is already registered"]);
90
+            }
91
+        }
92
+
93
+        if(empty($this->username)) {
94
+            $this->key=1;
95
+            $this->array_error=array_merge($this->array_error,["username"=>"Enter the username"]);
96
+        }
97
+        else
98
+        {
99
+            if($this->ob->validate_username_in_db($this->username))
100
+            {
101
+                $this->key=1;
102
+                $this->array_error=array_merge($this->array_error,["username"=>"Username is already registered"]);
103
+            }
104
+        }
105
+
106
+        if(empty($this->password)) {
107
+            $this->key=1;
108
+            $this->array_error=array_merge($this->array_error,["password"=>"Enter the password"]);
109
+        }
110
+
111
+        if(empty($this->mob)) {
112
+            $this->key=1;
113
+            $this->array_error=array_merge($this->array_error,["mob"=>"Enter the Mobile Number"]);
114
+        }
115
+        elseif (!preg_match("/^[0-9]{10}$/",$this->mob)) {
116
+            $this->key=1;
117
+            $this->array_error=array_merge($this->array_error,["mob"=>"Enter correct Mobile Number"]);
118
+        }
119
+
120
+        if($this->key==1)
121
+        {
122
+            return json_encode($this->array_error);
123
+        }
124
+        else
125
+        {
126
+            $this->key=0;
127
+            $pass=md5($this->password);
128
+            $query="INSERT INTO register VALUES(null,'$this->email','$this->username','$pass')";
129
+            if(!$this->connect->query($query)) {
130
+                $this->key=1;
131
+                echo "You are not registered || Error in registration2";
132
+            }
133
+            else
134
+            {
135
+                $query="SELECT id FROM register WHERE email='$this->email'";
136
+                if($result=$this->connect->query($query)) {
137
+                    $row=$result->fetch_assoc();
138
+                    $id=$row['id'];
139
+
140
+                    $query="INSERT INTO login VALUES('$id','$this->name','$this->email','$this->username','$this->mob','1')";
141
+                    if(!$this->connect->query($query)) {
142
+                        $this->key=1;
143
+                        echo "You are not registered || Error in registration1";
144
+                    }
145
+                    $join="Joined OpenChat";
146
+                    $query="INSERT INTO profile VALUES('$id','$join','$join','')";
147
+                    if(!$this->connect->query($query)) {
148
+                        $this->key=1;
149
+                        echo "You are not updated || Error in profile";
150
+                    }
151
+                }
152
+            }
153
+        }
154
+        if ($this->key==0) {
155
+            $_SESSION['start']=$id;
156
+            return json_encode(["location"=>"http://localhost/openchat/account.php"]);
157
+        }
158
+        else
159
+        {
160
+            return json_encode($this->array_error);
161
+        }
162
+    }
163 163
 }
164 164
 ?>
165 165
\ No newline at end of file
Please login to merge, or discard this patch.
registration-module/source/class.logout.php 1 patch
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -15,6 +15,6 @@
 block discarded – undo
15 15
 }
16 16
 else
17 17
 {
18
-	echo "Please Login";
18
+    echo "Please Login";
19 19
 }
20 20
 ?>
Please login to merge, or discard this patch.
registration-module/source/class.validate.php 1 patch
Indentation   +36 added lines, -36 removed lines patch added patch discarded remove patch
@@ -3,23 +3,23 @@  discard block
 block discarded – undo
3 3
 require_once 'database.php';
4 4
 class validate
5 5
 {
6
-	private $connect;
7
-	function __construct()
8
-	{
9
-		$this->connect = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME);
6
+    private $connect;
7
+    function __construct()
8
+    {
9
+        $this->connect = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME);
10 10
 
11
-		$query="CREATE TABLE IF NOT EXISTS register (
11
+        $query="CREATE TABLE IF NOT EXISTS register (
12 12
 			id int primary key auto_increment unique not null,
13 13
 			email varchar(255) unique not null,
14 14
 			username varchar(255) unique not null,
15 15
 			password varchar(255) not null
16 16
 			) ENGINE=INNODB;";
17 17
 
18
-		if (!$this->connect->query($query)) {
19
-			echo "Table is not created || Query failed";
20
-		}
18
+        if (!$this->connect->query($query)) {
19
+            echo "Table is not created || Query failed";
20
+        }
21 21
 
22
-			$query="CREATE TABLE IF NOT EXISTS login (
22
+            $query="CREATE TABLE IF NOT EXISTS login (
23 23
 			login_id int primary key not null,
24 24
 			name varchar(255) not null,
25 25
 			email varchar(255) unique not null,
@@ -28,34 +28,34 @@  discard block
 block discarded – undo
28 28
 			FOREIGN KEY (login_id) REFERENCES register(id)
29 29
 			) ENGINE=INNODB;";
30 30
 		
31
-		if (!$this->connect->query($query)) {
32
-			echo "Table is not created || Query failed";
33
-		}	
34
-	}
31
+        if (!$this->connect->query($query)) {
32
+            echo "Table is not created || Query failed";
33
+        }	
34
+    }
35 35
 	
36
-	function validate_email_in_db($email)
37
-	{
38
-		$query="SELECT login_id FROM login WHERE email='$email'";
39
-		if ($result=$this->connect->query($query)) 
40
-		{
41
-			if ($result->num_rows>0) {
42
-				return 1;
43
-			}
44
-			else
45
-				return 0;
46
-		}
47
-	}
36
+    function validate_email_in_db($email)
37
+    {
38
+        $query="SELECT login_id FROM login WHERE email='$email'";
39
+        if ($result=$this->connect->query($query)) 
40
+        {
41
+            if ($result->num_rows>0) {
42
+                return 1;
43
+            }
44
+            else
45
+                return 0;
46
+        }
47
+    }
48 48
 
49
-	function validate_username_in_db($username)
50
-	{
51
-		$query="SELECT login_id FROM login WHERE username='$username'";
52
-		if ($result=$this->connect->query($query)) {
53
-			if ($result->num_rows>0) {
54
-				return 1;
55
-			}
56
-			else
57
-				return 0;
49
+    function validate_username_in_db($username)
50
+    {
51
+        $query="SELECT login_id FROM login WHERE username='$username'";
52
+        if ($result=$this->connect->query($query)) {
53
+            if ($result->num_rows>0) {
54
+                return 1;
55
+            }
56
+            else
57
+                return 0;
58 58
 			
59
-		}
60
-	}
59
+        }
60
+    }
61 61
 }
62 62
\ No newline at end of file
Please login to merge, or discard this patch.
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.