@@ -12,11 +12,11 @@ discard block |
||
12 | 12 | } |
13 | 13 | |
14 | 14 | /** |
15 | - * Gets the images based on the aircraft registration |
|
16 | - * |
|
17 | - * @return Array the images list |
|
18 | - * |
|
19 | - */ |
|
15 | + * Gets the images based on the aircraft registration |
|
16 | + * |
|
17 | + * @return Array the images list |
|
18 | + * |
|
19 | + */ |
|
20 | 20 | public function getSpotterImage($registration,$aircraft_icao = '', $airline_icao = '') |
21 | 21 | { |
22 | 22 | $registration = filter_var($registration,FILTER_SANITIZE_STRING); |
@@ -29,7 +29,7 @@ discard block |
||
29 | 29 | WHERE spotter_image.registration = :registration"; |
30 | 30 | $sth = $this->db->prepare($query); |
31 | 31 | $sth->execute(array(':registration' => $registration)); |
32 | - /* |
|
32 | + /* |
|
33 | 33 | $images_array = array(); |
34 | 34 | $temp_array = array(); |
35 | 35 | |
@@ -52,11 +52,11 @@ discard block |
||
52 | 52 | } |
53 | 53 | |
54 | 54 | /** |
55 | - * Gets the image copyright based on the Exif data |
|
56 | - * |
|
57 | - * @return String image copyright |
|
58 | - * |
|
59 | - */ |
|
55 | + * Gets the image copyright based on the Exif data |
|
56 | + * |
|
57 | + * @return String image copyright |
|
58 | + * |
|
59 | + */ |
|
60 | 60 | public function getExifCopyright($url) { |
61 | 61 | $exif = exif_read_data($url); |
62 | 62 | $copyright = ''; |
@@ -71,11 +71,11 @@ discard block |
||
71 | 71 | } |
72 | 72 | |
73 | 73 | /** |
74 | - * Adds the images based on the aircraft registration |
|
75 | - * |
|
76 | - * @return String either success or error |
|
77 | - * |
|
78 | - */ |
|
74 | + * Adds the images based on the aircraft registration |
|
75 | + * |
|
76 | + * @return String either success or error |
|
77 | + * |
|
78 | + */ |
|
79 | 79 | public function addSpotterImage($registration,$aircraft_icao = '', $airline_icao = '') |
80 | 80 | { |
81 | 81 | global $globalDebug,$globalAircraftImageFetch; |
@@ -104,12 +104,12 @@ discard block |
||
104 | 104 | } |
105 | 105 | |
106 | 106 | /** |
107 | - * Gets the aircraft image |
|
108 | - * |
|
109 | - * @param String $aircraft_registration the registration of the aircraft |
|
110 | - * @return Array the aircraft thumbnail, orignal url and copyright |
|
111 | - * |
|
112 | - */ |
|
107 | + * Gets the aircraft image |
|
108 | + * |
|
109 | + * @param String $aircraft_registration the registration of the aircraft |
|
110 | + * @return Array the aircraft thumbnail, orignal url and copyright |
|
111 | + * |
|
112 | + */ |
|
113 | 113 | public function findAircraftImage($aircraft_registration, $aircraft_icao = '', $airline_icao = '') |
114 | 114 | { |
115 | 115 | global $globalAircraftImageSources, $globalIVAO, $globalAircraftImageCheckICAO; |
@@ -152,13 +152,13 @@ discard block |
||
152 | 152 | } |
153 | 153 | |
154 | 154 | /** |
155 | - * Gets the aircraft image from Planespotters |
|
156 | - * |
|
157 | - * @param String $aircraft_registration the registration of the aircraft |
|
158 | - * @param String $aircraft_name type of the aircraft |
|
159 | - * @return Array the aircraft thumbnail, orignal url and copyright |
|
160 | - * |
|
161 | - */ |
|
155 | + * Gets the aircraft image from Planespotters |
|
156 | + * |
|
157 | + * @param String $aircraft_registration the registration of the aircraft |
|
158 | + * @param String $aircraft_name type of the aircraft |
|
159 | + * @return Array the aircraft thumbnail, orignal url and copyright |
|
160 | + * |
|
161 | + */ |
|
162 | 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 |
@@ -185,13 +185,13 @@ discard block |
||
185 | 185 | } |
186 | 186 | |
187 | 187 | /** |
188 | - * Gets the aircraft image from Deviantart |
|
189 | - * |
|
190 | - * @param String $aircraft_registration the registration of the aircraft |
|
191 | - * @param String $aircraft_name type of the aircraft |
|
192 | - * @return Array the aircraft thumbnail, orignal url and copyright |
|
193 | - * |
|
194 | - */ |
|
188 | + * Gets the aircraft image from Deviantart |
|
189 | + * |
|
190 | + * @param String $aircraft_registration the registration of the aircraft |
|
191 | + * @param String $aircraft_name type of the aircraft |
|
192 | + * @return Array the aircraft thumbnail, orignal url and copyright |
|
193 | + * |
|
194 | + */ |
|
195 | 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 |
@@ -219,13 +219,13 @@ discard block |
||
219 | 219 | } |
220 | 220 | |
221 | 221 | /** |
222 | - * Gets the aircraft image from JetPhotos |
|
223 | - * |
|
224 | - * @param String $aircraft_registration the registration of the aircraft |
|
225 | - * @param String $aircraft_name type of the aircraft |
|
226 | - * @return Array the aircraft thumbnail, orignal url and copyright |
|
227 | - * |
|
228 | - */ |
|
222 | + * Gets the aircraft image from JetPhotos |
|
223 | + * |
|
224 | + * @param String $aircraft_registration the registration of the aircraft |
|
225 | + * @param String $aircraft_name type of the aircraft |
|
226 | + * @return Array the aircraft thumbnail, orignal url and copyright |
|
227 | + * |
|
228 | + */ |
|
229 | 229 | public function fromJetPhotos($aircraft_registration, $aircraft_name='') { |
230 | 230 | $Common = new Common(); |
231 | 231 | $url= 'http://jetphotos.net/showphotos.php?displaymode=2®search='.$aircraft_registration; |
@@ -261,13 +261,13 @@ discard block |
||
261 | 261 | } |
262 | 262 | |
263 | 263 | /** |
264 | - * Gets the aircraft image from PlanePictures |
|
265 | - * |
|
266 | - * @param String $aircraft_registration the registration of the aircraft |
|
267 | - * @param String $aircraft_name type of the aircraft |
|
268 | - * @return Array the aircraft thumbnail, orignal url and copyright |
|
269 | - * |
|
270 | - */ |
|
264 | + * Gets the aircraft image from PlanePictures |
|
265 | + * |
|
266 | + * @param String $aircraft_registration the registration of the aircraft |
|
267 | + * @param String $aircraft_name type of the aircraft |
|
268 | + * @return Array the aircraft thumbnail, orignal url and copyright |
|
269 | + * |
|
270 | + */ |
|
271 | 271 | public function fromPlanePictures($aircraft_registration, $aircraft_name='') { |
272 | 272 | $Common = new Common(); |
273 | 273 | $url= 'http://www.planepictures.net/netsearch4.cgi?srch='.$aircraft_registration.'&stype=reg&srng=2'; |
@@ -295,13 +295,13 @@ discard block |
||
295 | 295 | } |
296 | 296 | |
297 | 297 | /** |
298 | - * Gets the aircraft image from Flickr |
|
299 | - * |
|
300 | - * @param String $aircraft_registration the registration of the aircraft |
|
301 | - * @param String $aircraft_name type of the aircraft |
|
302 | - * @return Array the aircraft thumbnail, orignal url and copyright |
|
303 | - * |
|
304 | - */ |
|
298 | + * Gets the aircraft image from Flickr |
|
299 | + * |
|
300 | + * @param String $aircraft_registration the registration of the aircraft |
|
301 | + * @param String $aircraft_name type of the aircraft |
|
302 | + * @return Array the aircraft thumbnail, orignal url and copyright |
|
303 | + * |
|
304 | + */ |
|
305 | 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); |
@@ -339,13 +339,13 @@ discard block |
||
339 | 339 | } |
340 | 340 | |
341 | 341 | /** |
342 | - * Gets the aircraft image from Bing |
|
343 | - * |
|
344 | - * @param String $aircraft_registration the registration of the aircraft |
|
345 | - * @param String $aircraft_name type of the aircraft |
|
346 | - * @return Array the aircraft thumbnail, orignal url and copyright |
|
347 | - * |
|
348 | - */ |
|
342 | + * Gets the aircraft image from Bing |
|
343 | + * |
|
344 | + * @param String $aircraft_registration the registration of the aircraft |
|
345 | + * @param String $aircraft_name type of the aircraft |
|
346 | + * @return Array the aircraft thumbnail, orignal url and copyright |
|
347 | + * |
|
348 | + */ |
|
349 | 349 | public function fromBing($aircraft_registration,$aircraft_name='') { |
350 | 350 | global $globalImageBingKey; |
351 | 351 | $Common = new Common(); |
@@ -371,13 +371,13 @@ discard block |
||
371 | 371 | } |
372 | 372 | |
373 | 373 | /** |
374 | - * Gets the aircraft image from airport-data |
|
375 | - * |
|
376 | - * @param String $aircraft_registration the registration of the aircraft |
|
377 | - * @param String $aircraft_name type of the aircraft |
|
378 | - * @return Array the aircraft thumbnail, orignal url and copyright |
|
379 | - * |
|
380 | - */ |
|
374 | + * Gets the aircraft image from airport-data |
|
375 | + * |
|
376 | + * @param String $aircraft_registration the registration of the aircraft |
|
377 | + * @param String $aircraft_name type of the aircraft |
|
378 | + * @return Array the aircraft thumbnail, orignal url and copyright |
|
379 | + * |
|
380 | + */ |
|
381 | 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; |
@@ -396,13 +396,13 @@ discard block |
||
396 | 396 | } |
397 | 397 | |
398 | 398 | /** |
399 | - * Gets the aircraft image from WikiMedia |
|
400 | - * |
|
401 | - * @param String $aircraft_registration the registration of the aircraft |
|
402 | - * @param String $aircraft_name type of the aircraft |
|
403 | - * @return Array the aircraft thumbnail, orignal url and copyright |
|
404 | - * |
|
405 | - */ |
|
399 | + * Gets the aircraft image from WikiMedia |
|
400 | + * |
|
401 | + * @param String $aircraft_registration the registration of the aircraft |
|
402 | + * @param String $aircraft_name type of the aircraft |
|
403 | + * @return Array the aircraft thumbnail, orignal url and copyright |
|
404 | + * |
|
405 | + */ |
|
406 | 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); |
@@ -452,13 +452,13 @@ discard block |
||
452 | 452 | } |
453 | 453 | |
454 | 454 | /** |
455 | - * Gets the aircraft image from custom url |
|
456 | - * |
|
457 | - * @param String $aircraft_registration the registration of the aircraft |
|
458 | - * @param String $aircraft_name type of the aircraft |
|
459 | - * @return Array the aircraft thumbnail, orignal url and copyright |
|
460 | - * |
|
461 | - */ |
|
455 | + * Gets the aircraft image from custom url |
|
456 | + * |
|
457 | + * @param String $aircraft_registration the registration of the aircraft |
|
458 | + * @param String $aircraft_name type of the aircraft |
|
459 | + * @return Array the aircraft thumbnail, orignal url and copyright |
|
460 | + * |
|
461 | + */ |
|
462 | 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); |
@@ -17,14 +17,14 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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®search='.$aircraft_registration; |
|
231 | + $url = 'http://jetphotos.net/showphotos.php?displaymode=2®search='.$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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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']; |
@@ -22,7 +22,9 @@ discard block |
||
22 | 22 | $registration = filter_var($registration,FILTER_SANITIZE_STRING); |
23 | 23 | $aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING); |
24 | 24 | $airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING); |
25 | - if ($registration == '' && $aircraft_icao != '') $registration = $aircraft_icao.$airline_icao; |
|
25 | + if ($registration == '' && $aircraft_icao != '') { |
|
26 | + $registration = $aircraft_icao.$airline_icao; |
|
27 | + } |
|
26 | 28 | $registration = trim($registration); |
27 | 29 | $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 | 30 | FROM spotter_image |
@@ -60,8 +62,11 @@ discard block |
||
60 | 62 | public function getExifCopyright($url) { |
61 | 63 | $exif = exif_read_data($url); |
62 | 64 | $copyright = ''; |
63 | - if (isset($exif['COMPUTED']['copyright'])) $copyright = $exif['COMPUTED']['copyright']; |
|
64 | - elseif (isset($exif['copyright'])) $copyright = $exif['copyright']; |
|
65 | + if (isset($exif['COMPUTED']['copyright'])) { |
|
66 | + $copyright = $exif['COMPUTED']['copyright']; |
|
67 | + } elseif (isset($exif['copyright'])) { |
|
68 | + $copyright = $exif['copyright']; |
|
69 | + } |
|
65 | 70 | if ($copyright != '') { |
66 | 71 | $copyright = str_replace('Copyright ','',$copyright); |
67 | 72 | $copyright = str_replace('© ','',$copyright); |
@@ -79,18 +84,29 @@ discard block |
||
79 | 84 | public function addSpotterImage($registration,$aircraft_icao = '', $airline_icao = '') |
80 | 85 | { |
81 | 86 | global $globalDebug,$globalAircraftImageFetch; |
82 | - if (isset($globalAircraftImageFetch) && !$globalAircraftImageFetch) return ''; |
|
87 | + if (isset($globalAircraftImageFetch) && !$globalAircraftImageFetch) { |
|
88 | + return ''; |
|
89 | + } |
|
83 | 90 | $registration = filter_var($registration,FILTER_SANITIZE_STRING); |
84 | 91 | $registration = trim($registration); |
85 | 92 | //getting the aircraft image |
86 | - if ($globalDebug && $registration != '') echo 'Try to find an aircraft image for '.$registration.'...'; |
|
87 | - elseif ($globalDebug && $aircraft_icao != '') echo 'Try to find an aircraft image for '.$aircraft_icao.'...'; |
|
88 | - elseif ($globalDebug && $airline_icao != '') echo 'Try to find an aircraft image for '.$airline_icao.'...'; |
|
89 | - else return "success"; |
|
93 | + if ($globalDebug && $registration != '') { |
|
94 | + echo 'Try to find an aircraft image for '.$registration.'...'; |
|
95 | + } elseif ($globalDebug && $aircraft_icao != '') { |
|
96 | + echo 'Try to find an aircraft image for '.$aircraft_icao.'...'; |
|
97 | + } elseif ($globalDebug && $airline_icao != '') { |
|
98 | + echo 'Try to find an aircraft image for '.$airline_icao.'...'; |
|
99 | + } else { |
|
100 | + return "success"; |
|
101 | + } |
|
90 | 102 | $image_url = $this->findAircraftImage($registration,$aircraft_icao,$airline_icao); |
91 | - if ($registration == '' && $aircraft_icao != '') $registration = $aircraft_icao.$airline_icao; |
|
103 | + if ($registration == '' && $aircraft_icao != '') { |
|
104 | + $registration = $aircraft_icao.$airline_icao; |
|
105 | + } |
|
92 | 106 | if ($image_url['original'] != '') { |
93 | - if ($globalDebug) echo 'Found !'."\n"; |
|
107 | + if ($globalDebug) { |
|
108 | + echo 'Found !'."\n"; |
|
109 | + } |
|
94 | 110 | $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 | 111 | try { |
96 | 112 | $sth = $this->db->prepare($query); |
@@ -99,7 +115,9 @@ discard block |
||
99 | 115 | echo $e->getMessage()."\n"; |
100 | 116 | return "error"; |
101 | 117 | } |
102 | - } elseif ($globalDebug) echo "Not found :'(\n"; |
|
118 | + } elseif ($globalDebug) { |
|
119 | + echo "Not found :'(\n"; |
|
120 | + } |
|
103 | 121 | return "success"; |
104 | 122 | } |
105 | 123 | |
@@ -114,40 +132,84 @@ discard block |
||
114 | 132 | { |
115 | 133 | global $globalAircraftImageSources, $globalIVAO, $globalAircraftImageCheckICAO; |
116 | 134 | $Spotter = new Spotter($this->db); |
117 | - if (!isset($globalIVAO)) $globalIVAO = FALSE; |
|
135 | + if (!isset($globalIVAO)) { |
|
136 | + $globalIVAO = FALSE; |
|
137 | + } |
|
118 | 138 | $aircraft_registration = filter_var($aircraft_registration,FILTER_SANITIZE_STRING); |
119 | 139 | if ($aircraft_registration != '') { |
120 | - if (strpos($aircraft_registration,'/') !== false) return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => ''); |
|
140 | + if (strpos($aircraft_registration,'/') !== false) { |
|
141 | + return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => ''); |
|
142 | + } |
|
121 | 143 | $aircraft_registration = urlencode(trim($aircraft_registration)); |
122 | 144 | $aircraft_info = $Spotter->getAircraftInfoByRegistration($aircraft_registration); |
123 | - if (isset($aircraft_info[0]['aircraft_name'])) $aircraft_name = $aircraft_info[0]['aircraft_name']; |
|
124 | - else $aircraft_name = ''; |
|
125 | - if (isset($aircraft_info[0]['aircraft_icao'])) $aircraft_name = $aircraft_info[0]['aircraft_icao']; |
|
126 | - else $aircraft_icao = ''; |
|
127 | - if (isset($aircraft_info[0]['airline_icao'])) $airline_icao = $aircraft_info[0]['airline_icao']; |
|
128 | - else $airline_icao = ''; |
|
145 | + if (isset($aircraft_info[0]['aircraft_name'])) { |
|
146 | + $aircraft_name = $aircraft_info[0]['aircraft_name']; |
|
147 | + } else { |
|
148 | + $aircraft_name = ''; |
|
149 | + } |
|
150 | + if (isset($aircraft_info[0]['aircraft_icao'])) { |
|
151 | + $aircraft_name = $aircraft_info[0]['aircraft_icao']; |
|
152 | + } else { |
|
153 | + $aircraft_icao = ''; |
|
154 | + } |
|
155 | + if (isset($aircraft_info[0]['airline_icao'])) { |
|
156 | + $airline_icao = $aircraft_info[0]['airline_icao']; |
|
157 | + } else { |
|
158 | + $airline_icao = ''; |
|
159 | + } |
|
129 | 160 | } elseif ($aircraft_icao != '') { |
130 | 161 | $aircraft_info = $Spotter->getAllAircraftInfo($aircraft_icao); |
131 | - if (isset($aircraft_info[0]['type'])) $aircraft_name = $aircraft_info[0]['type']; |
|
132 | - else $aircraft_name = ''; |
|
162 | + if (isset($aircraft_info[0]['type'])) { |
|
163 | + $aircraft_name = $aircraft_info[0]['type']; |
|
164 | + } else { |
|
165 | + $aircraft_name = ''; |
|
166 | + } |
|
133 | 167 | $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'); |
|
168 | + } else { |
|
169 | + return array('thumbnail' => '','original' => '', 'copyright' => '', 'source' => '','source_website' => ''); |
|
170 | + } |
|
171 | + if (!isset($globalAircraftImageSources)) { |
|
172 | + $globalAircraftImageSources = array('ivaomtl','wikimedia','airportdata','deviantart','flickr','bing','jetphotos','planepictures','planespotters'); |
|
173 | + } |
|
136 | 174 | foreach ($globalAircraftImageSources as $source) { |
137 | 175 | $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); |
|
148 | - if (isset($images_array) && $images_array['original'] != '') return $images_array; |
|
176 | + if ($source == 'ivaomtl' && $globalIVAO && $aircraft_icao != '' && $airline_icao != '') { |
|
177 | + $images_array = $this->fromIvaoMtl($aircraft_icao,$airline_icao); |
|
178 | + } |
|
179 | + if ($source == 'planespotters' && !$globalIVAO) { |
|
180 | + $images_array = $this->fromPlanespotters($aircraft_registration,$aircraft_name); |
|
181 | + } |
|
182 | + if ($source == 'flickr') { |
|
183 | + $images_array = $this->fromFlickr($aircraft_registration,$aircraft_name); |
|
184 | + } |
|
185 | + if ($source == 'bing') { |
|
186 | + $images_array = $this->fromBing($aircraft_registration,$aircraft_name); |
|
187 | + } |
|
188 | + if ($source == 'deviantart') { |
|
189 | + $images_array = $this->fromDeviantart($aircraft_registration,$aircraft_name); |
|
190 | + } |
|
191 | + if ($source == 'wikimedia') { |
|
192 | + $images_array = $this->fromWikimedia($aircraft_registration,$aircraft_name); |
|
193 | + } |
|
194 | + if ($source == 'jetphotos' && !$globalIVAO) { |
|
195 | + $images_array = $this->fromJetPhotos($aircraft_registration,$aircraft_name); |
|
196 | + } |
|
197 | + if ($source == 'planepictures' && !$globalIVAO) { |
|
198 | + $images_array = $this->fromPlanePictures($aircraft_registration,$aircraft_name); |
|
199 | + } |
|
200 | + if ($source == 'airportdata' && !$globalIVAO) { |
|
201 | + $images_array = $this->fromAirportData($aircraft_registration,$aircraft_name); |
|
202 | + } |
|
203 | + if ($source == 'customsources') { |
|
204 | + $images_array = $this->fromCustomSource($aircraft_registration,$aircraft_name); |
|
205 | + } |
|
206 | + if (isset($images_array) && $images_array['original'] != '') { |
|
207 | + return $images_array; |
|
208 | + } |
|
209 | + } |
|
210 | + if ((!isset($globalAircraftImageCheckICAO) || $globalAircraftImageCheckICAO === TRUE) && isset($aircraft_icao)) { |
|
211 | + return $this->findAircraftImage($aircraft_icao); |
|
149 | 212 | } |
150 | - if ((!isset($globalAircraftImageCheckICAO) || $globalAircraftImageCheckICAO === TRUE) && isset($aircraft_icao)) return $this->findAircraftImage($aircraft_icao); |
|
151 | 213 | return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => ''); |
152 | 214 | } |
153 | 215 | |
@@ -304,8 +366,11 @@ discard block |
||
304 | 366 | */ |
305 | 367 | public function fromFlickr($aircraft_registration,$aircraft_name='') { |
306 | 368 | $Common = new Common(); |
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 | - 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'; |
|
369 | + if ($aircraft_name != '') { |
|
370 | + $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); |
|
371 | + } else { |
|
372 | + $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'; |
|
373 | + } |
|
309 | 374 | $data = $Common->getData($url); |
310 | 375 | if ($xml = simplexml_load_string($data)) { |
311 | 376 | if (isset($xml->channel->item)) { |
@@ -349,9 +414,14 @@ discard block |
||
349 | 414 | public function fromBing($aircraft_registration,$aircraft_name='') { |
350 | 415 | global $globalImageBingKey; |
351 | 416 | $Common = new Common(); |
352 | - if (!isset($globalImageBingKey) || $globalImageBingKey == '') return false; |
|
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 | - 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'; |
|
417 | + if (!isset($globalImageBingKey) || $globalImageBingKey == '') { |
|
418 | + return false; |
|
419 | + } |
|
420 | + if ($aircraft_name != '') { |
|
421 | + $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'; |
|
422 | + } else { |
|
423 | + $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'; |
|
424 | + } |
|
355 | 425 | $headers = array("Authorization: Basic " . base64_encode("ignored:".$globalImageBingKey)); |
356 | 426 | $data = $Common->getData($url,'get','',$headers); |
357 | 427 | $result = json_decode($data); |
@@ -405,13 +475,18 @@ discard block |
||
405 | 475 | */ |
406 | 476 | public function fromWikimedia($aircraft_registration,$aircraft_name='') { |
407 | 477 | $Common = new Common(); |
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 | - else $url = 'https://commons.wikimedia.org/w/api.php?action=query&list=search&format=json&srlimit=1&srnamespace=6&continue&srsearch="'.$aircraft_registration.'"%20aircraft'; |
|
478 | + if ($aircraft_name != '') { |
|
479 | + $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); |
|
480 | + } else { |
|
481 | + $url = 'https://commons.wikimedia.org/w/api.php?action=query&list=search&format=json&srlimit=1&srnamespace=6&continue&srsearch="'.$aircraft_registration.'"%20aircraft'; |
|
482 | + } |
|
410 | 483 | $data = $Common->getData($url); |
411 | 484 | $result = json_decode($data); |
412 | 485 | if (isset($result->query->search[0]->title)) { |
413 | 486 | $fileo = $result->query->search[0]->title; |
414 | - if (substr($fileo,-3) == 'pdf') return false; |
|
487 | + if (substr($fileo,-3) == 'pdf') { |
|
488 | + return false; |
|
489 | + } |
|
415 | 490 | $file = urlencode($fileo); |
416 | 491 | $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 | 492 | $data2 = $Common->getData($url2); |
@@ -482,18 +557,27 @@ discard block |
||
482 | 557 | $image_url = array(); |
483 | 558 | $image_url['thumbnail'] = $url_thumbnail; |
484 | 559 | $image_url['original'] = $url; |
485 | - if ($source['exif'] && exif_imagetype($url) == IMAGETYPE_JPEG) $exifCopyright = $this->getExifCopyright($url); |
|
486 | - else $exifCopyright = ''; |
|
487 | - if ($exifCopyright != '') $image_url['copyright'] = $exifCopyright; |
|
488 | - elseif (isset($source['copyright'])) $image_url['copyright'] = $source['copyright']; |
|
489 | - else $image_url['copyright'] = $source['source_website']; |
|
560 | + if ($source['exif'] && exif_imagetype($url) == IMAGETYPE_JPEG) { |
|
561 | + $exifCopyright = $this->getExifCopyright($url); |
|
562 | + } else { |
|
563 | + $exifCopyright = ''; |
|
564 | + } |
|
565 | + if ($exifCopyright != '') { |
|
566 | + $image_url['copyright'] = $exifCopyright; |
|
567 | + } elseif (isset($source['copyright'])) { |
|
568 | + $image_url['copyright'] = $source['copyright']; |
|
569 | + } else { |
|
570 | + $image_url['copyright'] = $source['source_website']; |
|
571 | + } |
|
490 | 572 | $image_url['source_website'] = $source['source_website']; |
491 | 573 | $image_url['source'] = $source['source']; |
492 | 574 | return $image_url; |
493 | 575 | } |
494 | 576 | } |
495 | 577 | return false; |
496 | - } else return false; |
|
578 | + } else { |
|
579 | + return false; |
|
580 | + } |
|
497 | 581 | } |
498 | 582 | } |
499 | 583 |