@@ -1,7 +1,7 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | 3 | namespace ChatApp; |
4 | -require_once (dirname(__DIR__) . '/vendor/autoload.php'); |
|
4 | +require_once (dirname(__DIR__).'/vendor/autoload.php'); |
|
5 | 5 | use ChatApp\Time; |
6 | 6 | use Dotenv\Dotenv; |
7 | 7 | $dotenv = new Dotenv(dirname(__DIR__)); |
@@ -34,20 +34,20 @@ discard block |
||
34 | 34 | $userId = $suggestion->userId; |
35 | 35 | $suggestion = trim($suggestion->value); |
36 | 36 | $flag = 0; |
37 | - if(!empty($userId) && !empty($suggestion)) |
|
37 | + if (!empty($userId) && !empty($suggestion)) |
|
38 | 38 | { |
39 | 39 | $query = "SELECT * FROM login where login_id != '$userId' and name like '$suggestion%' ORDER BY name DESC"; |
40 | - if($result = $this->connect->query($query)) |
|
40 | + if ($result = $this->connect->query($query)) |
|
41 | 41 | { |
42 | - if($result->num_rows > 0) |
|
42 | + if ($result->num_rows > 0) |
|
43 | 43 | { |
44 | - while($row = $result->fetch_assoc()) |
|
44 | + while ($row = $result->fetch_assoc()) |
|
45 | 45 | { |
46 | 46 | $check_id = $row["login_id"]; |
47 | 47 | $query = "SELECT * from total_message where (user1 = '$check_id' and user2 = '$userId') or (user2 = '$check_id' and user1 = '$userId')"; |
48 | - if($result1 = $this->connect->query($query)) |
|
48 | + if ($result1 = $this->connect->query($query)) |
|
49 | 49 | { |
50 | - if($result1->num_rows > 0) |
|
50 | + if ($result1->num_rows > 0) |
|
51 | 51 | { |
52 | 52 | $fetch = $result1->fetch_assoc(); |
53 | 53 | $fetch['time'] = $this->obTime->timeConversion($fetch['time']); |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | } |
60 | 60 | } |
61 | 61 | } |
62 | - if($flag != 0) |
|
62 | + if ($flag != 0) |
|
63 | 63 | { |
64 | 64 | $this->array = array_merge([], ["Search" => $this->array]); |
65 | 65 | return json_encode($this->array); |
@@ -36,13 +36,13 @@ discard block |
||
36 | 36 | |
37 | 37 | public function onMessage(ConnectionInterface $from, $msg) |
38 | 38 | { |
39 | - $msg = (object) json_decode($msg); |
|
40 | - if($msg->type == 'OpenChat initiated..!') |
|
39 | + $msg = (object)json_decode($msg); |
|
40 | + if ($msg->type == 'OpenChat initiated..!') |
|
41 | 41 | { |
42 | - $initial = (object) array(); |
|
42 | + $initial = (object)array(); |
|
43 | 43 | $initial->initial = json_decode($this->onSidebar($from->userId)); |
44 | 44 | |
45 | - if($initial->initial != null) |
|
45 | + if ($initial->initial != null) |
|
46 | 46 | { |
47 | 47 | $initial->conversation = json_decode( |
48 | 48 | $this->onConversation( |
@@ -58,14 +58,14 @@ discard block |
||
58 | 58 | } |
59 | 59 | elseif ($msg->type == 'Load Sidebar') |
60 | 60 | { |
61 | - $sidebar = (object) array(); |
|
61 | + $sidebar = (object)array(); |
|
62 | 62 | $sidebar->sidebar = json_decode($this->onSidebar($from->userId)); |
63 | 63 | $from->send(json_encode($sidebar)); |
64 | 64 | } |
65 | 65 | elseif ($msg->type == 'Initiated') |
66 | 66 | { |
67 | 67 | $msg->userId = $from->userId; |
68 | - $result = (object) array(); |
|
68 | + $result = (object)array(); |
|
69 | 69 | $result->conversation = json_decode($this->onConversation(json_encode($msg), False)); |
70 | 70 | $from->send(json_encode($result)); |
71 | 71 | } |
@@ -87,8 +87,8 @@ discard block |
||
87 | 87 | $getReturn = $this->onReply($msg); |
88 | 88 | echo $getReturn; |
89 | 89 | |
90 | - $receiveResult = (object) array(); |
|
91 | - $sentResult = (object) array(); |
|
90 | + $receiveResult = (object)array(); |
|
91 | + $sentResult = (object)array(); |
|
92 | 92 | foreach ($this->clients as $client) |
93 | 93 | { |
94 | 94 | if ($client->userId == $msg->name) |
@@ -107,7 +107,7 @@ discard block |
||
107 | 107 | |
108 | 108 | $client->send(json_encode($receiveResult)); |
109 | 109 | } |
110 | - elseif($client == $from) |
|
110 | + elseif ($client == $from) |
|
111 | 111 | { |
112 | 112 | $sentResult->sidebar = json_decode($this->onSidebar($client->userId)); |
113 | 113 |
@@ -1,7 +1,7 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | 3 | namespace ChatApp; |
4 | -require_once (dirname(__DIR__) . '/vendor/autoload.php'); |
|
4 | +require_once (dirname(__DIR__).'/vendor/autoload.php'); |
|
5 | 5 | use ChatApp\Time; |
6 | 6 | use ChatApp\User; |
7 | 7 | use Dotenv\Dotenv; |
@@ -35,38 +35,38 @@ discard block |
||
35 | 35 | public function conversationLoad($msg, $para) |
36 | 36 | { |
37 | 37 | $msg = json_decode($msg); |
38 | - if(!empty($msg)) |
|
38 | + if (!empty($msg)) |
|
39 | 39 | { |
40 | 40 | $userId = $msg->userId; |
41 | 41 | $add_load = 0; |
42 | 42 | $details = $msg->details; |
43 | 43 | $load = $msg->load; |
44 | 44 | |
45 | - if($para == True) |
|
45 | + if ($para == True) |
|
46 | 46 | { |
47 | 47 | $details = convert_uudecode(hex2bin($details)); |
48 | 48 | } |
49 | 49 | $fetch = $this->obUser->userDetails($details, $para); |
50 | 50 | |
51 | - if($fetch != NULL) |
|
51 | + if ($fetch != NULL) |
|
52 | 52 | { |
53 | 53 | $login_id = (int)$fetch['login_id']; |
54 | 54 | |
55 | 55 | // Unique Identifier |
56 | - if($login_id > $userId) |
|
56 | + if ($login_id > $userId) |
|
57 | 57 | $identifier = $userId.':'.$login_id; |
58 | 58 | else |
59 | 59 | $identifier = $login_id.':'.$userId; |
60 | 60 | |
61 | 61 | $query = "SELECT total_messages from total_message where identifier = '$identifier'"; |
62 | - if($result = $this->connect->query($query)) |
|
62 | + if ($result = $this->connect->query($query)) |
|
63 | 63 | { |
64 | - if($result->num_rows > 0) |
|
64 | + if ($result->num_rows > 0) |
|
65 | 65 | { |
66 | 66 | $total = $result->fetch_assoc(); |
67 | 67 | $total = $total['total_messages']; |
68 | - if($total - $load > 0) |
|
69 | - if($total - $load > 10) |
|
68 | + if ($total - $load > 0) |
|
69 | + if ($total - $load > 10) |
|
70 | 70 | $add_load = $load + 10; |
71 | 71 | else |
72 | 72 | $add_load = $total; |
@@ -74,14 +74,14 @@ discard block |
||
74 | 74 | } |
75 | 75 | |
76 | 76 | $query = "SELECT message, time, sent_by FROM messages WHERE identifier_message_number = '$identifier' ORDER BY id DESC limit ".$load; |
77 | - if($result = $this->connect->query($query)) |
|
77 | + if ($result = $this->connect->query($query)) |
|
78 | 78 | { |
79 | - if($result->num_rows > 0) |
|
79 | + if ($result->num_rows > 0) |
|
80 | 80 | { |
81 | - while($row = $result->fetch_assoc()) |
|
81 | + while ($row = $result->fetch_assoc()) |
|
82 | 82 | { |
83 | 83 | $row['time'] = $this->obTime->timeConversion($row['time']); |
84 | - $row = array_merge($row,['start' => $userId]); |
|
84 | + $row = array_merge($row, ['start' => $userId]); |
|
85 | 85 | $this->array = array_merge($this->array, [$row]); |
86 | 86 | } |
87 | 87 |
@@ -1,13 +1,13 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | -require_once (__DIR__ . '/vendor/autoload.php'); |
|
3 | +require_once (__DIR__.'/vendor/autoload.php'); |
|
4 | 4 | use ChatApp\Session; |
5 | 5 | use Dotenv\Dotenv; |
6 | 6 | $dotenv = new Dotenv(__DIR__); |
7 | 7 | $dotenv->load(); |
8 | 8 | |
9 | 9 | // die("Hello"); |
10 | -if(Session::get('start') != null) |
|
10 | +if (Session::get('start') != null) |
|
11 | 11 | { |
12 | 12 | header("Location:".getenv('APP_URL')."/views/account.php"); |
13 | 13 | } |
@@ -1,9 +1,9 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -require (dirname(__DIR__) . '/vendor/autoload.php'); |
|
3 | +require (dirname(__DIR__).'/vendor/autoload.php'); |
|
4 | 4 | use ChatApp\Register; |
5 | 5 | |
6 | -if(isset($_POST['q'])) |
|
6 | +if (isset($_POST['q'])) |
|
7 | 7 | { |
8 | 8 | $registerField = json_decode($_POST['q']); |
9 | 9 | $name = $registerField->name; |
@@ -20,7 +20,7 @@ discard block |
||
20 | 20 | 'mob' => $mob |
21 | 21 | ); |
22 | 22 | $result = $obRegister->authRegister($data); |
23 | - if(isset($result)) |
|
23 | + if (isset($result)) |
|
24 | 24 | echo $result; |
25 | 25 | else |
26 | 26 | echo json_encode([]); |
@@ -190,12 +190,12 @@ discard block |
||
190 | 190 | "passLogin" => 'testing' |
191 | 191 | ] |
192 | 192 | ); |
193 | - $outputEmail = (array) json_decode($outputEmail); |
|
193 | + $outputEmail = (array)json_decode($outputEmail); |
|
194 | 194 | $this->assertEquals($expectedOutput, $outputEmail); |
195 | 195 | $currentId = Session::get('start'); |
196 | 196 | Session::forget('start'); |
197 | 197 | |
198 | - $msg =(object) [ |
|
198 | + $msg = (object)[ |
|
199 | 199 | "name" => $userId, |
200 | 200 | "reply" => "Hello World", |
201 | 201 | "userId" => $currentId |
@@ -205,7 +205,7 @@ discard block |
||
205 | 205 | $output = $obReply->replyTo($msg); |
206 | 206 | $this->assertEquals("Messages is sent", $output); |
207 | 207 | |
208 | - $msg =(object) [ |
|
208 | + $msg = (object)[ |
|
209 | 209 | "name" => $currentId, |
210 | 210 | "reply" => "Hello World", |
211 | 211 | "userId" => $userId |
@@ -218,14 +218,14 @@ discard block |
||
218 | 218 | $output = $obReply->replyTo([]); |
219 | 219 | $this->assertEquals("Failed", $output); |
220 | 220 | |
221 | - $output = $obReply->replyTo((object) [ |
|
221 | + $output = $obReply->replyTo((object)[ |
|
222 | 222 | "name" => -1, |
223 | 223 | "reply" => "Hello World", |
224 | 224 | "userId" => $currentId |
225 | 225 | ]); |
226 | 226 | $this->assertEquals("Invalid Authentication", $output); |
227 | 227 | |
228 | - $output = $obReply->replyTo((object) [ |
|
228 | + $output = $obReply->replyTo((object)[ |
|
229 | 229 | "name" => $userId, |
230 | 230 | "reply" => "Hello", |
231 | 231 | "userId" => $currentId |
@@ -1,7 +1,7 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | 3 | namespace ChatApp; |
4 | -require_once (dirname(__DIR__) . '/vendor/autoload.php'); |
|
4 | +require_once (dirname(__DIR__).'/vendor/autoload.php'); |
|
5 | 5 | use ChatApp\Session; |
6 | 6 | use Dotenv\Dotenv; |
7 | 7 | $dotenv = new Dotenv(dirname(__DIR__)); |
@@ -36,13 +36,13 @@ discard block |
||
36 | 36 | |
37 | 37 | if (preg_match("/^.+[@]{1}.+$/", $login)) |
38 | 38 | { |
39 | - if(filter_var($login, FILTER_VALIDATE_EMAIL) == false) |
|
39 | + if (filter_var($login, FILTER_VALIDATE_EMAIL) == false) |
|
40 | 40 | { |
41 | 41 | $this->onError("login", " *Enter correct Email address"); |
42 | 42 | } |
43 | 43 | } |
44 | 44 | |
45 | - if($this->flag == 0) |
|
45 | + if ($this->flag == 0) |
|
46 | 46 | { |
47 | 47 | $password = md5($password); |
48 | 48 | $query = "SELECT * FROM login WHERE email = '$login' or username = '$login'"; |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | $row = $result->fetch_assoc(); |
54 | 54 | $loginID = $row['login_id']; |
55 | 55 | $query = "SELECT id FROM register WHERE id = '$loginID' and password = '$password'"; |
56 | - if($result = $this->connect->query($query)) |
|
56 | + if ($result = $this->connect->query($query)) |
|
57 | 57 | { |
58 | 58 | if ($result->num_rows > 0) |
59 | 59 | { |
@@ -65,12 +65,12 @@ discard block |
||
65 | 65 | $this->onError("passLogin", " *Invalid password"); |
66 | 66 | return json_encode($this->error); |
67 | 67 | } |
68 | - return json_encode(["Error" => "You are not registered, ".$this->connect->error ]); |
|
68 | + return json_encode(["Error" => "You are not registered, ".$this->connect->error]); |
|
69 | 69 | } |
70 | 70 | $this->onError("login", " *Invalid username or email"); |
71 | 71 | return json_encode($this->error); |
72 | 72 | } |
73 | - return json_encode(["Error" => "You are not registered, ".$this->connect->error ]); |
|
73 | + return json_encode(["Error" => "You are not registered, ".$this->connect->error]); |
|
74 | 74 | } |
75 | 75 | else |
76 | 76 | { |
@@ -94,7 +94,7 @@ discard block |
||
94 | 94 | foreach ($data as $key => $value) { |
95 | 95 | $data[$key] = trim($data[$key]); |
96 | 96 | $value = trim($value); |
97 | - if(empty($value)) |
|
97 | + if (empty($value)) |
|
98 | 98 | { |
99 | 99 | $this->onError($key, $errorCode[$key]); |
100 | 100 | } |
@@ -2,7 +2,7 @@ discard block |
||
2 | 2 | |
3 | 3 | |
4 | 4 | namespace ChatApp; |
5 | -require_once (dirname(__DIR__) . '/vendor/autoload.php'); |
|
5 | +require_once (dirname(__DIR__).'/vendor/autoload.php'); |
|
6 | 6 | use Dotenv\Dotenv; |
7 | 7 | $dotenv = new Dotenv(dirname(__DIR__)); |
8 | 8 | $dotenv->load(); |
@@ -30,7 +30,7 @@ discard block |
||
30 | 30 | |
31 | 31 | public function userDetails($details, $para) |
32 | 32 | { |
33 | - if($para == True) |
|
33 | + if ($para == True) |
|
34 | 34 | { |
35 | 35 | $this->query = "SELECT * from login where login_id = '$details'"; |
36 | 36 | } |
@@ -39,7 +39,7 @@ discard block |
||
39 | 39 | $this->query = "SELECT * from login where username = '$details'"; |
40 | 40 | } |
41 | 41 | $this->result = $this->connect->query($this->query); |
42 | - if($this->result->num_rows > 0) // if true |
|
42 | + if ($this->result->num_rows > 0) // if true |
|
43 | 43 | { |
44 | 44 | $this->details = $this->result->fetch_assoc(); |
45 | 45 | return $this->details; |
@@ -1,7 +1,7 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | 3 | namespace ChatApp; |
4 | -require_once (dirname(__DIR__) . '/vendor/autoload.php'); |
|
4 | +require_once (dirname(__DIR__).'/vendor/autoload.php'); |
|
5 | 5 | use ChatApp\Session; |
6 | 6 | use Dotenv\Dotenv; |
7 | 7 | $dotenv = new Dotenv(dirname(__DIR__)); |
@@ -33,14 +33,14 @@ discard block |
||
33 | 33 | $userId = $msg->userId; |
34 | 34 | $suggestion = $msg->value; |
35 | 35 | $suggestion = trim($suggestion); |
36 | - if(!empty($userId) && !empty($suggestion)) |
|
36 | + if (!empty($userId) && !empty($suggestion)) |
|
37 | 37 | { |
38 | 38 | $query = "SELECT * FROM login where login_id != '$userId' and name like '$suggestion%' ORDER BY name DESC"; |
39 | - if($result = $this->connect->query($query)) |
|
39 | + if ($result = $this->connect->query($query)) |
|
40 | 40 | { |
41 | - if($result->num_rows > 0) |
|
41 | + if ($result->num_rows > 0) |
|
42 | 42 | { |
43 | - while($row = $result->fetch_assoc()) |
|
43 | + while ($row = $result->fetch_assoc()) |
|
44 | 44 | { |
45 | 45 | $row["login_id"] = bin2hex(convert_uuencode($row["login_id"])); |
46 | 46 | $this->array = array_merge($this->array, [$row]); |