mambax7 /
tdmcreate-1.91
This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include, or for example
via PHP's auto-loading mechanism.
| 1 | <?php namespace XoopsModules\Tdmcreate; |
||||||
| 2 | |||||||
| 3 | use XoopsModules\Tdmcreate; |
||||||
| 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 | /** |
||||||
| 16 | * modules class. |
||||||
| 17 | * |
||||||
| 18 | * @copyright XOOPS Project (https://xoops.org) |
||||||
| 19 | * @license GNU GPL 2 (http://www.gnu.org/licenses/old-licenses/gpl-2.0.html) |
||||||
| 20 | * |
||||||
| 21 | * @since 2.5.7 |
||||||
| 22 | * |
||||||
| 23 | * @author Txmod Xoops <[email protected]> - <http://www.txmodxoops.org/> |
||||||
| 24 | * |
||||||
| 25 | * @version $Id: 1.91 logo.php 13040 2015-04-25 15:12:12Z timgno $ |
||||||
| 26 | */ |
||||||
| 27 | // include __DIR__ . '/autoload.php'; |
||||||
| 28 | /** |
||||||
| 29 | * Class Logo. |
||||||
| 30 | */ |
||||||
| 31 | class Logo |
||||||
| 32 | { |
||||||
| 33 | /* |
||||||
| 34 | * @static function getInstance |
||||||
| 35 | * @param null |
||||||
| 36 | */ |
||||||
| 37 | |||||||
| 38 | /** |
||||||
| 39 | * @return Logo |
||||||
| 40 | */ |
||||||
| 41 | public static function getInstance() |
||||||
| 42 | { |
||||||
| 43 | static $instance = false; |
||||||
| 44 | if (!$instance) { |
||||||
| 45 | $instance = new self(); |
||||||
| 46 | } |
||||||
| 47 | |||||||
| 48 | return $instance; |
||||||
| 49 | } |
||||||
| 50 | |||||||
| 51 | /* |
||||||
| 52 | * @private static function createLogo |
||||||
| 53 | * @param mixed $logoIcon |
||||||
| 54 | * @param string $moduleDirname |
||||||
| 55 | */ |
||||||
| 56 | /** |
||||||
| 57 | * @param $logoIcon |
||||||
| 58 | * @param $moduleDirname |
||||||
| 59 | * |
||||||
| 60 | * @return bool|string |
||||||
| 61 | */ |
||||||
| 62 | /*private static function createLogo($logoIcon, $moduleDirname) |
||||||
| 63 | { |
||||||
| 64 | if (!extension_loaded('gd')) { |
||||||
| 65 | return false; |
||||||
| 66 | } else { |
||||||
| 67 | $requiredFunctions = array('imagecreatefrompng', 'imagefttext', 'imagecopy', 'imagepng', 'imagedestroy', 'imagecolorallocate'); |
||||||
| 68 | foreach ($requiredFunctions as $func) { |
||||||
| 69 | if (!function_exists($func)) { |
||||||
| 70 | return false; |
||||||
| 71 | } |
||||||
| 72 | } |
||||||
| 73 | } |
||||||
| 74 | if (!file_exists($imageBase = TDMC_IMAGES_LOGOS_PATH.'/empty.png') || |
||||||
| 75 | !file_exists($font = TDMC_FONTS_PATH.'/VeraBd.ttf') || |
||||||
| 76 | !file_exists($iconFile = XOOPS_ICONS32_PATH.'/'.basename($logoIcon)) |
||||||
| 77 | ) { |
||||||
| 78 | return false; |
||||||
| 79 | } |
||||||
| 80 | $imageModule = imagecreatefrompng($imageBase); |
||||||
| 81 | $imageIcon = imagecreatefrompng($iconFile); |
||||||
| 82 | // Write text |
||||||
| 83 | $textColor = imagecolorallocate($imageModule, 0, 0, 0); |
||||||
| 84 | $spaceBorder = (92 - strlen($moduleDirname) * 7.5) / 2; |
||||||
| 85 | imagefttext($imageModule, 8.5, 0, $spaceBorder, 45, $textColor, $font, ucfirst($moduleDirname), array()); |
||||||
| 86 | imagecopy($imageModule, $imageIcon, 29, 2, 0, 0, 32, 32); |
||||||
| 87 | $logoImg = '/'.$moduleDirname.'_logo.png'; |
||||||
| 88 | imagepng($imageModule, TDMC_UPLOAD_IMGMOD_PATH.$logoImg); |
||||||
| 89 | imagedestroy($imageModule); |
||||||
| 90 | imagedestroy($imageIcon); |
||||||
| 91 | |||||||
| 92 | return TDMC_UPLOAD_IMGMOD_URL.$logoImg; |
||||||
| 93 | }*/ |
||||||
| 94 | |||||||
| 95 | /** |
||||||
| 96 | * @param $logoIcon |
||||||
| 97 | * @param $moduleDirname |
||||||
| 98 | * |
||||||
| 99 | * @return bool|string |
||||||
| 100 | */ |
||||||
| 101 | public static function createLogo($logoIcon, $moduleDirname) |
||||||
| 102 | { |
||||||
| 103 | if (!extension_loaded('gd')) { |
||||||
| 104 | return false; |
||||||
| 105 | } |
||||||
| 106 | $requiredFunctions = ['imagecreatefrompng', 'imagefttext', 'imagecopy', 'imagepng', 'imagedestroy', 'imagecolorallocate']; |
||||||
| 107 | foreach ($requiredFunctions as $func) { |
||||||
| 108 | if (!function_exists($func)) { |
||||||
| 109 | return false; |
||||||
| 110 | } |
||||||
| 111 | } |
||||||
| 112 | |||||||
| 113 | $dirname = 'tdmcreate'; |
||||||
| 114 | $iconFileName = XOOPS_ROOT_PATH . '/Frameworks/moduleclasses/icons/32/' . basename($logoIcon); |
||||||
| 115 | |||||||
| 116 | //$dirFonts = TDMC_PATH . "/assets/fonts"; |
||||||
| 117 | //$dirLogos = TDMC_PATH . "/assets/images/logos"; |
||||||
| 118 | $dirFonts = XOOPS_ROOT_PATH . '/modules/' . $dirname . '/assets/fonts'; |
||||||
| 119 | $dirLogos = XOOPS_ROOT_PATH . '/modules/' . $dirname . '/assets/images/logos'; |
||||||
| 120 | |||||||
| 121 | if (!file_exists($imageBase = $dirLogos . '/empty.png') || |
||||||
| 122 | !file_exists($font = $dirFonts . '/VeraBd.ttf') || |
||||||
| 123 | !file_exists($iconFile = $iconFileName)) { |
||||||
| 124 | return false; |
||||||
| 125 | } |
||||||
| 126 | |||||||
| 127 | $imageModule = imagecreatefrompng($imageBase); |
||||||
| 128 | $imageIcon = imagecreatefrompng($iconFile); |
||||||
| 129 | |||||||
| 130 | // Write text |
||||||
| 131 | $textColor = imagecolorallocate($imageModule, 0, 0, 0); |
||||||
|
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||||||
| 132 | $spaceToBorder = (92 - mb_strlen($moduleDirname) * 7.5) / 2; |
||||||
| 133 | imagefttext($imageModule, 8.5, 0, $spaceToBorder, 45, $textColor, $font, ucfirst($moduleDirname), []); |
||||||
|
0 ignored issues
–
show
It seems like
$imageModule can also be of type false; however, parameter $image of imagefttext() does only seem to accept resource, 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
Loading history...
$spaceToBorder of type double is incompatible with the type integer expected by parameter $x of imagefttext().
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||||
| 134 | |||||||
| 135 | imagecopy($imageModule, $imageIcon, 29, 2, 0, 0, 32, 32); |
||||||
|
0 ignored issues
–
show
It seems like
$imageModule can also be of type false; however, parameter $dst_im of imagecopy() does only seem to accept resource, 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
Loading history...
It seems like
$imageIcon can also be of type false; however, parameter $src_im of imagecopy() does only seem to accept resource, 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
Loading history...
|
|||||||
| 136 | |||||||
| 137 | //$targetImage = TDMC_UPLOAD_IMGMOD_URL . "/" . $moduleDirname . "_logo.png"; |
||||||
| 138 | $targetImage = '/uploads/' . $dirname . '/images/modules/' . $moduleDirname . '_logo.png'; |
||||||
| 139 | |||||||
| 140 | imagepng($imageModule, XOOPS_ROOT_PATH . $targetImage); |
||||||
|
0 ignored issues
–
show
It seems like
$imageModule can also be of type false; however, parameter $image of imagepng() does only seem to accept resource, 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
Loading history...
|
|||||||
| 141 | |||||||
| 142 | imagedestroy($imageModule); |
||||||
|
0 ignored issues
–
show
It seems like
$imageModule can also be of type false; however, parameter $image of imagedestroy() does only seem to accept resource, 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
Loading history...
|
|||||||
| 143 | imagedestroy($imageIcon); |
||||||
| 144 | |||||||
| 145 | return XOOPS_URL . $targetImage; |
||||||
| 146 | } |
||||||
| 147 | } |
||||||
| 148 |