@@ -122,26 +122,26 @@ discard block |
||
| 122 | 122 | */ |
| 123 | 123 | function cryption(string $message, string $ascii_key, string $type, array $SETTINGS): array |
| 124 | 124 | { |
| 125 | - $ascii_key = empty($ascii_key) === true ? file_get_contents(SECUREPATH . '/teampass-seckey.txt') : $ascii_key; |
|
| 125 | + $ascii_key = empty($ascii_key) === true ? file_get_contents(SECUREPATH.'/teampass-seckey.txt') : $ascii_key; |
|
| 126 | 126 | $err = false; |
| 127 | 127 | // load PhpEncryption library |
| 128 | 128 | if (isset($SETTINGS['cpassman_dir']) === false || empty($SETTINGS['cpassman_dir']) === true) { |
| 129 | 129 | $path = '../includes/libraries/Encryption/Encryption/'; |
| 130 | 130 | } else { |
| 131 | - $path = $SETTINGS['cpassman_dir'] . '/includes/libraries/Encryption/Encryption/'; |
|
| 131 | + $path = $SETTINGS['cpassman_dir'].'/includes/libraries/Encryption/Encryption/'; |
|
| 132 | 132 | } |
| 133 | 133 | |
| 134 | 134 | // Check if class already exists |
| 135 | 135 | if (!class_exists('Defuse\Crypto\Crypto', false)) { |
| 136 | - include_once $path . 'Crypto.php'; |
|
| 137 | - include_once $path . 'Encoding.php'; |
|
| 138 | - include_once $path . 'DerivedKeys.php'; |
|
| 139 | - include_once $path . 'Key.php'; |
|
| 140 | - include_once $path . 'KeyOrPassword.php'; |
|
| 141 | - include_once $path . 'File.php'; |
|
| 142 | - include_once $path . 'RuntimeTests.php'; |
|
| 143 | - include_once $path . 'KeyProtectedByPassword.php'; |
|
| 144 | - include_once $path . 'Core.php'; |
|
| 136 | + include_once $path.'Crypto.php'; |
|
| 137 | + include_once $path.'Encoding.php'; |
|
| 138 | + include_once $path.'DerivedKeys.php'; |
|
| 139 | + include_once $path.'Key.php'; |
|
| 140 | + include_once $path.'KeyOrPassword.php'; |
|
| 141 | + include_once $path.'File.php'; |
|
| 142 | + include_once $path.'RuntimeTests.php'; |
|
| 143 | + include_once $path.'KeyProtectedByPassword.php'; |
|
| 144 | + include_once $path.'Core.php'; |
|
| 145 | 145 | } |
| 146 | 146 | |
| 147 | 147 | // convert KEY |
@@ -187,15 +187,15 @@ discard block |
||
| 187 | 187 | $path = '../includes/libraries/Encryption/Encryption/'; |
| 188 | 188 | } |
| 189 | 189 | |
| 190 | - include_once $path . 'Crypto.php'; |
|
| 191 | - include_once $path . 'Encoding.php'; |
|
| 192 | - include_once $path . 'DerivedKeys.php'; |
|
| 193 | - include_once $path . 'Key.php'; |
|
| 194 | - include_once $path . 'KeyOrPassword.php'; |
|
| 195 | - include_once $path . 'File.php'; |
|
| 196 | - include_once $path . 'RuntimeTests.php'; |
|
| 197 | - include_once $path . 'KeyProtectedByPassword.php'; |
|
| 198 | - include_once $path . 'Core.php'; |
|
| 190 | + include_once $path.'Crypto.php'; |
|
| 191 | + include_once $path.'Encoding.php'; |
|
| 192 | + include_once $path.'DerivedKeys.php'; |
|
| 193 | + include_once $path.'Key.php'; |
|
| 194 | + include_once $path.'KeyOrPassword.php'; |
|
| 195 | + include_once $path.'File.php'; |
|
| 196 | + include_once $path.'RuntimeTests.php'; |
|
| 197 | + include_once $path.'KeyProtectedByPassword.php'; |
|
| 198 | + include_once $path.'Core.php'; |
|
| 199 | 199 | $key = \Defuse\Crypto\Key::createNewRandomKey(); |
| 200 | 200 | $key = $key->saveToAsciiSafeString(); |
| 201 | 201 | return $key; |
@@ -217,15 +217,15 @@ discard block |
||
| 217 | 217 | $path = '../includes/libraries/Encryption/Encryption/'; |
| 218 | 218 | } |
| 219 | 219 | |
| 220 | - include_once $path . 'Crypto.php'; |
|
| 221 | - include_once $path . 'Encoding.php'; |
|
| 222 | - include_once $path . 'DerivedKeys.php'; |
|
| 223 | - include_once $path . 'Key.php'; |
|
| 224 | - include_once $path . 'KeyOrPassword.php'; |
|
| 225 | - include_once $path . 'File.php'; |
|
| 226 | - include_once $path . 'RuntimeTests.php'; |
|
| 227 | - include_once $path . 'KeyProtectedByPassword.php'; |
|
| 228 | - include_once $path . 'Core.php'; |
|
| 220 | + include_once $path.'Crypto.php'; |
|
| 221 | + include_once $path.'Encoding.php'; |
|
| 222 | + include_once $path.'DerivedKeys.php'; |
|
| 223 | + include_once $path.'Key.php'; |
|
| 224 | + include_once $path.'KeyOrPassword.php'; |
|
| 225 | + include_once $path.'File.php'; |
|
| 226 | + include_once $path.'RuntimeTests.php'; |
|
| 227 | + include_once $path.'KeyProtectedByPassword.php'; |
|
| 228 | + include_once $path.'Core.php'; |
|
| 229 | 229 | $protected_key = \Defuse\Crypto\KeyProtectedByPassword::createRandomPasswordProtectedKey($psk); |
| 230 | 230 | return $protected_key->saveToAsciiSafeString(); // save this in user table |
| 231 | 231 | } |
@@ -247,15 +247,15 @@ discard block |
||
| 247 | 247 | $path = '../includes/libraries/Encryption/Encryption/'; |
| 248 | 248 | } |
| 249 | 249 | |
| 250 | - include_once $path . 'Crypto.php'; |
|
| 251 | - include_once $path . 'Encoding.php'; |
|
| 252 | - include_once $path . 'DerivedKeys.php'; |
|
| 253 | - include_once $path . 'Key.php'; |
|
| 254 | - include_once $path . 'KeyOrPassword.php'; |
|
| 255 | - include_once $path . 'File.php'; |
|
| 256 | - include_once $path . 'RuntimeTests.php'; |
|
| 257 | - include_once $path . 'KeyProtectedByPassword.php'; |
|
| 258 | - include_once $path . 'Core.php'; |
|
| 250 | + include_once $path.'Crypto.php'; |
|
| 251 | + include_once $path.'Encoding.php'; |
|
| 252 | + include_once $path.'DerivedKeys.php'; |
|
| 253 | + include_once $path.'Key.php'; |
|
| 254 | + include_once $path.'KeyOrPassword.php'; |
|
| 255 | + include_once $path.'File.php'; |
|
| 256 | + include_once $path.'RuntimeTests.php'; |
|
| 257 | + include_once $path.'KeyProtectedByPassword.php'; |
|
| 258 | + include_once $path.'Core.php'; |
|
| 259 | 259 | try { |
| 260 | 260 | $protected_key = \Defuse\Crypto\KeyProtectedByPassword::loadFromAsciiSafeString($protected_key_encoded); |
| 261 | 261 | $user_key = $protected_key->unlockKey($psk); |
@@ -294,7 +294,7 @@ discard block |
||
| 294 | 294 | */ |
| 295 | 295 | function trimElement($chaine, string $element): string |
| 296 | 296 | { |
| 297 | - if (! empty($chaine)) { |
|
| 297 | + if (!empty($chaine)) { |
|
| 298 | 298 | if (is_array($chaine) === true) { |
| 299 | 299 | $chaine = implode(';', $chaine); |
| 300 | 300 | } |
@@ -340,8 +340,8 @@ discard block |
||
| 340 | 340 | */ |
| 341 | 341 | function db_error_handler(array $params): void |
| 342 | 342 | { |
| 343 | - echo 'Error: ' . $params['error'] . "<br>\n"; |
|
| 344 | - echo 'Query: ' . $params['query'] . "<br>\n"; |
|
| 343 | + echo 'Error: '.$params['error']."<br>\n"; |
|
| 344 | + echo 'Query: '.$params['query']."<br>\n"; |
|
| 345 | 345 | throw new Exception('Error - Query', 1); |
| 346 | 346 | } |
| 347 | 347 | |
@@ -363,12 +363,12 @@ discard block |
||
| 363 | 363 | $SETTINGS |
| 364 | 364 | ) { |
| 365 | 365 | //load ClassLoader |
| 366 | - include_once $SETTINGS['cpassman_dir'] . '/sources/SplClassLoader.php'; |
|
| 366 | + include_once $SETTINGS['cpassman_dir'].'/sources/SplClassLoader.php'; |
|
| 367 | 367 | // Load superglobal |
| 368 | - include_once $SETTINGS['cpassman_dir'] . '/includes/libraries/protect/SuperGlobal/SuperGlobal.php'; |
|
| 368 | + include_once $SETTINGS['cpassman_dir'].'/includes/libraries/protect/SuperGlobal/SuperGlobal.php'; |
|
| 369 | 369 | $superGlobal = new protect\SuperGlobal\SuperGlobal(); |
| 370 | 370 | //Connect to DB |
| 371 | - include_once $SETTINGS['cpassman_dir'] . '/includes/libraries/Database/Meekrodb/db.class.php'; |
|
| 371 | + include_once $SETTINGS['cpassman_dir'].'/includes/libraries/Database/Meekrodb/db.class.php'; |
|
| 372 | 372 | if (defined('DB_PASSWD_CLEAR') === false) { |
| 373 | 373 | define('DB_PASSWD_CLEAR', defuseReturnDecrypted(DB_PASSWD, $SETTINGS)); |
| 374 | 374 | } |
@@ -379,7 +379,7 @@ discard block |
||
| 379 | 379 | DB::$port = DB_PORT; |
| 380 | 380 | DB::$encoding = DB_ENCODING; |
| 381 | 381 | //Build tree |
| 382 | - $tree = new SplClassLoader('Tree\NestedTree', $SETTINGS['cpassman_dir'] . '/includes/libraries'); |
|
| 382 | + $tree = new SplClassLoader('Tree\NestedTree', $SETTINGS['cpassman_dir'].'/includes/libraries'); |
|
| 383 | 383 | $tree->register(); |
| 384 | 384 | $tree = new Tree\NestedTree\NestedTree(prefixTable('nested_tree'), 'id', 'parent_id', 'title'); |
| 385 | 385 | // Check if user is ADMINISTRATOR |
@@ -422,7 +422,7 @@ discard block |
||
| 422 | 422 | function identAdmin($idFonctions, $SETTINGS, $tree) |
| 423 | 423 | { |
| 424 | 424 | // Load superglobal |
| 425 | - include_once $SETTINGS['cpassman_dir'] . '/includes/libraries/protect/SuperGlobal/SuperGlobal.php'; |
|
| 425 | + include_once $SETTINGS['cpassman_dir'].'/includes/libraries/protect/SuperGlobal/SuperGlobal.php'; |
|
| 426 | 426 | $superGlobal = new protect\SuperGlobal\SuperGlobal(); |
| 427 | 427 | // Init |
| 428 | 428 | $groupesVisibles = []; |
@@ -441,7 +441,7 @@ discard block |
||
| 441 | 441 | $globalsVisibleFolders = $superGlobal->get('groupes_visibles', 'SESSION'); |
| 442 | 442 | $globalsPersonalVisibleFolders = $superGlobal->get('personal_visible_groups', 'SESSION'); |
| 443 | 443 | // Get list of Folders |
| 444 | - $rows = DB::query('SELECT id FROM ' . prefixTable('nested_tree') . ' WHERE personal_folder = %i', 0); |
|
| 444 | + $rows = DB::query('SELECT id FROM '.prefixTable('nested_tree').' WHERE personal_folder = %i', 0); |
|
| 445 | 445 | foreach ($rows as $record) { |
| 446 | 446 | array_push($groupesVisibles, $record['id']); |
| 447 | 447 | } |
@@ -460,7 +460,7 @@ discard block |
||
| 460 | 460 | } |
| 461 | 461 | // Get ID of personal folder |
| 462 | 462 | $persfld = DB::queryfirstrow( |
| 463 | - 'SELECT id FROM ' . prefixTable('nested_tree') . ' WHERE title = %s', |
|
| 463 | + 'SELECT id FROM '.prefixTable('nested_tree').' WHERE title = %s', |
|
| 464 | 464 | $globalsUserId |
| 465 | 465 | ); |
| 466 | 466 | if (empty($persfld['id']) === false) { |
@@ -481,20 +481,20 @@ discard block |
||
| 481 | 481 | // get complete list of ROLES |
| 482 | 482 | $tmp = explode(';', $idFonctions); |
| 483 | 483 | $rows = DB::query( |
| 484 | - 'SELECT * FROM ' . prefixTable('roles_title') . ' |
|
| 484 | + 'SELECT * FROM '.prefixTable('roles_title').' |
|
| 485 | 485 | ORDER BY title ASC' |
| 486 | 486 | ); |
| 487 | 487 | foreach ($rows as $record) { |
| 488 | - if (! empty($record['id']) && ! in_array($record['id'], $tmp)) { |
|
| 488 | + if (!empty($record['id']) && !in_array($record['id'], $tmp)) { |
|
| 489 | 489 | array_push($tmp, $record['id']); |
| 490 | 490 | } |
| 491 | 491 | } |
| 492 | 492 | $superGlobal->put('fonction_id', implode(';', $tmp), 'SESSION'); |
| 493 | 493 | $superGlobal->put('is_admin', 1, 'SESSION'); |
| 494 | 494 | // Check if admin has created Folders and Roles |
| 495 | - DB::query('SELECT * FROM ' . prefixTable('nested_tree') . ''); |
|
| 495 | + DB::query('SELECT * FROM '.prefixTable('nested_tree').''); |
|
| 496 | 496 | $superGlobal->put('nb_folders', DB::count(), 'SESSION'); |
| 497 | - DB::query('SELECT * FROM ' . prefixTable('roles_title')); |
|
| 497 | + DB::query('SELECT * FROM '.prefixTable('roles_title')); |
|
| 498 | 498 | $superGlobal->put('nb_roles', DB::count(), 'SESSION'); |
| 499 | 499 | } |
| 500 | 500 | |
@@ -536,7 +536,7 @@ discard block |
||
| 536 | 536 | object $tree |
| 537 | 537 | ) { |
| 538 | 538 | // Load superglobal |
| 539 | - include_once $SETTINGS['cpassman_dir'] . '/includes/libraries/protect/SuperGlobal/SuperGlobal.php'; |
|
| 539 | + include_once $SETTINGS['cpassman_dir'].'/includes/libraries/protect/SuperGlobal/SuperGlobal.php'; |
|
| 540 | 540 | $superGlobal = new protect\SuperGlobal\SuperGlobal(); |
| 541 | 541 | // Init |
| 542 | 542 | $superGlobal->put('groupes_visibles', [], 'SESSION'); |
@@ -564,7 +564,7 @@ discard block |
||
| 564 | 564 | // Get list of folders depending on Roles |
| 565 | 565 | $rows = DB::query( |
| 566 | 566 | 'SELECT * |
| 567 | - FROM ' . prefixTable('roles_values') . ' |
|
| 567 | + FROM ' . prefixTable('roles_values').' |
|
| 568 | 568 | WHERE role_id IN %li AND type IN %ls', |
| 569 | 569 | $userRoles, |
| 570 | 570 | ['W', 'ND', 'NE', 'NDNE', 'R'] |
@@ -589,10 +589,10 @@ discard block |
||
| 589 | 589 | // Does this user is allowed to see other items |
| 590 | 590 | $inc = 0; |
| 591 | 591 | $rows = DB::query( |
| 592 | - 'SELECT id, id_tree FROM ' . prefixTable('items') . ' |
|
| 592 | + 'SELECT id, id_tree FROM '.prefixTable('items').' |
|
| 593 | 593 | WHERE restricted_to LIKE %ss AND inactif = %s'. |
| 594 | 594 | (count($allowedFolders) > 0 ? ' AND id_tree NOT IN ('.implode(',', $allowedFolders).')' : ''), |
| 595 | - $globalsUserId . ';', |
|
| 595 | + $globalsUserId.';', |
|
| 596 | 596 | '0' |
| 597 | 597 | ); |
| 598 | 598 | foreach ($rows as $record) { |
@@ -606,8 +606,8 @@ discard block |
||
| 606 | 606 | // Check for the users roles if some specific rights exist on items |
| 607 | 607 | $rows = DB::query( |
| 608 | 608 | 'SELECT i.id_tree, r.item_id |
| 609 | - FROM ' . prefixTable('items') . ' as i |
|
| 610 | - INNER JOIN ' . prefixTable('restriction_to_roles') . ' as r ON (r.item_id=i.id) |
|
| 609 | + FROM ' . prefixTable('items').' as i |
|
| 610 | + INNER JOIN ' . prefixTable('restriction_to_roles').' as r ON (r.item_id=i.id) |
|
| 611 | 611 | WHERE r.role_id IN %li AND i.id_tree <> "" |
| 612 | 612 | ORDER BY i.id_tree ASC', |
| 613 | 613 | $userRoles |
@@ -628,7 +628,7 @@ discard block |
||
| 628 | 628 | ) { |
| 629 | 629 | $persoFld = DB::queryfirstrow( |
| 630 | 630 | 'SELECT id |
| 631 | - FROM ' . prefixTable('nested_tree') . ' |
|
| 631 | + FROM ' . prefixTable('nested_tree').' |
|
| 632 | 632 | WHERE title = %s AND personal_folder = %i'. |
| 633 | 633 | (count($allowedFolders) > 0 ? ' AND id NOT IN ('.implode(',', $allowedFolders).')' : ''), |
| 634 | 634 | $globalsUserId, |
@@ -662,7 +662,7 @@ discard block |
||
| 662 | 662 | } |
| 663 | 663 | $persoFlds = DB::query( |
| 664 | 664 | 'SELECT id |
| 665 | - FROM ' . prefixTable('nested_tree') . ' |
|
| 665 | + FROM ' . prefixTable('nested_tree').' |
|
| 666 | 666 | WHERE %l', |
| 667 | 667 | $where |
| 668 | 668 | ); |
@@ -703,16 +703,16 @@ discard block |
||
| 703 | 703 | 'SESSION' |
| 704 | 704 | ); |
| 705 | 705 | // Folders and Roles numbers |
| 706 | - DB::queryfirstrow('SELECT id FROM ' . prefixTable('nested_tree') . ''); |
|
| 706 | + DB::queryfirstrow('SELECT id FROM '.prefixTable('nested_tree').''); |
|
| 707 | 707 | $superGlobal->put('nb_folders', DB::count(), 'SESSION'); |
| 708 | - DB::queryfirstrow('SELECT id FROM ' . prefixTable('roles_title')); |
|
| 708 | + DB::queryfirstrow('SELECT id FROM '.prefixTable('roles_title')); |
|
| 709 | 709 | $superGlobal->put('nb_roles', DB::count(), 'SESSION'); |
| 710 | 710 | // check if change proposals on User's items |
| 711 | 711 | if (isset($SETTINGS['enable_suggestion']) === true && (int) $SETTINGS['enable_suggestion'] === 1) { |
| 712 | 712 | DB::query( |
| 713 | 713 | 'SELECT * |
| 714 | - FROM ' . prefixTable('items_change') . ' AS c |
|
| 715 | - LEFT JOIN ' . prefixTable('log_items') . ' AS i ON (c.item_id = i.id_item) |
|
| 714 | + FROM ' . prefixTable('items_change').' AS c |
|
| 715 | + LEFT JOIN ' . prefixTable('log_items').' AS i ON (c.item_id = i.id_item) |
|
| 716 | 716 | WHERE i.action = %s AND i.id_user = %i', |
| 717 | 717 | 'at_creation', |
| 718 | 718 | $globalsUserId |
@@ -756,9 +756,9 @@ discard block |
||
| 756 | 756 | */ |
| 757 | 757 | function cacheTableRefresh(array $SETTINGS): void |
| 758 | 758 | { |
| 759 | - include_once $SETTINGS['cpassman_dir'] . '/sources/SplClassLoader.php'; |
|
| 759 | + include_once $SETTINGS['cpassman_dir'].'/sources/SplClassLoader.php'; |
|
| 760 | 760 | //Connect to DB |
| 761 | - include_once $SETTINGS['cpassman_dir'] . '/includes/libraries/Database/Meekrodb/db.class.php'; |
|
| 761 | + include_once $SETTINGS['cpassman_dir'].'/includes/libraries/Database/Meekrodb/db.class.php'; |
|
| 762 | 762 | if (defined('DB_PASSWD_CLEAR') === false) { |
| 763 | 763 | define('DB_PASSWD_CLEAR', defuseReturnDecrypted(DB_PASSWD, $SETTINGS)); |
| 764 | 764 | } |
@@ -773,12 +773,12 @@ discard block |
||
| 773 | 773 | $tree->register(); |
| 774 | 774 | $tree = new Tree\NestedTree\NestedTree(prefixTable('nested_tree'), 'id', 'parent_id', 'title'); |
| 775 | 775 | // truncate table |
| 776 | - DB::query('TRUNCATE TABLE ' . prefixTable('cache')); |
|
| 776 | + DB::query('TRUNCATE TABLE '.prefixTable('cache')); |
|
| 777 | 777 | // reload date |
| 778 | 778 | $rows = DB::query( |
| 779 | 779 | 'SELECT * |
| 780 | - FROM ' . prefixTable('items') . ' as i |
|
| 781 | - INNER JOIN ' . prefixTable('log_items') . ' as l ON (l.id_item = i.id) |
|
| 780 | + FROM ' . prefixTable('items').' as i |
|
| 781 | + INNER JOIN ' . prefixTable('log_items').' as l ON (l.id_item = i.id) |
|
| 782 | 782 | AND l.action = %s |
| 783 | 783 | AND i.inactif = %i', |
| 784 | 784 | 'at_creation', |
@@ -790,18 +790,18 @@ discard block |
||
| 790 | 790 | $tags = ''; |
| 791 | 791 | $itemTags = DB::query( |
| 792 | 792 | 'SELECT tag |
| 793 | - FROM ' . prefixTable('tags') . ' |
|
| 793 | + FROM ' . prefixTable('tags').' |
|
| 794 | 794 | WHERE item_id = %i AND tag != ""', |
| 795 | 795 | $record['id'] |
| 796 | 796 | ); |
| 797 | 797 | foreach ($itemTags as $itemTag) { |
| 798 | - $tags .= $itemTag['tag'] . ' '; |
|
| 798 | + $tags .= $itemTag['tag'].' '; |
|
| 799 | 799 | } |
| 800 | 800 | |
| 801 | 801 | // Get renewal period |
| 802 | 802 | $resNT = DB::queryfirstrow( |
| 803 | 803 | 'SELECT renewal_period |
| 804 | - FROM ' . prefixTable('nested_tree') . ' |
|
| 804 | + FROM ' . prefixTable('nested_tree').' |
|
| 805 | 805 | WHERE id = %i', |
| 806 | 806 | $record['id_tree'] |
| 807 | 807 | ); |
@@ -814,7 +814,7 @@ discard block |
||
| 814 | 814 | // Is this a User id? |
| 815 | 815 | $user = DB::queryfirstrow( |
| 816 | 816 | 'SELECT id, login |
| 817 | - FROM ' . prefixTable('users') . ' |
|
| 817 | + FROM ' . prefixTable('users').' |
|
| 818 | 818 | WHERE id = %i', |
| 819 | 819 | $elem->title |
| 820 | 820 | ); |
@@ -832,11 +832,11 @@ discard block |
||
| 832 | 832 | 'id' => $record['id'], |
| 833 | 833 | 'label' => $record['label'], |
| 834 | 834 | 'description' => $record['description'] ?? '', |
| 835 | - 'url' => isset($record['url']) && ! empty($record['url']) ? $record['url'] : '0', |
|
| 835 | + 'url' => isset($record['url']) && !empty($record['url']) ? $record['url'] : '0', |
|
| 836 | 836 | 'tags' => $tags, |
| 837 | 837 | 'id_tree' => $record['id_tree'], |
| 838 | 838 | 'perso' => $record['perso'], |
| 839 | - 'restricted_to' => isset($record['restricted_to']) && ! empty($record['restricted_to']) ? $record['restricted_to'] : '0', |
|
| 839 | + 'restricted_to' => isset($record['restricted_to']) && !empty($record['restricted_to']) ? $record['restricted_to'] : '0', |
|
| 840 | 840 | 'login' => $record['login'] ?? '', |
| 841 | 841 | 'folder' => implode(' > ', $folder), |
| 842 | 842 | 'author' => $record['id_user'], |
@@ -856,12 +856,12 @@ discard block |
||
| 856 | 856 | */ |
| 857 | 857 | function cacheTableUpdate(array $SETTINGS, ?int $ident = null): void |
| 858 | 858 | { |
| 859 | - include_once $SETTINGS['cpassman_dir'] . '/sources/SplClassLoader.php'; |
|
| 859 | + include_once $SETTINGS['cpassman_dir'].'/sources/SplClassLoader.php'; |
|
| 860 | 860 | // Load superglobal |
| 861 | - include_once $SETTINGS['cpassman_dir'] . '/includes/libraries/protect/SuperGlobal/SuperGlobal.php'; |
|
| 861 | + include_once $SETTINGS['cpassman_dir'].'/includes/libraries/protect/SuperGlobal/SuperGlobal.php'; |
|
| 862 | 862 | $superGlobal = new protect\SuperGlobal\SuperGlobal(); |
| 863 | 863 | //Connect to DB |
| 864 | - include_once $SETTINGS['cpassman_dir'] . '/includes/libraries/Database/Meekrodb/db.class.php'; |
|
| 864 | + include_once $SETTINGS['cpassman_dir'].'/includes/libraries/Database/Meekrodb/db.class.php'; |
|
| 865 | 865 | if (defined('DB_PASSWD_CLEAR') === false) { |
| 866 | 866 | define('DB_PASSWD_CLEAR', defuseReturnDecrypted(DB_PASSWD, $SETTINGS)); |
| 867 | 867 | } |
@@ -878,7 +878,7 @@ discard block |
||
| 878 | 878 | // get new value from db |
| 879 | 879 | $data = DB::queryfirstrow( |
| 880 | 880 | 'SELECT label, description, id_tree, perso, restricted_to, login, url |
| 881 | - FROM ' . prefixTable('items') . ' |
|
| 881 | + FROM ' . prefixTable('items').' |
|
| 882 | 882 | WHERE id=%i', |
| 883 | 883 | $ident |
| 884 | 884 | ); |
@@ -886,12 +886,12 @@ discard block |
||
| 886 | 886 | $tags = ''; |
| 887 | 887 | $itemTags = DB::query( |
| 888 | 888 | 'SELECT tag |
| 889 | - FROM ' . prefixTable('tags') . ' |
|
| 889 | + FROM ' . prefixTable('tags').' |
|
| 890 | 890 | WHERE item_id = %i AND tag != ""', |
| 891 | 891 | $ident |
| 892 | 892 | ); |
| 893 | 893 | foreach ($itemTags as $itemTag) { |
| 894 | - $tags .= $itemTag['tag'] . ' '; |
|
| 894 | + $tags .= $itemTag['tag'].' '; |
|
| 895 | 895 | } |
| 896 | 896 | // form id_tree to full foldername |
| 897 | 897 | $folder = []; |
@@ -902,7 +902,7 @@ discard block |
||
| 902 | 902 | // Is this a User id? |
| 903 | 903 | $user = DB::queryfirstrow( |
| 904 | 904 | 'SELECT id, login |
| 905 | - FROM ' . prefixTable('users') . ' |
|
| 905 | + FROM ' . prefixTable('users').' |
|
| 906 | 906 | WHERE id = %i', |
| 907 | 907 | $elem->title |
| 908 | 908 | ); |
@@ -920,10 +920,10 @@ discard block |
||
| 920 | 920 | 'label' => $data['label'], |
| 921 | 921 | 'description' => $data['description'], |
| 922 | 922 | 'tags' => $tags, |
| 923 | - 'url' => isset($data['url']) && ! empty($data['url']) ? $data['url'] : '0', |
|
| 923 | + 'url' => isset($data['url']) && !empty($data['url']) ? $data['url'] : '0', |
|
| 924 | 924 | 'id_tree' => $data['id_tree'], |
| 925 | 925 | 'perso' => $data['perso'], |
| 926 | - 'restricted_to' => isset($data['restricted_to']) && ! empty($data['restricted_to']) ? $data['restricted_to'] : '0', |
|
| 926 | + 'restricted_to' => isset($data['restricted_to']) && !empty($data['restricted_to']) ? $data['restricted_to'] : '0', |
|
| 927 | 927 | 'login' => $data['login'] ?? '', |
| 928 | 928 | 'folder' => implode(' » ', $folder), |
| 929 | 929 | 'author' => $superGlobal->get('user_id', 'SESSION'), |
@@ -941,14 +941,14 @@ discard block |
||
| 941 | 941 | */ |
| 942 | 942 | function cacheTableAdd(array $SETTINGS, ?int $ident = null): void |
| 943 | 943 | { |
| 944 | - include_once $SETTINGS['cpassman_dir'] . '/sources/SplClassLoader.php'; |
|
| 944 | + include_once $SETTINGS['cpassman_dir'].'/sources/SplClassLoader.php'; |
|
| 945 | 945 | // Load superglobal |
| 946 | - include_once $SETTINGS['cpassman_dir'] . '/includes/libraries/protect/SuperGlobal/SuperGlobal.php'; |
|
| 946 | + include_once $SETTINGS['cpassman_dir'].'/includes/libraries/protect/SuperGlobal/SuperGlobal.php'; |
|
| 947 | 947 | $superGlobal = new protect\SuperGlobal\SuperGlobal(); |
| 948 | 948 | // Get superglobals |
| 949 | 949 | $globalsUserId = $superGlobal->get('user_id', 'SESSION'); |
| 950 | 950 | //Connect to DB |
| 951 | - include_once $SETTINGS['cpassman_dir'] . '/includes/libraries/Database/Meekrodb/db.class.php'; |
|
| 951 | + include_once $SETTINGS['cpassman_dir'].'/includes/libraries/Database/Meekrodb/db.class.php'; |
|
| 952 | 952 | if (defined('DB_PASSWD_CLEAR') === false) { |
| 953 | 953 | define('DB_PASSWD_CLEAR', defuseReturnDecrypted(DB_PASSWD, $SETTINGS)); |
| 954 | 954 | } |
@@ -965,8 +965,8 @@ discard block |
||
| 965 | 965 | // get new value from db |
| 966 | 966 | $data = DB::queryFirstRow( |
| 967 | 967 | 'SELECT i.label, i.description, i.id_tree as id_tree, i.perso, i.restricted_to, i.id, i.login, i.url, l.date |
| 968 | - FROM ' . prefixTable('items') . ' as i |
|
| 969 | - INNER JOIN ' . prefixTable('log_items') . ' as l ON (l.id_item = i.id) |
|
| 968 | + FROM ' . prefixTable('items').' as i |
|
| 969 | + INNER JOIN ' . prefixTable('log_items').' as l ON (l.id_item = i.id) |
|
| 970 | 970 | WHERE i.id = %i |
| 971 | 971 | AND l.action = %s', |
| 972 | 972 | $ident, |
@@ -976,12 +976,12 @@ discard block |
||
| 976 | 976 | $tags = ''; |
| 977 | 977 | $itemTags = DB::query( |
| 978 | 978 | 'SELECT tag |
| 979 | - FROM ' . prefixTable('tags') . ' |
|
| 979 | + FROM ' . prefixTable('tags').' |
|
| 980 | 980 | WHERE item_id = %i AND tag != ""', |
| 981 | 981 | $ident |
| 982 | 982 | ); |
| 983 | 983 | foreach ($itemTags as $itemTag) { |
| 984 | - $tags .= $itemTag['tag'] . ' '; |
|
| 984 | + $tags .= $itemTag['tag'].' '; |
|
| 985 | 985 | } |
| 986 | 986 | // form id_tree to full foldername |
| 987 | 987 | $folder = []; |
@@ -992,7 +992,7 @@ discard block |
||
| 992 | 992 | // Is this a User id? |
| 993 | 993 | $user = DB::queryfirstrow( |
| 994 | 994 | 'SELECT id, login |
| 995 | - FROM ' . prefixTable('users') . ' |
|
| 995 | + FROM ' . prefixTable('users').' |
|
| 996 | 996 | WHERE id = %i', |
| 997 | 997 | $elem->title |
| 998 | 998 | ); |
@@ -1011,7 +1011,7 @@ discard block |
||
| 1011 | 1011 | 'label' => $data['label'], |
| 1012 | 1012 | 'description' => $data['description'], |
| 1013 | 1013 | 'tags' => isset($tags) && empty($tags) === false ? $tags : 'None', |
| 1014 | - 'url' => isset($data['url']) && ! empty($data['url']) ? $data['url'] : '0', |
|
| 1014 | + 'url' => isset($data['url']) && !empty($data['url']) ? $data['url'] : '0', |
|
| 1015 | 1015 | 'id_tree' => $data['id_tree'], |
| 1016 | 1016 | 'perso' => isset($data['perso']) && empty($data['perso']) === false && $data['perso'] !== 'None' ? $data['perso'] : '0', |
| 1017 | 1017 | 'restricted_to' => isset($data['restricted_to']) && empty($data['restricted_to']) === false ? $data['restricted_to'] : '0', |
@@ -1033,52 +1033,52 @@ discard block |
||
| 1033 | 1033 | function getStatisticsData(array $SETTINGS): array |
| 1034 | 1034 | { |
| 1035 | 1035 | DB::query( |
| 1036 | - 'SELECT id FROM ' . prefixTable('nested_tree') . ' WHERE personal_folder = %i', |
|
| 1036 | + 'SELECT id FROM '.prefixTable('nested_tree').' WHERE personal_folder = %i', |
|
| 1037 | 1037 | 0 |
| 1038 | 1038 | ); |
| 1039 | 1039 | $counter_folders = DB::count(); |
| 1040 | 1040 | DB::query( |
| 1041 | - 'SELECT id FROM ' . prefixTable('nested_tree') . ' WHERE personal_folder = %i', |
|
| 1041 | + 'SELECT id FROM '.prefixTable('nested_tree').' WHERE personal_folder = %i', |
|
| 1042 | 1042 | 1 |
| 1043 | 1043 | ); |
| 1044 | 1044 | $counter_folders_perso = DB::count(); |
| 1045 | 1045 | DB::query( |
| 1046 | - 'SELECT id FROM ' . prefixTable('items') . ' WHERE perso = %i', |
|
| 1046 | + 'SELECT id FROM '.prefixTable('items').' WHERE perso = %i', |
|
| 1047 | 1047 | 0 |
| 1048 | 1048 | ); |
| 1049 | 1049 | $counter_items = DB::count(); |
| 1050 | 1050 | DB::query( |
| 1051 | - 'SELECT id FROM ' . prefixTable('items') . ' WHERE perso = %i', |
|
| 1051 | + 'SELECT id FROM '.prefixTable('items').' WHERE perso = %i', |
|
| 1052 | 1052 | 1 |
| 1053 | 1053 | ); |
| 1054 | 1054 | $counter_items_perso = DB::count(); |
| 1055 | 1055 | DB::query( |
| 1056 | - 'SELECT id FROM ' . prefixTable('users') . '' |
|
| 1056 | + 'SELECT id FROM '.prefixTable('users').'' |
|
| 1057 | 1057 | ); |
| 1058 | 1058 | $counter_users = DB::count(); |
| 1059 | 1059 | DB::query( |
| 1060 | - 'SELECT id FROM ' . prefixTable('users') . ' WHERE admin = %i', |
|
| 1060 | + 'SELECT id FROM '.prefixTable('users').' WHERE admin = %i', |
|
| 1061 | 1061 | 1 |
| 1062 | 1062 | ); |
| 1063 | 1063 | $admins = DB::count(); |
| 1064 | 1064 | DB::query( |
| 1065 | - 'SELECT id FROM ' . prefixTable('users') . ' WHERE gestionnaire = %i', |
|
| 1065 | + 'SELECT id FROM '.prefixTable('users').' WHERE gestionnaire = %i', |
|
| 1066 | 1066 | 1 |
| 1067 | 1067 | ); |
| 1068 | 1068 | $managers = DB::count(); |
| 1069 | 1069 | DB::query( |
| 1070 | - 'SELECT id FROM ' . prefixTable('users') . ' WHERE read_only = %i', |
|
| 1070 | + 'SELECT id FROM '.prefixTable('users').' WHERE read_only = %i', |
|
| 1071 | 1071 | 1 |
| 1072 | 1072 | ); |
| 1073 | 1073 | $readOnly = DB::count(); |
| 1074 | 1074 | // list the languages |
| 1075 | 1075 | $usedLang = []; |
| 1076 | 1076 | $tp_languages = DB::query( |
| 1077 | - 'SELECT name FROM ' . prefixTable('languages') |
|
| 1077 | + 'SELECT name FROM '.prefixTable('languages') |
|
| 1078 | 1078 | ); |
| 1079 | 1079 | foreach ($tp_languages as $tp_language) { |
| 1080 | 1080 | DB::query( |
| 1081 | - 'SELECT * FROM ' . prefixTable('users') . ' WHERE user_language = %s', |
|
| 1081 | + 'SELECT * FROM '.prefixTable('users').' WHERE user_language = %s', |
|
| 1082 | 1082 | $tp_language['name'] |
| 1083 | 1083 | ); |
| 1084 | 1084 | $usedLang[$tp_language['name']] = round((DB::count() * 100 / $counter_users), 0); |
@@ -1087,12 +1087,12 @@ discard block |
||
| 1087 | 1087 | // get list of ips |
| 1088 | 1088 | $usedIp = []; |
| 1089 | 1089 | $tp_ips = DB::query( |
| 1090 | - 'SELECT user_ip FROM ' . prefixTable('users') |
|
| 1090 | + 'SELECT user_ip FROM '.prefixTable('users') |
|
| 1091 | 1091 | ); |
| 1092 | 1092 | foreach ($tp_ips as $ip) { |
| 1093 | 1093 | if (array_key_exists($ip['user_ip'], $usedIp)) { |
| 1094 | 1094 | $usedIp[$ip['user_ip']] += $usedIp[$ip['user_ip']]; |
| 1095 | - } elseif (! empty($ip['user_ip']) && $ip['user_ip'] !== 'none') { |
|
| 1095 | + } elseif (!empty($ip['user_ip']) && $ip['user_ip'] !== 'none') { |
|
| 1096 | 1096 | $usedIp[$ip['user_ip']] = 1; |
| 1097 | 1097 | } |
| 1098 | 1098 | } |
@@ -1158,14 +1158,14 @@ discard block |
||
| 1158 | 1158 | } |
| 1159 | 1159 | |
| 1160 | 1160 | // Load settings |
| 1161 | - include_once $SETTINGS['cpassman_dir'] . '/includes/config/settings.php'; |
|
| 1161 | + include_once $SETTINGS['cpassman_dir'].'/includes/config/settings.php'; |
|
| 1162 | 1162 | // Load superglobal |
| 1163 | - include_once $SETTINGS['cpassman_dir'] . '/includes/libraries/protect/SuperGlobal/SuperGlobal.php'; |
|
| 1163 | + include_once $SETTINGS['cpassman_dir'].'/includes/libraries/protect/SuperGlobal/SuperGlobal.php'; |
|
| 1164 | 1164 | $superGlobal = new protect\SuperGlobal\SuperGlobal(); |
| 1165 | 1165 | // Get user language |
| 1166 | - include_once $SETTINGS['cpassman_dir'] . '/includes/language/' . $superGlobal->get('user_language', 'SESSION') . '.php'; |
|
| 1166 | + include_once $SETTINGS['cpassman_dir'].'/includes/language/'.$superGlobal->get('user_language', 'SESSION').'.php'; |
|
| 1167 | 1167 | // Load library |
| 1168 | - include_once $SETTINGS['cpassman_dir'] . '/sources/SplClassLoader.php'; |
|
| 1168 | + include_once $SETTINGS['cpassman_dir'].'/sources/SplClassLoader.php'; |
|
| 1169 | 1169 | // load PHPMailer |
| 1170 | 1170 | $mail = new SplClassLoader('PHPMailer\PHPMailer', '../includes/libraries'); |
| 1171 | 1171 | $mail->register(); |
@@ -1173,7 +1173,7 @@ discard block |
||
| 1173 | 1173 | |
| 1174 | 1174 | try { |
| 1175 | 1175 | // send to user |
| 1176 | - $mail->setLanguage('en', $SETTINGS['cpassman_dir'] . '/includes/libraries/PHPMailer/PHPMailer/language/'); |
|
| 1176 | + $mail->setLanguage('en', $SETTINGS['cpassman_dir'].'/includes/libraries/PHPMailer/PHPMailer/language/'); |
|
| 1177 | 1177 | $mail->SMTPDebug = 0; |
| 1178 | 1178 | //value 1 can be used to debug - 4 for debuging connections |
| 1179 | 1179 | $mail->Port = $SETTINGS['email_port']; |
@@ -1265,7 +1265,7 @@ discard block |
||
| 1265 | 1265 | <table width="600" cellpadding="0" cellspacing="0" border="0" class="container" bgcolor="#ffffff" style="border-spacing: 0; border-bottom: 1px solid #e0e0e0; box-shadow: 0 0 3px #ddd; color: #434343; font-family: Helvetica, Verdana, sans-serif;"> |
| 1266 | 1266 | <tr><td class="container-padding" bgcolor="#ffffff" style="border-collapse: collapse; border-left: 1px solid #e0e0e0; background-color: #ffffff; padding-left: 30px; padding-right: 30px;"> |
| 1267 | 1267 | <br><div style="float:right;">' . |
| 1268 | - $textMail . |
|
| 1268 | + $textMail. |
|
| 1269 | 1269 | '<br><br></td></tr></table> |
| 1270 | 1270 | </td></tr></table> |
| 1271 | 1271 | <br></body></html>'; |
@@ -1276,7 +1276,7 @@ discard block |
||
| 1276 | 1276 | */ |
| 1277 | 1277 | function generateKey(): string |
| 1278 | 1278 | { |
| 1279 | - return substr(md5(rand() . rand()), 0, 15); |
|
| 1279 | + return substr(md5(rand().rand()), 0, 15); |
|
| 1280 | 1280 | } |
| 1281 | 1281 | |
| 1282 | 1282 | /** |
@@ -1347,7 +1347,7 @@ discard block |
||
| 1347 | 1347 | { |
| 1348 | 1348 | array_walk_recursive( |
| 1349 | 1349 | $array, |
| 1350 | - static function (&$item): void { |
|
| 1350 | + static function(&$item): void { |
|
| 1351 | 1351 | if (mb_detect_encoding((string) $item, 'utf-8', true) === false) { |
| 1352 | 1352 | $item = utf8_encode($item); |
| 1353 | 1353 | } |
@@ -1382,7 +1382,7 @@ discard block |
||
| 1382 | 1382 | } |
| 1383 | 1383 | |
| 1384 | 1384 | // Load superglobal |
| 1385 | - include_once $SETTINGS['cpassman_dir'] . '/includes/libraries/protect/SuperGlobal/SuperGlobal.php'; |
|
| 1385 | + include_once $SETTINGS['cpassman_dir'].'/includes/libraries/protect/SuperGlobal/SuperGlobal.php'; |
|
| 1386 | 1386 | $superGlobal = new protect\SuperGlobal\SuperGlobal(); |
| 1387 | 1387 | // Get superglobals |
| 1388 | 1388 | if ($key !== null) { |
@@ -1393,9 +1393,9 @@ discard block |
||
| 1393 | 1393 | } |
| 1394 | 1394 | |
| 1395 | 1395 | //load ClassLoader |
| 1396 | - include_once $SETTINGS['cpassman_dir'] . '/sources/SplClassLoader.php'; |
|
| 1396 | + include_once $SETTINGS['cpassman_dir'].'/sources/SplClassLoader.php'; |
|
| 1397 | 1397 | //Load AES |
| 1398 | - $aes = new SplClassLoader('Encryption\Crypt', $SETTINGS['cpassman_dir'] . '/includes/libraries'); |
|
| 1398 | + $aes = new SplClassLoader('Encryption\Crypt', $SETTINGS['cpassman_dir'].'/includes/libraries'); |
|
| 1399 | 1399 | $aes->register(); |
| 1400 | 1400 | if ($type === 'encode' && is_array($data) === true) { |
| 1401 | 1401 | // Ensure UTF8 format |
@@ -1465,8 +1465,8 @@ discard block |
||
| 1465 | 1465 | */ |
| 1466 | 1466 | function prefixTable(string $table): string |
| 1467 | 1467 | { |
| 1468 | - $safeTable = htmlspecialchars(DB_PREFIX . $table); |
|
| 1469 | - if (! empty($safeTable)) { |
|
| 1468 | + $safeTable = htmlspecialchars(DB_PREFIX.$table); |
|
| 1469 | + if (!empty($safeTable)) { |
|
| 1470 | 1470 | // sanitize string |
| 1471 | 1471 | return $safeTable; |
| 1472 | 1472 | } |
@@ -1494,13 +1494,13 @@ discard block |
||
| 1494 | 1494 | bool $lowercase = false, |
| 1495 | 1495 | array $SETTINGS = [] |
| 1496 | 1496 | ): string { |
| 1497 | - include_once $SETTINGS['cpassman_dir'] . '/sources/SplClassLoader.php'; |
|
| 1498 | - $generator = new SplClassLoader('PasswordGenerator\Generator', $SETTINGS['cpassman_dir'] . '/includes/libraries'); |
|
| 1497 | + include_once $SETTINGS['cpassman_dir'].'/sources/SplClassLoader.php'; |
|
| 1498 | + $generator = new SplClassLoader('PasswordGenerator\Generator', $SETTINGS['cpassman_dir'].'/includes/libraries'); |
|
| 1499 | 1499 | $generator->register(); |
| 1500 | 1500 | $generator = new PasswordGenerator\Generator\ComputerPasswordGenerator(); |
| 1501 | 1501 | // Is PHP7 being used? |
| 1502 | 1502 | if (version_compare(PHP_VERSION, '7.0.0', '>=')) { |
| 1503 | - $php7generator = new SplClassLoader('PasswordGenerator\RandomGenerator', $SETTINGS['cpassman_dir'] . '/includes/libraries'); |
|
| 1503 | + $php7generator = new SplClassLoader('PasswordGenerator\RandomGenerator', $SETTINGS['cpassman_dir'].'/includes/libraries'); |
|
| 1504 | 1504 | $php7generator->register(); |
| 1505 | 1505 | $generator->setRandomGenerator(new PasswordGenerator\RandomGenerator\Php7RandomGenerator()); |
| 1506 | 1506 | } |
@@ -1530,7 +1530,7 @@ discard block |
||
| 1530 | 1530 | function send_syslog($message, $host, $port, $component = 'teampass'): void |
| 1531 | 1531 | { |
| 1532 | 1532 | $sock = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP); |
| 1533 | - $syslog_message = '<123>' . date('M d H:i:s ') . $component . ': ' . $message; |
|
| 1533 | + $syslog_message = '<123>'.date('M d H:i:s ').$component.': '.$message; |
|
| 1534 | 1534 | socket_sendto($sock, $syslog_message, strlen($syslog_message), 0, $host, $port); |
| 1535 | 1535 | socket_close($sock); |
| 1536 | 1536 | } |
@@ -1552,7 +1552,7 @@ discard block |
||
| 1552 | 1552 | } |
| 1553 | 1553 | |
| 1554 | 1554 | // include librairies & connect to DB |
| 1555 | - include_once $SETTINGS['cpassman_dir'] . '/includes/libraries/Database/Meekrodb/db.class.php'; |
|
| 1555 | + include_once $SETTINGS['cpassman_dir'].'/includes/libraries/Database/Meekrodb/db.class.php'; |
|
| 1556 | 1556 | if (defined('DB_PASSWD_CLEAR') === false) { |
| 1557 | 1557 | define('DB_PASSWD_CLEAR', defuseReturnDecrypted(DB_PASSWD, $SETTINGS)); |
| 1558 | 1558 | } |
@@ -1576,14 +1576,14 @@ discard block |
||
| 1576 | 1576 | if (isset($SETTINGS['syslog_enable']) === true && (int) $SETTINGS['syslog_enable'] === 1) { |
| 1577 | 1577 | if ($type === 'user_mngt') { |
| 1578 | 1578 | send_syslog( |
| 1579 | - 'action=' . str_replace('at_', '', $label) . ' attribute=user user=' . $who . ' userid="' . $login . '" change="' . $field_1 . '" ', |
|
| 1579 | + 'action='.str_replace('at_', '', $label).' attribute=user user='.$who.' userid="'.$login.'" change="'.$field_1.'" ', |
|
| 1580 | 1580 | $SETTINGS['syslog_host'], |
| 1581 | 1581 | $SETTINGS['syslog_port'], |
| 1582 | 1582 | 'teampass' |
| 1583 | 1583 | ); |
| 1584 | 1584 | } else { |
| 1585 | 1585 | send_syslog( |
| 1586 | - 'action=' . $type . ' attribute=' . $label . ' user=' . $who . ' userid="' . $login . '" ', |
|
| 1586 | + 'action='.$type.' attribute='.$label.' user='.$who.' userid="'.$login.'" ', |
|
| 1587 | 1587 | $SETTINGS['syslog_host'], |
| 1588 | 1588 | $SETTINGS['syslog_port'], |
| 1589 | 1589 | 'teampass' |
@@ -1615,7 +1615,7 @@ discard block |
||
| 1615 | 1615 | ?string $encryption_type = null |
| 1616 | 1616 | ): void { |
| 1617 | 1617 | // include librairies & connect to DB |
| 1618 | - include_once $SETTINGS['cpassman_dir'] . '/includes/libraries/Database/Meekrodb/db.class.php'; |
|
| 1618 | + include_once $SETTINGS['cpassman_dir'].'/includes/libraries/Database/Meekrodb/db.class.php'; |
|
| 1619 | 1619 | if (defined('DB_PASSWD_CLEAR') === false) { |
| 1620 | 1620 | define('DB_PASSWD_CLEAR', defuseReturnDecrypted(DB_PASSWD, $SETTINGS)); |
| 1621 | 1621 | } |
@@ -1659,7 +1659,7 @@ discard block |
||
| 1659 | 1659 | if (empty($item_label) === true) { |
| 1660 | 1660 | $dataItem = DB::queryfirstrow( |
| 1661 | 1661 | 'SELECT id, id_tree, label |
| 1662 | - FROM ' . prefixTable('items') . ' |
|
| 1662 | + FROM ' . prefixTable('items').' |
|
| 1663 | 1663 | WHERE id = %i', |
| 1664 | 1664 | $item_id |
| 1665 | 1665 | ); |
@@ -1667,11 +1667,11 @@ discard block |
||
| 1667 | 1667 | } |
| 1668 | 1668 | |
| 1669 | 1669 | send_syslog( |
| 1670 | - 'action=' . str_replace('at_', '', $action) . |
|
| 1671 | - ' attribute=' . str_replace('at_', '', $attribute[0]) . |
|
| 1672 | - ' itemno=' . $item_id . |
|
| 1673 | - ' user=' . is_null($login) === true ? '' : addslashes((string) $login) . |
|
| 1674 | - ' itemname="' . addslashes($item_label) . '"', |
|
| 1670 | + 'action='.str_replace('at_', '', $action). |
|
| 1671 | + ' attribute='.str_replace('at_', '', $attribute[0]). |
|
| 1672 | + ' itemno='.$item_id. |
|
| 1673 | + ' user='.is_null($login) === true ? '' : addslashes((string) $login). |
|
| 1674 | + ' itemname="'.addslashes($item_label).'"', |
|
| 1675 | 1675 | $SETTINGS['syslog_host'], |
| 1676 | 1676 | $SETTINGS['syslog_port'], |
| 1677 | 1677 | 'teampass' |
@@ -1697,7 +1697,7 @@ discard block |
||
| 1697 | 1697 | && $action === 'at_shown' |
| 1698 | 1698 | ) { |
| 1699 | 1699 | // Load superglobal |
| 1700 | - include_once $SETTINGS['cpassman_dir'] . '/includes/libraries/protect/SuperGlobal/SuperGlobal.php'; |
|
| 1700 | + include_once $SETTINGS['cpassman_dir'].'/includes/libraries/protect/SuperGlobal/SuperGlobal.php'; |
|
| 1701 | 1701 | $superGlobal = new protect\SuperGlobal\SuperGlobal(); |
| 1702 | 1702 | // Get superglobals |
| 1703 | 1703 | $globalsLastname = $superGlobal->get('lastname', 'SESSION'); |
@@ -1706,7 +1706,7 @@ discard block |
||
| 1706 | 1706 | // Get info about item |
| 1707 | 1707 | $dataItem = DB::queryfirstrow( |
| 1708 | 1708 | 'SELECT id, id_tree, label |
| 1709 | - FROM ' . prefixTable('items') . ' |
|
| 1709 | + FROM ' . prefixTable('items').' |
|
| 1710 | 1710 | WHERE id = %i', |
| 1711 | 1711 | $item_id |
| 1712 | 1712 | ); |
@@ -1720,9 +1720,9 @@ discard block |
||
| 1720 | 1720 | 'body' => str_replace( |
| 1721 | 1721 | ['#tp_user#', '#tp_item#', '#tp_link#'], |
| 1722 | 1722 | [ |
| 1723 | - addslashes($globalsName . ' ' . $globalsLastname), |
|
| 1723 | + addslashes($globalsName.' '.$globalsLastname), |
|
| 1724 | 1724 | addslashes($item_label), |
| 1725 | - $SETTINGS['cpassman_url'] . '/index.php?page=items&group=' . $dataItem['id_tree'] . '&id=' . $item_id, |
|
| 1725 | + $SETTINGS['cpassman_url'].'/index.php?page=items&group='.$dataItem['id_tree'].'&id='.$item_id, |
|
| 1726 | 1726 | ], |
| 1727 | 1727 | langHdl('email_on_open_notification_mail') |
| 1728 | 1728 | ), |
@@ -1744,7 +1744,7 @@ discard block |
||
| 1744 | 1744 | function notifyChangesToSubscribers(int $item_id, string $label, array $changes, array $SETTINGS): void |
| 1745 | 1745 | { |
| 1746 | 1746 | // Load superglobal |
| 1747 | - include_once $SETTINGS['cpassman_dir'] . '/includes/libraries/protect/SuperGlobal/SuperGlobal.php'; |
|
| 1747 | + include_once $SETTINGS['cpassman_dir'].'/includes/libraries/protect/SuperGlobal/SuperGlobal.php'; |
|
| 1748 | 1748 | $superGlobal = new protect\SuperGlobal\SuperGlobal(); |
| 1749 | 1749 | // Get superglobals |
| 1750 | 1750 | $globalsUserId = $superGlobal->get('user_id', 'SESSION'); |
@@ -1754,8 +1754,8 @@ discard block |
||
| 1754 | 1754 | $notification = DB::queryOneColumn( |
| 1755 | 1755 | 'email', |
| 1756 | 1756 | 'SELECT * |
| 1757 | - FROM ' . prefixTable('notification') . ' AS n |
|
| 1758 | - INNER JOIN ' . prefixTable('users') . ' AS u ON (n.user_id = u.id) |
|
| 1757 | + FROM ' . prefixTable('notification').' AS n |
|
| 1758 | + INNER JOIN ' . prefixTable('users').' AS u ON (n.user_id = u.id) |
|
| 1759 | 1759 | WHERE n.item_id = %i AND n.user_id != %i', |
| 1760 | 1760 | $item_id, |
| 1761 | 1761 | $globalsUserId |
@@ -1766,7 +1766,7 @@ discard block |
||
| 1766 | 1766 | // Get list of changes |
| 1767 | 1767 | $htmlChanges = '<ul>'; |
| 1768 | 1768 | foreach ($changes as $change) { |
| 1769 | - $htmlChanges .= '<li>' . $change . '</li>'; |
|
| 1769 | + $htmlChanges .= '<li>'.$change.'</li>'; |
|
| 1770 | 1770 | } |
| 1771 | 1771 | $htmlChanges .= '</ul>'; |
| 1772 | 1772 | // send email |
@@ -1797,7 +1797,7 @@ discard block |
||
| 1797 | 1797 | function geItemReadablePath(int $id_tree, string $label, array $SETTINGS): string |
| 1798 | 1798 | { |
| 1799 | 1799 | // Class loader |
| 1800 | - include_once $SETTINGS['cpassman_dir'] . '/sources/SplClassLoader.php'; |
|
| 1800 | + include_once $SETTINGS['cpassman_dir'].'/sources/SplClassLoader.php'; |
|
| 1801 | 1801 | //Load Tree |
| 1802 | 1802 | $tree = new SplClassLoader('Tree\NestedTree', '../includes/libraries'); |
| 1803 | 1803 | $tree->register(); |
@@ -1806,15 +1806,15 @@ discard block |
||
| 1806 | 1806 | $path = ''; |
| 1807 | 1807 | foreach ($arbo as $elem) { |
| 1808 | 1808 | if (empty($path) === true) { |
| 1809 | - $path = htmlspecialchars(stripslashes(htmlspecialchars_decode($elem->title, ENT_QUOTES)), ENT_QUOTES) . ' '; |
|
| 1809 | + $path = htmlspecialchars(stripslashes(htmlspecialchars_decode($elem->title, ENT_QUOTES)), ENT_QUOTES).' '; |
|
| 1810 | 1810 | } else { |
| 1811 | - $path .= '→ ' . htmlspecialchars(stripslashes(htmlspecialchars_decode($elem->title, ENT_QUOTES)), ENT_QUOTES); |
|
| 1811 | + $path .= '→ '.htmlspecialchars(stripslashes(htmlspecialchars_decode($elem->title, ENT_QUOTES)), ENT_QUOTES); |
|
| 1812 | 1812 | } |
| 1813 | 1813 | } |
| 1814 | 1814 | |
| 1815 | 1815 | // Build text to show user |
| 1816 | 1816 | if (empty($label) === false) { |
| 1817 | - return empty($path) === true ? addslashes($label) : addslashes($label) . ' (' . $path . ')'; |
|
| 1817 | + return empty($path) === true ? addslashes($label) : addslashes($label).' ('.$path.')'; |
|
| 1818 | 1818 | } |
| 1819 | 1819 | return empty($path) === true ? '' : $path; |
| 1820 | 1820 | } |
@@ -1869,9 +1869,9 @@ discard block |
||
| 1869 | 1869 | */ |
| 1870 | 1870 | function handleConfigFile($action, $SETTINGS, $field = null, $value = null) |
| 1871 | 1871 | { |
| 1872 | - $tp_config_file = $SETTINGS['cpassman_dir'] . '/includes/config/tp.config.php'; |
|
| 1872 | + $tp_config_file = $SETTINGS['cpassman_dir'].'/includes/config/tp.config.php'; |
|
| 1873 | 1873 | // include librairies & connect to DB |
| 1874 | - include_once $SETTINGS['cpassman_dir'] . '/includes/libraries/Database/Meekrodb/db.class.php'; |
|
| 1874 | + include_once $SETTINGS['cpassman_dir'].'/includes/libraries/Database/Meekrodb/db.class.php'; |
|
| 1875 | 1875 | if (defined('DB_PASSWD_CLEAR') === false) { |
| 1876 | 1876 | define('DB_PASSWD_CLEAR', defuseReturnDecrypted(DB_PASSWD, $SETTINGS)); |
| 1877 | 1877 | } |
@@ -1884,8 +1884,8 @@ discard block |
||
| 1884 | 1884 | if (file_exists($tp_config_file) === false || $action === 'rebuild') { |
| 1885 | 1885 | // perform a copy |
| 1886 | 1886 | if (file_exists($tp_config_file)) { |
| 1887 | - if (! copy($tp_config_file, $tp_config_file . '.' . date('Y_m_d_His', time()))) { |
|
| 1888 | - return "ERROR: Could not copy file '" . $tp_config_file . "'"; |
|
| 1887 | + if (!copy($tp_config_file, $tp_config_file.'.'.date('Y_m_d_His', time()))) { |
|
| 1888 | + return "ERROR: Could not copy file '".$tp_config_file."'"; |
|
| 1889 | 1889 | } |
| 1890 | 1890 | } |
| 1891 | 1891 | |
@@ -1895,11 +1895,11 @@ discard block |
||
| 1895 | 1895 | $data[1] = "global \$SETTINGS;\n"; |
| 1896 | 1896 | $data[2] = "\$SETTINGS = array (\n"; |
| 1897 | 1897 | $rows = DB::query( |
| 1898 | - 'SELECT * FROM ' . prefixTable('misc') . ' WHERE type=%s', |
|
| 1898 | + 'SELECT * FROM '.prefixTable('misc').' WHERE type=%s', |
|
| 1899 | 1899 | 'admin' |
| 1900 | 1900 | ); |
| 1901 | 1901 | foreach ($rows as $record) { |
| 1902 | - array_push($data, " '" . $record['intitule'] . "' => '" . $record['valeur'] . "',\n"); |
|
| 1902 | + array_push($data, " '".$record['intitule']."' => '".$record['valeur']."',\n"); |
|
| 1903 | 1903 | } |
| 1904 | 1904 | array_push($data, ");\n"); |
| 1905 | 1905 | $data = array_unique($data); |
@@ -1913,15 +1913,15 @@ discard block |
||
| 1913 | 1913 | break; |
| 1914 | 1914 | } |
| 1915 | 1915 | |
| 1916 | - if (stristr($line, "'" . $field . "' => '")) { |
|
| 1917 | - $data[$inc] = " '" . $field . "' => '" . filter_var($value, FILTER_SANITIZE_STRING) . "',\n"; |
|
| 1916 | + if (stristr($line, "'".$field."' => '")) { |
|
| 1917 | + $data[$inc] = " '".$field."' => '".filter_var($value, FILTER_SANITIZE_STRING)."',\n"; |
|
| 1918 | 1918 | $bFound = true; |
| 1919 | 1919 | break; |
| 1920 | 1920 | } |
| 1921 | 1921 | ++$inc; |
| 1922 | 1922 | } |
| 1923 | 1923 | if ($bFound === false) { |
| 1924 | - $data[$inc] = " '" . $field . "' => '" . filter_var($value, FILTER_SANITIZE_STRING) . "',\n);\n"; |
|
| 1924 | + $data[$inc] = " '".$field."' => '".filter_var($value, FILTER_SANITIZE_STRING)."',\n);\n"; |
|
| 1925 | 1925 | } |
| 1926 | 1926 | } |
| 1927 | 1927 | |
@@ -1947,7 +1947,7 @@ discard block |
||
| 1947 | 1947 | { |
| 1948 | 1948 | global $SETTINGS; |
| 1949 | 1949 | /* LOAD CPASSMAN SETTINGS */ |
| 1950 | - if (! isset($SETTINGS['loaded']) || $SETTINGS['loaded'] !== 1) { |
|
| 1950 | + if (!isset($SETTINGS['loaded']) || $SETTINGS['loaded'] !== 1) { |
|
| 1951 | 1951 | $SETTINGS = []; |
| 1952 | 1952 | $SETTINGS['duplicate_folder'] = 0; |
| 1953 | 1953 | //by default, this is set to 0; |
@@ -1957,7 +1957,7 @@ discard block |
||
| 1957 | 1957 | //by default, this value is set to 5; |
| 1958 | 1958 | $settings = []; |
| 1959 | 1959 | $rows = DB::query( |
| 1960 | - 'SELECT * FROM ' . prefixTable('misc') . ' WHERE type=%s_type OR type=%s_type2', |
|
| 1960 | + 'SELECT * FROM '.prefixTable('misc').' WHERE type=%s_type OR type=%s_type2', |
|
| 1961 | 1961 | [ |
| 1962 | 1962 | 'type' => 'admin', |
| 1963 | 1963 | 'type2' => 'settings', |
@@ -1984,7 +1984,7 @@ discard block |
||
| 1984 | 1984 | $source_cf = []; |
| 1985 | 1985 | $rows = DB::QUERY( |
| 1986 | 1986 | 'SELECT id_category |
| 1987 | - FROM ' . prefixTable('categories_folders') . ' |
|
| 1987 | + FROM ' . prefixTable('categories_folders').' |
|
| 1988 | 1988 | WHERE id_folder = %i', |
| 1989 | 1989 | $source_id |
| 1990 | 1990 | ); |
@@ -1995,7 +1995,7 @@ discard block |
||
| 1995 | 1995 | $target_cf = []; |
| 1996 | 1996 | $rows = DB::QUERY( |
| 1997 | 1997 | 'SELECT id_category |
| 1998 | - FROM ' . prefixTable('categories_folders') . ' |
|
| 1998 | + FROM ' . prefixTable('categories_folders').' |
|
| 1999 | 1999 | WHERE id_folder = %i', |
| 2000 | 2000 | $target_id |
| 2001 | 2001 | ); |
@@ -2030,9 +2030,9 @@ discard block |
||
| 2030 | 2030 | $password = null |
| 2031 | 2031 | ) { |
| 2032 | 2032 | // Load AntiXSS |
| 2033 | - include_once $SETTINGS['cpassman_dir'] . '/includes/libraries/voku/helper/AntiXSS.php'; |
|
| 2034 | - include_once $SETTINGS['cpassman_dir'] . '/includes/libraries/voku/helper/ASCII.php'; |
|
| 2035 | - include_once $SETTINGS['cpassman_dir'] . '/includes/libraries/voku/helper/UTF8.php'; |
|
| 2033 | + include_once $SETTINGS['cpassman_dir'].'/includes/libraries/voku/helper/AntiXSS.php'; |
|
| 2034 | + include_once $SETTINGS['cpassman_dir'].'/includes/libraries/voku/helper/ASCII.php'; |
|
| 2035 | + include_once $SETTINGS['cpassman_dir'].'/includes/libraries/voku/helper/UTF8.php'; |
|
| 2036 | 2036 | $antiXss = new voku\helper\AntiXSS(); |
| 2037 | 2037 | // Protect against bad inputs |
| 2038 | 2038 | if (is_array($source_file) === true || is_array($target_file) === true) { |
@@ -2044,7 +2044,7 @@ discard block |
||
| 2044 | 2044 | $target_file = $antiXss->xss_clean($target_file); |
| 2045 | 2045 | if (empty($password) === true || is_null($password) === true) { |
| 2046 | 2046 | // get KEY to define password |
| 2047 | - $ascii_key = file_get_contents(SECUREPATH . '/teampass-seckey.txt'); |
|
| 2047 | + $ascii_key = file_get_contents(SECUREPATH.'/teampass-seckey.txt'); |
|
| 2048 | 2048 | $password = \Defuse\Crypto\Key::loadFromAsciiSafeString($ascii_key); |
| 2049 | 2049 | } |
| 2050 | 2050 | |
@@ -2089,15 +2089,15 @@ discard block |
||
| 2089 | 2089 | ) { |
| 2090 | 2090 | // load PhpEncryption library |
| 2091 | 2091 | $path_to_encryption = '/includes/libraries/Encryption/Encryption/'; |
| 2092 | - include_once $SETTINGS['cpassman_dir'] . $path_to_encryption . 'Crypto.php'; |
|
| 2093 | - include_once $SETTINGS['cpassman_dir'] . $path_to_encryption . 'Encoding.php'; |
|
| 2094 | - include_once $SETTINGS['cpassman_dir'] . $path_to_encryption . 'DerivedKeys.php'; |
|
| 2095 | - include_once $SETTINGS['cpassman_dir'] . $path_to_encryption . 'Key.php'; |
|
| 2096 | - include_once $SETTINGS['cpassman_dir'] . $path_to_encryption . 'KeyOrPassword.php'; |
|
| 2097 | - include_once $SETTINGS['cpassman_dir'] . $path_to_encryption . 'File.php'; |
|
| 2098 | - include_once $SETTINGS['cpassman_dir'] . $path_to_encryption . 'RuntimeTests.php'; |
|
| 2099 | - include_once $SETTINGS['cpassman_dir'] . $path_to_encryption . 'KeyProtectedByPassword.php'; |
|
| 2100 | - include_once $SETTINGS['cpassman_dir'] . $path_to_encryption . 'Core.php'; |
|
| 2092 | + include_once $SETTINGS['cpassman_dir'].$path_to_encryption.'Crypto.php'; |
|
| 2093 | + include_once $SETTINGS['cpassman_dir'].$path_to_encryption.'Encoding.php'; |
|
| 2094 | + include_once $SETTINGS['cpassman_dir'].$path_to_encryption.'DerivedKeys.php'; |
|
| 2095 | + include_once $SETTINGS['cpassman_dir'].$path_to_encryption.'Key.php'; |
|
| 2096 | + include_once $SETTINGS['cpassman_dir'].$path_to_encryption.'KeyOrPassword.php'; |
|
| 2097 | + include_once $SETTINGS['cpassman_dir'].$path_to_encryption.'File.php'; |
|
| 2098 | + include_once $SETTINGS['cpassman_dir'].$path_to_encryption.'RuntimeTests.php'; |
|
| 2099 | + include_once $SETTINGS['cpassman_dir'].$path_to_encryption.'KeyProtectedByPassword.php'; |
|
| 2100 | + include_once $SETTINGS['cpassman_dir'].$path_to_encryption.'Core.php'; |
|
| 2101 | 2101 | try { |
| 2102 | 2102 | \Defuse\Crypto\File::encryptFileWithPassword( |
| 2103 | 2103 | $source_file, |
@@ -2134,15 +2134,15 @@ discard block |
||
| 2134 | 2134 | ) { |
| 2135 | 2135 | // load PhpEncryption library |
| 2136 | 2136 | $path_to_encryption = '/includes/libraries/Encryption/Encryption/'; |
| 2137 | - include_once $SETTINGS['cpassman_dir'] . $path_to_encryption . 'Crypto.php'; |
|
| 2138 | - include_once $SETTINGS['cpassman_dir'] . $path_to_encryption . 'Encoding.php'; |
|
| 2139 | - include_once $SETTINGS['cpassman_dir'] . $path_to_encryption . 'DerivedKeys.php'; |
|
| 2140 | - include_once $SETTINGS['cpassman_dir'] . $path_to_encryption . 'Key.php'; |
|
| 2141 | - include_once $SETTINGS['cpassman_dir'] . $path_to_encryption . 'KeyOrPassword.php'; |
|
| 2142 | - include_once $SETTINGS['cpassman_dir'] . $path_to_encryption . 'File.php'; |
|
| 2143 | - include_once $SETTINGS['cpassman_dir'] . $path_to_encryption . 'RuntimeTests.php'; |
|
| 2144 | - include_once $SETTINGS['cpassman_dir'] . $path_to_encryption . 'KeyProtectedByPassword.php'; |
|
| 2145 | - include_once $SETTINGS['cpassman_dir'] . $path_to_encryption . 'Core.php'; |
|
| 2137 | + include_once $SETTINGS['cpassman_dir'].$path_to_encryption.'Crypto.php'; |
|
| 2138 | + include_once $SETTINGS['cpassman_dir'].$path_to_encryption.'Encoding.php'; |
|
| 2139 | + include_once $SETTINGS['cpassman_dir'].$path_to_encryption.'DerivedKeys.php'; |
|
| 2140 | + include_once $SETTINGS['cpassman_dir'].$path_to_encryption.'Key.php'; |
|
| 2141 | + include_once $SETTINGS['cpassman_dir'].$path_to_encryption.'KeyOrPassword.php'; |
|
| 2142 | + include_once $SETTINGS['cpassman_dir'].$path_to_encryption.'File.php'; |
|
| 2143 | + include_once $SETTINGS['cpassman_dir'].$path_to_encryption.'RuntimeTests.php'; |
|
| 2144 | + include_once $SETTINGS['cpassman_dir'].$path_to_encryption.'KeyProtectedByPassword.php'; |
|
| 2145 | + include_once $SETTINGS['cpassman_dir'].$path_to_encryption.'Core.php'; |
|
| 2146 | 2146 | try { |
| 2147 | 2147 | \Defuse\Crypto\File::decryptFileWithPassword( |
| 2148 | 2148 | $source_file, |
@@ -2187,9 +2187,9 @@ discard block |
||
| 2187 | 2187 | function fileDelete(string $file, array $SETTINGS): void |
| 2188 | 2188 | { |
| 2189 | 2189 | // Load AntiXSS |
| 2190 | - include_once $SETTINGS['cpassman_dir'] . '/includes/libraries/voku/helper/ASCII.php'; |
|
| 2191 | - include_once $SETTINGS['cpassman_dir'] . '/includes/libraries/voku/helper/UTF8.php'; |
|
| 2192 | - include_once $SETTINGS['cpassman_dir'] . '/includes/libraries/voku/helper/AntiXSS.php'; |
|
| 2190 | + include_once $SETTINGS['cpassman_dir'].'/includes/libraries/voku/helper/ASCII.php'; |
|
| 2191 | + include_once $SETTINGS['cpassman_dir'].'/includes/libraries/voku/helper/UTF8.php'; |
|
| 2192 | + include_once $SETTINGS['cpassman_dir'].'/includes/libraries/voku/helper/AntiXSS.php'; |
|
| 2193 | 2193 | $antiXss = new voku\helper\AntiXSS(); |
| 2194 | 2194 | $file = $antiXss->xss_clean($file); |
| 2195 | 2195 | if (is_file($file)) { |
@@ -2233,7 +2233,7 @@ discard block |
||
| 2233 | 2233 | |
| 2234 | 2234 | function recursiveChmod($path, $filePerm = 0644, $dirPerm = 0755) { |
| 2235 | 2235 | // Check if the path exists |
| 2236 | - if (! file_exists($path)) { |
|
| 2236 | + if (!file_exists($path)) { |
|
| 2237 | 2237 | return false; |
| 2238 | 2238 | } |
| 2239 | 2239 | |
@@ -2268,7 +2268,7 @@ discard block |
||
| 2268 | 2268 | */ |
| 2269 | 2269 | function accessToItemIsGranted(int $item_id, $SETTINGS) |
| 2270 | 2270 | { |
| 2271 | - include_once $SETTINGS['cpassman_dir'] . '/includes/libraries/protect/SuperGlobal/SuperGlobal.php'; |
|
| 2271 | + include_once $SETTINGS['cpassman_dir'].'/includes/libraries/protect/SuperGlobal/SuperGlobal.php'; |
|
| 2272 | 2272 | $superGlobal = new protect\SuperGlobal\SuperGlobal(); |
| 2273 | 2273 | // Prepare superGlobal variables |
| 2274 | 2274 | $session_groupes_visibles = $superGlobal->get('groupes_visibles', 'SESSION'); |
@@ -2276,7 +2276,7 @@ discard block |
||
| 2276 | 2276 | // Load item data |
| 2277 | 2277 | $data = DB::queryFirstRow( |
| 2278 | 2278 | 'SELECT id_tree |
| 2279 | - FROM ' . prefixTable('items') . ' |
|
| 2279 | + FROM ' . prefixTable('items').' |
|
| 2280 | 2280 | WHERE id = %i', |
| 2281 | 2281 | $item_id |
| 2282 | 2282 | ); |
@@ -2349,8 +2349,8 @@ discard block |
||
| 2349 | 2349 | function performDBQuery(array $SETTINGS, string $fields, string $table): array |
| 2350 | 2350 | { |
| 2351 | 2351 | // include librairies & connect to DB |
| 2352 | - include_once $SETTINGS['cpassman_dir'] . '/includes/config/settings.php'; |
|
| 2353 | - include_once $SETTINGS['cpassman_dir'] . '/includes/libraries/Database/Meekrodb/db.class.php'; |
|
| 2352 | + include_once $SETTINGS['cpassman_dir'].'/includes/config/settings.php'; |
|
| 2353 | + include_once $SETTINGS['cpassman_dir'].'/includes/libraries/Database/Meekrodb/db.class.php'; |
|
| 2354 | 2354 | if (defined('DB_PASSWD_CLEAR') === false) { |
| 2355 | 2355 | define('DB_PASSWD_CLEAR', defuseReturnDecrypted(DB_PASSWD, $SETTINGS)); |
| 2356 | 2356 | } |
@@ -2362,7 +2362,7 @@ discard block |
||
| 2362 | 2362 | DB::$encoding = DB_ENCODING; |
| 2363 | 2363 | // Insert log in DB |
| 2364 | 2364 | return DB::query( |
| 2365 | - 'SELECT ' . $fields . ' |
|
| 2365 | + 'SELECT '.$fields.' |
|
| 2366 | 2366 | FROM ' . prefixTable($table) |
| 2367 | 2367 | ); |
| 2368 | 2368 | } |
@@ -2375,11 +2375,11 @@ discard block |
||
| 2375 | 2375 | function formatSizeUnits(int $bytes): string |
| 2376 | 2376 | { |
| 2377 | 2377 | if ($bytes >= 1073741824) { |
| 2378 | - $bytes = number_format($bytes / 1073741824, 2) . ' GB'; |
|
| 2378 | + $bytes = number_format($bytes / 1073741824, 2).' GB'; |
|
| 2379 | 2379 | } elseif ($bytes >= 1048576) { |
| 2380 | - $bytes = number_format($bytes / 1048576, 2) . ' MB'; |
|
| 2380 | + $bytes = number_format($bytes / 1048576, 2).' MB'; |
|
| 2381 | 2381 | } elseif ($bytes >= 1024) { |
| 2382 | - $bytes = number_format($bytes / 1024, 2) . ' KB'; |
|
| 2382 | + $bytes = number_format($bytes / 1024, 2).' KB'; |
|
| 2383 | 2383 | } elseif ($bytes > 1) { |
| 2384 | 2384 | $bytes .= ' bytes'; |
| 2385 | 2385 | } elseif ($bytes === 1) { |
@@ -2570,14 +2570,14 @@ discard block |
||
| 2570 | 2570 | |
| 2571 | 2571 | // Encrypt the file content |
| 2572 | 2572 | $plaintext = file_get_contents( |
| 2573 | - filter_var($fileInPath . '/' . $fileInName, FILTER_SANITIZE_URL) |
|
| 2573 | + filter_var($fileInPath.'/'.$fileInName, FILTER_SANITIZE_URL) |
|
| 2574 | 2574 | ); |
| 2575 | 2575 | $ciphertext = $cipher->encrypt($plaintext); |
| 2576 | 2576 | // Save new file |
| 2577 | 2577 | $hash = md5($plaintext); |
| 2578 | - $fileOut = $fileInPath . '/' . TP_FILE_PREFIX . $hash; |
|
| 2578 | + $fileOut = $fileInPath.'/'.TP_FILE_PREFIX.$hash; |
|
| 2579 | 2579 | file_put_contents($fileOut, $ciphertext); |
| 2580 | - unlink($fileInPath . '/' . $fileInName); |
|
| 2580 | + unlink($fileInPath.'/'.$fileInName); |
|
| 2581 | 2581 | return [ |
| 2582 | 2582 | 'fileHash' => base64_encode($hash), |
| 2583 | 2583 | 'objectKey' => base64_encode($objectKey), |
@@ -2593,7 +2593,7 @@ discard block |
||
| 2593 | 2593 | */ |
| 2594 | 2594 | function decryptFile(string $fileName, string $filePath, string $key): string |
| 2595 | 2595 | { |
| 2596 | - if (! defined('FILE_BUFFER_SIZE')) { |
|
| 2596 | + if (!defined('FILE_BUFFER_SIZE')) { |
|
| 2597 | 2597 | define('FILE_BUFFER_SIZE', 128 * 1024); |
| 2598 | 2598 | } |
| 2599 | 2599 | |
@@ -2612,7 +2612,7 @@ discard block |
||
| 2612 | 2612 | $cipher->enableContinuousBuffer(); |
| 2613 | 2613 | $cipher->disablePadding(); |
| 2614 | 2614 | // Get file content |
| 2615 | - $ciphertext = file_get_contents($filePath . '/' . TP_FILE_PREFIX . $fileName); |
|
| 2615 | + $ciphertext = file_get_contents($filePath.'/'.TP_FILE_PREFIX.$fileName); |
|
| 2616 | 2616 | // Decrypt file content and return |
| 2617 | 2617 | return base64_encode($cipher->decrypt($ciphertext)); |
| 2618 | 2618 | } |
@@ -2662,8 +2662,8 @@ discard block |
||
| 2662 | 2662 | array $SETTINGS |
| 2663 | 2663 | ): void { |
| 2664 | 2664 | // include librairies & connect to DB |
| 2665 | - include_once $SETTINGS['cpassman_dir'] . '/includes/config/settings.php'; |
|
| 2666 | - include_once $SETTINGS['cpassman_dir'] . '/includes/libraries/Database/Meekrodb/db.class.php'; |
|
| 2665 | + include_once $SETTINGS['cpassman_dir'].'/includes/config/settings.php'; |
|
| 2666 | + include_once $SETTINGS['cpassman_dir'].'/includes/libraries/Database/Meekrodb/db.class.php'; |
|
| 2667 | 2667 | if (defined('DB_PASSWD_CLEAR') === false) { |
| 2668 | 2668 | define('DB_PASSWD_CLEAR', defuseReturnDecrypted(DB_PASSWD, $SETTINGS)); |
| 2669 | 2669 | } |
@@ -2680,7 +2680,7 @@ discard block |
||
| 2680 | 2680 | $post_object_id |
| 2681 | 2681 | ); |
| 2682 | 2682 | // Superglobals |
| 2683 | - include_once $SETTINGS['cpassman_dir'] . '/includes/libraries/protect/SuperGlobal/SuperGlobal.php'; |
|
| 2683 | + include_once $SETTINGS['cpassman_dir'].'/includes/libraries/protect/SuperGlobal/SuperGlobal.php'; |
|
| 2684 | 2684 | $superGlobal = new protect\SuperGlobal\SuperGlobal(); |
| 2685 | 2685 | // Prepare superGlobal variables |
| 2686 | 2686 | $sessionPpersonaFolders = $superGlobal->get('personal_folders', 'SESSION'); |
@@ -2705,8 +2705,8 @@ discard block |
||
| 2705 | 2705 | // Create sharekey for each user |
| 2706 | 2706 | $users = DB::query( |
| 2707 | 2707 | 'SELECT id, public_key |
| 2708 | - FROM ' . prefixTable('users') . ' |
|
| 2709 | - WHERE id NOT IN ("' . OTV_USER_ID . '","' . SSH_USER_ID . '","' . API_USER_ID . '") |
|
| 2708 | + FROM ' . prefixTable('users').' |
|
| 2709 | + WHERE id NOT IN ("' . OTV_USER_ID.'","'.SSH_USER_ID.'","'.API_USER_ID.'") |
|
| 2710 | 2710 | AND public_key != ""' |
| 2711 | 2711 | ); |
| 2712 | 2712 | foreach ($users as $user) { |
@@ -2734,7 +2734,7 @@ discard block |
||
| 2734 | 2734 | function isBase64(string $str): bool |
| 2735 | 2735 | { |
| 2736 | 2736 | $str = (string) trim($str); |
| 2737 | - if (! isset($str[0])) { |
|
| 2737 | + if (!isset($str[0])) { |
|
| 2738 | 2738 | return false; |
| 2739 | 2739 | } |
| 2740 | 2740 | |
@@ -2802,13 +2802,13 @@ discard block |
||
| 2802 | 2802 | ], |
| 2803 | 2803 | ]; |
| 2804 | 2804 | // Load expected libraries |
| 2805 | - require_once $SETTINGS['cpassman_dir'] . '/includes/libraries/Tightenco/Collect/Support/Traits/Macroable.php'; |
|
| 2806 | - require_once $SETTINGS['cpassman_dir'] . '/includes/libraries/Tightenco/Collect/Support/Arr.php'; |
|
| 2807 | - require_once $SETTINGS['cpassman_dir'] . '/includes/libraries/LdapRecord/DetectsErrors.php'; |
|
| 2808 | - require_once $SETTINGS['cpassman_dir'] . '/includes/libraries/LdapRecord/Connection.php'; |
|
| 2809 | - require_once $SETTINGS['cpassman_dir'] . '/includes/libraries/LdapRecord/LdapInterface.php'; |
|
| 2810 | - require_once $SETTINGS['cpassman_dir'] . '/includes/libraries/LdapRecord/LdapBase.php'; |
|
| 2811 | - require_once $SETTINGS['cpassman_dir'] . '/includes/libraries/LdapRecord/Ldap.php'; |
|
| 2805 | + require_once $SETTINGS['cpassman_dir'].'/includes/libraries/Tightenco/Collect/Support/Traits/Macroable.php'; |
|
| 2806 | + require_once $SETTINGS['cpassman_dir'].'/includes/libraries/Tightenco/Collect/Support/Arr.php'; |
|
| 2807 | + require_once $SETTINGS['cpassman_dir'].'/includes/libraries/LdapRecord/DetectsErrors.php'; |
|
| 2808 | + require_once $SETTINGS['cpassman_dir'].'/includes/libraries/LdapRecord/Connection.php'; |
|
| 2809 | + require_once $SETTINGS['cpassman_dir'].'/includes/libraries/LdapRecord/LdapInterface.php'; |
|
| 2810 | + require_once $SETTINGS['cpassman_dir'].'/includes/libraries/LdapRecord/LdapBase.php'; |
|
| 2811 | + require_once $SETTINGS['cpassman_dir'].'/includes/libraries/LdapRecord/Ldap.php'; |
|
| 2812 | 2812 | $ad = new SplClassLoader('LdapRecord', '../includes/libraries'); |
| 2813 | 2813 | $ad->register(); |
| 2814 | 2814 | $connection = new Connection($config); |
@@ -2817,7 +2817,7 @@ discard block |
||
| 2817 | 2817 | $connection->connect(); |
| 2818 | 2818 | } catch (\LdapRecord\Auth\BindException $e) { |
| 2819 | 2819 | $error = $e->getDetailedError(); |
| 2820 | - echo 'Error : '.$error->getErrorCode().' - '.$error->getErrorMessage(). '<br>'.$error->getDiagnosticMessage(); |
|
| 2820 | + echo 'Error : '.$error->getErrorCode().' - '.$error->getErrorMessage().'<br>'.$error->getDiagnosticMessage(); |
|
| 2821 | 2821 | return false; |
| 2822 | 2822 | } |
| 2823 | 2823 | |
@@ -2826,7 +2826,7 @@ discard block |
||
| 2826 | 2826 | $connection->auth()->attempt($SETTINGS['ldap_user_attribute'].'='.$login.','.$SETTINGS['ldap_bdn'], $password, $stayAuthenticated = true); |
| 2827 | 2827 | } catch (\LdapRecord\Auth\BindException $e) { |
| 2828 | 2828 | $error = $e->getDetailedError(); |
| 2829 | - echo 'Error : '.$error->getErrorCode().' - '.$error->getErrorMessage(). '<br>'.$error->getDiagnosticMessage(); |
|
| 2829 | + echo 'Error : '.$error->getErrorCode().' - '.$error->getErrorMessage().'<br>'.$error->getDiagnosticMessage(); |
|
| 2830 | 2830 | return false; |
| 2831 | 2831 | } |
| 2832 | 2832 | |
@@ -2844,8 +2844,8 @@ discard block |
||
| 2844 | 2844 | function deleteUserObjetsKeys(int $userId, array $SETTINGS): bool |
| 2845 | 2845 | { |
| 2846 | 2846 | // include librairies & connect to DB |
| 2847 | - include_once $SETTINGS['cpassman_dir'] . '/includes/config/settings.php'; |
|
| 2848 | - include_once $SETTINGS['cpassman_dir'] . '/includes/libraries/Database/Meekrodb/db.class.php'; |
|
| 2847 | + include_once $SETTINGS['cpassman_dir'].'/includes/config/settings.php'; |
|
| 2848 | + include_once $SETTINGS['cpassman_dir'].'/includes/libraries/Database/Meekrodb/db.class.php'; |
|
| 2849 | 2849 | if (defined('DB_PASSWD_CLEAR') === false) { |
| 2850 | 2850 | define('DB_PASSWD_CLEAR', defuseReturnDecrypted(DB_PASSWD, $SETTINGS)); |
| 2851 | 2851 | } |
@@ -2903,7 +2903,7 @@ discard block |
||
| 2903 | 2903 | foreach (DateTimeZone::listIdentifiers() as $timezone) { |
| 2904 | 2904 | $now->setTimezone(new DateTimeZone($timezone)); |
| 2905 | 2905 | $offsets[] = $offset = $now->getOffset(); |
| 2906 | - $timezones[$timezone] = '(' . format_GMT_offset($offset) . ') ' . format_timezone_name($timezone); |
|
| 2906 | + $timezones[$timezone] = '('.format_GMT_offset($offset).') '.format_timezone_name($timezone); |
|
| 2907 | 2907 | } |
| 2908 | 2908 | |
| 2909 | 2909 | array_multisort($offsets, $timezones); |
@@ -2923,7 +2923,7 @@ discard block |
||
| 2923 | 2923 | { |
| 2924 | 2924 | $hours = intval($offset / 3600); |
| 2925 | 2925 | $minutes = abs(intval($offset % 3600 / 60)); |
| 2926 | - return 'GMT' . ($offset ? sprintf('%+03d:%02d', $hours, $minutes) : ''); |
|
| 2926 | + return 'GMT'.($offset ? sprintf('%+03d:%02d', $hours, $minutes) : ''); |
|
| 2927 | 2927 | } |
| 2928 | 2928 | |
| 2929 | 2929 | /** |
@@ -1834,7 +1834,9 @@ |
||
| 1834 | 1834 | $record['id'], |
| 1835 | 1835 | $_SESSION['user_id'] |
| 1836 | 1836 | ); |
| 1837 | - if ($currentUserKey === null || count($currentUserKey) === 0) continue; |
|
| 1837 | + if ($currentUserKey === null || count($currentUserKey) === 0) { |
|
| 1838 | + continue; |
|
| 1839 | + } |
|
| 1838 | 1840 | |
| 1839 | 1841 | // Decrypt itemkey with admin key |
| 1840 | 1842 | $itemKey = decryptUserObjectKey($currentUserKey['share_key'], $_SESSION['user']['private_key']); |
@@ -117,7 +117,7 @@ discard block |
||
| 117 | 117 | console.log('User has to regenerate keys') |
| 118 | 118 | // HIde |
| 119 | 119 | $('.content-header, .content').addClass('hidden'); |
| 120 | - $('#dialog-user-temporary-code-info').html('<i class="icon fas fa-info mr-2"></i><?php echo langHdl('renecyption_expected');?>'); |
|
| 120 | + $('#dialog-user-temporary-code-info').html('<i class="icon fas fa-info mr-2"></i><?php echo langHdl('renecyption_expected'); ?>'); |
|
| 121 | 121 | |
| 122 | 122 | // Show passwords inputs and form |
| 123 | 123 | $('#dialog-user-temporary-code').removeClass('hidden'); |
@@ -131,7 +131,7 @@ discard block |
||
| 131 | 131 | |
| 132 | 132 | // Show passwords inputs and form |
| 133 | 133 | $('#dialog-user-change-password-info') |
| 134 | - .html('<i class="icon fas fa-info mr-2"></i><?php echo langHdl('user_has_to_change_password_info');?>') |
|
| 134 | + .html('<i class="icon fas fa-info mr-2"></i><?php echo langHdl('user_has_to_change_password_info'); ?>') |
|
| 135 | 135 | .removeClass('hidden'); |
| 136 | 136 | $('#dialog-user-change-password').removeClass('hidden'); |
| 137 | 137 | |
@@ -144,7 +144,7 @@ discard block |
||
| 144 | 144 | |
| 145 | 145 | // Show passwords inputs and form |
| 146 | 146 | $('#dialog-ldap-user-change-password-info') |
| 147 | - .html('<i class="icon fas fa-info mr-2"></i><?php echo langHdl('ldap_user_has_changed_his_password');?>') |
|
| 147 | + .html('<i class="icon fas fa-info mr-2"></i><?php echo langHdl('ldap_user_has_changed_his_password'); ?>') |
|
| 148 | 148 | .removeClass('hidden'); |
| 149 | 149 | $('#dialog-ldap-user-change-password').removeClass('hidden'); |
| 150 | 150 | |
@@ -218,7 +218,7 @@ discard block |
||
| 218 | 218 | console.log('User has to regenerate keys') |
| 219 | 219 | // HIde |
| 220 | 220 | $('.content-header, .content').addClass('hidden'); |
| 221 | - $('#dialog-user-temporary-code-info').html('<i class="icon fas fa-info mr-2"></i><?php echo langHdl('renecyption_expected');?>'); |
|
| 221 | + $('#dialog-user-temporary-code-info').html('<i class="icon fas fa-info mr-2"></i><?php echo langHdl('renecyption_expected'); ?>'); |
|
| 222 | 222 | |
| 223 | 223 | // Show passwords inputs and form |
| 224 | 224 | $('#dialog-user-temporary-code').removeClass('hidden'); |
@@ -296,7 +296,7 @@ discard block |
||
| 296 | 296 | { |
| 297 | 297 | if (step === 'psk') { |
| 298 | 298 | // Inform user |
| 299 | - $("#user-current-defuse-psk-progress").html('<b><?php echo langHdl('encryption_keys'); ?> </b> [' + start + ' - ' + (parseInt(start) + <?php echo NUMBER_ITEMS_IN_BATCH;?>) + '] ' + |
|
| 299 | + $("#user-current-defuse-psk-progress").html('<b><?php echo langHdl('encryption_keys'); ?> </b> [' + start + ' - ' + (parseInt(start) + <?php echo NUMBER_ITEMS_IN_BATCH; ?>) + '] ' + |
|
| 300 | 300 | '... <?php echo langHdl('please_wait'); ?><i class="fas fa-spinner fa-pulse ml-3 text-primary"></i>'); |
| 301 | 301 | |
| 302 | 302 | var data = {'userPsk' : $('#user-current-defuse-psk').val()}; |
@@ -305,7 +305,7 @@ discard block |
||
| 305 | 305 | "sources/main.queries.php", { |
| 306 | 306 | type: "user_psk_reencryption", |
| 307 | 307 | 'start': start, |
| 308 | - 'length': <?php echo NUMBER_ITEMS_IN_BATCH;?>, |
|
| 308 | + 'length': <?php echo NUMBER_ITEMS_IN_BATCH; ?>, |
|
| 309 | 309 | userId: userId, |
| 310 | 310 | data: prepareExchangedData(JSON.stringify(data), "encode", "<?php echo $_SESSION['key']; ?>"), |
| 311 | 311 | key: '<?php echo $_SESSION['key']; ?>' |
@@ -794,15 +794,15 @@ discard block |
||
| 794 | 794 | // Prepare data |
| 795 | 795 | var data = { |
| 796 | 796 | 'receipt': $('#temp-user-email').val(), |
| 797 | - 'subject': '[Teampass] <?php echo langHdl('temporary_encryption_code');?>', |
|
| 798 | - 'body': '<?php echo langHdl('email_body_temporary_encryption_code');?>', |
|
| 797 | + 'subject': '[Teampass] <?php echo langHdl('temporary_encryption_code'); ?>', |
|
| 798 | + 'body': '<?php echo langHdl('email_body_temporary_encryption_code'); ?>', |
|
| 799 | 799 | 'pre_replace' : { |
| 800 | 800 | '#enc_code#' : $('#temp-user-pwd').val(), |
| 801 | 801 | } |
| 802 | 802 | } |
| 803 | 803 | console.log(data); |
| 804 | 804 | // Prepare form |
| 805 | - $('#dialog-admin-change-user-password-info').html('<?php echo langHdl('sending_email_message');?>'); |
|
| 805 | + $('#dialog-admin-change-user-password-info').html('<?php echo langHdl('sending_email_message'); ?>'); |
|
| 806 | 806 | toastr.remove(); |
| 807 | 807 | toastr.info( |
| 808 | 808 | '<?php echo langHdl('in_progress'); ?><i class="fas fa-circle-notch fa-spin fa-2x ml-3"></i>' |
@@ -1270,7 +1270,7 @@ discard block |
||
| 1270 | 1270 | '#warningModal', |
| 1271 | 1271 | '<i class="fas fa-clock fa-lg warning mr-2"></i><?php echo langHdl('index_add_one_hour'); ?>', |
| 1272 | 1272 | '<div class="form-group">' + |
| 1273 | - '<label for="warningModal-input" class="col-form-label"><?php echo langHdl('index_session_duration') . ' (' . langHdl('minutes') . ')'; ?>:</label>' + |
|
| 1273 | + '<label for="warningModal-input" class="col-form-label"><?php echo langHdl('index_session_duration').' ('.langHdl('minutes').')'; ?>:</label>' + |
|
| 1274 | 1274 | '<input type="text" class="form-control" id="warningModal-input" value="<?php echo isset($_SESSION['user']['session_duration']) === true ? (int) $_SESSION['user']['session_duration'] / 60 : 60; ?>">' + |
| 1275 | 1275 | '</div>', |
| 1276 | 1276 | '<?php echo langHdl('confirm'); ?>', |
@@ -1522,13 +1522,13 @@ discard block |
||
| 1522 | 1522 | if (step !== 'finished') { |
| 1523 | 1523 | // Inform user |
| 1524 | 1524 | $("#"+divIdDialog+'-progress').html('<b><?php echo langHdl('encryption_keys'); ?> - ' + |
| 1525 | - stepText + '</b> [' + start + ' - ' + (parseInt(start) + <?php echo NUMBER_ITEMS_IN_BATCH;?>) + '] ' + |
|
| 1525 | + stepText + '</b> [' + start + ' - ' + (parseInt(start) + <?php echo NUMBER_ITEMS_IN_BATCH; ?>) + '] ' + |
|
| 1526 | 1526 | '... <?php echo langHdl('please_wait'); ?><i class="fas fa-spinner fa-pulse ml-3 text-primary"></i>'); |
| 1527 | 1527 | |
| 1528 | 1528 | var data = { |
| 1529 | 1529 | 'action': step, |
| 1530 | 1530 | 'start': start, |
| 1531 | - 'length': <?php echo NUMBER_ITEMS_IN_BATCH;?>, |
|
| 1531 | + 'length': <?php echo NUMBER_ITEMS_IN_BATCH; ?>, |
|
| 1532 | 1532 | 'user_id': userId, |
| 1533 | 1533 | } |
| 1534 | 1534 | // Do query |