@@ -18,22 +18,22 @@ discard block |
||
| 18 | 18 | * @return Array the images list |
| 19 | 19 | * |
| 20 | 20 | */ |
| 21 | - public function getSpotterImage($registration,$aircraft_icao = '', $airline_icao = '') |
|
| 21 | + public function getSpotterImage($registration, $aircraft_icao = '', $airline_icao = '') |
|
| 22 | 22 | { |
| 23 | - $registration = filter_var($registration,FILTER_SANITIZE_STRING); |
|
| 24 | - $aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING); |
|
| 25 | - $airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING); |
|
| 23 | + $registration = filter_var($registration, FILTER_SANITIZE_STRING); |
|
| 24 | + $aircraft_icao = filter_var($aircraft_icao, FILTER_SANITIZE_STRING); |
|
| 25 | + $airline_icao = filter_var($airline_icao, FILTER_SANITIZE_STRING); |
|
| 26 | 26 | $reg = $registration; |
| 27 | 27 | if ($reg == '' && $aircraft_icao != '') $reg = $aircraft_icao.$airline_icao; |
| 28 | 28 | $reg = trim($reg); |
| 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 |
|
| 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 |
|
| 30 | 30 | FROM spotter_image |
| 31 | 31 | WHERE spotter_image.registration = :registration LIMIT 1"; |
| 32 | 32 | $sth = $this->db->prepare($query); |
| 33 | 33 | $sth->execute(array(':registration' => $reg)); |
| 34 | 34 | $result = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 35 | 35 | if (!empty($result)) return $result; |
| 36 | - elseif ($registration != '') return $this->getSpotterImage('',$aircraft_icao,$airline_icao); |
|
| 36 | + elseif ($registration != '') return $this->getSpotterImage('', $aircraft_icao, $airline_icao); |
|
| 37 | 37 | else return array(); |
| 38 | 38 | } |
| 39 | 39 | |
@@ -43,23 +43,23 @@ discard block |
||
| 43 | 43 | * @return Array the images list |
| 44 | 44 | * |
| 45 | 45 | */ |
| 46 | - public function getMarineImage($mmsi,$imo = '',$name = '') |
|
| 46 | + public function getMarineImage($mmsi, $imo = '', $name = '') |
|
| 47 | 47 | { |
| 48 | - $mmsi = filter_var($mmsi,FILTER_SANITIZE_STRING); |
|
| 49 | - $imo = filter_var($imo,FILTER_SANITIZE_STRING); |
|
| 50 | - $name = filter_var($name,FILTER_SANITIZE_STRING); |
|
| 48 | + $mmsi = filter_var($mmsi, FILTER_SANITIZE_STRING); |
|
| 49 | + $imo = filter_var($imo, FILTER_SANITIZE_STRING); |
|
| 50 | + $name = filter_var($name, FILTER_SANITIZE_STRING); |
|
| 51 | 51 | $name = trim($name); |
| 52 | - $query = "SELECT marine_image.image, marine_image.image_thumbnail, marine_image.image_source, marine_image.image_source_website,marine_image.image_copyright, marine_image.mmsi, marine_image.imo, marine_image.name |
|
| 52 | + $query = "SELECT marine_image.image, marine_image.image_thumbnail, marine_image.image_source, marine_image.image_source_website,marine_image.image_copyright, marine_image.mmsi, marine_image.imo, marine_image.name |
|
| 53 | 53 | FROM marine_image |
| 54 | 54 | WHERE marine_image.mmsi = :mmsi"; |
| 55 | 55 | $query_data = array(':mmsi' => $mmsi); |
| 56 | 56 | if ($imo != '') { |
| 57 | 57 | $query .= " AND marine_image.imo = :imo"; |
| 58 | - $query_data = array_merge($query_data,array(':imo' => $imo)); |
|
| 58 | + $query_data = array_merge($query_data, array(':imo' => $imo)); |
|
| 59 | 59 | } |
| 60 | 60 | if ($name != '') { |
| 61 | 61 | $query .= " AND marine_image.name = :name"; |
| 62 | - $query_data = array_merge($query_data,array(':name' => $name)); |
|
| 62 | + $query_data = array_merge($query_data, array(':name' => $name)); |
|
| 63 | 63 | } |
| 64 | 64 | $query .= " LIMIT 1"; |
| 65 | 65 | $sth = $this->db->prepare($query); |
@@ -80,9 +80,9 @@ discard block |
||
| 80 | 80 | if (isset($exif['COMPUTED']['copyright'])) $copyright = $exif['COMPUTED']['copyright']; |
| 81 | 81 | elseif (isset($exif['copyright'])) $copyright = $exif['copyright']; |
| 82 | 82 | if ($copyright != '') { |
| 83 | - $copyright = str_replace('Copyright ','',$copyright); |
|
| 84 | - $copyright = str_replace('© ','',$copyright); |
|
| 85 | - $copyright = str_replace('(c) ','',$copyright); |
|
| 83 | + $copyright = str_replace('Copyright ', '', $copyright); |
|
| 84 | + $copyright = str_replace('© ', '', $copyright); |
|
| 85 | + $copyright = str_replace('(c) ', '', $copyright); |
|
| 86 | 86 | } |
| 87 | 87 | return $copyright; |
| 88 | 88 | } |
@@ -93,25 +93,25 @@ discard block |
||
| 93 | 93 | * @return String either success or error |
| 94 | 94 | * |
| 95 | 95 | */ |
| 96 | - public function addSpotterImage($registration,$aircraft_icao = '', $airline_icao = '') |
|
| 96 | + public function addSpotterImage($registration, $aircraft_icao = '', $airline_icao = '') |
|
| 97 | 97 | { |
| 98 | - global $globalDebug,$globalAircraftImageFetch; |
|
| 98 | + global $globalDebug, $globalAircraftImageFetch; |
|
| 99 | 99 | if (isset($globalAircraftImageFetch) && !$globalAircraftImageFetch) return ''; |
| 100 | - $registration = filter_var($registration,FILTER_SANITIZE_STRING); |
|
| 100 | + $registration = filter_var($registration, FILTER_SANITIZE_STRING); |
|
| 101 | 101 | $registration = trim($registration); |
| 102 | 102 | //getting the aircraft image |
| 103 | 103 | if ($globalDebug && $registration != '') echo 'Try to find an aircraft image for '.$registration.'...'; |
| 104 | 104 | elseif ($globalDebug && $aircraft_icao != '') echo 'Try to find an aircraft image for '.$aircraft_icao.'...'; |
| 105 | 105 | elseif ($globalDebug && $airline_icao != '') echo 'Try to find an aircraft image for '.$airline_icao.'...'; |
| 106 | - $image_url = $this->findAircraftImage($registration,$aircraft_icao,$airline_icao); |
|
| 106 | + $image_url = $this->findAircraftImage($registration, $aircraft_icao, $airline_icao); |
|
| 107 | 107 | if ($registration == '' && $aircraft_icao != '') $registration = $aircraft_icao.$airline_icao; |
| 108 | 108 | if ($image_url['original'] != '') { |
| 109 | 109 | if ($globalDebug) echo 'Found !'."\n"; |
| 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)"; |
|
| 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)"; |
|
| 111 | 111 | try { |
| 112 | 112 | $sth = $this->db->prepare($query); |
| 113 | - $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'])); |
|
| 114 | - } catch(PDOException $e) { |
|
| 113 | + $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'])); |
|
| 114 | + } catch (PDOException $e) { |
|
| 115 | 115 | echo $e->getMessage()."\n"; |
| 116 | 116 | return "error"; |
| 117 | 117 | } |
@@ -125,13 +125,13 @@ discard block |
||
| 125 | 125 | * @return String either success or error |
| 126 | 126 | * |
| 127 | 127 | */ |
| 128 | - public function addMarineImage($mmsi,$imo = '',$name = '') |
|
| 128 | + public function addMarineImage($mmsi, $imo = '', $name = '') |
|
| 129 | 129 | { |
| 130 | - global $globalDebug,$globalMarineImageFetch; |
|
| 130 | + global $globalDebug, $globalMarineImageFetch; |
|
| 131 | 131 | if (isset($globalMarineImageFetch) && !$globalMarineImageFetch) return ''; |
| 132 | - $mmsi = filter_var($mmsi,FILTER_SANITIZE_STRING); |
|
| 133 | - $imo = filter_var($imo,FILTER_SANITIZE_STRING); |
|
| 134 | - $name = filter_var($name,FILTER_SANITIZE_STRING); |
|
| 132 | + $mmsi = filter_var($mmsi, FILTER_SANITIZE_STRING); |
|
| 133 | + $imo = filter_var($imo, FILTER_SANITIZE_STRING); |
|
| 134 | + $name = filter_var($name, FILTER_SANITIZE_STRING); |
|
| 135 | 135 | $name = trim($name); |
| 136 | 136 | $Marine = new Marine($this->db); |
| 137 | 137 | if ($imo == '' || $name == '') { |
@@ -145,14 +145,14 @@ discard block |
||
| 145 | 145 | |
| 146 | 146 | //getting the aircraft image |
| 147 | 147 | if ($globalDebug && $name != '') echo 'Try to find an vessel image for '.$name.'...'; |
| 148 | - $image_url = $this->findMarineImage($mmsi,$imo,$name); |
|
| 148 | + $image_url = $this->findMarineImage($mmsi, $imo, $name); |
|
| 149 | 149 | if ($image_url['original'] != '') { |
| 150 | 150 | if ($globalDebug) echo 'Found !'."\n"; |
| 151 | - $query = "INSERT INTO marine_image (mmsi,imo,name, image, image_thumbnail, image_copyright, image_source,image_source_website) VALUES (:mmsi,:imo,:name,:image,:image_thumbnail,:copyright,:source,:source_website)"; |
|
| 151 | + $query = "INSERT INTO marine_image (mmsi,imo,name, image, image_thumbnail, image_copyright, image_source,image_source_website) VALUES (:mmsi,:imo,:name,:image,:image_thumbnail,:copyright,:source,:source_website)"; |
|
| 152 | 152 | try { |
| 153 | 153 | $sth = $this->db->prepare($query); |
| 154 | - $sth->execute(array(':mmsi' => $mmsi,':imo' => $imo,':name' => $name,':image' => $image_url['original'],':image_thumbnail' => $image_url['thumbnail'], ':copyright' => $image_url['copyright'],':source' => $image_url['source'],':source_website' => $image_url['source_website'])); |
|
| 155 | - } catch(PDOException $e) { |
|
| 154 | + $sth->execute(array(':mmsi' => $mmsi, ':imo' => $imo, ':name' => $name, ':image' => $image_url['original'], ':image_thumbnail' => $image_url['thumbnail'], ':copyright' => $image_url['copyright'], ':source' => $image_url['source'], ':source_website' => $image_url['source_website'])); |
|
| 155 | + } catch (PDOException $e) { |
|
| 156 | 156 | echo $e->getMessage()."\n"; |
| 157 | 157 | return "error"; |
| 158 | 158 | } |
@@ -172,9 +172,9 @@ discard block |
||
| 172 | 172 | global $globalAircraftImageSources, $globalIVAO, $globalAircraftImageCheckICAO, $globalVA; |
| 173 | 173 | $Spotter = new Spotter($this->db); |
| 174 | 174 | if (!isset($globalIVAO)) $globalIVAO = FALSE; |
| 175 | - $aircraft_registration = filter_var($aircraft_registration,FILTER_SANITIZE_STRING); |
|
| 175 | + $aircraft_registration = filter_var($aircraft_registration, FILTER_SANITIZE_STRING); |
|
| 176 | 176 | if ($aircraft_registration != '' && (!isset($globalVA) || $globalVA !== TRUE)) { |
| 177 | - if (strpos($aircraft_registration,'/') !== false) return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => ''); |
|
| 177 | + if (strpos($aircraft_registration, '/') !== false) return array('thumbnail' => '', 'original' => '', 'copyright' => '', 'source' => '', 'source_website' => ''); |
|
| 178 | 178 | $aircraft_registration = urlencode(trim($aircraft_registration)); |
| 179 | 179 | $aircraft_info = $Spotter->getAircraftInfoByRegistration($aircraft_registration); |
| 180 | 180 | if (isset($aircraft_info[0]['aircraft_name'])) $aircraft_name = $aircraft_info[0]['aircraft_name']; |
@@ -188,25 +188,25 @@ discard block |
||
| 188 | 188 | if (isset($aircraft_info[0]['type'])) $aircraft_name = $aircraft_info[0]['type']; |
| 189 | 189 | else $aircraft_name = ''; |
| 190 | 190 | $aircraft_registration = $aircraft_icao; |
| 191 | - } else return array('thumbnail' => '','original' => '', 'copyright' => '', 'source' => '','source_website' => ''); |
|
| 191 | + } else return array('thumbnail' => '', 'original' => '', 'copyright' => '', 'source' => '', 'source_website' => ''); |
|
| 192 | 192 | unset($Spotter); |
| 193 | - if (!isset($globalAircraftImageSources)) $globalAircraftImageSources = array('ivaomtl','wikimedia','airportdata','deviantart','flickr','bing','jetphotos','planepictures','planespotters'); |
|
| 193 | + if (!isset($globalAircraftImageSources)) $globalAircraftImageSources = array('ivaomtl', 'wikimedia', 'airportdata', 'deviantart', 'flickr', 'bing', 'jetphotos', 'planepictures', 'planespotters'); |
|
| 194 | 194 | foreach ($globalAircraftImageSources as $source) { |
| 195 | 195 | $source = strtolower($source); |
| 196 | - if ($source == 'ivaomtl' && $globalIVAO && $aircraft_icao != '' && $airline_icao != '') $images_array = $this->fromIvaoMtl('aircraft',$aircraft_icao,$airline_icao); |
|
| 197 | - if ($source == 'planespotters' && !$globalIVAO && extension_loaded('simplexml')) $images_array = $this->fromPlanespotters('aircraft',$aircraft_registration,$aircraft_name); |
|
| 198 | - if ($source == 'flickr' && extension_loaded('simplexml')) $images_array = $this->fromFlickr('aircraft',$aircraft_registration,$aircraft_name); |
|
| 199 | - if ($source == 'bing') $images_array = $this->fromBing('aircraft',$aircraft_registration,$aircraft_name); |
|
| 200 | - if ($source == 'deviantart' && extension_loaded('simplexml')) $images_array = $this->fromDeviantart('aircraft',$aircraft_registration,$aircraft_name); |
|
| 201 | - if ($source == 'wikimedia') $images_array = $this->fromWikimedia('aircraft',$aircraft_registration,$aircraft_name); |
|
| 202 | - if ($source == 'jetphotos' && !$globalIVAO && class_exists("DomDocument")) $images_array = $this->fromJetPhotos('aircraft',$aircraft_registration,$aircraft_name); |
|
| 203 | - if ($source == 'planepictures' && !$globalIVAO && class_exists("DomDocument")) $images_array = $this->fromPlanePictures('aircraft',$aircraft_registration,$aircraft_name); |
|
| 204 | - if ($source == 'airportdata' && !$globalIVAO) $images_array = $this->fromAirportData('aircraft',$aircraft_registration,$aircraft_name); |
|
| 205 | - if ($source == 'customsources') $images_array = $this->fromCustomSource('aircraft',$aircraft_registration,$aircraft_name); |
|
| 196 | + if ($source == 'ivaomtl' && $globalIVAO && $aircraft_icao != '' && $airline_icao != '') $images_array = $this->fromIvaoMtl('aircraft', $aircraft_icao, $airline_icao); |
|
| 197 | + if ($source == 'planespotters' && !$globalIVAO && extension_loaded('simplexml')) $images_array = $this->fromPlanespotters('aircraft', $aircraft_registration, $aircraft_name); |
|
| 198 | + if ($source == 'flickr' && extension_loaded('simplexml')) $images_array = $this->fromFlickr('aircraft', $aircraft_registration, $aircraft_name); |
|
| 199 | + if ($source == 'bing') $images_array = $this->fromBing('aircraft', $aircraft_registration, $aircraft_name); |
|
| 200 | + if ($source == 'deviantart' && extension_loaded('simplexml')) $images_array = $this->fromDeviantart('aircraft', $aircraft_registration, $aircraft_name); |
|
| 201 | + if ($source == 'wikimedia') $images_array = $this->fromWikimedia('aircraft', $aircraft_registration, $aircraft_name); |
|
| 202 | + if ($source == 'jetphotos' && !$globalIVAO && class_exists("DomDocument")) $images_array = $this->fromJetPhotos('aircraft', $aircraft_registration, $aircraft_name); |
|
| 203 | + if ($source == 'planepictures' && !$globalIVAO && class_exists("DomDocument")) $images_array = $this->fromPlanePictures('aircraft', $aircraft_registration, $aircraft_name); |
|
| 204 | + if ($source == 'airportdata' && !$globalIVAO) $images_array = $this->fromAirportData('aircraft', $aircraft_registration, $aircraft_name); |
|
| 205 | + if ($source == 'customsources') $images_array = $this->fromCustomSource('aircraft', $aircraft_registration, $aircraft_name); |
|
| 206 | 206 | if (isset($images_array) && $images_array['original'] != '') return $images_array; |
| 207 | 207 | } |
| 208 | 208 | if ((!isset($globalAircraftImageCheckICAO) || $globalAircraftImageCheckICAO === TRUE) && isset($aircraft_icao)) return $this->findAircraftImage($aircraft_icao); |
| 209 | - return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => ''); |
|
| 209 | + return array('thumbnail' => '', 'original' => '', 'copyright' => '', 'source' => '', 'source_website' => ''); |
|
| 210 | 210 | } |
| 211 | 211 | |
| 212 | 212 | /** |
@@ -218,14 +218,14 @@ discard block |
||
| 218 | 218 | * @return Array the aircraft thumbnail, orignal url and copyright |
| 219 | 219 | * |
| 220 | 220 | */ |
| 221 | - public function findMarineImage($mmsi,$imo = '',$name = '') |
|
| 221 | + public function findMarineImage($mmsi, $imo = '', $name = '') |
|
| 222 | 222 | { |
| 223 | 223 | global $globalMarineImageSources; |
| 224 | - $mmsi = filter_var($mmsi,FILTER_SANITIZE_STRING); |
|
| 224 | + $mmsi = filter_var($mmsi, FILTER_SANITIZE_STRING); |
|
| 225 | 225 | //$imo = filter_var($imo,FILTER_SANITIZE_STRING); |
| 226 | - $name = filter_var($name,FILTER_SANITIZE_STRING); |
|
| 226 | + $name = filter_var($name, FILTER_SANITIZE_STRING); |
|
| 227 | 227 | $name = trim($name); |
| 228 | - if (strlen($name) < 4) return array('thumbnail' => '','original' => '', 'copyright' => '', 'source' => '','source_website' => ''); |
|
| 228 | + if (strlen($name) < 4) return array('thumbnail' => '', 'original' => '', 'copyright' => '', 'source' => '', 'source_website' => ''); |
|
| 229 | 229 | /* |
| 230 | 230 | $Marine = new Marine($this->db); |
| 231 | 231 | if ($imo == '' || $name == '') { |
@@ -237,17 +237,17 @@ discard block |
||
| 237 | 237 | } |
| 238 | 238 | unset($Marine); |
| 239 | 239 | */ |
| 240 | - if (!isset($globalMarineImageSources)) $globalMarineImageSources = array('wikimedia','deviantart','flickr','bing'); |
|
| 240 | + if (!isset($globalMarineImageSources)) $globalMarineImageSources = array('wikimedia', 'deviantart', 'flickr', 'bing'); |
|
| 241 | 241 | foreach ($globalMarineImageSources as $source) { |
| 242 | 242 | $source = strtolower($source); |
| 243 | - if ($source == 'flickr') $images_array = $this->fromFlickr('marine',$mmsi,$name); |
|
| 244 | - if ($source == 'bing') $images_array = $this->fromBing('marine',$mmsi,$name); |
|
| 245 | - if ($source == 'deviantart') $images_array = $this->fromDeviantart('marine',$mmsi,$name); |
|
| 246 | - if ($source == 'wikimedia') $images_array = $this->fromWikimedia('marine',$mmsi,$name); |
|
| 247 | - if ($source == 'customsources') $images_array = $this->fromCustomSource('marine',$mmsi,$name); |
|
| 243 | + if ($source == 'flickr') $images_array = $this->fromFlickr('marine', $mmsi, $name); |
|
| 244 | + if ($source == 'bing') $images_array = $this->fromBing('marine', $mmsi, $name); |
|
| 245 | + if ($source == 'deviantart') $images_array = $this->fromDeviantart('marine', $mmsi, $name); |
|
| 246 | + if ($source == 'wikimedia') $images_array = $this->fromWikimedia('marine', $mmsi, $name); |
|
| 247 | + if ($source == 'customsources') $images_array = $this->fromCustomSource('marine', $mmsi, $name); |
|
| 248 | 248 | if (isset($images_array) && $images_array['original'] != '') return $images_array; |
| 249 | 249 | } |
| 250 | - return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => ''); |
|
| 250 | + return array('thumbnail' => '', 'original' => '', 'copyright' => '', 'source' => '', 'source_website' => ''); |
|
| 251 | 251 | } |
| 252 | 252 | |
| 253 | 253 | /** |
@@ -258,24 +258,24 @@ discard block |
||
| 258 | 258 | * @return Array the aircraft thumbnail, orignal url and copyright |
| 259 | 259 | * |
| 260 | 260 | */ |
| 261 | - public function fromPlanespotters($type,$aircraft_registration, $aircraft_name='') { |
|
| 261 | + public function fromPlanespotters($type, $aircraft_registration, $aircraft_name = '') { |
|
| 262 | 262 | $Common = new Common(); |
| 263 | 263 | // If aircraft registration is only number, also check with aircraft model |
| 264 | - if (preg_match('/^[[:digit]]+$/',$aircraft_registration) && $aircraft_name != '') { |
|
| 265 | - $url= 'http://www.planespotters.net/Aviation_Photos/search.php?tag='.$aircraft_registration.'&actype=s_'.urlencode($aircraft_name).'&output=rss'; |
|
| 264 | + if (preg_match('/^[[:digit]]+$/', $aircraft_registration) && $aircraft_name != '') { |
|
| 265 | + $url = 'http://www.planespotters.net/Aviation_Photos/search.php?tag='.$aircraft_registration.'&actype=s_'.urlencode($aircraft_name).'&output=rss'; |
|
| 266 | 266 | } else { |
| 267 | 267 | //$url= 'http://www.planespotters.net/Aviation_Photos/search.php?tag='.$airline_aircraft_type.'&output=rss'; |
| 268 | - $url= 'http://www.planespotters.net/Aviation_Photos/search.php?reg='.$aircraft_registration.'&output=rss'; |
|
| 268 | + $url = 'http://www.planespotters.net/Aviation_Photos/search.php?reg='.$aircraft_registration.'&output=rss'; |
|
| 269 | 269 | } |
| 270 | 270 | $data = $Common->getData($url); |
| 271 | 271 | if ($xml = simplexml_load_string($data)) { |
| 272 | 272 | if (isset($xml->channel->item)) { |
| 273 | 273 | $image_url = array(); |
| 274 | - $thumbnail_url = trim((string)$xml->channel->item->children('http://search.yahoo.com/mrss/')->thumbnail->attributes()->url); |
|
| 274 | + $thumbnail_url = trim((string) $xml->channel->item->children('http://search.yahoo.com/mrss/')->thumbnail->attributes()->url); |
|
| 275 | 275 | $image_url['thumbnail'] = $thumbnail_url; |
| 276 | - $image_url['original'] = str_replace('thumbnail','original',$thumbnail_url); |
|
| 277 | - $image_url['copyright'] = trim((string)$xml->channel->item->children('http://search.yahoo.com/mrss/')->copyright); |
|
| 278 | - $image_url['source_website'] = trim((string)$xml->channel->item->link); |
|
| 276 | + $image_url['original'] = str_replace('thumbnail', 'original', $thumbnail_url); |
|
| 277 | + $image_url['copyright'] = trim((string) $xml->channel->item->children('http://search.yahoo.com/mrss/')->copyright); |
|
| 278 | + $image_url['source_website'] = trim((string) $xml->channel->item->link); |
|
| 279 | 279 | $image_url['source'] = 'planespotters'; |
| 280 | 280 | return $image_url; |
| 281 | 281 | } |
@@ -291,30 +291,30 @@ discard block |
||
| 291 | 291 | * @return Array the aircraft thumbnail, orignal url and copyright |
| 292 | 292 | * |
| 293 | 293 | */ |
| 294 | - public function fromDeviantart($type,$registration, $name='') { |
|
| 294 | + public function fromDeviantart($type, $registration, $name = '') { |
|
| 295 | 295 | $Common = new Common(); |
| 296 | 296 | if ($type == 'aircraft') { |
| 297 | 297 | // If aircraft registration is only number, also check with aircraft model |
| 298 | - if (preg_match('/^[[:digit]]+$/',$registration) && $name != '') { |
|
| 299 | - $url= 'http://backend.deviantart.com/rss.xml?type=deviation&q='.$registration.'%20'.urlencode($name); |
|
| 298 | + if (preg_match('/^[[:digit]]+$/', $registration) && $name != '') { |
|
| 299 | + $url = 'http://backend.deviantart.com/rss.xml?type=deviation&q='.$registration.'%20'.urlencode($name); |
|
| 300 | 300 | } else { |
| 301 | - $url= 'http://backend.deviantart.com/rss.xml?type=deviation&q=aircraft%20'.$registration; |
|
| 301 | + $url = 'http://backend.deviantart.com/rss.xml?type=deviation&q=aircraft%20'.$registration; |
|
| 302 | 302 | } |
| 303 | 303 | } elseif ($type == 'marine') { |
| 304 | - $url= 'http://backend.deviantart.com/rss.xml?type=deviation&q=ship%20"'.urlencode($name).'"'; |
|
| 304 | + $url = 'http://backend.deviantart.com/rss.xml?type=deviation&q=ship%20"'.urlencode($name).'"'; |
|
| 305 | 305 | } else { |
| 306 | - $url= 'http://backend.deviantart.com/rss.xml?type=deviation&q="'.urlencode($name).'"'; |
|
| 306 | + $url = 'http://backend.deviantart.com/rss.xml?type=deviation&q="'.urlencode($name).'"'; |
|
| 307 | 307 | } |
| 308 | 308 | $data = $Common->getData($url); |
| 309 | 309 | if ($xml = simplexml_load_string($data)) { |
| 310 | 310 | if (isset($xml->channel->item->link)) { |
| 311 | 311 | $image_url = array(); |
| 312 | - $thumbnail_url = trim((string)$xml->channel->item->children('http://search.yahoo.com/mrss/')->thumbnail->attributes()->url); |
|
| 312 | + $thumbnail_url = trim((string) $xml->channel->item->children('http://search.yahoo.com/mrss/')->thumbnail->attributes()->url); |
|
| 313 | 313 | $image_url['thumbnail'] = $thumbnail_url; |
| 314 | - $original_url = trim((string)$xml->channel->item->children('http://search.yahoo.com/mrss/')->content->attributes()->url); |
|
| 314 | + $original_url = trim((string) $xml->channel->item->children('http://search.yahoo.com/mrss/')->content->attributes()->url); |
|
| 315 | 315 | $image_url['original'] = $original_url; |
| 316 | - $image_url['copyright'] = str_replace('Copyright ','',trim((string)$xml->channel->item->children('http://search.yahoo.com/mrss/')->copyright)); |
|
| 317 | - $image_url['source_website'] = trim((string)$xml->channel->item->link); |
|
| 316 | + $image_url['copyright'] = str_replace('Copyright ', '', trim((string) $xml->channel->item->children('http://search.yahoo.com/mrss/')->copyright)); |
|
| 317 | + $image_url['source_website'] = trim((string) $xml->channel->item->link); |
|
| 318 | 318 | $image_url['source'] = 'deviantart'; |
| 319 | 319 | return $image_url; |
| 320 | 320 | } |
@@ -330,32 +330,32 @@ discard block |
||
| 330 | 330 | * @return Array the aircraft thumbnail, orignal url and copyright |
| 331 | 331 | * |
| 332 | 332 | */ |
| 333 | - public function fromJetPhotos($type,$aircraft_registration, $aircraft_name='') { |
|
| 333 | + public function fromJetPhotos($type, $aircraft_registration, $aircraft_name = '') { |
|
| 334 | 334 | $Common = new Common(); |
| 335 | - $url= 'http://jetphotos.net/showphotos.php?displaymode=2®search='.$aircraft_registration; |
|
| 335 | + $url = 'http://jetphotos.net/showphotos.php?displaymode=2®search='.$aircraft_registration; |
|
| 336 | 336 | $data = $Common->getData($url); |
| 337 | 337 | $dom = new DOMDocument(); |
| 338 | 338 | @$dom->loadHTML($data); |
| 339 | 339 | $all_pics = array(); |
| 340 | - foreach($dom->getElementsByTagName('img') as $image) { |
|
| 340 | + foreach ($dom->getElementsByTagName('img') as $image) { |
|
| 341 | 341 | if ($image->getAttribute('itemprop') == "http://schema.org/image") { |
| 342 | 342 | $all_pics[] = $image->getAttribute('src'); |
| 343 | 343 | } |
| 344 | 344 | } |
| 345 | 345 | $all_authors = array(); |
| 346 | - foreach($dom->getElementsByTagName('meta') as $author) { |
|
| 346 | + foreach ($dom->getElementsByTagName('meta') as $author) { |
|
| 347 | 347 | if ($author->getAttribute('itemprop') == "http://schema.org/author") { |
| 348 | 348 | $all_authors[] = $author->getAttribute('content'); |
| 349 | 349 | } |
| 350 | 350 | } |
| 351 | 351 | $all_ref = array(); |
| 352 | - foreach($dom->getElementsByTagName('a') as $link) { |
|
| 352 | + foreach ($dom->getElementsByTagName('a') as $link) { |
|
| 353 | 353 | $all_ref[] = $link->getAttribute('href'); |
| 354 | 354 | } |
| 355 | 355 | if (isset($all_pics[0])) { |
| 356 | 356 | $image_url = array(); |
| 357 | 357 | $image_url['thumbnail'] = $all_pics[0]; |
| 358 | - $image_url['original'] = str_replace('_tb','',$all_pics[0]); |
|
| 358 | + $image_url['original'] = str_replace('_tb', '', $all_pics[0]); |
|
| 359 | 359 | $image_url['copyright'] = $all_authors[0]; |
| 360 | 360 | $image_url['source_website'] = 'http://jetphotos.net'.$all_ref[8]; |
| 361 | 361 | $image_url['source'] = 'JetPhotos'; |
@@ -372,24 +372,24 @@ discard block |
||
| 372 | 372 | * @return Array the aircraft thumbnail, orignal url and copyright |
| 373 | 373 | * |
| 374 | 374 | */ |
| 375 | - public function fromPlanePictures($type,$aircraft_registration, $aircraft_name='') { |
|
| 375 | + public function fromPlanePictures($type, $aircraft_registration, $aircraft_name = '') { |
|
| 376 | 376 | $Common = new Common(); |
| 377 | - $url= 'http://www.planepictures.net/netsearch4.cgi?srch='.$aircraft_registration.'&stype=reg&srng=2'; |
|
| 377 | + $url = 'http://www.planepictures.net/netsearch4.cgi?srch='.$aircraft_registration.'&stype=reg&srng=2'; |
|
| 378 | 378 | $data = $Common->getData($url); |
| 379 | 379 | $dom = new DOMDocument(); |
| 380 | 380 | @$dom->loadHTML($data); |
| 381 | 381 | $all_pics = array(); |
| 382 | - foreach($dom->getElementsByTagName('img') as $image) { |
|
| 382 | + foreach ($dom->getElementsByTagName('img') as $image) { |
|
| 383 | 383 | $all_pics[] = $image->getAttribute('src'); |
| 384 | 384 | } |
| 385 | 385 | $all_links = array(); |
| 386 | - foreach($dom->getElementsByTagName('a') as $link) { |
|
| 387 | - $all_links[] = array('text' => $link->textContent,'href' => $link->getAttribute('href')); |
|
| 386 | + foreach ($dom->getElementsByTagName('a') as $link) { |
|
| 387 | + $all_links[] = array('text' => $link->textContent, 'href' => $link->getAttribute('href')); |
|
| 388 | 388 | } |
| 389 | - if (isset($all_pics[1]) && !preg_match('/bit.ly/',$all_pics[1]) && !preg_match('/flagge/',$all_pics[1])) { |
|
| 389 | + if (isset($all_pics[1]) && !preg_match('/bit.ly/', $all_pics[1]) && !preg_match('/flagge/', $all_pics[1])) { |
|
| 390 | 390 | $image_url = array(); |
| 391 | 391 | $image_url['thumbnail'] = 'http://www.planepictures.net/'.$all_pics[1]; |
| 392 | - $image_url['original'] = 'http://www.planepictures.net/'.str_replace('_TN','',$all_pics[1]); |
|
| 392 | + $image_url['original'] = 'http://www.planepictures.net/'.str_replace('_TN', '', $all_pics[1]); |
|
| 393 | 393 | $image_url['copyright'] = $all_links[6]['text']; |
| 394 | 394 | $image_url['source_website'] = 'http://www.planepictures.net/'.$all_links[2]['href']; |
| 395 | 395 | $image_url['source'] = 'PlanePictures'; |
@@ -406,7 +406,7 @@ discard block |
||
| 406 | 406 | * @return Array the aircraft thumbnail, orignal url and copyright |
| 407 | 407 | * |
| 408 | 408 | */ |
| 409 | - public function fromFlickr($type,$registration,$name='') { |
|
| 409 | + public function fromFlickr($type, $registration, $name = '') { |
|
| 410 | 410 | $Common = new Common(); |
| 411 | 411 | if ($type == 'aircraft') { |
| 412 | 412 | if ($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='.$registration.','.urlencode($name); |
@@ -418,12 +418,12 @@ discard block |
||
| 418 | 418 | $data = $Common->getData($url); |
| 419 | 419 | if ($xml = simplexml_load_string($data)) { |
| 420 | 420 | if (isset($xml->channel->item)) { |
| 421 | - $original_url = trim((string)$xml->channel->item->enclosure->attributes()->url); |
|
| 421 | + $original_url = trim((string) $xml->channel->item->enclosure->attributes()->url); |
|
| 422 | 422 | $image_url = array(); |
| 423 | 423 | $image_url['thumbnail'] = $original_url; |
| 424 | 424 | $image_url['original'] = $original_url; |
| 425 | - $image_url['copyright'] = trim((string)$xml->channel->item->children('http://search.yahoo.com/mrss/')->credit); |
|
| 426 | - $image_url['source_website'] = trim((string)$xml->channel->item->link); |
|
| 425 | + $image_url['copyright'] = trim((string) $xml->channel->item->children('http://search.yahoo.com/mrss/')->credit); |
|
| 426 | + $image_url['source_website'] = trim((string) $xml->channel->item->link); |
|
| 427 | 427 | $image_url['source'] = 'flickr'; |
| 428 | 428 | return $image_url; |
| 429 | 429 | } |
@@ -431,7 +431,7 @@ discard block |
||
| 431 | 431 | return false; |
| 432 | 432 | } |
| 433 | 433 | |
| 434 | - public function fromIvaoMtl($type,$aircraft_icao,$airline_icao) { |
|
| 434 | + public function fromIvaoMtl($type, $aircraft_icao, $airline_icao) { |
|
| 435 | 435 | $Common = new Common(); |
| 436 | 436 | //echo "\n".'SEARCH IMAGE : http://mtlcatalog.ivao.aero/images/aircraft/'.$aircraft_icao.$airline_icao.'.jpg'; |
| 437 | 437 | if ($Common->urlexist('http://mtlcatalog.ivao.aero/images/aircraft/'.$aircraft_icao.$airline_icao.'.jpg')) { |
@@ -455,7 +455,7 @@ discard block |
||
| 455 | 455 | * @return Array the aircraft thumbnail, orignal url and copyright |
| 456 | 456 | * |
| 457 | 457 | */ |
| 458 | - public function fromBing($type,$aircraft_registration,$aircraft_name='') { |
|
| 458 | + public function fromBing($type, $aircraft_registration, $aircraft_name = '') { |
|
| 459 | 459 | global $globalImageBingKey; |
| 460 | 460 | $Common = new Common(); |
| 461 | 461 | if (!isset($globalImageBingKey) || $globalImageBingKey == '') return false; |
@@ -466,8 +466,8 @@ discard block |
||
| 466 | 466 | if ($aircraft_name != '') $url = 'https://api.datamarket.azure.com/Bing/Search/v1/Image?$format=json&$top=1&Query=%27'.urlencode($aircraft_name).'%20%2Bship%20-site:flickr.com%27'; |
| 467 | 467 | else $url = 'https://api.datamarket.azure.com/Bing/Search/v1/Image?$format=json&$top=1&Query=%27%2B'.$aircraft_registration.'%20%2Bship%20-site:flickr.com%27'; |
| 468 | 468 | } |
| 469 | - $headers = array("Authorization: Basic " . base64_encode("ignored:".$globalImageBingKey)); |
|
| 470 | - $data = $Common->getData($url,'get','',$headers); |
|
| 469 | + $headers = array("Authorization: Basic ".base64_encode("ignored:".$globalImageBingKey)); |
|
| 470 | + $data = $Common->getData($url, 'get', '', $headers); |
|
| 471 | 471 | $result = json_decode($data); |
| 472 | 472 | if (isset($result->d->results[0]->MediaUrl)) { |
| 473 | 473 | $image_url = array(); |
@@ -492,14 +492,14 @@ discard block |
||
| 492 | 492 | * @return Array the aircraft thumbnail, orignal url and copyright |
| 493 | 493 | * |
| 494 | 494 | */ |
| 495 | - public function fromAirportData($type,$aircraft_registration,$aircraft_name='') { |
|
| 495 | + public function fromAirportData($type, $aircraft_registration, $aircraft_name = '') { |
|
| 496 | 496 | $Common = new Common(); |
| 497 | 497 | $url = 'http://www.airport-data.com/api/ac_thumb.json?&n=1&r='.$aircraft_registration; |
| 498 | 498 | $data = $Common->getData($url); |
| 499 | 499 | $result = json_decode($data); |
| 500 | 500 | if (isset($result->count) && $result->count > 0) { |
| 501 | 501 | $image_url = array(); |
| 502 | - $image_url['original'] = str_replace('thumbnails','large',$result->data[0]->image); |
|
| 502 | + $image_url['original'] = str_replace('thumbnails', 'large', $result->data[0]->image); |
|
| 503 | 503 | $image_url['source_website'] = $result->data[0]->link; |
| 504 | 504 | $image_url['thumbnail'] = $result->data[0]->image; |
| 505 | 505 | $image_url['copyright'] = $result->data[0]->photographer; |
@@ -517,7 +517,7 @@ discard block |
||
| 517 | 517 | * @return Array the aircraft thumbnail, orignal url and copyright |
| 518 | 518 | * |
| 519 | 519 | */ |
| 520 | - public function fromWikimedia($type,$registration,$name='') { |
|
| 520 | + public function fromWikimedia($type, $registration, $name = '') { |
|
| 521 | 521 | $Common = new Common(); |
| 522 | 522 | if ($type == 'aircraft') { |
| 523 | 523 | if ($name != '') $url = 'https://commons.wikimedia.org/w/api.php?action=query&list=search&format=json&srlimit=1&srnamespace=6&continue&srsearch="'.$registration.'"%20'.urlencode($name); |
@@ -530,7 +530,7 @@ discard block |
||
| 530 | 530 | $result = json_decode($data); |
| 531 | 531 | if (isset($result->query->search[0]->title)) { |
| 532 | 532 | $fileo = $result->query->search[0]->title; |
| 533 | - if (substr($fileo,-3) == 'pdf') return false; |
|
| 533 | + if (substr($fileo, -3) == 'pdf') return false; |
|
| 534 | 534 | $file = urlencode($fileo); |
| 535 | 535 | $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; |
| 536 | 536 | $data2 = $Common->getData($url2); |
@@ -555,11 +555,11 @@ discard block |
||
| 555 | 555 | if (isset($result2->query->pages)) { |
| 556 | 556 | foreach ($result2->query->pages as $page) { |
| 557 | 557 | if (isset($page->imageinfo[0]->extmetadata->Artist)) { |
| 558 | - $image_url['copyright'] = preg_replace('/ from(.*)/','',strip_tags($page->imageinfo[0]->extmetadata->Artist->value)); |
|
| 558 | + $image_url['copyright'] = preg_replace('/ from(.*)/', '', strip_tags($page->imageinfo[0]->extmetadata->Artist->value)); |
|
| 559 | 559 | if (isset($page->imageinfo[0]->extmetadata->License->value)) { |
| 560 | 560 | $image_url['copyright'] = $image_url['copyright'].' (under '.$page->imageinfo[0]->extmetadata->License->value.')'; |
| 561 | 561 | } |
| 562 | - $image_url['copyright'] = trim(str_replace('\n','',$image_url['copyright'])); |
|
| 562 | + $image_url['copyright'] = trim(str_replace('\n', '', $image_url['copyright'])); |
|
| 563 | 563 | return $image_url; |
| 564 | 564 | } |
| 565 | 565 | } |
@@ -578,7 +578,7 @@ discard block |
||
| 578 | 578 | * @return Array the aircraft thumbnail, orignal url and copyright |
| 579 | 579 | * |
| 580 | 580 | */ |
| 581 | - public function fromCustomSource($type,$registration,$name='') { |
|
| 581 | + public function fromCustomSource($type, $registration, $name = '') { |
|
| 582 | 582 | global $globalAircraftImageCustomSources, $globalMarineImageCustomSources, $globalDebug; |
| 583 | 583 | //$globalAircraftImageCustomSource[] = array('thumbnail' => '','original' => '', 'copyright' => '', 'source_website' => '', 'source' => '','exif' => true); |
| 584 | 584 | if (!empty($globalAircraftImageCustomSources) && $type == 'aircraft') { |
@@ -595,15 +595,15 @@ discard block |
||
| 595 | 595 | print_r($source); |
| 596 | 596 | print_r($customsources); |
| 597 | 597 | } |
| 598 | - $url = str_replace('{registration}',$registration,$source['original']); |
|
| 599 | - $url_thumbnail = str_replace('{registration}',$registration,$source['thumbnail']); |
|
| 598 | + $url = str_replace('{registration}', $registration, $source['original']); |
|
| 599 | + $url_thumbnail = str_replace('{registration}', $registration, $source['thumbnail']); |
|
| 600 | 600 | if ($Common->urlexist($url)) { |
| 601 | 601 | $image_url = array(); |
| 602 | 602 | $image_url['thumbnail'] = $url_thumbnail; |
| 603 | 603 | $image_url['original'] = $url; |
| 604 | 604 | if ($source['exif'] && exif_imagetype($url) == IMAGETYPE_JPEG) $exifCopyright = $this->getExifCopyright($url); |
| 605 | 605 | else $exifCopyright = ''; |
| 606 | - if ($exifCopyright != '') $image_url['copyright'] = $exifCopyright; |
|
| 606 | + if ($exifCopyright != '') $image_url['copyright'] = $exifCopyright; |
|
| 607 | 607 | elseif (isset($source['copyright'])) $image_url['copyright'] = $source['copyright']; |
| 608 | 608 | else $image_url['copyright'] = $source['source_website']; |
| 609 | 609 | $image_url['source_website'] = $source['source_website']; |
@@ -627,19 +627,19 @@ discard block |
||
| 627 | 627 | print_r($source); |
| 628 | 628 | print_r($customsources); |
| 629 | 629 | } |
| 630 | - $url = str_replace('{registration}',$registration,$source['original']); |
|
| 631 | - $url = str_replace('{mmsi}',$registration,$url); |
|
| 632 | - $url = str_replace('{name}',$name,$url); |
|
| 633 | - $url_thumbnail = str_replace('{registration}',$registration,$source['thumbnail']); |
|
| 634 | - $url_thumbnail = str_replace('{mmsi}',$registration,$url_thumbnail); |
|
| 635 | - $url_thumbnail = str_replace('{name}',$name,$url_thumbnail); |
|
| 630 | + $url = str_replace('{registration}', $registration, $source['original']); |
|
| 631 | + $url = str_replace('{mmsi}', $registration, $url); |
|
| 632 | + $url = str_replace('{name}', $name, $url); |
|
| 633 | + $url_thumbnail = str_replace('{registration}', $registration, $source['thumbnail']); |
|
| 634 | + $url_thumbnail = str_replace('{mmsi}', $registration, $url_thumbnail); |
|
| 635 | + $url_thumbnail = str_replace('{name}', $name, $url_thumbnail); |
|
| 636 | 636 | if ($Common->urlexist($url)) { |
| 637 | 637 | $image_url = array(); |
| 638 | 638 | $image_url['thumbnail'] = $url_thumbnail; |
| 639 | 639 | $image_url['original'] = $url; |
| 640 | 640 | if ($source['exif'] && exif_imagetype($url) == IMAGETYPE_JPEG) $exifCopyright = $this->getExifCopyright($url); |
| 641 | 641 | else $exifCopyright = ''; |
| 642 | - if ($exifCopyright != '') $image_url['copyright'] = $exifCopyright; |
|
| 642 | + if ($exifCopyright != '') $image_url['copyright'] = $exifCopyright; |
|
| 643 | 643 | elseif (isset($source['copyright'])) $image_url['copyright'] = $source['copyright']; |
| 644 | 644 | else $image_url['copyright'] = $source['source_website']; |
| 645 | 645 | $image_url['source_website'] = $source['source_website']; |
@@ -9,7 +9,9 @@ discard block |
||
| 9 | 9 | public function __construct($dbc = null) { |
| 10 | 10 | $Connection = new Connection($dbc); |
| 11 | 11 | $this->db = $Connection->db(); |
| 12 | - if ($this->db === null) die('Error: No DB connection.'); |
|
| 12 | + if ($this->db === null) { |
|
| 13 | + die('Error: No DB connection.'); |
|
| 14 | + } |
|
| 13 | 15 | } |
| 14 | 16 | |
| 15 | 17 | /** |
@@ -24,7 +26,9 @@ discard block |
||
| 24 | 26 | $aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING); |
| 25 | 27 | $airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING); |
| 26 | 28 | $reg = $registration; |
| 27 | - if ($reg == '' && $aircraft_icao != '') $reg = $aircraft_icao.$airline_icao; |
|
| 29 | + if ($reg == '' && $aircraft_icao != '') { |
|
| 30 | + $reg = $aircraft_icao.$airline_icao; |
|
| 31 | + } |
|
| 28 | 32 | $reg = trim($reg); |
| 29 | 33 | $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 |
| 30 | 34 | FROM spotter_image |
@@ -32,9 +36,13 @@ discard block |
||
| 32 | 36 | $sth = $this->db->prepare($query); |
| 33 | 37 | $sth->execute(array(':registration' => $reg)); |
| 34 | 38 | $result = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 35 | - if (!empty($result)) return $result; |
|
| 36 | - elseif ($registration != '') return $this->getSpotterImage('',$aircraft_icao,$airline_icao); |
|
| 37 | - else return array(); |
|
| 39 | + if (!empty($result)) { |
|
| 40 | + return $result; |
|
| 41 | + } elseif ($registration != '') { |
|
| 42 | + return $this->getSpotterImage('',$aircraft_icao,$airline_icao); |
|
| 43 | + } else { |
|
| 44 | + return array(); |
|
| 45 | + } |
|
| 38 | 46 | } |
| 39 | 47 | |
| 40 | 48 | /** |
@@ -77,8 +85,11 @@ discard block |
||
| 77 | 85 | public function getExifCopyright($url) { |
| 78 | 86 | $exif = exif_read_data($url); |
| 79 | 87 | $copyright = ''; |
| 80 | - if (isset($exif['COMPUTED']['copyright'])) $copyright = $exif['COMPUTED']['copyright']; |
|
| 81 | - elseif (isset($exif['copyright'])) $copyright = $exif['copyright']; |
|
| 88 | + if (isset($exif['COMPUTED']['copyright'])) { |
|
| 89 | + $copyright = $exif['COMPUTED']['copyright']; |
|
| 90 | + } elseif (isset($exif['copyright'])) { |
|
| 91 | + $copyright = $exif['copyright']; |
|
| 92 | + } |
|
| 82 | 93 | if ($copyright != '') { |
| 83 | 94 | $copyright = str_replace('Copyright ','',$copyright); |
| 84 | 95 | $copyright = str_replace('© ','',$copyright); |
@@ -96,17 +107,27 @@ discard block |
||
| 96 | 107 | public function addSpotterImage($registration,$aircraft_icao = '', $airline_icao = '') |
| 97 | 108 | { |
| 98 | 109 | global $globalDebug,$globalAircraftImageFetch; |
| 99 | - if (isset($globalAircraftImageFetch) && !$globalAircraftImageFetch) return ''; |
|
| 110 | + if (isset($globalAircraftImageFetch) && !$globalAircraftImageFetch) { |
|
| 111 | + return ''; |
|
| 112 | + } |
|
| 100 | 113 | $registration = filter_var($registration,FILTER_SANITIZE_STRING); |
| 101 | 114 | $registration = trim($registration); |
| 102 | 115 | //getting the aircraft image |
| 103 | - if ($globalDebug && $registration != '') echo 'Try to find an aircraft image for '.$registration.'...'; |
|
| 104 | - elseif ($globalDebug && $aircraft_icao != '') echo 'Try to find an aircraft image for '.$aircraft_icao.'...'; |
|
| 105 | - elseif ($globalDebug && $airline_icao != '') echo 'Try to find an aircraft image for '.$airline_icao.'...'; |
|
| 116 | + if ($globalDebug && $registration != '') { |
|
| 117 | + echo 'Try to find an aircraft image for '.$registration.'...'; |
|
| 118 | + } elseif ($globalDebug && $aircraft_icao != '') { |
|
| 119 | + echo 'Try to find an aircraft image for '.$aircraft_icao.'...'; |
|
| 120 | + } elseif ($globalDebug && $airline_icao != '') { |
|
| 121 | + echo 'Try to find an aircraft image for '.$airline_icao.'...'; |
|
| 122 | + } |
|
| 106 | 123 | $image_url = $this->findAircraftImage($registration,$aircraft_icao,$airline_icao); |
| 107 | - if ($registration == '' && $aircraft_icao != '') $registration = $aircraft_icao.$airline_icao; |
|
| 124 | + if ($registration == '' && $aircraft_icao != '') { |
|
| 125 | + $registration = $aircraft_icao.$airline_icao; |
|
| 126 | + } |
|
| 108 | 127 | if ($image_url['original'] != '') { |
| 109 | - if ($globalDebug) echo 'Found !'."\n"; |
|
| 128 | + if ($globalDebug) { |
|
| 129 | + echo 'Found !'."\n"; |
|
| 130 | + } |
|
| 110 | 131 | $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)"; |
| 111 | 132 | try { |
| 112 | 133 | $sth = $this->db->prepare($query); |
@@ -115,7 +136,9 @@ discard block |
||
| 115 | 136 | echo $e->getMessage()."\n"; |
| 116 | 137 | return "error"; |
| 117 | 138 | } |
| 118 | - } elseif ($globalDebug) echo "Not found :'(\n"; |
|
| 139 | + } elseif ($globalDebug) { |
|
| 140 | + echo "Not found :'(\n"; |
|
| 141 | + } |
|
| 119 | 142 | return "success"; |
| 120 | 143 | } |
| 121 | 144 | |
@@ -128,7 +151,9 @@ discard block |
||
| 128 | 151 | public function addMarineImage($mmsi,$imo = '',$name = '') |
| 129 | 152 | { |
| 130 | 153 | global $globalDebug,$globalMarineImageFetch; |
| 131 | - if (isset($globalMarineImageFetch) && !$globalMarineImageFetch) return ''; |
|
| 154 | + if (isset($globalMarineImageFetch) && !$globalMarineImageFetch) { |
|
| 155 | + return ''; |
|
| 156 | + } |
|
| 132 | 157 | $mmsi = filter_var($mmsi,FILTER_SANITIZE_STRING); |
| 133 | 158 | $imo = filter_var($imo,FILTER_SANITIZE_STRING); |
| 134 | 159 | $name = filter_var($name,FILTER_SANITIZE_STRING); |
@@ -138,16 +163,22 @@ discard block |
||
| 138 | 163 | $identity = $Marine->getIdentity($mmsi); |
| 139 | 164 | if (isset($identity[0]['mmsi'])) { |
| 140 | 165 | $imo = $identity[0]['imo']; |
| 141 | - if ($identity[0]['ship_name'] != '') $name = $identity[0]['ship_name']; |
|
| 166 | + if ($identity[0]['ship_name'] != '') { |
|
| 167 | + $name = $identity[0]['ship_name']; |
|
| 168 | + } |
|
| 142 | 169 | } |
| 143 | 170 | } |
| 144 | 171 | unset($Marine); |
| 145 | 172 | |
| 146 | 173 | //getting the aircraft image |
| 147 | - if ($globalDebug && $name != '') echo 'Try to find an vessel image for '.$name.'...'; |
|
| 174 | + if ($globalDebug && $name != '') { |
|
| 175 | + echo 'Try to find an vessel image for '.$name.'...'; |
|
| 176 | + } |
|
| 148 | 177 | $image_url = $this->findMarineImage($mmsi,$imo,$name); |
| 149 | 178 | if ($image_url['original'] != '') { |
| 150 | - if ($globalDebug) echo 'Found !'."\n"; |
|
| 179 | + if ($globalDebug) { |
|
| 180 | + echo 'Found !'."\n"; |
|
| 181 | + } |
|
| 151 | 182 | $query = "INSERT INTO marine_image (mmsi,imo,name, image, image_thumbnail, image_copyright, image_source,image_source_website) VALUES (:mmsi,:imo,:name,:image,:image_thumbnail,:copyright,:source,:source_website)"; |
| 152 | 183 | try { |
| 153 | 184 | $sth = $this->db->prepare($query); |
@@ -156,7 +187,9 @@ discard block |
||
| 156 | 187 | echo $e->getMessage()."\n"; |
| 157 | 188 | return "error"; |
| 158 | 189 | } |
| 159 | - } elseif ($globalDebug) echo "Not found :'(\n"; |
|
| 190 | + } elseif ($globalDebug) { |
|
| 191 | + echo "Not found :'(\n"; |
|
| 192 | + } |
|
| 160 | 193 | return "success"; |
| 161 | 194 | } |
| 162 | 195 | |
@@ -171,41 +204,85 @@ discard block |
||
| 171 | 204 | { |
| 172 | 205 | global $globalAircraftImageSources, $globalIVAO, $globalAircraftImageCheckICAO, $globalVA; |
| 173 | 206 | $Spotter = new Spotter($this->db); |
| 174 | - if (!isset($globalIVAO)) $globalIVAO = FALSE; |
|
| 207 | + if (!isset($globalIVAO)) { |
|
| 208 | + $globalIVAO = FALSE; |
|
| 209 | + } |
|
| 175 | 210 | $aircraft_registration = filter_var($aircraft_registration,FILTER_SANITIZE_STRING); |
| 176 | 211 | if ($aircraft_registration != '' && (!isset($globalVA) || $globalVA !== TRUE)) { |
| 177 | - if (strpos($aircraft_registration,'/') !== false) return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => ''); |
|
| 212 | + if (strpos($aircraft_registration,'/') !== false) { |
|
| 213 | + return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => ''); |
|
| 214 | + } |
|
| 178 | 215 | $aircraft_registration = urlencode(trim($aircraft_registration)); |
| 179 | 216 | $aircraft_info = $Spotter->getAircraftInfoByRegistration($aircraft_registration); |
| 180 | - if (isset($aircraft_info[0]['aircraft_name'])) $aircraft_name = $aircraft_info[0]['aircraft_name']; |
|
| 181 | - else $aircraft_name = ''; |
|
| 182 | - if (isset($aircraft_info[0]['aircraft_icao'])) $aircraft_name = $aircraft_info[0]['aircraft_icao']; |
|
| 183 | - else $aircraft_icao = ''; |
|
| 184 | - if (isset($aircraft_info[0]['airline_icao'])) $airline_icao = $aircraft_info[0]['airline_icao']; |
|
| 185 | - else $airline_icao = ''; |
|
| 217 | + if (isset($aircraft_info[0]['aircraft_name'])) { |
|
| 218 | + $aircraft_name = $aircraft_info[0]['aircraft_name']; |
|
| 219 | + } else { |
|
| 220 | + $aircraft_name = ''; |
|
| 221 | + } |
|
| 222 | + if (isset($aircraft_info[0]['aircraft_icao'])) { |
|
| 223 | + $aircraft_name = $aircraft_info[0]['aircraft_icao']; |
|
| 224 | + } else { |
|
| 225 | + $aircraft_icao = ''; |
|
| 226 | + } |
|
| 227 | + if (isset($aircraft_info[0]['airline_icao'])) { |
|
| 228 | + $airline_icao = $aircraft_info[0]['airline_icao']; |
|
| 229 | + } else { |
|
| 230 | + $airline_icao = ''; |
|
| 231 | + } |
|
| 186 | 232 | } elseif ($aircraft_icao != '') { |
| 187 | 233 | $aircraft_info = $Spotter->getAllAircraftInfo($aircraft_icao); |
| 188 | - if (isset($aircraft_info[0]['type'])) $aircraft_name = $aircraft_info[0]['type']; |
|
| 189 | - else $aircraft_name = ''; |
|
| 234 | + if (isset($aircraft_info[0]['type'])) { |
|
| 235 | + $aircraft_name = $aircraft_info[0]['type']; |
|
| 236 | + } else { |
|
| 237 | + $aircraft_name = ''; |
|
| 238 | + } |
|
| 190 | 239 | $aircraft_registration = $aircraft_icao; |
| 191 | - } else return array('thumbnail' => '','original' => '', 'copyright' => '', 'source' => '','source_website' => ''); |
|
| 240 | + } else { |
|
| 241 | + return array('thumbnail' => '','original' => '', 'copyright' => '', 'source' => '','source_website' => ''); |
|
| 242 | + } |
|
| 192 | 243 | unset($Spotter); |
| 193 | - if (!isset($globalAircraftImageSources)) $globalAircraftImageSources = array('ivaomtl','wikimedia','airportdata','deviantart','flickr','bing','jetphotos','planepictures','planespotters'); |
|
| 244 | + if (!isset($globalAircraftImageSources)) { |
|
| 245 | + $globalAircraftImageSources = array('ivaomtl','wikimedia','airportdata','deviantart','flickr','bing','jetphotos','planepictures','planespotters'); |
|
| 246 | + } |
|
| 194 | 247 | foreach ($globalAircraftImageSources as $source) { |
| 195 | 248 | $source = strtolower($source); |
| 196 | - if ($source == 'ivaomtl' && $globalIVAO && $aircraft_icao != '' && $airline_icao != '') $images_array = $this->fromIvaoMtl('aircraft',$aircraft_icao,$airline_icao); |
|
| 197 | - if ($source == 'planespotters' && !$globalIVAO && extension_loaded('simplexml')) $images_array = $this->fromPlanespotters('aircraft',$aircraft_registration,$aircraft_name); |
|
| 198 | - if ($source == 'flickr' && extension_loaded('simplexml')) $images_array = $this->fromFlickr('aircraft',$aircraft_registration,$aircraft_name); |
|
| 199 | - if ($source == 'bing') $images_array = $this->fromBing('aircraft',$aircraft_registration,$aircraft_name); |
|
| 200 | - if ($source == 'deviantart' && extension_loaded('simplexml')) $images_array = $this->fromDeviantart('aircraft',$aircraft_registration,$aircraft_name); |
|
| 201 | - if ($source == 'wikimedia') $images_array = $this->fromWikimedia('aircraft',$aircraft_registration,$aircraft_name); |
|
| 202 | - if ($source == 'jetphotos' && !$globalIVAO && class_exists("DomDocument")) $images_array = $this->fromJetPhotos('aircraft',$aircraft_registration,$aircraft_name); |
|
| 203 | - if ($source == 'planepictures' && !$globalIVAO && class_exists("DomDocument")) $images_array = $this->fromPlanePictures('aircraft',$aircraft_registration,$aircraft_name); |
|
| 204 | - if ($source == 'airportdata' && !$globalIVAO) $images_array = $this->fromAirportData('aircraft',$aircraft_registration,$aircraft_name); |
|
| 205 | - if ($source == 'customsources') $images_array = $this->fromCustomSource('aircraft',$aircraft_registration,$aircraft_name); |
|
| 206 | - if (isset($images_array) && $images_array['original'] != '') return $images_array; |
|
| 207 | - } |
|
| 208 | - if ((!isset($globalAircraftImageCheckICAO) || $globalAircraftImageCheckICAO === TRUE) && isset($aircraft_icao)) return $this->findAircraftImage($aircraft_icao); |
|
| 249 | + if ($source == 'ivaomtl' && $globalIVAO && $aircraft_icao != '' && $airline_icao != '') { |
|
| 250 | + $images_array = $this->fromIvaoMtl('aircraft',$aircraft_icao,$airline_icao); |
|
| 251 | + } |
|
| 252 | + if ($source == 'planespotters' && !$globalIVAO && extension_loaded('simplexml')) { |
|
| 253 | + $images_array = $this->fromPlanespotters('aircraft',$aircraft_registration,$aircraft_name); |
|
| 254 | + } |
|
| 255 | + if ($source == 'flickr' && extension_loaded('simplexml')) { |
|
| 256 | + $images_array = $this->fromFlickr('aircraft',$aircraft_registration,$aircraft_name); |
|
| 257 | + } |
|
| 258 | + if ($source == 'bing') { |
|
| 259 | + $images_array = $this->fromBing('aircraft',$aircraft_registration,$aircraft_name); |
|
| 260 | + } |
|
| 261 | + if ($source == 'deviantart' && extension_loaded('simplexml')) { |
|
| 262 | + $images_array = $this->fromDeviantart('aircraft',$aircraft_registration,$aircraft_name); |
|
| 263 | + } |
|
| 264 | + if ($source == 'wikimedia') { |
|
| 265 | + $images_array = $this->fromWikimedia('aircraft',$aircraft_registration,$aircraft_name); |
|
| 266 | + } |
|
| 267 | + if ($source == 'jetphotos' && !$globalIVAO && class_exists("DomDocument")) { |
|
| 268 | + $images_array = $this->fromJetPhotos('aircraft',$aircraft_registration,$aircraft_name); |
|
| 269 | + } |
|
| 270 | + if ($source == 'planepictures' && !$globalIVAO && class_exists("DomDocument")) { |
|
| 271 | + $images_array = $this->fromPlanePictures('aircraft',$aircraft_registration,$aircraft_name); |
|
| 272 | + } |
|
| 273 | + if ($source == 'airportdata' && !$globalIVAO) { |
|
| 274 | + $images_array = $this->fromAirportData('aircraft',$aircraft_registration,$aircraft_name); |
|
| 275 | + } |
|
| 276 | + if ($source == 'customsources') { |
|
| 277 | + $images_array = $this->fromCustomSource('aircraft',$aircraft_registration,$aircraft_name); |
|
| 278 | + } |
|
| 279 | + if (isset($images_array) && $images_array['original'] != '') { |
|
| 280 | + return $images_array; |
|
| 281 | + } |
|
| 282 | + } |
|
| 283 | + if ((!isset($globalAircraftImageCheckICAO) || $globalAircraftImageCheckICAO === TRUE) && isset($aircraft_icao)) { |
|
| 284 | + return $this->findAircraftImage($aircraft_icao); |
|
| 285 | + } |
|
| 209 | 286 | return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => ''); |
| 210 | 287 | } |
| 211 | 288 | |
@@ -225,7 +302,9 @@ discard block |
||
| 225 | 302 | //$imo = filter_var($imo,FILTER_SANITIZE_STRING); |
| 226 | 303 | $name = filter_var($name,FILTER_SANITIZE_STRING); |
| 227 | 304 | $name = trim($name); |
| 228 | - if (strlen($name) < 4) return array('thumbnail' => '','original' => '', 'copyright' => '', 'source' => '','source_website' => ''); |
|
| 305 | + if (strlen($name) < 4) { |
|
| 306 | + return array('thumbnail' => '','original' => '', 'copyright' => '', 'source' => '','source_website' => ''); |
|
| 307 | + } |
|
| 229 | 308 | /* |
| 230 | 309 | $Marine = new Marine($this->db); |
| 231 | 310 | if ($imo == '' || $name == '') { |
@@ -237,15 +316,29 @@ discard block |
||
| 237 | 316 | } |
| 238 | 317 | unset($Marine); |
| 239 | 318 | */ |
| 240 | - if (!isset($globalMarineImageSources)) $globalMarineImageSources = array('wikimedia','deviantart','flickr','bing'); |
|
| 319 | + if (!isset($globalMarineImageSources)) { |
|
| 320 | + $globalMarineImageSources = array('wikimedia','deviantart','flickr','bing'); |
|
| 321 | + } |
|
| 241 | 322 | foreach ($globalMarineImageSources as $source) { |
| 242 | 323 | $source = strtolower($source); |
| 243 | - if ($source == 'flickr') $images_array = $this->fromFlickr('marine',$mmsi,$name); |
|
| 244 | - if ($source == 'bing') $images_array = $this->fromBing('marine',$mmsi,$name); |
|
| 245 | - if ($source == 'deviantart') $images_array = $this->fromDeviantart('marine',$mmsi,$name); |
|
| 246 | - if ($source == 'wikimedia') $images_array = $this->fromWikimedia('marine',$mmsi,$name); |
|
| 247 | - if ($source == 'customsources') $images_array = $this->fromCustomSource('marine',$mmsi,$name); |
|
| 248 | - if (isset($images_array) && $images_array['original'] != '') return $images_array; |
|
| 324 | + if ($source == 'flickr') { |
|
| 325 | + $images_array = $this->fromFlickr('marine',$mmsi,$name); |
|
| 326 | + } |
|
| 327 | + if ($source == 'bing') { |
|
| 328 | + $images_array = $this->fromBing('marine',$mmsi,$name); |
|
| 329 | + } |
|
| 330 | + if ($source == 'deviantart') { |
|
| 331 | + $images_array = $this->fromDeviantart('marine',$mmsi,$name); |
|
| 332 | + } |
|
| 333 | + if ($source == 'wikimedia') { |
|
| 334 | + $images_array = $this->fromWikimedia('marine',$mmsi,$name); |
|
| 335 | + } |
|
| 336 | + if ($source == 'customsources') { |
|
| 337 | + $images_array = $this->fromCustomSource('marine',$mmsi,$name); |
|
| 338 | + } |
|
| 339 | + if (isset($images_array) && $images_array['original'] != '') { |
|
| 340 | + return $images_array; |
|
| 341 | + } |
|
| 249 | 342 | } |
| 250 | 343 | return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => ''); |
| 251 | 344 | } |
@@ -409,11 +502,17 @@ discard block |
||
| 409 | 502 | public function fromFlickr($type,$registration,$name='') { |
| 410 | 503 | $Common = new Common(); |
| 411 | 504 | if ($type == 'aircraft') { |
| 412 | - if ($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='.$registration.','.urlencode($name); |
|
| 413 | - 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='.$registration.',aircraft'; |
|
| 505 | + if ($name != '') { |
|
| 506 | + $url = 'https://api.flickr.com/services/feeds/photos_public.gne?format=rss2&license=1,2,3,4,5,6,7&per_page=1&tags='.$registration.','.urlencode($name); |
|
| 507 | + } else { |
|
| 508 | + $url = 'https://api.flickr.com/services/feeds/photos_public.gne?format=rss2&license=1,2,3,4,5,6,7&per_page=1&tags='.$registration.',aircraft'; |
|
| 509 | + } |
|
| 414 | 510 | } elseif ($type == 'marine') { |
| 415 | - if ($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=ship,'.urlencode($name); |
|
| 416 | - 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='.$registration.',ship'; |
|
| 511 | + if ($name != '') { |
|
| 512 | + $url = 'https://api.flickr.com/services/feeds/photos_public.gne?format=rss2&license=1,2,3,4,5,6,7&per_page=1&tags=ship,'.urlencode($name); |
|
| 513 | + } else { |
|
| 514 | + $url = 'https://api.flickr.com/services/feeds/photos_public.gne?format=rss2&license=1,2,3,4,5,6,7&per_page=1&tags='.$registration.',ship'; |
|
| 515 | + } |
|
| 417 | 516 | } |
| 418 | 517 | $data = $Common->getData($url); |
| 419 | 518 | if ($xml = simplexml_load_string($data)) { |
@@ -458,13 +557,21 @@ discard block |
||
| 458 | 557 | public function fromBing($type,$aircraft_registration,$aircraft_name='') { |
| 459 | 558 | global $globalImageBingKey; |
| 460 | 559 | $Common = new Common(); |
| 461 | - if (!isset($globalImageBingKey) || $globalImageBingKey == '') return false; |
|
| 560 | + if (!isset($globalImageBingKey) || $globalImageBingKey == '') { |
|
| 561 | + return false; |
|
| 562 | + } |
|
| 462 | 563 | if ($type == 'aircraft') { |
| 463 | - 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'; |
|
| 464 | - 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'; |
|
| 564 | + if ($aircraft_name != '') { |
|
| 565 | + $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'; |
|
| 566 | + } else { |
|
| 567 | + $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'; |
|
| 568 | + } |
|
| 465 | 569 | } elseif ($type == 'marine') { |
| 466 | - if ($aircraft_name != '') $url = 'https://api.datamarket.azure.com/Bing/Search/v1/Image?$format=json&$top=1&Query=%27'.urlencode($aircraft_name).'%20%2Bship%20-site:flickr.com%27'; |
|
| 467 | - else $url = 'https://api.datamarket.azure.com/Bing/Search/v1/Image?$format=json&$top=1&Query=%27%2B'.$aircraft_registration.'%20%2Bship%20-site:flickr.com%27'; |
|
| 570 | + if ($aircraft_name != '') { |
|
| 571 | + $url = 'https://api.datamarket.azure.com/Bing/Search/v1/Image?$format=json&$top=1&Query=%27'.urlencode($aircraft_name).'%20%2Bship%20-site:flickr.com%27'; |
|
| 572 | + } else { |
|
| 573 | + $url = 'https://api.datamarket.azure.com/Bing/Search/v1/Image?$format=json&$top=1&Query=%27%2B'.$aircraft_registration.'%20%2Bship%20-site:flickr.com%27'; |
|
| 574 | + } |
|
| 468 | 575 | } |
| 469 | 576 | $headers = array("Authorization: Basic " . base64_encode("ignored:".$globalImageBingKey)); |
| 470 | 577 | $data = $Common->getData($url,'get','',$headers); |
@@ -520,17 +627,25 @@ discard block |
||
| 520 | 627 | public function fromWikimedia($type,$registration,$name='') { |
| 521 | 628 | $Common = new Common(); |
| 522 | 629 | if ($type == 'aircraft') { |
| 523 | - if ($name != '') $url = 'https://commons.wikimedia.org/w/api.php?action=query&list=search&format=json&srlimit=1&srnamespace=6&continue&srsearch="'.$registration.'"%20'.urlencode($name); |
|
| 524 | - else $url = 'https://commons.wikimedia.org/w/api.php?action=query&list=search&format=json&srlimit=1&srnamespace=6&continue&srsearch="'.$registration.'"%20aircraft'; |
|
| 630 | + if ($name != '') { |
|
| 631 | + $url = 'https://commons.wikimedia.org/w/api.php?action=query&list=search&format=json&srlimit=1&srnamespace=6&continue&srsearch="'.$registration.'"%20'.urlencode($name); |
|
| 632 | + } else { |
|
| 633 | + $url = 'https://commons.wikimedia.org/w/api.php?action=query&list=search&format=json&srlimit=1&srnamespace=6&continue&srsearch="'.$registration.'"%20aircraft'; |
|
| 634 | + } |
|
| 525 | 635 | } elseif ($type == 'marine') { |
| 526 | - if ($name != '') $url = 'https://commons.wikimedia.org/w/api.php?action=query&list=search&format=json&srlimit=1&srnamespace=6&continue&srsearch="'.urlencode($name).'%20ship"'; |
|
| 527 | - else return false; |
|
| 636 | + if ($name != '') { |
|
| 637 | + $url = 'https://commons.wikimedia.org/w/api.php?action=query&list=search&format=json&srlimit=1&srnamespace=6&continue&srsearch="'.urlencode($name).'%20ship"'; |
|
| 638 | + } else { |
|
| 639 | + return false; |
|
| 640 | + } |
|
| 528 | 641 | } |
| 529 | 642 | $data = $Common->getData($url); |
| 530 | 643 | $result = json_decode($data); |
| 531 | 644 | if (isset($result->query->search[0]->title)) { |
| 532 | 645 | $fileo = $result->query->search[0]->title; |
| 533 | - if (substr($fileo,-3) == 'pdf') return false; |
|
| 646 | + if (substr($fileo,-3) == 'pdf') { |
|
| 647 | + return false; |
|
| 648 | + } |
|
| 534 | 649 | $file = urlencode($fileo); |
| 535 | 650 | $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; |
| 536 | 651 | $data2 = $Common->getData($url2); |
@@ -601,18 +716,27 @@ discard block |
||
| 601 | 716 | $image_url = array(); |
| 602 | 717 | $image_url['thumbnail'] = $url_thumbnail; |
| 603 | 718 | $image_url['original'] = $url; |
| 604 | - if ($source['exif'] && exif_imagetype($url) == IMAGETYPE_JPEG) $exifCopyright = $this->getExifCopyright($url); |
|
| 605 | - else $exifCopyright = ''; |
|
| 606 | - if ($exifCopyright != '') $image_url['copyright'] = $exifCopyright; |
|
| 607 | - elseif (isset($source['copyright'])) $image_url['copyright'] = $source['copyright']; |
|
| 608 | - else $image_url['copyright'] = $source['source_website']; |
|
| 719 | + if ($source['exif'] && exif_imagetype($url) == IMAGETYPE_JPEG) { |
|
| 720 | + $exifCopyright = $this->getExifCopyright($url); |
|
| 721 | + } else { |
|
| 722 | + $exifCopyright = ''; |
|
| 723 | + } |
|
| 724 | + if ($exifCopyright != '') { |
|
| 725 | + $image_url['copyright'] = $exifCopyright; |
|
| 726 | + } elseif (isset($source['copyright'])) { |
|
| 727 | + $image_url['copyright'] = $source['copyright']; |
|
| 728 | + } else { |
|
| 729 | + $image_url['copyright'] = $source['source_website']; |
|
| 730 | + } |
|
| 609 | 731 | $image_url['source_website'] = $source['source_website']; |
| 610 | 732 | $image_url['source'] = $source['source']; |
| 611 | 733 | return $image_url; |
| 612 | 734 | } |
| 613 | 735 | } |
| 614 | 736 | return false; |
| 615 | - } else return false; |
|
| 737 | + } else { |
|
| 738 | + return false; |
|
| 739 | + } |
|
| 616 | 740 | if (!empty($globalMarineImageCustomSources) && $type == 'marine') { |
| 617 | 741 | $customsources = array(); |
| 618 | 742 | if (!isset($globalMarineImageCustomSources[0])) { |
@@ -637,18 +761,27 @@ discard block |
||
| 637 | 761 | $image_url = array(); |
| 638 | 762 | $image_url['thumbnail'] = $url_thumbnail; |
| 639 | 763 | $image_url['original'] = $url; |
| 640 | - if ($source['exif'] && exif_imagetype($url) == IMAGETYPE_JPEG) $exifCopyright = $this->getExifCopyright($url); |
|
| 641 | - else $exifCopyright = ''; |
|
| 642 | - if ($exifCopyright != '') $image_url['copyright'] = $exifCopyright; |
|
| 643 | - elseif (isset($source['copyright'])) $image_url['copyright'] = $source['copyright']; |
|
| 644 | - else $image_url['copyright'] = $source['source_website']; |
|
| 764 | + if ($source['exif'] && exif_imagetype($url) == IMAGETYPE_JPEG) { |
|
| 765 | + $exifCopyright = $this->getExifCopyright($url); |
|
| 766 | + } else { |
|
| 767 | + $exifCopyright = ''; |
|
| 768 | + } |
|
| 769 | + if ($exifCopyright != '') { |
|
| 770 | + $image_url['copyright'] = $exifCopyright; |
|
| 771 | + } elseif (isset($source['copyright'])) { |
|
| 772 | + $image_url['copyright'] = $source['copyright']; |
|
| 773 | + } else { |
|
| 774 | + $image_url['copyright'] = $source['source_website']; |
|
| 775 | + } |
|
| 645 | 776 | $image_url['source_website'] = $source['source_website']; |
| 646 | 777 | $image_url['source'] = $source['source']; |
| 647 | 778 | return $image_url; |
| 648 | 779 | } |
| 649 | 780 | } |
| 650 | 781 | return false; |
| 651 | - } else return false; |
|
| 782 | + } else { |
|
| 783 | + return false; |
|
| 784 | + } |
|
| 652 | 785 | } |
| 653 | 786 | } |
| 654 | 787 | |