Code Duplication    Length = 16-17 lines in 2 locations

sources/upload/upload.attachments.php 1 location

@@ 325-340 (lines=16) @@
322
        stream_filter_append($out, 'mcrypt.tripledes', STREAM_FILTER_WRITE, $opts);
323
    }
324
325
    if ($out) {
326
        // Read binary input stream and append it to temp file
327
        $in = fopen("php://input", "rb");
328
329
        if ($in) {
330
            while ($buff = fread($in, 4096)) {
331
                fwrite($out, $buff);
332
            }
333
        } else {
334
            die('{"jsonrpc" : "2.0", "error" : {"code": 101, "message": "Failed to open input stream."}, "id" : "id"}');
335
        }
336
        fclose($in);
337
        fclose($out);
338
    } else {
339
        die('{"jsonrpc" : "2.0", "error" : {"code": 102, "message": "Failed to open output stream."}, "id" : "id"}');
340
    }
341
}
342
343
// Check if file has been uploaded

sources/upload/upload.files.php 1 location

@@ 251-267 (lines=17) @@
248
} else {
249
    // Open temp file
250
    $out = fopen("{$filePath}.part", $chunk == 0 ? "wb" : "ab");
251
    if ($out) {
252
        // Read binary input stream and append it to temp file
253
        $in = fopen("php://input", "rb");
254
255
        if ($in) {
256
            while ($buff = fread($in, 4096)) {
257
                fwrite($out, $buff);
258
            }
259
        } else {
260
            die('{"jsonrpc" : "2.0", "error" : {"code": 101, "message": "Failed to open input stream."}, "id" : "id"}');
261
        }
262
263
        fclose($in);
264
        fclose($out);
265
    } else {
266
        die('{"jsonrpc" : "2.0", "error" : {"code": 102, "message": "Failed to open output stream."}, "id" : "id"}');
267
    }
268
}
269
270
// Check if file has been uploaded