Completed
Push — master ( 37eca5...0dfdea )
by Ankit
02:50
created
profile_generate.php 1 patch
Indentation   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -9,29 +9,29 @@
 block discarded – undo
9 9
 $data = '';
10 10
 if(isset($_POST['submit']))
11 11
 {
12
-	$data = Profile::getProfile($userId);
13
-	if($data != NULL):
14
-		$status = get($_POST['status'], $data['status']);
15
-		$edu = get($_POST['education'], $data['education']);
16
-		$gender = get($_POST['gender'], $data['gender']);
17
-		$query = "UPDATE profile set status='$status', education='$edu', gender='$gender' where login_id = '$userId'";
18
-		if($result = $connect->query($query))
19
-		{
20
-			header('Location:'.URL.'/account.php');
21
-		}
22
-		else
23
-		{
24
-			header("Location:".URL."/error.php");
25
-		}
26
-	endif;
12
+    $data = Profile::getProfile($userId);
13
+    if($data != NULL):
14
+        $status = get($_POST['status'], $data['status']);
15
+        $edu = get($_POST['education'], $data['education']);
16
+        $gender = get($_POST['gender'], $data['gender']);
17
+        $query = "UPDATE profile set status='$status', education='$edu', gender='$gender' where login_id = '$userId'";
18
+        if($result = $connect->query($query))
19
+        {
20
+            header('Location:'.URL.'/account.php');
21
+        }
22
+        else
23
+        {
24
+            header("Location:".URL."/error.php");
25
+        }
26
+    endif;
27 27
 }
28 28
 else
29 29
 {
30
-	header("Location:".URL."/error.php");
30
+    header("Location:".URL."/error.php");
31 31
 }
32 32
 
33 33
 function get($value, $default)
34 34
 {
35
-	$value = trim($value);
36
-	return (isset($value) ? $value : $default);
35
+    $value = trim($value);
36
+    return (isset($value) ? $value : $default);
37 37
 }
Please login to merge, or discard this patch.
config/database.example.php 1 patch
Indentation   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -1,13 +1,13 @@  discard block
 block discarded – undo
1 1
 <?php
2
-  // Define database connection constants
3
-  define('DB_HOST', 'localhost');
4
-  define('DB_USER', 'root');
5
-  define('DB_PASSWORD','');
6
-  define('DB_NAME', 'openchat');
7
-  define('URL', URL());
2
+    // Define database connection constants
3
+    define('DB_HOST', 'localhost');
4
+    define('DB_USER', 'root');
5
+    define('DB_PASSWORD','');
6
+    define('DB_NAME', 'openchat');
7
+    define('URL', URL());
8 8
 
9
-   function URL()
10
-  {
9
+    function URL()
10
+    {
11 11
     $http = "http://";
12 12
     $host = $_SERVER['SERVER_NAME'];
13 13
     $port = $_SERVER['SERVER_PORT'];
@@ -18,5 +18,5 @@  discard block
 block discarded – undo
18 18
     }
19 19
     $url = $http.$host.":".$port.$fol;
20 20
     return $url;
21
-  }
21
+    }
22 22
 ?>
Please login to merge, or discard this patch.
src/Register.php 1 patch
Indentation   +105 added lines, -105 removed lines patch added patch discarded remove patch
@@ -7,122 +7,122 @@
 block discarded – undo
7 7
 
8 8
 class Register
9 9
 {
10
-	protected $error;
11
-	protected $key;
12
-	protected $obValidate;
13
-	protected $connect;
10
+    protected $error;
11
+    protected $key;
12
+    protected $obValidate;
13
+    protected $connect;
14 14
 
15
-	public function __construct()
16
-	{
17
-		$this->error = array();
18
-		$this->key = 0;
19
-		$this->connect = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME);
20
-		$this->obValidate = new Validate();
15
+    public function __construct()
16
+    {
17
+        $this->error = array();
18
+        $this->key = 0;
19
+        $this->connect = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME);
20
+        $this->obValidate = new Validate();
21 21
 
22
-	}
22
+    }
23 23
 
24
-	public function authRegister($name, $email, $username, $password, $mob)
25
-	{
26
-		$name = trim($name);
27
-		$email = trim($email);
28
-		$username = trim($username);
29
-		$password = trim($password);
30
-		$mob = trim($mob);
31
-		$userId = '';
24
+    public function authRegister($name, $email, $username, $password, $mob)
25
+    {
26
+        $name = trim($name);
27
+        $email = trim($email);
28
+        $username = trim($username);
29
+        $password = trim($password);
30
+        $mob = trim($mob);
31
+        $userId = '';
32 32
 
33
-		if (empty($name)) {
34
-			$this->onError(["name" => " *Enter the name"]);
35
-		}
33
+        if (empty($name)) {
34
+            $this->onError(["name" => " *Enter the name"]);
35
+        }
36 36
 
37
-		if(empty($email)) {
38
-			$this->onError(["email" => " *Enter the email address"]);
39
-		}
40
-		elseif(filter_var($email, FILTER_VALIDATE_EMAIL) == false) {
41
-			$this->onError(["email" => " *Enter correct Email address"]);
42
-		}
43
-		else
44
-		{
45
-			if($this->obValidate->validateEmailInDb($email) === 1)
46
-			{
37
+        if(empty($email)) {
38
+            $this->onError(["email" => " *Enter the email address"]);
39
+        }
40
+        elseif(filter_var($email, FILTER_VALIDATE_EMAIL) == false) {
41
+            $this->onError(["email" => " *Enter correct Email address"]);
42
+        }
43
+        else
44
+        {
45
+            if($this->obValidate->validateEmailInDb($email) === 1)
46
+            {
47 47
 
48
-				$this->onError(["email" => " *Email is already registered"]);
49
-			}
50
-		}
48
+                $this->onError(["email" => " *Email is already registered"]);
49
+            }
50
+        }
51 51
 
52
-		if(empty($username)) {
53
-			$this->onError(["username" => " *Enter the username"]);
54
-		}
55
-		else
56
-		{
57
-			if($this->obValidate->validateUsernameInDb($username) === 1)
58
-			{
52
+        if(empty($username)) {
53
+            $this->onError(["username" => " *Enter the username"]);
54
+        }
55
+        else
56
+        {
57
+            if($this->obValidate->validateUsernameInDb($username) === 1)
58
+            {
59 59
 
60
-				$this->onError(["username" => " *Username is already registered"]);
61
-			}
62
-		}
60
+                $this->onError(["username" => " *Username is already registered"]);
61
+            }
62
+        }
63 63
 
64
-		if(empty($password)) {
65
-			$this->onError(["password" => " *Enter the password"]);
66
-		}
64
+        if(empty($password)) {
65
+            $this->onError(["password" => " *Enter the password"]);
66
+        }
67 67
 
68
-		if(empty($mob)) {
69
-			$this->onError(["mob" => " *Enter the Mobile Number"]);
70
-		}
71
-		elseif (!preg_match("/^[0-9]{10}$/", $mob)) {
72
-			$this->onError(["mob" => " *Enter correct Mobile Number"]);
73
-		}
68
+        if(empty($mob)) {
69
+            $this->onError(["mob" => " *Enter the Mobile Number"]);
70
+        }
71
+        elseif (!preg_match("/^[0-9]{10}$/", $mob)) {
72
+            $this->onError(["mob" => " *Enter correct Mobile Number"]);
73
+        }
74 74
 
75
-		if($this->key == 1)
76
-		{
77
-			return json_encode($this->error);
78
-		}
79
-		else
80
-		{
81
-			$this->key = 0;
82
-			$pass = md5($password);
83
-			$query = "INSERT INTO register VALUES(null, '$email', '$username', '$pass')";
84
-			if(!$this->connect->query($query)) {
85
-				$this->key = 1;
86
-				echo "You are not registered || Error in registration1";
87
-			}
88
-			else
89
-			{
90
-				$query = "SELECT id FROM register WHERE email = '$email'";
91
-				if($result = $this->connect->query($query)) {
92
-					$row = $result->fetch_assoc();
93
-					$userId = $row['id'];
75
+        if($this->key == 1)
76
+        {
77
+            return json_encode($this->error);
78
+        }
79
+        else
80
+        {
81
+            $this->key = 0;
82
+            $pass = md5($password);
83
+            $query = "INSERT INTO register VALUES(null, '$email', '$username', '$pass')";
84
+            if(!$this->connect->query($query)) {
85
+                $this->key = 1;
86
+                echo "You are not registered || Error in registration1";
87
+            }
88
+            else
89
+            {
90
+                $query = "SELECT id FROM register WHERE email = '$email'";
91
+                if($result = $this->connect->query($query)) {
92
+                    $row = $result->fetch_assoc();
93
+                    $userId = $row['id'];
94 94
 
95
-					$query = "INSERT INTO login VALUES('$userId', '$name', '$email', '$username', '$mob', 0)";
96
-					if(!$this->connect->query($query)) {
97
-						$this->key = 1;
98
-						echo "You are not registered || Error in registration2";
99
-					}
100
-					else
101
-					{
102
-						$query = "INSERT INTO profile VALUES('$userId', 'Joined OpenChat', 'Joined OpenChat', '')";
103
-						if(!$this->connect->query($query)) {
104
-							$this->key = 1;
105
-							echo "You are not registered || Error in registration3";
106
-						}
107
-					}
108
-				}
109
-			}
110
-		}
111
-		if ($this->key == 0) {
112
-			Session::put('start', $userId);
113
-			return json_encode([
114
-				"location" => URL."/account.php"
115
-			]);
116
-		}
117
-		else
118
-		{
119
-			return json_encode($this->error);
120
-		}
121
-	}
95
+                    $query = "INSERT INTO login VALUES('$userId', '$name', '$email', '$username', '$mob', 0)";
96
+                    if(!$this->connect->query($query)) {
97
+                        $this->key = 1;
98
+                        echo "You are not registered || Error in registration2";
99
+                    }
100
+                    else
101
+                    {
102
+                        $query = "INSERT INTO profile VALUES('$userId', 'Joined OpenChat', 'Joined OpenChat', '')";
103
+                        if(!$this->connect->query($query)) {
104
+                            $this->key = 1;
105
+                            echo "You are not registered || Error in registration3";
106
+                        }
107
+                    }
108
+                }
109
+            }
110
+        }
111
+        if ($this->key == 0) {
112
+            Session::put('start', $userId);
113
+            return json_encode([
114
+                "location" => URL."/account.php"
115
+            ]);
116
+        }
117
+        else
118
+        {
119
+            return json_encode($this->error);
120
+        }
121
+    }
122 122
 
123
-	public function onError($value)
124
-	{
125
-		$this->key = 1;
126
-		$this->error = array_merge($this->error, $value);
127
-	}
123
+    public function onError($value)
124
+    {
125
+        $this->key = 1;
126
+        $this->error = array_merge($this->error, $value);
127
+    }
128 128
 }
Please login to merge, or discard this patch.
tests/ExistsTest.php 1 patch
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -76,8 +76,8 @@
 block discarded – undo
76 76
     }
77 77
 
78 78
     /**
79
-    * @dataProvider ClassNameProvider
80
-    */
79
+     * @dataProvider ClassNameProvider
80
+     */
81 81
     public function testClassExists($className)
82 82
     {
83 83
         $this->assertTrue(class_exists($className));
Please login to merge, or discard this patch.