@@ -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\Login; |
| 5 | 5 | |
| 6 | -if(isset($_POST['q'])) |
|
| 6 | +if (isset($_POST['q'])) |
|
| 7 | 7 | { |
| 8 | 8 | $loginField = json_decode($_POST['q']); |
| 9 | 9 | $login = $loginField->login; |
@@ -14,7 +14,7 @@ discard block |
||
| 14 | 14 | 'passLogin' => $password |
| 15 | 15 | ); |
| 16 | 16 | $result = $obLogin->authLogin($data); |
| 17 | - if(isset($result)) |
|
| 17 | + if (isset($result)) |
|
| 18 | 18 | echo $result; |
| 19 | 19 | else |
| 20 | 20 | echo json_encode([]); |
@@ -14,8 +14,9 @@ |
||
| 14 | 14 | 'passLogin' => $password |
| 15 | 15 | ); |
| 16 | 16 | $result = $obLogin->authLogin($data); |
| 17 | - if(isset($result)) |
|
| 18 | - echo $result; |
|
| 19 | - else |
|
| 20 | - echo json_encode([]); |
|
| 21 | -} |
|
| 22 | 17 | \ No newline at end of file |
| 18 | + if(isset($result)) { |
|
| 19 | + echo $result; |
|
| 20 | + } else { |
|
| 21 | + echo json_encode([]); |
|
| 22 | + } |
|
| 23 | + } |
|
| 23 | 24 | \ No newline at end of file |
@@ -51,9 +51,9 @@ discard block |
||
| 51 | 51 | } |
| 52 | 52 | |
| 53 | 53 | /** |
| 54 | - * @depends test_authRegister |
|
| 55 | - * Testing for the register with empty username |
|
| 56 | - */ |
|
| 54 | + * @depends test_authRegister |
|
| 55 | + * Testing for the register with empty username |
|
| 56 | + */ |
|
| 57 | 57 | public function test_authregisterEmptyUsername() |
| 58 | 58 | { |
| 59 | 59 | $output = $this->obRegister->authregister( |
@@ -77,9 +77,9 @@ discard block |
||
| 77 | 77 | } |
| 78 | 78 | |
| 79 | 79 | /** |
| 80 | - * @depends test_authRegister |
|
| 81 | - * Testing for the register with invalid email credentials |
|
| 82 | - */ |
|
| 80 | + * @depends test_authRegister |
|
| 81 | + * Testing for the register with invalid email credentials |
|
| 82 | + */ |
|
| 83 | 83 | public function test_authregisterInvalidEmail() |
| 84 | 84 | { |
| 85 | 85 | $output = $this->obRegister->authregister( |
@@ -103,9 +103,9 @@ discard block |
||
| 103 | 103 | } |
| 104 | 104 | |
| 105 | 105 | /** |
| 106 | - * @depends test_authRegister |
|
| 107 | - * Testing for the register with repeated credentials |
|
| 108 | - */ |
|
| 106 | + * @depends test_authRegister |
|
| 107 | + * Testing for the register with repeated credentials |
|
| 108 | + */ |
|
| 109 | 109 | public function test_authregisterInvalidCredentials() |
| 110 | 110 | { |
| 111 | 111 | $output = $this->obRegister->authregister( |
@@ -137,9 +137,9 @@ discard block |
||
| 137 | 137 | } |
| 138 | 138 | |
| 139 | 139 | /** |
| 140 | - * @depends test_authRegister |
|
| 141 | - * Testing for the login with correct credentials |
|
| 142 | - */ |
|
| 140 | + * @depends test_authRegister |
|
| 141 | + * Testing for the login with correct credentials |
|
| 142 | + */ |
|
| 143 | 143 | |
| 144 | 144 | public function test_authLogin() |
| 145 | 145 | { |
@@ -163,9 +163,9 @@ discard block |
||
| 163 | 163 | } |
| 164 | 164 | |
| 165 | 165 | /** |
| 166 | - * @depends test_authRegister |
|
| 167 | - * Testing for the login with empty credentials |
|
| 168 | - */ |
|
| 166 | + * @depends test_authRegister |
|
| 167 | + * Testing for the login with empty credentials |
|
| 168 | + */ |
|
| 169 | 169 | |
| 170 | 170 | public function test_authLoginEmptyValues() |
| 171 | 171 | { |
@@ -191,9 +191,9 @@ discard block |
||
| 191 | 191 | } |
| 192 | 192 | |
| 193 | 193 | /** |
| 194 | - * @depends test_authRegister |
|
| 195 | - * Testing for the login with invalid or wrong email |
|
| 196 | - */ |
|
| 194 | + * @depends test_authRegister |
|
| 195 | + * Testing for the login with invalid or wrong email |
|
| 196 | + */ |
|
| 197 | 197 | |
| 198 | 198 | public function test_authLoginWrongEmail() |
| 199 | 199 | { |
@@ -215,9 +215,9 @@ discard block |
||
| 215 | 215 | } |
| 216 | 216 | |
| 217 | 217 | /** |
| 218 | - * @depends test_authRegister |
|
| 219 | - * Testing for the login with invalid email credentials |
|
| 220 | - */ |
|
| 218 | + * @depends test_authRegister |
|
| 219 | + * Testing for the login with invalid email credentials |
|
| 220 | + */ |
|
| 221 | 221 | public function test_authLoginInvalidUsernameEmail() |
| 222 | 222 | { |
| 223 | 223 | $output = $this->obLogin->authLogin( |
@@ -238,9 +238,9 @@ discard block |
||
| 238 | 238 | } |
| 239 | 239 | |
| 240 | 240 | /** |
| 241 | - * @depends test_authRegister |
|
| 242 | - * Testing for the login with invalid password credentials |
|
| 243 | - */ |
|
| 241 | + * @depends test_authRegister |
|
| 242 | + * Testing for the login with invalid password credentials |
|
| 243 | + */ |
|
| 244 | 244 | public function test_authLoginInvalidPassword() |
| 245 | 245 | { |
| 246 | 246 | $output = $this->obLogin->authLogin( |
@@ -260,9 +260,9 @@ discard block |
||
| 260 | 260 | } |
| 261 | 261 | |
| 262 | 262 | /** |
| 263 | - * @depends test_authRegister |
|
| 264 | - * Testing for the Profile::class with valid login_id |
|
| 265 | - */ |
|
| 263 | + * @depends test_authRegister |
|
| 264 | + * Testing for the Profile::class with valid login_id |
|
| 265 | + */ |
|
| 266 | 266 | public function test_getProfile() |
| 267 | 267 | { |
| 268 | 268 | $output = Profile::getProfile(1); |
@@ -275,9 +275,9 @@ discard block |
||
| 275 | 275 | } |
| 276 | 276 | |
| 277 | 277 | /** |
| 278 | - * @depends test_authRegister |
|
| 279 | - * Testing for the Profile::class with invalid login_id |
|
| 280 | - */ |
|
| 278 | + * @depends test_authRegister |
|
| 279 | + * Testing for the Profile::class with invalid login_id |
|
| 280 | + */ |
|
| 281 | 281 | public function test_getProfileInvalidID() |
| 282 | 282 | { |
| 283 | 283 | $output = Profile::getProfile(0); |
@@ -285,9 +285,9 @@ discard block |
||
| 285 | 285 | } |
| 286 | 286 | |
| 287 | 287 | /** |
| 288 | - * @depends test_authRegister |
|
| 289 | - * Testing for the User::class with valid login_id |
|
| 290 | - */ |
|
| 288 | + * @depends test_authRegister |
|
| 289 | + * Testing for the User::class with valid login_id |
|
| 290 | + */ |
|
| 291 | 291 | public function test_userDetails() |
| 292 | 292 | { |
| 293 | 293 | $expectedOutput = [ |
@@ -306,9 +306,9 @@ discard block |
||
| 306 | 306 | } |
| 307 | 307 | |
| 308 | 308 | /** |
| 309 | - * @depends test_authRegister |
|
| 310 | - * Testing for the User::class with invalid data |
|
| 311 | - */ |
|
| 309 | + * @depends test_authRegister |
|
| 310 | + * Testing for the User::class with invalid data |
|
| 311 | + */ |
|
| 312 | 312 | public function test_userDetailsInvalidID() |
| 313 | 313 | { |
| 314 | 314 | $output = $this->obUser->userDetails(0, True); |
@@ -316,9 +316,9 @@ discard block |
||
| 316 | 316 | } |
| 317 | 317 | |
| 318 | 318 | /** |
| 319 | - * @depends test_authRegister |
|
| 320 | - * Testing for the Validate::class for email |
|
| 321 | - */ |
|
| 319 | + * @depends test_authRegister |
|
| 320 | + * Testing for the Validate::class for email |
|
| 321 | + */ |
|
| 322 | 322 | public function test_validateEmailInDb() |
| 323 | 323 | { |
| 324 | 324 | $output = $this->obValidate->validateEmailInDb('[email protected]'); |
@@ -326,9 +326,9 @@ discard block |
||
| 326 | 326 | } |
| 327 | 327 | |
| 328 | 328 | /** |
| 329 | - * @depends test_authRegister |
|
| 330 | - * Testing for the Validate::class for username |
|
| 331 | - */ |
|
| 329 | + * @depends test_authRegister |
|
| 330 | + * Testing for the Validate::class for username |
|
| 331 | + */ |
|
| 332 | 332 | public function test_validateUsernameInDb() |
| 333 | 333 | { |
| 334 | 334 | $output = $this->obValidate->validateUsernameInDb('test'); |
@@ -336,9 +336,9 @@ discard block |
||
| 336 | 336 | } |
| 337 | 337 | |
| 338 | 338 | /** |
| 339 | - * @depends test_authRegister |
|
| 340 | - * Testing for the Validate::class for non-existing username |
|
| 341 | - */ |
|
| 339 | + * @depends test_authRegister |
|
| 340 | + * Testing for the Validate::class for non-existing username |
|
| 341 | + */ |
|
| 342 | 342 | public function test_validateUsernameInDbNot() |
| 343 | 343 | { |
| 344 | 344 | $output = $this->obValidate->validateUsernameInDb('abc'); |
@@ -346,9 +346,9 @@ discard block |
||
| 346 | 346 | } |
| 347 | 347 | |
| 348 | 348 | /** |
| 349 | - * @depends test_authRegister |
|
| 350 | - * Testing for the Validate::class for non-existing email |
|
| 351 | - */ |
|
| 349 | + * @depends test_authRegister |
|
| 350 | + * Testing for the Validate::class for non-existing email |
|
| 351 | + */ |
|
| 352 | 352 | public function test_validateEmailInDbNot() |
| 353 | 353 | { |
| 354 | 354 | $output = $this->obValidate->validateEmailInDb('[email protected]'); |
@@ -356,9 +356,9 @@ discard block |
||
| 356 | 356 | } |
| 357 | 357 | |
| 358 | 358 | /** |
| 359 | - * @depends test_authRegister |
|
| 360 | - * Testing for the Online::class |
|
| 361 | - */ |
|
| 359 | + * @depends test_authRegister |
|
| 360 | + * Testing for the Online::class |
|
| 361 | + */ |
|
| 362 | 362 | public function test_Online() |
| 363 | 363 | { |
| 364 | 364 | Online::setOnlineStatus(1); |
@@ -373,9 +373,9 @@ discard block |
||
| 373 | 373 | |
| 374 | 374 | |
| 375 | 375 | /** |
| 376 | - * @depends test_Online |
|
| 377 | - * Empty the DB |
|
| 378 | - */ |
|
| 376 | + * @depends test_Online |
|
| 377 | + * Empty the DB |
|
| 378 | + */ |
|
| 379 | 379 | public function test_EmptyDB() |
| 380 | 380 | { |
| 381 | 381 | $connect = mysqli_connect( |
@@ -8,7 +8,6 @@ |
||
| 8 | 8 | use ChatApp\Compose; |
| 9 | 9 | use ChatApp\Reply; |
| 10 | 10 | use ChatApp\Session; |
| 11 | - |
|
| 12 | 11 | use Dotenv\Dotenv; |
| 13 | 12 | $dotenv = new Dotenv(dirname(__DIR__)); |
| 14 | 13 | $dotenv->load(); |
@@ -49,9 +49,9 @@ discard block |
||
| 49 | 49 | } |
| 50 | 50 | |
| 51 | 51 | /** |
| 52 | - * @depends testAuthRegister |
|
| 53 | - * Register User2 |
|
| 54 | - */ |
|
| 52 | + * @depends testAuthRegister |
|
| 53 | + * Register User2 |
|
| 54 | + */ |
|
| 55 | 55 | public function testAuthRegister2() |
| 56 | 56 | { |
| 57 | 57 | $output = $this->obRegister->authRegister( |
@@ -76,9 +76,9 @@ discard block |
||
| 76 | 76 | } |
| 77 | 77 | |
| 78 | 78 | /** |
| 79 | - * @depends testAuthRegister2 |
|
| 80 | - * Testing for the register with empty username |
|
| 81 | - */ |
|
| 79 | + * @depends testAuthRegister2 |
|
| 80 | + * Testing for the register with empty username |
|
| 81 | + */ |
|
| 82 | 82 | public function testCompose() |
| 83 | 83 | { |
| 84 | 84 | $expectedOutput = ['location' => 'http://127.0.0.1/openchat/views/account.php']; |
@@ -133,9 +133,9 @@ discard block |
||
| 133 | 133 | } |
| 134 | 134 | |
| 135 | 135 | /** |
| 136 | - * @depends testAuthRegister2 |
|
| 137 | - * Testing for Search Class |
|
| 138 | - */ |
|
| 136 | + * @depends testAuthRegister2 |
|
| 137 | + * Testing for Search Class |
|
| 138 | + */ |
|
| 139 | 139 | public function testSearch($userId) |
| 140 | 140 | { |
| 141 | 141 | $expectedOutput = ['location' => 'http://127.0.0.1/openchat/views/account.php']; |
@@ -175,9 +175,9 @@ discard block |
||
| 175 | 175 | } |
| 176 | 176 | |
| 177 | 177 | /** |
| 178 | - * @depends testAuthRegister2 |
|
| 179 | - * Testing for Reply Class |
|
| 180 | - */ |
|
| 178 | + * @depends testAuthRegister2 |
|
| 179 | + * Testing for Reply Class |
|
| 180 | + */ |
|
| 181 | 181 | public function testReply($userId) |
| 182 | 182 | { |
| 183 | 183 | $msg = [ |
@@ -228,9 +228,9 @@ discard block |
||
| 228 | 228 | } |
| 229 | 229 | |
| 230 | 230 | /** |
| 231 | - * @depends testReply |
|
| 232 | - * Testing for Search Class |
|
| 233 | - */ |
|
| 231 | + * @depends testReply |
|
| 232 | + * Testing for Search Class |
|
| 233 | + */ |
|
| 234 | 234 | public function testSearchWithTotalMessages() |
| 235 | 235 | { |
| 236 | 236 | $expectedOutput = ['location' => 'http://127.0.0.1/openchat/views/account.php']; |
@@ -257,9 +257,9 @@ discard block |
||
| 257 | 257 | |
| 258 | 258 | |
| 259 | 259 | /** |
| 260 | - * @depends testSearchWithTotalMessages |
|
| 261 | - * Empty the DB |
|
| 262 | - */ |
|
| 260 | + * @depends testSearchWithTotalMessages |
|
| 261 | + * Empty the DB |
|
| 262 | + */ |
|
| 263 | 263 | public function test_EmptyDB() |
| 264 | 264 | { |
| 265 | 265 | $connect = mysqli_connect( |
@@ -180,7 +180,7 @@ discard block |
||
| 180 | 180 | */ |
| 181 | 181 | public function testReply($userId) |
| 182 | 182 | { |
| 183 | - $msg =(object) [ |
|
| 183 | + $msg = (object)[ |
|
| 184 | 184 | "name" => $userId, |
| 185 | 185 | "reply" => [ |
| 186 | 186 | 0 => "Hello World" |
@@ -207,7 +207,7 @@ discard block |
||
| 207 | 207 | $output = $obReply->replyTo([]); |
| 208 | 208 | $this->assertEquals("Failed", $output); |
| 209 | 209 | |
| 210 | - $output = $obReply->replyTo((object) [ |
|
| 210 | + $output = $obReply->replyTo((object)[ |
|
| 211 | 211 | "name" => -1, |
| 212 | 212 | "reply" => [ |
| 213 | 213 | 0 => "Hello World" |
@@ -216,7 +216,7 @@ discard block |
||
| 216 | 216 | ]); |
| 217 | 217 | $this->assertEquals("Invalid Authentication", $output); |
| 218 | 218 | |
| 219 | - $output = $obReply->replyTo((object) [ |
|
| 219 | + $output = $obReply->replyTo((object)[ |
|
| 220 | 220 | "name" => $userId, |
| 221 | 221 | "reply" => [ |
| 222 | 222 | 0 => "Hello" |
@@ -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 | $this->array = array_merge($this->array, [$row]); |
| 46 | 46 | } |
@@ -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); |