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.
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | ////////////////////////////////////////////////////////////// |
||
3 | // phpThumb() by James Heinrich <[email protected]> // |
||
4 | // available at http://phpthumb.sourceforge.net // |
||
5 | // and/or https://github.com/JamesHeinrich/phpThumb // |
||
6 | ////////////////////////////////////////////////////////////// |
||
7 | /// // |
||
8 | // phpthumb.ico.php - .ICO output format functions // |
||
9 | // /// |
||
10 | ////////////////////////////////////////////////////////////// |
||
11 | |||
12 | /** |
||
13 | * Class phpthumb_ico |
||
14 | */ |
||
15 | class phpthumb_ico |
||
16 | { |
||
17 | |||
18 | // removed for XOOPS |
||
19 | //function phpthumb_ico() { |
||
20 | // return true; |
||
21 | //} |
||
22 | |||
23 | /** |
||
24 | * @param $gd_image_array |
||
25 | * @return string |
||
26 | */ |
||
27 | public function GD2ICOstring(&$gd_image_array) |
||
28 | { |
||
29 | foreach ($gd_image_array as $key => $gd_image) { |
||
30 | $ImageWidths[$key] = imagesx($gd_image); |
||
0 ignored issues
–
show
|
|||
31 | $ImageHeights[$key] = imagesy($gd_image); |
||
0 ignored issues
–
show
Coding Style
Comprehensibility
introduced
by
$ImageHeights was never initialized. Although not strictly required by PHP, it is generally a good practice to add $ImageHeights = array(); before regardless.
Adding an explicit array definition is generally preferable to implicit array definition as it guarantees a stable state of the code. Let’s take a look at an example: foreach ($collection as $item) {
$myArray['foo'] = $item->getFoo();
if ($item->hasBar()) {
$myArray['bar'] = $item->getBar();
}
// do something with $myArray
}
As you can see in this example, the array This might or might not be intended. To make your intention clear, your code more readible and to avoid accidental bugs, we recommend to add an explicit initialization $myArray = array() either outside or inside the foreach loop. ![]() |
|||
32 | $bpp[$key] = imageistruecolor($gd_image) ? 32 : 24; |
||
0 ignored issues
–
show
Coding Style
Comprehensibility
introduced
by
$bpp was never initialized. Although not strictly required by PHP, it is generally a good practice to add $bpp = array(); before regardless.
Adding an explicit array definition is generally preferable to implicit array definition as it guarantees a stable state of the code. Let’s take a look at an example: foreach ($collection as $item) {
$myArray['foo'] = $item->getFoo();
if ($item->hasBar()) {
$myArray['bar'] = $item->getBar();
}
// do something with $myArray
}
As you can see in this example, the array This might or might not be intended. To make your intention clear, your code more readible and to avoid accidental bugs, we recommend to add an explicit initialization $myArray = array() either outside or inside the foreach loop. ![]() |
|||
33 | $totalcolors[$key] = imagecolorstotal($gd_image); |
||
0 ignored issues
–
show
Coding Style
Comprehensibility
introduced
by
$totalcolors was never initialized. Although not strictly required by PHP, it is generally a good practice to add $totalcolors = array(); before regardless.
Adding an explicit array definition is generally preferable to implicit array definition as it guarantees a stable state of the code. Let’s take a look at an example: foreach ($collection as $item) {
$myArray['foo'] = $item->getFoo();
if ($item->hasBar()) {
$myArray['bar'] = $item->getBar();
}
// do something with $myArray
}
As you can see in this example, the array This might or might not be intended. To make your intention clear, your code more readible and to avoid accidental bugs, we recommend to add an explicit initialization $myArray = array() either outside or inside the foreach loop. ![]() |
|||
34 | |||
35 | $icXOR[$key] = ''; |
||
0 ignored issues
–
show
Coding Style
Comprehensibility
introduced
by
$icXOR was never initialized. Although not strictly required by PHP, it is generally a good practice to add $icXOR = array(); before regardless.
Adding an explicit array definition is generally preferable to implicit array definition as it guarantees a stable state of the code. Let’s take a look at an example: foreach ($collection as $item) {
$myArray['foo'] = $item->getFoo();
if ($item->hasBar()) {
$myArray['bar'] = $item->getBar();
}
// do something with $myArray
}
As you can see in this example, the array This might or might not be intended. To make your intention clear, your code more readible and to avoid accidental bugs, we recommend to add an explicit initialization $myArray = array() either outside or inside the foreach loop. ![]() |
|||
36 | for ($y = $ImageHeights[$key] - 1; $y >= 0; $y--) { |
||
37 | for ($x = 0; $x < $ImageWidths[$key]; $x++) { |
||
38 | $argb = phpthumb_functions::GetPixelColor($gd_image, $x, $y); |
||
39 | $a = round(255 * ((127 - $argb['alpha']) / 127)); |
||
40 | $r = $argb['red']; |
||
41 | $g = $argb['green']; |
||
42 | $b = $argb['blue']; |
||
43 | |||
44 | if ($bpp[$key] == 32) { |
||
45 | $icXOR[$key] .= chr($b) . chr($g) . chr($r) . chr($a); |
||
46 | } elseif ($bpp[$key] == 24) { |
||
47 | $icXOR[$key] .= chr($b) . chr($g) . chr($r); |
||
48 | } |
||
49 | |||
50 | if ($a < 128) { |
||
51 | @$icANDmask[$key][$y] .= '1'; |
||
52 | } else { |
||
53 | @$icANDmask[$key][$y] .= '0'; |
||
54 | } |
||
55 | } |
||
56 | // mask bits are 32-bit aligned per scanline |
||
57 | while (strlen($icANDmask[$key][$y]) % 32) { |
||
58 | $icANDmask[$key][$y] .= '0'; |
||
59 | } |
||
60 | } |
||
61 | $icAND[$key] = ''; |
||
0 ignored issues
–
show
Coding Style
Comprehensibility
introduced
by
$icAND was never initialized. Although not strictly required by PHP, it is generally a good practice to add $icAND = array(); before regardless.
Adding an explicit array definition is generally preferable to implicit array definition as it guarantees a stable state of the code. Let’s take a look at an example: foreach ($collection as $item) {
$myArray['foo'] = $item->getFoo();
if ($item->hasBar()) {
$myArray['bar'] = $item->getBar();
}
// do something with $myArray
}
As you can see in this example, the array This might or might not be intended. To make your intention clear, your code more readible and to avoid accidental bugs, we recommend to add an explicit initialization $myArray = array() either outside or inside the foreach loop. ![]() |
|||
62 | foreach ($icANDmask[$key] as $y => $scanlinemaskbits) { |
||
63 | for ($i = 0, $iMax = strlen($scanlinemaskbits); $i < $iMax; $i += 8) { |
||
64 | $icAND[$key] .= chr(bindec(str_pad(substr($scanlinemaskbits, $i, 8), 8, '0', STR_PAD_LEFT))); |
||
65 | } |
||
66 | } |
||
67 | } |
||
68 | |||
69 | foreach ($gd_image_array as $key => $gd_image) { |
||
70 | $biSizeImage = $ImageWidths[$key] * $ImageHeights[$key] * ($bpp[$key] / 8); |
||
71 | |||
72 | // BITMAPINFOHEADER - 40 bytes |
||
73 | $BitmapInfoHeader[$key] = ''; |
||
0 ignored issues
–
show
Coding Style
Comprehensibility
introduced
by
$BitmapInfoHeader was never initialized. Although not strictly required by PHP, it is generally a good practice to add $BitmapInfoHeader = array(); before regardless.
Adding an explicit array definition is generally preferable to implicit array definition as it guarantees a stable state of the code. Let’s take a look at an example: foreach ($collection as $item) {
$myArray['foo'] = $item->getFoo();
if ($item->hasBar()) {
$myArray['bar'] = $item->getBar();
}
// do something with $myArray
}
As you can see in this example, the array This might or might not be intended. To make your intention clear, your code more readible and to avoid accidental bugs, we recommend to add an explicit initialization $myArray = array() either outside or inside the foreach loop. ![]() |
|||
74 | $BitmapInfoHeader[$key] .= "\x28\x00\x00\x00"; // DWORD biSize; |
||
75 | $BitmapInfoHeader[$key] .= phpthumb_functions::LittleEndian2String($ImageWidths[$key], 4); // LONG biWidth; |
||
76 | // The biHeight member specifies the combined |
||
77 | // height of the XOR and AND masks. |
||
78 | $BitmapInfoHeader[$key] .= phpthumb_functions::LittleEndian2String($ImageHeights[$key] * 2, 4); // LONG biHeight; |
||
79 | $BitmapInfoHeader[$key] .= "\x01\x00"; // WORD biPlanes; |
||
80 | $BitmapInfoHeader[$key] .= chr($bpp[$key]) . "\x00"; // wBitCount; |
||
81 | $BitmapInfoHeader[$key] .= "\x00\x00\x00\x00"; // DWORD biCompression; |
||
82 | $BitmapInfoHeader[$key] .= phpthumb_functions::LittleEndian2String($biSizeImage, 4); // DWORD biSizeImage; |
||
83 | $BitmapInfoHeader[$key] .= "\x00\x00\x00\x00"; // LONG biXPelsPerMeter; |
||
84 | $BitmapInfoHeader[$key] .= "\x00\x00\x00\x00"; // LONG biYPelsPerMeter; |
||
85 | $BitmapInfoHeader[$key] .= "\x00\x00\x00\x00"; // DWORD biClrUsed; |
||
86 | $BitmapInfoHeader[$key] .= "\x00\x00\x00\x00"; // DWORD biClrImportant; |
||
87 | } |
||
88 | |||
89 | $icondata = "\x00\x00"; // idReserved; // Reserved (must be 0) |
||
90 | $icondata .= "\x01\x00"; // idType; // Resource Type (1 for icons) |
||
91 | $icondata .= phpthumb_functions::LittleEndian2String(count($gd_image_array), 2); // idCount; // How many images? |
||
92 | |||
93 | $dwImageOffset = 6 + (count($gd_image_array) * 16); |
||
94 | foreach ($gd_image_array as $key => $gd_image) { |
||
95 | // ICONDIRENTRY idEntries[1]; // An entry for each image (idCount of 'em) |
||
96 | |||
97 | $icondata .= chr($ImageWidths[$key]); // bWidth; // Width, in pixels, of the image |
||
98 | $icondata .= chr($ImageHeights[$key]); // bHeight; // Height, in pixels, of the image |
||
99 | $icondata .= chr($totalcolors[$key]); // bColorCount; // Number of colors in image (0 if >=8bpp) |
||
100 | $icondata .= "\x00"; // bReserved; // Reserved ( must be 0) |
||
101 | |||
102 | $icondata .= "\x01\x00"; // wPlanes; // Color Planes |
||
103 | $icondata .= chr($bpp[$key]) . "\x00"; // wBitCount; // Bits per pixel |
||
104 | |||
105 | $dwBytesInRes = 40 + strlen($icXOR[$key]) + strlen($icAND[$key]); |
||
106 | $icondata .= phpthumb_functions::LittleEndian2String($dwBytesInRes, 4); // dwBytesInRes; // How many bytes in this resource? |
||
107 | |||
108 | $icondata .= phpthumb_functions::LittleEndian2String($dwImageOffset, 4); // dwImageOffset; // Where in the file is this image? |
||
109 | $dwImageOffset += strlen($BitmapInfoHeader[$key]); |
||
110 | $dwImageOffset += strlen($icXOR[$key]); |
||
111 | $dwImageOffset += strlen($icAND[$key]); |
||
112 | } |
||
113 | |||
114 | foreach ($gd_image_array as $key => $gd_image) { |
||
115 | $icondata .= $BitmapInfoHeader[$key]; |
||
116 | $icondata .= $icXOR[$key]; |
||
117 | $icondata .= $icAND[$key]; |
||
118 | } |
||
119 | |||
120 | return $icondata; |
||
121 | } |
||
122 | } |
||
123 |
Adding an explicit array definition is generally preferable to implicit array definition as it guarantees a stable state of the code.
Let’s take a look at an example:
As you can see in this example, the array
$myArray
is initialized the first time when the foreach loop is entered. You can also see that the value of thebar
key is only written conditionally; thus, its value might result from a previous iteration.This might or might not be intended. To make your intention clear, your code more readible and to avoid accidental bugs, we recommend to add an explicit initialization $myArray = array() either outside or inside the foreach loop.