Test Setup Failed
Branch master (f3ea8f)
by Ankit
03:00
created
database.php 1 patch
Indentation   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@
 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');
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 7
 ?>
Please login to merge, or discard this patch.
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.
account.php 1 patch
Indentation   +72 added lines, -72 removed lines patch added patch discarded remove patch
@@ -10,43 +10,43 @@  discard block
 block discarded – undo
10 10
 // var_dump($user);
11 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))
16
-	{
17
-		if($result->num_rows >0)
18
-		{
19
-			$row=$result->fetch_assoc();
20
-			$location="http://localhost/openchat/account.php/".$row['username'];
21
-			header("Location:".$location);
22
-		}
23
-	}
13
+    $login_id=$_SESSION['start'];
14
+    $query="SELECT username from login where login_id='$login_id'";
15
+    if($result=$connect->query($query))
16
+    {
17
+        if($result->num_rows >0)
18
+        {
19
+            $row=$result->fetch_assoc();
20
+            $location="http://localhost/openchat/account.php/".$row['username'];
21
+            header("Location:".$location);
22
+        }
23
+    }
24 24
 
25 25
 }
26 26
 
27 27
 else if($user)
28 28
 {
29
-	$query="SELECT * from login where username='$user'";
30
-	if($result=$connect->query($query))
31
-	{
32
-		if($result->num_rows >0)
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))
38
-			{
39
-				if($result->num_rows>0)
40
-				{
41
-					$r=$result->fetch_assoc();
42
-					$row=array_merge($row,$r);
43
-					// var_dump($row);
44
-				}
45
-			}
46
-			else
47
-			{
48
-				die("error");
49
-			}
29
+    $query="SELECT * from login where username='$user'";
30
+    if($result=$connect->query($query))
31
+    {
32
+        if($result->num_rows >0)
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))
38
+            {
39
+                if($result->num_rows>0)
40
+                {
41
+                    $r=$result->fetch_assoc();
42
+                    $row=array_merge($row,$r);
43
+                    // var_dump($row);
44
+                }
45
+            }
46
+            else
47
+            {
48
+                die("error");
49
+            }
50 50
 ?>
51 51
 	<head>
52 52
 		<title>OpenChat || Profile</title>
@@ -62,20 +62,20 @@  discard block
 block discarded – undo
62 62
             <ul class="nav-right">
63 63
                 <li><a href="../index.php">About</a></li>
64 64
                 <?php if(isset($_SESSION['start']))
65
-				{
66
-				?>
65
+                {
66
+                ?>
67 67
 				<li><a href="../message.php">Message</a></li>
68 68
 				<li><a href="../registration-module/source/class.logout.php">Log out</a></li>
69 69
 				<?php 
70
-				}
71
-				else
72
-				{
73
-				?>
70
+                }
71
+                else
72
+                {
73
+                ?>
74 74
 				<li><a href="../login.php">Login</a></li>
75 75
 				<li><a href="../register.php">Register</a></li>
76 76
 				<?php
77
-				}
78
-				?>
77
+                }
78
+                ?>
79 79
             </ul>
80 80
         </div>
81 81
 			
@@ -92,32 +92,32 @@  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>';
105
-					}
106
-					?>
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
+                    }
106
+                    ?>
107 107
 				</div>	
108 108
 				<?php if($_SESSION['start']==$row['login_id'])
109
-				{
110
-					?>
109
+                {
110
+                    ?>
111 111
 				<div class="edit"><a href="#">Edit Profile</a></div>
112 112
 				<?php
113
-				}
114
-				?>	
113
+                }
114
+                ?>	
115 115
 			</div>	
116 116
 	
117 117
 			<?php 
118
-			if($_SESSION['start']==$row['login_id'])
119
-			{
120
-				?>
118
+            if($_SESSION['start']==$row['login_id'])
119
+            {
120
+                ?>
121 121
 		
122 122
 			<div class="boxx" id="profile">
123 123
 				<form method="post" action="../profile_generate.php">
@@ -132,8 +132,8 @@  discard block
 block discarded – undo
132 132
 				</form>
133 133
 			</div>
134 134
 			<?php
135
-			}
136
-			?>
135
+            }
136
+            ?>
137 137
 		</div>
138 138
 
139 139
 
@@ -152,20 +152,20 @@  discard block
 block discarded – undo
152 152
 
153 153
 
154 154
 <?php
155
-		}
156
-		else
157
-		{
158
-			die("Invalid User");
159
-		}
160
-	}
161
-	else
162
-	{
163
-		die("invalid");
164
-	}
155
+        }
156
+        else
157
+        {
158
+            die("Invalid User");
159
+        }
160
+    }
161
+    else
162
+    {
163
+        die("invalid");
164
+    }
165 165
 }
166 166
 else
167 167
 {
168
-	header("Location:http://localhost/openchat/index.php");
168
+    header("Location:http://localhost/openchat/index.php");
169 169
 }
170 170
 ?>
171 171
 
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.