Completed
Push — master ( d8bb10...5083b1 )
by Ankit
02:09
created
logout.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -1,10 +1,10 @@
 block discarded – undo
1 1
 <?php
2 2
 
3 3
 namespace AnkitJain\RegistrationModule;
4
-require (dirname(__DIR__) . '/registration-module/vendor/autoload.php');
4
+require (dirname(__DIR__).'/registration-module/vendor/autoload.php');
5 5
 use AnkitJain\RegistrationModule\Session;
6 6
 
7
-if(Session::get('start') != null)
7
+if (Session::get('start') != null)
8 8
 {
9 9
 	Session::forget('start');
10 10
 	header('Location: index.php');
Please login to merge, or discard this patch.
index.php 2 patches
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -2,7 +2,7 @@
 block discarded – undo
2 2
 session_start();
3 3
 if(isset($_SESSION['start']))
4 4
 {
5
-    header("Location: account.php");
5
+	header("Location: account.php");
6 6
 }
7 7
 ?>
8 8
   <!Doctype html>
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
 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.
ajax/validate_login.php 2 patches
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -1,18 +1,18 @@
 block discarded – undo
1 1
 <?php
2 2
 
3 3
 namespace AnkitJain\RegistrationModule;
4
-require (dirname(__DIR__) . '/vendor/autoload.php');
4
+require (dirname(__DIR__).'/vendor/autoload.php');
5 5
 use AnkitJain\RegistrationModule\Login;
6 6
 @session_start();
7 7
 
8
-if(isset($_POST['q']))
8
+if (isset($_POST['q']))
9 9
 {
10 10
 	$loginField = json_decode($_POST['q']);
11 11
 	$login = $loginField->login;
12 12
 	$password = $loginField->password;
13 13
 	$obLogin = new Login();
14 14
 	$result = $obLogin->authLogin($login, $password);
15
-	if(isset($result))
15
+	if (isset($result))
16 16
 		echo $result;
17 17
 	else
18 18
 		echo json_encode([]);
Please login to merge, or discard this patch.
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -10,10 +10,10 @@
 block discarded – undo
10 10
 	$login = $loginField->login;
11 11
 	$password = $loginField->password;
12 12
 	$obLogin = new Login();
13
-    $data = array(
14
-        'login' => $login,
15
-        'passLogin' => $password
16
-    );
13
+	$data = array(
14
+		'login' => $login,
15
+		'passLogin' => $password
16
+	);
17 17
 	$result = $obLogin->authLogin($data);
18 18
 	if(isset($result))
19 19
 		echo $result;
Please login to merge, or discard this patch.
ajax/validate_register.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -1,18 +1,18 @@
 block discarded – undo
1 1
 <?php
2 2
 
3 3
 namespace AnkitJain\RegistrationModule;
4
-require (dirname(__DIR__) . '/vendor/autoload.php');
4
+require (dirname(__DIR__).'/vendor/autoload.php');
5 5
 use AnkitJain\RegistrationModule\Login;
6 6
 @session_start();
7 7
 
8
-if(isset($_POST['q']))
8
+if (isset($_POST['q']))
9 9
 {
10 10
 	$loginField = json_decode($_POST['q']);
11 11
 	$login = $loginField->login;
12 12
 	$password = $loginField->password;
13 13
 	$obLogin = new Login();
14 14
 	$result = $obLogin->authLogin($login, $password);
15
-	if(isset($result))
15
+	if (isset($result))
16 16
 		echo $result;
17 17
 	else
18 18
 		echo json_encode([]);
Please login to merge, or discard this patch.
config/database.travis.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -2,7 +2,7 @@
 block discarded – undo
2 2
   // Define database connection constants
3 3
   define('DB_HOST', '127.0.0.1');
4 4
   define('DB_USER', 'root');
5
-  define('DB_PASSWORD','');
5
+  define('DB_PASSWORD', '');
6 6
   define('DB_NAME', 'account');
7 7
   define('URL', 'http://127.0.0.1/openchat');
8 8
 
Please login to merge, or discard this patch.
config/database.example.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -2,7 +2,7 @@
 block discarded – undo
2 2
   // Define database connection constants
3 3
   define('DB_HOST', '127.0.0.1');
4 4
   define('DB_USER', 'root');
5
-  define('DB_PASSWORD','');
5
+  define('DB_PASSWORD', '');
6 6
   define('DB_NAME', 'account');
7 7
   define('URL', 'http://127.0.0.1/openchat');
8 8
 
Please login to merge, or discard this patch.
source/Login.php 2 patches
Indentation   +113 added lines, -113 removed lines patch added patch discarded remove patch
@@ -25,7 +25,7 @@  discard block
 block discarded – undo
25 25
  */
26 26
 class Login
27 27
 {
28
-    /*
28
+	/*
29 29
     |--------------------------------------------------------------------------
30 30
     | Login Class
31 31
     |--------------------------------------------------------------------------
@@ -34,131 +34,131 @@  discard block
 block discarded – undo
34 34
     |
35 35
     */
36 36
 
37
-    protected $flag;
38
-    protected $error;
39
-    protected $connect;
37
+	protected $flag;
38
+	protected $error;
39
+	protected $connect;
40 40
 
41
-    /**
42
-     * Create a new controller instance.
43
-     *
44
-     * @return void
45
-     */
46
-    public function __construct()
47
-    {
48
-        $this->flag = 0;
49
-        $this->connect = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME);
50
-        $this->error = array();
51
-    }
41
+	/**
42
+	 * Create a new controller instance.
43
+	 *
44
+	 * @return void
45
+	 */
46
+	public function __construct()
47
+	{
48
+		$this->flag = 0;
49
+		$this->connect = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME);
50
+		$this->error = array();
51
+	}
52 52
 
53
-    /**
54
-     * Credentials check for allowing user to login
55
-     *
56
-     * @param array $data Contains the User Credentials
57
-     *
58
-     * @return json
59
-     */
60
-    public function authLogin($data)
61
-    {
62
-         $data = $this->emptyValue($data);
53
+	/**
54
+	 * Credentials check for allowing user to login
55
+	 *
56
+	 * @param array $data Contains the User Credentials
57
+	 *
58
+	 * @return json
59
+	 */
60
+	public function authLogin($data)
61
+	{
62
+		 $data = $this->emptyValue($data);
63 63
 
64
-         $login = $data["login"];
65
-         $password = $data["passLogin"];
64
+		 $login = $data["login"];
65
+		 $password = $data["passLogin"];
66 66
 
67
-        if (preg_match("/^.+[@]{1}.+$/", $login)) {
68
-            if (filter_var($login, FILTER_VALIDATE_EMAIL) == false) {
69
-                $this->onError("login", " *Enter correct Email address");
70
-            }
71
-        }
67
+		if (preg_match("/^.+[@]{1}.+$/", $login)) {
68
+			if (filter_var($login, FILTER_VALIDATE_EMAIL) == false) {
69
+				$this->onError("login", " *Enter correct Email address");
70
+			}
71
+		}
72 72
 
73
-        if ($this->flag == 0) {
74
-            $password = md5($password);
75
-            $query = "
73
+		if ($this->flag == 0) {
74
+			$password = md5($password);
75
+			$query = "
76 76
             	SELECT * FROM login WHERE email = '$login' or username = '$login'
77 77
             ";
78
-            if ($result = $this->connect->query($query)) {
79
-                if ($result->num_rows > 0) {
78
+			if ($result = $this->connect->query($query)) {
79
+				if ($result->num_rows > 0) {
80 80
 
81
-                    $row = $result->fetch_assoc();
82
-                    $loginID = $row['login_id'];
83
-                    $query = "
81
+					$row = $result->fetch_assoc();
82
+					$loginID = $row['login_id'];
83
+					$query = "
84 84
                     	SELECT id FROM register WHERE
85 85
                     	id = '$loginID' and
86 86
                     	password = '$password'
87 87
                     ";
88
-                    if ($result = $this->connect->query($query)) {
89
-                        if ($result->num_rows > 0) {
90
-                            Session::put('start', $loginID);
91
-                            return json_encode(
92
-                                [
93
-                                "location" => URL . "/account.php"
94
-                                ]
95
-                            );
96
-                        }
97
-                        $this->onError("passLogin", " *Invalid password");
98
-                        return json_encode($this->error);
99
-                    }
100
-                    return json_encode(
101
-                        [
102
-                        "Error" => "You are not registered, " . $this->connect->error
103
-                        ]
104
-                    );
105
-                }
106
-                $this->onError("login", " *Invalid username or email");
107
-                return json_encode($this->error);
108
-            }
109
-            return json_encode(
110
-                [
111
-                "Error" => "You are not registered, " . $this->connect->error
112
-                ]
113
-            );
114
-        } else {
115
-            return json_encode($this->error);
116
-        }
117
-    }
88
+					if ($result = $this->connect->query($query)) {
89
+						if ($result->num_rows > 0) {
90
+							Session::put('start', $loginID);
91
+							return json_encode(
92
+								[
93
+								"location" => URL . "/account.php"
94
+								]
95
+							);
96
+						}
97
+						$this->onError("passLogin", " *Invalid password");
98
+						return json_encode($this->error);
99
+					}
100
+					return json_encode(
101
+						[
102
+						"Error" => "You are not registered, " . $this->connect->error
103
+						]
104
+					);
105
+				}
106
+				$this->onError("login", " *Invalid username or email");
107
+				return json_encode($this->error);
108
+			}
109
+			return json_encode(
110
+				[
111
+				"Error" => "You are not registered, " . $this->connect->error
112
+				]
113
+			);
114
+		} else {
115
+			return json_encode($this->error);
116
+		}
117
+	}
118 118
 
119
-    /**
120
-     * For generating Error array by key value pair
121
-     *
122
-     * @param string $key   Contains key
123
-     * @param string $value Contains the Value for the key
124
-     *
125
-     * @return void
126
-     */
127
-    public function onError($key, $value)
128
-    {
129
-        $this->flag = 1;
130
-        $this->error = array_merge(
131
-            $this->error,
132
-            [
133
-            [
134
-            "key" => $key,
135
-            "value" => $value
136
-            ]
137
-            ]
138
-        );
139
-    }
119
+	/**
120
+	 * For generating Error array by key value pair
121
+	 *
122
+	 * @param string $key   Contains key
123
+	 * @param string $value Contains the Value for the key
124
+	 *
125
+	 * @return void
126
+	 */
127
+	public function onError($key, $value)
128
+	{
129
+		$this->flag = 1;
130
+		$this->error = array_merge(
131
+			$this->error,
132
+			[
133
+			[
134
+			"key" => $key,
135
+			"value" => $value
136
+			]
137
+			]
138
+		);
139
+	}
140 140
 
141
-    /**
142
-     * For checking whether the credentials are empty or not
143
-     *
144
-     * @param array $data Contains the Credentials
145
-     *
146
-     * @return array
147
-     */
148
-    public function emptyValue($data)
149
-    {
150
-        $errorCode = array(
151
-            "login" => " *Enter the login field",
152
-            "passLogin" => " *Enter the password"
153
-        );
141
+	/**
142
+	 * For checking whether the credentials are empty or not
143
+	 *
144
+	 * @param array $data Contains the Credentials
145
+	 *
146
+	 * @return array
147
+	 */
148
+	public function emptyValue($data)
149
+	{
150
+		$errorCode = array(
151
+			"login" => " *Enter the login field",
152
+			"passLogin" => " *Enter the password"
153
+		);
154 154
 
155
-        foreach ($data as $key => $value) {
156
-            $data[$key] = trim($data[$key]);
157
-            $value = trim($value);
158
-            if (empty($value)) {
159
-                $this->onError($key, $errorCode[$key]);
160
-            }
161
-        }
162
-        return $data;
163
-    }
155
+		foreach ($data as $key => $value) {
156
+			$data[$key] = trim($data[$key]);
157
+			$value = trim($value);
158
+			if (empty($value)) {
159
+				$this->onError($key, $errorCode[$key]);
160
+			}
161
+		}
162
+		return $data;
163
+	}
164 164
 }
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@  discard block
 block discarded – undo
12 12
  */
13 13
 namespace AnkitJain\RegistrationModule;
14 14
 use AnkitJain\RegistrationModule\Session;
15
-require_once dirname(__DIR__) . '/config/database.php';
15
+require_once dirname(__DIR__).'/config/database.php';
16 16
 
17 17
 /**
18 18
  * For Login the User
@@ -90,7 +90,7 @@  discard block
 block discarded – undo
90 90
                             Session::put('start', $loginID);
91 91
                             return json_encode(
92 92
                                 [
93
-                                "location" => URL . "/account.php"
93
+                                "location" => URL."/account.php"
94 94
                                 ]
95 95
                             );
96 96
                         }
@@ -99,7 +99,7 @@  discard block
 block discarded – undo
99 99
                     }
100 100
                     return json_encode(
101 101
                         [
102
-                        "Error" => "You are not registered, " . $this->connect->error
102
+                        "Error" => "You are not registered, ".$this->connect->error
103 103
                         ]
104 104
                     );
105 105
                 }
@@ -108,7 +108,7 @@  discard block
 block discarded – undo
108 108
             }
109 109
             return json_encode(
110 110
                 [
111
-                "Error" => "You are not registered, " . $this->connect->error
111
+                "Error" => "You are not registered, ".$this->connect->error
112 112
                 ]
113 113
             );
114 114
         } else {
Please login to merge, or discard this patch.
source/Validate.php 2 patches
Indentation   +45 added lines, -45 removed lines patch added patch discarded remove patch
@@ -24,7 +24,7 @@  discard block
 block discarded – undo
24 24
  */
25 25
 class Validate
26 26
 {
27
-    /*
27
+	/*
28 28
     |--------------------------------------------------------------------------
29 29
     | Validate Class
30 30
     |--------------------------------------------------------------------------
@@ -33,51 +33,51 @@  discard block
 block discarded – undo
33 33
     |
34 34
     */
35 35
 
36
-    protected $connect;
36
+	protected $connect;
37 37
 
38
-    /**
39
-     * Create a new controller instance.
40
-     *
41
-     * @return void
42
-     */
43
-    public function __construct()
44
-    {
45
-        $this->connect = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME);
46
-    }
38
+	/**
39
+	 * Create a new controller instance.
40
+	 *
41
+	 * @return void
42
+	 */
43
+	public function __construct()
44
+	{
45
+		$this->connect = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME);
46
+	}
47 47
 
48
-    /**
49
-     * For checking whether the credentials are empty or not
50
-     *
51
-     * @param string $email Contains the email for checking
52
-     *
53
-     * @return 0 | 1
54
-     */
55
-    public function validateEmailInDb($email)
56
-    {
57
-        $query = "SELECT login_id FROM login WHERE email = '$email'";
58
-        if ($result = $this->connect->query($query)) {
59
-            if ($result->num_rows > 0) {
60
-                return 1;
61
-            }
62
-            return 0;
63
-        }
64
-    }
48
+	/**
49
+	 * For checking whether the credentials are empty or not
50
+	 *
51
+	 * @param string $email Contains the email for checking
52
+	 *
53
+	 * @return 0 | 1
54
+	 */
55
+	public function validateEmailInDb($email)
56
+	{
57
+		$query = "SELECT login_id FROM login WHERE email = '$email'";
58
+		if ($result = $this->connect->query($query)) {
59
+			if ($result->num_rows > 0) {
60
+				return 1;
61
+			}
62
+			return 0;
63
+		}
64
+	}
65 65
 
66
-    /**
67
-     * For checking whether the credentials are empty or not
68
-     *
69
-     * @param string $username Contains the username for checking
70
-     *
71
-     * @return 0 | 1
72
-     */
73
-    public function validateUsernameInDb($username)
74
-    {
75
-        $query = "SELECT login_id FROM login WHERE username = '$username'";
76
-        if ($result = $this->connect->query($query)) {
77
-            if ($result->num_rows > 0) {
78
-                return 1;
79
-            }
80
-            return 0;
81
-        }
82
-    }
66
+	/**
67
+	 * For checking whether the credentials are empty or not
68
+	 *
69
+	 * @param string $username Contains the username for checking
70
+	 *
71
+	 * @return 0 | 1
72
+	 */
73
+	public function validateUsernameInDb($username)
74
+	{
75
+		$query = "SELECT login_id FROM login WHERE username = '$username'";
76
+		if ($result = $this->connect->query($query)) {
77
+			if ($result->num_rows > 0) {
78
+				return 1;
79
+			}
80
+			return 0;
81
+		}
82
+	}
83 83
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@
 block discarded – undo
11 11
  * @link     https://github.com/ankitjain28may/registration-module
12 12
  */
13 13
 namespace AnkitJain\RegistrationModule;
14
-require_once dirname(__DIR__) . '/config/database.php';
14
+require_once dirname(__DIR__).'/config/database.php';
15 15
 
16 16
 /**
17 17
  * For validation the Email and Username in DB.
Please login to merge, or discard this patch.
source/Session.php 1 patch
Indentation   +35 added lines, -35 removed lines patch added patch discarded remove patch
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
26 26
 
27 27
 class Session
28 28
 {
29
-    /*
29
+	/*
30 30
     |--------------------------------------------------------------------------
31 31
     | Session Class
32 32
     |--------------------------------------------------------------------------
@@ -35,40 +35,40 @@  discard block
 block discarded – undo
35 35
     |
36 36
     */
37 37
 
38
-    /**
39
-     * For generating Session with the key
40
-     *
41
-     * @param string $key   Contains key
42
-     * @param string $value Contains the Value for the key
43
-     *
44
-     * @return void
45
-     */
46
-    public static function put($key, $value)
47
-    {
48
-        $_SESSION[$key] = $value;
49
-    }
38
+	/**
39
+	 * For generating Session with the key
40
+	 *
41
+	 * @param string $key   Contains key
42
+	 * @param string $value Contains the Value for the key
43
+	 *
44
+	 * @return void
45
+	 */
46
+	public static function put($key, $value)
47
+	{
48
+		$_SESSION[$key] = $value;
49
+	}
50 50
 
51
-    /**
52
-     * For getting Session value
53
-     *
54
-     * @param string $key Contains key
55
-     *
56
-     * @return string | null
57
-     */
58
-    public static function get($key)
59
-    {
60
-        return (isset($_SESSION[$key]) ? $_SESSION[$key] : null);
61
-    }
51
+	/**
52
+	 * For getting Session value
53
+	 *
54
+	 * @param string $key Contains key
55
+	 *
56
+	 * @return string | null
57
+	 */
58
+	public static function get($key)
59
+	{
60
+		return (isset($_SESSION[$key]) ? $_SESSION[$key] : null);
61
+	}
62 62
 
63
-    /**
64
-     * For unsetting Session key
65
-     *
66
-     * @param string $key Contains key
67
-     *
68
-     * @return void
69
-     */
70
-    public static function forget($key)
71
-    {
72
-        unset($_SESSION[$key]);
73
-    }
63
+	/**
64
+	 * For unsetting Session key
65
+	 *
66
+	 * @param string $key Contains key
67
+	 *
68
+	 * @return void
69
+	 */
70
+	public static function forget($key)
71
+	{
72
+		unset($_SESSION[$key]);
73
+	}
74 74
 }
Please login to merge, or discard this patch.