Test Setup Failed
Branch master (f3ea8f)
by Ankit
03:00
created
registration-module/source/class.register.php 3 patches
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.
Spacing   +58 added lines, -58 removed lines patch added patch discarded remove patch
@@ -17,13 +17,13 @@  discard block
 block discarded – undo
17 17
 
18 18
 	function __construct()
19 19
 	{
20
-		$this->array_error=array();
21
-		$this->key=0;
20
+		$this->array_error = array();
21
+		$this->key = 0;
22 22
 		$this->connect = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME);
23
-		$this->ob=new validate();
23
+		$this->ob = new validate();
24 24
 
25 25
 
26
-		$query="CREATE TABLE IF NOT EXISTS register (
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,
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
 			echo "Table is not created || Query failed";
35 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,
@@ -48,7 +48,7 @@  discard block
 block discarded – undo
48 48
 			echo "Table is not created || Query failed";
49 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,
@@ -61,98 +61,98 @@  discard block
 block discarded – undo
61 61
 
62 62
 	}
63 63
 
64
-	function _register($name,$email,$username,$password,$mob)
64
+	function _register($name, $email, $username, $password, $mob)
65 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);
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 71
 		if (empty($this->name)) {
72
-			$this->key=1;
73
-			$this->array_error=array_merge($this->array_error,["name"=>"Enter the name"]);
72
+			$this->key = 1;
73
+			$this->array_error = array_merge($this->array_error, ["name"=>"Enter the name"]);
74 74
 		}
75 75
 
76
-		if(empty($this->email)) {
77
-			$this->key=1;
78
-			$this->array_error=array_merge($this->array_error,["email"=>"Enter the email address"]);
76
+		if (empty($this->email)) {
77
+			$this->key = 1;
78
+			$this->array_error = array_merge($this->array_error, ["email"=>"Enter the email address"]);
79 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"]);
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 83
 		}
84 84
 		else
85 85
 		{
86
-			if($this->ob->validate_email_in_db($this->email))
86
+			if ($this->ob->validate_email_in_db($this->email))
87 87
 			{
88
-				$this->key=1;
89
-				$this->array_error=array_merge($this->array_error,["email"=>"Email is already registered"]);
88
+				$this->key = 1;
89
+				$this->array_error = array_merge($this->array_error, ["email"=>"Email is already registered"]);
90 90
 			}
91 91
 		}
92 92
 
93
-		if(empty($this->username)) {
94
-			$this->key=1;
95
-			$this->array_error=array_merge($this->array_error,["username"=>"Enter the username"]);
93
+		if (empty($this->username)) {
94
+			$this->key = 1;
95
+			$this->array_error = array_merge($this->array_error, ["username"=>"Enter the username"]);
96 96
 		}
97 97
 		else
98 98
 		{
99
-			if($this->ob->validate_username_in_db($this->username))
99
+			if ($this->ob->validate_username_in_db($this->username))
100 100
 			{
101
-				$this->key=1;
102
-				$this->array_error=array_merge($this->array_error,["username"=>"Username is already registered"]);
101
+				$this->key = 1;
102
+				$this->array_error = array_merge($this->array_error, ["username"=>"Username is already registered"]);
103 103
 			}
104 104
 		}
105 105
 
106
-		if(empty($this->password)) {
107
-			$this->key=1;
108
-			$this->array_error=array_merge($this->array_error,["password"=>"Enter the password"]);
106
+		if (empty($this->password)) {
107
+			$this->key = 1;
108
+			$this->array_error = array_merge($this->array_error, ["password"=>"Enter the password"]);
109 109
 		}
110 110
 
111
-		if(empty($this->mob)) {
112
-			$this->key=1;
113
-			$this->array_error=array_merge($this->array_error,["mob"=>"Enter the Mobile Number"]);
111
+		if (empty($this->mob)) {
112
+			$this->key = 1;
113
+			$this->array_error = array_merge($this->array_error, ["mob"=>"Enter the Mobile Number"]);
114 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"]);
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 118
 		}
119 119
 
120
-		if($this->key==1)
120
+		if ($this->key == 1)
121 121
 		{
122 122
 			return json_encode($this->array_error);
123 123
 		}
124 124
 		else
125 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;
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 131
 				echo "You are not registered || Error in registration2";
132 132
 			}
133 133
 			else
134 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;
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 143
 						echo "You are not registered || Error in registration1";
144 144
 					}
145
-					$join="Joined OpenChat";
146
-					$query="INSERT INTO profile VALUES('$id','$join','$join','')";
147
-					if(!$this->connect->query($query)) {
148
-						$this->key=1;
145
+					$join = "Joined OpenChat";
146
+					$query = "INSERT INTO profile VALUES('$id','$join','$join','')";
147
+					if (!$this->connect->query($query)) {
148
+						$this->key = 1;
149 149
 						echo "You are not updated || Error in profile";
150 150
 					}
151 151
 				}
152 152
 			}
153 153
 		}
154
-		if ($this->key==0) {
155
-			$_SESSION['start']=$id;
154
+		if ($this->key == 0) {
155
+			$_SESSION['start'] = $id;
156 156
 			return json_encode(["location"=>"http://localhost/openchat/account.php"]);
157 157
 		}
158 158
 		else
Please login to merge, or discard this patch.
Braces   +7 added lines, -14 removed lines patch added patch discarded remove patch
@@ -76,12 +76,10 @@  discard block
 block discarded – undo
76 76
 		if(empty($this->email)) {
77 77
 			$this->key=1;
78 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) {
79
+		} elseif(filter_var($this->email,FILTER_VALIDATE_EMAIL)== false) {
81 80
 			$this->key=1;
82 81
 			$this->array_error=array_merge($this->array_error,["email"=>"Enter correct Email address"]);
83
-		}
84
-		else
82
+		} else
85 83
 		{
86 84
 			if($this->ob->validate_email_in_db($this->email))
87 85
 			{
@@ -93,8 +91,7 @@  discard block
 block discarded – undo
93 91
 		if(empty($this->username)) {
94 92
 			$this->key=1;
95 93
 			$this->array_error=array_merge($this->array_error,["username"=>"Enter the username"]);
96
-		}
97
-		else
94
+		} else
98 95
 		{
99 96
 			if($this->ob->validate_username_in_db($this->username))
100 97
 			{
@@ -111,8 +108,7 @@  discard block
 block discarded – undo
111 108
 		if(empty($this->mob)) {
112 109
 			$this->key=1;
113 110
 			$this->array_error=array_merge($this->array_error,["mob"=>"Enter the Mobile Number"]);
114
-		}
115
-		elseif (!preg_match("/^[0-9]{10}$/",$this->mob)) {
111
+		} elseif (!preg_match("/^[0-9]{10}$/",$this->mob)) {
116 112
 			$this->key=1;
117 113
 			$this->array_error=array_merge($this->array_error,["mob"=>"Enter correct Mobile Number"]);
118 114
 		}
@@ -120,8 +116,7 @@  discard block
 block discarded – undo
120 116
 		if($this->key==1)
121 117
 		{
122 118
 			return json_encode($this->array_error);
123
-		}
124
-		else
119
+		} else
125 120
 		{
126 121
 			$this->key=0;
127 122
 			$pass=md5($this->password);
@@ -129,8 +124,7 @@  discard block
 block discarded – undo
129 124
 			if(!$this->connect->query($query)) {
130 125
 				$this->key=1;
131 126
 				echo "You are not registered || Error in registration2";
132
-			}
133
-			else
127
+			} else
134 128
 			{
135 129
 				$query="SELECT id FROM register WHERE email='$this->email'";
136 130
 				if($result=$this->connect->query($query)) {
@@ -154,8 +148,7 @@  discard block
 block discarded – undo
154 148
 		if ($this->key==0) {
155 149
 			$_SESSION['start']=$id;
156 150
 			return json_encode(["location"=>"http://localhost/openchat/account.php"]);
157
-		}
158
-		else
151
+		} else
159 152
 		{
160 153
 			return json_encode($this->array_error);
161 154
 		}
Please login to merge, or discard this patch.
registration-module/source/class.logout.php 3 patches
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.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -2,11 +2,11 @@
 block discarded – undo
2 2
 require_once 'database.php';
3 3
 session_start();
4 4
 $connect = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME);
5
-if(isset($_SESSION['start']))
5
+if (isset($_SESSION['start']))
6 6
 {
7 7
     $id = $_SESSION['start'];
8 8
     $query = "Update login set login_status = '' where login_id = '$id'";
9
-    if($result = $connect->query($query))
9
+    if ($result = $connect->query($query))
10 10
     {
11 11
         unset($_SESSION['start']);
12 12
         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.
registration-module/source/database.php 2 patches
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.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -2,6 +2,6 @@
 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
 ?>
Please login to merge, or discard this patch.
registration-module/source/class.login.php 3 patches
Indentation   +80 added lines, -80 removed lines patch added patch discarded remove patch
@@ -4,93 +4,93 @@
 block discarded – undo
4 4
 class login
5 5
 {
6 6
 
7
-	private $login;
8
-	private $password;
9
-	private $key;
10
-	private $array_error;
7
+    private $login;
8
+    private $password;
9
+    private $key;
10
+    private $array_error;
11 11
 
12
-	function __construct()
13
-	{
14
-		$_SESSION['password']='';
15
-		$_SESSION['login']='';
16
-		$this->key=0;
17
-		$this->array_error=array();
18
-	}
12
+    function __construct()
13
+    {
14
+        $_SESSION['password']='';
15
+        $_SESSION['login']='';
16
+        $this->key=0;
17
+        $this->array_error=array();
18
+    }
19 19
 
20
-	function _login($login,$password)
21
-	{
22
-		$connect = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME);
20
+    function _login($login,$password)
21
+    {
22
+        $connect = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME);
23 23
 
24
-		$this->login=trim($login);
25
-		$this->password=trim($password);
24
+        $this->login=trim($login);
25
+        $this->password=trim($password);
26 26
 
27
-		if(empty($this->login))
28
-		{
29
-			$this->key=1;
30
-			$this->array_error=array_merge($this->array_error,["login"=>"Enter the login field"]);
31
-		}
32
-		elseif (preg_match("/^[@]{1}$/",$this->login))
33
-		{
34
-			if(filter_var($this->email,FILTER_VALIDATE_EMAIL)== false)
35
-			{
36
-			$this->key=1;
37
-			$this->array_error=array_merge($this->array_error,["login"=>"Enter correct Email address"]);
38
-			}
39
-		}
40
-		if(empty($this->password)) {
41
-			$this->key=1;
42
-			$this->array_error=array_merge($this->array_error,["password"=>"Enter the password"]);
43
-		}
44
-		else
45
-		{
46
-			$pass=md5($this->password);
47
-		}
27
+        if(empty($this->login))
28
+        {
29
+            $this->key=1;
30
+            $this->array_error=array_merge($this->array_error,["login"=>"Enter the login field"]);
31
+        }
32
+        elseif (preg_match("/^[@]{1}$/",$this->login))
33
+        {
34
+            if(filter_var($this->email,FILTER_VALIDATE_EMAIL)== false)
35
+            {
36
+            $this->key=1;
37
+            $this->array_error=array_merge($this->array_error,["login"=>"Enter correct Email address"]);
38
+            }
39
+        }
40
+        if(empty($this->password)) {
41
+            $this->key=1;
42
+            $this->array_error=array_merge($this->array_error,["password"=>"Enter the password"]);
43
+        }
44
+        else
45
+        {
46
+            $pass=md5($this->password);
47
+        }
48 48
 
49
-		if($this->key==0)
50
-		{
51
-			$query="SELECT * FROM login WHERE email='$this->login' or username='$this->login'";
52
-			if ($result=$connect->query($query))
53
-			{
54
-				if ($result->num_rows>0)
55
-				{
56
-					$row=$result->fetch_assoc();
57
-					$login_id=$row['login_id'];
58
-					$query="SELECT id FROM register WHERE id='$login_id' and password='$pass'";
59
-					if($result=$connect->query($query))
60
-					{
61
-						if ($result->num_rows>0)
62
-						{
63
-							$query = "Update login set login_status = '1' where login_id = '$login_id'";
64
-							if($result = $connect->query($query))
65
-							{
66
-								$time=date("D d M Y H:i:s", time()+12600);	// current time
67
-								$time_id=date("YmdHis",time()+12600);
68
-								// $query = "Update "
69
-								$_SESSION['start']=$login_id;
70
-								return json_encode(["location"=>"http://localhost/openchat/account.php"]);
71
-							}
49
+        if($this->key==0)
50
+        {
51
+            $query="SELECT * FROM login WHERE email='$this->login' or username='$this->login'";
52
+            if ($result=$connect->query($query))
53
+            {
54
+                if ($result->num_rows>0)
55
+                {
56
+                    $row=$result->fetch_assoc();
57
+                    $login_id=$row['login_id'];
58
+                    $query="SELECT id FROM register WHERE id='$login_id' and password='$pass'";
59
+                    if($result=$connect->query($query))
60
+                    {
61
+                        if ($result->num_rows>0)
62
+                        {
63
+                            $query = "Update login set login_status = '1' where login_id = '$login_id'";
64
+                            if($result = $connect->query($query))
65
+                            {
66
+                                $time=date("D d M Y H:i:s", time()+12600);	// current time
67
+                                $time_id=date("YmdHis",time()+12600);
68
+                                // $query = "Update "
69
+                                $_SESSION['start']=$login_id;
70
+                                return json_encode(["location"=>"http://localhost/openchat/account.php"]);
71
+                            }
72 72
 
73
-						}
74
-						else
75
-						{
76
-							$this->array_error=array_merge($this->array_error,["password"=>"Invalid password"]);
77
-							return json_encode($this->array_error);
78
-						}
79
-					}
80
-				}
81
-				else
82
-				{
83
-					$this->array_error=array_merge($this->array_error,["login"=>"Invalid username or email"]);
84
-					return json_encode($this->array_error);
85
-				}
86
-			}
73
+                        }
74
+                        else
75
+                        {
76
+                            $this->array_error=array_merge($this->array_error,["password"=>"Invalid password"]);
77
+                            return json_encode($this->array_error);
78
+                        }
79
+                    }
80
+                }
81
+                else
82
+                {
83
+                    $this->array_error=array_merge($this->array_error,["login"=>"Invalid username or email"]);
84
+                    return json_encode($this->array_error);
85
+                }
86
+            }
87 87
 
88
-		}
89
-		else
90
-		{
91
-			return json_encode($this->array_error);
92
-		}
93
-	}
88
+        }
89
+        else
90
+        {
91
+            return json_encode($this->array_error);
92
+        }
93
+    }
94 94
 }
95 95
 
96 96
 
Please login to merge, or discard this patch.
Spacing   +33 added lines, -33 removed lines patch added patch discarded remove patch
@@ -11,76 +11,76 @@
 block discarded – undo
11 11
 
12 12
 	function __construct()
13 13
 	{
14
-		$_SESSION['password']='';
15
-		$_SESSION['login']='';
16
-		$this->key=0;
17
-		$this->array_error=array();
14
+		$_SESSION['password'] = '';
15
+		$_SESSION['login'] = '';
16
+		$this->key = 0;
17
+		$this->array_error = array();
18 18
 	}
19 19
 
20
-	function _login($login,$password)
20
+	function _login($login, $password)
21 21
 	{
22 22
 		$connect = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME);
23 23
 
24
-		$this->login=trim($login);
25
-		$this->password=trim($password);
24
+		$this->login = trim($login);
25
+		$this->password = trim($password);
26 26
 
27
-		if(empty($this->login))
27
+		if (empty($this->login))
28 28
 		{
29
-			$this->key=1;
30
-			$this->array_error=array_merge($this->array_error,["login"=>"Enter the login field"]);
29
+			$this->key = 1;
30
+			$this->array_error = array_merge($this->array_error, ["login"=>"Enter the login field"]);
31 31
 		}
32
-		elseif (preg_match("/^[@]{1}$/",$this->login))
32
+		elseif (preg_match("/^[@]{1}$/", $this->login))
33 33
 		{
34
-			if(filter_var($this->email,FILTER_VALIDATE_EMAIL)== false)
34
+			if (filter_var($this->email, FILTER_VALIDATE_EMAIL) == false)
35 35
 			{
36
-			$this->key=1;
37
-			$this->array_error=array_merge($this->array_error,["login"=>"Enter correct Email address"]);
36
+			$this->key = 1;
37
+			$this->array_error = array_merge($this->array_error, ["login"=>"Enter correct Email address"]);
38 38
 			}
39 39
 		}
40
-		if(empty($this->password)) {
41
-			$this->key=1;
42
-			$this->array_error=array_merge($this->array_error,["password"=>"Enter the password"]);
40
+		if (empty($this->password)) {
41
+			$this->key = 1;
42
+			$this->array_error = array_merge($this->array_error, ["password"=>"Enter the password"]);
43 43
 		}
44 44
 		else
45 45
 		{
46
-			$pass=md5($this->password);
46
+			$pass = md5($this->password);
47 47
 		}
48 48
 
49
-		if($this->key==0)
49
+		if ($this->key == 0)
50 50
 		{
51
-			$query="SELECT * FROM login WHERE email='$this->login' or username='$this->login'";
52
-			if ($result=$connect->query($query))
51
+			$query = "SELECT * FROM login WHERE email='$this->login' or username='$this->login'";
52
+			if ($result = $connect->query($query))
53 53
 			{
54
-				if ($result->num_rows>0)
54
+				if ($result->num_rows > 0)
55 55
 				{
56
-					$row=$result->fetch_assoc();
57
-					$login_id=$row['login_id'];
58
-					$query="SELECT id FROM register WHERE id='$login_id' and password='$pass'";
59
-					if($result=$connect->query($query))
56
+					$row = $result->fetch_assoc();
57
+					$login_id = $row['login_id'];
58
+					$query = "SELECT id FROM register WHERE id='$login_id' and password='$pass'";
59
+					if ($result = $connect->query($query))
60 60
 					{
61
-						if ($result->num_rows>0)
61
+						if ($result->num_rows > 0)
62 62
 						{
63 63
 							$query = "Update login set login_status = '1' where login_id = '$login_id'";
64
-							if($result = $connect->query($query))
64
+							if ($result = $connect->query($query))
65 65
 							{
66
-								$time=date("D d M Y H:i:s", time()+12600);	// current time
67
-								$time_id=date("YmdHis",time()+12600);
66
+								$time = date("D d M Y H:i:s", time() + 12600); // current time
67
+								$time_id = date("YmdHis", time() + 12600);
68 68
 								// $query = "Update "
69
-								$_SESSION['start']=$login_id;
69
+								$_SESSION['start'] = $login_id;
70 70
 								return json_encode(["location"=>"http://localhost/openchat/account.php"]);
71 71
 							}
72 72
 
73 73
 						}
74 74
 						else
75 75
 						{
76
-							$this->array_error=array_merge($this->array_error,["password"=>"Invalid password"]);
76
+							$this->array_error = array_merge($this->array_error, ["password"=>"Invalid password"]);
77 77
 							return json_encode($this->array_error);
78 78
 						}
79 79
 					}
80 80
 				}
81 81
 				else
82 82
 				{
83
-					$this->array_error=array_merge($this->array_error,["login"=>"Invalid username or email"]);
83
+					$this->array_error = array_merge($this->array_error, ["login"=>"Invalid username or email"]);
84 84
 					return json_encode($this->array_error);
85 85
 				}
86 86
 			}
Please login to merge, or discard this patch.
Braces   +5 added lines, -10 removed lines patch added patch discarded remove patch
@@ -28,8 +28,7 @@  discard block
 block discarded – undo
28 28
 		{
29 29
 			$this->key=1;
30 30
 			$this->array_error=array_merge($this->array_error,["login"=>"Enter the login field"]);
31
-		}
32
-		elseif (preg_match("/^[@]{1}$/",$this->login))
31
+		} elseif (preg_match("/^[@]{1}$/",$this->login))
33 32
 		{
34 33
 			if(filter_var($this->email,FILTER_VALIDATE_EMAIL)== false)
35 34
 			{
@@ -40,8 +39,7 @@  discard block
 block discarded – undo
40 39
 		if(empty($this->password)) {
41 40
 			$this->key=1;
42 41
 			$this->array_error=array_merge($this->array_error,["password"=>"Enter the password"]);
43
-		}
44
-		else
42
+		} else
45 43
 		{
46 44
 			$pass=md5($this->password);
47 45
 		}
@@ -70,23 +68,20 @@  discard block
 block discarded – undo
70 68
 								return json_encode(["location"=>"http://localhost/openchat/account.php"]);
71 69
 							}
72 70
 
73
-						}
74
-						else
71
+						} else
75 72
 						{
76 73
 							$this->array_error=array_merge($this->array_error,["password"=>"Invalid password"]);
77 74
 							return json_encode($this->array_error);
78 75
 						}
79 76
 					}
80
-				}
81
-				else
77
+				} else
82 78
 				{
83 79
 					$this->array_error=array_merge($this->array_error,["login"=>"Invalid username or email"]);
84 80
 					return json_encode($this->array_error);
85 81
 				}
86 82
 			}
87 83
 
88
-		}
89
-		else
84
+		} else
90 85
 		{
91 86
 			return json_encode($this->array_error);
92 87
 		}
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.
Spacing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -2,32 +2,32 @@
 block discarded – undo
2 2
 session_start();
3 3
 include '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.
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.