Code Duplication    Length = 11-12 lines in 2 locations

sources/upload/upload.attachments.php 1 location

@@ 204-215 (lines=12) @@
201
$fileName = preg_replace('[^'.$valid_chars_regex.']', '', strtolower(basename($fileName)));
202
203
// Make sure the fileName is unique but only if chunking is disabled
204
if ($chunks < 2 && file_exists($targetDir.DIRECTORY_SEPARATOR.$fileName)) {
205
    $ext = strrpos($fileName, '.');
206
    $fileNameA = substr($fileName, 0, $ext);
207
    $fileNameB = substr($fileName, $ext);
208
209
    $count = 1;
210
    while (file_exists($targetDir.DIRECTORY_SEPARATOR.$fileNameA.'_'.$count.$fileNameB)) {
211
        $count++;
212
    }
213
214
    $fileName = $fileNameA.'_'.$count.$fileNameB;
215
}
216
217
$filePath = $targetDir.DIRECTORY_SEPARATOR.$fileName;
218

sources/upload/upload.files.php 1 location

@@ 164-174 (lines=11) @@
161
$fileName = preg_replace('/[^'.$valid_chars_regex.'\.]/', '', strtolower(basename($fileName)));
162
163
// Make sure the fileName is unique but only if chunking is disabled
164
if ($chunks < 2 && file_exists($targetDir.DIRECTORY_SEPARATOR.$fileName)) {
165
    $fileNameA = substr($fileName, 0, $ext);
166
    $fileNameB = substr($fileName, $ext);
167
168
    $count = 1;
169
    while (file_exists($targetDir.DIRECTORY_SEPARATOR.$fileNameA.'_'.$count.$fileNameB)) {
170
        $count++;
171
    }
172
173
    $fileName = $fileNameA.'_'.$count.$fileNameB;
174
}
175
176
$filePath = $targetDir.DIRECTORY_SEPARATOR.$fileName;
177