Test Setup Failed
Push — master ( 15356d...37eca5 )
by Ankit
02:27
created
src/SideBar.php 2 patches
Braces   +4 added lines, -9 removed lines patch added patch discarded remove patch
@@ -38,27 +38,22 @@
 block discarded – undo
38 38
                         if($substring != $userId)
39 39
                         {
40 40
                             $this->Data($substring, $row);
41
-                        }
42
-
43
-                        else
41
+                        } else
44 42
                         {
45 43
                             $substring = substr($identifier, $length+1);
46 44
                             $this->Data($substring, $row);
47 45
                         }
48 46
                     }
49 47
                     return json_encode($this->array);
50
-                }
51
-                else
48
+                } else
52 49
                 {
53 50
                     return json_encode(null);
54 51
                 }
55
-            }
56
-            else
52
+            } else
57 53
             {
58 54
                 echo "Query Failed";
59 55
             }
60
-        }
61
-        else
56
+        } else
62 57
         {
63 58
             header('Location:../login.php');
64 59
         }
Please login to merge, or discard this patch.
Spacing   +8 added lines, -8 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
 use ChatApp\Time;
6 6
 
7 7
 /**
@@ -23,26 +23,26 @@  discard block
 block discarded – undo
23 23
 
24 24
     public function LoadSideBar($userId)
25 25
     {
26
-        if(isset($userId))
26
+        if (isset($userId))
27 27
         {
28 28
             $query = "SELECT * FROM total_message WHERE user1='$userId' or user2='$userId'  ORDER BY id DESC";
29
-            if($result = $this->connect->query($query))
29
+            if ($result = $this->connect->query($query))
30 30
             {
31 31
                 if ($result->num_rows > 0)
32 32
                 {
33 33
                     $length = strlen($userId);
34
-                    while($row = $result->fetch_assoc())
34
+                    while ($row = $result->fetch_assoc())
35 35
                     {
36 36
                         $identifier = $row['identifier'];
37 37
                         $substring = substr($identifier, 0, $length);
38
-                        if($substring != $userId)
38
+                        if ($substring != $userId)
39 39
                         {
40 40
                             $this->Data($substring, $row);
41 41
                         }
42 42
 
43 43
                         else
44 44
                         {
45
-                            $substring = substr($identifier, $length+1);
45
+                            $substring = substr($identifier, $length + 1);
46 46
                             $this->Data($substring, $row);
47 47
                         }
48 48
                     }
@@ -68,9 +68,9 @@  discard block
 block discarded – undo
68 68
     public function Data($id, $row)
69 69
     {
70 70
         $query = "SELECT username,name,login_status,login_id from login where login_id = '$id'";
71
-        if($result = $this->connect->query($query))
71
+        if ($result = $this->connect->query($query))
72 72
         {
73
-            if($result->num_rows > 0)
73
+            if ($result->num_rows > 0)
74 74
             {
75 75
                 $fetch = $result->fetch_assoc();
76 76
                 $row['time'] = $this->obTime->TimeConversion($row['time']);
Please login to merge, or discard this patch.
cmd.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -7,7 +7,7 @@
 block discarded – undo
7 7
 use Ratchet\WebSocket\WsServer;
8 8
 use ChatApp\Chat;
9 9
 
10
-$server =IoServer::factory(
10
+$server = IoServer::factory(
11 11
 	new HttpServer(
12 12
 		new WsServer(
13 13
 			new Chat()
Please login to merge, or discard this 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.
message.php 3 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 session_start();
3
-if(isset($_SESSION['start']) and empty($_GET['user']))
3
+if (isset($_SESSION['start']) and empty($_GET['user']))
4 4
 {
5 5
 ?>
6 6
 <!DOCTYPE html>
@@ -130,7 +130,7 @@  discard block
 block discarded – undo
130 130
 
131 131
 <?php
132 132
 }
133
-else{
133
+else {
134 134
 	header('Location:http://www.localhost/openchat/login.php');
135 135
 }
136 136
 ?>
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -129,8 +129,7 @@
 block discarded – undo
129 129
 </html>
130 130
 
131 131
 <?php
132
-}
133
-else{
132
+} else{
134 133
 	header('Location:http://www.localhost/openchat/login.php');
135 134
 }
136 135
 ?>
Please login to merge, or discard this 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.
profile_generate.php 3 patches
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.
Braces   +16 added lines, -14 removed lines patch added patch discarded remove patch
@@ -13,25 +13,27 @@
 block discarded – undo
13 13
 			$row=$result->fetch_assoc();
14 14
 		}
15 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'];
16
+	if(trim($_POST['status'])) {
17
+			$status=$_POST['status'];
18
+	} else {
19
+			$status=$row['status'];
20
+	}
21
+	if(trim($_POST['education'])) {
22
+			$edu=$_POST['education'];
23
+	} else {
24
+			$edu=$row['education'];
25
+	}
26
+	if(isset($_POST['gender'])) {
27
+			$gender=$_POST['gender'];
28
+	} else {
29
+			$gender=$row['gender'];
30
+	}
28 31
 
29 32
 	$query="UPDATE profile set status='$status', education='$edu', gender='$gender' where login_id='$login_id'";
30 33
 	if($result=$connect->query($query))
31 34
 	{
32 35
 		header('Location: account.php');
33
-	}
34
-	else
36
+	} else
35 37
 	{
36 38
 		die("error");
37 39
 	}
Please login to merge, or discard this patch.
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -1,33 +1,33 @@
 block discarded – undo
1 1
 <?php
2 2
 session_start();
3
-require_once (__DIR__ . '/config/database.php');
3
+require_once (__DIR__.'/config/database.php');
4 4
 $connect = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME);
5
-$login_id=$_SESSION['start'];
6
-if(isset($_POST['submit']))
5
+$login_id = $_SESSION['start'];
6
+if (isset($_POST['submit']))
7 7
 {
8
-	$query="SELECT * from profile where login_id='$login_id'";
9
-	if($result=$connect->query($query))
8
+	$query = "SELECT * from profile where login_id='$login_id'";
9
+	if ($result = $connect->query($query))
10 10
 	{
11
-		if($result->num_rows>0)
11
+		if ($result->num_rows > 0)
12 12
 		{
13
-			$row=$result->fetch_assoc();
13
+			$row = $result->fetch_assoc();
14 14
 		}
15 15
 	}
16
-	if(trim($_POST['status']))
17
-		$status=$_POST['status'];
16
+	if (trim($_POST['status']))
17
+		$status = $_POST['status'];
18 18
 	else
19
-		$status=$row['status'];
20
-	if(trim($_POST['education']))
21
-		$edu=$_POST['education'];
19
+		$status = $row['status'];
20
+	if (trim($_POST['education']))
21
+		$edu = $_POST['education'];
22 22
 	else
23
-		$edu=$row['education'];
24
-	if(isset($_POST['gender']))
25
-		$gender=$_POST['gender'];
23
+		$edu = $row['education'];
24
+	if (isset($_POST['gender']))
25
+		$gender = $_POST['gender'];
26 26
 	else
27
-		$gender=$row['gender'];
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))
29
+	$query = "UPDATE profile set status='$status', education='$edu', gender='$gender' where login_id='$login_id'";
30
+	if ($result = $connect->query($query))
31 31
 	{
32 32
 		header('Location: account.php');
33 33
 	}
Please login to merge, or discard this patch.
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.
src/Validate.php 4 patches
Doc Comments   +6 added lines patch added patch discarded remove patch
@@ -33,6 +33,9 @@  discard block
 block discarded – undo
33 33
 		}	
34 34
 	}
35 35
 	
36
+	/**
37
+	 * @param string $email
38
+	 */
36 39
 	function validate_email_in_db($email)
37 40
 	{
38 41
 		$query="SELECT login_id FROM login WHERE email='$email'";
@@ -46,6 +49,9 @@  discard block
 block discarded – undo
46 49
 		}
47 50
 	}
48 51
 
52
+	/**
53
+	 * @param string $username
54
+	 */
49 55
 	function validate_username_in_db($username)
50 56
 	{
51 57
 		$query="SELECT login_id FROM login WHERE username='$username'";
Please login to merge, or discard this 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.
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
 namespace ChatApp;
3
-require_once (dirname(__DIR__) . '/config/database.php');
3
+require_once (dirname(__DIR__).'/config/database.php');
4 4
 
5 5
 class Validate
6 6
 {
Please login to merge, or discard this patch.
Braces   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -40,9 +40,9 @@  discard block
 block discarded – undo
40 40
 		{
41 41
 			if ($result->num_rows>0) {
42 42
 				return 1;
43
+			} else {
44
+							return 0;
43 45
 			}
44
-			else
45
-				return 0;
46 46
 		}
47 47
 	}
48 48
 
@@ -52,9 +52,9 @@  discard block
 block discarded – undo
52 52
 		if ($result=$this->connect->query($query)) {
53 53
 			if ($result->num_rows>0) {
54 54
 				return 1;
55
+			} else {
56
+							return 0;
55 57
 			}
56
-			else
57
-				return 0;
58 58
 			
59 59
 		}
60 60
 	}
Please login to merge, or discard this patch.
config/database.php 2 patches
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.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -2,7 +2,7 @@  discard block
 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
   define('URL', URL());
8 8
 
@@ -12,7 +12,7 @@  discard block
 block discarded – undo
12 12
     $host = $_SERVER['SERVER_NAME'];
13 13
     $port = $_SERVER['SERVER_PORT'];
14 14
     $fol = "";
15
-    if(@$_SERVER['SERVER_ADDR']!=NULL)
15
+    if (@$_SERVER['SERVER_ADDR'] != NULL)
16 16
     {
17 17
         $fol = "/".explode('/', $_SERVER['PHP_SELF'])[1];
18 18
     }
Please login to merge, or discard this patch.
index.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.
src/Login.php 3 patches
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -2,7 +2,7 @@  discard block
 block discarded – undo
2 2
 
3 3
 namespace ChatApp;
4 4
 use ChatApp\Session;
5
-require_once (dirname(__DIR__) . '/config/database.php');
5
+require_once (dirname(__DIR__).'/config/database.php');
6 6
 
7 7
 class Login
8 8
 {
@@ -26,20 +26,20 @@  discard block
 block discarded – undo
26 26
 		$login = trim($login);
27 27
 		$password = trim($password);
28 28
 
29
-		if(empty($login))
29
+		if (empty($login))
30 30
 		{
31 31
 			$this->key = 1;
32 32
 			$this->error = array_merge($this->error, ["login" => " *Enter the login field"]);
33 33
 		}
34 34
 		elseif (preg_match("/^[@]{1}$/", $login))
35 35
 		{
36
-			if(filter_var($login, FILTER_VALIDATE_EMAIL) == false)
36
+			if (filter_var($login, FILTER_VALIDATE_EMAIL) == false)
37 37
 			{
38 38
 			$this->key = 1;
39 39
 			$this->error = array_merge($this->error, ["login" => " *Enter correct Email address"]);
40 40
 			}
41 41
 		}
42
-		if(empty($password)) {
42
+		if (empty($password)) {
43 43
 			$this->key = 1;
44 44
 			$this->error = array_merge($this->error, ["password" => " *Enter the password"]);
45 45
 		}
@@ -48,7 +48,7 @@  discard block
 block discarded – undo
48 48
 			$password = md5($password);
49 49
 		}
50 50
 
51
-		if($this->key == 0)
51
+		if ($this->key == 0)
52 52
 		{
53 53
 			$query = "SELECT * FROM login WHERE email = '$login' or username = '$login'";
54 54
 			if ($result = $this->connect->query($query))
@@ -58,7 +58,7 @@  discard block
 block discarded – undo
58 58
 					$row = $result->fetch_assoc();
59 59
 					$loginID = $row['login_id'];
60 60
 					$query = "SELECT id FROM register WHERE id = '$loginID' and password = '$password'";
61
-					if($result = $this->connect->query($query))
61
+					if ($result = $this->connect->query($query))
62 62
 					{
63 63
 						if ($result->num_rows > 0)
64 64
 						{
Please login to merge, or discard this patch.
Braces   +5 added lines, -10 removed lines patch added patch discarded remove patch
@@ -30,8 +30,7 @@  discard block
 block discarded – undo
30 30
 		{
31 31
 			$this->key = 1;
32 32
 			$this->error = array_merge($this->error, ["login" => " *Enter the login field"]);
33
-		}
34
-		elseif (preg_match("/^[@]{1}$/", $login))
33
+		} elseif (preg_match("/^[@]{1}$/", $login))
35 34
 		{
36 35
 			if(filter_var($login, FILTER_VALIDATE_EMAIL) == false)
37 36
 			{
@@ -42,8 +41,7 @@  discard block
 block discarded – undo
42 41
 		if(empty($password)) {
43 42
 			$this->key = 1;
44 43
 			$this->error = array_merge($this->error, ["password" => " *Enter the password"]);
45
-		}
46
-		else
44
+		} else
47 45
 		{
48 46
 			$password = md5($password);
49 47
 		}
@@ -66,23 +64,20 @@  discard block
 block discarded – undo
66 64
 							return json_encode([
67 65
 								"location" => URL."/account.php"
68 66
 							]);
69
-						}
70
-						else
67
+						} else
71 68
 						{
72 69
 							$this->error = array_merge($this->error, ["password" => " *Invalid password"]);
73 70
 							return json_encode($this->error);
74 71
 						}
75 72
 					}
76
-				}
77
-				else
73
+				} else
78 74
 				{
79 75
 					$this->error = array_merge($this->error, ["login" => " *Invalid username or email"]);
80 76
 					return json_encode($this->error);
81 77
 				}
82 78
 			}
83 79
 
84
-		}
85
-		else
80
+		} else
86 81
 		{
87 82
 			return json_encode($this->error);
88 83
 		}
Please login to merge, or discard this 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.