Completed
Push — master ( 3969e1...ada087 )
by Yannick
132:11 queued 106:14
created
getImages.php 1 patch
Indentation   +49 added lines, -49 removed lines patch added patch discarded remove patch
@@ -4,31 +4,31 @@  discard block
 block discarded – undo
4 4
 	$hex = str_replace("#", "", $hex);
5 5
 	$color = array();
6 6
 	if (strlen($hex) == 3) {
7
-	    $color['r'] = hexdec(substr($hex, 0, 1) . substr($hex,0,1));
8
-	    $color['g'] = hexdec(substr($hex, 1, 1) . substr($hex,1,1));
9
-	    $color['b'] = hexdec(substr($hex, 2, 1) . substr($hex,2,1));
7
+		$color['r'] = hexdec(substr($hex, 0, 1) . substr($hex,0,1));
8
+		$color['g'] = hexdec(substr($hex, 1, 1) . substr($hex,1,1));
9
+		$color['b'] = hexdec(substr($hex, 2, 1) . substr($hex,2,1));
10 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));
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 14
 	}
15 15
 	return $color;
16 16
 }
17 17
 
18 18
 
19 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);
20
+	exit(0);
21 21
 }
22 22
 $color = $_GET['color'];
23 23
 if (!isset($_GET['filename']) || !preg_match('/^[a-z0-9-_]+\.png$/', strtolower($_GET['filename']))) {
24
-    echo "Incorrect filename";
25
-    exit(0);
24
+	echo "Incorrect filename";
25
+	exit(0);
26 26
 }
27 27
 $filename = $_GET['filename'];
28 28
 if (file_exists(dirname(__FILE__).DIRECTORY_SEPARATOR.'cache'.DIRECTORY_SEPARATOR.$color.'-'.$filename) && is_readable(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);
29
+	header('Content-type: image/png');
30
+	readfile(dirname(__FILE__).DIRECTORY_SEPARATOR.'cache'.DIRECTORY_SEPARATOR.$color.'-'.$filename);
31
+	exit(0);
32 32
 }
33 33
 if (isset($_GET['tracker'])) {
34 34
 	$original = dirname(__FILE__).DIRECTORY_SEPARATOR.'images'.DIRECTORY_SEPARATOR.'vehicules'.DIRECTORY_SEPARATOR.'color'.DIRECTORY_SEPARATOR.$filename;
@@ -42,66 +42,66 @@  discard block
 block discarded – undo
42 42
 	$original = dirname(__FILE__).DIRECTORY_SEPARATOR.'images'.DIRECTORY_SEPARATOR.'aircrafts'.DIRECTORY_SEPARATOR.'new'.DIRECTORY_SEPARATOR.$filename;
43 43
 }
44 44
 if (!file_exists($original)) {
45
-    echo "File not found";
45
+	echo "File not found";
46 46
 }
47 47
 
48 48
 if (extension_loaded('gd') && function_exists('gd_info')) {
49
-    $image = imagecreatefrompng($original);
50
-    $index = imagecolorexact($image,26,49,81);
51
-    if ($index < 0) {
49
+	$image = imagecreatefrompng($original);
50
+	$index = imagecolorexact($image,26,49,81);
51
+	if ($index < 0) {
52 52
 	$index = imagecolorexact($image,25,49,79);
53
-    }
54
-    if ($index < 0) {
53
+	}
54
+	if ($index < 0) {
55 55
 	$index = imagecolorexact($image,0,0,0);
56
-    }
57
-    $c = hexToRGB($color);
58
-    imagecolorset($image,$index,$c['r'],$c['g'],$c['b']);
56
+	}
57
+	$c = hexToRGB($color);
58
+	imagecolorset($image,$index,$c['r'],$c['g'],$c['b']);
59 59
  /*
60 60
     $ig = imagecolorat($image, 0, 0);
61 61
     imagecolortransparent($image, $ig);
62 62
    */
63 63
 
64
-    header('Content-type: image/png');
65
-    if (isset($_GET['resize']) && function_exists('imagecopyresampled')) {
64
+	header('Content-type: image/png');
65
+	if (isset($_GET['resize']) && function_exists('imagecopyresampled')) {
66 66
 	$resize = filter_input(INPUT_GET,'resize',FILTER_SANITIZE_NUMBER_INT);
67 67
 	$newimg = imagecreatetruecolor($resize,$resize);
68
-        imagealphablending($newimg, false);
68
+		imagealphablending($newimg, false);
69 69
 	imagesavealpha($newimg, true);
70 70
 	imagecopyresampled($newimg,$image,0,0,0,0,15,15,imagesx($image),imagesy($image));
71 71
 	if (isset($_GET['heading'])) {
72
-    	    $heading = filter_input(INPUT_GET,'heading',FILTER_SANITIZE_NUMBER_INT);
73
-    	    $rotation = imagerotate($newimg,$heading,imageColorAllocateAlpha($newimg,0,0,0,127));
74
-    	    imagealphablending($rotation, false);
75
-	    imagesavealpha($rotation, true);
76
-    	    imagepng($rotation);
77
-    	    imagedestroy($newimg);
78
-    	    imagedestroy($image);
79
-    	    imagedestroy($rotation);
72
+			$heading = filter_input(INPUT_GET,'heading',FILTER_SANITIZE_NUMBER_INT);
73
+			$rotation = imagerotate($newimg,$heading,imageColorAllocateAlpha($newimg,0,0,0,127));
74
+			imagealphablending($rotation, false);
75
+		imagesavealpha($rotation, true);
76
+			imagepng($rotation);
77
+			imagedestroy($newimg);
78
+			imagedestroy($image);
79
+			imagedestroy($rotation);
80 80
 	
81 81
 	} else {
82
-    	    imagepng($newimg);
83
-    	    imagedestroy($newimg);
84
-    	    imagedestroy($image);
85
-        }
86
-    } else {
82
+			imagepng($newimg);
83
+			imagedestroy($newimg);
84
+			imagedestroy($image);
85
+		}
86
+	} else {
87 87
 	imagealphablending($image, false);
88
-        imagesavealpha($image, true);
88
+		imagesavealpha($image, true);
89 89
 	imagepng($image);
90 90
 	imagepng($image);
91 91
 	if (is_writable('cache')) {
92
-    	    imagepng($image,dirname(__FILE__).DIRECTORY_SEPARATOR.'cache/'.$color.'-'.$filename);
92
+			imagepng($image,dirname(__FILE__).DIRECTORY_SEPARATOR.'cache/'.$color.'-'.$filename);
93
+	}
94
+		imagedestroy($image);
93 95
 	}
94
-        imagedestroy($image);
95
-    }
96 96
 } else {
97
-    header('Content-type: image/png');
98
-    if (isset($_GET['tracker'])) {
99
-        readfile(dirname(__FILE__).DIRECTORY_SEPARATOR.'images/vehicules/'.$filename);
100
-    } elseif (isset($_GET['marine'])) {
101
-        readfile(dirname(__FILE__).DIRECTORY_SEPARATOR.'images/vehicules/'.$filename);
102
-    } else {
103
-        if ($color == 'FF0000') readfile(dirname(__FILE__).DIRECTORY_SEPARATOR.'images/aircrafts/selected/'.$filename);
97
+	header('Content-type: image/png');
98
+	if (isset($_GET['tracker'])) {
99
+		readfile(dirname(__FILE__).DIRECTORY_SEPARATOR.'images/vehicules/'.$filename);
100
+	} elseif (isset($_GET['marine'])) {
101
+		readfile(dirname(__FILE__).DIRECTORY_SEPARATOR.'images/vehicules/'.$filename);
102
+	} else {
103
+		if ($color == 'FF0000') readfile(dirname(__FILE__).DIRECTORY_SEPARATOR.'images/aircrafts/selected/'.$filename);
104 104
 	else readfile(dirname(__FILE__).DIRECTORY_SEPARATOR.'images/aircrafts/'.$filename);
105
-    }
105
+	}
106 106
 }
107 107
 ?>
108 108
\ No newline at end of file
Please login to merge, or discard this patch.