Code Duplication    Length = 24-27 lines in 3 locations

join.php 1 location

@@ 30-53 (lines=24) @@
27
28
        if ($_FILES['logo_file']['name'] !== '') {
29
            $filename = $_POST['xoops_upload_file'][0];
30
            if (!empty($filename) || $filename !== '') {
31
                global $xoopsModuleConfig;
32
33
                $max_size          = 10000000;
34
                $max_imgwidth      = $xoopsModuleConfig['img_max_width'];
35
                $max_imgheight     = $xoopsModuleConfig['img_max_height'];
36
                $allowed_mimetypes = smartpartner_getAllowedImagesTypes();
37
38
                include_once(XOOPS_ROOT_PATH . '/class/uploader.php');
39
40
                if ($_FILES[$filename]['tmp_name'] === '' || !is_readable($_FILES[$filename]['tmp_name'])) {
41
                    redirect_header('javascript:history.go(-1)', 2, _CO_SPARTNER_FILE_UPLOAD_ERROR);
42
                    exit;
43
                }
44
45
                $uploader = new XoopsMediaUploader(smartpartner_getImageDir(), $allowed_mimetypes, $max_size, $max_imgwidth, $max_imgheight);
46
47
                if ($uploader->fetchMedia($filename) && $uploader->upload()) {
48
                    $partnerObj->setVar('image', $uploader->getSavedFileName());
49
                } else {
50
                    redirect_header('javascript:history.go(-1)', 2, _CO_SPARTNER_FILE_UPLOAD_ERROR . $uploader->getErrors());
51
                    exit;
52
                }
53
            }
54
        }
55
56
        // Putting the values in the partner object

admin/category.php 1 location

@@ 312-337 (lines=26) @@
309
        // Retreive the filename to be uploaded
310
        if (isset($_FILES['image_file']['name']) && $_FILES['image_file']['name'] != '') {
311
            $filename = $_POST['xoops_upload_file'][0];
312
            if (!empty($filename) || $filename != '') {
313
                global $xoopsModuleConfig;
314
315
                // TODO: implement smartpartner mimetype management
316
317
                $max_size          = $xoopsModuleConfig['maximum_imagesize'];
318
                $max_imgwidth      = $xoopsModuleConfig['img_max_width'];
319
                $max_imgheight     = $xoopsModuleConfig['img_max_height'];
320
                $allowed_mimetypes = smartpartner_getAllowedImagesTypes();
321
322
                include_once(XOOPS_ROOT_PATH . '/class/uploader.php');
323
324
                if ($_FILES[$filename]['tmp_name'] == '' || !is_readable($_FILES[$filename]['tmp_name'])) {
325
                    redirect_header('javascript:history.go(-1)', 2, _AM_SPARTNER_FILEUPLOAD_ERROR);
326
                    exit;
327
                }
328
329
                $uploader = new XoopsMediaUploader(smartpartner_getImageDir('category'), $allowed_mimetypes, $max_size, $max_imgwidth, $max_imgheight);
330
331
                if ($uploader->fetchMedia($filename) && $uploader->upload()) {
332
                    $categoryObj->setVar('image', $uploader->getSavedFileName());
333
                } else {
334
                    redirect_header('javascript:history.go(-1)', 2, _AM_SPARTNER_FILEUPLOAD_ERROR . $uploader->getErrors());
335
                    exit;
336
                }
337
            }
338
        } else {
339
            if (isset($_POST['image'])) {
340
                $categoryObj->setVar('image', $_POST['image']);

admin/partner.php 1 location

@@ 394-420 (lines=27) @@
391
        // Retreive the filename to be uploaded
392
        if ($_FILES['logo_file']['name'] != '') {
393
            $filename = $_POST['xoops_upload_file'][0];
394
            if (!empty($filename) || $filename != '') {
395
                global $xoopsModuleConfig;
396
397
                $max_size          = 10000000;
398
                $max_imgwidth      = $xoopsModuleConfig['img_max_width'];
399
                $max_imgheight     = $xoopsModuleConfig['img_max_height'];
400
                $allowed_mimetypes = null; //smartpartner_getAllowedMimeTypes();
401
402
                include_once(XOOPS_ROOT_PATH . '/class/uploader.php');
403
404
                if ($_FILES[$filename]['tmp_name'] == '' || !is_readable($_FILES[$filename]['tmp_name'])) {
405
                    redirect_header('javascript:history.go(-1)', 2, _CO_SPARTNER_FILE_UPLOAD_ERROR);
406
                    exit;
407
                }
408
409
                $uploader = new XoopsMediaUploader(smartpartner_getImageDir(), $allowed_mimetypes, $max_size, $max_imgwidth, $max_imgheight);
410
411
                // TODO: prefix the image file with the partnerid, but for that we need to first save the partner to get partnerid...
412
                // $uploader->setTargetFileName($partnerObj->partnerid() . "_" . $_FILES['logo_file']['name']);
413
414
                if ($uploader->fetchMedia($filename) && $uploader->upload()) {
415
                    $partnerObj->setVar('image', $uploader->getSavedFileName());
416
                } else {
417
                    redirect_header('javascript:history.go(-1)', 2, _CO_SPARTNER_FILE_UPLOAD_ERROR . $uploader->getErrors());
418
                    exit;
419
                }
420
            }
421
        } else {
422
            $partnerObj->setVar('image', $_POST['image']);
423
        }