@@ -25,9 +25,9 @@ discard block |
||
| 25 | 25 | / @param String $source source of data |
| 26 | 26 | */ |
| 27 | 27 | |
| 28 | - public function addSchedule($ident,$departure_airport_icao,$departure_airport_time,$arrival_airport_icao,$arrival_airport_time,$source = 'website') { |
|
| 28 | + public function addSchedule($ident, $departure_airport_icao, $departure_airport_time, $arrival_airport_icao, $arrival_airport_time, $source = 'website') { |
|
| 29 | 29 | date_default_timezone_set('UTC'); |
| 30 | - $date = date("Y-m-d H:i:s",time()); |
|
| 30 | + $date = date("Y-m-d H:i:s", time()); |
|
| 31 | 31 | //if ($departure_airport_time == '' && $arrival_airport_time == '') exit; |
| 32 | 32 | //$query = "SELECT COUNT(*) FROM schedule WHERE ident = :ident"; |
| 33 | 33 | $query = "SELECT COUNT(*) FROM routes WHERE CallSign = :ident"; |
@@ -35,69 +35,69 @@ discard block |
||
| 35 | 35 | try { |
| 36 | 36 | $sth = $this->db->prepare($query); |
| 37 | 37 | $sth->execute($query_values); |
| 38 | - } catch(PDOException $e) { |
|
| 38 | + } catch (PDOException $e) { |
|
| 39 | 39 | return "error : ".$e->getMessage(); |
| 40 | 40 | } |
| 41 | 41 | if ($sth->fetchColumn() > 0) { |
| 42 | 42 | if ($departure_airport_time == '' && $arrival_airport_time == '') { |
| 43 | 43 | $query = "SELECT COUNT(*) FROM routes WHERE CallSign = :ident AND FromAirport_ICAO = :departure_airport_icao AND ToAirport_ICAO = :arrival_airport_icao"; |
| 44 | - $query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':arrival_airport_icao' => $arrival_airport_icao); |
|
| 44 | + $query_values = array(':ident' => $ident, ':departure_airport_icao' => $departure_airport_icao, ':arrival_airport_icao' => $arrival_airport_icao); |
|
| 45 | 45 | } elseif ($arrival_airport_time == '') { |
| 46 | 46 | $query = "SELECT COUNT(*) FROM routes WHERE CallSign = :ident AND FromAirport_ICAO = :departure_airport_icao AND FromAirport_Time = :departure_airport_time AND ToAirport_ICAO = :arrival_airport_icao"; |
| 47 | - $query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':departure_airport_time' => $departure_airport_time,':arrival_airport_icao' => $arrival_airport_icao); |
|
| 47 | + $query_values = array(':ident' => $ident, ':departure_airport_icao' => $departure_airport_icao, ':departure_airport_time' => $departure_airport_time, ':arrival_airport_icao' => $arrival_airport_icao); |
|
| 48 | 48 | } elseif ($departure_airport_time == '') { |
| 49 | 49 | $query = "SELECT COUNT(*) FROM routes WHERE CallSign = :ident AND FromAirport_ICAO = :departure_airport_icao AND ToAirport_ICAO = :arrival_airport_icao AND ToAirport_Time = :arrival_airport_time"; |
| 50 | - $query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':arrival_airport_icao' => $arrival_airport_icao,':arrival_airport_time' => $arrival_airport_time); |
|
| 50 | + $query_values = array(':ident' => $ident, ':departure_airport_icao' => $departure_airport_icao, ':arrival_airport_icao' => $arrival_airport_icao, ':arrival_airport_time' => $arrival_airport_time); |
|
| 51 | 51 | } else { |
| 52 | 52 | //$query = "SELECT COUNT(*) FROM schedule WHERE ident = :ident AND departure_airport_icao = :departure_airport_icao AND departure_airport_time = :departure_airport_time AND arrival_airport_icao = :arrival_airport_icao AND arrival_airport_time = :arrival_airport_time"; |
| 53 | 53 | $query = "SELECT COUNT(*) FROM routes WHERE CallSign = :ident AND FromAirport_ICAO = :departure_airport_icao AND FromAirport_Time = :departure_airport_time AND ToAirport_ICAO = :arrival_airport_icao AND ToAirport_Time = :arrival_airport_time"; |
| 54 | - $query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':departure_airport_time' => $departure_airport_time,':arrival_airport_icao' => $arrival_airport_icao,':arrival_airport_time' => $arrival_airport_time); |
|
| 54 | + $query_values = array(':ident' => $ident, ':departure_airport_icao' => $departure_airport_icao, ':departure_airport_time' => $departure_airport_time, ':arrival_airport_icao' => $arrival_airport_icao, ':arrival_airport_time' => $arrival_airport_time); |
|
| 55 | 55 | } |
| 56 | 56 | try { |
| 57 | 57 | $sth = $this->db->prepare($query); |
| 58 | 58 | $sth->execute($query_values); |
| 59 | - } catch(PDOException $e) { |
|
| 59 | + } catch (PDOException $e) { |
|
| 60 | 60 | return "error : ".$e->getMessage(); |
| 61 | 61 | } |
| 62 | 62 | if ($sth->fetchColumn() == 0) { |
| 63 | 63 | //$query = 'UPDATE schedule SET departure_airport_icao = :departure_airport_icao, departure_airport_time = :departure_airport_time, arrival_airport_icao = :arrival_airport_icao, arrival_airport_time = :arrival_airport_time, date_modified = :date, source = :source WHERE ident = :ident'; |
| 64 | 64 | if ($departure_airport_time == '' && $arrival_airport_time == '') { |
| 65 | 65 | $query = 'UPDATE routes SET FromAirport_ICAO = :departure_airport_icao, ToAirport_ICAO = :arrival_airport_icao, date_modified = :date, Source = :source WHERE CallSign = :ident'; |
| 66 | - $query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':arrival_airport_icao' => $arrival_airport_icao, ':date' => $date, ':source' => $source); |
|
| 66 | + $query_values = array(':ident' => $ident, ':departure_airport_icao' => $departure_airport_icao, ':arrival_airport_icao' => $arrival_airport_icao, ':date' => $date, ':source' => $source); |
|
| 67 | 67 | } elseif ($arrival_airport_time == '') { |
| 68 | 68 | $query = 'UPDATE routes SET FromAirport_ICAO = :departure_airport_icao, FromAiport_Time = :departure_airport_time, ToAirport_ICAO = :arrival_airport_icao, date_modified = :date, Source = :source WHERE CallSign = :ident'; |
| 69 | - $query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':departure_airport_time' => $departure_airport_time,':arrival_airport_icao' => $arrival_airport_icao, ':date' => $date, ':source' => $source); |
|
| 69 | + $query_values = array(':ident' => $ident, ':departure_airport_icao' => $departure_airport_icao, ':departure_airport_time' => $departure_airport_time, ':arrival_airport_icao' => $arrival_airport_icao, ':date' => $date, ':source' => $source); |
|
| 70 | 70 | } elseif ($departure_airport_time == '') { |
| 71 | 71 | $query = 'UPDATE routes SET FromAirport_ICAO = :departure_airport_icao, ToAirport_ICAO = :arrival_airport_icao, ToAirport_Time = :arrival_airport_time, date_modified = :date, Source = :source WHERE CallSign = :ident'; |
| 72 | - $query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':arrival_airport_icao' => $arrival_airport_icao,':arrival_airport_time' => $arrival_airport_time, ':date' => $date, ':source' => $source); |
|
| 72 | + $query_values = array(':ident' => $ident, ':departure_airport_icao' => $departure_airport_icao, ':arrival_airport_icao' => $arrival_airport_icao, ':arrival_airport_time' => $arrival_airport_time, ':date' => $date, ':source' => $source); |
|
| 73 | 73 | } else { |
| 74 | 74 | $query = 'UPDATE routes SET FromAirport_ICAO = :departure_airport_icao, FromAiport_Time = :departure_airport_time, ToAirport_ICAO = :arrival_airport_icao, ToAirport_Time = :arrival_airport_time, date_modified = :date, Source = :source WHERE CallSign = :ident'; |
| 75 | - $query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':departure_airport_time' => $departure_airport_time,':arrival_airport_icao' => $arrival_airport_icao,':arrival_airport_time' => $arrival_airport_time, ':date' => $date, ':source' => $source); |
|
| 75 | + $query_values = array(':ident' => $ident, ':departure_airport_icao' => $departure_airport_icao, ':departure_airport_time' => $departure_airport_time, ':arrival_airport_icao' => $arrival_airport_icao, ':arrival_airport_time' => $arrival_airport_time, ':date' => $date, ':source' => $source); |
|
| 76 | 76 | } |
| 77 | 77 | try { |
| 78 | 78 | $sth = $this->db->prepare($query); |
| 79 | 79 | $sth->execute($query_values); |
| 80 | - } catch(PDOException $e) { |
|
| 80 | + } catch (PDOException $e) { |
|
| 81 | 81 | return "error : ".$e->getMessage(); |
| 82 | 82 | } |
| 83 | 83 | } else { |
| 84 | 84 | //$query = 'UPDATE schedule SET date_lastseen = :date WHERE ident = :ident'; |
| 85 | 85 | $query = 'UPDATE routes SET date_lastseen = :date WHERE CallSign = :ident'; |
| 86 | - $query_values = array(':ident' => $ident,':date' => $date); |
|
| 86 | + $query_values = array(':ident' => $ident, ':date' => $date); |
|
| 87 | 87 | try { |
| 88 | 88 | $sth = $this->db->prepare($query); |
| 89 | 89 | $sth->execute($query_values); |
| 90 | - } catch(PDOException $e) { |
|
| 90 | + } catch (PDOException $e) { |
|
| 91 | 91 | return "error : ".$e->getMessage(); |
| 92 | 92 | } |
| 93 | 93 | } |
| 94 | 94 | } else { |
| 95 | 95 | $query = 'INSERT INTO routes (CallSign,FromAirport_ICAO, FromAirport_Time, ToAirport_ICAO, ToAirport_Time,date_added,source) VALUES (:ident,:departure_airport_icao,:departure_airport_time,:arrival_airport_icao,:arrival_airport_time,:date,:source)'; |
| 96 | - $query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':departure_airport_time' => $departure_airport_time,':arrival_airport_icao' => $arrival_airport_icao,':arrival_airport_time' => $arrival_airport_time, ':date' => $date, ':source' => $source); |
|
| 96 | + $query_values = array(':ident' => $ident, ':departure_airport_icao' => $departure_airport_icao, ':departure_airport_time' => $departure_airport_time, ':arrival_airport_icao' => $arrival_airport_icao, ':arrival_airport_time' => $arrival_airport_time, ':date' => $date, ':source' => $source); |
|
| 97 | 97 | try { |
| 98 | 98 | $sth = $this->db->prepare($query); |
| 99 | 99 | $sth->execute($query_values); |
| 100 | - } catch(PDOException $e) { |
|
| 100 | + } catch (PDOException $e) { |
|
| 101 | 101 | return "error : ".$e->getMessage(); |
| 102 | 102 | } |
| 103 | 103 | } |
@@ -106,10 +106,10 @@ discard block |
||
| 106 | 106 | |
| 107 | 107 | public function getSchedule($ident) { |
| 108 | 108 | $Translation = new Translation($this->db); |
| 109 | - $operator = $Translation->checkTranslation($ident,false); |
|
| 109 | + $operator = $Translation->checkTranslation($ident, false); |
|
| 110 | 110 | if ($ident != $operator) { |
| 111 | 111 | $query = "SELECT FromAirport_ICAO as departure_airport_icao, ToAirport_ICAO as arrival_airport_icao, FromAirport_Time as departure_airport_time, ToAirport_Time as arrival_airport_time FROM routes WHERE FromAirport_ICAO <> '' AND ToAirport_ICAO <> '' AND CallSign = :operator OR CallSign = :ident LIMIT 1"; |
| 112 | - $query_values = array(':ident' => $ident,'operator' => $operator); |
|
| 112 | + $query_values = array(':ident' => $ident, 'operator' => $operator); |
|
| 113 | 113 | } else { |
| 114 | 114 | $query = "SELECT FromAirport_ICAO as departure_airport_icao, ToAirport_ICAO as arrival_airport_icao, FromAirport_Time as departure_airport_time, ToAirport_Time as arrival_airport_time FROM routes WHERE FromAirport_ICAO <> '' AND ToAirport_ICAO <> '' AND CallSign = :ident LIMIT 1"; |
| 115 | 115 | $query_values = array(':ident' => $ident); |
@@ -117,7 +117,7 @@ discard block |
||
| 117 | 117 | try { |
| 118 | 118 | $sth = $this->db->prepare($query); |
| 119 | 119 | $sth->execute($query_values); |
| 120 | - } catch(PDOException $e) { |
|
| 120 | + } catch (PDOException $e) { |
|
| 121 | 121 | return "error : ".$e->getMessage(); |
| 122 | 122 | } |
| 123 | 123 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -141,7 +141,7 @@ discard block |
||
| 141 | 141 | try { |
| 142 | 142 | $sth = $this->db->prepare($query); |
| 143 | 143 | $sth->execute($query_values); |
| 144 | - } catch(PDOException $e) { |
|
| 144 | + } catch (PDOException $e) { |
|
| 145 | 145 | return "error : ".$e->getMessage(); |
| 146 | 146 | } |
| 147 | 147 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -156,16 +156,16 @@ discard block |
||
| 156 | 156 | * @param String $carrier IATA code |
| 157 | 157 | * @return Flight departure and arrival airports and time |
| 158 | 158 | */ |
| 159 | - private function getAirFrance($callsign, $date = 'NOW',$carrier = 'AF') { |
|
| 159 | + private function getAirFrance($callsign, $date = 'NOW', $carrier = 'AF') { |
|
| 160 | 160 | $Common = new Common(); |
| 161 | 161 | $check_date = new Datetime($date); |
| 162 | - $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
|
| 163 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
| 162 | + $numvol = preg_replace('/^[A-Z]*/', '', $callsign); |
|
| 163 | + if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array(); |
|
| 164 | 164 | $url = "http://www.airfrance.fr/cgi-bin/AF/FR/fr/local/resainfovol/infovols/detailsVolJson.do?codeCompagnie[0]=".$carrier."&numeroVol[0]=".$numvol."&dayFlightDate=".$check_date->format('d')."&yearMonthFlightDate=".$check_date->format('Ym'); |
| 165 | 165 | $json = $Common->getData($url); |
| 166 | 166 | |
| 167 | 167 | $parsed_json = json_decode($json); |
| 168 | - if (property_exists($parsed_json,'errors') === false) { |
|
| 168 | + if (property_exists($parsed_json, 'errors') === false) { |
|
| 169 | 169 | //$originLong = $parsed_json->{'flightsList'}[0]->{'segmentsList'}[0]->{'originLong'}; |
| 170 | 170 | $originShort = $parsed_json->{'flightsList'}[0]->{'segmentsList'}[0]->{'originShort'}; |
| 171 | 171 | //$departureDateMedium = $parsed_json->{'flightsList'}[0]->{'segmentsList'}[0]->{'departureDateMedium'}; |
@@ -175,9 +175,9 @@ discard block |
||
| 175 | 175 | //$arrivalDateMedium = $parsed_json->{'flightsList'}[0]->{'segmentsList'}[0]->{'arrivalDateMedium'}; |
| 176 | 176 | $arrivalTime = $parsed_json->{'flightsList'}[0]->{'segmentsList'}[0]->{'arrivalTime'}; |
| 177 | 177 | |
| 178 | - preg_match('/\((.*?)\)/',$originShort,$originiata); |
|
| 178 | + preg_match('/\((.*?)\)/', $originShort, $originiata); |
|
| 179 | 179 | $DepartureAirportIata = $originiata[1]; |
| 180 | - preg_match('/\((.*?)\)/',$destinationShort,$destinationiata); |
|
| 180 | + preg_match('/\((.*?)\)/', $destinationShort, $destinationiata); |
|
| 181 | 181 | $ArrivalAirportIata = $destinationiata[1]; |
| 182 | 182 | |
| 183 | 183 | /* |
@@ -186,7 +186,7 @@ discard block |
||
| 186 | 186 | $arrivalTime = gmdate('H:i',strtotime($arrivalTime)); |
| 187 | 187 | */ |
| 188 | 188 | |
| 189 | - return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_airfrance'); |
|
| 189 | + return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_airfrance'); |
|
| 190 | 190 | } else return array(); |
| 191 | 191 | } |
| 192 | 192 | |
@@ -201,8 +201,8 @@ discard block |
||
| 201 | 201 | $Common = new Common(); |
| 202 | 202 | date_default_timezone_set($globalTimezone); |
| 203 | 203 | $check_date = new Datetime($date); |
| 204 | - $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
|
| 205 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
| 204 | + $numvol = preg_replace('/^[A-Z]*/', '', $callsign); |
|
| 205 | + if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array(); |
|
| 206 | 206 | $url = "http://www.easyjet.com/ft/api/flights?date=".$check_date->format('Y-m-d')."&fn=".$callsign; |
| 207 | 207 | $json = $Common->getData($url); |
| 208 | 208 | $parsed_json = json_decode($json); |
@@ -214,7 +214,7 @@ discard block |
||
| 214 | 214 | $departureTime = $parsed_json->{'flights'}[0]->{'dates'}->{'fstd'}; |
| 215 | 215 | $arrivalTime = $parsed_json->{'flights'}[0]->{'dates'}->{'fsta'}; |
| 216 | 216 | |
| 217 | - return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_easyjet'); |
|
| 217 | + return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_easyjet'); |
|
| 218 | 218 | } else return array(); |
| 219 | 219 | } |
| 220 | 220 | |
@@ -225,12 +225,12 @@ discard block |
||
| 225 | 225 | */ |
| 226 | 226 | private function getRyanair($callsign) { |
| 227 | 227 | $Common = new Common(); |
| 228 | - $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
|
| 229 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
| 228 | + $numvol = preg_replace('/^[A-Z]*/', '', $callsign); |
|
| 229 | + if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array(); |
|
| 230 | 230 | $url = "http://www.ryanair.com/fr/api/2/flight-info/0/50/"; |
| 231 | 231 | $post = '{"flight":"'.$numvol.'","minDepartureTime":"00:00","maxDepartureTime":"23:59"}'; |
| 232 | - $headers = array('Content-Type: application/json','Content-Length: ' . strlen($post)); |
|
| 233 | - $json = $Common->getData($url,'post',$post,$headers); |
|
| 232 | + $headers = array('Content-Type: application/json', 'Content-Length: '.strlen($post)); |
|
| 233 | + $json = $Common->getData($url, 'post', $post, $headers); |
|
| 234 | 234 | $parsed_json = json_decode($json); |
| 235 | 235 | if (isset($parsed_json->{'flightInfo'})) { |
| 236 | 236 | $flights = $parsed_json->{'flightInfo'}; |
@@ -239,7 +239,7 @@ discard block |
||
| 239 | 239 | $ArrivalAirportIata = $parsed_json->{'flightInfo'}[0]->{'arrivalAirport'}->{'iata'}; //name |
| 240 | 240 | $departureTime = $parsed_json->{'flightInfo'}[0]->{'departureTime'}; |
| 241 | 241 | $arrivalTime = $parsed_json->{'flightInfo'}[0]->{'arrivalTime'}; |
| 242 | - return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime, 'Source' => 'website_ryanair'); |
|
| 242 | + return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_ryanair'); |
|
| 243 | 243 | } else return array(); |
| 244 | 244 | } else return array(); |
| 245 | 245 | } |
@@ -251,8 +251,8 @@ discard block |
||
| 251 | 251 | */ |
| 252 | 252 | private function getSwiss($callsign) { |
| 253 | 253 | $Common = new Common(); |
| 254 | - $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
|
| 255 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
| 254 | + $numvol = preg_replace('/^[A-Z]*/', '', $callsign); |
|
| 255 | + if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array(); |
|
| 256 | 256 | $url = "http://www.world-of-swiss.com/fr/routenetwork.json"; |
| 257 | 257 | $json = $Common->getData($url); |
| 258 | 258 | $parsed_json = json_decode($json); |
@@ -266,12 +266,12 @@ discard block |
||
| 266 | 266 | if ($flight->{'no'} == "Vol LX ".$numvol) { |
| 267 | 267 | $DepartureAirportIata = $flight->{'from'}->{'code'}; //city |
| 268 | 268 | $ArrivalAirportIata = $flight->{'to'}->{'code'}; //city |
| 269 | - $departureTime = substr($flight->{'from'}->{'hour'},0,5); |
|
| 270 | - $arrivalTime = substr($flight->{'to'}->{'hour'},0,5); |
|
| 269 | + $departureTime = substr($flight->{'from'}->{'hour'},0, 5); |
|
| 270 | + $arrivalTime = substr($flight->{'to'}->{'hour'},0, 5); |
|
| 271 | 271 | } |
| 272 | 272 | } |
| 273 | 273 | if (isset($DepartureAirportIata) && isset($ArrivalAirportIata)) { |
| 274 | - return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_swiss'); |
|
| 274 | + return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_swiss'); |
|
| 275 | 275 | } else return array(); |
| 276 | 276 | } else return array(); |
| 277 | 277 | } |
@@ -286,21 +286,21 @@ discard block |
||
| 286 | 286 | global $globalBritishAirwaysKey; |
| 287 | 287 | $Common = new Common(); |
| 288 | 288 | $check_date = new Datetime($date); |
| 289 | - $numvol = sprintf('%04d',preg_replace('/^[A-Z]*/','',$callsign)); |
|
| 290 | - if (!filter_var(preg_replace('/^[A-Z]*/','',$callsign),FILTER_VALIDATE_INT)) return array(); |
|
| 289 | + $numvol = sprintf('%04d', preg_replace('/^[A-Z]*/', '', $callsign)); |
|
| 290 | + if (!filter_var(preg_replace('/^[A-Z]*/', '', $callsign), FILTER_VALIDATE_INT)) return array(); |
|
| 291 | 291 | if ($globalBritishAirwaysKey == '') return array(); |
| 292 | 292 | $url = "https://api.ba.com/rest-v1/v1/flights;flightNumber=".$numvol.";scheduledDepartureDate=".$check_date->format('Y-m-d').".json"; |
| 293 | 293 | $headers = array('Client-Key: '.$globalBritishAirwaysKey); |
| 294 | - $json = $Common->getData($url,'get','',$headers); |
|
| 294 | + $json = $Common->getData($url, 'get', '', $headers); |
|
| 295 | 295 | if ($json == '') return array(); |
| 296 | 296 | $parsed_json = json_decode($json); |
| 297 | 297 | $flights = $parsed_json->{'FlightsResponse'}; |
| 298 | 298 | if (count($flights) > 0) { |
| 299 | 299 | $DepartureAirportIata = $parsed_json->{'FlightsResponse'}->{'Flight'}->{'Sector'}->{'DepartureAirport'}; |
| 300 | 300 | $ArrivalAirportIata = $parsed_json->{'FlightsResponse'}->{'Flight'}->{'Sector'}->{'ArrivalAirport'}; |
| 301 | - $departureTime = date('H:i',strtotime($parsed_json->{'FlightsResponse'}->{'Flight'}->{'Sector'}->{'ScheduledDepartureDateTime'})); |
|
| 302 | - $arrivalTime = date('H:i',strtotime($parsed_json->{'FlightsResponse'}->{'Flight'}->{'Sector'}->{'ScheduledArrivalDateTime'})); |
|
| 303 | - return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_britishairways'); |
|
| 301 | + $departureTime = date('H:i', strtotime($parsed_json->{'FlightsResponse'}->{'Flight'}->{'Sector'}->{'ScheduledDepartureDateTime'})); |
|
| 302 | + $arrivalTime = date('H:i', strtotime($parsed_json->{'FlightsResponse'}->{'Flight'}->{'Sector'}->{'ScheduledArrivalDateTime'})); |
|
| 303 | + return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_britishairways'); |
|
| 304 | 304 | } else return array(); |
| 305 | 305 | } |
| 306 | 306 | |
@@ -314,27 +314,27 @@ discard block |
||
| 314 | 314 | global $globalLufthansaKey; |
| 315 | 315 | $Common = new Common(); |
| 316 | 316 | $check_date = new Datetime($date); |
| 317 | - $numvol = sprintf('%04d',preg_replace('/^[A-Z]*/','',$callsign)); |
|
| 318 | - if (!filter_var(preg_replace('/^[A-Z]*/','',$callsign),FILTER_VALIDATE_INT)) return array(); |
|
| 317 | + $numvol = sprintf('%04d', preg_replace('/^[A-Z]*/', '', $callsign)); |
|
| 318 | + if (!filter_var(preg_replace('/^[A-Z]*/', '', $callsign), FILTER_VALIDATE_INT)) return array(); |
|
| 319 | 319 | if (!isset($globalLufthansaKey) || $globalLufthansaKey == '' || !isset($globalLufthansaKey['key']) || $globalLufthansaKey['key'] == '') return array(); |
| 320 | 320 | $url = "https://api.lufthansa.com/v1/oauth/token"; |
| 321 | - $post = array('client_id' => $globalLufthansaKey['key'],'client_secret' => $globalLufthansaKey['secret'],'grant_type' => 'client_credentials'); |
|
| 322 | - $data = $Common->getData($url,'post',$post); |
|
| 321 | + $post = array('client_id' => $globalLufthansaKey['key'], 'client_secret' => $globalLufthansaKey['secret'], 'grant_type' => 'client_credentials'); |
|
| 322 | + $data = $Common->getData($url, 'post', $post); |
|
| 323 | 323 | $parsed_data = json_decode($data); |
| 324 | 324 | if (!isset($parsed_data->{'access_token'})) return array(); |
| 325 | 325 | $token = $parsed_data->{'access_token'}; |
| 326 | 326 | |
| 327 | 327 | $url = "https://api.lufthansa.com/v1/operations/flightstatus/LH".$numvol."/".$check_date->format('Y-m-d'); |
| 328 | - $headers = array('Authorization: Bearer '.$token,'Accept: application/json'); |
|
| 329 | - $json = $Common->getData($url,'get','',$headers); |
|
| 328 | + $headers = array('Authorization: Bearer '.$token, 'Accept: application/json'); |
|
| 329 | + $json = $Common->getData($url, 'get', '', $headers); |
|
| 330 | 330 | if ($json == '') return array(); |
| 331 | 331 | $parsed_json = json_decode($json); |
| 332 | 332 | if (isset($parsed_json->{'FlightStatusResource'}) && count($parsed_json->{'FlightStatusResource'}) > 0) { |
| 333 | 333 | $DepartureAirportIata = $parsed_json->{'FlightStatusResource'}->{'Flights'}->{'Flight'}->{'Departure'}->{'AirportCode'}; |
| 334 | - $departureTime = date('H:i',strtotime($parsed_json->{'FlightStatusResource'}->{'Flights'}->{'Flight'}->{'Departure'}->{'ScheduledTimeLocal'}->{'DateTime'})); |
|
| 334 | + $departureTime = date('H:i', strtotime($parsed_json->{'FlightStatusResource'}->{'Flights'}->{'Flight'}->{'Departure'}->{'ScheduledTimeLocal'}->{'DateTime'})); |
|
| 335 | 335 | $ArrivalAirportIata = $parsed_json->{'FlightStatusResource'}->{'Flights'}->{'Flight'}->{'Arrival'}->{'AirportCode'}; |
| 336 | - $arrivalTime = date('H:i',strtotime($parsed_json->{'FlightStatusResource'}->{'Flights'}->{'Flight'}->{'Arrival'}->{'ScheduledTimeLocal'}->{'DateTime'})); |
|
| 337 | - return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_lufthansa'); |
|
| 336 | + $arrivalTime = date('H:i', strtotime($parsed_json->{'FlightStatusResource'}->{'Flights'}->{'Flight'}->{'Arrival'}->{'ScheduledTimeLocal'}->{'DateTime'})); |
|
| 337 | + return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_lufthansa'); |
|
| 338 | 338 | } else return array(); |
| 339 | 339 | } |
| 340 | 340 | |
@@ -348,23 +348,23 @@ discard block |
||
| 348 | 348 | global $globalTransaviaKey; |
| 349 | 349 | $Common = new Common(); |
| 350 | 350 | $check_date = new Datetime($date); |
| 351 | - $numvol = sprintf('%04d',preg_replace('/^[A-Z]*/','',$callsign)); |
|
| 352 | - if (!filter_var(preg_replace('/^[A-Z]*/','',$callsign),FILTER_VALIDATE_INT)) return array(); |
|
| 351 | + $numvol = sprintf('%04d', preg_replace('/^[A-Z]*/', '', $callsign)); |
|
| 352 | + if (!filter_var(preg_replace('/^[A-Z]*/', '', $callsign), FILTER_VALIDATE_INT)) return array(); |
|
| 353 | 353 | if ($globalTransaviaKey == '') return array(); |
| 354 | 354 | $url = "https://tst.api.transavia.com/v1/flightstatus/departuredate/".$check_date->format('Ymd').'/flightnumber/HV'.$numvol; |
| 355 | 355 | //$url = "https://api.transavia.com/v1/flightstatus/departuredate/".$check_date->format('Ymd').'/flightnumber/HV'.$numvol; |
| 356 | 356 | $headers = array('apikey: '.$globalTransaviaKey); |
| 357 | - $json = $Common->getData($url,'get','',$headers); |
|
| 357 | + $json = $Common->getData($url, 'get', '', $headers); |
|
| 358 | 358 | //echo 'result : '.$json; |
| 359 | 359 | if ($json == '') return array(); |
| 360 | 360 | $parsed_json = json_decode($json); |
| 361 | 361 | |
| 362 | 362 | if (isset($parsed_json->{'data'}[0])) { |
| 363 | 363 | $DepartureAirportIata = $parsed_json->{'data'}[0]->{'flight'}->{'departureAirport'}->{'locationCode'}; |
| 364 | - $departureTime = date('H:i',strtotime($parsed_json->{'data'}[0]->{'flight'}->{'departureDateTime'})); |
|
| 364 | + $departureTime = date('H:i', strtotime($parsed_json->{'data'}[0]->{'flight'}->{'departureDateTime'})); |
|
| 365 | 365 | $ArrivalAirportIata = $parsed_json->{'data'}[0]->{'flight'}->{'arrivalAirport'}->{'locationCode'}; |
| 366 | - $arrivalTime = date('H:i',strtotime($parsed_json->{'data'}[0]->{'flight'}->{'arrivalDateTime'})); |
|
| 367 | - return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_transavia'); |
|
| 366 | + $arrivalTime = date('H:i', strtotime($parsed_json->{'data'}[0]->{'flight'}->{'arrivalDateTime'})); |
|
| 367 | + return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_transavia'); |
|
| 368 | 368 | } else return array(); |
| 369 | 369 | } |
| 370 | 370 | |
@@ -375,14 +375,14 @@ discard block |
||
| 375 | 375 | */ |
| 376 | 376 | public function getTunisair($callsign) { |
| 377 | 377 | $Common = new Common(); |
| 378 | - $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
|
| 379 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
| 378 | + $numvol = preg_replace('/^[A-Z]*/', '', $callsign); |
|
| 379 | + if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array(); |
|
| 380 | 380 | $url = "http://www.tunisair.com/site/publish/module/Volj/fr/Flight_List.asp"; |
| 381 | 381 | $data = $Common->getData($url); |
| 382 | 382 | $table = $Common->table2array($data); |
| 383 | 383 | foreach ($table as $flight) { |
| 384 | - if (isset($flight[1]) && $flight[1] == "TU ".sprintf('%04d',$numvol)) { |
|
| 385 | - return array('DepartureAirportIATA' => $flight[2],'DepartureTime' => str_replace('.',':',$flight[5]),'ArrivalAirportIATA' => $flight[3],'ArrivalTime' => str_replace('.',':',$flight[6]),'Source' => 'website_tunisair'); |
|
| 384 | + if (isset($flight[1]) && $flight[1] == "TU ".sprintf('%04d', $numvol)) { |
|
| 385 | + return array('DepartureAirportIATA' => $flight[2], 'DepartureTime' => str_replace('.', ':', $flight[5]), 'ArrivalAirportIATA' => $flight[3], 'ArrivalTime' => str_replace('.', ':', $flight[6]), 'Source' => 'website_tunisair'); |
|
| 386 | 386 | } |
| 387 | 387 | } |
| 388 | 388 | return array(); |
@@ -393,21 +393,21 @@ discard block |
||
| 393 | 393 | * @param String $callsign The callsign |
| 394 | 394 | * @return Flight departure and arrival airports and time |
| 395 | 395 | */ |
| 396 | - public function getVueling($callsign,$date = 'NOW') { |
|
| 396 | + public function getVueling($callsign, $date = 'NOW') { |
|
| 397 | 397 | $Common = new Common(); |
| 398 | 398 | $check_date = new Datetime($date); |
| 399 | - $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
|
| 400 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
| 401 | - $final_date = str_replace('/','%2F',$check_date->format('d/m/Y')); |
|
| 399 | + $numvol = preg_replace('/^[A-Z]*/', '', $callsign); |
|
| 400 | + if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array(); |
|
| 401 | + $final_date = str_replace('/', '%2F', $check_date->format('d/m/Y')); |
|
| 402 | 402 | $url = "http://www.vueling.com/Base/BaseProxy/RenderMacro/?macroalias=FlightStatusResult&searchBy=bycode&date=".$final_date."&flightNumber=".$numvol."&idioma=en-GB"; |
| 403 | 403 | $data = $Common->getData($url); |
| 404 | - $data=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$data)); |
|
| 404 | + $data = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '', $data)); |
|
| 405 | 405 | if ($data != '') { |
| 406 | - preg_match('/flightOri=[A-Z]{3}/',$data,$result); |
|
| 407 | - $DepartureAirportIata = str_replace('flightOri=','',$result[0]); |
|
| 408 | - preg_match('/flightDest=[A-Z]{3}/',$data,$result); |
|
| 409 | - $ArrivalAirportIata = str_replace('flightDest=','',$result[0]); |
|
| 410 | - if ($DepartureAirportIata != '' && $ArrivalAirportIata != '') return array('DepartureAirportIATA' => $DepartureAirportIata,'ArrivalAirportIATA' => $ArrivalAirportIata,'Source' => 'website_vueling'); |
|
| 406 | + preg_match('/flightOri=[A-Z]{3}/', $data, $result); |
|
| 407 | + $DepartureAirportIata = str_replace('flightOri=', '', $result[0]); |
|
| 408 | + preg_match('/flightDest=[A-Z]{3}/', $data, $result); |
|
| 409 | + $ArrivalAirportIata = str_replace('flightDest=', '', $result[0]); |
|
| 410 | + if ($DepartureAirportIata != '' && $ArrivalAirportIata != '') return array('DepartureAirportIATA' => $DepartureAirportIata, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'Source' => 'website_vueling'); |
|
| 411 | 411 | else return array(); |
| 412 | 412 | } |
| 413 | 413 | return array(); |
@@ -421,27 +421,27 @@ discard block |
||
| 421 | 421 | */ |
| 422 | 422 | public function getIberia($callsign, $date = 'NOW') { |
| 423 | 423 | $Common = new Common(); |
| 424 | - $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
|
| 424 | + $numvol = preg_replace('/^[A-Z]*/', '', $callsign); |
|
| 425 | 425 | $check_date = new Datetime($date); |
| 426 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
| 426 | + if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array(); |
|
| 427 | 427 | $url = "https://www.iberia.com/web/flightDetail.do"; |
| 428 | - $post = array('numvuelo' => $numvol,'fecha' => $check_date->format('Ymd'),'airlineID' => 'IB'); |
|
| 429 | - $data = $Common->getData($url,'post',$post); |
|
| 428 | + $post = array('numvuelo' => $numvol, 'fecha' => $check_date->format('Ymd'), 'airlineID' => 'IB'); |
|
| 429 | + $data = $Common->getData($url, 'post', $post); |
|
| 430 | 430 | if ($data != '') { |
| 431 | 431 | $table = $Common->table2array($data); |
| 432 | 432 | //print_r($table); |
| 433 | 433 | if (count($table) > 0) { |
| 434 | 434 | $flight = $table; |
| 435 | - preg_match('/([A-Z]{3})/',$flight[3][0],$DepartureAirportIataMatch); |
|
| 436 | - preg_match('/([A-Z]{3})/',$flight[5][0],$ArrivalAirportIataMatch); |
|
| 435 | + preg_match('/([A-Z]{3})/', $flight[3][0], $DepartureAirportIataMatch); |
|
| 436 | + preg_match('/([A-Z]{3})/', $flight[5][0], $ArrivalAirportIataMatch); |
|
| 437 | 437 | $DepartureAirportIata = $DepartureAirportIataMatch[0]; |
| 438 | 438 | $ArrivalAirportIata = $ArrivalAirportIataMatch[0]; |
| 439 | - $departureTime = substr(trim(str_replace(' lunes','',str_replace(' ','',$flight[3][2]))),0,5); |
|
| 440 | - $arrivalTime = trim(str_replace(' lunes','',str_replace(' ','',$flight[5][1]))); |
|
| 439 | + $departureTime = substr(trim(str_replace(' lunes', '', str_replace(' ', '', $flight[3][2]))), 0, 5); |
|
| 440 | + $arrivalTime = trim(str_replace(' lunes', '', str_replace(' ', '', $flight[5][1]))); |
|
| 441 | 441 | if ($arrivalTime == 'Hora estimada de llegada') { |
| 442 | - $arrivalTime = substr(trim(str_replace(' lunes','',str_replace(' ','',$flight[5][2]))),0,5); |
|
| 443 | - } else $arrivalTime = substr($arrivalTime,0,5); |
|
| 444 | - return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_iberia'); |
|
| 442 | + $arrivalTime = substr(trim(str_replace(' lunes', '', str_replace(' ', '', $flight[5][2]))), 0, 5); |
|
| 443 | + } else $arrivalTime = substr($arrivalTime, 0, 5); |
|
| 444 | + return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_iberia'); |
|
| 445 | 445 | } |
| 446 | 446 | } |
| 447 | 447 | return array(); |
@@ -454,11 +454,11 @@ discard block |
||
| 454 | 454 | * @return Flight departure and arrival airports and time |
| 455 | 455 | */ |
| 456 | 456 | |
| 457 | - private function getStarAlliance($callsign, $date = 'NOW',$carrier = '') { |
|
| 457 | + private function getStarAlliance($callsign, $date = 'NOW', $carrier = '') { |
|
| 458 | 458 | $Common = new Common(); |
| 459 | - $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
|
| 459 | + $numvol = preg_replace('/^[A-Z]*/', '', $callsign); |
|
| 460 | 460 | $check_date = new Datetime($date); |
| 461 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
| 461 | + if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array(); |
|
| 462 | 462 | $url = "http://www.staralliance.com/flifoQueryAction.do?myAirline=&airlineCode=".$carrier."&flightNo=".$numvol."&day=".$check_date->format('d')."&month=".$check_date->format('m')."&year=".$check_date->format('Y')."&departuredate=".$check_date->format('d-M-Y'); |
| 463 | 463 | $data = $Common->getData($url); |
| 464 | 464 | if ($data != '') { |
@@ -467,13 +467,13 @@ discard block |
||
| 467 | 467 | $flight = $table; |
| 468 | 468 | //print_r($table); |
| 469 | 469 | if (isset($flight[25]) && isset($flight[29])) { |
| 470 | - preg_match('/([A-Z]{3})/',$flight[25][1],$DepartureAirportIataMatch); |
|
| 471 | - preg_match('/([A-Z]{3})/',$flight[25][3],$ArrivalAirportIataMatch); |
|
| 470 | + preg_match('/([A-Z]{3})/', $flight[25][1], $DepartureAirportIataMatch); |
|
| 471 | + preg_match('/([A-Z]{3})/', $flight[25][3], $ArrivalAirportIataMatch); |
|
| 472 | 472 | $DepartureAirportIata = $DepartureAirportIataMatch[0]; |
| 473 | 473 | $ArrivalAirportIata = $ArrivalAirportIataMatch[0]; |
| 474 | - $departureTime = substr(trim(str_replace('Scheduled: ','',$flight[29][0])),0,5); |
|
| 475 | - $arrivalTime = substr(trim(str_replace('Scheduled: ','',$flight[29][1])),0,5); |
|
| 476 | - return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_staralliance'); |
|
| 474 | + $departureTime = substr(trim(str_replace('Scheduled: ', '', $flight[29][0])), 0, 5); |
|
| 475 | + $arrivalTime = substr(trim(str_replace('Scheduled: ', '', $flight[29][1])), 0, 5); |
|
| 476 | + return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_staralliance'); |
|
| 477 | 477 | } else return array(); |
| 478 | 478 | } |
| 479 | 479 | |
@@ -491,10 +491,10 @@ discard block |
||
| 491 | 491 | */ |
| 492 | 492 | private function getAlitalia($callsign, $date = 'NOW') { |
| 493 | 493 | $Common = new Common(); |
| 494 | - $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
|
| 494 | + $numvol = preg_replace('/^[A-Z]*/', '', $callsign); |
|
| 495 | 495 | $check_date = new Datetime($date); |
| 496 | - $url= "http://booking.alitalia.com/FlightStatus/fr_fr/FlightInfo?Brand=az&NumeroVolo=".$numvol."&DataCompleta=".$check_date->format('d/m/Y'); |
|
| 497 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
| 496 | + $url = "http://booking.alitalia.com/FlightStatus/fr_fr/FlightInfo?Brand=az&NumeroVolo=".$numvol."&DataCompleta=".$check_date->format('d/m/Y'); |
|
| 497 | + if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array(); |
|
| 498 | 498 | $data = $Common->getData($url); |
| 499 | 499 | if ($data != '') { |
| 500 | 500 | $table = $Common->text2array($data); |
@@ -502,7 +502,7 @@ discard block |
||
| 502 | 502 | $ArrivalAirportIata = ''; |
| 503 | 503 | $departureTime = $table[4]; |
| 504 | 504 | $arrivalTime = $table[5]; |
| 505 | - return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_alitalia'); |
|
| 505 | + return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_alitalia'); |
|
| 506 | 506 | } |
| 507 | 507 | } |
| 508 | 508 | |
@@ -514,21 +514,21 @@ discard block |
||
| 514 | 514 | */ |
| 515 | 515 | private function getBrussels($callsign, $date = 'NOW') { |
| 516 | 516 | $Common = new Common(); |
| 517 | - $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
|
| 517 | + $numvol = preg_replace('/^[A-Z]*/', '', $callsign); |
|
| 518 | 518 | $check_date = new Datetime($date); |
| 519 | - $url= "http://www.brusselsairlines.com/api/flightstatus/getresults?from=NA&to=NA&date=".$check_date->format('d/m/Y')."&hour=NA&lookup=flightnumber&flightnumber=".$numvol."&publicationID=302"; |
|
| 519 | + $url = "http://www.brusselsairlines.com/api/flightstatus/getresults?from=NA&to=NA&date=".$check_date->format('d/m/Y')."&hour=NA&lookup=flightnumber&flightnumber=".$numvol."&publicationID=302"; |
|
| 520 | 520 | //http://www.brusselsairlines.com/fr-fr/informations-pratiques/statut-de-votre-vol/resultat.aspx?flightnumber=".$numvol."&date=".$check_date->format('d/m/Y')."&lookup=flightnumber"; |
| 521 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
| 521 | + if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array(); |
|
| 522 | 522 | $data = $Common->getData($url); |
| 523 | 523 | if ($data != '') { |
| 524 | 524 | //echo $data; |
| 525 | - $parsed_json = json_decode($data,true); |
|
| 525 | + $parsed_json = json_decode($data, true); |
|
| 526 | 526 | if (isset($parsed_json[0]['FromAirportCode'])) { |
| 527 | 527 | $DepartureAirportIata = $parsed_json[0]['FromAirportCode']; |
| 528 | 528 | $ArrivalAirportIata = $parsed_json[0]['ToAirportCode']; |
| 529 | - $departureTime = date('H:i',strtotime($parsed_json[0]['ScheduledDepatureDate'])); |
|
| 530 | - $arrivalTime = date('H:i',strtotime($parsed_json[0]['ScheduledArrivalDate'])); |
|
| 531 | - return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_brussels'); |
|
| 529 | + $departureTime = date('H:i', strtotime($parsed_json[0]['ScheduledDepatureDate'])); |
|
| 530 | + $arrivalTime = date('H:i', strtotime($parsed_json[0]['ScheduledArrivalDate'])); |
|
| 531 | + return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_brussels'); |
|
| 532 | 532 | } |
| 533 | 533 | } |
| 534 | 534 | } |
@@ -605,21 +605,21 @@ discard block |
||
| 605 | 605 | */ |
| 606 | 606 | private function getFlyTap($callsign) { |
| 607 | 607 | $Common = new Common(); |
| 608 | - $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
|
| 609 | - $url= "http://www.flytap.com/France/fr/PlanifierEtReserver/Outils/DepartsEtArrivees"; |
|
| 608 | + $numvol = preg_replace('/^[A-Z]*/', '', $callsign); |
|
| 609 | + $url = "http://www.flytap.com/France/fr/PlanifierEtReserver/Outils/DepartsEtArrivees"; |
|
| 610 | 610 | //$check_date = new Datetime($date); |
| 611 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
| 612 | - $post = array('arrivalsdepartures_content' => 'number','arrivalsdepartures_tp' => $numvol,'arrivalsdepartures_trk' => 'ARR','arrivalsdepartures_date_trk' => '1','aptCode' => '','arrivalsdepartures' => 'DEP','arrivalsdepartures_date' => '1','aptCodeFrom' => '','aptCodeTo' => '','arrivalsdepartures2' => 'DEP','arrivalsdepartures_date2' => '1'); |
|
| 613 | - $data = $Common->getData($url,'post',$post); |
|
| 611 | + if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array(); |
|
| 612 | + $post = array('arrivalsdepartures_content' => 'number', 'arrivalsdepartures_tp' => $numvol, 'arrivalsdepartures_trk' => 'ARR', 'arrivalsdepartures_date_trk' => '1', 'aptCode' => '', 'arrivalsdepartures' => 'DEP', 'arrivalsdepartures_date' => '1', 'aptCodeFrom' => '', 'aptCodeTo' => '', 'arrivalsdepartures2' => 'DEP', 'arrivalsdepartures_date2' => '1'); |
|
| 613 | + $data = $Common->getData($url, 'post', $post); |
|
| 614 | 614 | if ($data != '') { |
| 615 | 615 | $table = $Common->table2array($data); |
| 616 | - $departureTime = trim(substr($table[15][0],0,5)); |
|
| 617 | - $arrivalTime = trim(substr($table[35][0],0,5)); |
|
| 618 | - preg_match('/([A-Z]{3})/',$table[11][0],$DepartureAirportIataMatch); |
|
| 619 | - preg_match('/([A-Z]{3})/',$table[31][0],$ArrivalAirportIataMatch); |
|
| 616 | + $departureTime = trim(substr($table[15][0], 0, 5)); |
|
| 617 | + $arrivalTime = trim(substr($table[35][0], 0, 5)); |
|
| 618 | + preg_match('/([A-Z]{3})/', $table[11][0], $DepartureAirportIataMatch); |
|
| 619 | + preg_match('/([A-Z]{3})/', $table[31][0], $ArrivalAirportIataMatch); |
|
| 620 | 620 | $DepartureAirportIata = $DepartureAirportIataMatch[0]; |
| 621 | 621 | $ArrivalAirportIata = $ArrivalAirportIataMatch[0]; |
| 622 | - return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_flytap'); |
|
| 622 | + return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_flytap'); |
|
| 623 | 623 | } |
| 624 | 624 | return array(); |
| 625 | 625 | } |
@@ -641,10 +641,10 @@ discard block |
||
| 641 | 641 | } |
| 642 | 642 | } |
| 643 | 643 | if ($airline_icao == '') return array(); |
| 644 | - $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
|
| 645 | - $url= "http://info.flightmapper.net/flight/".$airline_icao.'_'.$numvol; |
|
| 644 | + $numvol = preg_replace('/^[A-Z]*/', '', $callsign); |
|
| 645 | + $url = "http://info.flightmapper.net/flight/".$airline_icao.'_'.$numvol; |
|
| 646 | 646 | //$check_date = new Datetime($date); |
| 647 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
| 647 | + if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array(); |
|
| 648 | 648 | $data = $Common->getData($url); |
| 649 | 649 | if ($data != '') { |
| 650 | 650 | $table = $Common->table2array($data); |
@@ -654,13 +654,13 @@ discard block |
||
| 654 | 654 | $darr = ''; |
| 655 | 655 | $ahour = ''; |
| 656 | 656 | $aarr = ''; |
| 657 | - $n = sscanf($sched,'%*s %5[0-9:] %*[^()] (%3[A-Z]) %5[0-9:] %*[^()] (%3[A-Z])',$dhour,$darr,$ahour,$aarr); |
|
| 657 | + $n = sscanf($sched, '%*s %5[0-9:] %*[^()] (%3[A-Z]) %5[0-9:] %*[^()] (%3[A-Z])', $dhour, $darr, $ahour, $aarr); |
|
| 658 | 658 | if ($n == 7) { |
| 659 | 659 | $departureTime = $dhour; |
| 660 | 660 | $arrivalTime = $ahour; |
| 661 | - $DepartureAirportIata = str_replace(array('(',')'),'',$darr); |
|
| 662 | - $ArrivalAirportIata = str_replace(array('(',')'),'',$aarr); |
|
| 663 | - return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_flightmapper'); |
|
| 661 | + $DepartureAirportIata = str_replace(array('(', ')'), '', $darr); |
|
| 662 | + $ArrivalAirportIata = str_replace(array('(', ')'), '', $aarr); |
|
| 663 | + return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_flightmapper'); |
|
| 664 | 664 | } |
| 665 | 665 | } |
| 666 | 666 | } |
@@ -684,20 +684,20 @@ discard block |
||
| 684 | 684 | } |
| 685 | 685 | } |
| 686 | 686 | */ |
| 687 | - $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
|
| 688 | - $url= "http://fr.flightaware.com/live/flight/".$callsign; |
|
| 687 | + $numvol = preg_replace('/^[A-Z]*/', '', $callsign); |
|
| 688 | + $url = "http://fr.flightaware.com/live/flight/".$callsign; |
|
| 689 | 689 | //$check_date = new Datetime($date); |
| 690 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
| 690 | + if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array(); |
|
| 691 | 691 | $data = $Common->getData($url); |
| 692 | 692 | if ($data != '') { |
| 693 | 693 | $table = $Common->table2array($data); |
| 694 | 694 | if (isset($table[11][0])) { |
| 695 | - $departureTime = str_replace('h',':',substr($table[5][0],0,5)); |
|
| 696 | - $arrivalTime = str_replace('h',':',substr($table[5][1],0,5)); |
|
| 695 | + $departureTime = str_replace('h', ':', substr($table[5][0], 0, 5)); |
|
| 696 | + $arrivalTime = str_replace('h', ':', substr($table[5][1], 0, 5)); |
|
| 697 | 697 | echo $table[3][0]; |
| 698 | - sscanf($table[3][0],'%*[^(] (%3[A-Z] / %*4[A-Z])',$DepartureAirportIata); |
|
| 699 | - sscanf($table[3][1],'%*[^(] (%3[A-Z] / %*4[A-Z])',$ArrivalAirportIata); |
|
| 700 | - return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_flightaware'); |
|
| 698 | + sscanf($table[3][0], '%*[^(] (%3[A-Z] / %*4[A-Z])', $DepartureAirportIata); |
|
| 699 | + sscanf($table[3][1], '%*[^(] (%3[A-Z] / %*4[A-Z])', $ArrivalAirportIata); |
|
| 700 | + return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_flightaware'); |
|
| 701 | 701 | } |
| 702 | 702 | } |
| 703 | 703 | return array(); |
@@ -710,7 +710,7 @@ discard block |
||
| 710 | 710 | */ |
| 711 | 711 | public function getCostToTravel($callsign) { |
| 712 | 712 | $Common = new Common(); |
| 713 | - $url= "http://www.costtotravel.com/flight-number/".$callsign; |
|
| 713 | + $url = "http://www.costtotravel.com/flight-number/".$callsign; |
|
| 714 | 714 | //$check_date = new Datetime($date); |
| 715 | 715 | //if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
| 716 | 716 | $data = $Common->getData($url); |
@@ -718,11 +718,11 @@ discard block |
||
| 718 | 718 | $table = $Common->table2array($data); |
| 719 | 719 | //print_r($table); |
| 720 | 720 | if (isset($table[11][1])) { |
| 721 | - $departureTime = substr($table[11][1],0,5); |
|
| 722 | - $arrivalTime = substr($table[17][1],0,5); |
|
| 723 | - $DepartureAirportIata = substr($table[13][1],0,3); |
|
| 724 | - $ArrivalAirportIata = substr($table[15][1],0,3); |
|
| 725 | - return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_costtotravel'); |
|
| 721 | + $departureTime = substr($table[11][1], 0, 5); |
|
| 722 | + $arrivalTime = substr($table[17][1], 0, 5); |
|
| 723 | + $DepartureAirportIata = substr($table[13][1], 0, 3); |
|
| 724 | + $ArrivalAirportIata = substr($table[15][1], 0, 3); |
|
| 725 | + return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_costtotravel'); |
|
| 726 | 726 | } |
| 727 | 727 | } |
| 728 | 728 | return array(); |
@@ -734,14 +734,14 @@ discard block |
||
| 734 | 734 | * @param String $date date we want flight number info |
| 735 | 735 | * @return Flight departure and arrival airports and time |
| 736 | 736 | */ |
| 737 | - private function getAirCanada($callsign,$date = 'NOW') { |
|
| 737 | + private function getAirCanada($callsign, $date = 'NOW') { |
|
| 738 | 738 | $Common = new Common(); |
| 739 | 739 | if (class_exists("DomDocument") === FALSE) return array(); |
| 740 | 740 | date_default_timezone_set('UTC'); |
| 741 | 741 | $check_date = new Datetime($date); |
| 742 | - $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
|
| 743 | - $url= "http://services.aircanada.com/portal/rest/getFlightsByFlightNumber?forceTimetable=true&flightNumber=".$numvol."&carrierCode=AC&date=".$check_date->format('m-d-Y')."&app_key=AE919FDCC80311DF9BABC975DFD72085&cache=74249"; |
|
| 744 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
| 742 | + $numvol = preg_replace('/^[A-Z]*/', '', $callsign); |
|
| 743 | + $url = "http://services.aircanada.com/portal/rest/getFlightsByFlightNumber?forceTimetable=true&flightNumber=".$numvol."&carrierCode=AC&date=".$check_date->format('m-d-Y')."&app_key=AE919FDCC80311DF9BABC975DFD72085&cache=74249"; |
|
| 744 | + if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array(); |
|
| 745 | 745 | $data = $Common->getData($url); |
| 746 | 746 | $dom = new DomDocument(); |
| 747 | 747 | $dom->loadXML($data); |
@@ -749,11 +749,11 @@ discard block |
||
| 749 | 749 | $departure = $dom->getElementsByTagName('DepartureStationInfo')->item(0); |
| 750 | 750 | if (isset($departure->getElementsByTagName('Airport')->item(0)->firstChild->nodeValue)) { |
| 751 | 751 | $DepartureAirportIata = $departure->getElementsByTagName('Airport')->item(0)->firstChild->nodeValue; |
| 752 | - $departureTime = date('H:i',strtotime($departure->getElementsByTagName('ScheduledTime')->item(0)->firstChild->nodeValue)); |
|
| 752 | + $departureTime = date('H:i', strtotime($departure->getElementsByTagName('ScheduledTime')->item(0)->firstChild->nodeValue)); |
|
| 753 | 753 | $arrival = $dom->getElementsByTagName('ArrivalStationInfo')->item(0); |
| 754 | 754 | $ArrivalAirportIata = $arrival->getElementsByTagName('Airport')->item(0)->firstChild->nodeValue; |
| 755 | - $arrivalTime = date('H:i',strtotime($arrival->getElementsByTagName('ScheduledTime')->item(0)->firstChild->nodeValue)); |
|
| 756 | - return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_aircanada'); |
|
| 755 | + $arrivalTime = date('H:i', strtotime($arrival->getElementsByTagName('ScheduledTime')->item(0)->firstChild->nodeValue)); |
|
| 756 | + return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_aircanada'); |
|
| 757 | 757 | } else return array(); |
| 758 | 758 | } |
| 759 | 759 | |
@@ -765,21 +765,21 @@ discard block |
||
| 765 | 765 | */ |
| 766 | 766 | private function getVietnamAirlines($callsign, $date = 'NOW') { |
| 767 | 767 | $Common = new Common(); |
| 768 | - $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
|
| 768 | + $numvol = preg_replace('/^[A-Z]*/', '', $callsign); |
|
| 769 | 769 | $check_date = new Datetime($date); |
| 770 | - $url= "https://cat.sabresonicweb.com/SSWVN/meridia?posid=VNVN&page=flifoFlightInfoDetailsMessage_learn&action=flightInfoDetails&airline=VN&language=fr&depDay=".$check_date->format('j')."&depMonth=".strtoupper($check_date->format('M'))."&=&flight=".$numvol."&"; |
|
| 771 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
| 770 | + $url = "https://cat.sabresonicweb.com/SSWVN/meridia?posid=VNVN&page=flifoFlightInfoDetailsMessage_learn&action=flightInfoDetails&airline=VN&language=fr&depDay=".$check_date->format('j')."&depMonth=".strtoupper($check_date->format('M'))."&=&flight=".$numvol."&"; |
|
| 771 | + if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array(); |
|
| 772 | 772 | $data = $Common->getData($url); |
| 773 | 773 | if ($data != '') { |
| 774 | 774 | $table = $Common->table2array($data); |
| 775 | 775 | $flight = $table; |
| 776 | - preg_match('/([A-Z]{3})/',$flight[3][0],$DepartureAirportIataMatch); |
|
| 777 | - preg_match('/([A-Z]{3})/',$flight[21][0],$ArrivalAirportIataMatch); |
|
| 776 | + preg_match('/([A-Z]{3})/', $flight[3][0], $DepartureAirportIataMatch); |
|
| 777 | + preg_match('/([A-Z]{3})/', $flight[21][0], $ArrivalAirportIataMatch); |
|
| 778 | 778 | $DepartureAirportIata = $DepartureAirportIataMatch[0]; |
| 779 | 779 | $ArrivalAirportIata = $ArrivalAirportIataMatch[0]; |
| 780 | 780 | $departureTime = $flight[5][1]; |
| 781 | 781 | $arrivalTime = $flight[23][1]; |
| 782 | - return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_vietnamairlines'); |
|
| 782 | + return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_vietnamairlines'); |
|
| 783 | 783 | } |
| 784 | 784 | } |
| 785 | 785 | |
@@ -790,16 +790,16 @@ discard block |
||
| 790 | 790 | * @param String $carrier airline code |
| 791 | 791 | * @return Flight departure and arrival airports and time |
| 792 | 792 | */ |
| 793 | - private function getAirBerlin($callsign, $date = 'NOW',$carrier = 'AB') { |
|
| 793 | + private function getAirBerlin($callsign, $date = 'NOW', $carrier = 'AB') { |
|
| 794 | 794 | $Common = new Common(); |
| 795 | 795 | date_default_timezone_set('UTC'); |
| 796 | 796 | //AB = airberlin, HG/NLY = NIKI, 4T/BHP = Belair |
| 797 | - $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
|
| 797 | + $numvol = preg_replace('/^[A-Z]*/', '', $callsign); |
|
| 798 | 798 | $check_date = new Datetime($date); |
| 799 | - $url= "http://www.airberlin.com/en-US/site/aims.php"; |
|
| 800 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
| 801 | - $post = array('type' => 'departure','searchFlightNo' => '1','requestsent' => 'true', 'flightno' => $numvol,'date' => $check_date->format('Y-m-d'),'carrier' => $carrier); |
|
| 802 | - $data = $Common->getData($url,'post',$post); |
|
| 799 | + $url = "http://www.airberlin.com/en-US/site/aims.php"; |
|
| 800 | + if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array(); |
|
| 801 | + $post = array('type' => 'departure', 'searchFlightNo' => '1', 'requestsent' => 'true', 'flightno' => $numvol, 'date' => $check_date->format('Y-m-d'), 'carrier' => $carrier); |
|
| 802 | + $data = $Common->getData($url, 'post', $post); |
|
| 803 | 803 | //echo $data; |
| 804 | 804 | $DepartureAirportIata = ''; |
| 805 | 805 | $ArrivalAirportIata = ''; |
@@ -812,8 +812,8 @@ discard block |
||
| 812 | 812 | if (isset($flight[5][2])) $departureAirport = $flight[5][2]; |
| 813 | 813 | else $departureAirport = ''; |
| 814 | 814 | } else return array(); |
| 815 | - $post = array('type' => 'arrival','searchFlightNo' => '1','requestsent' => 'true', 'flightno' => $numvol,'date' => $check_date->format('Y-m-d'),'carrier' => 'AB'); |
|
| 816 | - $data = $Common->getData($url,'post',$post); |
|
| 815 | + $post = array('type' => 'arrival', 'searchFlightNo' => '1', 'requestsent' => 'true', 'flightno' => $numvol, 'date' => $check_date->format('Y-m-d'), 'carrier' => 'AB'); |
|
| 816 | + $data = $Common->getData($url, 'post', $post); |
|
| 817 | 817 | if ($data != '') { |
| 818 | 818 | $table = $Common->table2array($data); |
| 819 | 819 | $flight = $table; |
@@ -841,13 +841,13 @@ discard block |
||
| 841 | 841 | } |
| 842 | 842 | } |
| 843 | 843 | if (isset($DepartureAirportIata)) { |
| 844 | - return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_airberlin'); |
|
| 844 | + return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_airberlin'); |
|
| 845 | 845 | } else return array(); |
| 846 | 846 | } |
| 847 | 847 | |
| 848 | 848 | |
| 849 | 849 | |
| 850 | - public function fetchSchedule($ident,$date = 'NOW') { |
|
| 850 | + public function fetchSchedule($ident, $date = 'NOW') { |
|
| 851 | 851 | global $globalSchedulesSources, $globalSchedulesFetch, $globalOffline; |
| 852 | 852 | //$Common = new Common(); |
| 853 | 853 | if ($globalSchedulesFetch === FALSE || (isset($globalOffline) && $globalOffline === TRUE)) return array(); |
@@ -917,7 +917,7 @@ discard block |
||
| 917 | 917 | // Brussels Airlines |
| 918 | 918 | case "BEL": |
| 919 | 919 | case "SN": |
| 920 | - return $this->getBrussels($ident,$date); |
|
| 920 | + return $this->getBrussels($ident, $date); |
|
| 921 | 921 | /* |
| 922 | 922 | // Copa Airlines |
| 923 | 923 | case "CMP": |
@@ -1002,17 +1002,17 @@ discard block |
||
| 1002 | 1002 | // Air France |
| 1003 | 1003 | case "AF": |
| 1004 | 1004 | case "AFR": |
| 1005 | - return $this->getAirFrance($ident,$date,'AF'); |
|
| 1005 | + return $this->getAirFrance($ident, $date, 'AF'); |
|
| 1006 | 1006 | // HOP |
| 1007 | 1007 | case "A5": |
| 1008 | 1008 | case "HOP": |
| 1009 | - return $this->getAirFrance($ident,$date,'A5'); |
|
| 1009 | + return $this->getAirFrance($ident, $date, 'A5'); |
|
| 1010 | 1010 | // EasyJet |
| 1011 | 1011 | case "U2": |
| 1012 | 1012 | case "DS": |
| 1013 | 1013 | case "EZY": |
| 1014 | 1014 | case "EZS": |
| 1015 | - return $this->getEasyJet($ident,$date); |
|
| 1015 | + return $this->getEasyJet($ident, $date); |
|
| 1016 | 1016 | // Ryanair |
| 1017 | 1017 | case "FR": |
| 1018 | 1018 | case "RYR": |
@@ -1062,25 +1062,25 @@ discard block |
||
| 1062 | 1062 | return $this->getIberia($ident); |
| 1063 | 1063 | // Vietnam Airlines |
| 1064 | 1064 | case "HVN": |
| 1065 | - return $this->getVietnamAirlines($ident,$date); |
|
| 1065 | + return $this->getVietnamAirlines($ident, $date); |
|
| 1066 | 1066 | // Air Berlin |
| 1067 | 1067 | case "AB": |
| 1068 | 1068 | case "BER": |
| 1069 | - return $this->getAirBerlin($ident,$date,'AB'); |
|
| 1069 | + return $this->getAirBerlin($ident, $date, 'AB'); |
|
| 1070 | 1070 | // NIKI |
| 1071 | 1071 | case "HG": |
| 1072 | 1072 | case "NLY": |
| 1073 | - return $this->getAirBerlin($ident,$date,'HG'); |
|
| 1073 | + return $this->getAirBerlin($ident, $date, 'HG'); |
|
| 1074 | 1074 | // BelAir |
| 1075 | 1075 | case "4T": |
| 1076 | 1076 | case "BHP": |
| 1077 | - return $this->getAirBerlin($ident,$date,'4T'); |
|
| 1077 | + return $this->getAirBerlin($ident, $date, '4T'); |
|
| 1078 | 1078 | default: |
| 1079 | 1079 | // Randomly use a generic function to get hours |
| 1080 | 1080 | if (strlen($airline_icao) == 2) { |
| 1081 | - if (!isset($globalSchedulesSources)) $globalSchedulesSources = array('flightmapper','costtotravel','flightradar24','flightaware'); |
|
| 1081 | + if (!isset($globalSchedulesSources)) $globalSchedulesSources = array('flightmapper', 'costtotravel', 'flightradar24', 'flightaware'); |
|
| 1082 | 1082 | if (count($globalSchedulesSources) > 0) { |
| 1083 | - $rand = mt_rand(0,count($globalSchedulesSources)-1); |
|
| 1083 | + $rand = mt_rand(0, count($globalSchedulesSources) - 1); |
|
| 1084 | 1084 | $source = $globalSchedulesSources[$rand]; |
| 1085 | 1085 | if ($source == 'flightmapper') return $this->getFlightMapper($ident); |
| 1086 | 1086 | elseif ($source == 'costtotravel') return $this->getCostToTravel($ident); |
@@ -13,11 +13,11 @@ discard block |
||
| 13 | 13 | } |
| 14 | 14 | |
| 15 | 15 | /** |
| 16 | - * Gets the images based on the aircraft registration |
|
| 17 | - * |
|
| 18 | - * @return Array the images list |
|
| 19 | - * |
|
| 20 | - */ |
|
| 16 | + * Gets the images based on the aircraft registration |
|
| 17 | + * |
|
| 18 | + * @return Array the images list |
|
| 19 | + * |
|
| 20 | + */ |
|
| 21 | 21 | public function getSpotterImage($registration,$aircraft_icao = '', $airline_icao = '') |
| 22 | 22 | { |
| 23 | 23 | $registration = filter_var($registration,FILTER_SANITIZE_STRING); |
@@ -38,11 +38,11 @@ discard block |
||
| 38 | 38 | } |
| 39 | 39 | |
| 40 | 40 | /** |
| 41 | - * Gets the images based on the ship name |
|
| 42 | - * |
|
| 43 | - * @return Array the images list |
|
| 44 | - * |
|
| 45 | - */ |
|
| 41 | + * Gets the images based on the ship name |
|
| 42 | + * |
|
| 43 | + * @return Array the images list |
|
| 44 | + * |
|
| 45 | + */ |
|
| 46 | 46 | public function getMarineImage($mmsi,$imo = '',$name = '') |
| 47 | 47 | { |
| 48 | 48 | $mmsi = filter_var($mmsi,FILTER_SANITIZE_STRING); |
@@ -69,11 +69,11 @@ discard block |
||
| 69 | 69 | } |
| 70 | 70 | |
| 71 | 71 | /** |
| 72 | - * Gets the image copyright based on the Exif data |
|
| 73 | - * |
|
| 74 | - * @return String image copyright |
|
| 75 | - * |
|
| 76 | - */ |
|
| 72 | + * Gets the image copyright based on the Exif data |
|
| 73 | + * |
|
| 74 | + * @return String image copyright |
|
| 75 | + * |
|
| 76 | + */ |
|
| 77 | 77 | public function getExifCopyright($url) { |
| 78 | 78 | $exif = exif_read_data($url); |
| 79 | 79 | $copyright = ''; |
@@ -88,11 +88,11 @@ discard block |
||
| 88 | 88 | } |
| 89 | 89 | |
| 90 | 90 | /** |
| 91 | - * Adds the images based on the aircraft registration |
|
| 92 | - * |
|
| 93 | - * @return String either success or error |
|
| 94 | - * |
|
| 95 | - */ |
|
| 91 | + * Adds the images based on the aircraft registration |
|
| 92 | + * |
|
| 93 | + * @return String either success or error |
|
| 94 | + * |
|
| 95 | + */ |
|
| 96 | 96 | public function addSpotterImage($registration,$aircraft_icao = '', $airline_icao = '') |
| 97 | 97 | { |
| 98 | 98 | global $globalDebug,$globalAircraftImageFetch, $globalOffline; |
@@ -120,11 +120,11 @@ discard block |
||
| 120 | 120 | } |
| 121 | 121 | |
| 122 | 122 | /** |
| 123 | - * Adds the images based on the marine name |
|
| 124 | - * |
|
| 125 | - * @return String either success or error |
|
| 126 | - * |
|
| 127 | - */ |
|
| 123 | + * Adds the images based on the marine name |
|
| 124 | + * |
|
| 125 | + * @return String either success or error |
|
| 126 | + * |
|
| 127 | + */ |
|
| 128 | 128 | public function addMarineImage($mmsi,$imo = '',$name = '') |
| 129 | 129 | { |
| 130 | 130 | global $globalDebug,$globalMarineImageFetch, $globalOffline; |
@@ -161,12 +161,12 @@ discard block |
||
| 161 | 161 | } |
| 162 | 162 | |
| 163 | 163 | /** |
| 164 | - * Gets the aircraft image |
|
| 165 | - * |
|
| 166 | - * @param String $aircraft_registration the registration of the aircraft |
|
| 167 | - * @return Array the aircraft thumbnail, orignal url and copyright |
|
| 168 | - * |
|
| 169 | - */ |
|
| 164 | + * Gets the aircraft image |
|
| 165 | + * |
|
| 166 | + * @param String $aircraft_registration the registration of the aircraft |
|
| 167 | + * @return Array the aircraft thumbnail, orignal url and copyright |
|
| 168 | + * |
|
| 169 | + */ |
|
| 170 | 170 | public function findAircraftImage($aircraft_registration, $aircraft_icao = '', $airline_icao = '') |
| 171 | 171 | { |
| 172 | 172 | global $globalAircraftImageSources, $globalIVAO, $globalAircraftImageCheckICAO, $globalVA; |
@@ -210,14 +210,14 @@ discard block |
||
| 210 | 210 | } |
| 211 | 211 | |
| 212 | 212 | /** |
| 213 | - * Gets the vessel image |
|
| 214 | - * |
|
| 215 | - * @param String $mmsi the vessel mmsi |
|
| 216 | - * @param String $imo the vessel imo |
|
| 217 | - * @param String $name the vessel name |
|
| 218 | - * @return Array the aircraft thumbnail, orignal url and copyright |
|
| 219 | - * |
|
| 220 | - */ |
|
| 213 | + * Gets the vessel image |
|
| 214 | + * |
|
| 215 | + * @param String $mmsi the vessel mmsi |
|
| 216 | + * @param String $imo the vessel imo |
|
| 217 | + * @param String $name the vessel name |
|
| 218 | + * @return Array the aircraft thumbnail, orignal url and copyright |
|
| 219 | + * |
|
| 220 | + */ |
|
| 221 | 221 | public function findMarineImage($mmsi,$imo = '',$name = '') |
| 222 | 222 | { |
| 223 | 223 | global $globalMarineImageSources; |
@@ -251,13 +251,13 @@ discard block |
||
| 251 | 251 | } |
| 252 | 252 | |
| 253 | 253 | /** |
| 254 | - * Gets the aircraft image from Planespotters |
|
| 255 | - * |
|
| 256 | - * @param String $aircraft_registration the registration of the aircraft |
|
| 257 | - * @param String $aircraft_name type of the aircraft |
|
| 258 | - * @return Array the aircraft thumbnail, orignal url and copyright |
|
| 259 | - * |
|
| 260 | - */ |
|
| 254 | + * Gets the aircraft image from Planespotters |
|
| 255 | + * |
|
| 256 | + * @param String $aircraft_registration the registration of the aircraft |
|
| 257 | + * @param String $aircraft_name type of the aircraft |
|
| 258 | + * @return Array the aircraft thumbnail, orignal url and copyright |
|
| 259 | + * |
|
| 260 | + */ |
|
| 261 | 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 |
@@ -285,13 +285,13 @@ discard block |
||
| 285 | 285 | } |
| 286 | 286 | |
| 287 | 287 | /** |
| 288 | - * Gets the aircraft image from Deviantart |
|
| 289 | - * |
|
| 290 | - * @param String $registration the registration of the aircraft |
|
| 291 | - * @param String $name type of the aircraft |
|
| 292 | - * @return Array the aircraft thumbnail, orignal url and copyright |
|
| 293 | - * |
|
| 294 | - */ |
|
| 288 | + * Gets the aircraft image from Deviantart |
|
| 289 | + * |
|
| 290 | + * @param String $registration the registration of the aircraft |
|
| 291 | + * @param String $name type of the aircraft |
|
| 292 | + * @return Array the aircraft thumbnail, orignal url and copyright |
|
| 293 | + * |
|
| 294 | + */ |
|
| 295 | 295 | public function fromDeviantart($type,$registration, $name='') { |
| 296 | 296 | $Common = new Common(); |
| 297 | 297 | if ($type == 'aircraft') { |
@@ -325,13 +325,13 @@ discard block |
||
| 325 | 325 | } |
| 326 | 326 | |
| 327 | 327 | /** |
| 328 | - * Gets the aircraft image from JetPhotos |
|
| 329 | - * |
|
| 330 | - * @param String $aircraft_registration the registration of the aircraft |
|
| 331 | - * @param String $aircraft_name type of the aircraft |
|
| 332 | - * @return Array the aircraft thumbnail, orignal url and copyright |
|
| 333 | - * |
|
| 334 | - */ |
|
| 328 | + * Gets the aircraft image from JetPhotos |
|
| 329 | + * |
|
| 330 | + * @param String $aircraft_registration the registration of the aircraft |
|
| 331 | + * @param String $aircraft_name type of the aircraft |
|
| 332 | + * @return Array the aircraft thumbnail, orignal url and copyright |
|
| 333 | + * |
|
| 334 | + */ |
|
| 335 | 335 | public function fromJetPhotos($type,$aircraft_registration, $aircraft_name='') { |
| 336 | 336 | $Common = new Common(); |
| 337 | 337 | $url= 'http://jetphotos.net/showphotos.php?displaymode=2®search='.$aircraft_registration; |
@@ -367,13 +367,13 @@ discard block |
||
| 367 | 367 | } |
| 368 | 368 | |
| 369 | 369 | /** |
| 370 | - * Gets the aircraft image from PlanePictures |
|
| 371 | - * |
|
| 372 | - * @param String $aircraft_registration the registration of the aircraft |
|
| 373 | - * @param String $aircraft_name type of the aircraft |
|
| 374 | - * @return Array the aircraft thumbnail, orignal url and copyright |
|
| 375 | - * |
|
| 376 | - */ |
|
| 370 | + * Gets the aircraft image from PlanePictures |
|
| 371 | + * |
|
| 372 | + * @param String $aircraft_registration the registration of the aircraft |
|
| 373 | + * @param String $aircraft_name type of the aircraft |
|
| 374 | + * @return Array the aircraft thumbnail, orignal url and copyright |
|
| 375 | + * |
|
| 376 | + */ |
|
| 377 | 377 | public function fromPlanePictures($type,$aircraft_registration, $aircraft_name='') { |
| 378 | 378 | $Common = new Common(); |
| 379 | 379 | $url= 'http://www.planepictures.net/netsearch4.cgi?srch='.$aircraft_registration.'&stype=reg&srng=2'; |
@@ -401,13 +401,13 @@ discard block |
||
| 401 | 401 | } |
| 402 | 402 | |
| 403 | 403 | /** |
| 404 | - * Gets the aircraft image from Flickr |
|
| 405 | - * |
|
| 406 | - * @param String $registration the registration of the aircraft |
|
| 407 | - * @param String $name type of the aircraft |
|
| 408 | - * @return Array the aircraft thumbnail, orignal url and copyright |
|
| 409 | - * |
|
| 410 | - */ |
|
| 404 | + * Gets the aircraft image from Flickr |
|
| 405 | + * |
|
| 406 | + * @param String $registration the registration of the aircraft |
|
| 407 | + * @param String $name type of the aircraft |
|
| 408 | + * @return Array the aircraft thumbnail, orignal url and copyright |
|
| 409 | + * |
|
| 410 | + */ |
|
| 411 | 411 | public function fromFlickr($type,$registration,$name='') { |
| 412 | 412 | $Common = new Common(); |
| 413 | 413 | if ($type == 'aircraft') { |
@@ -451,13 +451,13 @@ discard block |
||
| 451 | 451 | } |
| 452 | 452 | |
| 453 | 453 | /** |
| 454 | - * Gets the aircraft image from Bing |
|
| 455 | - * |
|
| 456 | - * @param String $aircraft_registration the registration of the aircraft |
|
| 457 | - * @param String $aircraft_name type of the aircraft |
|
| 458 | - * @return Array the aircraft thumbnail, orignal url and copyright |
|
| 459 | - * |
|
| 460 | - */ |
|
| 454 | + * Gets the aircraft image from Bing |
|
| 455 | + * |
|
| 456 | + * @param String $aircraft_registration the registration of the aircraft |
|
| 457 | + * @param String $aircraft_name type of the aircraft |
|
| 458 | + * @return Array the aircraft thumbnail, orignal url and copyright |
|
| 459 | + * |
|
| 460 | + */ |
|
| 461 | 461 | public function fromBing($type,$aircraft_registration,$aircraft_name='') { |
| 462 | 462 | global $globalImageBingKey; |
| 463 | 463 | $Common = new Common(); |
@@ -488,13 +488,13 @@ discard block |
||
| 488 | 488 | } |
| 489 | 489 | |
| 490 | 490 | /** |
| 491 | - * Gets the aircraft image from airport-data |
|
| 492 | - * |
|
| 493 | - * @param String $aircraft_registration the registration of the aircraft |
|
| 494 | - * @param String $aircraft_name type of the aircraft |
|
| 495 | - * @return Array the aircraft thumbnail, orignal url and copyright |
|
| 496 | - * |
|
| 497 | - */ |
|
| 491 | + * Gets the aircraft image from airport-data |
|
| 492 | + * |
|
| 493 | + * @param String $aircraft_registration the registration of the aircraft |
|
| 494 | + * @param String $aircraft_name type of the aircraft |
|
| 495 | + * @return Array the aircraft thumbnail, orignal url and copyright |
|
| 496 | + * |
|
| 497 | + */ |
|
| 498 | 498 | public function fromAirportData($type,$aircraft_registration,$aircraft_name='') { |
| 499 | 499 | $Common = new Common(); |
| 500 | 500 | $url = 'http://www.airport-data.com/api/ac_thumb.json?&n=1&r='.$aircraft_registration; |
@@ -513,13 +513,13 @@ discard block |
||
| 513 | 513 | } |
| 514 | 514 | |
| 515 | 515 | /** |
| 516 | - * Gets image from WikiMedia |
|
| 517 | - * |
|
| 518 | - * @param String $registration the registration of the aircraft/mmsi |
|
| 519 | - * @param String $name name |
|
| 520 | - * @return Array the aircraft thumbnail, orignal url and copyright |
|
| 521 | - * |
|
| 522 | - */ |
|
| 516 | + * Gets image from WikiMedia |
|
| 517 | + * |
|
| 518 | + * @param String $registration the registration of the aircraft/mmsi |
|
| 519 | + * @param String $name name |
|
| 520 | + * @return Array the aircraft thumbnail, orignal url and copyright |
|
| 521 | + * |
|
| 522 | + */ |
|
| 523 | 523 | public function fromWikimedia($type,$registration,$name='') { |
| 524 | 524 | $Common = new Common(); |
| 525 | 525 | if ($type == 'aircraft') { |
@@ -574,13 +574,13 @@ discard block |
||
| 574 | 574 | } |
| 575 | 575 | |
| 576 | 576 | /** |
| 577 | - * Gets the aircraft image from custom url |
|
| 578 | - * |
|
| 579 | - * @param String $registration the registration of the aircraft |
|
| 580 | - * @param String $name type of the aircraft |
|
| 581 | - * @return Array the aircraft thumbnail, orignal url and copyright |
|
| 582 | - * |
|
| 583 | - */ |
|
| 577 | + * Gets the aircraft image from custom url |
|
| 578 | + * |
|
| 579 | + * @param String $registration the registration of the aircraft |
|
| 580 | + * @param String $name type of the aircraft |
|
| 581 | + * @return Array the aircraft thumbnail, orignal url and copyright |
|
| 582 | + * |
|
| 583 | + */ |
|
| 584 | 584 | public function fromCustomSource($type,$registration,$name='') { |
| 585 | 585 | global $globalAircraftImageCustomSources, $globalMarineImageCustomSources, $globalDebug; |
| 586 | 586 | //$globalAircraftImageCustomSource[] = array('thumbnail' => '','original' => '', 'copyright' => '', 'source_website' => '', 'source' => '','exif' => true); |
@@ -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 == '' || $reg == 'NA') && $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 != '' && ($aircraft_icao != '' || $airline_icao != '')) return $this->getSpotterImage('',$aircraft_icao,$airline_icao); |
|
| 36 | + elseif ($registration != '' && ($aircraft_icao != '' || $airline_icao != '')) 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, $globalOffline; |
|
| 98 | + global $globalDebug, $globalAircraftImageFetch, $globalOffline; |
|
| 99 | 99 | if ((isset($globalAircraftImageFetch) && $globalAircraftImageFetch === FALSE) || (isset($globalOffline) && $globalOffline === TRUE)) 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, $globalOffline; |
|
| 130 | + global $globalDebug, $globalMarineImageFetch, $globalOffline; |
|
| 131 | 131 | if ((isset($globalMarineImageFetch) && !$globalMarineImageFetch) || (isset($globalOffline) && $globalOffline === TRUE)) 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 != '' && $aircraft_registration != 'NA' && (!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,25 +258,25 @@ 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 (substr($data, 0, 5) != "<?xml") return false; |
| 272 | 272 | if ($xml = simplexml_load_string($data)) { |
| 273 | 273 | if (isset($xml->channel->item)) { |
| 274 | 274 | $image_url = array(); |
| 275 | - $thumbnail_url = trim((string)$xml->channel->item->children('http://search.yahoo.com/mrss/')->thumbnail->attributes()->url); |
|
| 275 | + $thumbnail_url = trim((string) $xml->channel->item->children('http://search.yahoo.com/mrss/')->thumbnail->attributes()->url); |
|
| 276 | 276 | $image_url['thumbnail'] = $thumbnail_url; |
| 277 | - $image_url['original'] = str_replace('thumbnail','original',$thumbnail_url); |
|
| 278 | - $image_url['copyright'] = trim((string)$xml->channel->item->children('http://search.yahoo.com/mrss/')->copyright); |
|
| 279 | - $image_url['source_website'] = trim((string)$xml->channel->item->link); |
|
| 277 | + $image_url['original'] = str_replace('thumbnail', 'original', $thumbnail_url); |
|
| 278 | + $image_url['copyright'] = trim((string) $xml->channel->item->children('http://search.yahoo.com/mrss/')->copyright); |
|
| 279 | + $image_url['source_website'] = trim((string) $xml->channel->item->link); |
|
| 280 | 280 | $image_url['source'] = 'planespotters'; |
| 281 | 281 | return $image_url; |
| 282 | 282 | } |
@@ -292,31 +292,31 @@ discard block |
||
| 292 | 292 | * @return Array the aircraft thumbnail, orignal url and copyright |
| 293 | 293 | * |
| 294 | 294 | */ |
| 295 | - public function fromDeviantart($type,$registration, $name='') { |
|
| 295 | + public function fromDeviantart($type, $registration, $name = '') { |
|
| 296 | 296 | $Common = new Common(); |
| 297 | 297 | if ($type == 'aircraft') { |
| 298 | 298 | // If aircraft registration is only number, also check with aircraft model |
| 299 | - if (preg_match('/^[[:digit]]+$/',$registration) && $name != '') { |
|
| 300 | - $url= 'http://backend.deviantart.com/rss.xml?type=deviation&q='.$registration.'%20'.urlencode($name); |
|
| 299 | + if (preg_match('/^[[:digit]]+$/', $registration) && $name != '') { |
|
| 300 | + $url = 'http://backend.deviantart.com/rss.xml?type=deviation&q='.$registration.'%20'.urlencode($name); |
|
| 301 | 301 | } else { |
| 302 | - $url= 'http://backend.deviantart.com/rss.xml?type=deviation&q=aircraft%20'.$registration; |
|
| 302 | + $url = 'http://backend.deviantart.com/rss.xml?type=deviation&q=aircraft%20'.$registration; |
|
| 303 | 303 | } |
| 304 | 304 | } elseif ($type == 'marine') { |
| 305 | - $url= 'http://backend.deviantart.com/rss.xml?type=deviation&q=ship%20"'.urlencode($name).'"'; |
|
| 305 | + $url = 'http://backend.deviantart.com/rss.xml?type=deviation&q=ship%20"'.urlencode($name).'"'; |
|
| 306 | 306 | } else { |
| 307 | - $url= 'http://backend.deviantart.com/rss.xml?type=deviation&q="'.urlencode($name).'"'; |
|
| 307 | + $url = 'http://backend.deviantart.com/rss.xml?type=deviation&q="'.urlencode($name).'"'; |
|
| 308 | 308 | } |
| 309 | 309 | $data = $Common->getData($url); |
| 310 | 310 | if (substr($data, 0, 5) != "<?xml") return false; |
| 311 | 311 | if ($xml = simplexml_load_string($data)) { |
| 312 | 312 | if (isset($xml->channel->item->link)) { |
| 313 | 313 | $image_url = array(); |
| 314 | - $thumbnail_url = trim((string)$xml->channel->item->children('http://search.yahoo.com/mrss/')->thumbnail->attributes()->url); |
|
| 314 | + $thumbnail_url = trim((string) $xml->channel->item->children('http://search.yahoo.com/mrss/')->thumbnail->attributes()->url); |
|
| 315 | 315 | $image_url['thumbnail'] = $thumbnail_url; |
| 316 | - $original_url = trim((string)$xml->channel->item->children('http://search.yahoo.com/mrss/')->content->attributes()->url); |
|
| 316 | + $original_url = trim((string) $xml->channel->item->children('http://search.yahoo.com/mrss/')->content->attributes()->url); |
|
| 317 | 317 | $image_url['original'] = $original_url; |
| 318 | - $image_url['copyright'] = str_replace('Copyright ','',trim((string)$xml->channel->item->children('http://search.yahoo.com/mrss/')->copyright)); |
|
| 319 | - $image_url['source_website'] = trim((string)$xml->channel->item->link); |
|
| 318 | + $image_url['copyright'] = str_replace('Copyright ', '', trim((string) $xml->channel->item->children('http://search.yahoo.com/mrss/')->copyright)); |
|
| 319 | + $image_url['source_website'] = trim((string) $xml->channel->item->link); |
|
| 320 | 320 | $image_url['source'] = 'deviantart'; |
| 321 | 321 | return $image_url; |
| 322 | 322 | } |
@@ -332,32 +332,32 @@ discard block |
||
| 332 | 332 | * @return Array the aircraft thumbnail, orignal url and copyright |
| 333 | 333 | * |
| 334 | 334 | */ |
| 335 | - public function fromJetPhotos($type,$aircraft_registration, $aircraft_name='') { |
|
| 335 | + public function fromJetPhotos($type, $aircraft_registration, $aircraft_name = '') { |
|
| 336 | 336 | $Common = new Common(); |
| 337 | - $url= 'http://jetphotos.net/showphotos.php?displaymode=2®search='.$aircraft_registration; |
|
| 337 | + $url = 'http://jetphotos.net/showphotos.php?displaymode=2®search='.$aircraft_registration; |
|
| 338 | 338 | $data = $Common->getData($url); |
| 339 | 339 | $dom = new DOMDocument(); |
| 340 | 340 | @$dom->loadHTML($data); |
| 341 | 341 | $all_pics = array(); |
| 342 | - foreach($dom->getElementsByTagName('img') as $image) { |
|
| 342 | + foreach ($dom->getElementsByTagName('img') as $image) { |
|
| 343 | 343 | if ($image->getAttribute('itemprop') == "http://schema.org/image") { |
| 344 | 344 | $all_pics[] = $image->getAttribute('src'); |
| 345 | 345 | } |
| 346 | 346 | } |
| 347 | 347 | $all_authors = array(); |
| 348 | - foreach($dom->getElementsByTagName('meta') as $author) { |
|
| 348 | + foreach ($dom->getElementsByTagName('meta') as $author) { |
|
| 349 | 349 | if ($author->getAttribute('itemprop') == "http://schema.org/author") { |
| 350 | 350 | $all_authors[] = $author->getAttribute('content'); |
| 351 | 351 | } |
| 352 | 352 | } |
| 353 | 353 | $all_ref = array(); |
| 354 | - foreach($dom->getElementsByTagName('a') as $link) { |
|
| 354 | + foreach ($dom->getElementsByTagName('a') as $link) { |
|
| 355 | 355 | $all_ref[] = $link->getAttribute('href'); |
| 356 | 356 | } |
| 357 | 357 | if (isset($all_pics[0])) { |
| 358 | 358 | $image_url = array(); |
| 359 | 359 | $image_url['thumbnail'] = $all_pics[0]; |
| 360 | - $image_url['original'] = str_replace('_tb','',$all_pics[0]); |
|
| 360 | + $image_url['original'] = str_replace('_tb', '', $all_pics[0]); |
|
| 361 | 361 | $image_url['copyright'] = $all_authors[0]; |
| 362 | 362 | $image_url['source_website'] = 'http://jetphotos.net'.$all_ref[8]; |
| 363 | 363 | $image_url['source'] = 'JetPhotos'; |
@@ -374,24 +374,24 @@ discard block |
||
| 374 | 374 | * @return Array the aircraft thumbnail, orignal url and copyright |
| 375 | 375 | * |
| 376 | 376 | */ |
| 377 | - public function fromPlanePictures($type,$aircraft_registration, $aircraft_name='') { |
|
| 377 | + public function fromPlanePictures($type, $aircraft_registration, $aircraft_name = '') { |
|
| 378 | 378 | $Common = new Common(); |
| 379 | - $url= 'http://www.planepictures.net/netsearch4.cgi?srch='.$aircraft_registration.'&stype=reg&srng=2'; |
|
| 379 | + $url = 'http://www.planepictures.net/netsearch4.cgi?srch='.$aircraft_registration.'&stype=reg&srng=2'; |
|
| 380 | 380 | $data = $Common->getData($url); |
| 381 | 381 | $dom = new DOMDocument(); |
| 382 | 382 | @$dom->loadHTML($data); |
| 383 | 383 | $all_pics = array(); |
| 384 | - foreach($dom->getElementsByTagName('img') as $image) { |
|
| 384 | + foreach ($dom->getElementsByTagName('img') as $image) { |
|
| 385 | 385 | $all_pics[] = $image->getAttribute('src'); |
| 386 | 386 | } |
| 387 | 387 | $all_links = array(); |
| 388 | - foreach($dom->getElementsByTagName('a') as $link) { |
|
| 389 | - $all_links[] = array('text' => $link->textContent,'href' => $link->getAttribute('href')); |
|
| 388 | + foreach ($dom->getElementsByTagName('a') as $link) { |
|
| 389 | + $all_links[] = array('text' => $link->textContent, 'href' => $link->getAttribute('href')); |
|
| 390 | 390 | } |
| 391 | - if (isset($all_pics[1]) && !preg_match('/bit.ly/',$all_pics[1]) && !preg_match('/flagge/',$all_pics[1])) { |
|
| 391 | + if (isset($all_pics[1]) && !preg_match('/bit.ly/', $all_pics[1]) && !preg_match('/flagge/', $all_pics[1])) { |
|
| 392 | 392 | $image_url = array(); |
| 393 | 393 | $image_url['thumbnail'] = 'http://www.planepictures.net/'.$all_pics[1]; |
| 394 | - $image_url['original'] = 'http://www.planepictures.net/'.str_replace('_TN','',$all_pics[1]); |
|
| 394 | + $image_url['original'] = 'http://www.planepictures.net/'.str_replace('_TN', '', $all_pics[1]); |
|
| 395 | 395 | $image_url['copyright'] = $all_links[6]['text']; |
| 396 | 396 | $image_url['source_website'] = 'http://www.planepictures.net/'.$all_links[2]['href']; |
| 397 | 397 | $image_url['source'] = 'PlanePictures'; |
@@ -408,7 +408,7 @@ discard block |
||
| 408 | 408 | * @return Array the aircraft thumbnail, orignal url and copyright |
| 409 | 409 | * |
| 410 | 410 | */ |
| 411 | - public function fromFlickr($type,$registration,$name='') { |
|
| 411 | + public function fromFlickr($type, $registration, $name = '') { |
|
| 412 | 412 | $Common = new Common(); |
| 413 | 413 | if ($type == 'aircraft') { |
| 414 | 414 | 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); |
@@ -421,12 +421,12 @@ discard block |
||
| 421 | 421 | if (substr($data, 0, 5) != "<?xml") return false; |
| 422 | 422 | if ($xml = simplexml_load_string($data)) { |
| 423 | 423 | if (isset($xml->channel->item)) { |
| 424 | - $original_url = trim((string)$xml->channel->item->enclosure->attributes()->url); |
|
| 424 | + $original_url = trim((string) $xml->channel->item->enclosure->attributes()->url); |
|
| 425 | 425 | $image_url = array(); |
| 426 | 426 | $image_url['thumbnail'] = $original_url; |
| 427 | 427 | $image_url['original'] = $original_url; |
| 428 | - $image_url['copyright'] = trim((string)$xml->channel->item->children('http://search.yahoo.com/mrss/')->credit); |
|
| 429 | - $image_url['source_website'] = trim((string)$xml->channel->item->link); |
|
| 428 | + $image_url['copyright'] = trim((string) $xml->channel->item->children('http://search.yahoo.com/mrss/')->credit); |
|
| 429 | + $image_url['source_website'] = trim((string) $xml->channel->item->link); |
|
| 430 | 430 | $image_url['source'] = 'flickr'; |
| 431 | 431 | return $image_url; |
| 432 | 432 | } |
@@ -434,7 +434,7 @@ discard block |
||
| 434 | 434 | return false; |
| 435 | 435 | } |
| 436 | 436 | |
| 437 | - public function fromIvaoMtl($type,$aircraft_icao,$airline_icao) { |
|
| 437 | + public function fromIvaoMtl($type, $aircraft_icao, $airline_icao) { |
|
| 438 | 438 | $Common = new Common(); |
| 439 | 439 | //echo "\n".'SEARCH IMAGE : http://mtlcatalog.ivao.aero/images/aircraft/'.$aircraft_icao.$airline_icao.'.jpg'; |
| 440 | 440 | if ($Common->urlexist('http://mtlcatalog.ivao.aero/images/aircraft/'.$aircraft_icao.$airline_icao.'.jpg')) { |
@@ -458,7 +458,7 @@ discard block |
||
| 458 | 458 | * @return Array the aircraft thumbnail, orignal url and copyright |
| 459 | 459 | * |
| 460 | 460 | */ |
| 461 | - public function fromBing($type,$aircraft_registration,$aircraft_name='') { |
|
| 461 | + public function fromBing($type, $aircraft_registration, $aircraft_name = '') { |
|
| 462 | 462 | global $globalImageBingKey; |
| 463 | 463 | $Common = new Common(); |
| 464 | 464 | if (!isset($globalImageBingKey) || $globalImageBingKey == '') return false; |
@@ -469,8 +469,8 @@ discard block |
||
| 469 | 469 | 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'; |
| 470 | 470 | 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'; |
| 471 | 471 | } |
| 472 | - $headers = array("Authorization: Basic " . base64_encode("ignored:".$globalImageBingKey)); |
|
| 473 | - $data = $Common->getData($url,'get','',$headers); |
|
| 472 | + $headers = array("Authorization: Basic ".base64_encode("ignored:".$globalImageBingKey)); |
|
| 473 | + $data = $Common->getData($url, 'get', '', $headers); |
|
| 474 | 474 | $result = json_decode($data); |
| 475 | 475 | if (isset($result->d->results[0]->MediaUrl)) { |
| 476 | 476 | $image_url = array(); |
@@ -495,14 +495,14 @@ discard block |
||
| 495 | 495 | * @return Array the aircraft thumbnail, orignal url and copyright |
| 496 | 496 | * |
| 497 | 497 | */ |
| 498 | - public function fromAirportData($type,$aircraft_registration,$aircraft_name='') { |
|
| 498 | + public function fromAirportData($type, $aircraft_registration, $aircraft_name = '') { |
|
| 499 | 499 | $Common = new Common(); |
| 500 | 500 | $url = 'http://www.airport-data.com/api/ac_thumb.json?&n=1&r='.$aircraft_registration; |
| 501 | 501 | $data = $Common->getData($url); |
| 502 | 502 | $result = json_decode($data); |
| 503 | 503 | if (isset($result->count) && $result->count > 0) { |
| 504 | 504 | $image_url = array(); |
| 505 | - $image_url['original'] = str_replace('thumbnails','large',$result->data[0]->image); |
|
| 505 | + $image_url['original'] = str_replace('thumbnails', 'large', $result->data[0]->image); |
|
| 506 | 506 | $image_url['source_website'] = $result->data[0]->link; |
| 507 | 507 | $image_url['thumbnail'] = $result->data[0]->image; |
| 508 | 508 | $image_url['copyright'] = $result->data[0]->photographer; |
@@ -520,7 +520,7 @@ discard block |
||
| 520 | 520 | * @return Array the aircraft thumbnail, orignal url and copyright |
| 521 | 521 | * |
| 522 | 522 | */ |
| 523 | - public function fromWikimedia($type,$registration,$name='') { |
|
| 523 | + public function fromWikimedia($type, $registration, $name = '') { |
|
| 524 | 524 | $Common = new Common(); |
| 525 | 525 | if ($type == 'aircraft') { |
| 526 | 526 | 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); |
@@ -533,7 +533,7 @@ discard block |
||
| 533 | 533 | $result = json_decode($data); |
| 534 | 534 | if (isset($result->query->search[0]->title)) { |
| 535 | 535 | $fileo = $result->query->search[0]->title; |
| 536 | - if (substr($fileo,-3) == 'pdf') return false; |
|
| 536 | + if (substr($fileo, -3) == 'pdf') return false; |
|
| 537 | 537 | $file = urlencode($fileo); |
| 538 | 538 | $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; |
| 539 | 539 | $data2 = $Common->getData($url2); |
@@ -558,11 +558,11 @@ discard block |
||
| 558 | 558 | if (isset($result2->query->pages)) { |
| 559 | 559 | foreach ($result2->query->pages as $page) { |
| 560 | 560 | if (isset($page->imageinfo[0]->extmetadata->Artist)) { |
| 561 | - $image_url['copyright'] = preg_replace('/ from(.*)/','',strip_tags($page->imageinfo[0]->extmetadata->Artist->value)); |
|
| 561 | + $image_url['copyright'] = preg_replace('/ from(.*)/', '', strip_tags($page->imageinfo[0]->extmetadata->Artist->value)); |
|
| 562 | 562 | if (isset($page->imageinfo[0]->extmetadata->License->value)) { |
| 563 | 563 | $image_url['copyright'] = $image_url['copyright'].' (under '.$page->imageinfo[0]->extmetadata->License->value.')'; |
| 564 | 564 | } |
| 565 | - $image_url['copyright'] = trim(str_replace('\n','',$image_url['copyright'])); |
|
| 565 | + $image_url['copyright'] = trim(str_replace('\n', '', $image_url['copyright'])); |
|
| 566 | 566 | return $image_url; |
| 567 | 567 | } |
| 568 | 568 | } |
@@ -581,7 +581,7 @@ discard block |
||
| 581 | 581 | * @return Array the aircraft thumbnail, orignal url and copyright |
| 582 | 582 | * |
| 583 | 583 | */ |
| 584 | - public function fromCustomSource($type,$registration,$name='') { |
|
| 584 | + public function fromCustomSource($type, $registration, $name = '') { |
|
| 585 | 585 | global $globalAircraftImageCustomSources, $globalMarineImageCustomSources, $globalDebug; |
| 586 | 586 | //$globalAircraftImageCustomSource[] = array('thumbnail' => '','original' => '', 'copyright' => '', 'source_website' => '', 'source' => '','exif' => true); |
| 587 | 587 | if (!empty($globalAircraftImageCustomSources) && $type == 'aircraft') { |
@@ -598,15 +598,15 @@ discard block |
||
| 598 | 598 | print_r($source); |
| 599 | 599 | print_r($customsources); |
| 600 | 600 | } |
| 601 | - $url = str_replace('{registration}',$registration,$source['original']); |
|
| 602 | - $url_thumbnail = str_replace('{registration}',$registration,$source['thumbnail']); |
|
| 601 | + $url = str_replace('{registration}', $registration, $source['original']); |
|
| 602 | + $url_thumbnail = str_replace('{registration}', $registration, $source['thumbnail']); |
|
| 603 | 603 | if ($Common->urlexist($url)) { |
| 604 | 604 | $image_url = array(); |
| 605 | 605 | $image_url['thumbnail'] = $url_thumbnail; |
| 606 | 606 | $image_url['original'] = $url; |
| 607 | 607 | if ($source['exif'] && exif_imagetype($url) == IMAGETYPE_JPEG) $exifCopyright = $this->getExifCopyright($url); |
| 608 | 608 | else $exifCopyright = ''; |
| 609 | - if ($exifCopyright != '') $image_url['copyright'] = $exifCopyright; |
|
| 609 | + if ($exifCopyright != '') $image_url['copyright'] = $exifCopyright; |
|
| 610 | 610 | elseif (isset($source['copyright'])) $image_url['copyright'] = $source['copyright']; |
| 611 | 611 | else $image_url['copyright'] = $source['source_website']; |
| 612 | 612 | $image_url['source_website'] = $source['source_website']; |
@@ -630,19 +630,19 @@ discard block |
||
| 630 | 630 | print_r($source); |
| 631 | 631 | print_r($customsources); |
| 632 | 632 | } |
| 633 | - $url = str_replace('{registration}',$registration,$source['original']); |
|
| 634 | - $url = str_replace('{mmsi}',$registration,$url); |
|
| 635 | - $url = str_replace('{name}',$name,$url); |
|
| 636 | - $url_thumbnail = str_replace('{registration}',$registration,$source['thumbnail']); |
|
| 637 | - $url_thumbnail = str_replace('{mmsi}',$registration,$url_thumbnail); |
|
| 638 | - $url_thumbnail = str_replace('{name}',$name,$url_thumbnail); |
|
| 633 | + $url = str_replace('{registration}', $registration, $source['original']); |
|
| 634 | + $url = str_replace('{mmsi}', $registration, $url); |
|
| 635 | + $url = str_replace('{name}', $name, $url); |
|
| 636 | + $url_thumbnail = str_replace('{registration}', $registration, $source['thumbnail']); |
|
| 637 | + $url_thumbnail = str_replace('{mmsi}', $registration, $url_thumbnail); |
|
| 638 | + $url_thumbnail = str_replace('{name}', $name, $url_thumbnail); |
|
| 639 | 639 | if ($Common->urlexist($url)) { |
| 640 | 640 | $image_url = array(); |
| 641 | 641 | $image_url['thumbnail'] = $url_thumbnail; |
| 642 | 642 | $image_url['original'] = $url; |
| 643 | 643 | if ($source['exif'] && exif_imagetype($url) == IMAGETYPE_JPEG) $exifCopyright = $this->getExifCopyright($url); |
| 644 | 644 | else $exifCopyright = ''; |
| 645 | - if ($exifCopyright != '') $image_url['copyright'] = $exifCopyright; |
|
| 645 | + if ($exifCopyright != '') $image_url['copyright'] = $exifCopyright; |
|
| 646 | 646 | elseif (isset($source['copyright'])) $image_url['copyright'] = $source['copyright']; |
| 647 | 647 | else $image_url['copyright'] = $source['source_website']; |
| 648 | 648 | $image_url['source_website'] = $source['source_website']; |