@@ -25,6 +25,9 @@ discard block |
||
25 | 25 | Online::setOnlineStatus($conn->userId); |
26 | 26 | } |
27 | 27 | |
28 | + /** |
|
29 | + * @param ConnectionInterface $conn |
|
30 | + */ |
|
28 | 31 | public function setID($conn) |
29 | 32 | { |
30 | 33 | session_id($conn->WebSocket->request->getCookies()['PHPSESSID']); |
@@ -136,12 +139,20 @@ discard block |
||
136 | 139 | return $obSidebar->loadSideBar($data); |
137 | 140 | } |
138 | 141 | |
142 | + /** |
|
143 | + * @param string $data |
|
144 | + * @param boolean $para |
|
145 | + */ |
|
139 | 146 | public function onConversation($data, $para) |
140 | 147 | { |
141 | 148 | $obConversation = new Conversation(); |
142 | 149 | return $obConversation->conversationLoad($data, $para); |
143 | 150 | } |
144 | 151 | |
152 | + /** |
|
153 | + * @param string $data |
|
154 | + * @param boolean $para |
|
155 | + */ |
|
145 | 156 | public function onReceiver($data, $para) |
146 | 157 | { |
147 | 158 | $obReceiver = new Receiver(); |
@@ -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; |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | { |
37 | 37 | $msg = json_decode($msg); |
38 | 38 | |
39 | - if(!empty($msg)) |
|
39 | + if (!empty($msg)) |
|
40 | 40 | { |
41 | 41 | $userId = $msg->userId; |
42 | 42 | $add_load = 0; |
@@ -45,25 +45,25 @@ discard block |
||
45 | 45 | |
46 | 46 | $fetch = $this->obUser->userDetails($username, $para); |
47 | 47 | |
48 | - if($fetch != NULL) |
|
48 | + if ($fetch != NULL) |
|
49 | 49 | { |
50 | 50 | $login_id = (int)$fetch['login_id']; |
51 | 51 | |
52 | 52 | // Unique Identifier |
53 | - if($login_id > $userId) |
|
53 | + if ($login_id > $userId) |
|
54 | 54 | $identifier = $userId.':'.$login_id; |
55 | 55 | else |
56 | 56 | $identifier = $login_id.':'.$userId; |
57 | 57 | |
58 | 58 | $query = "SELECT total_messages from total_message where identifier = '$identifier'"; |
59 | - if($result = $this->connect->query($query)) |
|
59 | + if ($result = $this->connect->query($query)) |
|
60 | 60 | { |
61 | - if($result->num_rows > 0) |
|
61 | + if ($result->num_rows > 0) |
|
62 | 62 | { |
63 | 63 | $total = $result->fetch_assoc(); |
64 | 64 | $total = $total['total_messages']; |
65 | - if($total - $load > 0) |
|
66 | - if($total - $load > 10) |
|
65 | + if ($total - $load > 0) |
|
66 | + if ($total - $load > 10) |
|
67 | 67 | $add_load = $load + 10; |
68 | 68 | else |
69 | 69 | $add_load = $total; |
@@ -71,14 +71,14 @@ discard block |
||
71 | 71 | } |
72 | 72 | |
73 | 73 | $query = "SELECT message, time, sent_by FROM messages WHERE identifier_message_number = '$identifier' ORDER BY id DESC limit ".$load; |
74 | - if($result = $this->connect->query($query)) |
|
74 | + if ($result = $this->connect->query($query)) |
|
75 | 75 | { |
76 | - if($result->num_rows > 0) |
|
76 | + if ($result->num_rows > 0) |
|
77 | 77 | { |
78 | - while($row = $result->fetch_assoc()) |
|
78 | + while ($row = $result->fetch_assoc()) |
|
79 | 79 | { |
80 | 80 | $row['time'] = $this->obTime->timeConversion($row['time']); |
81 | - $row = array_merge($row,['start' => $userId]); |
|
81 | + $row = array_merge($row, ['start' => $userId]); |
|
82 | 82 | $this->array = array_merge($this->array, [$row]); |
83 | 83 | } |
84 | 84 |
@@ -50,10 +50,11 @@ discard block |
||
50 | 50 | $login_id = (int)$fetch['login_id']; |
51 | 51 | |
52 | 52 | // Unique Identifier |
53 | - if($login_id > $userId) |
|
54 | - $identifier = $userId.':'.$login_id; |
|
55 | - else |
|
56 | - $identifier = $login_id.':'.$userId; |
|
53 | + if($login_id > $userId) { |
|
54 | + $identifier = $userId.':'.$login_id; |
|
55 | + } else { |
|
56 | + $identifier = $login_id.':'.$userId; |
|
57 | + } |
|
57 | 58 | |
58 | 59 | $query = "SELECT total_messages from total_message where identifier = '$identifier'"; |
59 | 60 | if($result = $this->connect->query($query)) |
@@ -62,11 +63,12 @@ discard block |
||
62 | 63 | { |
63 | 64 | $total = $result->fetch_assoc(); |
64 | 65 | $total = $total['total_messages']; |
65 | - if($total - $load > 0) |
|
66 | - if($total - $load > 10) |
|
66 | + if($total - $load > 0) { |
|
67 | + if($total - $load > 10) |
|
67 | 68 | $add_load = $load + 10; |
68 | - else |
|
69 | - $add_load = $total; |
|
69 | + } else { |
|
70 | + $add_load = $total; |
|
71 | + } |
|
70 | 72 | } |
71 | 73 | } |
72 | 74 | |
@@ -84,8 +86,7 @@ discard block |
||
84 | 86 | |
85 | 87 | $this->array = array_merge([['name' => $fetch['name'], 'username' => $fetch['username'], 'id' => $fetch['login_id'], 'load' => $add_load, 'login_status' => $fetch['login_status'], 'type' => 1]], $this->array); |
86 | 88 | return json_encode($this->array); |
87 | - } |
|
88 | - else |
|
89 | + } else |
|
89 | 90 | { |
90 | 91 | return json_encode([['name' => $fetch['name'], 'username' => $fetch['username'], 'id' => $fetch['login_id'], 'login_status' => $fetch['login_status'], 'type' => 0]]); |
91 | 92 | } |
@@ -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,23 +34,23 @@ discard block |
||
34 | 34 | $userId = $suggestion->userId; |
35 | 35 | $suggestion = $suggestion->value; |
36 | 36 | $flag = 0; |
37 | - if(!empty($userId) && !empty($suggestion)) |
|
37 | + if (!empty($userId) && !empty($suggestion)) |
|
38 | 38 | { |
39 | 39 | $suggestion = trim($suggestion); |
40 | - if($suggestion != "") |
|
40 | + if ($suggestion != "") |
|
41 | 41 | { |
42 | 42 | $query = "SELECT * FROM login where login_id != '$userId' and name like '$suggestion%' ORDER BY name DESC"; |
43 | - if($result = $this->connect->query($query)) |
|
43 | + if ($result = $this->connect->query($query)) |
|
44 | 44 | { |
45 | - if($result->num_rows > 0) |
|
45 | + if ($result->num_rows > 0) |
|
46 | 46 | { |
47 | - while($row = $result->fetch_assoc()) |
|
47 | + while ($row = $result->fetch_assoc()) |
|
48 | 48 | { |
49 | 49 | $check_id = $row["login_id"]; |
50 | 50 | $query = "SELECT * from total_message where (user1 = '$check_id' and user2 = '$userId') or (user2 = '$check_id' and user1 = '$userId')"; |
51 | - if($result1 = $this->connect->query($query)) |
|
51 | + if ($result1 = $this->connect->query($query)) |
|
52 | 52 | { |
53 | - if($result1->num_rows > 0) |
|
53 | + if ($result1->num_rows > 0) |
|
54 | 54 | { |
55 | 55 | $fetch = $result1->fetch_assoc(); |
56 | 56 | $fetch['time'] = $this->obTime->timeConversion($fetch['time']); |
@@ -62,7 +62,7 @@ discard block |
||
62 | 62 | } |
63 | 63 | } |
64 | 64 | } |
65 | - if($flag != 0) |
|
65 | + if ($flag != 0) |
|
66 | 66 | { |
67 | 67 | $this->array = array_merge([], ["Search" => $this->array]); |
68 | 68 | return json_encode($this->array); |