@@ -70,7 +70,7 @@ discard block |
||
70 | 70 | ) { |
71 | 71 | // Not allowed page |
72 | 72 | $_SESSION['error']['code'] = ERR_NOT_ALLOWED; |
73 | - include $SETTINGS['cpassman_dir'] . '/error.php'; |
|
73 | + include $SETTINGS['cpassman_dir'].'/error.php'; |
|
74 | 74 | exit; |
75 | 75 | } |
76 | 76 | |
@@ -908,15 +908,15 @@ discard block |
||
908 | 908 | //col1 |
909 | 909 | $sOutput .= '"<span data-done=\"'.$record['is_in_progress'].'\" data-type=\"'.$record['process_type'].'\" data-process-id=\"'.$record['increment_id'].'\"></span>", '; |
910 | 910 | //col2 |
911 | - $sOutput .= '"'.date($SETTINGS['date_format'] . ' ' . $SETTINGS['time_format'], (int) $record['created_at']).'", '; |
|
911 | + $sOutput .= '"'.date($SETTINGS['date_format'].' '.$SETTINGS['time_format'], (int) $record['created_at']).'", '; |
|
912 | 912 | //col3 |
913 | - $sOutput .= '"'.($record['updated_at'] === '' ? '-' : date($SETTINGS['date_format'] . ' ' . $SETTINGS['time_format'], (int) $record['updated_at'])).'", '; |
|
913 | + $sOutput .= '"'.($record['updated_at'] === '' ? '-' : date($SETTINGS['date_format'].' '.$SETTINGS['time_format'], (int) $record['updated_at'])).'", '; |
|
914 | 914 | //col4 |
915 | 915 | $sOutput .= '"'.$record['process_type'].'", '; |
916 | 916 | // col5 |
917 | 917 | if (in_array($record['process_type'], array('create_user_keys', 'item_copy')) === true) { |
918 | 918 | $data_user = DB::queryfirstrow( |
919 | - 'SELECT name, lastname FROM ' . prefixTable('users') . ' |
|
919 | + 'SELECT name, lastname FROM '.prefixTable('users').' |
|
920 | 920 | WHERE id = %i', |
921 | 921 | json_decode($record['arguments'], true)['new_user_id'] |
922 | 922 | ); |
@@ -999,13 +999,12 @@ discard block |
||
999 | 999 | //col1 |
1000 | 1000 | $sOutput .= '"", '; |
1001 | 1001 | //col2 |
1002 | - $sOutput .= '"'.date($SETTINGS['date_format'] . ' ' . $SETTINGS['time_format'], (int) $record['created_at']).'", '; |
|
1002 | + $sOutput .= '"'.date($SETTINGS['date_format'].' '.$SETTINGS['time_format'], (int) $record['created_at']).'", '; |
|
1003 | 1003 | //col3 |
1004 | 1004 | $sOutput .= is_null($record['started_at']) === false ? |
1005 | - ('"'.date($SETTINGS['date_format'] . ' ' . $SETTINGS['time_format'], (int) $record['started_at']).'", ') : |
|
1006 | - ('"'.date($SETTINGS['date_format'] . ' ' . $SETTINGS['time_format'], (int) $record['created_at']).'", '); |
|
1005 | + ('"'.date($SETTINGS['date_format'].' '.$SETTINGS['time_format'], (int) $record['started_at']).'", ') : ('"'.date($SETTINGS['date_format'].' '.$SETTINGS['time_format'], (int) $record['created_at']).'", '); |
|
1007 | 1006 | //col4 |
1008 | - $sOutput .= '"'.date($SETTINGS['date_format'] . ' ' . $SETTINGS['time_format'], (int) $record['finished_at']).'", '; |
|
1007 | + $sOutput .= '"'.date($SETTINGS['date_format'].' '.$SETTINGS['time_format'], (int) $record['finished_at']).'", '; |
|
1009 | 1008 | // col7 |
1010 | 1009 | $sOutput .= '"'.gmdate('H:i:s', (int) $record['finished_at'] - (is_null($record['started_at']) === false ? (int) $record['started_at'] : (int) $record['created_at'])).'",'; |
1011 | 1010 | //col5 |
@@ -1023,7 +1022,7 @@ discard block |
||
1023 | 1022 | $newUserId = json_decode($record['arguments'], true)['new_user_id']; |
1024 | 1023 | if ($record['process_type'] === 'create_user_keys' && is_null($newUserId) === false && empty($newUserId) === false) { |
1025 | 1024 | $data_user = DB::queryfirstrow( |
1026 | - 'SELECT name, lastname, login FROM ' . prefixTable('users') . ' |
|
1025 | + 'SELECT name, lastname, login FROM '.prefixTable('users').' |
|
1027 | 1026 | WHERE id = %i', |
1028 | 1027 | $newUserId |
1029 | 1028 | ); |
@@ -1039,7 +1038,7 @@ discard block |
||
1039 | 1038 | } elseif ($record['process_type'] === 'user_build_cache_tree') { |
1040 | 1039 | $user = json_decode($record['arguments'], true)['user_id']; |
1041 | 1040 | $data_user = DB::queryfirstrow( |
1042 | - 'SELECT name, lastname, login FROM ' . prefixTable('users') . ' |
|
1041 | + 'SELECT name, lastname, login FROM '.prefixTable('users').' |
|
1043 | 1042 | WHERE id = %i', |
1044 | 1043 | $user |
1045 | 1044 | ); |
@@ -64,7 +64,7 @@ discard block |
||
64 | 64 | ) { |
65 | 65 | // Not allowed page |
66 | 66 | $_SESSION['error']['code'] = ERR_NOT_ALLOWED; |
67 | - include $SETTINGS['cpassman_dir'] . '/error.php'; |
|
67 | + include $SETTINGS['cpassman_dir'].'/error.php'; |
|
68 | 68 | exit; |
69 | 69 | } |
70 | 70 | |
@@ -138,7 +138,7 @@ discard block |
||
138 | 138 | // get exec from processes table |
139 | 139 | $rows = DB::query( |
140 | 140 | 'SELECT max(finished_at), process_type |
141 | - FROM ' . prefixTable('processes') . ' |
|
141 | + FROM ' . prefixTable('processes').' |
|
142 | 142 | GROUP BY process_type' |
143 | 143 | ); |
144 | 144 | foreach ($rows as $row) { |
@@ -154,7 +154,7 @@ discard block |
||
154 | 154 | // get exec from processes_log table |
155 | 155 | $rows = DB::query( |
156 | 156 | 'SELECT max(finished_at), job as process_type |
157 | - FROM ' . prefixTable('processes_logs') . ' |
|
157 | + FROM ' . prefixTable('processes_logs').' |
|
158 | 158 | GROUP BY process_type' |
159 | 159 | ); |
160 | 160 | foreach ($rows as $row) { |
@@ -125,7 +125,7 @@ discard block |
||
125 | 125 | error_reporting(E_ERROR); |
126 | 126 | |
127 | 127 | // Includes |
128 | - include_once __DIR__.'/../includes/language/' . $_SESSION['user']['user_language'] . '.php'; |
|
128 | + include_once __DIR__.'/../includes/language/'.$_SESSION['user']['user_language'].'.php'; |
|
129 | 129 | include_once __DIR__.'/../sources/main.functions.php'; |
130 | 130 | |
131 | 131 | // Load libraries |
@@ -532,7 +532,7 @@ discard block |
||
532 | 532 | $pwdlib = new PasswordLib(); |
533 | 533 | // generate key |
534 | 534 | $key = $pwdlib->getRandomToken(filter_input(INPUT_POST, 'size', FILTER_SANITIZE_NUMBER_INT)); |
535 | - return '[{"key" : "' . htmlentities($key, ENT_QUOTES) . '"}]'; |
|
535 | + return '[{"key" : "'.htmlentities($key, ENT_QUOTES).'"}]'; |
|
536 | 536 | |
537 | 537 | /* |
538 | 538 | * Launch user keys change on his demand |
@@ -685,7 +685,7 @@ discard block |
||
685 | 685 | ) |
686 | 686 | ); |
687 | 687 | |
688 | - return '[{"token" : "' . $token . '"}]'; |
|
688 | + return '[{"token" : "'.$token.'"}]'; |
|
689 | 689 | |
690 | 690 | /* |
691 | 691 | * Default case |
@@ -742,7 +742,7 @@ discard block |
||
742 | 742 | array( |
743 | 743 | 'error' => false, |
744 | 744 | 'timestamp' => $_SESSION['sessionDuration'], |
745 | - 'max_time_to_add' => intdiv((($maximum_session_expiration_time*60) - ((int) $_SESSION['sessionDuration'] - time())), 60), |
|
745 | + 'max_time_to_add' => intdiv((($maximum_session_expiration_time * 60) - ((int) $_SESSION['sessionDuration'] - time())), 60), |
|
746 | 746 | 'max_session_duration' => $maximum_session_expiration_time, |
747 | 747 | ), |
748 | 748 | 'encode' |
@@ -794,7 +794,7 @@ discard block |
||
794 | 794 | // get number of items |
795 | 795 | DB::queryFirstRow( |
796 | 796 | 'SELECT increment_id |
797 | - FROM ' . prefixTable('sharekeys_items') . |
|
797 | + FROM ' . prefixTable('sharekeys_items'). |
|
798 | 798 | ' WHERE user_id = %i', |
799 | 799 | $userId |
800 | 800 | ); |
@@ -846,7 +846,7 @@ discard block |
||
846 | 846 | // check if expected security level is reached |
847 | 847 | $dataUser = DB::queryfirstrow( |
848 | 848 | 'SELECT * |
849 | - FROM ' . prefixTable('users') . ' WHERE id = %i', |
|
849 | + FROM ' . prefixTable('users').' WHERE id = %i', |
|
850 | 850 | $post_user_id |
851 | 851 | ); |
852 | 852 | |
@@ -867,8 +867,8 @@ discard block |
||
867 | 867 | if (empty($dataUser['fonction_id']) === false) { |
868 | 868 | $data = DB::queryFirstRow( |
869 | 869 | 'SELECT complexity |
870 | - FROM ' . prefixTable('roles_title') . ' |
|
871 | - WHERE id IN (' . $dataUser['fonction_id'] . ') |
|
870 | + FROM ' . prefixTable('roles_title').' |
|
871 | + WHERE id IN (' . $dataUser['fonction_id'].') |
|
872 | 872 | ORDER BY complexity DESC' |
873 | 873 | ); |
874 | 874 | } else { |
@@ -881,8 +881,8 @@ discard block |
||
881 | 881 | return prepareExchangedData( |
882 | 882 | array( |
883 | 883 | 'error' => true, |
884 | - 'message' => '<div style="margin:10px 0 10px 15px;">' . langHdl('complexity_level_not_reached') . '.<br>' . |
|
885 | - langHdl('expected_complexity_level') . ': <b>' . TP_PW_COMPLEXITY[$data['complexity']][1] . '</b></div>', |
|
884 | + 'message' => '<div style="margin:10px 0 10px 15px;">'.langHdl('complexity_level_not_reached').'.<br>'. |
|
885 | + langHdl('expected_complexity_level').': <b>'.TP_PW_COMPLEXITY[$data['complexity']][1].'</b></div>', |
|
886 | 886 | ), |
887 | 887 | 'encode' |
888 | 888 | ); |
@@ -983,14 +983,14 @@ discard block |
||
983 | 983 | // Get data about user |
984 | 984 | $data = DB::queryfirstrow( |
985 | 985 | 'SELECT id, email, pw |
986 | - FROM ' . prefixTable('users') . ' |
|
986 | + FROM ' . prefixTable('users').' |
|
987 | 987 | WHERE login = %s', |
988 | 988 | $post_login |
989 | 989 | ); |
990 | 990 | } else { |
991 | 991 | $data = DB::queryfirstrow( |
992 | 992 | 'SELECT id, login, email, pw |
993 | - FROM ' . prefixTable('users') . ' |
|
993 | + FROM ' . prefixTable('users').' |
|
994 | 994 | WHERE id = %i', |
995 | 995 | $post_id |
996 | 996 | ); |
@@ -1081,7 +1081,7 @@ discard block |
||
1081 | 1081 | 'email' => $data['email'], |
1082 | 1082 | 'email_result' => str_replace( |
1083 | 1083 | '#email#', |
1084 | - '<b>' . obfuscateEmail($data['email']) . '</b>', |
|
1084 | + '<b>'.obfuscateEmail($data['email']).'</b>', |
|
1085 | 1085 | addslashes(langHdl('admin_email_result_ok')) |
1086 | 1086 | ), |
1087 | 1087 | ), |
@@ -1097,7 +1097,7 @@ discard block |
||
1097 | 1097 | 'email' => $data['email'], |
1098 | 1098 | 'email_result' => str_replace( |
1099 | 1099 | '#email#', |
1100 | - '<b>' . obfuscateEmail($data['email']) . '</b>', |
|
1100 | + '<b>'.obfuscateEmail($data['email']).'</b>', |
|
1101 | 1101 | addslashes(langHdl('admin_email_result_ok')) |
1102 | 1102 | ), |
1103 | 1103 | ), |
@@ -1111,7 +1111,7 @@ discard block |
||
1111 | 1111 | { |
1112 | 1112 | if (isKeyExistingAndEqual('enable_send_email_on_user_login', 1, $SETTINGS) === true) { |
1113 | 1113 | $row = DB::queryFirstRow( |
1114 | - 'SELECT valeur FROM ' . prefixTable('misc') . ' WHERE type = %s AND intitule = %s', |
|
1114 | + 'SELECT valeur FROM '.prefixTable('misc').' WHERE type = %s AND intitule = %s', |
|
1115 | 1115 | 'cron', |
1116 | 1116 | 'sending_emails' |
1117 | 1117 | ); |
@@ -1119,7 +1119,7 @@ discard block |
||
1119 | 1119 | if ((int) (time() - $row['valeur']) >= 300 || (int) $row['valeur'] === 0) { |
1120 | 1120 | $rows = DB::query( |
1121 | 1121 | 'SELECT * |
1122 | - FROM ' . prefixTable('emails') . |
|
1122 | + FROM ' . prefixTable('emails'). |
|
1123 | 1123 | ' WHERE status != %s', |
1124 | 1124 | 'sent' |
1125 | 1125 | ); |
@@ -1215,8 +1215,8 @@ discard block |
||
1215 | 1215 | $arr_html = array(); |
1216 | 1216 | $rows = DB::query( |
1217 | 1217 | 'SELECT i.id AS id, i.label AS label, i.id_tree AS id_tree, l.date, i.perso AS perso, i.restricted_to AS restricted |
1218 | - FROM ' . prefixTable('log_items') . ' AS l |
|
1219 | - RIGHT JOIN ' . prefixTable('items') . ' AS i ON (l.id_item = i.id) |
|
1218 | + FROM ' . prefixTable('log_items').' AS l |
|
1219 | + RIGHT JOIN ' . prefixTable('items').' AS i ON (l.id_item = i.id) |
|
1220 | 1220 | WHERE l.action = %s AND l.id_user = %i |
1221 | 1221 | ORDER BY l.date DESC |
1222 | 1222 | LIMIT 0, 100', |
@@ -1248,7 +1248,7 @@ discard block |
||
1248 | 1248 | if (isKeyExistingAndEqual('enable_suggestion', 1, $SETTINGS) === true |
1249 | 1249 | && ((int) $_SESSION['user_admin'] === 1 || (int) $_SESSION['user_manager'] === 1) |
1250 | 1250 | ) { |
1251 | - DB::query('SELECT * FROM ' . prefixTable('suggestion')); |
|
1251 | + DB::query('SELECT * FROM '.prefixTable('suggestion')); |
|
1252 | 1252 | $nb_suggestions_waiting = DB::count(); |
1253 | 1253 | } |
1254 | 1254 | |
@@ -1282,13 +1282,13 @@ discard block |
||
1282 | 1282 | if ($data === 'stat_languages') { |
1283 | 1283 | $tmp = ''; |
1284 | 1284 | foreach ($stats_data[$data] as $key => $value) { |
1285 | - $tmp .= $tmp === '' ? $key . '-' . $value : ',' . $key . '-' . $value; |
|
1285 | + $tmp .= $tmp === '' ? $key.'-'.$value : ','.$key.'-'.$value; |
|
1286 | 1286 | } |
1287 | 1287 | $statsToSend[$data] = $tmp; |
1288 | 1288 | } elseif ($data === 'stat_country') { |
1289 | 1289 | $tmp = ''; |
1290 | 1290 | foreach ($stats_data[$data] as $key => $value) { |
1291 | - $tmp .= $tmp === '' ? $key . '-' . $value : ',' . $key . '-' . $value; |
|
1291 | + $tmp .= $tmp === '' ? $key.'-'.$value : ','.$key.'-'.$value; |
|
1292 | 1292 | } |
1293 | 1293 | $statsToSend[$data] = $tmp; |
1294 | 1294 | } else { |
@@ -1374,8 +1374,8 @@ discard block |
||
1374 | 1374 | $url_found = substr($line, 19, strlen($line) - 22); |
1375 | 1375 | if (empty($url_found) === false) { |
1376 | 1376 | $tmp = parse_url($url_found); |
1377 | - $anonym_url = $tmp['scheme'] . '://<anonym_url>' . (isset($tmp['path']) === true ? $tmp['path'] : ''); |
|
1378 | - $line = "'cpassman_url' => '" . $anonym_url . "\n"; |
|
1377 | + $anonym_url = $tmp['scheme'].'://<anonym_url>'.(isset($tmp['path']) === true ? $tmp['path'] : ''); |
|
1378 | + $line = "'cpassman_url' => '".$anonym_url."\n"; |
|
1379 | 1379 | } else { |
1380 | 1380 | $line = "'cpassman_url' => \n"; |
1381 | 1381 | } |
@@ -1405,7 +1405,7 @@ discard block |
||
1405 | 1405 | $teampass_errors = ''; |
1406 | 1406 | $rows = DB::query( |
1407 | 1407 | 'SELECT label, date AS error_date |
1408 | - FROM ' . prefixTable('log_system') . " |
|
1408 | + FROM ' . prefixTable('log_system')." |
|
1409 | 1409 | WHERE `type` LIKE 'error' |
1410 | 1410 | ORDER BY `date` DESC |
1411 | 1411 | LIMIT 0, 10" |
@@ -1413,9 +1413,9 @@ discard block |
||
1413 | 1413 | if (DB::count() > 0) { |
1414 | 1414 | foreach ($rows as $record) { |
1415 | 1415 | if (empty($teampass_errors) === true) { |
1416 | - $teampass_errors = ' * ' . date($SETTINGS['date_format'] . ' ' . $SETTINGS['time_format'], (int) $record['error_date']) . ' - ' . $record['label']; |
|
1416 | + $teampass_errors = ' * '.date($SETTINGS['date_format'].' '.$SETTINGS['time_format'], (int) $record['error_date']).' - '.$record['label']; |
|
1417 | 1417 | } else { |
1418 | - $teampass_errors .= ' * ' . date($SETTINGS['date_format'] . ' ' . $SETTINGS['time_format'], (int) $record['error_date']) . ' - ' . $record['label']; |
|
1418 | + $teampass_errors .= ' * '.date($SETTINGS['date_format'].' '.$SETTINGS['time_format'], (int) $record['error_date']).' - '.$record['label']; |
|
1419 | 1419 | } |
1420 | 1420 | } |
1421 | 1421 | } |
@@ -1424,7 +1424,7 @@ discard block |
||
1424 | 1424 | |
1425 | 1425 | // Now prepare text |
1426 | 1426 | $txt = '### Page on which it happened |
1427 | -' . $data['current_page'] . ' |
|
1427 | +' . $data['current_page'].' |
|
1428 | 1428 | |
1429 | 1429 | ### Steps to reproduce |
1430 | 1430 | 1. |
@@ -1439,39 +1439,39 @@ discard block |
||
1439 | 1439 | Tell us what happens instead |
1440 | 1440 | |
1441 | 1441 | ### Server configuration |
1442 | -**Operating system**: ' . php_uname() . ' |
|
1442 | +**Operating system**: ' . php_uname().' |
|
1443 | 1443 | |
1444 | -**Web server:** ' . $_SERVER['SERVER_SOFTWARE'] . ' |
|
1444 | +**Web server:** ' . $_SERVER['SERVER_SOFTWARE'].' |
|
1445 | 1445 | |
1446 | -**Database:** ' . ($link === false ? langHdl('undefined') : mysqli_get_server_info($link)) . ' |
|
1446 | +**Database:** ' . ($link === false ? langHdl('undefined') : mysqli_get_server_info($link)).' |
|
1447 | 1447 | |
1448 | -**PHP version:** ' . PHP_VERSION . ' |
|
1448 | +**PHP version:** ' . PHP_VERSION.' |
|
1449 | 1449 | |
1450 | -**Teampass version:** ' . TP_VERSION . ' |
|
1450 | +**Teampass version:** ' . TP_VERSION.' |
|
1451 | 1451 | |
1452 | 1452 | **Teampass configuration file:** |
1453 | 1453 | ``` |
1454 | -' . $list_of_options . ' |
|
1454 | +' . $list_of_options.' |
|
1455 | 1455 | ``` |
1456 | 1456 | |
1457 | 1457 | **Updated from an older Teampass or fresh install:** |
1458 | 1458 | |
1459 | 1459 | ### Client configuration |
1460 | 1460 | |
1461 | -**Browser:** ' . $data['browser_name'] . ' - ' . $data['browser_version'] . ' |
|
1461 | +**Browser:** ' . $data['browser_name'].' - '.$data['browser_version'].' |
|
1462 | 1462 | |
1463 | -**Operating system:** ' . $data['os'] . ' - ' . $data['os_archi'] . 'bits |
|
1463 | +**Operating system:** ' . $data['os'].' - '.$data['os_archi'].'bits |
|
1464 | 1464 | |
1465 | 1465 | ### Logs |
1466 | 1466 | |
1467 | 1467 | #### Web server error log |
1468 | 1468 | ``` |
1469 | -' . $err['message'] . ' - ' . $err['file'] . ' (' . $err['line'] . ') |
|
1469 | +' . $err['message'].' - '.$err['file'].' ('.$err['line'].') |
|
1470 | 1470 | ``` |
1471 | 1471 | |
1472 | 1472 | #### Teampass 10 last system errors |
1473 | 1473 | ``` |
1474 | -' . $teampass_errors . ' |
|
1474 | +' . $teampass_errors.' |
|
1475 | 1475 | ``` |
1476 | 1476 | |
1477 | 1477 | #### Log from the web-browser developer console (CTRL + SHIFT + i) |
@@ -1507,7 +1507,7 @@ discard block |
||
1507 | 1507 | // Check if user exists |
1508 | 1508 | $userInfo = DB::queryFirstRow( |
1509 | 1509 | 'SELECT public_key, private_key, pw, auth_type |
1510 | - FROM ' . prefixTable('users') . ' |
|
1510 | + FROM ' . prefixTable('users').' |
|
1511 | 1511 | WHERE id = %i', |
1512 | 1512 | $post_user_id |
1513 | 1513 | ); |
@@ -1516,9 +1516,9 @@ discard block |
||
1516 | 1516 | // Get one item |
1517 | 1517 | $currentUserKey = DB::queryFirstRow( |
1518 | 1518 | 'SELECT object_id, share_key, increment_id |
1519 | - FROM ' . prefixTable('sharekeys_items') . ' AS si |
|
1520 | - INNER JOIN ' . prefixTable('items') . ' AS i ON (i.id = si.object_id) |
|
1521 | - INNER JOIN ' . prefixTable('nested_tree') . ' AS nt ON (i.id_tree = nt.id) |
|
1519 | + FROM ' . prefixTable('sharekeys_items').' AS si |
|
1520 | + INNER JOIN ' . prefixTable('items').' AS i ON (i.id = si.object_id) |
|
1521 | + INNER JOIN ' . prefixTable('nested_tree').' AS nt ON (i.id_tree = nt.id) |
|
1522 | 1522 | WHERE user_id = %i AND nt.personal_folder = %i', |
1523 | 1523 | $post_user_id, |
1524 | 1524 | 0 |
@@ -1616,7 +1616,7 @@ discard block |
||
1616 | 1616 | // Get user info |
1617 | 1617 | $userData = DB::queryFirstRow( |
1618 | 1618 | 'SELECT private_key |
1619 | - FROM ' . prefixTable('users') . ' |
|
1619 | + FROM ' . prefixTable('users').' |
|
1620 | 1620 | WHERE id = %i', |
1621 | 1621 | $post_user_id |
1622 | 1622 | ); |
@@ -1680,7 +1680,7 @@ discard block |
||
1680 | 1680 | // Get user info |
1681 | 1681 | $userData = DB::queryFirstRow( |
1682 | 1682 | 'SELECT email, auth_type, login |
1683 | - FROM ' . prefixTable('users') . ' |
|
1683 | + FROM ' . prefixTable('users').' |
|
1684 | 1684 | WHERE id = %i', |
1685 | 1685 | $post_user_id |
1686 | 1686 | ); |
@@ -1813,7 +1813,7 @@ discard block |
||
1813 | 1813 | // Get user info |
1814 | 1814 | $userData = DB::queryFirstRow( |
1815 | 1815 | 'SELECT email, auth_type, login |
1816 | - FROM ' . prefixTable('users') . ' |
|
1816 | + FROM ' . prefixTable('users').' |
|
1817 | 1817 | WHERE id = %i', |
1818 | 1818 | $post_user_id |
1819 | 1819 | ); |
@@ -1875,7 +1875,7 @@ discard block |
||
1875 | 1875 | // Check if user exists |
1876 | 1876 | DB::queryFirstRow( |
1877 | 1877 | 'SELECT * |
1878 | - FROM ' . prefixTable('users') . ' |
|
1878 | + FROM ' . prefixTable('users').' |
|
1879 | 1879 | WHERE id = %i', |
1880 | 1880 | $post_user_id |
1881 | 1881 | ); |
@@ -1941,7 +1941,7 @@ discard block |
||
1941 | 1941 | // Check if user exists |
1942 | 1942 | $userInfo = DB::queryFirstRow( |
1943 | 1943 | 'SELECT public_key |
1944 | - FROM ' . prefixTable('users') . ' |
|
1944 | + FROM ' . prefixTable('users').' |
|
1945 | 1945 | WHERE id = %i', |
1946 | 1946 | $post_user_id |
1947 | 1947 | ); |
@@ -2088,15 +2088,15 @@ discard block |
||
2088 | 2088 | // Loop on items |
2089 | 2089 | $rows = DB::query( |
2090 | 2090 | 'SELECT id, pw |
2091 | - FROM ' . prefixTable('items') . ' |
|
2091 | + FROM ' . prefixTable('items').' |
|
2092 | 2092 | WHERE perso = 0 |
2093 | - LIMIT ' . $post_start . ', ' . $post_length |
|
2093 | + LIMIT ' . $post_start.', '.$post_length |
|
2094 | 2094 | ); |
2095 | 2095 | foreach ($rows as $record) { |
2096 | 2096 | // Get itemKey from current user |
2097 | 2097 | $currentUserKey = DB::queryFirstRow( |
2098 | 2098 | 'SELECT share_key, increment_id |
2099 | - FROM ' . prefixTable('sharekeys_items') . ' |
|
2099 | + FROM ' . prefixTable('sharekeys_items').' |
|
2100 | 2100 | WHERE object_id = %i AND user_id = %i', |
2101 | 2101 | $record['id'], |
2102 | 2102 | $_SESSION['user_id'] |
@@ -2128,7 +2128,7 @@ discard block |
||
2128 | 2128 | if ((int) $post_user_id !== (int) $_SESSION['user_id']) { |
2129 | 2129 | $currentUserKey = DB::queryFirstRow( |
2130 | 2130 | 'SELECT increment_id |
2131 | - FROM ' . prefixTable('sharekeys_items') . ' |
|
2131 | + FROM ' . prefixTable('sharekeys_items').' |
|
2132 | 2132 | WHERE object_id = %i AND user_id = %i', |
2133 | 2133 | $record['id'], |
2134 | 2134 | $post_user_id |
@@ -2161,7 +2161,7 @@ discard block |
||
2161 | 2161 | // SHould we change step? |
2162 | 2162 | DB::query( |
2163 | 2163 | 'SELECT * |
2164 | - FROM ' . prefixTable('items') . ' |
|
2164 | + FROM ' . prefixTable('items').' |
|
2165 | 2165 | WHERE perso = 0' |
2166 | 2166 | ); |
2167 | 2167 | |
@@ -2185,15 +2185,15 @@ discard block |
||
2185 | 2185 | // Loop on logs |
2186 | 2186 | $rows = DB::query( |
2187 | 2187 | 'SELECT increment_id |
2188 | - FROM ' . prefixTable('log_items') . ' |
|
2188 | + FROM ' . prefixTable('log_items').' |
|
2189 | 2189 | WHERE raison LIKE "at_pw :%" AND encryption_type = "teampass_aes" |
2190 | - LIMIT ' . $post_start . ', ' . $post_length |
|
2190 | + LIMIT ' . $post_start.', '.$post_length |
|
2191 | 2191 | ); |
2192 | 2192 | foreach ($rows as $record) { |
2193 | 2193 | // Get itemKey from current user |
2194 | 2194 | $currentUserKey = DB::queryFirstRow( |
2195 | 2195 | 'SELECT share_key |
2196 | - FROM ' . prefixTable('sharekeys_logs') . ' |
|
2196 | + FROM ' . prefixTable('sharekeys_logs').' |
|
2197 | 2197 | WHERE object_id = %i AND user_id = %i', |
2198 | 2198 | $record['increment_id'], |
2199 | 2199 | $_SESSION['user_id'] |
@@ -2225,7 +2225,7 @@ discard block |
||
2225 | 2225 | if ((int) $post_user_id !== (int) $_SESSION['user_id']) { |
2226 | 2226 | $currentUserKey = DB::queryFirstRow( |
2227 | 2227 | 'SELECT increment_id |
2228 | - FROM ' . prefixTable('sharekeys_items') . ' |
|
2228 | + FROM ' . prefixTable('sharekeys_items').' |
|
2229 | 2229 | WHERE object_id = %i AND user_id = %i', |
2230 | 2230 | $record['id'], |
2231 | 2231 | $post_user_id |
@@ -2247,7 +2247,7 @@ discard block |
||
2247 | 2247 | // SHould we change step? |
2248 | 2248 | DB::query( |
2249 | 2249 | 'SELECT increment_id |
2250 | - FROM ' . prefixTable('log_items') . ' |
|
2250 | + FROM ' . prefixTable('log_items').' |
|
2251 | 2251 | WHERE raison LIKE "at_pw :%" AND encryption_type = "teampass_aes"' |
2252 | 2252 | ); |
2253 | 2253 | |
@@ -2271,15 +2271,15 @@ discard block |
||
2271 | 2271 | // Loop on fields |
2272 | 2272 | $rows = DB::query( |
2273 | 2273 | 'SELECT id |
2274 | - FROM ' . prefixTable('categories_items') . ' |
|
2274 | + FROM ' . prefixTable('categories_items').' |
|
2275 | 2275 | WHERE encryption_type = "teampass_aes" |
2276 | - LIMIT ' . $post_start . ', ' . $post_length |
|
2276 | + LIMIT ' . $post_start.', '.$post_length |
|
2277 | 2277 | ); |
2278 | 2278 | foreach ($rows as $record) { |
2279 | 2279 | // Get itemKey from current user |
2280 | 2280 | $currentUserKey = DB::queryFirstRow( |
2281 | 2281 | 'SELECT share_key |
2282 | - FROM ' . prefixTable('sharekeys_fields') . ' |
|
2282 | + FROM ' . prefixTable('sharekeys_fields').' |
|
2283 | 2283 | WHERE object_id = %i AND user_id = %i', |
2284 | 2284 | $record['id'], |
2285 | 2285 | $_SESSION['user_id'] |
@@ -2311,7 +2311,7 @@ discard block |
||
2311 | 2311 | if ((int) $post_user_id !== (int) $_SESSION['user_id']) { |
2312 | 2312 | $currentUserKey = DB::queryFirstRow( |
2313 | 2313 | 'SELECT increment_id |
2314 | - FROM ' . prefixTable('sharekeys_items') . ' |
|
2314 | + FROM ' . prefixTable('sharekeys_items').' |
|
2315 | 2315 | WHERE object_id = %i AND user_id = %i', |
2316 | 2316 | $record['id'], |
2317 | 2317 | $post_user_id |
@@ -2333,7 +2333,7 @@ discard block |
||
2333 | 2333 | // SHould we change step? |
2334 | 2334 | DB::query( |
2335 | 2335 | 'SELECT * |
2336 | - FROM ' . prefixTable('categories_items') . ' |
|
2336 | + FROM ' . prefixTable('categories_items').' |
|
2337 | 2337 | WHERE encryption_type = "teampass_aes"' |
2338 | 2338 | ); |
2339 | 2339 | |
@@ -2357,14 +2357,14 @@ discard block |
||
2357 | 2357 | // Loop on suggestions |
2358 | 2358 | $rows = DB::query( |
2359 | 2359 | 'SELECT id |
2360 | - FROM ' . prefixTable('suggestion') . ' |
|
2361 | - LIMIT ' . $post_start . ', ' . $post_length |
|
2360 | + FROM ' . prefixTable('suggestion').' |
|
2361 | + LIMIT ' . $post_start.', '.$post_length |
|
2362 | 2362 | ); |
2363 | 2363 | foreach ($rows as $record) { |
2364 | 2364 | // Get itemKey from current user |
2365 | 2365 | $currentUserKey = DB::queryFirstRow( |
2366 | 2366 | 'SELECT share_key |
2367 | - FROM ' . prefixTable('sharekeys_suggestions') . ' |
|
2367 | + FROM ' . prefixTable('sharekeys_suggestions').' |
|
2368 | 2368 | WHERE object_id = %i AND user_id = %i', |
2369 | 2369 | $record['id'], |
2370 | 2370 | $_SESSION['user_id'] |
@@ -2396,7 +2396,7 @@ discard block |
||
2396 | 2396 | if ((int) $post_user_id !== (int) $_SESSION['user_id']) { |
2397 | 2397 | $currentUserKey = DB::queryFirstRow( |
2398 | 2398 | 'SELECT increment_id |
2399 | - FROM ' . prefixTable('sharekeys_items') . ' |
|
2399 | + FROM ' . prefixTable('sharekeys_items').' |
|
2400 | 2400 | WHERE object_id = %i AND user_id = %i', |
2401 | 2401 | $record['id'], |
2402 | 2402 | $post_user_id |
@@ -2441,15 +2441,15 @@ discard block |
||
2441 | 2441 | // Loop on files |
2442 | 2442 | $rows = DB::query( |
2443 | 2443 | 'SELECT id |
2444 | - FROM ' . prefixTable('files') . ' |
|
2445 | - WHERE status = "' . TP_ENCRYPTION_NAME . '" |
|
2446 | - LIMIT ' . $post_start . ', ' . $post_length |
|
2444 | + FROM ' . prefixTable('files').' |
|
2445 | + WHERE status = "' . TP_ENCRYPTION_NAME.'" |
|
2446 | + LIMIT ' . $post_start.', '.$post_length |
|
2447 | 2447 | ); //aes_encryption |
2448 | 2448 | foreach ($rows as $record) { |
2449 | 2449 | // Get itemKey from current user |
2450 | 2450 | $currentUserKey = DB::queryFirstRow( |
2451 | 2451 | 'SELECT share_key |
2452 | - FROM ' . prefixTable('sharekeys_files') . ' |
|
2452 | + FROM ' . prefixTable('sharekeys_files').' |
|
2453 | 2453 | WHERE object_id = %i AND user_id = %i', |
2454 | 2454 | $record['id'], |
2455 | 2455 | $_SESSION['user_id'] |
@@ -2481,7 +2481,7 @@ discard block |
||
2481 | 2481 | if ((int) $post_user_id !== (int) $_SESSION['user_id']) { |
2482 | 2482 | $currentUserKey = DB::queryFirstRow( |
2483 | 2483 | 'SELECT increment_id |
2484 | - FROM ' . prefixTable('sharekeys_items') . ' |
|
2484 | + FROM ' . prefixTable('sharekeys_items').' |
|
2485 | 2485 | WHERE object_id = %i AND user_id = %i', |
2486 | 2486 | $record['id'], |
2487 | 2487 | $post_user_id |
@@ -2503,8 +2503,8 @@ discard block |
||
2503 | 2503 | // SHould we change step? |
2504 | 2504 | DB::query( |
2505 | 2505 | 'SELECT * |
2506 | - FROM ' . prefixTable('files') . ' |
|
2507 | - WHERE status = "' . TP_ENCRYPTION_NAME . '"' |
|
2506 | + FROM ' . prefixTable('files').' |
|
2507 | + WHERE status = "' . TP_ENCRYPTION_NAME.'"' |
|
2508 | 2508 | ); |
2509 | 2509 | |
2510 | 2510 | $next_start = (int) $post_start + (int) $post_length; |
@@ -2536,16 +2536,16 @@ discard block |
||
2536 | 2536 | if (count($_SESSION['personal_folders']) > 0) { |
2537 | 2537 | $rows = DB::query( |
2538 | 2538 | 'SELECT id, pw |
2539 | - FROM ' . prefixTable('items') . ' |
|
2539 | + FROM ' . prefixTable('items').' |
|
2540 | 2540 | WHERE perso = 1 AND id_tree IN %ls |
2541 | - LIMIT ' . $post_start . ', ' . $post_length, |
|
2541 | + LIMIT ' . $post_start.', '.$post_length, |
|
2542 | 2542 | $_SESSION['personal_folders'] |
2543 | 2543 | ); |
2544 | 2544 | foreach ($rows as $record) { |
2545 | 2545 | // Get itemKey from current user |
2546 | 2546 | $currentUserKey = DB::queryFirstRow( |
2547 | 2547 | 'SELECT share_key, increment_id |
2548 | - FROM ' . prefixTable('sharekeys_items') . ' |
|
2548 | + FROM ' . prefixTable('sharekeys_items').' |
|
2549 | 2549 | WHERE object_id = %i AND user_id = %i', |
2550 | 2550 | $record['id'], |
2551 | 2551 | $_SESSION['user_id'] |
@@ -2572,7 +2572,7 @@ discard block |
||
2572 | 2572 | if ((int) $post_user_id !== (int) $_SESSION['user_id']) { |
2573 | 2573 | $currentUserKey = DB::queryFirstRow( |
2574 | 2574 | 'SELECT increment_id |
2575 | - FROM ' . prefixTable('sharekeys_items') . ' |
|
2575 | + FROM ' . prefixTable('sharekeys_items').' |
|
2576 | 2576 | WHERE object_id = %i AND user_id = %i', |
2577 | 2577 | $record['id'], |
2578 | 2578 | $post_user_id |
@@ -2595,7 +2595,7 @@ discard block |
||
2595 | 2595 | // SHould we change step? |
2596 | 2596 | DB::query( |
2597 | 2597 | 'SELECT * |
2598 | - FROM ' . prefixTable('items') . ' |
|
2598 | + FROM ' . prefixTable('items').' |
|
2599 | 2599 | WHERE perso = 0' |
2600 | 2600 | ); |
2601 | 2601 | |
@@ -2619,7 +2619,7 @@ discard block |
||
2619 | 2619 | // Check if user exists |
2620 | 2620 | $userInfo = DB::queryFirstRow( |
2621 | 2621 | 'SELECT public_key, encrypted_psk |
2622 | - FROM ' . prefixTable('users') . ' |
|
2622 | + FROM ' . prefixTable('users').' |
|
2623 | 2623 | WHERE id = %i', |
2624 | 2624 | $post_user_id |
2625 | 2625 | ); |
@@ -2644,9 +2644,9 @@ discard block |
||
2644 | 2644 | // Loop on persoanl items |
2645 | 2645 | $rows = DB::query( |
2646 | 2646 | 'SELECT id, pw |
2647 | - FROM ' . prefixTable('items') . ' |
|
2647 | + FROM ' . prefixTable('items').' |
|
2648 | 2648 | WHERE perso = 1 AND id_tree IN %ls |
2649 | - LIMIT ' . $post_start . ', ' . $post_length, |
|
2649 | + LIMIT ' . $post_start.', '.$post_length, |
|
2650 | 2650 | $_SESSION['personal_folders'] |
2651 | 2651 | ); |
2652 | 2652 | $countUserPersonalItems = DB::count(); |
@@ -2689,7 +2689,7 @@ discard block |
||
2689 | 2689 | // Loop on files |
2690 | 2690 | $rows = DB::query( |
2691 | 2691 | 'SELECT id, file |
2692 | - FROM ' . prefixTable('files') . ' |
|
2692 | + FROM ' . prefixTable('files').' |
|
2693 | 2693 | WHERE status != %s |
2694 | 2694 | AND id_item = %i', |
2695 | 2695 | TP_ENCRYPTION_NAME, |
@@ -2700,14 +2700,14 @@ discard block |
||
2700 | 2700 | // Now decrypt the file |
2701 | 2701 | prepareFileWithDefuse( |
2702 | 2702 | 'decrypt', |
2703 | - $SETTINGS['path_to_upload_folder'] . '/' . $record2['file'], |
|
2704 | - $SETTINGS['path_to_upload_folder'] . '/' . $record2['file'] . '.delete', |
|
2703 | + $SETTINGS['path_to_upload_folder'].'/'.$record2['file'], |
|
2704 | + $SETTINGS['path_to_upload_folder'].'/'.$record2['file'].'.delete', |
|
2705 | 2705 | $SETTINGS, |
2706 | 2706 | $post_user_psk |
2707 | 2707 | ); |
2708 | 2708 | |
2709 | 2709 | // Encrypt the file |
2710 | - $encryptedFile = encryptFile($record2['file'] . '.delete', $SETTINGS['path_to_upload_folder']); |
|
2710 | + $encryptedFile = encryptFile($record2['file'].'.delete', $SETTINGS['path_to_upload_folder']); |
|
2711 | 2711 | |
2712 | 2712 | DB::update( |
2713 | 2713 | prefixTable('files'), |
@@ -2730,7 +2730,7 @@ discard block |
||
2730 | 2730 | ); |
2731 | 2731 | |
2732 | 2732 | // Unlink original file |
2733 | - unlink($SETTINGS['path_to_upload_folder'] . '/' . $record2['file']); |
|
2733 | + unlink($SETTINGS['path_to_upload_folder'].'/'.$record2['file']); |
|
2734 | 2734 | } |
2735 | 2735 | } |
2736 | 2736 | } |
@@ -2799,7 +2799,7 @@ discard block |
||
2799 | 2799 | // Get user info |
2800 | 2800 | $userData = DB::queryFirstRow( |
2801 | 2801 | 'SELECT '.$post_fields.' |
2802 | - FROM ' . prefixTable('users') . ' |
|
2802 | + FROM ' . prefixTable('users').' |
|
2803 | 2803 | WHERE id = %i', |
2804 | 2804 | $post_user_id |
2805 | 2805 | ); |
@@ -2843,7 +2843,7 @@ discard block |
||
2843 | 2843 | // Get user info |
2844 | 2844 | $userData = DB::queryFirstRow( |
2845 | 2845 | 'SELECT auth_type, login, private_key |
2846 | - FROM ' . prefixTable('users') . ' |
|
2846 | + FROM ' . prefixTable('users').' |
|
2847 | 2847 | WHERE id = %i', |
2848 | 2848 | $post_user_id |
2849 | 2849 | ); |
@@ -2894,7 +2894,7 @@ discard block |
||
2894 | 2894 | return prepareExchangedData( |
2895 | 2895 | array( |
2896 | 2896 | 'error' => false, |
2897 | - 'message' => langHdl('done'),'', |
|
2897 | + 'message' => langHdl('done'), '', |
|
2898 | 2898 | ), |
2899 | 2899 | 'encode' |
2900 | 2900 | ); |
@@ -2932,7 +2932,7 @@ discard block |
||
2932 | 2932 | // Get user info |
2933 | 2933 | $userData = DB::queryFirstRow( |
2934 | 2934 | 'SELECT auth_type, login, private_key, special |
2935 | - FROM ' . prefixTable('users') . ' |
|
2935 | + FROM ' . prefixTable('users').' |
|
2936 | 2936 | WHERE id = %i', |
2937 | 2937 | $post_user_id |
2938 | 2938 | ); |
@@ -2968,7 +2968,7 @@ discard block |
||
2968 | 2968 | return prepareExchangedData( |
2969 | 2969 | array( |
2970 | 2970 | 'error' => false, |
2971 | - 'message' => langHdl('done'),'', |
|
2971 | + 'message' => langHdl('done'), '', |
|
2972 | 2972 | ), |
2973 | 2973 | 'encode' |
2974 | 2974 | ); |
@@ -2992,14 +2992,14 @@ discard block |
||
2992 | 2992 | // Get one item |
2993 | 2993 | $record = DB::queryFirstRow( |
2994 | 2994 | 'SELECT id, pw |
2995 | - FROM ' . prefixTable('items') . ' |
|
2995 | + FROM ' . prefixTable('items').' |
|
2996 | 2996 | WHERE perso = 0' |
2997 | 2997 | ); |
2998 | 2998 | |
2999 | 2999 | // Get itemKey from current user |
3000 | 3000 | $currentUserKey = DB::queryFirstRow( |
3001 | 3001 | 'SELECT share_key, increment_id |
3002 | - FROM ' . prefixTable('sharekeys_items') . ' |
|
3002 | + FROM ' . prefixTable('sharekeys_items').' |
|
3003 | 3003 | WHERE object_id = %i AND user_id = %i', |
3004 | 3004 | $record['id'], |
3005 | 3005 | $post_user_id |
@@ -3080,7 +3080,7 @@ discard block |
||
3080 | 3080 | $_SESSION['user_id'] |
3081 | 3081 | ); |
3082 | 3082 | // Return data |
3083 | - return '[{"new_value":"' . $_SESSION['sessionDuration'] . '"}]'; |
|
3083 | + return '[{"new_value":"'.$_SESSION['sessionDuration'].'"}]'; |
|
3084 | 3084 | } |
3085 | 3085 | |
3086 | 3086 | return '[{"new_value":"expired"}]'; |
@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | if ($checkUserAccess->checkSession() === false) { |
82 | 82 | // Not allowed page |
83 | 83 | $_SESSION['error']['code'] = ERR_NOT_ALLOWED; |
84 | - include $SETTINGS['cpassman_dir'] . '/error.php'; |
|
84 | + include $SETTINGS['cpassman_dir'].'/error.php'; |
|
85 | 85 | exit; |
86 | 86 | } |
87 | 87 | |
@@ -215,18 +215,18 @@ discard block |
||
215 | 215 | } |
216 | 216 | |
217 | 217 | // Check if Duo auth is in progress and pass the pw and login back to the standard login process |
218 | - if( |
|
218 | + if ( |
|
219 | 219 | isKeyExistingAndEqual('duo', 1, $SETTINGS) === true |
220 | 220 | && $dataReceived['user_2fa_selection'] === 'duo' |
221 | - && $superGlobal->get('duo_status','SESSION') === 'IN_PROGRESS' |
|
221 | + && $superGlobal->get('duo_status', 'SESSION') === 'IN_PROGRESS' |
|
222 | 222 | && !empty($dataReceived['duo_state']) |
223 | - ){ |
|
223 | + ) { |
|
224 | 224 | $key = hash('sha256', $dataReceived['duo_state']); |
225 | 225 | $iv = substr(hash('sha256', $dataReceived['duo_state']), 0, 16); |
226 | - $duo_data_dec = openssl_decrypt(base64_decode($superGlobal->get('duo_data','SESSION')), 'AES-256-CBC', $key, 0, $iv); |
|
226 | + $duo_data_dec = openssl_decrypt(base64_decode($superGlobal->get('duo_data', 'SESSION')), 'AES-256-CBC', $key, 0, $iv); |
|
227 | 227 | // Clear the data from the Duo process to continue clean with the standard login process |
228 | - $superGlobal->forget('duo_data','SESSION'); |
|
229 | - if($duo_data_dec === false){ |
|
228 | + $superGlobal->forget('duo_data', 'SESSION'); |
|
229 | + if ($duo_data_dec === false) { |
|
230 | 230 | echo prepareExchangedData( |
231 | 231 | [ |
232 | 232 | 'error' => true, |
@@ -241,7 +241,7 @@ discard block |
||
241 | 241 | $dataReceived['login'] = $duo_data['duo_login']; |
242 | 242 | } |
243 | 243 | |
244 | - if(isset($dataReceived['pw']) === false || isset($dataReceived['login']) === false) { |
|
244 | + if (isset($dataReceived['pw']) === false || isset($dataReceived['login']) === false) { |
|
245 | 245 | echo json_encode([ |
246 | 246 | 'data' => prepareExchangedData( |
247 | 247 | [ |
@@ -546,7 +546,7 @@ discard block |
||
546 | 546 | } |
547 | 547 | // Append with roles from AD groups |
548 | 548 | if (is_null($userInfo['roles_from_ad_groups']) === false) { |
549 | - $userInfo['fonction_id'] = empty($userInfo['fonction_id']) === true ? $userInfo['roles_from_ad_groups'] : $userInfo['fonction_id']. ';' . $userInfo['roles_from_ad_groups']; |
|
549 | + $userInfo['fonction_id'] = empty($userInfo['fonction_id']) === true ? $userInfo['roles_from_ad_groups'] : $userInfo['fonction_id'].';'.$userInfo['roles_from_ad_groups']; |
|
550 | 550 | } |
551 | 551 | // store |
552 | 552 | $superGlobal->put('fonction_id', $userInfo['fonction_id'], 'SESSION'); |
@@ -557,7 +557,7 @@ discard block |
||
557 | 557 | if (count($superGlobal->get('user_roles', 'SESSION')) > 0) { |
558 | 558 | $rolesList = DB::query( |
559 | 559 | 'SELECT id, title, complexity |
560 | - FROM ' . prefixTable('roles_title') . ' |
|
560 | + FROM ' . prefixTable('roles_title').' |
|
561 | 561 | WHERE id IN %li', |
562 | 562 | $superGlobal->get('user_roles', 'SESSION') |
563 | 563 | ); |
@@ -622,7 +622,7 @@ discard block |
||
622 | 622 | |
623 | 623 | // build complete array of roles |
624 | 624 | $superGlobal->put('arr_roles_full', [], 'SESSION'); |
625 | - $rows = DB::query('SELECT id, title FROM ' . prefixTable('roles_title') . ' ORDER BY title ASC'); |
|
625 | + $rows = DB::query('SELECT id, title FROM '.prefixTable('roles_title').' ORDER BY title ASC'); |
|
626 | 626 | foreach ($rows as $record) { |
627 | 627 | $superGlobal->put( |
628 | 628 | $record['id'], |
@@ -690,10 +690,10 @@ discard block |
||
690 | 690 | $superGlobal->put('latest_items_tab', [], 'SESSION'); |
691 | 691 | $superGlobal->put('nb_roles', 0, 'SESSION'); |
692 | 692 | foreach ($superGlobal->get('latest_items', 'SESSION') as $item) { |
693 | - if (! empty($item)) { |
|
693 | + if (!empty($item)) { |
|
694 | 694 | $dataLastItems = DB::queryFirstRow( |
695 | 695 | 'SELECT id,label,id_tree |
696 | - FROM ' . prefixTable('items') . ' |
|
696 | + FROM ' . prefixTable('items').' |
|
697 | 697 | WHERE id=%i', |
698 | 698 | $item |
699 | 699 | ); |
@@ -702,7 +702,7 @@ discard block |
||
702 | 702 | [ |
703 | 703 | 'id' => $item, |
704 | 704 | 'label' => $dataLastItems['label'], |
705 | - 'url' => 'index.php?page=items&group=' . $dataLastItems['id_tree'] . '&id=' . $item, |
|
705 | + 'url' => 'index.php?page=items&group='.$dataLastItems['id_tree'].'&id='.$item, |
|
706 | 706 | ], |
707 | 707 | 'SESSION', |
708 | 708 | 'latest_items_tab' |
@@ -713,7 +713,7 @@ discard block |
||
713 | 713 | // Get cahce tree info |
714 | 714 | $cacheTreeData = DB::queryFirstRow( |
715 | 715 | 'SELECT visible_folders |
716 | - FROM ' . prefixTable('cache_tree') . ' |
|
716 | + FROM ' . prefixTable('cache_tree').' |
|
717 | 717 | WHERE user_id=%i', |
718 | 718 | (int) $superGlobal->get('user_id', 'SESSION') |
719 | 719 | ); |
@@ -745,7 +745,7 @@ discard block |
||
745 | 745 | && (int) $sessionAdmin !== 1 |
746 | 746 | ) { |
747 | 747 | // get all Admin users |
748 | - $val = DB::queryfirstrow('SELECT email FROM ' . prefixTable('users') . " WHERE admin = %i and email != ''", 1); |
|
748 | + $val = DB::queryfirstrow('SELECT email FROM '.prefixTable('users')." WHERE admin = %i and email != ''", 1); |
|
749 | 749 | if (DB::count() > 0) { |
750 | 750 | // Add email to table |
751 | 751 | prepareSendingEmail( |
@@ -757,7 +757,7 @@ discard block |
||
757 | 757 | '#tp_time#', |
758 | 758 | ], |
759 | 759 | [ |
760 | - ' ' . $superGlobal->get('login', 'SESSION') . ' (IP: ' . getClientIpServer() . ')', |
|
760 | + ' '.$superGlobal->get('login', 'SESSION').' (IP: '.getClientIpServer().')', |
|
761 | 761 | date($SETTINGS['date_format'], (int) $superGlobal->get('last_connection', 'SESSION')), |
762 | 762 | date($SETTINGS['time_format'], (int) $superGlobal->get('last_connection', 'SESSION')), |
763 | 763 | ], |
@@ -907,7 +907,7 @@ discard block |
||
907 | 907 | { |
908 | 908 | $rows = DB::query( |
909 | 909 | 'SELECT date |
910 | - FROM ' . prefixTable('log_system') . " |
|
910 | + FROM ' . prefixTable('log_system')." |
|
911 | 911 | WHERE field_1 = %s |
912 | 912 | AND type = 'failed_auth' |
913 | 913 | AND label = 'password_is_not_correct' |
@@ -921,7 +921,7 @@ discard block |
||
921 | 921 | foreach ($rows as $record) { |
922 | 922 | array_push( |
923 | 923 | $arrAttempts, |
924 | - date($SETTINGS['date_format'] . ' ' . $SETTINGS['time_format'], (int) $record['date']) |
|
924 | + date($SETTINGS['date_format'].' '.$SETTINGS['time_format'], (int) $record['date']) |
|
925 | 925 | ); |
926 | 926 | } |
927 | 927 | } |
@@ -975,7 +975,7 @@ discard block |
||
975 | 975 | $ldapConnection |
976 | 976 | ) : bool |
977 | 977 | { |
978 | - include_once $SETTINGS['cpassman_dir'] . '/sources/main.functions.php'; |
|
978 | + include_once $SETTINGS['cpassman_dir'].'/sources/main.functions.php'; |
|
979 | 979 | |
980 | 980 | if ((int) $userInfoDisabled === 1) { |
981 | 981 | return false; |
@@ -1196,7 +1196,7 @@ discard block |
||
1196 | 1196 | // 2- Get user info from AD |
1197 | 1197 | // We want to isolate attribute ldap_user_attribute or mostly samAccountName |
1198 | 1198 | $userADInfos = $connection->query() |
1199 | - ->where((isset($SETTINGS['ldap_user_attribute']) ===true && empty($SETTINGS['ldap_user_attribute']) === false) ? $SETTINGS['ldap_user_attribute'] : 'samaccountname', '=', $username) |
|
1199 | + ->where((isset($SETTINGS['ldap_user_attribute']) === true && empty($SETTINGS['ldap_user_attribute']) === false) ? $SETTINGS['ldap_user_attribute'] : 'samaccountname', '=', $username) |
|
1200 | 1200 | ->firstOrFail(); |
1201 | 1201 | |
1202 | 1202 | // Is user enabled? Only ActiveDirectory |
@@ -1214,7 +1214,7 @@ discard block |
||
1214 | 1214 | // Determining Auth Failure Cause |
1215 | 1215 | $dispatcher = Container::getDispatcher(); |
1216 | 1216 | $message = ''; |
1217 | - $dispatcher->listen(Failed::class, function (Failed $event) use (&$message) { |
|
1217 | + $dispatcher->listen(Failed::class, function(Failed $event) use (&$message) { |
|
1218 | 1218 | $ldap = $event->getConnection(); |
1219 | 1219 | |
1220 | 1220 | // The diagnostic message will be available here. |
@@ -1238,7 +1238,7 @@ discard block |
||
1238 | 1238 | // For OpenLDAP and others, we use attribute dn |
1239 | 1239 | $userAuthAttempt = $connection->auth()->attempt( |
1240 | 1240 | $SETTINGS['ldap_type'] === 'ActiveDirectory' ? |
1241 | - $userADInfos['userprincipalname'][0] : // refering to https://ldaprecord.com/docs/core/v2/authentication#basic-authentication |
|
1241 | + $userADInfos['userprincipalname'][0] : // refering to https://ldaprecord.com/docs/core/v2/authentication#basic-authentication |
|
1242 | 1242 | $userADInfos['dn'], |
1243 | 1243 | $passwordClear |
1244 | 1244 | ); |
@@ -1254,7 +1254,7 @@ discard block |
||
1254 | 1254 | $error = $e->getDetailedError(); |
1255 | 1255 | return [ |
1256 | 1256 | 'error' => true, |
1257 | - 'message' => langHdl('error')." - ".(isset($error) === true ? $error->getErrorCode()." - ".$error->getErrorMessage(). "<br>".$error->getDiagnosticMessage() : $e), |
|
1257 | + 'message' => langHdl('error')." - ".(isset($error) === true ? $error->getErrorCode()." - ".$error->getErrorMessage()."<br>".$error->getDiagnosticMessage() : $e), |
|
1258 | 1258 | |
1259 | 1259 | ]; |
1260 | 1260 | } |
@@ -1310,8 +1310,7 @@ discard block |
||
1310 | 1310 | } |
1311 | 1311 | $ret = getUserADGroups( |
1312 | 1312 | $SETTINGS['ldap_type'] === 'ActiveDirectory' ? |
1313 | - $userADInfos[(isset($SETTINGS['ldap_user_dn_attribute']) === true && empty($SETTINGS['ldap_user_dn_attribute']) === false) ? $SETTINGS['ldap_user_dn_attribute'] : 'distinguishedname'][0] : |
|
1314 | - $userADInfos['dn'], |
|
1313 | + $userADInfos[(isset($SETTINGS['ldap_user_dn_attribute']) === true && empty($SETTINGS['ldap_user_dn_attribute']) === false) ? $SETTINGS['ldap_user_dn_attribute'] : 'distinguishedname'][0] : $userADInfos['dn'], |
|
1315 | 1314 | $connection, |
1316 | 1315 | $SETTINGS |
1317 | 1316 | ); |
@@ -1347,12 +1346,12 @@ discard block |
||
1347 | 1346 | if (isset($SETTINGS['enable_ad_users_with_ad_groups']) === true && (int) $SETTINGS['enable_ad_users_with_ad_groups'] === 1) { |
1348 | 1347 | // Get user groups from AD |
1349 | 1348 | $user_ad_groups = []; |
1350 | - foreach($groups as $group) { |
|
1349 | + foreach ($groups as $group) { |
|
1351 | 1350 | //print_r($group); |
1352 | 1351 | // get relation role id for AD group |
1353 | 1352 | $role = DB::queryFirstRow( |
1354 | 1353 | 'SELECT lgr.role_id |
1355 | - FROM ' . prefixTable('ldap_groups_roles') . ' AS lgr |
|
1354 | + FROM ' . prefixTable('ldap_groups_roles').' AS lgr |
|
1356 | 1355 | WHERE lgr.ldap_group_id = %i', |
1357 | 1356 | $group |
1358 | 1357 | ); |
@@ -1502,7 +1501,7 @@ discard block |
||
1502 | 1501 | } |
1503 | 1502 | |
1504 | 1503 | // Now check yubico validity |
1505 | - include_once $SETTINGS['cpassman_dir'] . '/includes/libraries/Authentication/Yubico/Yubico.php'; |
|
1504 | + include_once $SETTINGS['cpassman_dir'].'/includes/libraries/Authentication/Yubico/Yubico.php'; |
|
1506 | 1505 | $yubi = new Auth_Yubico($yubico_user_id, $yubico_user_key); |
1507 | 1506 | $auth = $yubi->verify($yubico_key); |
1508 | 1507 | //, null, null, null, 60 |
@@ -1656,7 +1655,7 @@ discard block |
||
1656 | 1655 | $mfaMessage = langHdl('ga_flash_qr_and_login'); |
1657 | 1656 | // generate new QR |
1658 | 1657 | $new_2fa_qr = $tfa->getQRCodeImageAsDataUri( |
1659 | - 'Teampass - ' . $username, |
|
1658 | + 'Teampass - '.$username, |
|
1660 | 1659 | $userInfo['ga'] |
1661 | 1660 | ); |
1662 | 1661 | // clear temporary code from DB |
@@ -1669,7 +1668,7 @@ discard block |
||
1669 | 1668 | $userInfo['id'] |
1670 | 1669 | ); |
1671 | 1670 | $firstTime = [ |
1672 | - 'value' => '<img src="' . $new_2fa_qr . '">', |
|
1671 | + 'value' => '<img src="'.$new_2fa_qr.'">', |
|
1673 | 1672 | 'user_admin' => isset($sessionAdmin) ? (int) $sessionAdmin : '', |
1674 | 1673 | 'initial_url' => isset($sessionUrl) === true ? $sessionUrl : '', |
1675 | 1674 | 'pwd_attempts' => (int) $sessionPwdAttempts, |
@@ -1727,8 +1726,8 @@ discard block |
||
1727 | 1726 | $superGlobal = new SuperGlobal(); |
1728 | 1727 | |
1729 | 1728 | $sessionPwdAttempts = $superGlobal->get('pwd_attempts', 'SESSION'); |
1730 | - $saved_state = null !== $superGlobal->get('duo_state','SESSION') ? $superGlobal->get('duo_state','SESSION') : ''; |
|
1731 | - $duo_status = null !== $superGlobal->get('duo_status','SESSION') ? $superGlobal->get('duo_status','SESSION') : ''; |
|
1729 | + $saved_state = null !== $superGlobal->get('duo_state', 'SESSION') ? $superGlobal->get('duo_state', 'SESSION') : ''; |
|
1730 | + $duo_status = null !== $superGlobal->get('duo_status', 'SESSION') ? $superGlobal->get('duo_status', 'SESSION') : ''; |
|
1732 | 1731 | |
1733 | 1732 | // Ensure state and login are set |
1734 | 1733 | if ( |
@@ -1825,7 +1824,7 @@ discard block |
||
1825 | 1824 | }*/ |
1826 | 1825 | return [ |
1827 | 1826 | 'error' => true, |
1828 | - 'message' => $duo_error . langHdl('duo_error_check_config'), |
|
1827 | + 'message' => $duo_error.langHdl('duo_error_check_config'), |
|
1829 | 1828 | 'pwd_attempts' => (int) $sessionPwdAttempts, |
1830 | 1829 | 'debug_message' => $e->getMessage(), |
1831 | 1830 | 'proceedIdentification' => false, |
@@ -1841,7 +1840,7 @@ discard block |
||
1841 | 1840 | } catch (NestedTreeDuoException $e) { |
1842 | 1841 | return [ |
1843 | 1842 | 'error' => true, |
1844 | - 'message' => $duo_error . langHdl('duo_error_url'), |
|
1843 | + 'message' => $duo_error.langHdl('duo_error_url'), |
|
1845 | 1844 | 'pwd_attempts' => (int) $sessionPwdAttempts, |
1846 | 1845 | 'debug_message' => $e->getMessage(), |
1847 | 1846 | 'proceedIdentification' => false, |
@@ -1849,7 +1848,7 @@ discard block |
||
1849 | 1848 | } |
1850 | 1849 | |
1851 | 1850 | // Somethimes Duo return success but fail to return a URL, double check if the URL has been created |
1852 | - if (!empty($duo_redirect_url) && isset($duo_redirect_url) && filter_var($duo_redirect_url,FILTER_SANITIZE_URL)) { |
|
1851 | + if (!empty($duo_redirect_url) && isset($duo_redirect_url) && filter_var($duo_redirect_url, FILTER_SANITIZE_URL)) { |
|
1853 | 1852 | // Since Duo Universal requires a redirect, let's store some info when the user get's back after completing the Duo prompt |
1854 | 1853 | $key = hash('sha256', $duo_state); |
1855 | 1854 | $iv = substr(hash('sha256', $duo_state), 0, 16); |
@@ -1877,7 +1876,7 @@ discard block |
||
1877 | 1876 | } else { |
1878 | 1877 | return [ |
1879 | 1878 | 'error' => true, |
1880 | - 'message' => $duo_error . langHdl('duo_error_url'), |
|
1879 | + 'message' => $duo_error.langHdl('duo_error_url'), |
|
1881 | 1880 | 'pwd_attempts' => (int) $sessionPwdAttempts, |
1882 | 1881 | 'proceedIdentification' => false, |
1883 | 1882 | ]; |
@@ -1898,8 +1897,8 @@ discard block |
||
1898 | 1897 | // return the response (which should be the user name) |
1899 | 1898 | if ($decoded_token['preferred_username'] === $username) { |
1900 | 1899 | $superGlobal->put('duo_status', 'COMPLET', 'SESSION'); |
1901 | - $superGlobal->forget('duo_state','SESSION'); |
|
1902 | - $superGlobal->forget('duo_data','SESSION'); |
|
1900 | + $superGlobal->forget('duo_state', 'SESSION'); |
|
1901 | + $superGlobal->forget('duo_data', 'SESSION'); |
|
1903 | 1902 | $superGlobal->put('login', $username, 'SESSION'); |
1904 | 1903 | //unset($superGlobal); |
1905 | 1904 | |
@@ -1911,9 +1910,9 @@ discard block |
||
1911 | 1910 | ]; |
1912 | 1911 | } else { |
1913 | 1912 | // Something wrong, username from the original Duo request is different than the one received now |
1914 | - $superGlobal->forget('duo_status','SESSION'); |
|
1915 | - $superGlobal->forget('duo_state','SESSION'); |
|
1916 | - $superGlobal->forget('duo_data','SESSION'); |
|
1913 | + $superGlobal->forget('duo_status', 'SESSION'); |
|
1914 | + $superGlobal->forget('duo_state', 'SESSION'); |
|
1915 | + $superGlobal->forget('duo_data', 'SESSION'); |
|
1917 | 1916 | unset($superGlobal); |
1918 | 1917 | |
1919 | 1918 | return [ |
@@ -1925,9 +1924,9 @@ discard block |
||
1925 | 1924 | } |
1926 | 1925 | } |
1927 | 1926 | // If we are here something wrong |
1928 | - $superGlobal->forget('duo_status','SESSION'); |
|
1929 | - $superGlobal->forget('duo_state','SESSION'); |
|
1930 | - $superGlobal->forget('duo_data','SESSION'); |
|
1927 | + $superGlobal->forget('duo_status', 'SESSION'); |
|
1928 | + $superGlobal->forget('duo_state', 'SESSION'); |
|
1929 | + $superGlobal->forget('duo_data', 'SESSION'); |
|
1931 | 1930 | unset($superGlobal); |
1932 | 1931 | return [ |
1933 | 1932 | 'error' => true, |
@@ -2084,8 +2083,8 @@ discard block |
||
2084 | 2083 | public function get_user_info($login, $enable_ad_user_auto_creation) { |
2085 | 2084 | $data = DB::queryFirstRow( |
2086 | 2085 | 'SELECT u.*, a.value AS api_key |
2087 | - FROM ' . prefixTable('users') . ' AS u |
|
2088 | - LEFT JOIN ' . prefixTable('api') . ' AS a ON (u.id = a.user_id) |
|
2086 | + FROM ' . prefixTable('users').' AS u |
|
2087 | + LEFT JOIN ' . prefixTable('api').' AS a ON (u.id = a.user_id) |
|
2089 | 2088 | WHERE login = %s AND deleted_at IS NULL', |
2090 | 2089 | $login |
2091 | 2090 | ); |
@@ -2434,16 +2433,16 @@ discard block |
||
2434 | 2433 | |
2435 | 2434 | if ($ret['error'] !== false) { |
2436 | 2435 | logEvents($SETTINGS, 'failed_auth', 'bad_duo_mfa', '', stripslashes($username), stripslashes($username)); |
2437 | - $superGlobal->forget('duo_state','SESSION'); |
|
2438 | - $superGlobal->forget('duo_data','SESSION'); |
|
2439 | - $superGlobal->forget('duo_status','SESSION'); |
|
2436 | + $superGlobal->forget('duo_state', 'SESSION'); |
|
2437 | + $superGlobal->forget('duo_data', 'SESSION'); |
|
2438 | + $superGlobal->forget('duo_status', 'SESSION'); |
|
2440 | 2439 | unset($superGlobal); |
2441 | 2440 | return [ |
2442 | 2441 | 'error' => true, |
2443 | 2442 | 'mfaData' => $ret, |
2444 | 2443 | 'mfaQRCodeInfos' => false, |
2445 | 2444 | ]; |
2446 | - } else if ($ret['duo_url_ready'] === true){ |
|
2445 | + } else if ($ret['duo_url_ready'] === true) { |
|
2447 | 2446 | return [ |
2448 | 2447 | 'error' => false, |
2449 | 2448 | 'mfaData' => $ret, |
@@ -67,7 +67,7 @@ discard block |
||
67 | 67 | ) { |
68 | 68 | // Not allowed page |
69 | 69 | $_SESSION['error']['code'] = ERR_NOT_ALLOWED; |
70 | - include $SETTINGS['cpassman_dir'] . '/error.php'; |
|
70 | + include $SETTINGS['cpassman_dir'].'/error.php'; |
|
71 | 71 | exit; |
72 | 72 | } |
73 | 73 | |
@@ -541,8 +541,7 @@ discard block |
||
541 | 541 | $post_masked = filter_var($dataReceived['masked'], FILTER_SANITIZE_FULL_SPECIAL_CHARS); |
542 | 542 | $post_encrypted = filter_var($dataReceived['encrypted'], FILTER_SANITIZE_FULL_SPECIAL_CHARS); |
543 | 543 | $post_roles = filter_var_array($dataReceived['roles'], FILTER_SANITIZE_FULL_SPECIAL_CHARS); |
544 | - $post_fieldId = isset($dataReceived['fieldId']) === false ? '' : |
|
545 | - filter_var($dataReceived['fieldId'], FILTER_SANITIZE_NUMBER_INT); |
|
544 | + $post_fieldId = isset($dataReceived['fieldId']) === false ? '' : filter_var($dataReceived['fieldId'], FILTER_SANITIZE_NUMBER_INT); |
|
546 | 545 | |
547 | 546 | if (empty($post_fieldId) === false) { |
548 | 547 | // UPDATE FIELD |
@@ -558,7 +557,7 @@ discard block |
||
558 | 557 | 'encrypted_data' => $post_encrypted, |
559 | 558 | 'is_mandatory' => $post_mandatory, |
560 | 559 | 'masked' => $post_masked, |
561 | - 'role_visibility' => is_null($post_roles) === true || count($post_roles) ===0 ? '' : implode(',', $post_roles), |
|
560 | + 'role_visibility' => is_null($post_roles) === true || count($post_roles) === 0 ? '' : implode(',', $post_roles), |
|
562 | 561 | 'order' => calculateOrder($post_fieldId, $post_order), |
563 | 562 | ), |
564 | 563 | 'id = %i', |
@@ -45,7 +45,7 @@ discard block |
||
45 | 45 | { |
46 | 46 | $superGlobal = new SuperGlobal(); |
47 | 47 | $uri = parse_url($superGlobal->get('REQUEST_URI', 'SERVER'), PHP_URL_PATH); |
48 | - $uri = explode( '/', $uri ); |
|
48 | + $uri = explode('/', $uri); |
|
49 | 49 | return $this->sanitizeUrl(array_slice($uri, ((int) array_search('index.php', $uri) + 1))); |
50 | 50 | } |
51 | 51 | |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | { |
72 | 72 | $filters = []; |
73 | 73 | $array_size = count($array); |
74 | - for ($i=0; $i < $array_size; $i++) { |
|
74 | + for ($i = 0; $i < $array_size; $i++) { |
|
75 | 75 | array_push($filters, 'trim|escape'); |
76 | 76 | } |
77 | 77 | |
@@ -89,7 +89,7 @@ discard block |
||
89 | 89 | * @param mixed $data |
90 | 90 | * @param string $httpHeader |
91 | 91 | */ |
92 | - protected function sendOutput($data, $httpHeaders=array()): void |
|
92 | + protected function sendOutput($data, $httpHeaders = array()): void |
|
93 | 93 | { |
94 | 94 | header_remove('Set-Cookie'); |
95 | 95 |
@@ -26,10 +26,10 @@ discard block |
||
26 | 26 | |
27 | 27 | Use TeampassClasses\SuperGlobal\SuperGlobal; |
28 | 28 | |
29 | -define("API_ROOT_PATH", __DIR__ . "/.."); |
|
29 | +define("API_ROOT_PATH", __DIR__."/.."); |
|
30 | 30 | |
31 | 31 | // include main configuration file |
32 | -require API_ROOT_PATH . '/../sources/main.functions.php'; |
|
32 | +require API_ROOT_PATH.'/../sources/main.functions.php'; |
|
33 | 33 | |
34 | 34 | // init |
35 | 35 | loadClasses('DB'); |
@@ -38,12 +38,12 @@ discard block |
||
38 | 38 | $superGlobal = new SuperGlobal(); |
39 | 39 | |
40 | 40 | // include the base controller file |
41 | -require API_ROOT_PATH . "/Controller/Api/BaseController.php"; |
|
41 | +require API_ROOT_PATH."/Controller/Api/BaseController.php"; |
|
42 | 42 | |
43 | 43 | // include the use model file |
44 | -require API_ROOT_PATH . "/Model/UserModel.php"; |
|
45 | -require API_ROOT_PATH . "/Model/ItemModel.php"; |
|
46 | -require API_ROOT_PATH . "/Model/FolderModel.php"; |
|
44 | +require API_ROOT_PATH."/Model/UserModel.php"; |
|
45 | +require API_ROOT_PATH."/Model/ItemModel.php"; |
|
46 | +require API_ROOT_PATH."/Model/FolderModel.php"; |
|
47 | 47 | |
48 | 48 | /** |
49 | 49 | * Launch expected action for ITEM |
@@ -54,10 +54,10 @@ discard block |
||
54 | 54 | */ |
55 | 55 | function itemAction(array $actions, array $userData) |
56 | 56 | { |
57 | - require API_ROOT_PATH . "/Controller/Api/ItemController.php"; |
|
57 | + require API_ROOT_PATH."/Controller/Api/ItemController.php"; |
|
58 | 58 | |
59 | 59 | $objFeedController = new ItemController(); |
60 | - $strMethodName = $actions[0] . 'Action'; |
|
60 | + $strMethodName = $actions[0].'Action'; |
|
61 | 61 | $objFeedController->{$strMethodName}($userData); |
62 | 62 | } |
63 | 63 | |
@@ -70,10 +70,10 @@ discard block |
||
70 | 70 | */ |
71 | 71 | function folderAction(array $actions, array $userData) |
72 | 72 | { |
73 | - require API_ROOT_PATH . "/Controller/Api/FolderController.php"; |
|
73 | + require API_ROOT_PATH."/Controller/Api/FolderController.php"; |
|
74 | 74 | |
75 | 75 | $objFeedController = new FolderController(); |
76 | - $strMethodName = $actions[0] . 'Action'; |
|
76 | + $strMethodName = $actions[0].'Action'; |
|
77 | 77 | $objFeedController->{$strMethodName}($userData); |
78 | 78 | } |
79 | 79 | |
@@ -84,7 +84,7 @@ discard block |
||
84 | 84 | */ |
85 | 85 | function apiIsEnabled(): string |
86 | 86 | { |
87 | - require API_ROOT_PATH . '/../includes/config/tp.config.php'; |
|
87 | + require API_ROOT_PATH.'/../includes/config/tp.config.php'; |
|
88 | 88 | |
89 | 89 | if ((int) $SETTINGS['api'] === 1) { |
90 | 90 | return json_encode( |
@@ -113,7 +113,7 @@ discard block |
||
113 | 113 | */ |
114 | 114 | function verifyAuth(): string |
115 | 115 | { |
116 | - include_once API_ROOT_PATH . '/inc/jwt_utils.php'; |
|
116 | + include_once API_ROOT_PATH.'/inc/jwt_utils.php'; |
|
117 | 117 | $bearer_token = get_bearer_token(); |
118 | 118 | |
119 | 119 | if (empty($bearer_token) === false && is_jwt_valid($bearer_token) === true) { |
@@ -143,7 +143,7 @@ discard block |
||
143 | 143 | */ |
144 | 144 | function getDataFromToken(): string |
145 | 145 | { |
146 | - include_once API_ROOT_PATH . '/inc/jwt_utils.php'; |
|
146 | + include_once API_ROOT_PATH.'/inc/jwt_utils.php'; |
|
147 | 147 | $bearer_token = get_bearer_token(); |
148 | 148 | |
149 | 149 | if (empty($bearer_token) === false) { |
@@ -26,43 +26,43 @@ discard block |
||
26 | 26 | Use TeampassClasses\SuperGlobal\SuperGlobal; |
27 | 27 | |
28 | 28 | function generate_jwt($headers, $payload) { |
29 | - $headers_encoded = base64url_encode(json_encode($headers)); |
|
29 | + $headers_encoded = base64url_encode(json_encode($headers)); |
|
30 | 30 | |
31 | - $payload_encoded = base64url_encode(json_encode($payload)); |
|
31 | + $payload_encoded = base64url_encode(json_encode($payload)); |
|
32 | 32 | |
33 | - $signature = hash_hmac('SHA256', "$headers_encoded.$payload_encoded", DB_PASSWD, true); |
|
34 | - $signature_encoded = base64url_encode($signature); |
|
33 | + $signature = hash_hmac('SHA256', "$headers_encoded.$payload_encoded", DB_PASSWD, true); |
|
34 | + $signature_encoded = base64url_encode($signature); |
|
35 | 35 | |
36 | - $jwt = "$headers_encoded.$payload_encoded.$signature_encoded"; |
|
36 | + $jwt = "$headers_encoded.$payload_encoded.$signature_encoded"; |
|
37 | 37 | |
38 | - return $jwt; |
|
38 | + return $jwt; |
|
39 | 39 | } |
40 | 40 | |
41 | 41 | function is_jwt_valid($jwt) { |
42 | - // split the jwt |
|
43 | - $tokenParts = explode('.', $jwt); |
|
44 | - $header = base64_decode($tokenParts[0]); |
|
45 | - $payload = base64_decode($tokenParts[1]); |
|
46 | - $signature_provided = $tokenParts[2]; |
|
42 | + // split the jwt |
|
43 | + $tokenParts = explode('.', $jwt); |
|
44 | + $header = base64_decode($tokenParts[0]); |
|
45 | + $payload = base64_decode($tokenParts[1]); |
|
46 | + $signature_provided = $tokenParts[2]; |
|
47 | 47 | |
48 | - // check the expiration time - note this will cause an error if there is no 'exp' claim in the jwt |
|
49 | - $expiration = json_decode($payload)->exp; |
|
50 | - $is_token_expired = ($expiration - time()) < 0; |
|
48 | + // check the expiration time - note this will cause an error if there is no 'exp' claim in the jwt |
|
49 | + $expiration = json_decode($payload)->exp; |
|
50 | + $is_token_expired = ($expiration - time()) < 0; |
|
51 | 51 | |
52 | - // build a signature based on the header and payload using the secret |
|
53 | - $base64_url_header = base64url_encode($header); |
|
54 | - $base64_url_payload = base64url_encode($payload); |
|
55 | - $signature = hash_hmac('SHA256', $base64_url_header . "." . $base64_url_payload, DB_PASSWD, true); |
|
56 | - $base64_url_signature = base64url_encode($signature); |
|
52 | + // build a signature based on the header and payload using the secret |
|
53 | + $base64_url_header = base64url_encode($header); |
|
54 | + $base64_url_payload = base64url_encode($payload); |
|
55 | + $signature = hash_hmac('SHA256', $base64_url_header . "." . $base64_url_payload, DB_PASSWD, true); |
|
56 | + $base64_url_signature = base64url_encode($signature); |
|
57 | 57 | |
58 | - // verify it matches the signature provided in the jwt |
|
59 | - $is_signature_valid = ($base64_url_signature === $signature_provided); |
|
58 | + // verify it matches the signature provided in the jwt |
|
59 | + $is_signature_valid = ($base64_url_signature === $signature_provided); |
|
60 | 60 | |
61 | - if ($is_token_expired || !$is_signature_valid) { |
|
62 | - return FALSE; |
|
63 | - } else { |
|
64 | - return TRUE; |
|
65 | - } |
|
61 | + if ($is_token_expired || !$is_signature_valid) { |
|
62 | + return FALSE; |
|
63 | + } else { |
|
64 | + return TRUE; |
|
65 | + } |
|
66 | 66 | } |
67 | 67 | |
68 | 68 | function base64url_encode($data) { |
@@ -70,24 +70,24 @@ discard block |
||
70 | 70 | } |
71 | 71 | |
72 | 72 | function get_authorization_header(){ |
73 | - $superGlobal = new SuperGlobal(); |
|
74 | - $headers = null; |
|
73 | + $superGlobal = new SuperGlobal(); |
|
74 | + $headers = null; |
|
75 | 75 | |
76 | - if (null !== $superGlobal->get('Authorization', 'SERVER')) { |
|
77 | - $headers = trim($superGlobal->get('Authorization', 'SERVER')); |
|
78 | - } else if (null !== $superGlobal->get('HTTP_AUTHORIZATION', 'SERVER')) { //Nginx or fast CGI |
|
79 | - $headers = trim($superGlobal->get('HTTP_AUTHORIZATION', 'SERVER')); |
|
80 | - } else if (function_exists('apache_request_headers') === true) { |
|
81 | - $requestHeaders = (array) apache_request_headers(); |
|
82 | - // Server-side fix for bug in old Android versions (a nice side-effect of this fix means we don't care about capitalization for Authorization) |
|
83 | - $requestHeaders = array_combine(array_map('ucwords', array_keys($requestHeaders)), array_values($requestHeaders)); |
|
84 | - //print_r($requestHeaders); |
|
85 | - if (isset($requestHeaders['Authorization']) === true) { |
|
86 | - $headers = trim($requestHeaders['Authorization']); |
|
87 | - } |
|
88 | - } |
|
76 | + if (null !== $superGlobal->get('Authorization', 'SERVER')) { |
|
77 | + $headers = trim($superGlobal->get('Authorization', 'SERVER')); |
|
78 | + } else if (null !== $superGlobal->get('HTTP_AUTHORIZATION', 'SERVER')) { //Nginx or fast CGI |
|
79 | + $headers = trim($superGlobal->get('HTTP_AUTHORIZATION', 'SERVER')); |
|
80 | + } else if (function_exists('apache_request_headers') === true) { |
|
81 | + $requestHeaders = (array) apache_request_headers(); |
|
82 | + // Server-side fix for bug in old Android versions (a nice side-effect of this fix means we don't care about capitalization for Authorization) |
|
83 | + $requestHeaders = array_combine(array_map('ucwords', array_keys($requestHeaders)), array_values($requestHeaders)); |
|
84 | + //print_r($requestHeaders); |
|
85 | + if (isset($requestHeaders['Authorization']) === true) { |
|
86 | + $headers = trim($requestHeaders['Authorization']); |
|
87 | + } |
|
88 | + } |
|
89 | 89 | |
90 | - return $headers; |
|
90 | + return $headers; |
|
91 | 91 | } |
92 | 92 | |
93 | 93 | function get_bearer_token() { |
@@ -104,8 +104,8 @@ discard block |
||
104 | 104 | |
105 | 105 | function get_bearer_data($jwt) { |
106 | 106 | // split the jwt |
107 | - $tokenParts = explode('.', $jwt); |
|
108 | - $payload = base64_decode($tokenParts[1]); |
|
107 | + $tokenParts = explode('.', $jwt); |
|
108 | + $payload = base64_decode($tokenParts[1]); |
|
109 | 109 | |
110 | 110 | // HEADER: Get the access token from the header |
111 | 111 | if (empty($payload) === false) { |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | // build a signature based on the header and payload using the secret |
53 | 53 | $base64_url_header = base64url_encode($header); |
54 | 54 | $base64_url_payload = base64url_encode($payload); |
55 | - $signature = hash_hmac('SHA256', $base64_url_header . "." . $base64_url_payload, DB_PASSWD, true); |
|
55 | + $signature = hash_hmac('SHA256', $base64_url_header.".".$base64_url_payload, DB_PASSWD, true); |
|
56 | 56 | $base64_url_signature = base64url_encode($signature); |
57 | 57 | |
58 | 58 | // verify it matches the signature provided in the jwt |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | return rtrim(strtr(base64_encode($data), '+/', '-_'), '='); |
70 | 70 | } |
71 | 71 | |
72 | -function get_authorization_header(){ |
|
72 | +function get_authorization_header() { |
|
73 | 73 | $superGlobal = new SuperGlobal(); |
74 | 74 | $headers = null; |
75 | 75 |
@@ -24,7 +24,7 @@ discard block |
||
24 | 24 | */ |
25 | 25 | Use TeampassClasses\NestedTree\NestedTree; |
26 | 26 | |
27 | -require_once API_ROOT_PATH . "/Model/Database.php"; |
|
27 | +require_once API_ROOT_PATH."/Model/Database.php"; |
|
28 | 28 | |
29 | 29 | class ItemModel extends Database |
30 | 30 | { |
@@ -46,15 +46,15 @@ discard block |
||
46 | 46 | "SELECT i.id, label, description, i.pw, i.url, i.id_tree, i.login, i.email, i.viewed_no, i.fa_icon, i.inactif, i.perso, t.title as folder_label |
47 | 47 | FROM ".prefixTable('items')." as i |
48 | 48 | LEFT JOIN ".prefixTable('nested_tree')." as t ON (t.id = i.id_tree) ". |
49 | - $sqlExtra . |
|
50 | - " ORDER BY i.id ASC" . |
|
51 | - ($limit > 0 ? " LIMIT ?". ["i", $limit] : '') |
|
49 | + $sqlExtra. |
|
50 | + " ORDER BY i.id ASC". |
|
51 | + ($limit > 0 ? " LIMIT ?".["i", $limit] : '') |
|
52 | 52 | ); |
53 | 53 | $ret = []; |
54 | 54 | foreach ($rows as $row) { |
55 | 55 | $userKey = $this->select( |
56 | 56 | 'SELECT share_key |
57 | - FROM ' . prefixTable('sharekeys_items') . ' |
|
57 | + FROM ' . prefixTable('sharekeys_items').' |
|
58 | 58 | WHERE user_id = '.$userId.' AND object_id = '.$row['id'] |
59 | 59 | ); |
60 | 60 | if (count($userKey) === 0 || empty($row['pw']) === true) { |
@@ -88,7 +88,7 @@ discard block |
||
88 | 88 | if (empty($path) === true) { |
89 | 89 | $path = htmlspecialchars(stripslashes(htmlspecialchars_decode($elem->title, ENT_QUOTES)), ENT_QUOTES); |
90 | 90 | } else { |
91 | - $path .= '/' . htmlspecialchars(stripslashes(htmlspecialchars_decode($elem->title, ENT_QUOTES)), ENT_QUOTES); |
|
91 | + $path .= '/'.htmlspecialchars(stripslashes(htmlspecialchars_decode($elem->title, ENT_QUOTES)), ENT_QUOTES); |
|
92 | 92 | } |
93 | 93 | } |
94 | 94 |