Completed
Push — master ( 55ae08...b8e332 )
by Yannick
29:04
created
getImages.php 2 patches
Indentation   +51 added lines, -51 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__).'/cache/'.$color.'-'.$filename) && is_readable(dirname(__FILE__).'/cache/'.$color.'-'.$filename)) {
29
-    header('Content-type: image/png');
30
-    readfile(dirname(__FILE__).'/cache/'.$color.'-'.$filename);
31
-    exit(0);
29
+	header('Content-type: image/png');
30
+	readfile(dirname(__FILE__).'/cache/'.$color.'-'.$filename);
31
+	exit(0);
32 32
 }
33 33
 if (isset($_GET['tracker'])) {
34 34
 	$original = dirname(__FILE__).'/images/vehicules/color/'.$filename;
@@ -45,68 +45,68 @@  discard block
 block discarded – undo
45 45
 	$original = dirname(__FILE__).'/images/aircrafts/new/'.$filename;
46 46
 }
47 47
 if (!file_exists($original)) {
48
-    echo "File not found";
48
+	echo "File not found";
49 49
 }
50 50
 
51 51
 if (extension_loaded('gd') && function_exists('gd_info')) {
52
-    $image = imagecreatefrompng($original);
53
-    $index = imagecolorexact($image,26,49,81);
54
-    if ($index < 0) {
52
+	$image = imagecreatefrompng($original);
53
+	$index = imagecolorexact($image,26,49,81);
54
+	if ($index < 0) {
55 55
 	$index = imagecolorexact($image,25,49,79);
56
-    }
57
-    if ($index < 0) {
56
+	}
57
+	if ($index < 0) {
58 58
 	$index = imagecolorexact($image,0,0,0);
59
-    }
60
-    $c = hexToRGB($color);
61
-    imagecolorset($image,$index,$c['r'],$c['g'],$c['b']);
59
+	}
60
+	$c = hexToRGB($color);
61
+	imagecolorset($image,$index,$c['r'],$c['g'],$c['b']);
62 62
  /*
63 63
     $ig = imagecolorat($image, 0, 0);
64 64
     imagecolortransparent($image, $ig);
65 65
    */
66 66
 
67
-    header('Content-type: image/png');
68
-    if (isset($_GET['resize']) && function_exists('imagecopyresampled')) {
67
+	header('Content-type: image/png');
68
+	if (isset($_GET['resize']) && function_exists('imagecopyresampled')) {
69 69
 	$resize = filter_input(INPUT_GET,'resize',FILTER_SANITIZE_NUMBER_INT);
70 70
 	$newimg = imagecreatetruecolor($resize,$resize);
71
-        imagealphablending($newimg, false);
71
+		imagealphablending($newimg, false);
72 72
 	imagesavealpha($newimg, true);
73 73
 	imagecopyresampled($newimg,$image,0,0,0,0,15,15,imagesx($image),imagesy($image));
74 74
 	if (isset($_GET['heading'])) {
75
-    	    $heading = filter_input(INPUT_GET,'heading',FILTER_SANITIZE_NUMBER_INT);
76
-    	    $rotation = imagerotate($newimg,$heading,imageColorAllocateAlpha($newimg,0,0,0,127));
77
-    	    imagealphablending($rotation, false);
78
-	    imagesavealpha($rotation, true);
79
-    	    imagepng($rotation);
80
-    	    imagedestroy($newimg);
81
-    	    imagedestroy($image);
82
-    	    imagedestroy($rotation);
75
+			$heading = filter_input(INPUT_GET,'heading',FILTER_SANITIZE_NUMBER_INT);
76
+			$rotation = imagerotate($newimg,$heading,imageColorAllocateAlpha($newimg,0,0,0,127));
77
+			imagealphablending($rotation, false);
78
+		imagesavealpha($rotation, true);
79
+			imagepng($rotation);
80
+			imagedestroy($newimg);
81
+			imagedestroy($image);
82
+			imagedestroy($rotation);
83 83
 	
84 84
 	} else {
85
-    	    imagepng($newimg);
86
-    	    imagedestroy($newimg);
87
-    	    imagedestroy($image);
88
-        }
89
-    } else {
85
+			imagepng($newimg);
86
+			imagedestroy($newimg);
87
+			imagedestroy($image);
88
+		}
89
+	} else {
90 90
 	imagealphablending($image, false);
91
-        imagesavealpha($image, true);
91
+		imagesavealpha($image, true);
92 92
 	imagepng($image);
93 93
 	imagepng($image);
94 94
 	if (is_writable(dirname(__FILE__).'/cache')) {
95
-    	    imagepng($image,dirname(__FILE__).'/cache/'.$color.'-'.$filename);
95
+			imagepng($image,dirname(__FILE__).'/cache/'.$color.'-'.$filename);
96
+	}
97
+		imagedestroy($image);
96 98
 	}
97
-        imagedestroy($image);
98
-    }
99 99
 } else {
100
-    header('Content-type: image/png');
101
-    if (isset($_GET['tracker'])) {
102
-        readfile(dirname(__FILE__).'/images/vehicules/'.$filename);
103
-    } elseif (isset($_GET['marine'])) {
104
-        readfile(dirname(__FILE__).'/images/vehicules/'.$filename);
105
-    } elseif (isset($_GET['satellite'])) {
106
-        readfile(dirname(__FILE__).'/images/satellites/'.$filename);
107
-    } else {
108
-        if ($color == 'FF0000') readfile(dirname(__FILE__).'/images/aircrafts/selected/'.$filename);
100
+	header('Content-type: image/png');
101
+	if (isset($_GET['tracker'])) {
102
+		readfile(dirname(__FILE__).'/images/vehicules/'.$filename);
103
+	} elseif (isset($_GET['marine'])) {
104
+		readfile(dirname(__FILE__).'/images/vehicules/'.$filename);
105
+	} elseif (isset($_GET['satellite'])) {
106
+		readfile(dirname(__FILE__).'/images/satellites/'.$filename);
107
+	} else {
108
+		if ($color == 'FF0000') readfile(dirname(__FILE__).'/images/aircrafts/selected/'.$filename);
109 109
 	else readfile(dirname(__FILE__).'/images/aircrafts/'.$filename);
110
-    }
110
+	}
111 111
 }
112 112
 ?>
113 113
\ No newline at end of file
Please login to merge, or discard this patch.
Braces   +5 added lines, -2 removed lines patch added patch discarded remove patch
@@ -105,8 +105,11 @@
 block discarded – undo
105 105
     } elseif (isset($_GET['satellite'])) {
106 106
         readfile(dirname(__FILE__).'/images/satellites/'.$filename);
107 107
     } else {
108
-        if ($color == 'FF0000') readfile(dirname(__FILE__).'/images/aircrafts/selected/'.$filename);
109
-	else readfile(dirname(__FILE__).'/images/aircrafts/'.$filename);
108
+        if ($color == 'FF0000') {
109
+        	readfile(dirname(__FILE__).'/images/aircrafts/selected/'.$filename);
110
+        } else {
111
+		readfile(dirname(__FILE__).'/images/aircrafts/'.$filename);
112
+	}
110 113
     }
111 114
 }
112 115
 ?>
113 116
\ No newline at end of file
Please login to merge, or discard this patch.