@@ -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; |
| 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']; |
@@ -129,23 +129,23 @@ discard block |
||
| 129 | 129 | } elseif ($aircraft_icao != '') { |
| 130 | 130 | $aircraft_registration = $aircraft_icao; |
| 131 | 131 | $aircraft_name = ''; |
| 132 | - } else return array('thumbnail' => '','original' => '', 'copyright' => '', 'source' => '','source_website' => ''); |
|
| 133 | - if (!isset($globalAircraftImageSources)) $globalAircraftImageSources = array('ivaomtl','wikimedia','airportdata','deviantart','flickr','bing','jetphotos','planepictures','planespotters'); |
|
| 132 | + } else return array('thumbnail' => '', 'original' => '', 'copyright' => '', 'source' => '', 'source_website' => ''); |
|
| 133 | + if (!isset($globalAircraftImageSources)) $globalAircraftImageSources = array('ivaomtl', 'wikimedia', 'airportdata', 'deviantart', 'flickr', 'bing', 'jetphotos', 'planepictures', 'planespotters'); |
|
| 134 | 134 | foreach ($globalAircraftImageSources as $source) { |
| 135 | 135 | $source = strtolower($source); |
| 136 | - if ($source == 'ivaomtl' && $globalIVAO && $aircraft_icao != '' && $airline_icao != '') $images_array = $this->fromIvaoMtl($aircraft_icao,$airline_icao); |
|
| 137 | - if ($source == 'planespotters' && !$globalIVAO) $images_array = $this->fromPlanespotters($aircraft_registration,$aircraft_name); |
|
| 138 | - if ($source == 'flickr') $images_array = $this->fromFlickr($aircraft_registration,$aircraft_name); |
|
| 139 | - if ($source == 'bing') $images_array = $this->fromBing($aircraft_registration,$aircraft_name); |
|
| 140 | - if ($source == 'deviantart') $images_array = $this->fromDeviantart($aircraft_registration,$aircraft_name); |
|
| 141 | - if ($source == 'wikimedia') $images_array = $this->fromWikimedia($aircraft_registration,$aircraft_name); |
|
| 142 | - if ($source == 'jetphotos' && !$globalIVAO) $images_array = $this->fromJetPhotos($aircraft_registration,$aircraft_name); |
|
| 143 | - if ($source == 'planepictures' && !$globalIVAO) $images_array = $this->fromPlanePictures($aircraft_registration,$aircraft_name); |
|
| 144 | - if ($source == 'airportdata' && !$globalIVAO) $images_array = $this->fromAirportData($aircraft_registration,$aircraft_name); |
|
| 145 | - if ($source == 'customsources') $images_array = $this->fromCustomSource($aircraft_registration,$aircraft_name); |
|
| 136 | + if ($source == 'ivaomtl' && $globalIVAO && $aircraft_icao != '' && $airline_icao != '') $images_array = $this->fromIvaoMtl($aircraft_icao, $airline_icao); |
|
| 137 | + if ($source == 'planespotters' && !$globalIVAO) $images_array = $this->fromPlanespotters($aircraft_registration, $aircraft_name); |
|
| 138 | + if ($source == 'flickr') $images_array = $this->fromFlickr($aircraft_registration, $aircraft_name); |
|
| 139 | + if ($source == 'bing') $images_array = $this->fromBing($aircraft_registration, $aircraft_name); |
|
| 140 | + if ($source == 'deviantart') $images_array = $this->fromDeviantart($aircraft_registration, $aircraft_name); |
|
| 141 | + if ($source == 'wikimedia') $images_array = $this->fromWikimedia($aircraft_registration, $aircraft_name); |
|
| 142 | + if ($source == 'jetphotos' && !$globalIVAO) $images_array = $this->fromJetPhotos($aircraft_registration, $aircraft_name); |
|
| 143 | + if ($source == 'planepictures' && !$globalIVAO) $images_array = $this->fromPlanePictures($aircraft_registration, $aircraft_name); |
|
| 144 | + if ($source == 'airportdata' && !$globalIVAO) $images_array = $this->fromAirportData($aircraft_registration, $aircraft_name); |
|
| 145 | + if ($source == 'customsources') $images_array = $this->fromCustomSource($aircraft_registration, $aircraft_name); |
|
| 146 | 146 | if (isset($images_array) && $images_array['original'] != '') return $images_array; |
| 147 | 147 | } |
| 148 | - return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => ''); |
|
| 148 | + return array('thumbnail' => '', 'original' => '', 'copyright' => '', 'source' => '', 'source_website' => ''); |
|
| 149 | 149 | } |
| 150 | 150 | |
| 151 | 151 | /** |
@@ -156,24 +156,24 @@ discard block |
||
| 156 | 156 | * @return Array the aircraft thumbnail, orignal url and copyright |
| 157 | 157 | * |
| 158 | 158 | */ |
| 159 | - public function fromPlanespotters($aircraft_registration, $aircraft_name='') { |
|
| 159 | + public function fromPlanespotters($aircraft_registration, $aircraft_name = '') { |
|
| 160 | 160 | $Common = new Common(); |
| 161 | 161 | // If aircraft registration is only number, also check with aircraft model |
| 162 | - if (preg_match('/^[[:digit]]+$/',$aircraft_registration) && $aircraft_name != '') { |
|
| 163 | - $url= 'http://www.planespotters.net/Aviation_Photos/search.php?tag='.$aircraft_registration.'&actype=s_'.urlencode($aircraft_name).'&output=rss'; |
|
| 162 | + if (preg_match('/^[[:digit]]+$/', $aircraft_registration) && $aircraft_name != '') { |
|
| 163 | + $url = 'http://www.planespotters.net/Aviation_Photos/search.php?tag='.$aircraft_registration.'&actype=s_'.urlencode($aircraft_name).'&output=rss'; |
|
| 164 | 164 | } else { |
| 165 | 165 | //$url= 'http://www.planespotters.net/Aviation_Photos/search.php?tag='.$airline_aircraft_type.'&output=rss'; |
| 166 | - $url= 'http://www.planespotters.net/Aviation_Photos/search.php?reg='.$aircraft_registration.'&output=rss'; |
|
| 166 | + $url = 'http://www.planespotters.net/Aviation_Photos/search.php?reg='.$aircraft_registration.'&output=rss'; |
|
| 167 | 167 | } |
| 168 | 168 | $data = $Common->getData($url); |
| 169 | 169 | if ($xml = simplexml_load_string($data)) { |
| 170 | 170 | if (isset($xml->channel->item)) { |
| 171 | 171 | $image_url = array(); |
| 172 | - $thumbnail_url = trim((string)$xml->channel->item->children('http://search.yahoo.com/mrss/')->thumbnail->attributes()->url); |
|
| 172 | + $thumbnail_url = trim((string) $xml->channel->item->children('http://search.yahoo.com/mrss/')->thumbnail->attributes()->url); |
|
| 173 | 173 | $image_url['thumbnail'] = $thumbnail_url; |
| 174 | - $image_url['original'] = str_replace('thumbnail','original',$thumbnail_url); |
|
| 175 | - $image_url['copyright'] = trim((string)$xml->channel->item->children('http://search.yahoo.com/mrss/')->copyright); |
|
| 176 | - $image_url['source_website'] = trim((string)$xml->channel->item->link); |
|
| 174 | + $image_url['original'] = str_replace('thumbnail', 'original', $thumbnail_url); |
|
| 175 | + $image_url['copyright'] = trim((string) $xml->channel->item->children('http://search.yahoo.com/mrss/')->copyright); |
|
| 176 | + $image_url['source_website'] = trim((string) $xml->channel->item->link); |
|
| 177 | 177 | $image_url['source'] = 'planespotters'; |
| 178 | 178 | return $image_url; |
| 179 | 179 | } |
@@ -189,25 +189,25 @@ discard block |
||
| 189 | 189 | * @return Array the aircraft thumbnail, orignal url and copyright |
| 190 | 190 | * |
| 191 | 191 | */ |
| 192 | - public function fromDeviantart($aircraft_registration, $aircraft_name='') { |
|
| 192 | + public function fromDeviantart($aircraft_registration, $aircraft_name = '') { |
|
| 193 | 193 | $Common = new Common(); |
| 194 | 194 | // If aircraft registration is only number, also check with aircraft model |
| 195 | - if (preg_match('/^[[:digit]]+$/',$aircraft_registration) && $aircraft_name != '') { |
|
| 196 | - $url= 'http://backend.deviantart.com/rss.xml?type=deviation&q='.$aircraft_registration.'%20'.urlencode($aircraft_name); |
|
| 195 | + if (preg_match('/^[[:digit]]+$/', $aircraft_registration) && $aircraft_name != '') { |
|
| 196 | + $url = 'http://backend.deviantart.com/rss.xml?type=deviation&q='.$aircraft_registration.'%20'.urlencode($aircraft_name); |
|
| 197 | 197 | } else { |
| 198 | - $url= 'http://backend.deviantart.com/rss.xml?type=deviation&q=aircraft%20'.$aircraft_registration; |
|
| 198 | + $url = 'http://backend.deviantart.com/rss.xml?type=deviation&q=aircraft%20'.$aircraft_registration; |
|
| 199 | 199 | } |
| 200 | 200 | |
| 201 | 201 | $data = $Common->getData($url); |
| 202 | 202 | if ($xml = simplexml_load_string($data)) { |
| 203 | 203 | if (isset($xml->channel->item->link)) { |
| 204 | 204 | $image_url = array(); |
| 205 | - $thumbnail_url = trim((string)$xml->channel->item->children('http://search.yahoo.com/mrss/')->thumbnail->attributes()->url); |
|
| 205 | + $thumbnail_url = trim((string) $xml->channel->item->children('http://search.yahoo.com/mrss/')->thumbnail->attributes()->url); |
|
| 206 | 206 | $image_url['thumbnail'] = $thumbnail_url; |
| 207 | - $original_url = trim((string)$xml->channel->item->children('http://search.yahoo.com/mrss/')->content->attributes()->url); |
|
| 207 | + $original_url = trim((string) $xml->channel->item->children('http://search.yahoo.com/mrss/')->content->attributes()->url); |
|
| 208 | 208 | $image_url['original'] = $original_url; |
| 209 | - $image_url['copyright'] = str_replace('Copyright ','',trim((string)$xml->channel->item->children('http://search.yahoo.com/mrss/')->copyright)); |
|
| 210 | - $image_url['source_website'] = trim((string)$xml->channel->item->link); |
|
| 209 | + $image_url['copyright'] = str_replace('Copyright ', '', trim((string) $xml->channel->item->children('http://search.yahoo.com/mrss/')->copyright)); |
|
| 210 | + $image_url['source_website'] = trim((string) $xml->channel->item->link); |
|
| 211 | 211 | $image_url['source'] = 'deviantart'; |
| 212 | 212 | return $image_url; |
| 213 | 213 | } |
@@ -223,32 +223,32 @@ discard block |
||
| 223 | 223 | * @return Array the aircraft thumbnail, orignal url and copyright |
| 224 | 224 | * |
| 225 | 225 | */ |
| 226 | - public function fromJetPhotos($aircraft_registration, $aircraft_name='') { |
|
| 226 | + public function fromJetPhotos($aircraft_registration, $aircraft_name = '') { |
|
| 227 | 227 | $Common = new Common(); |
| 228 | - $url= 'http://jetphotos.net/showphotos.php?displaymode=2®search='.$aircraft_registration; |
|
| 228 | + $url = 'http://jetphotos.net/showphotos.php?displaymode=2®search='.$aircraft_registration; |
|
| 229 | 229 | $data = $Common->getData($url); |
| 230 | 230 | $dom = new DOMDocument(); |
| 231 | 231 | @$dom->loadHTML($data); |
| 232 | 232 | $all_pics = array(); |
| 233 | - foreach($dom->getElementsByTagName('img') as $image) { |
|
| 233 | + foreach ($dom->getElementsByTagName('img') as $image) { |
|
| 234 | 234 | if ($image->getAttribute('itemprop') == "http://schema.org/image") { |
| 235 | 235 | $all_pics[] = $image->getAttribute('src'); |
| 236 | 236 | } |
| 237 | 237 | } |
| 238 | 238 | $all_authors = array(); |
| 239 | - foreach($dom->getElementsByTagName('meta') as $author) { |
|
| 239 | + foreach ($dom->getElementsByTagName('meta') as $author) { |
|
| 240 | 240 | if ($author->getAttribute('itemprop') == "http://schema.org/author") { |
| 241 | 241 | $all_authors[] = $author->getAttribute('content'); |
| 242 | 242 | } |
| 243 | 243 | } |
| 244 | 244 | $all_ref = array(); |
| 245 | - foreach($dom->getElementsByTagName('a') as $link) { |
|
| 245 | + foreach ($dom->getElementsByTagName('a') as $link) { |
|
| 246 | 246 | $all_ref[] = $link->getAttribute('href'); |
| 247 | 247 | } |
| 248 | 248 | if (isset($all_pics[0])) { |
| 249 | 249 | $image_url = array(); |
| 250 | 250 | $image_url['thumbnail'] = $all_pics[0]; |
| 251 | - $image_url['original'] = str_replace('_tb','',$all_pics[0]); |
|
| 251 | + $image_url['original'] = str_replace('_tb', '', $all_pics[0]); |
|
| 252 | 252 | $image_url['copyright'] = $all_authors[0]; |
| 253 | 253 | $image_url['source_website'] = 'http://jetphotos.net'.$all_ref[8]; |
| 254 | 254 | $image_url['source'] = 'JetPhotos'; |
@@ -265,24 +265,24 @@ discard block |
||
| 265 | 265 | * @return Array the aircraft thumbnail, orignal url and copyright |
| 266 | 266 | * |
| 267 | 267 | */ |
| 268 | - public function fromPlanePictures($aircraft_registration, $aircraft_name='') { |
|
| 268 | + public function fromPlanePictures($aircraft_registration, $aircraft_name = '') { |
|
| 269 | 269 | $Common = new Common(); |
| 270 | - $url= 'http://www.planepictures.net/netsearch4.cgi?srch='.$aircraft_registration.'&stype=reg&srng=2'; |
|
| 270 | + $url = 'http://www.planepictures.net/netsearch4.cgi?srch='.$aircraft_registration.'&stype=reg&srng=2'; |
|
| 271 | 271 | $data = $Common->getData($url); |
| 272 | 272 | $dom = new DOMDocument(); |
| 273 | 273 | @$dom->loadHTML($data); |
| 274 | 274 | $all_pics = array(); |
| 275 | - foreach($dom->getElementsByTagName('img') as $image) { |
|
| 275 | + foreach ($dom->getElementsByTagName('img') as $image) { |
|
| 276 | 276 | $all_pics[] = $image->getAttribute('src'); |
| 277 | 277 | } |
| 278 | 278 | $all_links = array(); |
| 279 | - foreach($dom->getElementsByTagName('a') as $link) { |
|
| 280 | - $all_links[] = array('text' => $link->textContent,'href' => $link->getAttribute('href')); |
|
| 279 | + foreach ($dom->getElementsByTagName('a') as $link) { |
|
| 280 | + $all_links[] = array('text' => $link->textContent, 'href' => $link->getAttribute('href')); |
|
| 281 | 281 | } |
| 282 | - if (isset($all_pics[1]) && !preg_match('/bit.ly/',$all_pics[1])) { |
|
| 282 | + if (isset($all_pics[1]) && !preg_match('/bit.ly/', $all_pics[1])) { |
|
| 283 | 283 | $image_url = array(); |
| 284 | 284 | $image_url['thumbnail'] = 'http://www.planepictures.net'.$all_pics[1]; |
| 285 | - $image_url['original'] = 'http://www.planepictures.net'.str_replace('_TN','',$all_pics[1]); |
|
| 285 | + $image_url['original'] = 'http://www.planepictures.net'.str_replace('_TN', '', $all_pics[1]); |
|
| 286 | 286 | $image_url['copyright'] = $all_links[6]['text']; |
| 287 | 287 | $image_url['source_website'] = 'http://www.planepictures.net/'.$all_links[2]['href']; |
| 288 | 288 | $image_url['source'] = 'PlanePictures'; |
@@ -299,19 +299,19 @@ discard block |
||
| 299 | 299 | * @return Array the aircraft thumbnail, orignal url and copyright |
| 300 | 300 | * |
| 301 | 301 | */ |
| 302 | - public function fromFlickr($aircraft_registration,$aircraft_name='') { |
|
| 302 | + public function fromFlickr($aircraft_registration, $aircraft_name = '') { |
|
| 303 | 303 | $Common = new Common(); |
| 304 | 304 | 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); |
| 305 | 305 | 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'; |
| 306 | 306 | $data = $Common->getData($url); |
| 307 | 307 | if ($xml = simplexml_load_string($data)) { |
| 308 | 308 | if (isset($xml->channel->item)) { |
| 309 | - $original_url = trim((string)$xml->channel->item->enclosure->attributes()->url); |
|
| 309 | + $original_url = trim((string) $xml->channel->item->enclosure->attributes()->url); |
|
| 310 | 310 | $image_url = array(); |
| 311 | 311 | $image_url['thumbnail'] = $original_url; |
| 312 | 312 | $image_url['original'] = $original_url; |
| 313 | - $image_url['copyright'] = trim((string)$xml->channel->item->children('http://search.yahoo.com/mrss/')->credit); |
|
| 314 | - $image_url['source_website'] = trim((string)$xml->channel->item->link); |
|
| 313 | + $image_url['copyright'] = trim((string) $xml->channel->item->children('http://search.yahoo.com/mrss/')->credit); |
|
| 314 | + $image_url['source_website'] = trim((string) $xml->channel->item->link); |
|
| 315 | 315 | $image_url['source'] = 'flickr'; |
| 316 | 316 | return $image_url; |
| 317 | 317 | } |
@@ -319,7 +319,7 @@ discard block |
||
| 319 | 319 | return false; |
| 320 | 320 | } |
| 321 | 321 | |
| 322 | - public function fromIvaoMtl($aircraft_icao,$airline_icao) { |
|
| 322 | + public function fromIvaoMtl($aircraft_icao, $airline_icao) { |
|
| 323 | 323 | $Common = new Common(); |
| 324 | 324 | //echo "\n".'SEARCH IMAGE : http://mtlcatalog.ivao.aero/images/aircraft/'.$aircraft_icao.$airline_icao.'.jpg'; |
| 325 | 325 | if ($Common->urlexist('http://mtlcatalog.ivao.aero/images/aircraft/'.$aircraft_icao.$airline_icao.'.jpg')) { |
@@ -343,14 +343,14 @@ discard block |
||
| 343 | 343 | * @return Array the aircraft thumbnail, orignal url and copyright |
| 344 | 344 | * |
| 345 | 345 | */ |
| 346 | - public function fromBing($aircraft_registration,$aircraft_name='') { |
|
| 346 | + public function fromBing($aircraft_registration, $aircraft_name = '') { |
|
| 347 | 347 | global $globalImageBingKey; |
| 348 | 348 | $Common = new Common(); |
| 349 | 349 | if (!isset($globalImageBingKey) || $globalImageBingKey == '') return false; |
| 350 | 350 | 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'; |
| 351 | 351 | 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'; |
| 352 | - $headers = array("Authorization: Basic " . base64_encode("ignored:".$globalImageBingKey)); |
|
| 353 | - $data = $Common->getData($url,'get','',$headers); |
|
| 352 | + $headers = array("Authorization: Basic ".base64_encode("ignored:".$globalImageBingKey)); |
|
| 353 | + $data = $Common->getData($url, 'get', '', $headers); |
|
| 354 | 354 | $result = json_decode($data); |
| 355 | 355 | if (isset($result->d->results[0]->MediaUrl)) { |
| 356 | 356 | $image_url = array(); |
@@ -375,14 +375,14 @@ discard block |
||
| 375 | 375 | * @return Array the aircraft thumbnail, orignal url and copyright |
| 376 | 376 | * |
| 377 | 377 | */ |
| 378 | - public function fromAirportData($aircraft_registration,$aircraft_name='') { |
|
| 378 | + public function fromAirportData($aircraft_registration, $aircraft_name = '') { |
|
| 379 | 379 | $Common = new Common(); |
| 380 | 380 | $url = 'http://www.airport-data.com/api/ac_thumb.json?&n=1&r='.$aircraft_registration; |
| 381 | 381 | $data = $Common->getData($url); |
| 382 | 382 | $result = json_decode($data); |
| 383 | 383 | if (isset($result->count) && $result->count > 0) { |
| 384 | 384 | $image_url = array(); |
| 385 | - $image_url['original'] = str_replace('thumbnails','large',$result->data[0]->image); |
|
| 385 | + $image_url['original'] = str_replace('thumbnails', 'large', $result->data[0]->image); |
|
| 386 | 386 | $image_url['source_website'] = $result->data[0]->link; |
| 387 | 387 | $image_url['thumbnail'] = $result->data[0]->image; |
| 388 | 388 | $image_url['copyright'] = $result->data[0]->photographer; |
@@ -400,7 +400,7 @@ discard block |
||
| 400 | 400 | * @return Array the aircraft thumbnail, orignal url and copyright |
| 401 | 401 | * |
| 402 | 402 | */ |
| 403 | - public function fromWikimedia($aircraft_registration,$aircraft_name='') { |
|
| 403 | + public function fromWikimedia($aircraft_registration, $aircraft_name = '') { |
|
| 404 | 404 | $Common = new Common(); |
| 405 | 405 | 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); |
| 406 | 406 | else $url = 'https://commons.wikimedia.org/w/api.php?action=query&list=search&format=json&srlimit=1&srnamespace=6&continue&srsearch="'.$aircraft_registration.'"%20aircraft'; |
@@ -408,7 +408,7 @@ discard block |
||
| 408 | 408 | $result = json_decode($data); |
| 409 | 409 | if (isset($result->query->search[0]->title)) { |
| 410 | 410 | $fileo = $result->query->search[0]->title; |
| 411 | - if (substr($fileo,-3) == 'pdf') return false; |
|
| 411 | + if (substr($fileo, -3) == 'pdf') return false; |
|
| 412 | 412 | $file = urlencode($fileo); |
| 413 | 413 | $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; |
| 414 | 414 | $data2 = $Common->getData($url2); |
@@ -433,11 +433,11 @@ discard block |
||
| 433 | 433 | if (isset($result2->query->pages)) { |
| 434 | 434 | foreach ($result2->query->pages as $page) { |
| 435 | 435 | if (isset($page->imageinfo[0]->extmetadata->Artist)) { |
| 436 | - $image_url['copyright'] = preg_replace('/ from(.*)/','',strip_tags($page->imageinfo[0]->extmetadata->Artist->value)); |
|
| 436 | + $image_url['copyright'] = preg_replace('/ from(.*)/', '', strip_tags($page->imageinfo[0]->extmetadata->Artist->value)); |
|
| 437 | 437 | if (isset($page->imageinfo[0]->extmetadata->License->value)) { |
| 438 | 438 | $image_url['copyright'] = $image_url['copyright'].' (under '.$page->imageinfo[0]->extmetadata->License->value.')'; |
| 439 | 439 | } |
| 440 | - $image_url['copyright'] = trim(str_replace('\n','',$image_url['copyright'])); |
|
| 440 | + $image_url['copyright'] = trim(str_replace('\n', '', $image_url['copyright'])); |
|
| 441 | 441 | return $image_url; |
| 442 | 442 | } |
| 443 | 443 | } |
@@ -456,7 +456,7 @@ discard block |
||
| 456 | 456 | * @return Array the aircraft thumbnail, orignal url and copyright |
| 457 | 457 | * |
| 458 | 458 | */ |
| 459 | - public function fromCustomSource($aircraft_registration,$aircraft_name='') { |
|
| 459 | + public function fromCustomSource($aircraft_registration, $aircraft_name = '') { |
|
| 460 | 460 | global $globalAircraftImageCustomSources, $globalDebug; |
| 461 | 461 | //$globalAircraftImageCustomSource[] = array('thumbnail' => '','original' => '', 'copyright' => '', 'source_website' => '', 'source' => '','exif' => true); |
| 462 | 462 | if (!empty($globalAircraftImageCustomSources)) { |
@@ -473,15 +473,15 @@ discard block |
||
| 473 | 473 | print_r($source); |
| 474 | 474 | print_r($customsources); |
| 475 | 475 | } |
| 476 | - $url = str_replace('{registration}',$aircraft_registration,$source['original']); |
|
| 477 | - $url_thumbnail = str_replace('{registration}',$aircraft_registration,$source['thumbnail']); |
|
| 476 | + $url = str_replace('{registration}', $aircraft_registration, $source['original']); |
|
| 477 | + $url_thumbnail = str_replace('{registration}', $aircraft_registration, $source['thumbnail']); |
|
| 478 | 478 | if ($Common->urlexist($url)) { |
| 479 | 479 | $image_url = array(); |
| 480 | 480 | $image_url['thumbnail'] = $url_thumbnail; |
| 481 | 481 | $image_url['original'] = $url; |
| 482 | 482 | if ($source['exif'] && exif_imagetype($url) == IMAGETYPE_JPEG) $exifCopyright = $this->getExifCopyright($url); |
| 483 | 483 | else $exifCopyright = ''; |
| 484 | - if ($exifCopyright != '') $image_url['copyright'] = $exifCopyright; |
|
| 484 | + if ($exifCopyright != '') $image_url['copyright'] = $exifCopyright; |
|
| 485 | 485 | elseif (isset($source['copyright'])) $image_url['copyright'] = $source['copyright']; |
| 486 | 486 | else $image_url['copyright'] = $source['source_website']; |
| 487 | 487 | $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,36 +132,75 @@ discard block |
||
| 114 | 132 | { |
| 115 | 133 | global $globalAircraftImageSources, $globalIVAO; |
| 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_registration = $aircraft_icao; |
| 131 | 162 | $aircraft_name = ''; |
| 132 | - } else return array('thumbnail' => '','original' => '', 'copyright' => '', 'source' => '','source_website' => ''); |
|
| 133 | - if (!isset($globalAircraftImageSources)) $globalAircraftImageSources = array('ivaomtl','wikimedia','airportdata','deviantart','flickr','bing','jetphotos','planepictures','planespotters'); |
|
| 163 | + } else { |
|
| 164 | + return array('thumbnail' => '','original' => '', 'copyright' => '', 'source' => '','source_website' => ''); |
|
| 165 | + } |
|
| 166 | + if (!isset($globalAircraftImageSources)) { |
|
| 167 | + $globalAircraftImageSources = array('ivaomtl','wikimedia','airportdata','deviantart','flickr','bing','jetphotos','planepictures','planespotters'); |
|
| 168 | + } |
|
| 134 | 169 | foreach ($globalAircraftImageSources as $source) { |
| 135 | 170 | $source = strtolower($source); |
| 136 | - if ($source == 'ivaomtl' && $globalIVAO && $aircraft_icao != '' && $airline_icao != '') $images_array = $this->fromIvaoMtl($aircraft_icao,$airline_icao); |
|
| 137 | - if ($source == 'planespotters' && !$globalIVAO) $images_array = $this->fromPlanespotters($aircraft_registration,$aircraft_name); |
|
| 138 | - if ($source == 'flickr') $images_array = $this->fromFlickr($aircraft_registration,$aircraft_name); |
|
| 139 | - if ($source == 'bing') $images_array = $this->fromBing($aircraft_registration,$aircraft_name); |
|
| 140 | - if ($source == 'deviantart') $images_array = $this->fromDeviantart($aircraft_registration,$aircraft_name); |
|
| 141 | - if ($source == 'wikimedia') $images_array = $this->fromWikimedia($aircraft_registration,$aircraft_name); |
|
| 142 | - if ($source == 'jetphotos' && !$globalIVAO) $images_array = $this->fromJetPhotos($aircraft_registration,$aircraft_name); |
|
| 143 | - if ($source == 'planepictures' && !$globalIVAO) $images_array = $this->fromPlanePictures($aircraft_registration,$aircraft_name); |
|
| 144 | - if ($source == 'airportdata' && !$globalIVAO) $images_array = $this->fromAirportData($aircraft_registration,$aircraft_name); |
|
| 145 | - if ($source == 'customsources') $images_array = $this->fromCustomSource($aircraft_registration,$aircraft_name); |
|
| 146 | - if (isset($images_array) && $images_array['original'] != '') return $images_array; |
|
| 171 | + if ($source == 'ivaomtl' && $globalIVAO && $aircraft_icao != '' && $airline_icao != '') { |
|
| 172 | + $images_array = $this->fromIvaoMtl($aircraft_icao,$airline_icao); |
|
| 173 | + } |
|
| 174 | + if ($source == 'planespotters' && !$globalIVAO) { |
|
| 175 | + $images_array = $this->fromPlanespotters($aircraft_registration,$aircraft_name); |
|
| 176 | + } |
|
| 177 | + if ($source == 'flickr') { |
|
| 178 | + $images_array = $this->fromFlickr($aircraft_registration,$aircraft_name); |
|
| 179 | + } |
|
| 180 | + if ($source == 'bing') { |
|
| 181 | + $images_array = $this->fromBing($aircraft_registration,$aircraft_name); |
|
| 182 | + } |
|
| 183 | + if ($source == 'deviantart') { |
|
| 184 | + $images_array = $this->fromDeviantart($aircraft_registration,$aircraft_name); |
|
| 185 | + } |
|
| 186 | + if ($source == 'wikimedia') { |
|
| 187 | + $images_array = $this->fromWikimedia($aircraft_registration,$aircraft_name); |
|
| 188 | + } |
|
| 189 | + if ($source == 'jetphotos' && !$globalIVAO) { |
|
| 190 | + $images_array = $this->fromJetPhotos($aircraft_registration,$aircraft_name); |
|
| 191 | + } |
|
| 192 | + if ($source == 'planepictures' && !$globalIVAO) { |
|
| 193 | + $images_array = $this->fromPlanePictures($aircraft_registration,$aircraft_name); |
|
| 194 | + } |
|
| 195 | + if ($source == 'airportdata' && !$globalIVAO) { |
|
| 196 | + $images_array = $this->fromAirportData($aircraft_registration,$aircraft_name); |
|
| 197 | + } |
|
| 198 | + if ($source == 'customsources') { |
|
| 199 | + $images_array = $this->fromCustomSource($aircraft_registration,$aircraft_name); |
|
| 200 | + } |
|
| 201 | + if (isset($images_array) && $images_array['original'] != '') { |
|
| 202 | + return $images_array; |
|
| 203 | + } |
|
| 147 | 204 | } |
| 148 | 205 | return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => ''); |
| 149 | 206 | } |
@@ -301,8 +358,11 @@ discard block |
||
| 301 | 358 | */ |
| 302 | 359 | public function fromFlickr($aircraft_registration,$aircraft_name='') { |
| 303 | 360 | $Common = new Common(); |
| 304 | - 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); |
|
| 305 | - 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'; |
|
| 361 | + if ($aircraft_name != '') { |
|
| 362 | + $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); |
|
| 363 | + } else { |
|
| 364 | + $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'; |
|
| 365 | + } |
|
| 306 | 366 | $data = $Common->getData($url); |
| 307 | 367 | if ($xml = simplexml_load_string($data)) { |
| 308 | 368 | if (isset($xml->channel->item)) { |
@@ -346,9 +406,14 @@ discard block |
||
| 346 | 406 | public function fromBing($aircraft_registration,$aircraft_name='') { |
| 347 | 407 | global $globalImageBingKey; |
| 348 | 408 | $Common = new Common(); |
| 349 | - if (!isset($globalImageBingKey) || $globalImageBingKey == '') return false; |
|
| 350 | - 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'; |
|
| 351 | - 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'; |
|
| 409 | + if (!isset($globalImageBingKey) || $globalImageBingKey == '') { |
|
| 410 | + return false; |
|
| 411 | + } |
|
| 412 | + if ($aircraft_name != '') { |
|
| 413 | + $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'; |
|
| 414 | + } else { |
|
| 415 | + $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'; |
|
| 416 | + } |
|
| 352 | 417 | $headers = array("Authorization: Basic " . base64_encode("ignored:".$globalImageBingKey)); |
| 353 | 418 | $data = $Common->getData($url,'get','',$headers); |
| 354 | 419 | $result = json_decode($data); |
@@ -402,13 +467,18 @@ discard block |
||
| 402 | 467 | */ |
| 403 | 468 | public function fromWikimedia($aircraft_registration,$aircraft_name='') { |
| 404 | 469 | $Common = new Common(); |
| 405 | - 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); |
|
| 406 | - else $url = 'https://commons.wikimedia.org/w/api.php?action=query&list=search&format=json&srlimit=1&srnamespace=6&continue&srsearch="'.$aircraft_registration.'"%20aircraft'; |
|
| 470 | + if ($aircraft_name != '') { |
|
| 471 | + $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); |
|
| 472 | + } else { |
|
| 473 | + $url = 'https://commons.wikimedia.org/w/api.php?action=query&list=search&format=json&srlimit=1&srnamespace=6&continue&srsearch="'.$aircraft_registration.'"%20aircraft'; |
|
| 474 | + } |
|
| 407 | 475 | $data = $Common->getData($url); |
| 408 | 476 | $result = json_decode($data); |
| 409 | 477 | if (isset($result->query->search[0]->title)) { |
| 410 | 478 | $fileo = $result->query->search[0]->title; |
| 411 | - if (substr($fileo,-3) == 'pdf') return false; |
|
| 479 | + if (substr($fileo,-3) == 'pdf') { |
|
| 480 | + return false; |
|
| 481 | + } |
|
| 412 | 482 | $file = urlencode($fileo); |
| 413 | 483 | $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; |
| 414 | 484 | $data2 = $Common->getData($url2); |
@@ -479,18 +549,27 @@ discard block |
||
| 479 | 549 | $image_url = array(); |
| 480 | 550 | $image_url['thumbnail'] = $url_thumbnail; |
| 481 | 551 | $image_url['original'] = $url; |
| 482 | - if ($source['exif'] && exif_imagetype($url) == IMAGETYPE_JPEG) $exifCopyright = $this->getExifCopyright($url); |
|
| 483 | - else $exifCopyright = ''; |
|
| 484 | - if ($exifCopyright != '') $image_url['copyright'] = $exifCopyright; |
|
| 485 | - elseif (isset($source['copyright'])) $image_url['copyright'] = $source['copyright']; |
|
| 486 | - else $image_url['copyright'] = $source['source_website']; |
|
| 552 | + if ($source['exif'] && exif_imagetype($url) == IMAGETYPE_JPEG) { |
|
| 553 | + $exifCopyright = $this->getExifCopyright($url); |
|
| 554 | + } else { |
|
| 555 | + $exifCopyright = ''; |
|
| 556 | + } |
|
| 557 | + if ($exifCopyright != '') { |
|
| 558 | + $image_url['copyright'] = $exifCopyright; |
|
| 559 | + } elseif (isset($source['copyright'])) { |
|
| 560 | + $image_url['copyright'] = $source['copyright']; |
|
| 561 | + } else { |
|
| 562 | + $image_url['copyright'] = $source['source_website']; |
|
| 563 | + } |
|
| 487 | 564 | $image_url['source_website'] = $source['source_website']; |
| 488 | 565 | $image_url['source'] = $source['source']; |
| 489 | 566 | return $image_url; |
| 490 | 567 | } |
| 491 | 568 | } |
| 492 | 569 | return false; |
| 493 | - } else return false; |
|
| 570 | + } else { |
|
| 571 | + return false; |
|
| 572 | + } |
|
| 494 | 573 | } |
| 495 | 574 | } |
| 496 | 575 | |