@@ -2,11 +2,9 @@ |
||
2 | 2 | namespace ChatApp; |
3 | 3 | use Ratchet\MessageComponentInterface; |
4 | 4 | use Ratchet\ConnectionInterface; |
5 | -use ChatApp\Models\Message; |
|
6 | 5 | use ChatApp\Reply; |
7 | 6 | use ChatApp\Conversation; |
8 | 7 | use ChatApp\Receiver; |
9 | -use ChatApp\SideBar; |
|
10 | 8 | use ChatApp\Search; |
11 | 9 | use ChatApp\Compose; |
12 | 10 |
@@ -3,7 +3,6 @@ |
||
3 | 3 | namespace ChatApp; |
4 | 4 | require_once (dirname(__DIR__) . '/database.php'); |
5 | 5 | use ChatApp\User; |
6 | -use ChatApp\Time; |
|
7 | 6 | use ChatApp\Conversation; |
8 | 7 | /** |
9 | 8 | * |
@@ -5,36 +5,36 @@ |
||
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 |
@@ -1,13 +1,13 @@ discard block |
||
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 |
||
18 | 18 | } |
19 | 19 | $url = $http.$host.":".$port.$fol; |
20 | 20 | return $url; |
21 | - } |
|
21 | + } |
|
22 | 22 | ?> |
@@ -131,6 +131,6 @@ |
||
131 | 131 | <?php |
132 | 132 | } |
133 | 133 | else{ |
134 | - header('Location:http://localhost/openchat'); |
|
134 | + header('Location:http://localhost/openchat'); |
|
135 | 135 | } |
136 | 136 | ?> |
@@ -4,35 +4,35 @@ |
||
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 | } |
@@ -5,13 +5,13 @@ |
||
5 | 5 | |
6 | 6 | if(isset($_POST['q'])) |
7 | 7 | { |
8 | - $loginField = json_decode($_POST['q']); |
|
9 | - $login = $loginField->login; |
|
10 | - $password = $loginField->password; |
|
11 | - $obLogin = new Login(); |
|
12 | - $result = $obLogin->authLogin($login, $password); |
|
13 | - if(isset($result)) |
|
14 | - echo $result; |
|
15 | - else |
|
16 | - echo json_encode([]); |
|
8 | + $loginField = json_decode($_POST['q']); |
|
9 | + $login = $loginField->login; |
|
10 | + $password = $loginField->password; |
|
11 | + $obLogin = new Login(); |
|
12 | + $result = $obLogin->authLogin($login, $password); |
|
13 | + if(isset($result)) |
|
14 | + echo $result; |
|
15 | + else |
|
16 | + echo json_encode([]); |
|
17 | 17 | } |
18 | 18 | \ No newline at end of file |
@@ -5,17 +5,17 @@ |
||
5 | 5 | |
6 | 6 | if(isset($_POST['q'])) |
7 | 7 | { |
8 | - $registerField = json_decode($_POST['q']); |
|
9 | - $name = $registerField->name; |
|
10 | - $email = $registerField->email; |
|
11 | - $username = $registerField->username; |
|
12 | - $mob = $registerField->mob; |
|
13 | - $password = $registerField->password; |
|
14 | - $obRegister = new Register(); |
|
15 | - $result = $obRegister->authRegister($name, $email, $username, $password, $mob); |
|
16 | - if(isset($result)) |
|
17 | - echo $result; |
|
18 | - else |
|
19 | - echo json_encode([]); |
|
8 | + $registerField = json_decode($_POST['q']); |
|
9 | + $name = $registerField->name; |
|
10 | + $email = $registerField->email; |
|
11 | + $username = $registerField->username; |
|
12 | + $mob = $registerField->mob; |
|
13 | + $password = $registerField->password; |
|
14 | + $obRegister = new Register(); |
|
15 | + $result = $obRegister->authRegister($name, $email, $username, $password, $mob); |
|
16 | + if(isset($result)) |
|
17 | + echo $result; |
|
18 | + else |
|
19 | + echo json_encode([]); |
|
20 | 20 | } |
21 | 21 |
@@ -7,83 +7,83 @@ |
||
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 | } |