Ysurac /
FlightAirMap
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
| 1 | <?php |
||
| 2 | |||
| 3 | function hexToRGB($hex) { |
||
| 4 | $hex = str_replace("#", "", $hex); |
||
| 5 | $color = array(); |
||
| 6 | if (strlen($hex) == 3) { |
||
| 7 | $color['r'] = hexdec(substr($hex, 0, 1) . $r); |
||
|
0 ignored issues
–
show
|
|||
| 8 | $color['g'] = hexdec(substr($hex, 1, 1) . $g); |
||
|
0 ignored issues
–
show
|
|||
| 9 | $color['b'] = hexdec(substr($hex, 2, 1) . $b); |
||
|
0 ignored issues
–
show
|
|||
| 10 | } else if (strlen($hex) == 6) { |
||
| 11 | $color['r'] = hexdec(substr($hex, 0, 2)); |
||
| 12 | $color['g'] = hexdec(substr($hex, 2, 2)); |
||
| 13 | $color['b'] = hexdec(substr($hex, 4, 2)); |
||
| 14 | } |
||
| 15 | return $color; |
||
| 16 | } |
||
| 17 | |||
| 18 | |||
| 19 | if (!isset($_GET['color']) || $_GET['color'] == '' || !preg_match('/^([a-fA-F0-9]){3}(([a-fA-F0-9]){3})?\b/',$_GET['color'])) { |
||
| 20 | exit(0); |
||
| 21 | } |
||
| 22 | $color = $_GET['color']; |
||
| 23 | if (!isset($_GET['filename']) || !preg_match('/^[a-z0-9-_]+\.png$/', strtolower($_GET['filename']))) { |
||
| 24 | echo "Incorrect filename"; |
||
| 25 | exit(0); |
||
| 26 | } |
||
| 27 | $filename = $_GET['filename']; |
||
| 28 | if (file_exists(dirname(__FILE__).DIRECTORY_SEPARATOR.'cache'.DIRECTORY_SEPARATOR.$color.'-'.$filename)) { |
||
| 29 | header('Content-type: image/png'); |
||
| 30 | readfile(dirname(__FILE__).DIRECTORY_SEPARATOR.'cache'.DIRECTORY_SEPARATOR.$color.'-'.$filename); |
||
| 31 | exit(0); |
||
| 32 | } |
||
| 33 | $original = dirname(__FILE__).DIRECTORY_SEPARATOR.'images'.DIRECTORY_SEPARATOR.'aircrafts'.DIRECTORY_SEPARATOR.'new'.DIRECTORY_SEPARATOR.$filename; |
||
| 34 | if (!file_exists($original)) { |
||
| 35 | echo "File not found"; |
||
| 36 | } |
||
| 37 | |||
| 38 | if (extension_loaded('gd') && function_exists('gd_info')) { |
||
| 39 | $image = imagecreatefrompng($original); |
||
| 40 | $index = imagecolorexact($image,26,49,81); |
||
| 41 | if ($index < 0) { |
||
| 42 | $index = imagecolorexact($image,25,49,79); |
||
| 43 | } |
||
| 44 | if ($index < 0) { |
||
| 45 | $index = imagecolorexact($image,0,0,0); |
||
| 46 | } |
||
| 47 | $c = hexToRGB($color); |
||
| 48 | imagecolorset($image,$index,$c['r'],$c['g'],$c['b']); |
||
| 49 | /* |
||
| 50 | $ig = imagecolorat($image, 0, 0); |
||
| 51 | imagecolortransparent($image, $ig); |
||
| 52 | */ |
||
| 53 | |||
| 54 | |||
| 55 | header('Content-type: image/png'); |
||
| 56 | imagealphablending($image, false); |
||
| 57 | imagesavealpha($image, true); |
||
| 58 | imagepng($image); |
||
| 59 | if (is_writable('cache')) { |
||
| 60 | imagepng($image,dirname(__FILE__).DIRECTORY_SEPARATOR.'cache/'.$color.'-'.$filename); |
||
| 61 | } |
||
| 62 | |||
| 63 | imagedestroy($image); |
||
| 64 | } else { |
||
| 65 | header('Content-type: image/png'); |
||
| 66 | if ($color == 'FF0000') readfile(dirname(__FILE__).DIRECTORY_SEPARATOR.'images/aircrafts/selected/'.$filename); |
||
| 67 | else readfile(dirname(__FILE__).DIRECTORY_SEPARATOR.'images/aircrafts/'.$filename); |
||
| 68 | } |
||
| 69 | ?> |
This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.