Passed
Push — wip_sessions ( 2f1ef6...1e15ba )
by Nils
06:51
created
sources/main.functions.php 1 patch
Spacing   +148 added lines, -151 removed lines patch added patch discarded remove patch
@@ -49,7 +49,7 @@  discard block
 block discarded – undo
49 49
 
50 50
 // Load config if $SETTINGS not defined
51 51
 if (isset($SETTINGS['cpassman_dir']) === false || empty($SETTINGS['cpassman_dir']) === true) {
52
-    include_once __DIR__ . '/../includes/config/tp.config.php';
52
+    include_once __DIR__.'/../includes/config/tp.config.php';
53 53
 }
54 54
 
55 55
 header('Content-type: text/html; charset=utf-8');
@@ -219,7 +219,7 @@  discard block
 block discarded – undo
219 219
  */
220 220
 function trimElement($chaine, string $element): string
221 221
 {
222
-    if (! empty($chaine)) {
222
+    if (!empty($chaine)) {
223 223
         if (is_array($chaine) === true) {
224 224
             $chaine = implode(';', $chaine);
225 225
         }
@@ -267,8 +267,8 @@  discard block
 block discarded – undo
267 267
  */
268 268
 function db_error_handler(array $params): void
269 269
 {
270
-    echo 'Error: ' . $params['error'] . "<br>\n";
271
-    echo 'Query: ' . $params['query'] . "<br>\n";
270
+    echo 'Error: '.$params['error']."<br>\n";
271
+    echo 'Query: '.$params['query']."<br>\n";
272 272
     throw new Exception('Error - Query', 1);
273 273
 }
274 274
 
@@ -348,7 +348,7 @@  discard block
 block discarded – undo
348 348
     $globalsVisibleFolders = $session->get('user-accessible_folders');
349 349
     $globalsPersonalVisibleFolders = $session->get('user-personal_visible_folders');
350 350
     // Get list of Folders
351
-    $rows = DB::query('SELECT id FROM ' . prefixTable('nested_tree') . ' WHERE personal_folder = %i', 0);
351
+    $rows = DB::query('SELECT id FROM '.prefixTable('nested_tree').' WHERE personal_folder = %i', 0);
352 352
     foreach ($rows as $record) {
353 353
         array_push($groupesVisibles, $record['id']);
354 354
     }
@@ -367,7 +367,7 @@  discard block
 block discarded – undo
367 367
     }
368 368
     // Get ID of personal folder
369 369
     $persfld = DB::queryfirstrow(
370
-        'SELECT id FROM ' . prefixTable('nested_tree') . ' WHERE title = %s',
370
+        'SELECT id FROM '.prefixTable('nested_tree').' WHERE title = %s',
371 371
         $globalsUserId
372 372
     );
373 373
     if (empty($persfld['id']) === false) {
@@ -387,20 +387,20 @@  discard block
 block discarded – undo
387 387
     // get complete list of ROLES
388 388
     $tmp = explode(';', $idFonctions);
389 389
     $rows = DB::query(
390
-        'SELECT * FROM ' . prefixTable('roles_title') . '
390
+        'SELECT * FROM '.prefixTable('roles_title').'
391 391
         ORDER BY title ASC'
392 392
     );
393 393
     foreach ($rows as $record) {
394
-        if (! empty($record['id']) && ! in_array($record['id'], $tmp)) {
394
+        if (!empty($record['id']) && !in_array($record['id'], $tmp)) {
395 395
             array_push($tmp, $record['id']);
396 396
         }
397 397
     }
398 398
     $session->set('user-roles', implode(';', $tmp));
399 399
     $session->set('user-admin', 1);
400 400
     // Check if admin has created Folders and Roles
401
-    DB::query('SELECT * FROM ' . prefixTable('nested_tree') . '');
401
+    DB::query('SELECT * FROM '.prefixTable('nested_tree').'');
402 402
     $session->set('user-nb_folders', DB::count());
403
-    DB::query('SELECT * FROM ' . prefixTable('roles_title'));
403
+    DB::query('SELECT * FROM '.prefixTable('roles_title'));
404 404
     $session->set('user-nb_roles', DB::count());
405 405
 
406 406
     return true;
@@ -483,7 +483,7 @@  discard block
 block discarded – undo
483 483
     // Does this user is allowed to see other items
484 484
     $inc = 0;
485 485
     $rows = DB::query(
486
-        'SELECT id, id_tree FROM ' . prefixTable('items') . '
486
+        'SELECT id, id_tree FROM '.prefixTable('items').'
487 487
             WHERE restricted_to LIKE %ss AND inactif = %s'.
488 488
             (count($allowedFolders) > 0 ? ' AND id_tree NOT IN ('.implode(',', $allowedFolders).')' : ''),
489 489
         $globalsUserId,
@@ -500,8 +500,8 @@  discard block
 block discarded – undo
500 500
     // Check for the users roles if some specific rights exist on items
501 501
     $rows = DB::query(
502 502
         'SELECT i.id_tree, r.item_id
503
-        FROM ' . prefixTable('items') . ' as i
504
-        INNER JOIN ' . prefixTable('restriction_to_roles') . ' as r ON (r.item_id=i.id)
503
+        FROM ' . prefixTable('items').' as i
504
+        INNER JOIN ' . prefixTable('restriction_to_roles').' as r ON (r.item_id=i.id)
505 505
         WHERE i.id_tree <> "" '.
506 506
         (count($userRoles) > 0 ? 'AND r.role_id IN %li ' : '').
507 507
         'ORDER BY i.id_tree ASC',
@@ -555,16 +555,16 @@  discard block
 block discarded – undo
555 555
         ), SORT_NUMERIC)
556 556
     );
557 557
     // Folders and Roles numbers
558
-    DB::queryfirstrow('SELECT id FROM ' . prefixTable('nested_tree') . '');
558
+    DB::queryfirstrow('SELECT id FROM '.prefixTable('nested_tree').'');
559 559
     $session->set('user-nb_folders', DB::count());
560
-    DB::queryfirstrow('SELECT id FROM ' . prefixTable('roles_title'));
560
+    DB::queryfirstrow('SELECT id FROM '.prefixTable('roles_title'));
561 561
     $session->set('user-nb_roles', DB::count());
562 562
     // check if change proposals on User's items
563 563
     if (isset($SETTINGS['enable_suggestion']) === true && (int) $SETTINGS['enable_suggestion'] === 1) {
564 564
         $countNewItems = DB::query(
565 565
             'SELECT COUNT(*)
566
-            FROM ' . prefixTable('items_change') . ' AS c
567
-            LEFT JOIN ' . prefixTable('log_items') . ' AS i ON (c.item_id = i.id_item)
566
+            FROM ' . prefixTable('items_change').' AS c
567
+            LEFT JOIN ' . prefixTable('log_items').' AS i ON (c.item_id = i.id_item)
568 568
             WHERE i.action = %s AND i.id_user = %i',
569 569
             'at_creation',
570 570
             $globalsUserId
@@ -591,7 +591,7 @@  discard block
 block discarded – undo
591 591
 {
592 592
     $rows = DB::query(
593 593
         'SELECT *
594
-        FROM ' . prefixTable('roles_values') . '
594
+        FROM ' . prefixTable('roles_values').'
595 595
         WHERE type IN %ls'.(count($userRoles) > 0 ? ' AND role_id IN %li' : ''),
596 596
         ['W', 'ND', 'NE', 'NDNE', 'R'],
597 597
         $userRoles,
@@ -658,7 +658,7 @@  discard block
 block discarded – undo
658 658
     ) {
659 659
         $persoFld = DB::queryfirstrow(
660 660
             'SELECT id
661
-            FROM ' . prefixTable('nested_tree') . '
661
+            FROM ' . prefixTable('nested_tree').'
662 662
             WHERE title = %s AND personal_folder = %i'.
663 663
             (count($allowedFolders) > 0 ? ' AND id NOT IN ('.implode(',', $allowedFolders).')' : ''),
664 664
             $globalsUserId,
@@ -691,7 +691,7 @@  discard block
 block discarded – undo
691 691
     }
692 692
     $persoFlds = DB::query(
693 693
         'SELECT id
694
-        FROM ' . prefixTable('nested_tree') . '
694
+        FROM ' . prefixTable('nested_tree').'
695 695
         WHERE %l',
696 696
         $where
697 697
     );
@@ -759,12 +759,12 @@  discard block
 block discarded – undo
759 759
     //Load Tree
760 760
     $tree = new NestedTree(prefixTable('nested_tree'), 'id', 'parent_id', 'title');
761 761
     // truncate table
762
-    DB::query('TRUNCATE TABLE ' . prefixTable('cache'));
762
+    DB::query('TRUNCATE TABLE '.prefixTable('cache'));
763 763
     // reload date
764 764
     $rows = DB::query(
765 765
         'SELECT *
766
-        FROM ' . prefixTable('items') . ' as i
767
-        INNER JOIN ' . prefixTable('log_items') . ' as l ON (l.id_item = i.id)
766
+        FROM ' . prefixTable('items').' as i
767
+        INNER JOIN ' . prefixTable('log_items').' as l ON (l.id_item = i.id)
768 768
         AND l.action = %s
769 769
         AND i.inactif = %i',
770 770
         'at_creation',
@@ -776,18 +776,18 @@  discard block
 block discarded – undo
776 776
             $tags = '';
777 777
             $itemTags = DB::query(
778 778
                 'SELECT tag
779
-                FROM ' . prefixTable('tags') . '
779
+                FROM ' . prefixTable('tags').'
780 780
                 WHERE item_id = %i AND tag != ""',
781 781
                 $record['id']
782 782
             );
783 783
             foreach ($itemTags as $itemTag) {
784
-                $tags .= $itemTag['tag'] . ' ';
784
+                $tags .= $itemTag['tag'].' ';
785 785
             }
786 786
 
787 787
             // Get renewal period
788 788
             $resNT = DB::queryfirstrow(
789 789
                 'SELECT renewal_period
790
-                FROM ' . prefixTable('nested_tree') . '
790
+                FROM ' . prefixTable('nested_tree').'
791 791
                 WHERE id = %i',
792 792
                 $record['id_tree']
793 793
             );
@@ -800,7 +800,7 @@  discard block
 block discarded – undo
800 800
                     // Is this a User id?
801 801
                     $user = DB::queryfirstrow(
802 802
                         'SELECT id, login
803
-                        FROM ' . prefixTable('users') . '
803
+                        FROM ' . prefixTable('users').'
804 804
                         WHERE id = %i',
805 805
                         $elem->title
806 806
                     );
@@ -818,11 +818,11 @@  discard block
 block discarded – undo
818 818
                     'id' => $record['id'],
819 819
                     'label' => $record['label'],
820 820
                     'description' => $record['description'] ?? '',
821
-                    'url' => isset($record['url']) && ! empty($record['url']) ? $record['url'] : '0',
821
+                    'url' => isset($record['url']) && !empty($record['url']) ? $record['url'] : '0',
822 822
                     'tags' => $tags,
823 823
                     'id_tree' => $record['id_tree'],
824 824
                     'perso' => $record['perso'],
825
-                    'restricted_to' => isset($record['restricted_to']) && ! empty($record['restricted_to']) ? $record['restricted_to'] : '0',
825
+                    'restricted_to' => isset($record['restricted_to']) && !empty($record['restricted_to']) ? $record['restricted_to'] : '0',
826 826
                     'login' => $record['login'] ?? '',
827 827
                     'folder' => implode(' > ', $folder),
828 828
                     'author' => $record['id_user'],
@@ -851,7 +851,7 @@  discard block
 block discarded – undo
851 851
     // get new value from db
852 852
     $data = DB::queryfirstrow(
853 853
         'SELECT label, description, id_tree, perso, restricted_to, login, url
854
-        FROM ' . prefixTable('items') . '
854
+        FROM ' . prefixTable('items').'
855 855
         WHERE id=%i',
856 856
         $ident
857 857
     );
@@ -859,12 +859,12 @@  discard block
 block discarded – undo
859 859
     $tags = '';
860 860
     $itemTags = DB::query(
861 861
         'SELECT tag
862
-            FROM ' . prefixTable('tags') . '
862
+            FROM ' . prefixTable('tags').'
863 863
             WHERE item_id = %i AND tag != ""',
864 864
         $ident
865 865
     );
866 866
     foreach ($itemTags as $itemTag) {
867
-        $tags .= $itemTag['tag'] . ' ';
867
+        $tags .= $itemTag['tag'].' ';
868 868
     }
869 869
     // form id_tree to full foldername
870 870
     $folder = [];
@@ -875,7 +875,7 @@  discard block
 block discarded – undo
875 875
             // Is this a User id?
876 876
             $user = DB::queryfirstrow(
877 877
                 'SELECT id, login
878
-                FROM ' . prefixTable('users') . '
878
+                FROM ' . prefixTable('users').'
879 879
                 WHERE id = %i',
880 880
                 $elem->title
881 881
             );
@@ -893,10 +893,10 @@  discard block
 block discarded – undo
893 893
             'label' => $data['label'],
894 894
             'description' => $data['description'],
895 895
             'tags' => $tags,
896
-            'url' => isset($data['url']) && ! empty($data['url']) ? $data['url'] : '0',
896
+            'url' => isset($data['url']) && !empty($data['url']) ? $data['url'] : '0',
897 897
             'id_tree' => $data['id_tree'],
898 898
             'perso' => $data['perso'],
899
-            'restricted_to' => isset($data['restricted_to']) && ! empty($data['restricted_to']) ? $data['restricted_to'] : '0',
899
+            'restricted_to' => isset($data['restricted_to']) && !empty($data['restricted_to']) ? $data['restricted_to'] : '0',
900 900
             'login' => $data['login'] ?? '',
901 901
             'folder' => implode(' » ', $folder),
902 902
             'author' => $session->get('user-id'),
@@ -926,8 +926,8 @@  discard block
 block discarded – undo
926 926
     // get new value from db
927 927
     $data = DB::queryFirstRow(
928 928
         'SELECT i.label, i.description, i.id_tree as id_tree, i.perso, i.restricted_to, i.id, i.login, i.url, l.date
929
-        FROM ' . prefixTable('items') . ' as i
930
-        INNER JOIN ' . prefixTable('log_items') . ' as l ON (l.id_item = i.id)
929
+        FROM ' . prefixTable('items').' as i
930
+        INNER JOIN ' . prefixTable('log_items').' as l ON (l.id_item = i.id)
931 931
         WHERE i.id = %i
932 932
         AND l.action = %s',
933 933
         $ident,
@@ -937,12 +937,12 @@  discard block
 block discarded – undo
937 937
     $tags = '';
938 938
     $itemTags = DB::query(
939 939
         'SELECT tag
940
-            FROM ' . prefixTable('tags') . '
940
+            FROM ' . prefixTable('tags').'
941 941
             WHERE item_id = %i AND tag != ""',
942 942
         $ident
943 943
     );
944 944
     foreach ($itemTags as $itemTag) {
945
-        $tags .= $itemTag['tag'] . ' ';
945
+        $tags .= $itemTag['tag'].' ';
946 946
     }
947 947
     // form id_tree to full foldername
948 948
     $folder = [];
@@ -953,7 +953,7 @@  discard block
 block discarded – undo
953 953
             // Is this a User id?
954 954
             $user = DB::queryfirstrow(
955 955
                 'SELECT id, login
956
-                FROM ' . prefixTable('users') . '
956
+                FROM ' . prefixTable('users').'
957 957
                 WHERE id = %i',
958 958
                 $elem->title
959 959
             );
@@ -972,7 +972,7 @@  discard block
 block discarded – undo
972 972
             'label' => $data['label'],
973 973
             'description' => $data['description'],
974 974
             'tags' => isset($tags) && empty($tags) === false ? $tags : 'None',
975
-            'url' => isset($data['url']) && ! empty($data['url']) ? $data['url'] : '0',
975
+            'url' => isset($data['url']) && !empty($data['url']) ? $data['url'] : '0',
976 976
             'id_tree' => $data['id_tree'],
977 977
             'perso' => isset($data['perso']) && empty($data['perso']) === false && $data['perso'] !== 'None' ? $data['perso'] : '0',
978 978
             'restricted_to' => isset($data['restricted_to']) && empty($data['restricted_to']) === false ? $data['restricted_to'] : '0',
@@ -994,52 +994,52 @@  discard block
 block discarded – undo
994 994
 function getStatisticsData(array $SETTINGS): array
995 995
 {
996 996
     DB::query(
997
-        'SELECT id FROM ' . prefixTable('nested_tree') . ' WHERE personal_folder = %i',
997
+        'SELECT id FROM '.prefixTable('nested_tree').' WHERE personal_folder = %i',
998 998
         0
999 999
     );
1000 1000
     $counter_folders = DB::count();
1001 1001
     DB::query(
1002
-        'SELECT id FROM ' . prefixTable('nested_tree') . ' WHERE personal_folder = %i',
1002
+        'SELECT id FROM '.prefixTable('nested_tree').' WHERE personal_folder = %i',
1003 1003
         1
1004 1004
     );
1005 1005
     $counter_folders_perso = DB::count();
1006 1006
     DB::query(
1007
-        'SELECT id FROM ' . prefixTable('items') . ' WHERE perso = %i',
1007
+        'SELECT id FROM '.prefixTable('items').' WHERE perso = %i',
1008 1008
         0
1009 1009
     );
1010 1010
     $counter_items = DB::count();
1011 1011
         DB::query(
1012
-        'SELECT id FROM ' . prefixTable('items') . ' WHERE perso = %i',
1012
+        'SELECT id FROM '.prefixTable('items').' WHERE perso = %i',
1013 1013
         1
1014 1014
     );
1015 1015
     $counter_items_perso = DB::count();
1016 1016
         DB::query(
1017
-        'SELECT id FROM ' . prefixTable('users') . ''
1017
+        'SELECT id FROM '.prefixTable('users').''
1018 1018
     );
1019 1019
     $counter_users = DB::count();
1020 1020
         DB::query(
1021
-        'SELECT id FROM ' . prefixTable('users') . ' WHERE admin = %i',
1021
+        'SELECT id FROM '.prefixTable('users').' WHERE admin = %i',
1022 1022
         1
1023 1023
     );
1024 1024
     $admins = DB::count();
1025 1025
     DB::query(
1026
-        'SELECT id FROM ' . prefixTable('users') . ' WHERE gestionnaire = %i',
1026
+        'SELECT id FROM '.prefixTable('users').' WHERE gestionnaire = %i',
1027 1027
         1
1028 1028
     );
1029 1029
     $managers = DB::count();
1030 1030
     DB::query(
1031
-        'SELECT id FROM ' . prefixTable('users') . ' WHERE read_only = %i',
1031
+        'SELECT id FROM '.prefixTable('users').' WHERE read_only = %i',
1032 1032
         1
1033 1033
     );
1034 1034
     $readOnly = DB::count();
1035 1035
     // list the languages
1036 1036
     $usedLang = [];
1037 1037
     $tp_languages = DB::query(
1038
-        'SELECT name FROM ' . prefixTable('languages')
1038
+        'SELECT name FROM '.prefixTable('languages')
1039 1039
     );
1040 1040
     foreach ($tp_languages as $tp_language) {
1041 1041
         DB::query(
1042
-            'SELECT * FROM ' . prefixTable('users') . ' WHERE user_language = %s',
1042
+            'SELECT * FROM '.prefixTable('users').' WHERE user_language = %s',
1043 1043
             $tp_language['name']
1044 1044
         );
1045 1045
         $usedLang[$tp_language['name']] = round((DB::count() * 100 / $counter_users), 0);
@@ -1048,12 +1048,12 @@  discard block
 block discarded – undo
1048 1048
     // get list of ips
1049 1049
     $usedIp = [];
1050 1050
     $tp_ips = DB::query(
1051
-        'SELECT user_ip FROM ' . prefixTable('users')
1051
+        'SELECT user_ip FROM '.prefixTable('users')
1052 1052
     );
1053 1053
     foreach ($tp_ips as $ip) {
1054 1054
         if (array_key_exists($ip['user_ip'], $usedIp)) {
1055 1055
             $usedIp[$ip['user_ip']] += $usedIp[$ip['user_ip']];
1056
-        } elseif (! empty($ip['user_ip']) && $ip['user_ip'] !== 'none') {
1056
+        } elseif (!empty($ip['user_ip']) && $ip['user_ip'] !== 'none') {
1057 1057
             $usedIp[$ip['user_ip']] = 1;
1058 1058
         }
1059 1059
     }
@@ -1206,7 +1206,7 @@  discard block
 block discarded – undo
1206 1206
 {
1207 1207
     // Load PHPMailer
1208 1208
     $mail = new PHPMailer(true);
1209
-    $languageDir = $SETTINGS['cpassman_dir'] . '/vendor/phpmailer/phpmailer/language/';
1209
+    $languageDir = $SETTINGS['cpassman_dir'].'/vendor/phpmailer/phpmailer/language/';
1210 1210
 
1211 1211
     try {
1212 1212
         // Set language and SMTPDebug
@@ -1357,7 +1357,7 @@  discard block
 block discarded – undo
1357 1357
         <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;">
1358 1358
         <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;">
1359 1359
         <br><div style="float:right;">' .
1360
-        $textMail .
1360
+        $textMail.
1361 1361
         '<br><br></td></tr></table>
1362 1362
     </td></tr></table>
1363 1363
     <br></body></html>';
@@ -1370,7 +1370,7 @@  discard block
 block discarded – undo
1370 1370
  */
1371 1371
 function generateKey(): string
1372 1372
 {
1373
-    return substr(md5(rand() . rand()), 0, 15);
1373
+    return substr(md5(rand().rand()), 0, 15);
1374 1374
 }
1375 1375
 
1376 1376
 /**
@@ -1448,7 +1448,7 @@  discard block
 block discarded – undo
1448 1448
 {
1449 1449
     array_walk_recursive(
1450 1450
         $array,
1451
-        static function (&$item): void {
1451
+        static function(&$item): void {
1452 1452
             if (mb_detect_encoding((string) $item, 'utf-8', true) === false) {
1453 1453
                 $item = mb_convert_encoding($item, 'ISO-8859-1', 'UTF-8');
1454 1454
             }
@@ -1549,7 +1549,7 @@  discard block
 block discarded – undo
1549 1549
  */
1550 1550
 function prefixTable(string $table): string
1551 1551
 {
1552
-    $safeTable = htmlspecialchars(DB_PREFIX . $table);
1552
+    $safeTable = htmlspecialchars(DB_PREFIX.$table);
1553 1553
     if (empty($safeTable) === false) {
1554 1554
         // sanitize string
1555 1555
         return $safeTable;
@@ -1613,7 +1613,7 @@  discard block
 block discarded – undo
1613 1613
 function send_syslog($message, $host, $port, $component = 'teampass'): void
1614 1614
 {
1615 1615
     $sock = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP);
1616
-    $syslog_message = '<123>' . date('M d H:i:s ') . $component . ': ' . $message;
1616
+    $syslog_message = '<123>'.date('M d H:i:s ').$component.': '.$message;
1617 1617
     socket_sendto($sock, (string) $syslog_message, strlen($syslog_message), 0, (string) $host, (int) $port);
1618 1618
     socket_close($sock);
1619 1619
 }
@@ -1660,14 +1660,14 @@  discard block
 block discarded – undo
1660 1660
     if (isset($SETTINGS['syslog_enable']) === true && (int) $SETTINGS['syslog_enable'] === 1) {
1661 1661
         if ($type === 'user_mngt') {
1662 1662
             send_syslog(
1663
-                'action=' . str_replace('at_', '', $label) . ' attribute=user user=' . $who . ' userid="' . $login . '" change="' . $field_1 . '" ',
1663
+                'action='.str_replace('at_', '', $label).' attribute=user user='.$who.' userid="'.$login.'" change="'.$field_1.'" ',
1664 1664
                 $SETTINGS['syslog_host'],
1665 1665
                 $SETTINGS['syslog_port'],
1666 1666
                 'teampass'
1667 1667
             );
1668 1668
         } else {
1669 1669
             send_syslog(
1670
-                'action=' . $type . ' attribute=' . $label . ' user=' . $who . ' userid="' . $login . '" ',
1670
+                'action='.$type.' attribute='.$label.' user='.$who.' userid="'.$login.'" ',
1671 1671
                 $SETTINGS['syslog_host'],
1672 1672
                 $SETTINGS['syslog_port'],
1673 1673
                 'teampass'
@@ -1741,7 +1741,7 @@  discard block
 block discarded – undo
1741 1741
         if (empty($item_label) === true) {
1742 1742
             $dataItem = DB::queryfirstrow(
1743 1743
                 'SELECT id, id_tree, label
1744
-                FROM ' . prefixTable('items') . '
1744
+                FROM ' . prefixTable('items').'
1745 1745
                 WHERE id = %i',
1746 1746
                 $item_id
1747 1747
             );
@@ -1749,11 +1749,11 @@  discard block
 block discarded – undo
1749 1749
         }
1750 1750
 
1751 1751
         send_syslog(
1752
-            'action=' . str_replace('at_', '', $action) .
1753
-                ' attribute=' . str_replace('at_', '', $attribute[0]) .
1754
-                ' itemno=' . $item_id .
1755
-                ' user=' . is_null($login) === true ? '' : addslashes((string) $login) .
1756
-                ' itemname="' . addslashes($item_label) . '"',
1752
+            'action='.str_replace('at_', '', $action).
1753
+                ' attribute='.str_replace('at_', '', $attribute[0]).
1754
+                ' itemno='.$item_id.
1755
+                ' user='.is_null($login) === true ? '' : addslashes((string) $login).
1756
+                ' itemname="'.addslashes($item_label).'"',
1757 1757
             $SETTINGS['syslog_host'],
1758 1758
             $SETTINGS['syslog_port'],
1759 1759
             'teampass'
@@ -1785,8 +1785,8 @@  discard block
 block discarded – undo
1785 1785
     $notification = DB::queryOneColumn(
1786 1786
         'email',
1787 1787
         'SELECT *
1788
-        FROM ' . prefixTable('notification') . ' AS n
1789
-        INNER JOIN ' . prefixTable('users') . ' AS u ON (n.user_id = u.id)
1788
+        FROM ' . prefixTable('notification').' AS n
1789
+        INNER JOIN ' . prefixTable('users').' AS u ON (n.user_id = u.id)
1790 1790
         WHERE n.item_id = %i AND n.user_id != %i',
1791 1791
         $item_id,
1792 1792
         $globalsUserId
@@ -1797,7 +1797,7 @@  discard block
 block discarded – undo
1797 1797
         // Get list of changes
1798 1798
         $htmlChanges = '<ul>';
1799 1799
         foreach ($changes as $change) {
1800
-            $htmlChanges .= '<li>' . $change . '</li>';
1800
+            $htmlChanges .= '<li>'.$change.'</li>';
1801 1801
         }
1802 1802
         $htmlChanges .= '</ul>';
1803 1803
         // send email
@@ -1834,15 +1834,15 @@  discard block
 block discarded – undo
1834 1834
     $path = '';
1835 1835
     foreach ($arbo as $elem) {
1836 1836
         if (empty($path) === true) {
1837
-            $path = htmlspecialchars(stripslashes(htmlspecialchars_decode($elem->title, ENT_QUOTES)), ENT_QUOTES) . ' ';
1837
+            $path = htmlspecialchars(stripslashes(htmlspecialchars_decode($elem->title, ENT_QUOTES)), ENT_QUOTES).' ';
1838 1838
         } else {
1839
-            $path .= '&#8594; ' . htmlspecialchars(stripslashes(htmlspecialchars_decode($elem->title, ENT_QUOTES)), ENT_QUOTES);
1839
+            $path .= '&#8594; '.htmlspecialchars(stripslashes(htmlspecialchars_decode($elem->title, ENT_QUOTES)), ENT_QUOTES);
1840 1840
         }
1841 1841
     }
1842 1842
 
1843 1843
     // Build text to show user
1844 1844
     if (empty($label) === false) {
1845
-        return empty($path) === true ? addslashes($label) : addslashes($label) . ' (' . $path . ')';
1845
+        return empty($path) === true ? addslashes($label) : addslashes($label).' ('.$path.')';
1846 1846
     }
1847 1847
     return empty($path) === true ? '' : $path;
1848 1848
 }
@@ -1899,7 +1899,7 @@  discard block
 block discarded – undo
1899 1899
  */
1900 1900
 function handleConfigFile($action, $SETTINGS, $field = null, $value = null)
1901 1901
 {
1902
-    $tp_config_file = $SETTINGS['cpassman_dir'] . '/includes/config/tp.config.php';
1902
+    $tp_config_file = $SETTINGS['cpassman_dir'].'/includes/config/tp.config.php';
1903 1903
 
1904 1904
     // Load class DB
1905 1905
     loadClasses('DB');
@@ -1907,8 +1907,8 @@  discard block
 block discarded – undo
1907 1907
     if (file_exists($tp_config_file) === false || $action === 'rebuild') {
1908 1908
         // perform a copy
1909 1909
         if (file_exists($tp_config_file)) {
1910
-            if (! copy($tp_config_file, $tp_config_file . '.' . date('Y_m_d_His', time()))) {
1911
-                return "ERROR: Could not copy file '" . $tp_config_file . "'";
1910
+            if (!copy($tp_config_file, $tp_config_file.'.'.date('Y_m_d_His', time()))) {
1911
+                return "ERROR: Could not copy file '".$tp_config_file."'";
1912 1912
             }
1913 1913
         }
1914 1914
 
@@ -1918,11 +1918,11 @@  discard block
 block discarded – undo
1918 1918
         $data[1] = "global \$SETTINGS;\n";
1919 1919
         $data[2] = "\$SETTINGS = array (\n";
1920 1920
         $rows = DB::query(
1921
-            'SELECT * FROM ' . prefixTable('misc') . ' WHERE type=%s',
1921
+            'SELECT * FROM '.prefixTable('misc').' WHERE type=%s',
1922 1922
             'admin'
1923 1923
         );
1924 1924
         foreach ($rows as $record) {
1925
-            array_push($data, "    '" . $record['intitule'] . "' => '" . htmlspecialchars_decode($record['valeur'], ENT_COMPAT) . "',\n");
1925
+            array_push($data, "    '".$record['intitule']."' => '".htmlspecialchars_decode($record['valeur'], ENT_COMPAT)."',\n");
1926 1926
         }
1927 1927
         array_push($data, ");\n");
1928 1928
         $data = array_unique($data);
@@ -1936,15 +1936,15 @@  discard block
 block discarded – undo
1936 1936
                 break;
1937 1937
             }
1938 1938
 
1939
-            if (stristr($line, "'" . $field . "' => '")) {
1940
-                $data[$inc] = "    '" . $field . "' => '" . htmlspecialchars_decode($value ?? '', ENT_COMPAT) . "',\n";
1939
+            if (stristr($line, "'".$field."' => '")) {
1940
+                $data[$inc] = "    '".$field."' => '".htmlspecialchars_decode($value ?? '', ENT_COMPAT)."',\n";
1941 1941
                 $bFound = true;
1942 1942
                 break;
1943 1943
             }
1944 1944
             ++$inc;
1945 1945
         }
1946 1946
         if ($bFound === false) {
1947
-            $data[$inc] = "    '" . $field . "' => '" . htmlspecialchars_decode($value ?? '', ENT_COMPAT). "',\n);\n";
1947
+            $data[$inc] = "    '".$field."' => '".htmlspecialchars_decode($value ?? '', ENT_COMPAT)."',\n);\n";
1948 1948
         }
1949 1949
     }
1950 1950
 
@@ -1974,7 +1974,7 @@  discard block
 block discarded – undo
1974 1974
 {
1975 1975
     global $SETTINGS;
1976 1976
     /* LOAD CPASSMAN SETTINGS */
1977
-    if (! isset($SETTINGS['loaded']) || $SETTINGS['loaded'] !== 1) {
1977
+    if (!isset($SETTINGS['loaded']) || $SETTINGS['loaded'] !== 1) {
1978 1978
         $SETTINGS = [];
1979 1979
         $SETTINGS['duplicate_folder'] = 0;
1980 1980
         //by default, this is set to 0;
@@ -1984,7 +1984,7 @@  discard block
 block discarded – undo
1984 1984
         //by default, this value is set to 5;
1985 1985
         $settings = [];
1986 1986
         $rows = DB::query(
1987
-            'SELECT * FROM ' . prefixTable('misc') . ' WHERE type=%s_type OR type=%s_type2',
1987
+            'SELECT * FROM '.prefixTable('misc').' WHERE type=%s_type OR type=%s_type2',
1988 1988
             [
1989 1989
                 'type' => 'admin',
1990 1990
                 'type2' => 'settings',
@@ -2016,7 +2016,7 @@  discard block
 block discarded – undo
2016 2016
     $source_cf = [];
2017 2017
     $rows = DB::QUERY(
2018 2018
         'SELECT id_category
2019
-            FROM ' . prefixTable('categories_folders') . '
2019
+            FROM ' . prefixTable('categories_folders').'
2020 2020
             WHERE id_folder = %i',
2021 2021
         $source_id
2022 2022
     );
@@ -2027,7 +2027,7 @@  discard block
 block discarded – undo
2027 2027
     $target_cf = [];
2028 2028
     $rows = DB::QUERY(
2029 2029
         'SELECT id_category
2030
-            FROM ' . prefixTable('categories_folders') . '
2030
+            FROM ' . prefixTable('categories_folders').'
2031 2031
             WHERE id_folder = %i',
2032 2032
         $target_id
2033 2033
     );
@@ -2245,7 +2245,7 @@  discard block
 block discarded – undo
2245 2245
     int  $dirPerm = 0755
2246 2246
 ) {
2247 2247
     // Check if the path exists
2248
-    if (! file_exists($path)) {
2248
+    if (!file_exists($path)) {
2249 2249
         return false;
2250 2250
     }
2251 2251
 
@@ -2298,7 +2298,7 @@  discard block
 block discarded – undo
2298 2298
     // Load item data
2299 2299
     $data = DB::queryFirstRow(
2300 2300
         'SELECT id_tree
2301
-        FROM ' . prefixTable('items') . '
2301
+        FROM ' . prefixTable('items').'
2302 2302
         WHERE id = %i',
2303 2303
         $item_id
2304 2304
     );
@@ -2361,7 +2361,7 @@  discard block
 block discarded – undo
2361 2361
         }
2362 2362
         $host .= substr(explode(".", $email[1])[0], -1, 1);
2363 2363
     }
2364
-    $email = $name . "@" . $host . "." . explode(".", $email[1])[1];
2364
+    $email = $name."@".$host.".".explode(".", $email[1])[1];
2365 2365
     return $email;
2366 2366
 }
2367 2367
 
@@ -2384,7 +2384,7 @@  discard block
 block discarded – undo
2384 2384
     
2385 2385
     // Insert log in DB
2386 2386
     return DB::query(
2387
-        'SELECT ' . $fields . '
2387
+        'SELECT '.$fields.'
2388 2388
         FROM ' . prefixTable($table)
2389 2389
     );
2390 2390
 }
@@ -2399,11 +2399,11 @@  discard block
 block discarded – undo
2399 2399
 function formatSizeUnits(int $bytes): string
2400 2400
 {
2401 2401
     if ($bytes >= 1073741824) {
2402
-        $bytes = number_format($bytes / 1073741824, 2) . ' GB';
2402
+        $bytes = number_format($bytes / 1073741824, 2).' GB';
2403 2403
     } elseif ($bytes >= 1048576) {
2404
-        $bytes = number_format($bytes / 1048576, 2) . ' MB';
2404
+        $bytes = number_format($bytes / 1048576, 2).' MB';
2405 2405
     } elseif ($bytes >= 1024) {
2406
-        $bytes = number_format($bytes / 1024, 2) . ' KB';
2406
+        $bytes = number_format($bytes / 1024, 2).' KB';
2407 2407
     } elseif ($bytes > 1) {
2408 2408
         $bytes .= ' bytes';
2409 2409
     } elseif ($bytes === 1) {
@@ -2648,14 +2648,14 @@  discard block
 block discarded – undo
2648 2648
 
2649 2649
         // Encrypt the file content
2650 2650
         $plaintext = file_get_contents(
2651
-            filter_var($fileInPath . '/' . $fileInName, FILTER_SANITIZE_URL)
2651
+            filter_var($fileInPath.'/'.$fileInName, FILTER_SANITIZE_URL)
2652 2652
         );
2653 2653
         $ciphertext = $cipher->encrypt($plaintext);
2654 2654
         // Save new file
2655 2655
         $hash = md5($plaintext);
2656
-        $fileOut = $fileInPath . '/' . TP_FILE_PREFIX . $hash;
2656
+        $fileOut = $fileInPath.'/'.TP_FILE_PREFIX.$hash;
2657 2657
         file_put_contents($fileOut, $ciphertext);
2658
-        unlink($fileInPath . '/' . $fileInName);
2658
+        unlink($fileInPath.'/'.$fileInName);
2659 2659
         return [
2660 2660
             'fileHash' => base64_encode($hash),
2661 2661
             'objectKey' => base64_encode($objectKey),
@@ -2676,7 +2676,7 @@  discard block
 block discarded – undo
2676 2676
  */
2677 2677
 function decryptFile(string $fileName, string $filePath, string $key): string
2678 2678
 {
2679
-    if (! defined('FILE_BUFFER_SIZE')) {
2679
+    if (!defined('FILE_BUFFER_SIZE')) {
2680 2680
         define('FILE_BUFFER_SIZE', 128 * 1024);
2681 2681
     }
2682 2682
     
@@ -2692,7 +2692,7 @@  discard block
 block discarded – undo
2692 2692
         $cipher->enableContinuousBuffer();
2693 2693
         $cipher->disablePadding();
2694 2694
         // Get file content
2695
-        $ciphertext = file_get_contents($filePath . '/' . TP_FILE_PREFIX . $fileName);
2695
+        $ciphertext = file_get_contents($filePath.'/'.TP_FILE_PREFIX.$fileName);
2696 2696
         // Decrypt file content and return
2697 2697
         return base64_encode($cipher->decrypt($ciphertext));
2698 2698
     /*} else {
@@ -2775,8 +2775,8 @@  discard block
 block discarded – undo
2775 2775
         // Only create the sharekey for a user
2776 2776
         $user = DB::queryFirstRow(
2777 2777
             'SELECT public_key
2778
-            FROM ' . prefixTable('users') . '
2779
-            WHERE id = ' . (int) $session->get('user-id') . '
2778
+            FROM ' . prefixTable('users').'
2779
+            WHERE id = ' . (int) $session->get('user-id').'
2780 2780
             AND public_key != ""'
2781 2781
         );
2782 2782
 
@@ -2812,10 +2812,9 @@  discard block
 block discarded – undo
2812 2812
         //DB::debugmode(true);
2813 2813
         $users = DB::query(
2814 2814
             'SELECT id, public_key
2815
-            FROM ' . prefixTable('users') . '
2815
+            FROM ' . prefixTable('users').'
2816 2816
             WHERE ' . ($onlyForUser === true ? 
2817
-                'id IN ("' . TP_USER_ID . '","' . $session->get('user-id') . '") ' : 
2818
-                'id NOT IN ("' . OTV_USER_ID . '","' . SSH_USER_ID . '","' . API_USER_ID . '") ') . '
2817
+                'id IN ("'.TP_USER_ID.'","'.$session->get('user-id').'") ' : 'id NOT IN ("'.OTV_USER_ID.'","'.SSH_USER_ID.'","'.API_USER_ID.'") ').'
2819 2818
             AND public_key != ""'
2820 2819
         );
2821 2820
         //DB::debugmode(false);
@@ -2862,7 +2861,7 @@  discard block
 block discarded – undo
2862 2861
 function isBase64(string $str): bool
2863 2862
 {
2864 2863
     $str = (string) trim($str);
2865
-    if (! isset($str[0])) {
2864
+    if (!isset($str[0])) {
2866 2865
         return false;
2867 2866
     }
2868 2867
 
@@ -2935,7 +2934,7 @@  discard block
 block discarded – undo
2935 2934
         $connection->connect();
2936 2935
     } catch (\LdapRecord\Auth\BindException $e) {
2937 2936
         $error = $e->getDetailedError();
2938
-        echo 'Error : '.$error->getErrorCode().' - '.$error->getErrorMessage(). '<br>'.$error->getDiagnosticMessage();
2937
+        echo 'Error : '.$error->getErrorCode().' - '.$error->getErrorMessage().'<br>'.$error->getDiagnosticMessage();
2939 2938
         return false;
2940 2939
     }
2941 2940
 
@@ -2948,7 +2947,7 @@  discard block
 block discarded – undo
2948 2947
         }
2949 2948
     } catch (\LdapRecord\Auth\BindException $e) {
2950 2949
         $error = $e->getDetailedError();
2951
-        echo 'Error : '.$error->getErrorCode().' - '.$error->getErrorMessage(). '<br>'.$error->getDiagnosticMessage();
2950
+        echo 'Error : '.$error->getErrorCode().' - '.$error->getErrorMessage().'<br>'.$error->getDiagnosticMessage();
2952 2951
         return false;
2953 2952
     }
2954 2953
 
@@ -2972,7 +2971,7 @@  discard block
 block discarded – undo
2972 2971
     // expect if personal item
2973 2972
     DB::delete(
2974 2973
         prefixTable('sharekeys_items'),
2975
-        'user_id = %i AND object_id NOT IN (SELECT i.id FROM ' . prefixTable('items') . ' AS i WHERE i.perso = 1)',
2974
+        'user_id = %i AND object_id NOT IN (SELECT i.id FROM '.prefixTable('items').' AS i WHERE i.perso = 1)',
2976 2975
         $userId
2977 2976
     );
2978 2977
     // Remove all item sharekeys files
@@ -2980,8 +2979,8 @@  discard block
 block discarded – undo
2980 2979
         prefixTable('sharekeys_files'),
2981 2980
         'user_id = %i AND object_id NOT IN (
2982 2981
             SELECT f.id 
2983
-            FROM ' . prefixTable('items') . ' AS i 
2984
-            INNER JOIN ' . prefixTable('files') . ' AS f ON f.id_item = i.id
2982
+            FROM ' . prefixTable('items').' AS i 
2983
+            INNER JOIN ' . prefixTable('files').' AS f ON f.id_item = i.id
2985 2984
             WHERE i.perso = 1
2986 2985
         )',
2987 2986
         $userId
@@ -2991,8 +2990,8 @@  discard block
 block discarded – undo
2991 2990
         prefixTable('sharekeys_fields'),
2992 2991
         'user_id = %i AND object_id NOT IN (
2993 2992
             SELECT c.id 
2994
-            FROM ' . prefixTable('items') . ' AS i 
2995
-            INNER JOIN ' . prefixTable('categories_items') . ' AS c ON c.item_id = i.id
2993
+            FROM ' . prefixTable('items').' AS i 
2994
+            INNER JOIN ' . prefixTable('categories_items').' AS c ON c.item_id = i.id
2996 2995
             WHERE i.perso = 1
2997 2996
         )',
2998 2997
         $userId
@@ -3000,13 +2999,13 @@  discard block
 block discarded – undo
3000 2999
     // Remove all item sharekeys logs
3001 3000
     DB::delete(
3002 3001
         prefixTable('sharekeys_logs'),
3003
-        'user_id = %i AND object_id NOT IN (SELECT i.id FROM ' . prefixTable('items') . ' AS i WHERE i.perso = 1)',
3002
+        'user_id = %i AND object_id NOT IN (SELECT i.id FROM '.prefixTable('items').' AS i WHERE i.perso = 1)',
3004 3003
         $userId
3005 3004
     );
3006 3005
     // Remove all item sharekeys suggestions
3007 3006
     DB::delete(
3008 3007
         prefixTable('sharekeys_suggestions'),
3009
-        'user_id = %i AND object_id NOT IN (SELECT i.id FROM ' . prefixTable('items') . ' AS i WHERE i.perso = 1)',
3008
+        'user_id = %i AND object_id NOT IN (SELECT i.id FROM '.prefixTable('items').' AS i WHERE i.perso = 1)',
3010 3009
         $userId
3011 3010
     );
3012 3011
     return false;
@@ -3027,7 +3026,7 @@  discard block
 block discarded – undo
3027 3026
         foreach (DateTimeZone::listIdentifiers() as $timezone) {
3028 3027
             $now->setTimezone(new DateTimeZone($timezone));
3029 3028
             $offsets[] = $offset = $now->getOffset();
3030
-            $timezones[$timezone] = '(' . format_GMT_offset($offset) . ') ' . format_timezone_name($timezone);
3029
+            $timezones[$timezone] = '('.format_GMT_offset($offset).') '.format_timezone_name($timezone);
3031 3030
         }
3032 3031
 
3033 3032
         array_multisort($offsets, $timezones);
@@ -3047,7 +3046,7 @@  discard block
 block discarded – undo
3047 3046
 {
3048 3047
     $hours = intval($offset / 3600);
3049 3048
     $minutes = abs(intval($offset % 3600 / 60));
3050
-    return 'GMT' . ($offset ? sprintf('%+03d:%02d', $hours, $minutes) : '');
3049
+    return 'GMT'.($offset ? sprintf('%+03d:%02d', $hours, $minutes) : '');
3051 3050
 }
3052 3051
 
3053 3052
 /**
@@ -3147,8 +3146,7 @@  discard block
 block discarded – undo
3147 3146
 {
3148 3147
     if (isset($array[$key]) === true
3149 3148
         && (is_int($value) === true ?
3150
-            (int) $array[$key] === $value :
3151
-            (string) $array[$key] === $value)
3149
+            (int) $array[$key] === $value : (string) $array[$key] === $value)
3152 3150
     ) {
3153 3151
         return true;
3154 3152
     }
@@ -3170,8 +3168,7 @@  discard block
 block discarded – undo
3170 3168
 {
3171 3169
     if (isset($var) === false
3172 3170
         || (is_int($value) === true ?
3173
-            (int) $var === $value :
3174
-            (string) $var === $value)
3171
+            (int) $var === $value : (string) $var === $value)
3175 3172
     ) {
3176 3173
         return true;
3177 3174
     }
@@ -3222,7 +3219,7 @@  discard block
 block discarded – undo
3222 3219
  */
3223 3220
 function isSetArrayOfValues(array $arrayOfValues): bool
3224 3221
 {
3225
-    foreach($arrayOfValues as $value) {
3222
+    foreach ($arrayOfValues as $value) {
3226 3223
         if (isset($value) === false) {
3227 3224
             return false;
3228 3225
         }
@@ -3244,7 +3241,7 @@  discard block
 block discarded – undo
3244 3241
     /*PHP8 - integer|string*/$value
3245 3242
 ) : bool
3246 3243
 {
3247
-    foreach($arrayOfVars as $variable) {
3244
+    foreach ($arrayOfVars as $variable) {
3248 3245
         if ($variable !== $value) {
3249 3246
             return false;
3250 3247
         }
@@ -3264,7 +3261,7 @@  discard block
 block discarded – undo
3264 3261
     /*PHP8 - integer|string*/$value
3265 3262
 ) : bool
3266 3263
 {
3267
-    foreach($arrayOfVars as $variable) {
3264
+    foreach ($arrayOfVars as $variable) {
3268 3265
         if ($variable === $value) {
3269 3266
             return true;
3270 3267
         }
@@ -3332,7 +3329,7 @@  discard block
 block discarded – undo
3332 3329
  * @param array     $filters
3333 3330
  * @return array|string
3334 3331
  */
3335
-function dataSanitizer(array $data, array $filters): array|string
3332
+function dataSanitizer(array $data, array $filters): array | string
3336 3333
 {
3337 3334
     // Load Sanitizer library
3338 3335
     $sanitizer = new Sanitizer($data, $filters);
@@ -3361,7 +3358,7 @@  discard block
 block discarded – undo
3361 3358
     // Exists ?
3362 3359
     $userCacheId = DB::queryfirstrow(
3363 3360
         'SELECT increment_id
3364
-        FROM ' . prefixTable('cache_tree') . '
3361
+        FROM ' . prefixTable('cache_tree').'
3365 3362
         WHERE user_id = %i',
3366 3363
         $user_id
3367 3364
     );
@@ -3412,7 +3409,7 @@  discard block
 block discarded – undo
3412 3409
  */
3413 3410
 function pourcentage(float $nombre, float $total, float $pourcentage): float
3414 3411
 { 
3415
-    $resultat = ($nombre/$total) * $pourcentage;
3412
+    $resultat = ($nombre / $total) * $pourcentage;
3416 3413
     return round($resultat);
3417 3414
 }
3418 3415
 
@@ -3442,7 +3439,7 @@  discard block
 block discarded – undo
3442 3439
 
3443 3440
     // Get last folder update
3444 3441
     $lastFolderChange = DB::queryfirstrow(
3445
-        'SELECT valeur FROM ' . prefixTable('misc') . '
3442
+        'SELECT valeur FROM '.prefixTable('misc').'
3446 3443
         WHERE type = %s AND intitule = %s',
3447 3444
         'timestamp',
3448 3445
         'last_folder_change'
@@ -3472,7 +3469,7 @@  discard block
 block discarded – undo
3472 3469
     // Does this user has a tree cache
3473 3470
     $userCacheTree = DB::queryfirstrow(
3474 3471
         'SELECT '.$fieldName.'
3475
-        FROM ' . prefixTable('cache_tree') . '
3472
+        FROM ' . prefixTable('cache_tree').'
3476 3473
         WHERE user_id = %i',
3477 3474
         $session->get('user-id')
3478 3475
     );
@@ -3514,7 +3511,7 @@  discard block
 block discarded – undo
3514 3511
     if (count($folderIds) === 0) {
3515 3512
         $folderIds = DB::queryFirstColumn(
3516 3513
             'SELECT id
3517
-            FROM ' . prefixTable('nested_tree') . '
3514
+            FROM ' . prefixTable('nested_tree').'
3518 3515
             WHERE personal_folder=%i',
3519 3516
             0
3520 3517
         );
@@ -3531,8 +3528,8 @@  discard block
 block discarded – undo
3531 3528
         $rows_tmp = DB::query(
3532 3529
             'SELECT c.id, c.title, c.level, c.type, c.masked, c.order, c.encrypted_data, c.role_visibility, c.is_mandatory,
3533 3530
             f.id_category AS category_id
3534
-            FROM ' . prefixTable('categories_folders') . ' AS f
3535
-            INNER JOIN ' . prefixTable('categories') . ' AS c ON (f.id_category = c.parent_id)
3531
+            FROM ' . prefixTable('categories_folders').' AS f
3532
+            INNER JOIN ' . prefixTable('categories').' AS c ON (f.id_category = c.parent_id)
3536 3533
             WHERE id_folder=%i',
3537 3534
             $folder
3538 3535
         );
@@ -3558,7 +3555,7 @@  discard block
 block discarded – undo
3558 3555
         $valTemp = '';
3559 3556
         $data = DB::queryFirstRow(
3560 3557
             'SELECT valeur
3561
-            FROM ' . prefixTable('misc') . '
3558
+            FROM ' . prefixTable('misc').'
3562 3559
             WHERE type = %s AND intitule=%i',
3563 3560
             'complex',
3564 3561
             $folder
@@ -3575,14 +3572,14 @@  discard block
 block discarded – undo
3575 3572
         $valTemp = '';
3576 3573
         $rows_tmp = DB::query(
3577 3574
             'SELECT t.title
3578
-            FROM ' . prefixTable('roles_values') . ' as v
3579
-            INNER JOIN ' . prefixTable('roles_title') . ' as t ON (v.role_id = t.id)
3575
+            FROM ' . prefixTable('roles_values').' as v
3576
+            INNER JOIN ' . prefixTable('roles_title').' as t ON (v.role_id = t.id)
3580 3577
             WHERE v.folder_id = %i
3581 3578
             GROUP BY title',
3582 3579
             $folder
3583 3580
         );
3584 3581
         foreach ($rows_tmp as $record) {
3585
-            $valTemp .= (empty($valTemp) === true ? '' : ' - ') . $record['title'];
3582
+            $valTemp .= (empty($valTemp) === true ? '' : ' - ').$record['title'];
3586 3583
         }
3587 3584
         $arr_data['visibilityRoles'] = $valTemp;
3588 3585
 
@@ -3615,7 +3612,7 @@  discard block
 block discarded – undo
3615 3612
         // loop on users and check if user has this role
3616 3613
         $rows = DB::query(
3617 3614
             'SELECT id, fonction_id
3618
-            FROM ' . prefixTable('users') . '
3615
+            FROM ' . prefixTable('users').'
3619 3616
             WHERE id != %i AND admin = 0 AND fonction_id IS NOT NULL AND fonction_id != ""',
3620 3617
             $session->get('user-id')
3621 3618
         );
@@ -3647,7 +3644,7 @@  discard block
 block discarded – undo
3647 3644
 
3648 3645
     $val = DB::queryfirstrow(
3649 3646
         'SELECT *
3650
-        FROM ' . prefixTable('users') . '
3647
+        FROM ' . prefixTable('users').'
3651 3648
         WHERE id = %i',
3652 3649
         $userId
3653 3650
     );
@@ -3663,12 +3660,12 @@  discard block
 block discarded – undo
3663 3660
 function upgradeRequired(): bool
3664 3661
 {
3665 3662
     // Get settings.php
3666
-    include_once __DIR__. '/../includes/config/settings.php';
3663
+    include_once __DIR__.'/../includes/config/settings.php';
3667 3664
 
3668 3665
     // Get timestamp in DB
3669 3666
     $val = DB::queryfirstrow(
3670 3667
         'SELECT valeur
3671
-        FROM ' . prefixTable('misc') . '
3668
+        FROM ' . prefixTable('misc').'
3672 3669
         WHERE type = %s AND intitule = %s',
3673 3670
         'admin',
3674 3671
         'upgrade_timestamp'
@@ -3723,7 +3720,7 @@  discard block
 block discarded – undo
3723 3720
     // prepapre background tasks for item keys generation        
3724 3721
     $userTP = DB::queryFirstRow(
3725 3722
         'SELECT pw, public_key, private_key
3726
-        FROM ' . prefixTable('users') . '
3723
+        FROM ' . prefixTable('users').'
3727 3724
         WHERE id = %i',
3728 3725
         TP_USER_ID
3729 3726
     );
@@ -3748,7 +3745,7 @@  discard block
 block discarded – undo
3748 3745
         }
3749 3746
 
3750 3747
         // Generate new keys
3751
-        if ($user_self_change === true && empty($recovery_public_key) === false && empty($recovery_private_key) === false){
3748
+        if ($user_self_change === true && empty($recovery_public_key) === false && empty($recovery_private_key) === false) {
3752 3749
             $userKeys = [
3753 3750
                 'public_key' => $recovery_public_key,
3754 3751
                 'private_key_clear' => $recovery_private_key,
@@ -3788,8 +3785,8 @@  discard block
 block discarded – undo
3788 3785
                 'process_type' => 'create_user_keys',
3789 3786
                 'arguments' => json_encode([
3790 3787
                     'new_user_id' => (int) $userId,
3791
-                    'new_user_pwd' => cryption($passwordClear, '','encrypt')['string'],
3792
-                    'new_user_code' => cryption(empty($encryptionKey) === true ? uniqidReal(20) : $encryptionKey, '','encrypt')['string'],
3788
+                    'new_user_pwd' => cryption($passwordClear, '', 'encrypt')['string'],
3789
+                    'new_user_code' => cryption(empty($encryptionKey) === true ? uniqidReal(20) : $encryptionKey, '', 'encrypt')['string'],
3793 3790
                     'owner_id' => (int) TP_USER_ID,
3794 3791
                     'creator_pwd' => $userTP['pw'],
3795 3792
                     'send_email' => $sendEmailToUser === true ? 1 : 0,
@@ -4085,7 +4082,7 @@  discard block
 block discarded – undo
4085 4082
  * @param integer $user_id
4086 4083
  * @return void
4087 4084
  */
4088
-function purgeUnnecessaryKeys(bool $allUsers = true, int $user_id=0)
4085
+function purgeUnnecessaryKeys(bool $allUsers = true, int $user_id = 0)
4089 4086
 {
4090 4087
     if ($allUsers === true) {
4091 4088
         // Load class DB
@@ -4095,7 +4092,7 @@  discard block
 block discarded – undo
4095 4092
 
4096 4093
         $users = DB::query(
4097 4094
             'SELECT id
4098
-            FROM ' . prefixTable('users') . '
4095
+            FROM ' . prefixTable('users').'
4099 4096
             WHERE id NOT IN ('.OTV_USER_ID.', '.TP_USER_ID.', '.SSH_USER_ID.', '.API_USER_ID.')
4100 4097
             ORDER BY login ASC'
4101 4098
         );
@@ -4113,7 +4110,7 @@  discard block
 block discarded – undo
4113 4110
  * @param integer $user_id
4114 4111
  * @return void
4115 4112
  */
4116
-function purgeUnnecessaryKeysForUser(int $user_id=0)
4113
+function purgeUnnecessaryKeysForUser(int $user_id = 0)
4117 4114
 {
4118 4115
     if ($user_id === 0) {
4119 4116
         return;
@@ -4124,8 +4121,8 @@  discard block
 block discarded – undo
4124 4121
 
4125 4122
     $personalItems = DB::queryFirstColumn(
4126 4123
         'SELECT id
4127
-        FROM ' . prefixTable('items') . ' AS i
4128
-        INNER JOIN ' . prefixTable('log_items') . ' AS li ON li.id_item = i.id
4124
+        FROM ' . prefixTable('items').' AS i
4125
+        INNER JOIN ' . prefixTable('log_items').' AS li ON li.id_item = i.id
4129 4126
         WHERE i.perso = 1 AND li.action = "at_creation" AND li.id_user IN (%i, '.TP_USER_ID.')',
4130 4127
         $user_id
4131 4128
     );
@@ -4174,7 +4171,7 @@  discard block
 block discarded – undo
4174 4171
     // Check if user exists
4175 4172
     $userInfo = DB::queryFirstRow(
4176 4173
         'SELECT pw, public_key, private_key, login, name
4177
-        FROM ' . prefixTable('users') . '
4174
+        FROM ' . prefixTable('users').'
4178 4175
         WHERE id = %i',
4179 4176
         $userId
4180 4177
     );
@@ -4184,7 +4181,7 @@  discard block
 block discarded – undo
4184 4181
 
4185 4182
         // Prepare file content
4186 4183
         $export_value = file_get_contents(__DIR__."/../includes/core/teampass_ascii.txt")."\n".
4187
-            "Generation date: ".date($SETTINGS['date_format'] . ' ' . $SETTINGS['time_format'], $now)."\n\n".
4184
+            "Generation date: ".date($SETTINGS['date_format'].' '.$SETTINGS['time_format'], $now)."\n\n".
4188 4185
             "RECOVERY KEYS - Not to be shared - To be store safely\n\n".
4189 4186
             "Public Key:\n".$userInfo['public_key']."\n\n".
4190 4187
             "Private Key:\n".decryptPrivateKey($session->get('user-password'), $userInfo['private_key'])."\n\n";
@@ -4207,7 +4204,7 @@  discard block
 block discarded – undo
4207 4204
         return prepareExchangedData(
4208 4205
             array(
4209 4206
                 'error' => false,
4210
-                'datetime' => date($SETTINGS['date_format'] . ' ' . $SETTINGS['time_format'], $now),
4207
+                'datetime' => date($SETTINGS['date_format'].' '.$SETTINGS['time_format'], $now),
4211 4208
                 'timestamp' => $now,
4212 4209
                 'content' => base64_encode($export_value),
4213 4210
                 'login' => $userInfo['login'],
@@ -4233,8 +4230,8 @@  discard block
 block discarded – undo
4233 4230
  */
4234 4231
 function loadClasses(string $className = ''): void
4235 4232
 {
4236
-    require_once __DIR__. '/../includes/config/include.php';
4237
-    require_once __DIR__. '/../includes/config/settings.php';
4233
+    require_once __DIR__.'/../includes/config/include.php';
4234
+    require_once __DIR__.'/../includes/config/settings.php';
4238 4235
     require_once __DIR__.'/../vendor/autoload.php';
4239 4236
 
4240 4237
     if (defined('DB_PASSWD_CLEAR') === false) {
Please login to merge, or discard this patch.
sources/identify.php 1 patch
Spacing   +47 added lines, -47 removed lines patch added patch discarded remove patch
@@ -100,7 +100,7 @@  discard block
 block discarded – undo
100 100
 if ($checkUserAccess->checkSession() === false) {
101 101
     // Not allowed page
102 102
     $session->set('system-error_code', ERR_NOT_ALLOWED);
103
-    include $SETTINGS['cpassman_dir'] . '/error.php';
103
+    include $SETTINGS['cpassman_dir'].'/error.php';
104 104
     exit;
105 105
 }
106 106
 
@@ -135,7 +135,7 @@  discard block
 block discarded – undo
135 135
      * @param array $SETTINGS
136 136
      * @return bool|string
137 137
      */
138
-    function handleAuthAttempts($post_data, $SETTINGS): bool|string
138
+    function handleAuthAttempts($post_data, $SETTINGS): bool | string
139 139
     {
140 140
         $session = SessionManager::getSession();
141 141
         $lang = new Language();
@@ -262,18 +262,18 @@  discard block
 block discarded – undo
262 262
     }
263 263
 
264 264
     // Check if Duo auth is in progress and pass the pw and login back to the standard login process
265
-    if(
265
+    if (
266 266
         isKeyExistingAndEqual('duo', 1, $SETTINGS) === true
267 267
         && $dataReceived['user_2fa_selection'] === 'duo'
268 268
         && $session->get('user-duo_status') === 'IN_PROGRESS'
269 269
         && !empty($dataReceived['duo_state'])
270
-    ){
270
+    ) {
271 271
         $key = hash('sha256', $dataReceived['duo_state']);
272 272
         $iv = substr(hash('sha256', $dataReceived['duo_state']), 0, 16);
273 273
         $duo_data_dec = openssl_decrypt(base64_decode($session->get('user-duo_status')), 'AES-256-CBC', $key, 0, $iv);
274 274
         // Clear the data from the Duo process to continue clean with the standard login process
275
-        $session->set('user-duo_data','');
276
-        if($duo_data_dec === false){
275
+        $session->set('user-duo_data', '');
276
+        if ($duo_data_dec === false) {
277 277
             echo prepareExchangedData(
278 278
                 [
279 279
                     'error' => true,
@@ -288,7 +288,7 @@  discard block
 block discarded – undo
288 288
         $dataReceived['login'] = $duo_data['duo_login'];
289 289
     }
290 290
 
291
-    if(isset($dataReceived['pw']) === false || isset($dataReceived['login']) === false) {
291
+    if (isset($dataReceived['pw']) === false || isset($dataReceived['login']) === false) {
292 292
         echo json_encode([
293 293
             'data' => prepareExchangedData(
294 294
                 [
@@ -559,7 +559,7 @@  discard block
 block discarded – undo
559 559
         }
560 560
         // Append with roles from AD groups
561 561
         if (is_null($userInfo['roles_from_ad_groups']) === false) {
562
-            $userInfo['fonction_id'] = empty($userInfo['fonction_id'])  === true ? $userInfo['roles_from_ad_groups'] : $userInfo['fonction_id']. ';' . $userInfo['roles_from_ad_groups'];
562
+            $userInfo['fonction_id'] = empty($userInfo['fonction_id']) === true ? $userInfo['roles_from_ad_groups'] : $userInfo['fonction_id'].';'.$userInfo['roles_from_ad_groups'];
563 563
         }
564 564
         // store
565 565
         $session->set('user-roles', $userInfo['fonction_id']);
@@ -571,7 +571,7 @@  discard block
 block discarded – undo
571 571
         if (count($session->get('user-roles_array')) > 0) {
572 572
             $rolesList = DB::query(
573 573
                 'SELECT id, title, complexity
574
-                FROM ' . prefixTable('roles_title') . '
574
+                FROM ' . prefixTable('roles_title').'
575 575
                 WHERE id IN %li',
576 576
                 $session->get('user-roles_array')
577 577
             );
@@ -617,7 +617,7 @@  discard block
 block discarded – undo
617 617
             if ($adjustPermissions) {
618 618
                 $session->set('user-admin', (int) $userInfo['admin']);
619 619
                 $session->set('user-manager', (int) $userInfo['gestionnaire']);
620
-                $session->set('user-can_manage_all_users',(int)  $userInfo['can_manage_all_users']);
620
+                $session->set('user-can_manage_all_users', (int) $userInfo['can_manage_all_users']);
621 621
                 $session->set('user-read_only', (int) $userInfo['read_only']);
622 622
                 DB::update(
623 623
                     prefixTable('users'),
@@ -689,10 +689,10 @@  discard block
 block discarded – undo
689 689
         $session->set('user-latest_items_tab', []);
690 690
         $session->set('user-nb_roles', 0);
691 691
         foreach ($session->get('user-latest_items') as $item) {
692
-            if (! empty($item)) {
692
+            if (!empty($item)) {
693 693
                 $dataLastItems = DB::queryFirstRow(
694 694
                     'SELECT id,label,id_tree
695
-                    FROM ' . prefixTable('items') . '
695
+                    FROM ' . prefixTable('items').'
696 696
                     WHERE id=%i',
697 697
                     $item
698 698
                 );
@@ -701,7 +701,7 @@  discard block
 block discarded – undo
701 701
                     [
702 702
                         'id' => $item,
703 703
                         'label' => $dataLastItems['label'],
704
-                        'url' => 'index.php?page=items&amp;group=' . $dataLastItems['id_tree'] . '&amp;id=' . $item,
704
+                        'url' => 'index.php?page=items&amp;group='.$dataLastItems['id_tree'].'&amp;id='.$item,
705 705
                     ],
706 706
                     'add'
707 707
                 );
@@ -711,7 +711,7 @@  discard block
 block discarded – undo
711 711
         // Get cahce tree info
712 712
         $cacheTreeData = DB::queryFirstRow(
713 713
             'SELECT visible_folders
714
-            FROM ' . prefixTable('cache_tree') . '
714
+            FROM ' . prefixTable('cache_tree').'
715 715
             WHERE user_id=%i',
716 716
             (int) $session->get('user-id')
717 717
         );
@@ -743,7 +743,7 @@  discard block
 block discarded – undo
743 743
             && (int) $sessionAdmin !== 1
744 744
         ) {
745 745
             // get all Admin users
746
-            $val = DB::queryfirstrow('SELECT email FROM ' . prefixTable('users') . " WHERE admin = %i and email != ''", 1);
746
+            $val = DB::queryfirstrow('SELECT email FROM '.prefixTable('users')." WHERE admin = %i and email != ''", 1);
747 747
             if (DB::count() > 0) {
748 748
                 // Add email to table
749 749
                 prepareSendingEmail(
@@ -755,7 +755,7 @@  discard block
 block discarded – undo
755 755
                             '#tp_time#',
756 756
                         ],
757 757
                         [
758
-                            ' ' . $session->get('user-login') . ' (IP: ' . getClientIpServer() . ')',
758
+                            ' '.$session->get('user-login').' (IP: '.getClientIpServer().')',
759 759
                             date($SETTINGS['date_format'], (int) $session->get('user-last_connection')),
760 760
                             date($SETTINGS['time_format'], (int) $session->get('user-last_connection')),
761 761
                         ],
@@ -903,7 +903,7 @@  discard block
 block discarded – undo
903 903
 {
904 904
     $rows = DB::query(
905 905
         'SELECT date
906
-        FROM ' . prefixTable('log_system') . "
906
+        FROM ' . prefixTable('log_system')."
907 907
         WHERE field_1 = %s
908 908
         AND type = 'failed_auth'
909 909
         AND label = 'password_is_not_correct'
@@ -917,7 +917,7 @@  discard block
 block discarded – undo
917 917
         foreach ($rows as $record) {
918 918
             array_push(
919 919
                 $arrAttempts,
920
-                date($SETTINGS['date_format'] . ' ' . $SETTINGS['time_format'], (int) $record['date'])
920
+                date($SETTINGS['date_format'].' '.$SETTINGS['time_format'], (int) $record['date'])
921 921
             );
922 922
         }
923 923
     }
@@ -971,7 +971,7 @@  discard block
 block discarded – undo
971 971
     $ldapConnection
972 972
 ) : bool
973 973
 {
974
-    include_once $SETTINGS['cpassman_dir'] . '/sources/main.functions.php';
974
+    include_once $SETTINGS['cpassman_dir'].'/sources/main.functions.php';
975 975
 
976 976
     if ((int) $userInfoDisabled === 1) {
977 977
         return false;
@@ -1179,7 +1179,7 @@  discard block
 block discarded – undo
1179 1179
                 $openLdapExtra = new OpenLdapExtra();
1180 1180
                 break;
1181 1181
             default:
1182
-                throw new Exception("Unsupported LDAP type: " . $SETTINGS['ldap_type']);
1182
+                throw new Exception("Unsupported LDAP type: ".$SETTINGS['ldap_type']);
1183 1183
         }
1184 1184
     } catch (Exception $e) {
1185 1185
         return [
@@ -1192,7 +1192,7 @@  discard block
 block discarded – undo
1192 1192
         // 2- Get user info from AD
1193 1193
         // We want to isolate attribute ldap_user_attribute or mostly samAccountName
1194 1194
         $userADInfos = $ldapConnection->query()
1195
-            ->where((isset($SETTINGS['ldap_user_attribute']) ===true && empty($SETTINGS['ldap_user_attribute']) === false) ? $SETTINGS['ldap_user_attribute'] : 'samaccountname', '=', $username)
1195
+            ->where((isset($SETTINGS['ldap_user_attribute']) === true && empty($SETTINGS['ldap_user_attribute']) === false) ? $SETTINGS['ldap_user_attribute'] : 'samaccountname', '=', $username)
1196 1196
             ->firstOrFail();
1197 1197
 
1198 1198
         // Is user enabled? Only ActiveDirectory
@@ -1211,7 +1211,7 @@  discard block
 block discarded – undo
1211 1211
         // For OpenLDAP and others, we use attribute dn
1212 1212
         $userAuthAttempt = $ldapConnection->auth()->attempt(
1213 1213
             $SETTINGS['ldap_type'] === 'ActiveDirectory' ?
1214
-                $userADInfos['userprincipalname'][0] :  // refering to https://ldaprecord.com/docs/core/v2/authentication#basic-authentication
1214
+                $userADInfos['userprincipalname'][0] : // refering to https://ldaprecord.com/docs/core/v2/authentication#basic-authentication
1215 1215
                 $userADInfos['dn'],
1216 1216
             $passwordClear
1217 1217
         );
@@ -1228,7 +1228,7 @@  discard block
 block discarded – undo
1228 1228
         $error = $e->getDetailedError();
1229 1229
         return [
1230 1230
             'error' => true,
1231
-            'message' => $lang->get('error')." - ".(isset($error) === true ? $error->getErrorCode()." - ".$error->getErrorMessage(). "<br>".$error->getDiagnosticMessage() : $e),
1231
+            'message' => $lang->get('error')." - ".(isset($error) === true ? $error->getErrorCode()." - ".$error->getErrorMessage()."<br>".$error->getDiagnosticMessage() : $e),
1232 1232
 
1233 1233
         ];
1234 1234
     }
@@ -1293,7 +1293,7 @@  discard block
 block discarded – undo
1293 1293
         // error
1294 1294
         return [
1295 1295
             'error' => true,
1296
-            'message' => "Error: Unsupported LDAP type: " . $SETTINGS['ldap_type'],
1296
+            'message' => "Error: Unsupported LDAP type: ".$SETTINGS['ldap_type'],
1297 1297
         ];
1298 1298
     }
1299 1299
     
@@ -1328,12 +1328,12 @@  discard block
 block discarded – undo
1328 1328
     if (isset($SETTINGS['enable_ad_users_with_ad_groups']) === true && (int) $SETTINGS['enable_ad_users_with_ad_groups'] === 1) {
1329 1329
         // Get user groups from AD
1330 1330
         $user_ad_groups = [];
1331
-        foreach($groups as $group) {
1331
+        foreach ($groups as $group) {
1332 1332
             //print_r($group);
1333 1333
             // get relation role id for AD group
1334 1334
             $role = DB::queryFirstRow(
1335 1335
                 'SELECT lgr.role_id
1336
-                FROM ' . prefixTable('ldap_groups_roles') . ' AS lgr
1336
+                FROM ' . prefixTable('ldap_groups_roles').' AS lgr
1337 1337
                 WHERE lgr.ldap_group_id = %i',
1338 1338
                 $group
1339 1339
             );
@@ -1482,7 +1482,7 @@  discard block
 block discarded – undo
1482 1482
     }
1483 1483
 
1484 1484
     // Now check yubico validity
1485
-    include_once $SETTINGS['cpassman_dir'] . '/includes/libraries/Authentication/Yubico/Yubico.php';
1485
+    include_once $SETTINGS['cpassman_dir'].'/includes/libraries/Authentication/Yubico/Yubico.php';
1486 1486
     $yubi = new Auth_Yubico($yubico_user_id, $yubico_user_key);
1487 1487
     $auth = $yubi->verify($yubico_key);
1488 1488
     //, null, null, null, 60
@@ -1636,7 +1636,7 @@  discard block
 block discarded – undo
1636 1636
             $mfaMessage = $lang->get('ga_flash_qr_and_login');
1637 1637
             // generate new QR
1638 1638
             $new_2fa_qr = $tfa->getQRCodeImageAsDataUri(
1639
-                'Teampass - ' . $username,
1639
+                'Teampass - '.$username,
1640 1640
                 $userInfo['ga']
1641 1641
             );
1642 1642
             // clear temporary code from DB
@@ -1649,7 +1649,7 @@  discard block
 block discarded – undo
1649 1649
                 $userInfo['id']
1650 1650
             );
1651 1651
             $firstTime = [
1652
-                'value' => '<img src="' . $new_2fa_qr . '">',
1652
+                'value' => '<img src="'.$new_2fa_qr.'">',
1653 1653
                 'user_admin' => isset($sessionAdmin) ? (int) $sessionAdmin : '',
1654 1654
                 'initial_url' => isset($sessionUrl) === true ? $sessionUrl : '',
1655 1655
                 'pwd_attempts' => (int) $sessionPwdAttempts,
@@ -1805,7 +1805,7 @@  discard block
 block discarded – undo
1805 1805
         }*/
1806 1806
         return [
1807 1807
             'error' => true,
1808
-            'message' => $duo_error . $lang->get('duo_error_check_config'),
1808
+            'message' => $duo_error.$lang->get('duo_error_check_config'),
1809 1809
             'pwd_attempts' => (int) $sessionPwdAttempts,
1810 1810
             'debug_message' => $e->getMessage(),
1811 1811
             'proceedIdentification' => false,
@@ -1821,7 +1821,7 @@  discard block
 block discarded – undo
1821 1821
         } catch (DuoException $e) {
1822 1822
             return [
1823 1823
                 'error' => true,
1824
-                'message' => $duo_error . $lang->get('duo_error_url'),
1824
+                'message' => $duo_error.$lang->get('duo_error_url'),
1825 1825
                 'pwd_attempts' => (int) $sessionPwdAttempts,
1826 1826
                 'debug_message' => $e->getMessage(),
1827 1827
                 'proceedIdentification' => false,
@@ -1829,7 +1829,7 @@  discard block
 block discarded – undo
1829 1829
         }
1830 1830
         
1831 1831
         // Somethimes Duo return success but fail to return a URL, double check if the URL has been created
1832
-        if (!empty($duo_redirect_url) && isset($duo_redirect_url) && filter_var($duo_redirect_url,FILTER_SANITIZE_URL)) {
1832
+        if (!empty($duo_redirect_url) && isset($duo_redirect_url) && filter_var($duo_redirect_url, FILTER_SANITIZE_URL)) {
1833 1833
             // Since Duo Universal requires a redirect, let's store some info when the user get's back after completing the Duo prompt
1834 1834
             $key = hash('sha256', $duo_state);
1835 1835
             $iv = substr(hash('sha256', $duo_state), 0, 16);
@@ -1857,7 +1857,7 @@  discard block
 block discarded – undo
1857 1857
         } else {
1858 1858
             return [
1859 1859
                 'error' => true,
1860
-                'message' => $duo_error . $lang->get('duo_error_url'),
1860
+                'message' => $duo_error.$lang->get('duo_error_url'),
1861 1861
                 'pwd_attempts' => (int) $sessionPwdAttempts,
1862 1862
                 'proceedIdentification' => false,
1863 1863
             ];
@@ -1878,8 +1878,8 @@  discard block
 block discarded – undo
1878 1878
         // return the response (which should be the user name)
1879 1879
         if ($decoded_token['preferred_username'] === $username) {
1880 1880
             $session->set('user-duo_status', 'COMPLET');
1881
-            $session->set('user-duo_state','');
1882
-            $session->set('user-duo_data','');
1881
+            $session->set('user-duo_state', '');
1882
+            $session->set('user-duo_data', '');
1883 1883
             $session->set('user-login', $username);
1884 1884
 
1885 1885
             return [
@@ -1890,9 +1890,9 @@  discard block
 block discarded – undo
1890 1890
             ];
1891 1891
         } else {
1892 1892
             // Something wrong, username from the original Duo request is different than the one received now
1893
-            $session->set('user-duo_status','');
1894
-            $session->set('user-duo_state','');
1895
-            $session->set('user-duo_data','');
1893
+            $session->set('user-duo_status', '');
1894
+            $session->set('user-duo_state', '');
1895
+            $session->set('user-duo_data', '');
1896 1896
 
1897 1897
             return [
1898 1898
                 'error' => true,
@@ -1903,9 +1903,9 @@  discard block
 block discarded – undo
1903 1903
         }
1904 1904
     }
1905 1905
     // If we are here something wrong
1906
-    $session->set('user-duo_status','');
1907
-    $session->set('user-duo_state','');
1908
-    $session->set('user-duo_data','');
1906
+    $session->set('user-duo_status', '');
1907
+    $session->set('user-duo_state', '');
1908
+    $session->set('user-duo_data', '');
1909 1909
     return [
1910 1910
         'error' => true,
1911 1911
         'message' => $lang->get('duo_login_mismatch'),
@@ -2061,8 +2061,8 @@  discard block
 block discarded – undo
2061 2061
     public function get_user_info($login, $enable_ad_user_auto_creation) {
2062 2062
         $data = DB::queryFirstRow(
2063 2063
             'SELECT u.*, a.value AS api_key
2064
-            FROM ' . prefixTable('users') . ' AS u
2065
-            LEFT JOIN ' . prefixTable('api') . ' AS a ON (u.id = a.user_id)
2064
+            FROM ' . prefixTable('users').' AS u
2065
+            LEFT JOIN ' . prefixTable('api').' AS a ON (u.id = a.user_id)
2066 2066
             WHERE login = %s AND deleted_at IS NULL',
2067 2067
             $login
2068 2068
         );
@@ -2412,15 +2412,15 @@  discard block
 block discarded – undo
2412 2412
 
2413 2413
             if ($ret['error'] !== false) {
2414 2414
                 logEvents($SETTINGS, 'failed_auth', 'bad_duo_mfa', '', stripslashes($username), stripslashes($username));
2415
-                $session->set('user-duo_status','');
2416
-                $session->set('user-duo_state','');
2417
-                $session->set('user-duo_data','');
2415
+                $session->set('user-duo_status', '');
2416
+                $session->set('user-duo_state', '');
2417
+                $session->set('user-duo_data', '');
2418 2418
                 return [
2419 2419
                     'error' => true,
2420 2420
                     'mfaData' => $ret,
2421 2421
                     'mfaQRCodeInfos' => false,
2422 2422
                 ];
2423
-            } else if ($ret['duo_url_ready'] === true){
2423
+            } else if ($ret['duo_url_ready'] === true) {
2424 2424
                 return [
2425 2425
                     'error' => false,
2426 2426
                     'mfaData' => $ret,
Please login to merge, or discard this patch.