Completed
Push — master ( 5b2234...f7c0d7 )
by Yannick
07:17
created
require/class.Image.php 1 patch
Spacing   +77 added lines, -77 removed lines patch added patch discarded remove patch
@@ -17,14 +17,14 @@  discard block
 block discarded – undo
17 17
 	* @return Array the images list
18 18
 	*
19 19
 	*/
20
-	public function getSpotterImage($registration,$aircraft_icao = '', $airline_icao = '')
20
+	public function getSpotterImage($registration, $aircraft_icao = '', $airline_icao = '')
21 21
 	{
22
-		$registration = filter_var($registration,FILTER_SANITIZE_STRING);
23
-		$aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING);
24
-		$airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING);
22
+		$registration = filter_var($registration, FILTER_SANITIZE_STRING);
23
+		$aircraft_icao = filter_var($aircraft_icao, FILTER_SANITIZE_STRING);
24
+		$airline_icao = filter_var($airline_icao, FILTER_SANITIZE_STRING);
25 25
 		if ($registration == '' && $aircraft_icao != '') $registration = $aircraft_icao.$airline_icao;
26 26
 		$registration = trim($registration);
27
-		$query  = "SELECT spotter_image.image, spotter_image.image_thumbnail, spotter_image.image_source, spotter_image.image_source_website,spotter_image.image_copyright, spotter_image.registration 
27
+		$query = "SELECT spotter_image.image, spotter_image.image_thumbnail, spotter_image.image_source, spotter_image.image_source_website,spotter_image.image_copyright, spotter_image.registration 
28 28
 			FROM spotter_image 
29 29
 			WHERE spotter_image.registration = :registration";
30 30
 		$sth = $this->db->prepare($query);
@@ -63,9 +63,9 @@  discard block
 block discarded – undo
63 63
 		if (isset($exif['COMPUTED']['copyright'])) $copyright = $exif['COMPUTED']['copyright'];
64 64
 		elseif (isset($exif['copyright'])) $copyright = $exif['copyright'];
65 65
 		if ($copyright != '') {
66
-			$copyright = str_replace('Copyright ','',$copyright);
67
-			$copyright = str_replace('© ','',$copyright);
68
-			$copyright = str_replace('(c) ','',$copyright);
66
+			$copyright = str_replace('Copyright ', '', $copyright);
67
+			$copyright = str_replace('© ', '', $copyright);
68
+			$copyright = str_replace('(c) ', '', $copyright);
69 69
 		}
70 70
 		return $copyright;
71 71
 	}
@@ -76,26 +76,26 @@  discard block
 block discarded – undo
76 76
 	* @return String either success or error
77 77
 	*
78 78
 	*/
79
-	public function addSpotterImage($registration,$aircraft_icao = '', $airline_icao = '')
79
+	public function addSpotterImage($registration, $aircraft_icao = '', $airline_icao = '')
80 80
 	{
81
-		global $globalDebug,$globalAircraftImageFetch;
81
+		global $globalDebug, $globalAircraftImageFetch;
82 82
 		if (isset($globalAircraftImageFetch) && !$globalAircraftImageFetch) return '';
83
-		$registration = filter_var($registration,FILTER_SANITIZE_STRING);
83
+		$registration = filter_var($registration, FILTER_SANITIZE_STRING);
84 84
 		$registration = trim($registration);
85 85
 		//getting the aircraft image
86 86
 		if ($globalDebug && $registration != '') echo 'Try to find an aircraft image for '.$registration.'...';
87 87
 		elseif ($globalDebug && $aircraft_icao != '') echo 'Try to find an aircraft image for '.$aircraft_icao.'...';
88 88
 		elseif ($globalDebug && $airline_icao != '') echo 'Try to find an aircraft image for '.$airline_icao.'...';
89 89
 		else return "success";
90
-		$image_url = $this->findAircraftImage($registration,$aircraft_icao,$airline_icao);
90
+		$image_url = $this->findAircraftImage($registration, $aircraft_icao, $airline_icao);
91 91
 		if ($registration == '' && $aircraft_icao != '') $registration = $aircraft_icao.$airline_icao;
92 92
 		if ($image_url['original'] != '') {
93 93
 			if ($globalDebug) echo 'Found !'."\n";
94
-			$query  = "INSERT INTO spotter_image (registration, image, image_thumbnail, image_copyright, image_source,image_source_website) VALUES (:registration,:image,:image_thumbnail,:copyright,:source,:source_website)";
94
+			$query = "INSERT INTO spotter_image (registration, image, image_thumbnail, image_copyright, image_source,image_source_website) VALUES (:registration,:image,:image_thumbnail,:copyright,:source,:source_website)";
95 95
 			try {
96 96
 				$sth = $this->db->prepare($query);
97
-				$sth->execute(array(':registration' => $registration,':image' => $image_url['original'],':image_thumbnail' => $image_url['thumbnail'], ':copyright' => $image_url['copyright'],':source' => $image_url['source'],':source_website' => $image_url['source_website']));
98
-			} catch(PDOException $e) {
97
+				$sth->execute(array(':registration' => $registration, ':image' => $image_url['original'], ':image_thumbnail' => $image_url['thumbnail'], ':copyright' => $image_url['copyright'], ':source' => $image_url['source'], ':source_website' => $image_url['source_website']));
98
+			} catch (PDOException $e) {
99 99
 				echo $e->getMessage()."\n";
100 100
 				return "error";
101 101
 			}
@@ -115,9 +115,9 @@  discard block
 block discarded – undo
115 115
 		global $globalAircraftImageSources, $globalIVAO, $globalAircraftImageCheckICAO;
116 116
 		$Spotter = new Spotter($this->db);
117 117
 		if (!isset($globalIVAO)) $globalIVAO = FALSE;
118
-		$aircraft_registration = filter_var($aircraft_registration,FILTER_SANITIZE_STRING);
118
+		$aircraft_registration = filter_var($aircraft_registration, FILTER_SANITIZE_STRING);
119 119
 		if ($aircraft_registration != '') {
120
-			if (strpos($aircraft_registration,'/') !== false) return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => '');
120
+			if (strpos($aircraft_registration, '/') !== false) return array('thumbnail' => '', 'original' => '', 'copyright' => '', 'source' => '', 'source_website' => '');
121 121
 			$aircraft_registration = urlencode(trim($aircraft_registration));
122 122
 			$aircraft_info = $Spotter->getAircraftInfoByRegistration($aircraft_registration);
123 123
 			if (isset($aircraft_info[0]['aircraft_name'])) $aircraft_name = $aircraft_info[0]['aircraft_name'];
@@ -131,24 +131,24 @@  discard block
 block discarded – undo
131 131
 			if (isset($aircraft_info[0]['type'])) $aircraft_name = $aircraft_info[0]['type'];
132 132
 			else $aircraft_name = '';
133 133
 			$aircraft_registration = $aircraft_icao;
134
-		} else return array('thumbnail' => '','original' => '', 'copyright' => '', 'source' => '','source_website' => '');
135
-		if (!isset($globalAircraftImageSources)) $globalAircraftImageSources = array('ivaomtl','wikimedia','airportdata','deviantart','flickr','bing','jetphotos','planepictures','planespotters');
134
+		} else return array('thumbnail' => '', 'original' => '', 'copyright' => '', 'source' => '', 'source_website' => '');
135
+		if (!isset($globalAircraftImageSources)) $globalAircraftImageSources = array('ivaomtl', 'wikimedia', 'airportdata', 'deviantart', 'flickr', 'bing', 'jetphotos', 'planepictures', 'planespotters');
136 136
 		foreach ($globalAircraftImageSources as $source) {
137 137
 			$source = strtolower($source);
138
-			if ($source == 'ivaomtl' && $globalIVAO && $aircraft_icao != '' && $airline_icao != '') $images_array = $this->fromIvaoMtl($aircraft_icao,$airline_icao);
139
-			if ($source == 'planespotters' && !$globalIVAO) $images_array = $this->fromPlanespotters($aircraft_registration,$aircraft_name);
140
-			if ($source == 'flickr') $images_array = $this->fromFlickr($aircraft_registration,$aircraft_name);
141
-			if ($source == 'bing') $images_array = $this->fromBing($aircraft_registration,$aircraft_name);
142
-			if ($source == 'deviantart') $images_array = $this->fromDeviantart($aircraft_registration,$aircraft_name);
143
-			if ($source == 'wikimedia') $images_array = $this->fromWikimedia($aircraft_registration,$aircraft_name);
144
-			if ($source == 'jetphotos' && !$globalIVAO) $images_array = $this->fromJetPhotos($aircraft_registration,$aircraft_name);
145
-			if ($source == 'planepictures' && !$globalIVAO) $images_array = $this->fromPlanePictures($aircraft_registration,$aircraft_name);
146
-			if ($source == 'airportdata' && !$globalIVAO) $images_array = $this->fromAirportData($aircraft_registration,$aircraft_name);
147
-			if ($source == 'customsources') $images_array = $this->fromCustomSource($aircraft_registration,$aircraft_name);
138
+			if ($source == 'ivaomtl' && $globalIVAO && $aircraft_icao != '' && $airline_icao != '') $images_array = $this->fromIvaoMtl($aircraft_icao, $airline_icao);
139
+			if ($source == 'planespotters' && !$globalIVAO) $images_array = $this->fromPlanespotters($aircraft_registration, $aircraft_name);
140
+			if ($source == 'flickr') $images_array = $this->fromFlickr($aircraft_registration, $aircraft_name);
141
+			if ($source == 'bing') $images_array = $this->fromBing($aircraft_registration, $aircraft_name);
142
+			if ($source == 'deviantart') $images_array = $this->fromDeviantart($aircraft_registration, $aircraft_name);
143
+			if ($source == 'wikimedia') $images_array = $this->fromWikimedia($aircraft_registration, $aircraft_name);
144
+			if ($source == 'jetphotos' && !$globalIVAO) $images_array = $this->fromJetPhotos($aircraft_registration, $aircraft_name);
145
+			if ($source == 'planepictures' && !$globalIVAO) $images_array = $this->fromPlanePictures($aircraft_registration, $aircraft_name);
146
+			if ($source == 'airportdata' && !$globalIVAO) $images_array = $this->fromAirportData($aircraft_registration, $aircraft_name);
147
+			if ($source == 'customsources') $images_array = $this->fromCustomSource($aircraft_registration, $aircraft_name);
148 148
 			if (isset($images_array) && $images_array['original'] != '') return $images_array;
149 149
 		}
150 150
 		if ((!isset($globalAircraftImageCheckICAO) || $globalAircraftImageCheckICAO === TRUE) && isset($aircraft_icao)) return $this->findAircraftImage($aircraft_icao);
151
-		return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => '');
151
+		return array('thumbnail' => '', 'original' => '', 'copyright' => '', 'source' => '', 'source_website' => '');
152 152
 	}
153 153
 
154 154
 	/**
@@ -159,24 +159,24 @@  discard block
 block discarded – undo
159 159
 	* @return Array the aircraft thumbnail, orignal url and copyright
160 160
 	*
161 161
 	*/
162
-	public function fromPlanespotters($aircraft_registration, $aircraft_name='') {
162
+	public function fromPlanespotters($aircraft_registration, $aircraft_name = '') {
163 163
 		$Common = new Common();
164 164
 		// If aircraft registration is only number, also check with aircraft model
165
-		if (preg_match('/^[[:digit]]+$/',$aircraft_registration) && $aircraft_name != '') {
166
-			$url= 'http://www.planespotters.net/Aviation_Photos/search.php?tag='.$aircraft_registration.'&actype=s_'.urlencode($aircraft_name).'&output=rss';
165
+		if (preg_match('/^[[:digit]]+$/', $aircraft_registration) && $aircraft_name != '') {
166
+			$url = 'http://www.planespotters.net/Aviation_Photos/search.php?tag='.$aircraft_registration.'&actype=s_'.urlencode($aircraft_name).'&output=rss';
167 167
 		} else {
168 168
 			//$url= 'http://www.planespotters.net/Aviation_Photos/search.php?tag='.$airline_aircraft_type.'&output=rss';
169
-			$url= 'http://www.planespotters.net/Aviation_Photos/search.php?reg='.$aircraft_registration.'&output=rss';
169
+			$url = 'http://www.planespotters.net/Aviation_Photos/search.php?reg='.$aircraft_registration.'&output=rss';
170 170
 		}
171 171
 		$data = $Common->getData($url);
172 172
 		if ($xml = simplexml_load_string($data)) {
173 173
 			if (isset($xml->channel->item)) {
174 174
 				$image_url = array();
175
-				$thumbnail_url = trim((string)$xml->channel->item->children('http://search.yahoo.com/mrss/')->thumbnail->attributes()->url);
175
+				$thumbnail_url = trim((string) $xml->channel->item->children('http://search.yahoo.com/mrss/')->thumbnail->attributes()->url);
176 176
 				$image_url['thumbnail'] = $thumbnail_url;
177
-				$image_url['original'] = str_replace('thumbnail','original',$thumbnail_url);
178
-				$image_url['copyright'] = trim((string)$xml->channel->item->children('http://search.yahoo.com/mrss/')->copyright);
179
-				$image_url['source_website'] = trim((string)$xml->channel->item->link);
177
+				$image_url['original'] = str_replace('thumbnail', 'original', $thumbnail_url);
178
+				$image_url['copyright'] = trim((string) $xml->channel->item->children('http://search.yahoo.com/mrss/')->copyright);
179
+				$image_url['source_website'] = trim((string) $xml->channel->item->link);
180 180
 				$image_url['source'] = 'planespotters';
181 181
 				return $image_url;
182 182
 			}
@@ -192,25 +192,25 @@  discard block
 block discarded – undo
192 192
 	* @return Array the aircraft thumbnail, orignal url and copyright
193 193
 	*
194 194
 	*/
195
-	public function fromDeviantart($aircraft_registration, $aircraft_name='') {
195
+	public function fromDeviantart($aircraft_registration, $aircraft_name = '') {
196 196
 		$Common = new Common();
197 197
 		// If aircraft registration is only number, also check with aircraft model
198
-		if (preg_match('/^[[:digit]]+$/',$aircraft_registration) && $aircraft_name != '') {
199
-			$url= 'http://backend.deviantart.com/rss.xml?type=deviation&q='.$aircraft_registration.'%20'.urlencode($aircraft_name);
198
+		if (preg_match('/^[[:digit]]+$/', $aircraft_registration) && $aircraft_name != '') {
199
+			$url = 'http://backend.deviantart.com/rss.xml?type=deviation&q='.$aircraft_registration.'%20'.urlencode($aircraft_name);
200 200
 		} else {
201
-			$url= 'http://backend.deviantart.com/rss.xml?type=deviation&q=aircraft%20'.$aircraft_registration;
201
+			$url = 'http://backend.deviantart.com/rss.xml?type=deviation&q=aircraft%20'.$aircraft_registration;
202 202
 		}
203 203
 
204 204
 		$data = $Common->getData($url);
205 205
 		if ($xml = simplexml_load_string($data)) {
206 206
 			if (isset($xml->channel->item->link)) {
207 207
 				$image_url = array();
208
-				$thumbnail_url = trim((string)$xml->channel->item->children('http://search.yahoo.com/mrss/')->thumbnail->attributes()->url);
208
+				$thumbnail_url = trim((string) $xml->channel->item->children('http://search.yahoo.com/mrss/')->thumbnail->attributes()->url);
209 209
 				$image_url['thumbnail'] = $thumbnail_url;
210
-				$original_url = trim((string)$xml->channel->item->children('http://search.yahoo.com/mrss/')->content->attributes()->url);
210
+				$original_url = trim((string) $xml->channel->item->children('http://search.yahoo.com/mrss/')->content->attributes()->url);
211 211
 				$image_url['original'] = $original_url;
212
-				$image_url['copyright'] = str_replace('Copyright ','',trim((string)$xml->channel->item->children('http://search.yahoo.com/mrss/')->copyright));
213
-				$image_url['source_website'] = trim((string)$xml->channel->item->link);
212
+				$image_url['copyright'] = str_replace('Copyright ', '', trim((string) $xml->channel->item->children('http://search.yahoo.com/mrss/')->copyright));
213
+				$image_url['source_website'] = trim((string) $xml->channel->item->link);
214 214
 				$image_url['source'] = 'deviantart';
215 215
 				return $image_url;
216 216
 			}
@@ -226,32 +226,32 @@  discard block
 block discarded – undo
226 226
 	* @return Array the aircraft thumbnail, orignal url and copyright
227 227
 	*
228 228
 	*/
229
-	public function fromJetPhotos($aircraft_registration, $aircraft_name='') {
229
+	public function fromJetPhotos($aircraft_registration, $aircraft_name = '') {
230 230
 		$Common = new Common();
231
-		$url= 'http://jetphotos.net/showphotos.php?displaymode=2&regsearch='.$aircraft_registration;
231
+		$url = 'http://jetphotos.net/showphotos.php?displaymode=2&regsearch='.$aircraft_registration;
232 232
 		$data = $Common->getData($url);
233 233
 		$dom = new DOMDocument();
234 234
 		@$dom->loadHTML($data);
235 235
 		$all_pics = array();
236
-		foreach($dom->getElementsByTagName('img') as $image) {
236
+		foreach ($dom->getElementsByTagName('img') as $image) {
237 237
 			if ($image->getAttribute('itemprop') == "http://schema.org/image") {
238 238
 				$all_pics[] = $image->getAttribute('src');
239 239
 			}
240 240
 		}
241 241
 		$all_authors = array();
242
-		foreach($dom->getElementsByTagName('meta') as $author) {
242
+		foreach ($dom->getElementsByTagName('meta') as $author) {
243 243
 			if ($author->getAttribute('itemprop') == "http://schema.org/author") {
244 244
 				$all_authors[] = $author->getAttribute('content');
245 245
 			}
246 246
 		}
247 247
 		$all_ref = array();
248
-		foreach($dom->getElementsByTagName('a') as $link) {
248
+		foreach ($dom->getElementsByTagName('a') as $link) {
249 249
 			$all_ref[] = $link->getAttribute('href');
250 250
 		}
251 251
 		if (isset($all_pics[0])) {
252 252
 			$image_url = array();
253 253
 			$image_url['thumbnail'] = $all_pics[0];
254
-			$image_url['original'] = str_replace('_tb','',$all_pics[0]);
254
+			$image_url['original'] = str_replace('_tb', '', $all_pics[0]);
255 255
 			$image_url['copyright'] = $all_authors[0];
256 256
 			$image_url['source_website'] = 'http://jetphotos.net'.$all_ref[8];
257 257
 			$image_url['source'] = 'JetPhotos';
@@ -268,24 +268,24 @@  discard block
 block discarded – undo
268 268
 	* @return Array the aircraft thumbnail, orignal url and copyright
269 269
 	*
270 270
 	*/
271
-	public function fromPlanePictures($aircraft_registration, $aircraft_name='') {
271
+	public function fromPlanePictures($aircraft_registration, $aircraft_name = '') {
272 272
 		$Common = new Common();
273
-		$url= 'http://www.planepictures.net/netsearch4.cgi?srch='.$aircraft_registration.'&stype=reg&srng=2';
273
+		$url = 'http://www.planepictures.net/netsearch4.cgi?srch='.$aircraft_registration.'&stype=reg&srng=2';
274 274
 		$data = $Common->getData($url);
275 275
 		$dom = new DOMDocument();
276 276
 		@$dom->loadHTML($data);
277 277
 		$all_pics = array();
278
-		foreach($dom->getElementsByTagName('img') as $image) {
278
+		foreach ($dom->getElementsByTagName('img') as $image) {
279 279
 			$all_pics[] = $image->getAttribute('src');
280 280
 		}
281 281
 		$all_links = array();
282
-		foreach($dom->getElementsByTagName('a') as $link) {
283
-			$all_links[] = array('text' => $link->textContent,'href' => $link->getAttribute('href'));
282
+		foreach ($dom->getElementsByTagName('a') as $link) {
283
+			$all_links[] = array('text' => $link->textContent, 'href' => $link->getAttribute('href'));
284 284
 		}
285
-		if (isset($all_pics[1]) && !preg_match('/bit.ly/',$all_pics[1])) {
285
+		if (isset($all_pics[1]) && !preg_match('/bit.ly/', $all_pics[1])) {
286 286
 			$image_url = array();
287 287
 			$image_url['thumbnail'] = 'http://www.planepictures.net'.$all_pics[1];
288
-			$image_url['original'] = 'http://www.planepictures.net'.str_replace('_TN','',$all_pics[1]);
288
+			$image_url['original'] = 'http://www.planepictures.net'.str_replace('_TN', '', $all_pics[1]);
289 289
 			$image_url['copyright'] = $all_links[6]['text'];
290 290
 			$image_url['source_website'] = 'http://www.planepictures.net/'.$all_links[2]['href'];
291 291
 			$image_url['source'] = 'PlanePictures';
@@ -302,19 +302,19 @@  discard block
 block discarded – undo
302 302
 	* @return Array the aircraft thumbnail, orignal url and copyright
303 303
 	*
304 304
 	*/
305
-	public function fromFlickr($aircraft_registration,$aircraft_name='') {
305
+	public function fromFlickr($aircraft_registration, $aircraft_name = '') {
306 306
 		$Common = new Common();
307 307
 		if ($aircraft_name != '') $url = 'https://api.flickr.com/services/feeds/photos_public.gne?format=rss2&license=1,2,3,4,5,6,7&per_page=1&tags='.$aircraft_registration.','.urlencode($aircraft_name);
308 308
 		else $url = 'https://api.flickr.com/services/feeds/photos_public.gne?format=rss2&license=1,2,3,4,5,6,7&per_page=1&tags='.$aircraft_registration.',aircraft';
309 309
 		$data = $Common->getData($url);
310 310
 		if ($xml = simplexml_load_string($data)) {
311 311
 			if (isset($xml->channel->item)) {
312
-				$original_url = trim((string)$xml->channel->item->enclosure->attributes()->url);
312
+				$original_url = trim((string) $xml->channel->item->enclosure->attributes()->url);
313 313
 				$image_url = array();
314 314
 				$image_url['thumbnail'] = $original_url;
315 315
 				$image_url['original'] = $original_url;
316
-				$image_url['copyright'] = trim((string)$xml->channel->item->children('http://search.yahoo.com/mrss/')->credit);
317
-				$image_url['source_website'] = trim((string)$xml->channel->item->link);
316
+				$image_url['copyright'] = trim((string) $xml->channel->item->children('http://search.yahoo.com/mrss/')->credit);
317
+				$image_url['source_website'] = trim((string) $xml->channel->item->link);
318 318
 				$image_url['source'] = 'flickr';
319 319
 				return $image_url;
320 320
 			}
@@ -322,7 +322,7 @@  discard block
 block discarded – undo
322 322
 		return false;
323 323
 	}
324 324
 
325
-	public function fromIvaoMtl($aircraft_icao,$airline_icao) {
325
+	public function fromIvaoMtl($aircraft_icao, $airline_icao) {
326 326
 		$Common = new Common();
327 327
 		//echo "\n".'SEARCH IMAGE : http://mtlcatalog.ivao.aero/images/aircraft/'.$aircraft_icao.$airline_icao.'.jpg';
328 328
 		if ($Common->urlexist('http://mtlcatalog.ivao.aero/images/aircraft/'.$aircraft_icao.$airline_icao.'.jpg')) {
@@ -346,14 +346,14 @@  discard block
 block discarded – undo
346 346
 	* @return Array the aircraft thumbnail, orignal url and copyright
347 347
 	*
348 348
 	*/
349
-	public function fromBing($aircraft_registration,$aircraft_name='') {
349
+	public function fromBing($aircraft_registration, $aircraft_name = '') {
350 350
 		global $globalImageBingKey;
351 351
 		$Common = new Common();
352 352
 		if (!isset($globalImageBingKey) || $globalImageBingKey == '') return false;
353 353
 		if ($aircraft_name != '') $url = 'https://api.datamarket.azure.com/Bing/Search/v1/Image?$format=json&$top=1&Query=%27'.$aircraft_registration.'%20'.urlencode($aircraft_name).'%20-site:planespotters.com%20-site:flickr.com%27';
354 354
 		else $url = 'https://api.datamarket.azure.com/Bing/Search/v1/Image?$format=json&$top=1&Query=%27%2B'.$aircraft_registration.'%20%2Baircraft%20-site:planespotters.com%20-site:flickr.com%27';
355
-		$headers = array("Authorization: Basic " . base64_encode("ignored:".$globalImageBingKey));
356
-		$data = $Common->getData($url,'get','',$headers);
355
+		$headers = array("Authorization: Basic ".base64_encode("ignored:".$globalImageBingKey));
356
+		$data = $Common->getData($url, 'get', '', $headers);
357 357
 		$result = json_decode($data);
358 358
 		if (isset($result->d->results[0]->MediaUrl)) {
359 359
 			$image_url = array();
@@ -378,14 +378,14 @@  discard block
 block discarded – undo
378 378
 	* @return Array the aircraft thumbnail, orignal url and copyright
379 379
 	*
380 380
 	*/
381
-	public function fromAirportData($aircraft_registration,$aircraft_name='') {
381
+	public function fromAirportData($aircraft_registration, $aircraft_name = '') {
382 382
 		$Common = new Common();
383 383
 		$url = 'http://www.airport-data.com/api/ac_thumb.json?&n=1&r='.$aircraft_registration;
384 384
 		$data = $Common->getData($url);
385 385
 		$result = json_decode($data);
386 386
 		if (isset($result->count) && $result->count > 0) {
387 387
 			$image_url = array();
388
-			$image_url['original'] = str_replace('thumbnails','large',$result->data[0]->image);
388
+			$image_url['original'] = str_replace('thumbnails', 'large', $result->data[0]->image);
389 389
 			$image_url['source_website'] = $result->data[0]->link;
390 390
 			$image_url['thumbnail'] = $result->data[0]->image;
391 391
 			$image_url['copyright'] = $result->data[0]->photographer;
@@ -403,7 +403,7 @@  discard block
 block discarded – undo
403 403
 	* @return Array the aircraft thumbnail, orignal url and copyright
404 404
 	*
405 405
 	*/
406
-	public function fromWikimedia($aircraft_registration,$aircraft_name='') {
406
+	public function fromWikimedia($aircraft_registration, $aircraft_name = '') {
407 407
 		$Common = new Common();
408 408
 		if ($aircraft_name != '') $url = 'https://commons.wikimedia.org/w/api.php?action=query&list=search&format=json&srlimit=1&srnamespace=6&continue&srsearch="'.$aircraft_registration.'"%20'.urlencode($aircraft_name);
409 409
 		else $url = 'https://commons.wikimedia.org/w/api.php?action=query&list=search&format=json&srlimit=1&srnamespace=6&continue&srsearch="'.$aircraft_registration.'"%20aircraft';
@@ -411,7 +411,7 @@  discard block
 block discarded – undo
411 411
 		$result = json_decode($data);
412 412
 		if (isset($result->query->search[0]->title)) {
413 413
 			$fileo = $result->query->search[0]->title;
414
-			if (substr($fileo,-3) == 'pdf') return false;
414
+			if (substr($fileo, -3) == 'pdf') return false;
415 415
 			$file = urlencode($fileo);
416 416
 			$url2 = 'https://commons.wikimedia.org/w/api.php?action=query&format=json&continue&iilimit=500&prop=imageinfo&iiprop=user|url|size|mime|sha1|timestamp&iiurlwidth=200%27&titles='.$file;
417 417
 			$data2 = $Common->getData($url2);
@@ -436,11 +436,11 @@  discard block
 block discarded – undo
436 436
 				if (isset($result2->query->pages)) {
437 437
 					foreach ($result2->query->pages as $page) {
438 438
 						if (isset($page->imageinfo[0]->extmetadata->Artist)) {
439
-							$image_url['copyright'] = preg_replace('/ from(.*)/','',strip_tags($page->imageinfo[0]->extmetadata->Artist->value));
439
+							$image_url['copyright'] = preg_replace('/ from(.*)/', '', strip_tags($page->imageinfo[0]->extmetadata->Artist->value));
440 440
 							if (isset($page->imageinfo[0]->extmetadata->License->value)) {
441 441
 								$image_url['copyright'] = $image_url['copyright'].' (under '.$page->imageinfo[0]->extmetadata->License->value.')';
442 442
 							}
443
-							$image_url['copyright'] = trim(str_replace('\n','',$image_url['copyright']));
443
+							$image_url['copyright'] = trim(str_replace('\n', '', $image_url['copyright']));
444 444
 							return $image_url;
445 445
 						}
446 446
 					}
@@ -459,7 +459,7 @@  discard block
 block discarded – undo
459 459
 	* @return Array the aircraft thumbnail, orignal url and copyright
460 460
 	*
461 461
 	*/
462
-	public function fromCustomSource($aircraft_registration,$aircraft_name='') {
462
+	public function fromCustomSource($aircraft_registration, $aircraft_name = '') {
463 463
 		global $globalAircraftImageCustomSources, $globalDebug;
464 464
 		//$globalAircraftImageCustomSource[] = array('thumbnail' => '','original' => '', 'copyright' => '', 'source_website' => '', 'source' => '','exif' => true);
465 465
 		if (!empty($globalAircraftImageCustomSources)) {
@@ -476,15 +476,15 @@  discard block
 block discarded – undo
476 476
 					print_r($source);
477 477
 					print_r($customsources);
478 478
 				}
479
-				$url = str_replace('{registration}',$aircraft_registration,$source['original']);
480
-				$url_thumbnail = str_replace('{registration}',$aircraft_registration,$source['thumbnail']);
479
+				$url = str_replace('{registration}', $aircraft_registration, $source['original']);
480
+				$url_thumbnail = str_replace('{registration}', $aircraft_registration, $source['thumbnail']);
481 481
 				if ($Common->urlexist($url)) {
482 482
 					$image_url = array();
483 483
 					$image_url['thumbnail'] = $url_thumbnail;
484 484
 					$image_url['original'] = $url;
485 485
 					if ($source['exif'] && exif_imagetype($url) == IMAGETYPE_JPEG) $exifCopyright = $this->getExifCopyright($url);
486 486
 					else $exifCopyright = '';
487
-					if ($exifCopyright  != '') $image_url['copyright'] = $exifCopyright;
487
+					if ($exifCopyright != '') $image_url['copyright'] = $exifCopyright;
488 488
 					elseif (isset($source['copyright'])) $image_url['copyright'] = $source['copyright'];
489 489
 					else $image_url['copyright'] = $source['source_website'];
490 490
 					$image_url['source_website'] = $source['source_website'];
Please login to merge, or discard this patch.