Code Duplication    Length = 9-9 lines in 2 locations

post.php 2 locations

@@ 233-241 (lines=9) @@
230
231
    //    $attachments_tmp = array();
232
    //    if (!empty($_POST["attachments_tmp"])) {
233
    if (Request::getString('attachments_tmp', '', 'POST')) {
234
        $attachments_tmp = unserialize(base64_decode(Request::getString('attachments_tmp', '', 'POST')));
235
        if (Request::getArray('delete_tmp', null, 'POST') && count(Request::getArray('delete_tmp', null, 'POST')) > 1) {
236
            foreach (Request::getArray('delete_tmp', null, 'POST') as $key) {
237
                unlink($GLOBALS['xoops']->path($GLOBALS['xoopsModuleConfig']['dir_attachments'] . '/' . $attachments_tmp[$key][0]));
238
                unset($attachments_tmp[$key]);
239
            }
240
        }
241
    }
242
    if (isset($attachments_tmp) && count($attachments_tmp)) {
243
        foreach ($attachments_tmp as $key => $attach) {
244
            if (rename(XOOPS_CACHE_PATH . '/' . $attachments_tmp[$key][0], $GLOBALS['xoops']->path($GLOBALS['xoopsModuleConfig']['dir_attachments'] . '/' . $attachments_tmp[$key][0]))) {
@@ 413-421 (lines=9) @@
410
411
if (Request::getString('contents_upload', null, 'POST')) {
412
    $attachments_tmp = [];
413
    if (Request::getArray('attachments_tmp', null, 'POST')) {
414
        $attachments_tmp = unserialize(base64_decode(Request::getArray('attachments_tmp', [], 'POST')));
415
        if (Request::getArray('delete_tmp', null, 'POST') && count(Request::getArray('delete_tmp', null, 'POST'))) {
416
            foreach (Request::getArray('delete_tmp', '', 'POST') as $key) {
417
                unlink($uploaddir = $GLOBALS['xoops']->path($GLOBALS['xoopsModuleConfig']['dir_attachments'] . '/' . $attachments_tmp[$key][0]));
418
                unset($attachments_tmp[$key]);
419
            }
420
        }
421
    }
422
423
    $error_upload = '';
424
    if (isset($_FILES['userfile']['name']) && '' !== $_FILES['userfile']['name']) {