@@ -51,19 +51,19 @@ discard block |
||
| 51 | 51 | $rows = DB::query( |
| 52 | 52 | 'SELECT i.id, label, description, i.pw, i.url, i.id_tree, i.login, i.email, i.viewed_no, i.fa_icon, i.inactif, i.perso, |
| 53 | 53 | t.title as folder_label, io.secret as otp_secret |
| 54 | - FROM ' . prefixTable('items') . ' AS i |
|
| 54 | + FROM ' . prefixTable('items').' AS i |
|
| 55 | 55 | LEFT JOIN '.prefixTable('nested_tree').' as t ON (t.id = i.id_tree) |
| 56 | 56 | LEFT JOIN '.prefixTable('items_otp').' as io ON (io.item_id = i.id) '. |
| 57 | - $sqlExtra . |
|
| 58 | - " ORDER BY i.id ASC" . |
|
| 59 | - ($limit > 0 ? " LIMIT ". $limit : '') |
|
| 57 | + $sqlExtra. |
|
| 58 | + " ORDER BY i.id ASC". |
|
| 59 | + ($limit > 0 ? " LIMIT ".$limit : '') |
|
| 60 | 60 | ); |
| 61 | 61 | |
| 62 | 62 | $ret = []; |
| 63 | 63 | foreach ($rows as $row) { |
| 64 | 64 | $userKey = DB::queryfirstrow( |
| 65 | 65 | 'SELECT share_key |
| 66 | - FROM ' . prefixTable('sharekeys_items') . ' |
|
| 66 | + FROM ' . prefixTable('sharekeys_items').' |
|
| 67 | 67 | WHERE user_id = %i AND object_id = %i', |
| 68 | 68 | $userId, |
| 69 | 69 | $row['id'] |
@@ -100,7 +100,7 @@ discard block |
||
| 100 | 100 | if (empty($path) === true) { |
| 101 | 101 | $path = htmlspecialchars(stripslashes(htmlspecialchars_decode($elem->title, ENT_QUOTES)), ENT_QUOTES); |
| 102 | 102 | } else { |
| 103 | - $path .= '/' . htmlspecialchars(stripslashes(htmlspecialchars_decode($elem->title, ENT_QUOTES)), ENT_QUOTES); |
|
| 103 | + $path .= '/'.htmlspecialchars(stripslashes(htmlspecialchars_decode($elem->title, ENT_QUOTES)), ENT_QUOTES); |
|
| 104 | 104 | } |
| 105 | 105 | } |
| 106 | 106 | |
@@ -162,7 +162,7 @@ discard block |
||
| 162 | 162 | ) : array |
| 163 | 163 | { |
| 164 | 164 | try { |
| 165 | - include_once API_ROOT_PATH . '/../sources/main.functions.php'; |
|
| 165 | + include_once API_ROOT_PATH.'/../sources/main.functions.php'; |
|
| 166 | 166 | |
| 167 | 167 | // Load config |
| 168 | 168 | $configManager = new ConfigManager(); |
@@ -288,7 +288,7 @@ discard block |
||
| 288 | 288 | } |
| 289 | 289 | |
| 290 | 290 | if (strlen($password) > $SETTINGS['pwd_maximum_length']) { |
| 291 | - throw new Exception('Password is too long (max allowed is ' . $SETTINGS['pwd_maximum_length'] . ' characters)'); |
|
| 291 | + throw new Exception('Password is too long (max allowed is '.$SETTINGS['pwd_maximum_length'].' characters)'); |
|
| 292 | 292 | } |
| 293 | 293 | } |
| 294 | 294 | |
@@ -301,7 +301,7 @@ discard block |
||
| 301 | 301 | { |
| 302 | 302 | $dataFolderSettings = DB::queryFirstRow( |
| 303 | 303 | 'SELECT bloquer_creation, bloquer_modification, personal_folder |
| 304 | - FROM ' . prefixTable('nested_tree') . ' |
|
| 304 | + FROM ' . prefixTable('nested_tree').' |
|
| 305 | 305 | WHERE id = %i', |
| 306 | 306 | $folderId |
| 307 | 307 | ); |
@@ -324,7 +324,7 @@ discard block |
||
| 324 | 324 | { |
| 325 | 325 | $folderComplexity = DB::queryFirstRow( |
| 326 | 326 | 'SELECT valeur |
| 327 | - FROM ' . prefixTable('misc') . ' |
|
| 327 | + FROM ' . prefixTable('misc').' |
|
| 328 | 328 | WHERE type = %s AND intitule = %i', |
| 329 | 329 | 'complex', |
| 330 | 330 | $itemInfos['folderId'] |
@@ -352,7 +352,7 @@ discard block |
||
| 352 | 352 | private function checkForDuplicates(string $label, array $SETTINGS, array $itemInfos) : void |
| 353 | 353 | { |
| 354 | 354 | DB::queryFirstRow( |
| 355 | - 'SELECT * FROM ' . prefixTable('items') . ' |
|
| 355 | + 'SELECT * FROM '.prefixTable('items').' |
|
| 356 | 356 | WHERE label = %s AND inactif = %i', |
| 357 | 357 | $label, |
| 358 | 358 | 0 |
@@ -390,7 +390,7 @@ discard block |
||
| 390 | 390 | */ |
| 391 | 391 | private function insertNewItem(array $data, string $password, array $itemInfos) : int |
| 392 | 392 | { |
| 393 | - include_once API_ROOT_PATH . '/../sources/main.functions.php'; |
|
| 393 | + include_once API_ROOT_PATH.'/../sources/main.functions.php'; |
|
| 394 | 394 | |
| 395 | 395 | DB::insert( |
| 396 | 396 | prefixTable('items'), |
@@ -556,7 +556,7 @@ discard block |
||
| 556 | 556 | ): array |
| 557 | 557 | { |
| 558 | 558 | try { |
| 559 | - include_once API_ROOT_PATH . '/../sources/main.functions.php'; |
|
| 559 | + include_once API_ROOT_PATH.'/../sources/main.functions.php'; |
|
| 560 | 560 | |
| 561 | 561 | // Load config |
| 562 | 562 | $configManager = new ConfigManager(); |
@@ -564,7 +564,7 @@ discard block |
||
| 564 | 564 | |
| 565 | 565 | // Load current item data |
| 566 | 566 | $currentItem = DB::queryFirstRow( |
| 567 | - 'SELECT * FROM ' . prefixTable('items') . ' WHERE id = %i', |
|
| 567 | + 'SELECT * FROM '.prefixTable('items').' WHERE id = %i', |
|
| 568 | 568 | $itemId |
| 569 | 569 | ); |
| 570 | 570 | |
@@ -640,7 +640,7 @@ discard block |
||
| 640 | 640 | if (strlen($newPassword) > $SETTINGS['pwd_maximum_length']) { |
| 641 | 641 | return [ |
| 642 | 642 | 'error' => true, |
| 643 | - 'error_message' => 'Password is too long (max allowed is ' . $SETTINGS['pwd_maximum_length'] . ' characters)', |
|
| 643 | + 'error_message' => 'Password is too long (max allowed is '.$SETTINGS['pwd_maximum_length'].' characters)', |
|
| 644 | 644 | 'error_header' => 'HTTP/1.1 400 Bad Request', |
| 645 | 645 | ]; |
| 646 | 646 | } |
@@ -763,7 +763,7 @@ discard block |
||
| 763 | 763 | ): array |
| 764 | 764 | { |
| 765 | 765 | try { |
| 766 | - include_once API_ROOT_PATH . '/../sources/main.functions.php'; |
|
| 766 | + include_once API_ROOT_PATH.'/../sources/main.functions.php'; |
|
| 767 | 767 | |
| 768 | 768 | // Load config |
| 769 | 769 | $configManager = new ConfigManager(); |
@@ -771,7 +771,7 @@ discard block |
||
| 771 | 771 | |
| 772 | 772 | // Load current item data |
| 773 | 773 | $currentItem = DB::queryFirstRow( |
| 774 | - 'SELECT * FROM ' . prefixTable('items') . ' WHERE id = %i', |
|
| 774 | + 'SELECT * FROM '.prefixTable('items').' WHERE id = %i', |
|
| 775 | 775 | $itemId |
| 776 | 776 | ); |
| 777 | 777 | |
@@ -40,11 +40,11 @@ discard block |
||
| 40 | 40 | */ |
| 41 | 41 | private function getUserPrivateKey(array $userData): ?string |
| 42 | 42 | { |
| 43 | - include_once API_ROOT_PATH . '/inc/jwt_utils.php'; |
|
| 43 | + include_once API_ROOT_PATH.'/inc/jwt_utils.php'; |
|
| 44 | 44 | |
| 45 | 45 | // Verify session_key exists in JWT payload |
| 46 | 46 | if (!isset($userData['session_key']) || empty($userData['session_key'])) { |
| 47 | - error_log('getUserPrivateKey: Missing session_key in JWT token for user ID ' . $userData['id']); |
|
| 47 | + error_log('getUserPrivateKey: Missing session_key in JWT token for user ID '.$userData['id']); |
|
| 48 | 48 | return null; |
| 49 | 49 | } |
| 50 | 50 | |
@@ -88,7 +88,7 @@ discard block |
||
| 88 | 88 | // SQL where clause with folders list |
| 89 | 89 | if (isset($arrQueryStringParams['folders']) === true) { |
| 90 | 90 | // convert the folders to an array |
| 91 | - $arrQueryStringParams['folders'] = explode(',', str_replace( array('[',']') , '' , $arrQueryStringParams['folders'])); |
|
| 91 | + $arrQueryStringParams['folders'] = explode(',', str_replace(array('[', ']'), '', $arrQueryStringParams['folders'])); |
|
| 92 | 92 | |
| 93 | 93 | // ensure to only use the intersection |
| 94 | 94 | $foldersList = implode(',', array_intersect($arrQueryStringParams['folders'], $userData['folders_list'])); |
@@ -243,7 +243,7 @@ discard block |
||
| 243 | 243 | (string) $arrQueryStringParams['description'] ?? '', |
| 244 | 244 | (string) $arrQueryStringParams['login'], |
| 245 | 245 | (string) $arrQueryStringParams['email'] ?? '', |
| 246 | - (string) $arrQueryStringParams['url'] ?? '' , |
|
| 246 | + (string) $arrQueryStringParams['url'] ?? '', |
|
| 247 | 247 | (string) $arrQueryStringParams['tags'] ?? '', |
| 248 | 248 | (int) $arrQueryStringParams['anyone_can_modify'] ?? 0, |
| 249 | 249 | (string) $arrQueryStringParams['icon'] ?? '', |
@@ -257,7 +257,7 @@ discard block |
||
| 257 | 257 | } else { |
| 258 | 258 | // Gérer le cas où les paramètres ne sont pas un tableau |
| 259 | 259 | $strErrorDesc = 'Data not consistent'; |
| 260 | - $strErrorHeader = 'Expected array, received ' . gettype($arrQueryStringParams); |
|
| 260 | + $strErrorHeader = 'Expected array, received '.gettype($arrQueryStringParams); |
|
| 261 | 261 | } |
| 262 | 262 | } |
| 263 | 263 | } else { |
@@ -308,10 +308,10 @@ discard block |
||
| 308 | 308 | // SQL where clause with item id |
| 309 | 309 | if (isset($arrQueryStringParams['id']) === true) { |
| 310 | 310 | // build sql where clause by ID |
| 311 | - $sqlExtra = ' WHERE i.id = '.$arrQueryStringParams['id'] . $sql_constraint; |
|
| 311 | + $sqlExtra = ' WHERE i.id = '.$arrQueryStringParams['id'].$sql_constraint; |
|
| 312 | 312 | } else if (isset($arrQueryStringParams['label']) === true) { |
| 313 | 313 | // build sql where clause by LABEL |
| 314 | - $sqlExtra = ' WHERE i.label '.(isset($arrQueryStringParams['like']) === true && (int) $arrQueryStringParams['like'] === 1 ? ' LIKE '.$arrQueryStringParams['label'] : ' = '.$arrQueryStringParams['label']) . $sql_constraint; |
|
| 314 | + $sqlExtra = ' WHERE i.label '.(isset($arrQueryStringParams['like']) === true && (int) $arrQueryStringParams['like'] === 1 ? ' LIKE '.$arrQueryStringParams['label'] : ' = '.$arrQueryStringParams['label']).$sql_constraint; |
|
| 315 | 315 | } else if (isset($arrQueryStringParams['description']) === true) { |
| 316 | 316 | // build sql where clause by LABEL |
| 317 | 317 | $sqlExtra = ' WHERE i.description '.(isset($arrQueryStringParams['like']) === true && (int) $arrQueryStringParams['like'] === 1 ? ' LIKE '.$arrQueryStringParams['description'] : ' = '.$arrQueryStringParams['description']).$sql_constraint; |
@@ -394,9 +394,9 @@ discard block |
||
| 394 | 394 | }*/ |
| 395 | 395 | |
| 396 | 396 | // Build SQL constraint for accessible folders |
| 397 | - $sql_constraint = ' AND (i.id_tree IN (' . $userData['folders_list'] . ')'; |
|
| 397 | + $sql_constraint = ' AND (i.id_tree IN ('.$userData['folders_list'].')'; |
|
| 398 | 398 | if (!empty($userData['restricted_items_list'])) { |
| 399 | - $sql_constraint .= ' OR i.id IN (' . $userData['restricted_items_list'] . ')'; |
|
| 399 | + $sql_constraint .= ' OR i.id IN ('.$userData['restricted_items_list'].')'; |
|
| 400 | 400 | } |
| 401 | 401 | $sql_constraint .= ')'; |
| 402 | 402 | |
@@ -414,9 +414,9 @@ discard block |
||
| 414 | 414 | $rows = DB::query( |
| 415 | 415 | "SELECT i.id, i.label, i.login, i.url, i.id_tree, |
| 416 | 416 | CASE WHEN o.enabled = 1 THEN 1 ELSE 0 END AS has_otp |
| 417 | - FROM " . prefixTable('items') . " AS i |
|
| 418 | - LEFT JOIN " . prefixTable('items_otp') . " AS o ON (o.item_id = i.id) |
|
| 419 | - WHERE i.url LIKE %s" . $sql_constraint . " |
|
| 417 | + FROM " . prefixTable('items')." AS i |
|
| 418 | + LEFT JOIN " . prefixTable('items_otp')." AS o ON (o.item_id = i.id) |
|
| 419 | + WHERE i.url LIKE %s" . $sql_constraint." |
|
| 420 | 420 | AND i.deleted_at IS NULL |
| 421 | 421 | ORDER BY i.label ASC", |
| 422 | 422 | "%".$searchUrl."%" |
@@ -427,7 +427,7 @@ discard block |
||
| 427 | 427 | // Get user's sharekey for this item |
| 428 | 428 | $shareKey = DB::queryfirstrow( |
| 429 | 429 | 'SELECT share_key |
| 430 | - FROM ' . prefixTable('sharekeys_items') . ' |
|
| 430 | + FROM ' . prefixTable('sharekeys_items').' |
|
| 431 | 431 | WHERE user_id = %i AND object_id = %i', |
| 432 | 432 | $userData['id'], |
| 433 | 433 | $row['id'] |
@@ -460,7 +460,7 @@ discard block |
||
| 460 | 460 | } |
| 461 | 461 | } |
| 462 | 462 | } catch (Error $e) { |
| 463 | - $strErrorDesc = $e->getMessage() . '. Something went wrong! Please contact support.'; |
|
| 463 | + $strErrorDesc = $e->getMessage().'. Something went wrong! Please contact support.'; |
|
| 464 | 464 | $strErrorHeader = 'HTTP/1.1 500 Internal Server Error'; |
| 465 | 465 | } |
| 466 | 466 | } else { |
@@ -520,7 +520,7 @@ discard block |
||
| 520 | 520 | |
| 521 | 521 | // Load item basic info to check folder access |
| 522 | 522 | $itemInfo = DB::queryFirstRow( |
| 523 | - 'SELECT id_tree FROM ' . prefixTable('items') . ' WHERE id = %i', |
|
| 523 | + 'SELECT id_tree FROM '.prefixTable('items').' WHERE id = %i', |
|
| 524 | 524 | $itemId |
| 525 | 525 | ); |
| 526 | 526 | |
@@ -544,7 +544,7 @@ discard block |
||
| 544 | 544 | } else { |
| 545 | 545 | // Load OTP data |
| 546 | 546 | $otpData = DB::queryFirstRow( |
| 547 | - 'SELECT secret, enabled FROM ' . prefixTable('items_otp') . ' WHERE item_id = %i', |
|
| 547 | + 'SELECT secret, enabled FROM '.prefixTable('items_otp').' WHERE item_id = %i', |
|
| 548 | 548 | $itemId |
| 549 | 549 | ); |
| 550 | 550 | |
@@ -575,7 +575,7 @@ discard block |
||
| 575 | 575 | 'item_id' => $itemId |
| 576 | 576 | ]); |
| 577 | 577 | } catch (\RuntimeException $e) { |
| 578 | - $strErrorDesc = 'Failed to generate OTP code: ' . $e->getMessage(); |
|
| 578 | + $strErrorDesc = 'Failed to generate OTP code: '.$e->getMessage(); |
|
| 579 | 579 | $strErrorHeader = 'HTTP/1.1 500 Internal Server Error'; |
| 580 | 580 | } |
| 581 | 581 | } else { |
@@ -586,7 +586,7 @@ discard block |
||
| 586 | 586 | } |
| 587 | 587 | } |
| 588 | 588 | } catch (\Error $e) { |
| 589 | - $strErrorDesc = $e->getMessage() . '. Something went wrong! Please contact support.'; |
|
| 589 | + $strErrorDesc = $e->getMessage().'. Something went wrong! Please contact support.'; |
|
| 590 | 590 | $strErrorHeader = 'HTTP/1.1 500 Internal Server Error'; |
| 591 | 591 | } |
| 592 | 592 | } else { |
@@ -651,7 +651,7 @@ discard block |
||
| 651 | 651 | try { |
| 652 | 652 | // Load item info to check access rights |
| 653 | 653 | $itemInfo = DB::queryFirstRow( |
| 654 | - 'SELECT id, id_tree, label FROM ' . prefixTable('items') . ' WHERE id = %i', |
|
| 654 | + 'SELECT id, id_tree, label FROM '.prefixTable('items').' WHERE id = %i', |
|
| 655 | 655 | $itemId |
| 656 | 656 | ); |
| 657 | 657 | |
@@ -712,13 +712,13 @@ discard block |
||
| 712 | 712 | } |
| 713 | 713 | } |
| 714 | 714 | } catch (Error $e) { |
| 715 | - $strErrorDesc = $e->getMessage() . '. Something went wrong! Please contact support.'; |
|
| 715 | + $strErrorDesc = $e->getMessage().'. Something went wrong! Please contact support.'; |
|
| 716 | 716 | $strErrorHeader = 'HTTP/1.1 500 Internal Server Error'; |
| 717 | 717 | } |
| 718 | 718 | } |
| 719 | 719 | } else { |
| 720 | 720 | $strErrorDesc = 'Data not consistent'; |
| 721 | - $strErrorHeader = 'HTTP/1.1 400 Bad Request - Expected array, received ' . gettype($arrQueryStringParams); |
|
| 721 | + $strErrorHeader = 'HTTP/1.1 400 Bad Request - Expected array, received '.gettype($arrQueryStringParams); |
|
| 722 | 722 | } |
| 723 | 723 | } |
| 724 | 724 | } else { |
@@ -776,7 +776,7 @@ discard block |
||
| 776 | 776 | try { |
| 777 | 777 | // Load item info to check access rights |
| 778 | 778 | $itemInfo = DB::queryFirstRow( |
| 779 | - 'SELECT id, id_tree, label FROM ' . prefixTable('items') . ' WHERE id = %i', |
|
| 779 | + 'SELECT id, id_tree, label FROM '.prefixTable('items').' WHERE id = %i', |
|
| 780 | 780 | $itemId |
| 781 | 781 | ); |
| 782 | 782 | |
@@ -814,13 +814,13 @@ discard block |
||
| 814 | 814 | } |
| 815 | 815 | } |
| 816 | 816 | } catch (Error $e) { |
| 817 | - $strErrorDesc = $e->getMessage() . '. Something went wrong! Please contact support.'; |
|
| 817 | + $strErrorDesc = $e->getMessage().'. Something went wrong! Please contact support.'; |
|
| 818 | 818 | $strErrorHeader = 'HTTP/1.1 500 Internal Server Error'; |
| 819 | 819 | } |
| 820 | 820 | } |
| 821 | 821 | } else { |
| 822 | 822 | $strErrorDesc = 'Data not consistent'; |
| 823 | - $strErrorHeader = 'HTTP/1.1 400 Bad Request - Expected array, received ' . gettype($arrQueryStringParams); |
|
| 823 | + $strErrorHeader = 'HTTP/1.1 400 Bad Request - Expected array, received '.gettype($arrQueryStringParams); |
|
| 824 | 824 | } |
| 825 | 825 | } |
| 826 | 826 | } else { |
@@ -48,7 +48,7 @@ discard block |
||
| 48 | 48 | $arrFolders = $folderModel->getFoldersInfo(explode(",", $userData['folders_list'])); |
| 49 | 49 | $responseData = json_encode($arrFolders); |
| 50 | 50 | } catch (Error $e) { |
| 51 | - $strErrorDesc = $e->getMessage() . ' Something went wrong! Please contact support.3'; |
|
| 51 | + $strErrorDesc = $e->getMessage().' Something went wrong! Please contact support.3'; |
|
| 52 | 52 | $strErrorHeader = 'HTTP/1.1 500 Internal Server Error'; |
| 53 | 53 | } |
| 54 | 54 | } |
@@ -118,7 +118,7 @@ discard block |
||
| 118 | 118 | |
| 119 | 119 | $responseData = json_encode($arrFolder); |
| 120 | 120 | } catch (Error $e) { |
| 121 | - $strErrorDesc = $e->getMessage() . ' Something went wrong! Please contact support.1'; |
|
| 121 | + $strErrorDesc = $e->getMessage().' Something went wrong! Please contact support.1'; |
|
| 122 | 122 | $strErrorHeader = 'HTTP/1.1 500 Internal Server Error'; |
| 123 | 123 | } |
| 124 | 124 | } |
@@ -159,8 +159,8 @@ discard block |
||
| 159 | 159 | $userFolders = !empty($userData['folders_list']) ? explode(',', $userData['folders_list']) : []; |
| 160 | 160 | $rows = DB::query( |
| 161 | 161 | 'SELECT nt.id AS folder_id, nt.title, nt.nlevel, nt.parent_id |
| 162 | - FROM ' . prefixTable('nested_tree') . ' AS nt |
|
| 163 | - LEFT JOIN ' . prefixTable('nested_tree') . ' AS personal |
|
| 162 | + FROM ' . prefixTable('nested_tree').' AS nt |
|
| 163 | + LEFT JOIN ' . prefixTable('nested_tree').' AS personal |
|
| 164 | 164 | ON personal.personal_folder = 1 |
| 165 | 165 | AND personal.title = %s |
| 166 | 166 | WHERE nt.id IN %li |
@@ -194,7 +194,7 @@ discard block |
||
| 194 | 194 | $responseData = json_encode($writableFolders); |
| 195 | 195 | |
| 196 | 196 | } catch (Error $e) { |
| 197 | - $strErrorDesc = $e->getMessage() . ' Something went wrong! Please contact support.'; |
|
| 197 | + $strErrorDesc = $e->getMessage().' Something went wrong! Please contact support.'; |
|
| 198 | 198 | $strErrorHeader = 'HTTP/1.1 500 Internal Server Error'; |
| 199 | 199 | } |
| 200 | 200 | } else { |