@@ -33,7 +33,7 @@ discard block |
||
| 33 | 33 | use Symfony\Component\HttpFoundation\Request as SymfonyRequest; |
| 34 | 34 | |
| 35 | 35 | // Load functions |
| 36 | -require_once __DIR__. '/includes/config/include.php'; |
|
| 36 | +require_once __DIR__.'/includes/config/include.php'; |
|
| 37 | 37 | require_once __DIR__.'/sources/main.functions.php'; |
| 38 | 38 | |
| 39 | 39 | // init |
@@ -53,10 +53,10 @@ discard block |
||
| 53 | 53 | // Check for existing lock |
| 54 | 54 | $result = DB::queryFirstField( |
| 55 | 55 | 'SELECT 1 |
| 56 | - FROM ' . prefixTable('auth_failures') . ' |
|
| 56 | + FROM ' . prefixTable('auth_failures').' |
|
| 57 | 57 | WHERE unlock_at = ( |
| 58 | 58 | SELECT MAX(unlock_at) |
| 59 | - FROM ' . prefixTable('auth_failures') . ' |
|
| 59 | + FROM ' . prefixTable('auth_failures').' |
|
| 60 | 60 | WHERE unlock_at > %s |
| 61 | 61 | AND source = %s AND value = %s) |
| 62 | 62 | AND unlock_code = %s', |
@@ -2663,7 +2663,7 @@ |
||
| 2663 | 2663 | 'SELECT email, name |
| 2664 | 2664 | FROM '.prefixTable('users').' |
| 2665 | 2665 | WHERE login = %s', |
| 2666 | - $value |
|
| 2666 | + $value |
|
| 2667 | 2667 | ); |
| 2668 | 2668 | |
| 2669 | 2669 | // No valid email address for user |
@@ -2401,7 +2401,9 @@ discard block |
||
| 2401 | 2401 | // Complete $userInfo |
| 2402 | 2402 | $userInfo['has_been_created'] = 1; |
| 2403 | 2403 | |
| 2404 | - if (WIP === true) error_log("--- USER CREATED ---"); |
|
| 2404 | + if (WIP === true) { |
|
| 2405 | + error_log("--- USER CREATED ---"); |
|
| 2406 | + } |
|
| 2405 | 2407 | |
| 2406 | 2408 | return [ |
| 2407 | 2409 | 'error' => false, |
@@ -2437,7 +2439,9 @@ discard block |
||
| 2437 | 2439 | } |
| 2438 | 2440 | |
| 2439 | 2441 | // Oauth2 user already exists and authenticated |
| 2440 | - if (WIP === true) error_log("--- USER AUTHENTICATED ---"); |
|
| 2442 | + if (WIP === true) { |
|
| 2443 | + error_log("--- USER AUTHENTICATED ---"); |
|
| 2444 | + } |
|
| 2441 | 2445 | $userInfo['has_been_created'] = 0; |
| 2442 | 2446 | |
| 2443 | 2447 | $passwordManager = new PasswordManager(); |
@@ -2667,8 +2671,9 @@ discard block |
||
| 2667 | 2671 | ); |
| 2668 | 2672 | |
| 2669 | 2673 | // No valid email address for user |
| 2670 | - if (!$userInfos || !filter_var($userInfos['email'], FILTER_VALIDATE_EMAIL)) |
|
| 2671 | - return; |
|
| 2674 | + if (!$userInfos || !filter_var($userInfos['email'], FILTER_VALIDATE_EMAIL)) { |
|
| 2675 | + return; |
|
| 2676 | + } |
|
| 2672 | 2677 | |
| 2673 | 2678 | $unlock_url = $SETTINGS['cpassman_url'].'/self-unlock.php?login='.$value.'&otp='.$unlock_code; |
| 2674 | 2679 | |
@@ -147,7 +147,7 @@ discard block |
||
| 147 | 147 | $sessionPwdAttempts = $session->get('pwd_attempts'); |
| 148 | 148 | $sessionUrl = $session->get('user-initial_url'); |
| 149 | 149 | $server = []; |
| 150 | - $server['PHP_AUTH_USER'] = $request->getUser(); |
|
| 150 | + $server['PHP_AUTH_USER'] = $request->getUser(); |
|
| 151 | 151 | $server['PHP_AUTH_PW'] = $request->getPassword(); |
| 152 | 152 | |
| 153 | 153 | // decrypt and retreive data in JSON format |
@@ -167,18 +167,18 @@ discard block |
||
| 167 | 167 | } |
| 168 | 168 | |
| 169 | 169 | // Check if Duo auth is in progress and pass the pw and login back to the standard login process |
| 170 | - if( |
|
| 170 | + if ( |
|
| 171 | 171 | isKeyExistingAndEqual('duo', 1, $SETTINGS) === true |
| 172 | 172 | && $dataReceived['user_2fa_selection'] === 'duo' |
| 173 | 173 | && $session->get('user-duo_status') === 'IN_PROGRESS' |
| 174 | 174 | && !empty($dataReceived['duo_state']) |
| 175 | - ){ |
|
| 175 | + ) { |
|
| 176 | 176 | $key = hash('sha256', $dataReceived['duo_state']); |
| 177 | 177 | $iv = substr(hash('sha256', $dataReceived['duo_state']), 0, 16); |
| 178 | 178 | $duo_data_dec = openssl_decrypt(base64_decode($session->get('user-duo_data')), 'AES-256-CBC', $key, 0, $iv); |
| 179 | 179 | // Clear the data from the Duo process to continue clean with the standard login process |
| 180 | - $session->set('user-duo_data',''); |
|
| 181 | - if($duo_data_dec === false) { |
|
| 180 | + $session->set('user-duo_data', ''); |
|
| 181 | + if ($duo_data_dec === false) { |
|
| 182 | 182 | // Add failed authentication log |
| 183 | 183 | addFailedAuthentication(filter_var($dataReceived['login'], FILTER_SANITIZE_FULL_SPECIAL_CHARS), getClientIpServer()); |
| 184 | 184 | |
@@ -196,7 +196,7 @@ discard block |
||
| 196 | 196 | $dataReceived['login'] = $duo_data['duo_login']; |
| 197 | 197 | } |
| 198 | 198 | |
| 199 | - if(isset($dataReceived['pw']) === false || isset($dataReceived['login']) === false) { |
|
| 199 | + if (isset($dataReceived['pw']) === false || isset($dataReceived['login']) === false) { |
|
| 200 | 200 | echo json_encode([ |
| 201 | 201 | 'data' => prepareExchangedData( |
| 202 | 202 | [ |
@@ -542,7 +542,7 @@ discard block |
||
| 542 | 542 | } |
| 543 | 543 | // Append with roles from AD groups |
| 544 | 544 | if (is_null($userInfo['roles_from_ad_groups']) === false) { |
| 545 | - $userInfo['fonction_id'] = empty($userInfo['fonction_id']) === true ? $userInfo['roles_from_ad_groups'] : $userInfo['fonction_id']. ';' . $userInfo['roles_from_ad_groups']; |
|
| 545 | + $userInfo['fonction_id'] = empty($userInfo['fonction_id']) === true ? $userInfo['roles_from_ad_groups'] : $userInfo['fonction_id'].';'.$userInfo['roles_from_ad_groups']; |
|
| 546 | 546 | } |
| 547 | 547 | // store |
| 548 | 548 | $session->set('user-roles', $userInfo['fonction_id']); |
@@ -554,7 +554,7 @@ discard block |
||
| 554 | 554 | if (count($session->get('user-roles_array')) > 0) { |
| 555 | 555 | $rolesList = DB::query( |
| 556 | 556 | 'SELECT id, title, complexity |
| 557 | - FROM ' . prefixTable('roles_title') . ' |
|
| 557 | + FROM ' . prefixTable('roles_title').' |
|
| 558 | 558 | WHERE id IN %li', |
| 559 | 559 | $session->get('user-roles_array') |
| 560 | 560 | ); |
@@ -600,7 +600,7 @@ discard block |
||
| 600 | 600 | if ($adjustPermissions) { |
| 601 | 601 | $session->set('user-admin', (int) $userInfo['admin']); |
| 602 | 602 | $session->set('user-manager', (int) $userInfo['gestionnaire']); |
| 603 | - $session->set('user-can_manage_all_users',(int) $userInfo['can_manage_all_users']); |
|
| 603 | + $session->set('user-can_manage_all_users', (int) $userInfo['can_manage_all_users']); |
|
| 604 | 604 | $session->set('user-read_only', (int) $userInfo['read_only']); |
| 605 | 605 | DB::update( |
| 606 | 606 | prefixTable('users'), |
@@ -669,10 +669,10 @@ discard block |
||
| 669 | 669 | // Get last seen items |
| 670 | 670 | $session->set('user-nb_roles', 0); |
| 671 | 671 | foreach ($session->get('user-latest_items') as $item) { |
| 672 | - if (! empty($item)) { |
|
| 672 | + if (!empty($item)) { |
|
| 673 | 673 | $dataLastItems = DB::queryFirstRow( |
| 674 | 674 | 'SELECT id,label,id_tree |
| 675 | - FROM ' . prefixTable('items') . ' |
|
| 675 | + FROM ' . prefixTable('items').' |
|
| 676 | 676 | WHERE id=%i', |
| 677 | 677 | $item |
| 678 | 678 | ); |
@@ -682,7 +682,7 @@ discard block |
||
| 682 | 682 | // Get cahce tree info |
| 683 | 683 | $cacheTreeData = DB::queryFirstRow( |
| 684 | 684 | 'SELECT visible_folders |
| 685 | - FROM ' . prefixTable('cache_tree') . ' |
|
| 685 | + FROM ' . prefixTable('cache_tree').' |
|
| 686 | 686 | WHERE user_id=%i', |
| 687 | 687 | (int) $session->get('user-id') |
| 688 | 688 | ); |
@@ -714,7 +714,7 @@ discard block |
||
| 714 | 714 | && (int) $sessionAdmin !== 1 |
| 715 | 715 | ) { |
| 716 | 716 | // get all Admin users |
| 717 | - $val = DB::queryFirstRow('SELECT email FROM ' . prefixTable('users') . " WHERE admin = %i and email != ''", 1); |
|
| 717 | + $val = DB::queryFirstRow('SELECT email FROM '.prefixTable('users')." WHERE admin = %i and email != ''", 1); |
|
| 718 | 718 | if (DB::count() > 0) { |
| 719 | 719 | // Add email to table |
| 720 | 720 | prepareSendingEmail( |
@@ -726,7 +726,7 @@ discard block |
||
| 726 | 726 | '#tp_time#', |
| 727 | 727 | ], |
| 728 | 728 | [ |
| 729 | - ' ' . $session->get('user-login') . ' (IP: ' . getClientIpServer() . ')', |
|
| 729 | + ' '.$session->get('user-login').' (IP: '.getClientIpServer().')', |
|
| 730 | 730 | date($SETTINGS['date_format'], (int) $session->get('user-last_connection')), |
| 731 | 731 | date($SETTINGS['time_format'], (int) $session->get('user-last_connection')), |
| 732 | 732 | ], |
@@ -837,7 +837,7 @@ discard block |
||
| 837 | 837 | { |
| 838 | 838 | $rows = DB::query( |
| 839 | 839 | 'SELECT date |
| 840 | - FROM ' . prefixTable('log_system') . " |
|
| 840 | + FROM ' . prefixTable('log_system')." |
|
| 841 | 841 | WHERE field_1 = %s |
| 842 | 842 | AND type = 'failed_auth' |
| 843 | 843 | AND label = 'password_is_not_correct' |
@@ -851,7 +851,7 @@ discard block |
||
| 851 | 851 | foreach ($rows as $record) { |
| 852 | 852 | array_push( |
| 853 | 853 | $arrAttempts, |
| 854 | - date($SETTINGS['date_format'] . ' ' . $SETTINGS['time_format'], (int) $record['date']) |
|
| 854 | + date($SETTINGS['date_format'].' '.$SETTINGS['time_format'], (int) $record['date']) |
|
| 855 | 855 | ); |
| 856 | 856 | } |
| 857 | 857 | } |
@@ -886,7 +886,7 @@ discard block |
||
| 886 | 886 | $ldapConnection |
| 887 | 887 | ) : bool |
| 888 | 888 | { |
| 889 | - include_once $SETTINGS['cpassman_dir'] . '/sources/main.functions.php'; |
|
| 889 | + include_once $SETTINGS['cpassman_dir'].'/sources/main.functions.php'; |
|
| 890 | 890 | |
| 891 | 891 | if ((int) $userInfoDisabled === 1) { |
| 892 | 892 | return false; |
@@ -1081,7 +1081,7 @@ discard block |
||
| 1081 | 1081 | } catch (Exception $e) { |
| 1082 | 1082 | return [ |
| 1083 | 1083 | 'error' => true, |
| 1084 | - 'message' => "Error: " . $e->getMessage(), |
|
| 1084 | + 'message' => "Error: ".$e->getMessage(), |
|
| 1085 | 1085 | ]; |
| 1086 | 1086 | } |
| 1087 | 1087 | } |
@@ -1112,7 +1112,7 @@ discard block |
||
| 1112 | 1112 | 'type' => 'OpenLDAP' |
| 1113 | 1113 | ]; |
| 1114 | 1114 | default: |
| 1115 | - throw new Exception("Unsupported LDAP type: " . $SETTINGS['ldap_type']); |
|
| 1115 | + throw new Exception("Unsupported LDAP type: ".$SETTINGS['ldap_type']); |
|
| 1116 | 1116 | } |
| 1117 | 1117 | } |
| 1118 | 1118 | |
@@ -1249,7 +1249,7 @@ discard block |
||
| 1249 | 1249 | ); |
| 1250 | 1250 | } |
| 1251 | 1251 | |
| 1252 | - throw new Exception("Unsupported LDAP type: " . $ldapHandler['type']); |
|
| 1252 | + throw new Exception("Unsupported LDAP type: ".$ldapHandler['type']); |
|
| 1253 | 1253 | } |
| 1254 | 1254 | |
| 1255 | 1255 | /** |
@@ -1266,12 +1266,12 @@ discard block |
||
| 1266 | 1266 | if (isset($SETTINGS['enable_ad_users_with_ad_groups']) === true && (int) $SETTINGS['enable_ad_users_with_ad_groups'] === 1) { |
| 1267 | 1267 | // Get user groups from AD |
| 1268 | 1268 | $user_ad_groups = []; |
| 1269 | - foreach($groups as $group) { |
|
| 1269 | + foreach ($groups as $group) { |
|
| 1270 | 1270 | //print_r($group); |
| 1271 | 1271 | // get relation role id for AD group |
| 1272 | 1272 | $role = DB::queryFirstRow( |
| 1273 | 1273 | 'SELECT lgr.role_id |
| 1274 | - FROM ' . prefixTable('ldap_groups_roles') . ' AS lgr |
|
| 1274 | + FROM ' . prefixTable('ldap_groups_roles').' AS lgr |
|
| 1275 | 1275 | WHERE lgr.ldap_group_id = %s', |
| 1276 | 1276 | $group |
| 1277 | 1277 | ); |
@@ -1402,7 +1402,7 @@ discard block |
||
| 1402 | 1402 | // Check if exists in DB |
| 1403 | 1403 | $groupData = DB::queryFirstRow( |
| 1404 | 1404 | 'SELECT id |
| 1405 | - FROM ' . prefixTable('roles_title') . ' |
|
| 1405 | + FROM ' . prefixTable('roles_title').' |
|
| 1406 | 1406 | WHERE title = %s', |
| 1407 | 1407 | $group["displayName"] |
| 1408 | 1408 | ); |
@@ -1543,7 +1543,7 @@ discard block |
||
| 1543 | 1543 | |
| 1544 | 1544 | // generate new QR |
| 1545 | 1545 | $new_2fa_qr = $tfa->getQRCodeImageAsDataUri( |
| 1546 | - 'Teampass - ' . $username, |
|
| 1546 | + 'Teampass - '.$username, |
|
| 1547 | 1547 | $userInfo['ga'] |
| 1548 | 1548 | ); |
| 1549 | 1549 | // clear temporary code from DB |
@@ -1556,7 +1556,7 @@ discard block |
||
| 1556 | 1556 | $userInfo['id'] |
| 1557 | 1557 | ); |
| 1558 | 1558 | $firstTime = [ |
| 1559 | - 'value' => '<img src="' . $new_2fa_qr . '">', |
|
| 1559 | + 'value' => '<img src="'.$new_2fa_qr.'">', |
|
| 1560 | 1560 | 'user_admin' => isset($sessionAdmin) ? (int) $sessionAdmin : '', |
| 1561 | 1561 | 'initial_url' => isset($sessionUrl) === true ? $sessionUrl : '', |
| 1562 | 1562 | 'pwd_attempts' => (int) $sessionPwdAttempts, |
@@ -1712,7 +1712,7 @@ discard block |
||
| 1712 | 1712 | }*/ |
| 1713 | 1713 | return [ |
| 1714 | 1714 | 'error' => true, |
| 1715 | - 'message' => $duo_error . $lang->get('duo_error_check_config'), |
|
| 1715 | + 'message' => $duo_error.$lang->get('duo_error_check_config'), |
|
| 1716 | 1716 | 'pwd_attempts' => (int) $sessionPwdAttempts, |
| 1717 | 1717 | 'debug_message' => $e->getMessage(), |
| 1718 | 1718 | 'proceedIdentification' => false, |
@@ -1728,7 +1728,7 @@ discard block |
||
| 1728 | 1728 | } catch (DuoException $e) { |
| 1729 | 1729 | return [ |
| 1730 | 1730 | 'error' => true, |
| 1731 | - 'message' => $duo_error . $lang->get('duo_error_url'), |
|
| 1731 | + 'message' => $duo_error.$lang->get('duo_error_url'), |
|
| 1732 | 1732 | 'pwd_attempts' => (int) $sessionPwdAttempts, |
| 1733 | 1733 | 'debug_message' => $e->getMessage(), |
| 1734 | 1734 | 'proceedIdentification' => false, |
@@ -1736,7 +1736,7 @@ discard block |
||
| 1736 | 1736 | } |
| 1737 | 1737 | |
| 1738 | 1738 | // Somethimes Duo return success but fail to return a URL, double check if the URL has been created |
| 1739 | - if (!empty($duo_redirect_url) && filter_var($duo_redirect_url,FILTER_SANITIZE_URL)) { |
|
| 1739 | + if (!empty($duo_redirect_url) && filter_var($duo_redirect_url, FILTER_SANITIZE_URL)) { |
|
| 1740 | 1740 | // Since Duo Universal requires a redirect, let's store some info when the user get's back after completing the Duo prompt |
| 1741 | 1741 | $key = hash('sha256', $duo_state); |
| 1742 | 1742 | $iv = substr(hash('sha256', $duo_state), 0, 16); |
@@ -1764,7 +1764,7 @@ discard block |
||
| 1764 | 1764 | } else { |
| 1765 | 1765 | return [ |
| 1766 | 1766 | 'error' => true, |
| 1767 | - 'message' => $duo_error . $lang->get('duo_error_url'), |
|
| 1767 | + 'message' => $duo_error.$lang->get('duo_error_url'), |
|
| 1768 | 1768 | 'pwd_attempts' => (int) $sessionPwdAttempts, |
| 1769 | 1769 | 'proceedIdentification' => false, |
| 1770 | 1770 | ]; |
@@ -1785,8 +1785,8 @@ discard block |
||
| 1785 | 1785 | // return the response (which should be the user name) |
| 1786 | 1786 | if ($decoded_token['preferred_username'] === $username) { |
| 1787 | 1787 | $session->set('user-duo_status', 'COMPLET'); |
| 1788 | - $session->set('user-duo_state',''); |
|
| 1789 | - $session->set('user-duo_data',''); |
|
| 1788 | + $session->set('user-duo_state', ''); |
|
| 1789 | + $session->set('user-duo_data', ''); |
|
| 1790 | 1790 | $session->set('user-login', $username); |
| 1791 | 1791 | |
| 1792 | 1792 | return [ |
@@ -1797,9 +1797,9 @@ discard block |
||
| 1797 | 1797 | ]; |
| 1798 | 1798 | } else { |
| 1799 | 1799 | // Something wrong, username from the original Duo request is different than the one received now |
| 1800 | - $session->set('user-duo_status',''); |
|
| 1801 | - $session->set('user-duo_state',''); |
|
| 1802 | - $session->set('user-duo_data',''); |
|
| 1800 | + $session->set('user-duo_status', ''); |
|
| 1801 | + $session->set('user-duo_state', ''); |
|
| 1802 | + $session->set('user-duo_data', ''); |
|
| 1803 | 1803 | |
| 1804 | 1804 | return [ |
| 1805 | 1805 | 'error' => true, |
@@ -1810,9 +1810,9 @@ discard block |
||
| 1810 | 1810 | } |
| 1811 | 1811 | } |
| 1812 | 1812 | // If we are here something wrong |
| 1813 | - $session->set('user-duo_status',''); |
|
| 1814 | - $session->set('user-duo_state',''); |
|
| 1815 | - $session->set('user-duo_data',''); |
|
| 1813 | + $session->set('user-duo_status', ''); |
|
| 1814 | + $session->set('user-duo_state', ''); |
|
| 1815 | + $session->set('user-duo_data', ''); |
|
| 1816 | 1816 | return [ |
| 1817 | 1817 | 'error' => true, |
| 1818 | 1818 | 'message' => $lang->get('duo_login_mismatch'), |
@@ -1924,7 +1924,7 @@ discard block |
||
| 1924 | 1924 | // Check for existing lock |
| 1925 | 1925 | $unlock_at = DB::queryFirstField( |
| 1926 | 1926 | 'SELECT MAX(unlock_at) |
| 1927 | - FROM ' . prefixTable('auth_failures') . ' |
|
| 1927 | + FROM ' . prefixTable('auth_failures').' |
|
| 1928 | 1928 | WHERE unlock_at > %s |
| 1929 | 1929 | AND ((source = %s AND value = %s) OR (source = %s AND value = %s))', |
| 1930 | 1930 | date('Y-m-d H:i:s', time()), |
@@ -1946,8 +1946,8 @@ discard block |
||
| 1946 | 1946 | // Get user info from DB |
| 1947 | 1947 | $data = DB::queryFirstRow( |
| 1948 | 1948 | 'SELECT u.*, a.value AS api_key |
| 1949 | - FROM ' . prefixTable('users') . ' AS u |
|
| 1950 | - LEFT JOIN ' . prefixTable('api') . ' AS a ON (u.id = a.user_id) |
|
| 1949 | + FROM ' . prefixTable('users').' AS u |
|
| 1950 | + LEFT JOIN ' . prefixTable('api').' AS a ON (u.id = a.user_id) |
|
| 1951 | 1951 | WHERE login = %s AND deleted_at IS NULL', |
| 1952 | 1952 | $login |
| 1953 | 1953 | ); |
@@ -2065,7 +2065,7 @@ discard block |
||
| 2065 | 2065 | 'array' => [ |
| 2066 | 2066 | 'value' => 'bruteforce_wait', |
| 2067 | 2067 | 'error' => true, |
| 2068 | - 'message' => $lang->get('bruteforce_wait') . (string) $e->getMessage(), |
|
| 2068 | + 'message' => $lang->get('bruteforce_wait').(string) $e->getMessage(), |
|
| 2069 | 2069 | ] |
| 2070 | 2070 | ]; |
| 2071 | 2071 | } |
@@ -2602,15 +2602,15 @@ discard block |
||
| 2602 | 2602 | |
| 2603 | 2603 | if ($ret['error'] !== false) { |
| 2604 | 2604 | logEvents($SETTINGS, 'failed_auth', 'bad_duo_mfa', '', stripslashes($username), stripslashes($username)); |
| 2605 | - $session->set('user-duo_status',''); |
|
| 2606 | - $session->set('user-duo_state',''); |
|
| 2607 | - $session->set('user-duo_data',''); |
|
| 2605 | + $session->set('user-duo_status', ''); |
|
| 2606 | + $session->set('user-duo_state', ''); |
|
| 2607 | + $session->set('user-duo_data', ''); |
|
| 2608 | 2608 | return [ |
| 2609 | 2609 | 'error' => true, |
| 2610 | 2610 | 'mfaData' => $ret, |
| 2611 | 2611 | 'mfaQRCodeInfos' => false, |
| 2612 | 2612 | ]; |
| 2613 | - } else if ($ret['duo_url_ready'] === true){ |
|
| 2613 | + } else if ($ret['duo_url_ready'] === true) { |
|
| 2614 | 2614 | return [ |
| 2615 | 2615 | 'error' => false, |
| 2616 | 2616 | 'mfaData' => $ret, |
@@ -2674,7 +2674,7 @@ discard block |
||
| 2674 | 2674 | // Count failed attempts from this source |
| 2675 | 2675 | $count = DB::queryFirstField( |
| 2676 | 2676 | 'SELECT COUNT(*) |
| 2677 | - FROM ' . prefixTable('auth_failures') . ' |
|
| 2677 | + FROM ' . prefixTable('auth_failures').' |
|
| 2678 | 2678 | WHERE source = %s AND value = %s', |
| 2679 | 2679 | $source, |
| 2680 | 2680 | $value |
@@ -73,7 +73,7 @@ discard block |
||
| 73 | 73 | if ($checkUserAccess->checkSession() === false || $checkUserAccess->userAccessPage('profile') === false) { |
| 74 | 74 | // Not allowed page |
| 75 | 75 | $session->set('system-error_code', ERR_NOT_ALLOWED); |
| 76 | - include $SETTINGS['cpassman_dir'] . '/error.php'; |
|
| 76 | + include $SETTINGS['cpassman_dir'].'/error.php'; |
|
| 77 | 77 | exit; |
| 78 | 78 | } |
| 79 | 79 | ?> |
@@ -97,7 +97,7 @@ discard block |
||
| 97 | 97 | }) |
| 98 | 98 | |
| 99 | 99 | // Select user properties |
| 100 | - $('#profile-user-language option[value=<?php echo $session->get('user-language');?>').attr('selected','selected'); |
|
| 100 | + $('#profile-user-language option[value=<?php echo $session->get('user-language'); ?>').attr('selected','selected'); |
|
| 101 | 101 | |
| 102 | 102 | |
| 103 | 103 | // AVATAR IMPORT |
@@ -295,7 +295,7 @@ discard block |
||
| 295 | 295 | |
| 296 | 296 | // reload page in case of language change |
| 297 | 297 | if ($('#profile-user-language').val() |
| 298 | - && $('#profile-user-language').val().toLowerCase() !== '<?php echo $session->get('user-language');?>') { |
|
| 298 | + && $('#profile-user-language').val().toLowerCase() !== '<?php echo $session->get('user-language'); ?>') { |
|
| 299 | 299 | // prepare reload |
| 300 | 300 | $(this).delay(3000).queue(function() { |
| 301 | 301 | document.location.href = "index.php?page=profile"; |
@@ -306,7 +306,7 @@ discard block |
||
| 306 | 306 | // Inform user |
| 307 | 307 | toastr.remove(); |
| 308 | 308 | toastr.info( |
| 309 | - '<?php echo $lang->get('alert_page_will_reload') . ' ... ' . $lang->get('please_wait'); ?>', |
|
| 309 | + '<?php echo $lang->get('alert_page_will_reload').' ... '.$lang->get('please_wait'); ?>', |
|
| 310 | 310 | '', { |
| 311 | 311 | timeOut: 3000, |
| 312 | 312 | progressBar: true |
@@ -410,27 +410,27 @@ discard block |
||
| 410 | 410 | "defaultText": "<?php echo $lang->get('index_pw_level_txt'); ?>", |
| 411 | 411 | "ratings": [ |
| 412 | 412 | { |
| 413 | - "minScore": <?php echo TP_PW_STRENGTH_1;?>, |
|
| 413 | + "minScore": <?php echo TP_PW_STRENGTH_1; ?>, |
|
| 414 | 414 | "className": "meterWarn", |
| 415 | 415 | "text": "<?php echo $lang->get('complex_level1'); ?>" |
| 416 | 416 | }, |
| 417 | 417 | { |
| 418 | - "minScore": <?php echo TP_PW_STRENGTH_2;?>, |
|
| 418 | + "minScore": <?php echo TP_PW_STRENGTH_2; ?>, |
|
| 419 | 419 | "className": "meterWarn", |
| 420 | 420 | "text": "<?php echo $lang->get('complex_level2'); ?>" |
| 421 | 421 | }, |
| 422 | 422 | { |
| 423 | - "minScore": <?php echo TP_PW_STRENGTH_3;?>, |
|
| 423 | + "minScore": <?php echo TP_PW_STRENGTH_3; ?>, |
|
| 424 | 424 | "className": "meterGood", |
| 425 | 425 | "text": "<?php echo $lang->get('complex_level3'); ?>" |
| 426 | 426 | }, |
| 427 | 427 | { |
| 428 | - "minScore": <?php echo TP_PW_STRENGTH_4;?>, |
|
| 428 | + "minScore": <?php echo TP_PW_STRENGTH_4; ?>, |
|
| 429 | 429 | "className": "meterGood", |
| 430 | 430 | "text": "<?php echo $lang->get('complex_level4'); ?>" |
| 431 | 431 | }, |
| 432 | 432 | { |
| 433 | - "minScore": <?php echo TP_PW_STRENGTH_5;?>, |
|
| 433 | + "minScore": <?php echo TP_PW_STRENGTH_5; ?>, |
|
| 434 | 434 | "className": "meterExcel", |
| 435 | 435 | "text": "<?php echo $lang->get('complex_level5'); ?>" |
| 436 | 436 | } |
@@ -523,27 +523,27 @@ discard block |
||
| 523 | 523 | "defaultText": "<?php echo $lang->get('index_pw_level_txt'); ?>", |
| 524 | 524 | "ratings": [ |
| 525 | 525 | { |
| 526 | - "minScore": <?php echo TP_PW_STRENGTH_1;?>, |
|
| 526 | + "minScore": <?php echo TP_PW_STRENGTH_1; ?>, |
|
| 527 | 527 | "className": "meterWarn", |
| 528 | 528 | "text": "<?php echo $lang->get('complex_level1'); ?>" |
| 529 | 529 | }, |
| 530 | 530 | { |
| 531 | - "minScore": <?php echo TP_PW_STRENGTH_2;?>, |
|
| 531 | + "minScore": <?php echo TP_PW_STRENGTH_2; ?>, |
|
| 532 | 532 | "className": "meterWarn", |
| 533 | 533 | "text": "<?php echo $lang->get('complex_level2'); ?>" |
| 534 | 534 | }, |
| 535 | 535 | { |
| 536 | - "minScore": <?php echo TP_PW_STRENGTH_3;?>, |
|
| 536 | + "minScore": <?php echo TP_PW_STRENGTH_3; ?>, |
|
| 537 | 537 | "className": "meterGood", |
| 538 | 538 | "text": "<?php echo $lang->get('complex_level3'); ?>" |
| 539 | 539 | }, |
| 540 | 540 | { |
| 541 | - "minScore": <?php echo TP_PW_STRENGTH_4;?>, |
|
| 541 | + "minScore": <?php echo TP_PW_STRENGTH_4; ?>, |
|
| 542 | 542 | "className": "meterGood", |
| 543 | 543 | "text": "<?php echo $lang->get('complex_level4'); ?>" |
| 544 | 544 | }, |
| 545 | 545 | { |
| 546 | - "minScore": <?php echo TP_PW_STRENGTH_5;?>, |
|
| 546 | + "minScore": <?php echo TP_PW_STRENGTH_5; ?>, |
|
| 547 | 547 | "className": "meterExcel", |
| 548 | 548 | "text": "<?php echo $lang->get('complex_level5'); ?>" |
| 549 | 549 | } |
@@ -559,7 +559,7 @@ discard block |
||
| 559 | 559 | } |
| 560 | 560 | }); |
| 561 | 561 | |
| 562 | - $('#profile-keys_download-date').text('<?php echo null === $session->get('user-keys_recovery_time') ? $lang->get('none') : date($SETTINGS['date_format'] . ' ' . $SETTINGS['time_format'], (int) $session->get('user-keys_recovery_time')); ?>'); |
|
| 562 | + $('#profile-keys_download-date').text('<?php echo null === $session->get('user-keys_recovery_time') ? $lang->get('none') : date($SETTINGS['date_format'].' '.$SETTINGS['time_format'], (int) $session->get('user-keys_recovery_time')); ?>'); |
|
| 563 | 563 | |
| 564 | 564 | $("#open-dialog-keys-download").on('click', function(event) { |
| 565 | 565 | event.preventDefault(); |
@@ -69,7 +69,7 @@ discard block |
||
| 69 | 69 | if ($checkUserAccess->checkSession() === false || $checkUserAccess->userAccessPage('items') === false) { |
| 70 | 70 | // Not allowed page |
| 71 | 71 | $session->set('system-error_code', ERR_NOT_ALLOWED); |
| 72 | - include $SETTINGS['cpassman_dir'] . '/error.php'; |
|
| 72 | + include $SETTINGS['cpassman_dir'].'/error.php'; |
|
| 73 | 73 | exit; |
| 74 | 74 | } |
| 75 | 75 | // Define Timezone |
@@ -90,7 +90,7 @@ discard block |
||
| 90 | 90 | |
| 91 | 91 | // Get list of users |
| 92 | 92 | $usersList = []; |
| 93 | -$rows = DB::query('SELECT id,login,email FROM ' . prefixTable('users') . ' ORDER BY login ASC'); |
|
| 93 | +$rows = DB::query('SELECT id,login,email FROM '.prefixTable('users').' ORDER BY login ASC'); |
|
| 94 | 94 | foreach ($rows as $record) { |
| 95 | 95 | $usersList[$record['login']] = [ |
| 96 | 96 | 'id' => $record['id'], |
@@ -101,16 +101,16 @@ discard block |
||
| 101 | 101 | // Get list of roles |
| 102 | 102 | $arrRoles = []; |
| 103 | 103 | $listRoles = ''; |
| 104 | -$rows = DB::query('SELECT id,title FROM ' . prefixTable('roles_title') . ' ORDER BY title ASC'); |
|
| 104 | +$rows = DB::query('SELECT id,title FROM '.prefixTable('roles_title').' ORDER BY title ASC'); |
|
| 105 | 105 | foreach ($rows as $reccord) { |
| 106 | 106 | $arrRoles[$reccord['title']] = [ |
| 107 | 107 | 'id' => $reccord['id'], |
| 108 | 108 | 'title' => $reccord['title'], |
| 109 | 109 | ]; |
| 110 | 110 | if (empty($listRoles)) { |
| 111 | - $listRoles = $reccord['id'] . '#' . $reccord['title']; |
|
| 111 | + $listRoles = $reccord['id'].'#'.$reccord['title']; |
|
| 112 | 112 | } else { |
| 113 | - $listRoles .= ';' . $reccord['id'] . '#' . $reccord['title']; |
|
| 113 | + $listRoles .= ';'.$reccord['id'].'#'.$reccord['title']; |
|
| 114 | 114 | } |
| 115 | 115 | } |
| 116 | 116 | |
@@ -185,7 +185,7 @@ discard block |
||
| 185 | 185 | <li class="nav-item"><a class="nav-link" href="#tab_3" data-toggle="tab"><i class="fa-solid fa-archive mr-2"></i><?php echo $lang->get('attachments'); ?></a></li> |
| 186 | 186 | <?php |
| 187 | 187 | echo isset($SETTINGS['item_extra_fields']) === true && (int) $SETTINGS['item_extra_fields'] === 1 ? ' |
| 188 | - <li class="nav-item"><a class="nav-link" href="#tab_4" data-toggle="tab"><i class="fa-solid fa-cubes mr-2"></i>' . $lang->get('fields') . '</a></li>' : ''; |
|
| 188 | + <li class="nav-item"><a class="nav-link" href="#tab_4" data-toggle="tab"><i class="fa-solid fa-cubes mr-2"></i>' . $lang->get('fields').'</a></li>' : ''; |
|
| 189 | 189 | ?> |
| 190 | 190 | </ul> |
| 191 | 191 | </div><!-- /.card-header --> |
@@ -254,7 +254,7 @@ discard block |
||
| 254 | 254 | <?php |
| 255 | 255 | for ($i = 4; $i <= $SETTINGS['pwd_maximum_length']; ++$i) { |
| 256 | 256 | echo ' |
| 257 | - <option>' . $i . '</option>'; |
|
| 257 | + <option>' . $i.'</option>'; |
|
| 258 | 258 | } |
| 259 | 259 | ?> |
| 260 | 260 | </select> |
@@ -284,7 +284,7 @@ discard block |
||
| 284 | 284 | <span class="ml-2 col-md-1 clear-me-html" id="form-item-icon-show"></span> |
| 285 | 285 | </div> |
| 286 | 286 | <small class='form-text text-muted'> |
| 287 | - <?php echo $lang->get('fontawesome_icon_tip'); ?><a href="<?php echo FONTAWESOME_URL;?>" target="_blank"><i class="fa-solid fa-external-link-alt ml-1"></i></a> |
|
| 287 | + <?php echo $lang->get('fontawesome_icon_tip'); ?><a href="<?php echo FONTAWESOME_URL; ?>" target="_blank"><i class="fa-solid fa-external-link-alt ml-1"></i></a> |
|
| 288 | 288 | </small> |
| 289 | 289 | </div> |
| 290 | 290 | |
@@ -472,39 +472,39 @@ discard block |
||
| 472 | 472 | <div class="tab-pane" id="tab_4"> |
| 473 | 473 | <div id="form-item-field" class="hidden"> |
| 474 | 474 | <?php |
| 475 | - $session_item_fields = $session->get('system-item_fields');//print_r($session_item_fields); |
|
| 475 | + $session_item_fields = $session->get('system-item_fields'); //print_r($session_item_fields); |
|
| 476 | 476 | if (isset($session_item_fields) === true) { |
| 477 | 477 | foreach ($session_item_fields as $category) { |
| 478 | 478 | //print_r($category); |
| 479 | 479 | echo ' |
| 480 | - <div class="callout callout-info form-item-category hidden" id="form-item-category-' . $category['id'] . '"> |
|
| 481 | - <h5>' . $category['title'] . '</h5> |
|
| 480 | + <div class="callout callout-info form-item-category hidden" id="form-item-category-' . $category['id'].'"> |
|
| 481 | + <h5>' . $category['title'].'</h5> |
|
| 482 | 482 | <p>'; |
| 483 | 483 | foreach ($category['fields'] as $field) { |
| 484 | 484 | if ($field['type'] === 'textarea') { |
| 485 | 485 | echo ' |
| 486 | - <div class="form-group mb-3 form-item-field" id="form-item-field-' . $field['id'] . '" data-field-id="' . $field['id'] . '"> |
|
| 486 | + <div class="form-group mb-3 form-item-field" id="form-item-field-' . $field['id'].'" data-field-id="'.$field['id'].'"> |
|
| 487 | 487 | <label>' . $field['title'], |
| 488 | 488 | $field['is_mandatory'] === '1' ? |
| 489 | - '<span class="fa-solid fa-fire text-danger ml-1 infotip" title="' . $lang->get('is_mandatory') . '"></span>' : '', |
|
| 489 | + '<span class="fa-solid fa-fire text-danger ml-1 infotip" title="'.$lang->get('is_mandatory').'"></span>' : '', |
|
| 490 | 490 | '</label> |
| 491 | - <textarea class="form-control form-item-control form-item-field-custom" rows="2" data-field-name="' . $field['id'] . '" data-field-mandatory="' . $field['is_mandatory'] . '" data-field-regex="' . $field['regex'] . '" data-change-ongoing="0"></textarea> |
|
| 491 | + <textarea class="form-control form-item-control form-item-field-custom" rows="2" data-field-name="' . $field['id'].'" data-field-mandatory="'.$field['is_mandatory'].'" data-field-regex="'.$field['regex'].'" data-change-ongoing="0"></textarea> |
|
| 492 | 492 | </div>'; |
| 493 | 493 | } else { |
| 494 | 494 | echo ' |
| 495 | - <div class="input-group mb-3 form-item-field" id="form-item-field-' . $field['id'] . '" data-field-id="' . $field['id'] . '"> |
|
| 495 | + <div class="input-group mb-3 form-item-field" id="form-item-field-' . $field['id'].'" data-field-id="'.$field['id'].'"> |
|
| 496 | 496 | <div class="input-group-prepend"> |
| 497 | 497 | <span class="input-group-text">' . $field['title'], |
| 498 | 498 | $field['is_mandatory'] === '1' ? |
| 499 | - '<span class="fa-solid fa-fire text-danger ml-1 infotip" title="' . $lang->get('is_mandatory') . '"></span>' : '', |
|
| 499 | + '<span class="fa-solid fa-fire text-danger ml-1 infotip" title="'.$lang->get('is_mandatory').'"></span>' : '', |
|
| 500 | 500 | '</span> |
| 501 | 501 | </div> |
| 502 | - <input type="' . $field['type'] . '" class="form-control form-item-control form-item-field-custom" data-field-name="' . $field['id'] . '" data-field-mandatory="' . $field['is_mandatory'] . '" data-field-regex="' . $field['regex'] . '" data-change-ongoing="0"> |
|
| 502 | + <input type="' . $field['type'].'" class="form-control form-item-control form-item-field-custom" data-field-name="'.$field['id'].'" data-field-mandatory="'.$field['is_mandatory'].'" data-field-regex="'.$field['regex'].'" data-change-ongoing="0"> |
|
| 503 | 503 | </div>'; |
| 504 | 504 | } |
| 505 | 505 | if (!empty($field['regex'])) { |
| 506 | 506 | echo ' |
| 507 | - <div>Regex: '. $field['regex'] .'</div> |
|
| 507 | + <div>Regex: '. $field['regex'].'</div> |
|
| 508 | 508 | '; |
| 509 | 509 | } |
| 510 | 510 | } |
@@ -515,8 +515,8 @@ discard block |
||
| 515 | 515 | ) { |
| 516 | 516 | echo ' |
| 517 | 517 | <div class="form-check icheck-blue"> |
| 518 | - <input type="checkbox" class="form-check-input form-check-input-template form-item-control flat-blue" data-category-id="' . $category['id'] . '" data-change-ongoing="0" data-field-name="template" id="template_' . $category['id'] . '"> |
|
| 519 | - <label class="form-check-label ml-3" for="template_' . $category['id'] . '">' . $lang->get('main_template') . '</label> |
|
| 518 | + <input type="checkbox" class="form-check-input form-check-input-template form-item-control flat-blue" data-category-id="' . $category['id'].'" data-change-ongoing="0" data-field-name="template" id="template_'.$category['id'].'"> |
|
| 519 | + <label class="form-check-label ml-3" for="template_' . $category['id'].'">'.$lang->get('main_template').'</label> |
|
| 520 | 520 | </div>'; |
| 521 | 521 | } |
| 522 | 522 | echo ' |
@@ -526,8 +526,8 @@ discard block |
||
| 526 | 526 | } else { |
| 527 | 527 | echo |
| 528 | 528 | '<div class="alert alert-info"> |
| 529 | - <h5><i class="icon fa fa-info mr-3"></i>' . $lang->get('information') . '</h5> |
|
| 530 | - ' . $lang->get('no_fields') . ' |
|
| 529 | + <h5><i class="icon fa fa-info mr-3"></i>' . $lang->get('information').'</h5> |
|
| 530 | + ' . $lang->get('no_fields').' |
|
| 531 | 531 | </div>'; |
| 532 | 532 | } ?> |
| 533 | 533 | </div> |
@@ -668,7 +668,7 @@ discard block |
||
| 668 | 668 | <p><?php |
| 669 | 669 | echo str_replace( |
| 670 | 670 | ['##otv_expiration_period##', '. '], |
| 671 | - ['<span class="text-bold text-primary">' . $SETTINGS['otv_expiration_period'] . '</span>', '<br>'], |
|
| 671 | + ['<span class="text-bold text-primary">'.$SETTINGS['otv_expiration_period'].'</span>', '<br>'], |
|
| 672 | 672 | $lang->get('otv_message') |
| 673 | 673 | ); |
| 674 | 674 | ?></p> |
@@ -686,9 +686,9 @@ discard block |
||
| 686 | 686 | |
| 687 | 687 | <div class="row"> |
| 688 | 688 | <div class="form-group col-4"> |
| 689 | - <label for="form-item-otv-days"><i class="fa-regular fa-calendar-days mr-2"></i><?php echo $lang->get('number_of_days'); ?> (<?php echo $lang->get('maximum').': '.$SETTINGS['otv_expiration_period'];?>)</label> |
|
| 689 | + <label for="form-item-otv-days"><i class="fa-regular fa-calendar-days mr-2"></i><?php echo $lang->get('number_of_days'); ?> (<?php echo $lang->get('maximum').': '.$SETTINGS['otv_expiration_period']; ?>)</label> |
|
| 690 | 690 | <div class="input-group mb-3"> |
| 691 | - <input type="number" class="form-control clear-me-val" id="form-item-otv-days" min="0" max="<?php echo $SETTINGS['otv_expiration_period'];?>" value="<?php echo $SETTINGS['otv_expiration_period'];?>"> |
|
| 691 | + <input type="number" class="form-control clear-me-val" id="form-item-otv-days" min="0" max="<?php echo $SETTINGS['otv_expiration_period']; ?>" value="<?php echo $SETTINGS['otv_expiration_period']; ?>"> |
|
| 692 | 692 | </div> |
| 693 | 693 | </div> |
| 694 | 694 | |
@@ -776,7 +776,7 @@ discard block |
||
| 776 | 776 | <select class="form-control form-folder-control select2" style="width:100%;" id="form-folder-add-complexicity" required> |
| 777 | 777 | <?php |
| 778 | 778 | foreach (TP_PW_COMPLEXITY as $key => $value) { |
| 779 | - echo '<option value="' . $key . '">' . $value[1] . '</option>'; |
|
| 779 | + echo '<option value="'.$key.'">'.$value[1].'</option>'; |
|
| 780 | 780 | } |
| 781 | 781 | ?> |
| 782 | 782 | </select> |
@@ -794,14 +794,14 @@ discard block |
||
| 794 | 794 | <label><?php echo $lang->get('icon'); ?></label> |
| 795 | 795 | <input type="text" class="form-control form-folder-control" id="form-folder-add-icon"> |
| 796 | 796 | <small class='form-text text-muted'> |
| 797 | - <?php echo $lang->get('fontawesome_icon_tip'); ?><a href="<?php echo FONTAWESOME_URL;?>" target="_blank"><i class="fa-solid fa-external-link-alt ml-1"></i></a> |
|
| 797 | + <?php echo $lang->get('fontawesome_icon_tip'); ?><a href="<?php echo FONTAWESOME_URL; ?>" target="_blank"><i class="fa-solid fa-external-link-alt ml-1"></i></a> |
|
| 798 | 798 | </small> |
| 799 | 799 | </div> |
| 800 | 800 | <div class="form-group"> |
| 801 | 801 | <label><?php echo $lang->get('icon_on_selection'); ?></label> |
| 802 | 802 | <input type="text" class="form-control form-folder-control" id="form-folder-add-icon-selected"> |
| 803 | 803 | <small class='form-text text-muted'> |
| 804 | - <?php echo $lang->get('fontawesome_icon_tip'); ?><a href="<?php echo FONTAWESOME_URL;?>" target="_blank"><i class="fa-solid fa-external-link-alt ml-1"></i></a> |
|
| 804 | + <?php echo $lang->get('fontawesome_icon_tip'); ?><a href="<?php echo FONTAWESOME_URL; ?>" target="_blank"><i class="fa-solid fa-external-link-alt ml-1"></i></a> |
|
| 805 | 805 | </small> |
| 806 | 806 | </div> |
| 807 | 807 | </div> |
@@ -1212,18 +1212,18 @@ discard block |
||
| 1212 | 1212 | <?php |
| 1213 | 1213 | foreach ($session_item_fields as $elem) { |
| 1214 | 1214 | echo ' |
| 1215 | - <div class="callout callout-info card-item-category hidden" id="card-item-category-' . $elem['id'] . '"> |
|
| 1216 | - <h5>' . $elem['title'] . '</h5> |
|
| 1215 | + <div class="callout callout-info card-item-category hidden" id="card-item-category-' . $elem['id'].'"> |
|
| 1216 | + <h5>' . $elem['title'].'</h5> |
|
| 1217 | 1217 | <p> |
| 1218 | 1218 | <ul class="list-group list-group-unbordered mb-3">'; |
| 1219 | 1219 | foreach ($elem['fields'] as $field) { |
| 1220 | 1220 | echo ' |
| 1221 | - <li class="list-group-item card-item-field hidden" id="card-item-field-' . $field['id'] . '"> |
|
| 1222 | - <span id="card-item-field-title-' . $field['id'] . '"><b>' . $field['title'] . '</b></span> |
|
| 1223 | - <button type="button" class="float-right btn btn-secondary btn-sm ml-1 btn-copy-clipboard-clear" data-clipboard-target="card-item-field-value-' . $field['id'] . '"> |
|
| 1221 | + <li class="list-group-item card-item-field hidden" id="card-item-field-' . $field['id'].'"> |
|
| 1222 | + <span id="card-item-field-title-' . $field['id'].'"><b>'.$field['title'].'</b></span> |
|
| 1223 | + <button type="button" class="float-right btn btn-secondary btn-sm ml-1 btn-copy-clipboard-clear" data-clipboard-target="card-item-field-value-' . $field['id'].'"> |
|
| 1224 | 1224 | <i class="fa-solid fa-copy"></i> |
| 1225 | 1225 | </button> |
| 1226 | - <span class="card-item-field-value float-right ml-1" id="card-item-field-value-' . $field['id'] . '"></span> |
|
| 1226 | + <span class="card-item-field-value float-right ml-1" id="card-item-field-value-' . $field['id'].'"></span> |
|
| 1227 | 1227 | </li>'; |
| 1228 | 1228 | } |
| 1229 | 1229 | echo ' |
@@ -91,215 +91,215 @@ |
||
| 91 | 91 | switch ($post_type) { |
| 92 | 92 | //########################################################## |
| 93 | 93 | //CASE for creating a DB backup |
| 94 | -case 'perform_fix_pf_items-step1': |
|
| 95 | - // Check KEY |
|
| 96 | - if (!hash_equals((string) $session->get('key'), (string) $post_key)) { |
|
| 97 | - echo prepareExchangedData( |
|
| 98 | - array( |
|
| 99 | - 'error' => true, |
|
| 100 | - 'message' => $lang->get('key_is_not_correct'), |
|
| 101 | - ), |
|
| 102 | - 'encode' |
|
| 103 | - ); |
|
| 104 | - break; |
|
| 105 | - } |
|
| 106 | - // Is admin? |
|
| 107 | - if ((int) $session->get('user-admin') !== 1) { |
|
| 108 | - echo prepareExchangedData( |
|
| 109 | - array( |
|
| 110 | - 'error' => true, |
|
| 111 | - 'message' => $lang->get('error_not_allowed_to'), |
|
| 112 | - ), |
|
| 113 | - 'encode' |
|
| 114 | - ); |
|
| 115 | - break; |
|
| 116 | - } |
|
| 94 | + case 'perform_fix_pf_items-step1': |
|
| 95 | + // Check KEY |
|
| 96 | + if (!hash_equals((string) $session->get('key'), (string) $post_key)) { |
|
| 97 | + echo prepareExchangedData( |
|
| 98 | + array( |
|
| 99 | + 'error' => true, |
|
| 100 | + 'message' => $lang->get('key_is_not_correct'), |
|
| 101 | + ), |
|
| 102 | + 'encode' |
|
| 103 | + ); |
|
| 104 | + break; |
|
| 105 | + } |
|
| 106 | + // Is admin? |
|
| 107 | + if ((int) $session->get('user-admin') !== 1) { |
|
| 108 | + echo prepareExchangedData( |
|
| 109 | + array( |
|
| 110 | + 'error' => true, |
|
| 111 | + 'message' => $lang->get('error_not_allowed_to'), |
|
| 112 | + ), |
|
| 113 | + 'encode' |
|
| 114 | + ); |
|
| 115 | + break; |
|
| 116 | + } |
|
| 117 | 117 | |
| 118 | - // decrypt and retrieve data in JSON format |
|
| 119 | - $dataReceived = prepareExchangedData( |
|
| 120 | - $post_data, |
|
| 121 | - 'decode' |
|
| 122 | - ); |
|
| 118 | + // decrypt and retrieve data in JSON format |
|
| 119 | + $dataReceived = prepareExchangedData( |
|
| 120 | + $post_data, |
|
| 121 | + 'decode' |
|
| 122 | + ); |
|
| 123 | 123 | |
| 124 | - $userId = filter_var($dataReceived['userId'], FILTER_SANITIZE_NUMBER_INT); |
|
| 124 | + $userId = filter_var($dataReceived['userId'], FILTER_SANITIZE_NUMBER_INT); |
|
| 125 | 125 | |
| 126 | - // Get user info |
|
| 127 | - $userInfo = DB::queryFirstRow( |
|
| 128 | - 'SELECT private_key, public_key, psk, encrypted_psk |
|
| 126 | + // Get user info |
|
| 127 | + $userInfo = DB::queryFirstRow( |
|
| 128 | + 'SELECT private_key, public_key, psk, encrypted_psk |
|
| 129 | 129 | FROM teampass_users |
| 130 | 130 | WHERE id = %i', |
| 131 | - $userId |
|
| 132 | - ); |
|
| 131 | + $userId |
|
| 132 | + ); |
|
| 133 | 133 | |
| 134 | - // Get user's private folders |
|
| 135 | - $userPFRoot = DB::queryFirstRow( |
|
| 136 | - 'SELECT id |
|
| 134 | + // Get user's private folders |
|
| 135 | + $userPFRoot = DB::queryFirstRow( |
|
| 136 | + 'SELECT id |
|
| 137 | 137 | FROM teampass_nested_tree |
| 138 | 138 | WHERE title = %i', |
| 139 | - $userId |
|
| 140 | - ); |
|
| 141 | - if (DB::count() === 0) { |
|
| 142 | - echo prepareExchangedData( |
|
| 143 | - array( |
|
| 144 | - 'error' => true, |
|
| 145 | - 'message' => 'User has no personal folders', |
|
| 146 | - ), |
|
| 147 | - 'encode' |
|
| 148 | - ); |
|
| 149 | - break; |
|
| 150 | - } |
|
| 151 | - $personalFolders = []; |
|
| 152 | - $tree = new NestedTree(prefixTable('nested_tree'), 'id', 'parent_id', 'title'); |
|
| 153 | - $tree->rebuild(); |
|
| 154 | - $folders = $tree->getDescendants($userPFRoot['id'], true); |
|
| 155 | - foreach ($folders as $folder) { |
|
| 156 | - array_push($personalFolders, $folder->id); |
|
| 157 | - } |
|
| 158 | - |
|
| 159 | - //Show done |
|
| 160 | - echo prepareExchangedData( |
|
| 161 | - array( |
|
| 162 | - 'error' => false, |
|
| 163 | - 'message' => 'Personal Folders found: ', |
|
| 164 | - 'personalFolders' => json_encode($personalFolders), |
|
| 165 | - ), |
|
| 166 | - 'encode' |
|
| 167 | - ); |
|
| 168 | - break; |
|
| 169 | - |
|
| 170 | -case 'perform_fix_pf_items-step2': |
|
| 171 | - // Check KEY |
|
| 172 | - if (!hash_equals((string) $session->get('key'), (string) $post_key)) { |
|
| 173 | - echo prepareExchangedData( |
|
| 174 | - array( |
|
| 175 | - 'error' => true, |
|
| 176 | - 'message' => $lang->get('key_is_not_correct'), |
|
| 177 | - ), |
|
| 178 | - 'encode' |
|
| 139 | + $userId |
|
| 179 | 140 | ); |
| 180 | - break; |
|
| 181 | - } |
|
| 182 | - // Is admin? |
|
| 183 | - if ((int) $session->get('user-admin') !== 1) { |
|
| 141 | + if (DB::count() === 0) { |
|
| 142 | + echo prepareExchangedData( |
|
| 143 | + array( |
|
| 144 | + 'error' => true, |
|
| 145 | + 'message' => 'User has no personal folders', |
|
| 146 | + ), |
|
| 147 | + 'encode' |
|
| 148 | + ); |
|
| 149 | + break; |
|
| 150 | + } |
|
| 151 | + $personalFolders = []; |
|
| 152 | + $tree = new NestedTree(prefixTable('nested_tree'), 'id', 'parent_id', 'title'); |
|
| 153 | + $tree->rebuild(); |
|
| 154 | + $folders = $tree->getDescendants($userPFRoot['id'], true); |
|
| 155 | + foreach ($folders as $folder) { |
|
| 156 | + array_push($personalFolders, $folder->id); |
|
| 157 | + } |
|
| 158 | + |
|
| 159 | + //Show done |
|
| 184 | 160 | echo prepareExchangedData( |
| 185 | 161 | array( |
| 186 | - 'error' => true, |
|
| 187 | - 'message' => $lang->get('error_not_allowed_to'), |
|
| 162 | + 'error' => false, |
|
| 163 | + 'message' => 'Personal Folders found: ', |
|
| 164 | + 'personalFolders' => json_encode($personalFolders), |
|
| 188 | 165 | ), |
| 189 | 166 | 'encode' |
| 190 | 167 | ); |
| 191 | 168 | break; |
| 192 | - } |
|
| 193 | 169 | |
| 194 | - // decrypt and retrieve data in JSON format |
|
| 195 | - $dataReceived = prepareExchangedData( |
|
| 196 | - $post_data, |
|
| 197 | - 'decode' |
|
| 198 | - ); |
|
| 170 | + case 'perform_fix_pf_items-step2': |
|
| 171 | + // Check KEY |
|
| 172 | + if (!hash_equals((string) $session->get('key'), (string) $post_key)) { |
|
| 173 | + echo prepareExchangedData( |
|
| 174 | + array( |
|
| 175 | + 'error' => true, |
|
| 176 | + 'message' => $lang->get('key_is_not_correct'), |
|
| 177 | + ), |
|
| 178 | + 'encode' |
|
| 179 | + ); |
|
| 180 | + break; |
|
| 181 | + } |
|
| 182 | + // Is admin? |
|
| 183 | + if ((int) $session->get('user-admin') !== 1) { |
|
| 184 | + echo prepareExchangedData( |
|
| 185 | + array( |
|
| 186 | + 'error' => true, |
|
| 187 | + 'message' => $lang->get('error_not_allowed_to'), |
|
| 188 | + ), |
|
| 189 | + 'encode' |
|
| 190 | + ); |
|
| 191 | + break; |
|
| 192 | + } |
|
| 199 | 193 | |
| 200 | - $userId = filter_var($dataReceived['userId'], FILTER_SANITIZE_NUMBER_INT); |
|
| 201 | - $personalFolders = filter_var($dataReceived['personalFolders'], FILTER_SANITIZE_FULL_SPECIAL_CHARS); |
|
| 194 | + // decrypt and retrieve data in JSON format |
|
| 195 | + $dataReceived = prepareExchangedData( |
|
| 196 | + $post_data, |
|
| 197 | + 'decode' |
|
| 198 | + ); |
|
| 199 | + |
|
| 200 | + $userId = filter_var($dataReceived['userId'], FILTER_SANITIZE_NUMBER_INT); |
|
| 201 | + $personalFolders = filter_var($dataReceived['personalFolders'], FILTER_SANITIZE_FULL_SPECIAL_CHARS); |
|
| 202 | 202 | |
| 203 | - // Delete all private items with sharekeys |
|
| 204 | - $pfiSharekeys = DB::queryFirstColumn( |
|
| 205 | - 'select s.increment_id |
|
| 203 | + // Delete all private items with sharekeys |
|
| 204 | + $pfiSharekeys = DB::queryFirstColumn( |
|
| 205 | + 'select s.increment_id |
|
| 206 | 206 | from teampass_sharekeys_items as s |
| 207 | 207 | INNER JOIN teampass_items AS i ON (i.id = s.object_id) |
| 208 | 208 | WHERE s.user_id = %i AND i.perso = 1 AND i.id_tree IN %ls', |
| 209 | - $userId, |
|
| 210 | - $personalFolders |
|
| 211 | - ); |
|
| 212 | - $pfiSharekeysCount = DB::count(); |
|
| 213 | - if ($pfiSharekeysCount > 0) { |
|
| 214 | - DB::delete( |
|
| 215 | - "teampass_sharekeys_items", |
|
| 216 | - "increment_id IN %ls", |
|
| 217 | - $pfiSharekeys |
|
| 209 | + $userId, |
|
| 210 | + $personalFolders |
|
| 218 | 211 | ); |
| 219 | - } |
|
| 212 | + $pfiSharekeysCount = DB::count(); |
|
| 213 | + if ($pfiSharekeysCount > 0) { |
|
| 214 | + DB::delete( |
|
| 215 | + "teampass_sharekeys_items", |
|
| 216 | + "increment_id IN %ls", |
|
| 217 | + $pfiSharekeys |
|
| 218 | + ); |
|
| 219 | + } |
|
| 220 | 220 | |
| 221 | 221 | |
| 222 | - //Show done |
|
| 223 | - echo prepareExchangedData( |
|
| 224 | - array( |
|
| 225 | - 'error' => false, |
|
| 226 | - 'message' => '<br>Number of Sharekeys for private items DELETED: ', |
|
| 227 | - 'nbDeleted' => $pfiSharekeysCount, |
|
| 228 | - 'personalFolders' => json_encode($personalFolders), |
|
| 229 | - ), |
|
| 230 | - 'encode' |
|
| 231 | - ); |
|
| 232 | - break; |
|
| 233 | - |
|
| 234 | -case 'perform_fix_pf_items-step3': |
|
| 235 | - // Check KEY |
|
| 236 | - if (!hash_equals((string) $session->get('key'), (string) $post_key)) { |
|
| 237 | - echo prepareExchangedData( |
|
| 238 | - array( |
|
| 239 | - 'error' => true, |
|
| 240 | - 'message' => $lang->get('key_is_not_correct'), |
|
| 241 | - ), |
|
| 242 | - 'encode' |
|
| 243 | - ); |
|
| 244 | - break; |
|
| 245 | - } |
|
| 246 | - // Is admin? |
|
| 247 | - if ((int) $session->get('user-admin') !== 1) { |
|
| 222 | + //Show done |
|
| 248 | 223 | echo prepareExchangedData( |
| 249 | 224 | array( |
| 250 | - 'error' => true, |
|
| 251 | - 'message' => $lang->get('error_not_allowed_to'), |
|
| 225 | + 'error' => false, |
|
| 226 | + 'message' => '<br>Number of Sharekeys for private items DELETED: ', |
|
| 227 | + 'nbDeleted' => $pfiSharekeysCount, |
|
| 228 | + 'personalFolders' => json_encode($personalFolders), |
|
| 252 | 229 | ), |
| 253 | 230 | 'encode' |
| 254 | 231 | ); |
| 255 | 232 | break; |
| 256 | - } |
|
| 257 | 233 | |
| 258 | - // decrypt and retrieve data in JSON format |
|
| 259 | - $dataReceived = prepareExchangedData( |
|
| 260 | - $post_data, |
|
| 261 | - 'decode' |
|
| 262 | - ); |
|
| 234 | + case 'perform_fix_pf_items-step3': |
|
| 235 | + // Check KEY |
|
| 236 | + if (!hash_equals((string) $session->get('key'), (string) $post_key)) { |
|
| 237 | + echo prepareExchangedData( |
|
| 238 | + array( |
|
| 239 | + 'error' => true, |
|
| 240 | + 'message' => $lang->get('key_is_not_correct'), |
|
| 241 | + ), |
|
| 242 | + 'encode' |
|
| 243 | + ); |
|
| 244 | + break; |
|
| 245 | + } |
|
| 246 | + // Is admin? |
|
| 247 | + if ((int) $session->get('user-admin') !== 1) { |
|
| 248 | + echo prepareExchangedData( |
|
| 249 | + array( |
|
| 250 | + 'error' => true, |
|
| 251 | + 'message' => $lang->get('error_not_allowed_to'), |
|
| 252 | + ), |
|
| 253 | + 'encode' |
|
| 254 | + ); |
|
| 255 | + break; |
|
| 256 | + } |
|
| 257 | + |
|
| 258 | + // decrypt and retrieve data in JSON format |
|
| 259 | + $dataReceived = prepareExchangedData( |
|
| 260 | + $post_data, |
|
| 261 | + 'decode' |
|
| 262 | + ); |
|
| 263 | 263 | |
| 264 | - $userId = filter_var($dataReceived['userId'], FILTER_SANITIZE_NUMBER_INT); |
|
| 265 | - $personalFolders = filter_var($dataReceived['personalFolders'], FILTER_SANITIZE_FULL_SPECIAL_CHARS); |
|
| 264 | + $userId = filter_var($dataReceived['userId'], FILTER_SANITIZE_NUMBER_INT); |
|
| 265 | + $personalFolders = filter_var($dataReceived['personalFolders'], FILTER_SANITIZE_FULL_SPECIAL_CHARS); |
|
| 266 | 266 | |
| 267 | - // Update from items_old to items all the private itemsitems that have been converted to teampass_aes |
|
| 268 | - // Get all key back |
|
| 269 | - $items = DB::query( |
|
| 270 | - "SELECT id |
|
| 267 | + // Update from items_old to items all the private itemsitems that have been converted to teampass_aes |
|
| 268 | + // Get all key back |
|
| 269 | + $items = DB::query( |
|
| 270 | + "SELECT id |
|
| 271 | 271 | FROM teampass_items |
| 272 | 272 | WHERE id_tree IN %ls AND encryption_type = %s", |
| 273 | - $personalFolders, |
|
| 274 | - "teampass_aes" |
|
| 275 | - ); |
|
| 276 | - //DB::debugMode(false); |
|
| 277 | - $nbItems = DB::count(); |
|
| 278 | - foreach ($items as $item) { |
|
| 279 | - $defusePwd = DB::queryFirstField("SELECT pw FROM teampass_items_old WHERE id = %i", $item['id']); |
|
| 280 | - DB::update( |
|
| 281 | - "teampass_items", |
|
| 282 | - ['pw' => $defusePwd, "encryption_type" => "defuse"], |
|
| 283 | - "id = %i", |
|
| 284 | - $item['id'] |
|
| 273 | + $personalFolders, |
|
| 274 | + "teampass_aes" |
|
| 285 | 275 | ); |
| 286 | - } |
|
| 276 | + //DB::debugMode(false); |
|
| 277 | + $nbItems = DB::count(); |
|
| 278 | + foreach ($items as $item) { |
|
| 279 | + $defusePwd = DB::queryFirstField("SELECT pw FROM teampass_items_old WHERE id = %i", $item['id']); |
|
| 280 | + DB::update( |
|
| 281 | + "teampass_items", |
|
| 282 | + ['pw' => $defusePwd, "encryption_type" => "defuse"], |
|
| 283 | + "id = %i", |
|
| 284 | + $item['id'] |
|
| 285 | + ); |
|
| 286 | + } |
|
| 287 | 287 | |
| 288 | 288 | |
| 289 | - //Show done |
|
| 290 | - echo prepareExchangedData( |
|
| 291 | - array( |
|
| 292 | - 'error' => false, |
|
| 293 | - 'message' => '<br>Number of items reseted to Defuse: ', |
|
| 294 | - 'nbItems' => $nbItems, |
|
| 295 | - 'personalFolders' => json_encode($personalFolders), |
|
| 296 | - ), |
|
| 297 | - 'encode' |
|
| 298 | - ); |
|
| 299 | - break; |
|
| 300 | - |
|
| 301 | - /* TOOL #2 - Fixing items master keys */ |
|
| 302 | - /* |
|
| 289 | + //Show done |
|
| 290 | + echo prepareExchangedData( |
|
| 291 | + array( |
|
| 292 | + 'error' => false, |
|
| 293 | + 'message' => '<br>Number of items reseted to Defuse: ', |
|
| 294 | + 'nbItems' => $nbItems, |
|
| 295 | + 'personalFolders' => json_encode($personalFolders), |
|
| 296 | + ), |
|
| 297 | + 'encode' |
|
| 298 | + ); |
|
| 299 | + break; |
|
| 300 | + |
|
| 301 | + /* TOOL #2 - Fixing items master keys */ |
|
| 302 | + /* |
|
| 303 | 303 | * STEP 1 - Check if we have the correct pwd for TP_USER |
| 304 | 304 | */ |
| 305 | 305 | case 'perform_fix_items_master_keys-step1': |
@@ -70,7 +70,7 @@ discard block |
||
| 70 | 70 | if ($checkUserAccess->checkSession() === false || $checkUserAccess->userAccessPage('tools') === false) { |
| 71 | 71 | // Not allowed page |
| 72 | 72 | $session->set('system-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 | |
@@ -335,7 +335,7 @@ discard block |
||
| 335 | 335 | // Get PT_USER info |
| 336 | 336 | $userInfo = DB::queryFirstRow( |
| 337 | 337 | 'SELECT pw, public_key, private_key, login, name |
| 338 | - FROM ' . prefixTable('users') . ' |
|
| 338 | + FROM ' . prefixTable('users').' |
|
| 339 | 339 | WHERE id = %i', |
| 340 | 340 | TP_USER_ID |
| 341 | 341 | ); |
@@ -372,8 +372,8 @@ discard block |
||
| 372 | 372 | // Get one itemKey from current user |
| 373 | 373 | $currentUserKey = DB::queryFirstRow( |
| 374 | 374 | 'SELECT ski.share_key, ski.increment_id AS increment_id, l.id_user |
| 375 | - FROM ' . prefixTable('sharekeys_items') . ' AS ski |
|
| 376 | - INNER JOIN ' . prefixTable('log_items') . ' AS l ON ski.object_id = l.id_item |
|
| 375 | + FROM ' . prefixTable('sharekeys_items').' AS ski |
|
| 376 | + INNER JOIN ' . prefixTable('log_items').' AS l ON ski.object_id = l.id_item |
|
| 377 | 377 | WHERE ski.user_id = %i |
| 378 | 378 | ORDER BY RAND() |
| 379 | 379 | LIMIT 1', |
@@ -392,7 +392,7 @@ discard block |
||
| 392 | 392 | echo prepareExchangedData( |
| 393 | 393 | array( |
| 394 | 394 | 'error' => true, |
| 395 | - 'message' => 'No issue found, normal process should work. This process is now finished. (item id : ' . $currentUserKey['increment_id'] . ')', |
|
| 395 | + 'message' => 'No issue found, normal process should work. This process is now finished. (item id : '.$currentUserKey['increment_id'].')', |
|
| 396 | 396 | ), |
| 397 | 397 | 'encode' |
| 398 | 398 | ); |
@@ -452,7 +452,7 @@ discard block |
||
| 452 | 452 | // Get user info |
| 453 | 453 | $userInfo = DB::queryFirstRow( |
| 454 | 454 | 'SELECT public_key, private_key |
| 455 | - FROM ' . prefixTable('users') . ' |
|
| 455 | + FROM ' . prefixTable('users').' |
|
| 456 | 456 | WHERE id = %i', |
| 457 | 457 | $userId |
| 458 | 458 | ); |
@@ -475,8 +475,8 @@ discard block |
||
| 475 | 475 | // Get one itemKey from current user |
| 476 | 476 | $currentUserKey = DB::queryFirstRow( |
| 477 | 477 | 'SELECT ski.share_key, ski.increment_id AS increment_id, l.id_user |
| 478 | - FROM ' . prefixTable('sharekeys_items') . ' AS ski |
|
| 479 | - INNER JOIN ' . prefixTable('log_items') . ' AS l ON ski.object_id = l.id_item |
|
| 478 | + FROM ' . prefixTable('sharekeys_items').' AS ski |
|
| 479 | + INNER JOIN ' . prefixTable('log_items').' AS l ON ski.object_id = l.id_item |
|
| 480 | 480 | WHERE ski.user_id = %i |
| 481 | 481 | ORDER BY RAND() |
| 482 | 482 | LIMIT 1', |
@@ -514,8 +514,8 @@ discard block |
||
| 514 | 514 | // Get number of users to treat |
| 515 | 515 | DB::query( |
| 516 | 516 | 'SELECT i.id |
| 517 | - FROM ' . prefixTable('items') . ' AS i |
|
| 518 | - INNER JOIN ' . prefixTable('sharekeys_items') . ' AS si ON i.id = si.object_id |
|
| 517 | + FROM ' . prefixTable('items').' AS i |
|
| 518 | + INNER JOIN ' . prefixTable('sharekeys_items').' AS si ON i.id = si.object_id |
|
| 519 | 519 | WHERE i.perso = %i AND si.user_id = %i;', |
| 520 | 520 | 0, |
| 521 | 521 | $userId |
@@ -597,11 +597,11 @@ discard block |
||
| 597 | 597 | // Loop on items |
| 598 | 598 | $rows = DB::query( |
| 599 | 599 | 'SELECT si.object_id AS object_id, si.share_key AS share_key, i.pw AS pw, si.increment_id as increment_id |
| 600 | - FROM ' . prefixTable('sharekeys_items') . ' AS si |
|
| 601 | - INNER JOIN ' . prefixTable('items') . ' AS i ON (i.id = si.object_id) |
|
| 600 | + FROM ' . prefixTable('sharekeys_items').' AS si |
|
| 601 | + INNER JOIN ' . prefixTable('items').' AS i ON (i.id = si.object_id) |
|
| 602 | 602 | WHERE si.user_id = %i |
| 603 | 603 | ORDER BY si.increment_id ASC |
| 604 | - LIMIT ' . $startIndex . ', ' . $limit, |
|
| 604 | + LIMIT ' . $startIndex.', '.$limit, |
|
| 605 | 605 | $userId |
| 606 | 606 | ); |
| 607 | 607 | |
@@ -625,7 +625,7 @@ discard block |
||
| 625 | 625 | // It will be updated if already exists |
| 626 | 626 | $currentTPUserKey = DB::queryFirstRow( |
| 627 | 627 | 'SELECT increment_id, user_id, share_key |
| 628 | - FROM ' . prefixTable('sharekeys_items') . ' |
|
| 628 | + FROM ' . prefixTable('sharekeys_items').' |
|
| 629 | 629 | WHERE object_id = %i AND user_id = %i', |
| 630 | 630 | $record['object_id'], |
| 631 | 631 | TP_USER_ID |
@@ -661,7 +661,7 @@ discard block |
||
| 661 | 661 | DB::commit(); |
| 662 | 662 | } catch (Exception $e) { |
| 663 | 663 | DB::rollback(); |
| 664 | - error_log("Teampass - Error: Keys treatment: " . $e->getMessage()); |
|
| 664 | + error_log("Teampass - Error: Keys treatment: ".$e->getMessage()); |
|
| 665 | 665 | } |
| 666 | 666 | |
| 667 | 667 | $nextIndex = (int) $startIndex + (int) $limit; |
@@ -717,7 +717,7 @@ discard block |
||
| 717 | 717 | // Get PT_USER info |
| 718 | 718 | DB::queryFirstRow( |
| 719 | 719 | 'SELECT operation_code |
| 720 | - FROM ' . prefixTable('sharekeys_backup') . ' |
|
| 720 | + FROM ' . prefixTable('sharekeys_backup').' |
|
| 721 | 721 | WHERE operation_code = %s', |
| 722 | 722 | $operationCode |
| 723 | 723 | ); |
@@ -727,7 +727,7 @@ discard block |
||
| 727 | 727 | // using increment_id_value in order to update the correct record |
| 728 | 728 | $rows = DB::query( |
| 729 | 729 | 'SELECT * |
| 730 | - FROM ' . prefixTable('sharekeys_backup') . ' |
|
| 730 | + FROM ' . prefixTable('sharekeys_backup').' |
|
| 731 | 731 | WHERE operation_code = %s', |
| 732 | 732 | $operationCode |
| 733 | 733 | ); |
@@ -746,7 +746,7 @@ discard block |
||
| 746 | 746 | |
| 747 | 747 | // Delete all sharekeys for this operation |
| 748 | 748 | DB::query( |
| 749 | - 'DELETE FROM ' . prefixTable('sharekeys_backup') . ' |
|
| 749 | + 'DELETE FROM '.prefixTable('sharekeys_backup').' |
|
| 750 | 750 | WHERE operation_code = %i', |
| 751 | 751 | $operationCode |
| 752 | 752 | ); |
@@ -809,7 +809,7 @@ discard block |
||
| 809 | 809 | // Get operation info |
| 810 | 810 | DB::query( |
| 811 | 811 | 'SELECT operation_code |
| 812 | - FROM ' . prefixTable('sharekeys_backup') . ' |
|
| 812 | + FROM ' . prefixTable('sharekeys_backup').' |
|
| 813 | 813 | WHERE operation_code = %s', |
| 814 | 814 | $operationCode |
| 815 | 815 | ); |
@@ -818,7 +818,7 @@ discard block |
||
| 818 | 818 | if ($nbKeys > 0) { |
| 819 | 819 | // Delete all sharekeys for this operation |
| 820 | 820 | DB::query( |
| 821 | - 'DELETE FROM ' . prefixTable('sharekeys_backup') . ' |
|
| 821 | + 'DELETE FROM '.prefixTable('sharekeys_backup').' |
|
| 822 | 822 | WHERE operation_code = %s', |
| 823 | 823 | $operationCode |
| 824 | 824 | ); |
@@ -75,7 +75,7 @@ discard block |
||
| 75 | 75 | ) { |
| 76 | 76 | // Not allowed page |
| 77 | 77 | $session->set('system-error_code', ERR_NOT_ALLOWED); |
| 78 | - include $SETTINGS['cpassman_dir'] . '/error.php'; |
|
| 78 | + include $SETTINGS['cpassman_dir'].'/error.php'; |
|
| 79 | 79 | exit; |
| 80 | 80 | } |
| 81 | 81 | |
@@ -145,7 +145,7 @@ discard block |
||
| 145 | 145 | if (isset($order['column']) && preg_match('#^(asc|desc)$#i', $order['dir'])) { |
| 146 | 146 | $columnIndex = $order['column']; |
| 147 | 147 | $dir = $inputData['dir']; |
| 148 | - $sOrder .= $aColumns[$columnIndex] . ' ' . $dir . ', '; |
|
| 148 | + $sOrder .= $aColumns[$columnIndex].' '.$dir.', '; |
|
| 149 | 149 | } |
| 150 | 150 | |
| 151 | 151 | $sOrder = substr_replace($sOrder, '', -2); |
@@ -113,7 +113,7 @@ |
||
| 113 | 113 | private function isParentFolderAllowed($parent_id, $user_accessible_folders, $user_is_admin, $user_can_create_root_folder) |
| 114 | 114 | { |
| 115 | 115 | if ($parent_id == 0 && $user_can_create_root_folder == true) |
| 116 | - return true; |
|
| 116 | + return true; |
|
| 117 | 117 | |
| 118 | 118 | if (in_array($parent_id, $user_accessible_folders) === false |
| 119 | 119 | && (int) $user_is_admin !== 1 |
@@ -112,8 +112,9 @@ discard block |
||
| 112 | 112 | */ |
| 113 | 113 | private function isParentFolderAllowed($parent_id, $user_accessible_folders, $user_is_admin, $user_can_create_root_folder) |
| 114 | 114 | { |
| 115 | - if ($parent_id == 0 && $user_can_create_root_folder == true) |
|
| 116 | - return true; |
|
| 115 | + if ($parent_id == 0 && $user_can_create_root_folder == true) { |
|
| 116 | + return true; |
|
| 117 | + } |
|
| 117 | 118 | |
| 118 | 119 | if (in_array($parent_id, $user_accessible_folders) === false |
| 119 | 120 | && (int) $user_is_admin !== 1 |
@@ -438,8 +439,9 @@ discard block |
||
| 438 | 439 | )['count']; |
| 439 | 440 | |
| 440 | 441 | // Don't insert duplicates |
| 441 | - if ($count > 0) |
|
| 442 | - continue; |
|
| 442 | + if ($count > 0) { |
|
| 443 | + continue; |
|
| 444 | + } |
|
| 443 | 445 | |
| 444 | 446 | // Insert new background task |
| 445 | 447 | DB::insert( |
@@ -91,7 +91,7 @@ discard block |
||
| 91 | 91 | |
| 92 | 92 | $parentComplexity = $this->checkComplexityLevel($parentFolderData, $complexity, $parent_id); |
| 93 | 93 | if (isset($parentComplexity['error']) && $parentComplexity['error'] === true) { |
| 94 | - return $this->errorResponse($this->lang->get('error_folder_complexity_lower_than_top_folder') . " [<b>{$this->settings['TP_PW_COMPLEXITY'][$parentComplexity['valeur']][1]}</b>]"); |
|
| 94 | + return $this->errorResponse($this->lang->get('error_folder_complexity_lower_than_top_folder')." [<b>{$this->settings['TP_PW_COMPLEXITY'][$parentComplexity['valeur']][1]}</b>]"); |
|
| 95 | 95 | } |
| 96 | 96 | |
| 97 | 97 | return $this->createFolder($params, array_merge($parentFolderData, $parentComplexity), $options); |
@@ -144,7 +144,7 @@ discard block |
||
| 144 | 144 | ) { |
| 145 | 145 | DB::query( |
| 146 | 146 | 'SELECT * |
| 147 | - FROM ' . prefixTable('nested_tree') . ' |
|
| 147 | + FROM ' . prefixTable('nested_tree').' |
|
| 148 | 148 | WHERE title = %s AND personal_folder = 0', |
| 149 | 149 | $title |
| 150 | 150 | ); |
@@ -168,7 +168,7 @@ discard block |
||
| 168 | 168 | //check if parent folder is personal |
| 169 | 169 | $data = DB::queryFirstRow( |
| 170 | 170 | 'SELECT personal_folder, bloquer_creation, bloquer_modification |
| 171 | - FROM ' . prefixTable('nested_tree') . ' |
|
| 171 | + FROM ' . prefixTable('nested_tree').' |
|
| 172 | 172 | WHERE id = %i', |
| 173 | 173 | $parent_id |
| 174 | 174 | ); |
@@ -207,7 +207,7 @@ discard block |
||
| 207 | 207 | // get complexity level for this folder |
| 208 | 208 | $data = DB::queryFirstRow( |
| 209 | 209 | 'SELECT valeur |
| 210 | - FROM ' . prefixTable('misc') . ' |
|
| 210 | + FROM ' . prefixTable('misc').' |
|
| 211 | 211 | WHERE intitule = %i AND type = %s', |
| 212 | 212 | $parent_id, |
| 213 | 213 | 'complex' |
@@ -278,11 +278,11 @@ discard block |
||
| 278 | 278 | */ |
| 279 | 279 | private function canCreateFolder($isPersonal, $user_is_admin, $user_is_manager, $user_can_manage_all_users, $user_can_create_root_folder) |
| 280 | 280 | { |
| 281 | - return (int)$isPersonal === 1 || |
|
| 282 | - (int)$user_is_admin === 1 || |
|
| 283 | - ((int)$user_is_manager === 1 || (int)$user_can_manage_all_users === 1) || |
|
| 281 | + return (int) $isPersonal === 1 || |
|
| 282 | + (int) $user_is_admin === 1 || |
|
| 283 | + ((int) $user_is_manager === 1 || (int) $user_can_manage_all_users === 1) || |
|
| 284 | 284 | ($this->settings['enable_user_can_create_folders'] ?? false) || |
| 285 | - ((int)$user_can_create_root_folder === 1); |
|
| 285 | + ((int) $user_can_create_root_folder === 1); |
|
| 286 | 286 | } |
| 287 | 287 | |
| 288 | 288 | /** |
@@ -362,7 +362,7 @@ discard block |
||
| 362 | 362 | $path = ''; |
| 363 | 363 | $tree_path = $tree->getPath(0, false); |
| 364 | 364 | foreach ($tree_path as $fld) { |
| 365 | - $path .= empty($path) ? $fld->title : '/' . $fld->title; |
|
| 365 | + $path .= empty($path) ? $fld->title : '/'.$fld->title; |
|
| 366 | 366 | } |
| 367 | 367 | |
| 368 | 368 | $new_json = [ |
@@ -378,7 +378,7 @@ discard block |
||
| 378 | 378 | |
| 379 | 379 | $cache_tree = DB::queryFirstRow( |
| 380 | 380 | 'SELECT increment_id, folders, visible_folders |
| 381 | - FROM ' . prefixTable('cache_tree') . ' |
|
| 381 | + FROM ' . prefixTable('cache_tree').' |
|
| 382 | 382 | WHERE user_id = %i', |
| 383 | 383 | (int) $user_id |
| 384 | 384 | ); |
@@ -419,7 +419,7 @@ discard block |
||
| 419 | 419 | private function manageFolderPermissions($parent_id, $newId, $user_roles, $access_rights, $user_is_admin) |
| 420 | 420 | { |
| 421 | 421 | if ($parent_id !== 0 && $this->settings['subfolder_rights_as_parent'] ?? false) { |
| 422 | - $rows = DB::query('SELECT role_id, type FROM ' . prefixTable('roles_values') . ' WHERE folder_id = %i', $parent_id); |
|
| 422 | + $rows = DB::query('SELECT role_id, type FROM '.prefixTable('roles_values').' WHERE folder_id = %i', $parent_id); |
|
| 423 | 423 | foreach ($rows as $record) { |
| 424 | 424 | DB::insert(prefixTable('roles_values'), [ |
| 425 | 425 | 'role_id' => $record['role_id'], |
@@ -427,7 +427,7 @@ discard block |
||
| 427 | 427 | 'type' => $record['type'], |
| 428 | 428 | ]); |
| 429 | 429 | } |
| 430 | - } elseif ((int)$user_is_admin !== 1) { |
|
| 430 | + } elseif ((int) $user_is_admin !== 1) { |
|
| 431 | 431 | foreach (array_unique(explode(';', $user_roles)) as $role) { |
| 432 | 432 | if (!empty($role)) { |
| 433 | 433 | DB::insert(prefixTable('roles_values'), [ |
@@ -445,7 +445,7 @@ discard block |
||
| 445 | 445 | */ |
| 446 | 446 | private function copyCustomFieldsCategories($parent_id, $newId) |
| 447 | 447 | { |
| 448 | - $rows = DB::query('SELECT id_category FROM ' . prefixTable('categories_folders') . ' WHERE id_folder = %i', $parent_id); |
|
| 448 | + $rows = DB::query('SELECT id_category FROM '.prefixTable('categories_folders').' WHERE id_folder = %i', $parent_id); |
|
| 449 | 449 | foreach ($rows as $record) { |
| 450 | 450 | DB::insert(prefixTable('categories_folders'), [ |
| 451 | 451 | 'id_category' => $record['id_category'], |
@@ -470,7 +470,7 @@ discard block |
||
| 470 | 470 | // Search for existing job |
| 471 | 471 | $count = DB::queryFirstRow( |
| 472 | 472 | 'SELECT COUNT(*) AS count |
| 473 | - FROM ' . prefixTable('background_tasks') . ' |
|
| 473 | + FROM ' . prefixTable('background_tasks').' |
|
| 474 | 474 | WHERE is_in_progress = %i AND process_type = %s AND arguments = %s', |
| 475 | 475 | 0, |
| 476 | 476 | 'user_build_cache_tree', |
@@ -504,7 +504,7 @@ discard block |
||
| 504 | 504 | return [ |
| 505 | 505 | 'error' => true, |
| 506 | 506 | 'message' => $message, |
| 507 | - 'newId' => '' . $newIdSuffix, |
|
| 507 | + 'newId' => ''.$newIdSuffix, |
|
| 508 | 508 | ]; |
| 509 | 509 | } |
| 510 | 510 | } |
@@ -1364,4 +1364,4 @@ |
||
| 1364 | 1364 | $string = str_replace("{%}", "?", $string); |
| 1365 | 1365 | // Trim and return. |
| 1366 | 1366 | return trim($string); |
| 1367 | - } |
|
| 1367 | + } |
|
@@ -79,7 +79,7 @@ discard block |
||
| 79 | 79 | ) { |
| 80 | 80 | // Not allowed page |
| 81 | 81 | $session->set('system-error_code', ERR_NOT_ALLOWED); |
| 82 | - include $SETTINGS['cpassman_dir'] . '/error.php'; |
|
| 82 | + include $SETTINGS['cpassman_dir'].'/error.php'; |
|
| 83 | 83 | exit; |
| 84 | 84 | } |
| 85 | 85 | |
@@ -167,7 +167,7 @@ discard block |
||
| 167 | 167 | ); |
| 168 | 168 | |
| 169 | 169 | // Initialisation |
| 170 | - $file = $SETTINGS['path_to_files_folder'] . '/' . $data['valeur']; |
|
| 170 | + $file = $SETTINGS['path_to_files_folder'].'/'.$data['valeur']; |
|
| 171 | 171 | $importation_possible = true; |
| 172 | 172 | $valuesToImport = []; |
| 173 | 173 | $items_number = 0; |
@@ -224,26 +224,26 @@ discard block |
||
| 224 | 224 | 'ISO-8859-1', |
| 225 | 225 | 'ISO-8859-15', |
| 226 | 226 | 'Windows-1252', |
| 227 | - 'Windows-1251', // Cyrillique |
|
| 228 | - 'CP1251', // Cyrillique alternatif |
|
| 229 | - 'KOI8-R', // Cyrillique russe |
|
| 230 | - 'Shift_JIS', // Japonais |
|
| 231 | - 'EUC-JP', // Japonais |
|
| 232 | - 'ISO-2022-JP', // Japonais |
|
| 233 | - 'TIS-620', // Thaï |
|
| 234 | - 'Windows-874', // Thaï Windows |
|
| 235 | - 'Big5', // Chinois traditionnel |
|
| 236 | - 'GB2312', // Chinois simplifié |
|
| 237 | - 'GBK', // Chinois simplifié étendu |
|
| 238 | - 'EUC-KR', // Coréen |
|
| 239 | - 'ISO-8859-2', // Europe centrale |
|
| 240 | - 'ISO-8859-5', // Cyrillique ISO |
|
| 241 | - 'ISO-8859-7', // Grec |
|
| 242 | - 'Windows-1250', // Europe centrale |
|
| 243 | - 'Windows-1253', // Grec |
|
| 244 | - 'Windows-1254', // Turc |
|
| 245 | - 'Windows-1255', // Hébreu |
|
| 246 | - 'Windows-1256', // Arabe |
|
| 227 | + 'Windows-1251', // Cyrillique |
|
| 228 | + 'CP1251', // Cyrillique alternatif |
|
| 229 | + 'KOI8-R', // Cyrillique russe |
|
| 230 | + 'Shift_JIS', // Japonais |
|
| 231 | + 'EUC-JP', // Japonais |
|
| 232 | + 'ISO-2022-JP', // Japonais |
|
| 233 | + 'TIS-620', // Thaï |
|
| 234 | + 'Windows-874', // Thaï Windows |
|
| 235 | + 'Big5', // Chinois traditionnel |
|
| 236 | + 'GB2312', // Chinois simplifié |
|
| 237 | + 'GBK', // Chinois simplifié étendu |
|
| 238 | + 'EUC-KR', // Coréen |
|
| 239 | + 'ISO-8859-2', // Europe centrale |
|
| 240 | + 'ISO-8859-5', // Cyrillique ISO |
|
| 241 | + 'ISO-8859-7', // Grec |
|
| 242 | + 'Windows-1250', // Europe centrale |
|
| 243 | + 'Windows-1253', // Grec |
|
| 244 | + 'Windows-1254', // Turc |
|
| 245 | + 'Windows-1255', // Hébreu |
|
| 246 | + 'Windows-1256', // Arabe |
|
| 247 | 247 | ]; |
| 248 | 248 | |
| 249 | 249 | // Get the list of encodings supported by the system |
@@ -286,7 +286,7 @@ discard block |
||
| 286 | 286 | |
| 287 | 287 | // Get the data and ensure columns are correctly mapped |
| 288 | 288 | $interpreter = new Interpreter(); |
| 289 | - $interpreter->addObserver(function (array $row) use (&$valuesToImport, $header) { |
|
| 289 | + $interpreter->addObserver(function(array $row) use (&$valuesToImport, $header) { |
|
| 290 | 290 | $rowData = array_combine($header, $row); |
| 291 | 291 | |
| 292 | 292 | if ($rowData !== false) { |
@@ -339,7 +339,7 @@ discard block |
||
| 339 | 339 | // Handle multiple lignes description |
| 340 | 340 | if (strpos($comments, '<br>') !== false || strpos($label, '<br>') !== false) { |
| 341 | 341 | $continue_on_next_line = true; |
| 342 | - $comment .= " " . $label . " " . $comments; |
|
| 342 | + $comment .= " ".$label." ".$comments; |
|
| 343 | 343 | } else { |
| 344 | 344 | // Insert previous line if changing line |
| 345 | 345 | if (!empty($label)) { |
@@ -348,7 +348,7 @@ discard block |
||
| 348 | 348 | // Insert in batch |
| 349 | 349 | $batchInsert[] = array( |
| 350 | 350 | 'label' => $label, |
| 351 | - 'description' => $comment . $comments, |
|
| 351 | + 'description' => $comment.$comments, |
|
| 352 | 352 | 'pwd' => $pwd, |
| 353 | 353 | 'url' => $url, |
| 354 | 354 | 'folder' => ((int) $session->get('user-admin') === 1 || (int) $session->get('user-manager') === 1 || (int) $session->get('user-can_manage_all_users') === 1) ? $folder : '', |
@@ -379,7 +379,7 @@ discard block |
||
| 379 | 379 | // Insert in batch |
| 380 | 380 | $batchInsert[] = array( |
| 381 | 381 | 'label' => $label, |
| 382 | - 'description' => $comment . $comments, |
|
| 382 | + 'description' => $comment.$comments, |
|
| 383 | 383 | 'pwd' => $pwd, |
| 384 | 384 | 'url' => $url, |
| 385 | 385 | 'folder' => ((int) $session->get('user-admin') === 1 || (int) $session->get('user-manager') === 1 || (int) $session->get('user-can_manage_all_users') === 1) ? $folder : '', |
@@ -403,10 +403,10 @@ discard block |
||
| 403 | 403 | $values = []; |
| 404 | 404 | |
| 405 | 405 | foreach ($batchInsert as $data) { |
| 406 | - $values[] = "('" . implode("','", array_map('addslashes', $data)) . "')"; |
|
| 406 | + $values[] = "('".implode("','", array_map('addslashes', $data))."')"; |
|
| 407 | 407 | } |
| 408 | 408 | |
| 409 | - $sql = "INSERT INTO `$tableName` (`label`, `description`, `pwd`, `url`, `folder`, `login`, `operation_id`) VALUES " . implode(',', $values); |
|
| 409 | + $sql = "INSERT INTO `$tableName` (`label`, `description`, `pwd`, `url`, `folder`, `login`, `operation_id`) VALUES ".implode(',', $values); |
|
| 410 | 410 | |
| 411 | 411 | DB::query($sql); |
| 412 | 412 | } |
@@ -489,7 +489,7 @@ discard block |
||
| 489 | 489 | $parentId = $dataReceived['folderId']; // Strating with provided folder |
| 490 | 490 | |
| 491 | 491 | foreach ($parts as $part) { |
| 492 | - $currentPath = trim($currentPath . "/" . $part, "/"); |
|
| 492 | + $currentPath = trim($currentPath."/".$part, "/"); |
|
| 493 | 493 | $currentFolder = $part; |
| 494 | 494 | |
| 495 | 495 | // Check if this folder has already been created |
@@ -550,7 +550,7 @@ discard block |
||
| 550 | 550 | // Get ID of existing folder |
| 551 | 551 | $ret = DB::queryFirstRow( |
| 552 | 552 | 'SELECT * |
| 553 | - FROM ' . prefixTable('nested_tree') . ' |
|
| 553 | + FROM ' . prefixTable('nested_tree').' |
|
| 554 | 554 | WHERE title = %s', |
| 555 | 555 | $currentFolder |
| 556 | 556 | ); |
@@ -760,9 +760,9 @@ discard block |
||
| 760 | 760 | ]; |
| 761 | 761 | |
| 762 | 762 | error_log( |
| 763 | - 'SQL Error during import | increment_id: ' . $item['increment_id'] . |
|
| 764 | - ' | Message: ' . $e->getMessage() . |
|
| 765 | - ' | StackTrace: ' . $e->getTraceAsString() |
|
| 763 | + 'SQL Error during import | increment_id: '.$item['increment_id']. |
|
| 764 | + ' | Message: '.$e->getMessage(). |
|
| 765 | + ' | StackTrace: '.$e->getTraceAsString() |
|
| 766 | 766 | ); |
| 767 | 767 | } |
| 768 | 768 | } |
@@ -1071,7 +1071,7 @@ discard block |
||
| 1071 | 1071 | ]; |
| 1072 | 1072 | $startPathLevel = 1; |
| 1073 | 1073 | |
| 1074 | - foreach($post_folders as $folder) { |
|
| 1074 | + foreach ($post_folders as $folder) { |
|
| 1075 | 1075 | // get parent id |
| 1076 | 1076 | if (!isset($arrFolders[$folder['parentFolderId']])) { |
| 1077 | 1077 | // If parent folder is not in the array, it means it is the destination folder |
@@ -1147,7 +1147,7 @@ discard block |
||
| 1147 | 1147 | DB::startTransaction(); |
| 1148 | 1148 | |
| 1149 | 1149 | // Import all items |
| 1150 | - foreach($post_items as $item) { |
|
| 1150 | + foreach ($post_items as $item) { |
|
| 1151 | 1151 | // get info about this folder |
| 1152 | 1152 | $destinationFolderMore = DB::queryFirstRow( |
| 1153 | 1153 | 'SELECT title FROM '.prefixTable('nested_tree').' WHERE id = %i', |
@@ -1178,7 +1178,7 @@ discard block |
||
| 1178 | 1178 | 'pw' => $cryptedStuff['encrypted'], |
| 1179 | 1179 | 'pw_iv' => '', |
| 1180 | 1180 | 'url' => substr($item['URL'], 0, 500), |
| 1181 | - 'id_tree' => isset($post_folders[$item['parentFolderId']]['id']) ? (int)$post_folders[$item['parentFolderId']]['id'] : 0, |
|
| 1181 | + 'id_tree' => isset($post_folders[$item['parentFolderId']]['id']) ? (int) $post_folders[$item['parentFolderId']]['id'] : 0, |
|
| 1182 | 1182 | 'login' => substr($item['UserName'], 0, 500), |
| 1183 | 1183 | 'anyone_can_modify' => $$inputData['editAll'], |
| 1184 | 1184 | 'encryption_type' => 'teampass_aes', |
@@ -1313,7 +1313,7 @@ discard block |
||
| 1313 | 1313 | |
| 1314 | 1314 | //For each role to which the user depends on, add the folder just created. |
| 1315 | 1315 | // (if not personal, otherwise, add to user-personal_folders) |
| 1316 | - if ( $isPersonalFolder ) { |
|
| 1316 | + if ($isPersonalFolder) { |
|
| 1317 | 1317 | SessionManager::addRemoveFromSessionArray('user-personal_folders', [$id], 'add'); |
| 1318 | 1318 | } else { |
| 1319 | 1319 | foreach ($session->get('system-array_roles') as $role) { |
@@ -1384,7 +1384,7 @@ discard block |
||
| 1384 | 1384 | ]; |
| 1385 | 1385 | } |
| 1386 | 1386 | |
| 1387 | -spl_autoload_register(function ($class) { |
|
| 1387 | +spl_autoload_register(function($class) { |
|
| 1388 | 1388 | $prefix = 'League\\Csv\\'; |
| 1389 | 1389 | $base_dir = __DIR__.'/src/'; |
| 1390 | 1390 | $len = strlen($prefix); |
@@ -54,13 +54,17 @@ discard block |
||
| 54 | 54 | ); |
| 55 | 55 | |
| 56 | 56 | if (empty($subtasks)) { |
| 57 | - if (LOG_TASKS=== true) $this->logger->log("No subtask was found for task {$this->taskId}"); |
|
| 57 | + if (LOG_TASKS=== true) { |
|
| 58 | + $this->logger->log("No subtask was found for task {$this->taskId}"); |
|
| 59 | + } |
|
| 58 | 60 | return; |
| 59 | 61 | } |
| 60 | 62 | |
| 61 | 63 | // Process each subtask |
| 62 | 64 | foreach ($subtasks as $subtask) { |
| 63 | - if (LOG_TASKS=== true) $this->logger->log("Processing subtask {$subtask['increment_id']} for task {$this->taskId}"); |
|
| 65 | + if (LOG_TASKS=== true) { |
|
| 66 | + $this->logger->log("Processing subtask {$subtask['increment_id']} for task {$this->taskId}"); |
|
| 67 | + } |
|
| 64 | 68 | $this->processGenerateUserKeysSubtask($subtask, $arguments); |
| 65 | 69 | } |
| 66 | 70 | |
@@ -97,7 +101,9 @@ discard block |
||
| 97 | 101 | $subtask['increment_id'] |
| 98 | 102 | ); |
| 99 | 103 | |
| 100 | - if (LOG_TASKS=== true) $this->logger->log("Subtask is in progress: ".$taskData['step'], 'INFO'); |
|
| 104 | + if (LOG_TASKS=== true) { |
|
| 105 | + $this->logger->log("Subtask is in progress: ".$taskData['step'], 'INFO'); |
|
| 106 | + } |
|
| 101 | 107 | switch ($taskData['step'] ?? '') { |
| 102 | 108 | case 'step0': |
| 103 | 109 | $this->generateNewUserStep0($arguments); |
@@ -50,24 +50,24 @@ discard block |
||
| 50 | 50 | private function generateUserKeys($arguments) { |
| 51 | 51 | // Get all subtasks related to this task |
| 52 | 52 | $subtasks = DB::query( |
| 53 | - 'SELECT * FROM ' . prefixTable('background_subtasks') . ' WHERE task_id = %i AND is_in_progress = 0 ORDER BY `task` ASC', |
|
| 53 | + 'SELECT * FROM '.prefixTable('background_subtasks').' WHERE task_id = %i AND is_in_progress = 0 ORDER BY `task` ASC', |
|
| 54 | 54 | $this->taskId |
| 55 | 55 | ); |
| 56 | 56 | |
| 57 | 57 | if (empty($subtasks)) { |
| 58 | - if (LOG_TASKS=== true) $this->logger->log("No subtask was found for task {$this->taskId}"); |
|
| 58 | + if (LOG_TASKS === true) $this->logger->log("No subtask was found for task {$this->taskId}"); |
|
| 59 | 59 | return; |
| 60 | 60 | } |
| 61 | 61 | |
| 62 | 62 | // Process each subtask |
| 63 | 63 | foreach ($subtasks as $subtask) { |
| 64 | - if (LOG_TASKS=== true) $this->logger->log("Processing subtask {$subtask['increment_id']} for task {$this->taskId}"); |
|
| 64 | + if (LOG_TASKS === true) $this->logger->log("Processing subtask {$subtask['increment_id']} for task {$this->taskId}"); |
|
| 65 | 65 | $this->processGenerateUserKeysSubtask($subtask, $arguments); |
| 66 | 66 | } |
| 67 | 67 | |
| 68 | 68 | // Are all subtasks completed? |
| 69 | 69 | $remainingSubtasks = DB::queryFirstField( |
| 70 | - 'SELECT COUNT(*) FROM ' . prefixTable('background_subtasks') . ' WHERE task_id = %i AND is_in_progress = 0', |
|
| 70 | + 'SELECT COUNT(*) FROM '.prefixTable('background_subtasks').' WHERE task_id = %i AND is_in_progress = 0', |
|
| 71 | 71 | $this->taskId |
| 72 | 72 | ); |
| 73 | 73 | if ($remainingSubtasks == 0) { |
@@ -98,7 +98,7 @@ discard block |
||
| 98 | 98 | $subtask['increment_id'] |
| 99 | 99 | ); |
| 100 | 100 | |
| 101 | - if (LOG_TASKS=== true) $this->logger->log("Subtask is in progress: ".$taskData['step'], 'INFO'); |
|
| 101 | + if (LOG_TASKS === true) $this->logger->log("Subtask is in progress: ".$taskData['step'], 'INFO'); |
|
| 102 | 102 | switch ($taskData['step'] ?? '') { |
| 103 | 103 | case 'step0': |
| 104 | 104 | $this->generateNewUserStep0($arguments); |
@@ -152,7 +152,7 @@ discard block |
||
| 152 | 152 | $subtask['increment_id'] |
| 153 | 153 | ); |
| 154 | 154 | |
| 155 | - $this->logger->log("Subtask {$subtask['increment_id']} failure: " . $e->getMessage(), 'ERROR'); |
|
| 155 | + $this->logger->log("Subtask {$subtask['increment_id']} failure: ".$e->getMessage(), 'ERROR'); |
|
| 156 | 156 | } |
| 157 | 157 | } |
| 158 | 158 | |
@@ -186,7 +186,7 @@ discard block |
||
| 186 | 186 | // Loop on items |
| 187 | 187 | $rows = DB::query( |
| 188 | 188 | 'SELECT id, pw, perso |
| 189 | - FROM ' . prefixTable('items') . ' |
|
| 189 | + FROM ' . prefixTable('items').' |
|
| 190 | 190 | WHERE perso = %i |
| 191 | 191 | ORDER BY id ASC |
| 192 | 192 | LIMIT %i, %i', |
@@ -199,7 +199,7 @@ discard block |
||
| 199 | 199 | // Get itemKey from current user |
| 200 | 200 | $currentUserKey = DB::queryFirstRow( |
| 201 | 201 | 'SELECT share_key, increment_id |
| 202 | - FROM ' . prefixTable('sharekeys_items') . ' |
|
| 202 | + FROM ' . prefixTable('sharekeys_items').' |
|
| 203 | 203 | WHERE object_id = %i AND user_id = %i', |
| 204 | 204 | $record['id'], |
| 205 | 205 | (int) $record['perso'] === 0 ? $arguments['owner_id'] : $arguments['new_user_id'] |
@@ -226,7 +226,7 @@ discard block |
||
| 226 | 226 | |
| 227 | 227 | $currentUserKey = DB::queryFirstRow( |
| 228 | 228 | 'SELECT increment_id |
| 229 | - FROM ' . prefixTable('sharekeys_items') . ' |
|
| 229 | + FROM ' . prefixTable('sharekeys_items').' |
|
| 230 | 230 | WHERE object_id = %i AND user_id = %i', |
| 231 | 231 | $record['id'], |
| 232 | 232 | $arguments['new_user_id'] |
@@ -276,16 +276,16 @@ discard block |
||
| 276 | 276 | // Loop on logs |
| 277 | 277 | $rows = DB::query( |
| 278 | 278 | 'SELECT increment_id |
| 279 | - FROM ' . prefixTable('log_items') . ' |
|
| 279 | + FROM ' . prefixTable('log_items').' |
|
| 280 | 280 | WHERE raison LIKE "at_pw :%" AND encryption_type = "teampass_aes" |
| 281 | 281 | ORDER BY increment_id ASC |
| 282 | - LIMIT ' . $taskData['index'] . ', ' . $taskData['nb'] |
|
| 282 | + LIMIT ' . $taskData['index'].', '.$taskData['nb'] |
|
| 283 | 283 | ); |
| 284 | 284 | foreach ($rows as $record) { |
| 285 | 285 | // Get itemKey from current user |
| 286 | 286 | $currentUserKey = DB::queryFirstRow( |
| 287 | 287 | 'SELECT share_key |
| 288 | - FROM ' . prefixTable('sharekeys_logs') . ' |
|
| 288 | + FROM ' . prefixTable('sharekeys_logs').' |
|
| 289 | 289 | WHERE object_id = %i AND user_id = %i', |
| 290 | 290 | $record['increment_id'], |
| 291 | 291 | $arguments['owner_id'] |
@@ -317,7 +317,7 @@ discard block |
||
| 317 | 317 | if ((int) $arguments['new_user_id'] !== (int) $arguments['owner_id']) { |
| 318 | 318 | $currentUserKey = DB::queryFirstRow( |
| 319 | 319 | 'SELECT increment_id |
| 320 | - FROM ' . prefixTable('sharekeys_items') . ' |
|
| 320 | + FROM ' . prefixTable('sharekeys_items').' |
|
| 321 | 321 | WHERE object_id = %i AND user_id = %i', |
| 322 | 322 | $record['id'], |
| 323 | 323 | $arguments['new_user_id'] |
@@ -358,7 +358,7 @@ discard block |
||
| 358 | 358 | // Loop on fields |
| 359 | 359 | $rows = DB::query( |
| 360 | 360 | 'SELECT id |
| 361 | - FROM ' . prefixTable('categories_items') . ' |
|
| 361 | + FROM ' . prefixTable('categories_items').' |
|
| 362 | 362 | WHERE encryption_type = "teampass_aes" |
| 363 | 363 | ORDER BY id ASC |
| 364 | 364 | LIMIT %i, %i', |
@@ -369,7 +369,7 @@ discard block |
||
| 369 | 369 | // Get itemKey from current user |
| 370 | 370 | $currentUserKey = DB::queryFirstRow( |
| 371 | 371 | 'SELECT share_key |
| 372 | - FROM ' . prefixTable('sharekeys_fields') . ' |
|
| 372 | + FROM ' . prefixTable('sharekeys_fields').' |
|
| 373 | 373 | WHERE object_id = %i AND user_id = %i', |
| 374 | 374 | $record['id'], |
| 375 | 375 | $arguments['owner_id'] |
@@ -397,7 +397,7 @@ discard block |
||
| 397 | 397 | if ((int) $arguments['new_user_id'] !== (int) $arguments['owner_id']) { |
| 398 | 398 | $currentUserKey = DB::queryFirstRow( |
| 399 | 399 | 'SELECT increment_id |
| 400 | - FROM ' . prefixTable('sharekeys_items') . ' |
|
| 400 | + FROM ' . prefixTable('sharekeys_items').' |
|
| 401 | 401 | WHERE object_id = %i AND user_id = %i', |
| 402 | 402 | $record['id'], |
| 403 | 403 | $arguments['new_user_id'] |
@@ -439,7 +439,7 @@ discard block |
||
| 439 | 439 | // Loop on suggestions |
| 440 | 440 | $rows = DB::query( |
| 441 | 441 | 'SELECT id |
| 442 | - FROM ' . prefixTable('suggestion') . ' |
|
| 442 | + FROM ' . prefixTable('suggestion').' |
|
| 443 | 443 | ORDER BY id ASC |
| 444 | 444 | LIMIT %i, %i', |
| 445 | 445 | $taskData['index'], |
@@ -449,7 +449,7 @@ discard block |
||
| 449 | 449 | // Get itemKey from current user |
| 450 | 450 | $currentUserKey = DB::queryFirstRow( |
| 451 | 451 | 'SELECT share_key |
| 452 | - FROM ' . prefixTable('sharekeys_suggestions') . ' |
|
| 452 | + FROM ' . prefixTable('sharekeys_suggestions').' |
|
| 453 | 453 | WHERE object_id = %i AND user_id = %i', |
| 454 | 454 | $record['id'], |
| 455 | 455 | $arguments['owner_id'] |
@@ -481,7 +481,7 @@ discard block |
||
| 481 | 481 | if ((int) $arguments['new_user_id'] !== (int) $arguments['owner_id']) { |
| 482 | 482 | $currentUserKey = DB::queryFirstRow( |
| 483 | 483 | 'SELECT increment_id |
| 484 | - FROM ' . prefixTable('sharekeys_items') . ' |
|
| 484 | + FROM ' . prefixTable('sharekeys_items').' |
|
| 485 | 485 | WHERE object_id = %i AND user_id = %i', |
| 486 | 486 | $record['id'], |
| 487 | 487 | $arguments['new_user_id'] |
@@ -522,9 +522,9 @@ discard block |
||
| 522 | 522 | // Loop on files |
| 523 | 523 | $rows = DB::query( |
| 524 | 524 | 'SELECT f.id AS id, i.perso AS perso |
| 525 | - FROM ' . prefixTable('files') . ' AS f |
|
| 526 | - INNER JOIN ' . prefixTable('items') . ' AS i ON i.id = f.id_item |
|
| 527 | - WHERE f.status = "' . TP_ENCRYPTION_NAME . '" |
|
| 525 | + FROM ' . prefixTable('files').' AS f |
|
| 526 | + INNER JOIN ' . prefixTable('items').' AS i ON i.id = f.id_item |
|
| 527 | + WHERE f.status = "' . TP_ENCRYPTION_NAME.'" |
|
| 528 | 528 | LIMIT %i, %i', |
| 529 | 529 | $taskData['index'], |
| 530 | 530 | $taskData['nb'] |
@@ -533,7 +533,7 @@ discard block |
||
| 533 | 533 | // Get itemKey from current user |
| 534 | 534 | $currentUserKey = DB::queryFirstRow( |
| 535 | 535 | 'SELECT share_key, increment_id |
| 536 | - FROM ' . prefixTable('sharekeys_files') . ' |
|
| 536 | + FROM ' . prefixTable('sharekeys_files').' |
|
| 537 | 537 | WHERE object_id = %i AND user_id = %i', |
| 538 | 538 | $record['id'], |
| 539 | 539 | (int) $record['perso'] === 0 ? $arguments['owner_id'] : $arguments['new_user_id'] |
@@ -561,7 +561,7 @@ discard block |
||
| 561 | 561 | |
| 562 | 562 | $currentUserKey = DB::queryFirstRow( |
| 563 | 563 | 'SELECT increment_id |
| 564 | - FROM ' . prefixTable('sharekeys_files') . ' |
|
| 564 | + FROM ' . prefixTable('sharekeys_files').' |
|
| 565 | 565 | WHERE object_id = %i AND user_id = %i', |
| 566 | 566 | $record['id'], |
| 567 | 567 | $arguments['new_user_id'] |
@@ -623,7 +623,7 @@ discard block |
||
| 623 | 623 | // get user info |
| 624 | 624 | $userInfo = DB::queryFirstRow( |
| 625 | 625 | 'SELECT email, login, auth_type, special, lastname, name |
| 626 | - FROM ' . prefixTable('users') . ' |
|
| 626 | + FROM ' . prefixTable('users').' |
|
| 627 | 627 | WHERE id = %i', |
| 628 | 628 | $arguments['new_user_id'] |
| 629 | 629 | ); |
@@ -638,10 +638,10 @@ discard block |
||
| 638 | 638 | filter_var($userInfo['email'], FILTER_SANITIZE_EMAIL), |
| 639 | 639 | // @scrutinizer ignore-type |
| 640 | 640 | empty($arguments['email_body']) === false ? $arguments['email_body'] : $lang->get('email_body_user_config_1'), |
| 641 | - 'TEAMPASS - ' . $lang->get('login_credentials'), |
|
| 641 | + 'TEAMPASS - '.$lang->get('login_credentials'), |
|
| 642 | 642 | (array) filter_var_array( |
| 643 | 643 | [ |
| 644 | - '#code#' => cryption($arguments['new_user_code'], '','decrypt', $this->settings)['string'], |
|
| 644 | + '#code#' => cryption($arguments['new_user_code'], '', 'decrypt', $this->settings)['string'], |
|
| 645 | 645 | '#lastname#' => isset($userInfo['name']) === true ? $userInfo['name'] : '', |
| 646 | 646 | '#login#' => isset($userInfo['login']) === true ? $userInfo['login'] : '', |
| 647 | 647 | ], |
@@ -677,13 +677,13 @@ discard block |
||
| 677 | 677 | private function getOwnerInfos(int $owner_id, string $owner_pwd) { |
| 678 | 678 | $userInfo = DB::queryFirstRow( |
| 679 | 679 | 'SELECT pw, public_key, private_key, login, name |
| 680 | - FROM ' . prefixTable('users') . ' |
|
| 680 | + FROM ' . prefixTable('users').' |
|
| 681 | 681 | WHERE id = %i', |
| 682 | 682 | $owner_id |
| 683 | 683 | ); |
| 684 | 684 | |
| 685 | 685 | // decrypt owner password |
| 686 | - $pwd = cryption($owner_pwd, '','decrypt', $this->settings)['string']; |
|
| 686 | + $pwd = cryption($owner_pwd, '', 'decrypt', $this->settings)['string']; |
|
| 687 | 687 | // decrypt private key and send back |
| 688 | 688 | return [ |
| 689 | 689 | 'private_key' => decryptPrivateKey($pwd, $userInfo['private_key']), |