@@ -8,8 +8,11 @@ |
||
| 8 | 8 | } |
| 9 | 9 | header('Content-Type: text/javascript'); |
| 10 | 10 | $timearray = array(); |
| 11 | -if (isset($_GET['now'])) $begin = time(); |
|
| 12 | -else $begin = strtotime(date("Y").'-12-24T02:00:00Z'); |
|
| 11 | +if (isset($_GET['now'])) { |
|
| 12 | + $begin = time(); |
|
| 13 | +} else { |
|
| 14 | + $begin = strtotime(date("Y").'-12-24T02:00:00Z'); |
|
| 15 | +} |
|
| 13 | 16 | for ($i =0; $i <= 288; $i++) { |
| 14 | 17 | $timearray[] = ($begin + $i*300)*1000; |
| 15 | 18 | } |
@@ -15,7 +15,7 @@ discard block |
||
| 15 | 15 | $limit_start = 0; |
| 16 | 16 | $limit_end = 25; |
| 17 | 17 | $absolute_difference = 25; |
| 18 | - } else { |
|
| 18 | + } else { |
|
| 19 | 19 | $limit_explode = explode(",", $_GET['limit']); |
| 20 | 20 | $limit_start = $limit_explode[0]; |
| 21 | 21 | $limit_end = $limit_explode[1]; |
@@ -46,7 +46,9 @@ discard block |
||
| 46 | 46 | $METAR = new METAR(); |
| 47 | 47 | $metar_info = $METAR->getMETAR($airport_icao); |
| 48 | 48 | //print_r($metar_info); |
| 49 | - if (isset($metar_info[0]['metar'])) $metar_parse = $METAR->parse($metar_info[0]['metar']); |
|
| 49 | + if (isset($metar_info[0]['metar'])) { |
|
| 50 | + $metar_parse = $METAR->parse($metar_info[0]['metar']); |
|
| 51 | + } |
|
| 50 | 52 | //print_r($metar_parse); |
| 51 | 53 | } |
| 52 | 54 | |
@@ -60,7 +62,9 @@ discard block |
||
| 60 | 62 | print '<option></option>'; |
| 61 | 63 | $Stats = new Stats(); |
| 62 | 64 | $airport_names = $Stats->getAllAirportNames(); |
| 63 | - if (empty($airport_names)) $airport_names = $Spotter->getAllAirportNames(); |
|
| 65 | + if (empty($airport_names)) { |
|
| 66 | + $airport_names = $Spotter->getAllAirportNames(); |
|
| 67 | + } |
|
| 64 | 68 | ksort($airport_names); |
| 65 | 69 | foreach($airport_names as $airport_name) |
| 66 | 70 | { |
@@ -102,7 +106,9 @@ discard block |
||
| 102 | 106 | // Use spotter also |
| 103 | 107 | if (isset($globalTimezone)) { |
| 104 | 108 | date_default_timezone_set($globalTimezone); |
| 105 | - } else date_default_timezone_set('UTC'); |
|
| 109 | + } else { |
|
| 110 | + date_default_timezone_set('UTC'); |
|
| 111 | + } |
|
| 106 | 112 | if (count($all_data) > 0) { |
| 107 | 113 | print '<div id="chart6" class="chart" width="100%"></div> |
| 108 | 114 | <script> |
@@ -123,7 +123,9 @@ discard block |
||
| 123 | 123 | $sth->closeCursor(); |
| 124 | 124 | if (count($row) > 0) { |
| 125 | 125 | return $row; |
| 126 | - } else return array(); |
|
| 126 | + } else { |
|
| 127 | + return array(); |
|
| 128 | + } |
|
| 127 | 129 | } |
| 128 | 130 | |
| 129 | 131 | public function checkSchedule($ident) { |
@@ -159,7 +161,9 @@ discard block |
||
| 159 | 161 | $Common = new Common(); |
| 160 | 162 | $check_date = new Datetime($date); |
| 161 | 163 | $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
| 162 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
| 164 | + if (!filter_var($numvol,FILTER_VALIDATE_INT)) { |
|
| 165 | + return array(); |
|
| 166 | + } |
|
| 163 | 167 | $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'); |
| 164 | 168 | $json = $Common->getData($url); |
| 165 | 169 | |
@@ -186,7 +190,9 @@ discard block |
||
| 186 | 190 | */ |
| 187 | 191 | |
| 188 | 192 | return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_airfrance'); |
| 189 | - } else return array(); |
|
| 193 | + } else { |
|
| 194 | + return array(); |
|
| 195 | + } |
|
| 190 | 196 | } |
| 191 | 197 | |
| 192 | 198 | /** |
@@ -201,7 +207,9 @@ discard block |
||
| 201 | 207 | date_default_timezone_set($globalTimezone); |
| 202 | 208 | $check_date = new Datetime($date); |
| 203 | 209 | $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
| 204 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
| 210 | + if (!filter_var($numvol,FILTER_VALIDATE_INT)) { |
|
| 211 | + return array(); |
|
| 212 | + } |
|
| 205 | 213 | $url = "http://www.easyjet.com/ft/api/flights?date=".$check_date->format('Y-m-d')."&fn=".$callsign; |
| 206 | 214 | $json = $Common->getData($url); |
| 207 | 215 | $parsed_json = json_decode($json); |
@@ -214,7 +222,9 @@ discard block |
||
| 214 | 222 | $arrivalTime = $parsed_json->{'flights'}[0]->{'dates'}->{'fsta'}; |
| 215 | 223 | |
| 216 | 224 | return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_easyjet'); |
| 217 | - } else return array(); |
|
| 225 | + } else { |
|
| 226 | + return array(); |
|
| 227 | + } |
|
| 218 | 228 | } |
| 219 | 229 | |
| 220 | 230 | /** |
@@ -225,7 +235,9 @@ discard block |
||
| 225 | 235 | private function getRyanair($callsign) { |
| 226 | 236 | $Common = new Common(); |
| 227 | 237 | $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
| 228 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
| 238 | + if (!filter_var($numvol,FILTER_VALIDATE_INT)) { |
|
| 239 | + return array(); |
|
| 240 | + } |
|
| 229 | 241 | $url = "http://www.ryanair.com/fr/api/2/flight-info/0/50/"; |
| 230 | 242 | $post = '{"flight":"'.$numvol.'","minDepartureTime":"00:00","maxDepartureTime":"23:59"}'; |
| 231 | 243 | $headers = array('Content-Type: application/json','Content-Length: ' . strlen($post)); |
@@ -239,8 +251,12 @@ discard block |
||
| 239 | 251 | $departureTime = $parsed_json->{'flightInfo'}[0]->{'departureTime'}; |
| 240 | 252 | $arrivalTime = $parsed_json->{'flightInfo'}[0]->{'arrivalTime'}; |
| 241 | 253 | return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime, 'Source' => 'website_ryanair'); |
| 242 | - } else return array(); |
|
| 243 | - } else return array(); |
|
| 254 | + } else { |
|
| 255 | + return array(); |
|
| 256 | + } |
|
| 257 | + } else { |
|
| 258 | + return array(); |
|
| 259 | + } |
|
| 244 | 260 | } |
| 245 | 261 | |
| 246 | 262 | /** |
@@ -251,7 +267,9 @@ discard block |
||
| 251 | 267 | private function getSwiss($callsign) { |
| 252 | 268 | $Common = new Common(); |
| 253 | 269 | $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
| 254 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
| 270 | + if (!filter_var($numvol,FILTER_VALIDATE_INT)) { |
|
| 271 | + return array(); |
|
| 272 | + } |
|
| 255 | 273 | $url = "http://www.world-of-swiss.com/fr/routenetwork.json"; |
| 256 | 274 | $json = $Common->getData($url); |
| 257 | 275 | $parsed_json = json_decode($json); |
@@ -271,8 +289,12 @@ discard block |
||
| 271 | 289 | } |
| 272 | 290 | if (isset($DepartureAirportIata) && isset($ArrivalAirportIata)) { |
| 273 | 291 | return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_swiss'); |
| 274 | - } else return array(); |
|
| 275 | - } else return array(); |
|
| 292 | + } else { |
|
| 293 | + return array(); |
|
| 294 | + } |
|
| 295 | + } else { |
|
| 296 | + return array(); |
|
| 297 | + } |
|
| 276 | 298 | } |
| 277 | 299 | |
| 278 | 300 | /** |
@@ -286,12 +308,18 @@ discard block |
||
| 286 | 308 | $Common = new Common(); |
| 287 | 309 | $check_date = new Datetime($date); |
| 288 | 310 | $numvol = sprintf('%04d',preg_replace('/^[A-Z]*/','',$callsign)); |
| 289 | - if (!filter_var(preg_replace('/^[A-Z]*/','',$callsign),FILTER_VALIDATE_INT)) return array(); |
|
| 290 | - if ($globalBritishAirwaysKey == '') return array(); |
|
| 311 | + if (!filter_var(preg_replace('/^[A-Z]*/','',$callsign),FILTER_VALIDATE_INT)) { |
|
| 312 | + return array(); |
|
| 313 | + } |
|
| 314 | + if ($globalBritishAirwaysKey == '') { |
|
| 315 | + return array(); |
|
| 316 | + } |
|
| 291 | 317 | $url = "https://api.ba.com/rest-v1/v1/flights;flightNumber=".$numvol.";scheduledDepartureDate=".$check_date->format('Y-m-d').".json"; |
| 292 | 318 | $headers = array('Client-Key: '.$globalBritishAirwaysKey); |
| 293 | 319 | $json = $Common->getData($url,'get','',$headers); |
| 294 | - if ($json == '') return array(); |
|
| 320 | + if ($json == '') { |
|
| 321 | + return array(); |
|
| 322 | + } |
|
| 295 | 323 | $parsed_json = json_decode($json); |
| 296 | 324 | $flights = $parsed_json->{'FlightsResponse'}; |
| 297 | 325 | if (count($flights) > 0) { |
@@ -300,7 +328,9 @@ discard block |
||
| 300 | 328 | $departureTime = date('H:i',strtotime($parsed_json->{'FlightsResponse'}->{'Flight'}->{'Sector'}->{'ScheduledDepartureDateTime'})); |
| 301 | 329 | $arrivalTime = date('H:i',strtotime($parsed_json->{'FlightsResponse'}->{'Flight'}->{'Sector'}->{'ScheduledArrivalDateTime'})); |
| 302 | 330 | return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_britishairways'); |
| 303 | - } else return array(); |
|
| 331 | + } else { |
|
| 332 | + return array(); |
|
| 333 | + } |
|
| 304 | 334 | } |
| 305 | 335 | |
| 306 | 336 | /** |
@@ -314,19 +344,27 @@ discard block |
||
| 314 | 344 | $Common = new Common(); |
| 315 | 345 | $check_date = new Datetime($date); |
| 316 | 346 | $numvol = sprintf('%04d',preg_replace('/^[A-Z]*/','',$callsign)); |
| 317 | - if (!filter_var(preg_replace('/^[A-Z]*/','',$callsign),FILTER_VALIDATE_INT)) return array(); |
|
| 318 | - if (!isset($globalLufthansaKey) || $globalLufthansaKey == '' || !isset($globalLufthansaKey['key']) || $globalLufthansaKey['key'] == '') return array(); |
|
| 347 | + if (!filter_var(preg_replace('/^[A-Z]*/','',$callsign),FILTER_VALIDATE_INT)) { |
|
| 348 | + return array(); |
|
| 349 | + } |
|
| 350 | + if (!isset($globalLufthansaKey) || $globalLufthansaKey == '' || !isset($globalLufthansaKey['key']) || $globalLufthansaKey['key'] == '') { |
|
| 351 | + return array(); |
|
| 352 | + } |
|
| 319 | 353 | $url = "https://api.lufthansa.com/v1/oauth/token"; |
| 320 | 354 | $post = array('client_id' => $globalLufthansaKey['key'],'client_secret' => $globalLufthansaKey['secret'],'grant_type' => 'client_credentials'); |
| 321 | 355 | $data = $Common->getData($url,'post',$post); |
| 322 | 356 | $parsed_data = json_decode($data); |
| 323 | - if (!isset($parsed_data->{'access_token'})) return array(); |
|
| 357 | + if (!isset($parsed_data->{'access_token'})) { |
|
| 358 | + return array(); |
|
| 359 | + } |
|
| 324 | 360 | $token = $parsed_data->{'access_token'}; |
| 325 | 361 | |
| 326 | 362 | $url = "https://api.lufthansa.com/v1/operations/flightstatus/LH".$numvol."/".$check_date->format('Y-m-d'); |
| 327 | 363 | $headers = array('Authorization: Bearer '.$token,'Accept: application/json'); |
| 328 | 364 | $json = $Common->getData($url,'get','',$headers); |
| 329 | - if ($json == '') return array(); |
|
| 365 | + if ($json == '') { |
|
| 366 | + return array(); |
|
| 367 | + } |
|
| 330 | 368 | $parsed_json = json_decode($json); |
| 331 | 369 | if (isset($parsed_json->{'FlightStatusResource'}) && count($parsed_json->{'FlightStatusResource'}) > 0) { |
| 332 | 370 | $DepartureAirportIata = $parsed_json->{'FlightStatusResource'}->{'Flights'}->{'Flight'}->{'Departure'}->{'AirportCode'}; |
@@ -334,7 +372,9 @@ discard block |
||
| 334 | 372 | $ArrivalAirportIata = $parsed_json->{'FlightStatusResource'}->{'Flights'}->{'Flight'}->{'Arrival'}->{'AirportCode'}; |
| 335 | 373 | $arrivalTime = date('H:i',strtotime($parsed_json->{'FlightStatusResource'}->{'Flights'}->{'Flight'}->{'Arrival'}->{'ScheduledTimeLocal'}->{'DateTime'})); |
| 336 | 374 | return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_lufthansa'); |
| 337 | - } else return array(); |
|
| 375 | + } else { |
|
| 376 | + return array(); |
|
| 377 | + } |
|
| 338 | 378 | } |
| 339 | 379 | |
| 340 | 380 | /** |
@@ -348,14 +388,20 @@ discard block |
||
| 348 | 388 | $Common = new Common(); |
| 349 | 389 | $check_date = new Datetime($date); |
| 350 | 390 | $numvol = sprintf('%04d',preg_replace('/^[A-Z]*/','',$callsign)); |
| 351 | - if (!filter_var(preg_replace('/^[A-Z]*/','',$callsign),FILTER_VALIDATE_INT)) return array(); |
|
| 352 | - if ($globalTransaviaKey == '') return array(); |
|
| 391 | + if (!filter_var(preg_replace('/^[A-Z]*/','',$callsign),FILTER_VALIDATE_INT)) { |
|
| 392 | + return array(); |
|
| 393 | + } |
|
| 394 | + if ($globalTransaviaKey == '') { |
|
| 395 | + return array(); |
|
| 396 | + } |
|
| 353 | 397 | $url = "https://tst.api.transavia.com/v1/flightstatus/departuredate/".$check_date->format('Ymd').'/flightnumber/HV'.$numvol; |
| 354 | 398 | //$url = "https://api.transavia.com/v1/flightstatus/departuredate/".$check_date->format('Ymd').'/flightnumber/HV'.$numvol; |
| 355 | 399 | $headers = array('apikey: '.$globalTransaviaKey); |
| 356 | 400 | $json = $Common->getData($url,'get','',$headers); |
| 357 | 401 | //echo 'result : '.$json; |
| 358 | - if ($json == '') return array(); |
|
| 402 | + if ($json == '') { |
|
| 403 | + return array(); |
|
| 404 | + } |
|
| 359 | 405 | $parsed_json = json_decode($json); |
| 360 | 406 | |
| 361 | 407 | if (isset($parsed_json->{'data'}[0])) { |
@@ -364,7 +410,9 @@ discard block |
||
| 364 | 410 | $ArrivalAirportIata = $parsed_json->{'data'}[0]->{'flight'}->{'arrivalAirport'}->{'locationCode'}; |
| 365 | 411 | $arrivalTime = date('H:i',strtotime($parsed_json->{'data'}[0]->{'flight'}->{'arrivalDateTime'})); |
| 366 | 412 | return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_transavia'); |
| 367 | - } else return array(); |
|
| 413 | + } else { |
|
| 414 | + return array(); |
|
| 415 | + } |
|
| 368 | 416 | } |
| 369 | 417 | |
| 370 | 418 | /** |
@@ -375,7 +423,9 @@ discard block |
||
| 375 | 423 | public function getTunisair($callsign) { |
| 376 | 424 | $Common = new Common(); |
| 377 | 425 | $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
| 378 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
| 426 | + if (!filter_var($numvol,FILTER_VALIDATE_INT)) { |
|
| 427 | + return array(); |
|
| 428 | + } |
|
| 379 | 429 | $url = "http://www.tunisair.com/site/publish/module/Volj/fr/Flight_List.asp"; |
| 380 | 430 | $data = $Common->getData($url); |
| 381 | 431 | $table = $Common->table2array($data); |
@@ -396,7 +446,9 @@ discard block |
||
| 396 | 446 | $Common = new Common(); |
| 397 | 447 | $check_date = new Datetime($date); |
| 398 | 448 | $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
| 399 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
| 449 | + if (!filter_var($numvol,FILTER_VALIDATE_INT)) { |
|
| 450 | + return array(); |
|
| 451 | + } |
|
| 400 | 452 | $final_date = str_replace('/','%2F',$check_date->format('d/m/Y')); |
| 401 | 453 | $url = "http://www.vueling.com/Base/BaseProxy/RenderMacro/?macroalias=FlightStatusResult&searchBy=bycode&date=".$final_date."&flightNumber=".$numvol."&idioma=en-GB"; |
| 402 | 454 | $data = $Common->getData($url); |
@@ -406,8 +458,11 @@ discard block |
||
| 406 | 458 | $DepartureAirportIata = str_replace('flightOri=','',$result[0]); |
| 407 | 459 | preg_match('/flightDest=[A-Z]{3}/',$data,$result); |
| 408 | 460 | $ArrivalAirportIata = str_replace('flightDest=','',$result[0]); |
| 409 | - if ($DepartureAirportIata != '' && $ArrivalAirportIata != '') return array('DepartureAirportIATA' => $DepartureAirportIata,'ArrivalAirportIATA' => $ArrivalAirportIata,'Source' => 'website_vueling'); |
|
| 410 | - else return array(); |
|
| 461 | + if ($DepartureAirportIata != '' && $ArrivalAirportIata != '') { |
|
| 462 | + return array('DepartureAirportIATA' => $DepartureAirportIata,'ArrivalAirportIATA' => $ArrivalAirportIata,'Source' => 'website_vueling'); |
|
| 463 | + } else { |
|
| 464 | + return array(); |
|
| 465 | + } |
|
| 411 | 466 | } |
| 412 | 467 | return array(); |
| 413 | 468 | } |
@@ -422,7 +477,9 @@ discard block |
||
| 422 | 477 | $Common = new Common(); |
| 423 | 478 | $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
| 424 | 479 | $check_date = new Datetime($date); |
| 425 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
| 480 | + if (!filter_var($numvol,FILTER_VALIDATE_INT)) { |
|
| 481 | + return array(); |
|
| 482 | + } |
|
| 426 | 483 | $url = "https://www.iberia.com/web/flightDetail.do"; |
| 427 | 484 | $post = array('numvuelo' => $numvol,'fecha' => $check_date->format('Ymd'),'airlineID' => 'IB'); |
| 428 | 485 | $data = $Common->getData($url,'post',$post); |
@@ -439,7 +496,9 @@ discard block |
||
| 439 | 496 | $arrivalTime = trim(str_replace(' lunes','',str_replace(' ','',$flight[5][1]))); |
| 440 | 497 | if ($arrivalTime == 'Hora estimada de llegada') { |
| 441 | 498 | $arrivalTime = substr(trim(str_replace(' lunes','',str_replace(' ','',$flight[5][2]))),0,5); |
| 442 | - } else $arrivalTime = substr($arrivalTime,0,5); |
|
| 499 | + } else { |
|
| 500 | + $arrivalTime = substr($arrivalTime,0,5); |
|
| 501 | + } |
|
| 443 | 502 | return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_iberia'); |
| 444 | 503 | } |
| 445 | 504 | } |
@@ -457,7 +516,9 @@ discard block |
||
| 457 | 516 | $Common = new Common(); |
| 458 | 517 | $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
| 459 | 518 | $check_date = new Datetime($date); |
| 460 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
| 519 | + if (!filter_var($numvol,FILTER_VALIDATE_INT)) { |
|
| 520 | + return array(); |
|
| 521 | + } |
|
| 461 | 522 | $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'); |
| 462 | 523 | $data = $Common->getData($url); |
| 463 | 524 | if ($data != '') { |
@@ -473,7 +534,9 @@ discard block |
||
| 473 | 534 | $departureTime = substr(trim(str_replace('Scheduled: ','',$flight[29][0])),0,5); |
| 474 | 535 | $arrivalTime = substr(trim(str_replace('Scheduled: ','',$flight[29][1])),0,5); |
| 475 | 536 | return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_staralliance'); |
| 476 | - } else return array(); |
|
| 537 | + } else { |
|
| 538 | + return array(); |
|
| 539 | + } |
|
| 477 | 540 | } |
| 478 | 541 | |
| 479 | 542 | |
@@ -493,7 +556,9 @@ discard block |
||
| 493 | 556 | $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
| 494 | 557 | $check_date = new Datetime($date); |
| 495 | 558 | $url= "http://booking.alitalia.com/FlightStatus/fr_fr/FlightInfo?Brand=az&NumeroVolo=".$numvol."&DataCompleta=".$check_date->format('d/m/Y'); |
| 496 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
| 559 | + if (!filter_var($numvol,FILTER_VALIDATE_INT)) { |
|
| 560 | + return array(); |
|
| 561 | + } |
|
| 497 | 562 | $data = $Common->getData($url); |
| 498 | 563 | if ($data != '') { |
| 499 | 564 | $table = $Common->text2array($data); |
@@ -517,7 +582,9 @@ discard block |
||
| 517 | 582 | $check_date = new Datetime($date); |
| 518 | 583 | $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 | 584 | //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"; |
| 520 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
| 585 | + if (!filter_var($numvol,FILTER_VALIDATE_INT)) { |
|
| 586 | + return array(); |
|
| 587 | + } |
|
| 521 | 588 | $data = $Common->getData($url); |
| 522 | 589 | if ($data != '') { |
| 523 | 590 | //echo $data; |
@@ -607,7 +674,9 @@ discard block |
||
| 607 | 674 | $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
| 608 | 675 | $url= "http://www.flytap.com/France/fr/PlanifierEtReserver/Outils/DepartsEtArrivees"; |
| 609 | 676 | //$check_date = new Datetime($date); |
| 610 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
| 677 | + if (!filter_var($numvol,FILTER_VALIDATE_INT)) { |
|
| 678 | + return array(); |
|
| 679 | + } |
|
| 611 | 680 | $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'); |
| 612 | 681 | $data = $Common->getData($url,'post',$post); |
| 613 | 682 | if ($data != '') { |
@@ -639,11 +708,15 @@ discard block |
||
| 639 | 708 | $airline_icao = substr($callsign, 0, 3); |
| 640 | 709 | } |
| 641 | 710 | } |
| 642 | - if ($airline_icao == '') return array(); |
|
| 711 | + if ($airline_icao == '') { |
|
| 712 | + return array(); |
|
| 713 | + } |
|
| 643 | 714 | $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
| 644 | 715 | $url= "http://info.flightmapper.net/flight/".$airline_icao.'_'.$numvol; |
| 645 | 716 | //$check_date = new Datetime($date); |
| 646 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
| 717 | + if (!filter_var($numvol,FILTER_VALIDATE_INT)) { |
|
| 718 | + return array(); |
|
| 719 | + } |
|
| 647 | 720 | $data = $Common->getData($url); |
| 648 | 721 | if ($data != '') { |
| 649 | 722 | $table = $Common->table2array($data); |
@@ -686,7 +759,9 @@ discard block |
||
| 686 | 759 | $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
| 687 | 760 | $url= "http://fr.flightaware.com/live/flight/".$callsign; |
| 688 | 761 | //$check_date = new Datetime($date); |
| 689 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
| 762 | + if (!filter_var($numvol,FILTER_VALIDATE_INT)) { |
|
| 763 | + return array(); |
|
| 764 | + } |
|
| 690 | 765 | $data = $Common->getData($url); |
| 691 | 766 | if ($data != '') { |
| 692 | 767 | $table = $Common->table2array($data); |
@@ -739,11 +814,15 @@ discard block |
||
| 739 | 814 | $check_date = new Datetime($date); |
| 740 | 815 | $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
| 741 | 816 | $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"; |
| 742 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
| 817 | + if (!filter_var($numvol,FILTER_VALIDATE_INT)) { |
|
| 818 | + return array(); |
|
| 819 | + } |
|
| 743 | 820 | $data = $Common->getData($url); |
| 744 | 821 | $dom = new DomDocument(); |
| 745 | 822 | $dom->loadXML($data); |
| 746 | - if ($dom->getElementsByTagName('DepartureStationInfo')->length == 0) return array(); |
|
| 823 | + if ($dom->getElementsByTagName('DepartureStationInfo')->length == 0) { |
|
| 824 | + return array(); |
|
| 825 | + } |
|
| 747 | 826 | $departure = $dom->getElementsByTagName('DepartureStationInfo')->item(0); |
| 748 | 827 | if (isset($departure->getElementsByTagName('Airport')->item(0)->firstChild->nodeValue)) { |
| 749 | 828 | $DepartureAirportIata = $departure->getElementsByTagName('Airport')->item(0)->firstChild->nodeValue; |
@@ -752,7 +831,9 @@ discard block |
||
| 752 | 831 | $ArrivalAirportIata = $arrival->getElementsByTagName('Airport')->item(0)->firstChild->nodeValue; |
| 753 | 832 | $arrivalTime = date('H:i',strtotime($arrival->getElementsByTagName('ScheduledTime')->item(0)->firstChild->nodeValue)); |
| 754 | 833 | return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_aircanada'); |
| 755 | - } else return array(); |
|
| 834 | + } else { |
|
| 835 | + return array(); |
|
| 836 | + } |
|
| 756 | 837 | } |
| 757 | 838 | |
| 758 | 839 | /** |
@@ -766,7 +847,9 @@ discard block |
||
| 766 | 847 | $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
| 767 | 848 | $check_date = new Datetime($date); |
| 768 | 849 | $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."&"; |
| 769 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
| 850 | + if (!filter_var($numvol,FILTER_VALIDATE_INT)) { |
|
| 851 | + return array(); |
|
| 852 | + } |
|
| 770 | 853 | $data = $Common->getData($url); |
| 771 | 854 | if ($data != '') { |
| 772 | 855 | $table = $Common->table2array($data); |
@@ -795,7 +878,9 @@ discard block |
||
| 795 | 878 | $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
| 796 | 879 | $check_date = new Datetime($date); |
| 797 | 880 | $url= "http://www.airberlin.com/en-US/site/aims.php"; |
| 798 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
| 881 | + if (!filter_var($numvol,FILTER_VALIDATE_INT)) { |
|
| 882 | + return array(); |
|
| 883 | + } |
|
| 799 | 884 | $post = array('type' => 'departure','searchFlightNo' => '1','requestsent' => 'true', 'flightno' => $numvol,'date' => $check_date->format('Y-m-d'),'carrier' => $carrier); |
| 800 | 885 | $data = $Common->getData($url,'post',$post); |
| 801 | 886 | //echo $data; |
@@ -805,11 +890,19 @@ discard block |
||
| 805 | 890 | if ($data != '') { |
| 806 | 891 | $table = $Common->table2array($data); |
| 807 | 892 | $flight = $table; |
| 808 | - if (isset($flight[5][4])) $departureTime = $flight[5][4]; |
|
| 809 | - else $departureTime = ''; |
|
| 810 | - if (isset($flight[5][2])) $departureAirport = $flight[5][2]; |
|
| 811 | - else $departureAirport = ''; |
|
| 812 | - } else return array(); |
|
| 893 | + if (isset($flight[5][4])) { |
|
| 894 | + $departureTime = $flight[5][4]; |
|
| 895 | + } else { |
|
| 896 | + $departureTime = ''; |
|
| 897 | + } |
|
| 898 | + if (isset($flight[5][2])) { |
|
| 899 | + $departureAirport = $flight[5][2]; |
|
| 900 | + } else { |
|
| 901 | + $departureAirport = ''; |
|
| 902 | + } |
|
| 903 | + } else { |
|
| 904 | + return array(); |
|
| 905 | + } |
|
| 813 | 906 | $post = array('type' => 'arrival','searchFlightNo' => '1','requestsent' => 'true', 'flightno' => $numvol,'date' => $check_date->format('Y-m-d'),'carrier' => 'AB'); |
| 814 | 907 | $data = $Common->getData($url,'post',$post); |
| 815 | 908 | if ($data != '') { |
@@ -822,10 +915,14 @@ discard block |
||
| 822 | 915 | $arrivalTime = ''; |
| 823 | 916 | $arrivalAirport = ''; |
| 824 | 917 | } |
| 825 | - } else return array(); |
|
| 918 | + } else { |
|
| 919 | + return array(); |
|
| 920 | + } |
|
| 826 | 921 | $url = 'http://www.airberlin.com/en-US/site/json/suggestAirport.php?searchfor=departures&searchflightid=0&departures%5B%5D=&suggestsource%5B0%5D=activeairports&withcountries=0&withoutroutings=0&promotion%5Bid%5D=&promotion%5Btype%5D=&routesource%5B0%5D=airberlin&routesource%5B1%5D=partner'; |
| 827 | 922 | $json = $Common->getData($url); |
| 828 | - if ($json == '') return array(); |
|
| 923 | + if ($json == '') { |
|
| 924 | + return array(); |
|
| 925 | + } |
|
| 829 | 926 | $parsed_json = json_decode($json); |
| 830 | 927 | $airports = $parsed_json->{'suggestList'}; |
| 831 | 928 | if (count($airports) > 0) { |
@@ -840,7 +937,9 @@ discard block |
||
| 840 | 937 | } |
| 841 | 938 | if (isset($DepartureAirportIata)) { |
| 842 | 939 | return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_airberlin'); |
| 843 | - } else return array(); |
|
| 940 | + } else { |
|
| 941 | + return array(); |
|
| 942 | + } |
|
| 844 | 943 | } |
| 845 | 944 | |
| 846 | 945 | |
@@ -848,7 +947,9 @@ discard block |
||
| 848 | 947 | public function fetchSchedule($ident,$date = 'NOW') { |
| 849 | 948 | global $globalSchedulesSources, $globalSchedulesFetch; |
| 850 | 949 | //$Common = new Common(); |
| 851 | - if (!$globalSchedulesFetch) return array(); |
|
| 950 | + if (!$globalSchedulesFetch) { |
|
| 951 | + return array(); |
|
| 952 | + } |
|
| 852 | 953 | $airline_icao = ''; |
| 853 | 954 | if (!is_numeric(substr($ident, 0, 3))) |
| 854 | 955 | { |
@@ -1076,14 +1177,21 @@ discard block |
||
| 1076 | 1177 | default: |
| 1077 | 1178 | // Randomly use a generic function to get hours |
| 1078 | 1179 | if (strlen($airline_icao) == 2) { |
| 1079 | - if (!isset($globalSchedulesSources)) $globalSchedulesSources = array('flightmapper','costtotravel','flightradar24','flightaware'); |
|
| 1180 | + if (!isset($globalSchedulesSources)) { |
|
| 1181 | + $globalSchedulesSources = array('flightmapper','costtotravel','flightradar24','flightaware'); |
|
| 1182 | + } |
|
| 1080 | 1183 | if (count($globalSchedulesSources) > 0) { |
| 1081 | 1184 | $rand = mt_rand(0,count($globalSchedulesSources)-1); |
| 1082 | 1185 | $source = $globalSchedulesSources[$rand]; |
| 1083 | - if ($source == 'flightmapper') return $this->getFlightMapper($ident); |
|
| 1084 | - elseif ($source == 'costtotravel') return $this->getCostToTravel($ident); |
|
| 1186 | + if ($source == 'flightmapper') { |
|
| 1187 | + return $this->getFlightMapper($ident); |
|
| 1188 | + } elseif ($source == 'costtotravel') { |
|
| 1189 | + return $this->getCostToTravel($ident); |
|
| 1190 | + } |
|
| 1085 | 1191 | //elseif ($source == 'flightradar24') return $this->getFlightRadar24($ident,$date); |
| 1086 | - elseif ($source == 'flightaware') return $this->getFlightAware($ident); |
|
| 1192 | + elseif ($source == 'flightaware') { |
|
| 1193 | + return $this->getFlightAware($ident); |
|
| 1194 | + } |
|
| 1087 | 1195 | } |
| 1088 | 1196 | } |
| 1089 | 1197 | } |
@@ -1015,8 +1015,11 @@ discard block |
||
| 1015 | 1015 | $data = file_get_contents($filename); |
| 1016 | 1016 | preg_match_all("/%%(.+?)%%/is", $data, $matches); |
| 1017 | 1017 | //print_r($matches); |
| 1018 | - if (isset($matches[1])) return $matches[1]; |
|
| 1019 | - else return array(); |
|
| 1018 | + if (isset($matches[1])) { |
|
| 1019 | + return $matches[1]; |
|
| 1020 | + } else { |
|
| 1021 | + return array(); |
|
| 1022 | + } |
|
| 1020 | 1023 | } |
| 1021 | 1024 | public function getAllNOTAMbyScope($scope) { |
| 1022 | 1025 | global $globalDBdriver; |
@@ -1053,7 +1056,9 @@ discard block |
||
| 1053 | 1056 | $minlong = $maxlong; |
| 1054 | 1057 | $maxlong = $tmplong; |
| 1055 | 1058 | } |
| 1056 | - } else return array(); |
|
| 1059 | + } else { |
|
| 1060 | + return array(); |
|
| 1061 | + } |
|
| 1057 | 1062 | if ($globalDBdriver == 'mysql') { |
| 1058 | 1063 | $query = 'SELECT * FROM notam WHERE center_latitude BETWEEN '.$minlat.' AND '.$maxlat.' AND center_longitude BETWEEN '.$minlong.' AND '.$maxlong.' AND radius > 0 AND date_end > UTC_TIMESTAMP() AND date_begin < UTC_TIMESTAMP()'; |
| 1059 | 1064 | } else { |
@@ -1077,7 +1082,9 @@ discard block |
||
| 1077 | 1082 | $minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
| 1078 | 1083 | $maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
| 1079 | 1084 | $maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
| 1080 | - } else return array(); |
|
| 1085 | + } else { |
|
| 1086 | + return array(); |
|
| 1087 | + } |
|
| 1081 | 1088 | if ($globalDBdriver == 'mysql') { |
| 1082 | 1089 | $query = 'SELECT * FROM notam WHERE center_latitude BETWEEN '.$minlat.' AND '.$maxlat.' AND center_longitude BETWEEN '.$minlong.' AND '.$maxlong.' AND radius > 0 AND date_end > UTC_TIMESTAMP() AND date_begin < UTC_TIMESTAMP() AND scope = :scope'; |
| 1083 | 1090 | } else { |
@@ -1104,8 +1111,11 @@ discard block |
||
| 1104 | 1111 | return "error : ".$e->getMessage(); |
| 1105 | 1112 | } |
| 1106 | 1113 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 1107 | - if (isset($all[0])) return $all[0]; |
|
| 1108 | - else return array(); |
|
| 1114 | + if (isset($all[0])) { |
|
| 1115 | + return $all[0]; |
|
| 1116 | + } else { |
|
| 1117 | + return array(); |
|
| 1118 | + } |
|
| 1109 | 1119 | } |
| 1110 | 1120 | |
| 1111 | 1121 | public function addNOTAM($ref,$title,$type,$fir,$code,$rules,$scope,$lower_limit,$upper_limit,$center_latitude,$center_longitude,$radius,$date_begin,$date_end,$permanent,$text,$full_notam) { |
@@ -1183,7 +1193,9 @@ discard block |
||
| 1183 | 1193 | foreach ($alldata as $initial_data) { |
| 1184 | 1194 | $data = $this->parse($initial_data); |
| 1185 | 1195 | $notamref = $this->getNOTAMbyRef($data['ref']); |
| 1186 | - if (count($notamref) == 0) $this->addNOTAM($data['ref'],$data['title'],'',$data['fir'],$data['code'],'',$data['scope'],$data['lower_limit'],$data['upper_limit'],$data['latitude'],$data['longitude'],$data['radius'],$data['date_begin'],$data['date_end'],$data['permanent'],$data['text'],$data['full_notam']); |
|
| 1196 | + if (count($notamref) == 0) { |
|
| 1197 | + $this->addNOTAM($data['ref'],$data['title'],'',$data['fir'],$data['code'],'',$data['scope'],$data['lower_limit'],$data['upper_limit'],$data['latitude'],$data['longitude'],$data['radius'],$data['date_begin'],$data['date_end'],$data['permanent'],$data['text'],$data['full_notam']); |
|
| 1198 | + } |
|
| 1187 | 1199 | } |
| 1188 | 1200 | } |
| 1189 | 1201 | } |
@@ -1196,7 +1208,9 @@ discard block |
||
| 1196 | 1208 | foreach ($alldata as $initial_data) { |
| 1197 | 1209 | $data = $this->parse($initial_data); |
| 1198 | 1210 | $notamref = $this->getNOTAMbyRef($data['ref']); |
| 1199 | - if (!isset($notamref['notam_id'])) $this->addNOTAM($data['ref'],$data['title'],'',$data['fir'],$data['code'],'',$data['scope'],$data['lower_limit'],$data['upper_limit'],$data['latitude'],$data['longitude'],$data['radius'],$data['date_begin'],$data['date_end'],$data['permanent'],$data['text'],$data['full_notam']); |
|
| 1211 | + if (!isset($notamref['notam_id'])) { |
|
| 1212 | + $this->addNOTAM($data['ref'],$data['title'],'',$data['fir'],$data['code'],'',$data['scope'],$data['lower_limit'],$data['upper_limit'],$data['latitude'],$data['longitude'],$data['radius'],$data['date_begin'],$data['date_end'],$data['permanent'],$data['text'],$data['full_notam']); |
|
| 1213 | + } |
|
| 1200 | 1214 | } |
| 1201 | 1215 | } |
| 1202 | 1216 | } |
@@ -1208,11 +1222,15 @@ discard block |
||
| 1208 | 1222 | foreach (array_chunk($allairports,20) as $airport) { |
| 1209 | 1223 | $airports_icao = array(); |
| 1210 | 1224 | foreach($airport as $icao) { |
| 1211 | - if (isset($icao['icao'])) $airports_icao[] = $icao['icao']; |
|
| 1225 | + if (isset($icao['icao'])) { |
|
| 1226 | + $airports_icao[] = $icao['icao']; |
|
| 1227 | + } |
|
| 1212 | 1228 | } |
| 1213 | 1229 | $airport_icao = implode(',',$airports_icao); |
| 1214 | 1230 | $alldata = $this->downloadNOTAM($airport_icao); |
| 1215 | - if ($globalTransaction) $this->db->beginTransaction(); |
|
| 1231 | + if ($globalTransaction) { |
|
| 1232 | + $this->db->beginTransaction(); |
|
| 1233 | + } |
|
| 1216 | 1234 | if (count($alldata) > 0) { |
| 1217 | 1235 | foreach ($alldata as $initial_data) { |
| 1218 | 1236 | //print_r($initial_data); |
@@ -1221,14 +1239,23 @@ discard block |
||
| 1221 | 1239 | if (isset($data['ref'])) { |
| 1222 | 1240 | $notamref = $this->getNOTAMbyRef($data['ref']); |
| 1223 | 1241 | if (count($notamref) == 0) { |
| 1224 | - if (isset($data['ref_replaced'])) $this->deleteNOTAMbyRef($data['ref_replaced']); |
|
| 1225 | - if (isset($data['ref_cancelled'])) $this->deleteNOTAMbyRef($data['ref_cancelled']); |
|
| 1226 | - elseif (isset($data['latitude']) && isset($data['scope']) && isset($data['text']) && isset($data['permanent'])) echo $this->addNOTAM($data['ref'],'','',$data['fir'],$data['code'],'',$data['scope'],$data['lower_limit'],$data['upper_limit'],$data['latitude'],$data['longitude'],$data['radius'],$data['date_begin'],$data['date_end'],$data['permanent'],$data['text'],$data['full_notam']); |
|
| 1242 | + if (isset($data['ref_replaced'])) { |
|
| 1243 | + $this->deleteNOTAMbyRef($data['ref_replaced']); |
|
| 1244 | + } |
|
| 1245 | + if (isset($data['ref_cancelled'])) { |
|
| 1246 | + $this->deleteNOTAMbyRef($data['ref_cancelled']); |
|
| 1247 | + } elseif (isset($data['latitude']) && isset($data['scope']) && isset($data['text']) && isset($data['permanent'])) { |
|
| 1248 | + echo $this->addNOTAM($data['ref'],'','',$data['fir'],$data['code'],'',$data['scope'],$data['lower_limit'],$data['upper_limit'],$data['latitude'],$data['longitude'],$data['radius'],$data['date_begin'],$data['date_end'],$data['permanent'],$data['text'],$data['full_notam']); |
|
| 1249 | + } |
|
| 1227 | 1250 | } |
| 1228 | 1251 | } |
| 1229 | 1252 | } |
| 1230 | - } else echo 'Error on download. Nothing matches for '.$airport_icao."\n"; |
|
| 1231 | - if ($globalTransaction) $this->db->commit(); |
|
| 1253 | + } else { |
|
| 1254 | + echo 'Error on download. Nothing matches for '.$airport_icao."\n"; |
|
| 1255 | + } |
|
| 1256 | + if ($globalTransaction) { |
|
| 1257 | + $this->db->commit(); |
|
| 1258 | + } |
|
| 1232 | 1259 | sleep(5); |
| 1233 | 1260 | } |
| 1234 | 1261 | } |
@@ -1241,8 +1268,11 @@ discard block |
||
| 1241 | 1268 | $data = $Common->getData($url); |
| 1242 | 1269 | preg_match_all("/<pre>(.+?)<\/pre>/is", $data, $matches); |
| 1243 | 1270 | //print_r($matches); |
| 1244 | - if (isset($matches[1])) return $matches[1]; |
|
| 1245 | - else return array(); |
|
| 1271 | + if (isset($matches[1])) { |
|
| 1272 | + return $matches[1]; |
|
| 1273 | + } else { |
|
| 1274 | + return array(); |
|
| 1275 | + } |
|
| 1246 | 1276 | } |
| 1247 | 1277 | |
| 1248 | 1278 | public function parse($data) { |
@@ -1265,89 +1295,145 @@ discard block |
||
| 1265 | 1295 | $rules = str_split($matches[3]); |
| 1266 | 1296 | foreach ($rules as $rule) { |
| 1267 | 1297 | if ($rule == 'I') { |
| 1268 | - if (isset($result['rules'])) $result['rules'] = $result['rules'].'/IFR'; |
|
| 1269 | - else $result['rules'] = 'IFR'; |
|
| 1298 | + if (isset($result['rules'])) { |
|
| 1299 | + $result['rules'] = $result['rules'].'/IFR'; |
|
| 1300 | + } else { |
|
| 1301 | + $result['rules'] = 'IFR'; |
|
| 1302 | + } |
|
| 1270 | 1303 | } elseif ($rule == 'V') { |
| 1271 | - if (isset($result['rules'])) $result['rules'] = $result['rules'].'/VFR'; |
|
| 1272 | - else $result['rules'] = 'VFR'; |
|
| 1304 | + if (isset($result['rules'])) { |
|
| 1305 | + $result['rules'] = $result['rules'].'/VFR'; |
|
| 1306 | + } else { |
|
| 1307 | + $result['rules'] = 'VFR'; |
|
| 1308 | + } |
|
| 1273 | 1309 | } elseif ($rule == 'K') { |
| 1274 | - if (isset($result['rules'])) $result['rules'] = $result['rules'].'/Checklist'; |
|
| 1275 | - else $result['rules'] = 'Checklist'; |
|
| 1310 | + if (isset($result['rules'])) { |
|
| 1311 | + $result['rules'] = $result['rules'].'/Checklist'; |
|
| 1312 | + } else { |
|
| 1313 | + $result['rules'] = 'Checklist'; |
|
| 1314 | + } |
|
| 1276 | 1315 | } |
| 1277 | 1316 | } |
| 1278 | 1317 | $attentions = str_split($matches[4]); |
| 1279 | 1318 | foreach ($attentions as $attention) { |
| 1280 | 1319 | if ($attention == 'N') { |
| 1281 | - if (isset($result['attention'])) $result['attention'] = $result['attention'].' / Immediate attention'; |
|
| 1282 | - else $result['rules'] = 'Immediate attention'; |
|
| 1320 | + if (isset($result['attention'])) { |
|
| 1321 | + $result['attention'] = $result['attention'].' / Immediate attention'; |
|
| 1322 | + } else { |
|
| 1323 | + $result['rules'] = 'Immediate attention'; |
|
| 1324 | + } |
|
| 1283 | 1325 | } elseif ($attention == 'B') { |
| 1284 | - if (isset($result['attention'])) $result['attention'] = $result['attention'].' / Operational significance'; |
|
| 1285 | - else $result['rules'] = 'Operational significance'; |
|
| 1326 | + if (isset($result['attention'])) { |
|
| 1327 | + $result['attention'] = $result['attention'].' / Operational significance'; |
|
| 1328 | + } else { |
|
| 1329 | + $result['rules'] = 'Operational significance'; |
|
| 1330 | + } |
|
| 1286 | 1331 | } elseif ($attention == 'O') { |
| 1287 | - if (isset($result['attention'])) $result['attention'] = $result['attention'].' / Flight operations'; |
|
| 1288 | - else $result['rules'] = 'Flight operations'; |
|
| 1332 | + if (isset($result['attention'])) { |
|
| 1333 | + $result['attention'] = $result['attention'].' / Flight operations'; |
|
| 1334 | + } else { |
|
| 1335 | + $result['rules'] = 'Flight operations'; |
|
| 1336 | + } |
|
| 1289 | 1337 | } elseif ($attention == 'M') { |
| 1290 | - if (isset($result['attention'])) $result['attention'] = $result['attention'].' / Misc'; |
|
| 1291 | - else $result['rules'] = 'Misc'; |
|
| 1338 | + if (isset($result['attention'])) { |
|
| 1339 | + $result['attention'] = $result['attention'].' / Misc'; |
|
| 1340 | + } else { |
|
| 1341 | + $result['rules'] = 'Misc'; |
|
| 1342 | + } |
|
| 1292 | 1343 | } elseif ($attention == 'K') { |
| 1293 | - if (isset($result['attention'])) $result['attention'] = $result['attention'].' / Checklist'; |
|
| 1294 | - else $result['rules'] = 'Checklist'; |
|
| 1344 | + if (isset($result['attention'])) { |
|
| 1345 | + $result['attention'] = $result['attention'].' / Checklist'; |
|
| 1346 | + } else { |
|
| 1347 | + $result['rules'] = 'Checklist'; |
|
| 1348 | + } |
|
| 1295 | 1349 | } |
| 1296 | 1350 | } |
| 1297 | - if ($matches[5] == 'A') $result['scope'] = 'Airport warning'; |
|
| 1298 | - elseif ($matches[5] == 'E') $result['scope'] = 'Enroute warning'; |
|
| 1299 | - elseif ($matches[5] == 'W') $result['scope'] = 'Navigation warning'; |
|
| 1300 | - elseif ($matches[5] == 'K') $result['scope'] = 'Checklist'; |
|
| 1301 | - elseif ($matches[5] == 'AE') $result['scope'] = 'Airport/Enroute warning'; |
|
| 1302 | - elseif ($matches[5] == 'AW') $result['scope'] = 'Airport/Navigation warning'; |
|
| 1351 | + if ($matches[5] == 'A') { |
|
| 1352 | + $result['scope'] = 'Airport warning'; |
|
| 1353 | + } elseif ($matches[5] == 'E') { |
|
| 1354 | + $result['scope'] = 'Enroute warning'; |
|
| 1355 | + } elseif ($matches[5] == 'W') { |
|
| 1356 | + $result['scope'] = 'Navigation warning'; |
|
| 1357 | + } elseif ($matches[5] == 'K') { |
|
| 1358 | + $result['scope'] = 'Checklist'; |
|
| 1359 | + } elseif ($matches[5] == 'AE') { |
|
| 1360 | + $result['scope'] = 'Airport/Enroute warning'; |
|
| 1361 | + } elseif ($matches[5] == 'AW') { |
|
| 1362 | + $result['scope'] = 'Airport/Navigation warning'; |
|
| 1363 | + } |
|
| 1303 | 1364 | $result['lower_limit'] = $matches[6]; |
| 1304 | 1365 | $result['upper_limit'] = $matches[7]; |
| 1305 | 1366 | $latitude = $Common->convertDec($matches[8],'latitude'); |
| 1306 | - if ($matches[9] == 'S') $latitude = -$latitude; |
|
| 1367 | + if ($matches[9] == 'S') { |
|
| 1368 | + $latitude = -$latitude; |
|
| 1369 | + } |
|
| 1307 | 1370 | $longitude = $Common->convertDec($matches[10],'longitude'); |
| 1308 | - if ($matches[11] == 'W') $longitude = -$longitude; |
|
| 1371 | + if ($matches[11] == 'W') { |
|
| 1372 | + $longitude = -$longitude; |
|
| 1373 | + } |
|
| 1309 | 1374 | $result['latitude'] = $latitude; |
| 1310 | 1375 | $result['longitude'] = $longitude; |
| 1311 | 1376 | $result['radius'] = intval($matches[12]); |
| 1312 | - } else echo 'ERROR : '.$line."\n"; |
|
| 1313 | - } |
|
| 1314 | - elseif (preg_match('#A\) (.*)#',$line,$matches)) { |
|
| 1377 | + } else { |
|
| 1378 | + echo 'ERROR : '.$line."\n"; |
|
| 1379 | + } |
|
| 1380 | + } elseif (preg_match('#A\) (.*)#',$line,$matches)) { |
|
| 1315 | 1381 | $result['icao'] = $matches[1]; |
| 1316 | - } |
|
| 1317 | - elseif (preg_match('#B\) ([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})#',$line,$matches)) { |
|
| 1318 | - if ($matches[1] > 50) $year = '19'.$matches[1]; |
|
| 1319 | - else $year = '20'.$matches[1]; |
|
| 1382 | + } elseif (preg_match('#B\) ([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})#',$line,$matches)) { |
|
| 1383 | + if ($matches[1] > 50) { |
|
| 1384 | + $year = '19'.$matches[1]; |
|
| 1385 | + } else { |
|
| 1386 | + $year = '20'.$matches[1]; |
|
| 1387 | + } |
|
| 1320 | 1388 | $result['date_begin'] = $year.'/'.$matches[2].'/'.$matches[3].' '.$matches[4].':'.$matches[5]; |
| 1321 | - } |
|
| 1322 | - elseif (preg_match('#C\) ([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})$#',$line,$matches)) { |
|
| 1323 | - if ($matches[1] > 50) $year = '19'.$matches[1]; |
|
| 1324 | - else $year = '20'.$matches[1]; |
|
| 1389 | + } elseif (preg_match('#C\) ([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})$#',$line,$matches)) { |
|
| 1390 | + if ($matches[1] > 50) { |
|
| 1391 | + $year = '19'.$matches[1]; |
|
| 1392 | + } else { |
|
| 1393 | + $year = '20'.$matches[1]; |
|
| 1394 | + } |
|
| 1325 | 1395 | $result['date_end'] = $year.'/'.$matches[2].'/'.$matches[3].' '.$matches[4].':'.$matches[5]; |
| 1326 | 1396 | $result['permanent'] = 0; |
| 1327 | - } |
|
| 1328 | - elseif (preg_match('#C\) ([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2}) (EST|PERM)$#',$line,$matches)) { |
|
| 1329 | - if ($matches[1] > 50) $year = '19'.$matches[1]; |
|
| 1330 | - else $year = '20'.$matches[1]; |
|
| 1397 | + } elseif (preg_match('#C\) ([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2}) (EST|PERM)$#',$line,$matches)) { |
|
| 1398 | + if ($matches[1] > 50) { |
|
| 1399 | + $year = '19'.$matches[1]; |
|
| 1400 | + } else { |
|
| 1401 | + $year = '20'.$matches[1]; |
|
| 1402 | + } |
|
| 1331 | 1403 | $result['date_end'] = $year.'/'.$matches[2].'/'.$matches[3].' '.$matches[4].':'.$matches[5]; |
| 1332 | - if ($matches[6] == 'EST') $result['estimated'] = 1; |
|
| 1333 | - else $result['estimated'] = 0; |
|
| 1334 | - if ($matches[6] == 'PERM') $result['permanent'] = 1; |
|
| 1335 | - else $result['permanent'] = 0; |
|
| 1336 | - } |
|
| 1337 | - elseif (preg_match('#C\) (EST|PERM)$#',$line,$matches)) { |
|
| 1404 | + if ($matches[6] == 'EST') { |
|
| 1405 | + $result['estimated'] = 1; |
|
| 1406 | + } else { |
|
| 1407 | + $result['estimated'] = 0; |
|
| 1408 | + } |
|
| 1409 | + if ($matches[6] == 'PERM') { |
|
| 1410 | + $result['permanent'] = 1; |
|
| 1411 | + } else { |
|
| 1412 | + $result['permanent'] = 0; |
|
| 1413 | + } |
|
| 1414 | + } elseif (preg_match('#C\) (EST|PERM)$#',$line,$matches)) { |
|
| 1338 | 1415 | $result['date_end'] = '2030/12/20 12:00'; |
| 1339 | - if ($matches[1] == 'EST') $result['estimated'] = 1; |
|
| 1340 | - else $result['estimated'] = 0; |
|
| 1341 | - if ($matches[1] == 'PERM') $result['permanent'] = 1; |
|
| 1342 | - else $result['permanent'] = 0; |
|
| 1343 | - } |
|
| 1344 | - elseif (preg_match('#E\) (.*)#',$line,$matches)) { |
|
| 1416 | + if ($matches[1] == 'EST') { |
|
| 1417 | + $result['estimated'] = 1; |
|
| 1418 | + } else { |
|
| 1419 | + $result['estimated'] = 0; |
|
| 1420 | + } |
|
| 1421 | + if ($matches[1] == 'PERM') { |
|
| 1422 | + $result['permanent'] = 1; |
|
| 1423 | + } else { |
|
| 1424 | + $result['permanent'] = 0; |
|
| 1425 | + } |
|
| 1426 | + } elseif (preg_match('#E\) (.*)#',$line,$matches)) { |
|
| 1345 | 1427 | $rtext = array(); |
| 1346 | 1428 | $text = explode(' ',$matches[1]); |
| 1347 | 1429 | foreach ($text as $word) { |
| 1348 | - if (isset($this->abbr[$word])) $rtext[] = strtoupper($this->abbr[$word]); |
|
| 1349 | - elseif (ctype_digit(strval(substr($word,3))) && isset($this->abbr[substr($word,0,3)])) $rtext[] = strtoupper($this->abbr[substr($word,0,3)]).' '.substr($word,3); |
|
| 1350 | - else $rtext[] = $word; |
|
| 1430 | + if (isset($this->abbr[$word])) { |
|
| 1431 | + $rtext[] = strtoupper($this->abbr[$word]); |
|
| 1432 | + } elseif (ctype_digit(strval(substr($word,3))) && isset($this->abbr[substr($word,0,3)])) { |
|
| 1433 | + $rtext[] = strtoupper($this->abbr[substr($word,0,3)]).' '.substr($word,3); |
|
| 1434 | + } else { |
|
| 1435 | + $rtext[] = $word; |
|
| 1436 | + } |
|
| 1351 | 1437 | } |
| 1352 | 1438 | $result['text'] = implode(' ',$rtext); |
| 1353 | 1439 | //} elseif (preg_match('#F\) (.*)#',$line,$matches)) { |
@@ -1355,7 +1441,9 @@ discard block |
||
| 1355 | 1441 | } elseif (preg_match('#(NOTAMN|NOTAMR|NOTAMC)#',$line,$matches)) { |
| 1356 | 1442 | $text = explode(' ',$line); |
| 1357 | 1443 | $result['ref'] = $text[0]; |
| 1358 | - if ($matches[1] == 'NOTAMN') $result['type'] = 'new'; |
|
| 1444 | + if ($matches[1] == 'NOTAMN') { |
|
| 1445 | + $result['type'] = 'new'; |
|
| 1446 | + } |
|
| 1359 | 1447 | if ($matches[1] == 'NOTAMC') { |
| 1360 | 1448 | $result['type'] = 'cancel'; |
| 1361 | 1449 | $result['ref_cancelled'] = $text[2]; |
@@ -1377,69 +1465,101 @@ discard block |
||
| 1377 | 1465 | switch ($code[1]) { |
| 1378 | 1466 | case 'A': |
| 1379 | 1467 | $result = 'Airspace organization '; |
| 1380 | - if (isset($this->code_airspace[$code_fp])) $result .= $this->code_airspace[$code_fp]; |
|
| 1468 | + if (isset($this->code_airspace[$code_fp])) { |
|
| 1469 | + $result .= $this->code_airspace[$code_fp]; |
|
| 1470 | + } |
|
| 1381 | 1471 | break; |
| 1382 | 1472 | case 'C': |
| 1383 | 1473 | $result = 'Communications and radar facilities '; |
| 1384 | - if (isset($this->code_comradar[$code_fp])) $result .= $this->code_comradar[$code_fp]; |
|
| 1474 | + if (isset($this->code_comradar[$code_fp])) { |
|
| 1475 | + $result .= $this->code_comradar[$code_fp]; |
|
| 1476 | + } |
|
| 1385 | 1477 | break; |
| 1386 | 1478 | case 'F': |
| 1387 | 1479 | $result = 'Facilities and services '; |
| 1388 | - if (isset($this->code_facilities[$code_fp])) $result .= $this->code_facilities[$code_fp]; |
|
| 1480 | + if (isset($this->code_facilities[$code_fp])) { |
|
| 1481 | + $result .= $this->code_facilities[$code_fp]; |
|
| 1482 | + } |
|
| 1389 | 1483 | break; |
| 1390 | 1484 | case 'I': |
| 1391 | 1485 | $result = 'Instrument and Microwave Landing System '; |
| 1392 | - if (isset($this->code_instrumentlanding[$code_fp])) $result .= $this->code_instrumentlanding[$code_fp]; |
|
| 1486 | + if (isset($this->code_instrumentlanding[$code_fp])) { |
|
| 1487 | + $result .= $this->code_instrumentlanding[$code_fp]; |
|
| 1488 | + } |
|
| 1393 | 1489 | break; |
| 1394 | 1490 | case 'L': |
| 1395 | 1491 | $result = 'Lighting facilities '; |
| 1396 | - if (isset($this->code_lightingfacilities[$code_fp])) $result .= $this->code_lightingfacilities[$code_fp]; |
|
| 1492 | + if (isset($this->code_lightingfacilities[$code_fp])) { |
|
| 1493 | + $result .= $this->code_lightingfacilities[$code_fp]; |
|
| 1494 | + } |
|
| 1397 | 1495 | break; |
| 1398 | 1496 | case 'M': |
| 1399 | 1497 | $result = 'Movement and landing areas '; |
| 1400 | - if (isset($this->code_movementareas[$code_fp])) $result .= $this->code_movementareas[$code_fp]; |
|
| 1498 | + if (isset($this->code_movementareas[$code_fp])) { |
|
| 1499 | + $result .= $this->code_movementareas[$code_fp]; |
|
| 1500 | + } |
|
| 1401 | 1501 | break; |
| 1402 | 1502 | case 'N': |
| 1403 | 1503 | $result = 'Terminal and En Route Navigation Facilities '; |
| 1404 | - if (isset($this->code_terminalfacilities[$code_fp])) $result .= $this->code_terminalfacilities[$code_fp]; |
|
| 1504 | + if (isset($this->code_terminalfacilities[$code_fp])) { |
|
| 1505 | + $result .= $this->code_terminalfacilities[$code_fp]; |
|
| 1506 | + } |
|
| 1405 | 1507 | break; |
| 1406 | 1508 | case 'O': |
| 1407 | 1509 | $result = 'Other information '; |
| 1408 | - if (isset($this->code_information[$code_fp])) $result .= $this->code_information[$code_fp]; |
|
| 1510 | + if (isset($this->code_information[$code_fp])) { |
|
| 1511 | + $result .= $this->code_information[$code_fp]; |
|
| 1512 | + } |
|
| 1409 | 1513 | break; |
| 1410 | 1514 | case 'P': |
| 1411 | 1515 | $result = 'Air Traffic procedures '; |
| 1412 | - if (isset($this->code_airtraffic[$code_fp])) $result .= $this->code_airtraffic[$code_fp]; |
|
| 1516 | + if (isset($this->code_airtraffic[$code_fp])) { |
|
| 1517 | + $result .= $this->code_airtraffic[$code_fp]; |
|
| 1518 | + } |
|
| 1413 | 1519 | break; |
| 1414 | 1520 | case 'R': |
| 1415 | 1521 | $result = 'Navigation Warnings: Airspace Restrictions '; |
| 1416 | - if (isset($this->code_navigationw[$code_fp])) $result .= $this->code_navigationw[$code_fp]; |
|
| 1522 | + if (isset($this->code_navigationw[$code_fp])) { |
|
| 1523 | + $result .= $this->code_navigationw[$code_fp]; |
|
| 1524 | + } |
|
| 1417 | 1525 | break; |
| 1418 | 1526 | case 'S': |
| 1419 | 1527 | $result = 'Air Traffic and VOLMET Services '; |
| 1420 | - if (isset($this->code_volmet[$code_fp])) $result .= $this->code_volmet[$code_fp]; |
|
| 1528 | + if (isset($this->code_volmet[$code_fp])) { |
|
| 1529 | + $result .= $this->code_volmet[$code_fp]; |
|
| 1530 | + } |
|
| 1421 | 1531 | break; |
| 1422 | 1532 | case 'W': |
| 1423 | 1533 | $result = 'Navigation Warnings: Warnings '; |
| 1424 | - if (isset($this->code_warnings[$code_fp])) $result .= $this->code_warnings[$code_fp]; |
|
| 1534 | + if (isset($this->code_warnings[$code_fp])) { |
|
| 1535 | + $result .= $this->code_warnings[$code_fp]; |
|
| 1536 | + } |
|
| 1425 | 1537 | break; |
| 1426 | 1538 | } |
| 1427 | 1539 | switch ($code[3]) { |
| 1428 | 1540 | case 'A': |
| 1429 | 1541 | // Availability |
| 1430 | - if (isset($this->code_sp_availabity[$code_sp])) $result .= ' '.$this->code_sp_availabity[$code_sp]; |
|
| 1542 | + if (isset($this->code_sp_availabity[$code_sp])) { |
|
| 1543 | + $result .= ' '.$this->code_sp_availabity[$code_sp]; |
|
| 1544 | + } |
|
| 1431 | 1545 | break; |
| 1432 | 1546 | case 'C': |
| 1433 | 1547 | // Changes |
| 1434 | - if (isset($this->code_sp_changes[$code_sp])) $result .= ' '.$this->code_sp_changes[$code_sp]; |
|
| 1548 | + if (isset($this->code_sp_changes[$code_sp])) { |
|
| 1549 | + $result .= ' '.$this->code_sp_changes[$code_sp]; |
|
| 1550 | + } |
|
| 1435 | 1551 | break; |
| 1436 | 1552 | case 'H': |
| 1437 | 1553 | // Hazardous conditions |
| 1438 | - if (isset($this->code_sp_hazardous[$code_sp])) $result .= ' '.$this->code_sp_hazardous[$code_sp]; |
|
| 1554 | + if (isset($this->code_sp_hazardous[$code_sp])) { |
|
| 1555 | + $result .= ' '.$this->code_sp_hazardous[$code_sp]; |
|
| 1556 | + } |
|
| 1439 | 1557 | break; |
| 1440 | 1558 | case 'L': |
| 1441 | 1559 | // Limitations |
| 1442 | - if (isset($this->code_sp_limitations[$code_sp])) $result .= ' '.$this->code_sp_limitations[$code_sp]; |
|
| 1560 | + if (isset($this->code_sp_limitations[$code_sp])) { |
|
| 1561 | + $result .= ' '.$this->code_sp_limitations[$code_sp]; |
|
| 1562 | + } |
|
| 1443 | 1563 | break; |
| 1444 | 1564 | case 'X': |
| 1445 | 1565 | // Other Information |
@@ -159,8 +159,9 @@ discard block |
||
| 159 | 159 | if ($show_attr && count($this->attr)>0) |
| 160 | 160 | { |
| 161 | 161 | echo '('; |
| 162 | - foreach ($this->attr as $k=>$v) |
|
| 163 | - echo "[$k]=>\"".$this->$k.'", '; |
|
| 162 | + foreach ($this->attr as $k=>$v) { |
|
| 163 | + echo "[$k]=>\"".$this->$k.'", '; |
|
| 164 | + } |
|
| 164 | 165 | echo ')'; |
| 165 | 166 | } |
| 166 | 167 | echo "\n"; |
@@ -218,8 +219,7 @@ discard block |
||
| 218 | 219 | if (isset($node->_[HDOM_INFO_INNER])) |
| 219 | 220 | { |
| 220 | 221 | $string .= $node->_[HDOM_INFO_INNER] . "'"; |
| 221 | - } |
|
| 222 | - else |
|
| 222 | + } else |
|
| 223 | 223 | { |
| 224 | 224 | $string .= ' NULL '; |
| 225 | 225 | } |
@@ -233,8 +233,7 @@ discard block |
||
| 233 | 233 | { |
| 234 | 234 | echo $string; |
| 235 | 235 | return; |
| 236 | - } |
|
| 237 | - else |
|
| 236 | + } else |
|
| 238 | 237 | { |
| 239 | 238 | return $string; |
| 240 | 239 | } |
@@ -320,12 +319,17 @@ discard block |
||
| 320 | 319 | // returns the previous sibling of node |
| 321 | 320 | function prev_sibling() |
| 322 | 321 | { |
| 323 | - if ($this->parent===null) return null; |
|
| 322 | + if ($this->parent===null) { |
|
| 323 | + return null; |
|
| 324 | + } |
|
| 324 | 325 | $idx = 0; |
| 325 | 326 | $count = count($this->parent->children); |
| 326 | - while ($idx<$count && $this!==$this->parent->children[$idx]) |
|
| 327 | - ++$idx; |
|
| 328 | - if (--$idx<0) return null; |
|
| 327 | + while ($idx<$count && $this!==$this->parent->children[$idx]) { |
|
| 328 | + ++$idx; |
|
| 329 | + } |
|
| 330 | + if (--$idx<0) { |
|
| 331 | + return null; |
|
| 332 | + } |
|
| 329 | 333 | return $this->parent->children[$idx]; |
| 330 | 334 | } |
| 331 | 335 | |
@@ -354,12 +358,17 @@ discard block |
||
| 354 | 358 | // get dom node's inner html |
| 355 | 359 | function innertext() |
| 356 | 360 | { |
| 357 | - if (isset($this->_[HDOM_INFO_INNER])) return $this->_[HDOM_INFO_INNER]; |
|
| 358 | - if (isset($this->_[HDOM_INFO_TEXT])) return $this->dom->restore_noise($this->_[HDOM_INFO_TEXT]); |
|
| 361 | + if (isset($this->_[HDOM_INFO_INNER])) { |
|
| 362 | + return $this->_[HDOM_INFO_INNER]; |
|
| 363 | + } |
|
| 364 | + if (isset($this->_[HDOM_INFO_TEXT])) { |
|
| 365 | + return $this->dom->restore_noise($this->_[HDOM_INFO_TEXT]); |
|
| 366 | + } |
|
| 359 | 367 | |
| 360 | 368 | $ret = ''; |
| 361 | - foreach ($this->nodes as $n) |
|
| 362 | - $ret .= $n->outertext(); |
|
| 369 | + foreach ($this->nodes as $n) { |
|
| 370 | + $ret .= $n->outertext(); |
|
| 371 | + } |
|
| 363 | 372 | return $ret; |
| 364 | 373 | } |
| 365 | 374 | |
@@ -380,7 +389,9 @@ discard block |
||
| 380 | 389 | $debug_object->debug_log(1, 'Innertext of tag: ' . $this->tag . $text); |
| 381 | 390 | } |
| 382 | 391 | |
| 383 | - if ($this->tag==='root') return $this->innertext(); |
|
| 392 | + if ($this->tag==='root') { |
|
| 393 | + return $this->innertext(); |
|
| 394 | + } |
|
| 384 | 395 | |
| 385 | 396 | // trigger callback |
| 386 | 397 | if ($this->dom && $this->dom->callback!==null) |
@@ -388,8 +399,12 @@ discard block |
||
| 388 | 399 | call_user_func_array($this->dom->callback, array($this)); |
| 389 | 400 | } |
| 390 | 401 | |
| 391 | - if (isset($this->_[HDOM_INFO_OUTER])) return $this->_[HDOM_INFO_OUTER]; |
|
| 392 | - if (isset($this->_[HDOM_INFO_TEXT])) return $this->dom->restore_noise($this->_[HDOM_INFO_TEXT]); |
|
| 402 | + if (isset($this->_[HDOM_INFO_OUTER])) { |
|
| 403 | + return $this->_[HDOM_INFO_OUTER]; |
|
| 404 | + } |
|
| 405 | + if (isset($this->_[HDOM_INFO_TEXT])) { |
|
| 406 | + return $this->dom->restore_noise($this->_[HDOM_INFO_TEXT]); |
|
| 407 | + } |
|
| 393 | 408 | |
| 394 | 409 | // render begin tag |
| 395 | 410 | if ($this->dom && $this->dom->nodes[$this->_[HDOM_INFO_BEGIN]]) |
@@ -418,23 +433,30 @@ discard block |
||
| 418 | 433 | } |
| 419 | 434 | |
| 420 | 435 | // render end tag |
| 421 | - if (isset($this->_[HDOM_INFO_END]) && $this->_[HDOM_INFO_END]!=0) |
|
| 422 | - $ret .= '</'.$this->tag.'>'; |
|
| 436 | + if (isset($this->_[HDOM_INFO_END]) && $this->_[HDOM_INFO_END]!=0) { |
|
| 437 | + $ret .= '</'.$this->tag.'>'; |
|
| 438 | + } |
|
| 423 | 439 | return $ret; |
| 424 | 440 | } |
| 425 | 441 | |
| 426 | 442 | // get dom node's plain text |
| 427 | 443 | function text() |
| 428 | 444 | { |
| 429 | - if (isset($this->_[HDOM_INFO_INNER])) return $this->_[HDOM_INFO_INNER]; |
|
| 445 | + if (isset($this->_[HDOM_INFO_INNER])) { |
|
| 446 | + return $this->_[HDOM_INFO_INNER]; |
|
| 447 | + } |
|
| 430 | 448 | switch ($this->nodetype) |
| 431 | 449 | { |
| 432 | 450 | case HDOM_TYPE_TEXT: return $this->dom->restore_noise($this->_[HDOM_INFO_TEXT]); |
| 433 | 451 | case HDOM_TYPE_COMMENT: return ''; |
| 434 | 452 | case HDOM_TYPE_UNKNOWN: return ''; |
| 435 | 453 | } |
| 436 | - if (strcasecmp($this->tag, 'script')===0) return ''; |
|
| 437 | - if (strcasecmp($this->tag, 'style')===0) return ''; |
|
| 454 | + if (strcasecmp($this->tag, 'script')===0) { |
|
| 455 | + return ''; |
|
| 456 | + } |
|
| 457 | + if (strcasecmp($this->tag, 'style')===0) { |
|
| 458 | + return ''; |
|
| 459 | + } |
|
| 438 | 460 | |
| 439 | 461 | $ret = ''; |
| 440 | 462 | // In rare cases, (always node type 1 or HDOM_TYPE_ELEMENT - observed for some span tags, and some p tags) $this->nodes is set to NULL. |
@@ -470,7 +492,9 @@ discard block |
||
| 470 | 492 | function makeup() |
| 471 | 493 | { |
| 472 | 494 | // text, comment, unknown |
| 473 | - if (isset($this->_[HDOM_INFO_TEXT])) return $this->dom->restore_noise($this->_[HDOM_INFO_TEXT]); |
|
| 495 | + if (isset($this->_[HDOM_INFO_TEXT])) { |
|
| 496 | + return $this->dom->restore_noise($this->_[HDOM_INFO_TEXT]); |
|
| 497 | + } |
|
| 474 | 498 | |
| 475 | 499 | $ret = '<'.$this->tag; |
| 476 | 500 | $i = -1; |
@@ -480,14 +504,15 @@ discard block |
||
| 480 | 504 | ++$i; |
| 481 | 505 | |
| 482 | 506 | // skip removed attribute |
| 483 | - if ($val===null || $val===false) |
|
| 484 | - continue; |
|
| 507 | + if ($val===null || $val===false) { |
|
| 508 | + continue; |
|
| 509 | + } |
|
| 485 | 510 | |
| 486 | 511 | $ret .= $this->_[HDOM_INFO_SPACE][$i][0]; |
| 487 | 512 | //no value attr: nowrap, checked selected... |
| 488 | - if ($val===true) |
|
| 489 | - $ret .= $key; |
|
| 490 | - else { |
|
| 513 | + if ($val===true) { |
|
| 514 | + $ret .= $key; |
|
| 515 | + } else { |
|
| 491 | 516 | switch ($this->_[HDOM_INFO_QUOTE][$i]) |
| 492 | 517 | { |
| 493 | 518 | case HDOM_QUOTE_DOUBLE: $quote = '"'; break; |
@@ -506,7 +531,9 @@ discard block |
||
| 506 | 531 | function find($selector, $idx=null, $lowercase=false) |
| 507 | 532 | { |
| 508 | 533 | $selectors = $this->parse_selector($selector); |
| 509 | - if (($count=count($selectors))===0) return array(); |
|
| 534 | + if (($count=count($selectors))===0) { |
|
| 535 | + return array(); |
|
| 536 | + } |
|
| 510 | 537 | $found_keys = array(); |
| 511 | 538 | |
| 512 | 539 | // find each selector |
@@ -514,8 +541,12 @@ discard block |
||
| 514 | 541 | { |
| 515 | 542 | // The change on the below line was documented on the sourceforge code tracker id 2788009 |
| 516 | 543 | // used to be: if (($levle=count($selectors[0]))===0) return array(); |
| 517 | - if (($levle=count($selectors[$c]))===0) return array(); |
|
| 518 | - if (!isset($this->_[HDOM_INFO_BEGIN])) return array(); |
|
| 544 | + if (($levle=count($selectors[$c]))===0) { |
|
| 545 | + return array(); |
|
| 546 | + } |
|
| 547 | + if (!isset($this->_[HDOM_INFO_BEGIN])) { |
|
| 548 | + return array(); |
|
| 549 | + } |
|
| 519 | 550 | |
| 520 | 551 | $head = array($this->_[HDOM_INFO_BEGIN]=>1); |
| 521 | 552 | |
@@ -545,12 +576,16 @@ discard block |
||
| 545 | 576 | ksort($found_keys); |
| 546 | 577 | |
| 547 | 578 | $found = array(); |
| 548 | - foreach ($found_keys as $k=>$v) |
|
| 549 | - $found[] = $this->dom->nodes[$k]; |
|
| 579 | + foreach ($found_keys as $k=>$v) { |
|
| 580 | + $found[] = $this->dom->nodes[$k]; |
|
| 581 | + } |
|
| 550 | 582 | |
| 551 | 583 | // return nth-element or array |
| 552 | - if (is_null($idx)) return $found; |
|
| 553 | - else if ($idx<0) $idx = count($found) + $idx; |
|
| 584 | + if (is_null($idx)) { |
|
| 585 | + return $found; |
|
| 586 | + } else if ($idx<0) { |
|
| 587 | + $idx = count($found) + $idx; |
|
| 588 | + } |
|
| 554 | 589 | return (isset($found[$idx])) ? $found[$idx] : null; |
| 555 | 590 | } |
| 556 | 591 | |
@@ -595,8 +630,9 @@ discard block |
||
| 595 | 630 | $pass = true; |
| 596 | 631 | |
| 597 | 632 | if ($tag==='*' && !$key) { |
| 598 | - if (in_array($node, $this->children, true)) |
|
| 599 | - $ret[$i] = 1; |
|
| 633 | + if (in_array($node, $this->children, true)) { |
|
| 634 | + $ret[$i] = 1; |
|
| 635 | + } |
|
| 600 | 636 | continue; |
| 601 | 637 | } |
| 602 | 638 | |
@@ -605,9 +641,13 @@ discard block |
||
| 605 | 641 | // compare key |
| 606 | 642 | if ($pass && $key) { |
| 607 | 643 | if ($no_key) { |
| 608 | - if (isset($node->attr[$key])) $pass=false; |
|
| 644 | + if (isset($node->attr[$key])) { |
|
| 645 | + $pass=false; |
|
| 646 | + } |
|
| 609 | 647 | } else { |
| 610 | - if (($key != "plaintext") && !isset($node->attr[$key])) $pass=false; |
|
| 648 | + if (($key != "plaintext") && !isset($node->attr[$key])) { |
|
| 649 | + $pass=false; |
|
| 650 | + } |
|
| 611 | 651 | } |
| 612 | 652 | } |
| 613 | 653 | // compare value |
@@ -640,13 +680,19 @@ discard block |
||
| 640 | 680 | } else { |
| 641 | 681 | $check = $this->match($exp, $val, $k); |
| 642 | 682 | } |
| 643 | - if ($check) break; |
|
| 683 | + if ($check) { |
|
| 684 | + break; |
|
| 685 | + } |
|
| 644 | 686 | } |
| 645 | 687 | } |
| 646 | 688 | } |
| 647 | - if (!$check) $pass = false; |
|
| 689 | + if (!$check) { |
|
| 690 | + $pass = false; |
|
| 691 | + } |
|
| 692 | + } |
|
| 693 | + if ($pass) { |
|
| 694 | + $ret[$i] = 1; |
|
| 648 | 695 | } |
| 649 | - if ($pass) $ret[$i] = 1; |
|
| 650 | 696 | unset($node); |
| 651 | 697 | } |
| 652 | 698 | // It's passed by reference so this is actually what this function returns. |
@@ -696,9 +742,13 @@ discard block |
||
| 696 | 742 | |
| 697 | 743 | foreach ($matches as $m) { |
| 698 | 744 | $m[0] = trim($m[0]); |
| 699 | - if ($m[0]==='' || $m[0]==='/' || $m[0]==='//') continue; |
|
| 745 | + if ($m[0]==='' || $m[0]==='/' || $m[0]==='//') { |
|
| 746 | + continue; |
|
| 747 | + } |
|
| 700 | 748 | // for browser generated xpath |
| 701 | - if ($m[1]==='tbody') continue; |
|
| 749 | + if ($m[1]==='tbody') { |
|
| 750 | + continue; |
|
| 751 | + } |
|
| 702 | 752 | |
| 703 | 753 | list($tag, $key, $val, $exp, $no_key) = array($m[1], null, null, '=', false); |
| 704 | 754 | if (!empty($m[2])) {$key='id'; $val=$m[2];} |
@@ -718,8 +768,9 @@ discard block |
||
| 718 | 768 | $result = array(); |
| 719 | 769 | } |
| 720 | 770 | } |
| 721 | - if (count($result)>0) |
|
| 722 | - $selectors[] = $result; |
|
| 771 | + if (count($result)>0) { |
|
| 772 | + $selectors[] = $result; |
|
| 773 | + } |
|
| 723 | 774 | return $selectors; |
| 724 | 775 | } |
| 725 | 776 | |
@@ -748,7 +799,9 @@ discard block |
||
| 748 | 799 | { |
| 749 | 800 | case 'outertext': return $this->_[HDOM_INFO_OUTER] = $value; |
| 750 | 801 | case 'innertext': |
| 751 | - if (isset($this->_[HDOM_INFO_TEXT])) return $this->_[HDOM_INFO_TEXT] = $value; |
|
| 802 | + if (isset($this->_[HDOM_INFO_TEXT])) { |
|
| 803 | + return $this->_[HDOM_INFO_TEXT] = $value; |
|
| 804 | + } |
|
| 752 | 805 | return $this->_[HDOM_INFO_INNER] = $value; |
| 753 | 806 | } |
| 754 | 807 | if (!isset($this->attr[$name])) |
@@ -772,8 +825,9 @@ discard block |
||
| 772 | 825 | } |
| 773 | 826 | |
| 774 | 827 | function __unset($name) { |
| 775 | - if (isset($this->attr[$name])) |
|
| 776 | - unset($this->attr[$name]); |
|
| 828 | + if (isset($this->attr[$name])) { |
|
| 829 | + unset($this->attr[$name]); |
|
| 830 | + } |
|
| 777 | 831 | } |
| 778 | 832 | |
| 779 | 833 | // PaperG - Function to convert the text from one character set to another if the two sets are not the same. |
@@ -800,8 +854,7 @@ discard block |
||
| 800 | 854 | if ((strcasecmp($targetCharset, 'UTF-8') == 0) && ($this->is_utf8($text))) |
| 801 | 855 | { |
| 802 | 856 | $converted_text = $text; |
| 803 | - } |
|
| 804 | - else |
|
| 857 | + } else |
|
| 805 | 858 | { |
| 806 | 859 | $converted_text = iconv($sourceCharset, $targetCharset, $text); |
| 807 | 860 | } |
@@ -839,19 +892,31 @@ discard block |
||
| 839 | 892 | $c=ord($str[$i]); |
| 840 | 893 | if($c > 128) |
| 841 | 894 | { |
| 842 | - if(($c >= 254)) return false; |
|
| 843 | - elseif($c >= 252) $bits=6; |
|
| 844 | - elseif($c >= 248) $bits=5; |
|
| 845 | - elseif($c >= 240) $bits=4; |
|
| 846 | - elseif($c >= 224) $bits=3; |
|
| 847 | - elseif($c >= 192) $bits=2; |
|
| 848 | - else return false; |
|
| 849 | - if(($i+$bits) > $len) return false; |
|
| 895 | + if(($c >= 254)) { |
|
| 896 | + return false; |
|
| 897 | + } elseif($c >= 252) { |
|
| 898 | + $bits=6; |
|
| 899 | + } elseif($c >= 248) { |
|
| 900 | + $bits=5; |
|
| 901 | + } elseif($c >= 240) { |
|
| 902 | + $bits=4; |
|
| 903 | + } elseif($c >= 224) { |
|
| 904 | + $bits=3; |
|
| 905 | + } elseif($c >= 192) { |
|
| 906 | + $bits=2; |
|
| 907 | + } else { |
|
| 908 | + return false; |
|
| 909 | + } |
|
| 910 | + if(($i+$bits) > $len) { |
|
| 911 | + return false; |
|
| 912 | + } |
|
| 850 | 913 | while($bits > 1) |
| 851 | 914 | { |
| 852 | 915 | $i++; |
| 853 | 916 | $b=ord($str[$i]); |
| 854 | - if($b < 128 || $b > 191) return false; |
|
| 917 | + if($b < 128 || $b > 191) { |
|
| 918 | + return false; |
|
| 919 | + } |
|
| 855 | 920 | $bits--; |
| 856 | 921 | } |
| 857 | 922 | } |
@@ -1035,8 +1100,7 @@ discard block |
||
| 1035 | 1100 | if (preg_match("/^http:\/\//i",$str) || is_file($str)) |
| 1036 | 1101 | { |
| 1037 | 1102 | $this->load_file($str); |
| 1038 | - } |
|
| 1039 | - else |
|
| 1103 | + } else |
|
| 1040 | 1104 | { |
| 1041 | 1105 | $this->load($str, $lowercase, $stripRN, $defaultBRText, $defaultSpanText); |
| 1042 | 1106 | } |
@@ -1118,7 +1182,9 @@ discard block |
||
| 1118 | 1182 | function save($filepath='') |
| 1119 | 1183 | { |
| 1120 | 1184 | $ret = $this->root->innertext(); |
| 1121 | - if ($filepath!=='') file_put_contents($filepath, $ret, LOCK_EX); |
|
| 1185 | + if ($filepath!=='') { |
|
| 1186 | + file_put_contents($filepath, $ret, LOCK_EX); |
|
| 1187 | + } |
|
| 1122 | 1188 | return $ret; |
| 1123 | 1189 | } |
| 1124 | 1190 | |
@@ -1134,7 +1200,10 @@ discard block |
||
| 1134 | 1200 | { |
| 1135 | 1201 | foreach ($this->nodes as $n) {$n->clear(); $n = null;} |
| 1136 | 1202 | // This add next line is documented in the sourceforge repository. 2977248 as a fix for ongoing memory leaks that occur even with the use of clear. |
| 1137 | - if (isset($this->children)) foreach ($this->children as $n) {$n->clear(); $n = null;} |
|
| 1203 | + if (isset($this->children)) { |
|
| 1204 | + foreach ($this->children as $n) {$n->clear(); |
|
| 1205 | + } |
|
| 1206 | + $n = null;} |
|
| 1138 | 1207 | if (isset($this->parent)) {$this->parent->clear(); unset($this->parent);} |
| 1139 | 1208 | if (isset($this->root)) {$this->root->clear(); unset($this->root);} |
| 1140 | 1209 | unset($this->doc); |
@@ -1178,7 +1247,9 @@ discard block |
||
| 1178 | 1247 | $this->root->_[HDOM_INFO_BEGIN] = -1; |
| 1179 | 1248 | $this->root->nodetype = HDOM_TYPE_ROOT; |
| 1180 | 1249 | $this->parent = $this->root; |
| 1181 | - if ($this->size>0) $this->char = $this->doc[0]; |
|
| 1250 | + if ($this->size>0) { |
|
| 1251 | + $this->char = $this->doc[0]; |
|
| 1252 | + } |
|
| 1182 | 1253 | } |
| 1183 | 1254 | |
| 1184 | 1255 | // parse html content |
@@ -1232,8 +1303,7 @@ discard block |
||
| 1232 | 1303 | if ($success) |
| 1233 | 1304 | { |
| 1234 | 1305 | $charset = $matches[1]; |
| 1235 | - } |
|
| 1236 | - else |
|
| 1306 | + } else |
|
| 1237 | 1307 | { |
| 1238 | 1308 | // If there is a meta tag, and they don't specify the character set, research says that it's typically ISO-8859-1 |
| 1239 | 1309 | if (is_object($debug_object)) {$debug_object->debug_log(2, 'meta content-type tag couldn\'t be parsed. using iso-8859 default.');} |
@@ -1296,8 +1366,9 @@ discard block |
||
| 1296 | 1366 | $tag = $this->copy_until_char('>'); |
| 1297 | 1367 | |
| 1298 | 1368 | // skip attributes in end tag |
| 1299 | - if (($pos = strpos($tag, ' '))!==false) |
|
| 1300 | - $tag = substr($tag, 0, $pos); |
|
| 1369 | + if (($pos = strpos($tag, ' '))!==false) { |
|
| 1370 | + $tag = substr($tag, 0, $pos); |
|
| 1371 | + } |
|
| 1301 | 1372 | |
| 1302 | 1373 | $parent_lower = strtolower($this->parent->tag); |
| 1303 | 1374 | $tag_lower = strtolower($tag); |
@@ -1309,23 +1380,26 @@ discard block |
||
| 1309 | 1380 | $this->parent->_[HDOM_INFO_END] = 0; |
| 1310 | 1381 | $org_parent = $this->parent; |
| 1311 | 1382 | |
| 1312 | - while (($this->parent->parent) && strtolower($this->parent->tag)!==$tag_lower) |
|
| 1313 | - $this->parent = $this->parent->parent; |
|
| 1383 | + while (($this->parent->parent) && strtolower($this->parent->tag)!==$tag_lower) { |
|
| 1384 | + $this->parent = $this->parent->parent; |
|
| 1385 | + } |
|
| 1314 | 1386 | |
| 1315 | 1387 | if (strtolower($this->parent->tag)!==$tag_lower) { |
| 1316 | 1388 | $this->parent = $org_parent; // restore origonal parent |
| 1317 | - if ($this->parent->parent) $this->parent = $this->parent->parent; |
|
| 1389 | + if ($this->parent->parent) { |
|
| 1390 | + $this->parent = $this->parent->parent; |
|
| 1391 | + } |
|
| 1318 | 1392 | $this->parent->_[HDOM_INFO_END] = $this->cursor; |
| 1319 | 1393 | return $this->as_text_node($tag); |
| 1320 | 1394 | } |
| 1321 | - } |
|
| 1322 | - else if (($this->parent->parent) && isset($this->block_tags[$tag_lower])) |
|
| 1395 | + } else if (($this->parent->parent) && isset($this->block_tags[$tag_lower])) |
|
| 1323 | 1396 | { |
| 1324 | 1397 | $this->parent->_[HDOM_INFO_END] = 0; |
| 1325 | 1398 | $org_parent = $this->parent; |
| 1326 | 1399 | |
| 1327 | - while (($this->parent->parent) && strtolower($this->parent->tag)!==$tag_lower) |
|
| 1328 | - $this->parent = $this->parent->parent; |
|
| 1400 | + while (($this->parent->parent) && strtolower($this->parent->tag)!==$tag_lower) { |
|
| 1401 | + $this->parent = $this->parent->parent; |
|
| 1402 | + } |
|
| 1329 | 1403 | |
| 1330 | 1404 | if (strtolower($this->parent->tag)!==$tag_lower) |
| 1331 | 1405 | { |
@@ -1333,18 +1407,19 @@ discard block |
||
| 1333 | 1407 | $this->parent->_[HDOM_INFO_END] = $this->cursor; |
| 1334 | 1408 | return $this->as_text_node($tag); |
| 1335 | 1409 | } |
| 1336 | - } |
|
| 1337 | - else if (($this->parent->parent) && strtolower($this->parent->parent->tag)===$tag_lower) |
|
| 1410 | + } else if (($this->parent->parent) && strtolower($this->parent->parent->tag)===$tag_lower) |
|
| 1338 | 1411 | { |
| 1339 | 1412 | $this->parent->_[HDOM_INFO_END] = 0; |
| 1340 | 1413 | $this->parent = $this->parent->parent; |
| 1414 | + } else { |
|
| 1415 | + return $this->as_text_node($tag); |
|
| 1341 | 1416 | } |
| 1342 | - else |
|
| 1343 | - return $this->as_text_node($tag); |
|
| 1344 | 1417 | } |
| 1345 | 1418 | |
| 1346 | 1419 | $this->parent->_[HDOM_INFO_END] = $this->cursor; |
| 1347 | - if ($this->parent->parent) $this->parent = $this->parent->parent; |
|
| 1420 | + if ($this->parent->parent) { |
|
| 1421 | + $this->parent = $this->parent->parent; |
|
| 1422 | + } |
|
| 1348 | 1423 | |
| 1349 | 1424 | $this->char = (++$this->pos<$this->size) ? $this->doc[$this->pos] : null; // next |
| 1350 | 1425 | return true; |
@@ -1367,7 +1442,9 @@ discard block |
||
| 1367 | 1442 | $node->nodetype = HDOM_TYPE_UNKNOWN; |
| 1368 | 1443 | $node->tag = 'unknown'; |
| 1369 | 1444 | } |
| 1370 | - if ($this->char==='>') $node->_[HDOM_INFO_TEXT].='>'; |
|
| 1445 | + if ($this->char==='>') { |
|
| 1446 | + $node->_[HDOM_INFO_TEXT].='>'; |
|
| 1447 | + } |
|
| 1371 | 1448 | $this->link_nodes($node, true); |
| 1372 | 1449 | $this->char = (++$this->pos<$this->size) ? $this->doc[$this->pos] : null; // next |
| 1373 | 1450 | return true; |
@@ -1389,7 +1466,9 @@ discard block |
||
| 1389 | 1466 | return true; |
| 1390 | 1467 | } |
| 1391 | 1468 | |
| 1392 | - if ($this->char==='>') $node->_[HDOM_INFO_TEXT].='>'; |
|
| 1469 | + if ($this->char==='>') { |
|
| 1470 | + $node->_[HDOM_INFO_TEXT].='>'; |
|
| 1471 | + } |
|
| 1393 | 1472 | $this->link_nodes($node, false); |
| 1394 | 1473 | $this->char = (++$this->pos<$this->size) ? $this->doc[$this->pos] : null; // next |
| 1395 | 1474 | return true; |
@@ -1455,22 +1534,26 @@ discard block |
||
| 1455 | 1534 | if ($name!=='/' && $name!=='') { |
| 1456 | 1535 | $space[1] = $this->copy_skip($this->token_blank); |
| 1457 | 1536 | $name = $this->restore_noise($name); |
| 1458 | - if ($this->lowercase) $name = strtolower($name); |
|
| 1537 | + if ($this->lowercase) { |
|
| 1538 | + $name = strtolower($name); |
|
| 1539 | + } |
|
| 1459 | 1540 | if ($this->char==='=') { |
| 1460 | 1541 | $this->char = (++$this->pos<$this->size) ? $this->doc[$this->pos] : null; // next |
| 1461 | 1542 | $this->parse_attr($node, $name, $space); |
| 1462 | - } |
|
| 1463 | - else { |
|
| 1543 | + } else { |
|
| 1464 | 1544 | //no value attr: nowrap, checked selected... |
| 1465 | 1545 | $node->_[HDOM_INFO_QUOTE][] = HDOM_QUOTE_NO; |
| 1466 | 1546 | $node->attr[$name] = true; |
| 1467 | - if ($this->char!='>') $this->char = $this->doc[--$this->pos]; // prev |
|
| 1547 | + if ($this->char!='>') { |
|
| 1548 | + $this->char = $this->doc[--$this->pos]; |
|
| 1549 | + } |
|
| 1550 | + // prev |
|
| 1468 | 1551 | } |
| 1469 | 1552 | $node->_[HDOM_INFO_SPACE][] = $space; |
| 1470 | 1553 | $space = array($this->copy_skip($this->token_blank), '', ''); |
| 1554 | + } else { |
|
| 1555 | + break; |
|
| 1471 | 1556 | } |
| 1472 | - else |
|
| 1473 | - break; |
|
| 1474 | 1557 | } while ($this->char!=='>' && $this->char!=='/'); |
| 1475 | 1558 | |
| 1476 | 1559 | $this->link_nodes($node, true); |
@@ -1481,11 +1564,12 @@ discard block |
||
| 1481 | 1564 | { |
| 1482 | 1565 | $node->_[HDOM_INFO_ENDSPACE] .= '/'; |
| 1483 | 1566 | $node->_[HDOM_INFO_END] = 0; |
| 1484 | - } |
|
| 1485 | - else |
|
| 1567 | + } else |
|
| 1486 | 1568 | { |
| 1487 | 1569 | // reset parent |
| 1488 | - if (!isset($this->self_closing_tags[strtolower($node->tag)])) $this->parent = $node; |
|
| 1570 | + if (!isset($this->self_closing_tags[strtolower($node->tag)])) { |
|
| 1571 | + $this->parent = $node; |
|
| 1572 | + } |
|
| 1489 | 1573 | } |
| 1490 | 1574 | $this->char = (++$this->pos<$this->size) ? $this->doc[$this->pos] : null; // next |
| 1491 | 1575 | |
@@ -1571,7 +1655,9 @@ discard block |
||
| 1571 | 1655 | $len = strspn($this->doc, $chars, $pos); |
| 1572 | 1656 | $this->pos += $len; |
| 1573 | 1657 | $this->char = ($this->pos<$this->size) ? $this->doc[$this->pos] : null; // next |
| 1574 | - if ($len===0) return ''; |
|
| 1658 | + if ($len===0) { |
|
| 1659 | + return ''; |
|
| 1660 | + } |
|
| 1575 | 1661 | return substr($this->doc, $pos, $len); |
| 1576 | 1662 | } |
| 1577 | 1663 | |
@@ -1586,7 +1672,9 @@ discard block |
||
| 1586 | 1672 | |
| 1587 | 1673 | protected function copy_until_char($char) |
| 1588 | 1674 | { |
| 1589 | - if ($this->char===null) return ''; |
|
| 1675 | + if ($this->char===null) { |
|
| 1676 | + return ''; |
|
| 1677 | + } |
|
| 1590 | 1678 | |
| 1591 | 1679 | if (($pos = strpos($this->doc, $char, $this->pos))===false) { |
| 1592 | 1680 | $ret = substr($this->doc, $this->pos, $this->size-$this->pos); |
@@ -1595,7 +1683,9 @@ discard block |
||
| 1595 | 1683 | return $ret; |
| 1596 | 1684 | } |
| 1597 | 1685 | |
| 1598 | - if ($pos===$this->pos) return ''; |
|
| 1686 | + if ($pos===$this->pos) { |
|
| 1687 | + return ''; |
|
| 1688 | + } |
|
| 1599 | 1689 | $pos_old = $this->pos; |
| 1600 | 1690 | $this->char = $this->doc[$pos]; |
| 1601 | 1691 | $this->pos = $pos; |
@@ -1604,7 +1694,9 @@ discard block |
||
| 1604 | 1694 | |
| 1605 | 1695 | protected function copy_until_char_escape($char) |
| 1606 | 1696 | { |
| 1607 | - if ($this->char===null) return ''; |
|
| 1697 | + if ($this->char===null) { |
|
| 1698 | + return ''; |
|
| 1699 | + } |
|
| 1608 | 1700 | |
| 1609 | 1701 | $start = $this->pos; |
| 1610 | 1702 | while (1) |
@@ -1617,7 +1709,9 @@ discard block |
||
| 1617 | 1709 | return $ret; |
| 1618 | 1710 | } |
| 1619 | 1711 | |
| 1620 | - if ($pos===$this->pos) return ''; |
|
| 1712 | + if ($pos===$this->pos) { |
|
| 1713 | + return ''; |
|
| 1714 | + } |
|
| 1621 | 1715 | |
| 1622 | 1716 | if ($this->doc[$pos-1]==='\\') { |
| 1623 | 1717 | $start = $pos+1; |
@@ -1674,14 +1768,12 @@ discard block |
||
| 1674 | 1768 | if (isset($this->noise[$key])) |
| 1675 | 1769 | { |
| 1676 | 1770 | $text = substr($text, 0, $pos).$this->noise[$key].substr($text, $pos+16); |
| 1677 | - } |
|
| 1678 | - else |
|
| 1771 | + } else |
|
| 1679 | 1772 | { |
| 1680 | 1773 | // do this to prevent an infinite loop. |
| 1681 | 1774 | $text = substr($text, 0, $pos).'UNDEFINED NOISE FOR KEY: '.$key . substr($text, $pos+16); |
| 1682 | 1775 | } |
| 1683 | - } |
|
| 1684 | - else |
|
| 1776 | + } else |
|
| 1685 | 1777 | { |
| 1686 | 1778 | // There is no valid key being given back to us... We must get rid of the ___noise___ or we will have a problem. |
| 1687 | 1779 | $text = substr($text, 0, $pos).'NO NUMERIC NOISE KEY' . substr($text, $pos+11); |
@@ -7,9 +7,13 @@ discard block |
||
| 7 | 7 | //echo $buffer."\n"; |
| 8 | 8 | $data = array(); |
| 9 | 9 | $typehex = substr($buffer,0,1); |
| 10 | - if ($typehex == '*' || $typehex == ':') $hex = substr($buffer,1,-1); |
|
| 11 | - elseif ($typehex == '@' || $typehex == '%') $hex = substr($buffer,13,-13); |
|
| 12 | - else $hex = substr($buffer,1,-1); |
|
| 10 | + if ($typehex == '*' || $typehex == ':') { |
|
| 11 | + $hex = substr($buffer,1,-1); |
|
| 12 | + } elseif ($typehex == '@' || $typehex == '%') { |
|
| 13 | + $hex = substr($buffer,13,-13); |
|
| 14 | + } else { |
|
| 15 | + $hex = substr($buffer,1,-1); |
|
| 16 | + } |
|
| 13 | 17 | $bin = gmp_strval( gmp_init($hex,16), 2); |
| 14 | 18 | //if (strlen($hex) == 28 && $this->parityCheck($hex,$bin)) { |
| 15 | 19 | if (strlen($hex) == 28) { |
@@ -52,8 +56,9 @@ discard block |
||
| 52 | 56 | // 131072 is 2^17 since CPR latitude and longitude are encoded in 17 bits. |
| 53 | 57 | $cprlat = intval(substr($bin,54,17),2)/131072.0; |
| 54 | 58 | $cprlon = intval(substr($bin,71,17),2)/131072.0; |
| 55 | - if ($oe == 0) $this::$latlon[$icao] = array('latitude' => $cprlat,'longitude' => $cprlon,'created' => time()); |
|
| 56 | - elseif (isset($this::$latlon[$icao]) && (time() - $this::$latlon[$icao]['created']) < 10) { |
|
| 59 | + if ($oe == 0) { |
|
| 60 | + $this::$latlon[$icao] = array('latitude' => $cprlat,'longitude' => $cprlon,'created' => time()); |
|
| 61 | + } elseif (isset($this::$latlon[$icao]) && (time() - $this::$latlon[$icao]['created']) < 10) { |
|
| 57 | 62 | $cprlat_odd = $cprlat; |
| 58 | 63 | $cprlon_odd = $cprlon; |
| 59 | 64 | $cprlat_even = $this::$latlon[$icao]['latitude']; |
@@ -62,8 +67,12 @@ discard block |
||
| 62 | 67 | $j = 59*$cprlat_even-60*$cprlat_odd+0.5; |
| 63 | 68 | $lat_even = (360.0/60)*($j%60+$cprlat_even); |
| 64 | 69 | $lat_odd = (360.0/59)*($j%59+$cprlat_odd); |
| 65 | - if ($lat_even >= 270) $lat_even = $lat_even - 360; |
|
| 66 | - if ($lat_odd >= 270) $lat_odd = $lat_odd - 360; |
|
| 70 | + if ($lat_even >= 270) { |
|
| 71 | + $lat_even = $lat_even - 360; |
|
| 72 | + } |
|
| 73 | + if ($lat_odd >= 270) { |
|
| 74 | + $lat_odd = $lat_odd - 360; |
|
| 75 | + } |
|
| 67 | 76 | // check latitude zone |
| 68 | 77 | if ($this->cprNL($lat_even) == $this->cprNL($lat_odd)) { |
| 69 | 78 | if ($this::$latlon[$icao]['created'] > time()) { |
@@ -71,7 +80,9 @@ discard block |
||
| 71 | 80 | $m = floor($cprlon_even*($this->cprNL($lat_even)-1) - $cprlon_odd * $this->cprNL($lat_even)+0.5); |
| 72 | 81 | $lon = (360.0/$ni)*($m%$ni+$cprlon_even); |
| 73 | 82 | $lat = $lat_even; |
| 74 | - if ($lon > 180) $lon = $lon -360; |
|
| 83 | + if ($lon > 180) { |
|
| 84 | + $lon = $lon -360; |
|
| 85 | + } |
|
| 75 | 86 | if ($lat > -91 && $lat < 91 && $lon > -181 && $lon < 181) { |
| 76 | 87 | //if ($globalDebug) echo 'cs : '.$cs.' - hex : '.$hex.' - lat : '.$lat.' - lon : '.$lon; |
| 77 | 88 | $data['latitude'] = $lat; |
@@ -82,14 +93,18 @@ discard block |
||
| 82 | 93 | $m = floor($cprlon_even*($this->cprNL($lat_odd)-1) - $cprlon_odd * $this->cprNL($lat_odd)+0.5); |
| 83 | 94 | $lon = (360.0/$ni)*($m%$ni+$cprlon_odd); |
| 84 | 95 | $lat = $lat_odd; |
| 85 | - if ($lon > 180) $lon = $lon -360; |
|
| 96 | + if ($lon > 180) { |
|
| 97 | + $lon = $lon -360; |
|
| 98 | + } |
|
| 86 | 99 | if ($lat > -91 && $lat < 91 && $lon > -181 && $lon < 181) { |
| 87 | 100 | //if ($globalDebug) echo 'icao : '.$icao.' - hex : '.$hex.' - lat : '.$lat.' - lon : '.$lon.' second'."\n"; |
| 88 | 101 | $data['latitude'] = $lat; |
| 89 | 102 | $data['longitude'] = $lon; |
| 90 | 103 | } |
| 91 | 104 | } |
| 92 | - } else echo "Not cprNL"; |
|
| 105 | + } else { |
|
| 106 | + echo "Not cprNL"; |
|
| 107 | + } |
|
| 93 | 108 | unset($this::$latlon[$icao]); |
| 94 | 109 | } |
| 95 | 110 | } elseif ($tc == 19) { |
@@ -98,11 +113,17 @@ discard block |
||
| 98 | 113 | $v_ew = intval(substr($bin,46,10),2); |
| 99 | 114 | $v_ns_dir = intval(substr($bin,56,1)); |
| 100 | 115 | $v_ns = intval(substr($bin,57,10),2); |
| 101 | - if ($v_ew_dir) $v_ew = -1*$v_ew; |
|
| 102 | - if ($v_ns_dir) $v_ns = -1*$v_ns; |
|
| 116 | + if ($v_ew_dir) { |
|
| 117 | + $v_ew = -1*$v_ew; |
|
| 118 | + } |
|
| 119 | + if ($v_ns_dir) { |
|
| 120 | + $v_ns = -1*$v_ns; |
|
| 121 | + } |
|
| 103 | 122 | $speed = sqrt($v_ns*$v_ns+$v_ew*$v_ew); |
| 104 | 123 | $heading = atan2($v_ew,$v_ns)*360.0/(2*pi()); |
| 105 | - if ($heading <0) $heading = $heading+360; |
|
| 124 | + if ($heading <0) { |
|
| 125 | + $heading = $heading+360; |
|
| 126 | + } |
|
| 106 | 127 | $data['speed'] = $speed; |
| 107 | 128 | $data['heading'] = $heading; |
| 108 | 129 | } |
@@ -117,72 +138,194 @@ discard block |
||
| 117 | 138 | |
| 118 | 139 | public function cprNL($lat) { |
| 119 | 140 | //Lookup table to convert the latitude to index. |
| 120 | - if ($lat < 0) $lat = -$lat; // Table is simmetric about the equator. |
|
| 121 | - if ($lat < 10.47047130) return 59; |
|
| 122 | - if ($lat < 14.82817437) return 58; |
|
| 123 | - if ($lat < 18.18626357) return 57; |
|
| 124 | - if ($lat < 21.02939493) return 56; |
|
| 125 | - if ($lat < 23.54504487) return 55; |
|
| 126 | - if ($lat < 25.82924707) return 54; |
|
| 127 | - if ($lat < 27.93898710) return 53; |
|
| 128 | - if ($lat < 29.91135686) return 52; |
|
| 129 | - if ($lat < 31.77209708) return 51; |
|
| 130 | - if ($lat < 33.53993436) return 50; |
|
| 131 | - if ($lat < 35.22899598) return 49; |
|
| 132 | - if ($lat < 36.85025108) return 48; |
|
| 133 | - if ($lat < 38.41241892) return 47; |
|
| 134 | - if ($lat < 39.92256684) return 46; |
|
| 135 | - if ($lat < 41.38651832) return 45; |
|
| 136 | - if ($lat < 42.80914012) return 44; |
|
| 137 | - if ($lat < 44.19454951) return 43; |
|
| 138 | - if ($lat < 45.54626723) return 42; |
|
| 139 | - if ($lat < 46.86733252) return 41; |
|
| 140 | - if ($lat < 48.16039128) return 40; |
|
| 141 | - if ($lat < 49.42776439) return 39; |
|
| 142 | - if ($lat < 50.67150166) return 38; |
|
| 143 | - if ($lat < 51.89342469) return 37; |
|
| 144 | - if ($lat < 53.09516153) return 36; |
|
| 145 | - if ($lat < 54.27817472) return 35; |
|
| 146 | - if ($lat < 55.44378444) return 34; |
|
| 147 | - if ($lat < 56.59318756) return 33; |
|
| 148 | - if ($lat < 57.72747354) return 32; |
|
| 149 | - if ($lat < 58.84763776) return 31; |
|
| 150 | - if ($lat < 59.95459277) return 30; |
|
| 151 | - if ($lat < 61.04917774) return 29; |
|
| 152 | - if ($lat < 62.13216659) return 28; |
|
| 153 | - if ($lat < 63.20427479) return 27; |
|
| 154 | - if ($lat < 64.26616523) return 26; |
|
| 155 | - if ($lat < 65.31845310) return 25; |
|
| 156 | - if ($lat < 66.36171008) return 24; |
|
| 157 | - if ($lat < 67.39646774) return 23; |
|
| 158 | - if ($lat < 68.42322022) return 22; |
|
| 159 | - if ($lat < 69.44242631) return 21; |
|
| 160 | - if ($lat < 70.45451075) return 20; |
|
| 161 | - if ($lat < 71.45986473) return 19; |
|
| 162 | - if ($lat < 72.45884545) return 18; |
|
| 163 | - if ($lat < 73.45177442) return 17; |
|
| 164 | - if ($lat < 74.43893416) return 16; |
|
| 165 | - if ($lat < 75.42056257) return 15; |
|
| 166 | - if ($lat < 76.39684391) return 14; |
|
| 167 | - if ($lat < 77.36789461) return 13; |
|
| 168 | - if ($lat < 78.33374083) return 12; |
|
| 169 | - if ($lat < 79.29428225) return 11; |
|
| 170 | - if ($lat < 80.24923213) return 10; |
|
| 171 | - if ($lat < 81.19801349) return 9; |
|
| 172 | - if ($lat < 82.13956981) return 8; |
|
| 173 | - if ($lat < 83.07199445) return 7; |
|
| 174 | - if ($lat < 83.99173563) return 6; |
|
| 175 | - if ($lat < 84.89166191) return 5; |
|
| 176 | - if ($lat < 85.75541621) return 4; |
|
| 177 | - if ($lat < 86.53536998) return 3; |
|
| 178 | - if ($lat < 87.00000000) return 2; |
|
| 141 | + if ($lat < 0) { |
|
| 142 | + $lat = -$lat; |
|
| 143 | + } |
|
| 144 | + // Table is simmetric about the equator. |
|
| 145 | + if ($lat < 10.47047130) { |
|
| 146 | + return 59; |
|
| 147 | + } |
|
| 148 | + if ($lat < 14.82817437) { |
|
| 149 | + return 58; |
|
| 150 | + } |
|
| 151 | + if ($lat < 18.18626357) { |
|
| 152 | + return 57; |
|
| 153 | + } |
|
| 154 | + if ($lat < 21.02939493) { |
|
| 155 | + return 56; |
|
| 156 | + } |
|
| 157 | + if ($lat < 23.54504487) { |
|
| 158 | + return 55; |
|
| 159 | + } |
|
| 160 | + if ($lat < 25.82924707) { |
|
| 161 | + return 54; |
|
| 162 | + } |
|
| 163 | + if ($lat < 27.93898710) { |
|
| 164 | + return 53; |
|
| 165 | + } |
|
| 166 | + if ($lat < 29.91135686) { |
|
| 167 | + return 52; |
|
| 168 | + } |
|
| 169 | + if ($lat < 31.77209708) { |
|
| 170 | + return 51; |
|
| 171 | + } |
|
| 172 | + if ($lat < 33.53993436) { |
|
| 173 | + return 50; |
|
| 174 | + } |
|
| 175 | + if ($lat < 35.22899598) { |
|
| 176 | + return 49; |
|
| 177 | + } |
|
| 178 | + if ($lat < 36.85025108) { |
|
| 179 | + return 48; |
|
| 180 | + } |
|
| 181 | + if ($lat < 38.41241892) { |
|
| 182 | + return 47; |
|
| 183 | + } |
|
| 184 | + if ($lat < 39.92256684) { |
|
| 185 | + return 46; |
|
| 186 | + } |
|
| 187 | + if ($lat < 41.38651832) { |
|
| 188 | + return 45; |
|
| 189 | + } |
|
| 190 | + if ($lat < 42.80914012) { |
|
| 191 | + return 44; |
|
| 192 | + } |
|
| 193 | + if ($lat < 44.19454951) { |
|
| 194 | + return 43; |
|
| 195 | + } |
|
| 196 | + if ($lat < 45.54626723) { |
|
| 197 | + return 42; |
|
| 198 | + } |
|
| 199 | + if ($lat < 46.86733252) { |
|
| 200 | + return 41; |
|
| 201 | + } |
|
| 202 | + if ($lat < 48.16039128) { |
|
| 203 | + return 40; |
|
| 204 | + } |
|
| 205 | + if ($lat < 49.42776439) { |
|
| 206 | + return 39; |
|
| 207 | + } |
|
| 208 | + if ($lat < 50.67150166) { |
|
| 209 | + return 38; |
|
| 210 | + } |
|
| 211 | + if ($lat < 51.89342469) { |
|
| 212 | + return 37; |
|
| 213 | + } |
|
| 214 | + if ($lat < 53.09516153) { |
|
| 215 | + return 36; |
|
| 216 | + } |
|
| 217 | + if ($lat < 54.27817472) { |
|
| 218 | + return 35; |
|
| 219 | + } |
|
| 220 | + if ($lat < 55.44378444) { |
|
| 221 | + return 34; |
|
| 222 | + } |
|
| 223 | + if ($lat < 56.59318756) { |
|
| 224 | + return 33; |
|
| 225 | + } |
|
| 226 | + if ($lat < 57.72747354) { |
|
| 227 | + return 32; |
|
| 228 | + } |
|
| 229 | + if ($lat < 58.84763776) { |
|
| 230 | + return 31; |
|
| 231 | + } |
|
| 232 | + if ($lat < 59.95459277) { |
|
| 233 | + return 30; |
|
| 234 | + } |
|
| 235 | + if ($lat < 61.04917774) { |
|
| 236 | + return 29; |
|
| 237 | + } |
|
| 238 | + if ($lat < 62.13216659) { |
|
| 239 | + return 28; |
|
| 240 | + } |
|
| 241 | + if ($lat < 63.20427479) { |
|
| 242 | + return 27; |
|
| 243 | + } |
|
| 244 | + if ($lat < 64.26616523) { |
|
| 245 | + return 26; |
|
| 246 | + } |
|
| 247 | + if ($lat < 65.31845310) { |
|
| 248 | + return 25; |
|
| 249 | + } |
|
| 250 | + if ($lat < 66.36171008) { |
|
| 251 | + return 24; |
|
| 252 | + } |
|
| 253 | + if ($lat < 67.39646774) { |
|
| 254 | + return 23; |
|
| 255 | + } |
|
| 256 | + if ($lat < 68.42322022) { |
|
| 257 | + return 22; |
|
| 258 | + } |
|
| 259 | + if ($lat < 69.44242631) { |
|
| 260 | + return 21; |
|
| 261 | + } |
|
| 262 | + if ($lat < 70.45451075) { |
|
| 263 | + return 20; |
|
| 264 | + } |
|
| 265 | + if ($lat < 71.45986473) { |
|
| 266 | + return 19; |
|
| 267 | + } |
|
| 268 | + if ($lat < 72.45884545) { |
|
| 269 | + return 18; |
|
| 270 | + } |
|
| 271 | + if ($lat < 73.45177442) { |
|
| 272 | + return 17; |
|
| 273 | + } |
|
| 274 | + if ($lat < 74.43893416) { |
|
| 275 | + return 16; |
|
| 276 | + } |
|
| 277 | + if ($lat < 75.42056257) { |
|
| 278 | + return 15; |
|
| 279 | + } |
|
| 280 | + if ($lat < 76.39684391) { |
|
| 281 | + return 14; |
|
| 282 | + } |
|
| 283 | + if ($lat < 77.36789461) { |
|
| 284 | + return 13; |
|
| 285 | + } |
|
| 286 | + if ($lat < 78.33374083) { |
|
| 287 | + return 12; |
|
| 288 | + } |
|
| 289 | + if ($lat < 79.29428225) { |
|
| 290 | + return 11; |
|
| 291 | + } |
|
| 292 | + if ($lat < 80.24923213) { |
|
| 293 | + return 10; |
|
| 294 | + } |
|
| 295 | + if ($lat < 81.19801349) { |
|
| 296 | + return 9; |
|
| 297 | + } |
|
| 298 | + if ($lat < 82.13956981) { |
|
| 299 | + return 8; |
|
| 300 | + } |
|
| 301 | + if ($lat < 83.07199445) { |
|
| 302 | + return 7; |
|
| 303 | + } |
|
| 304 | + if ($lat < 83.99173563) { |
|
| 305 | + return 6; |
|
| 306 | + } |
|
| 307 | + if ($lat < 84.89166191) { |
|
| 308 | + return 5; |
|
| 309 | + } |
|
| 310 | + if ($lat < 85.75541621) { |
|
| 311 | + return 4; |
|
| 312 | + } |
|
| 313 | + if ($lat < 86.53536998) { |
|
| 314 | + return 3; |
|
| 315 | + } |
|
| 316 | + if ($lat < 87.00000000) { |
|
| 317 | + return 2; |
|
| 318 | + } |
|
| 179 | 319 | return 1; |
| 180 | 320 | } |
| 181 | 321 | |
| 182 | 322 | public function cprN($lat,$isodd) { |
| 183 | 323 | $nl = $this->cprNL($lat) - $isodd; |
| 184 | - if ($nl > 1) return $nl; |
|
| 185 | - else return 1; |
|
| 324 | + if ($nl > 1) { |
|
| 325 | + return $nl; |
|
| 326 | + } else { |
|
| 327 | + return 1; |
|
| 328 | + } |
|
| 186 | 329 | } |
| 187 | 330 | |
| 188 | 331 | |
@@ -208,10 +351,13 @@ discard block |
||
| 208 | 351 | $checksum = intval(substr($msg,22,6),16); |
| 209 | 352 | |
| 210 | 353 | for ($j = 0; $j < strlen($bin); $j++) { |
| 211 | - if ($bin[$j]) $crc = $crc^intval($modes_checksum_table[$j],0); |
|
| 354 | + if ($bin[$j]) { |
|
| 355 | + $crc = $crc^intval($modes_checksum_table[$j],0); |
|
| 356 | + } |
|
| 212 | 357 | } |
| 213 | - if ($crc == $checksum) return true; |
|
| 214 | - else { |
|
| 358 | + if ($crc == $checksum) { |
|
| 359 | + return true; |
|
| 360 | + } else { |
|
| 215 | 361 | //echo "**** CRC ERROR ****\n"; |
| 216 | 362 | return false; |
| 217 | 363 | } |
@@ -28,16 +28,25 @@ discard block |
||
| 28 | 28 | } elseif (is_numeric(substr(substr($ident, 0, 4), -1, 1))) { |
| 29 | 29 | //$airline_icao = substr($ident, 0, 3); |
| 30 | 30 | return $ident; |
| 31 | - } else return $ident; |
|
| 32 | - } else return $ident; |
|
| 31 | + } else { |
|
| 32 | + return $ident; |
|
| 33 | + } |
|
| 34 | + } else { |
|
| 35 | + return $ident; |
|
| 36 | + } |
|
| 33 | 37 | if ($airline_icao == 'AF') { |
| 34 | - if (filter_var(substr($ident,2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $ident; |
|
| 35 | - else $icao = 'AFR'.ltrim(substr($ident,2),'0'); |
|
| 38 | + if (filter_var(substr($ident,2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) { |
|
| 39 | + $icao = $ident; |
|
| 40 | + } else { |
|
| 41 | + $icao = 'AFR'.ltrim(substr($ident,2),'0'); |
|
| 42 | + } |
|
| 36 | 43 | } else { |
| 37 | 44 | $identicao = $Spotter->getAllAirlineInfo($airline_icao); |
| 38 | 45 | if (isset($identicao[0])) { |
| 39 | 46 | $icao = $identicao[0]['icao'].ltrim(substr($ident,2),'0'); |
| 40 | - } else $icao = $ident; |
|
| 47 | + } else { |
|
| 48 | + $icao = $ident; |
|
| 49 | + } |
|
| 41 | 50 | } |
| 42 | 51 | return $icao; |
| 43 | 52 | } |
@@ -56,7 +65,9 @@ discard block |
||
| 56 | 65 | $sth->closeCursor(); |
| 57 | 66 | if (count($row) > 0) { |
| 58 | 67 | return $row['operator_correct']; |
| 59 | - } else return $ident; |
|
| 68 | + } else { |
|
| 69 | + return $ident; |
|
| 70 | + } |
|
| 60 | 71 | } |
| 61 | 72 | |
| 62 | 73 | public function addOperator($ident,$correct_ident,$source) { |
@@ -85,7 +96,9 @@ discard block |
||
| 85 | 96 | global $globalTranslationSources, $globalTranslationFetch; |
| 86 | 97 | //if (!isset($globalTranslationSources)) $globalTranslationSources = array('planefinder'); |
| 87 | 98 | $globalTranslationSources = array(); |
| 88 | - if (!isset($globalTranslationFetch)) $globalTranslationFetch = TRUE; |
|
| 99 | + if (!isset($globalTranslationFetch)) { |
|
| 100 | + $globalTranslationFetch = TRUE; |
|
| 101 | + } |
|
| 89 | 102 | //echo "Check Translation for ".$ident."..."; |
| 90 | 103 | $correct = $this->getOperator($ident); |
| 91 | 104 | if ($correct != '' && $correct != $ident) { |
@@ -21,7 +21,9 @@ discard block |
||
| 21 | 21 | print '<option></option>'; |
| 22 | 22 | $Stats = new Stats(); |
| 23 | 23 | $airline_names = $Stats->getAllAirlineNames(); |
| 24 | - if (empty($airline_names)) $airline_names = $Spotter->getAllAirlineNames(); |
|
| 24 | + if (empty($airline_names)) { |
|
| 25 | + $airline_names = $Spotter->getAllAirlineNames(); |
|
| 26 | + } |
|
| 25 | 27 | foreach($airline_names as $airline_name) |
| 26 | 28 | { |
| 27 | 29 | if($airline == $airline_name['airline_icao']) |
@@ -43,8 +45,7 @@ discard block |
||
| 43 | 45 | if ($globalIVAO && @getimagesize($globalURL.'/images/airlines/'.$spotter_array[0]['airline_icao'].'.gif')) |
| 44 | 46 | { |
| 45 | 47 | print '<img src="'.$globalURL.'/images/airlines/'.$spotter_array[0]['airline_icao'].'.gif" alt="'.$spotter_array[0]['airline_name'].' ('.$spotter_array[0]['airline_icao'].')" title="'.$spotter_array[0]['airline_name'].' ('.$spotter_array[0]['airline_icao'].')" class="logo" />'; |
| 46 | - } |
|
| 47 | - elseif (@getimagesize($globalURL.'/images/airlines/'.$spotter_array[0]['airline_icao'].'.png')) |
|
| 48 | + } elseif (@getimagesize($globalURL.'/images/airlines/'.$spotter_array[0]['airline_icao'].'.png')) |
|
| 48 | 49 | { |
| 49 | 50 | print '<img src="'.$globalURL.'/images/airlines/'.$spotter_array[0]['airline_icao'].'.png" alt="'.$spotter_array[0]['airline_name'].' ('.$spotter_array[0]['airline_icao'].')" title="'.$spotter_array[0]['airline_name'].' ('.$spotter_array[0]['airline_icao'].')" class="logo" />'; |
| 50 | 51 | } |
@@ -14,7 +14,7 @@ |
||
| 14 | 14 | $limit_start = 0; |
| 15 | 15 | $limit_end = 25; |
| 16 | 16 | $absolute_difference = 25; |
| 17 | - } else { |
|
| 17 | + } else { |
|
| 18 | 18 | $limit_explode = explode(",", $_GET['limit']); |
| 19 | 19 | $limit_start = $limit_explode[0]; |
| 20 | 20 | $limit_end = $limit_explode[1]; |