Passed
Push — teampass_3.0 ( 8a3983...68cd42 )
by Nils
04:35
created
sources/main.functions.php 1 patch
Spacing   +209 added lines, -209 removed lines patch added patch discarded remove patch
@@ -119,25 +119,25 @@  discard block
 block discarded – undo
119 119
  */
120 120
 function cryption($message, $ascii_key, $type, $SETTINGS)
121 121
 {
122
-    $ascii_key = (empty($ascii_key) === true) ? file_get_contents(SECUREPATH . '/teampass-seckey.txt') : $ascii_key;
122
+    $ascii_key = (empty($ascii_key) === true) ? file_get_contents(SECUREPATH.'/teampass-seckey.txt') : $ascii_key;
123 123
     $err = false;
124 124
 
125 125
     // load PhpEncryption library
126 126
     if (isset($SETTINGS['cpassman_dir']) === false || empty($SETTINGS['cpassman_dir']) === true) {
127 127
         $path = '../includes/libraries/Encryption/Encryption/';
128 128
     } else {
129
-        $path = $SETTINGS['cpassman_dir'] . '/includes/libraries/Encryption/Encryption/';
129
+        $path = $SETTINGS['cpassman_dir'].'/includes/libraries/Encryption/Encryption/';
130 130
     }
131 131
 
132
-    include_once $path . 'Crypto.php';
133
-    include_once $path . 'Encoding.php';
134
-    include_once $path . 'DerivedKeys.php';
135
-    include_once $path . 'Key.php';
136
-    include_once $path . 'KeyOrPassword.php';
137
-    include_once $path . 'File.php';
138
-    include_once $path . 'RuntimeTests.php';
139
-    include_once $path . 'KeyProtectedByPassword.php';
140
-    include_once $path . 'Core.php';
132
+    include_once $path.'Crypto.php';
133
+    include_once $path.'Encoding.php';
134
+    include_once $path.'DerivedKeys.php';
135
+    include_once $path.'Key.php';
136
+    include_once $path.'KeyOrPassword.php';
137
+    include_once $path.'File.php';
138
+    include_once $path.'RuntimeTests.php';
139
+    include_once $path.'KeyProtectedByPassword.php';
140
+    include_once $path.'Core.php';
141 141
 
142 142
     // convert KEY
143 143
     $key = \Defuse\Crypto\Key::loadFromAsciiSafeString($ascii_key);
@@ -183,15 +183,15 @@  discard block
 block discarded – undo
183 183
         $path = '../includes/libraries/Encryption/Encryption/';
184 184
     }
185 185
 
186
-    include_once $path . 'Crypto.php';
187
-    include_once $path . 'Encoding.php';
188
-    include_once $path . 'DerivedKeys.php';
189
-    include_once $path . 'Key.php';
190
-    include_once $path . 'KeyOrPassword.php';
191
-    include_once $path . 'File.php';
192
-    include_once $path . 'RuntimeTests.php';
193
-    include_once $path . 'KeyProtectedByPassword.php';
194
-    include_once $path . 'Core.php';
186
+    include_once $path.'Crypto.php';
187
+    include_once $path.'Encoding.php';
188
+    include_once $path.'DerivedKeys.php';
189
+    include_once $path.'Key.php';
190
+    include_once $path.'KeyOrPassword.php';
191
+    include_once $path.'File.php';
192
+    include_once $path.'RuntimeTests.php';
193
+    include_once $path.'KeyProtectedByPassword.php';
194
+    include_once $path.'Core.php';
195 195
 
196 196
     $key = \Defuse\Crypto\Key::createNewRandomKey();
197 197
     $key = $key->saveToAsciiSafeString();
@@ -217,15 +217,15 @@  discard block
 block discarded – undo
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
 
230 230
     $protected_key = \Defuse\Crypto\KeyProtectedByPassword::createRandomPasswordProtectedKey($psk);
231 231
     $protected_key_encoded = $protected_key->saveToAsciiSafeString();
@@ -252,15 +252,15 @@  discard block
 block discarded – undo
252 252
         $path = '../includes/libraries/Encryption/Encryption/';
253 253
     }
254 254
 
255
-    include_once $path . 'Crypto.php';
256
-    include_once $path . 'Encoding.php';
257
-    include_once $path . 'DerivedKeys.php';
258
-    include_once $path . 'Key.php';
259
-    include_once $path . 'KeyOrPassword.php';
260
-    include_once $path . 'File.php';
261
-    include_once $path . 'RuntimeTests.php';
262
-    include_once $path . 'KeyProtectedByPassword.php';
263
-    include_once $path . 'Core.php';
255
+    include_once $path.'Crypto.php';
256
+    include_once $path.'Encoding.php';
257
+    include_once $path.'DerivedKeys.php';
258
+    include_once $path.'Key.php';
259
+    include_once $path.'KeyOrPassword.php';
260
+    include_once $path.'File.php';
261
+    include_once $path.'RuntimeTests.php';
262
+    include_once $path.'KeyProtectedByPassword.php';
263
+    include_once $path.'Core.php';
264 264
 
265 265
     try {
266 266
         $protected_key = \Defuse\Crypto\KeyProtectedByPassword::loadFromAsciiSafeString($protected_key_encoded);
@@ -347,8 +347,8 @@  discard block
 block discarded – undo
347 347
  */
348 348
 function db_error_handler($params)
349 349
 {
350
-    echo 'Error: ' . $params['error'] . "<br>\n";
351
-    echo 'Query: ' . $params['query'] . "<br>\n";
350
+    echo 'Error: '.$params['error']."<br>\n";
351
+    echo 'Query: '.$params['query']."<br>\n";
352 352
     throw new Exception('Error - Query', 1);
353 353
 }
354 354
 
@@ -370,14 +370,14 @@  discard block
 block discarded – undo
370 370
     $SETTINGS
371 371
 ) {
372 372
     //load ClassLoader
373
-    include_once $SETTINGS['cpassman_dir'] . '/sources/SplClassLoader.php';
373
+    include_once $SETTINGS['cpassman_dir'].'/sources/SplClassLoader.php';
374 374
 
375 375
     // Load superglobal
376
-    include_once $SETTINGS['cpassman_dir'] . '/includes/libraries/protect/SuperGlobal/SuperGlobal.php';
376
+    include_once $SETTINGS['cpassman_dir'].'/includes/libraries/protect/SuperGlobal/SuperGlobal.php';
377 377
     $superGlobal = new protect\SuperGlobal\SuperGlobal();
378 378
 
379 379
     //Connect to DB
380
-    include_once $SETTINGS['cpassman_dir'] . '/includes/libraries/Database/Meekrodb/db.class.php';
380
+    include_once $SETTINGS['cpassman_dir'].'/includes/libraries/Database/Meekrodb/db.class.php';
381 381
     if (defined('DB_PASSWD_CLEAR') === false) {
382 382
         define('DB_PASSWD_CLEAR', defuseReturnDecrypted(DB_PASSWD, $SETTINGS));
383 383
     }
@@ -389,7 +389,7 @@  discard block
 block discarded – undo
389 389
     DB::$encoding = DB_ENCODING;
390 390
 
391 391
     //Build tree
392
-    $tree = new SplClassLoader('Tree\NestedTree', $SETTINGS['cpassman_dir'] . '/includes/libraries');
392
+    $tree = new SplClassLoader('Tree\NestedTree', $SETTINGS['cpassman_dir'].'/includes/libraries');
393 393
     $tree->register();
394 394
     $tree = new Tree\NestedTree\NestedTree(prefixTable('nested_tree'), 'id', 'parent_id', 'title');
395 395
 
@@ -431,7 +431,7 @@  discard block
 block discarded – undo
431 431
 function identAdmin($idFonctions, $SETTINGS, $tree)
432 432
 {
433 433
     // Load superglobal
434
-    include_once $SETTINGS['cpassman_dir'] . '/includes/libraries/protect/SuperGlobal/SuperGlobal.php';
434
+    include_once $SETTINGS['cpassman_dir'].'/includes/libraries/protect/SuperGlobal/SuperGlobal.php';
435 435
     $superGlobal = new protect\SuperGlobal\SuperGlobal();
436 436
 
437 437
     // Init
@@ -453,7 +453,7 @@  discard block
 block discarded – undo
453 453
     $globalsPersonalVisibleFolders = $superGlobal->get('personal_visible_groups', 'SESSION');
454 454
 
455 455
     // Get list of Folders
456
-    $rows = DB::query('SELECT id FROM ' . prefixTable('nested_tree') . ' WHERE personal_folder = %i', 0);
456
+    $rows = DB::query('SELECT id FROM '.prefixTable('nested_tree').' WHERE personal_folder = %i', 0);
457 457
     foreach ($rows as $record) {
458 458
         array_push($groupesVisibles, $record['id']);
459 459
     }
@@ -472,7 +472,7 @@  discard block
 block discarded – undo
472 472
     }
473 473
     // Get ID of personal folder
474 474
     $persfld = DB::queryfirstrow(
475
-        'SELECT id FROM ' . prefixTable('nested_tree') . ' WHERE title = %s',
475
+        'SELECT id FROM '.prefixTable('nested_tree').' WHERE title = %s',
476 476
         $globalsUserId
477 477
     );
478 478
     if (empty($persfld['id']) === false) {
@@ -493,7 +493,7 @@  discard block
 block discarded – undo
493 493
     // get complete list of ROLES
494 494
     $tmp = explode(';', $idFonctions);
495 495
     $rows = DB::query(
496
-        'SELECT * FROM ' . prefixTable('roles_title') . '
496
+        'SELECT * FROM '.prefixTable('roles_title').'
497 497
         ORDER BY title ASC'
498 498
     );
499 499
     foreach ($rows as $record) {
@@ -505,9 +505,9 @@  discard block
 block discarded – undo
505 505
     $superGlobal->put('is_admin', 1, 'SESSION');
506 506
 
507 507
     // Check if admin has created Folders and Roles
508
-    DB::query('SELECT * FROM ' . prefixTable('nested_tree') . '');
508
+    DB::query('SELECT * FROM '.prefixTable('nested_tree').'');
509 509
     $superGlobal->put('nb_folders', DB::count(), 'SESSION');
510
-    DB::query('SELECT * FROM ' . prefixTable('roles_title'));
510
+    DB::query('SELECT * FROM '.prefixTable('roles_title'));
511 511
     $superGlobal->put('nb_roles', DB::count(), 'SESSION');
512 512
 }
513 513
 
@@ -551,7 +551,7 @@  discard block
 block discarded – undo
551 551
     $tree
552 552
 ) {
553 553
     // Load superglobal
554
-    include_once $SETTINGS['cpassman_dir'] . '/includes/libraries/protect/SuperGlobal/SuperGlobal.php';
554
+    include_once $SETTINGS['cpassman_dir'].'/includes/libraries/protect/SuperGlobal/SuperGlobal.php';
555 555
     $superGlobal = new protect\SuperGlobal\SuperGlobal();
556 556
 
557 557
     // Init
@@ -584,7 +584,7 @@  discard block
 block discarded – undo
584 584
     // Get list of folders depending on Roles
585 585
     $rows = DB::query(
586 586
         'SELECT *
587
-        FROM ' . prefixTable('roles_values') . '
587
+        FROM ' . prefixTable('roles_values').'
588 588
         WHERE role_id IN %li AND type IN %ls',
589 589
         $userRoles,
590 590
         array('W', 'ND', 'NE', 'NDNE', 'R')
@@ -609,9 +609,9 @@  discard block
 block discarded – undo
609 609
     // Does this user is allowed to see other items
610 610
     $inc = 0;
611 611
     $rows = DB::query(
612
-        'SELECT id, id_tree FROM ' . prefixTable('items') . '
612
+        'SELECT id, id_tree FROM '.prefixTable('items').'
613 613
         WHERE restricted_to LIKE %ss AND inactif = %s',
614
-        $globalsUserId . ';',
614
+        $globalsUserId.';',
615 615
         '0'
616 616
     );
617 617
     foreach ($rows as $record) {
@@ -625,8 +625,8 @@  discard block
 block discarded – undo
625 625
     // Check for the users roles if some specific rights exist on items
626 626
     $rows = DB::query(
627 627
         'SELECT i.id_tree, r.item_id
628
-        FROM ' . prefixTable('items') . ' as i
629
-        INNER JOIN ' . prefixTable('restriction_to_roles') . ' as r ON (r.item_id=i.id)
628
+        FROM ' . prefixTable('items').' as i
629
+        INNER JOIN ' . prefixTable('restriction_to_roles').' as r ON (r.item_id=i.id)
630 630
         WHERE r.role_id IN %li
631 631
         ORDER BY i.id_tree ASC',
632 632
         $userRoles
@@ -647,7 +647,7 @@  discard block
 block discarded – undo
647 647
     ) {
648 648
         $persoFld = DB::queryfirstrow(
649 649
             'SELECT id
650
-            FROM ' . prefixTable('nested_tree') . '
650
+            FROM ' . prefixTable('nested_tree').'
651 651
             WHERE title = %s AND personal_folder = %i',
652 652
             $globalsUserId,
653 653
             1
@@ -681,7 +681,7 @@  discard block
 block discarded – undo
681 681
     }
682 682
     $persoFlds = DB::query(
683 683
         'SELECT id
684
-        FROM ' . prefixTable('nested_tree') . '
684
+        FROM ' . prefixTable('nested_tree').'
685 685
         WHERE %l',
686 686
         $where
687 687
     );
@@ -724,17 +724,17 @@  discard block
 block discarded – undo
724 724
     );
725 725
 
726 726
     // Folders and Roles numbers
727
-    DB::queryfirstrow('SELECT id FROM ' . prefixTable('nested_tree') . '');
727
+    DB::queryfirstrow('SELECT id FROM '.prefixTable('nested_tree').'');
728 728
     $superGlobal->put('nb_folders', DB::count(), 'SESSION');
729
-    DB::queryfirstrow('SELECT id FROM ' . prefixTable('roles_title'));
729
+    DB::queryfirstrow('SELECT id FROM '.prefixTable('roles_title'));
730 730
     $superGlobal->put('nb_roles', DB::count(), 'SESSION');
731 731
 
732 732
     // check if change proposals on User's items
733 733
     if (isset($SETTINGS['enable_suggestion']) === true && (int) $SETTINGS['enable_suggestion'] === 1) {
734 734
         DB::query(
735 735
             'SELECT *
736
-            FROM ' . prefixTable('items_change') . ' AS c
737
-            LEFT JOIN ' . prefixTable('log_items') . ' AS i ON (c.item_id = i.id_item)
736
+            FROM ' . prefixTable('items_change').' AS c
737
+            LEFT JOIN ' . prefixTable('log_items').' AS i ON (c.item_id = i.id_item)
738 738
             WHERE i.action = %s AND i.id_user = %i',
739 739
             'at_creation',
740 740
             $globalsUserId
@@ -778,10 +778,10 @@  discard block
 block discarded – undo
778 778
  */
779 779
 function cacheTableRefresh($SETTINGS)
780 780
 {
781
-    include_once $SETTINGS['cpassman_dir'] . '/sources/SplClassLoader.php';
781
+    include_once $SETTINGS['cpassman_dir'].'/sources/SplClassLoader.php';
782 782
 
783 783
     //Connect to DB
784
-    include_once $SETTINGS['cpassman_dir'] . '/includes/libraries/Database/Meekrodb/db.class.php';
784
+    include_once $SETTINGS['cpassman_dir'].'/includes/libraries/Database/Meekrodb/db.class.php';
785 785
     if (defined('DB_PASSWD_CLEAR') === false) {
786 786
         define('DB_PASSWD_CLEAR', defuseReturnDecrypted(DB_PASSWD, $SETTINGS));
787 787
     }
@@ -798,13 +798,13 @@  discard block
 block discarded – undo
798 798
     $tree = new Tree\NestedTree\NestedTree(prefixTable('nested_tree'), 'id', 'parent_id', 'title');
799 799
 
800 800
     // truncate table
801
-    DB::query('TRUNCATE TABLE ' . prefixTable('cache'));
801
+    DB::query('TRUNCATE TABLE '.prefixTable('cache'));
802 802
 
803 803
     // reload date
804 804
     $rows = DB::query(
805 805
         'SELECT *
806
-        FROM ' . prefixTable('items') . ' as i
807
-        INNER JOIN ' . prefixTable('log_items') . ' as l ON (l.id_item = i.id)
806
+        FROM ' . prefixTable('items').' as i
807
+        INNER JOIN ' . prefixTable('log_items').' as l ON (l.id_item = i.id)
808 808
         AND l.action = %s
809 809
         AND i.inactif = %i',
810 810
         'at_creation',
@@ -816,18 +816,18 @@  discard block
 block discarded – undo
816 816
             $tags = '';
817 817
             $itemTags = DB::query(
818 818
                 'SELECT tag
819
-                FROM ' . prefixTable('tags') . '
819
+                FROM ' . prefixTable('tags').'
820 820
                 WHERE item_id = %i AND tag != ""',
821 821
                 $record['id']
822 822
             );
823 823
             foreach ($itemTags as $itemTag) {
824
-                $tags .= $itemTag['tag'] . ' ';
824
+                $tags .= $itemTag['tag'].' ';
825 825
             }
826 826
 
827 827
             // Get renewal period
828 828
             $resNT = DB::queryfirstrow(
829 829
                 'SELECT renewal_period
830
-                FROM ' . prefixTable('nested_tree') . '
830
+                FROM ' . prefixTable('nested_tree').'
831 831
                 WHERE id = %i',
832 832
                 $record['id_tree']
833 833
             );
@@ -841,7 +841,7 @@  discard block
 block discarded – undo
841 841
                     // Is this a User id?
842 842
                     $user = DB::queryfirstrow(
843 843
                         'SELECT id, login
844
-                        FROM ' . prefixTable('users') . '
844
+                        FROM ' . prefixTable('users').'
845 845
                         WHERE id = %i',
846 846
                         $elem->title
847 847
                     );
@@ -883,14 +883,14 @@  discard block
 block discarded – undo
883 883
  */
884 884
 function cacheTableUpdate($SETTINGS, $ident = null)
885 885
 {
886
-    include_once $SETTINGS['cpassman_dir'] . '/sources/SplClassLoader.php';
886
+    include_once $SETTINGS['cpassman_dir'].'/sources/SplClassLoader.php';
887 887
 
888 888
     // Load superglobal
889
-    include_once $SETTINGS['cpassman_dir'] . '/includes/libraries/protect/SuperGlobal/SuperGlobal.php';
889
+    include_once $SETTINGS['cpassman_dir'].'/includes/libraries/protect/SuperGlobal/SuperGlobal.php';
890 890
     $superGlobal = new protect\SuperGlobal\SuperGlobal();
891 891
 
892 892
     //Connect to DB
893
-    include_once $SETTINGS['cpassman_dir'] . '/includes/libraries/Database/Meekrodb/db.class.php';
893
+    include_once $SETTINGS['cpassman_dir'].'/includes/libraries/Database/Meekrodb/db.class.php';
894 894
     if (defined('DB_PASSWD_CLEAR') === false) {
895 895
         define('DB_PASSWD_CLEAR', defuseReturnDecrypted(DB_PASSWD, $SETTINGS));
896 896
     }
@@ -909,7 +909,7 @@  discard block
 block discarded – undo
909 909
     // get new value from db
910 910
     $data = DB::queryfirstrow(
911 911
         'SELECT label, description, id_tree, perso, restricted_to, login, url
912
-        FROM ' . prefixTable('items') . '
912
+        FROM ' . prefixTable('items').'
913 913
         WHERE id=%i',
914 914
         $ident
915 915
     );
@@ -917,12 +917,12 @@  discard block
 block discarded – undo
917 917
     $tags = '';
918 918
     $itemTags = DB::query(
919 919
         'SELECT tag
920
-        FROM ' . prefixTable('tags') . '
920
+        FROM ' . prefixTable('tags').'
921 921
         WHERE item_id = %i AND tag != ""',
922 922
         $ident
923 923
     );
924 924
     foreach ($itemTags as $itemTag) {
925
-        $tags .= $itemTag['tag'] . ' ';
925
+        $tags .= $itemTag['tag'].' ';
926 926
     }
927 927
     // form id_tree to full foldername
928 928
     $folder = array();
@@ -933,7 +933,7 @@  discard block
 block discarded – undo
933 933
             // Is this a User id?
934 934
             $user = DB::queryfirstrow(
935 935
                 'SELECT id, login
936
-                FROM ' . prefixTable('users') . '
936
+                FROM ' . prefixTable('users').'
937 937
                 WHERE id = %i',
938 938
                 $elem->title
939 939
             );
@@ -972,17 +972,17 @@  discard block
 block discarded – undo
972 972
  */
973 973
 function cacheTableAdd($SETTINGS, $ident = null)
974 974
 {
975
-    include_once $SETTINGS['cpassman_dir'] . '/sources/SplClassLoader.php';
975
+    include_once $SETTINGS['cpassman_dir'].'/sources/SplClassLoader.php';
976 976
 
977 977
     // Load superglobal
978
-    include_once $SETTINGS['cpassman_dir'] . '/includes/libraries/protect/SuperGlobal/SuperGlobal.php';
978
+    include_once $SETTINGS['cpassman_dir'].'/includes/libraries/protect/SuperGlobal/SuperGlobal.php';
979 979
     $superGlobal = new protect\SuperGlobal\SuperGlobal();
980 980
 
981 981
     // Get superglobals
982 982
     $globalsUserId = $superGlobal->get('user_id', 'SESSION');
983 983
 
984 984
     //Connect to DB
985
-    include_once $SETTINGS['cpassman_dir'] . '/includes/libraries/Database/Meekrodb/db.class.php';
985
+    include_once $SETTINGS['cpassman_dir'].'/includes/libraries/Database/Meekrodb/db.class.php';
986 986
     if (defined('DB_PASSWD_CLEAR') === false) {
987 987
         define('DB_PASSWD_CLEAR', defuseReturnDecrypted(DB_PASSWD, $SETTINGS));
988 988
     }
@@ -1001,8 +1001,8 @@  discard block
 block discarded – undo
1001 1001
     // get new value from db
1002 1002
     $data = DB::queryFirstRow(
1003 1003
         'SELECT i.label, i.description, i.id_tree as id_tree, i.perso, i.restricted_to, i.id, i.login, i.url, l.date
1004
-        FROM ' . prefixTable('items') . ' as i
1005
-        INNER JOIN ' . prefixTable('log_items') . ' as l ON (l.id_item = i.id)
1004
+        FROM ' . prefixTable('items').' as i
1005
+        INNER JOIN ' . prefixTable('log_items').' as l ON (l.id_item = i.id)
1006 1006
         WHERE i.id = %i
1007 1007
         AND l.action = %s',
1008 1008
         $ident,
@@ -1012,12 +1012,12 @@  discard block
 block discarded – undo
1012 1012
     $tags = '';
1013 1013
     $itemTags = DB::query(
1014 1014
         'SELECT tag
1015
-        FROM ' . prefixTable('tags') . '
1015
+        FROM ' . prefixTable('tags').'
1016 1016
         WHERE item_id = %i AND tag != ""',
1017 1017
         $ident
1018 1018
     );
1019 1019
     foreach ($itemTags as $itemTag) {
1020
-        $tags .= $itemTag['tag'] . ' ';
1020
+        $tags .= $itemTag['tag'].' ';
1021 1021
     }
1022 1022
     // form id_tree to full foldername
1023 1023
     $folder = array();
@@ -1028,7 +1028,7 @@  discard block
 block discarded – undo
1028 1028
             // Is this a User id?
1029 1029
             $user = DB::queryfirstrow(
1030 1030
                 'SELECT id, login
1031
-                FROM ' . prefixTable('users') . '
1031
+                FROM ' . prefixTable('users').'
1032 1032
                 WHERE id = %i',
1033 1033
                 $elem->title
1034 1034
             );
@@ -1069,48 +1069,48 @@  discard block
 block discarded – undo
1069 1069
 function getStatisticsData($SETTINGS)
1070 1070
 {
1071 1071
     DB::query(
1072
-        'SELECT id FROM ' . prefixTable('nested_tree') . ' WHERE personal_folder = %i',
1072
+        'SELECT id FROM '.prefixTable('nested_tree').' WHERE personal_folder = %i',
1073 1073
         0
1074 1074
     );
1075 1075
     $counter_folders = DB::count();
1076 1076
 
1077 1077
     DB::query(
1078
-        'SELECT id FROM ' . prefixTable('nested_tree') . ' WHERE personal_folder = %i',
1078
+        'SELECT id FROM '.prefixTable('nested_tree').' WHERE personal_folder = %i',
1079 1079
         1
1080 1080
     );
1081 1081
     $counter_folders_perso = DB::count();
1082 1082
 
1083 1083
     DB::query(
1084
-        'SELECT id FROM ' . prefixTable('items') . ' WHERE perso = %i',
1084
+        'SELECT id FROM '.prefixTable('items').' WHERE perso = %i',
1085 1085
         0
1086 1086
     );
1087 1087
     $counter_items = DB::count();
1088 1088
 
1089 1089
     DB::query(
1090
-        'SELECT id FROM ' . prefixTable('items') . ' WHERE perso = %i',
1090
+        'SELECT id FROM '.prefixTable('items').' WHERE perso = %i',
1091 1091
         1
1092 1092
     );
1093 1093
     $counter_items_perso = DB::count();
1094 1094
 
1095 1095
     DB::query(
1096
-        'SELECT id FROM ' . prefixTable('users') . ''
1096
+        'SELECT id FROM '.prefixTable('users').''
1097 1097
     );
1098 1098
     $counter_users = DB::count();
1099 1099
 
1100 1100
     DB::query(
1101
-        'SELECT id FROM ' . prefixTable('users') . ' WHERE admin = %i',
1101
+        'SELECT id FROM '.prefixTable('users').' WHERE admin = %i',
1102 1102
         1
1103 1103
     );
1104 1104
     $admins = DB::count();
1105 1105
 
1106 1106
     DB::query(
1107
-        'SELECT id FROM ' . prefixTable('users') . ' WHERE gestionnaire = %i',
1107
+        'SELECT id FROM '.prefixTable('users').' WHERE gestionnaire = %i',
1108 1108
         1
1109 1109
     );
1110 1110
     $managers = DB::count();
1111 1111
 
1112 1112
     DB::query(
1113
-        'SELECT id FROM ' . prefixTable('users') . ' WHERE read_only = %i',
1113
+        'SELECT id FROM '.prefixTable('users').' WHERE read_only = %i',
1114 1114
         1
1115 1115
     );
1116 1116
     $readOnly = DB::count();
@@ -1118,11 +1118,11 @@  discard block
 block discarded – undo
1118 1118
     // list the languages
1119 1119
     $usedLang = [];
1120 1120
     $tp_languages = DB::query(
1121
-        'SELECT name FROM ' . prefixTable('languages')
1121
+        'SELECT name FROM '.prefixTable('languages')
1122 1122
     );
1123 1123
     foreach ($tp_languages as $tp_language) {
1124 1124
         DB::query(
1125
-            'SELECT * FROM ' . prefixTable('users') . ' WHERE user_language = %s',
1125
+            'SELECT * FROM '.prefixTable('users').' WHERE user_language = %s',
1126 1126
             $tp_language['name']
1127 1127
         );
1128 1128
         $usedLang[$tp_language['name']] = round((DB::count() * 100 / $counter_users), 0);
@@ -1131,7 +1131,7 @@  discard block
 block discarded – undo
1131 1131
     // get list of ips
1132 1132
     $usedIp = [];
1133 1133
     $tp_ips = DB::query(
1134
-        'SELECT user_ip FROM ' . prefixTable('users')
1134
+        'SELECT user_ip FROM '.prefixTable('users')
1135 1135
     );
1136 1136
     foreach ($tp_ips as $ip) {
1137 1137
         if (array_key_exists($ip['user_ip'], $usedIp)) {
@@ -1193,21 +1193,21 @@  discard block
 block discarded – undo
1193 1193
 ) {
1194 1194
     // CAse where email not defined
1195 1195
     if ($email === 'none' || empty($email) === true) {
1196
-        return '"error":"" , "message":"' . langHdl('forgot_my_pw_email_sent') . '"';
1196
+        return '"error":"" , "message":"'.langHdl('forgot_my_pw_email_sent').'"';
1197 1197
     }
1198 1198
 
1199 1199
     // Load settings
1200
-    include_once $SETTINGS['cpassman_dir'] . '/includes/config/settings.php';
1200
+    include_once $SETTINGS['cpassman_dir'].'/includes/config/settings.php';
1201 1201
 
1202 1202
     // Load superglobal
1203
-    include_once $SETTINGS['cpassman_dir'] . '/includes/libraries/protect/SuperGlobal/SuperGlobal.php';
1203
+    include_once $SETTINGS['cpassman_dir'].'/includes/libraries/protect/SuperGlobal/SuperGlobal.php';
1204 1204
     $superGlobal = new protect\SuperGlobal\SuperGlobal();
1205 1205
 
1206 1206
     // Get user language
1207
-    include_once $SETTINGS['cpassman_dir'] . '/includes/language/' . $superGlobal->get('user_language', 'SESSION') . '.php';
1207
+    include_once $SETTINGS['cpassman_dir'].'/includes/language/'.$superGlobal->get('user_language', 'SESSION').'.php';
1208 1208
 
1209 1209
     // Load library
1210
-    include_once $SETTINGS['cpassman_dir'] . '/sources/SplClassLoader.php';
1210
+    include_once $SETTINGS['cpassman_dir'].'/sources/SplClassLoader.php';
1211 1211
 
1212 1212
     // load PHPMailer
1213 1213
     $mail = new SplClassLoader('PHPMailer\PHPMailer', '../includes/libraries');
@@ -1215,7 +1215,7 @@  discard block
 block discarded – undo
1215 1215
     $mail = new PHPMailer\PHPMailer\PHPMailer(true);
1216 1216
     try {
1217 1217
         // send to user
1218
-        $mail->setLanguage('en', $SETTINGS['cpassman_dir'] . '/includes/libraries/PHPMailer/PHPMailer/language/');
1218
+        $mail->setLanguage('en', $SETTINGS['cpassman_dir'].'/includes/libraries/PHPMailer/PHPMailer/language/');
1219 1219
         $mail->SMTPDebug = 0; //value 1 can be used to debug - 4 for debuging connections
1220 1220
         $mail->Port = $SETTINGS['email_port']; //COULD BE USED
1221 1221
         $mail->CharSet = 'utf-8';
@@ -1301,7 +1301,7 @@  discard block
 block discarded – undo
1301 1301
         <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;">
1302 1302
         <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;">
1303 1303
         <br><div style="float:right;">' .
1304
-        $textMail .
1304
+        $textMail.
1305 1305
         '<br><br></td></tr></table>
1306 1306
     </td></tr></table>
1307 1307
     <br></body></html>';
@@ -1314,7 +1314,7 @@  discard block
 block discarded – undo
1314 1314
  */
1315 1315
 function generateKey()
1316 1316
 {
1317
-    return substr(md5(rand() . rand()), 0, 15);
1317
+    return substr(md5(rand().rand()), 0, 15);
1318 1318
 }
1319 1319
 
1320 1320
 /**
@@ -1384,7 +1384,7 @@  discard block
 block discarded – undo
1384 1384
 {
1385 1385
     array_walk_recursive(
1386 1386
         $array,
1387
-        function (&$item) {
1387
+        function(&$item) {
1388 1388
             if (mb_detect_encoding($item, 'utf-8', true) === false) {
1389 1389
                 $item = utf8_encode($item);
1390 1390
             }
@@ -1420,7 +1420,7 @@  discard block
 block discarded – undo
1420 1420
     }
1421 1421
 
1422 1422
     // Load superglobal
1423
-    include_once $SETTINGS['cpassman_dir'] . '/includes/libraries/protect/SuperGlobal/SuperGlobal.php';
1423
+    include_once $SETTINGS['cpassman_dir'].'/includes/libraries/protect/SuperGlobal/SuperGlobal.php';
1424 1424
     $superGlobal = new protect\SuperGlobal\SuperGlobal();
1425 1425
 
1426 1426
     // Get superglobals
@@ -1432,9 +1432,9 @@  discard block
 block discarded – undo
1432 1432
     }
1433 1433
 
1434 1434
     //load ClassLoader
1435
-    include_once $SETTINGS['cpassman_dir'] . '/sources/SplClassLoader.php';
1435
+    include_once $SETTINGS['cpassman_dir'].'/sources/SplClassLoader.php';
1436 1436
     //Load AES
1437
-    $aes = new SplClassLoader('Encryption\Crypt', $SETTINGS['cpassman_dir'] . '/includes/libraries');
1437
+    $aes = new SplClassLoader('Encryption\Crypt', $SETTINGS['cpassman_dir'].'/includes/libraries');
1438 1438
     $aes->register();
1439 1439
 
1440 1440
     if ($type === 'encode' && is_array($data) === true) {
@@ -1489,7 +1489,7 @@  discard block
 block discarded – undo
1489 1489
 function makeThumbnail($src, $dest, $desired_width)
1490 1490
 {
1491 1491
     /* read the source image */
1492
-    if(is_file($src) === true && mime_content_type($src) === 'image/png'){
1492
+    if (is_file($src) === true && mime_content_type($src) === 'image/png') {
1493 1493
         $source_image = imagecreatefrompng($src);
1494 1494
         if ($source_image === false) {
1495 1495
             return "Error: Not a valid PNG file! It's type is ".mime_content_type($src);
@@ -1526,7 +1526,7 @@  discard block
 block discarded – undo
1526 1526
  */
1527 1527
 function prefixTable($table)
1528 1528
 {
1529
-    $safeTable = htmlspecialchars(DB_PREFIX . $table);
1529
+    $safeTable = htmlspecialchars(DB_PREFIX.$table);
1530 1530
     if (!empty($safeTable)) {
1531 1531
         // sanitize string
1532 1532
         return $safeTable;
@@ -1558,14 +1558,14 @@  discard block
 block discarded – undo
1558 1558
     $lowercase = false,
1559 1559
     $SETTINGS = array()
1560 1560
 ) {
1561
-    include_once $SETTINGS['cpassman_dir'] . '/sources/SplClassLoader.php';
1562
-    $generator = new SplClassLoader('PasswordGenerator\Generator', $SETTINGS['cpassman_dir'] . '/includes/libraries');
1561
+    include_once $SETTINGS['cpassman_dir'].'/sources/SplClassLoader.php';
1562
+    $generator = new SplClassLoader('PasswordGenerator\Generator', $SETTINGS['cpassman_dir'].'/includes/libraries');
1563 1563
     $generator->register();
1564 1564
     $generator = new PasswordGenerator\Generator\ComputerPasswordGenerator();
1565 1565
 
1566 1566
     // Is PHP7 being used?
1567 1567
     if (version_compare(PHP_VERSION, '7.0.0', '>=')) {
1568
-        $php7generator = new SplClassLoader('PasswordGenerator\RandomGenerator', $SETTINGS['cpassman_dir'] . '/includes/libraries');
1568
+        $php7generator = new SplClassLoader('PasswordGenerator\RandomGenerator', $SETTINGS['cpassman_dir'].'/includes/libraries');
1569 1569
         $php7generator->register();
1570 1570
         $generator->setRandomGenerator(new PasswordGenerator\RandomGenerator\Php7RandomGenerator());
1571 1571
     }
@@ -1596,7 +1596,7 @@  discard block
 block discarded – undo
1596 1596
 function send_syslog($message, $host, $port, $component = 'teampass')
1597 1597
 {
1598 1598
     $sock = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP);
1599
-    $syslog_message = '<123>' . date('M d H:i:s ') . $component . ': ' . $message;
1599
+    $syslog_message = '<123>'.date('M d H:i:s ').$component.': '.$message;
1600 1600
     socket_sendto($sock, $syslog_message, strlen($syslog_message), 0, $host, $port);
1601 1601
     socket_close($sock);
1602 1602
 }
@@ -1620,7 +1620,7 @@  discard block
 block discarded – undo
1620 1620
     }
1621 1621
 
1622 1622
     // include librairies & connect to DB
1623
-    include_once $SETTINGS['cpassman_dir'] . '/includes/libraries/Database/Meekrodb/db.class.php';
1623
+    include_once $SETTINGS['cpassman_dir'].'/includes/libraries/Database/Meekrodb/db.class.php';
1624 1624
     if (defined('DB_PASSWD_CLEAR') === false) {
1625 1625
         define('DB_PASSWD_CLEAR', defuseReturnDecrypted(DB_PASSWD, $SETTINGS));
1626 1626
     }
@@ -1646,14 +1646,14 @@  discard block
 block discarded – undo
1646 1646
     if (isset($SETTINGS['syslog_enable']) === true && (int) $SETTINGS['syslog_enable'] === 1) {
1647 1647
         if ($type === 'user_mngt') {
1648 1648
             send_syslog(
1649
-                'action=' . str_replace('at_', '', $label) . ' attribute=user user=' . $who . ' userid="' . $login . '" change="' . $field_1 . '" ',
1649
+                'action='.str_replace('at_', '', $label).' attribute=user user='.$who.' userid="'.$login.'" change="'.$field_1.'" ',
1650 1650
                 $SETTINGS['syslog_host'],
1651 1651
                 $SETTINGS['syslog_port'],
1652 1652
                 'teampass'
1653 1653
             );
1654 1654
         } else {
1655 1655
             send_syslog(
1656
-                'action=' . $type . ' attribute=' . $label . ' user=' . $who . ' userid="' . $login . '" ',
1656
+                'action='.$type.' attribute='.$label.' user='.$who.' userid="'.$login.'" ',
1657 1657
                 $SETTINGS['syslog_host'],
1658 1658
                 $SETTINGS['syslog_port'],
1659 1659
                 'teampass'
@@ -1685,7 +1685,7 @@  discard block
 block discarded – undo
1685 1685
     $encryption_type = null
1686 1686
 ) {
1687 1687
     // include librairies & connect to DB
1688
-    include_once $SETTINGS['cpassman_dir'] . '/includes/libraries/Database/Meekrodb/db.class.php';
1688
+    include_once $SETTINGS['cpassman_dir'].'/includes/libraries/Database/Meekrodb/db.class.php';
1689 1689
     if (defined('DB_PASSWD_CLEAR') === false) {
1690 1690
         define('DB_PASSWD_CLEAR', defuseReturnDecrypted(DB_PASSWD, $SETTINGS));
1691 1691
     }
@@ -1731,7 +1731,7 @@  discard block
 block discarded – undo
1731 1731
         if (empty($item_label) === true) {
1732 1732
             $dataItem = DB::queryfirstrow(
1733 1733
                 'SELECT id, id_tree, label
1734
-                FROM ' . prefixTable('items') . '
1734
+                FROM ' . prefixTable('items').'
1735 1735
                 WHERE id = %i',
1736 1736
                 $item_id
1737 1737
             );
@@ -1740,11 +1740,11 @@  discard block
 block discarded – undo
1740 1740
         }
1741 1741
 
1742 1742
         send_syslog(
1743
-            'action=' . str_replace('at_', '', $action) .
1744
-                ' attribute=' . str_replace('at_', '', $attribute[0]) .
1745
-                ' itemno=' . $item_id .
1746
-                ' user=' . is_null($login) === true ? '' : addslashes((string) $login) .
1747
-                ' itemname="' . addslashes($item_label) . '"',
1743
+            'action='.str_replace('at_', '', $action).
1744
+                ' attribute='.str_replace('at_', '', $attribute[0]).
1745
+                ' itemno='.$item_id.
1746
+                ' user='.is_null($login) === true ? '' : addslashes((string) $login).
1747
+                ' itemname="'.addslashes($item_label).'"',
1748 1748
             $SETTINGS['syslog_host'],
1749 1749
             $SETTINGS['syslog_port'],
1750 1750
             'teampass'
@@ -1770,7 +1770,7 @@  discard block
 block discarded – undo
1770 1770
         && $action === 'at_shown'
1771 1771
     ) {
1772 1772
         // Load superglobal
1773
-        include_once $SETTINGS['cpassman_dir'] . '/includes/libraries/protect/SuperGlobal/SuperGlobal.php';
1773
+        include_once $SETTINGS['cpassman_dir'].'/includes/libraries/protect/SuperGlobal/SuperGlobal.php';
1774 1774
         $superGlobal = new protect\SuperGlobal\SuperGlobal();
1775 1775
 
1776 1776
         // Get superglobals
@@ -1781,7 +1781,7 @@  discard block
 block discarded – undo
1781 1781
         // Get info about item
1782 1782
         $dataItem = DB::queryfirstrow(
1783 1783
             'SELECT id, id_tree, label
1784
-            FROM ' . prefixTable('items') . '
1784
+            FROM ' . prefixTable('items').'
1785 1785
             WHERE id = %i',
1786 1786
             $item_id
1787 1787
         );
@@ -1796,9 +1796,9 @@  discard block
 block discarded – undo
1796 1796
                 'body' => str_replace(
1797 1797
                     array('#tp_user#', '#tp_item#', '#tp_link#'),
1798 1798
                     array(
1799
-                        addslashes($globalsName . ' ' . $globalsLastname),
1799
+                        addslashes($globalsName.' '.$globalsLastname),
1800 1800
                         addslashes($item_label),
1801
-                        $SETTINGS['cpassman_url'] . '/index.php?page=items&group=' . $dataItem['id_tree'] . '&id=' . $item_id,
1801
+                        $SETTINGS['cpassman_url'].'/index.php?page=items&group='.$dataItem['id_tree'].'&id='.$item_id,
1802 1802
                     ),
1803 1803
                     langHdl('email_on_open_notification_mail')
1804 1804
                 ),
@@ -1820,7 +1820,7 @@  discard block
 block discarded – undo
1820 1820
 function notifyChangesToSubscribers($item_id, $label, $changes, $SETTINGS)
1821 1821
 {
1822 1822
     // Load superglobal
1823
-    include_once $SETTINGS['cpassman_dir'] . '/includes/libraries/protect/SuperGlobal/SuperGlobal.php';
1823
+    include_once $SETTINGS['cpassman_dir'].'/includes/libraries/protect/SuperGlobal/SuperGlobal.php';
1824 1824
     $superGlobal = new protect\SuperGlobal\SuperGlobal();
1825 1825
 
1826 1826
     // Get superglobals
@@ -1832,8 +1832,8 @@  discard block
 block discarded – undo
1832 1832
     $notification = DB::queryOneColumn(
1833 1833
         'email',
1834 1834
         'SELECT *
1835
-        FROM ' . prefixTable('notification') . ' AS n
1836
-        INNER JOIN ' . prefixTable('users') . ' AS u ON (n.user_id = u.id)
1835
+        FROM ' . prefixTable('notification').' AS n
1836
+        INNER JOIN ' . prefixTable('users').' AS u ON (n.user_id = u.id)
1837 1837
         WHERE n.item_id = %i AND n.user_id != %i',
1838 1838
         $item_id,
1839 1839
         $globalsUserId
@@ -1846,7 +1846,7 @@  discard block
 block discarded – undo
1846 1846
         // Get list of changes
1847 1847
         $htmlChanges = '<ul>';
1848 1848
         foreach ($changes as $change) {
1849
-            $htmlChanges .= '<li>' . $change . '</li>';
1849
+            $htmlChanges .= '<li>'.$change.'</li>';
1850 1850
         }
1851 1851
         $htmlChanges .= '</ul>';
1852 1852
 
@@ -1880,7 +1880,7 @@  discard block
 block discarded – undo
1880 1880
 function geItemReadablePath($id_tree, $label, $SETTINGS)
1881 1881
 {
1882 1882
     // Class loader
1883
-    include_once $SETTINGS['cpassman_dir'] . '/sources/SplClassLoader.php';
1883
+    include_once $SETTINGS['cpassman_dir'].'/sources/SplClassLoader.php';
1884 1884
 
1885 1885
     //Load Tree
1886 1886
     $tree = new SplClassLoader('Tree\NestedTree', '../includes/libraries');
@@ -1891,15 +1891,15 @@  discard block
 block discarded – undo
1891 1891
     $path = '';
1892 1892
     foreach ($arbo as $elem) {
1893 1893
         if (empty($path) === true) {
1894
-            $path = htmlspecialchars(stripslashes(htmlspecialchars_decode($elem->title, ENT_QUOTES)), ENT_QUOTES) . ' ';
1894
+            $path = htmlspecialchars(stripslashes(htmlspecialchars_decode($elem->title, ENT_QUOTES)), ENT_QUOTES).' ';
1895 1895
         } else {
1896
-            $path .= '&#8594; ' . htmlspecialchars(stripslashes(htmlspecialchars_decode($elem->title, ENT_QUOTES)), ENT_QUOTES);
1896
+            $path .= '&#8594; '.htmlspecialchars(stripslashes(htmlspecialchars_decode($elem->title, ENT_QUOTES)), ENT_QUOTES);
1897 1897
         }
1898 1898
     }
1899 1899
 
1900 1900
     // Build text to show user
1901 1901
     if (empty($label) === false) {
1902
-        return empty($path) === true ? addslashes($label) : addslashes($label) . ' (' . $path . ')';
1902
+        return empty($path) === true ? addslashes($label) : addslashes($label).' ('.$path.')';
1903 1903
     } else {
1904 1904
         return empty($path) === true ? '' : $path;
1905 1905
     }
@@ -1958,10 +1958,10 @@  discard block
 block discarded – undo
1958 1958
  */
1959 1959
 function handleConfigFile($action, $SETTINGS, $field = null, $value = null)
1960 1960
 {
1961
-    $tp_config_file = $SETTINGS['cpassman_dir'] . '/includes/config/tp.config.php';
1961
+    $tp_config_file = $SETTINGS['cpassman_dir'].'/includes/config/tp.config.php';
1962 1962
 
1963 1963
     // include librairies & connect to DB
1964
-    include_once $SETTINGS['cpassman_dir'] . '/includes/libraries/Database/Meekrodb/db.class.php';
1964
+    include_once $SETTINGS['cpassman_dir'].'/includes/libraries/Database/Meekrodb/db.class.php';
1965 1965
     if (defined('DB_PASSWD_CLEAR') === false) {
1966 1966
         define('DB_PASSWD_CLEAR', defuseReturnDecrypted(DB_PASSWD, $SETTINGS));
1967 1967
     }
@@ -1975,8 +1975,8 @@  discard block
 block discarded – undo
1975 1975
     if (file_exists($tp_config_file) === false || $action === 'rebuild') {
1976 1976
         // perform a copy
1977 1977
         if (file_exists($tp_config_file)) {
1978
-            if (!copy($tp_config_file, $tp_config_file . '.' . date('Y_m_d_His', time()))) {
1979
-                return "ERROR: Could not copy file '" . $tp_config_file . "'";
1978
+            if (!copy($tp_config_file, $tp_config_file.'.'.date('Y_m_d_His', time()))) {
1979
+                return "ERROR: Could not copy file '".$tp_config_file."'";
1980 1980
             }
1981 1981
         }
1982 1982
 
@@ -1987,11 +1987,11 @@  discard block
 block discarded – undo
1987 1987
         $data[1] = "global \$SETTINGS;\n";
1988 1988
         $data[2] = "\$SETTINGS = array (\n";
1989 1989
         $rows = DB::query(
1990
-            'SELECT * FROM ' . prefixTable('misc') . ' WHERE type=%s',
1990
+            'SELECT * FROM '.prefixTable('misc').' WHERE type=%s',
1991 1991
             'admin'
1992 1992
         );
1993 1993
         foreach ($rows as $record) {
1994
-            array_push($data, "    '" . $record['intitule'] . "' => '" . $record['valeur'] . "',\n");
1994
+            array_push($data, "    '".$record['intitule']."' => '".$record['valeur']."',\n");
1995 1995
         }
1996 1996
         array_push($data, ");\n");
1997 1997
         $data = array_unique($data);
@@ -2005,15 +2005,15 @@  discard block
 block discarded – undo
2005 2005
                 break;
2006 2006
             }
2007 2007
 
2008
-            if (stristr($line, "'" . $field . "' => '")) {
2009
-                $data[$inc] = "    '" . $field . "' => '" . filter_var($value, FILTER_SANITIZE_STRING) . "',\n";
2008
+            if (stristr($line, "'".$field."' => '")) {
2009
+                $data[$inc] = "    '".$field."' => '".filter_var($value, FILTER_SANITIZE_STRING)."',\n";
2010 2010
                 $bFound = true;
2011 2011
                 break;
2012 2012
             }
2013 2013
             ++$inc;
2014 2014
         }
2015 2015
         if ($bFound === false) {
2016
-            $data[($inc)] = "    '" . $field . "' => '" . filter_var($value, FILTER_SANITIZE_STRING) . "',\n);\n";
2016
+            $data[($inc)] = "    '".$field."' => '".filter_var($value, FILTER_SANITIZE_STRING)."',\n);\n";
2017 2017
         }
2018 2018
     }
2019 2019
 
@@ -2051,7 +2051,7 @@  discard block
 block discarded – undo
2051 2051
         $settings = array();
2052 2052
 
2053 2053
         $rows = DB::query(
2054
-            'SELECT * FROM ' . prefixTable('misc') . ' WHERE type=%s_type OR type=%s_type2',
2054
+            'SELECT * FROM '.prefixTable('misc').' WHERE type=%s_type OR type=%s_type2',
2055 2055
             array(
2056 2056
                 'type' => 'admin',
2057 2057
                 'type2' => 'settings',
@@ -2078,7 +2078,7 @@  discard block
 block discarded – undo
2078 2078
     $source_cf = array();
2079 2079
     $rows = DB::QUERY(
2080 2080
         'SELECT id_category
2081
-        FROM ' . prefixTable('categories_folders') . '
2081
+        FROM ' . prefixTable('categories_folders').'
2082 2082
         WHERE id_folder = %i',
2083 2083
         $source_id
2084 2084
     );
@@ -2089,7 +2089,7 @@  discard block
 block discarded – undo
2089 2089
     $target_cf = array();
2090 2090
     $rows = DB::QUERY(
2091 2091
         'SELECT id_category
2092
-        FROM ' . prefixTable('categories_folders') . '
2092
+        FROM ' . prefixTable('categories_folders').'
2093 2093
         WHERE id_folder = %i',
2094 2094
         $target_id
2095 2095
     );
@@ -2124,9 +2124,9 @@  discard block
 block discarded – undo
2124 2124
     $password = null
2125 2125
 ) {
2126 2126
     // Load AntiXSS
2127
-    include_once $SETTINGS['cpassman_dir'] . '/includes/libraries/voku/helper/AntiXSS.php';
2128
-    include_once $SETTINGS['cpassman_dir'] . '/includes/libraries/voku/helper/ASCII.php';
2129
-    include_once $SETTINGS['cpassman_dir'] . '/includes/libraries/voku/helper/UTF8.php';
2127
+    include_once $SETTINGS['cpassman_dir'].'/includes/libraries/voku/helper/AntiXSS.php';
2128
+    include_once $SETTINGS['cpassman_dir'].'/includes/libraries/voku/helper/ASCII.php';
2129
+    include_once $SETTINGS['cpassman_dir'].'/includes/libraries/voku/helper/UTF8.php';
2130 2130
     $antiXss = new voku\helper\AntiXSS();
2131 2131
 
2132 2132
     // Protect against bad inputs
@@ -2140,7 +2140,7 @@  discard block
 block discarded – undo
2140 2140
 
2141 2141
     if (empty($password) === true || is_null($password) === true) {
2142 2142
         // get KEY to define password
2143
-        $ascii_key = file_get_contents(SECUREPATH . '/teampass-seckey.txt');
2143
+        $ascii_key = file_get_contents(SECUREPATH.'/teampass-seckey.txt');
2144 2144
         $password = \Defuse\Crypto\Key::loadFromAsciiSafeString($ascii_key);
2145 2145
     }
2146 2146
 
@@ -2186,15 +2186,15 @@  discard block
 block discarded – undo
2186 2186
 ) {
2187 2187
     // load PhpEncryption library
2188 2188
     $path_to_encryption = '/includes/libraries/Encryption/Encryption/';
2189
-    include_once $SETTINGS['cpassman_dir'] . $path_to_encryption . 'Crypto.php';
2190
-    include_once $SETTINGS['cpassman_dir'] . $path_to_encryption . 'Encoding.php';
2191
-    include_once $SETTINGS['cpassman_dir'] . $path_to_encryption . 'DerivedKeys.php';
2192
-    include_once $SETTINGS['cpassman_dir'] . $path_to_encryption . 'Key.php';
2193
-    include_once $SETTINGS['cpassman_dir'] . $path_to_encryption . 'KeyOrPassword.php';
2194
-    include_once $SETTINGS['cpassman_dir'] . $path_to_encryption . 'File.php';
2195
-    include_once $SETTINGS['cpassman_dir'] . $path_to_encryption . 'RuntimeTests.php';
2196
-    include_once $SETTINGS['cpassman_dir'] . $path_to_encryption . 'KeyProtectedByPassword.php';
2197
-    include_once $SETTINGS['cpassman_dir'] . $path_to_encryption . 'Core.php';
2189
+    include_once $SETTINGS['cpassman_dir'].$path_to_encryption.'Crypto.php';
2190
+    include_once $SETTINGS['cpassman_dir'].$path_to_encryption.'Encoding.php';
2191
+    include_once $SETTINGS['cpassman_dir'].$path_to_encryption.'DerivedKeys.php';
2192
+    include_once $SETTINGS['cpassman_dir'].$path_to_encryption.'Key.php';
2193
+    include_once $SETTINGS['cpassman_dir'].$path_to_encryption.'KeyOrPassword.php';
2194
+    include_once $SETTINGS['cpassman_dir'].$path_to_encryption.'File.php';
2195
+    include_once $SETTINGS['cpassman_dir'].$path_to_encryption.'RuntimeTests.php';
2196
+    include_once $SETTINGS['cpassman_dir'].$path_to_encryption.'KeyProtectedByPassword.php';
2197
+    include_once $SETTINGS['cpassman_dir'].$path_to_encryption.'Core.php';
2198 2198
 
2199 2199
     try {
2200 2200
         \Defuse\Crypto\File::encryptFileWithPassword(
@@ -2232,15 +2232,15 @@  discard block
 block discarded – undo
2232 2232
 ) {
2233 2233
     // load PhpEncryption library
2234 2234
     $path_to_encryption = '/includes/libraries/Encryption/Encryption/';
2235
-    include_once $SETTINGS['cpassman_dir'] . $path_to_encryption . 'Crypto.php';
2236
-    include_once $SETTINGS['cpassman_dir'] . $path_to_encryption . 'Encoding.php';
2237
-    include_once $SETTINGS['cpassman_dir'] . $path_to_encryption . 'DerivedKeys.php';
2238
-    include_once $SETTINGS['cpassman_dir'] . $path_to_encryption . 'Key.php';
2239
-    include_once $SETTINGS['cpassman_dir'] . $path_to_encryption . 'KeyOrPassword.php';
2240
-    include_once $SETTINGS['cpassman_dir'] . $path_to_encryption . 'File.php';
2241
-    include_once $SETTINGS['cpassman_dir'] . $path_to_encryption . 'RuntimeTests.php';
2242
-    include_once $SETTINGS['cpassman_dir'] . $path_to_encryption . 'KeyProtectedByPassword.php';
2243
-    include_once $SETTINGS['cpassman_dir'] . $path_to_encryption . 'Core.php';
2235
+    include_once $SETTINGS['cpassman_dir'].$path_to_encryption.'Crypto.php';
2236
+    include_once $SETTINGS['cpassman_dir'].$path_to_encryption.'Encoding.php';
2237
+    include_once $SETTINGS['cpassman_dir'].$path_to_encryption.'DerivedKeys.php';
2238
+    include_once $SETTINGS['cpassman_dir'].$path_to_encryption.'Key.php';
2239
+    include_once $SETTINGS['cpassman_dir'].$path_to_encryption.'KeyOrPassword.php';
2240
+    include_once $SETTINGS['cpassman_dir'].$path_to_encryption.'File.php';
2241
+    include_once $SETTINGS['cpassman_dir'].$path_to_encryption.'RuntimeTests.php';
2242
+    include_once $SETTINGS['cpassman_dir'].$path_to_encryption.'KeyProtectedByPassword.php';
2243
+    include_once $SETTINGS['cpassman_dir'].$path_to_encryption.'Core.php';
2244 2244
 
2245 2245
     try {
2246 2246
         \Defuse\Crypto\File::decryptFileWithPassword(
@@ -2286,9 +2286,9 @@  discard block
 block discarded – undo
2286 2286
 function fileDelete($file, $SETTINGS)
2287 2287
 {
2288 2288
     // Load AntiXSS
2289
-    include_once $SETTINGS['cpassman_dir'] . '/includes/libraries/voku/helper/ASCII.php';
2290
-    include_once $SETTINGS['cpassman_dir'] . '/includes/libraries/voku/helper/UTF8.php';
2291
-    include_once $SETTINGS['cpassman_dir'] . '/includes/libraries/voku/helper/AntiXSS.php';
2289
+    include_once $SETTINGS['cpassman_dir'].'/includes/libraries/voku/helper/ASCII.php';
2290
+    include_once $SETTINGS['cpassman_dir'].'/includes/libraries/voku/helper/UTF8.php';
2291
+    include_once $SETTINGS['cpassman_dir'].'/includes/libraries/voku/helper/AntiXSS.php';
2292 2292
     $antiXss = new voku\helper\AntiXSS();
2293 2293
 
2294 2294
     $file = $antiXss->xss_clean($file);
@@ -2331,7 +2331,7 @@  discard block
 block discarded – undo
2331 2331
 *    More info at: http://php.net/chmod.
2332 2332
 */
2333 2333
 
2334
-function recursiveChmod($path, $filePerm=0644, $dirPerm=0755) {
2334
+function recursiveChmod($path, $filePerm = 0644, $dirPerm = 0755) {
2335 2335
     // Check if the path exists
2336 2336
     if (!file_exists($path)) {
2337 2337
         return false;
@@ -2371,7 +2371,7 @@  discard block
 block discarded – undo
2371 2371
  */
2372 2372
 function accessToItemIsGranted($item_id, $SETTINGS)
2373 2373
 {
2374
-    include_once $SETTINGS['cpassman_dir'] . '/includes/libraries/protect/SuperGlobal/SuperGlobal.php';
2374
+    include_once $SETTINGS['cpassman_dir'].'/includes/libraries/protect/SuperGlobal/SuperGlobal.php';
2375 2375
     $superGlobal = new protect\SuperGlobal\SuperGlobal();
2376 2376
 
2377 2377
     // Prepare superGlobal variables
@@ -2381,7 +2381,7 @@  discard block
 block discarded – undo
2381 2381
     // Load item data
2382 2382
     $data = DB::queryFirstRow(
2383 2383
         'SELECT id_tree
2384
-        FROM ' . prefixTable('items') . '
2384
+        FROM ' . prefixTable('items').'
2385 2385
         WHERE id = %i',
2386 2386
         $item_id
2387 2387
     );
@@ -2463,8 +2463,8 @@  discard block
 block discarded – undo
2463 2463
 function performDBQuery($SETTINGS, $fields, $table)
2464 2464
 {
2465 2465
     // include librairies & connect to DB
2466
-    include_once $SETTINGS['cpassman_dir'] . '/includes/config/settings.php';
2467
-    include_once $SETTINGS['cpassman_dir'] . '/includes/libraries/Database/Meekrodb/db.class.php';
2466
+    include_once $SETTINGS['cpassman_dir'].'/includes/config/settings.php';
2467
+    include_once $SETTINGS['cpassman_dir'].'/includes/libraries/Database/Meekrodb/db.class.php';
2468 2468
     if (defined('DB_PASSWD_CLEAR') === false) {
2469 2469
         define('DB_PASSWD_CLEAR', defuseReturnDecrypted(DB_PASSWD, $SETTINGS));
2470 2470
     }
@@ -2477,7 +2477,7 @@  discard block
 block discarded – undo
2477 2477
 
2478 2478
     // Insert log in DB
2479 2479
     return DB::query(
2480
-        'SELECT ' . $fields . '
2480
+        'SELECT '.$fields.'
2481 2481
         FROM ' . prefixTable($table)
2482 2482
     );
2483 2483
 }
@@ -2492,15 +2492,15 @@  discard block
 block discarded – undo
2492 2492
 function formatSizeUnits($bytes)
2493 2493
 {
2494 2494
     if ($bytes >= 1073741824) {
2495
-        $bytes = number_format($bytes / 1073741824, 2) . ' GB';
2495
+        $bytes = number_format($bytes / 1073741824, 2).' GB';
2496 2496
     } elseif ($bytes >= 1048576) {
2497
-        $bytes = number_format($bytes / 1048576, 2) . ' MB';
2497
+        $bytes = number_format($bytes / 1048576, 2).' MB';
2498 2498
     } elseif ($bytes >= 1024) {
2499
-        $bytes = number_format($bytes / 1024, 2) . ' KB';
2499
+        $bytes = number_format($bytes / 1024, 2).' KB';
2500 2500
     } elseif ($bytes > 1) {
2501
-        $bytes = $bytes . ' bytes';
2501
+        $bytes = $bytes.' bytes';
2502 2502
     } elseif ($bytes == 1) {
2503
-        $bytes = $bytes . ' byte';
2503
+        $bytes = $bytes.' byte';
2504 2504
     } else {
2505 2505
         $bytes = '0 bytes';
2506 2506
     }
@@ -2680,7 +2680,7 @@  discard block
 block discarded – undo
2680 2680
     // Decrypt
2681 2681
     try {
2682 2682
         $ret = base64_encode($rsa->decrypt(base64_decode($key)));
2683
-    } catch(Exception $e) {
2683
+    } catch (Exception $e) {
2684 2684
         return $e;
2685 2685
     }
2686 2686
 
@@ -2722,16 +2722,16 @@  discard block
 block discarded – undo
2722 2722
 
2723 2723
     // Encrypt the file content
2724 2724
     $plaintext = file_get_contents(
2725
-        filter_var($fileInPath . '/' . $fileInName, FILTER_SANITIZE_URL)
2725
+        filter_var($fileInPath.'/'.$fileInName, FILTER_SANITIZE_URL)
2726 2726
     );
2727 2727
 
2728 2728
     $ciphertext = $cipher->encrypt($plaintext);
2729 2729
 
2730 2730
     // Save new file
2731 2731
     $hash = md5($plaintext);
2732
-    $fileOut = $fileInPath . '/' . TP_FILE_PREFIX . $hash;
2732
+    $fileOut = $fileInPath.'/'.TP_FILE_PREFIX.$hash;
2733 2733
     file_put_contents($fileOut, $ciphertext);
2734
-    unlink($fileInPath . '/' . $fileInName);
2734
+    unlink($fileInPath.'/'.$fileInName);
2735 2735
 
2736 2736
     return array(
2737 2737
         'fileHash' => base64_encode($hash),
@@ -2774,7 +2774,7 @@  discard block
 block discarded – undo
2774 2774
     $cipher->disablePadding();
2775 2775
 
2776 2776
     // Get file content
2777
-    $ciphertext = file_get_contents($filePath . '/' . TP_FILE_PREFIX . $fileName);
2777
+    $ciphertext = file_get_contents($filePath.'/'.TP_FILE_PREFIX.$fileName);
2778 2778
 
2779 2779
     // Decrypt file content and return
2780 2780
     return base64_encode($cipher->decrypt($ciphertext));
@@ -2830,8 +2830,8 @@  discard block
 block discarded – undo
2830 2830
     $SETTINGS
2831 2831
 ) {
2832 2832
     // include librairies & connect to DB
2833
-    include_once $SETTINGS['cpassman_dir'] . '/includes/config/settings.php';
2834
-    include_once $SETTINGS['cpassman_dir'] . '/includes/libraries/Database/Meekrodb/db.class.php';
2833
+    include_once $SETTINGS['cpassman_dir'].'/includes/config/settings.php';
2834
+    include_once $SETTINGS['cpassman_dir'].'/includes/libraries/Database/Meekrodb/db.class.php';
2835 2835
     if (defined('DB_PASSWD_CLEAR') === false) {
2836 2836
         define('DB_PASSWD_CLEAR', defuseReturnDecrypted(DB_PASSWD, $SETTINGS));
2837 2837
     }
@@ -2850,7 +2850,7 @@  discard block
 block discarded – undo
2850 2850
     );
2851 2851
 
2852 2852
     // Superglobals
2853
-    include_once $SETTINGS['cpassman_dir'] . '/includes/libraries/protect/SuperGlobal/SuperGlobal.php';
2853
+    include_once $SETTINGS['cpassman_dir'].'/includes/libraries/protect/SuperGlobal/SuperGlobal.php';
2854 2854
     $superGlobal = new protect\SuperGlobal\SuperGlobal();
2855 2855
 
2856 2856
     // Prepare superGlobal variables
@@ -2877,8 +2877,8 @@  discard block
 block discarded – undo
2877 2877
         // Create sharekey for each user
2878 2878
         $users = DB::query(
2879 2879
             'SELECT id, public_key
2880
-            FROM ' . prefixTable('users') . '
2881
-            WHERE id NOT IN ("' . OTV_USER_ID . '","' . SSH_USER_ID . '","' . API_USER_ID . '")
2880
+            FROM ' . prefixTable('users').'
2881
+            WHERE id NOT IN ("' . OTV_USER_ID.'","'.SSH_USER_ID.'","'.API_USER_ID.'")
2882 2882
             AND public_key != ""'
2883 2883
         );
2884 2884
         foreach ($users as $user) {
@@ -2979,13 +2979,13 @@  discard block
 block discarded – undo
2979 2979
     ];
2980 2980
 
2981 2981
     // Load expected libraries
2982
-    require_once $SETTINGS['cpassman_dir'] . '/includes/libraries/Tightenco/Collect/Support/Traits/Macroable.php';
2983
-    require_once $SETTINGS['cpassman_dir'] . '/includes/libraries/Tightenco/Collect/Support/Arr.php';
2984
-    require_once $SETTINGS['cpassman_dir'] . '/includes/libraries/LdapRecord/DetectsErrors.php';
2985
-    require_once $SETTINGS['cpassman_dir'] . '/includes/libraries/LdapRecord/Connection.php';
2986
-    require_once $SETTINGS['cpassman_dir'] . '/includes/libraries/LdapRecord/LdapInterface.php';
2987
-    require_once $SETTINGS['cpassman_dir'] . '/includes/libraries/LdapRecord/LdapBase.php';
2988
-    require_once $SETTINGS['cpassman_dir'] . '/includes/libraries/LdapRecord/Ldap.php';
2982
+    require_once $SETTINGS['cpassman_dir'].'/includes/libraries/Tightenco/Collect/Support/Traits/Macroable.php';
2983
+    require_once $SETTINGS['cpassman_dir'].'/includes/libraries/Tightenco/Collect/Support/Arr.php';
2984
+    require_once $SETTINGS['cpassman_dir'].'/includes/libraries/LdapRecord/DetectsErrors.php';
2985
+    require_once $SETTINGS['cpassman_dir'].'/includes/libraries/LdapRecord/Connection.php';
2986
+    require_once $SETTINGS['cpassman_dir'].'/includes/libraries/LdapRecord/LdapInterface.php';
2987
+    require_once $SETTINGS['cpassman_dir'].'/includes/libraries/LdapRecord/LdapBase.php';
2988
+    require_once $SETTINGS['cpassman_dir'].'/includes/libraries/LdapRecord/Ldap.php';
2989 2989
 
2990 2990
     $ad = new SplClassLoader('LdapRecord', '../includes/libraries');
2991 2991
     $ad->register();
@@ -2998,7 +2998,7 @@  discard block
 block discarded – undo
2998 2998
     } catch (\LdapRecord\Auth\BindException $e) {
2999 2999
         $error = $e->getDetailedError();
3000 3000
 
3001
-        echo "Error : ".$error->getErrorCode()." - ".$error->getErrorMessage(). "<br>".$error->getDiagnosticMessage();
3001
+        echo "Error : ".$error->getErrorCode()." - ".$error->getErrorMessage()."<br>".$error->getDiagnosticMessage();
3002 3002
         return false;
3003 3003
     }
3004 3004
 
@@ -3009,7 +3009,7 @@  discard block
 block discarded – undo
3009 3009
     } catch (\LdapRecord\Auth\BindException $e) {
3010 3010
         $error = $e->getDetailedError();
3011 3011
         
3012
-        echo "Error : ".$error->getErrorCode()." - ".$error->getErrorMessage(). "<br>".$error->getDiagnosticMessage();
3012
+        echo "Error : ".$error->getErrorCode()." - ".$error->getErrorMessage()."<br>".$error->getDiagnosticMessage();
3013 3013
         return false;
3014 3014
     }
3015 3015
 
@@ -3030,8 +3030,8 @@  discard block
 block discarded – undo
3030 3030
 function deleteUserObjetsKeys($userId, $SETTINGS)
3031 3031
 {
3032 3032
     // include librairies & connect to DB
3033
-    include_once $SETTINGS['cpassman_dir'] . '/includes/config/settings.php';
3034
-    include_once $SETTINGS['cpassman_dir'] . '/includes/libraries/Database/Meekrodb/db.class.php';
3033
+    include_once $SETTINGS['cpassman_dir'].'/includes/config/settings.php';
3034
+    include_once $SETTINGS['cpassman_dir'].'/includes/libraries/Database/Meekrodb/db.class.php';
3035 3035
     if (defined('DB_PASSWD_CLEAR') === false) {
3036 3036
         define('DB_PASSWD_CLEAR', defuseReturnDecrypted(DB_PASSWD, $SETTINGS));
3037 3037
     }
@@ -3092,7 +3092,7 @@  discard block
 block discarded – undo
3092 3092
         foreach (DateTimeZone::listIdentifiers() as $timezone) {
3093 3093
             $now->setTimezone(new DateTimeZone($timezone));
3094 3094
             $offsets[] = $offset = $now->getOffset();
3095
-            $timezones[$timezone] = '(' . format_GMT_offset($offset) . ') ' . format_timezone_name($timezone);
3095
+            $timezones[$timezone] = '('.format_GMT_offset($offset).') '.format_timezone_name($timezone);
3096 3096
         }
3097 3097
 
3098 3098
         array_multisort($offsets, $timezones);
@@ -3104,7 +3104,7 @@  discard block
 block discarded – undo
3104 3104
 function format_GMT_offset($offset) {
3105 3105
     $hours = intval($offset / 3600);
3106 3106
     $minutes = abs(intval($offset % 3600 / 60));
3107
-    return 'GMT' . ($offset ? sprintf('%+03d:%02d', $hours, $minutes) : '');
3107
+    return 'GMT'.($offset ? sprintf('%+03d:%02d', $hours, $minutes) : '');
3108 3108
 }
3109 3109
 
3110 3110
 function format_timezone_name($name) {
@@ -3130,7 +3130,7 @@  discard block
 block discarded – undo
3130 3130
 	}
3131 3131
 	
3132 3132
     $mfaRoles = array_values(json_decode($mfaRoles, true));
3133
-    $userRolesIds = array_filter(explode(';' , $userRolesIds));
3133
+    $userRolesIds = array_filter(explode(';', $userRolesIds));
3134 3134
 
3135 3135
     if (count($mfaRoles) === 0 || count($mfaRoles) === 0) {
3136 3136
         return true;
Please login to merge, or discard this patch.