MediaImgUploader   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 17
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 4
dl 0
loc 17
rs 10
c 0
b 0
f 0
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
1
<?php
2
3
namespace XoopsModules\Wfdownloads;
4
5
/*
6
 You may not change or alter any portion of this comment or credits
7
 of supporting developers from this source code or any supporting source code
8
 which is considered copyrighted (c) material of the original comment or credit authors.
9
10
 This program is distributed in the hope that it will be useful,
11
 but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13
 */
14
/**
15
 * Wfdownloads module
16
 *
17
 * @copyright       XOOPS Project (https://xoops.org)
18
 * @license         GNU GPL 2 or later (https://www.gnu.org/licenses/gpl-2.0.html)
19
 * @package         wfdownload
20
 * @since           3.23
21
 * @author          Xoops Development Team
22
 */
23
/**
24
 * !
25
 * Example
26
 *
27
 * require_once __DIR__ . '/uploader.php';
28
 * $allowed_mimetypes = array('image/gif', 'image/jpeg', 'image/pjpeg', 'image/x-png');
29
 * $maxfilesize = 50000;
30
 * $maxfilewidth = 120;
31
 * $maxfileheight = 120;
32
 * $uploader = new \XoopsMediaUploader('/home/xoops/uploads', $allowed_mimetypes, $maxfilesize, $maxfilewidth, $maxfileheight);
33
 * if ($uploader->fetchMedia($_POST['uploade_file_name'])) {
34
 * if (!$uploader->upload()) {
35
 * echo $uploader->getErrors();
36
 * } else {
37
 * echo '<h4>File uploaded successfully!</h4>'
38
 * echo 'Saved as: ' . $uploader->getSavedFileName() . '<br>';
39
 * echo 'Full path: ' . $uploader->getSavedDestination();
40
 * }
41
 * } else {
42
 * echo $uploader->getErrors();
43
 * }
44
 */
45
46
/**
47
 * Upload Media files
48
 *
49
 * Example of usage:
50
 * <code>
51
 * require_once __DIR__ . '/uploader.php';
52
 * $allowed_mimetypes = array('image/gif', 'image/jpeg', 'image/pjpeg', 'image/x-png');
53
 * $maxfilesize = 50000;
54
 * $maxfilewidth = 120;
55
 * $maxfileheight = 120;
56
 * $uploader = new \XoopsMediaUploader('/home/xoops/uploads', $allowed_mimetypes, $maxfilesize, $maxfilewidth, $maxfileheight);
57
 * if ($uploader->fetchMedia($_POST['uploade_file_name'])) {
58
 *            if (!$uploader->upload()) {
59
 *               echo $uploader->getErrors();
60
 *            } else {
61
 *               echo '<h4>File uploaded successfully!</h4>'
62
 *               echo 'Saved as: ' . $uploader->getSavedFileName() . '<br>';
63
 *               echo 'Full path: ' . $uploader->getSavedDestination();
64
 *            }
65
 * } else {
66
 *            echo $uploader->getErrors();
67
 * }
68
 * </code>
69
 *
70
 * @package       kernel
71
 * @subpackage    core
72
 * @author        Kazumi Ono <[email protected]>
73
 * @copyright (c) 2000-2003 The Xoops Project - www.xoops.org
74
 */
75
76
use XoopsModules\Wfdownloads;
77
78
//require_once XOOPS_ROOT_PATH . '/modules/wfdownloads/class/uploader.php';
79
require_once XOOPS_ROOT_PATH . '/class/uploader.php';
80
81
/**
82
 * Class MediaImgUploader
83
 */
84
class MediaImgUploader extends \XoopsMediaUploader
85
{
86
    public $randomfilename;
87
88
    /**
89
     * Constructor
90
     *
91
     * @param string    $uploadDir
92
     * @param array|int $allowedMimeTypes
93
     * @param int       $maxFileSize
94
     * @param int       $maxWidth
95
     * @param int       $maxHeight
96
     */
97
    public function __construct($uploadDir, $allowedMimeTypes, $maxFileSize, $maxWidth = 0, $maxHeight = 0)
98
    {
99
        parent::__construct($uploadDir, $allowedMimeTypes, $maxFileSize, $maxWidth, $maxHeight);
0 ignored issues
show
Bug introduced by
It seems like $allowedMimeTypes can also be of type integer; however, parameter $allowedMimeTypes of XoopsMediaUploader::__construct() does only seem to accept array, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

99
        parent::__construct($uploadDir, /** @scrutinizer ignore-type */ $allowedMimeTypes, $maxFileSize, $maxWidth, $maxHeight);
Loading history...
100
        $this->randomfilename = false;
101
    }
102
}
103