@@ -76,7 +76,7 @@ discard block |
||
| 76 | 76 | ) { |
| 77 | 77 | // Not allowed page |
| 78 | 78 | $session->set('system-error_code', ERR_NOT_ALLOWED); |
| 79 | - include $SETTINGS['cpassman_dir'] . '/error.php'; |
|
| 79 | + include $SETTINGS['cpassman_dir'].'/error.php'; |
|
| 80 | 80 | exit; |
| 81 | 81 | } |
| 82 | 82 | |
@@ -168,7 +168,7 @@ discard block |
||
| 168 | 168 | |
| 169 | 169 | // Output |
| 170 | 170 | $sOutput = '{'; |
| 171 | - $sOutput .= '"sEcho": '. $request->query->filter('draw', FILTER_SANITIZE_NUMBER_INT) . ', '; |
|
| 171 | + $sOutput .= '"sEcho": '.$request->query->filter('draw', FILTER_SANITIZE_NUMBER_INT).', '; |
|
| 172 | 172 | $sOutput .= '"iTotalRecords": '.$iTotal.', '; |
| 173 | 173 | $sOutput .= '"iTotalDisplayRecords": '.$iTotal.', '; |
| 174 | 174 | $sOutput .= '"aaData": '; |
@@ -241,7 +241,7 @@ discard block |
||
| 241 | 241 | |
| 242 | 242 | // Output |
| 243 | 243 | $sOutput = '{'; |
| 244 | - $sOutput .= '"sEcho": '. $request->query->filter('draw', FILTER_SANITIZE_NUMBER_INT) . ', '; |
|
| 244 | + $sOutput .= '"sEcho": '.$request->query->filter('draw', FILTER_SANITIZE_NUMBER_INT).', '; |
|
| 245 | 245 | $sOutput .= '"iTotalRecords": '.$iTotal.', '; |
| 246 | 246 | $sOutput .= '"iTotalDisplayRecords": '.$iTotal.', '; |
| 247 | 247 | $sOutput .= '"aaData": '; |
@@ -314,7 +314,7 @@ discard block |
||
| 314 | 314 | |
| 315 | 315 | // Output |
| 316 | 316 | $sOutput = '{'; |
| 317 | - $sOutput .= '"sEcho": '. (int) $request->query->filter('draw', FILTER_SANITIZE_NUMBER_INT) . ', '; |
|
| 317 | + $sOutput .= '"sEcho": '.(int) $request->query->filter('draw', FILTER_SANITIZE_NUMBER_INT).', '; |
|
| 318 | 318 | $sOutput .= '"iTotalRecords": '.$iTotal.', '; |
| 319 | 319 | $sOutput .= '"iTotalDisplayRecords": '.$iTotal.', '; |
| 320 | 320 | $sOutput .= '"aaData": '; |
@@ -387,7 +387,7 @@ discard block |
||
| 387 | 387 | |
| 388 | 388 | // Output |
| 389 | 389 | $sOutput = '{'; |
| 390 | - $sOutput .= '"sEcho": '. (int) $request->query->filter('draw', FILTER_SANITIZE_NUMBER_INT) . ', '; |
|
| 390 | + $sOutput .= '"sEcho": '.(int) $request->query->filter('draw', FILTER_SANITIZE_NUMBER_INT).', '; |
|
| 391 | 391 | $sOutput .= '"iTotalRecords": '.$iTotal.', '; |
| 392 | 392 | $sOutput .= '"iTotalDisplayRecords": '.$iTotal.', '; |
| 393 | 393 | $sOutput .= '"aaData": [ '; |
@@ -490,7 +490,7 @@ discard block |
||
| 490 | 490 | |
| 491 | 491 | // Output |
| 492 | 492 | $sOutput = '{'; |
| 493 | - $sOutput .= '"sEcho": '. (int) $request->query->filter('draw', FILTER_SANITIZE_NUMBER_INT) . ', '; |
|
| 493 | + $sOutput .= '"sEcho": '.(int) $request->query->filter('draw', FILTER_SANITIZE_NUMBER_INT).', '; |
|
| 494 | 494 | $sOutput .= '"iTotalRecords": '.$iTotal.', '; |
| 495 | 495 | $sOutput .= '"iTotalDisplayRecords": '.$iTotal.', '; |
| 496 | 496 | $sOutput .= '"aaData": [ '; |
@@ -572,7 +572,7 @@ discard block |
||
| 572 | 572 | $iTotal = 0; |
| 573 | 573 | } |
| 574 | 574 | $sOutput = '{'; |
| 575 | - $sOutput .= '"sEcho": '. (int) $request->query->filter('draw', FILTER_SANITIZE_NUMBER_INT) . ', '; |
|
| 575 | + $sOutput .= '"sEcho": '.(int) $request->query->filter('draw', FILTER_SANITIZE_NUMBER_INT).', '; |
|
| 576 | 576 | $sOutput .= '"iTotalRecords": '.$iTotal.', '; |
| 577 | 577 | $sOutput .= '"iTotalDisplayRecords": '.$iTotal.', '; |
| 578 | 578 | $sOutput .= '"aaData": '; |
@@ -648,7 +648,7 @@ discard block |
||
| 648 | 648 | |
| 649 | 649 | // Output |
| 650 | 650 | $sOutput = '{'; |
| 651 | - $sOutput .= '"sEcho": '. (int) $request->query->filter('draw', FILTER_SANITIZE_NUMBER_INT) . ', '; |
|
| 651 | + $sOutput .= '"sEcho": '.(int) $request->query->filter('draw', FILTER_SANITIZE_NUMBER_INT).', '; |
|
| 652 | 652 | $sOutput .= '"iTotalRecords": '.$iTotal.', '; |
| 653 | 653 | $sOutput .= '"iTotalDisplayRecords": '.$iTotal.', '; |
| 654 | 654 | $sOutput .= '"aaData": '; |
@@ -717,7 +717,7 @@ discard block |
||
| 717 | 717 | |
| 718 | 718 | // Output |
| 719 | 719 | $sOutput = '{'; |
| 720 | - $sOutput .= '"sEcho": '. (int) $request->query->filter('draw', FILTER_SANITIZE_NUMBER_INT) . ', '; |
|
| 720 | + $sOutput .= '"sEcho": '.(int) $request->query->filter('draw', FILTER_SANITIZE_NUMBER_INT).', '; |
|
| 721 | 721 | $sOutput .= '"iTotalRecords": '.$iTotal.', '; |
| 722 | 722 | $sOutput .= '"iTotalDisplayRecords": '.$iTotal.', '; |
| 723 | 723 | $sOutput .= '"aaData": '; |
@@ -790,7 +790,7 @@ discard block |
||
| 790 | 790 | |
| 791 | 791 | // Output |
| 792 | 792 | $sOutput = '{'; |
| 793 | - $sOutput .= '"sEcho": '. (int) $request->query->filter('draw', FILTER_SANITIZE_NUMBER_INT) . ', '; |
|
| 793 | + $sOutput .= '"sEcho": '.(int) $request->query->filter('draw', FILTER_SANITIZE_NUMBER_INT).', '; |
|
| 794 | 794 | $sOutput .= '"iTotalRecords": '.$iTotal.', '; |
| 795 | 795 | $sOutput .= '"iTotalDisplayRecords": '.$iTotal.', '; |
| 796 | 796 | $sOutput .= '"aaData": '; |
@@ -867,7 +867,7 @@ discard block |
||
| 867 | 867 | FROM '.prefixTable('background_tasks').' AS p |
| 868 | 868 | LEFT JOIN '.prefixTable('users').' AS u ON %l |
| 869 | 869 | WHERE %l ORDER BY %l %l LIMIT %i, %i'; |
| 870 | - $params = ['u.id = json_extract(p.arguments, "$[0]")',$sWhere, $orderColumn, $orderDirection, $sLimitStart, $sLimitLength]; |
|
| 870 | + $params = ['u.id = json_extract(p.arguments, "$[0]")', $sWhere, $orderColumn, $orderDirection, $sLimitStart, $sLimitLength]; |
|
| 871 | 871 | |
| 872 | 872 | // Get the records |
| 873 | 873 | $rows = DB::query($sql, ...$params); |
@@ -875,7 +875,7 @@ discard block |
||
| 875 | 875 | |
| 876 | 876 | // Output |
| 877 | 877 | $sOutput = '{'; |
| 878 | - $sOutput .= '"sEcho": '. (int) $request->query->filter('draw', FILTER_SANITIZE_NUMBER_INT) . ', '; |
|
| 878 | + $sOutput .= '"sEcho": '.(int) $request->query->filter('draw', FILTER_SANITIZE_NUMBER_INT).', '; |
|
| 879 | 879 | $sOutput .= '"iTotalRecords": '.$iTotal.', '; |
| 880 | 880 | $sOutput .= '"iTotalDisplayRecords": '.$iTotal.', '; |
| 881 | 881 | $sOutput .= '"aaData": '; |
@@ -890,7 +890,7 @@ discard block |
||
| 890 | 890 | //col1 |
| 891 | 891 | $sOutput .= '"<span data-done=\"'.$record['is_in_progress'].'\" data-type=\"'.$record['process_type'].'\" data-process-id=\"'.$record['increment_id'].'\"></span>", '; |
| 892 | 892 | //col2 |
| 893 | - $sOutput .= '"'.date($SETTINGS['date_format'] . ' ' . $SETTINGS['time_format'], (int) $record['created_at']).'", '; |
|
| 893 | + $sOutput .= '"'.date($SETTINGS['date_format'].' '.$SETTINGS['time_format'], (int) $record['created_at']).'", '; |
|
| 894 | 894 | //col3 |
| 895 | 895 | //$sOutput .= '"'.($record['updated_at'] === '' ? '-' : date($SETTINGS['date_format'] . ' ' . $SETTINGS['time_format'], (int) $record['updated_at'])).'", '; |
| 896 | 896 | $sOutput .= '"<div class=\"progress mt-2\"><div class=\"progress-bar\" style=\"width: '.$subtaskProgress.'\">'.$subtaskProgress.'</div></div>", '; |
@@ -900,7 +900,7 @@ discard block |
||
| 900 | 900 | // col5 |
| 901 | 901 | if (in_array($record['process_type'], array('create_user_keys', 'item_copy')) === true) { |
| 902 | 902 | $data_user = DB::queryFirstRow( |
| 903 | - 'SELECT name, lastname FROM ' . prefixTable('users') . ' |
|
| 903 | + 'SELECT name, lastname FROM '.prefixTable('users').' |
|
| 904 | 904 | WHERE id = %i', |
| 905 | 905 | json_decode($record['arguments'], true)['new_user_id'] |
| 906 | 906 | ); |
@@ -956,7 +956,7 @@ discard block |
||
| 956 | 956 | FROM '.prefixTable('background_tasks').' AS p |
| 957 | 957 | LEFT JOIN '.prefixTable('users').' AS u ON %l |
| 958 | 958 | WHERE %l ORDER BY %l %l LIMIT %i, %i'; |
| 959 | - $params = ['u.id = json_extract(p.arguments, "$[0]")',$sWhere, $orderColumn, $orderDirection, $sLimitStart, $sLimitLength]; |
|
| 959 | + $params = ['u.id = json_extract(p.arguments, "$[0]")', $sWhere, $orderColumn, $orderDirection, $sLimitStart, $sLimitLength]; |
|
| 960 | 960 | |
| 961 | 961 | // Get the records |
| 962 | 962 | $rows = DB::query($sql, ...$params); |
@@ -964,7 +964,7 @@ discard block |
||
| 964 | 964 | |
| 965 | 965 | // Output |
| 966 | 966 | $sOutput = '{'; |
| 967 | - $sOutput .= '"sEcho": '. (int) $request->query->filter('draw', FILTER_SANITIZE_NUMBER_INT) . ', '; |
|
| 967 | + $sOutput .= '"sEcho": '.(int) $request->query->filter('draw', FILTER_SANITIZE_NUMBER_INT).', '; |
|
| 968 | 968 | $sOutput .= '"iTotalRecords": '.$iTotal.', '; |
| 969 | 969 | $sOutput .= '"iTotalDisplayRecords": '.$iTotal.', '; |
| 970 | 970 | $sOutput .= '"aaData": '; |
@@ -980,13 +980,12 @@ discard block |
||
| 980 | 980 | //col1 |
| 981 | 981 | $sOutput .= '"'.(is_null($record['error_message']) ? '' : addslashes($record['error_message'])).'", '; |
| 982 | 982 | //col2 |
| 983 | - $sOutput .= '"'.date($SETTINGS['date_format'] . ' ' . $SETTINGS['time_format'], (int) $record['created_at']).'", '; |
|
| 983 | + $sOutput .= '"'.date($SETTINGS['date_format'].' '.$SETTINGS['time_format'], (int) $record['created_at']).'", '; |
|
| 984 | 984 | //col3 |
| 985 | 985 | $sOutput .= is_null($record['started_at']) === false ? |
| 986 | - ('"'.date($SETTINGS['date_format'] . ' ' . $SETTINGS['time_format'], (int) $record['started_at']).'", ') : |
|
| 987 | - ('"'.date($SETTINGS['date_format'] . ' ' . $SETTINGS['time_format'], (int) $record['created_at']).'", '); |
|
| 986 | + ('"'.date($SETTINGS['date_format'].' '.$SETTINGS['time_format'], (int) $record['started_at']).'", ') : ('"'.date($SETTINGS['date_format'].' '.$SETTINGS['time_format'], (int) $record['created_at']).'", '); |
|
| 988 | 987 | //col4 |
| 989 | - $sOutput .= '"'.date($SETTINGS['date_format'] . ' ' . $SETTINGS['time_format'], (int) $record['finished_at']).'", '; |
|
| 988 | + $sOutput .= '"'.date($SETTINGS['date_format'].' '.$SETTINGS['time_format'], (int) $record['finished_at']).'", '; |
|
| 990 | 989 | // col7 |
| 991 | 990 | $sOutput .= '"'.gmdate('H:i:s', (int) $record['finished_at'] - (is_null($record['started_at']) === false ? (int) $record['started_at'] : (int) $record['created_at'])).'",'; |
| 992 | 991 | //col5 |
@@ -1009,11 +1008,10 @@ discard block |
||
| 1009 | 1008 | // col6 |
| 1010 | 1009 | $arguments = json_decode($record['arguments'], true); |
| 1011 | 1010 | $newUserId = array_key_exists('new_user_id', $arguments) ? |
| 1012 | - $arguments['new_user_id'] : |
|
| 1013 | - (array_key_exists('user_id', $arguments) ? $arguments['user_id'] : null); |
|
| 1011 | + $arguments['new_user_id'] : (array_key_exists('user_id', $arguments) ? $arguments['user_id'] : null); |
|
| 1014 | 1012 | if ($record['process_type'] === 'create_user_keys' && is_null($newUserId) === false && empty($newUserId) === false) { |
| 1015 | 1013 | $data_user = DB::queryFirstRow( |
| 1016 | - 'SELECT name, lastname, login FROM ' . prefixTable('users') . ' |
|
| 1014 | + 'SELECT name, lastname, login FROM '.prefixTable('users').' |
|
| 1017 | 1015 | WHERE id = %i', |
| 1018 | 1016 | $newUserId |
| 1019 | 1017 | ); |
@@ -1029,7 +1027,7 @@ discard block |
||
| 1029 | 1027 | } elseif ($record['process_type'] === 'user_build_cache_tree') { |
| 1030 | 1028 | $user = json_decode($record['arguments'], true)['user_id']; |
| 1031 | 1029 | $data_user = DB::queryFirstRow( |
| 1032 | - 'SELECT name, lastname, login FROM ' . prefixTable('users') . ' |
|
| 1030 | + 'SELECT name, lastname, login FROM '.prefixTable('users').' |
|
| 1033 | 1031 | WHERE id = %i', |
| 1034 | 1032 | $user |
| 1035 | 1033 | ); |
@@ -1063,7 +1061,7 @@ discard block |
||
| 1063 | 1061 | { |
| 1064 | 1062 | $subtasks = DB::query( |
| 1065 | 1063 | 'SELECT * |
| 1066 | - FROM ' . prefixTable('background_subtasks') . ' |
|
| 1064 | + FROM ' . prefixTable('background_subtasks').' |
|
| 1067 | 1065 | WHERE task_id = %i', |
| 1068 | 1066 | $id |
| 1069 | 1067 | ); |
@@ -1079,5 +1077,5 @@ discard block |
||
| 1079 | 1077 | $i++; |
| 1080 | 1078 | } |
| 1081 | 1079 | |
| 1082 | - return ($finished_nb !== 0 ? pourcentage($finished_nb, $nb, 100) : 0) .'%'; |
|
| 1080 | + return ($finished_nb !== 0 ? pourcentage($finished_nb, $nb, 100) : 0).'%'; |
|
| 1083 | 1081 | } |
| 1084 | 1082 | \ No newline at end of file |
@@ -47,8 +47,8 @@ |
||
| 47 | 47 | */ |
| 48 | 48 | public function log(string $message, string $level = 'INFO') { |
| 49 | 49 | if (!empty($this->settings['enable_tasks_log'])) { |
| 50 | - $formattedMessage = date($this->settings['date_format'] . ' ' . $this->settings['time_format']) . |
|
| 51 | - " - [$level] $message" . PHP_EOL; |
|
| 50 | + $formattedMessage = date($this->settings['date_format'].' '.$this->settings['time_format']). |
|
| 51 | + " - [$level] $message".PHP_EOL; |
|
| 52 | 52 | |
| 53 | 53 | if (!empty($this->logFile)) { |
| 54 | 54 | // WWrite to the specified log file |
@@ -32,7 +32,7 @@ discard block |
||
| 32 | 32 | require_once __DIR__.'/traits/ItemHandlerTrait.php'; |
| 33 | 33 | require_once __DIR__.'/traits/UserHandlerTrait.php'; |
| 34 | 34 | require_once __DIR__.'/traits/EmailTrait.php'; |
| 35 | -require_once __DIR__ . '/taskLogger.php'; |
|
| 35 | +require_once __DIR__.'/taskLogger.php'; |
|
| 36 | 36 | |
| 37 | 37 | class TaskWorker { |
| 38 | 38 | use ItemHandlerTrait; |
@@ -64,7 +64,7 @@ discard block |
||
| 64 | 64 | */ |
| 65 | 65 | public function execute() { |
| 66 | 66 | try { |
| 67 | - if (LOG_TASKS=== true) $this->logger->log('Processing task: ' . print_r($this->taskData, true), 'DEBUG'); |
|
| 67 | + if (LOG_TASKS === true) $this->logger->log('Processing task: '.print_r($this->taskData, true), 'DEBUG'); |
|
| 68 | 68 | // Dispatch selon le type de processus |
| 69 | 69 | switch ($this->processType) { |
| 70 | 70 | case 'item_copy': |
@@ -136,7 +136,7 @@ discard block |
||
| 136 | 136 | $arguments = ''; |
| 137 | 137 | } |
| 138 | 138 | |
| 139 | - if (LOG_TASKS=== true) $this->logger->log('Process: '.$this->processType.' -- '.print_r($arguments, true), 'DEBUG'); |
|
| 139 | + if (LOG_TASKS === true) $this->logger->log('Process: '.$this->processType.' -- '.print_r($arguments, true), 'DEBUG'); |
|
| 140 | 140 | |
| 141 | 141 | // Add 'arguments' only if not empty |
| 142 | 142 | if (!empty($arguments)) { |
@@ -150,7 +150,7 @@ discard block |
||
| 150 | 150 | 'increment_id = %i', |
| 151 | 151 | $this->taskId |
| 152 | 152 | ); |
| 153 | - if (LOG_TASKS=== true) $this->logger->log('Finishing task: ' . $this->taskId, 'DEBUG'); |
|
| 153 | + if (LOG_TASKS === true) $this->logger->log('Finishing task: '.$this->taskId, 'DEBUG'); |
|
| 154 | 154 | } |
| 155 | 155 | |
| 156 | 156 | /** |
@@ -173,7 +173,7 @@ discard block |
||
| 173 | 173 | 'increment_id = %i', |
| 174 | 174 | $this->taskId |
| 175 | 175 | ); |
| 176 | - $this->logger->log('Task failure: ' . $e->getMessage(), 'ERROR'); |
|
| 176 | + $this->logger->log('Task failure: '.$e->getMessage(), 'ERROR'); |
|
| 177 | 177 | } |
| 178 | 178 | |
| 179 | 179 | /** |
@@ -185,16 +185,16 @@ discard block |
||
| 185 | 185 | * @return void |
| 186 | 186 | */ |
| 187 | 187 | private function processSubTasks($arguments) { |
| 188 | - if (LOG_TASKS=== true) $this->logger->log('processSubTasks: '.print_r($arguments, true), 'DEBUG'); |
|
| 188 | + if (LOG_TASKS === true) $this->logger->log('processSubTasks: '.print_r($arguments, true), 'DEBUG'); |
|
| 189 | 189 | // Get all subtasks related to this task |
| 190 | 190 | $subtasks = DB::query( |
| 191 | - 'SELECT * FROM ' . prefixTable('background_subtasks') . ' WHERE task_id = %i AND is_in_progress = 0 ORDER BY `task` ASC', |
|
| 191 | + 'SELECT * FROM '.prefixTable('background_subtasks').' WHERE task_id = %i AND is_in_progress = 0 ORDER BY `task` ASC', |
|
| 192 | 192 | $this->taskId |
| 193 | 193 | ); |
| 194 | 194 | |
| 195 | 195 | // Check if there are any subtasks to process |
| 196 | 196 | if (empty($subtasks)) { |
| 197 | - if (LOG_TASKS=== true) $this->logger->log('No subtask was found for task: ' . $this->taskId, 'DEBUG'); |
|
| 197 | + if (LOG_TASKS === true) $this->logger->log('No subtask was found for task: '.$this->taskId, 'DEBUG'); |
|
| 198 | 198 | return; |
| 199 | 199 | } |
| 200 | 200 | |
@@ -204,7 +204,7 @@ discard block |
||
| 204 | 204 | // Get the subtask data |
| 205 | 205 | $subtaskData = json_decode($subtask['task'], true); |
| 206 | 206 | |
| 207 | - if (LOG_TASKS=== true) $this->logger->log('Processing subtask: ' . $subtaskData['step'], 'DEBUG'); |
|
| 207 | + if (LOG_TASKS === true) $this->logger->log('Processing subtask: '.$subtaskData['step'], 'DEBUG'); |
|
| 208 | 208 | |
| 209 | 209 | // Process the subtask based on its type |
| 210 | 210 | switch ($subtaskData['step'] ?? '') { |
@@ -248,13 +248,13 @@ discard block |
||
| 248 | 248 | $subtask['increment_id'] |
| 249 | 249 | ); |
| 250 | 250 | |
| 251 | - $this->logger->log('processSubTasks : ' . $e->getMessage(), 'ERROR'); |
|
| 251 | + $this->logger->log('processSubTasks : '.$e->getMessage(), 'ERROR'); |
|
| 252 | 252 | } |
| 253 | 253 | } |
| 254 | 254 | |
| 255 | 255 | // Are all subtasks completed? |
| 256 | 256 | $remainingSubtasks = DB::queryFirstField( |
| 257 | - 'SELECT COUNT(*) FROM ' . prefixTable('background_subtasks') . ' WHERE task_id = %i AND is_in_progress = 0', |
|
| 257 | + 'SELECT COUNT(*) FROM '.prefixTable('background_subtasks').' WHERE task_id = %i AND is_in_progress = 0', |
|
| 258 | 258 | $this->taskId |
| 259 | 259 | ); |
| 260 | 260 | |
@@ -270,7 +270,7 @@ discard block |
||
| 270 | 270 | error_log("Usage: php background_tasks___worker.php <task_id> <process_type> [<task_data>]"); |
| 271 | 271 | exit(1); |
| 272 | 272 | } |
| 273 | -$taskId = (int)$argv[1]; |
|
| 273 | +$taskId = (int) $argv[1]; |
|
| 274 | 274 | $processType = $argv[2]; |
| 275 | 275 | $taskData = $argv[3] ?? null; |
| 276 | 276 | if ($taskData) { |
@@ -64,7 +64,9 @@ discard block |
||
| 64 | 64 | */ |
| 65 | 65 | public function execute() { |
| 66 | 66 | try { |
| 67 | - if (LOG_TASKS=== true) $this->logger->log('Processing task: ' . print_r($this->taskData, true), 'DEBUG'); |
|
| 67 | + if (LOG_TASKS=== true) { |
|
| 68 | + $this->logger->log('Processing task: ' . print_r($this->taskData, true), 'DEBUG'); |
|
| 69 | + } |
|
| 68 | 70 | // Dispatch selon le type de processus |
| 69 | 71 | switch ($this->processType) { |
| 70 | 72 | case 'item_copy': |
@@ -136,7 +138,9 @@ discard block |
||
| 136 | 138 | $arguments = ''; |
| 137 | 139 | } |
| 138 | 140 | |
| 139 | - if (LOG_TASKS=== true) $this->logger->log('Process: '.$this->processType.' -- '.print_r($arguments, true), 'DEBUG'); |
|
| 141 | + if (LOG_TASKS=== true) { |
|
| 142 | + $this->logger->log('Process: '.$this->processType.' -- '.print_r($arguments, true), 'DEBUG'); |
|
| 143 | + } |
|
| 140 | 144 | |
| 141 | 145 | // Add 'arguments' only if not empty |
| 142 | 146 | if (!empty($arguments)) { |
@@ -150,7 +154,9 @@ discard block |
||
| 150 | 154 | 'increment_id = %i', |
| 151 | 155 | $this->taskId |
| 152 | 156 | ); |
| 153 | - if (LOG_TASKS=== true) $this->logger->log('Finishing task: ' . $this->taskId, 'DEBUG'); |
|
| 157 | + if (LOG_TASKS=== true) { |
|
| 158 | + $this->logger->log('Finishing task: ' . $this->taskId, 'DEBUG'); |
|
| 159 | + } |
|
| 154 | 160 | } |
| 155 | 161 | |
| 156 | 162 | /** |
@@ -185,7 +191,9 @@ discard block |
||
| 185 | 191 | * @return void |
| 186 | 192 | */ |
| 187 | 193 | private function processSubTasks($arguments) { |
| 188 | - if (LOG_TASKS=== true) $this->logger->log('processSubTasks: '.print_r($arguments, true), 'DEBUG'); |
|
| 194 | + if (LOG_TASKS=== true) { |
|
| 195 | + $this->logger->log('processSubTasks: '.print_r($arguments, true), 'DEBUG'); |
|
| 196 | + } |
|
| 189 | 197 | // Get all subtasks related to this task |
| 190 | 198 | $subtasks = DB::query( |
| 191 | 199 | 'SELECT * FROM ' . prefixTable('background_subtasks') . ' WHERE task_id = %i AND is_in_progress = 0 ORDER BY `task` ASC', |
@@ -194,7 +202,9 @@ discard block |
||
| 194 | 202 | |
| 195 | 203 | // Check if there are any subtasks to process |
| 196 | 204 | if (empty($subtasks)) { |
| 197 | - if (LOG_TASKS=== true) $this->logger->log('No subtask was found for task: ' . $this->taskId, 'DEBUG'); |
|
| 205 | + if (LOG_TASKS=== true) { |
|
| 206 | + $this->logger->log('No subtask was found for task: ' . $this->taskId, 'DEBUG'); |
|
| 207 | + } |
|
| 198 | 208 | return; |
| 199 | 209 | } |
| 200 | 210 | |
@@ -204,7 +214,9 @@ discard block |
||
| 204 | 214 | // Get the subtask data |
| 205 | 215 | $subtaskData = json_decode($subtask['task'], true); |
| 206 | 216 | |
| 207 | - if (LOG_TASKS=== true) $this->logger->log('Processing subtask: ' . $subtaskData['step'], 'DEBUG'); |
|
| 217 | + if (LOG_TASKS=== true) { |
|
| 218 | + $this->logger->log('Processing subtask: ' . $subtaskData['step'], 'DEBUG'); |
|
| 219 | + } |
|
| 208 | 220 | |
| 209 | 221 | // Process the subtask based on its type |
| 210 | 222 | switch ($subtaskData['step'] ?? '') { |
@@ -30,7 +30,7 @@ discard block |
||
| 30 | 30 | use TeampassClasses\ConfigManager\ConfigManager; |
| 31 | 31 | |
| 32 | 32 | require_once __DIR__.'/../sources/main.functions.php'; |
| 33 | -require_once __DIR__ . '/taskLogger.php'; |
|
| 33 | +require_once __DIR__.'/taskLogger.php'; |
|
| 34 | 34 | |
| 35 | 35 | class BackgroundTasksHandler { |
| 36 | 36 | private $settings; |
@@ -55,7 +55,7 @@ discard block |
||
| 55 | 55 | public function processBackgroundTasks() { |
| 56 | 56 | // Prevent multiple concurrent executions |
| 57 | 57 | if (!$this->acquireProcessLock()) { |
| 58 | - if (LOG_TASKS=== true) $this->logger->log('Process already running', 'INFO'); |
|
| 58 | + if (LOG_TASKS === true) $this->logger->log('Process already running', 'INFO'); |
|
| 59 | 59 | return false; |
| 60 | 60 | } |
| 61 | 61 | |
@@ -64,7 +64,7 @@ discard block |
||
| 64 | 64 | $this->processTaskBatches(); |
| 65 | 65 | $this->performMaintenanceTasks(); |
| 66 | 66 | } catch (Exception $e) { |
| 67 | - if (LOG_TASKS=== true) $this->logger->log('Task processing error: ' . $e->getMessage(), 'ERROR'); |
|
| 67 | + if (LOG_TASKS === true) $this->logger->log('Task processing error: '.$e->getMessage(), 'ERROR'); |
|
| 68 | 68 | } finally { |
| 69 | 69 | $this->releaseProcessLock(); |
| 70 | 70 | } |
@@ -83,7 +83,7 @@ discard block |
||
| 83 | 83 | return false; |
| 84 | 84 | } |
| 85 | 85 | |
| 86 | - fwrite($fp, (string)getmypid()); |
|
| 86 | + fwrite($fp, (string) getmypid()); |
|
| 87 | 87 | return true; |
| 88 | 88 | } |
| 89 | 89 | |
@@ -101,7 +101,7 @@ discard block |
||
| 101 | 101 | private function cleanupStaleTasks() { |
| 102 | 102 | // Mark tasks as failed if they've been running too long |
| 103 | 103 | DB::query( |
| 104 | - 'UPDATE ' . prefixTable('background_tasks') . ' |
|
| 104 | + 'UPDATE '.prefixTable('background_tasks').' |
|
| 105 | 105 | SET is_in_progress = -1, |
| 106 | 106 | finished_at = %i, |
| 107 | 107 | status = "failed" |
@@ -113,8 +113,8 @@ discard block |
||
| 113 | 113 | |
| 114 | 114 | // Remove very old failed tasks |
| 115 | 115 | DB::query( |
| 116 | - 'DELETE t, st FROM ' . prefixTable('background_tasks') . ' t |
|
| 117 | - INNER JOIN ' . prefixTable('background_subtasks') . ' st ON (t.increment_id = st.task_id) |
|
| 116 | + 'DELETE t, st FROM '.prefixTable('background_tasks').' t |
|
| 117 | + INNER JOIN ' . prefixTable('background_subtasks').' st ON (t.increment_id = st.task_id) |
|
| 118 | 118 | WHERE t.finished_at > %i |
| 119 | 119 | AND t.status = %s', |
| 120 | 120 | time() - $this->maxTimeBeforeRemoval, |
@@ -131,7 +131,7 @@ discard block |
||
| 131 | 131 | |
| 132 | 132 | // Check if the maximum number of parallel tasks is reached |
| 133 | 133 | if ($runningTasks >= $this->maxParallelTasks) { |
| 134 | - if (LOG_TASKS=== true) $this->logger->log('Wait ... '.$runningTasks.' out of '.$this->maxParallelTasks.' are already running ', 'INFO'); |
|
| 134 | + if (LOG_TASKS === true) $this->logger->log('Wait ... '.$runningTasks.' out of '.$this->maxParallelTasks.' are already running ', 'INFO'); |
|
| 135 | 135 | return; |
| 136 | 136 | } |
| 137 | 137 | |
@@ -140,7 +140,7 @@ discard block |
||
| 140 | 140 | // Fetch next batch of tasks |
| 141 | 141 | $tasks = DB::query( |
| 142 | 142 | 'SELECT increment_id, process_type, arguments |
| 143 | - FROM ' . prefixTable('background_tasks') . ' |
|
| 143 | + FROM ' . prefixTable('background_tasks').' |
|
| 144 | 144 | WHERE is_in_progress = 0 |
| 145 | 145 | AND (finished_at IS NULL OR finished_at = "") |
| 146 | 146 | ORDER BY increment_id ASC |
@@ -149,7 +149,7 @@ discard block |
||
| 149 | 149 | ); |
| 150 | 150 | |
| 151 | 151 | foreach ($tasks as $task) { |
| 152 | - if (LOG_TASKS=== true) $this->logger->log('Launching '.$task['increment_id'], 'INFO'); |
|
| 152 | + if (LOG_TASKS === true) $this->logger->log('Launching '.$task['increment_id'], 'INFO'); |
|
| 153 | 153 | $this->processIndividualTask($task); |
| 154 | 154 | } |
| 155 | 155 | } |
@@ -160,7 +160,7 @@ discard block |
||
| 160 | 160 | * @param array $task The task to process. |
| 161 | 161 | */ |
| 162 | 162 | private function processIndividualTask(array $task) { |
| 163 | - if (LOG_TASKS=== true) $this->logger->log('Starting task: ' . print_r($task, true), 'INFO'); |
|
| 163 | + if (LOG_TASKS === true) $this->logger->log('Starting task: '.print_r($task, true), 'INFO'); |
|
| 164 | 164 | |
| 165 | 165 | // Store progress in the database |
| 166 | 166 | DB::update( |
@@ -177,18 +177,18 @@ discard block |
||
| 177 | 177 | // Prepare process |
| 178 | 178 | $process = new Process([ |
| 179 | 179 | PHP_BINARY, |
| 180 | - __DIR__ . '/background_tasks___worker.php', |
|
| 180 | + __DIR__.'/background_tasks___worker.php', |
|
| 181 | 181 | $task['increment_id'], |
| 182 | 182 | $task['process_type'], |
| 183 | 183 | $task['arguments'] |
| 184 | 184 | ]); |
| 185 | 185 | |
| 186 | 186 | // Launch process |
| 187 | - try{ |
|
| 187 | + try { |
|
| 188 | 188 | $process->mustRun(); |
| 189 | 189 | |
| 190 | 190 | } catch (Exception $e) { |
| 191 | - if (LOG_TASKS=== true) $this->logger->log('Error launching task: ' . $e->getMessage(), 'ERROR'); |
|
| 191 | + if (LOG_TASKS === true) $this->logger->log('Error launching task: '.$e->getMessage(), 'ERROR'); |
|
| 192 | 192 | DB::update( |
| 193 | 193 | prefixTable('background_tasks'), |
| 194 | 194 | [ |
@@ -209,7 +209,7 @@ discard block |
||
| 209 | 209 | private function countRunningTasks(): int { |
| 210 | 210 | return DB::queryFirstField( |
| 211 | 211 | 'SELECT COUNT(*) |
| 212 | - FROM ' . prefixTable('background_tasks') . ' |
|
| 212 | + FROM ' . prefixTable('background_tasks').' |
|
| 213 | 213 | WHERE is_in_progress = 1' |
| 214 | 214 | ); |
| 215 | 215 | } |
@@ -230,10 +230,10 @@ discard block |
||
| 230 | 230 | */ |
| 231 | 231 | private function cleanMultipleItemsEdition() { |
| 232 | 232 | DB::query( |
| 233 | - 'DELETE i1 FROM ' . prefixTable('items_edition') . ' i1 |
|
| 233 | + 'DELETE i1 FROM '.prefixTable('items_edition').' i1 |
|
| 234 | 234 | JOIN ( |
| 235 | 235 | SELECT user_id, item_id, MIN(timestamp) AS oldest_timestamp |
| 236 | - FROM ' . prefixTable('items_edition') . ' |
|
| 236 | + FROM ' . prefixTable('items_edition').' |
|
| 237 | 237 | GROUP BY user_id, item_id |
| 238 | 238 | ) i2 ON i1.user_id = i2.user_id AND i1.item_id = i2.item_id |
| 239 | 239 | WHERE i1.timestamp > i2.oldest_timestamp' |
@@ -246,7 +246,7 @@ discard block |
||
| 246 | 246 | */ |
| 247 | 247 | private function handleItemTokensExpiration() { |
| 248 | 248 | DB::query( |
| 249 | - 'DELETE FROM ' . prefixTable('items_edition') . ' |
|
| 249 | + 'DELETE FROM '.prefixTable('items_edition').' |
|
| 250 | 250 | WHERE timestamp < %i', |
| 251 | 251 | time() - ($this->settings['delay_item_edition'] * 60 ?: EDITION_LOCK_PERIOD) |
| 252 | 252 | ); |
@@ -263,7 +263,7 @@ discard block |
||
| 263 | 263 | // 1. Get all finished tasks older than the cutoff timestamp |
| 264 | 264 | // and that are not in progress |
| 265 | 265 | $tasks = DB::query( |
| 266 | - 'SELECT increment_id FROM ' . prefixTable('background_tasks') . ' |
|
| 266 | + 'SELECT increment_id FROM '.prefixTable('background_tasks').' |
|
| 267 | 267 | WHERE status = %s AND is_in_progress = %i AND finished_at < %s', |
| 268 | 268 | 'completed', |
| 269 | 269 | -1, |
@@ -278,19 +278,19 @@ discard block |
||
| 278 | 278 | |
| 279 | 279 | // 2. Delete all subtasks related to these tasks |
| 280 | 280 | DB::query( |
| 281 | - 'DELETE FROM ' . prefixTable('background_subtasks') . ' |
|
| 281 | + 'DELETE FROM '.prefixTable('background_subtasks').' |
|
| 282 | 282 | WHERE task_id IN %ls', |
| 283 | 283 | $taskIds |
| 284 | 284 | ); |
| 285 | 285 | |
| 286 | 286 | // 3. Delete the tasks themselves |
| 287 | 287 | DB::query( |
| 288 | - 'DELETE FROM ' . prefixTable('background_tasks') . ' |
|
| 288 | + 'DELETE FROM '.prefixTable('background_tasks').' |
|
| 289 | 289 | WHERE increment_id IN %ls', |
| 290 | 290 | $taskIds |
| 291 | 291 | ); |
| 292 | 292 | |
| 293 | - if (LOG_TASKS=== true) $this->logger->log('Old finished tasks cleaned: ' . count($taskIds), 'INFO'); |
|
| 293 | + if (LOG_TASKS === true) $this->logger->log('Old finished tasks cleaned: '.count($taskIds), 'INFO'); |
|
| 294 | 294 | } |
| 295 | 295 | } |
| 296 | 296 | |
@@ -304,5 +304,5 @@ discard block |
||
| 304 | 304 | $tasksHandler = new BackgroundTasksHandler($settings); |
| 305 | 305 | $tasksHandler->processBackgroundTasks(); |
| 306 | 306 | } catch (Exception $e) { |
| 307 | - error_log('Teampass Background Tasks Error: ' . $e->getMessage()); |
|
| 307 | + error_log('Teampass Background Tasks Error: '.$e->getMessage()); |
|
| 308 | 308 | } |
| 309 | 309 | \ No newline at end of file |
@@ -55,7 +55,9 @@ discard block |
||
| 55 | 55 | public function processBackgroundTasks() { |
| 56 | 56 | // Prevent multiple concurrent executions |
| 57 | 57 | if (!$this->acquireProcessLock()) { |
| 58 | - if (LOG_TASKS=== true) $this->logger->log('Process already running', 'INFO'); |
|
| 58 | + if (LOG_TASKS=== true) { |
|
| 59 | + $this->logger->log('Process already running', 'INFO'); |
|
| 60 | + } |
|
| 59 | 61 | return false; |
| 60 | 62 | } |
| 61 | 63 | |
@@ -64,7 +66,9 @@ discard block |
||
| 64 | 66 | $this->processTaskBatches(); |
| 65 | 67 | $this->performMaintenanceTasks(); |
| 66 | 68 | } catch (Exception $e) { |
| 67 | - if (LOG_TASKS=== true) $this->logger->log('Task processing error: ' . $e->getMessage(), 'ERROR'); |
|
| 69 | + if (LOG_TASKS=== true) { |
|
| 70 | + $this->logger->log('Task processing error: ' . $e->getMessage(), 'ERROR'); |
|
| 71 | + } |
|
| 68 | 72 | } finally { |
| 69 | 73 | $this->releaseProcessLock(); |
| 70 | 74 | } |
@@ -131,7 +135,9 @@ discard block |
||
| 131 | 135 | |
| 132 | 136 | // Check if the maximum number of parallel tasks is reached |
| 133 | 137 | if ($runningTasks >= $this->maxParallelTasks) { |
| 134 | - if (LOG_TASKS=== true) $this->logger->log('Wait ... '.$runningTasks.' out of '.$this->maxParallelTasks.' are already running ', 'INFO'); |
|
| 138 | + if (LOG_TASKS=== true) { |
|
| 139 | + $this->logger->log('Wait ... '.$runningTasks.' out of '.$this->maxParallelTasks.' are already running ', 'INFO'); |
|
| 140 | + } |
|
| 135 | 141 | return; |
| 136 | 142 | } |
| 137 | 143 | |
@@ -149,7 +155,9 @@ discard block |
||
| 149 | 155 | ); |
| 150 | 156 | |
| 151 | 157 | foreach ($tasks as $task) { |
| 152 | - if (LOG_TASKS=== true) $this->logger->log('Launching '.$task['increment_id'], 'INFO'); |
|
| 158 | + if (LOG_TASKS=== true) { |
|
| 159 | + $this->logger->log('Launching '.$task['increment_id'], 'INFO'); |
|
| 160 | + } |
|
| 153 | 161 | $this->processIndividualTask($task); |
| 154 | 162 | } |
| 155 | 163 | } |
@@ -160,7 +168,9 @@ discard block |
||
| 160 | 168 | * @param array $task The task to process. |
| 161 | 169 | */ |
| 162 | 170 | private function processIndividualTask(array $task) { |
| 163 | - if (LOG_TASKS=== true) $this->logger->log('Starting task: ' . print_r($task, true), 'INFO'); |
|
| 171 | + if (LOG_TASKS=== true) { |
|
| 172 | + $this->logger->log('Starting task: ' . print_r($task, true), 'INFO'); |
|
| 173 | + } |
|
| 164 | 174 | |
| 165 | 175 | // Store progress in the database |
| 166 | 176 | DB::update( |
@@ -188,7 +198,9 @@ discard block |
||
| 188 | 198 | $process->mustRun(); |
| 189 | 199 | |
| 190 | 200 | } catch (Exception $e) { |
| 191 | - if (LOG_TASKS=== true) $this->logger->log('Error launching task: ' . $e->getMessage(), 'ERROR'); |
|
| 201 | + if (LOG_TASKS=== true) { |
|
| 202 | + $this->logger->log('Error launching task: ' . $e->getMessage(), 'ERROR'); |
|
| 203 | + } |
|
| 192 | 204 | DB::update( |
| 193 | 205 | prefixTable('background_tasks'), |
| 194 | 206 | [ |
@@ -290,7 +302,9 @@ discard block |
||
| 290 | 302 | $taskIds |
| 291 | 303 | ); |
| 292 | 304 | |
| 293 | - if (LOG_TASKS=== true) $this->logger->log('Old finished tasks cleaned: ' . count($taskIds), 'INFO'); |
|
| 305 | + if (LOG_TASKS=== true) { |
|
| 306 | + $this->logger->log('Old finished tasks cleaned: ' . count($taskIds), 'INFO'); |
|
| 307 | + } |
|
| 294 | 308 | } |
| 295 | 309 | } |
| 296 | 310 | |
@@ -69,7 +69,7 @@ discard block |
||
| 69 | 69 | if ($checkUserAccess->checkSession() === false || $checkUserAccess->userAccessPage('options') === 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 | |
@@ -322,7 +322,7 @@ discard block |
||
| 322 | 322 | // get list of all timezones |
| 323 | 323 | foreach ($zones as $key => $zone) { |
| 324 | 324 | echo ' |
| 325 | - <option value="' . $key . '"', isset($SETTINGS['timezone']) === true && $SETTINGS['timezone'] === $key ? ' selected' : '', '>' . $zone . '</option>'; |
|
| 325 | + <option value="' . $key.'"', isset($SETTINGS['timezone']) === true && $SETTINGS['timezone'] === $key ? ' selected' : '', '>'.$zone.'</option>'; |
|
| 326 | 326 | } |
| 327 | 327 | ?> |
| 328 | 328 | </select> |
@@ -374,7 +374,7 @@ discard block |
||
| 374 | 374 | $languagesList = $languagesList ?? []; |
| 375 | 375 | foreach ($languagesList as $teampassLang) { |
| 376 | 376 | echo ' |
| 377 | - <option value="' . $teampassLang . '"', isset($SETTINGS['default_language']) === true && $SETTINGS['default_language'] === $teampassLang ? ' selected' : '', '>' . $teampassLang . '</option>'; |
|
| 377 | + <option value="' . $teampassLang.'"', isset($SETTINGS['default_language']) === true && $SETTINGS['default_language'] === $teampassLang ? ' selected' : '', '>'.$teampassLang.'</option>'; |
|
| 378 | 378 | } |
| 379 | 379 | ?> |
| 380 | 380 | </select> |
@@ -471,7 +471,7 @@ discard block |
||
| 471 | 471 | <?php |
| 472 | 472 | foreach (TP_PW_COMPLEXITY as $complex) { |
| 473 | 473 | echo ' |
| 474 | - <option value="' . $complex[0] . '"', isset($SETTINGS['personal_saltkey_security_level']) === true && $SETTINGS['personal_saltkey_security_level'] === $complex[0] ? ' selected' : '', '>' . $complex[1] . '</option>'; |
|
| 474 | + <option value="' . $complex[0].'"', isset($SETTINGS['personal_saltkey_security_level']) === true && $SETTINGS['personal_saltkey_security_level'] === $complex[0] ? ' selected' : '', '>'.$complex[1].'</option>'; |
|
| 475 | 475 | } |
| 476 | 476 | ?> |
| 477 | 477 | </select> |
@@ -848,7 +848,7 @@ discard block |
||
| 848 | 848 | $roles = getRolesTitles(); |
| 849 | 849 | foreach ($roles as $role) { |
| 850 | 850 | echo ' |
| 851 | - <option value="' . htmlspecialchars($role['id']) . '"', in_array($role['id'], $arrRolesToPrint) === true ? ' selected' : '', '>' . htmlspecialchars(addslashes($role['title'])) . '</option>'; |
|
| 851 | + <option value="' . htmlspecialchars($role['id']).'"', in_array($role['id'], $arrRolesToPrint) === true ? ' selected' : '', '>'.htmlspecialchars(addslashes($role['title'])).'</option>'; |
|
| 852 | 852 | } |
| 853 | 853 | } |
| 854 | 854 | ?> |
@@ -1075,7 +1075,7 @@ discard block |
||
| 1075 | 1075 | <?php |
| 1076 | 1076 | foreach (TP_PW_COMPLEXITY as $complex) { |
| 1077 | 1077 | echo ' |
| 1078 | - <option value="' . $complex[0] . '"', isset($SETTINGS['offline_key_level']) === true && $SETTINGS['offline_key_level'] === $complex[0] ? ' selected' : '', '>' . $complex[1] . '</option>'; |
|
| 1078 | + <option value="' . $complex[0].'"', isset($SETTINGS['offline_key_level']) === true && $SETTINGS['offline_key_level'] === $complex[0] ? ' selected' : '', '>'.$complex[1].'</option>'; |
|
| 1079 | 1079 | } |
| 1080 | 1080 | ?> |
| 1081 | 1081 | </select> |
@@ -72,7 +72,7 @@ discard block |
||
| 72 | 72 | || (isset($session_user_admin) && (int) $session_user_admin === 1)) { |
| 73 | 73 | // Not allowed page |
| 74 | 74 | $session->set('system-error_code', ERR_NOT_ALLOWED); |
| 75 | - include $SETTINGS['cpassman_dir'] . '/error.php'; |
|
| 75 | + include $SETTINGS['cpassman_dir'].'/error.php'; |
|
| 76 | 76 | exit; |
| 77 | 77 | } |
| 78 | 78 | |
@@ -125,12 +125,12 @@ discard block |
||
| 125 | 125 | if (empty($fav) === false) { |
| 126 | 126 | $data = DB::queryFirstRow( |
| 127 | 127 | 'SELECT i.label, i.description, i.id, i.id_tree, t.title |
| 128 | - FROM ' . prefixTable('items') . ' as i |
|
| 129 | - INNER JOIN ' . prefixTable('nested_tree') . ' as t ON (t.id = i.id_tree) |
|
| 128 | + FROM ' . prefixTable('items').' as i |
|
| 129 | + INNER JOIN ' . prefixTable('nested_tree').' as t ON (t.id = i.id_tree) |
|
| 130 | 130 | WHERE i.id = %i', |
| 131 | 131 | $fav |
| 132 | 132 | ); |
| 133 | - if (! empty($data['label'])) { |
|
| 133 | + if (!empty($data['label'])) { |
|
| 134 | 134 | ?> |
| 135 | 135 | <tr> |
| 136 | 136 | <td> |
@@ -33,7 +33,7 @@ |
||
| 33 | 33 | use TeampassClasses\SessionManager\SessionManager; |
| 34 | 34 | use TeampassClasses\ConfigManager\ConfigManager; |
| 35 | 35 | |
| 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 |
@@ -74,7 +74,7 @@ discard block |
||
| 74 | 74 | ) { |
| 75 | 75 | // Not allowed page |
| 76 | 76 | $session->set('system-error_code', ERR_NOT_ALLOWED); |
| 77 | - include $SETTINGS['cpassman_dir'] . '/error.php'; |
|
| 77 | + include $SETTINGS['cpassman_dir'].'/error.php'; |
|
| 78 | 78 | exit; |
| 79 | 79 | } |
| 80 | 80 | |
@@ -107,7 +107,7 @@ discard block |
||
| 107 | 107 | $post_isNewItem = $request->request->filter('isNewItem', null, FILTER_SANITIZE_NUMBER_INT); |
| 108 | 108 | $post_randomId = $request->request->filter('randomId', null, FILTER_SANITIZE_NUMBER_INT); |
| 109 | 109 | $post_isPersonal = $request->request->filter('isPersonal', null, FILTER_SANITIZE_NUMBER_INT); |
| 110 | -$post_fileSize= $request->request->filter('file_size', null, FILTER_SANITIZE_NUMBER_INT); |
|
| 110 | +$post_fileSize = $request->request->filter('file_size', null, FILTER_SANITIZE_NUMBER_INT); |
|
| 111 | 111 | $chunk = $request->request->filter('chunk', 0, FILTER_SANITIZE_NUMBER_INT); |
| 112 | 112 | $chunks = $request->request->filter('chunks', 0, FILTER_SANITIZE_NUMBER_INT); |
| 113 | 113 | $fileName = $request->request->filter('name', '', FILTER_SANITIZE_FULL_SPECIAL_CHARS); |
@@ -122,10 +122,10 @@ discard block |
||
| 122 | 122 | $unit = strtoupper(substr(trim($POST_MAX_SIZE), -1)); // Assurez-vous de bien gérer les espaces éventuels |
| 123 | 123 | $units = ['G' => 1073741824, 'M' => 1048576, 'K' => 1024]; |
| 124 | 124 | $multiplier = $units[$unit] ?? 1; // Vérifie si l'unité est dans le tableau, sinon 1 |
| 125 | - $maxSize = (int)$POST_MAX_SIZE * $multiplier; |
|
| 125 | + $maxSize = (int) $POST_MAX_SIZE * $multiplier; |
|
| 126 | 126 | |
| 127 | 127 | // CHeck if the POST is too big |
| 128 | - if (!empty($_SERVER['CONTENT_LENGTH']) && (int)$_SERVER['CONTENT_LENGTH'] > $maxSize && $maxSize > 0) { |
|
| 128 | + if (!empty($_SERVER['CONTENT_LENGTH']) && (int) $_SERVER['CONTENT_LENGTH'] > $maxSize && $maxSize > 0) { |
|
| 129 | 129 | handleAttachmentError('POST exceeded maximum allowed size.', 111, 413); |
| 130 | 130 | } |
| 131 | 131 | |
@@ -134,7 +134,7 @@ discard block |
||
| 134 | 134 | handleAttachmentError('File exceeds the maximum allowed size', 120, 413); |
| 135 | 135 | die(); |
| 136 | 136 | } |
| 137 | - if (WIP === true) error_log('POST_MAX_SIZE: ' . $POST_MAX_SIZE." - CONTENT_LENGTH: ".$_SERVER['CONTENT_LENGTH']." - UNIT: ".$unit." - MAX: ".$maxSize." - MULTIPLIER: ".$multiplier." - FILE_SIZE: ".$post_fileSize); |
|
| 137 | + if (WIP === true) error_log('POST_MAX_SIZE: '.$POST_MAX_SIZE." - CONTENT_LENGTH: ".$_SERVER['CONTENT_LENGTH']." - UNIT: ".$unit." - MAX: ".$maxSize." - MULTIPLIER: ".$multiplier." - FILE_SIZE: ".$post_fileSize); |
|
| 138 | 138 | |
| 139 | 139 | // delete expired tokens |
| 140 | 140 | DB::delete(prefixTable('tokens'), 'end_timestamp < %i', time()); |
@@ -185,7 +185,7 @@ discard block |
||
| 185 | 185 | // check if token is expired |
| 186 | 186 | $data = DB::queryFirstRow( |
| 187 | 187 | 'SELECT end_timestamp |
| 188 | - FROM ' . prefixTable('tokens') . ' |
|
| 188 | + FROM ' . prefixTable('tokens').' |
|
| 189 | 189 | WHERE user_id = %i AND token = %s', |
| 190 | 190 | $session->get('user-id'), |
| 191 | 191 | $post_user_token |
@@ -218,7 +218,7 @@ discard block |
||
| 218 | 218 | |
| 219 | 219 | // HTTP headers for no cache etc |
| 220 | 220 | header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); |
| 221 | -header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); |
|
| 221 | +header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT'); |
|
| 222 | 222 | header('Cache-Control: no-store, no-cache, must-revalidate'); |
| 223 | 223 | header('Cache-Control: post-check=0, pre-check=0', false); |
| 224 | 224 | |
@@ -256,7 +256,7 @@ discard block |
||
| 256 | 256 | // Validate file name (for our purposes we'll just remove invalid characters) |
| 257 | 257 | $file_name = preg_replace('[^A-Za-z0-9]', '', strtolower(basename($_FILES['file']['name']))); |
| 258 | 258 | if (strlen($file_name) == 0 || strlen($file_name) > $MAX_FILENAME_LENGTH) { |
| 259 | - handleAttachmentError('Invalid file name: ' . $file_name . '.', 114); |
|
| 259 | + handleAttachmentError('Invalid file name: '.$file_name.'.', 114); |
|
| 260 | 260 | } |
| 261 | 261 | |
| 262 | 262 | // Validate file extension |
@@ -266,8 +266,8 @@ discard block |
||
| 266 | 266 | $ext, |
| 267 | 267 | explode( |
| 268 | 268 | ',', |
| 269 | - $SETTINGS['upload_docext'] . ',' . $SETTINGS['upload_imagesext'] . |
|
| 270 | - ',' . $SETTINGS['upload_pkgext'] . ',' . $SETTINGS['upload_otherext'] |
|
| 269 | + $SETTINGS['upload_docext'].','.$SETTINGS['upload_imagesext']. |
|
| 270 | + ','.$SETTINGS['upload_pkgext'].','.$SETTINGS['upload_otherext'] |
|
| 271 | 271 | ) |
| 272 | 272 | ) === false |
| 273 | 273 | ) { |
@@ -279,24 +279,24 @@ discard block |
||
| 279 | 279 | |
| 280 | 280 | // Clean the fileName for security reasons |
| 281 | 281 | $fileInfo = pathinfo($fileName); |
| 282 | -$fileName = base64_encode($fileInfo['filename']) . '.' . $fileInfo['extension']; |
|
| 282 | +$fileName = base64_encode($fileInfo['filename']).'.'.$fileInfo['extension']; |
|
| 283 | 283 | $fileFullSize = 0; |
| 284 | 284 | |
| 285 | 285 | // Make sure the fileName is unique but only if chunking is disabled |
| 286 | -if ($chunks < 2 && file_exists($targetDir . DIRECTORY_SEPARATOR . $fileName)) { |
|
| 286 | +if ($chunks < 2 && file_exists($targetDir.DIRECTORY_SEPARATOR.$fileName)) { |
|
| 287 | 287 | $ext = strrpos($fileName, '.'); |
| 288 | 288 | $fileNameA = substr($fileName, 0, $ext); |
| 289 | 289 | $fileNameB = substr($fileName, $ext); |
| 290 | 290 | |
| 291 | 291 | $count = 1; |
| 292 | - while (file_exists($targetDir . DIRECTORY_SEPARATOR . $fileNameA . '_' . $count . $fileNameB)) { |
|
| 292 | + while (file_exists($targetDir.DIRECTORY_SEPARATOR.$fileNameA.'_'.$count.$fileNameB)) { |
|
| 293 | 293 | ++$count; |
| 294 | 294 | } |
| 295 | 295 | |
| 296 | - $fileName = $fileNameA . '_' . $count . $fileNameB; |
|
| 296 | + $fileName = $fileNameA.'_'.$count.$fileNameB; |
|
| 297 | 297 | } |
| 298 | 298 | |
| 299 | -$filePath = $targetDir . DIRECTORY_SEPARATOR . $fileName; |
|
| 299 | +$filePath = $targetDir.DIRECTORY_SEPARATOR.$fileName; |
|
| 300 | 300 | |
| 301 | 301 | // Create target dir |
| 302 | 302 | if (file_exists($targetDir) === false) { |
@@ -310,7 +310,7 @@ discard block |
||
| 310 | 310 | // Remove old temp files |
| 311 | 311 | if ($cleanupTargetDir && is_dir($targetDir) && ($dir = opendir($targetDir))) { |
| 312 | 312 | while (($file = readdir($dir)) !== false) { |
| 313 | - $tmpfilePath = $targetDir . DIRECTORY_SEPARATOR . $file; |
|
| 313 | + $tmpfilePath = $targetDir.DIRECTORY_SEPARATOR.$file; |
|
| 314 | 314 | |
| 315 | 315 | // Remove temp file if it is older than the max age and is not the current file |
| 316 | 316 | if ( |
@@ -429,8 +429,8 @@ discard block |
||
| 429 | 429 | // This is a public object |
| 430 | 430 | $users = DB::query( |
| 431 | 431 | 'SELECT id, public_key |
| 432 | - FROM ' . prefixTable('users') . ' |
|
| 433 | - WHERE id NOT IN ("' . OTV_USER_ID . '","' . SSH_USER_ID . '","' . API_USER_ID . '") |
|
| 432 | + FROM ' . prefixTable('users').' |
|
| 433 | + WHERE id NOT IN ("' . OTV_USER_ID.'","'.SSH_USER_ID.'","'.API_USER_ID.'") |
|
| 434 | 434 | AND public_key != ""' |
| 435 | 435 | ); |
| 436 | 436 | foreach ($users as $user) { |
@@ -464,14 +464,14 @@ discard block |
||
| 464 | 464 | 'date' => time(), |
| 465 | 465 | 'id_user' => $session->get('user-id'), |
| 466 | 466 | 'action' => 'at_modification', |
| 467 | - 'raison' => 'at_add_file : ' . $fileName . ':' . $newID, |
|
| 467 | + 'raison' => 'at_add_file : '.$fileName.':'.$newID, |
|
| 468 | 468 | ) |
| 469 | 469 | ); |
| 470 | 470 | } |
| 471 | 471 | } |
| 472 | 472 | |
| 473 | 473 | // Return JSON-RPC response |
| 474 | -die('{"jsonrpc" : "2.0", "result" : null, "id" : "' . $newID . '"}'); |
|
| 474 | +die('{"jsonrpc" : "2.0", "result" : null, "id" : "'.$newID.'"}'); |
|
| 475 | 475 | |
| 476 | 476 | /** |
| 477 | 477 | * Handle errors and kill script. |
@@ -134,7 +134,9 @@ |
||
| 134 | 134 | handleAttachmentError('File exceeds the maximum allowed size', 120, 413); |
| 135 | 135 | die(); |
| 136 | 136 | } |
| 137 | - if (WIP === true) error_log('POST_MAX_SIZE: ' . $POST_MAX_SIZE." - CONTENT_LENGTH: ".$_SERVER['CONTENT_LENGTH']." - UNIT: ".$unit." - MAX: ".$maxSize." - MULTIPLIER: ".$multiplier." - FILE_SIZE: ".$post_fileSize); |
|
| 137 | + if (WIP === true) { |
|
| 138 | + error_log('POST_MAX_SIZE: ' . $POST_MAX_SIZE." - CONTENT_LENGTH: ".$_SERVER['CONTENT_LENGTH']." - UNIT: ".$unit." - MAX: ".$maxSize." - MULTIPLIER: ".$multiplier." - FILE_SIZE: ".$post_fileSize); |
|
| 139 | + } |
|
| 138 | 140 | |
| 139 | 141 | // delete expired tokens |
| 140 | 142 | DB::delete(prefixTable('tokens'), 'end_timestamp < %i', time()); |
@@ -76,7 +76,7 @@ discard block |
||
| 76 | 76 | ) { |
| 77 | 77 | // Not allowed page |
| 78 | 78 | $session->set('system-error_code', ERR_NOT_ALLOWED); |
| 79 | - include $SETTINGS['cpassman_dir'] . '/error.php'; |
|
| 79 | + include $SETTINGS['cpassman_dir'].'/error.php'; |
|
| 80 | 80 | exit; |
| 81 | 81 | } |
| 82 | 82 | |
@@ -461,7 +461,7 @@ discard block |
||
| 461 | 461 | ); |
| 462 | 462 | |
| 463 | 463 | // add new role to user |
| 464 | - $tmp = $data_tmp['fonction_id'] . (substr($data_tmp['fonction_id'], -1) == ';' ? $role_id : ';' . $role_id); |
|
| 464 | + $tmp = $data_tmp['fonction_id'].(substr($data_tmp['fonction_id'], -1) == ';' ? $role_id : ';'.$role_id); |
|
| 465 | 465 | $session->set('user-roles', str_replace(';;', ';', $tmp)); |
| 466 | 466 | |
| 467 | 467 | // store in DB |
@@ -649,7 +649,7 @@ discard block |
||
| 649 | 649 | $groupsData = $openLdapExtra->getADGroups($ldapConnection, $SETTINGS); |
| 650 | 650 | break; |
| 651 | 651 | default: |
| 652 | - throw new Exception("Unsupported LDAP type: " . $SETTINGS['ldap_type']); |
|
| 652 | + throw new Exception("Unsupported LDAP type: ".$SETTINGS['ldap_type']); |
|
| 653 | 653 | } |
| 654 | 654 | } catch (Exception $e) { |
| 655 | 655 | if (defined('LOG_TO_SERVER') && LOG_TO_SERVER === true) { |
@@ -669,7 +669,7 @@ discard block |
||
| 669 | 669 | } else { |
| 670 | 670 | // Handle successful retrieval of groups |
| 671 | 671 | // exists in Teampass |
| 672 | - foreach($groupsData['userGroups'] as $key => $group) { |
|
| 672 | + foreach ($groupsData['userGroups'] as $key => $group) { |
|
| 673 | 673 | $role_detail = DB::queryFirstRow( |
| 674 | 674 | 'SELECT a.increment_id as increment_id, a.role_id as role_id, r.title as title |
| 675 | 675 | FROM '.prefixTable('ldap_groups_roles').' AS a |
@@ -694,7 +694,7 @@ discard block |
||
| 694 | 694 | |
| 695 | 695 | // Get all groups in Teampass |
| 696 | 696 | $teampassRoles = array(); |
| 697 | - $rows = DB::query('SELECT id,title FROM ' . prefixTable('roles_title')); |
|
| 697 | + $rows = DB::query('SELECT id,title FROM '.prefixTable('roles_title')); |
|
| 698 | 698 | foreach ($rows as $record) { |
| 699 | 699 | array_push( |
| 700 | 700 | $teampassRoles, |