@@ -55,23 +55,23 @@ discard block |
||
| 55 | 55 | $min = true; |
| 56 | 56 | $allhistory = false; |
| 57 | 57 | $filter['source'] = array(); |
| 58 | -if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalVATSIM) && $globalVATSIM && isset($_COOKIE['filter_ShowVATSIM']) && $_COOKIE['filter_ShowVATSIM'] == 'true') $filter['source'] = array_merge($filter['source'],array('vatsimtxt')); |
|
| 59 | -if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalIVAO) && $globalIVAO && isset($_COOKIE['filter_ShowIVAO']) && $_COOKIE['filter_ShowIVAO'] == 'true') $filter['source'] = array_merge($filter['source'],array('whazzup')); |
|
| 60 | -if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalphpVMS) && $globalphpVMS && isset($_COOKIE['filter_ShowVMS']) && $_COOKIE['filter_ShowVMS'] == 'true') $filter['source'] = array_merge($filter['source'],array('phpvmacars')); |
|
| 61 | -if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalSBS1) && $globalSBS1 && isset($_COOKIE['filter_ShowSBS1']) && $_COOKIE['filter_ShowSBS1'] == 'true') $filter['source'] = array_merge($filter['source'],array('sbs','famaprs')); |
|
| 62 | -if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalAPRS) && $globalAPRS && isset($_COOKIE['filter_ShowAPRS']) && $_COOKIE['filter_ShowAPRS'] == 'true') $filter['source'] = array_merge($filter['source'],array('aprs')); |
|
| 63 | -if (isset($_COOKIE['filter_ident']) && $_COOKIE['filter_ident'] != '') $filter['ident'] = filter_var($_COOKIE['filter_ident'],FILTER_SANITIZE_STRING); |
|
| 64 | -if (isset($_COOKIE['filter_Airlines']) && $_COOKIE['filter_Airlines'] != '') $filter['airlines'] = filter_var_array(explode(',',$_COOKIE['filter_Airlines']),FILTER_SANITIZE_STRING); |
|
| 65 | -if (isset($_COOKIE['filter_Sources']) && $_COOKIE['filter_Sources'] != '') $filter['source_aprs'] = filter_var_array(explode(',',$_COOKIE['filter_Sources']),FILTER_SANITIZE_STRING); |
|
| 66 | -if (isset($_COOKIE['filter_airlinestype']) && $_COOKIE['filter_airlinestype'] != 'all') $filter['airlinestype'] = filter_var($_COOKIE['filter_airlinestype'],FILTER_SANITIZE_STRING); |
|
| 67 | -if (isset($_COOKIE['filter_alliance']) && $_COOKIE['filter_alliance'] != 'all') $filter['alliance'] = filter_var($_COOKIE['filter_alliance'],FILTER_SANITIZE_STRING); |
|
| 58 | +if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalVATSIM) && $globalVATSIM && isset($_COOKIE['filter_ShowVATSIM']) && $_COOKIE['filter_ShowVATSIM'] == 'true') $filter['source'] = array_merge($filter['source'], array('vatsimtxt')); |
|
| 59 | +if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalIVAO) && $globalIVAO && isset($_COOKIE['filter_ShowIVAO']) && $_COOKIE['filter_ShowIVAO'] == 'true') $filter['source'] = array_merge($filter['source'], array('whazzup')); |
|
| 60 | +if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalphpVMS) && $globalphpVMS && isset($_COOKIE['filter_ShowVMS']) && $_COOKIE['filter_ShowVMS'] == 'true') $filter['source'] = array_merge($filter['source'], array('phpvmacars')); |
|
| 61 | +if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalSBS1) && $globalSBS1 && isset($_COOKIE['filter_ShowSBS1']) && $_COOKIE['filter_ShowSBS1'] == 'true') $filter['source'] = array_merge($filter['source'], array('sbs', 'famaprs')); |
|
| 62 | +if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalAPRS) && $globalAPRS && isset($_COOKIE['filter_ShowAPRS']) && $_COOKIE['filter_ShowAPRS'] == 'true') $filter['source'] = array_merge($filter['source'], array('aprs')); |
|
| 63 | +if (isset($_COOKIE['filter_ident']) && $_COOKIE['filter_ident'] != '') $filter['ident'] = filter_var($_COOKIE['filter_ident'], FILTER_SANITIZE_STRING); |
|
| 64 | +if (isset($_COOKIE['filter_Airlines']) && $_COOKIE['filter_Airlines'] != '') $filter['airlines'] = filter_var_array(explode(',', $_COOKIE['filter_Airlines']), FILTER_SANITIZE_STRING); |
|
| 65 | +if (isset($_COOKIE['filter_Sources']) && $_COOKIE['filter_Sources'] != '') $filter['source_aprs'] = filter_var_array(explode(',', $_COOKIE['filter_Sources']), FILTER_SANITIZE_STRING); |
|
| 66 | +if (isset($_COOKIE['filter_airlinestype']) && $_COOKIE['filter_airlinestype'] != 'all') $filter['airlinestype'] = filter_var($_COOKIE['filter_airlinestype'], FILTER_SANITIZE_STRING); |
|
| 67 | +if (isset($_COOKIE['filter_alliance']) && $_COOKIE['filter_alliance'] != 'all') $filter['alliance'] = filter_var($_COOKIE['filter_alliance'], FILTER_SANITIZE_STRING); |
|
| 68 | 68 | |
| 69 | 69 | if (isset($globalMapPopup) && !$globalMapPopup && !(isset($_COOKIE['flightpopup']) && $_COOKIE['flightpopup'] == 'true')) { |
| 70 | 70 | $min = true; |
| 71 | 71 | } else $min = false; |
| 72 | 72 | |
| 73 | 73 | if (isset($_GET['ident'])) { |
| 74 | - $ident = urldecode(filter_input(INPUT_GET,'ident',FILTER_SANITIZE_STRING)); |
|
| 74 | + $ident = urldecode(filter_input(INPUT_GET, 'ident', FILTER_SANITIZE_STRING)); |
|
| 75 | 75 | if ($tracker) { |
| 76 | 76 | $spotter_array = $TrackerLive->getLastLiveTrackerDataByIdent($ident); |
| 77 | 77 | } elseif ($marine) { |
@@ -85,7 +85,7 @@ discard block |
||
| 85 | 85 | } |
| 86 | 86 | $allhistory = true; |
| 87 | 87 | } elseif (isset($_GET['flightaware_id'])) { |
| 88 | - $flightaware_id = filter_input(INPUT_GET,'flightaware_id',FILTER_SANITIZE_STRING); |
|
| 88 | + $flightaware_id = filter_input(INPUT_GET, 'flightaware_id', FILTER_SANITIZE_STRING); |
|
| 89 | 89 | $spotter_array = $SpotterLive->getLastLiveSpotterDataById($flightaware_id); |
| 90 | 90 | if (empty($spotter_array)) { |
| 91 | 91 | $from_archive = true; |
@@ -93,44 +93,44 @@ discard block |
||
| 93 | 93 | } |
| 94 | 94 | $allhistory = true; |
| 95 | 95 | } elseif (isset($_GET['famtrack_id'])) { |
| 96 | - $famtrack_id = urldecode(filter_input(INPUT_GET,'famtrack_id',FILTER_SANITIZE_STRING)); |
|
| 96 | + $famtrack_id = urldecode(filter_input(INPUT_GET, 'famtrack_id', FILTER_SANITIZE_STRING)); |
|
| 97 | 97 | $spotter_array = $TrackerLive->getLastLiveTrackerDataById($famtrack_id); |
| 98 | 98 | $allhistory = true; |
| 99 | 99 | } elseif (isset($_GET['fammarine_id'])) { |
| 100 | - $fammarine_id = urldecode(filter_input(INPUT_GET,'fammarine_id',FILTER_SANITIZE_STRING)); |
|
| 100 | + $fammarine_id = urldecode(filter_input(INPUT_GET, 'fammarine_id', FILTER_SANITIZE_STRING)); |
|
| 101 | 101 | $spotter_array = $MarineLive->getLastLiveMarineDataById($fammarine_id); |
| 102 | 102 | $allhistory = true; |
| 103 | 103 | } elseif (isset($globalMapUseBbox) && $globalMapUseBbox && isset($_GET['coord']) && (!isset($globalMapPopup) || $globalMapPopup || (isset($_COOKIE['flightpopup']) && $_COOKIE['flightpopup'] == 'true'))) { |
| 104 | 104 | //} elseif (isset($_GET['coord'])) { |
| 105 | 105 | $usecoord = true; |
| 106 | - $coord = explode(',',$_GET['coord']); |
|
| 106 | + $coord = explode(',', $_GET['coord']); |
|
| 107 | 107 | if ($tracker) { |
| 108 | - $spotter_array = $TrackerLive->getLiveTrackerDatabyCoord($coord,$filter); |
|
| 108 | + $spotter_array = $TrackerLive->getLiveTrackerDatabyCoord($coord, $filter); |
|
| 109 | 109 | } elseif ($marine) { |
| 110 | - $spotter_array = $MarineLive->getLiveMarineDatabyCoord($coord,$filter); |
|
| 110 | + $spotter_array = $MarineLive->getLiveMarineDatabyCoord($coord, $filter); |
|
| 111 | 111 | } else { |
| 112 | - $spotter_array = $SpotterLive->getLiveSpotterDatabyCoord($coord,$filter); |
|
| 112 | + $spotter_array = $SpotterLive->getLiveSpotterDatabyCoord($coord, $filter); |
|
| 113 | 113 | } |
| 114 | 114 | } elseif (isset($globalMapUseBbox) && $globalMapUseBbox && isset($_GET['coord']) && $min) { |
| 115 | 115 | $usecoord = true; |
| 116 | - $coord = explode(',',$_GET['coord']); |
|
| 116 | + $coord = explode(',', $_GET['coord']); |
|
| 117 | 117 | if ($tracker) { |
| 118 | - $spotter_array = $TrackerLive->getMinLiveTrackerDatabyCoord($coord,$filter); |
|
| 118 | + $spotter_array = $TrackerLive->getMinLiveTrackerDatabyCoord($coord, $filter); |
|
| 119 | 119 | } elseif ($marine) { |
| 120 | - $spotter_array = $MarineLive->getMinLiveMarineDatabyCoord($coord,$filter); |
|
| 120 | + $spotter_array = $MarineLive->getMinLiveMarineDatabyCoord($coord, $filter); |
|
| 121 | 121 | } else { |
| 122 | - $spotter_array = $SpotterLive->getMinLiveSpotterDatabyCoord($coord,$filter); |
|
| 122 | + $spotter_array = $SpotterLive->getMinLiveSpotterDatabyCoord($coord, $filter); |
|
| 123 | 123 | } |
| 124 | 124 | } elseif (isset($_GET['archive']) && isset($_GET['begindate']) && isset($_GET['enddate']) && isset($_GET['speed']) && !isset($_GET['tracker']) && !isset($_GET['marine'])) { |
| 125 | 125 | $from_archive = true; |
| 126 | 126 | // $begindate = filter_input(INPUT_GET,'begindate',FILTER_VALIDATE_REGEXP,array("options"=>array("regexp"=>'~^\d{4}/\d{2}/\d{2}$~'))); |
| 127 | 127 | // $enddate = filter_input(INPUT_GET,'enddate',FILTER_VALIDATE_REGEXP,array("options"=>array("regexp"=>'~^\d{4}/\d{2}/\d{2}$~'))); |
| 128 | - $begindate = filter_input(INPUT_GET,'begindate',FILTER_SANITIZE_NUMBER_INT); |
|
| 129 | - $enddate = filter_input(INPUT_GET,'enddate',FILTER_SANITIZE_NUMBER_INT); |
|
| 130 | - $archivespeed = filter_input(INPUT_GET,'speed',FILTER_SANITIZE_NUMBER_INT); |
|
| 131 | - $begindate = date('Y-m-d H:i:s',$begindate); |
|
| 132 | - $enddate = date('Y-m-d H:i:s',$enddate); |
|
| 133 | - $spotter_array = $SpotterArchive->getMinLiveSpotterData($begindate,$enddate,$filter); |
|
| 128 | + $begindate = filter_input(INPUT_GET, 'begindate', FILTER_SANITIZE_NUMBER_INT); |
|
| 129 | + $enddate = filter_input(INPUT_GET, 'enddate', FILTER_SANITIZE_NUMBER_INT); |
|
| 130 | + $archivespeed = filter_input(INPUT_GET, 'speed', FILTER_SANITIZE_NUMBER_INT); |
|
| 131 | + $begindate = date('Y-m-d H:i:s', $begindate); |
|
| 132 | + $enddate = date('Y-m-d H:i:s', $enddate); |
|
| 133 | + $spotter_array = $SpotterArchive->getMinLiveSpotterData($begindate, $enddate, $filter); |
|
| 134 | 134 | } elseif ($min) { |
| 135 | 135 | if ($tracker) { |
| 136 | 136 | $spotter_array = $TrackerLive->getMinLiveTrackerData($filter); |
@@ -142,17 +142,17 @@ discard block |
||
| 142 | 142 | # $min = true; |
| 143 | 143 | } else { |
| 144 | 144 | if ($tracker) { |
| 145 | - $spotter_array = $TrackerLive->getLiveTrackerData('','',$filter); |
|
| 145 | + $spotter_array = $TrackerLive->getLiveTrackerData('', '', $filter); |
|
| 146 | 146 | } elseif ($marine) { |
| 147 | - $spotter_array = $marineLive->getLiveMarineData('','',$filter); |
|
| 147 | + $spotter_array = $marineLive->getLiveMarineData('', '', $filter); |
|
| 148 | 148 | } else { |
| 149 | - $spotter_array = $SpotterLive->getLiveSpotterData('','',$filter); |
|
| 149 | + $spotter_array = $SpotterLive->getLiveSpotterData('', '', $filter); |
|
| 150 | 150 | } |
| 151 | 151 | } |
| 152 | 152 | |
| 153 | 153 | if ($usecoord) { |
| 154 | 154 | if (isset($_GET['archive'])) { |
| 155 | - $flightcnt = $SpotterArchive->getLiveSpotterCount($begindate,$enddate,$filter); |
|
| 155 | + $flightcnt = $SpotterArchive->getLiveSpotterCount($begindate, $enddate, $filter); |
|
| 156 | 156 | } else { |
| 157 | 157 | if ($tracker) { |
| 158 | 158 | $flightcnt = $TrackerLive->getLiveSpotterCount($filter); |
@@ -165,7 +165,7 @@ discard block |
||
| 165 | 165 | if ($flightcnt == '') $flightcnt = 0; |
| 166 | 166 | } else $flightcnt = 0; |
| 167 | 167 | |
| 168 | -$sqltime = round(microtime(true)-$begintime,2); |
|
| 168 | +$sqltime = round(microtime(true) - $begintime, 2); |
|
| 169 | 169 | |
| 170 | 170 | if ((!isset($_COOKIE['flightestimation']) && isset($globalMapEstimation) && $globalMapEstimation == FALSE) || (isset($_COOKIE['flightestimation']) && $_COOKIE['flightestimation'] == 'false')) $usenextlatlon = false; |
| 171 | 171 | else $usenextlatlon = true; |
@@ -182,7 +182,7 @@ discard block |
||
| 182 | 182 | if (!empty($spotter_array) && is_array($spotter_array)) |
| 183 | 183 | { |
| 184 | 184 | $output .= '"features": ['; |
| 185 | - foreach($spotter_array as $spotter_item) |
|
| 185 | + foreach ($spotter_array as $spotter_item) |
|
| 186 | 186 | { |
| 187 | 187 | $j++; |
| 188 | 188 | date_default_timezone_set('UTC'); |
@@ -238,8 +238,8 @@ discard block |
||
| 238 | 238 | */ |
| 239 | 239 | //$output .= '"fc": "'.$spotter_item['nb'].'",'; |
| 240 | 240 | if (isset($spotter_item['ident']) && $spotter_item['ident'] != '') { |
| 241 | - if ($compress) $output .= '"c": "'.str_replace('\\','',$spotter_item['ident']).'",'; |
|
| 242 | - else $output .= '"callsign": "'.str_replace('\\','',$spotter_item['ident']).'",'; |
|
| 241 | + if ($compress) $output .= '"c": "'.str_replace('\\', '', $spotter_item['ident']).'",'; |
|
| 242 | + else $output .= '"callsign": "'.str_replace('\\', '', $spotter_item['ident']).'",'; |
|
| 243 | 243 | //" |
| 244 | 244 | } else { |
| 245 | 245 | if ($compress) $output .= '"c": "NA",'; |
@@ -248,7 +248,7 @@ discard block |
||
| 248 | 248 | if (isset($spotter_item['registration'])) $output .= '"registration": "'.$spotter_item['registration'].'",'; |
| 249 | 249 | if (isset($spotter_item['aircraft_name']) && isset($spotter_item['aircraft_type'])) { |
| 250 | 250 | $output .= '"aircraft_name": "'.$spotter_item['aircraft_name'].' ('.$spotter_item['aircraft_type'].')",'; |
| 251 | - $output .= '"aircraft_wiki": "http://'.strtolower($globalLanguage).'.wikipedia.org/wiki/'.urlencode(str_replace(' ','_',$spotter_item['aircraft_name'])).'",'; |
|
| 251 | + $output .= '"aircraft_wiki": "http://'.strtolower($globalLanguage).'.wikipedia.org/wiki/'.urlencode(str_replace(' ', '_', $spotter_item['aircraft_name'])).'",'; |
|
| 252 | 252 | } elseif (isset($spotter_item['aircraft_type'])) { |
| 253 | 253 | $output .= '"aircraft_name": "NA ('.$spotter_item['aircraft_type'].')",'; |
| 254 | 254 | } elseif (!$min) { |
@@ -389,16 +389,16 @@ discard block |
||
| 389 | 389 | else $output .= '"heading": "'.$spotter_item['heading'].'",'; |
| 390 | 390 | |
| 391 | 391 | if (isset($archivespeed)) { |
| 392 | - $nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$spotter_item['heading'],$archivespeed); |
|
| 392 | + $nextcoord = $Common->nextcoord($spotter_item['latitude'], $spotter_item['longitude'], $spotter_item['ground_speed'], $spotter_item['heading'], $archivespeed); |
|
| 393 | 393 | $output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],'; |
| 394 | 394 | } elseif ($usenextlatlon) { |
| 395 | - $nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$spotter_item['heading']); |
|
| 395 | + $nextcoord = $Common->nextcoord($spotter_item['latitude'], $spotter_item['longitude'], $spotter_item['ground_speed'], $spotter_item['heading']); |
|
| 396 | 396 | $output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],'; |
| 397 | 397 | } |
| 398 | 398 | |
| 399 | 399 | if (!$min) $output .= '"image": "'.$image.'",'; |
| 400 | 400 | if (isset($spotter_item['image_copyright']) && $spotter_item['image_copyright'] != '') { |
| 401 | - $output .= '"image_copyright": "'.str_replace('"',"'",trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$spotter_item['image_copyright']))).'",'; |
|
| 401 | + $output .= '"image_copyright": "'.str_replace('"', "'", trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '', $spotter_item['image_copyright']))).'",'; |
|
| 402 | 402 | } |
| 403 | 403 | if (isset($spotter_item['image_source_website'])) { |
| 404 | 404 | $output .= '"image_source_website": "'.urlencode($spotter_item['image_source_website']).'",'; |
@@ -420,7 +420,7 @@ discard block |
||
| 420 | 420 | $output .= '"waypoints": "'.$spotter_item['waypoints'].'",'; |
| 421 | 421 | } |
| 422 | 422 | if (isset($spotter_item['acars'])) { |
| 423 | - $output .= '"acars": "'.trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"), '<br />',$spotter_item['acars']['message'])).'",'; |
|
| 423 | + $output .= '"acars": "'.trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '<br />', $spotter_item['acars']['message'])).'",'; |
|
| 424 | 424 | } |
| 425 | 425 | // type when not aircraft ? |
| 426 | 426 | if (isset($spotter_item['type'])) { |
@@ -498,7 +498,7 @@ discard block |
||
| 498 | 498 | |
| 499 | 499 | } |
| 500 | 500 | */ |
| 501 | - $history = filter_input(INPUT_GET,'history',FILTER_SANITIZE_STRING); |
|
| 501 | + $history = filter_input(INPUT_GET, 'history', FILTER_SANITIZE_STRING); |
|
| 502 | 502 | if ($history == '' && isset($_COOKIE['history'])) $history = $_COOKIE['history']; |
| 503 | 503 | |
| 504 | 504 | if ( |
@@ -506,11 +506,11 @@ discard block |
||
| 506 | 506 | || ((isset($globalMapHistory) && $globalMapHistory) || $allhistory) |
| 507 | 507 | // || (isset($history) && $history != '' && $history != 'NA' && ($history == $spotter_item['ident'] || $history == $spotter_item['flightaware_id'])) |
| 508 | 508 | // || (isset($history) && $history != '' && $history != 'NA' && $history == $spotter_item['ident']) |
| 509 | - || (isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['flightaware_id']) && str_replace('-','',$history) == str_replace('-','',$spotter_item['flightaware_id'])) |
|
| 509 | + || (isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['flightaware_id']) && str_replace('-', '', $history) == str_replace('-', '', $spotter_item['flightaware_id'])) |
|
| 510 | 510 | || (isset($history) && $history == '' && isset($spotter_item['flightaware_id']) && isset($_GET['flightaware_id']) && $_GET['flightaware_id'] == $spotter_item['flightaware_id']) |
| 511 | - || (isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['fammarine_id']) && str_replace('-','',$history) == str_replace('-','',$spotter_item['fammarine_id'])) |
|
| 511 | + || (isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['fammarine_id']) && str_replace('-', '', $history) == str_replace('-', '', $spotter_item['fammarine_id'])) |
|
| 512 | 512 | || (isset($history) && $history == '' && isset($spotter_item['flightaware_id']) && isset($_GET['fammarine_id']) && $_GET['fammarine_id'] == $spotter_item['fammarine_id']) |
| 513 | - || (isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['famtrackid']) && str_replace('-','',$history) == str_replace('-','',$spotter_item['famtrackid'])) |
|
| 513 | + || (isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['famtrackid']) && str_replace('-', '', $history) == str_replace('-', '', $spotter_item['famtrackid'])) |
|
| 514 | 514 | || (isset($history) && $history == '' && isset($spotter_item['flightaware_id']) && isset($_GET['famtrackid']) && $_GET['famtrackid'] == $spotter_item['famtrackid']) |
| 515 | 515 | ) { |
| 516 | 516 | if ($tracker) { |
@@ -547,9 +547,9 @@ discard block |
||
| 547 | 547 | else $output_history = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "history","altitude": "'.$alt.'"},"geometry": {"type": "LineString","coordinates": ['; |
| 548 | 548 | } |
| 549 | 549 | $output_history .= '['; |
| 550 | - $output_history .= $spotter_history['longitude'].', '; |
|
| 551 | - $output_history .= $spotter_history['latitude'].', '; |
|
| 552 | - $output_history .= $spotter_history['altitude']*30.48; |
|
| 550 | + $output_history .= $spotter_history['longitude'].', '; |
|
| 551 | + $output_history .= $spotter_history['latitude'].', '; |
|
| 552 | + $output_history .= $spotter_history['altitude']*30.48; |
|
| 553 | 553 | $output_history .= '],'; |
| 554 | 554 | /* |
| 555 | 555 | if ($from_archive === false) { |
@@ -567,8 +567,8 @@ discard block |
||
| 567 | 567 | else $output_history = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "history"},"geometry": {"type": "LineString","coordinates": ['; |
| 568 | 568 | } else $d = true; |
| 569 | 569 | $output_history .= '['; |
| 570 | - $output_history .= $spotter_history['longitude'].', '; |
|
| 571 | - $output_history .= $spotter_history['latitude']; |
|
| 570 | + $output_history .= $spotter_history['longitude'].', '; |
|
| 571 | + $output_history .= $spotter_history['latitude']; |
|
| 572 | 572 | $output_history .= '],'; |
| 573 | 573 | /* |
| 574 | 574 | if ($from_archive === false) { |
@@ -584,9 +584,9 @@ discard block |
||
| 584 | 584 | |
| 585 | 585 | if ($from_archive === false) { |
| 586 | 586 | $output_historyd = '['; |
| 587 | - $output_historyd .= $spotter_item['longitude'].', '; |
|
| 588 | - $output_historyd .= $spotter_item['latitude']; |
|
| 589 | - if (isset($spotter_history['altitude'])) $output_historyd .= ','.$spotter_item['altitude']*30.48; |
|
| 587 | + $output_historyd .= $spotter_item['longitude'].', '; |
|
| 588 | + $output_historyd .= $spotter_item['latitude']; |
|
| 589 | + if (isset($spotter_history['altitude'])) $output_historyd .= ','.$spotter_item['altitude']*30.48; |
|
| 590 | 590 | $output_historyd .= '],'; |
| 591 | 591 | //$output_history = $output_historyd.$output_history; |
| 592 | 592 | $output_history = $output_history.$output_historyd; |
@@ -600,7 +600,7 @@ discard block |
||
| 600 | 600 | } |
| 601 | 601 | } |
| 602 | 602 | |
| 603 | - if (((isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['flightaware_id']) && str_replace('-','',$history) == str_replace('-','',$spotter_item['flightaware_id'])) |
|
| 603 | + if (((isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['flightaware_id']) && str_replace('-', '', $history) == str_replace('-', '', $spotter_item['flightaware_id'])) |
|
| 604 | 604 | || (isset($history) && $history == '' && isset($spotter_item['flightaware_id']) && isset($_GET['flightaware_id']) && $_GET['flightaware_id'] == $spotter_item['flightaware_id'])) |
| 605 | 605 | && (isset($spotter_item['departure_airport']) |
| 606 | 606 | && $spotter_item['departure_airport'] != 'NA' |
@@ -634,7 +634,7 @@ discard block |
||
| 634 | 634 | |
| 635 | 635 | //if (isset($history) && $history != '' && $history == $spotter_item['ident'] && isset($spotter_item['departure_airport']) && $spotter_item['departure_airport'] != 'NA' && isset($spotter_item['arrival_airport']) && $spotter_item['arrival_airport'] != 'NA' && ((isset($_COOKIE['MapRoute']) && $_COOKIE['MapRoute'] == "true") || (!isset($_COOKIE['MapRoute']) && (!isset($globalMapRoute) || (isset($globalMapRoute) && $globalMapRoute))))) { |
| 636 | 636 | //if (isset($history) && $history != '' && $history == $spotter_item['ident'] && isset($spotter_item['arrival_airport']) && $spotter_item['arrival_airport'] != 'NA' && ((isset($_COOKIE['MapRoute']) && $_COOKIE['MapRoute'] == "true") || (!isset($_COOKIE['MapRoute']) && (!isset($globalMapRoute) || (isset($globalMapRoute) && $globalMapRoute))))) { |
| 637 | - if (((isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['flightaware_id']) && str_replace('-','',$history) == str_replace('-','',$spotter_item['flightaware_id'])) |
|
| 637 | + if (((isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['flightaware_id']) && str_replace('-', '', $history) == str_replace('-', '', $spotter_item['flightaware_id'])) |
|
| 638 | 638 | || (isset($history) && $history == '' && isset($spotter_item['flightaware_id']) && isset($_GET['flightaware_id']) && $_GET['flightaware_id'] == $spotter_item['flightaware_id'])) |
| 639 | 639 | && (isset($spotter_item['arrival_airport']) |
| 640 | 640 | && $spotter_item['arrival_airport'] != 'NA' |
@@ -665,7 +665,7 @@ discard block |
||
| 665 | 665 | $output = substr($output, 0, -1); |
| 666 | 666 | $output .= ']'; |
| 667 | 667 | $output .= ',"initial_sqltime": "'.$sqltime.'",'; |
| 668 | - $output .= '"totaltime": "'.round(microtime(true)-$begintime,2).'",'; |
|
| 668 | + $output .= '"totaltime": "'.round(microtime(true) - $begintime, 2).'",'; |
|
| 669 | 669 | if (isset($begindate)) $output .= '"archive_date": "'.$begindate.'",'; |
| 670 | 670 | $output .= '"fc": "'.$j.'"'; |
| 671 | 671 | } else { |
@@ -48,27 +48,52 @@ discard block |
||
| 48 | 48 | } |
| 49 | 49 | header('Content-Type: text/javascript'); |
| 50 | 50 | |
| 51 | -if (!isset($globalJsonCompress)) $compress = true; |
|
| 52 | -else $compress = $globalJsonCompress; |
|
| 51 | +if (!isset($globalJsonCompress)) { |
|
| 52 | + $compress = true; |
|
| 53 | +} else { |
|
| 54 | + $compress = $globalJsonCompress; |
|
| 55 | +} |
|
| 53 | 56 | |
| 54 | 57 | $from_archive = false; |
| 55 | 58 | $min = true; |
| 56 | 59 | $allhistory = false; |
| 57 | 60 | $filter['source'] = array(); |
| 58 | -if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalVATSIM) && $globalVATSIM && isset($_COOKIE['filter_ShowVATSIM']) && $_COOKIE['filter_ShowVATSIM'] == 'true') $filter['source'] = array_merge($filter['source'],array('vatsimtxt')); |
|
| 59 | -if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalIVAO) && $globalIVAO && isset($_COOKIE['filter_ShowIVAO']) && $_COOKIE['filter_ShowIVAO'] == 'true') $filter['source'] = array_merge($filter['source'],array('whazzup')); |
|
| 60 | -if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalphpVMS) && $globalphpVMS && isset($_COOKIE['filter_ShowVMS']) && $_COOKIE['filter_ShowVMS'] == 'true') $filter['source'] = array_merge($filter['source'],array('phpvmacars')); |
|
| 61 | -if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalSBS1) && $globalSBS1 && isset($_COOKIE['filter_ShowSBS1']) && $_COOKIE['filter_ShowSBS1'] == 'true') $filter['source'] = array_merge($filter['source'],array('sbs','famaprs')); |
|
| 62 | -if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalAPRS) && $globalAPRS && isset($_COOKIE['filter_ShowAPRS']) && $_COOKIE['filter_ShowAPRS'] == 'true') $filter['source'] = array_merge($filter['source'],array('aprs')); |
|
| 63 | -if (isset($_COOKIE['filter_ident']) && $_COOKIE['filter_ident'] != '') $filter['ident'] = filter_var($_COOKIE['filter_ident'],FILTER_SANITIZE_STRING); |
|
| 64 | -if (isset($_COOKIE['filter_Airlines']) && $_COOKIE['filter_Airlines'] != '') $filter['airlines'] = filter_var_array(explode(',',$_COOKIE['filter_Airlines']),FILTER_SANITIZE_STRING); |
|
| 65 | -if (isset($_COOKIE['filter_Sources']) && $_COOKIE['filter_Sources'] != '') $filter['source_aprs'] = filter_var_array(explode(',',$_COOKIE['filter_Sources']),FILTER_SANITIZE_STRING); |
|
| 66 | -if (isset($_COOKIE['filter_airlinestype']) && $_COOKIE['filter_airlinestype'] != 'all') $filter['airlinestype'] = filter_var($_COOKIE['filter_airlinestype'],FILTER_SANITIZE_STRING); |
|
| 67 | -if (isset($_COOKIE['filter_alliance']) && $_COOKIE['filter_alliance'] != 'all') $filter['alliance'] = filter_var($_COOKIE['filter_alliance'],FILTER_SANITIZE_STRING); |
|
| 61 | +if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalVATSIM) && $globalVATSIM && isset($_COOKIE['filter_ShowVATSIM']) && $_COOKIE['filter_ShowVATSIM'] == 'true') { |
|
| 62 | + $filter['source'] = array_merge($filter['source'],array('vatsimtxt')); |
|
| 63 | +} |
|
| 64 | +if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalIVAO) && $globalIVAO && isset($_COOKIE['filter_ShowIVAO']) && $_COOKIE['filter_ShowIVAO'] == 'true') { |
|
| 65 | + $filter['source'] = array_merge($filter['source'],array('whazzup')); |
|
| 66 | +} |
|
| 67 | +if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalphpVMS) && $globalphpVMS && isset($_COOKIE['filter_ShowVMS']) && $_COOKIE['filter_ShowVMS'] == 'true') { |
|
| 68 | + $filter['source'] = array_merge($filter['source'],array('phpvmacars')); |
|
| 69 | +} |
|
| 70 | +if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalSBS1) && $globalSBS1 && isset($_COOKIE['filter_ShowSBS1']) && $_COOKIE['filter_ShowSBS1'] == 'true') { |
|
| 71 | + $filter['source'] = array_merge($filter['source'],array('sbs','famaprs')); |
|
| 72 | +} |
|
| 73 | +if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalAPRS) && $globalAPRS && isset($_COOKIE['filter_ShowAPRS']) && $_COOKIE['filter_ShowAPRS'] == 'true') { |
|
| 74 | + $filter['source'] = array_merge($filter['source'],array('aprs')); |
|
| 75 | +} |
|
| 76 | +if (isset($_COOKIE['filter_ident']) && $_COOKIE['filter_ident'] != '') { |
|
| 77 | + $filter['ident'] = filter_var($_COOKIE['filter_ident'],FILTER_SANITIZE_STRING); |
|
| 78 | +} |
|
| 79 | +if (isset($_COOKIE['filter_Airlines']) && $_COOKIE['filter_Airlines'] != '') { |
|
| 80 | + $filter['airlines'] = filter_var_array(explode(',',$_COOKIE['filter_Airlines']),FILTER_SANITIZE_STRING); |
|
| 81 | +} |
|
| 82 | +if (isset($_COOKIE['filter_Sources']) && $_COOKIE['filter_Sources'] != '') { |
|
| 83 | + $filter['source_aprs'] = filter_var_array(explode(',',$_COOKIE['filter_Sources']),FILTER_SANITIZE_STRING); |
|
| 84 | +} |
|
| 85 | +if (isset($_COOKIE['filter_airlinestype']) && $_COOKIE['filter_airlinestype'] != 'all') { |
|
| 86 | + $filter['airlinestype'] = filter_var($_COOKIE['filter_airlinestype'],FILTER_SANITIZE_STRING); |
|
| 87 | +} |
|
| 88 | +if (isset($_COOKIE['filter_alliance']) && $_COOKIE['filter_alliance'] != 'all') { |
|
| 89 | + $filter['alliance'] = filter_var($_COOKIE['filter_alliance'],FILTER_SANITIZE_STRING); |
|
| 90 | +} |
|
| 68 | 91 | |
| 69 | 92 | if (isset($globalMapPopup) && !$globalMapPopup && !(isset($_COOKIE['flightpopup']) && $_COOKIE['flightpopup'] == 'true')) { |
| 70 | 93 | $min = true; |
| 71 | -} else $min = false; |
|
| 94 | +} else { |
|
| 95 | + $min = false; |
|
| 96 | +} |
|
| 72 | 97 | |
| 73 | 98 | if (isset($_GET['ident'])) { |
| 74 | 99 | $ident = urldecode(filter_input(INPUT_GET,'ident',FILTER_SANITIZE_STRING)); |
@@ -162,20 +187,30 @@ discard block |
||
| 162 | 187 | $flightcnt = $SpotterLive->getLiveSpotterCount($filter); |
| 163 | 188 | } |
| 164 | 189 | } |
| 165 | - if ($flightcnt == '') $flightcnt = 0; |
|
| 166 | -} else $flightcnt = 0; |
|
| 190 | + if ($flightcnt == '') { |
|
| 191 | + $flightcnt = 0; |
|
| 192 | + } |
|
| 193 | + } else { |
|
| 194 | + $flightcnt = 0; |
|
| 195 | +} |
|
| 167 | 196 | |
| 168 | 197 | $sqltime = round(microtime(true)-$begintime,2); |
| 169 | 198 | |
| 170 | -if ((!isset($_COOKIE['flightestimation']) && isset($globalMapEstimation) && $globalMapEstimation == FALSE) || (isset($_COOKIE['flightestimation']) && $_COOKIE['flightestimation'] == 'false')) $usenextlatlon = false; |
|
| 171 | -else $usenextlatlon = true; |
|
| 199 | +if ((!isset($_COOKIE['flightestimation']) && isset($globalMapEstimation) && $globalMapEstimation == FALSE) || (isset($_COOKIE['flightestimation']) && $_COOKIE['flightestimation'] == 'false')) { |
|
| 200 | + $usenextlatlon = false; |
|
| 201 | +} else { |
|
| 202 | + $usenextlatlon = true; |
|
| 203 | +} |
|
| 172 | 204 | $j = 0; |
| 173 | 205 | $prev_flightaware_id = ''; |
| 174 | 206 | $aircrafts_shadow = array(); |
| 175 | 207 | $output = '{'; |
| 176 | 208 | $output .= '"type": "FeatureCollection",'; |
| 177 | - if ($min) $output .= '"minimal": "true",'; |
|
| 178 | - else $output .= '"minimal": "false",'; |
|
| 209 | + if ($min) { |
|
| 210 | + $output .= '"minimal": "true",'; |
|
| 211 | + } else { |
|
| 212 | + $output .= '"minimal": "false",'; |
|
| 213 | + } |
|
| 179 | 214 | //$output .= '"fc": "'.$flightcnt.'",'; |
| 180 | 215 | $output .= '"sqt": "'.$sqltime.'",'; |
| 181 | 216 | |
@@ -219,18 +254,29 @@ discard block |
||
| 219 | 254 | } |
| 220 | 255 | $output .= '"properties": {'; |
| 221 | 256 | if (isset($spotter_item['flightaware_id'])) { |
| 222 | - if ($compress) $output .= '"fi": "'.$spotter_item['flightaware_id'].'",'; |
|
| 223 | - else $output .= '"flightaware_id": "'.$spotter_item['flightaware_id'].'",'; |
|
| 257 | + if ($compress) { |
|
| 258 | + $output .= '"fi": "'.$spotter_item['flightaware_id'].'",'; |
|
| 259 | + } else { |
|
| 260 | + $output .= '"flightaware_id": "'.$spotter_item['flightaware_id'].'",'; |
|
| 261 | + } |
|
| 224 | 262 | } elseif (isset($spotter_item['famtrackid'])) { |
| 225 | - if ($compress) $output .= '"fti": "'.$spotter_item['famtrackid'].'",'; |
|
| 226 | - else $output .= '"famtrackid": "'.$spotter_item['famtrackid'].'",'; |
|
| 263 | + if ($compress) { |
|
| 264 | + $output .= '"fti": "'.$spotter_item['famtrackid'].'",'; |
|
| 265 | + } else { |
|
| 266 | + $output .= '"famtrackid": "'.$spotter_item['famtrackid'].'",'; |
|
| 267 | + } |
|
| 227 | 268 | } elseif (isset($spotter_item['fammarine_id'])) { |
| 228 | - if ($compress) $output .= '"fmi": "'.$spotter_item['fammarine_id'].'",'; |
|
| 229 | - else $output .= '"fammarineid": "'.$spotter_item['fammarine_id'].'",'; |
|
| 269 | + if ($compress) { |
|
| 270 | + $output .= '"fmi": "'.$spotter_item['fammarine_id'].'",'; |
|
| 271 | + } else { |
|
| 272 | + $output .= '"fammarineid": "'.$spotter_item['fammarine_id'].'",'; |
|
| 273 | + } |
|
| 230 | 274 | } |
| 231 | 275 | $output .= '"fc": "'.$flightcnt.'",'; |
| 232 | 276 | $output .= '"sqt": "'.$sqltime.'",'; |
| 233 | - if (isset($begindate)) $output .= '"archive_date": "'.$begindate.'",'; |
|
| 277 | + if (isset($begindate)) { |
|
| 278 | + $output .= '"archive_date": "'.$begindate.'",'; |
|
| 279 | + } |
|
| 234 | 280 | |
| 235 | 281 | /* |
| 236 | 282 | if ($min) $output .= '"minimal": "true",'; |
@@ -238,14 +284,22 @@ discard block |
||
| 238 | 284 | */ |
| 239 | 285 | //$output .= '"fc": "'.$spotter_item['nb'].'",'; |
| 240 | 286 | if (isset($spotter_item['ident']) && $spotter_item['ident'] != '') { |
| 241 | - if ($compress) $output .= '"c": "'.str_replace('\\','',$spotter_item['ident']).'",'; |
|
| 242 | - else $output .= '"callsign": "'.str_replace('\\','',$spotter_item['ident']).'",'; |
|
| 287 | + if ($compress) { |
|
| 288 | + $output .= '"c": "'.str_replace('\\','',$spotter_item['ident']).'",'; |
|
| 289 | + } else { |
|
| 290 | + $output .= '"callsign": "'.str_replace('\\','',$spotter_item['ident']).'",'; |
|
| 291 | + } |
|
| 243 | 292 | //" |
| 244 | 293 | } else { |
| 245 | - if ($compress) $output .= '"c": "NA",'; |
|
| 246 | - else $output .= '"callsign": "NA",'; |
|
| 294 | + if ($compress) { |
|
| 295 | + $output .= '"c": "NA",'; |
|
| 296 | + } else { |
|
| 297 | + $output .= '"callsign": "NA",'; |
|
| 298 | + } |
|
| 299 | + } |
|
| 300 | + if (isset($spotter_item['registration'])) { |
|
| 301 | + $output .= '"registration": "'.$spotter_item['registration'].'",'; |
|
| 247 | 302 | } |
| 248 | - if (isset($spotter_item['registration'])) $output .= '"registration": "'.$spotter_item['registration'].'",'; |
|
| 249 | 303 | if (isset($spotter_item['aircraft_name']) && isset($spotter_item['aircraft_type'])) { |
| 250 | 304 | $output .= '"aircraft_name": "'.$spotter_item['aircraft_name'].' ('.$spotter_item['aircraft_type'].')",'; |
| 251 | 305 | $output .= '"aircraft_wiki": "http://'.strtolower($globalLanguage).'.wikipedia.org/wiki/'.urlencode(str_replace(' ','_',$spotter_item['aircraft_name'])).'",'; |
@@ -258,16 +312,23 @@ discard block |
||
| 258 | 312 | $output .= '"aircraft_icao": "'.$spotter_item['aircraft_icao'].'",'; |
| 259 | 313 | } |
| 260 | 314 | if (!isset($spotter_item['aircraft_shadow']) && !$tracker) { |
| 261 | - if (!isset($spotter_item['aircraft_icao']) || $spotter_item['aircraft_icao'] == '') $spotter_item['aircraft_shadow'] = ''; |
|
| 262 | - else { |
|
| 315 | + if (!isset($spotter_item['aircraft_icao']) || $spotter_item['aircraft_icao'] == '') { |
|
| 316 | + $spotter_item['aircraft_shadow'] = ''; |
|
| 317 | + } else { |
|
| 263 | 318 | $aircraft_icao = $spotter_item['aircraft_icao']; |
| 264 | - if (isset($aircrafts_shadow[$aircraft_icao])) $spotter_item['aircraft_shadow'] = $aircrafts_shadow[$aircraft_icao]; |
|
| 265 | - else { |
|
| 319 | + if (isset($aircrafts_shadow[$aircraft_icao])) { |
|
| 320 | + $spotter_item['aircraft_shadow'] = $aircrafts_shadow[$aircraft_icao]; |
|
| 321 | + } else { |
|
| 266 | 322 | $aircraft_info = $Spotter->getAllAircraftInfo($spotter_item['aircraft_icao']); |
| 267 | - if (count($aircraft_info) > 0) $spotter_item['aircraft_shadow'] = $aircraft_info[0]['aircraft_shadow']; |
|
| 268 | - elseif (isset($spotter_item['format_source']) && $spotter_item['format_source'] == 'aprs') $spotter_item['aircraft_shadow'] = 'PA18.png'; |
|
| 269 | - elseif ($aircraft_icao == 'PARAGLIDER') $spotter_item['aircraft_shadow'] = 'PARAGLIDER.png'; |
|
| 270 | - else $spotter_item['aircraft_shadow'] = ''; |
|
| 323 | + if (count($aircraft_info) > 0) { |
|
| 324 | + $spotter_item['aircraft_shadow'] = $aircraft_info[0]['aircraft_shadow']; |
|
| 325 | + } elseif (isset($spotter_item['format_source']) && $spotter_item['format_source'] == 'aprs') { |
|
| 326 | + $spotter_item['aircraft_shadow'] = 'PA18.png'; |
|
| 327 | + } elseif ($aircraft_icao == 'PARAGLIDER') { |
|
| 328 | + $spotter_item['aircraft_shadow'] = 'PARAGLIDER.png'; |
|
| 329 | + } else { |
|
| 330 | + $spotter_item['aircraft_shadow'] = ''; |
|
| 331 | + } |
|
| 271 | 332 | $aircrafts_shadow[$aircraft_icao] = $spotter_item['aircraft_shadow']; |
| 272 | 333 | } |
| 273 | 334 | } |
@@ -275,73 +336,139 @@ discard block |
||
| 275 | 336 | if (!isset($spotter_item['aircraft_shadow']) || $spotter_item['aircraft_shadow'] == '') { |
| 276 | 337 | if ($tracker) { |
| 277 | 338 | if (isset($spotter_item['type']) && $spotter_item['type'] == 'Ambulance') { |
| 278 | - if ($compress) $output .= '"as": "ambulance.png",'; |
|
| 279 | - else $output .= '"aircraft_shadow": "ambulance.png",'; |
|
| 339 | + if ($compress) { |
|
| 340 | + $output .= '"as": "ambulance.png",'; |
|
| 341 | + } else { |
|
| 342 | + $output .= '"aircraft_shadow": "ambulance.png",'; |
|
| 343 | + } |
|
| 280 | 344 | } elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Police') { |
| 281 | - if ($compress) $output .= '"as": "police.png",'; |
|
| 282 | - else $output .= '"aircraft_shadow": "police.png",'; |
|
| 345 | + if ($compress) { |
|
| 346 | + $output .= '"as": "police.png",'; |
|
| 347 | + } else { |
|
| 348 | + $output .= '"aircraft_shadow": "police.png",'; |
|
| 349 | + } |
|
| 283 | 350 | } elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Yacht (Sail)') { |
| 284 | - if ($compress) $output .= '"as": "ship.png",'; |
|
| 285 | - else $output .= '"aircraft_shadow": "ship.png",'; |
|
| 351 | + if ($compress) { |
|
| 352 | + $output .= '"as": "ship.png",'; |
|
| 353 | + } else { |
|
| 354 | + $output .= '"aircraft_shadow": "ship.png",'; |
|
| 355 | + } |
|
| 286 | 356 | } elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Ship (Power Boat)') { |
| 287 | - if ($compress) $output .= '"as": "ship.png",'; |
|
| 288 | - else $output .= '"aircraft_shadow": "ship.png",'; |
|
| 357 | + if ($compress) { |
|
| 358 | + $output .= '"as": "ship.png",'; |
|
| 359 | + } else { |
|
| 360 | + $output .= '"aircraft_shadow": "ship.png",'; |
|
| 361 | + } |
|
| 289 | 362 | } elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Shuttle') { |
| 290 | - if ($compress) $output .= '"as": "ship.png",'; |
|
| 291 | - else $output .= '"aircraft_shadow": "ship.png",'; |
|
| 363 | + if ($compress) { |
|
| 364 | + $output .= '"as": "ship.png",'; |
|
| 365 | + } else { |
|
| 366 | + $output .= '"aircraft_shadow": "ship.png",'; |
|
| 367 | + } |
|
| 292 | 368 | } elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Truck') { |
| 293 | - if ($compress) $output .= '"as": "truck.png",'; |
|
| 294 | - else $output .= '"aircraft_shadow": "truck.png",'; |
|
| 369 | + if ($compress) { |
|
| 370 | + $output .= '"as": "truck.png",'; |
|
| 371 | + } else { |
|
| 372 | + $output .= '"aircraft_shadow": "truck.png",'; |
|
| 373 | + } |
|
| 295 | 374 | } elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Truck (18 Wheeler)') { |
| 296 | - if ($compress) $output .= '"as": "truck.png",'; |
|
| 297 | - else $output .= '"aircraft_shadow": "truck.png",'; |
|
| 375 | + if ($compress) { |
|
| 376 | + $output .= '"as": "truck.png",'; |
|
| 377 | + } else { |
|
| 378 | + $output .= '"aircraft_shadow": "truck.png",'; |
|
| 379 | + } |
|
| 298 | 380 | } elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Aircraft (small)') { |
| 299 | - if ($compress) $output .= '"as": "aircraft.png",'; |
|
| 300 | - else $output .= '"aircraft_shadow": "aircraft.png",'; |
|
| 381 | + if ($compress) { |
|
| 382 | + $output .= '"as": "aircraft.png",'; |
|
| 383 | + } else { |
|
| 384 | + $output .= '"aircraft_shadow": "aircraft.png",'; |
|
| 385 | + } |
|
| 301 | 386 | } elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Large Aircraft') { |
| 302 | - if ($compress) $output .= '"as": "aircraft.png",'; |
|
| 303 | - else $output .= '"aircraft_shadow": "aircraft.png",'; |
|
| 387 | + if ($compress) { |
|
| 388 | + $output .= '"as": "aircraft.png",'; |
|
| 389 | + } else { |
|
| 390 | + $output .= '"aircraft_shadow": "aircraft.png",'; |
|
| 391 | + } |
|
| 304 | 392 | } elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Helicopter') { |
| 305 | - if ($compress) $output .= '"as": "helico.png",'; |
|
| 306 | - else $output .= '"aircraft_shadow": "helico.png",'; |
|
| 393 | + if ($compress) { |
|
| 394 | + $output .= '"as": "helico.png",'; |
|
| 395 | + } else { |
|
| 396 | + $output .= '"aircraft_shadow": "helico.png",'; |
|
| 397 | + } |
|
| 307 | 398 | } elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Railroad Engine') { |
| 308 | - if ($compress) $output .= '"as": "rail.png",'; |
|
| 309 | - else $output .= '"aircraft_shadow": "rail.png",'; |
|
| 399 | + if ($compress) { |
|
| 400 | + $output .= '"as": "rail.png",'; |
|
| 401 | + } else { |
|
| 402 | + $output .= '"aircraft_shadow": "rail.png",'; |
|
| 403 | + } |
|
| 310 | 404 | } elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Firetruck') { |
| 311 | - if ($compress) $output .= '"as": "firetruck.png",'; |
|
| 312 | - else $output .= '"aircraft_shadow": "firetruck.png",'; |
|
| 405 | + if ($compress) { |
|
| 406 | + $output .= '"as": "firetruck.png",'; |
|
| 407 | + } else { |
|
| 408 | + $output .= '"aircraft_shadow": "firetruck.png",'; |
|
| 409 | + } |
|
| 313 | 410 | } elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Bus') { |
| 314 | - if ($compress) $output .= '"as": "bus.png",'; |
|
| 315 | - else $output .= '"aircraft_shadow": "bus.png",'; |
|
| 411 | + if ($compress) { |
|
| 412 | + $output .= '"as": "bus.png",'; |
|
| 413 | + } else { |
|
| 414 | + $output .= '"aircraft_shadow": "bus.png",'; |
|
| 415 | + } |
|
| 316 | 416 | } elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Phone') { |
| 317 | - if ($compress) $output .= '"as": "phone.png",'; |
|
| 318 | - else $output .= '"aircraft_shadow": "phone.png",'; |
|
| 417 | + if ($compress) { |
|
| 418 | + $output .= '"as": "phone.png",'; |
|
| 419 | + } else { |
|
| 420 | + $output .= '"aircraft_shadow": "phone.png",'; |
|
| 421 | + } |
|
| 319 | 422 | } elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Jogger') { |
| 320 | - if ($compress) $output .= '"as": "jogger.png",'; |
|
| 321 | - else $output .= '"aircraft_shadow": "jogger.png",'; |
|
| 423 | + if ($compress) { |
|
| 424 | + $output .= '"as": "jogger.png",'; |
|
| 425 | + } else { |
|
| 426 | + $output .= '"aircraft_shadow": "jogger.png",'; |
|
| 427 | + } |
|
| 322 | 428 | } elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Bike') { |
| 323 | - if ($compress) $output .= '"as": "bike.png",'; |
|
| 324 | - else $output .= '"aircraft_shadow": "bike.png",'; |
|
| 429 | + if ($compress) { |
|
| 430 | + $output .= '"as": "bike.png",'; |
|
| 431 | + } else { |
|
| 432 | + $output .= '"aircraft_shadow": "bike.png",'; |
|
| 433 | + } |
|
| 325 | 434 | } elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Motorcycle') { |
| 326 | - if ($compress) $output .= '"as": "motorcycle.png",'; |
|
| 327 | - else $output .= '"aircraft_shadow": "motorcycle.png",'; |
|
| 435 | + if ($compress) { |
|
| 436 | + $output .= '"as": "motorcycle.png",'; |
|
| 437 | + } else { |
|
| 438 | + $output .= '"aircraft_shadow": "motorcycle.png",'; |
|
| 439 | + } |
|
| 328 | 440 | } elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Balloon') { |
| 329 | - if ($compress) $output .= '"as": "balloon.png",'; |
|
| 330 | - else $output .= '"aircraft_shadow": "balloon.png",'; |
|
| 441 | + if ($compress) { |
|
| 442 | + $output .= '"as": "balloon.png",'; |
|
| 443 | + } else { |
|
| 444 | + $output .= '"aircraft_shadow": "balloon.png",'; |
|
| 445 | + } |
|
| 331 | 446 | } else { |
| 332 | - if ($compress) $output .= '"as": "car.png",'; |
|
| 333 | - else $output .= '"aircraft_shadow": "car.png",'; |
|
| 447 | + if ($compress) { |
|
| 448 | + $output .= '"as": "car.png",'; |
|
| 449 | + } else { |
|
| 450 | + $output .= '"aircraft_shadow": "car.png",'; |
|
| 451 | + } |
|
| 334 | 452 | } |
| 335 | 453 | } elseif ($marine) { |
| 336 | - if ($compress) $output .= '"as": "ship.png",'; |
|
| 337 | - else $output .= '"aircraft_shadow": "ship.png",'; |
|
| 454 | + if ($compress) { |
|
| 455 | + $output .= '"as": "ship.png",'; |
|
| 456 | + } else { |
|
| 457 | + $output .= '"aircraft_shadow": "ship.png",'; |
|
| 458 | + } |
|
| 338 | 459 | } else { |
| 339 | - if ($compress) $output .= '"as": "default.png",'; |
|
| 340 | - else $output .= '"aircraft_shadow": "default.png",'; |
|
| 460 | + if ($compress) { |
|
| 461 | + $output .= '"as": "default.png",'; |
|
| 462 | + } else { |
|
| 463 | + $output .= '"aircraft_shadow": "default.png",'; |
|
| 464 | + } |
|
| 341 | 465 | } |
| 342 | 466 | } else { |
| 343 | - if ($compress) $output .= '"as": "'.$spotter_item['aircraft_shadow'].'",'; |
|
| 344 | - else $output .= '"aircraft_shadow": "'.$spotter_item['aircraft_shadow'].'",'; |
|
| 467 | + if ($compress) { |
|
| 468 | + $output .= '"as": "'.$spotter_item['aircraft_shadow'].'",'; |
|
| 469 | + } else { |
|
| 470 | + $output .= '"aircraft_shadow": "'.$spotter_item['aircraft_shadow'].'",'; |
|
| 471 | + } |
|
| 345 | 472 | } |
| 346 | 473 | if (isset($spotter_item['airline_name'])) { |
| 347 | 474 | $output .= '"airline_name": "'.$spotter_item['airline_name'].'",'; |
@@ -349,8 +476,11 @@ discard block |
||
| 349 | 476 | $output .= '"airline_name": "NA",'; |
| 350 | 477 | } |
| 351 | 478 | if (isset($spotter_item['departure_airport'])) { |
| 352 | - if ($compress) $output .= '"dac": "'.$spotter_item['departure_airport'].'",'; |
|
| 353 | - else $output .= '"departure_airport_code": "'.$spotter_item['departure_airport'].'",'; |
|
| 479 | + if ($compress) { |
|
| 480 | + $output .= '"dac": "'.$spotter_item['departure_airport'].'",'; |
|
| 481 | + } else { |
|
| 482 | + $output .= '"departure_airport_code": "'.$spotter_item['departure_airport'].'",'; |
|
| 483 | + } |
|
| 354 | 484 | } |
| 355 | 485 | if (isset($spotter_item['departure_airport_city'])) { |
| 356 | 486 | $output .= '"departure_airport": "'.$spotter_item['departure_airport_city'].', '.$spotter_item['departure_airport_country'].'",'; |
@@ -362,8 +492,11 @@ discard block |
||
| 362 | 492 | $output .= '"arrival_airport_time": "'.$spotter_item['arrival_airport_time'].'",'; |
| 363 | 493 | } |
| 364 | 494 | if (isset($spotter_item['arrival_airport'])) { |
| 365 | - if ($compress) $output .= '"aac": "'.$spotter_item['arrival_airport'].'",'; |
|
| 366 | - else $output .= '"arrival_airport_code": "'.$spotter_item['arrival_airport'].'",'; |
|
| 495 | + if ($compress) { |
|
| 496 | + $output .= '"aac": "'.$spotter_item['arrival_airport'].'",'; |
|
| 497 | + } else { |
|
| 498 | + $output .= '"arrival_airport_code": "'.$spotter_item['arrival_airport'].'",'; |
|
| 499 | + } |
|
| 367 | 500 | } |
| 368 | 501 | if (isset($spotter_item['arrival_airport_city'])) { |
| 369 | 502 | $output .= '"arrival_airport": "'.$spotter_item['arrival_airport_city'].', '.$spotter_item['arrival_airport_country'].'",'; |
@@ -382,11 +515,17 @@ discard block |
||
| 382 | 515 | } |
| 383 | 516 | |
| 384 | 517 | if (isset($spotter_item['altitude'])) { |
| 385 | - if ($compress) $output .= '"a": "'.$spotter_item['altitude'].'",'; |
|
| 386 | - else $output .= '"altitude": "'.$spotter_item['altitude'].'",'; |
|
| 518 | + if ($compress) { |
|
| 519 | + $output .= '"a": "'.$spotter_item['altitude'].'",'; |
|
| 520 | + } else { |
|
| 521 | + $output .= '"altitude": "'.$spotter_item['altitude'].'",'; |
|
| 522 | + } |
|
| 523 | + } |
|
| 524 | + if ($compress) { |
|
| 525 | + $output .= '"h": "'.$spotter_item['heading'].'",'; |
|
| 526 | + } else { |
|
| 527 | + $output .= '"heading": "'.$spotter_item['heading'].'",'; |
|
| 387 | 528 | } |
| 388 | - if ($compress)$output .= '"h": "'.$spotter_item['heading'].'",'; |
|
| 389 | - else $output .= '"heading": "'.$spotter_item['heading'].'",'; |
|
| 390 | 529 | |
| 391 | 530 | if (isset($archivespeed)) { |
| 392 | 531 | $nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$spotter_item['heading'],$archivespeed); |
@@ -396,7 +535,9 @@ discard block |
||
| 396 | 535 | $output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],'; |
| 397 | 536 | } |
| 398 | 537 | |
| 399 | - if (!$min) $output .= '"image": "'.$image.'",'; |
|
| 538 | + if (!$min) { |
|
| 539 | + $output .= '"image": "'.$image.'",'; |
|
| 540 | + } |
|
| 400 | 541 | if (isset($spotter_item['image_copyright']) && $spotter_item['image_copyright'] != '') { |
| 401 | 542 | $output .= '"image_copyright": "'.str_replace('"',"'",trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$spotter_item['image_copyright']))).'",'; |
| 402 | 543 | } |
@@ -404,8 +545,11 @@ discard block |
||
| 404 | 545 | $output .= '"image_source_website": "'.urlencode($spotter_item['image_source_website']).'",'; |
| 405 | 546 | } |
| 406 | 547 | if (isset($spotter_item['squawk'])) { |
| 407 | - if ($compress) $output .= '"sq": "'.$spotter_item['squawk'].'",'; |
|
| 408 | - else $output .= '"squawk": "'.$spotter_item['squawk'].'",'; |
|
| 548 | + if ($compress) { |
|
| 549 | + $output .= '"sq": "'.$spotter_item['squawk'].'",'; |
|
| 550 | + } else { |
|
| 551 | + $output .= '"squawk": "'.$spotter_item['squawk'].'",'; |
|
| 552 | + } |
|
| 409 | 553 | } |
| 410 | 554 | if (isset($spotter_item['squawk_usage'])) { |
| 411 | 555 | $output .= '"squawk_usage": "'.$spotter_item['squawk_usage'].'",'; |
@@ -424,14 +568,23 @@ discard block |
||
| 424 | 568 | } |
| 425 | 569 | // type when not aircraft ? |
| 426 | 570 | if (isset($spotter_item['type'])) { |
| 427 | - if ($compress) $output .= '"t": "'.$spotter_item['type'].'"'; |
|
| 428 | - else $output .= '"type": "'.$spotter_item['type'].'"'; |
|
| 571 | + if ($compress) { |
|
| 572 | + $output .= '"t": "'.$spotter_item['type'].'"'; |
|
| 573 | + } else { |
|
| 574 | + $output .= '"type": "'.$spotter_item['type'].'"'; |
|
| 575 | + } |
|
| 429 | 576 | } elseif ($marine) { |
| 430 | - if ($compress) $output .= '"t": "ship"'; |
|
| 431 | - else $output .= '"type": "ship"'; |
|
| 577 | + if ($compress) { |
|
| 578 | + $output .= '"t": "ship"'; |
|
| 579 | + } else { |
|
| 580 | + $output .= '"type": "ship"'; |
|
| 581 | + } |
|
| 432 | 582 | } else { |
| 433 | - if ($compress) $output .= '"t": "aircraft"'; |
|
| 434 | - else $output .= '"type": "aircraft"'; |
|
| 583 | + if ($compress) { |
|
| 584 | + $output .= '"t": "aircraft"'; |
|
| 585 | + } else { |
|
| 586 | + $output .= '"type": "aircraft"'; |
|
| 587 | + } |
|
| 435 | 588 | } |
| 436 | 589 | $output .= '},'; |
| 437 | 590 | $output .= '"geometry": {'; |
@@ -499,7 +652,9 @@ discard block |
||
| 499 | 652 | } |
| 500 | 653 | */ |
| 501 | 654 | $history = filter_input(INPUT_GET,'history',FILTER_SANITIZE_STRING); |
| 502 | - if ($history == '' && isset($_COOKIE['history'])) $history = $_COOKIE['history']; |
|
| 655 | + if ($history == '' && isset($_COOKIE['history'])) { |
|
| 656 | + $history = $_COOKIE['history']; |
|
| 657 | + } |
|
| 503 | 658 | |
| 504 | 659 | if ( |
| 505 | 660 | (isset($_COOKIE['flightpath']) && $_COOKIE['flightpath'] == 'true') |
@@ -543,8 +698,11 @@ discard block |
||
| 543 | 698 | $output_history .= ']}},'; |
| 544 | 699 | $output .= $output_history; |
| 545 | 700 | } |
| 546 | - if ($compress) $output_history = '{"type": "Feature","properties": {"c": "'.$spotter_item['ident'].'","t": "history","a": "'.$alt.'"},"geometry": {"type": "LineString","coordinates": ['; |
|
| 547 | - else $output_history = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "history","altitude": "'.$alt.'"},"geometry": {"type": "LineString","coordinates": ['; |
|
| 701 | + if ($compress) { |
|
| 702 | + $output_history = '{"type": "Feature","properties": {"c": "'.$spotter_item['ident'].'","t": "history","a": "'.$alt.'"},"geometry": {"type": "LineString","coordinates": ['; |
|
| 703 | + } else { |
|
| 704 | + $output_history = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "history","altitude": "'.$alt.'"},"geometry": {"type": "LineString","coordinates": ['; |
|
| 705 | + } |
|
| 548 | 706 | } |
| 549 | 707 | $output_history .= '['; |
| 550 | 708 | $output_history .= $spotter_history['longitude'].', '; |
@@ -563,9 +721,14 @@ discard block |
||
| 563 | 721 | $prev_alt = $alt; |
| 564 | 722 | } else { |
| 565 | 723 | if ($d == false) { |
| 566 | - if ($compress) $output_history = '{"type": "Feature","properties": {"c": "'.$spotter_item['ident'].'","t": "history"},"geometry": {"type": "LineString","coordinates": ['; |
|
| 567 | - else $output_history = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "history"},"geometry": {"type": "LineString","coordinates": ['; |
|
| 568 | - } else $d = true; |
|
| 724 | + if ($compress) { |
|
| 725 | + $output_history = '{"type": "Feature","properties": {"c": "'.$spotter_item['ident'].'","t": "history"},"geometry": {"type": "LineString","coordinates": ['; |
|
| 726 | + } else { |
|
| 727 | + $output_history = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "history"},"geometry": {"type": "LineString","coordinates": ['; |
|
| 728 | + } |
|
| 729 | + } else { |
|
| 730 | + $d = true; |
|
| 731 | + } |
|
| 569 | 732 | $output_history .= '['; |
| 570 | 733 | $output_history .= $spotter_history['longitude'].', '; |
| 571 | 734 | $output_history .= $spotter_history['latitude']; |
@@ -586,7 +749,9 @@ discard block |
||
| 586 | 749 | $output_historyd = '['; |
| 587 | 750 | $output_historyd .= $spotter_item['longitude'].', '; |
| 588 | 751 | $output_historyd .= $spotter_item['latitude']; |
| 589 | - if (isset($spotter_history['altitude'])) $output_historyd .= ','.$spotter_item['altitude']*30.48; |
|
| 752 | + if (isset($spotter_history['altitude'])) { |
|
| 753 | + $output_historyd .= ','.$spotter_item['altitude']*30.48; |
|
| 754 | + } |
|
| 590 | 755 | $output_historyd .= '],'; |
| 591 | 756 | //$output_history = $output_historyd.$output_history; |
| 592 | 757 | $output_history = $output_history.$output_historyd; |
@@ -608,8 +773,11 @@ discard block |
||
| 608 | 773 | && $spotter_item['arrival_airport'] != 'NA' |
| 609 | 774 | && ((isset($_COOKIE['MapRoute']) && $_COOKIE['MapRoute'] == "true") |
| 610 | 775 | || (!isset($_COOKIE['MapRoute']) && isset($globalMapRoute) && $globalMapRoute)))) { |
| 611 | - if ($compress) $output_air = '{"type": "Feature","properties": {"c": "'.$spotter_item['ident'].'","t": "route"},"geometry": {"type": "LineString","coordinates": ['; |
|
| 612 | - else $output_air = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "route"},"geometry": {"type": "LineString","coordinates": ['; |
|
| 776 | + if ($compress) { |
|
| 777 | + $output_air = '{"type": "Feature","properties": {"c": "'.$spotter_item['ident'].'","t": "route"},"geometry": {"type": "LineString","coordinates": ['; |
|
| 778 | + } else { |
|
| 779 | + $output_air = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "route"},"geometry": {"type": "LineString","coordinates": ['; |
|
| 780 | + } |
|
| 613 | 781 | if (isset($spotter_item['departure_airport_latitude'])) { |
| 614 | 782 | $output_air .= '['.$spotter_item['departure_airport_longitude'].','.$spotter_item['departure_airport_latitude'].'],'; |
| 615 | 783 | } elseif (isset($spotter_item['departure_airport']) && $spotter_item['departure_airport'] != 'NA') { |
@@ -642,8 +810,11 @@ discard block |
||
| 642 | 810 | || (!isset($_COOKIE['MapRemainaingRoute']) && (!isset($globalMapRemainingRoute) |
| 643 | 811 | || (isset($globalMapRemainingRoute) && $globalMapRemainingRoute)))))) { |
| 644 | 812 | $havedata = false; |
| 645 | - if ($compress) $output_dest = '{"type": "Feature","properties": {"c": "'.$spotter_item['ident'].'","t": "routedest"},"geometry": {"type": "LineString","coordinates": ['; |
|
| 646 | - else $output_dest = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "routedest"},"geometry": {"type": "LineString","coordinates": ['; |
|
| 813 | + if ($compress) { |
|
| 814 | + $output_dest = '{"type": "Feature","properties": {"c": "'.$spotter_item['ident'].'","t": "routedest"},"geometry": {"type": "LineString","coordinates": ['; |
|
| 815 | + } else { |
|
| 816 | + $output_dest = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "routedest"},"geometry": {"type": "LineString","coordinates": ['; |
|
| 817 | + } |
|
| 647 | 818 | $output_dest .= '['.$spotter_item['longitude'].','.$spotter_item['latitude'].'],'; |
| 648 | 819 | |
| 649 | 820 | if (isset($spotter_item['arrival_airport_latitude'])) { |
@@ -658,7 +829,9 @@ discard block |
||
| 658 | 829 | } |
| 659 | 830 | //$output_dest = substr($output_dest, 0, -1); |
| 660 | 831 | $output_dest .= ']}},'; |
| 661 | - if ($havedata) $output .= $output_dest; |
|
| 832 | + if ($havedata) { |
|
| 833 | + $output .= $output_dest; |
|
| 834 | + } |
|
| 662 | 835 | unset($output_dest); |
| 663 | 836 | } |
| 664 | 837 | } |
@@ -666,7 +839,9 @@ discard block |
||
| 666 | 839 | $output .= ']'; |
| 667 | 840 | $output .= ',"initial_sqltime": "'.$sqltime.'",'; |
| 668 | 841 | $output .= '"totaltime": "'.round(microtime(true)-$begintime,2).'",'; |
| 669 | - if (isset($begindate)) $output .= '"archive_date": "'.$begindate.'",'; |
|
| 842 | + if (isset($begindate)) { |
|
| 843 | + $output .= '"archive_date": "'.$begindate.'",'; |
|
| 844 | + } |
|
| 670 | 845 | $output .= '"fc": "'.$j.'"'; |
| 671 | 846 | } else { |
| 672 | 847 | $output .= '"features": '; |
@@ -85,38 +85,38 @@ discard block |
||
| 85 | 85 | try { |
| 86 | 86 | //$Connection = new Connection(); |
| 87 | 87 | $sth = $Connection->db->prepare($query); |
| 88 | - $sth->execute(array(':source' => $database_file)); |
|
| 89 | - } catch(PDOException $e) { |
|
| 90 | - return "error : ".$e->getMessage(); |
|
| 91 | - } |
|
| 88 | + $sth->execute(array(':source' => $database_file)); |
|
| 89 | + } catch(PDOException $e) { |
|
| 90 | + return "error : ".$e->getMessage(); |
|
| 91 | + } |
|
| 92 | 92 | |
| 93 | - if ($globalDebug) echo " - Add routes to DB -"; |
|
| 94 | - update_db::connect_sqlite($database_file); |
|
| 93 | + if ($globalDebug) echo " - Add routes to DB -"; |
|
| 94 | + update_db::connect_sqlite($database_file); |
|
| 95 | 95 | //$query = 'select Route.RouteID, Route.callsign, operator.Icao AS operator_icao, FromAir.Icao AS FromAirportIcao, ToAir.Icao AS ToAirportIcao from Route inner join operator ON Route.operatorId = operator.operatorId LEFT JOIN Airport AS FromAir ON route.FromAirportId = FromAir.AirportId LEFT JOIN Airport AS ToAir ON ToAir.AirportID = route.ToAirportID'; |
| 96 | 96 | $query = "select Route.RouteID, Route.callsign, operator.Icao AS operator_icao, FromAir.Icao AS FromAirportIcao, ToAir.Icao AS ToAirportIcao, rstp.allstop AS AllStop from Route inner join operator ON Route.operatorId = operator.operatorId LEFT JOIN Airport AS FromAir ON route.FromAirportId = FromAir.AirportId LEFT JOIN Airport AS ToAir ON ToAir.AirportID = route.ToAirportID LEFT JOIN (select RouteId,GROUP_CONCAT(icao,' ') as allstop from routestop left join Airport as air ON routestop.AirportId = air.AirportID group by RouteID) AS rstp ON Route.RouteID = rstp.RouteID"; |
| 97 | 97 | try { |
| 98 | - $sth = update_db::$db_sqlite->prepare($query); |
|
| 99 | - $sth->execute(); |
|
| 100 | - } catch(PDOException $e) { |
|
| 101 | - return "error : ".$e->getMessage(); |
|
| 102 | - } |
|
| 98 | + $sth = update_db::$db_sqlite->prepare($query); |
|
| 99 | + $sth->execute(); |
|
| 100 | + } catch(PDOException $e) { |
|
| 101 | + return "error : ".$e->getMessage(); |
|
| 102 | + } |
|
| 103 | 103 | //$query_dest = 'INSERT INTO routes (`RouteID`,`CallSign`,`Operator_ICAO`,`FromAirport_ICAO`,`ToAirport_ICAO`,`RouteStop`,`Source`) VALUES (:RouteID, :CallSign, :Operator_ICAO, :FromAirport_ICAO, :ToAirport_ICAO, :routestop, :source)'; |
| 104 | 104 | $query_dest = 'INSERT INTO routes (CallSign,Operator_ICAO,FromAirport_ICAO,ToAirport_ICAO,RouteStop,Source) VALUES (:CallSign, :Operator_ICAO, :FromAirport_ICAO, :ToAirport_ICAO, :routestop, :source)'; |
| 105 | 105 | $Connection = new Connection(); |
| 106 | 106 | $sth_dest = $Connection->db->prepare($query_dest); |
| 107 | 107 | try { |
| 108 | 108 | if ($globalTransaction) $Connection->db->beginTransaction(); |
| 109 | - while ($values = $sth->fetch(PDO::FETCH_ASSOC)) { |
|
| 109 | + while ($values = $sth->fetch(PDO::FETCH_ASSOC)) { |
|
| 110 | 110 | //$query_dest_values = array(':RouteID' => $values['RouteId'],':CallSign' => $values['Callsign'],':Operator_ICAO' => $values['operator_icao'],':FromAirport_ICAO' => $values['FromAirportIcao'],':ToAirport_ICAO' => $values['ToAirportIcao'],':routestop' => $values['AllStop'],':source' => $database_file); |
| 111 | 111 | $query_dest_values = array(':CallSign' => $values['Callsign'],':Operator_ICAO' => $values['operator_icao'],':FromAirport_ICAO' => $values['FromAirportIcao'],':ToAirport_ICAO' => $values['ToAirportIcao'],':routestop' => $values['AllStop'],':source' => $database_file); |
| 112 | 112 | $sth_dest->execute($query_dest_values); |
| 113 | - } |
|
| 113 | + } |
|
| 114 | 114 | if ($globalTransaction) $Connection->db->commit(); |
| 115 | 115 | } catch(PDOException $e) { |
| 116 | 116 | if ($globalTransaction) $Connection->db->rollBack(); |
| 117 | 117 | return "error : ".$e->getMessage(); |
| 118 | 118 | } |
| 119 | - return ''; |
|
| 119 | + return ''; |
|
| 120 | 120 | } |
| 121 | 121 | public static function retrieve_route_oneworld($database_file) { |
| 122 | 122 | global $globalDebug, $globalTransaction; |
@@ -127,12 +127,12 @@ discard block |
||
| 127 | 127 | try { |
| 128 | 128 | //$Connection = new Connection(); |
| 129 | 129 | $sth = $Connection->db->prepare($query); |
| 130 | - $sth->execute(array(':source' => 'oneworld')); |
|
| 131 | - } catch(PDOException $e) { |
|
| 132 | - return "error : ".$e->getMessage(); |
|
| 133 | - } |
|
| 130 | + $sth->execute(array(':source' => 'oneworld')); |
|
| 131 | + } catch(PDOException $e) { |
|
| 132 | + return "error : ".$e->getMessage(); |
|
| 133 | + } |
|
| 134 | 134 | |
| 135 | - if ($globalDebug) echo " - Add routes to DB -"; |
|
| 135 | + if ($globalDebug) echo " - Add routes to DB -"; |
|
| 136 | 136 | require_once(dirname(__FILE__).'/../require/class.Spotter.php'); |
| 137 | 137 | $Spotter = new Spotter(); |
| 138 | 138 | if ($fh = fopen($database_file,"r")) { |
@@ -156,7 +156,7 @@ discard block |
||
| 156 | 156 | } |
| 157 | 157 | if ($globalTransaction) $Connection->db->commit(); |
| 158 | 158 | } |
| 159 | - return ''; |
|
| 159 | + return ''; |
|
| 160 | 160 | } |
| 161 | 161 | |
| 162 | 162 | public static function retrieve_route_skyteam($database_file) { |
@@ -168,12 +168,12 @@ discard block |
||
| 168 | 168 | try { |
| 169 | 169 | //$Connection = new Connection(); |
| 170 | 170 | $sth = $Connection->db->prepare($query); |
| 171 | - $sth->execute(array(':source' => 'skyteam')); |
|
| 172 | - } catch(PDOException $e) { |
|
| 173 | - return "error : ".$e->getMessage(); |
|
| 174 | - } |
|
| 171 | + $sth->execute(array(':source' => 'skyteam')); |
|
| 172 | + } catch(PDOException $e) { |
|
| 173 | + return "error : ".$e->getMessage(); |
|
| 174 | + } |
|
| 175 | 175 | |
| 176 | - if ($globalDebug) echo " - Add routes to DB -"; |
|
| 176 | + if ($globalDebug) echo " - Add routes to DB -"; |
|
| 177 | 177 | |
| 178 | 178 | require_once(dirname(__FILE__).'/../require/class.Spotter.php'); |
| 179 | 179 | $Spotter = new Spotter(); |
@@ -199,7 +199,7 @@ discard block |
||
| 199 | 199 | return "error : ".$e->getMessage(); |
| 200 | 200 | } |
| 201 | 201 | } |
| 202 | - return ''; |
|
| 202 | + return ''; |
|
| 203 | 203 | } |
| 204 | 204 | public static function retrieve_modes_sqlite_to_dest($database_file) { |
| 205 | 205 | global $globalTransaction; |
@@ -208,27 +208,27 @@ discard block |
||
| 208 | 208 | try { |
| 209 | 209 | $Connection = new Connection(); |
| 210 | 210 | $sth = $Connection->db->prepare($query); |
| 211 | - $sth->execute(array(':source' => $database_file)); |
|
| 212 | - } catch(PDOException $e) { |
|
| 213 | - return "error : ".$e->getMessage(); |
|
| 214 | - } |
|
| 211 | + $sth->execute(array(':source' => $database_file)); |
|
| 212 | + } catch(PDOException $e) { |
|
| 213 | + return "error : ".$e->getMessage(); |
|
| 214 | + } |
|
| 215 | 215 | $query = "DELETE FROM aircraft_owner WHERE Source = '' OR Source IS NULL OR Source = :source"; |
| 216 | 216 | try { |
| 217 | 217 | $Connection = new Connection(); |
| 218 | 218 | $sth = $Connection->db->prepare($query); |
| 219 | - $sth->execute(array(':source' => $database_file)); |
|
| 220 | - } catch(PDOException $e) { |
|
| 221 | - return "error : ".$e->getMessage(); |
|
| 222 | - } |
|
| 219 | + $sth->execute(array(':source' => $database_file)); |
|
| 220 | + } catch(PDOException $e) { |
|
| 221 | + return "error : ".$e->getMessage(); |
|
| 222 | + } |
|
| 223 | 223 | |
| 224 | - update_db::connect_sqlite($database_file); |
|
| 224 | + update_db::connect_sqlite($database_file); |
|
| 225 | 225 | $query = 'select * from Aircraft'; |
| 226 | 226 | try { |
| 227 | - $sth = update_db::$db_sqlite->prepare($query); |
|
| 228 | - $sth->execute(); |
|
| 229 | - } catch(PDOException $e) { |
|
| 230 | - return "error : ".$e->getMessage(); |
|
| 231 | - } |
|
| 227 | + $sth = update_db::$db_sqlite->prepare($query); |
|
| 228 | + $sth->execute(); |
|
| 229 | + } catch(PDOException $e) { |
|
| 230 | + return "error : ".$e->getMessage(); |
|
| 231 | + } |
|
| 232 | 232 | //$query_dest = 'INSERT INTO aircraft_modes (`AircraftID`,`FirstCreated`,`LastModified`, `ModeS`,`ModeSCountry`,`Registration`,`ICAOTypeCode`,`SerialNo`, `OperatorFlagCode`, `Manufacturer`, `Type`, `FirstRegDate`, `CurrentRegDate`, `Country`, `PreviousID`, `DeRegDate`, `Status`, `PopularName`,`GenericName`,`AircraftClass`, `Engines`, `OwnershipStatus`,`RegisteredOwners`,`MTOW`, `TotalHours`, `YearBuilt`, `CofACategory`, `CofAExpiry`, `UserNotes`, `Interested`, `UserTag`, `InfoUrl`, `PictureUrl1`, `PictureUrl2`, `PictureUrl3`, `UserBool1`, `UserBool2`, `UserBool3`, `UserBool4`, `UserBool5`, `UserString1`, `UserString2`, `UserString3`, `UserString4`, `UserString5`, `UserInt1`, `UserInt2`, `UserInt3`, `UserInt4`, `UserInt5`) VALUES (:AircraftID,:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:SerialNo, :OperatorFlagCode, :Manufacturer, :Type, :FirstRegDate, :CurrentRegDate, :Country, :PreviousID, :DeRegDate, :Status, :PopularName,:GenericName,:AircraftClass, :Engines, :OwnershipStatus,:RegisteredOwners,:MTOW, :TotalHours,:YearBuilt, :CofACategory, :CofAExpiry, :UserNotes, :Interested, :UserTag, :InfoUrl, :PictureUrl1, :PictureUrl2, :PictureUrl3, :UserBool1, :UserBool2, :UserBool3, :UserBool4, :UserBool5, :UserString1, :UserString2, :UserString3, :UserString4, :UserString5, :UserInt1, :UserInt2, :UserInt3, :UserInt4, :UserInt5)'; |
| 233 | 233 | $query_dest = 'INSERT INTO aircraft_modes (LastModified, ModeS,ModeSCountry,Registration,ICAOTypeCode,type_flight,Source) VALUES (:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:type,:source)'; |
| 234 | 234 | |
@@ -239,17 +239,17 @@ discard block |
||
| 239 | 239 | $sth_dest_owner = $Connection->db->prepare($query_dest_owner); |
| 240 | 240 | try { |
| 241 | 241 | if ($globalTransaction) $Connection->db->beginTransaction(); |
| 242 | - while ($values = $sth->fetch(PDO::FETCH_ASSOC)) { |
|
| 242 | + while ($values = $sth->fetch(PDO::FETCH_ASSOC)) { |
|
| 243 | 243 | //$query_dest_values = array(':AircraftID' => $values['AircraftID'],':FirstCreated' => $values['FirstCreated'],':LastModified' => $values['LastModified'],':ModeS' => $values['ModeS'],':ModeSCountry' => $values['ModeSCountry'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':SerialNo' => $values['SerialNo'], ':OperatorFlagCode' => $values['OperatorFlagCode'], ':Manufacturer' => $values['Manufacturer'], ':Type' => $values['Type'], ':FirstRegDate' => $values['FirstRegDate'], ':CurrentRegDate' => $values['CurrentRegDate'], ':Country' => $values['Country'], ':PreviousID' => $values['PreviousID'], ':DeRegDate' => $values['DeRegDate'], ':Status' => $values['Status'], ':PopularName' => $values['PopularName'],':GenericName' => $values['GenericName'],':AircraftClass' => $values['AircraftClass'], ':Engines' => $values['Engines'], ':OwnershipStatus' => $values['OwnershipStatus'],':RegisteredOwners' => $values['RegisteredOwners'],':MTOW' => $values['MTOW'], ':TotalHours' => $values['TotalHours'],':YearBuilt' => $values['YearBuilt'], ':CofACategory' => $values['CofACategory'], ':CofAExpiry' => $values['CofAExpiry'], ':UserNotes' => $values['UserNotes'], ':Interested' => $values['Interested'], ':UserTag' => $values['UserTag'], ':InfoUrl' => $values['InfoURL'], ':PictureUrl1' => $values['PictureURL1'], ':PictureUrl2' => $values['PictureURL2'], ':PictureUrl3' => $values['PictureURL3'], ':UserBool1' => $values['UserBool1'], ':UserBool2' => $values['UserBool2'], ':UserBool3' => $values['UserBool3'], ':UserBool4' => $values['UserBool4'], ':UserBool5' => $values['UserBool5'], ':UserString1' => $values['UserString1'], ':UserString2' => $values['UserString2'], ':UserString3' => $values['UserString3'], ':UserString4' => $values['UserString4'], ':UserString5' => $values['UserString5'], ':UserInt1' => $values['UserInt1'], ':UserInt2' => $values['UserInt2'], ':UserInt3' => $values['UserInt3'], ':UserInt4' => $values['UserInt4'], ':UserInt5' => $values['UserInt5']); |
| 244 | 244 | if ($values['UserString4'] == 'M') $type = 'military'; |
| 245 | 245 | else $type = null; |
| 246 | 246 | $query_dest_values = array(':LastModified' => $values['LastModified'],':ModeS' => $values['ModeS'],':ModeSCountry' => $values['ModeSCountry'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':source' => $database_file,':type' => $type); |
| 247 | 247 | $sth_dest->execute($query_dest_values); |
| 248 | 248 | if ($values['RegisteredOwners'] != '' && $values['RegisteredOwners'] != NULL && $values['RegisteredOwners'] != 'Private') { |
| 249 | - $query_dest_owner_values = array(':registration' => $values['Registration'],':source' => $database_file,':owner' => $values['RegisteredOwners']); |
|
| 250 | - $sth_dest_owner->execute($query_dest_owner_values); |
|
| 249 | + $query_dest_owner_values = array(':registration' => $values['Registration'],':source' => $database_file,':owner' => $values['RegisteredOwners']); |
|
| 250 | + $sth_dest_owner->execute($query_dest_owner_values); |
|
| 251 | 251 | } |
| 252 | - } |
|
| 252 | + } |
|
| 253 | 253 | if ($globalTransaction) $Connection->db->commit(); |
| 254 | 254 | } catch(PDOException $e) { |
| 255 | 255 | return "error : ".$e->getMessage(); |
@@ -260,10 +260,10 @@ discard block |
||
| 260 | 260 | try { |
| 261 | 261 | $Connection = new Connection(); |
| 262 | 262 | $sth = $Connection->db->prepare($query); |
| 263 | - $sth->execute(array(':source' => $database_file)); |
|
| 264 | - } catch(PDOException $e) { |
|
| 265 | - return "error : ".$e->getMessage(); |
|
| 266 | - } |
|
| 263 | + $sth->execute(array(':source' => $database_file)); |
|
| 264 | + } catch(PDOException $e) { |
|
| 265 | + return "error : ".$e->getMessage(); |
|
| 266 | + } |
|
| 267 | 267 | return ''; |
| 268 | 268 | } |
| 269 | 269 | |
@@ -275,10 +275,10 @@ discard block |
||
| 275 | 275 | try { |
| 276 | 276 | $Connection = new Connection(); |
| 277 | 277 | $sth = $Connection->db->prepare($query); |
| 278 | - $sth->execute(array(':source' => $database_file)); |
|
| 279 | - } catch(PDOException $e) { |
|
| 280 | - return "error : ".$e->getMessage(); |
|
| 281 | - } |
|
| 278 | + $sth->execute(array(':source' => $database_file)); |
|
| 279 | + } catch(PDOException $e) { |
|
| 280 | + return "error : ".$e->getMessage(); |
|
| 281 | + } |
|
| 282 | 282 | |
| 283 | 283 | if ($fh = fopen($database_file,"r")) { |
| 284 | 284 | //$query_dest = 'INSERT INTO aircraft_modes (`AircraftID`,`FirstCreated`,`LastModified`, `ModeS`,`ModeSCountry`,`Registration`,`ICAOTypeCode`,`SerialNo`, `OperatorFlagCode`, `Manufacturer`, `Type`, `FirstRegDate`, `CurrentRegDate`, `Country`, `PreviousID`, `DeRegDate`, `Status`, `PopularName`,`GenericName`,`AircraftClass`, `Engines`, `OwnershipStatus`,`RegisteredOwners`,`MTOW`, `TotalHours`, `YearBuilt`, `CofACategory`, `CofAExpiry`, `UserNotes`, `Interested`, `UserTag`, `InfoUrl`, `PictureUrl1`, `PictureUrl2`, `PictureUrl3`, `UserBool1`, `UserBool2`, `UserBool3`, `UserBool4`, `UserBool5`, `UserString1`, `UserString2`, `UserString3`, `UserString4`, `UserString5`, `UserInt1`, `UserInt2`, `UserInt3`, `UserInt4`, `UserInt5`) VALUES (:AircraftID,:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:SerialNo, :OperatorFlagCode, :Manufacturer, :Type, :FirstRegDate, :CurrentRegDate, :Country, :PreviousID, :DeRegDate, :Status, :PopularName,:GenericName,:AircraftClass, :Engines, :OwnershipStatus,:RegisteredOwners,:MTOW, :TotalHours,:YearBuilt, :CofACategory, :CofAExpiry, :UserNotes, :Interested, :UserTag, :InfoUrl, :PictureUrl1, :PictureUrl2, :PictureUrl3, :UserBool1, :UserBool2, :UserBool3, :UserBool4, :UserBool5, :UserString1, :UserString2, :UserString3, :UserString4, :UserString5, :UserInt1, :UserInt2, :UserInt3, :UserInt4, :UserInt5)'; |
@@ -288,26 +288,26 @@ discard block |
||
| 288 | 288 | $sth_dest = $Connection->db->prepare($query_dest); |
| 289 | 289 | try { |
| 290 | 290 | if ($globalTransaction) $Connection->db->beginTransaction(); |
| 291 | - while (!feof($fh)) { |
|
| 292 | - $values = array(); |
|
| 293 | - $line = $Common->hex2str(fgets($fh,9999)); |
|
| 291 | + while (!feof($fh)) { |
|
| 292 | + $values = array(); |
|
| 293 | + $line = $Common->hex2str(fgets($fh,9999)); |
|
| 294 | 294 | //FFFFFF RIDEAU VALLEY SOARINGASW-20 C-FBKN MZ 123.400 |
| 295 | - $values['ModeS'] = substr($line,0,6); |
|
| 296 | - $values['Registration'] = trim(substr($line,69,6)); |
|
| 297 | - $aircraft_name = trim(substr($line,48,6)); |
|
| 298 | - // Check if we can find ICAO, else set it to GLID |
|
| 299 | - $aircraft_name_split = explode(' ',$aircraft_name); |
|
| 300 | - $search_more = ''; |
|
| 301 | - if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'"; |
|
| 302 | - $query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more; |
|
| 303 | - $sth_search = $Connection->db->prepare($query_search); |
|
| 295 | + $values['ModeS'] = substr($line,0,6); |
|
| 296 | + $values['Registration'] = trim(substr($line,69,6)); |
|
| 297 | + $aircraft_name = trim(substr($line,48,6)); |
|
| 298 | + // Check if we can find ICAO, else set it to GLID |
|
| 299 | + $aircraft_name_split = explode(' ',$aircraft_name); |
|
| 300 | + $search_more = ''; |
|
| 301 | + if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'"; |
|
| 302 | + $query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more; |
|
| 303 | + $sth_search = $Connection->db->prepare($query_search); |
|
| 304 | 304 | try { |
| 305 | - $sth_search->execute(); |
|
| 306 | - $result = $sth_search->fetch(PDO::FETCH_ASSOC); |
|
| 307 | - //if (count($result) > 0) { |
|
| 308 | - if (isset($result['icao']) && $result['icao'] != '') { |
|
| 309 | - $values['ICAOTypeCode'] = $result['icao']; |
|
| 310 | - } |
|
| 305 | + $sth_search->execute(); |
|
| 306 | + $result = $sth_search->fetch(PDO::FETCH_ASSOC); |
|
| 307 | + //if (count($result) > 0) { |
|
| 308 | + if (isset($result['icao']) && $result['icao'] != '') { |
|
| 309 | + $values['ICAOTypeCode'] = $result['icao']; |
|
| 310 | + } |
|
| 311 | 311 | } catch(PDOException $e) { |
| 312 | 312 | return "error : ".$e->getMessage(); |
| 313 | 313 | } |
@@ -330,10 +330,10 @@ discard block |
||
| 330 | 330 | try { |
| 331 | 331 | $Connection = new Connection(); |
| 332 | 332 | $sth = $Connection->db->prepare($query); |
| 333 | - $sth->execute(array(':source' => $database_file)); |
|
| 334 | - } catch(PDOException $e) { |
|
| 335 | - return "error : ".$e->getMessage(); |
|
| 336 | - } |
|
| 333 | + $sth->execute(array(':source' => $database_file)); |
|
| 334 | + } catch(PDOException $e) { |
|
| 335 | + return "error : ".$e->getMessage(); |
|
| 336 | + } |
|
| 337 | 337 | return ''; |
| 338 | 338 | } |
| 339 | 339 | |
@@ -344,10 +344,10 @@ discard block |
||
| 344 | 344 | try { |
| 345 | 345 | $Connection = new Connection(); |
| 346 | 346 | $sth = $Connection->db->prepare($query); |
| 347 | - $sth->execute(array(':source' => $database_file)); |
|
| 348 | - } catch(PDOException $e) { |
|
| 349 | - return "error : ".$e->getMessage(); |
|
| 350 | - } |
|
| 347 | + $sth->execute(array(':source' => $database_file)); |
|
| 348 | + } catch(PDOException $e) { |
|
| 349 | + return "error : ".$e->getMessage(); |
|
| 350 | + } |
|
| 351 | 351 | |
| 352 | 352 | if ($fh = fopen($database_file,"r")) { |
| 353 | 353 | //$query_dest = 'INSERT INTO aircraft_modes (`AircraftID`,`FirstCreated`,`LastModified`, `ModeS`,`ModeSCountry`,`Registration`,`ICAOTypeCode`,`SerialNo`, `OperatorFlagCode`, `Manufacturer`, `Type`, `FirstRegDate`, `CurrentRegDate`, `Country`, `PreviousID`, `DeRegDate`, `Status`, `PopularName`,`GenericName`,`AircraftClass`, `Engines`, `OwnershipStatus`,`RegisteredOwners`,`MTOW`, `TotalHours`, `YearBuilt`, `CofACategory`, `CofAExpiry`, `UserNotes`, `Interested`, `UserTag`, `InfoUrl`, `PictureUrl1`, `PictureUrl2`, `PictureUrl3`, `UserBool1`, `UserBool2`, `UserBool3`, `UserBool4`, `UserBool5`, `UserString1`, `UserString2`, `UserString3`, `UserString4`, `UserString5`, `UserInt1`, `UserInt2`, `UserInt3`, `UserInt4`, `UserInt5`) VALUES (:AircraftID,:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:SerialNo, :OperatorFlagCode, :Manufacturer, :Type, :FirstRegDate, :CurrentRegDate, :Country, :PreviousID, :DeRegDate, :Status, :PopularName,:GenericName,:AircraftClass, :Engines, :OwnershipStatus,:RegisteredOwners,:MTOW, :TotalHours,:YearBuilt, :CofACategory, :CofAExpiry, :UserNotes, :Interested, :UserTag, :InfoUrl, :PictureUrl1, :PictureUrl2, :PictureUrl3, :UserBool1, :UserBool2, :UserBool3, :UserBool4, :UserBool5, :UserString1, :UserString2, :UserString3, :UserString4, :UserString5, :UserInt1, :UserInt2, :UserInt3, :UserInt4, :UserInt5)'; |
@@ -358,25 +358,25 @@ discard block |
||
| 358 | 358 | try { |
| 359 | 359 | if ($globalTransaction) $Connection->db->beginTransaction(); |
| 360 | 360 | $tmp = fgetcsv($fh,9999,',',"'"); |
| 361 | - while (!feof($fh)) { |
|
| 362 | - $line = fgetcsv($fh,9999,',',"'"); |
|
| 361 | + while (!feof($fh)) { |
|
| 362 | + $line = fgetcsv($fh,9999,',',"'"); |
|
| 363 | 363 | |
| 364 | 364 | //FFFFFF RIDEAU VALLEY SOARINGASW-20 C-FBKN MZ 123.400 |
| 365 | 365 | //print_r($line); |
| 366 | - $values['ModeS'] = $line[1]; |
|
| 367 | - $values['Registration'] = $line[3]; |
|
| 368 | - $values['ICAOTypeCode'] = ''; |
|
| 369 | - $aircraft_name = $line[2]; |
|
| 370 | - // Check if we can find ICAO, else set it to GLID |
|
| 371 | - $aircraft_name_split = explode(' ',$aircraft_name); |
|
| 372 | - $search_more = ''; |
|
| 373 | - if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'"; |
|
| 374 | - $query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more; |
|
| 375 | - $sth_search = $Connection->db->prepare($query_search); |
|
| 366 | + $values['ModeS'] = $line[1]; |
|
| 367 | + $values['Registration'] = $line[3]; |
|
| 368 | + $values['ICAOTypeCode'] = ''; |
|
| 369 | + $aircraft_name = $line[2]; |
|
| 370 | + // Check if we can find ICAO, else set it to GLID |
|
| 371 | + $aircraft_name_split = explode(' ',$aircraft_name); |
|
| 372 | + $search_more = ''; |
|
| 373 | + if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'"; |
|
| 374 | + $query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more; |
|
| 375 | + $sth_search = $Connection->db->prepare($query_search); |
|
| 376 | 376 | try { |
| 377 | - $sth_search->execute(); |
|
| 378 | - $result = $sth_search->fetch(PDO::FETCH_ASSOC); |
|
| 379 | - if (isset($result['icao']) && $result['icao'] != '') $values['ICAOTypeCode'] = $result['icao']; |
|
| 377 | + $sth_search->execute(); |
|
| 378 | + $result = $sth_search->fetch(PDO::FETCH_ASSOC); |
|
| 379 | + if (isset($result['icao']) && $result['icao'] != '') $values['ICAOTypeCode'] = $result['icao']; |
|
| 380 | 380 | } catch(PDOException $e) { |
| 381 | 381 | return "error : ".$e->getMessage(); |
| 382 | 382 | } |
@@ -399,10 +399,10 @@ discard block |
||
| 399 | 399 | try { |
| 400 | 400 | $Connection = new Connection(); |
| 401 | 401 | $sth = $Connection->db->prepare($query); |
| 402 | - $sth->execute(array(':source' => $database_file)); |
|
| 403 | - } catch(PDOException $e) { |
|
| 404 | - return "error : ".$e->getMessage(); |
|
| 405 | - } |
|
| 402 | + $sth->execute(array(':source' => $database_file)); |
|
| 403 | + } catch(PDOException $e) { |
|
| 404 | + return "error : ".$e->getMessage(); |
|
| 405 | + } |
|
| 406 | 406 | return ''; |
| 407 | 407 | } |
| 408 | 408 | |
@@ -413,16 +413,16 @@ discard block |
||
| 413 | 413 | try { |
| 414 | 414 | $Connection = new Connection(); |
| 415 | 415 | $sth = $Connection->db->prepare($query); |
| 416 | - $sth->execute(array(':source' => $database_file)); |
|
| 417 | - } catch(PDOException $e) { |
|
| 418 | - return "error : ".$e->getMessage(); |
|
| 419 | - } |
|
| 416 | + $sth->execute(array(':source' => $database_file)); |
|
| 417 | + } catch(PDOException $e) { |
|
| 418 | + return "error : ".$e->getMessage(); |
|
| 419 | + } |
|
| 420 | 420 | require_once(dirname(__FILE__).'/../require/class.Spotter.php'); |
| 421 | 421 | $Spotter = new Spotter(); |
| 422 | 422 | if ($fh = fopen($database_file,"r")) { |
| 423 | 423 | //$query_dest = 'INSERT INTO aircraft_modes (`AircraftID`,`FirstCreated`,`LastModified`, `ModeS`,`ModeSCountry`,`Registration`,`ICAOTypeCode`,`SerialNo`, `OperatorFlagCode`, `Manufacturer`, `Type`, `FirstRegDate`, `CurrentRegDate`, `Country`, `PreviousID`, `DeRegDate`, `Status`, `PopularName`,`GenericName`,`AircraftClass`, `Engines`, `OwnershipStatus`,`RegisteredOwners`,`MTOW`, `TotalHours`, `YearBuilt`, `CofACategory`, `CofAExpiry`, `UserNotes`, `Interested`, `UserTag`, `InfoUrl`, `PictureUrl1`, `PictureUrl2`, `PictureUrl3`, `UserBool1`, `UserBool2`, `UserBool3`, `UserBool4`, `UserBool5`, `UserString1`, `UserString2`, `UserString3`, `UserString4`, `UserString5`, `UserInt1`, `UserInt2`, `UserInt3`, `UserInt4`, `UserInt5`) VALUES (:AircraftID,:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:SerialNo, :OperatorFlagCode, :Manufacturer, :Type, :FirstRegDate, :CurrentRegDate, :Country, :PreviousID, :DeRegDate, :Status, :PopularName,:GenericName,:AircraftClass, :Engines, :OwnershipStatus,:RegisteredOwners,:MTOW, :TotalHours,:YearBuilt, :CofACategory, :CofAExpiry, :UserNotes, :Interested, :UserTag, :InfoUrl, :PictureUrl1, :PictureUrl2, :PictureUrl3, :UserBool1, :UserBool2, :UserBool3, :UserBool4, :UserBool5, :UserString1, :UserString2, :UserString3, :UserString4, :UserString5, :UserInt1, :UserInt2, :UserInt3, :UserInt4, :UserInt5)'; |
| 424 | 424 | $query_dest = 'INSERT INTO aircraft_owner (registration,base,owner,date_first_reg,Source) VALUES (:registration,:base,:owner,:date_first_reg,:source)'; |
| 425 | - $query_modes = 'INSERT INTO aircraft_modes (ModeS,ModeSCountry,Registration,ICAOTypeCode,Source) VALUES (:modes,:modescountry,:registration,:icaotypecode,:source)'; |
|
| 425 | + $query_modes = 'INSERT INTO aircraft_modes (ModeS,ModeSCountry,Registration,ICAOTypeCode,Source) VALUES (:modes,:modescountry,:registration,:icaotypecode,:source)'; |
|
| 426 | 426 | |
| 427 | 427 | $Connection = new Connection(); |
| 428 | 428 | $sth_dest = $Connection->db->prepare($query_dest); |
@@ -430,126 +430,126 @@ discard block |
||
| 430 | 430 | try { |
| 431 | 431 | if ($globalTransaction) $Connection->db->beginTransaction(); |
| 432 | 432 | $tmp = fgetcsv($fh,9999,',','"'); |
| 433 | - while (!feof($fh)) { |
|
| 434 | - $line = fgetcsv($fh,9999,',','"'); |
|
| 435 | - $values = array(); |
|
| 436 | - //print_r($line); |
|
| 437 | - if ($country == 'F') { |
|
| 438 | - $values['registration'] = $line[0]; |
|
| 439 | - $values['base'] = $line[4]; |
|
| 440 | - $values['owner'] = $line[5]; |
|
| 441 | - if ($line[6] == '') $values['date_first_reg'] = null; |
|
| 442 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6])); |
|
| 443 | - $values['cancel'] = $line[7]; |
|
| 433 | + while (!feof($fh)) { |
|
| 434 | + $line = fgetcsv($fh,9999,',','"'); |
|
| 435 | + $values = array(); |
|
| 436 | + //print_r($line); |
|
| 437 | + if ($country == 'F') { |
|
| 438 | + $values['registration'] = $line[0]; |
|
| 439 | + $values['base'] = $line[4]; |
|
| 440 | + $values['owner'] = $line[5]; |
|
| 441 | + if ($line[6] == '') $values['date_first_reg'] = null; |
|
| 442 | + else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6])); |
|
| 443 | + $values['cancel'] = $line[7]; |
|
| 444 | 444 | } elseif ($country == 'EI') { |
| 445 | - // TODO : add modeS & reg to aircraft_modes |
|
| 446 | - $values['registration'] = $line[0]; |
|
| 447 | - $values['base'] = $line[3]; |
|
| 448 | - $values['owner'] = $line[2]; |
|
| 449 | - if ($line[1] == '') $values['date_first_reg'] = null; |
|
| 450 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[1])); |
|
| 451 | - $values['cancel'] = ''; |
|
| 452 | - $values['modes'] = $line[7]; |
|
| 453 | - $values['icao'] = $line[8]; |
|
| 445 | + // TODO : add modeS & reg to aircraft_modes |
|
| 446 | + $values['registration'] = $line[0]; |
|
| 447 | + $values['base'] = $line[3]; |
|
| 448 | + $values['owner'] = $line[2]; |
|
| 449 | + if ($line[1] == '') $values['date_first_reg'] = null; |
|
| 450 | + else $values['date_first_reg'] = date("Y-m-d",strtotime($line[1])); |
|
| 451 | + $values['cancel'] = ''; |
|
| 452 | + $values['modes'] = $line[7]; |
|
| 453 | + $values['icao'] = $line[8]; |
|
| 454 | 454 | |
| 455 | 455 | } elseif ($country == 'HB') { |
| 456 | - // TODO : add modeS & reg to aircraft_modes |
|
| 457 | - $values['registration'] = $line[0]; |
|
| 458 | - $values['base'] = null; |
|
| 459 | - $values['owner'] = $line[5]; |
|
| 460 | - $values['date_first_reg'] = null; |
|
| 461 | - $values['cancel'] = ''; |
|
| 462 | - $values['modes'] = $line[4]; |
|
| 463 | - $values['icao'] = $line[7]; |
|
| 456 | + // TODO : add modeS & reg to aircraft_modes |
|
| 457 | + $values['registration'] = $line[0]; |
|
| 458 | + $values['base'] = null; |
|
| 459 | + $values['owner'] = $line[5]; |
|
| 460 | + $values['date_first_reg'] = null; |
|
| 461 | + $values['cancel'] = ''; |
|
| 462 | + $values['modes'] = $line[4]; |
|
| 463 | + $values['icao'] = $line[7]; |
|
| 464 | 464 | } elseif ($country == 'OK') { |
| 465 | - // TODO : add modeS & reg to aircraft_modes |
|
| 466 | - $values['registration'] = $line[3]; |
|
| 467 | - $values['base'] = null; |
|
| 468 | - $values['owner'] = $line[5]; |
|
| 469 | - if ($line[18] == '') $values['date_first_reg'] = null; |
|
| 470 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[18])); |
|
| 471 | - $values['cancel'] = ''; |
|
| 465 | + // TODO : add modeS & reg to aircraft_modes |
|
| 466 | + $values['registration'] = $line[3]; |
|
| 467 | + $values['base'] = null; |
|
| 468 | + $values['owner'] = $line[5]; |
|
| 469 | + if ($line[18] == '') $values['date_first_reg'] = null; |
|
| 470 | + else $values['date_first_reg'] = date("Y-m-d",strtotime($line[18])); |
|
| 471 | + $values['cancel'] = ''; |
|
| 472 | 472 | } elseif ($country == 'VH') { |
| 473 | - // TODO : add modeS & reg to aircraft_modes |
|
| 474 | - $values['registration'] = $line[0]; |
|
| 475 | - $values['base'] = null; |
|
| 476 | - $values['owner'] = $line[12]; |
|
| 477 | - if ($line[28] == '') $values['date_first_reg'] = null; |
|
| 478 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[28])); |
|
| 479 | - |
|
| 480 | - $values['cancel'] = $line[39]; |
|
| 473 | + // TODO : add modeS & reg to aircraft_modes |
|
| 474 | + $values['registration'] = $line[0]; |
|
| 475 | + $values['base'] = null; |
|
| 476 | + $values['owner'] = $line[12]; |
|
| 477 | + if ($line[28] == '') $values['date_first_reg'] = null; |
|
| 478 | + else $values['date_first_reg'] = date("Y-m-d",strtotime($line[28])); |
|
| 479 | + |
|
| 480 | + $values['cancel'] = $line[39]; |
|
| 481 | 481 | } elseif ($country == 'OE' || $country == '9A' || $country == 'VP' || $country == 'LX' || $country == 'P2' || $country == 'HC') { |
| 482 | - $values['registration'] = $line[0]; |
|
| 483 | - $values['base'] = null; |
|
| 484 | - $values['owner'] = $line[4]; |
|
| 485 | - $values['date_first_reg'] = null; |
|
| 486 | - $values['cancel'] = ''; |
|
| 482 | + $values['registration'] = $line[0]; |
|
| 483 | + $values['base'] = null; |
|
| 484 | + $values['owner'] = $line[4]; |
|
| 485 | + $values['date_first_reg'] = null; |
|
| 486 | + $values['cancel'] = ''; |
|
| 487 | 487 | } elseif ($country == 'CC') { |
| 488 | - $values['registration'] = $line[0]; |
|
| 489 | - $values['base'] = null; |
|
| 490 | - $values['owner'] = $line[6]; |
|
| 491 | - $values['date_first_reg'] = null; |
|
| 492 | - $values['cancel'] = ''; |
|
| 488 | + $values['registration'] = $line[0]; |
|
| 489 | + $values['base'] = null; |
|
| 490 | + $values['owner'] = $line[6]; |
|
| 491 | + $values['date_first_reg'] = null; |
|
| 492 | + $values['cancel'] = ''; |
|
| 493 | 493 | } elseif ($country == 'HJ') { |
| 494 | - $values['registration'] = $line[0]; |
|
| 495 | - $values['base'] = null; |
|
| 496 | - $values['owner'] = $line[8]; |
|
| 497 | - if ($line[7] == '') $values['date_first_reg'] = null; |
|
| 498 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7])); |
|
| 499 | - $values['cancel'] = ''; |
|
| 494 | + $values['registration'] = $line[0]; |
|
| 495 | + $values['base'] = null; |
|
| 496 | + $values['owner'] = $line[8]; |
|
| 497 | + if ($line[7] == '') $values['date_first_reg'] = null; |
|
| 498 | + else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7])); |
|
| 499 | + $values['cancel'] = ''; |
|
| 500 | 500 | } elseif ($country == 'PP') { |
| 501 | - $values['registration'] = $line[0]; |
|
| 502 | - $values['base'] = null; |
|
| 503 | - $values['owner'] = $line[4]; |
|
| 504 | - if ($line[6] == '') $values['date_first_reg'] = null; |
|
| 505 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6])); |
|
| 506 | - $values['cancel'] = $line[7]; |
|
| 501 | + $values['registration'] = $line[0]; |
|
| 502 | + $values['base'] = null; |
|
| 503 | + $values['owner'] = $line[4]; |
|
| 504 | + if ($line[6] == '') $values['date_first_reg'] = null; |
|
| 505 | + else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6])); |
|
| 506 | + $values['cancel'] = $line[7]; |
|
| 507 | 507 | } elseif ($country == 'E7') { |
| 508 | - $values['registration'] = $line[0]; |
|
| 509 | - $values['base'] = null; |
|
| 510 | - $values['owner'] = $line[4]; |
|
| 511 | - if ($line[5] == '') $values['date_first_reg'] = null; |
|
| 512 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[5])); |
|
| 513 | - $values['cancel'] = ''; |
|
| 508 | + $values['registration'] = $line[0]; |
|
| 509 | + $values['base'] = null; |
|
| 510 | + $values['owner'] = $line[4]; |
|
| 511 | + if ($line[5] == '') $values['date_first_reg'] = null; |
|
| 512 | + else $values['date_first_reg'] = date("Y-m-d",strtotime($line[5])); |
|
| 513 | + $values['cancel'] = ''; |
|
| 514 | 514 | } elseif ($country == '8Q') { |
| 515 | - $values['registration'] = $line[0]; |
|
| 516 | - $values['base'] = null; |
|
| 517 | - $values['owner'] = $line[3]; |
|
| 518 | - if ($line[7] == '') $values['date_first_reg'] = null; |
|
| 519 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7])); |
|
| 520 | - $values['cancel'] = ''; |
|
| 515 | + $values['registration'] = $line[0]; |
|
| 516 | + $values['base'] = null; |
|
| 517 | + $values['owner'] = $line[3]; |
|
| 518 | + if ($line[7] == '') $values['date_first_reg'] = null; |
|
| 519 | + else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7])); |
|
| 520 | + $values['cancel'] = ''; |
|
| 521 | 521 | } elseif ($country == 'ZK') { |
| 522 | - $values['registration'] = $line[0]; |
|
| 523 | - $values['base'] = null; |
|
| 524 | - $values['owner'] = $line[3]; |
|
| 525 | - $values['date_first_reg'] = null; |
|
| 526 | - $values['cancel'] = ''; |
|
| 527 | - $values['modes'] = $line[5]; |
|
| 528 | - $values['icao'] = $line[9]; |
|
| 522 | + $values['registration'] = $line[0]; |
|
| 523 | + $values['base'] = null; |
|
| 524 | + $values['owner'] = $line[3]; |
|
| 525 | + $values['date_first_reg'] = null; |
|
| 526 | + $values['cancel'] = ''; |
|
| 527 | + $values['modes'] = $line[5]; |
|
| 528 | + $values['icao'] = $line[9]; |
|
| 529 | 529 | } elseif ($country == 'M') { |
| 530 | - $values['registration'] = $line[0]; |
|
| 531 | - $values['base'] = null; |
|
| 532 | - $values['owner'] = $line[6]; |
|
| 533 | - $values['date_first_reg'] = date("Y-m-d",strtotime($line[5])); |
|
| 534 | - $values['cancel'] = date("Y-m-d",strtotime($line[8])); |
|
| 535 | - $values['modes'] = $line[4]; |
|
| 536 | - $values['icao'] = $line[10]; |
|
| 530 | + $values['registration'] = $line[0]; |
|
| 531 | + $values['base'] = null; |
|
| 532 | + $values['owner'] = $line[6]; |
|
| 533 | + $values['date_first_reg'] = date("Y-m-d",strtotime($line[5])); |
|
| 534 | + $values['cancel'] = date("Y-m-d",strtotime($line[8])); |
|
| 535 | + $values['modes'] = $line[4]; |
|
| 536 | + $values['icao'] = $line[10]; |
|
| 537 | 537 | } elseif ($country == 'OY') { |
| 538 | - $values['registration'] = $line[0]; |
|
| 539 | - $values['date_first_reg'] = date("Y-m-d",strtotime($line[4])); |
|
| 540 | - $values['modes'] = $line[5]; |
|
| 541 | - $values['icao'] = $line[6]; |
|
| 538 | + $values['registration'] = $line[0]; |
|
| 539 | + $values['date_first_reg'] = date("Y-m-d",strtotime($line[4])); |
|
| 540 | + $values['modes'] = $line[5]; |
|
| 541 | + $values['icao'] = $line[6]; |
|
| 542 | 542 | } elseif ($country == 'PH') { |
| 543 | - $values['registration'] = $line[0]; |
|
| 544 | - $values['date_first_reg'] = date("Y-m-d",strtotime($line[3])); |
|
| 545 | - $values['modes'] = $line[4]; |
|
| 546 | - $values['icao'] = $line[5]; |
|
| 543 | + $values['registration'] = $line[0]; |
|
| 544 | + $values['date_first_reg'] = date("Y-m-d",strtotime($line[3])); |
|
| 545 | + $values['modes'] = $line[4]; |
|
| 546 | + $values['icao'] = $line[5]; |
|
| 547 | 547 | } elseif ($country == 'OM' || $country == 'TF') { |
| 548 | - $values['registration'] = $line[0]; |
|
| 549 | - $values['base'] = null; |
|
| 550 | - $values['owner'] = $line[3]; |
|
| 551 | - $values['date_first_reg'] = null; |
|
| 552 | - $values['cancel'] = ''; |
|
| 548 | + $values['registration'] = $line[0]; |
|
| 549 | + $values['base'] = null; |
|
| 550 | + $values['owner'] = $line[3]; |
|
| 551 | + $values['date_first_reg'] = null; |
|
| 552 | + $values['cancel'] = ''; |
|
| 553 | 553 | } |
| 554 | 554 | if (isset($values['cancel']) && $values['cancel'] == '' && $values['registration'] != null && isset($values['owner'])) { |
| 555 | 555 | $query_dest_values = array(':registration' => $values['registration'],':base' => $values['base'],':date_first_reg' => $values['date_first_reg'],':owner' => $values['owner'],':source' => $database_file); |
@@ -682,7 +682,7 @@ discard block |
||
| 682 | 682 | return "error : ".$e->getMessage(); |
| 683 | 683 | } |
| 684 | 684 | */ |
| 685 | - /* |
|
| 685 | + /* |
|
| 686 | 686 | $query = 'ALTER TABLE airport DROP INDEX icaoidx'; |
| 687 | 687 | try { |
| 688 | 688 | $Connection = new Connection(); |
@@ -927,10 +927,10 @@ discard block |
||
| 927 | 927 | try { |
| 928 | 928 | $Connection = new Connection(); |
| 929 | 929 | $sth = $Connection->db->prepare($query); |
| 930 | - $sth->execute(array(':source' => 'translation.csv')); |
|
| 931 | - } catch(PDOException $e) { |
|
| 932 | - return "error : ".$e->getMessage(); |
|
| 933 | - } |
|
| 930 | + $sth->execute(array(':source' => 'translation.csv')); |
|
| 931 | + } catch(PDOException $e) { |
|
| 932 | + return "error : ".$e->getMessage(); |
|
| 933 | + } |
|
| 934 | 934 | |
| 935 | 935 | |
| 936 | 936 | //update_db::unzip($out_file); |
@@ -949,21 +949,21 @@ discard block |
||
| 949 | 949 | $data = $row; |
| 950 | 950 | $operator = $data[2]; |
| 951 | 951 | if ($operator != '' && is_numeric(substr(substr($operator, 0, 3), -1, 1))) { |
| 952 | - $airline_array = $Spotter->getAllAirlineInfo(substr($operator, 0, 2)); |
|
| 953 | - //echo substr($operator, 0, 2)."\n";; |
|
| 954 | - if (count($airline_array) > 0) { |
|
| 952 | + $airline_array = $Spotter->getAllAirlineInfo(substr($operator, 0, 2)); |
|
| 953 | + //echo substr($operator, 0, 2)."\n";; |
|
| 954 | + if (count($airline_array) > 0) { |
|
| 955 | 955 | //print_r($airline_array); |
| 956 | 956 | $operator = $airline_array[0]['icao'].substr($operator,2); |
| 957 | - } |
|
| 958 | - } |
|
| 957 | + } |
|
| 958 | + } |
|
| 959 | 959 | |
| 960 | 960 | $operator_correct = $data[3]; |
| 961 | 961 | if ($operator_correct != '' && is_numeric(substr(substr($operator_correct, 0, 3), -1, 1))) { |
| 962 | - $airline_array = $Spotter->getAllAirlineInfo(substr($operator_correct, 0, 2)); |
|
| 963 | - if (count($airline_array) > 0) { |
|
| 964 | - $operator_correct = $airline_array[0]['icao'].substr($operator_correct,2); |
|
| 965 | - } |
|
| 966 | - } |
|
| 962 | + $airline_array = $Spotter->getAllAirlineInfo(substr($operator_correct, 0, 2)); |
|
| 963 | + if (count($airline_array) > 0) { |
|
| 964 | + $operator_correct = $airline_array[0]['icao'].substr($operator_correct,2); |
|
| 965 | + } |
|
| 966 | + } |
|
| 967 | 967 | $query = 'INSERT INTO translation (Reg,Reg_correct,Operator,Operator_correct,Source) VALUES (:Reg, :Reg_correct, :Operator, :Operator_correct, :source)'; |
| 968 | 968 | try { |
| 969 | 969 | $sth = $Connection->db->prepare($query); |
@@ -977,7 +977,7 @@ discard block |
||
| 977 | 977 | //$Connection->db->commit(); |
| 978 | 978 | } |
| 979 | 979 | return ''; |
| 980 | - } |
|
| 980 | + } |
|
| 981 | 981 | |
| 982 | 982 | public static function translation_fam() { |
| 983 | 983 | global $tmp_dir, $globalTransaction; |
@@ -1015,7 +1015,7 @@ discard block |
||
| 1015 | 1015 | //$Connection->db->commit(); |
| 1016 | 1016 | } |
| 1017 | 1017 | return ''; |
| 1018 | - } |
|
| 1018 | + } |
|
| 1019 | 1019 | |
| 1020 | 1020 | /* |
| 1021 | 1021 | * This function use FAA public data. |
@@ -1027,19 +1027,19 @@ discard block |
||
| 1027 | 1027 | try { |
| 1028 | 1028 | $Connection = new Connection(); |
| 1029 | 1029 | $sth = $Connection->db->prepare($query); |
| 1030 | - $sth->execute(array(':source' => 'website_faa')); |
|
| 1031 | - } catch(PDOException $e) { |
|
| 1032 | - return "error : ".$e->getMessage(); |
|
| 1033 | - } |
|
| 1030 | + $sth->execute(array(':source' => 'website_faa')); |
|
| 1031 | + } catch(PDOException $e) { |
|
| 1032 | + return "error : ".$e->getMessage(); |
|
| 1033 | + } |
|
| 1034 | 1034 | |
| 1035 | 1035 | $query = "DELETE FROM aircraft_owner WHERE Source = '' OR Source = :source"; |
| 1036 | 1036 | try { |
| 1037 | 1037 | $Connection = new Connection(); |
| 1038 | 1038 | $sth = $Connection->db->prepare($query); |
| 1039 | - $sth->execute(array(':source' => 'website_faa')); |
|
| 1040 | - } catch(PDOException $e) { |
|
| 1041 | - return "error : ".$e->getMessage(); |
|
| 1042 | - } |
|
| 1039 | + $sth->execute(array(':source' => 'website_faa')); |
|
| 1040 | + } catch(PDOException $e) { |
|
| 1041 | + return "error : ".$e->getMessage(); |
|
| 1042 | + } |
|
| 1043 | 1043 | |
| 1044 | 1044 | $delimiter = ","; |
| 1045 | 1045 | $mfr = array(); |
@@ -1115,17 +1115,17 @@ discard block |
||
| 1115 | 1115 | } |
| 1116 | 1116 | //print_r($mfr); |
| 1117 | 1117 | return ''; |
| 1118 | - } |
|
| 1118 | + } |
|
| 1119 | 1119 | public static function modes_fam() { |
| 1120 | 1120 | global $tmp_dir, $globalTransaction; |
| 1121 | 1121 | $query = "DELETE FROM aircraft_modes WHERE Source = '' OR Source = :source"; |
| 1122 | 1122 | try { |
| 1123 | 1123 | $Connection = new Connection(); |
| 1124 | 1124 | $sth = $Connection->db->prepare($query); |
| 1125 | - $sth->execute(array(':source' => 'website_fam')); |
|
| 1126 | - } catch(PDOException $e) { |
|
| 1127 | - return "error : ".$e->getMessage(); |
|
| 1128 | - } |
|
| 1125 | + $sth->execute(array(':source' => 'website_fam')); |
|
| 1126 | + } catch(PDOException $e) { |
|
| 1127 | + return "error : ".$e->getMessage(); |
|
| 1128 | + } |
|
| 1129 | 1129 | |
| 1130 | 1130 | |
| 1131 | 1131 | //update_db::unzip($out_file); |
@@ -1155,7 +1155,7 @@ discard block |
||
| 1155 | 1155 | if ($globalTransaction) $Connection->db->commit(); |
| 1156 | 1156 | } |
| 1157 | 1157 | return ''; |
| 1158 | - } |
|
| 1158 | + } |
|
| 1159 | 1159 | |
| 1160 | 1160 | public static function owner_fam() { |
| 1161 | 1161 | global $tmp_dir, $globalTransaction; |
@@ -1163,10 +1163,10 @@ discard block |
||
| 1163 | 1163 | try { |
| 1164 | 1164 | $Connection = new Connection(); |
| 1165 | 1165 | $sth = $Connection->db->prepare($query); |
| 1166 | - $sth->execute(array(':source' => 'website_fam')); |
|
| 1167 | - } catch(PDOException $e) { |
|
| 1168 | - return "error : ".$e->getMessage(); |
|
| 1169 | - } |
|
| 1166 | + $sth->execute(array(':source' => 'website_fam')); |
|
| 1167 | + } catch(PDOException $e) { |
|
| 1168 | + return "error : ".$e->getMessage(); |
|
| 1169 | + } |
|
| 1170 | 1170 | |
| 1171 | 1171 | $delimiter = "\t"; |
| 1172 | 1172 | $Connection = new Connection(); |
@@ -1192,7 +1192,7 @@ discard block |
||
| 1192 | 1192 | if ($globalTransaction) $Connection->db->commit(); |
| 1193 | 1193 | } |
| 1194 | 1194 | return ''; |
| 1195 | - } |
|
| 1195 | + } |
|
| 1196 | 1196 | |
| 1197 | 1197 | public static function routes_fam() { |
| 1198 | 1198 | global $tmp_dir, $globalTransaction, $globalDebug; |
@@ -1227,7 +1227,7 @@ discard block |
||
| 1227 | 1227 | if ($globalTransaction) $Connection->db->commit(); |
| 1228 | 1228 | } |
| 1229 | 1229 | return ''; |
| 1230 | - } |
|
| 1230 | + } |
|
| 1231 | 1231 | |
| 1232 | 1232 | public static function marine_identity_fam() { |
| 1233 | 1233 | global $tmp_dir, $globalTransaction; |
@@ -1235,10 +1235,10 @@ discard block |
||
| 1235 | 1235 | try { |
| 1236 | 1236 | $Connection = new Connection(); |
| 1237 | 1237 | $sth = $Connection->db->prepare($query); |
| 1238 | - $sth->execute(); |
|
| 1239 | - } catch(PDOException $e) { |
|
| 1240 | - return "error : ".$e->getMessage(); |
|
| 1241 | - } |
|
| 1238 | + $sth->execute(); |
|
| 1239 | + } catch(PDOException $e) { |
|
| 1240 | + return "error : ".$e->getMessage(); |
|
| 1241 | + } |
|
| 1242 | 1242 | |
| 1243 | 1243 | |
| 1244 | 1244 | //update_db::unzip($out_file); |
@@ -1268,7 +1268,7 @@ discard block |
||
| 1268 | 1268 | if ($globalTransaction) $Connection->db->commit(); |
| 1269 | 1269 | } |
| 1270 | 1270 | return ''; |
| 1271 | - } |
|
| 1271 | + } |
|
| 1272 | 1272 | |
| 1273 | 1273 | public static function satellite_fam() { |
| 1274 | 1274 | global $tmp_dir, $globalTransaction; |
@@ -1339,7 +1339,7 @@ discard block |
||
| 1339 | 1339 | if ($globalTransaction) $Connection->db->commit(); |
| 1340 | 1340 | } |
| 1341 | 1341 | return ''; |
| 1342 | - } |
|
| 1342 | + } |
|
| 1343 | 1343 | |
| 1344 | 1344 | public static function tle($filename,$tletype) { |
| 1345 | 1345 | require_once(dirname(__FILE__).'/../require/class.Spotter.php'); |
@@ -1350,10 +1350,10 @@ discard block |
||
| 1350 | 1350 | try { |
| 1351 | 1351 | $Connection = new Connection(); |
| 1352 | 1352 | $sth = $Connection->db->prepare($query); |
| 1353 | - $sth->execute(array(':source' => $filename)); |
|
| 1354 | - } catch(PDOException $e) { |
|
| 1355 | - return "error : ".$e->getMessage(); |
|
| 1356 | - } |
|
| 1353 | + $sth->execute(array(':source' => $filename)); |
|
| 1354 | + } catch(PDOException $e) { |
|
| 1355 | + return "error : ".$e->getMessage(); |
|
| 1356 | + } |
|
| 1357 | 1357 | |
| 1358 | 1358 | $Connection = new Connection(); |
| 1359 | 1359 | if (($handle = fopen($filename, 'r')) !== FALSE) |
@@ -1388,7 +1388,7 @@ discard block |
||
| 1388 | 1388 | //$Connection->db->commit(); |
| 1389 | 1389 | } |
| 1390 | 1390 | return ''; |
| 1391 | - } |
|
| 1391 | + } |
|
| 1392 | 1392 | |
| 1393 | 1393 | public static function satellite_ucsdb($filename) { |
| 1394 | 1394 | global $tmp_dir, $globalTransaction; |
@@ -1637,11 +1637,11 @@ discard block |
||
| 1637 | 1637 | try { |
| 1638 | 1638 | $sth = $Connection->db->prepare($query); |
| 1639 | 1639 | $sth->execute(array( |
| 1640 | - ':name' => $result['name'], ':name_alternate' => '', ':country_un' => '', ':country_owner' => $result['country_owner'], ':owner' => $result['owner'], ':users' => '', ':purpose' => '', ':purpose_detailed' => '', ':orbit' => $result['status'], |
|
| 1641 | - ':type' => '', ':longitude_geo' => NULL, ':perigee' => !empty($result['perigee']) ? $result['perigee'] : NULL, ':apogee' => !empty($result['apogee']) ? $result['apogee'] : NULL, ':eccentricity' => NULL, ':inclination' => $result['inclination'], |
|
| 1642 | - ':period' => !empty($result['period']) ? $result['period'] : NULL, ':launch_mass' => NULL, ':dry_mass' => NULL, ':power' => NULL, ':launch_date' => $result['launch_date'], ':lifetime' => $result['lifetime'], |
|
| 1643 | - ':contractor' => '',':country_contractor' => '', ':launch_site' => $result['launch_site'], ':launch_vehicule' => '', ':cospar' => $result['cospar'], ':norad' => $result['norad'], ':comments' => '', ':source_orbital' => '', ':sources' => '' |
|
| 1644 | - ) |
|
| 1640 | + ':name' => $result['name'], ':name_alternate' => '', ':country_un' => '', ':country_owner' => $result['country_owner'], ':owner' => $result['owner'], ':users' => '', ':purpose' => '', ':purpose_detailed' => '', ':orbit' => $result['status'], |
|
| 1641 | + ':type' => '', ':longitude_geo' => NULL, ':perigee' => !empty($result['perigee']) ? $result['perigee'] : NULL, ':apogee' => !empty($result['apogee']) ? $result['apogee'] : NULL, ':eccentricity' => NULL, ':inclination' => $result['inclination'], |
|
| 1642 | + ':period' => !empty($result['period']) ? $result['period'] : NULL, ':launch_mass' => NULL, ':dry_mass' => NULL, ':power' => NULL, ':launch_date' => $result['launch_date'], ':lifetime' => $result['lifetime'], |
|
| 1643 | + ':contractor' => '',':country_contractor' => '', ':launch_site' => $result['launch_site'], ':launch_vehicule' => '', ':cospar' => $result['cospar'], ':norad' => $result['norad'], ':comments' => '', ':source_orbital' => '', ':sources' => '' |
|
| 1644 | + ) |
|
| 1645 | 1645 | ); |
| 1646 | 1646 | } catch(PDOException $e) { |
| 1647 | 1647 | return "error : ".$e->getMessage(); |
@@ -1665,13 +1665,13 @@ discard block |
||
| 1665 | 1665 | //$Connection->db->commit(); |
| 1666 | 1666 | } |
| 1667 | 1667 | return ''; |
| 1668 | - } |
|
| 1668 | + } |
|
| 1669 | 1669 | |
| 1670 | 1670 | /** |
| 1671 | - * Convert a HTML table to an array |
|
| 1672 | - * @param String $data HTML page |
|
| 1673 | - * @return Array array of the tables in HTML page |
|
| 1674 | - */ |
|
| 1671 | + * Convert a HTML table to an array |
|
| 1672 | + * @param String $data HTML page |
|
| 1673 | + * @return Array array of the tables in HTML page |
|
| 1674 | + */ |
|
| 1675 | 1675 | /* |
| 1676 | 1676 | private static function table2array($data) { |
| 1677 | 1677 | $html = str_get_html($data); |
@@ -1701,11 +1701,11 @@ discard block |
||
| 1701 | 1701 | return(array_filter($tabledata)); |
| 1702 | 1702 | } |
| 1703 | 1703 | */ |
| 1704 | - /** |
|
| 1705 | - * Get data from form result |
|
| 1706 | - * @param String $url form URL |
|
| 1707 | - * @return String the result |
|
| 1708 | - */ |
|
| 1704 | + /** |
|
| 1705 | + * Get data from form result |
|
| 1706 | + * @param String $url form URL |
|
| 1707 | + * @return String the result |
|
| 1708 | + */ |
|
| 1709 | 1709 | /* |
| 1710 | 1710 | private static function getData($url) { |
| 1711 | 1711 | $ch = curl_init(); |
@@ -1798,7 +1798,7 @@ discard block |
||
| 1798 | 1798 | if ($globalTransaction) $Connection->db->commit(); |
| 1799 | 1799 | } |
| 1800 | 1800 | return ''; |
| 1801 | - } |
|
| 1801 | + } |
|
| 1802 | 1802 | |
| 1803 | 1803 | public static function ivao_airlines($filename) { |
| 1804 | 1804 | //require_once(dirname(__FILE__).'/../require/class.Spotter.php'); |
@@ -1808,10 +1808,10 @@ discard block |
||
| 1808 | 1808 | try { |
| 1809 | 1809 | $Connection = new Connection(); |
| 1810 | 1810 | $sth = $Connection->db->prepare($query); |
| 1811 | - $sth->execute(); |
|
| 1812 | - } catch(PDOException $e) { |
|
| 1813 | - return "error : ".$e->getMessage(); |
|
| 1814 | - } |
|
| 1811 | + $sth->execute(); |
|
| 1812 | + } catch(PDOException $e) { |
|
| 1813 | + return "error : ".$e->getMessage(); |
|
| 1814 | + } |
|
| 1815 | 1815 | |
| 1816 | 1816 | $header = NULL; |
| 1817 | 1817 | $delimiter = ':'; |
@@ -1835,7 +1835,7 @@ discard block |
||
| 1835 | 1835 | if ($globalTransaction) $Connection->db->commit(); |
| 1836 | 1836 | } |
| 1837 | 1837 | return ''; |
| 1838 | - } |
|
| 1838 | + } |
|
| 1839 | 1839 | |
| 1840 | 1840 | public static function update_airspace() { |
| 1841 | 1841 | global $tmp_dir, $globalDBdriver; |
@@ -1845,11 +1845,11 @@ discard block |
||
| 1845 | 1845 | $query = 'DROP TABLE airspace'; |
| 1846 | 1846 | try { |
| 1847 | 1847 | $sth = $Connection->db->prepare($query); |
| 1848 | - $sth->execute(); |
|
| 1849 | - } catch(PDOException $e) { |
|
| 1848 | + $sth->execute(); |
|
| 1849 | + } catch(PDOException $e) { |
|
| 1850 | 1850 | return "error : ".$e->getMessage(); |
| 1851 | - } |
|
| 1852 | - } |
|
| 1851 | + } |
|
| 1852 | + } |
|
| 1853 | 1853 | |
| 1854 | 1854 | |
| 1855 | 1855 | if ($globalDBdriver == 'mysql') update_db::gunzip('../db/airspace.sql.gz',$tmp_dir.'airspace.sql'); |
@@ -1909,10 +1909,10 @@ discard block |
||
| 1909 | 1909 | $query = 'DROP TABLE countries'; |
| 1910 | 1910 | try { |
| 1911 | 1911 | $sth = $Connection->db->prepare($query); |
| 1912 | - $sth->execute(); |
|
| 1913 | - } catch(PDOException $e) { |
|
| 1914 | - echo "error : ".$e->getMessage(); |
|
| 1915 | - } |
|
| 1912 | + $sth->execute(); |
|
| 1913 | + } catch(PDOException $e) { |
|
| 1914 | + echo "error : ".$e->getMessage(); |
|
| 1915 | + } |
|
| 1916 | 1916 | } |
| 1917 | 1917 | if ($globalDBdriver == 'mysql') { |
| 1918 | 1918 | update_db::gunzip('../db/countries.sql.gz',$tmp_dir.'countries.sql'); |
@@ -2712,12 +2712,12 @@ discard block |
||
| 2712 | 2712 | echo $data; |
| 2713 | 2713 | */ |
| 2714 | 2714 | if (file_exists($tmp_dir.'aircrafts.html')) { |
| 2715 | - //var_dump(file_get_html($tmp_dir.'aircrafts.html')); |
|
| 2716 | - $fh = fopen($tmp_dir.'aircrafts.html',"r"); |
|
| 2717 | - $result = fread($fh,100000000); |
|
| 2718 | - //echo $result; |
|
| 2719 | - //var_dump(str_get_html($result)); |
|
| 2720 | - //print_r(self::table2array($result)); |
|
| 2715 | + //var_dump(file_get_html($tmp_dir.'aircrafts.html')); |
|
| 2716 | + $fh = fopen($tmp_dir.'aircrafts.html',"r"); |
|
| 2717 | + $result = fread($fh,100000000); |
|
| 2718 | + //echo $result; |
|
| 2719 | + //var_dump(str_get_html($result)); |
|
| 2720 | + //print_r(self::table2array($result)); |
|
| 2721 | 2721 | } |
| 2722 | 2722 | |
| 2723 | 2723 | } |
@@ -2731,10 +2731,10 @@ discard block |
||
| 2731 | 2731 | try { |
| 2732 | 2732 | $Connection = new Connection(); |
| 2733 | 2733 | $sth = $Connection->db->prepare($query); |
| 2734 | - $sth->execute(); |
|
| 2735 | - } catch(PDOException $e) { |
|
| 2736 | - return "error : ".$e->getMessage(); |
|
| 2737 | - } |
|
| 2734 | + $sth->execute(); |
|
| 2735 | + } catch(PDOException $e) { |
|
| 2736 | + return "error : ".$e->getMessage(); |
|
| 2737 | + } |
|
| 2738 | 2738 | |
| 2739 | 2739 | $error = ''; |
| 2740 | 2740 | if ($globalDebug) echo "Notam : Download..."; |
@@ -2790,8 +2790,8 @@ discard block |
||
| 2790 | 2790 | $data['date_end'] = date("Y-m-d H:i:s",strtotime($to)); |
| 2791 | 2791 | $data['permanent'] = 0; |
| 2792 | 2792 | } else { |
| 2793 | - $data['date_end'] = NULL; |
|
| 2794 | - $data['permanent'] = 1; |
|
| 2793 | + $data['date_end'] = NULL; |
|
| 2794 | + $data['permanent'] = 1; |
|
| 2795 | 2795 | } |
| 2796 | 2796 | $data['full_notam'] = $notam['title'].'<br>'.$notam['description']; |
| 2797 | 2797 | $NOTAM = new NOTAM(); |
@@ -2865,13 +2865,13 @@ discard block |
||
| 2865 | 2865 | try { |
| 2866 | 2866 | $Connection = new Connection(); |
| 2867 | 2867 | $sth = $Connection->db->prepare($query); |
| 2868 | - $sth->execute(); |
|
| 2869 | - } catch(PDOException $e) { |
|
| 2870 | - return "error : ".$e->getMessage(); |
|
| 2871 | - } |
|
| 2872 | - $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
| 2873 | - if ($row['nb'] > 0) return false; |
|
| 2874 | - else return true; |
|
| 2868 | + $sth->execute(); |
|
| 2869 | + } catch(PDOException $e) { |
|
| 2870 | + return "error : ".$e->getMessage(); |
|
| 2871 | + } |
|
| 2872 | + $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
| 2873 | + if ($row['nb'] > 0) return false; |
|
| 2874 | + else return true; |
|
| 2875 | 2875 | } |
| 2876 | 2876 | |
| 2877 | 2877 | public static function insert_last_update() { |
@@ -2880,10 +2880,10 @@ discard block |
||
| 2880 | 2880 | try { |
| 2881 | 2881 | $Connection = new Connection(); |
| 2882 | 2882 | $sth = $Connection->db->prepare($query); |
| 2883 | - $sth->execute(); |
|
| 2884 | - } catch(PDOException $e) { |
|
| 2885 | - return "error : ".$e->getMessage(); |
|
| 2886 | - } |
|
| 2883 | + $sth->execute(); |
|
| 2884 | + } catch(PDOException $e) { |
|
| 2885 | + return "error : ".$e->getMessage(); |
|
| 2886 | + } |
|
| 2887 | 2887 | } |
| 2888 | 2888 | |
| 2889 | 2889 | public static function check_airspace_version($version) { |
@@ -2891,13 +2891,13 @@ discard block |
||
| 2891 | 2891 | try { |
| 2892 | 2892 | $Connection = new Connection(); |
| 2893 | 2893 | $sth = $Connection->db->prepare($query); |
| 2894 | - $sth->execute(array(':version' => $version)); |
|
| 2895 | - } catch(PDOException $e) { |
|
| 2896 | - return "error : ".$e->getMessage(); |
|
| 2897 | - } |
|
| 2898 | - $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
| 2899 | - if ($row['nb'] > 0) return true; |
|
| 2900 | - else return false; |
|
| 2894 | + $sth->execute(array(':version' => $version)); |
|
| 2895 | + } catch(PDOException $e) { |
|
| 2896 | + return "error : ".$e->getMessage(); |
|
| 2897 | + } |
|
| 2898 | + $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
| 2899 | + if ($row['nb'] > 0) return true; |
|
| 2900 | + else return false; |
|
| 2901 | 2901 | } |
| 2902 | 2902 | |
| 2903 | 2903 | public static function check_geoid_version($version) { |
@@ -2905,13 +2905,13 @@ discard block |
||
| 2905 | 2905 | try { |
| 2906 | 2906 | $Connection = new Connection(); |
| 2907 | 2907 | $sth = $Connection->db->prepare($query); |
| 2908 | - $sth->execute(array(':version' => $version)); |
|
| 2909 | - } catch(PDOException $e) { |
|
| 2910 | - return "error : ".$e->getMessage(); |
|
| 2911 | - } |
|
| 2912 | - $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
| 2913 | - if ($row['nb'] > 0) return true; |
|
| 2914 | - else return false; |
|
| 2908 | + $sth->execute(array(':version' => $version)); |
|
| 2909 | + } catch(PDOException $e) { |
|
| 2910 | + return "error : ".$e->getMessage(); |
|
| 2911 | + } |
|
| 2912 | + $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
| 2913 | + if ($row['nb'] > 0) return true; |
|
| 2914 | + else return false; |
|
| 2915 | 2915 | } |
| 2916 | 2916 | |
| 2917 | 2917 | public static function check_marine_identity_version($version) { |
@@ -2961,10 +2961,10 @@ discard block |
||
| 2961 | 2961 | try { |
| 2962 | 2962 | $Connection = new Connection(); |
| 2963 | 2963 | $sth = $Connection->db->prepare($query); |
| 2964 | - $sth->execute(array(':version' => $version)); |
|
| 2965 | - } catch(PDOException $e) { |
|
| 2966 | - return "error : ".$e->getMessage(); |
|
| 2967 | - } |
|
| 2964 | + $sth->execute(array(':version' => $version)); |
|
| 2965 | + } catch(PDOException $e) { |
|
| 2966 | + return "error : ".$e->getMessage(); |
|
| 2967 | + } |
|
| 2968 | 2968 | } |
| 2969 | 2969 | |
| 2970 | 2970 | public static function insert_marine_identity_version($version) { |
@@ -3001,13 +3001,13 @@ discard block |
||
| 3001 | 3001 | try { |
| 3002 | 3002 | $Connection = new Connection(); |
| 3003 | 3003 | $sth = $Connection->db->prepare($query); |
| 3004 | - $sth->execute(); |
|
| 3005 | - } catch(PDOException $e) { |
|
| 3006 | - return "error : ".$e->getMessage(); |
|
| 3007 | - } |
|
| 3008 | - $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
| 3009 | - if ($row['nb'] > 0) return false; |
|
| 3010 | - else return true; |
|
| 3004 | + $sth->execute(); |
|
| 3005 | + } catch(PDOException $e) { |
|
| 3006 | + return "error : ".$e->getMessage(); |
|
| 3007 | + } |
|
| 3008 | + $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
| 3009 | + if ($row['nb'] > 0) return false; |
|
| 3010 | + else return true; |
|
| 3011 | 3011 | } |
| 3012 | 3012 | |
| 3013 | 3013 | public static function insert_last_notam_update() { |
@@ -3016,10 +3016,10 @@ discard block |
||
| 3016 | 3016 | try { |
| 3017 | 3017 | $Connection = new Connection(); |
| 3018 | 3018 | $sth = $Connection->db->prepare($query); |
| 3019 | - $sth->execute(); |
|
| 3020 | - } catch(PDOException $e) { |
|
| 3021 | - return "error : ".$e->getMessage(); |
|
| 3022 | - } |
|
| 3019 | + $sth->execute(); |
|
| 3020 | + } catch(PDOException $e) { |
|
| 3021 | + return "error : ".$e->getMessage(); |
|
| 3022 | + } |
|
| 3023 | 3023 | } |
| 3024 | 3024 | |
| 3025 | 3025 | public static function check_last_airspace_update() { |
@@ -3032,13 +3032,13 @@ discard block |
||
| 3032 | 3032 | try { |
| 3033 | 3033 | $Connection = new Connection(); |
| 3034 | 3034 | $sth = $Connection->db->prepare($query); |
| 3035 | - $sth->execute(); |
|
| 3036 | - } catch(PDOException $e) { |
|
| 3037 | - return "error : ".$e->getMessage(); |
|
| 3038 | - } |
|
| 3039 | - $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
| 3040 | - if ($row['nb'] > 0) return false; |
|
| 3041 | - else return true; |
|
| 3035 | + $sth->execute(); |
|
| 3036 | + } catch(PDOException $e) { |
|
| 3037 | + return "error : ".$e->getMessage(); |
|
| 3038 | + } |
|
| 3039 | + $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
| 3040 | + if ($row['nb'] > 0) return false; |
|
| 3041 | + else return true; |
|
| 3042 | 3042 | } |
| 3043 | 3043 | |
| 3044 | 3044 | public static function insert_last_airspace_update() { |
@@ -3047,10 +3047,10 @@ discard block |
||
| 3047 | 3047 | try { |
| 3048 | 3048 | $Connection = new Connection(); |
| 3049 | 3049 | $sth = $Connection->db->prepare($query); |
| 3050 | - $sth->execute(); |
|
| 3051 | - } catch(PDOException $e) { |
|
| 3052 | - return "error : ".$e->getMessage(); |
|
| 3053 | - } |
|
| 3050 | + $sth->execute(); |
|
| 3051 | + } catch(PDOException $e) { |
|
| 3052 | + return "error : ".$e->getMessage(); |
|
| 3053 | + } |
|
| 3054 | 3054 | } |
| 3055 | 3055 | |
| 3056 | 3056 | public static function check_last_geoid_update() { |
@@ -3063,13 +3063,13 @@ discard block |
||
| 3063 | 3063 | try { |
| 3064 | 3064 | $Connection = new Connection(); |
| 3065 | 3065 | $sth = $Connection->db->prepare($query); |
| 3066 | - $sth->execute(); |
|
| 3067 | - } catch(PDOException $e) { |
|
| 3068 | - return "error : ".$e->getMessage(); |
|
| 3069 | - } |
|
| 3070 | - $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
| 3071 | - if ($row['nb'] > 0) return false; |
|
| 3072 | - else return true; |
|
| 3066 | + $sth->execute(); |
|
| 3067 | + } catch(PDOException $e) { |
|
| 3068 | + return "error : ".$e->getMessage(); |
|
| 3069 | + } |
|
| 3070 | + $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
| 3071 | + if ($row['nb'] > 0) return false; |
|
| 3072 | + else return true; |
|
| 3073 | 3073 | } |
| 3074 | 3074 | |
| 3075 | 3075 | public static function insert_last_geoid_update() { |
@@ -3078,10 +3078,10 @@ discard block |
||
| 3078 | 3078 | try { |
| 3079 | 3079 | $Connection = new Connection(); |
| 3080 | 3080 | $sth = $Connection->db->prepare($query); |
| 3081 | - $sth->execute(); |
|
| 3082 | - } catch(PDOException $e) { |
|
| 3083 | - return "error : ".$e->getMessage(); |
|
| 3084 | - } |
|
| 3081 | + $sth->execute(); |
|
| 3082 | + } catch(PDOException $e) { |
|
| 3083 | + return "error : ".$e->getMessage(); |
|
| 3084 | + } |
|
| 3085 | 3085 | } |
| 3086 | 3086 | |
| 3087 | 3087 | public static function check_last_owner_update() { |
@@ -3094,13 +3094,13 @@ discard block |
||
| 3094 | 3094 | try { |
| 3095 | 3095 | $Connection = new Connection(); |
| 3096 | 3096 | $sth = $Connection->db->prepare($query); |
| 3097 | - $sth->execute(); |
|
| 3098 | - } catch(PDOException $e) { |
|
| 3099 | - return "error : ".$e->getMessage(); |
|
| 3100 | - } |
|
| 3101 | - $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
| 3102 | - if ($row['nb'] > 0) return false; |
|
| 3103 | - else return true; |
|
| 3097 | + $sth->execute(); |
|
| 3098 | + } catch(PDOException $e) { |
|
| 3099 | + return "error : ".$e->getMessage(); |
|
| 3100 | + } |
|
| 3101 | + $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
| 3102 | + if ($row['nb'] > 0) return false; |
|
| 3103 | + else return true; |
|
| 3104 | 3104 | } |
| 3105 | 3105 | |
| 3106 | 3106 | public static function insert_last_owner_update() { |
@@ -3109,10 +3109,10 @@ discard block |
||
| 3109 | 3109 | try { |
| 3110 | 3110 | $Connection = new Connection(); |
| 3111 | 3111 | $sth = $Connection->db->prepare($query); |
| 3112 | - $sth->execute(); |
|
| 3113 | - } catch(PDOException $e) { |
|
| 3114 | - return "error : ".$e->getMessage(); |
|
| 3115 | - } |
|
| 3112 | + $sth->execute(); |
|
| 3113 | + } catch(PDOException $e) { |
|
| 3114 | + return "error : ".$e->getMessage(); |
|
| 3115 | + } |
|
| 3116 | 3116 | } |
| 3117 | 3117 | public static function check_last_schedules_update() { |
| 3118 | 3118 | global $globalDBdriver; |
@@ -3124,13 +3124,13 @@ discard block |
||
| 3124 | 3124 | try { |
| 3125 | 3125 | $Connection = new Connection(); |
| 3126 | 3126 | $sth = $Connection->db->prepare($query); |
| 3127 | - $sth->execute(); |
|
| 3128 | - } catch(PDOException $e) { |
|
| 3129 | - return "error : ".$e->getMessage(); |
|
| 3130 | - } |
|
| 3131 | - $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
| 3132 | - if ($row['nb'] > 0) return false; |
|
| 3133 | - else return true; |
|
| 3127 | + $sth->execute(); |
|
| 3128 | + } catch(PDOException $e) { |
|
| 3129 | + return "error : ".$e->getMessage(); |
|
| 3130 | + } |
|
| 3131 | + $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
| 3132 | + if ($row['nb'] > 0) return false; |
|
| 3133 | + else return true; |
|
| 3134 | 3134 | } |
| 3135 | 3135 | |
| 3136 | 3136 | public static function insert_last_schedules_update() { |
@@ -3310,10 +3310,10 @@ discard block |
||
| 3310 | 3310 | try { |
| 3311 | 3311 | $Connection = new Connection(); |
| 3312 | 3312 | $sth = $Connection->db->prepare($query); |
| 3313 | - $sth->execute(); |
|
| 3314 | - } catch(PDOException $e) { |
|
| 3315 | - return "error : ".$e->getMessage(); |
|
| 3316 | - } |
|
| 3313 | + $sth->execute(); |
|
| 3314 | + } catch(PDOException $e) { |
|
| 3315 | + return "error : ".$e->getMessage(); |
|
| 3316 | + } |
|
| 3317 | 3317 | } |
| 3318 | 3318 | public static function delete_duplicateowner() { |
| 3319 | 3319 | global $globalDBdriver; |
@@ -3325,10 +3325,10 @@ discard block |
||
| 3325 | 3325 | try { |
| 3326 | 3326 | $Connection = new Connection(); |
| 3327 | 3327 | $sth = $Connection->db->prepare($query); |
| 3328 | - $sth->execute(); |
|
| 3329 | - } catch(PDOException $e) { |
|
| 3330 | - return "error : ".$e->getMessage(); |
|
| 3331 | - } |
|
| 3328 | + $sth->execute(); |
|
| 3329 | + } catch(PDOException $e) { |
|
| 3330 | + return "error : ".$e->getMessage(); |
|
| 3331 | + } |
|
| 3332 | 3332 | } |
| 3333 | 3333 | |
| 3334 | 3334 | public static function update_all() { |
@@ -16,7 +16,7 @@ discard block |
||
| 16 | 16 | $ch = curl_init(); |
| 17 | 17 | curl_setopt($ch, CURLOPT_URL, $url); |
| 18 | 18 | if (isset($globalForceIPv4) && $globalForceIPv4) { |
| 19 | - if (defined('CURLOPT_IPRESOLVE') && defined('CURL_IPRESOLVE_V4')){ |
|
| 19 | + if (defined('CURLOPT_IPRESOLVE') && defined('CURL_IPRESOLVE_V4')) { |
|
| 20 | 20 | curl_setopt($ch, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4); |
| 21 | 21 | } |
| 22 | 22 | } |
@@ -34,20 +34,20 @@ discard block |
||
| 34 | 34 | fclose($fp); |
| 35 | 35 | } |
| 36 | 36 | |
| 37 | - public static function gunzip($in_file,$out_file_name = '') { |
|
| 37 | + public static function gunzip($in_file, $out_file_name = '') { |
|
| 38 | 38 | //echo $in_file.' -> '.$out_file_name."\n"; |
| 39 | 39 | $buffer_size = 4096; // read 4kb at a time |
| 40 | 40 | if ($out_file_name == '') $out_file_name = str_replace('.gz', '', $in_file); |
| 41 | 41 | if ($in_file != '' && file_exists($in_file)) { |
| 42 | 42 | // PHP version of Ubuntu use gzopen64 instead of gzopen |
| 43 | - if (function_exists('gzopen')) $file = gzopen($in_file,'rb'); |
|
| 44 | - elseif (function_exists('gzopen64')) $file = gzopen64($in_file,'rb'); |
|
| 43 | + if (function_exists('gzopen')) $file = gzopen($in_file, 'rb'); |
|
| 44 | + elseif (function_exists('gzopen64')) $file = gzopen64($in_file, 'rb'); |
|
| 45 | 45 | else { |
| 46 | 46 | echo 'gzopen not available'; |
| 47 | 47 | die; |
| 48 | 48 | } |
| 49 | 49 | $out_file = fopen($out_file_name, 'wb'); |
| 50 | - while(!gzeof($file)) { |
|
| 50 | + while (!gzeof($file)) { |
|
| 51 | 51 | fwrite($out_file, gzread($file, $buffer_size)); |
| 52 | 52 | } |
| 53 | 53 | fclose($out_file); |
@@ -71,7 +71,7 @@ discard block |
||
| 71 | 71 | try { |
| 72 | 72 | self::$db_sqlite = new PDO('sqlite:'.$database); |
| 73 | 73 | self::$db_sqlite->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); |
| 74 | - } catch(PDOException $e) { |
|
| 74 | + } catch (PDOException $e) { |
|
| 75 | 75 | return "error : ".$e->getMessage(); |
| 76 | 76 | } |
| 77 | 77 | } |
@@ -86,7 +86,7 @@ discard block |
||
| 86 | 86 | //$Connection = new Connection(); |
| 87 | 87 | $sth = $Connection->db->prepare($query); |
| 88 | 88 | $sth->execute(array(':source' => $database_file)); |
| 89 | - } catch(PDOException $e) { |
|
| 89 | + } catch (PDOException $e) { |
|
| 90 | 90 | return "error : ".$e->getMessage(); |
| 91 | 91 | } |
| 92 | 92 | |
@@ -97,7 +97,7 @@ discard block |
||
| 97 | 97 | try { |
| 98 | 98 | $sth = update_db::$db_sqlite->prepare($query); |
| 99 | 99 | $sth->execute(); |
| 100 | - } catch(PDOException $e) { |
|
| 100 | + } catch (PDOException $e) { |
|
| 101 | 101 | return "error : ".$e->getMessage(); |
| 102 | 102 | } |
| 103 | 103 | //$query_dest = 'INSERT INTO routes (`RouteID`,`CallSign`,`Operator_ICAO`,`FromAirport_ICAO`,`ToAirport_ICAO`,`RouteStop`,`Source`) VALUES (:RouteID, :CallSign, :Operator_ICAO, :FromAirport_ICAO, :ToAirport_ICAO, :routestop, :source)'; |
@@ -108,11 +108,11 @@ discard block |
||
| 108 | 108 | if ($globalTransaction) $Connection->db->beginTransaction(); |
| 109 | 109 | while ($values = $sth->fetch(PDO::FETCH_ASSOC)) { |
| 110 | 110 | //$query_dest_values = array(':RouteID' => $values['RouteId'],':CallSign' => $values['Callsign'],':Operator_ICAO' => $values['operator_icao'],':FromAirport_ICAO' => $values['FromAirportIcao'],':ToAirport_ICAO' => $values['ToAirportIcao'],':routestop' => $values['AllStop'],':source' => $database_file); |
| 111 | - $query_dest_values = array(':CallSign' => $values['Callsign'],':Operator_ICAO' => $values['operator_icao'],':FromAirport_ICAO' => $values['FromAirportIcao'],':ToAirport_ICAO' => $values['ToAirportIcao'],':routestop' => $values['AllStop'],':source' => $database_file); |
|
| 111 | + $query_dest_values = array(':CallSign' => $values['Callsign'], ':Operator_ICAO' => $values['operator_icao'], ':FromAirport_ICAO' => $values['FromAirportIcao'], ':ToAirport_ICAO' => $values['ToAirportIcao'], ':routestop' => $values['AllStop'], ':source' => $database_file); |
|
| 112 | 112 | $sth_dest->execute($query_dest_values); |
| 113 | 113 | } |
| 114 | 114 | if ($globalTransaction) $Connection->db->commit(); |
| 115 | - } catch(PDOException $e) { |
|
| 115 | + } catch (PDOException $e) { |
|
| 116 | 116 | if ($globalTransaction) $Connection->db->rollBack(); |
| 117 | 117 | return "error : ".$e->getMessage(); |
| 118 | 118 | } |
@@ -128,26 +128,26 @@ discard block |
||
| 128 | 128 | //$Connection = new Connection(); |
| 129 | 129 | $sth = $Connection->db->prepare($query); |
| 130 | 130 | $sth->execute(array(':source' => 'oneworld')); |
| 131 | - } catch(PDOException $e) { |
|
| 131 | + } catch (PDOException $e) { |
|
| 132 | 132 | return "error : ".$e->getMessage(); |
| 133 | 133 | } |
| 134 | 134 | |
| 135 | 135 | if ($globalDebug) echo " - Add routes to DB -"; |
| 136 | 136 | require_once(dirname(__FILE__).'/../require/class.Spotter.php'); |
| 137 | 137 | $Spotter = new Spotter(); |
| 138 | - if ($fh = fopen($database_file,"r")) { |
|
| 138 | + if ($fh = fopen($database_file, "r")) { |
|
| 139 | 139 | $query_dest = 'INSERT INTO routes (CallSign,Operator_ICAO,FromAirport_ICAO,FromAirport_Time,ToAirport_ICAO,ToAirport_Time,RouteStop,Source) VALUES (:CallSign, :Operator_ICAO, :FromAirport_ICAO,:FromAirport_Time, :ToAirport_ICAO, :ToAirport_Time,:routestop, :source)'; |
| 140 | 140 | $Connection = new Connection(); |
| 141 | 141 | $sth_dest = $Connection->db->prepare($query_dest); |
| 142 | 142 | if ($globalTransaction) $Connection->db->beginTransaction(); |
| 143 | 143 | while (!feof($fh)) { |
| 144 | - $line = fgetcsv($fh,9999,','); |
|
| 144 | + $line = fgetcsv($fh, 9999, ','); |
|
| 145 | 145 | if ($line[0] != '') { |
| 146 | 146 | if (($line[2] == '-' || ($line[2] != '-' && (strtotime($line[2]) > time()))) && ($line[3] == '-' || ($line[3] != '-' && (strtotime($line[3]) < time())))) { |
| 147 | 147 | try { |
| 148 | - $query_dest_values = array(':CallSign' => str_replace('*','',$line[7]),':Operator_ICAO' => '',':FromAirport_ICAO' => $Spotter->getAirportICAO($line[0]),':FromAirport_Time' => $line[5],':ToAirport_ICAO' => $Spotter->getAirportICAO($line[1]),':ToAirport_Time' => $line[6],':routestop' => '',':source' => 'oneworld'); |
|
| 148 | + $query_dest_values = array(':CallSign' => str_replace('*', '', $line[7]), ':Operator_ICAO' => '', ':FromAirport_ICAO' => $Spotter->getAirportICAO($line[0]), ':FromAirport_Time' => $line[5], ':ToAirport_ICAO' => $Spotter->getAirportICAO($line[1]), ':ToAirport_Time' => $line[6], ':routestop' => '', ':source' => 'oneworld'); |
|
| 149 | 149 | $sth_dest->execute($query_dest_values); |
| 150 | - } catch(PDOException $e) { |
|
| 150 | + } catch (PDOException $e) { |
|
| 151 | 151 | if ($globalTransaction) $Connection->db->rollBack(); |
| 152 | 152 | return "error : ".$e->getMessage(); |
| 153 | 153 | } |
@@ -169,7 +169,7 @@ discard block |
||
| 169 | 169 | //$Connection = new Connection(); |
| 170 | 170 | $sth = $Connection->db->prepare($query); |
| 171 | 171 | $sth->execute(array(':source' => 'skyteam')); |
| 172 | - } catch(PDOException $e) { |
|
| 172 | + } catch (PDOException $e) { |
|
| 173 | 173 | return "error : ".$e->getMessage(); |
| 174 | 174 | } |
| 175 | 175 | |
@@ -177,24 +177,24 @@ discard block |
||
| 177 | 177 | |
| 178 | 178 | require_once(dirname(__FILE__).'/../require/class.Spotter.php'); |
| 179 | 179 | $Spotter = new Spotter(); |
| 180 | - if ($fh = fopen($database_file,"r")) { |
|
| 180 | + if ($fh = fopen($database_file, "r")) { |
|
| 181 | 181 | $query_dest = 'INSERT INTO routes (CallSign,Operator_ICAO,FromAirport_ICAO,FromAirport_Time,ToAirport_ICAO,ToAirport_Time,RouteStop,Source) VALUES (:CallSign, :Operator_ICAO, :FromAirport_ICAO,:FromAirport_Time, :ToAirport_ICAO, :ToAirport_Time,:routestop, :source)'; |
| 182 | 182 | $Connection = new Connection(); |
| 183 | 183 | $sth_dest = $Connection->db->prepare($query_dest); |
| 184 | 184 | try { |
| 185 | 185 | if ($globalTransaction) $Connection->db->beginTransaction(); |
| 186 | 186 | while (!feof($fh)) { |
| 187 | - $line = fgetcsv($fh,9999,','); |
|
| 187 | + $line = fgetcsv($fh, 9999, ','); |
|
| 188 | 188 | if ($line[0] != '') { |
| 189 | - $datebe = explode(' - ',$line[2]); |
|
| 189 | + $datebe = explode(' - ', $line[2]); |
|
| 190 | 190 | if (strtotime($datebe[0]) > time() && strtotime($datebe[1]) < time()) { |
| 191 | - $query_dest_values = array(':CallSign' => str_replace('*','',$line[6]),':Operator_ICAO' => '',':FromAirport_ICAO' => $Spotter->getAirportICAO($line[0]),':FromAirport_Time' => $line[4],':ToAirport_ICAO' => $Spotter->getAirportICAO($line[1]),':ToAirport_Time' => $line[5],':routestop' => '',':source' => 'skyteam'); |
|
| 191 | + $query_dest_values = array(':CallSign' => str_replace('*', '', $line[6]), ':Operator_ICAO' => '', ':FromAirport_ICAO' => $Spotter->getAirportICAO($line[0]), ':FromAirport_Time' => $line[4], ':ToAirport_ICAO' => $Spotter->getAirportICAO($line[1]), ':ToAirport_Time' => $line[5], ':routestop' => '', ':source' => 'skyteam'); |
|
| 192 | 192 | $sth_dest->execute($query_dest_values); |
| 193 | 193 | } |
| 194 | 194 | } |
| 195 | 195 | } |
| 196 | 196 | if ($globalTransaction) $Connection->db->commit(); |
| 197 | - } catch(PDOException $e) { |
|
| 197 | + } catch (PDOException $e) { |
|
| 198 | 198 | if ($globalTransaction) $Connection->db->rollBack(); |
| 199 | 199 | return "error : ".$e->getMessage(); |
| 200 | 200 | } |
@@ -209,7 +209,7 @@ discard block |
||
| 209 | 209 | $Connection = new Connection(); |
| 210 | 210 | $sth = $Connection->db->prepare($query); |
| 211 | 211 | $sth->execute(array(':source' => $database_file)); |
| 212 | - } catch(PDOException $e) { |
|
| 212 | + } catch (PDOException $e) { |
|
| 213 | 213 | return "error : ".$e->getMessage(); |
| 214 | 214 | } |
| 215 | 215 | $query = "DELETE FROM aircraft_owner WHERE Source = '' OR Source IS NULL OR Source = :source"; |
@@ -217,7 +217,7 @@ discard block |
||
| 217 | 217 | $Connection = new Connection(); |
| 218 | 218 | $sth = $Connection->db->prepare($query); |
| 219 | 219 | $sth->execute(array(':source' => $database_file)); |
| 220 | - } catch(PDOException $e) { |
|
| 220 | + } catch (PDOException $e) { |
|
| 221 | 221 | return "error : ".$e->getMessage(); |
| 222 | 222 | } |
| 223 | 223 | |
@@ -226,7 +226,7 @@ discard block |
||
| 226 | 226 | try { |
| 227 | 227 | $sth = update_db::$db_sqlite->prepare($query); |
| 228 | 228 | $sth->execute(); |
| 229 | - } catch(PDOException $e) { |
|
| 229 | + } catch (PDOException $e) { |
|
| 230 | 230 | return "error : ".$e->getMessage(); |
| 231 | 231 | } |
| 232 | 232 | //$query_dest = 'INSERT INTO aircraft_modes (`AircraftID`,`FirstCreated`,`LastModified`, `ModeS`,`ModeSCountry`,`Registration`,`ICAOTypeCode`,`SerialNo`, `OperatorFlagCode`, `Manufacturer`, `Type`, `FirstRegDate`, `CurrentRegDate`, `Country`, `PreviousID`, `DeRegDate`, `Status`, `PopularName`,`GenericName`,`AircraftClass`, `Engines`, `OwnershipStatus`,`RegisteredOwners`,`MTOW`, `TotalHours`, `YearBuilt`, `CofACategory`, `CofAExpiry`, `UserNotes`, `Interested`, `UserTag`, `InfoUrl`, `PictureUrl1`, `PictureUrl2`, `PictureUrl3`, `UserBool1`, `UserBool2`, `UserBool3`, `UserBool4`, `UserBool5`, `UserString1`, `UserString2`, `UserString3`, `UserString4`, `UserString5`, `UserInt1`, `UserInt2`, `UserInt3`, `UserInt4`, `UserInt5`) VALUES (:AircraftID,:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:SerialNo, :OperatorFlagCode, :Manufacturer, :Type, :FirstRegDate, :CurrentRegDate, :Country, :PreviousID, :DeRegDate, :Status, :PopularName,:GenericName,:AircraftClass, :Engines, :OwnershipStatus,:RegisteredOwners,:MTOW, :TotalHours,:YearBuilt, :CofACategory, :CofAExpiry, :UserNotes, :Interested, :UserTag, :InfoUrl, :PictureUrl1, :PictureUrl2, :PictureUrl3, :UserBool1, :UserBool2, :UserBool3, :UserBool4, :UserBool5, :UserString1, :UserString2, :UserString3, :UserString4, :UserString5, :UserInt1, :UserInt2, :UserInt3, :UserInt4, :UserInt5)'; |
@@ -243,15 +243,15 @@ discard block |
||
| 243 | 243 | //$query_dest_values = array(':AircraftID' => $values['AircraftID'],':FirstCreated' => $values['FirstCreated'],':LastModified' => $values['LastModified'],':ModeS' => $values['ModeS'],':ModeSCountry' => $values['ModeSCountry'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':SerialNo' => $values['SerialNo'], ':OperatorFlagCode' => $values['OperatorFlagCode'], ':Manufacturer' => $values['Manufacturer'], ':Type' => $values['Type'], ':FirstRegDate' => $values['FirstRegDate'], ':CurrentRegDate' => $values['CurrentRegDate'], ':Country' => $values['Country'], ':PreviousID' => $values['PreviousID'], ':DeRegDate' => $values['DeRegDate'], ':Status' => $values['Status'], ':PopularName' => $values['PopularName'],':GenericName' => $values['GenericName'],':AircraftClass' => $values['AircraftClass'], ':Engines' => $values['Engines'], ':OwnershipStatus' => $values['OwnershipStatus'],':RegisteredOwners' => $values['RegisteredOwners'],':MTOW' => $values['MTOW'], ':TotalHours' => $values['TotalHours'],':YearBuilt' => $values['YearBuilt'], ':CofACategory' => $values['CofACategory'], ':CofAExpiry' => $values['CofAExpiry'], ':UserNotes' => $values['UserNotes'], ':Interested' => $values['Interested'], ':UserTag' => $values['UserTag'], ':InfoUrl' => $values['InfoURL'], ':PictureUrl1' => $values['PictureURL1'], ':PictureUrl2' => $values['PictureURL2'], ':PictureUrl3' => $values['PictureURL3'], ':UserBool1' => $values['UserBool1'], ':UserBool2' => $values['UserBool2'], ':UserBool3' => $values['UserBool3'], ':UserBool4' => $values['UserBool4'], ':UserBool5' => $values['UserBool5'], ':UserString1' => $values['UserString1'], ':UserString2' => $values['UserString2'], ':UserString3' => $values['UserString3'], ':UserString4' => $values['UserString4'], ':UserString5' => $values['UserString5'], ':UserInt1' => $values['UserInt1'], ':UserInt2' => $values['UserInt2'], ':UserInt3' => $values['UserInt3'], ':UserInt4' => $values['UserInt4'], ':UserInt5' => $values['UserInt5']); |
| 244 | 244 | if ($values['UserString4'] == 'M') $type = 'military'; |
| 245 | 245 | else $type = null; |
| 246 | - $query_dest_values = array(':LastModified' => $values['LastModified'],':ModeS' => $values['ModeS'],':ModeSCountry' => $values['ModeSCountry'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':source' => $database_file,':type' => $type); |
|
| 246 | + $query_dest_values = array(':LastModified' => $values['LastModified'], ':ModeS' => $values['ModeS'], ':ModeSCountry' => $values['ModeSCountry'], ':Registration' => $values['Registration'], ':ICAOTypeCode' => $values['ICAOTypeCode'], ':source' => $database_file, ':type' => $type); |
|
| 247 | 247 | $sth_dest->execute($query_dest_values); |
| 248 | 248 | if ($values['RegisteredOwners'] != '' && $values['RegisteredOwners'] != NULL && $values['RegisteredOwners'] != 'Private') { |
| 249 | - $query_dest_owner_values = array(':registration' => $values['Registration'],':source' => $database_file,':owner' => $values['RegisteredOwners']); |
|
| 249 | + $query_dest_owner_values = array(':registration' => $values['Registration'], ':source' => $database_file, ':owner' => $values['RegisteredOwners']); |
|
| 250 | 250 | $sth_dest_owner->execute($query_dest_owner_values); |
| 251 | 251 | } |
| 252 | 252 | } |
| 253 | 253 | if ($globalTransaction) $Connection->db->commit(); |
| 254 | - } catch(PDOException $e) { |
|
| 254 | + } catch (PDOException $e) { |
|
| 255 | 255 | return "error : ".$e->getMessage(); |
| 256 | 256 | } |
| 257 | 257 | |
@@ -261,7 +261,7 @@ discard block |
||
| 261 | 261 | $Connection = new Connection(); |
| 262 | 262 | $sth = $Connection->db->prepare($query); |
| 263 | 263 | $sth->execute(array(':source' => $database_file)); |
| 264 | - } catch(PDOException $e) { |
|
| 264 | + } catch (PDOException $e) { |
|
| 265 | 265 | return "error : ".$e->getMessage(); |
| 266 | 266 | } |
| 267 | 267 | return ''; |
@@ -276,11 +276,11 @@ discard block |
||
| 276 | 276 | $Connection = new Connection(); |
| 277 | 277 | $sth = $Connection->db->prepare($query); |
| 278 | 278 | $sth->execute(array(':source' => $database_file)); |
| 279 | - } catch(PDOException $e) { |
|
| 279 | + } catch (PDOException $e) { |
|
| 280 | 280 | return "error : ".$e->getMessage(); |
| 281 | 281 | } |
| 282 | 282 | |
| 283 | - if ($fh = fopen($database_file,"r")) { |
|
| 283 | + if ($fh = fopen($database_file, "r")) { |
|
| 284 | 284 | //$query_dest = 'INSERT INTO aircraft_modes (`AircraftID`,`FirstCreated`,`LastModified`, `ModeS`,`ModeSCountry`,`Registration`,`ICAOTypeCode`,`SerialNo`, `OperatorFlagCode`, `Manufacturer`, `Type`, `FirstRegDate`, `CurrentRegDate`, `Country`, `PreviousID`, `DeRegDate`, `Status`, `PopularName`,`GenericName`,`AircraftClass`, `Engines`, `OwnershipStatus`,`RegisteredOwners`,`MTOW`, `TotalHours`, `YearBuilt`, `CofACategory`, `CofAExpiry`, `UserNotes`, `Interested`, `UserTag`, `InfoUrl`, `PictureUrl1`, `PictureUrl2`, `PictureUrl3`, `UserBool1`, `UserBool2`, `UserBool3`, `UserBool4`, `UserBool5`, `UserString1`, `UserString2`, `UserString3`, `UserString4`, `UserString5`, `UserInt1`, `UserInt2`, `UserInt3`, `UserInt4`, `UserInt5`) VALUES (:AircraftID,:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:SerialNo, :OperatorFlagCode, :Manufacturer, :Type, :FirstRegDate, :CurrentRegDate, :Country, :PreviousID, :DeRegDate, :Status, :PopularName,:GenericName,:AircraftClass, :Engines, :OwnershipStatus,:RegisteredOwners,:MTOW, :TotalHours,:YearBuilt, :CofACategory, :CofAExpiry, :UserNotes, :Interested, :UserTag, :InfoUrl, :PictureUrl1, :PictureUrl2, :PictureUrl3, :UserBool1, :UserBool2, :UserBool3, :UserBool4, :UserBool5, :UserString1, :UserString2, :UserString3, :UserString4, :UserString5, :UserInt1, :UserInt2, :UserInt3, :UserInt4, :UserInt5)'; |
| 285 | 285 | $query_dest = 'INSERT INTO aircraft_modes (ModeS,Registration,ICAOTypeCode,Source,source_type) VALUES (:ModeS,:Registration,:ICAOTypeCode,:source,:source_type)'; |
| 286 | 286 | |
@@ -290,13 +290,13 @@ discard block |
||
| 290 | 290 | if ($globalTransaction) $Connection->db->beginTransaction(); |
| 291 | 291 | while (!feof($fh)) { |
| 292 | 292 | $values = array(); |
| 293 | - $line = $Common->hex2str(fgets($fh,9999)); |
|
| 293 | + $line = $Common->hex2str(fgets($fh, 9999)); |
|
| 294 | 294 | //FFFFFF RIDEAU VALLEY SOARINGASW-20 C-FBKN MZ 123.400 |
| 295 | - $values['ModeS'] = substr($line,0,6); |
|
| 296 | - $values['Registration'] = trim(substr($line,69,6)); |
|
| 297 | - $aircraft_name = trim(substr($line,48,6)); |
|
| 295 | + $values['ModeS'] = substr($line, 0, 6); |
|
| 296 | + $values['Registration'] = trim(substr($line, 69, 6)); |
|
| 297 | + $aircraft_name = trim(substr($line, 48, 6)); |
|
| 298 | 298 | // Check if we can find ICAO, else set it to GLID |
| 299 | - $aircraft_name_split = explode(' ',$aircraft_name); |
|
| 299 | + $aircraft_name_split = explode(' ', $aircraft_name); |
|
| 300 | 300 | $search_more = ''; |
| 301 | 301 | if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'"; |
| 302 | 302 | $query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more; |
@@ -308,20 +308,20 @@ discard block |
||
| 308 | 308 | if (isset($result['icao']) && $result['icao'] != '') { |
| 309 | 309 | $values['ICAOTypeCode'] = $result['icao']; |
| 310 | 310 | } |
| 311 | - } catch(PDOException $e) { |
|
| 311 | + } catch (PDOException $e) { |
|
| 312 | 312 | return "error : ".$e->getMessage(); |
| 313 | 313 | } |
| 314 | 314 | if (!isset($values['ICAOTypeCode'])) $values['ICAOTypeCode'] = 'GLID'; |
| 315 | 315 | // Add data to db |
| 316 | 316 | if ($values['Registration'] != '' && $values['Registration'] != '0000') { |
| 317 | 317 | //$query_dest_values = array(':AircraftID' => $values['AircraftID'],':FirstCreated' => $values['FirstCreated'],':LastModified' => $values['LastModified'],':ModeS' => $values['ModeS'],':ModeSCountry' => $values['ModeSCountry'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':SerialNo' => $values['SerialNo'], ':OperatorFlagCode' => $values['OperatorFlagCode'], ':Manufacturer' => $values['Manufacturer'], ':Type' => $values['Type'], ':FirstRegDate' => $values['FirstRegDate'], ':CurrentRegDate' => $values['CurrentRegDate'], ':Country' => $values['Country'], ':PreviousID' => $values['PreviousID'], ':DeRegDate' => $values['DeRegDate'], ':Status' => $values['Status'], ':PopularName' => $values['PopularName'],':GenericName' => $values['GenericName'],':AircraftClass' => $values['AircraftClass'], ':Engines' => $values['Engines'], ':OwnershipStatus' => $values['OwnershipStatus'],':RegisteredOwners' => $values['RegisteredOwners'],':MTOW' => $values['MTOW'], ':TotalHours' => $values['TotalHours'],':YearBuilt' => $values['YearBuilt'], ':CofACategory' => $values['CofACategory'], ':CofAExpiry' => $values['CofAExpiry'], ':UserNotes' => $values['UserNotes'], ':Interested' => $values['Interested'], ':UserTag' => $values['UserTag'], ':InfoUrl' => $values['InfoURL'], ':PictureUrl1' => $values['PictureURL1'], ':PictureUrl2' => $values['PictureURL2'], ':PictureUrl3' => $values['PictureURL3'], ':UserBool1' => $values['UserBool1'], ':UserBool2' => $values['UserBool2'], ':UserBool3' => $values['UserBool3'], ':UserBool4' => $values['UserBool4'], ':UserBool5' => $values['UserBool5'], ':UserString1' => $values['UserString1'], ':UserString2' => $values['UserString2'], ':UserString3' => $values['UserString3'], ':UserString4' => $values['UserString4'], ':UserString5' => $values['UserString5'], ':UserInt1' => $values['UserInt1'], ':UserInt2' => $values['UserInt2'], ':UserInt3' => $values['UserInt3'], ':UserInt4' => $values['UserInt4'], ':UserInt5' => $values['UserInt5']); |
| 318 | - $query_dest_values = array(':ModeS' => $values['ModeS'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':source' => $database_file,':source_type' => 'flarm'); |
|
| 318 | + $query_dest_values = array(':ModeS' => $values['ModeS'], ':Registration' => $values['Registration'], ':ICAOTypeCode' => $values['ICAOTypeCode'], ':source' => $database_file, ':source_type' => 'flarm'); |
|
| 319 | 319 | //print_r($query_dest_values); |
| 320 | 320 | $sth_dest->execute($query_dest_values); |
| 321 | 321 | } |
| 322 | 322 | } |
| 323 | 323 | if ($globalTransaction) $Connection->db->commit(); |
| 324 | - } catch(PDOException $e) { |
|
| 324 | + } catch (PDOException $e) { |
|
| 325 | 325 | return "error : ".$e->getMessage(); |
| 326 | 326 | } |
| 327 | 327 | } |
@@ -331,7 +331,7 @@ discard block |
||
| 331 | 331 | $Connection = new Connection(); |
| 332 | 332 | $sth = $Connection->db->prepare($query); |
| 333 | 333 | $sth->execute(array(':source' => $database_file)); |
| 334 | - } catch(PDOException $e) { |
|
| 334 | + } catch (PDOException $e) { |
|
| 335 | 335 | return "error : ".$e->getMessage(); |
| 336 | 336 | } |
| 337 | 337 | return ''; |
@@ -345,11 +345,11 @@ discard block |
||
| 345 | 345 | $Connection = new Connection(); |
| 346 | 346 | $sth = $Connection->db->prepare($query); |
| 347 | 347 | $sth->execute(array(':source' => $database_file)); |
| 348 | - } catch(PDOException $e) { |
|
| 348 | + } catch (PDOException $e) { |
|
| 349 | 349 | return "error : ".$e->getMessage(); |
| 350 | 350 | } |
| 351 | 351 | |
| 352 | - if ($fh = fopen($database_file,"r")) { |
|
| 352 | + if ($fh = fopen($database_file, "r")) { |
|
| 353 | 353 | //$query_dest = 'INSERT INTO aircraft_modes (`AircraftID`,`FirstCreated`,`LastModified`, `ModeS`,`ModeSCountry`,`Registration`,`ICAOTypeCode`,`SerialNo`, `OperatorFlagCode`, `Manufacturer`, `Type`, `FirstRegDate`, `CurrentRegDate`, `Country`, `PreviousID`, `DeRegDate`, `Status`, `PopularName`,`GenericName`,`AircraftClass`, `Engines`, `OwnershipStatus`,`RegisteredOwners`,`MTOW`, `TotalHours`, `YearBuilt`, `CofACategory`, `CofAExpiry`, `UserNotes`, `Interested`, `UserTag`, `InfoUrl`, `PictureUrl1`, `PictureUrl2`, `PictureUrl3`, `UserBool1`, `UserBool2`, `UserBool3`, `UserBool4`, `UserBool5`, `UserString1`, `UserString2`, `UserString3`, `UserString4`, `UserString5`, `UserInt1`, `UserInt2`, `UserInt3`, `UserInt4`, `UserInt5`) VALUES (:AircraftID,:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:SerialNo, :OperatorFlagCode, :Manufacturer, :Type, :FirstRegDate, :CurrentRegDate, :Country, :PreviousID, :DeRegDate, :Status, :PopularName,:GenericName,:AircraftClass, :Engines, :OwnershipStatus,:RegisteredOwners,:MTOW, :TotalHours,:YearBuilt, :CofACategory, :CofAExpiry, :UserNotes, :Interested, :UserTag, :InfoUrl, :PictureUrl1, :PictureUrl2, :PictureUrl3, :UserBool1, :UserBool2, :UserBool3, :UserBool4, :UserBool5, :UserString1, :UserString2, :UserString3, :UserString4, :UserString5, :UserInt1, :UserInt2, :UserInt3, :UserInt4, :UserInt5)'; |
| 354 | 354 | $query_dest = 'INSERT INTO aircraft_modes (LastModified,ModeS,Registration,ICAOTypeCode,Source,source_type) VALUES (:lastmodified,:ModeS,:Registration,:ICAOTypeCode,:source,:source_type)'; |
| 355 | 355 | |
@@ -357,9 +357,9 @@ discard block |
||
| 357 | 357 | $sth_dest = $Connection->db->prepare($query_dest); |
| 358 | 358 | try { |
| 359 | 359 | if ($globalTransaction) $Connection->db->beginTransaction(); |
| 360 | - $tmp = fgetcsv($fh,9999,',',"'"); |
|
| 360 | + $tmp = fgetcsv($fh, 9999, ',', "'"); |
|
| 361 | 361 | while (!feof($fh)) { |
| 362 | - $line = fgetcsv($fh,9999,',',"'"); |
|
| 362 | + $line = fgetcsv($fh, 9999, ',', "'"); |
|
| 363 | 363 | |
| 364 | 364 | //FFFFFF RIDEAU VALLEY SOARINGASW-20 C-FBKN MZ 123.400 |
| 365 | 365 | //print_r($line); |
@@ -368,7 +368,7 @@ discard block |
||
| 368 | 368 | $values['ICAOTypeCode'] = ''; |
| 369 | 369 | $aircraft_name = $line[2]; |
| 370 | 370 | // Check if we can find ICAO, else set it to GLID |
| 371 | - $aircraft_name_split = explode(' ',$aircraft_name); |
|
| 371 | + $aircraft_name_split = explode(' ', $aircraft_name); |
|
| 372 | 372 | $search_more = ''; |
| 373 | 373 | if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'"; |
| 374 | 374 | $query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more; |
@@ -377,20 +377,20 @@ discard block |
||
| 377 | 377 | $sth_search->execute(); |
| 378 | 378 | $result = $sth_search->fetch(PDO::FETCH_ASSOC); |
| 379 | 379 | if (isset($result['icao']) && $result['icao'] != '') $values['ICAOTypeCode'] = $result['icao']; |
| 380 | - } catch(PDOException $e) { |
|
| 380 | + } catch (PDOException $e) { |
|
| 381 | 381 | return "error : ".$e->getMessage(); |
| 382 | 382 | } |
| 383 | 383 | //if (!isset($values['ICAOTypeCode'])) $values['ICAOTypeCode'] = 'GLID'; |
| 384 | 384 | // Add data to db |
| 385 | 385 | if ($values['Registration'] != '' && $values['Registration'] != '0000' && $values['ICAOTypeCode'] != '') { |
| 386 | 386 | //$query_dest_values = array(':AircraftID' => $values['AircraftID'],':FirstCreated' => $values['FirstCreated'],':LastModified' => $values['LastModified'],':ModeS' => $values['ModeS'],':ModeSCountry' => $values['ModeSCountry'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':SerialNo' => $values['SerialNo'], ':OperatorFlagCode' => $values['OperatorFlagCode'], ':Manufacturer' => $values['Manufacturer'], ':Type' => $values['Type'], ':FirstRegDate' => $values['FirstRegDate'], ':CurrentRegDate' => $values['CurrentRegDate'], ':Country' => $values['Country'], ':PreviousID' => $values['PreviousID'], ':DeRegDate' => $values['DeRegDate'], ':Status' => $values['Status'], ':PopularName' => $values['PopularName'],':GenericName' => $values['GenericName'],':AircraftClass' => $values['AircraftClass'], ':Engines' => $values['Engines'], ':OwnershipStatus' => $values['OwnershipStatus'],':RegisteredOwners' => $values['RegisteredOwners'],':MTOW' => $values['MTOW'], ':TotalHours' => $values['TotalHours'],':YearBuilt' => $values['YearBuilt'], ':CofACategory' => $values['CofACategory'], ':CofAExpiry' => $values['CofAExpiry'], ':UserNotes' => $values['UserNotes'], ':Interested' => $values['Interested'], ':UserTag' => $values['UserTag'], ':InfoUrl' => $values['InfoURL'], ':PictureUrl1' => $values['PictureURL1'], ':PictureUrl2' => $values['PictureURL2'], ':PictureUrl3' => $values['PictureURL3'], ':UserBool1' => $values['UserBool1'], ':UserBool2' => $values['UserBool2'], ':UserBool3' => $values['UserBool3'], ':UserBool4' => $values['UserBool4'], ':UserBool5' => $values['UserBool5'], ':UserString1' => $values['UserString1'], ':UserString2' => $values['UserString2'], ':UserString3' => $values['UserString3'], ':UserString4' => $values['UserString4'], ':UserString5' => $values['UserString5'], ':UserInt1' => $values['UserInt1'], ':UserInt2' => $values['UserInt2'], ':UserInt3' => $values['UserInt3'], ':UserInt4' => $values['UserInt4'], ':UserInt5' => $values['UserInt5']); |
| 387 | - $query_dest_values = array(':lastmodified' => date('Y-m-d H:m:s'),':ModeS' => $values['ModeS'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':source' => $database_file,':source_type' => 'flarm'); |
|
| 387 | + $query_dest_values = array(':lastmodified' => date('Y-m-d H:m:s'), ':ModeS' => $values['ModeS'], ':Registration' => $values['Registration'], ':ICAOTypeCode' => $values['ICAOTypeCode'], ':source' => $database_file, ':source_type' => 'flarm'); |
|
| 388 | 388 | //print_r($query_dest_values); |
| 389 | 389 | $sth_dest->execute($query_dest_values); |
| 390 | 390 | } |
| 391 | 391 | } |
| 392 | 392 | if ($globalTransaction) $Connection->db->commit(); |
| 393 | - } catch(PDOException $e) { |
|
| 393 | + } catch (PDOException $e) { |
|
| 394 | 394 | return "error : ".$e->getMessage(); |
| 395 | 395 | } |
| 396 | 396 | } |
@@ -400,13 +400,13 @@ discard block |
||
| 400 | 400 | $Connection = new Connection(); |
| 401 | 401 | $sth = $Connection->db->prepare($query); |
| 402 | 402 | $sth->execute(array(':source' => $database_file)); |
| 403 | - } catch(PDOException $e) { |
|
| 403 | + } catch (PDOException $e) { |
|
| 404 | 404 | return "error : ".$e->getMessage(); |
| 405 | 405 | } |
| 406 | 406 | return ''; |
| 407 | 407 | } |
| 408 | 408 | |
| 409 | - public static function retrieve_owner($database_file,$country = 'F') { |
|
| 409 | + public static function retrieve_owner($database_file, $country = 'F') { |
|
| 410 | 410 | global $globalTransaction, $globalMasterSource; |
| 411 | 411 | //$query = 'TRUNCATE TABLE aircraft_modes'; |
| 412 | 412 | $query = "DELETE FROM aircraft_owner WHERE Source = '' OR Source IS NULL OR Source = :source; DELETE FROM aircraft_modes WHERE Source = :source;"; |
@@ -414,12 +414,12 @@ discard block |
||
| 414 | 414 | $Connection = new Connection(); |
| 415 | 415 | $sth = $Connection->db->prepare($query); |
| 416 | 416 | $sth->execute(array(':source' => $database_file)); |
| 417 | - } catch(PDOException $e) { |
|
| 417 | + } catch (PDOException $e) { |
|
| 418 | 418 | return "error : ".$e->getMessage(); |
| 419 | 419 | } |
| 420 | 420 | require_once(dirname(__FILE__).'/../require/class.Spotter.php'); |
| 421 | 421 | $Spotter = new Spotter(); |
| 422 | - if ($fh = fopen($database_file,"r")) { |
|
| 422 | + if ($fh = fopen($database_file, "r")) { |
|
| 423 | 423 | //$query_dest = 'INSERT INTO aircraft_modes (`AircraftID`,`FirstCreated`,`LastModified`, `ModeS`,`ModeSCountry`,`Registration`,`ICAOTypeCode`,`SerialNo`, `OperatorFlagCode`, `Manufacturer`, `Type`, `FirstRegDate`, `CurrentRegDate`, `Country`, `PreviousID`, `DeRegDate`, `Status`, `PopularName`,`GenericName`,`AircraftClass`, `Engines`, `OwnershipStatus`,`RegisteredOwners`,`MTOW`, `TotalHours`, `YearBuilt`, `CofACategory`, `CofAExpiry`, `UserNotes`, `Interested`, `UserTag`, `InfoUrl`, `PictureUrl1`, `PictureUrl2`, `PictureUrl3`, `UserBool1`, `UserBool2`, `UserBool3`, `UserBool4`, `UserBool5`, `UserString1`, `UserString2`, `UserString3`, `UserString4`, `UserString5`, `UserInt1`, `UserInt2`, `UserInt3`, `UserInt4`, `UserInt5`) VALUES (:AircraftID,:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:SerialNo, :OperatorFlagCode, :Manufacturer, :Type, :FirstRegDate, :CurrentRegDate, :Country, :PreviousID, :DeRegDate, :Status, :PopularName,:GenericName,:AircraftClass, :Engines, :OwnershipStatus,:RegisteredOwners,:MTOW, :TotalHours,:YearBuilt, :CofACategory, :CofAExpiry, :UserNotes, :Interested, :UserTag, :InfoUrl, :PictureUrl1, :PictureUrl2, :PictureUrl3, :UserBool1, :UserBool2, :UserBool3, :UserBool4, :UserBool5, :UserString1, :UserString2, :UserString3, :UserString4, :UserString5, :UserInt1, :UserInt2, :UserInt3, :UserInt4, :UserInt5)'; |
| 424 | 424 | $query_dest = 'INSERT INTO aircraft_owner (registration,base,owner,date_first_reg,Source) VALUES (:registration,:base,:owner,:date_first_reg,:source)'; |
| 425 | 425 | $query_modes = 'INSERT INTO aircraft_modes (ModeS,ModeSCountry,Registration,ICAOTypeCode,Source) VALUES (:modes,:modescountry,:registration,:icaotypecode,:source)'; |
@@ -429,9 +429,9 @@ discard block |
||
| 429 | 429 | $sth_modes = $Connection->db->prepare($query_modes); |
| 430 | 430 | try { |
| 431 | 431 | if ($globalTransaction) $Connection->db->beginTransaction(); |
| 432 | - $tmp = fgetcsv($fh,9999,',','"'); |
|
| 432 | + $tmp = fgetcsv($fh, 9999, ',', '"'); |
|
| 433 | 433 | while (!feof($fh)) { |
| 434 | - $line = fgetcsv($fh,9999,',','"'); |
|
| 434 | + $line = fgetcsv($fh, 9999, ',', '"'); |
|
| 435 | 435 | $values = array(); |
| 436 | 436 | //print_r($line); |
| 437 | 437 | if ($country == 'F') { |
@@ -439,7 +439,7 @@ discard block |
||
| 439 | 439 | $values['base'] = $line[4]; |
| 440 | 440 | $values['owner'] = $line[5]; |
| 441 | 441 | if ($line[6] == '') $values['date_first_reg'] = null; |
| 442 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6])); |
|
| 442 | + else $values['date_first_reg'] = date("Y-m-d", strtotime($line[6])); |
|
| 443 | 443 | $values['cancel'] = $line[7]; |
| 444 | 444 | } elseif ($country == 'EI') { |
| 445 | 445 | // TODO : add modeS & reg to aircraft_modes |
@@ -447,7 +447,7 @@ discard block |
||
| 447 | 447 | $values['base'] = $line[3]; |
| 448 | 448 | $values['owner'] = $line[2]; |
| 449 | 449 | if ($line[1] == '') $values['date_first_reg'] = null; |
| 450 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[1])); |
|
| 450 | + else $values['date_first_reg'] = date("Y-m-d", strtotime($line[1])); |
|
| 451 | 451 | $values['cancel'] = ''; |
| 452 | 452 | $values['modes'] = $line[7]; |
| 453 | 453 | $values['icao'] = $line[8]; |
@@ -467,7 +467,7 @@ discard block |
||
| 467 | 467 | $values['base'] = null; |
| 468 | 468 | $values['owner'] = $line[5]; |
| 469 | 469 | if ($line[18] == '') $values['date_first_reg'] = null; |
| 470 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[18])); |
|
| 470 | + else $values['date_first_reg'] = date("Y-m-d", strtotime($line[18])); |
|
| 471 | 471 | $values['cancel'] = ''; |
| 472 | 472 | } elseif ($country == 'VH') { |
| 473 | 473 | // TODO : add modeS & reg to aircraft_modes |
@@ -475,7 +475,7 @@ discard block |
||
| 475 | 475 | $values['base'] = null; |
| 476 | 476 | $values['owner'] = $line[12]; |
| 477 | 477 | if ($line[28] == '') $values['date_first_reg'] = null; |
| 478 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[28])); |
|
| 478 | + else $values['date_first_reg'] = date("Y-m-d", strtotime($line[28])); |
|
| 479 | 479 | |
| 480 | 480 | $values['cancel'] = $line[39]; |
| 481 | 481 | } elseif ($country == 'OE' || $country == '9A' || $country == 'VP' || $country == 'LX' || $country == 'P2' || $country == 'HC') { |
@@ -495,28 +495,28 @@ discard block |
||
| 495 | 495 | $values['base'] = null; |
| 496 | 496 | $values['owner'] = $line[8]; |
| 497 | 497 | if ($line[7] == '') $values['date_first_reg'] = null; |
| 498 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7])); |
|
| 498 | + else $values['date_first_reg'] = date("Y-m-d", strtotime($line[7])); |
|
| 499 | 499 | $values['cancel'] = ''; |
| 500 | 500 | } elseif ($country == 'PP') { |
| 501 | 501 | $values['registration'] = $line[0]; |
| 502 | 502 | $values['base'] = null; |
| 503 | 503 | $values['owner'] = $line[4]; |
| 504 | 504 | if ($line[6] == '') $values['date_first_reg'] = null; |
| 505 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6])); |
|
| 505 | + else $values['date_first_reg'] = date("Y-m-d", strtotime($line[6])); |
|
| 506 | 506 | $values['cancel'] = $line[7]; |
| 507 | 507 | } elseif ($country == 'E7') { |
| 508 | 508 | $values['registration'] = $line[0]; |
| 509 | 509 | $values['base'] = null; |
| 510 | 510 | $values['owner'] = $line[4]; |
| 511 | 511 | if ($line[5] == '') $values['date_first_reg'] = null; |
| 512 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[5])); |
|
| 512 | + else $values['date_first_reg'] = date("Y-m-d", strtotime($line[5])); |
|
| 513 | 513 | $values['cancel'] = ''; |
| 514 | 514 | } elseif ($country == '8Q') { |
| 515 | 515 | $values['registration'] = $line[0]; |
| 516 | 516 | $values['base'] = null; |
| 517 | 517 | $values['owner'] = $line[3]; |
| 518 | 518 | if ($line[7] == '') $values['date_first_reg'] = null; |
| 519 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7])); |
|
| 519 | + else $values['date_first_reg'] = date("Y-m-d", strtotime($line[7])); |
|
| 520 | 520 | $values['cancel'] = ''; |
| 521 | 521 | } elseif ($country == 'ZK') { |
| 522 | 522 | $values['registration'] = $line[0]; |
@@ -530,18 +530,18 @@ discard block |
||
| 530 | 530 | $values['registration'] = $line[0]; |
| 531 | 531 | $values['base'] = null; |
| 532 | 532 | $values['owner'] = $line[6]; |
| 533 | - $values['date_first_reg'] = date("Y-m-d",strtotime($line[5])); |
|
| 534 | - $values['cancel'] = date("Y-m-d",strtotime($line[8])); |
|
| 533 | + $values['date_first_reg'] = date("Y-m-d", strtotime($line[5])); |
|
| 534 | + $values['cancel'] = date("Y-m-d", strtotime($line[8])); |
|
| 535 | 535 | $values['modes'] = $line[4]; |
| 536 | 536 | $values['icao'] = $line[10]; |
| 537 | 537 | } elseif ($country == 'OY') { |
| 538 | 538 | $values['registration'] = $line[0]; |
| 539 | - $values['date_first_reg'] = date("Y-m-d",strtotime($line[4])); |
|
| 539 | + $values['date_first_reg'] = date("Y-m-d", strtotime($line[4])); |
|
| 540 | 540 | $values['modes'] = $line[5]; |
| 541 | 541 | $values['icao'] = $line[6]; |
| 542 | 542 | } elseif ($country == 'PH') { |
| 543 | 543 | $values['registration'] = $line[0]; |
| 544 | - $values['date_first_reg'] = date("Y-m-d",strtotime($line[3])); |
|
| 544 | + $values['date_first_reg'] = date("Y-m-d", strtotime($line[3])); |
|
| 545 | 545 | $values['modes'] = $line[4]; |
| 546 | 546 | $values['icao'] = $line[5]; |
| 547 | 547 | } elseif ($country == 'OM' || $country == 'TF') { |
@@ -552,17 +552,17 @@ discard block |
||
| 552 | 552 | $values['cancel'] = ''; |
| 553 | 553 | } |
| 554 | 554 | if (isset($values['cancel']) && $values['cancel'] == '' && $values['registration'] != null && isset($values['owner'])) { |
| 555 | - $query_dest_values = array(':registration' => $values['registration'],':base' => $values['base'],':date_first_reg' => $values['date_first_reg'],':owner' => $values['owner'],':source' => $database_file); |
|
| 555 | + $query_dest_values = array(':registration' => $values['registration'], ':base' => $values['base'], ':date_first_reg' => $values['date_first_reg'], ':owner' => $values['owner'], ':source' => $database_file); |
|
| 556 | 556 | $sth_dest->execute($query_dest_values); |
| 557 | 557 | } |
| 558 | 558 | if ($globalMasterSource && $values['registration'] != null && isset($values['modes']) && $values['modes'] != '') { |
| 559 | 559 | $modescountry = $Spotter->countryFromAircraftRegistration($values['registration']); |
| 560 | - $query_modes_values = array(':registration' => $values['registration'],':modes' => $values['modes'],':modescountry' => $modescountry,':icaotypecode' => $values['icao'],':source' => $database_file); |
|
| 560 | + $query_modes_values = array(':registration' => $values['registration'], ':modes' => $values['modes'], ':modescountry' => $modescountry, ':icaotypecode' => $values['icao'], ':source' => $database_file); |
|
| 561 | 561 | $sth_modes->execute($query_modes_values); |
| 562 | 562 | } |
| 563 | 563 | } |
| 564 | 564 | if ($globalTransaction) $Connection->db->commit(); |
| 565 | - } catch(PDOException $e) { |
|
| 565 | + } catch (PDOException $e) { |
|
| 566 | 566 | return "error : ".$e->getMessage(); |
| 567 | 567 | } |
| 568 | 568 | } |
@@ -700,7 +700,7 @@ discard block |
||
| 700 | 700 | if ($globalTransaction) $Connection->db->beginTransaction(); |
| 701 | 701 | |
| 702 | 702 | $i = 0; |
| 703 | - while($row = sparql_fetch_array($result)) |
|
| 703 | + while ($row = sparql_fetch_array($result)) |
|
| 704 | 704 | { |
| 705 | 705 | if ($i >= 1) { |
| 706 | 706 | //print_r($row); |
@@ -720,33 +720,33 @@ discard block |
||
| 720 | 720 | $row['image'] = ''; |
| 721 | 721 | $row['image_thumb'] = ''; |
| 722 | 722 | } else { |
| 723 | - $image = str_replace(' ','_',$row['image']); |
|
| 723 | + $image = str_replace(' ', '_', $row['image']); |
|
| 724 | 724 | $digest = md5($image); |
| 725 | - $folder = $digest[0] . '/' . $digest[0] . $digest[1] . '/' . $image . '/220px-' . $image; |
|
| 726 | - $row['image_thumb'] = 'http://upload.wikimedia.org/wikipedia/commons/thumb/' . $folder; |
|
| 727 | - $folder = $digest[0] . '/' . $digest[0] . $digest[1] . '/' . $image; |
|
| 728 | - $row['image'] = 'http://upload.wikimedia.org/wikipedia/commons/' . $folder; |
|
| 725 | + $folder = $digest[0].'/'.$digest[0].$digest[1].'/'.$image.'/220px-'.$image; |
|
| 726 | + $row['image_thumb'] = 'http://upload.wikimedia.org/wikipedia/commons/thumb/'.$folder; |
|
| 727 | + $folder = $digest[0].'/'.$digest[0].$digest[1].'/'.$image; |
|
| 728 | + $row['image'] = 'http://upload.wikimedia.org/wikipedia/commons/'.$folder; |
|
| 729 | 729 | } |
| 730 | 730 | |
| 731 | - $country = explode('-',$row['country']); |
|
| 731 | + $country = explode('-', $row['country']); |
|
| 732 | 732 | $row['country'] = $country[0]; |
| 733 | 733 | |
| 734 | 734 | $row['type'] = trim($row['type']); |
| 735 | - if ($row['type'] == 'Military: Naval Auxiliary Air Station' || $row['type'] == 'http://dbpedia.org/resource/Naval_air_station' || $row['type'] == 'Military: Naval Air Station' || $row['type'] == 'Military Northern Fleet' || $row['type'] == 'Military and industrial' || $row['type'] == 'Military: Royal Air Force station' || $row['type'] == 'http://dbpedia.org/resource/Military_airbase' || $row['type'] == 'Military: Naval air station' || preg_match('/air base/i',$row['name'])) { |
|
| 735 | + if ($row['type'] == 'Military: Naval Auxiliary Air Station' || $row['type'] == 'http://dbpedia.org/resource/Naval_air_station' || $row['type'] == 'Military: Naval Air Station' || $row['type'] == 'Military Northern Fleet' || $row['type'] == 'Military and industrial' || $row['type'] == 'Military: Royal Air Force station' || $row['type'] == 'http://dbpedia.org/resource/Military_airbase' || $row['type'] == 'Military: Naval air station' || preg_match('/air base/i', $row['name'])) { |
|
| 736 | 736 | $row['type'] = 'military'; |
| 737 | 737 | } elseif ($row['type'] == 'http://dbpedia.org/resource/Airport' || $row['type'] == 'Civil' || $row['type'] == 'Public use' || $row['type'] == 'Public' || $row['type'] == 'http://dbpedia.org/resource/Civilian' || $row['type'] == 'Public, Civilian' || $row['type'] == 'Public / Military' || $row['type'] == 'Private & Civilian' || $row['type'] == 'Civilian and Military' || $row['type'] == 'Public/military' || $row['type'] == 'Active With Few Facilities' || $row['type'] == '?ivilian' || $row['type'] == 'Civil/Military' || $row['type'] == 'NA' || $row['type'] == 'Public/Military') { |
| 738 | 738 | $row['type'] = 'small_airport'; |
| 739 | 739 | } |
| 740 | 740 | |
| 741 | - $row['city'] = urldecode(str_replace('_',' ',str_replace('http://dbpedia.org/resource/','',$row['city']))); |
|
| 742 | - $query_dest_values = array(':name' => $row['name'],':iata' => $row['iata'],':icao' => $row['icao'],':latitude' => $row['latitude'],':longitude' => $row['longitude'],':altitude' => round($row['altitude']),':type' => $row['type'],':city' => $row['city'],':country' => $row['country'],':home_link' => $row['homepage'],':wikipedia_link' => $row['wikipedia_page'],':image' => $row['image'],':image_thumb' => $row['image_thumb']); |
|
| 741 | + $row['city'] = urldecode(str_replace('_', ' ', str_replace('http://dbpedia.org/resource/', '', $row['city']))); |
|
| 742 | + $query_dest_values = array(':name' => $row['name'], ':iata' => $row['iata'], ':icao' => $row['icao'], ':latitude' => $row['latitude'], ':longitude' => $row['longitude'], ':altitude' => round($row['altitude']), ':type' => $row['type'], ':city' => $row['city'], ':country' => $row['country'], ':home_link' => $row['homepage'], ':wikipedia_link' => $row['wikipedia_page'], ':image' => $row['image'], ':image_thumb' => $row['image_thumb']); |
|
| 743 | 743 | //print_r($query_dest_values); |
| 744 | 744 | |
| 745 | 745 | if ($row['icao'] != '') { |
| 746 | 746 | try { |
| 747 | 747 | $sth = $Connection->db->prepare('SELECT COUNT(*) FROM airport WHERE icao = :icao'); |
| 748 | 748 | $sth->execute(array(':icao' => $row['icao'])); |
| 749 | - } catch(PDOException $e) { |
|
| 749 | + } catch (PDOException $e) { |
|
| 750 | 750 | return "error : ".$e->getMessage(); |
| 751 | 751 | } |
| 752 | 752 | if ($sth->fetchColumn() > 0) { |
@@ -754,15 +754,15 @@ discard block |
||
| 754 | 754 | $query = 'UPDATE airport SET type = :type WHERE icao = :icao'; |
| 755 | 755 | try { |
| 756 | 756 | $sth = $Connection->db->prepare($query); |
| 757 | - $sth->execute(array(':icao' => $row['icao'],':type' => $row['type'])); |
|
| 758 | - } catch(PDOException $e) { |
|
| 757 | + $sth->execute(array(':icao' => $row['icao'], ':type' => $row['type'])); |
|
| 758 | + } catch (PDOException $e) { |
|
| 759 | 759 | return "error : ".$e->getMessage(); |
| 760 | 760 | } |
| 761 | 761 | echo $row['icao'].' : '.$row['type']."\n"; |
| 762 | 762 | } else { |
| 763 | 763 | try { |
| 764 | 764 | $sth_dest->execute($query_dest_values); |
| 765 | - } catch(PDOException $e) { |
|
| 765 | + } catch (PDOException $e) { |
|
| 766 | 766 | return "error : ".$e->getMessage(); |
| 767 | 767 | } |
| 768 | 768 | } |
@@ -813,7 +813,7 @@ discard block |
||
| 813 | 813 | echo "Download data from ourairports.com...\n"; |
| 814 | 814 | $delimiter = ','; |
| 815 | 815 | $out_file = $tmp_dir.'airports.csv'; |
| 816 | - update_db::download('http://ourairports.com/data/airports.csv',$out_file); |
|
| 816 | + update_db::download('http://ourairports.com/data/airports.csv', $out_file); |
|
| 817 | 817 | if (!file_exists($out_file) || !is_readable($out_file)) return FALSE; |
| 818 | 818 | echo "Add data from ourairports.com...\n"; |
| 819 | 819 | |
@@ -824,33 +824,33 @@ discard block |
||
| 824 | 824 | //$Connection->db->beginTransaction(); |
| 825 | 825 | while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
| 826 | 826 | { |
| 827 | - if(!$header) $header = $row; |
|
| 827 | + if (!$header) $header = $row; |
|
| 828 | 828 | else { |
| 829 | 829 | $data = array(); |
| 830 | 830 | $data = array_combine($header, $row); |
| 831 | 831 | try { |
| 832 | 832 | $sth = $Connection->db->prepare('SELECT COUNT(*) FROM airport WHERE icao = :icao'); |
| 833 | 833 | $sth->execute(array(':icao' => $data['ident'])); |
| 834 | - } catch(PDOException $e) { |
|
| 834 | + } catch (PDOException $e) { |
|
| 835 | 835 | return "error : ".$e->getMessage(); |
| 836 | 836 | } |
| 837 | 837 | if ($sth->fetchColumn() > 0) { |
| 838 | 838 | $query = 'UPDATE airport SET type = :type WHERE icao = :icao'; |
| 839 | 839 | try { |
| 840 | 840 | $sth = $Connection->db->prepare($query); |
| 841 | - $sth->execute(array(':icao' => $data['ident'],':type' => $data['type'])); |
|
| 842 | - } catch(PDOException $e) { |
|
| 841 | + $sth->execute(array(':icao' => $data['ident'], ':type' => $data['type'])); |
|
| 842 | + } catch (PDOException $e) { |
|
| 843 | 843 | return "error : ".$e->getMessage(); |
| 844 | 844 | } |
| 845 | 845 | } else { |
| 846 | 846 | if ($data['gps_code'] == $data['ident']) { |
| 847 | 847 | $query = "INSERT INTO airport (name,city,country,iata,icao,latitude,longitude,altitude,type,home_link,wikipedia_link) |
| 848 | 848 | VALUES (:name, :city, :country, :iata, :icao, :latitude, :longitude, :altitude, :type, :home_link, :wikipedia_link)"; |
| 849 | - $query_values = array(':name' => $data['name'],':iata' => $data['iata_code'],':icao' => $data['gps_code'],':latitude' => $data['latitude_deg'],':longitude' => $data['longitude_deg'],':altitude' => round($data['elevation_ft']),':type' => $data['type'],':city' => $data['municipality'],':country' => $data['iso_country'],':home_link' => $data['home_link'],':wikipedia_link' => $data['wikipedia_link']); |
|
| 849 | + $query_values = array(':name' => $data['name'], ':iata' => $data['iata_code'], ':icao' => $data['gps_code'], ':latitude' => $data['latitude_deg'], ':longitude' => $data['longitude_deg'], ':altitude' => round($data['elevation_ft']), ':type' => $data['type'], ':city' => $data['municipality'], ':country' => $data['iso_country'], ':home_link' => $data['home_link'], ':wikipedia_link' => $data['wikipedia_link']); |
|
| 850 | 850 | try { |
| 851 | 851 | $sth = $Connection->db->prepare($query); |
| 852 | 852 | $sth->execute($query_values); |
| 853 | - } catch(PDOException $e) { |
|
| 853 | + } catch (PDOException $e) { |
|
| 854 | 854 | return "error : ".$e->getMessage(); |
| 855 | 855 | } |
| 856 | 856 | $i++; |
@@ -865,7 +865,7 @@ discard block |
||
| 865 | 865 | |
| 866 | 866 | echo "Download data from another free database...\n"; |
| 867 | 867 | $out_file = $tmp_dir.'GlobalAirportDatabase.zip'; |
| 868 | - update_db::download('http://www.partow.net/downloads/GlobalAirportDatabase.zip',$out_file); |
|
| 868 | + update_db::download('http://www.partow.net/downloads/GlobalAirportDatabase.zip', $out_file); |
|
| 869 | 869 | if (!file_exists($out_file) || !is_readable($out_file)) return FALSE; |
| 870 | 870 | update_db::unzip($out_file); |
| 871 | 871 | $header = NULL; |
@@ -877,15 +877,15 @@ discard block |
||
| 877 | 877 | //$Connection->db->beginTransaction(); |
| 878 | 878 | while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
| 879 | 879 | { |
| 880 | - if(!$header) $header = $row; |
|
| 880 | + if (!$header) $header = $row; |
|
| 881 | 881 | else { |
| 882 | 882 | $data = $row; |
| 883 | 883 | |
| 884 | 884 | $query = 'UPDATE airport SET city = :city, country = :country WHERE icao = :icao'; |
| 885 | 885 | try { |
| 886 | 886 | $sth = $Connection->db->prepare($query); |
| 887 | - $sth->execute(array(':icao' => $data[0],':city' => ucwords(strtolower($data[3])),':country' => ucwords(strtolower($data[4])))); |
|
| 888 | - } catch(PDOException $e) { |
|
| 887 | + $sth->execute(array(':icao' => $data[0], ':city' => ucwords(strtolower($data[3])), ':country' => ucwords(strtolower($data[4])))); |
|
| 888 | + } catch (PDOException $e) { |
|
| 889 | 889 | return "error : ".$e->getMessage(); |
| 890 | 890 | } |
| 891 | 891 | } |
@@ -899,15 +899,15 @@ discard block |
||
| 899 | 899 | try { |
| 900 | 900 | $sth = $Connection->db->prepare("SELECT icao FROM airport WHERE name LIKE '%Air Base%'"); |
| 901 | 901 | $sth->execute(); |
| 902 | - } catch(PDOException $e) { |
|
| 902 | + } catch (PDOException $e) { |
|
| 903 | 903 | return "error : ".$e->getMessage(); |
| 904 | 904 | } |
| 905 | 905 | while ($row = $sth->fetch(PDO::FETCH_ASSOC)) { |
| 906 | 906 | $query2 = 'UPDATE airport SET type = :type WHERE icao = :icao'; |
| 907 | 907 | try { |
| 908 | 908 | $sth2 = $Connection->db->prepare($query2); |
| 909 | - $sth2->execute(array(':icao' => $row['icao'],':type' => 'military')); |
|
| 910 | - } catch(PDOException $e) { |
|
| 909 | + $sth2->execute(array(':icao' => $row['icao'], ':type' => 'military')); |
|
| 910 | + } catch (PDOException $e) { |
|
| 911 | 911 | return "error : ".$e->getMessage(); |
| 912 | 912 | } |
| 913 | 913 | } |
@@ -928,7 +928,7 @@ discard block |
||
| 928 | 928 | $Connection = new Connection(); |
| 929 | 929 | $sth = $Connection->db->prepare($query); |
| 930 | 930 | $sth->execute(array(':source' => 'translation.csv')); |
| 931 | - } catch(PDOException $e) { |
|
| 931 | + } catch (PDOException $e) { |
|
| 932 | 932 | return "error : ".$e->getMessage(); |
| 933 | 933 | } |
| 934 | 934 | |
@@ -945,7 +945,7 @@ discard block |
||
| 945 | 945 | while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
| 946 | 946 | { |
| 947 | 947 | $i++; |
| 948 | - if($i > 12) { |
|
| 948 | + if ($i > 12) { |
|
| 949 | 949 | $data = $row; |
| 950 | 950 | $operator = $data[2]; |
| 951 | 951 | if ($operator != '' && is_numeric(substr(substr($operator, 0, 3), -1, 1))) { |
@@ -953,7 +953,7 @@ discard block |
||
| 953 | 953 | //echo substr($operator, 0, 2)."\n";; |
| 954 | 954 | if (count($airline_array) > 0) { |
| 955 | 955 | //print_r($airline_array); |
| 956 | - $operator = $airline_array[0]['icao'].substr($operator,2); |
|
| 956 | + $operator = $airline_array[0]['icao'].substr($operator, 2); |
|
| 957 | 957 | } |
| 958 | 958 | } |
| 959 | 959 | |
@@ -961,14 +961,14 @@ discard block |
||
| 961 | 961 | if ($operator_correct != '' && is_numeric(substr(substr($operator_correct, 0, 3), -1, 1))) { |
| 962 | 962 | $airline_array = $Spotter->getAllAirlineInfo(substr($operator_correct, 0, 2)); |
| 963 | 963 | if (count($airline_array) > 0) { |
| 964 | - $operator_correct = $airline_array[0]['icao'].substr($operator_correct,2); |
|
| 964 | + $operator_correct = $airline_array[0]['icao'].substr($operator_correct, 2); |
|
| 965 | 965 | } |
| 966 | 966 | } |
| 967 | 967 | $query = 'INSERT INTO translation (Reg,Reg_correct,Operator,Operator_correct,Source) VALUES (:Reg, :Reg_correct, :Operator, :Operator_correct, :source)'; |
| 968 | 968 | try { |
| 969 | 969 | $sth = $Connection->db->prepare($query); |
| 970 | - $sth->execute(array(':Reg' => $data[0],':Reg_correct' => $data[1],':Operator' => $operator,':Operator_correct' => $operator_correct, ':source' => 'translation.csv')); |
|
| 971 | - } catch(PDOException $e) { |
|
| 970 | + $sth->execute(array(':Reg' => $data[0], ':Reg_correct' => $data[1], ':Operator' => $operator, ':Operator_correct' => $operator_correct, ':source' => 'translation.csv')); |
|
| 971 | + } catch (PDOException $e) { |
|
| 972 | 972 | return "error : ".$e->getMessage(); |
| 973 | 973 | } |
| 974 | 974 | } |
@@ -986,7 +986,7 @@ discard block |
||
| 986 | 986 | $Connection = new Connection(); |
| 987 | 987 | $sth = $Connection->db->prepare($query); |
| 988 | 988 | $sth->execute(array(':source' => 'website_fam')); |
| 989 | - } catch(PDOException $e) { |
|
| 989 | + } catch (PDOException $e) { |
|
| 990 | 990 | return "error : ".$e->getMessage(); |
| 991 | 991 | } |
| 992 | 992 | //update_db::unzip($out_file); |
@@ -1004,8 +1004,8 @@ discard block |
||
| 1004 | 1004 | $query = 'INSERT INTO translation (Reg,Reg_correct,Operator,Operator_correct,Source) VALUES (:Reg, :Reg_correct, :Operator, :Operator_correct, :source)'; |
| 1005 | 1005 | try { |
| 1006 | 1006 | $sth = $Connection->db->prepare($query); |
| 1007 | - $sth->execute(array(':Reg' => $data[0],':Reg_correct' => $data[1],':Operator' => $data[2],':Operator_correct' => $data[3], ':source' => 'website_fam')); |
|
| 1008 | - } catch(PDOException $e) { |
|
| 1007 | + $sth->execute(array(':Reg' => $data[0], ':Reg_correct' => $data[1], ':Operator' => $data[2], ':Operator_correct' => $data[3], ':source' => 'website_fam')); |
|
| 1008 | + } catch (PDOException $e) { |
|
| 1009 | 1009 | return "error : ".$e->getMessage(); |
| 1010 | 1010 | } |
| 1011 | 1011 | } |
@@ -1028,7 +1028,7 @@ discard block |
||
| 1028 | 1028 | $Connection = new Connection(); |
| 1029 | 1029 | $sth = $Connection->db->prepare($query); |
| 1030 | 1030 | $sth->execute(array(':source' => 'website_faa')); |
| 1031 | - } catch(PDOException $e) { |
|
| 1031 | + } catch (PDOException $e) { |
|
| 1032 | 1032 | return "error : ".$e->getMessage(); |
| 1033 | 1033 | } |
| 1034 | 1034 | |
@@ -1037,7 +1037,7 @@ discard block |
||
| 1037 | 1037 | $Connection = new Connection(); |
| 1038 | 1038 | $sth = $Connection->db->prepare($query); |
| 1039 | 1039 | $sth->execute(array(':source' => 'website_faa')); |
| 1040 | - } catch(PDOException $e) { |
|
| 1040 | + } catch (PDOException $e) { |
|
| 1041 | 1041 | return "error : ".$e->getMessage(); |
| 1042 | 1042 | } |
| 1043 | 1043 | |
@@ -1054,8 +1054,8 @@ discard block |
||
| 1054 | 1054 | $query_search = 'SELECT icaotypecode FROM aircraft_modes WHERE registration = :registration AND Source <> :source LIMIT 1'; |
| 1055 | 1055 | try { |
| 1056 | 1056 | $sths = $Connection->db->prepare($query_search); |
| 1057 | - $sths->execute(array(':registration' => 'N'.$data[0],':source' => 'website_faa')); |
|
| 1058 | - } catch(PDOException $e) { |
|
| 1057 | + $sths->execute(array(':registration' => 'N'.$data[0], ':source' => 'website_faa')); |
|
| 1058 | + } catch (PDOException $e) { |
|
| 1059 | 1059 | return "error s : ".$e->getMessage(); |
| 1060 | 1060 | } |
| 1061 | 1061 | $result_search = $sths->fetchAll(PDO::FETCH_ASSOC); |
@@ -1068,8 +1068,8 @@ discard block |
||
| 1068 | 1068 | //} |
| 1069 | 1069 | try { |
| 1070 | 1070 | $sthi = $Connection->db->prepare($queryi); |
| 1071 | - $sthi->execute(array(':mfr' => $data[2],':icao' => $result_search[0]['icaotypecode'])); |
|
| 1072 | - } catch(PDOException $e) { |
|
| 1071 | + $sthi->execute(array(':mfr' => $data[2], ':icao' => $result_search[0]['icaotypecode'])); |
|
| 1072 | + } catch (PDOException $e) { |
|
| 1073 | 1073 | return "error u : ".$e->getMessage(); |
| 1074 | 1074 | } |
| 1075 | 1075 | } else { |
@@ -1077,7 +1077,7 @@ discard block |
||
| 1077 | 1077 | try { |
| 1078 | 1078 | $sthsm = $Connection->db->prepare($query_search_mfr); |
| 1079 | 1079 | $sthsm->execute(array(':mfr' => $data[2])); |
| 1080 | - } catch(PDOException $e) { |
|
| 1080 | + } catch (PDOException $e) { |
|
| 1081 | 1081 | return "error mfr : ".$e->getMessage(); |
| 1082 | 1082 | } |
| 1083 | 1083 | $result_search_mfr = $sthsm->fetchAll(PDO::FETCH_ASSOC); |
@@ -1087,8 +1087,8 @@ discard block |
||
| 1087 | 1087 | $queryf = 'INSERT INTO aircraft_modes (FirstCreated,LastModified,ModeS,ModeSCountry,Registration,ICAOTypeCode,Source) VALUES (:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:source)'; |
| 1088 | 1088 | try { |
| 1089 | 1089 | $sthf = $Connection->db->prepare($queryf); |
| 1090 | - $sthf->execute(array(':FirstCreated' => $data[16],':LastModified' => $data[15],':ModeS' => $data[33],':ModeSCountry' => $data[14], ':Registration' => 'N'.$data[0],':ICAOTypeCode' => $result_search_mfr[0]['icao'],':source' => 'website_faa')); |
|
| 1091 | - } catch(PDOException $e) { |
|
| 1090 | + $sthf->execute(array(':FirstCreated' => $data[16], ':LastModified' => $data[15], ':ModeS' => $data[33], ':ModeSCountry' => $data[14], ':Registration' => 'N'.$data[0], ':ICAOTypeCode' => $result_search_mfr[0]['icao'], ':source' => 'website_faa')); |
|
| 1091 | + } catch (PDOException $e) { |
|
| 1092 | 1092 | return "error f : ".$e->getMessage(); |
| 1093 | 1093 | } |
| 1094 | 1094 | } |
@@ -1098,13 +1098,13 @@ discard block |
||
| 1098 | 1098 | $query = 'INSERT INTO aircraft_owner (registration,base,owner,date_first_reg,Source) VALUES (:registration,:base,:owner,:date_first_reg,:source)'; |
| 1099 | 1099 | try { |
| 1100 | 1100 | $sth = $Connection->db->prepare($query); |
| 1101 | - $sth->execute(array(':registration' => 'N'.$data[0],':base' => $data[9],':owner' => ucwords(strtolower($data[6])),':date_first_reg' => date('Y-m-d',strtotime($data[23])), ':source' => 'website_faa')); |
|
| 1102 | - } catch(PDOException $e) { |
|
| 1101 | + $sth->execute(array(':registration' => 'N'.$data[0], ':base' => $data[9], ':owner' => ucwords(strtolower($data[6])), ':date_first_reg' => date('Y-m-d', strtotime($data[23])), ':source' => 'website_faa')); |
|
| 1102 | + } catch (PDOException $e) { |
|
| 1103 | 1103 | return "error i : ".$e->getMessage(); |
| 1104 | 1104 | } |
| 1105 | 1105 | } |
| 1106 | 1106 | } |
| 1107 | - if ($i % 90 == 0) { |
|
| 1107 | + if ($i%90 == 0) { |
|
| 1108 | 1108 | if ($globalTransaction) $Connection->db->commit(); |
| 1109 | 1109 | if ($globalTransaction) $Connection->db->beginTransaction(); |
| 1110 | 1110 | } |
@@ -1123,7 +1123,7 @@ discard block |
||
| 1123 | 1123 | $Connection = new Connection(); |
| 1124 | 1124 | $sth = $Connection->db->prepare($query); |
| 1125 | 1125 | $sth->execute(array(':source' => 'website_fam')); |
| 1126 | - } catch(PDOException $e) { |
|
| 1126 | + } catch (PDOException $e) { |
|
| 1127 | 1127 | return "error : ".$e->getMessage(); |
| 1128 | 1128 | } |
| 1129 | 1129 | |
@@ -1144,8 +1144,8 @@ discard block |
||
| 1144 | 1144 | $query = 'INSERT INTO aircraft_modes (FirstCreated,LastModified,ModeS,ModeSCountry,Registration,ICAOTypeCode,type_flight,Source) VALUES (:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:type_flight,:source)'; |
| 1145 | 1145 | try { |
| 1146 | 1146 | $sth = $Connection->db->prepare($query); |
| 1147 | - $sth->execute(array(':FirstCreated' => $data[0],':LastModified' => $data[1],':ModeS' => $data[2],':ModeSCountry' => $data[3], ':Registration' => $data[4],':ICAOTypeCode' => $data[5],':type_flight' => $data[6],':source' => 'website_fam')); |
|
| 1148 | - } catch(PDOException $e) { |
|
| 1147 | + $sth->execute(array(':FirstCreated' => $data[0], ':LastModified' => $data[1], ':ModeS' => $data[2], ':ModeSCountry' => $data[3], ':Registration' => $data[4], ':ICAOTypeCode' => $data[5], ':type_flight' => $data[6], ':source' => 'website_fam')); |
|
| 1148 | + } catch (PDOException $e) { |
|
| 1149 | 1149 | return "error : ".$e->getMessage(); |
| 1150 | 1150 | } |
| 1151 | 1151 | } |
@@ -1164,7 +1164,7 @@ discard block |
||
| 1164 | 1164 | $Connection = new Connection(); |
| 1165 | 1165 | $sth = $Connection->db->prepare($query); |
| 1166 | 1166 | $sth->execute(array(':source' => 'website_fam')); |
| 1167 | - } catch(PDOException $e) { |
|
| 1167 | + } catch (PDOException $e) { |
|
| 1168 | 1168 | return "error : ".$e->getMessage(); |
| 1169 | 1169 | } |
| 1170 | 1170 | |
@@ -1180,8 +1180,8 @@ discard block |
||
| 1180 | 1180 | $query = 'INSERT INTO aircraft_owner (registration,base,owner,date_first_reg,Source) VALUES (:registration,:base,:owner,NULL,:source)'; |
| 1181 | 1181 | try { |
| 1182 | 1182 | $sth = $Connection->db->prepare($query); |
| 1183 | - $sth->execute(array(':registration' => $data[0],':base' => $data[1],':owner' => $data[2], ':source' => 'website_fam')); |
|
| 1184 | - } catch(PDOException $e) { |
|
| 1183 | + $sth->execute(array(':registration' => $data[0], ':base' => $data[1], ':owner' => $data[2], ':source' => 'website_fam')); |
|
| 1184 | + } catch (PDOException $e) { |
|
| 1185 | 1185 | //print_r($data); |
| 1186 | 1186 | return "error : ".$e->getMessage(); |
| 1187 | 1187 | } |
@@ -1201,7 +1201,7 @@ discard block |
||
| 1201 | 1201 | $Connection = new Connection(); |
| 1202 | 1202 | $sth = $Connection->db->prepare($query); |
| 1203 | 1203 | $sth->execute(array(':source' => 'website_fam')); |
| 1204 | - } catch(PDOException $e) { |
|
| 1204 | + } catch (PDOException $e) { |
|
| 1205 | 1205 | return "error : ".$e->getMessage(); |
| 1206 | 1206 | } |
| 1207 | 1207 | $delimiter = "\t"; |
@@ -1216,9 +1216,9 @@ discard block |
||
| 1216 | 1216 | $query = 'INSERT INTO routes (CallSign,Operator_ICAO,FromAirport_ICAO,FromAirport_Time,ToAirport_ICAO,ToAirport_Time,RouteStop,Source) VALUES (:CallSign,:Operator_ICAO,:FromAirport_ICAO,:FromAirport_Time,:ToAirport_ICAO,:ToAirport_Time,:RouteStop,:source)'; |
| 1217 | 1217 | try { |
| 1218 | 1218 | $sth = $Connection->db->prepare($query); |
| 1219 | - $sth->execute(array(':CallSign' => $data[0],':Operator_ICAO' => $data[1],':FromAirport_ICAO' => $data[2],':FromAirport_Time' => $data[3], ':ToAirport_ICAO' => $data[4],':ToAirport_Time' => $data[5],':RouteStop' => $data[6],':source' => 'website_fam')); |
|
| 1220 | - } catch(PDOException $e) { |
|
| 1221 | - if ($globalDebug) echo "error: ".$e->getMessage()." - data: ".implode(',',$data); |
|
| 1219 | + $sth->execute(array(':CallSign' => $data[0], ':Operator_ICAO' => $data[1], ':FromAirport_ICAO' => $data[2], ':FromAirport_Time' => $data[3], ':ToAirport_ICAO' => $data[4], ':ToAirport_Time' => $data[5], ':RouteStop' => $data[6], ':source' => 'website_fam')); |
|
| 1220 | + } catch (PDOException $e) { |
|
| 1221 | + if ($globalDebug) echo "error: ".$e->getMessage()." - data: ".implode(',', $data); |
|
| 1222 | 1222 | } |
| 1223 | 1223 | } |
| 1224 | 1224 | $i++; |
@@ -1236,7 +1236,7 @@ discard block |
||
| 1236 | 1236 | $Connection = new Connection(); |
| 1237 | 1237 | $sth = $Connection->db->prepare($query); |
| 1238 | 1238 | $sth->execute(); |
| 1239 | - } catch(PDOException $e) { |
|
| 1239 | + } catch (PDOException $e) { |
|
| 1240 | 1240 | return "error : ".$e->getMessage(); |
| 1241 | 1241 | } |
| 1242 | 1242 | |
@@ -1257,8 +1257,8 @@ discard block |
||
| 1257 | 1257 | $query = 'INSERT INTO marine_identity (mmsi,imo,call_sign,ship_name,length,gross_tonnage,dead_weight,width,country,engine_power,type) VALUES (:mmsi,:imo,:call_sign,:ship_name,:length,:gross_tonnage,:dead_weight,:width,:country,:engine_power,:type)'; |
| 1258 | 1258 | try { |
| 1259 | 1259 | $sth = $Connection->db->prepare($query); |
| 1260 | - $sth->execute(array(':mmsi' => $data[0],':imo' => $data[1],':call_sign' => $data[2],':ship_name' => $data[3], ':length' => $data[4],':gross_tonnage' => $data[5],':dead_weight' => $data[6],':width' => $data[7],':country' => $data[8],':engine_power' => $data[9],':type' => $data[10])); |
|
| 1261 | - } catch(PDOException $e) { |
|
| 1260 | + $sth->execute(array(':mmsi' => $data[0], ':imo' => $data[1], ':call_sign' => $data[2], ':ship_name' => $data[3], ':length' => $data[4], ':gross_tonnage' => $data[5], ':dead_weight' => $data[6], ':width' => $data[7], ':country' => $data[8], ':engine_power' => $data[9], ':type' => $data[10])); |
|
| 1261 | + } catch (PDOException $e) { |
|
| 1262 | 1262 | return "error : ".$e->getMessage(); |
| 1263 | 1263 | } |
| 1264 | 1264 | } |
@@ -1277,7 +1277,7 @@ discard block |
||
| 1277 | 1277 | $Connection = new Connection(); |
| 1278 | 1278 | $sth = $Connection->db->prepare($query); |
| 1279 | 1279 | $sth->execute(); |
| 1280 | - } catch(PDOException $e) { |
|
| 1280 | + } catch (PDOException $e) { |
|
| 1281 | 1281 | return "error : ".$e->getMessage(); |
| 1282 | 1282 | } |
| 1283 | 1283 | $delimiter = "\t"; |
@@ -1294,8 +1294,8 @@ discard block |
||
| 1294 | 1294 | VALUES (:name, :name_alternate, :country_un, :country_owner, :owner, :users, :purpose, :purpose_detailed, :orbit, :type, :longitude_geo, :perigee, :apogee, :eccentricity, :inclination, :period, :launch_mass, :dry_mass, :power, :launch_date, :lifetime, :contractor, :country_contractor, :launch_site, :launch_vehicule, :cospar, :norad, :comments, :source_orbital, :sources)'; |
| 1295 | 1295 | try { |
| 1296 | 1296 | $sth = $Connection->db->prepare($query); |
| 1297 | - $sth->execute(array(':name' => $data[0], ':name_alternate' => $data[1], ':country_un' => $data[2], ':country_owner' => $data[3], ':owner' => $data[4], ':users' => $data[5], ':purpose' => $data[6], ':purpose_detailed' => $data[7], ':orbit' => $data[8], ':type' => $data[9], ':longitude_geo' => $data[10], ':perigee' => !empty($data[11]) ? $data[11] : NULL, ':apogee' => !empty($data[12]) ? $data[12] : NULL, ':eccentricity' => $data[13], ':inclination' => $data[14], ':period' => !empty($data[15]) ? $data[15] : NULL, ':launch_mass' => !empty($data[16]) ? $data[16] : NULL, ':dry_mass' => !empty($data[17]) ? $data[17] : NULL, ':power' => !empty($data[18]) ? $data[18] : NULL, ':launch_date' => $data[19], ':lifetime' => $data[20], ':contractor' => $data[21],':country_contractor' => $data[22], ':launch_site' => $data[23], ':launch_vehicule' => $data[24], ':cospar' => $data[25], ':norad' => $data[26], ':comments' => $data[27], ':source_orbital' => $data[28], ':sources' => $data[29])); |
|
| 1298 | - } catch(PDOException $e) { |
|
| 1297 | + $sth->execute(array(':name' => $data[0], ':name_alternate' => $data[1], ':country_un' => $data[2], ':country_owner' => $data[3], ':owner' => $data[4], ':users' => $data[5], ':purpose' => $data[6], ':purpose_detailed' => $data[7], ':orbit' => $data[8], ':type' => $data[9], ':longitude_geo' => $data[10], ':perigee' => !empty($data[11]) ? $data[11] : NULL, ':apogee' => !empty($data[12]) ? $data[12] : NULL, ':eccentricity' => $data[13], ':inclination' => $data[14], ':period' => !empty($data[15]) ? $data[15] : NULL, ':launch_mass' => !empty($data[16]) ? $data[16] : NULL, ':dry_mass' => !empty($data[17]) ? $data[17] : NULL, ':power' => !empty($data[18]) ? $data[18] : NULL, ':launch_date' => $data[19], ':lifetime' => $data[20], ':contractor' => $data[21], ':country_contractor' => $data[22], ':launch_site' => $data[23], ':launch_vehicule' => $data[24], ':cospar' => $data[25], ':norad' => $data[26], ':comments' => $data[27], ':source_orbital' => $data[28], ':sources' => $data[29])); |
|
| 1298 | + } catch (PDOException $e) { |
|
| 1299 | 1299 | return "error : ".$e->getMessage(); |
| 1300 | 1300 | } |
| 1301 | 1301 | } |
@@ -1314,7 +1314,7 @@ discard block |
||
| 1314 | 1314 | $Connection = new Connection(); |
| 1315 | 1315 | $sth = $Connection->db->prepare($query); |
| 1316 | 1316 | $sth->execute(); |
| 1317 | - } catch(PDOException $e) { |
|
| 1317 | + } catch (PDOException $e) { |
|
| 1318 | 1318 | return "error : ".$e->getMessage(); |
| 1319 | 1319 | } |
| 1320 | 1320 | |
@@ -1330,7 +1330,7 @@ discard block |
||
| 1330 | 1330 | try { |
| 1331 | 1331 | $sth = $Connection->db->prepare($query); |
| 1332 | 1332 | $sth->execute(array(':icao' => $icao)); |
| 1333 | - } catch(PDOException $e) { |
|
| 1333 | + } catch (PDOException $e) { |
|
| 1334 | 1334 | return "error : ".$e->getMessage(); |
| 1335 | 1335 | } |
| 1336 | 1336 | } |
@@ -1341,7 +1341,7 @@ discard block |
||
| 1341 | 1341 | return ''; |
| 1342 | 1342 | } |
| 1343 | 1343 | |
| 1344 | - public static function tle($filename,$tletype) { |
|
| 1344 | + public static function tle($filename, $tletype) { |
|
| 1345 | 1345 | require_once(dirname(__FILE__).'/../require/class.Spotter.php'); |
| 1346 | 1346 | global $tmp_dir, $globalTransaction; |
| 1347 | 1347 | //$Spotter = new Spotter(); |
@@ -1351,7 +1351,7 @@ discard block |
||
| 1351 | 1351 | $Connection = new Connection(); |
| 1352 | 1352 | $sth = $Connection->db->prepare($query); |
| 1353 | 1353 | $sth->execute(array(':source' => $filename)); |
| 1354 | - } catch(PDOException $e) { |
|
| 1354 | + } catch (PDOException $e) { |
|
| 1355 | 1355 | return "error : ".$e->getMessage(); |
| 1356 | 1356 | } |
| 1357 | 1357 | |
@@ -1376,8 +1376,8 @@ discard block |
||
| 1376 | 1376 | $query = 'INSERT INTO tle (tle_name,tle_tle1,tle_tle2,tle_type,tle_source) VALUES (:name, :tle1, :tle2, :type, :source)'; |
| 1377 | 1377 | try { |
| 1378 | 1378 | $sth = $Connection->db->prepare($query); |
| 1379 | - $sth->execute(array(':name' => $dbdata['name'],':tle1' => $dbdata['tle1'],':tle2' => $dbdata['tle2'], ':type' => $tletype,':source' => $filename)); |
|
| 1380 | - } catch(PDOException $e) { |
|
| 1379 | + $sth->execute(array(':name' => $dbdata['name'], ':tle1' => $dbdata['tle1'], ':tle2' => $dbdata['tle2'], ':type' => $tletype, ':source' => $filename)); |
|
| 1380 | + } catch (PDOException $e) { |
|
| 1381 | 1381 | return "error : ".$e->getMessage(); |
| 1382 | 1382 | } |
| 1383 | 1383 | |
@@ -1397,7 +1397,7 @@ discard block |
||
| 1397 | 1397 | $Connection = new Connection(); |
| 1398 | 1398 | $sth = $Connection->db->prepare($query); |
| 1399 | 1399 | $sth->execute(array(':source' => $filename)); |
| 1400 | - } catch(PDOException $e) { |
|
| 1400 | + } catch (PDOException $e) { |
|
| 1401 | 1401 | return "error : ".$e->getMessage(); |
| 1402 | 1402 | } |
| 1403 | 1403 | |
@@ -1407,13 +1407,13 @@ discard block |
||
| 1407 | 1407 | $i = 0; |
| 1408 | 1408 | //$Connection->db->setAttribute(PDO::ATTR_AUTOCOMMIT, FALSE); |
| 1409 | 1409 | //$Connection->db->beginTransaction(); |
| 1410 | - while (($data = fgetcsv($handle, 1000,"\t")) !== FALSE) |
|
| 1410 | + while (($data = fgetcsv($handle, 1000, "\t")) !== FALSE) |
|
| 1411 | 1411 | { |
| 1412 | 1412 | if ($i > 0 && $data[0] != '') { |
| 1413 | 1413 | $sources = trim($data[28].' '.$data[29].' '.$data[30].' '.$data[31].' '.$data[32].' '.$data[33]); |
| 1414 | - $period = str_replace(',','',$data[14]); |
|
| 1415 | - if (!empty($period) && strpos($period,'days')) $period = str_replace(' days','',$period)*24*60; |
|
| 1416 | - if ($data[18] != '') $launch_date = date('Y-m-d',strtotime($data[18])); |
|
| 1414 | + $period = str_replace(',', '', $data[14]); |
|
| 1415 | + if (!empty($period) && strpos($period, 'days')) $period = str_replace(' days', '', $period)*24*60; |
|
| 1416 | + if ($data[18] != '') $launch_date = date('Y-m-d', strtotime($data[18])); |
|
| 1417 | 1417 | else $launch_date = NULL; |
| 1418 | 1418 | $data = array_map(function($value) { |
| 1419 | 1419 | return trim($value) === '' ? null : $value; |
@@ -1423,8 +1423,8 @@ discard block |
||
| 1423 | 1423 | VALUES (:name, :name_alternate, :country_un, :country_owner, :owner, :users, :purpose, :purpose_detailed, :orbit, :type, :longitude_geo, :perigee, :apogee, :eccentricity, :inclination, :period, :launch_mass, :dry_mass, :power, :launch_date, :lifetime, :contractor, :country_contractor, :launch_site, :launch_vehicule, :cospar, :norad, :comments, :source_orbital, :sources)'; |
| 1424 | 1424 | try { |
| 1425 | 1425 | $sth = $Connection->db->prepare($query); |
| 1426 | - $sth->execute(array(':name' => $data[0], ':name_alternate' => '', ':country_un' => $data[1], ':country_owner' => $data[2], ':owner' => $data[3], ':users' => $data[4], ':purpose' => $data[5], ':purpose_detailed' => $data[6], ':orbit' => $data[7], ':type' => $data[8], ':longitude_geo' => $data[9], ':perigee' => !empty($data[10]) ? str_replace(',','',$data[10]) : NULL, ':apogee' => !empty($data[11]) ? str_replace(',','',$data[11]) : NULL, ':eccentricity' => $data[12], ':inclination' => $data[13], ':period' => !empty($period) ? $period : NULL, ':launch_mass' => !empty($data[15]) ? str_replace(array('+',','),'',$data[15]) : NULL, ':dry_mass' => !empty($data[16]) ? str_replace(array(',','-1900',' (BOL)',' (EOL)'),'',$data[16]) : NULL, ':power' => !empty($data[17]) ? str_replace(array(',',' (BOL)',' (EOL)'),'',$data[17]) : NULL, ':launch_date' => $launch_date, ':lifetime' => $data[19], ':contractor' => $data[20],':country_contractor' => $data[21], ':launch_site' => $data[22], ':launch_vehicule' => $data[23], ':cospar' => $data[24], ':norad' => $data[25], ':comments' => $data[26], ':source_orbital' => $data[27], ':sources' => $sources)); |
|
| 1427 | - } catch(PDOException $e) { |
|
| 1426 | + $sth->execute(array(':name' => $data[0], ':name_alternate' => '', ':country_un' => $data[1], ':country_owner' => $data[2], ':owner' => $data[3], ':users' => $data[4], ':purpose' => $data[5], ':purpose_detailed' => $data[6], ':orbit' => $data[7], ':type' => $data[8], ':longitude_geo' => $data[9], ':perigee' => !empty($data[10]) ? str_replace(',', '', $data[10]) : NULL, ':apogee' => !empty($data[11]) ? str_replace(',', '', $data[11]) : NULL, ':eccentricity' => $data[12], ':inclination' => $data[13], ':period' => !empty($period) ? $period : NULL, ':launch_mass' => !empty($data[15]) ? str_replace(array('+', ','), '', $data[15]) : NULL, ':dry_mass' => !empty($data[16]) ? str_replace(array(',', '-1900', ' (BOL)', ' (EOL)'), '', $data[16]) : NULL, ':power' => !empty($data[17]) ? str_replace(array(',', ' (BOL)', ' (EOL)'), '', $data[17]) : NULL, ':launch_date' => $launch_date, ':lifetime' => $data[19], ':contractor' => $data[20], ':country_contractor' => $data[21], ':launch_site' => $data[22], ':launch_vehicule' => $data[23], ':cospar' => $data[24], ':norad' => $data[25], ':comments' => $data[26], ':source_orbital' => $data[27], ':sources' => $sources)); |
|
| 1427 | + } catch (PDOException $e) { |
|
| 1428 | 1428 | return "error : ".$e->getMessage(); |
| 1429 | 1429 | } |
| 1430 | 1430 | } |
@@ -1464,7 +1464,7 @@ discard block |
||
| 1464 | 1464 | 'EGYP' => array('country' => 'Egypt', 'owner' => ''), |
| 1465 | 1465 | 'ESA' => array('country' => 'Multinational', 'owner' => 'European Space Agency'), |
| 1466 | 1466 | 'ESRO' => array('country' => 'Multinational', 'owner' => 'European Space Research Organization'), |
| 1467 | - 'EST' => array('country' => 'Estonia','owner' => ''), |
|
| 1467 | + 'EST' => array('country' => 'Estonia', 'owner' => ''), |
|
| 1468 | 1468 | 'EUME' => array('country' => 'Multinational', 'owner' => 'EUMETSAT (European Organization for the Exploitation of Meteorological Satellites)'), |
| 1469 | 1469 | 'EUTE' => array('country' => 'Multinational', 'owner' => 'European Telecommunications Satellite Consortium (EUTELSAT)'), |
| 1470 | 1470 | 'FGER' => array('country' => 'France/Germany', 'owner' => ''), |
@@ -1587,10 +1587,10 @@ discard block |
||
| 1587 | 1587 | while (($data = fgets($handle, 1000)) !== FALSE) |
| 1588 | 1588 | { |
| 1589 | 1589 | $result = array(); |
| 1590 | - $result['cospar'] = trim(substr($data,0,11)); |
|
| 1591 | - $result['norad'] = trim(substr($data,13,6)); |
|
| 1592 | - $result['operational'] = trim(substr($data,21,1)); |
|
| 1593 | - $result['name'] = trim(substr($data,23,24)); |
|
| 1590 | + $result['cospar'] = trim(substr($data, 0, 11)); |
|
| 1591 | + $result['norad'] = trim(substr($data, 13, 6)); |
|
| 1592 | + $result['operational'] = trim(substr($data, 21, 1)); |
|
| 1593 | + $result['name'] = trim(substr($data, 23, 24)); |
|
| 1594 | 1594 | /* |
| 1595 | 1595 | * R/B(1) = Rocket body, first stage |
| 1596 | 1596 | * R/B(2) = Rocket body, second stage |
@@ -1602,20 +1602,20 @@ discard block |
||
| 1602 | 1602 | * An ampersand (&) indicates two or more objects are attached |
| 1603 | 1603 | */ |
| 1604 | 1604 | |
| 1605 | - $owner_code = trim(substr($data,49,5)); |
|
| 1605 | + $owner_code = trim(substr($data, 49, 5)); |
|
| 1606 | 1606 | if ($owner_code != 'TBD') { |
| 1607 | 1607 | $result['country_owner'] = $satcat_sources[$owner_code]['country']; |
| 1608 | 1608 | $result['owner'] = $satcat_sources[$owner_code]['owner']; |
| 1609 | - $result['launch_date'] = trim(substr($data,56,10)); |
|
| 1610 | - $launch_site_code = trim(substr($data,68,5)); |
|
| 1609 | + $result['launch_date'] = trim(substr($data, 56, 10)); |
|
| 1610 | + $launch_site_code = trim(substr($data, 68, 5)); |
|
| 1611 | 1611 | $result['launch_site'] = $satcat_launch_site[$launch_site_code]; |
| 1612 | - $result['lifetime'] = trim(substr($data,75,10)); |
|
| 1613 | - $result['period'] = trim(substr($data,87,7)); |
|
| 1614 | - $result['inclination'] = trim(substr($data,96,5)); |
|
| 1615 | - $result['apogee'] = trim(substr($data,103,6)); |
|
| 1616 | - $result['perigee'] = trim(substr($data,111,6)); |
|
| 1612 | + $result['lifetime'] = trim(substr($data, 75, 10)); |
|
| 1613 | + $result['period'] = trim(substr($data, 87, 7)); |
|
| 1614 | + $result['inclination'] = trim(substr($data, 96, 5)); |
|
| 1615 | + $result['apogee'] = trim(substr($data, 103, 6)); |
|
| 1616 | + $result['perigee'] = trim(substr($data, 111, 6)); |
|
| 1617 | 1617 | //$result['radarcross'] = trim(substr($data,119,8)); |
| 1618 | - $result['status'] = trim(substr($data,129,3)); |
|
| 1618 | + $result['status'] = trim(substr($data, 129, 3)); |
|
| 1619 | 1619 | //print_r($result); |
| 1620 | 1620 | $result = array_map(function($value) { |
| 1621 | 1621 | return trim($value) === '' ? null : $value; |
@@ -1628,7 +1628,7 @@ discard block |
||
| 1628 | 1628 | $sth = $Connection->db->prepare($query); |
| 1629 | 1629 | $sth->execute(array(':cospar' => $result['cospar'])); |
| 1630 | 1630 | $exist = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 1631 | - } catch(PDOException $e) { |
|
| 1631 | + } catch (PDOException $e) { |
|
| 1632 | 1632 | return "error : ".$e->getMessage(); |
| 1633 | 1633 | } |
| 1634 | 1634 | if (empty($exist)) { |
@@ -1640,10 +1640,10 @@ discard block |
||
| 1640 | 1640 | ':name' => $result['name'], ':name_alternate' => '', ':country_un' => '', ':country_owner' => $result['country_owner'], ':owner' => $result['owner'], ':users' => '', ':purpose' => '', ':purpose_detailed' => '', ':orbit' => $result['status'], |
| 1641 | 1641 | ':type' => '', ':longitude_geo' => NULL, ':perigee' => !empty($result['perigee']) ? $result['perigee'] : NULL, ':apogee' => !empty($result['apogee']) ? $result['apogee'] : NULL, ':eccentricity' => NULL, ':inclination' => $result['inclination'], |
| 1642 | 1642 | ':period' => !empty($result['period']) ? $result['period'] : NULL, ':launch_mass' => NULL, ':dry_mass' => NULL, ':power' => NULL, ':launch_date' => $result['launch_date'], ':lifetime' => $result['lifetime'], |
| 1643 | - ':contractor' => '',':country_contractor' => '', ':launch_site' => $result['launch_site'], ':launch_vehicule' => '', ':cospar' => $result['cospar'], ':norad' => $result['norad'], ':comments' => '', ':source_orbital' => '', ':sources' => '' |
|
| 1643 | + ':contractor' => '', ':country_contractor' => '', ':launch_site' => $result['launch_site'], ':launch_vehicule' => '', ':cospar' => $result['cospar'], ':norad' => $result['norad'], ':comments' => '', ':source_orbital' => '', ':sources' => '' |
|
| 1644 | 1644 | ) |
| 1645 | 1645 | ); |
| 1646 | - } catch(PDOException $e) { |
|
| 1646 | + } catch (PDOException $e) { |
|
| 1647 | 1647 | return "error : ".$e->getMessage(); |
| 1648 | 1648 | } |
| 1649 | 1649 | } elseif ($exist[0]['name'] != $result['name'] && $exist[0]['name_alternate'] != $result['name']) { |
@@ -1651,8 +1651,8 @@ discard block |
||
| 1651 | 1651 | try { |
| 1652 | 1652 | $Connection = new Connection(); |
| 1653 | 1653 | $sth = $Connection->db->prepare($query); |
| 1654 | - $sth->execute(array(':name_alternate' => $result['name'],':cospar' => $result['cospar'])); |
|
| 1655 | - } catch(PDOException $e) { |
|
| 1654 | + $sth->execute(array(':name_alternate' => $result['name'], ':cospar' => $result['cospar'])); |
|
| 1655 | + } catch (PDOException $e) { |
|
| 1656 | 1656 | return "error : ".$e->getMessage(); |
| 1657 | 1657 | } |
| 1658 | 1658 | } |
@@ -1771,13 +1771,13 @@ discard block |
||
| 1771 | 1771 | while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
| 1772 | 1772 | { |
| 1773 | 1773 | $i++; |
| 1774 | - if($i > 3 && count($row) > 2) { |
|
| 1774 | + if ($i > 3 && count($row) > 2) { |
|
| 1775 | 1775 | $data = array_values(array_filter($row)); |
| 1776 | 1776 | $cntdata = count($data); |
| 1777 | 1777 | if ($cntdata > 10) { |
| 1778 | 1778 | $value = $data[9]; |
| 1779 | 1779 | |
| 1780 | - for ($i =10;$i < $cntdata;$i++) { |
|
| 1780 | + for ($i = 10; $i < $cntdata; $i++) { |
|
| 1781 | 1781 | $value .= ' '.$data[$i]; |
| 1782 | 1782 | } |
| 1783 | 1783 | $data[9] = $value; |
@@ -1787,8 +1787,8 @@ discard block |
||
| 1787 | 1787 | $query = 'INSERT INTO waypoints (name_begin,latitude_begin,longitude_begin,name_end,latitude_end,longitude_end,high,base,top,segment_name) VALUES (:name_begin, :latitude_begin, :longitude_begin, :name_end, :latitude_end, :longitude_end, :high, :base, :top, :segment_name)'; |
| 1788 | 1788 | try { |
| 1789 | 1789 | $sth = $Connection->db->prepare($query); |
| 1790 | - $sth->execute(array(':name_begin' => $data[0],':latitude_begin' => $data[1],':longitude_begin' => $data[2],':name_end' => $data[3], ':latitude_end' => $data[4], ':longitude_end' => $data[5], ':high' => $data[6], ':base' => $data[7], ':top' => $data[8], ':segment_name' => $data[9])); |
|
| 1791 | - } catch(PDOException $e) { |
|
| 1790 | + $sth->execute(array(':name_begin' => $data[0], ':latitude_begin' => $data[1], ':longitude_begin' => $data[2], ':name_end' => $data[3], ':latitude_end' => $data[4], ':longitude_end' => $data[5], ':high' => $data[6], ':base' => $data[7], ':top' => $data[8], ':segment_name' => $data[9])); |
|
| 1791 | + } catch (PDOException $e) { |
|
| 1792 | 1792 | return "error : ".$e->getMessage(); |
| 1793 | 1793 | } |
| 1794 | 1794 | } |
@@ -1809,7 +1809,7 @@ discard block |
||
| 1809 | 1809 | $Connection = new Connection(); |
| 1810 | 1810 | $sth = $Connection->db->prepare($query); |
| 1811 | 1811 | $sth->execute(); |
| 1812 | - } catch(PDOException $e) { |
|
| 1812 | + } catch (PDOException $e) { |
|
| 1813 | 1813 | return "error : ".$e->getMessage(); |
| 1814 | 1814 | } |
| 1815 | 1815 | |
@@ -1821,12 +1821,12 @@ discard block |
||
| 1821 | 1821 | if ($globalTransaction) $Connection->db->beginTransaction(); |
| 1822 | 1822 | while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
| 1823 | 1823 | { |
| 1824 | - if(count($row) > 1) { |
|
| 1824 | + if (count($row) > 1) { |
|
| 1825 | 1825 | $query = "INSERT INTO airlines (name,icao,active,forsource) VALUES (:name, :icao, 'Y','ivao')"; |
| 1826 | 1826 | try { |
| 1827 | 1827 | $sth = $Connection->db->prepare($query); |
| 1828 | - $sth->execute(array(':name' => $row[1],':icao' => $row[0])); |
|
| 1829 | - } catch(PDOException $e) { |
|
| 1828 | + $sth->execute(array(':name' => $row[1], ':icao' => $row[0])); |
|
| 1829 | + } catch (PDOException $e) { |
|
| 1830 | 1830 | return "error : ".$e->getMessage(); |
| 1831 | 1831 | } |
| 1832 | 1832 | } |
@@ -1846,21 +1846,21 @@ discard block |
||
| 1846 | 1846 | try { |
| 1847 | 1847 | $sth = $Connection->db->prepare($query); |
| 1848 | 1848 | $sth->execute(); |
| 1849 | - } catch(PDOException $e) { |
|
| 1849 | + } catch (PDOException $e) { |
|
| 1850 | 1850 | return "error : ".$e->getMessage(); |
| 1851 | 1851 | } |
| 1852 | 1852 | } |
| 1853 | 1853 | |
| 1854 | 1854 | |
| 1855 | - if ($globalDBdriver == 'mysql') update_db::gunzip('../db/airspace.sql.gz',$tmp_dir.'airspace.sql'); |
|
| 1855 | + if ($globalDBdriver == 'mysql') update_db::gunzip('../db/airspace.sql.gz', $tmp_dir.'airspace.sql'); |
|
| 1856 | 1856 | else { |
| 1857 | - update_db::gunzip('../db/pgsql/airspace.sql.gz',$tmp_dir.'airspace.sql'); |
|
| 1857 | + update_db::gunzip('../db/pgsql/airspace.sql.gz', $tmp_dir.'airspace.sql'); |
|
| 1858 | 1858 | $query = "CREATE EXTENSION postgis"; |
| 1859 | - $Connection = new Connection(null,null,$_SESSION['database_root'],$_SESSION['database_rootpass']); |
|
| 1859 | + $Connection = new Connection(null, null, $_SESSION['database_root'], $_SESSION['database_rootpass']); |
|
| 1860 | 1860 | try { |
| 1861 | 1861 | $sth = $Connection->db->prepare($query); |
| 1862 | 1862 | $sth->execute(); |
| 1863 | - } catch(PDOException $e) { |
|
| 1863 | + } catch (PDOException $e) { |
|
| 1864 | 1864 | return "error : ".$e->getMessage(); |
| 1865 | 1865 | } |
| 1866 | 1866 | } |
@@ -1873,11 +1873,11 @@ discard block |
||
| 1873 | 1873 | include_once('class.create_db.php'); |
| 1874 | 1874 | require_once(dirname(__FILE__).'/../require/class.NOTAM.php'); |
| 1875 | 1875 | if ($globalDebug) echo "NOTAM from FlightAirMap website : Download..."; |
| 1876 | - update_db::download('http://data.flightairmap.com/data/notam.txt.gz',$tmp_dir.'notam.txt.gz'); |
|
| 1877 | - update_db::download('http://data.flightairmap.com/data/notam.txt.gz.md5',$tmp_dir.'notam.txt.gz.md5'); |
|
| 1876 | + update_db::download('http://data.flightairmap.com/data/notam.txt.gz', $tmp_dir.'notam.txt.gz'); |
|
| 1877 | + update_db::download('http://data.flightairmap.com/data/notam.txt.gz.md5', $tmp_dir.'notam.txt.gz.md5'); |
|
| 1878 | 1878 | $error = ''; |
| 1879 | 1879 | if (file_exists($tmp_dir.'notam.txt.gz') && file_exists($tmp_dir.'notam.txt.gz.md5')) { |
| 1880 | - $notam_md5_file = explode(' ',file_get_contents($tmp_dir.'notam.txt.gz.md5')); |
|
| 1880 | + $notam_md5_file = explode(' ', file_get_contents($tmp_dir.'notam.txt.gz.md5')); |
|
| 1881 | 1881 | $notam_md5 = $notam_md5_file[0]; |
| 1882 | 1882 | if (md5_file($tmp_dir.'notam.txt.gz') == $notam_md5) { |
| 1883 | 1883 | if ($globalDebug) echo "Gunzip..."; |
@@ -1910,14 +1910,14 @@ discard block |
||
| 1910 | 1910 | try { |
| 1911 | 1911 | $sth = $Connection->db->prepare($query); |
| 1912 | 1912 | $sth->execute(); |
| 1913 | - } catch(PDOException $e) { |
|
| 1913 | + } catch (PDOException $e) { |
|
| 1914 | 1914 | echo "error : ".$e->getMessage(); |
| 1915 | 1915 | } |
| 1916 | 1916 | } |
| 1917 | 1917 | if ($globalDBdriver == 'mysql') { |
| 1918 | - update_db::gunzip('../db/countries.sql.gz',$tmp_dir.'countries.sql'); |
|
| 1918 | + update_db::gunzip('../db/countries.sql.gz', $tmp_dir.'countries.sql'); |
|
| 1919 | 1919 | } else { |
| 1920 | - update_db::gunzip('../db/pgsql/countries.sql.gz',$tmp_dir.'countries.sql'); |
|
| 1920 | + update_db::gunzip('../db/pgsql/countries.sql.gz', $tmp_dir.'countries.sql'); |
|
| 1921 | 1921 | } |
| 1922 | 1922 | $error = create_db::import_file($tmp_dir.'countries.sql'); |
| 1923 | 1923 | return $error; |
@@ -1930,7 +1930,7 @@ discard block |
||
| 1930 | 1930 | // update_db::unzip($tmp_dir.'AptNav.zip'); |
| 1931 | 1931 | // update_db::download('https://gitorious.org/fg/fgdata/raw/e81f8a15424a175a7b715f8f7eb8f4147b802a27:Navaids/awy.dat.gz',$tmp_dir.'awy.dat.gz'); |
| 1932 | 1932 | // update_db::download('http://sourceforge.net/p/flightgear/fgdata/ci/next/tree/Navaids/awy.dat.gz?format=raw',$tmp_dir.'awy.dat.gz','http://sourceforge.net'); |
| 1933 | - update_db::download('http://pkgs.fedoraproject.org/repo/extras/FlightGear-Atlas/awy.dat.gz/f530c9d1c4b31a288ba88dcc8224268b/awy.dat.gz',$tmp_dir.'awy.dat.gz','http://sourceforge.net'); |
|
| 1933 | + update_db::download('http://pkgs.fedoraproject.org/repo/extras/FlightGear-Atlas/awy.dat.gz/f530c9d1c4b31a288ba88dcc8224268b/awy.dat.gz', $tmp_dir.'awy.dat.gz', 'http://sourceforge.net'); |
|
| 1934 | 1934 | update_db::gunzip($tmp_dir.'awy.dat.gz'); |
| 1935 | 1935 | $error = update_db::waypoints($tmp_dir.'awy.dat'); |
| 1936 | 1936 | return $error; |
@@ -1951,7 +1951,7 @@ discard block |
||
| 1951 | 1951 | update_db::ivao_airlines($tmp_dir.'data/airlines.dat'); |
| 1952 | 1952 | if ($globalDebug) echo "Copy airlines logos to airlines images directory..."; |
| 1953 | 1953 | if (is_writable(dirname(__FILE__).'/../images/airlines')) { |
| 1954 | - if (!$Common->xcopy($tmp_dir.'logos/',dirname(__FILE__).'/../images/airlines/')) $error = "Failed to copy airlines logo."; |
|
| 1954 | + if (!$Common->xcopy($tmp_dir.'logos/', dirname(__FILE__).'/../images/airlines/')) $error = "Failed to copy airlines logo."; |
|
| 1955 | 1955 | } else $error = "The directory ".dirname(__FILE__).'/../images/airlines'." must be writable"; |
| 1956 | 1956 | } else $error = "File ".$tmp_dir.'ivao.zip'." doesn't exist. Download failed."; |
| 1957 | 1957 | } else $error = "ZIP module not loaded but required for IVAO."; |
@@ -1965,7 +1965,7 @@ discard block |
||
| 1965 | 1965 | global $tmp_dir, $globalDebug; |
| 1966 | 1966 | $error = ''; |
| 1967 | 1967 | if ($globalDebug) echo "Routes : Download..."; |
| 1968 | - update_db::download('http://www.virtualradarserver.co.uk/Files/StandingData.sqb.gz',$tmp_dir.'StandingData.sqb.gz'); |
|
| 1968 | + update_db::download('http://www.virtualradarserver.co.uk/Files/StandingData.sqb.gz', $tmp_dir.'StandingData.sqb.gz'); |
|
| 1969 | 1969 | if (file_exists($tmp_dir.'StandingData.sqb.gz')) { |
| 1970 | 1970 | if ($globalDebug) echo "Gunzip..."; |
| 1971 | 1971 | update_db::gunzip($tmp_dir.'StandingData.sqb.gz'); |
@@ -1981,7 +1981,7 @@ discard block |
||
| 1981 | 1981 | global $tmp_dir, $globalDebug; |
| 1982 | 1982 | $error = ''; |
| 1983 | 1983 | if ($globalDebug) echo "Schedules Oneworld : Download..."; |
| 1984 | - update_db::download('http://data.flightairmap.com/data/schedules/oneworld.csv.gz',$tmp_dir.'oneworld.csv.gz'); |
|
| 1984 | + update_db::download('http://data.flightairmap.com/data/schedules/oneworld.csv.gz', $tmp_dir.'oneworld.csv.gz'); |
|
| 1985 | 1985 | if (file_exists($tmp_dir.'oneworld.csv.gz')) { |
| 1986 | 1986 | if ($globalDebug) echo "Gunzip..."; |
| 1987 | 1987 | update_db::gunzip($tmp_dir.'oneworld.csv.gz'); |
@@ -1997,7 +1997,7 @@ discard block |
||
| 1997 | 1997 | global $tmp_dir, $globalDebug; |
| 1998 | 1998 | $error = ''; |
| 1999 | 1999 | if ($globalDebug) echo "Schedules Skyteam : Download..."; |
| 2000 | - update_db::download('http://data.flightairmap.com/data/schedules/skyteam.csv.gz',$tmp_dir.'skyteam.csv.gz'); |
|
| 2000 | + update_db::download('http://data.flightairmap.com/data/schedules/skyteam.csv.gz', $tmp_dir.'skyteam.csv.gz'); |
|
| 2001 | 2001 | if (file_exists($tmp_dir.'skyteam.csv.gz')) { |
| 2002 | 2002 | if ($globalDebug) echo "Gunzip..."; |
| 2003 | 2003 | update_db::gunzip($tmp_dir.'skyteam.csv.gz'); |
@@ -2025,7 +2025,7 @@ discard block |
||
| 2025 | 2025 | */ |
| 2026 | 2026 | if ($globalDebug) echo "Modes : Download..."; |
| 2027 | 2027 | // update_db::download('http://planebase.biz/sqb.php?f=basestationall.zip',$tmp_dir.'basestation_latest.zip','http://planebase.biz/bstnsqb'); |
| 2028 | - update_db::download('http://data.flightairmap.com/data/BaseStation.sqb.gz',$tmp_dir.'BaseStation.sqb.gz'); |
|
| 2028 | + update_db::download('http://data.flightairmap.com/data/BaseStation.sqb.gz', $tmp_dir.'BaseStation.sqb.gz'); |
|
| 2029 | 2029 | |
| 2030 | 2030 | // if (file_exists($tmp_dir.'basestation_latest.zip')) { |
| 2031 | 2031 | if (file_exists($tmp_dir.'BaseStation.sqb.gz')) { |
@@ -2045,7 +2045,7 @@ discard block |
||
| 2045 | 2045 | public static function update_ModeS_faa() { |
| 2046 | 2046 | global $tmp_dir, $globalDebug; |
| 2047 | 2047 | if ($globalDebug) echo "Modes FAA: Download..."; |
| 2048 | - update_db::download('http://registry.faa.gov/database/ReleasableAircraft.zip',$tmp_dir.'ReleasableAircraft.zip'); |
|
| 2048 | + update_db::download('http://registry.faa.gov/database/ReleasableAircraft.zip', $tmp_dir.'ReleasableAircraft.zip'); |
|
| 2049 | 2049 | if (file_exists($tmp_dir.'ReleasableAircraft.zip')) { |
| 2050 | 2050 | if ($globalDebug) echo "Unzip..."; |
| 2051 | 2051 | update_db::unzip($tmp_dir.'ReleasableAircraft.zip'); |
@@ -2061,7 +2061,7 @@ discard block |
||
| 2061 | 2061 | public static function update_ModeS_flarm() { |
| 2062 | 2062 | global $tmp_dir, $globalDebug; |
| 2063 | 2063 | if ($globalDebug) echo "Modes Flarmnet: Download..."; |
| 2064 | - update_db::download('http://flarmnet.org/files/data.fln',$tmp_dir.'data.fln'); |
|
| 2064 | + update_db::download('http://flarmnet.org/files/data.fln', $tmp_dir.'data.fln'); |
|
| 2065 | 2065 | if (file_exists($tmp_dir.'data.fln')) { |
| 2066 | 2066 | if ($globalDebug) echo "Add to DB..."; |
| 2067 | 2067 | $error = update_db::retrieve_modes_flarmnet($tmp_dir.'data.fln'); |
@@ -2075,7 +2075,7 @@ discard block |
||
| 2075 | 2075 | public static function update_ModeS_ogn() { |
| 2076 | 2076 | global $tmp_dir, $globalDebug; |
| 2077 | 2077 | if ($globalDebug) echo "Modes OGN: Download..."; |
| 2078 | - update_db::download('http://ddb.glidernet.org/download/',$tmp_dir.'ogn.csv'); |
|
| 2078 | + update_db::download('http://ddb.glidernet.org/download/', $tmp_dir.'ogn.csv'); |
|
| 2079 | 2079 | if (file_exists($tmp_dir.'ogn.csv')) { |
| 2080 | 2080 | if ($globalDebug) echo "Add to DB..."; |
| 2081 | 2081 | $error = update_db::retrieve_modes_ogn($tmp_dir.'ogn.csv'); |
@@ -2090,201 +2090,201 @@ discard block |
||
| 2090 | 2090 | global $tmp_dir, $globalDebug, $globalMasterSource; |
| 2091 | 2091 | |
| 2092 | 2092 | if ($globalDebug) echo "Owner France: Download..."; |
| 2093 | - update_db::download('http://antonakis.co.uk/registers/France.txt',$tmp_dir.'owner_f.csv'); |
|
| 2093 | + update_db::download('http://antonakis.co.uk/registers/France.txt', $tmp_dir.'owner_f.csv'); |
|
| 2094 | 2094 | if (file_exists($tmp_dir.'owner_f.csv')) { |
| 2095 | 2095 | if ($globalDebug) echo "Add to DB..."; |
| 2096 | - $error = update_db::retrieve_owner($tmp_dir.'owner_f.csv','F'); |
|
| 2096 | + $error = update_db::retrieve_owner($tmp_dir.'owner_f.csv', 'F'); |
|
| 2097 | 2097 | } else $error = "File ".$tmp_dir.'owner_f.csv'." doesn't exist. Download failed."; |
| 2098 | 2098 | if ($error != '') { |
| 2099 | 2099 | return $error; |
| 2100 | 2100 | } elseif ($globalDebug) echo "Done\n"; |
| 2101 | 2101 | |
| 2102 | 2102 | if ($globalDebug) echo "Owner Ireland: Download..."; |
| 2103 | - update_db::download('http://antonakis.co.uk/registers/Ireland.txt',$tmp_dir.'owner_ei.csv'); |
|
| 2103 | + update_db::download('http://antonakis.co.uk/registers/Ireland.txt', $tmp_dir.'owner_ei.csv'); |
|
| 2104 | 2104 | if (file_exists($tmp_dir.'owner_ei.csv')) { |
| 2105 | 2105 | if ($globalDebug) echo "Add to DB..."; |
| 2106 | - $error = update_db::retrieve_owner($tmp_dir.'owner_ei.csv','EI'); |
|
| 2106 | + $error = update_db::retrieve_owner($tmp_dir.'owner_ei.csv', 'EI'); |
|
| 2107 | 2107 | } else $error = "File ".$tmp_dir.'owner_ei.csv'." doesn't exist. Download failed."; |
| 2108 | 2108 | if ($error != '') { |
| 2109 | 2109 | return $error; |
| 2110 | 2110 | } elseif ($globalDebug) echo "Done\n"; |
| 2111 | 2111 | if ($globalDebug) echo "Owner Switzerland: Download..."; |
| 2112 | - update_db::download('http://antonakis.co.uk/registers/Switzerland.txt',$tmp_dir.'owner_hb.csv'); |
|
| 2112 | + update_db::download('http://antonakis.co.uk/registers/Switzerland.txt', $tmp_dir.'owner_hb.csv'); |
|
| 2113 | 2113 | if (file_exists($tmp_dir.'owner_hb.csv')) { |
| 2114 | 2114 | if ($globalDebug) echo "Add to DB..."; |
| 2115 | - $error = update_db::retrieve_owner($tmp_dir.'owner_hb.csv','HB'); |
|
| 2115 | + $error = update_db::retrieve_owner($tmp_dir.'owner_hb.csv', 'HB'); |
|
| 2116 | 2116 | } else $error = "File ".$tmp_dir.'owner_hb.csv'." doesn't exist. Download failed."; |
| 2117 | 2117 | if ($error != '') { |
| 2118 | 2118 | return $error; |
| 2119 | 2119 | } elseif ($globalDebug) echo "Done\n"; |
| 2120 | 2120 | if ($globalDebug) echo "Owner Czech Republic: Download..."; |
| 2121 | - update_db::download('http://antonakis.co.uk/registers/CzechRepublic.txt',$tmp_dir.'owner_ok.csv'); |
|
| 2121 | + update_db::download('http://antonakis.co.uk/registers/CzechRepublic.txt', $tmp_dir.'owner_ok.csv'); |
|
| 2122 | 2122 | if (file_exists($tmp_dir.'owner_ok.csv')) { |
| 2123 | 2123 | if ($globalDebug) echo "Add to DB..."; |
| 2124 | - $error = update_db::retrieve_owner($tmp_dir.'owner_ok.csv','OK'); |
|
| 2124 | + $error = update_db::retrieve_owner($tmp_dir.'owner_ok.csv', 'OK'); |
|
| 2125 | 2125 | } else $error = "File ".$tmp_dir.'owner_ok.csv'." doesn't exist. Download failed."; |
| 2126 | 2126 | if ($error != '') { |
| 2127 | 2127 | return $error; |
| 2128 | 2128 | } elseif ($globalDebug) echo "Done\n"; |
| 2129 | 2129 | if ($globalDebug) echo "Owner Australia: Download..."; |
| 2130 | - update_db::download('http://antonakis.co.uk/registers/Australia.txt',$tmp_dir.'owner_vh.csv'); |
|
| 2130 | + update_db::download('http://antonakis.co.uk/registers/Australia.txt', $tmp_dir.'owner_vh.csv'); |
|
| 2131 | 2131 | if (file_exists($tmp_dir.'owner_vh.csv')) { |
| 2132 | 2132 | if ($globalDebug) echo "Add to DB..."; |
| 2133 | - $error = update_db::retrieve_owner($tmp_dir.'owner_vh.csv','VH'); |
|
| 2133 | + $error = update_db::retrieve_owner($tmp_dir.'owner_vh.csv', 'VH'); |
|
| 2134 | 2134 | } else $error = "File ".$tmp_dir.'owner_vh.csv'." doesn't exist. Download failed."; |
| 2135 | 2135 | if ($error != '') { |
| 2136 | 2136 | return $error; |
| 2137 | 2137 | } elseif ($globalDebug) echo "Done\n"; |
| 2138 | 2138 | if ($globalDebug) echo "Owner Austria: Download..."; |
| 2139 | - update_db::download('http://antonakis.co.uk/registers/Austria.txt',$tmp_dir.'owner_oe.csv'); |
|
| 2139 | + update_db::download('http://antonakis.co.uk/registers/Austria.txt', $tmp_dir.'owner_oe.csv'); |
|
| 2140 | 2140 | if (file_exists($tmp_dir.'owner_oe.csv')) { |
| 2141 | 2141 | if ($globalDebug) echo "Add to DB..."; |
| 2142 | - $error = update_db::retrieve_owner($tmp_dir.'owner_oe.csv','OE'); |
|
| 2142 | + $error = update_db::retrieve_owner($tmp_dir.'owner_oe.csv', 'OE'); |
|
| 2143 | 2143 | } else $error = "File ".$tmp_dir.'owner_oe.csv'." doesn't exist. Download failed."; |
| 2144 | 2144 | if ($error != '') { |
| 2145 | 2145 | return $error; |
| 2146 | 2146 | } elseif ($globalDebug) echo "Done\n"; |
| 2147 | 2147 | if ($globalDebug) echo "Owner Chile: Download..."; |
| 2148 | - update_db::download('http://antonakis.co.uk/registers/Chile.txt',$tmp_dir.'owner_cc.csv'); |
|
| 2148 | + update_db::download('http://antonakis.co.uk/registers/Chile.txt', $tmp_dir.'owner_cc.csv'); |
|
| 2149 | 2149 | if (file_exists($tmp_dir.'owner_cc.csv')) { |
| 2150 | 2150 | if ($globalDebug) echo "Add to DB..."; |
| 2151 | - $error = update_db::retrieve_owner($tmp_dir.'owner_cc.csv','CC'); |
|
| 2151 | + $error = update_db::retrieve_owner($tmp_dir.'owner_cc.csv', 'CC'); |
|
| 2152 | 2152 | } else $error = "File ".$tmp_dir.'owner_cc.csv'." doesn't exist. Download failed."; |
| 2153 | 2153 | if ($error != '') { |
| 2154 | 2154 | return $error; |
| 2155 | 2155 | } elseif ($globalDebug) echo "Done\n"; |
| 2156 | 2156 | if ($globalDebug) echo "Owner Colombia: Download..."; |
| 2157 | - update_db::download('http://antonakis.co.uk/registers/Colombia.txt',$tmp_dir.'owner_hj.csv'); |
|
| 2157 | + update_db::download('http://antonakis.co.uk/registers/Colombia.txt', $tmp_dir.'owner_hj.csv'); |
|
| 2158 | 2158 | if (file_exists($tmp_dir.'owner_hj.csv')) { |
| 2159 | 2159 | if ($globalDebug) echo "Add to DB..."; |
| 2160 | - $error = update_db::retrieve_owner($tmp_dir.'owner_hj.csv','HJ'); |
|
| 2160 | + $error = update_db::retrieve_owner($tmp_dir.'owner_hj.csv', 'HJ'); |
|
| 2161 | 2161 | } else $error = "File ".$tmp_dir.'owner_hj.csv'." doesn't exist. Download failed."; |
| 2162 | 2162 | if ($error != '') { |
| 2163 | 2163 | return $error; |
| 2164 | 2164 | } elseif ($globalDebug) echo "Done\n"; |
| 2165 | 2165 | if ($globalDebug) echo "Owner Bosnia Herzegobina: Download..."; |
| 2166 | - update_db::download('http://antonakis.co.uk/registers/BosniaHerzegovina.txt',$tmp_dir.'owner_e7.csv'); |
|
| 2166 | + update_db::download('http://antonakis.co.uk/registers/BosniaHerzegovina.txt', $tmp_dir.'owner_e7.csv'); |
|
| 2167 | 2167 | if (file_exists($tmp_dir.'owner_e7.csv')) { |
| 2168 | 2168 | if ($globalDebug) echo "Add to DB..."; |
| 2169 | - $error = update_db::retrieve_owner($tmp_dir.'owner_e7.csv','E7'); |
|
| 2169 | + $error = update_db::retrieve_owner($tmp_dir.'owner_e7.csv', 'E7'); |
|
| 2170 | 2170 | } else $error = "File ".$tmp_dir.'owner_e7.csv'." doesn't exist. Download failed."; |
| 2171 | 2171 | if ($error != '') { |
| 2172 | 2172 | return $error; |
| 2173 | 2173 | } elseif ($globalDebug) echo "Done\n"; |
| 2174 | 2174 | if ($globalDebug) echo "Owner Brazil: Download..."; |
| 2175 | - update_db::download('http://antonakis.co.uk/registers/Brazil.txt',$tmp_dir.'owner_pp.csv'); |
|
| 2175 | + update_db::download('http://antonakis.co.uk/registers/Brazil.txt', $tmp_dir.'owner_pp.csv'); |
|
| 2176 | 2176 | if (file_exists($tmp_dir.'owner_pp.csv')) { |
| 2177 | 2177 | if ($globalDebug) echo "Add to DB..."; |
| 2178 | - $error = update_db::retrieve_owner($tmp_dir.'owner_pp.csv','PP'); |
|
| 2178 | + $error = update_db::retrieve_owner($tmp_dir.'owner_pp.csv', 'PP'); |
|
| 2179 | 2179 | } else $error = "File ".$tmp_dir.'owner_pp.csv'." doesn't exist. Download failed."; |
| 2180 | 2180 | if ($error != '') { |
| 2181 | 2181 | return $error; |
| 2182 | 2182 | } elseif ($globalDebug) echo "Done\n"; |
| 2183 | 2183 | if ($globalDebug) echo "Owner Cayman Islands: Download..."; |
| 2184 | - update_db::download('http://antonakis.co.uk/registers/CaymanIslands.txt',$tmp_dir.'owner_vp.csv'); |
|
| 2184 | + update_db::download('http://antonakis.co.uk/registers/CaymanIslands.txt', $tmp_dir.'owner_vp.csv'); |
|
| 2185 | 2185 | if (file_exists($tmp_dir.'owner_vp.csv')) { |
| 2186 | 2186 | if ($globalDebug) echo "Add to DB..."; |
| 2187 | - $error = update_db::retrieve_owner($tmp_dir.'owner_vp.csv','VP'); |
|
| 2187 | + $error = update_db::retrieve_owner($tmp_dir.'owner_vp.csv', 'VP'); |
|
| 2188 | 2188 | } else $error = "File ".$tmp_dir.'owner_vp.csv'." doesn't exist. Download failed."; |
| 2189 | 2189 | if ($error != '') { |
| 2190 | 2190 | return $error; |
| 2191 | 2191 | } elseif ($globalDebug) echo "Done\n"; |
| 2192 | 2192 | if ($globalDebug) echo "Owner Croatia: Download..."; |
| 2193 | - update_db::download('http://antonakis.co.uk/registers/Croatia.txt',$tmp_dir.'owner_9a.csv'); |
|
| 2193 | + update_db::download('http://antonakis.co.uk/registers/Croatia.txt', $tmp_dir.'owner_9a.csv'); |
|
| 2194 | 2194 | if (file_exists($tmp_dir.'owner_9a.csv')) { |
| 2195 | 2195 | if ($globalDebug) echo "Add to DB..."; |
| 2196 | - $error = update_db::retrieve_owner($tmp_dir.'owner_9a.csv','9A'); |
|
| 2196 | + $error = update_db::retrieve_owner($tmp_dir.'owner_9a.csv', '9A'); |
|
| 2197 | 2197 | } else $error = "File ".$tmp_dir.'owner_9a.csv'." doesn't exist. Download failed."; |
| 2198 | 2198 | if ($error != '') { |
| 2199 | 2199 | return $error; |
| 2200 | 2200 | } elseif ($globalDebug) echo "Done\n"; |
| 2201 | 2201 | if ($globalDebug) echo "Owner Luxembourg: Download..."; |
| 2202 | - update_db::download('http://antonakis.co.uk/registers/Luxembourg.txt',$tmp_dir.'owner_lx.csv'); |
|
| 2202 | + update_db::download('http://antonakis.co.uk/registers/Luxembourg.txt', $tmp_dir.'owner_lx.csv'); |
|
| 2203 | 2203 | if (file_exists($tmp_dir.'owner_lx.csv')) { |
| 2204 | 2204 | if ($globalDebug) echo "Add to DB..."; |
| 2205 | - $error = update_db::retrieve_owner($tmp_dir.'owner_lx.csv','LX'); |
|
| 2205 | + $error = update_db::retrieve_owner($tmp_dir.'owner_lx.csv', 'LX'); |
|
| 2206 | 2206 | } else $error = "File ".$tmp_dir.'owner_lx.csv'." doesn't exist. Download failed."; |
| 2207 | 2207 | if ($error != '') { |
| 2208 | 2208 | return $error; |
| 2209 | 2209 | } elseif ($globalDebug) echo "Done\n"; |
| 2210 | 2210 | if ($globalDebug) echo "Owner Maldives: Download..."; |
| 2211 | - update_db::download('http://antonakis.co.uk/registers/Maldives.txt',$tmp_dir.'owner_8q.csv'); |
|
| 2211 | + update_db::download('http://antonakis.co.uk/registers/Maldives.txt', $tmp_dir.'owner_8q.csv'); |
|
| 2212 | 2212 | if (file_exists($tmp_dir.'owner_8q.csv')) { |
| 2213 | 2213 | if ($globalDebug) echo "Add to DB..."; |
| 2214 | - $error = update_db::retrieve_owner($tmp_dir.'owner_8q.csv','8Q'); |
|
| 2214 | + $error = update_db::retrieve_owner($tmp_dir.'owner_8q.csv', '8Q'); |
|
| 2215 | 2215 | } else $error = "File ".$tmp_dir.'owner_8q.csv'." doesn't exist. Download failed."; |
| 2216 | 2216 | if ($error != '') { |
| 2217 | 2217 | return $error; |
| 2218 | 2218 | } elseif ($globalDebug) echo "Done\n"; |
| 2219 | 2219 | if ($globalDebug) echo "Owner New Zealand: Download..."; |
| 2220 | - update_db::download('http://antonakis.co.uk/registers/NewZealand.txt',$tmp_dir.'owner_zk.csv'); |
|
| 2220 | + update_db::download('http://antonakis.co.uk/registers/NewZealand.txt', $tmp_dir.'owner_zk.csv'); |
|
| 2221 | 2221 | if (file_exists($tmp_dir.'owner_zk.csv')) { |
| 2222 | 2222 | if ($globalDebug) echo "Add to DB..."; |
| 2223 | - $error = update_db::retrieve_owner($tmp_dir.'owner_zk.csv','ZK'); |
|
| 2223 | + $error = update_db::retrieve_owner($tmp_dir.'owner_zk.csv', 'ZK'); |
|
| 2224 | 2224 | } else $error = "File ".$tmp_dir.'owner_zk.csv'." doesn't exist. Download failed."; |
| 2225 | 2225 | if ($error != '') { |
| 2226 | 2226 | return $error; |
| 2227 | 2227 | } elseif ($globalDebug) echo "Done\n"; |
| 2228 | 2228 | if ($globalDebug) echo "Owner Papua New Guinea: Download..."; |
| 2229 | - update_db::download('http://antonakis.co.uk/registers/PapuaNewGuinea.txt',$tmp_dir.'owner_p2.csv'); |
|
| 2229 | + update_db::download('http://antonakis.co.uk/registers/PapuaNewGuinea.txt', $tmp_dir.'owner_p2.csv'); |
|
| 2230 | 2230 | if (file_exists($tmp_dir.'owner_p2.csv')) { |
| 2231 | 2231 | if ($globalDebug) echo "Add to DB..."; |
| 2232 | - $error = update_db::retrieve_owner($tmp_dir.'owner_p2.csv','P2'); |
|
| 2232 | + $error = update_db::retrieve_owner($tmp_dir.'owner_p2.csv', 'P2'); |
|
| 2233 | 2233 | } else $error = "File ".$tmp_dir.'owner_p2.csv'." doesn't exist. Download failed."; |
| 2234 | 2234 | if ($error != '') { |
| 2235 | 2235 | return $error; |
| 2236 | 2236 | } elseif ($globalDebug) echo "Done\n"; |
| 2237 | 2237 | if ($globalDebug) echo "Owner Slovakia: Download..."; |
| 2238 | - update_db::download('http://antonakis.co.uk/registers/Slovakia.txt',$tmp_dir.'owner_om.csv'); |
|
| 2238 | + update_db::download('http://antonakis.co.uk/registers/Slovakia.txt', $tmp_dir.'owner_om.csv'); |
|
| 2239 | 2239 | if (file_exists($tmp_dir.'owner_om.csv')) { |
| 2240 | 2240 | if ($globalDebug) echo "Add to DB..."; |
| 2241 | - $error = update_db::retrieve_owner($tmp_dir.'owner_om.csv','OM'); |
|
| 2241 | + $error = update_db::retrieve_owner($tmp_dir.'owner_om.csv', 'OM'); |
|
| 2242 | 2242 | } else $error = "File ".$tmp_dir.'owner_om.csv'." doesn't exist. Download failed."; |
| 2243 | 2243 | if ($error != '') { |
| 2244 | 2244 | return $error; |
| 2245 | 2245 | } elseif ($globalDebug) echo "Done\n"; |
| 2246 | 2246 | if ($globalDebug) echo "Owner Ecuador: Download..."; |
| 2247 | - update_db::download('http://antonakis.co.uk/registers/Ecuador.txt',$tmp_dir.'owner_hc.csv'); |
|
| 2247 | + update_db::download('http://antonakis.co.uk/registers/Ecuador.txt', $tmp_dir.'owner_hc.csv'); |
|
| 2248 | 2248 | if (file_exists($tmp_dir.'owner_hc.csv')) { |
| 2249 | 2249 | if ($globalDebug) echo "Add to DB..."; |
| 2250 | - $error = update_db::retrieve_owner($tmp_dir.'owner_hc.csv','HC'); |
|
| 2250 | + $error = update_db::retrieve_owner($tmp_dir.'owner_hc.csv', 'HC'); |
|
| 2251 | 2251 | } else $error = "File ".$tmp_dir.'owner_hc.csv'." doesn't exist. Download failed."; |
| 2252 | 2252 | if ($error != '') { |
| 2253 | 2253 | return $error; |
| 2254 | 2254 | } elseif ($globalDebug) echo "Done\n"; |
| 2255 | 2255 | if ($globalDebug) echo "Owner Iceland: Download..."; |
| 2256 | - update_db::download('http://antonakis.co.uk/registers/Iceland.txt',$tmp_dir.'owner_tf.csv'); |
|
| 2256 | + update_db::download('http://antonakis.co.uk/registers/Iceland.txt', $tmp_dir.'owner_tf.csv'); |
|
| 2257 | 2257 | if (file_exists($tmp_dir.'owner_tf.csv')) { |
| 2258 | 2258 | if ($globalDebug) echo "Add to DB..."; |
| 2259 | - $error = update_db::retrieve_owner($tmp_dir.'owner_tf.csv','TF'); |
|
| 2259 | + $error = update_db::retrieve_owner($tmp_dir.'owner_tf.csv', 'TF'); |
|
| 2260 | 2260 | } else $error = "File ".$tmp_dir.'owner_tf.csv'." doesn't exist. Download failed."; |
| 2261 | 2261 | if ($error != '') { |
| 2262 | 2262 | return $error; |
| 2263 | 2263 | } elseif ($globalDebug) echo "Done\n"; |
| 2264 | 2264 | if ($globalDebug) echo "Owner Isle of Man: Download..."; |
| 2265 | - update_db::download('http://antonakis.co.uk/registers/IsleOfMan.txt',$tmp_dir.'owner_m.csv'); |
|
| 2265 | + update_db::download('http://antonakis.co.uk/registers/IsleOfMan.txt', $tmp_dir.'owner_m.csv'); |
|
| 2266 | 2266 | if (file_exists($tmp_dir.'owner_m.csv')) { |
| 2267 | 2267 | if ($globalDebug) echo "Add to DB..."; |
| 2268 | - $error = update_db::retrieve_owner($tmp_dir.'owner_m.csv','M'); |
|
| 2268 | + $error = update_db::retrieve_owner($tmp_dir.'owner_m.csv', 'M'); |
|
| 2269 | 2269 | } else $error = "File ".$tmp_dir.'owner_m.csv'." doesn't exist. Download failed."; |
| 2270 | 2270 | if ($error != '') { |
| 2271 | 2271 | return $error; |
| 2272 | 2272 | } elseif ($globalDebug) echo "Done\n"; |
| 2273 | 2273 | if ($globalMasterSource) { |
| 2274 | 2274 | if ($globalDebug) echo "ModeS Netherlands: Download..."; |
| 2275 | - update_db::download('http://antonakis.co.uk/registers/Netherlands.txt',$tmp_dir.'owner_ph.csv'); |
|
| 2275 | + update_db::download('http://antonakis.co.uk/registers/Netherlands.txt', $tmp_dir.'owner_ph.csv'); |
|
| 2276 | 2276 | if (file_exists($tmp_dir.'owner_ph.csv')) { |
| 2277 | 2277 | if ($globalDebug) echo "Add to DB..."; |
| 2278 | - $error = update_db::retrieve_owner($tmp_dir.'owner_ph.csv','PH'); |
|
| 2278 | + $error = update_db::retrieve_owner($tmp_dir.'owner_ph.csv', 'PH'); |
|
| 2279 | 2279 | } else $error = "File ".$tmp_dir.'owner_ph.csv'." doesn't exist. Download failed."; |
| 2280 | 2280 | if ($error != '') { |
| 2281 | 2281 | return $error; |
| 2282 | 2282 | } elseif ($globalDebug) echo "Done\n"; |
| 2283 | 2283 | if ($globalDebug) echo "ModeS Denmark: Download..."; |
| 2284 | - update_db::download('http://antonakis.co.uk/registers/Denmark.txt',$tmp_dir.'owner_oy.csv'); |
|
| 2284 | + update_db::download('http://antonakis.co.uk/registers/Denmark.txt', $tmp_dir.'owner_oy.csv'); |
|
| 2285 | 2285 | if (file_exists($tmp_dir.'owner_oy.csv')) { |
| 2286 | 2286 | if ($globalDebug) echo "Add to DB..."; |
| 2287 | - $error = update_db::retrieve_owner($tmp_dir.'owner_oy.csv','OY'); |
|
| 2287 | + $error = update_db::retrieve_owner($tmp_dir.'owner_oy.csv', 'OY'); |
|
| 2288 | 2288 | } else $error = "File ".$tmp_dir.'owner_oy.csv'." doesn't exist. Download failed."; |
| 2289 | 2289 | if ($error != '') { |
| 2290 | 2290 | return $error; |
@@ -2297,7 +2297,7 @@ discard block |
||
| 2297 | 2297 | global $tmp_dir, $globalDebug; |
| 2298 | 2298 | $error = ''; |
| 2299 | 2299 | if ($globalDebug) echo "Translation : Download..."; |
| 2300 | - update_db::download('http://www.acarsd.org/download/translation.php',$tmp_dir.'translation.zip'); |
|
| 2300 | + update_db::download('http://www.acarsd.org/download/translation.php', $tmp_dir.'translation.zip'); |
|
| 2301 | 2301 | if (file_exists($tmp_dir.'translation.zip')) { |
| 2302 | 2302 | if ($globalDebug) echo "Unzip..."; |
| 2303 | 2303 | update_db::unzip($tmp_dir.'translation.zip'); |
@@ -2313,10 +2313,10 @@ discard block |
||
| 2313 | 2313 | public static function update_translation_fam() { |
| 2314 | 2314 | global $tmp_dir, $globalDebug; |
| 2315 | 2315 | if ($globalDebug) echo "Translation from FlightAirMap website : Download..."; |
| 2316 | - update_db::download('http://data.flightairmap.com/data/translation.tsv.gz',$tmp_dir.'translation.tsv.gz'); |
|
| 2317 | - update_db::download('http://data.flightairmap.com/data/translation.tsv.gz.md5',$tmp_dir.'translation.tsv.gz.md5'); |
|
| 2316 | + update_db::download('http://data.flightairmap.com/data/translation.tsv.gz', $tmp_dir.'translation.tsv.gz'); |
|
| 2317 | + update_db::download('http://data.flightairmap.com/data/translation.tsv.gz.md5', $tmp_dir.'translation.tsv.gz.md5'); |
|
| 2318 | 2318 | if (file_exists($tmp_dir.'translation.tsv.gz') && file_exists($tmp_dir.'translation.tsv.gz')) { |
| 2319 | - $translation_md5_file = explode(' ',file_get_contents($tmp_dir.'translation.tsv.gz.md5')); |
|
| 2319 | + $translation_md5_file = explode(' ', file_get_contents($tmp_dir.'translation.tsv.gz.md5')); |
|
| 2320 | 2320 | $translation_md5 = $translation_md5_file[0]; |
| 2321 | 2321 | if (md5_file($tmp_dir.'translation.tsv.gz') == $translation_md5) { |
| 2322 | 2322 | if ($globalDebug) echo "Gunzip..."; |
@@ -2333,10 +2333,10 @@ discard block |
||
| 2333 | 2333 | public static function update_ModeS_fam() { |
| 2334 | 2334 | global $tmp_dir, $globalDebug; |
| 2335 | 2335 | if ($globalDebug) echo "ModeS from FlightAirMap website : Download..."; |
| 2336 | - update_db::download('http://data.flightairmap.com/data/modes.tsv.gz',$tmp_dir.'modes.tsv.gz'); |
|
| 2337 | - update_db::download('http://data.flightairmap.com/data/modes.tsv.gz.md5',$tmp_dir.'modes.tsv.gz.md5'); |
|
| 2336 | + update_db::download('http://data.flightairmap.com/data/modes.tsv.gz', $tmp_dir.'modes.tsv.gz'); |
|
| 2337 | + update_db::download('http://data.flightairmap.com/data/modes.tsv.gz.md5', $tmp_dir.'modes.tsv.gz.md5'); |
|
| 2338 | 2338 | if (file_exists($tmp_dir.'modes.tsv.gz') && file_exists($tmp_dir.'modes.tsv.gz.md5')) { |
| 2339 | - $modes_md5_file = explode(' ',file_get_contents($tmp_dir.'modes.tsv.gz.md5')); |
|
| 2339 | + $modes_md5_file = explode(' ', file_get_contents($tmp_dir.'modes.tsv.gz.md5')); |
|
| 2340 | 2340 | $modes_md5 = $modes_md5_file[0]; |
| 2341 | 2341 | if (md5_file($tmp_dir.'modes.tsv.gz') == $modes_md5) { |
| 2342 | 2342 | if ($globalDebug) echo "Gunzip..."; |
@@ -2354,14 +2354,14 @@ discard block |
||
| 2354 | 2354 | global $tmp_dir, $globalDebug, $globalOwner; |
| 2355 | 2355 | if ($globalDebug) echo "owner from FlightAirMap website : Download..."; |
| 2356 | 2356 | if ($globalOwner === TRUE) { |
| 2357 | - update_db::download('http://data.flightairmap.com/data/owners_all.tsv.gz',$tmp_dir.'owners.tsv.gz'); |
|
| 2358 | - update_db::download('http://data.flightairmap.com/data/owners_all.tsv.gz.md5',$tmp_dir.'owners.tsv.gz.md5'); |
|
| 2357 | + update_db::download('http://data.flightairmap.com/data/owners_all.tsv.gz', $tmp_dir.'owners.tsv.gz'); |
|
| 2358 | + update_db::download('http://data.flightairmap.com/data/owners_all.tsv.gz.md5', $tmp_dir.'owners.tsv.gz.md5'); |
|
| 2359 | 2359 | } else { |
| 2360 | - update_db::download('http://data.flightairmap.com/data/owners.tsv.gz',$tmp_dir.'owners.tsv.gz'); |
|
| 2361 | - update_db::download('http://data.flightairmap.com/data/owners.tsv.gz.md5',$tmp_dir.'owners.tsv.gz.md5'); |
|
| 2360 | + update_db::download('http://data.flightairmap.com/data/owners.tsv.gz', $tmp_dir.'owners.tsv.gz'); |
|
| 2361 | + update_db::download('http://data.flightairmap.com/data/owners.tsv.gz.md5', $tmp_dir.'owners.tsv.gz.md5'); |
|
| 2362 | 2362 | } |
| 2363 | 2363 | if (file_exists($tmp_dir.'owners.tsv.gz') && file_exists($tmp_dir.'owners.tsv.gz.md5')) { |
| 2364 | - $owners_md5_file = explode(' ',file_get_contents($tmp_dir.'owners.tsv.gz.md5')); |
|
| 2364 | + $owners_md5_file = explode(' ', file_get_contents($tmp_dir.'owners.tsv.gz.md5')); |
|
| 2365 | 2365 | $owners_md5 = $owners_md5_file[0]; |
| 2366 | 2366 | if (md5_file($tmp_dir.'owners.tsv.gz') == $owners_md5) { |
| 2367 | 2367 | if ($globalDebug) echo "Gunzip..."; |
@@ -2378,10 +2378,10 @@ discard block |
||
| 2378 | 2378 | public static function update_routes_fam() { |
| 2379 | 2379 | global $tmp_dir, $globalDebug; |
| 2380 | 2380 | if ($globalDebug) echo "Routes from FlightAirMap website : Download..."; |
| 2381 | - update_db::download('http://data.flightairmap.com/data/routes.tsv.gz',$tmp_dir.'routes.tsv.gz'); |
|
| 2382 | - update_db::download('http://data.flightairmap.com/data/routes.tsv.gz.md5',$tmp_dir.'routes.tsv.gz.md5'); |
|
| 2381 | + update_db::download('http://data.flightairmap.com/data/routes.tsv.gz', $tmp_dir.'routes.tsv.gz'); |
|
| 2382 | + update_db::download('http://data.flightairmap.com/data/routes.tsv.gz.md5', $tmp_dir.'routes.tsv.gz.md5'); |
|
| 2383 | 2383 | if (file_exists($tmp_dir.'routes.tsv.gz') && file_exists($tmp_dir.'routes.tsv.gz.md5')) { |
| 2384 | - $routes_md5_file = explode(' ',file_get_contents($tmp_dir.'routes.tsv.gz.md5')); |
|
| 2384 | + $routes_md5_file = explode(' ', file_get_contents($tmp_dir.'routes.tsv.gz.md5')); |
|
| 2385 | 2385 | $routes_md5 = $routes_md5_file[0]; |
| 2386 | 2386 | if (md5_file($tmp_dir.'routes.tsv.gz') == $routes_md5) { |
| 2387 | 2387 | if ($globalDebug) echo "Gunzip..."; |
@@ -2397,13 +2397,13 @@ discard block |
||
| 2397 | 2397 | } |
| 2398 | 2398 | public static function update_marine_identity_fam() { |
| 2399 | 2399 | global $tmp_dir, $globalDebug; |
| 2400 | - update_db::download('http://data.flightairmap.com/data/marine_identity.tsv.gz.md5',$tmp_dir.'marine_identity.tsv.gz.md5'); |
|
| 2400 | + update_db::download('http://data.flightairmap.com/data/marine_identity.tsv.gz.md5', $tmp_dir.'marine_identity.tsv.gz.md5'); |
|
| 2401 | 2401 | if (file_exists($tmp_dir.'marine_identity.tsv.gz.md5')) { |
| 2402 | - $marine_identity_md5_file = explode(' ',file_get_contents($tmp_dir.'marine_identity.tsv.gz.md5')); |
|
| 2402 | + $marine_identity_md5_file = explode(' ', file_get_contents($tmp_dir.'marine_identity.tsv.gz.md5')); |
|
| 2403 | 2403 | $marine_identity_md5 = $marine_identity_md5_file[0]; |
| 2404 | 2404 | if (!update_db::check_marine_identity_version($marine_identity_md5)) { |
| 2405 | 2405 | if ($globalDebug) echo "Marine identity from FlightAirMap website : Download..."; |
| 2406 | - update_db::download('http://data.flightairmap.com/data/marine_identity.tsv.gz',$tmp_dir.'marine_identity.tsv.gz'); |
|
| 2406 | + update_db::download('http://data.flightairmap.com/data/marine_identity.tsv.gz', $tmp_dir.'marine_identity.tsv.gz'); |
|
| 2407 | 2407 | if (file_exists($tmp_dir.'marine_identity.tsv.gz')) { |
| 2408 | 2408 | if (md5_file($tmp_dir.'marine_identity.tsv.gz') == $marine_identity_md5) { |
| 2409 | 2409 | if ($globalDebug) echo "Gunzip..."; |
@@ -2425,13 +2425,13 @@ discard block |
||
| 2425 | 2425 | |
| 2426 | 2426 | public static function update_satellite_fam() { |
| 2427 | 2427 | global $tmp_dir, $globalDebug; |
| 2428 | - update_db::download('http://data.flightairmap.com/data/satellite.tsv.gz.md5',$tmp_dir.'satellite.tsv.gz.md5'); |
|
| 2428 | + update_db::download('http://data.flightairmap.com/data/satellite.tsv.gz.md5', $tmp_dir.'satellite.tsv.gz.md5'); |
|
| 2429 | 2429 | if (file_exists($tmp_dir.'satellite.tsv.gz.md5')) { |
| 2430 | - $satellite_md5_file = explode(' ',file_get_contents($tmp_dir.'satellite.tsv.gz.md5')); |
|
| 2430 | + $satellite_md5_file = explode(' ', file_get_contents($tmp_dir.'satellite.tsv.gz.md5')); |
|
| 2431 | 2431 | $satellite_md5 = $satellite_md5_file[0]; |
| 2432 | 2432 | if (!update_db::check_satellite_version($satellite_md5)) { |
| 2433 | 2433 | if ($globalDebug) echo "Satellite from FlightAirMap website : Download..."; |
| 2434 | - update_db::download('http://data.flightairmap.com/data/satellite.tsv.gz',$tmp_dir.'satellite.tsv.gz'); |
|
| 2434 | + update_db::download('http://data.flightairmap.com/data/satellite.tsv.gz', $tmp_dir.'satellite.tsv.gz'); |
|
| 2435 | 2435 | if (file_exists($tmp_dir.'satellite.tsv.gz')) { |
| 2436 | 2436 | if (md5_file($tmp_dir.'satellite.tsv.gz') == $satellite_md5) { |
| 2437 | 2437 | if ($globalDebug) echo "Gunzip..."; |
@@ -2453,7 +2453,7 @@ discard block |
||
| 2453 | 2453 | public static function update_banned_fam() { |
| 2454 | 2454 | global $tmp_dir, $globalDebug; |
| 2455 | 2455 | if ($globalDebug) echo "Banned airlines in Europe from FlightAirMap website : Download..."; |
| 2456 | - update_db::download('http://data.flightairmap.com/data/ban-eu.csv',$tmp_dir.'ban_eu.csv'); |
|
| 2456 | + update_db::download('http://data.flightairmap.com/data/ban-eu.csv', $tmp_dir.'ban_eu.csv'); |
|
| 2457 | 2457 | if (file_exists($tmp_dir.'ban_eu.csv')) { |
| 2458 | 2458 | //if ($globalDebug) echo "Gunzip..."; |
| 2459 | 2459 | //update_db::gunzip($tmp_dir.'ban_ue.csv'); |
@@ -2472,18 +2472,18 @@ discard block |
||
| 2472 | 2472 | $error = ''; |
| 2473 | 2473 | if ($globalDebug) echo "Airspace from FlightAirMap website : Download..."; |
| 2474 | 2474 | if ($globalDBdriver == 'mysql') { |
| 2475 | - update_db::download('http://data.flightairmap.com/data/airspace_mysql.sql.gz.md5',$tmp_dir.'airspace.sql.gz.md5'); |
|
| 2475 | + update_db::download('http://data.flightairmap.com/data/airspace_mysql.sql.gz.md5', $tmp_dir.'airspace.sql.gz.md5'); |
|
| 2476 | 2476 | } else { |
| 2477 | - update_db::download('http://data.flightairmap.com/data/airspace_pgsql.sql.gz.md5',$tmp_dir.'airspace.sql.gz.md5'); |
|
| 2477 | + update_db::download('http://data.flightairmap.com/data/airspace_pgsql.sql.gz.md5', $tmp_dir.'airspace.sql.gz.md5'); |
|
| 2478 | 2478 | } |
| 2479 | 2479 | if (file_exists($tmp_dir.'airspace.sql.gz.md5')) { |
| 2480 | - $airspace_md5_file = explode(' ',file_get_contents($tmp_dir.'airspace.sql.gz.md5')); |
|
| 2480 | + $airspace_md5_file = explode(' ', file_get_contents($tmp_dir.'airspace.sql.gz.md5')); |
|
| 2481 | 2481 | $airspace_md5 = $airspace_md5_file[0]; |
| 2482 | 2482 | if (!update_db::check_airspace_version($airspace_md5)) { |
| 2483 | 2483 | if ($globalDBdriver == 'mysql') { |
| 2484 | - update_db::download('http://data.flightairmap.com/data/airspace_mysql.sql.gz',$tmp_dir.'airspace.sql.gz'); |
|
| 2484 | + update_db::download('http://data.flightairmap.com/data/airspace_mysql.sql.gz', $tmp_dir.'airspace.sql.gz'); |
|
| 2485 | 2485 | } else { |
| 2486 | - update_db::download('http://data.flightairmap.com/data/airspace_pgsql.sql.gz',$tmp_dir.'airspace.sql.gz'); |
|
| 2486 | + update_db::download('http://data.flightairmap.com/data/airspace_pgsql.sql.gz', $tmp_dir.'airspace.sql.gz'); |
|
| 2487 | 2487 | } |
| 2488 | 2488 | if (file_exists($tmp_dir.'airspace.sql.gz')) { |
| 2489 | 2489 | if (md5_file($tmp_dir.'airspace.sql.gz') == $airspace_md5) { |
@@ -2496,7 +2496,7 @@ discard block |
||
| 2496 | 2496 | try { |
| 2497 | 2497 | $sth = $Connection->db->prepare($query); |
| 2498 | 2498 | $sth->execute(); |
| 2499 | - } catch(PDOException $e) { |
|
| 2499 | + } catch (PDOException $e) { |
|
| 2500 | 2500 | return "error : ".$e->getMessage(); |
| 2501 | 2501 | } |
| 2502 | 2502 | } |
@@ -2516,16 +2516,16 @@ discard block |
||
| 2516 | 2516 | global $tmp_dir, $globalDebug, $globalGeoidSource; |
| 2517 | 2517 | $error = ''; |
| 2518 | 2518 | if ($globalDebug) echo "Geoid from FlightAirMap website : Download..."; |
| 2519 | - update_db::download('http://data.flightairmap.com/data/geoid/'.$globalGeoidSource.'.pgm.gz.md5',$tmp_dir.$globalGeoidSource.'.pgm.gz.md5'); |
|
| 2519 | + update_db::download('http://data.flightairmap.com/data/geoid/'.$globalGeoidSource.'.pgm.gz.md5', $tmp_dir.$globalGeoidSource.'.pgm.gz.md5'); |
|
| 2520 | 2520 | if (file_exists($tmp_dir.$globalGeoidSource.'.pgm.gz.md5')) { |
| 2521 | - $geoid_md5_file = explode(' ',file_get_contents($tmp_dir.$globalGeoidSource.'.pgm.gz.md5')); |
|
| 2521 | + $geoid_md5_file = explode(' ', file_get_contents($tmp_dir.$globalGeoidSource.'.pgm.gz.md5')); |
|
| 2522 | 2522 | $geoid_md5 = $geoid_md5_file[0]; |
| 2523 | 2523 | if (!update_db::check_geoid_version($geoid_md5)) { |
| 2524 | - update_db::download('http://data.flightairmap.com/data/geoid/'.$globalGeoidSource.'.pgm.gz',$tmp_dir.$globalGeoidSource.'.pgm.gz'); |
|
| 2524 | + update_db::download('http://data.flightairmap.com/data/geoid/'.$globalGeoidSource.'.pgm.gz', $tmp_dir.$globalGeoidSource.'.pgm.gz'); |
|
| 2525 | 2525 | if (file_exists($tmp_dir.$globalGeoidSource.'.pgm.gz')) { |
| 2526 | 2526 | if (md5_file($tmp_dir.$globalGeoidSource.'.pgm.gz') == $geoid_md5) { |
| 2527 | 2527 | if ($globalDebug) echo "Gunzip..."; |
| 2528 | - update_db::gunzip($tmp_dir.$globalGeoidSource.'.pgm.gz',dirname(__FILE__).'/../data/'.$globalGeoidSource.'.pgm'); |
|
| 2528 | + update_db::gunzip($tmp_dir.$globalGeoidSource.'.pgm.gz', dirname(__FILE__).'/../data/'.$globalGeoidSource.'.pgm'); |
|
| 2529 | 2529 | if (file_exists(dirname(__FILE__).'/../data/'.$globalGeoidSource.'.pgm')) { |
| 2530 | 2530 | update_db::insert_geoid_version($geoid_md5); |
| 2531 | 2531 | } |
@@ -2542,15 +2542,15 @@ discard block |
||
| 2542 | 2542 | public static function update_tle() { |
| 2543 | 2543 | global $tmp_dir, $globalDebug; |
| 2544 | 2544 | if ($globalDebug) echo "Download TLE : Download..."; |
| 2545 | - $alltle = array('stations.txt','gps-ops.txt','glo-ops.txt','galileo.txt','weather.txt','noaa.txt','goes.txt','resource.txt','dmc.txt','tdrss.txt','geo.txt','intelsat.txt','gorizont.txt', |
|
| 2546 | - 'raduga.txt','molniya.txt','iridium.txt','orbcomm.txt','globalstar.txt','amateur.txt','x-comm.txt','other-comm.txt','sbas.txt','nnss.txt','musson.txt','science.txt','geodetic.txt', |
|
| 2547 | - 'engineering.txt','education.txt','military.txt','radar.txt','cubesat.txt','other.txt','tle-new.txt','visual.txt','sarsat.txt','argos.txt','ses.txt','iridium-NEXT.txt','beidou.txt'); |
|
| 2545 | + $alltle = array('stations.txt', 'gps-ops.txt', 'glo-ops.txt', 'galileo.txt', 'weather.txt', 'noaa.txt', 'goes.txt', 'resource.txt', 'dmc.txt', 'tdrss.txt', 'geo.txt', 'intelsat.txt', 'gorizont.txt', |
|
| 2546 | + 'raduga.txt', 'molniya.txt', 'iridium.txt', 'orbcomm.txt', 'globalstar.txt', 'amateur.txt', 'x-comm.txt', 'other-comm.txt', 'sbas.txt', 'nnss.txt', 'musson.txt', 'science.txt', 'geodetic.txt', |
|
| 2547 | + 'engineering.txt', 'education.txt', 'military.txt', 'radar.txt', 'cubesat.txt', 'other.txt', 'tle-new.txt', 'visual.txt', 'sarsat.txt', 'argos.txt', 'ses.txt', 'iridium-NEXT.txt', 'beidou.txt'); |
|
| 2548 | 2548 | foreach ($alltle as $filename) { |
| 2549 | 2549 | if ($globalDebug) echo "downloading ".$filename.'...'; |
| 2550 | - update_db::download('http://celestrak.com/NORAD/elements/'.$filename,$tmp_dir.$filename); |
|
| 2550 | + update_db::download('http://celestrak.com/NORAD/elements/'.$filename, $tmp_dir.$filename); |
|
| 2551 | 2551 | if (file_exists($tmp_dir.$filename)) { |
| 2552 | 2552 | if ($globalDebug) echo "Add to DB ".$filename."..."; |
| 2553 | - $error = update_db::tle($tmp_dir.$filename,str_replace('.txt','',$filename)); |
|
| 2553 | + $error = update_db::tle($tmp_dir.$filename, str_replace('.txt', '', $filename)); |
|
| 2554 | 2554 | } else $error = "File ".$tmp_dir.$filename." doesn't exist. Download failed."; |
| 2555 | 2555 | if ($error != '') { |
| 2556 | 2556 | echo $error."\n"; |
@@ -2562,7 +2562,7 @@ discard block |
||
| 2562 | 2562 | public static function update_ucsdb() { |
| 2563 | 2563 | global $tmp_dir, $globalDebug; |
| 2564 | 2564 | if ($globalDebug) echo "Download UCS DB : Download..."; |
| 2565 | - update_db::download('https://s3.amazonaws.com/ucs-documents/nuclear-weapons/sat-database/4-11-17-update/UCS_Satellite_Database_officialname_1-1-17.txt',$tmp_dir.'UCS_Satellite_Database_officialname_1-1-17.txt'); |
|
| 2565 | + update_db::download('https://s3.amazonaws.com/ucs-documents/nuclear-weapons/sat-database/4-11-17-update/UCS_Satellite_Database_officialname_1-1-17.txt', $tmp_dir.'UCS_Satellite_Database_officialname_1-1-17.txt'); |
|
| 2566 | 2566 | if (file_exists($tmp_dir.'UCS_Satellite_Database_officialname_1-1-17.txt')) { |
| 2567 | 2567 | if ($globalDebug) echo "Add to DB..."; |
| 2568 | 2568 | $error = update_db::satellite_ucsdb($tmp_dir.'UCS_Satellite_Database_officialname_1-1-17.txt'); |
@@ -2576,7 +2576,7 @@ discard block |
||
| 2576 | 2576 | public static function update_celestrak() { |
| 2577 | 2577 | global $tmp_dir, $globalDebug; |
| 2578 | 2578 | if ($globalDebug) echo "Download Celestrak DB : Download..."; |
| 2579 | - update_db::download('http://celestrak.com/pub/satcat.txt',$tmp_dir.'satcat.txt'); |
|
| 2579 | + update_db::download('http://celestrak.com/pub/satcat.txt', $tmp_dir.'satcat.txt'); |
|
| 2580 | 2580 | if (file_exists($tmp_dir.'satcat.txt')) { |
| 2581 | 2581 | if ($globalDebug) echo "Add to DB..."; |
| 2582 | 2582 | $error = update_db::satellite_celestrak($tmp_dir.'satcat.txt'); |
@@ -2591,32 +2591,32 @@ discard block |
||
| 2591 | 2591 | global $tmp_dir, $globalDebug; |
| 2592 | 2592 | $error = ''; |
| 2593 | 2593 | if ($globalDebug) echo "Models from FlightAirMap website : Download..."; |
| 2594 | - update_db::download('http://data.flightairmap.com/data/models/models.md5sum',$tmp_dir.'models.md5sum'); |
|
| 2594 | + update_db::download('http://data.flightairmap.com/data/models/models.md5sum', $tmp_dir.'models.md5sum'); |
|
| 2595 | 2595 | if (file_exists($tmp_dir.'models.md5sum')) { |
| 2596 | 2596 | if ($globalDebug) echo "Check files...\n"; |
| 2597 | 2597 | $newmodelsdb = array(); |
| 2598 | - if (($handle = fopen($tmp_dir.'models.md5sum','r')) !== FALSE) { |
|
| 2599 | - while (($row = fgetcsv($handle,1000," ")) !== FALSE) { |
|
| 2598 | + if (($handle = fopen($tmp_dir.'models.md5sum', 'r')) !== FALSE) { |
|
| 2599 | + while (($row = fgetcsv($handle, 1000, " ")) !== FALSE) { |
|
| 2600 | 2600 | $model = trim($row[2]); |
| 2601 | 2601 | $newmodelsdb[$model] = trim($row[0]); |
| 2602 | 2602 | } |
| 2603 | 2603 | } |
| 2604 | 2604 | $modelsdb = array(); |
| 2605 | 2605 | if (file_exists(dirname(__FILE__).'/../models/models.md5sum')) { |
| 2606 | - if (($handle = fopen(dirname(__FILE__).'/../models/models.md5sum','r')) !== FALSE) { |
|
| 2607 | - while (($row = fgetcsv($handle,1000," ")) !== FALSE) { |
|
| 2606 | + if (($handle = fopen(dirname(__FILE__).'/../models/models.md5sum', 'r')) !== FALSE) { |
|
| 2607 | + while (($row = fgetcsv($handle, 1000, " ")) !== FALSE) { |
|
| 2608 | 2608 | $model = trim($row[2]); |
| 2609 | 2609 | $modelsdb[$model] = trim($row[0]); |
| 2610 | 2610 | } |
| 2611 | 2611 | } |
| 2612 | 2612 | } |
| 2613 | - $diff = array_diff($newmodelsdb,$modelsdb); |
|
| 2613 | + $diff = array_diff($newmodelsdb, $modelsdb); |
|
| 2614 | 2614 | foreach ($diff as $key => $value) { |
| 2615 | 2615 | if ($globalDebug) echo 'Downloading model '.$key.' ...'."\n"; |
| 2616 | - update_db::download('http://data.flightairmap.com/data/models/'.$key,dirname(__FILE__).'/../models/'.$key); |
|
| 2616 | + update_db::download('http://data.flightairmap.com/data/models/'.$key, dirname(__FILE__).'/../models/'.$key); |
|
| 2617 | 2617 | |
| 2618 | 2618 | } |
| 2619 | - update_db::download('http://data.flightairmap.com/data/models/models.md5sum',dirname(__FILE__).'/../models/models.md5sum'); |
|
| 2619 | + update_db::download('http://data.flightairmap.com/data/models/models.md5sum', dirname(__FILE__).'/../models/models.md5sum'); |
|
| 2620 | 2620 | } else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed."; |
| 2621 | 2621 | if ($error != '') { |
| 2622 | 2622 | return $error; |
@@ -2628,32 +2628,32 @@ discard block |
||
| 2628 | 2628 | global $tmp_dir, $globalDebug; |
| 2629 | 2629 | $error = ''; |
| 2630 | 2630 | if ($globalDebug) echo "Space models from FlightAirMap website : Download..."; |
| 2631 | - update_db::download('http://data.flightairmap.com/data/models/space/space_models.md5sum',$tmp_dir.'space_models.md5sum'); |
|
| 2631 | + update_db::download('http://data.flightairmap.com/data/models/space/space_models.md5sum', $tmp_dir.'space_models.md5sum'); |
|
| 2632 | 2632 | if (file_exists($tmp_dir.'space_models.md5sum')) { |
| 2633 | 2633 | if ($globalDebug) echo "Check files...\n"; |
| 2634 | 2634 | $newmodelsdb = array(); |
| 2635 | - if (($handle = fopen($tmp_dir.'space_models.md5sum','r')) !== FALSE) { |
|
| 2636 | - while (($row = fgetcsv($handle,1000," ")) !== FALSE) { |
|
| 2635 | + if (($handle = fopen($tmp_dir.'space_models.md5sum', 'r')) !== FALSE) { |
|
| 2636 | + while (($row = fgetcsv($handle, 1000, " ")) !== FALSE) { |
|
| 2637 | 2637 | $model = trim($row[2]); |
| 2638 | 2638 | $newmodelsdb[$model] = trim($row[0]); |
| 2639 | 2639 | } |
| 2640 | 2640 | } |
| 2641 | 2641 | $modelsdb = array(); |
| 2642 | 2642 | if (file_exists(dirname(__FILE__).'/../models/space/space_models.md5sum')) { |
| 2643 | - if (($handle = fopen(dirname(__FILE__).'/../models/space/space_models.md5sum','r')) !== FALSE) { |
|
| 2644 | - while (($row = fgetcsv($handle,1000," ")) !== FALSE) { |
|
| 2643 | + if (($handle = fopen(dirname(__FILE__).'/../models/space/space_models.md5sum', 'r')) !== FALSE) { |
|
| 2644 | + while (($row = fgetcsv($handle, 1000, " ")) !== FALSE) { |
|
| 2645 | 2645 | $model = trim($row[2]); |
| 2646 | 2646 | $modelsdb[$model] = trim($row[0]); |
| 2647 | 2647 | } |
| 2648 | 2648 | } |
| 2649 | 2649 | } |
| 2650 | - $diff = array_diff($newmodelsdb,$modelsdb); |
|
| 2650 | + $diff = array_diff($newmodelsdb, $modelsdb); |
|
| 2651 | 2651 | foreach ($diff as $key => $value) { |
| 2652 | 2652 | if ($globalDebug) echo 'Downloading space model '.$key.' ...'."\n"; |
| 2653 | - update_db::download('http://data.flightairmap.com/data/models/space/'.$key,dirname(__FILE__).'/../models/space/'.$key); |
|
| 2653 | + update_db::download('http://data.flightairmap.com/data/models/space/'.$key, dirname(__FILE__).'/../models/space/'.$key); |
|
| 2654 | 2654 | |
| 2655 | 2655 | } |
| 2656 | - update_db::download('http://data.flightairmap.com/data/models/space/space_models.md5sum',dirname(__FILE__).'/../models/space/space_models.md5sum'); |
|
| 2656 | + update_db::download('http://data.flightairmap.com/data/models/space/space_models.md5sum', dirname(__FILE__).'/../models/space/space_models.md5sum'); |
|
| 2657 | 2657 | } else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed."; |
| 2658 | 2658 | if ($error != '') { |
| 2659 | 2659 | return $error; |
@@ -2665,32 +2665,32 @@ discard block |
||
| 2665 | 2665 | global $tmp_dir, $globalDebug; |
| 2666 | 2666 | $error = ''; |
| 2667 | 2667 | if ($globalDebug) echo "Vehicules models from FlightAirMap website : Download..."; |
| 2668 | - update_db::download('http://data.flightairmap.com/data/models/vehicules/vehicules_models.md5sum',$tmp_dir.'vehicules_models.md5sum'); |
|
| 2668 | + update_db::download('http://data.flightairmap.com/data/models/vehicules/vehicules_models.md5sum', $tmp_dir.'vehicules_models.md5sum'); |
|
| 2669 | 2669 | if (file_exists($tmp_dir.'vehicules_models.md5sum')) { |
| 2670 | 2670 | if ($globalDebug) echo "Check files...\n"; |
| 2671 | 2671 | $newmodelsdb = array(); |
| 2672 | - if (($handle = fopen($tmp_dir.'vehicules_models.md5sum','r')) !== FALSE) { |
|
| 2673 | - while (($row = fgetcsv($handle,1000," ")) !== FALSE) { |
|
| 2672 | + if (($handle = fopen($tmp_dir.'vehicules_models.md5sum', 'r')) !== FALSE) { |
|
| 2673 | + while (($row = fgetcsv($handle, 1000, " ")) !== FALSE) { |
|
| 2674 | 2674 | $model = trim($row[2]); |
| 2675 | 2675 | $newmodelsdb[$model] = trim($row[0]); |
| 2676 | 2676 | } |
| 2677 | 2677 | } |
| 2678 | 2678 | $modelsdb = array(); |
| 2679 | 2679 | if (file_exists(dirname(__FILE__).'/../models/vehicules/vehicules_models.md5sum')) { |
| 2680 | - if (($handle = fopen(dirname(__FILE__).'/../models/vehicules/vehicules_models.md5sum','r')) !== FALSE) { |
|
| 2681 | - while (($row = fgetcsv($handle,1000," ")) !== FALSE) { |
|
| 2680 | + if (($handle = fopen(dirname(__FILE__).'/../models/vehicules/vehicules_models.md5sum', 'r')) !== FALSE) { |
|
| 2681 | + while (($row = fgetcsv($handle, 1000, " ")) !== FALSE) { |
|
| 2682 | 2682 | $model = trim($row[2]); |
| 2683 | 2683 | $modelsdb[$model] = trim($row[0]); |
| 2684 | 2684 | } |
| 2685 | 2685 | } |
| 2686 | 2686 | } |
| 2687 | - $diff = array_diff($newmodelsdb,$modelsdb); |
|
| 2687 | + $diff = array_diff($newmodelsdb, $modelsdb); |
|
| 2688 | 2688 | foreach ($diff as $key => $value) { |
| 2689 | 2689 | if ($globalDebug) echo 'Downloading vehicules model '.$key.' ...'."\n"; |
| 2690 | - update_db::download('http://data.flightairmap.com/data/models/vehicules/'.$key,dirname(__FILE__).'/../models/vehicules/'.$key); |
|
| 2690 | + update_db::download('http://data.flightairmap.com/data/models/vehicules/'.$key, dirname(__FILE__).'/../models/vehicules/'.$key); |
|
| 2691 | 2691 | |
| 2692 | 2692 | } |
| 2693 | - update_db::download('http://data.flightairmap.com/data/models/vehicules/vehicules_models.md5sum',dirname(__FILE__).'/../models/vehicules/vehicules_models.md5sum'); |
|
| 2693 | + update_db::download('http://data.flightairmap.com/data/models/vehicules/vehicules_models.md5sum', dirname(__FILE__).'/../models/vehicules/vehicules_models.md5sum'); |
|
| 2694 | 2694 | } else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed."; |
| 2695 | 2695 | if ($error != '') { |
| 2696 | 2696 | return $error; |
@@ -2713,8 +2713,8 @@ discard block |
||
| 2713 | 2713 | */ |
| 2714 | 2714 | if (file_exists($tmp_dir.'aircrafts.html')) { |
| 2715 | 2715 | //var_dump(file_get_html($tmp_dir.'aircrafts.html')); |
| 2716 | - $fh = fopen($tmp_dir.'aircrafts.html',"r"); |
|
| 2717 | - $result = fread($fh,100000000); |
|
| 2716 | + $fh = fopen($tmp_dir.'aircrafts.html', "r"); |
|
| 2717 | + $result = fread($fh, 100000000); |
|
| 2718 | 2718 | //echo $result; |
| 2719 | 2719 | //var_dump(str_get_html($result)); |
| 2720 | 2720 | //print_r(self::table2array($result)); |
@@ -2732,23 +2732,23 @@ discard block |
||
| 2732 | 2732 | $Connection = new Connection(); |
| 2733 | 2733 | $sth = $Connection->db->prepare($query); |
| 2734 | 2734 | $sth->execute(); |
| 2735 | - } catch(PDOException $e) { |
|
| 2735 | + } catch (PDOException $e) { |
|
| 2736 | 2736 | return "error : ".$e->getMessage(); |
| 2737 | 2737 | } |
| 2738 | 2738 | |
| 2739 | 2739 | $error = ''; |
| 2740 | 2740 | if ($globalDebug) echo "Notam : Download..."; |
| 2741 | - update_db::download($globalNOTAMSource,$tmp_dir.'notam.rss'); |
|
| 2741 | + update_db::download($globalNOTAMSource, $tmp_dir.'notam.rss'); |
|
| 2742 | 2742 | if (file_exists($tmp_dir.'notam.rss')) { |
| 2743 | - $notams = json_decode(json_encode(simplexml_load_file($tmp_dir.'notam.rss')),true); |
|
| 2743 | + $notams = json_decode(json_encode(simplexml_load_file($tmp_dir.'notam.rss')), true); |
|
| 2744 | 2744 | foreach ($notams['channel']['item'] as $notam) { |
| 2745 | - $title = explode(':',$notam['title']); |
|
| 2745 | + $title = explode(':', $notam['title']); |
|
| 2746 | 2746 | $data['ref'] = trim($title[0]); |
| 2747 | 2747 | unset($title[0]); |
| 2748 | - $data['title'] = trim(implode(':',$title)); |
|
| 2749 | - $description = strip_tags($notam['description'],'<pre>'); |
|
| 2750 | - preg_match(':^(.*?)<pre>:',$description,$match); |
|
| 2751 | - $q = explode('/',$match[1]); |
|
| 2748 | + $data['title'] = trim(implode(':', $title)); |
|
| 2749 | + $description = strip_tags($notam['description'], '<pre>'); |
|
| 2750 | + preg_match(':^(.*?)<pre>:', $description, $match); |
|
| 2751 | + $q = explode('/', $match[1]); |
|
| 2752 | 2752 | $data['fir'] = $q[0]; |
| 2753 | 2753 | $data['code'] = $q[1]; |
| 2754 | 2754 | $ifrvfr = $q[2]; |
@@ -2764,30 +2764,30 @@ discard block |
||
| 2764 | 2764 | $data['lower_limit'] = $q[5]; |
| 2765 | 2765 | $data['upper_limit'] = $q[6]; |
| 2766 | 2766 | $latlonrad = $q[7]; |
| 2767 | - sscanf($latlonrad,'%4c%c%5c%c%3d',$las,$lac,$lns,$lnc,$radius); |
|
| 2768 | - $latitude = $Common->convertDec($las,'latitude'); |
|
| 2769 | - $longitude = $Common->convertDec($lns,'longitude'); |
|
| 2767 | + sscanf($latlonrad, '%4c%c%5c%c%3d', $las, $lac, $lns, $lnc, $radius); |
|
| 2768 | + $latitude = $Common->convertDec($las, 'latitude'); |
|
| 2769 | + $longitude = $Common->convertDec($lns, 'longitude'); |
|
| 2770 | 2770 | if ($lac == 'S') $latitude = '-'.$latitude; |
| 2771 | 2771 | if ($lnc == 'W') $longitude = '-'.$longitude; |
| 2772 | 2772 | $data['center_latitude'] = $latitude; |
| 2773 | 2773 | $data['center_longitude'] = $longitude; |
| 2774 | 2774 | $data['radius'] = intval($radius); |
| 2775 | 2775 | |
| 2776 | - preg_match(':<pre>(.*?)</pre>:',$description,$match); |
|
| 2776 | + preg_match(':<pre>(.*?)</pre>:', $description, $match); |
|
| 2777 | 2777 | $data['text'] = $match[1]; |
| 2778 | - preg_match(':</pre>(.*?)$:',$description,$match); |
|
| 2778 | + preg_match(':</pre>(.*?)$:', $description, $match); |
|
| 2779 | 2779 | $fromto = $match[1]; |
| 2780 | - preg_match('#FROM:(.*?)TO:#',$fromto,$match); |
|
| 2780 | + preg_match('#FROM:(.*?)TO:#', $fromto, $match); |
|
| 2781 | 2781 | $fromall = trim($match[1]); |
| 2782 | - preg_match('#^(.*?) \((.*?)\)$#',$fromall,$match); |
|
| 2782 | + preg_match('#^(.*?) \((.*?)\)$#', $fromall, $match); |
|
| 2783 | 2783 | $from = trim($match[1]); |
| 2784 | - $data['date_begin'] = date("Y-m-d H:i:s",strtotime($from)); |
|
| 2785 | - preg_match('#TO:(.*?)$#',$fromto,$match); |
|
| 2784 | + $data['date_begin'] = date("Y-m-d H:i:s", strtotime($from)); |
|
| 2785 | + preg_match('#TO:(.*?)$#', $fromto, $match); |
|
| 2786 | 2786 | $toall = trim($match[1]); |
| 2787 | - if (!preg_match(':Permanent:',$toall)) { |
|
| 2788 | - preg_match('#^(.*?) \((.*?)\)#',$toall,$match); |
|
| 2787 | + if (!preg_match(':Permanent:', $toall)) { |
|
| 2788 | + preg_match('#^(.*?) \((.*?)\)#', $toall, $match); |
|
| 2789 | 2789 | $to = trim($match[1]); |
| 2790 | - $data['date_end'] = date("Y-m-d H:i:s",strtotime($to)); |
|
| 2790 | + $data['date_end'] = date("Y-m-d H:i:s", strtotime($to)); |
|
| 2791 | 2791 | $data['permanent'] = 0; |
| 2792 | 2792 | } else { |
| 2793 | 2793 | $data['date_end'] = NULL; |
@@ -2795,7 +2795,7 @@ discard block |
||
| 2795 | 2795 | } |
| 2796 | 2796 | $data['full_notam'] = $notam['title'].'<br>'.$notam['description']; |
| 2797 | 2797 | $NOTAM = new NOTAM(); |
| 2798 | - $NOTAM->addNOTAM($data['ref'],$data['title'],'',$data['fir'],$data['code'],'',$data['scope'],$data['lower_limit'],$data['upper_limit'],$data['center_latitude'],$data['center_longitude'],$data['radius'],$data['date_begin'],$data['date_end'],$data['permanent'],$data['text'],$data['full_notam']); |
|
| 2798 | + $NOTAM->addNOTAM($data['ref'], $data['title'], '', $data['fir'], $data['code'], '', $data['scope'], $data['lower_limit'], $data['upper_limit'], $data['center_latitude'], $data['center_longitude'], $data['radius'], $data['date_begin'], $data['date_end'], $data['permanent'], $data['text'], $data['full_notam']); |
|
| 2799 | 2799 | unset($data); |
| 2800 | 2800 | } |
| 2801 | 2801 | } else $error = "File ".$tmp_dir.'notam.rss'." doesn't exist. Download failed."; |
@@ -2818,16 +2818,16 @@ discard block |
||
| 2818 | 2818 | $Connection = new Connection(); |
| 2819 | 2819 | $sth = $Connection->db->prepare($query); |
| 2820 | 2820 | $sth->execute(); |
| 2821 | - } catch(PDOException $e) { |
|
| 2821 | + } catch (PDOException $e) { |
|
| 2822 | 2822 | return "error : ".$e->getMessage(); |
| 2823 | 2823 | } |
| 2824 | 2824 | } |
| 2825 | 2825 | $Common = new Common(); |
| 2826 | 2826 | $airspace_lst = $Common->getData('https://raw.githubusercontent.com/XCSoar/xcsoar-data-repository/master/data/airspace.json'); |
| 2827 | - $airspace_json = json_decode($airspace_lst,true); |
|
| 2827 | + $airspace_json = json_decode($airspace_lst, true); |
|
| 2828 | 2828 | foreach ($airspace_json['records'] as $airspace) { |
| 2829 | 2829 | if ($globalDebug) echo $airspace['name']."...\n"; |
| 2830 | - update_db::download($airspace['uri'],$tmp_dir.$airspace['name']); |
|
| 2830 | + update_db::download($airspace['uri'], $tmp_dir.$airspace['name']); |
|
| 2831 | 2831 | if (file_exists($tmp_dir.$airspace['name'])) { |
| 2832 | 2832 | file_put_contents($tmp_dir.$airspace['name'], utf8_encode(file_get_contents($tmp_dir.$airspace['name']))); |
| 2833 | 2833 | //system('recode l9..utf8 '.$tmp_dir.$airspace['name']); |
@@ -2849,7 +2849,7 @@ discard block |
||
| 2849 | 2849 | $Connection = new Connection(); |
| 2850 | 2850 | $sth = $Connection->db->prepare($query); |
| 2851 | 2851 | $sth->execute(array(':new' => $new, ':old' => $old)); |
| 2852 | - } catch(PDOException $e) { |
|
| 2852 | + } catch (PDOException $e) { |
|
| 2853 | 2853 | return "error : ".$e->getMessage(); |
| 2854 | 2854 | } |
| 2855 | 2855 | } |
@@ -2866,7 +2866,7 @@ discard block |
||
| 2866 | 2866 | $Connection = new Connection(); |
| 2867 | 2867 | $sth = $Connection->db->prepare($query); |
| 2868 | 2868 | $sth->execute(); |
| 2869 | - } catch(PDOException $e) { |
|
| 2869 | + } catch (PDOException $e) { |
|
| 2870 | 2870 | return "error : ".$e->getMessage(); |
| 2871 | 2871 | } |
| 2872 | 2872 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -2881,7 +2881,7 @@ discard block |
||
| 2881 | 2881 | $Connection = new Connection(); |
| 2882 | 2882 | $sth = $Connection->db->prepare($query); |
| 2883 | 2883 | $sth->execute(); |
| 2884 | - } catch(PDOException $e) { |
|
| 2884 | + } catch (PDOException $e) { |
|
| 2885 | 2885 | return "error : ".$e->getMessage(); |
| 2886 | 2886 | } |
| 2887 | 2887 | } |
@@ -2892,7 +2892,7 @@ discard block |
||
| 2892 | 2892 | $Connection = new Connection(); |
| 2893 | 2893 | $sth = $Connection->db->prepare($query); |
| 2894 | 2894 | $sth->execute(array(':version' => $version)); |
| 2895 | - } catch(PDOException $e) { |
|
| 2895 | + } catch (PDOException $e) { |
|
| 2896 | 2896 | return "error : ".$e->getMessage(); |
| 2897 | 2897 | } |
| 2898 | 2898 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -2906,7 +2906,7 @@ discard block |
||
| 2906 | 2906 | $Connection = new Connection(); |
| 2907 | 2907 | $sth = $Connection->db->prepare($query); |
| 2908 | 2908 | $sth->execute(array(':version' => $version)); |
| 2909 | - } catch(PDOException $e) { |
|
| 2909 | + } catch (PDOException $e) { |
|
| 2910 | 2910 | return "error : ".$e->getMessage(); |
| 2911 | 2911 | } |
| 2912 | 2912 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -2920,7 +2920,7 @@ discard block |
||
| 2920 | 2920 | $Connection = new Connection(); |
| 2921 | 2921 | $sth = $Connection->db->prepare($query); |
| 2922 | 2922 | $sth->execute(array(':version' => $version)); |
| 2923 | - } catch(PDOException $e) { |
|
| 2923 | + } catch (PDOException $e) { |
|
| 2924 | 2924 | return "error : ".$e->getMessage(); |
| 2925 | 2925 | } |
| 2926 | 2926 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -2934,7 +2934,7 @@ discard block |
||
| 2934 | 2934 | $Connection = new Connection(); |
| 2935 | 2935 | $sth = $Connection->db->prepare($query); |
| 2936 | 2936 | $sth->execute(array(':version' => $version)); |
| 2937 | - } catch(PDOException $e) { |
|
| 2937 | + } catch (PDOException $e) { |
|
| 2938 | 2938 | return "error : ".$e->getMessage(); |
| 2939 | 2939 | } |
| 2940 | 2940 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -2950,7 +2950,7 @@ discard block |
||
| 2950 | 2950 | $Connection = new Connection(); |
| 2951 | 2951 | $sth = $Connection->db->prepare($query); |
| 2952 | 2952 | $sth->execute(array(':version' => $version)); |
| 2953 | - } catch(PDOException $e) { |
|
| 2953 | + } catch (PDOException $e) { |
|
| 2954 | 2954 | return "error : ".$e->getMessage(); |
| 2955 | 2955 | } |
| 2956 | 2956 | } |
@@ -2962,7 +2962,7 @@ discard block |
||
| 2962 | 2962 | $Connection = new Connection(); |
| 2963 | 2963 | $sth = $Connection->db->prepare($query); |
| 2964 | 2964 | $sth->execute(array(':version' => $version)); |
| 2965 | - } catch(PDOException $e) { |
|
| 2965 | + } catch (PDOException $e) { |
|
| 2966 | 2966 | return "error : ".$e->getMessage(); |
| 2967 | 2967 | } |
| 2968 | 2968 | } |
@@ -2974,7 +2974,7 @@ discard block |
||
| 2974 | 2974 | $Connection = new Connection(); |
| 2975 | 2975 | $sth = $Connection->db->prepare($query); |
| 2976 | 2976 | $sth->execute(array(':version' => $version)); |
| 2977 | - } catch(PDOException $e) { |
|
| 2977 | + } catch (PDOException $e) { |
|
| 2978 | 2978 | return "error : ".$e->getMessage(); |
| 2979 | 2979 | } |
| 2980 | 2980 | } |
@@ -2986,7 +2986,7 @@ discard block |
||
| 2986 | 2986 | $Connection = new Connection(); |
| 2987 | 2987 | $sth = $Connection->db->prepare($query); |
| 2988 | 2988 | $sth->execute(array(':version' => $version)); |
| 2989 | - } catch(PDOException $e) { |
|
| 2989 | + } catch (PDOException $e) { |
|
| 2990 | 2990 | return "error : ".$e->getMessage(); |
| 2991 | 2991 | } |
| 2992 | 2992 | } |
@@ -3002,7 +3002,7 @@ discard block |
||
| 3002 | 3002 | $Connection = new Connection(); |
| 3003 | 3003 | $sth = $Connection->db->prepare($query); |
| 3004 | 3004 | $sth->execute(); |
| 3005 | - } catch(PDOException $e) { |
|
| 3005 | + } catch (PDOException $e) { |
|
| 3006 | 3006 | return "error : ".$e->getMessage(); |
| 3007 | 3007 | } |
| 3008 | 3008 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -3017,7 +3017,7 @@ discard block |
||
| 3017 | 3017 | $Connection = new Connection(); |
| 3018 | 3018 | $sth = $Connection->db->prepare($query); |
| 3019 | 3019 | $sth->execute(); |
| 3020 | - } catch(PDOException $e) { |
|
| 3020 | + } catch (PDOException $e) { |
|
| 3021 | 3021 | return "error : ".$e->getMessage(); |
| 3022 | 3022 | } |
| 3023 | 3023 | } |
@@ -3033,7 +3033,7 @@ discard block |
||
| 3033 | 3033 | $Connection = new Connection(); |
| 3034 | 3034 | $sth = $Connection->db->prepare($query); |
| 3035 | 3035 | $sth->execute(); |
| 3036 | - } catch(PDOException $e) { |
|
| 3036 | + } catch (PDOException $e) { |
|
| 3037 | 3037 | return "error : ".$e->getMessage(); |
| 3038 | 3038 | } |
| 3039 | 3039 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -3048,7 +3048,7 @@ discard block |
||
| 3048 | 3048 | $Connection = new Connection(); |
| 3049 | 3049 | $sth = $Connection->db->prepare($query); |
| 3050 | 3050 | $sth->execute(); |
| 3051 | - } catch(PDOException $e) { |
|
| 3051 | + } catch (PDOException $e) { |
|
| 3052 | 3052 | return "error : ".$e->getMessage(); |
| 3053 | 3053 | } |
| 3054 | 3054 | } |
@@ -3064,7 +3064,7 @@ discard block |
||
| 3064 | 3064 | $Connection = new Connection(); |
| 3065 | 3065 | $sth = $Connection->db->prepare($query); |
| 3066 | 3066 | $sth->execute(); |
| 3067 | - } catch(PDOException $e) { |
|
| 3067 | + } catch (PDOException $e) { |
|
| 3068 | 3068 | return "error : ".$e->getMessage(); |
| 3069 | 3069 | } |
| 3070 | 3070 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -3079,7 +3079,7 @@ discard block |
||
| 3079 | 3079 | $Connection = new Connection(); |
| 3080 | 3080 | $sth = $Connection->db->prepare($query); |
| 3081 | 3081 | $sth->execute(); |
| 3082 | - } catch(PDOException $e) { |
|
| 3082 | + } catch (PDOException $e) { |
|
| 3083 | 3083 | return "error : ".$e->getMessage(); |
| 3084 | 3084 | } |
| 3085 | 3085 | } |
@@ -3095,7 +3095,7 @@ discard block |
||
| 3095 | 3095 | $Connection = new Connection(); |
| 3096 | 3096 | $sth = $Connection->db->prepare($query); |
| 3097 | 3097 | $sth->execute(); |
| 3098 | - } catch(PDOException $e) { |
|
| 3098 | + } catch (PDOException $e) { |
|
| 3099 | 3099 | return "error : ".$e->getMessage(); |
| 3100 | 3100 | } |
| 3101 | 3101 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -3110,7 +3110,7 @@ discard block |
||
| 3110 | 3110 | $Connection = new Connection(); |
| 3111 | 3111 | $sth = $Connection->db->prepare($query); |
| 3112 | 3112 | $sth->execute(); |
| 3113 | - } catch(PDOException $e) { |
|
| 3113 | + } catch (PDOException $e) { |
|
| 3114 | 3114 | return "error : ".$e->getMessage(); |
| 3115 | 3115 | } |
| 3116 | 3116 | } |
@@ -3125,7 +3125,7 @@ discard block |
||
| 3125 | 3125 | $Connection = new Connection(); |
| 3126 | 3126 | $sth = $Connection->db->prepare($query); |
| 3127 | 3127 | $sth->execute(); |
| 3128 | - } catch(PDOException $e) { |
|
| 3128 | + } catch (PDOException $e) { |
|
| 3129 | 3129 | return "error : ".$e->getMessage(); |
| 3130 | 3130 | } |
| 3131 | 3131 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -3140,7 +3140,7 @@ discard block |
||
| 3140 | 3140 | $Connection = new Connection(); |
| 3141 | 3141 | $sth = $Connection->db->prepare($query); |
| 3142 | 3142 | $sth->execute(); |
| 3143 | - } catch(PDOException $e) { |
|
| 3143 | + } catch (PDOException $e) { |
|
| 3144 | 3144 | return "error : ".$e->getMessage(); |
| 3145 | 3145 | } |
| 3146 | 3146 | } |
@@ -3156,7 +3156,7 @@ discard block |
||
| 3156 | 3156 | $Connection = new Connection(); |
| 3157 | 3157 | $sth = $Connection->db->prepare($query); |
| 3158 | 3158 | $sth->execute(); |
| 3159 | - } catch(PDOException $e) { |
|
| 3159 | + } catch (PDOException $e) { |
|
| 3160 | 3160 | return "error : ".$e->getMessage(); |
| 3161 | 3161 | } |
| 3162 | 3162 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -3171,7 +3171,7 @@ discard block |
||
| 3171 | 3171 | $Connection = new Connection(); |
| 3172 | 3172 | $sth = $Connection->db->prepare($query); |
| 3173 | 3173 | $sth->execute(); |
| 3174 | - } catch(PDOException $e) { |
|
| 3174 | + } catch (PDOException $e) { |
|
| 3175 | 3175 | return "error : ".$e->getMessage(); |
| 3176 | 3176 | } |
| 3177 | 3177 | } |
@@ -3187,7 +3187,7 @@ discard block |
||
| 3187 | 3187 | $Connection = new Connection(); |
| 3188 | 3188 | $sth = $Connection->db->prepare($query); |
| 3189 | 3189 | $sth->execute(); |
| 3190 | - } catch(PDOException $e) { |
|
| 3190 | + } catch (PDOException $e) { |
|
| 3191 | 3191 | return "error : ".$e->getMessage(); |
| 3192 | 3192 | } |
| 3193 | 3193 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -3202,7 +3202,7 @@ discard block |
||
| 3202 | 3202 | $Connection = new Connection(); |
| 3203 | 3203 | $sth = $Connection->db->prepare($query); |
| 3204 | 3204 | $sth->execute(); |
| 3205 | - } catch(PDOException $e) { |
|
| 3205 | + } catch (PDOException $e) { |
|
| 3206 | 3206 | return "error : ".$e->getMessage(); |
| 3207 | 3207 | } |
| 3208 | 3208 | } |
@@ -3218,7 +3218,7 @@ discard block |
||
| 3218 | 3218 | $Connection = new Connection(); |
| 3219 | 3219 | $sth = $Connection->db->prepare($query); |
| 3220 | 3220 | $sth->execute(); |
| 3221 | - } catch(PDOException $e) { |
|
| 3221 | + } catch (PDOException $e) { |
|
| 3222 | 3222 | return "error : ".$e->getMessage(); |
| 3223 | 3223 | } |
| 3224 | 3224 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -3233,7 +3233,7 @@ discard block |
||
| 3233 | 3233 | $Connection = new Connection(); |
| 3234 | 3234 | $sth = $Connection->db->prepare($query); |
| 3235 | 3235 | $sth->execute(); |
| 3236 | - } catch(PDOException $e) { |
|
| 3236 | + } catch (PDOException $e) { |
|
| 3237 | 3237 | return "error : ".$e->getMessage(); |
| 3238 | 3238 | } |
| 3239 | 3239 | } |
@@ -3249,7 +3249,7 @@ discard block |
||
| 3249 | 3249 | $Connection = new Connection(); |
| 3250 | 3250 | $sth = $Connection->db->prepare($query); |
| 3251 | 3251 | $sth->execute(); |
| 3252 | - } catch(PDOException $e) { |
|
| 3252 | + } catch (PDOException $e) { |
|
| 3253 | 3253 | return "error : ".$e->getMessage(); |
| 3254 | 3254 | } |
| 3255 | 3255 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -3268,7 +3268,7 @@ discard block |
||
| 3268 | 3268 | $Connection = new Connection(); |
| 3269 | 3269 | $sth = $Connection->db->prepare($query); |
| 3270 | 3270 | $sth->execute(); |
| 3271 | - } catch(PDOException $e) { |
|
| 3271 | + } catch (PDOException $e) { |
|
| 3272 | 3272 | return "error : ".$e->getMessage(); |
| 3273 | 3273 | } |
| 3274 | 3274 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -3283,7 +3283,7 @@ discard block |
||
| 3283 | 3283 | $Connection = new Connection(); |
| 3284 | 3284 | $sth = $Connection->db->prepare($query); |
| 3285 | 3285 | $sth->execute(); |
| 3286 | - } catch(PDOException $e) { |
|
| 3286 | + } catch (PDOException $e) { |
|
| 3287 | 3287 | return "error : ".$e->getMessage(); |
| 3288 | 3288 | } |
| 3289 | 3289 | } |
@@ -3295,7 +3295,7 @@ discard block |
||
| 3295 | 3295 | $Connection = new Connection(); |
| 3296 | 3296 | $sth = $Connection->db->prepare($query); |
| 3297 | 3297 | $sth->execute(); |
| 3298 | - } catch(PDOException $e) { |
|
| 3298 | + } catch (PDOException $e) { |
|
| 3299 | 3299 | return "error : ".$e->getMessage(); |
| 3300 | 3300 | } |
| 3301 | 3301 | } |
@@ -3311,7 +3311,7 @@ discard block |
||
| 3311 | 3311 | $Connection = new Connection(); |
| 3312 | 3312 | $sth = $Connection->db->prepare($query); |
| 3313 | 3313 | $sth->execute(); |
| 3314 | - } catch(PDOException $e) { |
|
| 3314 | + } catch (PDOException $e) { |
|
| 3315 | 3315 | return "error : ".$e->getMessage(); |
| 3316 | 3316 | } |
| 3317 | 3317 | } |
@@ -3326,7 +3326,7 @@ discard block |
||
| 3326 | 3326 | $Connection = new Connection(); |
| 3327 | 3327 | $sth = $Connection->db->prepare($query); |
| 3328 | 3328 | $sth->execute(); |
| 3329 | - } catch(PDOException $e) { |
|
| 3329 | + } catch (PDOException $e) { |
|
| 3330 | 3330 | return "error : ".$e->getMessage(); |
| 3331 | 3331 | } |
| 3332 | 3332 | } |
@@ -26,7 +26,9 @@ discard block |
||
| 26 | 26 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); |
| 27 | 27 | curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); |
| 28 | 28 | curl_setopt($ch, CURLOPT_TIMEOUT, 20); |
| 29 | - if ($referer != '') curl_setopt($ch, CURLOPT_REFERER, $referer); |
|
| 29 | + if ($referer != '') { |
|
| 30 | + curl_setopt($ch, CURLOPT_REFERER, $referer); |
|
| 31 | + } |
|
| 30 | 32 | curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.1.2) Gecko/20090729 Firefox/3.5.2 GTB5'); |
| 31 | 33 | curl_setopt($ch, CURLOPT_FILE, $fp); |
| 32 | 34 | curl_exec($ch); |
@@ -37,12 +39,16 @@ discard block |
||
| 37 | 39 | public static function gunzip($in_file,$out_file_name = '') { |
| 38 | 40 | //echo $in_file.' -> '.$out_file_name."\n"; |
| 39 | 41 | $buffer_size = 4096; // read 4kb at a time |
| 40 | - if ($out_file_name == '') $out_file_name = str_replace('.gz', '', $in_file); |
|
| 42 | + if ($out_file_name == '') { |
|
| 43 | + $out_file_name = str_replace('.gz', '', $in_file); |
|
| 44 | + } |
|
| 41 | 45 | if ($in_file != '' && file_exists($in_file)) { |
| 42 | 46 | // PHP version of Ubuntu use gzopen64 instead of gzopen |
| 43 | - if (function_exists('gzopen')) $file = gzopen($in_file,'rb'); |
|
| 44 | - elseif (function_exists('gzopen64')) $file = gzopen64($in_file,'rb'); |
|
| 45 | - else { |
|
| 47 | + if (function_exists('gzopen')) { |
|
| 48 | + $file = gzopen($in_file,'rb'); |
|
| 49 | + } elseif (function_exists('gzopen64')) { |
|
| 50 | + $file = gzopen64($in_file,'rb'); |
|
| 51 | + } else { |
|
| 46 | 52 | echo 'gzopen not available'; |
| 47 | 53 | die; |
| 48 | 54 | } |
@@ -63,8 +69,12 @@ discard block |
||
| 63 | 69 | if ($res === TRUE) { |
| 64 | 70 | $zip->extractTo($path); |
| 65 | 71 | $zip->close(); |
| 66 | - } else return false; |
|
| 67 | - } else return false; |
|
| 72 | + } else { |
|
| 73 | + return false; |
|
| 74 | + } |
|
| 75 | + } else { |
|
| 76 | + return false; |
|
| 77 | + } |
|
| 68 | 78 | } |
| 69 | 79 | |
| 70 | 80 | public static function connect_sqlite($database) { |
@@ -79,7 +89,9 @@ discard block |
||
| 79 | 89 | public static function retrieve_route_sqlite_to_dest($database_file) { |
| 80 | 90 | global $globalDebug, $globalTransaction; |
| 81 | 91 | //$query = 'TRUNCATE TABLE routes'; |
| 82 | - if ($globalDebug) echo " - Delete previous routes from DB -"; |
|
| 92 | + if ($globalDebug) { |
|
| 93 | + echo " - Delete previous routes from DB -"; |
|
| 94 | + } |
|
| 83 | 95 | $query = "DELETE FROM routes WHERE Source = '' OR Source = :source"; |
| 84 | 96 | $Connection = new Connection(); |
| 85 | 97 | try { |
@@ -90,7 +102,9 @@ discard block |
||
| 90 | 102 | return "error : ".$e->getMessage(); |
| 91 | 103 | } |
| 92 | 104 | |
| 93 | - if ($globalDebug) echo " - Add routes to DB -"; |
|
| 105 | + if ($globalDebug) { |
|
| 106 | + echo " - Add routes to DB -"; |
|
| 107 | + } |
|
| 94 | 108 | update_db::connect_sqlite($database_file); |
| 95 | 109 | //$query = 'select Route.RouteID, Route.callsign, operator.Icao AS operator_icao, FromAir.Icao AS FromAirportIcao, ToAir.Icao AS ToAirportIcao from Route inner join operator ON Route.operatorId = operator.operatorId LEFT JOIN Airport AS FromAir ON route.FromAirportId = FromAir.AirportId LEFT JOIN Airport AS ToAir ON ToAir.AirportID = route.ToAirportID'; |
| 96 | 110 | $query = "select Route.RouteID, Route.callsign, operator.Icao AS operator_icao, FromAir.Icao AS FromAirportIcao, ToAir.Icao AS ToAirportIcao, rstp.allstop AS AllStop from Route inner join operator ON Route.operatorId = operator.operatorId LEFT JOIN Airport AS FromAir ON route.FromAirportId = FromAir.AirportId LEFT JOIN Airport AS ToAir ON ToAir.AirportID = route.ToAirportID LEFT JOIN (select RouteId,GROUP_CONCAT(icao,' ') as allstop from routestop left join Airport as air ON routestop.AirportId = air.AirportID group by RouteID) AS rstp ON Route.RouteID = rstp.RouteID"; |
@@ -105,15 +119,21 @@ discard block |
||
| 105 | 119 | $Connection = new Connection(); |
| 106 | 120 | $sth_dest = $Connection->db->prepare($query_dest); |
| 107 | 121 | try { |
| 108 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
| 122 | + if ($globalTransaction) { |
|
| 123 | + $Connection->db->beginTransaction(); |
|
| 124 | + } |
|
| 109 | 125 | while ($values = $sth->fetch(PDO::FETCH_ASSOC)) { |
| 110 | 126 | //$query_dest_values = array(':RouteID' => $values['RouteId'],':CallSign' => $values['Callsign'],':Operator_ICAO' => $values['operator_icao'],':FromAirport_ICAO' => $values['FromAirportIcao'],':ToAirport_ICAO' => $values['ToAirportIcao'],':routestop' => $values['AllStop'],':source' => $database_file); |
| 111 | 127 | $query_dest_values = array(':CallSign' => $values['Callsign'],':Operator_ICAO' => $values['operator_icao'],':FromAirport_ICAO' => $values['FromAirportIcao'],':ToAirport_ICAO' => $values['ToAirportIcao'],':routestop' => $values['AllStop'],':source' => $database_file); |
| 112 | 128 | $sth_dest->execute($query_dest_values); |
| 113 | 129 | } |
| 114 | - if ($globalTransaction) $Connection->db->commit(); |
|
| 130 | + if ($globalTransaction) { |
|
| 131 | + $Connection->db->commit(); |
|
| 132 | + } |
|
| 115 | 133 | } catch(PDOException $e) { |
| 116 | - if ($globalTransaction) $Connection->db->rollBack(); |
|
| 134 | + if ($globalTransaction) { |
|
| 135 | + $Connection->db->rollBack(); |
|
| 136 | + } |
|
| 117 | 137 | return "error : ".$e->getMessage(); |
| 118 | 138 | } |
| 119 | 139 | return ''; |
@@ -121,7 +141,9 @@ discard block |
||
| 121 | 141 | public static function retrieve_route_oneworld($database_file) { |
| 122 | 142 | global $globalDebug, $globalTransaction; |
| 123 | 143 | //$query = 'TRUNCATE TABLE routes'; |
| 124 | - if ($globalDebug) echo " - Delete previous routes from DB -"; |
|
| 144 | + if ($globalDebug) { |
|
| 145 | + echo " - Delete previous routes from DB -"; |
|
| 146 | + } |
|
| 125 | 147 | $query = "DELETE FROM routes WHERE Source = '' OR Source = :source"; |
| 126 | 148 | $Connection = new Connection(); |
| 127 | 149 | try { |
@@ -132,14 +154,18 @@ discard block |
||
| 132 | 154 | return "error : ".$e->getMessage(); |
| 133 | 155 | } |
| 134 | 156 | |
| 135 | - if ($globalDebug) echo " - Add routes to DB -"; |
|
| 157 | + if ($globalDebug) { |
|
| 158 | + echo " - Add routes to DB -"; |
|
| 159 | + } |
|
| 136 | 160 | require_once(dirname(__FILE__).'/../require/class.Spotter.php'); |
| 137 | 161 | $Spotter = new Spotter(); |
| 138 | 162 | if ($fh = fopen($database_file,"r")) { |
| 139 | 163 | $query_dest = 'INSERT INTO routes (CallSign,Operator_ICAO,FromAirport_ICAO,FromAirport_Time,ToAirport_ICAO,ToAirport_Time,RouteStop,Source) VALUES (:CallSign, :Operator_ICAO, :FromAirport_ICAO,:FromAirport_Time, :ToAirport_ICAO, :ToAirport_Time,:routestop, :source)'; |
| 140 | 164 | $Connection = new Connection(); |
| 141 | 165 | $sth_dest = $Connection->db->prepare($query_dest); |
| 142 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
| 166 | + if ($globalTransaction) { |
|
| 167 | + $Connection->db->beginTransaction(); |
|
| 168 | + } |
|
| 143 | 169 | while (!feof($fh)) { |
| 144 | 170 | $line = fgetcsv($fh,9999,','); |
| 145 | 171 | if ($line[0] != '') { |
@@ -148,13 +174,17 @@ discard block |
||
| 148 | 174 | $query_dest_values = array(':CallSign' => str_replace('*','',$line[7]),':Operator_ICAO' => '',':FromAirport_ICAO' => $Spotter->getAirportICAO($line[0]),':FromAirport_Time' => $line[5],':ToAirport_ICAO' => $Spotter->getAirportICAO($line[1]),':ToAirport_Time' => $line[6],':routestop' => '',':source' => 'oneworld'); |
| 149 | 175 | $sth_dest->execute($query_dest_values); |
| 150 | 176 | } catch(PDOException $e) { |
| 151 | - if ($globalTransaction) $Connection->db->rollBack(); |
|
| 177 | + if ($globalTransaction) { |
|
| 178 | + $Connection->db->rollBack(); |
|
| 179 | + } |
|
| 152 | 180 | return "error : ".$e->getMessage(); |
| 153 | 181 | } |
| 154 | 182 | } |
| 155 | 183 | } |
| 156 | 184 | } |
| 157 | - if ($globalTransaction) $Connection->db->commit(); |
|
| 185 | + if ($globalTransaction) { |
|
| 186 | + $Connection->db->commit(); |
|
| 187 | + } |
|
| 158 | 188 | } |
| 159 | 189 | return ''; |
| 160 | 190 | } |
@@ -162,7 +192,9 @@ discard block |
||
| 162 | 192 | public static function retrieve_route_skyteam($database_file) { |
| 163 | 193 | global $globalDebug, $globalTransaction; |
| 164 | 194 | //$query = 'TRUNCATE TABLE routes'; |
| 165 | - if ($globalDebug) echo " - Delete previous routes from DB -"; |
|
| 195 | + if ($globalDebug) { |
|
| 196 | + echo " - Delete previous routes from DB -"; |
|
| 197 | + } |
|
| 166 | 198 | $query = "DELETE FROM routes WHERE Source = '' OR Source = :source"; |
| 167 | 199 | $Connection = new Connection(); |
| 168 | 200 | try { |
@@ -173,7 +205,9 @@ discard block |
||
| 173 | 205 | return "error : ".$e->getMessage(); |
| 174 | 206 | } |
| 175 | 207 | |
| 176 | - if ($globalDebug) echo " - Add routes to DB -"; |
|
| 208 | + if ($globalDebug) { |
|
| 209 | + echo " - Add routes to DB -"; |
|
| 210 | + } |
|
| 177 | 211 | |
| 178 | 212 | require_once(dirname(__FILE__).'/../require/class.Spotter.php'); |
| 179 | 213 | $Spotter = new Spotter(); |
@@ -182,7 +216,9 @@ discard block |
||
| 182 | 216 | $Connection = new Connection(); |
| 183 | 217 | $sth_dest = $Connection->db->prepare($query_dest); |
| 184 | 218 | try { |
| 185 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
| 219 | + if ($globalTransaction) { |
|
| 220 | + $Connection->db->beginTransaction(); |
|
| 221 | + } |
|
| 186 | 222 | while (!feof($fh)) { |
| 187 | 223 | $line = fgetcsv($fh,9999,','); |
| 188 | 224 | if ($line[0] != '') { |
@@ -193,9 +229,13 @@ discard block |
||
| 193 | 229 | } |
| 194 | 230 | } |
| 195 | 231 | } |
| 196 | - if ($globalTransaction) $Connection->db->commit(); |
|
| 232 | + if ($globalTransaction) { |
|
| 233 | + $Connection->db->commit(); |
|
| 234 | + } |
|
| 197 | 235 | } catch(PDOException $e) { |
| 198 | - if ($globalTransaction) $Connection->db->rollBack(); |
|
| 236 | + if ($globalTransaction) { |
|
| 237 | + $Connection->db->rollBack(); |
|
| 238 | + } |
|
| 199 | 239 | return "error : ".$e->getMessage(); |
| 200 | 240 | } |
| 201 | 241 | } |
@@ -238,11 +278,16 @@ discard block |
||
| 238 | 278 | $sth_dest = $Connection->db->prepare($query_dest); |
| 239 | 279 | $sth_dest_owner = $Connection->db->prepare($query_dest_owner); |
| 240 | 280 | try { |
| 241 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
| 281 | + if ($globalTransaction) { |
|
| 282 | + $Connection->db->beginTransaction(); |
|
| 283 | + } |
|
| 242 | 284 | while ($values = $sth->fetch(PDO::FETCH_ASSOC)) { |
| 243 | 285 | //$query_dest_values = array(':AircraftID' => $values['AircraftID'],':FirstCreated' => $values['FirstCreated'],':LastModified' => $values['LastModified'],':ModeS' => $values['ModeS'],':ModeSCountry' => $values['ModeSCountry'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':SerialNo' => $values['SerialNo'], ':OperatorFlagCode' => $values['OperatorFlagCode'], ':Manufacturer' => $values['Manufacturer'], ':Type' => $values['Type'], ':FirstRegDate' => $values['FirstRegDate'], ':CurrentRegDate' => $values['CurrentRegDate'], ':Country' => $values['Country'], ':PreviousID' => $values['PreviousID'], ':DeRegDate' => $values['DeRegDate'], ':Status' => $values['Status'], ':PopularName' => $values['PopularName'],':GenericName' => $values['GenericName'],':AircraftClass' => $values['AircraftClass'], ':Engines' => $values['Engines'], ':OwnershipStatus' => $values['OwnershipStatus'],':RegisteredOwners' => $values['RegisteredOwners'],':MTOW' => $values['MTOW'], ':TotalHours' => $values['TotalHours'],':YearBuilt' => $values['YearBuilt'], ':CofACategory' => $values['CofACategory'], ':CofAExpiry' => $values['CofAExpiry'], ':UserNotes' => $values['UserNotes'], ':Interested' => $values['Interested'], ':UserTag' => $values['UserTag'], ':InfoUrl' => $values['InfoURL'], ':PictureUrl1' => $values['PictureURL1'], ':PictureUrl2' => $values['PictureURL2'], ':PictureUrl3' => $values['PictureURL3'], ':UserBool1' => $values['UserBool1'], ':UserBool2' => $values['UserBool2'], ':UserBool3' => $values['UserBool3'], ':UserBool4' => $values['UserBool4'], ':UserBool5' => $values['UserBool5'], ':UserString1' => $values['UserString1'], ':UserString2' => $values['UserString2'], ':UserString3' => $values['UserString3'], ':UserString4' => $values['UserString4'], ':UserString5' => $values['UserString5'], ':UserInt1' => $values['UserInt1'], ':UserInt2' => $values['UserInt2'], ':UserInt3' => $values['UserInt3'], ':UserInt4' => $values['UserInt4'], ':UserInt5' => $values['UserInt5']); |
| 244 | - if ($values['UserString4'] == 'M') $type = 'military'; |
|
| 245 | - else $type = null; |
|
| 286 | + if ($values['UserString4'] == 'M') { |
|
| 287 | + $type = 'military'; |
|
| 288 | + } else { |
|
| 289 | + $type = null; |
|
| 290 | + } |
|
| 246 | 291 | $query_dest_values = array(':LastModified' => $values['LastModified'],':ModeS' => $values['ModeS'],':ModeSCountry' => $values['ModeSCountry'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':source' => $database_file,':type' => $type); |
| 247 | 292 | $sth_dest->execute($query_dest_values); |
| 248 | 293 | if ($values['RegisteredOwners'] != '' && $values['RegisteredOwners'] != NULL && $values['RegisteredOwners'] != 'Private') { |
@@ -250,7 +295,9 @@ discard block |
||
| 250 | 295 | $sth_dest_owner->execute($query_dest_owner_values); |
| 251 | 296 | } |
| 252 | 297 | } |
| 253 | - if ($globalTransaction) $Connection->db->commit(); |
|
| 298 | + if ($globalTransaction) { |
|
| 299 | + $Connection->db->commit(); |
|
| 300 | + } |
|
| 254 | 301 | } catch(PDOException $e) { |
| 255 | 302 | return "error : ".$e->getMessage(); |
| 256 | 303 | } |
@@ -287,7 +334,9 @@ discard block |
||
| 287 | 334 | $Connection = new Connection(); |
| 288 | 335 | $sth_dest = $Connection->db->prepare($query_dest); |
| 289 | 336 | try { |
| 290 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
| 337 | + if ($globalTransaction) { |
|
| 338 | + $Connection->db->beginTransaction(); |
|
| 339 | + } |
|
| 291 | 340 | while (!feof($fh)) { |
| 292 | 341 | $values = array(); |
| 293 | 342 | $line = $Common->hex2str(fgets($fh,9999)); |
@@ -298,7 +347,9 @@ discard block |
||
| 298 | 347 | // Check if we can find ICAO, else set it to GLID |
| 299 | 348 | $aircraft_name_split = explode(' ',$aircraft_name); |
| 300 | 349 | $search_more = ''; |
| 301 | - if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'"; |
|
| 350 | + if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) { |
|
| 351 | + $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'"; |
|
| 352 | + } |
|
| 302 | 353 | $query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more; |
| 303 | 354 | $sth_search = $Connection->db->prepare($query_search); |
| 304 | 355 | try { |
@@ -311,7 +362,9 @@ discard block |
||
| 311 | 362 | } catch(PDOException $e) { |
| 312 | 363 | return "error : ".$e->getMessage(); |
| 313 | 364 | } |
| 314 | - if (!isset($values['ICAOTypeCode'])) $values['ICAOTypeCode'] = 'GLID'; |
|
| 365 | + if (!isset($values['ICAOTypeCode'])) { |
|
| 366 | + $values['ICAOTypeCode'] = 'GLID'; |
|
| 367 | + } |
|
| 315 | 368 | // Add data to db |
| 316 | 369 | if ($values['Registration'] != '' && $values['Registration'] != '0000') { |
| 317 | 370 | //$query_dest_values = array(':AircraftID' => $values['AircraftID'],':FirstCreated' => $values['FirstCreated'],':LastModified' => $values['LastModified'],':ModeS' => $values['ModeS'],':ModeSCountry' => $values['ModeSCountry'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':SerialNo' => $values['SerialNo'], ':OperatorFlagCode' => $values['OperatorFlagCode'], ':Manufacturer' => $values['Manufacturer'], ':Type' => $values['Type'], ':FirstRegDate' => $values['FirstRegDate'], ':CurrentRegDate' => $values['CurrentRegDate'], ':Country' => $values['Country'], ':PreviousID' => $values['PreviousID'], ':DeRegDate' => $values['DeRegDate'], ':Status' => $values['Status'], ':PopularName' => $values['PopularName'],':GenericName' => $values['GenericName'],':AircraftClass' => $values['AircraftClass'], ':Engines' => $values['Engines'], ':OwnershipStatus' => $values['OwnershipStatus'],':RegisteredOwners' => $values['RegisteredOwners'],':MTOW' => $values['MTOW'], ':TotalHours' => $values['TotalHours'],':YearBuilt' => $values['YearBuilt'], ':CofACategory' => $values['CofACategory'], ':CofAExpiry' => $values['CofAExpiry'], ':UserNotes' => $values['UserNotes'], ':Interested' => $values['Interested'], ':UserTag' => $values['UserTag'], ':InfoUrl' => $values['InfoURL'], ':PictureUrl1' => $values['PictureURL1'], ':PictureUrl2' => $values['PictureURL2'], ':PictureUrl3' => $values['PictureURL3'], ':UserBool1' => $values['UserBool1'], ':UserBool2' => $values['UserBool2'], ':UserBool3' => $values['UserBool3'], ':UserBool4' => $values['UserBool4'], ':UserBool5' => $values['UserBool5'], ':UserString1' => $values['UserString1'], ':UserString2' => $values['UserString2'], ':UserString3' => $values['UserString3'], ':UserString4' => $values['UserString4'], ':UserString5' => $values['UserString5'], ':UserInt1' => $values['UserInt1'], ':UserInt2' => $values['UserInt2'], ':UserInt3' => $values['UserInt3'], ':UserInt4' => $values['UserInt4'], ':UserInt5' => $values['UserInt5']); |
@@ -320,7 +373,9 @@ discard block |
||
| 320 | 373 | $sth_dest->execute($query_dest_values); |
| 321 | 374 | } |
| 322 | 375 | } |
| 323 | - if ($globalTransaction) $Connection->db->commit(); |
|
| 376 | + if ($globalTransaction) { |
|
| 377 | + $Connection->db->commit(); |
|
| 378 | + } |
|
| 324 | 379 | } catch(PDOException $e) { |
| 325 | 380 | return "error : ".$e->getMessage(); |
| 326 | 381 | } |
@@ -356,7 +411,9 @@ discard block |
||
| 356 | 411 | $Connection = new Connection(); |
| 357 | 412 | $sth_dest = $Connection->db->prepare($query_dest); |
| 358 | 413 | try { |
| 359 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
| 414 | + if ($globalTransaction) { |
|
| 415 | + $Connection->db->beginTransaction(); |
|
| 416 | + } |
|
| 360 | 417 | $tmp = fgetcsv($fh,9999,',',"'"); |
| 361 | 418 | while (!feof($fh)) { |
| 362 | 419 | $line = fgetcsv($fh,9999,',',"'"); |
@@ -370,13 +427,17 @@ discard block |
||
| 370 | 427 | // Check if we can find ICAO, else set it to GLID |
| 371 | 428 | $aircraft_name_split = explode(' ',$aircraft_name); |
| 372 | 429 | $search_more = ''; |
| 373 | - if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'"; |
|
| 430 | + if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) { |
|
| 431 | + $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'"; |
|
| 432 | + } |
|
| 374 | 433 | $query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more; |
| 375 | 434 | $sth_search = $Connection->db->prepare($query_search); |
| 376 | 435 | try { |
| 377 | 436 | $sth_search->execute(); |
| 378 | 437 | $result = $sth_search->fetch(PDO::FETCH_ASSOC); |
| 379 | - if (isset($result['icao']) && $result['icao'] != '') $values['ICAOTypeCode'] = $result['icao']; |
|
| 438 | + if (isset($result['icao']) && $result['icao'] != '') { |
|
| 439 | + $values['ICAOTypeCode'] = $result['icao']; |
|
| 440 | + } |
|
| 380 | 441 | } catch(PDOException $e) { |
| 381 | 442 | return "error : ".$e->getMessage(); |
| 382 | 443 | } |
@@ -389,7 +450,9 @@ discard block |
||
| 389 | 450 | $sth_dest->execute($query_dest_values); |
| 390 | 451 | } |
| 391 | 452 | } |
| 392 | - if ($globalTransaction) $Connection->db->commit(); |
|
| 453 | + if ($globalTransaction) { |
|
| 454 | + $Connection->db->commit(); |
|
| 455 | + } |
|
| 393 | 456 | } catch(PDOException $e) { |
| 394 | 457 | return "error : ".$e->getMessage(); |
| 395 | 458 | } |
@@ -428,7 +491,9 @@ discard block |
||
| 428 | 491 | $sth_dest = $Connection->db->prepare($query_dest); |
| 429 | 492 | $sth_modes = $Connection->db->prepare($query_modes); |
| 430 | 493 | try { |
| 431 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
| 494 | + if ($globalTransaction) { |
|
| 495 | + $Connection->db->beginTransaction(); |
|
| 496 | + } |
|
| 432 | 497 | $tmp = fgetcsv($fh,9999,',','"'); |
| 433 | 498 | while (!feof($fh)) { |
| 434 | 499 | $line = fgetcsv($fh,9999,',','"'); |
@@ -438,16 +503,22 @@ discard block |
||
| 438 | 503 | $values['registration'] = $line[0]; |
| 439 | 504 | $values['base'] = $line[4]; |
| 440 | 505 | $values['owner'] = $line[5]; |
| 441 | - if ($line[6] == '') $values['date_first_reg'] = null; |
|
| 442 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6])); |
|
| 506 | + if ($line[6] == '') { |
|
| 507 | + $values['date_first_reg'] = null; |
|
| 508 | + } else { |
|
| 509 | + $values['date_first_reg'] = date("Y-m-d",strtotime($line[6])); |
|
| 510 | + } |
|
| 443 | 511 | $values['cancel'] = $line[7]; |
| 444 | 512 | } elseif ($country == 'EI') { |
| 445 | 513 | // TODO : add modeS & reg to aircraft_modes |
| 446 | 514 | $values['registration'] = $line[0]; |
| 447 | 515 | $values['base'] = $line[3]; |
| 448 | 516 | $values['owner'] = $line[2]; |
| 449 | - if ($line[1] == '') $values['date_first_reg'] = null; |
|
| 450 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[1])); |
|
| 517 | + if ($line[1] == '') { |
|
| 518 | + $values['date_first_reg'] = null; |
|
| 519 | + } else { |
|
| 520 | + $values['date_first_reg'] = date("Y-m-d",strtotime($line[1])); |
|
| 521 | + } |
|
| 451 | 522 | $values['cancel'] = ''; |
| 452 | 523 | $values['modes'] = $line[7]; |
| 453 | 524 | $values['icao'] = $line[8]; |
@@ -466,16 +537,22 @@ discard block |
||
| 466 | 537 | $values['registration'] = $line[3]; |
| 467 | 538 | $values['base'] = null; |
| 468 | 539 | $values['owner'] = $line[5]; |
| 469 | - if ($line[18] == '') $values['date_first_reg'] = null; |
|
| 470 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[18])); |
|
| 540 | + if ($line[18] == '') { |
|
| 541 | + $values['date_first_reg'] = null; |
|
| 542 | + } else { |
|
| 543 | + $values['date_first_reg'] = date("Y-m-d",strtotime($line[18])); |
|
| 544 | + } |
|
| 471 | 545 | $values['cancel'] = ''; |
| 472 | 546 | } elseif ($country == 'VH') { |
| 473 | 547 | // TODO : add modeS & reg to aircraft_modes |
| 474 | 548 | $values['registration'] = $line[0]; |
| 475 | 549 | $values['base'] = null; |
| 476 | 550 | $values['owner'] = $line[12]; |
| 477 | - if ($line[28] == '') $values['date_first_reg'] = null; |
|
| 478 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[28])); |
|
| 551 | + if ($line[28] == '') { |
|
| 552 | + $values['date_first_reg'] = null; |
|
| 553 | + } else { |
|
| 554 | + $values['date_first_reg'] = date("Y-m-d",strtotime($line[28])); |
|
| 555 | + } |
|
| 479 | 556 | |
| 480 | 557 | $values['cancel'] = $line[39]; |
| 481 | 558 | } elseif ($country == 'OE' || $country == '9A' || $country == 'VP' || $country == 'LX' || $country == 'P2' || $country == 'HC') { |
@@ -494,29 +571,41 @@ discard block |
||
| 494 | 571 | $values['registration'] = $line[0]; |
| 495 | 572 | $values['base'] = null; |
| 496 | 573 | $values['owner'] = $line[8]; |
| 497 | - if ($line[7] == '') $values['date_first_reg'] = null; |
|
| 498 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7])); |
|
| 574 | + if ($line[7] == '') { |
|
| 575 | + $values['date_first_reg'] = null; |
|
| 576 | + } else { |
|
| 577 | + $values['date_first_reg'] = date("Y-m-d",strtotime($line[7])); |
|
| 578 | + } |
|
| 499 | 579 | $values['cancel'] = ''; |
| 500 | 580 | } elseif ($country == 'PP') { |
| 501 | 581 | $values['registration'] = $line[0]; |
| 502 | 582 | $values['base'] = null; |
| 503 | 583 | $values['owner'] = $line[4]; |
| 504 | - if ($line[6] == '') $values['date_first_reg'] = null; |
|
| 505 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6])); |
|
| 584 | + if ($line[6] == '') { |
|
| 585 | + $values['date_first_reg'] = null; |
|
| 586 | + } else { |
|
| 587 | + $values['date_first_reg'] = date("Y-m-d",strtotime($line[6])); |
|
| 588 | + } |
|
| 506 | 589 | $values['cancel'] = $line[7]; |
| 507 | 590 | } elseif ($country == 'E7') { |
| 508 | 591 | $values['registration'] = $line[0]; |
| 509 | 592 | $values['base'] = null; |
| 510 | 593 | $values['owner'] = $line[4]; |
| 511 | - if ($line[5] == '') $values['date_first_reg'] = null; |
|
| 512 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[5])); |
|
| 594 | + if ($line[5] == '') { |
|
| 595 | + $values['date_first_reg'] = null; |
|
| 596 | + } else { |
|
| 597 | + $values['date_first_reg'] = date("Y-m-d",strtotime($line[5])); |
|
| 598 | + } |
|
| 513 | 599 | $values['cancel'] = ''; |
| 514 | 600 | } elseif ($country == '8Q') { |
| 515 | 601 | $values['registration'] = $line[0]; |
| 516 | 602 | $values['base'] = null; |
| 517 | 603 | $values['owner'] = $line[3]; |
| 518 | - if ($line[7] == '') $values['date_first_reg'] = null; |
|
| 519 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7])); |
|
| 604 | + if ($line[7] == '') { |
|
| 605 | + $values['date_first_reg'] = null; |
|
| 606 | + } else { |
|
| 607 | + $values['date_first_reg'] = date("Y-m-d",strtotime($line[7])); |
|
| 608 | + } |
|
| 520 | 609 | $values['cancel'] = ''; |
| 521 | 610 | } elseif ($country == 'ZK') { |
| 522 | 611 | $values['registration'] = $line[0]; |
@@ -561,7 +650,9 @@ discard block |
||
| 561 | 650 | $sth_modes->execute($query_modes_values); |
| 562 | 651 | } |
| 563 | 652 | } |
| 564 | - if ($globalTransaction) $Connection->db->commit(); |
|
| 653 | + if ($globalTransaction) { |
|
| 654 | + $Connection->db->commit(); |
|
| 655 | + } |
|
| 565 | 656 | } catch(PDOException $e) { |
| 566 | 657 | return "error : ".$e->getMessage(); |
| 567 | 658 | } |
@@ -697,25 +788,45 @@ discard block |
||
| 697 | 788 | VALUES (:name, :city, :country, :iata, :icao, :latitude, :longitude, :altitude, :type, :home_link, :wikipedia_link, :image_thumb, :image)"; |
| 698 | 789 | $Connection = new Connection(); |
| 699 | 790 | $sth_dest = $Connection->db->prepare($query_dest); |
| 700 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
| 791 | + if ($globalTransaction) { |
|
| 792 | + $Connection->db->beginTransaction(); |
|
| 793 | + } |
|
| 701 | 794 | |
| 702 | 795 | $i = 0; |
| 703 | 796 | while($row = sparql_fetch_array($result)) |
| 704 | 797 | { |
| 705 | 798 | if ($i >= 1) { |
| 706 | 799 | //print_r($row); |
| 707 | - if (!isset($row['iata'])) $row['iata'] = ''; |
|
| 708 | - if (!isset($row['icao'])) $row['icao'] = ''; |
|
| 709 | - if (!isset($row['type'])) $row['type'] = ''; |
|
| 710 | - if (!isset($row['altitude'])) $row['altitude'] = ''; |
|
| 800 | + if (!isset($row['iata'])) { |
|
| 801 | + $row['iata'] = ''; |
|
| 802 | + } |
|
| 803 | + if (!isset($row['icao'])) { |
|
| 804 | + $row['icao'] = ''; |
|
| 805 | + } |
|
| 806 | + if (!isset($row['type'])) { |
|
| 807 | + $row['type'] = ''; |
|
| 808 | + } |
|
| 809 | + if (!isset($row['altitude'])) { |
|
| 810 | + $row['altitude'] = ''; |
|
| 811 | + } |
|
| 711 | 812 | if (isset($row['city_bis'])) { |
| 712 | 813 | $row['city'] = $row['city_bis']; |
| 713 | 814 | } |
| 714 | - if (!isset($row['city'])) $row['city'] = ''; |
|
| 715 | - if (!isset($row['country'])) $row['country'] = ''; |
|
| 716 | - if (!isset($row['homepage'])) $row['homepage'] = ''; |
|
| 717 | - if (!isset($row['wikipedia_page'])) $row['wikipedia_page'] = ''; |
|
| 718 | - if (!isset($row['name'])) continue; |
|
| 815 | + if (!isset($row['city'])) { |
|
| 816 | + $row['city'] = ''; |
|
| 817 | + } |
|
| 818 | + if (!isset($row['country'])) { |
|
| 819 | + $row['country'] = ''; |
|
| 820 | + } |
|
| 821 | + if (!isset($row['homepage'])) { |
|
| 822 | + $row['homepage'] = ''; |
|
| 823 | + } |
|
| 824 | + if (!isset($row['wikipedia_page'])) { |
|
| 825 | + $row['wikipedia_page'] = ''; |
|
| 826 | + } |
|
| 827 | + if (!isset($row['name'])) { |
|
| 828 | + continue; |
|
| 829 | + } |
|
| 719 | 830 | if (!isset($row['image'])) { |
| 720 | 831 | $row['image'] = ''; |
| 721 | 832 | $row['image_thumb'] = ''; |
@@ -771,7 +882,9 @@ discard block |
||
| 771 | 882 | |
| 772 | 883 | $i++; |
| 773 | 884 | } |
| 774 | - if ($globalTransaction) $Connection->db->commit(); |
|
| 885 | + if ($globalTransaction) { |
|
| 886 | + $Connection->db->commit(); |
|
| 887 | + } |
|
| 775 | 888 | /* |
| 776 | 889 | echo "Delete duplicate rows...\n"; |
| 777 | 890 | $query = 'ALTER IGNORE TABLE airport ADD UNIQUE INDEX icaoidx (icao)'; |
@@ -814,7 +927,9 @@ discard block |
||
| 814 | 927 | $delimiter = ','; |
| 815 | 928 | $out_file = $tmp_dir.'airports.csv'; |
| 816 | 929 | update_db::download('http://ourairports.com/data/airports.csv',$out_file); |
| 817 | - if (!file_exists($out_file) || !is_readable($out_file)) return FALSE; |
|
| 930 | + if (!file_exists($out_file) || !is_readable($out_file)) { |
|
| 931 | + return FALSE; |
|
| 932 | + } |
|
| 818 | 933 | echo "Add data from ourairports.com...\n"; |
| 819 | 934 | |
| 820 | 935 | $header = NULL; |
@@ -824,8 +939,9 @@ discard block |
||
| 824 | 939 | //$Connection->db->beginTransaction(); |
| 825 | 940 | while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
| 826 | 941 | { |
| 827 | - if(!$header) $header = $row; |
|
| 828 | - else { |
|
| 942 | + if(!$header) { |
|
| 943 | + $header = $row; |
|
| 944 | + } else { |
|
| 829 | 945 | $data = array(); |
| 830 | 946 | $data = array_combine($header, $row); |
| 831 | 947 | try { |
@@ -866,7 +982,9 @@ discard block |
||
| 866 | 982 | echo "Download data from another free database...\n"; |
| 867 | 983 | $out_file = $tmp_dir.'GlobalAirportDatabase.zip'; |
| 868 | 984 | update_db::download('http://www.partow.net/downloads/GlobalAirportDatabase.zip',$out_file); |
| 869 | - if (!file_exists($out_file) || !is_readable($out_file)) return FALSE; |
|
| 985 | + if (!file_exists($out_file) || !is_readable($out_file)) { |
|
| 986 | + return FALSE; |
|
| 987 | + } |
|
| 870 | 988 | update_db::unzip($out_file); |
| 871 | 989 | $header = NULL; |
| 872 | 990 | echo "Add data from another free database...\n"; |
@@ -877,8 +995,9 @@ discard block |
||
| 877 | 995 | //$Connection->db->beginTransaction(); |
| 878 | 996 | while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
| 879 | 997 | { |
| 880 | - if(!$header) $header = $row; |
|
| 881 | - else { |
|
| 998 | + if(!$header) { |
|
| 999 | + $header = $row; |
|
| 1000 | + } else { |
|
| 882 | 1001 | $data = $row; |
| 883 | 1002 | |
| 884 | 1003 | $query = 'UPDATE airport SET city = :city, country = :country WHERE icao = :icao'; |
@@ -1047,7 +1166,9 @@ discard block |
||
| 1047 | 1166 | if (($handle = fopen($tmp_dir.'MASTER.txt', 'r')) !== FALSE) |
| 1048 | 1167 | { |
| 1049 | 1168 | $i = 0; |
| 1050 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
| 1169 | + if ($globalTransaction) { |
|
| 1170 | + $Connection->db->beginTransaction(); |
|
| 1171 | + } |
|
| 1051 | 1172 | while (($data = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
| 1052 | 1173 | { |
| 1053 | 1174 | if ($i > 0) { |
@@ -1060,7 +1181,9 @@ discard block |
||
| 1060 | 1181 | } |
| 1061 | 1182 | $result_search = $sths->fetchAll(PDO::FETCH_ASSOC); |
| 1062 | 1183 | if (!empty($result_search)) { |
| 1063 | - if ($globalDebug) echo '.'; |
|
| 1184 | + if ($globalDebug) { |
|
| 1185 | + echo '.'; |
|
| 1186 | + } |
|
| 1064 | 1187 | //if ($globalDBdriver == 'mysql') { |
| 1065 | 1188 | // $queryi = 'INSERT INTO faamfr (mfr,icao) VALUES (:mfr,:icao) ON DUPLICATE KEY UPDATE icao = :icao'; |
| 1066 | 1189 | //} else { |
@@ -1082,8 +1205,12 @@ discard block |
||
| 1082 | 1205 | } |
| 1083 | 1206 | $result_search_mfr = $sthsm->fetchAll(PDO::FETCH_ASSOC); |
| 1084 | 1207 | if (!empty($result_search_mfr)) { |
| 1085 | - if (trim($data[16]) == '' && trim($data[23]) != '') $data[16] = $data[23]; |
|
| 1086 | - if (trim($data[16]) == '' && trim($data[15]) != '') $data[16] = $data[15]; |
|
| 1208 | + if (trim($data[16]) == '' && trim($data[23]) != '') { |
|
| 1209 | + $data[16] = $data[23]; |
|
| 1210 | + } |
|
| 1211 | + if (trim($data[16]) == '' && trim($data[15]) != '') { |
|
| 1212 | + $data[16] = $data[15]; |
|
| 1213 | + } |
|
| 1087 | 1214 | $queryf = 'INSERT INTO aircraft_modes (FirstCreated,LastModified,ModeS,ModeSCountry,Registration,ICAOTypeCode,Source) VALUES (:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:source)'; |
| 1088 | 1215 | try { |
| 1089 | 1216 | $sthf = $Connection->db->prepare($queryf); |
@@ -1094,7 +1221,9 @@ discard block |
||
| 1094 | 1221 | } |
| 1095 | 1222 | } |
| 1096 | 1223 | if (strtotime($data[29]) > time()) { |
| 1097 | - if ($globalDebug) echo 'i'; |
|
| 1224 | + if ($globalDebug) { |
|
| 1225 | + echo 'i'; |
|
| 1226 | + } |
|
| 1098 | 1227 | $query = 'INSERT INTO aircraft_owner (registration,base,owner,date_first_reg,Source) VALUES (:registration,:base,:owner,:date_first_reg,:source)'; |
| 1099 | 1228 | try { |
| 1100 | 1229 | $sth = $Connection->db->prepare($query); |
@@ -1105,13 +1234,19 @@ discard block |
||
| 1105 | 1234 | } |
| 1106 | 1235 | } |
| 1107 | 1236 | if ($i % 90 == 0) { |
| 1108 | - if ($globalTransaction) $Connection->db->commit(); |
|
| 1109 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
| 1237 | + if ($globalTransaction) { |
|
| 1238 | + $Connection->db->commit(); |
|
| 1239 | + } |
|
| 1240 | + if ($globalTransaction) { |
|
| 1241 | + $Connection->db->beginTransaction(); |
|
| 1242 | + } |
|
| 1110 | 1243 | } |
| 1111 | 1244 | $i++; |
| 1112 | 1245 | } |
| 1113 | 1246 | fclose($handle); |
| 1114 | - if ($globalTransaction) $Connection->db->commit(); |
|
| 1247 | + if ($globalTransaction) { |
|
| 1248 | + $Connection->db->commit(); |
|
| 1249 | + } |
|
| 1115 | 1250 | } |
| 1116 | 1251 | //print_r($mfr); |
| 1117 | 1252 | return ''; |
@@ -1136,11 +1271,15 @@ discard block |
||
| 1136 | 1271 | $i = 0; |
| 1137 | 1272 | //$Connection->db->setAttribute(PDO::ATTR_AUTOCOMMIT, FALSE); |
| 1138 | 1273 | //$Connection->db->beginTransaction(); |
| 1139 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
| 1274 | + if ($globalTransaction) { |
|
| 1275 | + $Connection->db->beginTransaction(); |
|
| 1276 | + } |
|
| 1140 | 1277 | while (($data = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
| 1141 | 1278 | { |
| 1142 | 1279 | if ($i > 0) { |
| 1143 | - if ($data[1] == 'NULL') $data[1] = $data[0]; |
|
| 1280 | + if ($data[1] == 'NULL') { |
|
| 1281 | + $data[1] = $data[0]; |
|
| 1282 | + } |
|
| 1144 | 1283 | $query = 'INSERT INTO aircraft_modes (FirstCreated,LastModified,ModeS,ModeSCountry,Registration,ICAOTypeCode,type_flight,Source) VALUES (:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:type_flight,:source)'; |
| 1145 | 1284 | try { |
| 1146 | 1285 | $sth = $Connection->db->prepare($query); |
@@ -1152,7 +1291,9 @@ discard block |
||
| 1152 | 1291 | $i++; |
| 1153 | 1292 | } |
| 1154 | 1293 | fclose($handle); |
| 1155 | - if ($globalTransaction) $Connection->db->commit(); |
|
| 1294 | + if ($globalTransaction) { |
|
| 1295 | + $Connection->db->commit(); |
|
| 1296 | + } |
|
| 1156 | 1297 | } |
| 1157 | 1298 | return ''; |
| 1158 | 1299 | } |
@@ -1173,7 +1314,9 @@ discard block |
||
| 1173 | 1314 | if (($handle = fopen($tmp_dir.'owners.tsv', 'r')) !== FALSE) |
| 1174 | 1315 | { |
| 1175 | 1316 | $i = 0; |
| 1176 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
| 1317 | + if ($globalTransaction) { |
|
| 1318 | + $Connection->db->beginTransaction(); |
|
| 1319 | + } |
|
| 1177 | 1320 | while (($data = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
| 1178 | 1321 | { |
| 1179 | 1322 | if ($i > 0) { |
@@ -1189,7 +1332,9 @@ discard block |
||
| 1189 | 1332 | $i++; |
| 1190 | 1333 | } |
| 1191 | 1334 | fclose($handle); |
| 1192 | - if ($globalTransaction) $Connection->db->commit(); |
|
| 1335 | + if ($globalTransaction) { |
|
| 1336 | + $Connection->db->commit(); |
|
| 1337 | + } |
|
| 1193 | 1338 | } |
| 1194 | 1339 | return ''; |
| 1195 | 1340 | } |
@@ -1209,7 +1354,9 @@ discard block |
||
| 1209 | 1354 | if (($handle = fopen($tmp_dir.'routes.tsv', 'r')) !== FALSE) |
| 1210 | 1355 | { |
| 1211 | 1356 | $i = 0; |
| 1212 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
| 1357 | + if ($globalTransaction) { |
|
| 1358 | + $Connection->db->beginTransaction(); |
|
| 1359 | + } |
|
| 1213 | 1360 | while (($data = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
| 1214 | 1361 | { |
| 1215 | 1362 | if ($i > 0) { |
@@ -1218,13 +1365,17 @@ discard block |
||
| 1218 | 1365 | $sth = $Connection->db->prepare($query); |
| 1219 | 1366 | $sth->execute(array(':CallSign' => $data[0],':Operator_ICAO' => $data[1],':FromAirport_ICAO' => $data[2],':FromAirport_Time' => $data[3], ':ToAirport_ICAO' => $data[4],':ToAirport_Time' => $data[5],':RouteStop' => $data[6],':source' => 'website_fam')); |
| 1220 | 1367 | } catch(PDOException $e) { |
| 1221 | - if ($globalDebug) echo "error: ".$e->getMessage()." - data: ".implode(',',$data); |
|
| 1368 | + if ($globalDebug) { |
|
| 1369 | + echo "error: ".$e->getMessage()." - data: ".implode(',',$data); |
|
| 1370 | + } |
|
| 1222 | 1371 | } |
| 1223 | 1372 | } |
| 1224 | 1373 | $i++; |
| 1225 | 1374 | } |
| 1226 | 1375 | fclose($handle); |
| 1227 | - if ($globalTransaction) $Connection->db->commit(); |
|
| 1376 | + if ($globalTransaction) { |
|
| 1377 | + $Connection->db->commit(); |
|
| 1378 | + } |
|
| 1228 | 1379 | } |
| 1229 | 1380 | return ''; |
| 1230 | 1381 | } |
@@ -1249,7 +1400,9 @@ discard block |
||
| 1249 | 1400 | $i = 0; |
| 1250 | 1401 | //$Connection->db->setAttribute(PDO::ATTR_AUTOCOMMIT, FALSE); |
| 1251 | 1402 | //$Connection->db->beginTransaction(); |
| 1252 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
| 1403 | + if ($globalTransaction) { |
|
| 1404 | + $Connection->db->beginTransaction(); |
|
| 1405 | + } |
|
| 1253 | 1406 | while (($data = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
| 1254 | 1407 | { |
| 1255 | 1408 | if ($i > 0) { |
@@ -1265,7 +1418,9 @@ discard block |
||
| 1265 | 1418 | $i++; |
| 1266 | 1419 | } |
| 1267 | 1420 | fclose($handle); |
| 1268 | - if ($globalTransaction) $Connection->db->commit(); |
|
| 1421 | + if ($globalTransaction) { |
|
| 1422 | + $Connection->db->commit(); |
|
| 1423 | + } |
|
| 1269 | 1424 | } |
| 1270 | 1425 | return ''; |
| 1271 | 1426 | } |
@@ -1285,7 +1440,9 @@ discard block |
||
| 1285 | 1440 | if (($handle = fopen($tmp_dir.'satellite.tsv', 'r')) !== FALSE) |
| 1286 | 1441 | { |
| 1287 | 1442 | $i = 0; |
| 1288 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
| 1443 | + if ($globalTransaction) { |
|
| 1444 | + $Connection->db->beginTransaction(); |
|
| 1445 | + } |
|
| 1289 | 1446 | while (($data = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
| 1290 | 1447 | { |
| 1291 | 1448 | if ($i > 0) { |
@@ -1302,7 +1459,9 @@ discard block |
||
| 1302 | 1459 | $i++; |
| 1303 | 1460 | } |
| 1304 | 1461 | fclose($handle); |
| 1305 | - if ($globalTransaction) $Connection->db->commit(); |
|
| 1462 | + if ($globalTransaction) { |
|
| 1463 | + $Connection->db->commit(); |
|
| 1464 | + } |
|
| 1306 | 1465 | } |
| 1307 | 1466 | return ''; |
| 1308 | 1467 | } |
@@ -1321,7 +1480,9 @@ discard block |
||
| 1321 | 1480 | $Connection = new Connection(); |
| 1322 | 1481 | if (($handle = fopen($tmp_dir.'ban_eu.csv', 'r')) !== FALSE) |
| 1323 | 1482 | { |
| 1324 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
| 1483 | + if ($globalTransaction) { |
|
| 1484 | + $Connection->db->beginTransaction(); |
|
| 1485 | + } |
|
| 1325 | 1486 | while (($data = fgetcsv($handle, 1000)) !== FALSE) |
| 1326 | 1487 | { |
| 1327 | 1488 | $query = 'UPDATE airlines SET ban_eu = 1 WHERE icao = :icao AND forsource IS NULL'; |
@@ -1336,7 +1497,9 @@ discard block |
||
| 1336 | 1497 | } |
| 1337 | 1498 | } |
| 1338 | 1499 | fclose($handle); |
| 1339 | - if ($globalTransaction) $Connection->db->commit(); |
|
| 1500 | + if ($globalTransaction) { |
|
| 1501 | + $Connection->db->commit(); |
|
| 1502 | + } |
|
| 1340 | 1503 | } |
| 1341 | 1504 | return ''; |
| 1342 | 1505 | } |
@@ -1412,9 +1575,14 @@ discard block |
||
| 1412 | 1575 | if ($i > 0 && $data[0] != '') { |
| 1413 | 1576 | $sources = trim($data[28].' '.$data[29].' '.$data[30].' '.$data[31].' '.$data[32].' '.$data[33]); |
| 1414 | 1577 | $period = str_replace(',','',$data[14]); |
| 1415 | - if (!empty($period) && strpos($period,'days')) $period = str_replace(' days','',$period)*24*60; |
|
| 1416 | - if ($data[18] != '') $launch_date = date('Y-m-d',strtotime($data[18])); |
|
| 1417 | - else $launch_date = NULL; |
|
| 1578 | + if (!empty($period) && strpos($period,'days')) { |
|
| 1579 | + $period = str_replace(' days','',$period)*24*60; |
|
| 1580 | + } |
|
| 1581 | + if ($data[18] != '') { |
|
| 1582 | + $launch_date = date('Y-m-d',strtotime($data[18])); |
|
| 1583 | + } else { |
|
| 1584 | + $launch_date = NULL; |
|
| 1585 | + } |
|
| 1418 | 1586 | $data = array_map(function($value) { |
| 1419 | 1587 | return trim($value) === '' ? null : $value; |
| 1420 | 1588 | }, $data); |
@@ -1767,7 +1935,9 @@ discard block |
||
| 1767 | 1935 | if (($handle = fopen($filename, 'r')) !== FALSE) |
| 1768 | 1936 | { |
| 1769 | 1937 | $i = 0; |
| 1770 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
| 1938 | + if ($globalTransaction) { |
|
| 1939 | + $Connection->db->beginTransaction(); |
|
| 1940 | + } |
|
| 1771 | 1941 | while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
| 1772 | 1942 | { |
| 1773 | 1943 | $i++; |
@@ -1795,7 +1965,9 @@ discard block |
||
| 1795 | 1965 | } |
| 1796 | 1966 | } |
| 1797 | 1967 | fclose($handle); |
| 1798 | - if ($globalTransaction) $Connection->db->commit(); |
|
| 1968 | + if ($globalTransaction) { |
|
| 1969 | + $Connection->db->commit(); |
|
| 1970 | + } |
|
| 1799 | 1971 | } |
| 1800 | 1972 | return ''; |
| 1801 | 1973 | } |
@@ -1818,7 +1990,9 @@ discard block |
||
| 1818 | 1990 | $Connection = new Connection(); |
| 1819 | 1991 | if (($handle = fopen($filename, 'r')) !== FALSE) |
| 1820 | 1992 | { |
| 1821 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
| 1993 | + if ($globalTransaction) { |
|
| 1994 | + $Connection->db->beginTransaction(); |
|
| 1995 | + } |
|
| 1822 | 1996 | while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
| 1823 | 1997 | { |
| 1824 | 1998 | if(count($row) > 1) { |
@@ -1832,7 +2006,9 @@ discard block |
||
| 1832 | 2006 | } |
| 1833 | 2007 | } |
| 1834 | 2008 | fclose($handle); |
| 1835 | - if ($globalTransaction) $Connection->db->commit(); |
|
| 2009 | + if ($globalTransaction) { |
|
| 2010 | + $Connection->db->commit(); |
|
| 2011 | + } |
|
| 1836 | 2012 | } |
| 1837 | 2013 | return ''; |
| 1838 | 2014 | } |
@@ -1852,8 +2028,9 @@ discard block |
||
| 1852 | 2028 | } |
| 1853 | 2029 | |
| 1854 | 2030 | |
| 1855 | - if ($globalDBdriver == 'mysql') update_db::gunzip('../db/airspace.sql.gz',$tmp_dir.'airspace.sql'); |
|
| 1856 | - else { |
|
| 2031 | + if ($globalDBdriver == 'mysql') { |
|
| 2032 | + update_db::gunzip('../db/airspace.sql.gz',$tmp_dir.'airspace.sql'); |
|
| 2033 | + } else { |
|
| 1857 | 2034 | update_db::gunzip('../db/pgsql/airspace.sql.gz',$tmp_dir.'airspace.sql'); |
| 1858 | 2035 | $query = "CREATE EXTENSION postgis"; |
| 1859 | 2036 | $Connection = new Connection(null,null,$_SESSION['database_root'],$_SESSION['database_rootpass']); |
@@ -1872,7 +2049,9 @@ discard block |
||
| 1872 | 2049 | global $tmp_dir, $globalDebug; |
| 1873 | 2050 | include_once('class.create_db.php'); |
| 1874 | 2051 | require_once(dirname(__FILE__).'/../require/class.NOTAM.php'); |
| 1875 | - if ($globalDebug) echo "NOTAM from FlightAirMap website : Download..."; |
|
| 2052 | + if ($globalDebug) { |
|
| 2053 | + echo "NOTAM from FlightAirMap website : Download..."; |
|
| 2054 | + } |
|
| 1876 | 2055 | update_db::download('http://data.flightairmap.com/data/notam.txt.gz',$tmp_dir.'notam.txt.gz'); |
| 1877 | 2056 | update_db::download('http://data.flightairmap.com/data/notam.txt.gz.md5',$tmp_dir.'notam.txt.gz.md5'); |
| 1878 | 2057 | $error = ''; |
@@ -1880,17 +2059,27 @@ discard block |
||
| 1880 | 2059 | $notam_md5_file = explode(' ',file_get_contents($tmp_dir.'notam.txt.gz.md5')); |
| 1881 | 2060 | $notam_md5 = $notam_md5_file[0]; |
| 1882 | 2061 | if (md5_file($tmp_dir.'notam.txt.gz') == $notam_md5) { |
| 1883 | - if ($globalDebug) echo "Gunzip..."; |
|
| 2062 | + if ($globalDebug) { |
|
| 2063 | + echo "Gunzip..."; |
|
| 2064 | + } |
|
| 1884 | 2065 | update_db::gunzip($tmp_dir.'notam.txt.gz'); |
| 1885 | - if ($globalDebug) echo "Add to DB..."; |
|
| 2066 | + if ($globalDebug) { |
|
| 2067 | + echo "Add to DB..."; |
|
| 2068 | + } |
|
| 1886 | 2069 | //$error = create_db::import_file($tmp_dir.'notam.sql'); |
| 1887 | 2070 | $NOTAM = new NOTAM(); |
| 1888 | 2071 | $NOTAM->updateNOTAMfromTextFile($tmp_dir.'notam.txt'); |
| 1889 | - } else $error = "File ".$tmp_dir.'notam.txt.gz'." md5 failed. Download failed."; |
|
| 1890 | - } else $error = "File ".$tmp_dir.'notam.txt.gz'." doesn't exist. Download failed."; |
|
| 2072 | + } else { |
|
| 2073 | + $error = "File ".$tmp_dir.'notam.txt.gz'." md5 failed. Download failed."; |
|
| 2074 | + } |
|
| 2075 | + } else { |
|
| 2076 | + $error = "File ".$tmp_dir.'notam.txt.gz'." doesn't exist. Download failed."; |
|
| 2077 | + } |
|
| 1891 | 2078 | if ($error != '') { |
| 1892 | 2079 | return $error; |
| 1893 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 2080 | + } elseif ($globalDebug) { |
|
| 2081 | + echo "Done\n"; |
|
| 2082 | + } |
|
| 1894 | 2083 | return ''; |
| 1895 | 2084 | } |
| 1896 | 2085 | |
@@ -1945,68 +2134,114 @@ discard block |
||
| 1945 | 2134 | //update_db::download('http://fr.mirror.ivao.aero/software/ivae_feb2013.zip',$tmp_dir.'ivae_feb2013.zip'); |
| 1946 | 2135 | if (extension_loaded('zip')) { |
| 1947 | 2136 | if (file_exists($tmp_dir.'ivae_feb2013.zip')) { |
| 1948 | - if ($globalDebug) echo "Unzip..."; |
|
| 2137 | + if ($globalDebug) { |
|
| 2138 | + echo "Unzip..."; |
|
| 2139 | + } |
|
| 1949 | 2140 | update_db::unzip($tmp_dir.'ivae_feb2013.zip'); |
| 1950 | - if ($globalDebug) echo "Add to DB..."; |
|
| 2141 | + if ($globalDebug) { |
|
| 2142 | + echo "Add to DB..."; |
|
| 2143 | + } |
|
| 1951 | 2144 | update_db::ivao_airlines($tmp_dir.'data/airlines.dat'); |
| 1952 | - if ($globalDebug) echo "Copy airlines logos to airlines images directory..."; |
|
| 2145 | + if ($globalDebug) { |
|
| 2146 | + echo "Copy airlines logos to airlines images directory..."; |
|
| 2147 | + } |
|
| 1953 | 2148 | if (is_writable(dirname(__FILE__).'/../images/airlines')) { |
| 1954 | - if (!$Common->xcopy($tmp_dir.'logos/',dirname(__FILE__).'/../images/airlines/')) $error = "Failed to copy airlines logo."; |
|
| 1955 | - } else $error = "The directory ".dirname(__FILE__).'/../images/airlines'." must be writable"; |
|
| 1956 | - } else $error = "File ".$tmp_dir.'ivao.zip'." doesn't exist. Download failed."; |
|
| 1957 | - } else $error = "ZIP module not loaded but required for IVAO."; |
|
| 2149 | + if (!$Common->xcopy($tmp_dir.'logos/',dirname(__FILE__).'/../images/airlines/')) { |
|
| 2150 | + $error = "Failed to copy airlines logo."; |
|
| 2151 | + } |
|
| 2152 | + } else { |
|
| 2153 | + $error = "The directory ".dirname(__FILE__).'/../images/airlines'." must be writable"; |
|
| 2154 | + } |
|
| 2155 | + } else { |
|
| 2156 | + $error = "File ".$tmp_dir.'ivao.zip'." doesn't exist. Download failed."; |
|
| 2157 | + } |
|
| 2158 | + } else { |
|
| 2159 | + $error = "ZIP module not loaded but required for IVAO."; |
|
| 2160 | + } |
|
| 1958 | 2161 | if ($error != '') { |
| 1959 | 2162 | return $error; |
| 1960 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 2163 | + } elseif ($globalDebug) { |
|
| 2164 | + echo "Done\n"; |
|
| 2165 | + } |
|
| 1961 | 2166 | return ''; |
| 1962 | 2167 | } |
| 1963 | 2168 | |
| 1964 | 2169 | public static function update_routes() { |
| 1965 | 2170 | global $tmp_dir, $globalDebug; |
| 1966 | 2171 | $error = ''; |
| 1967 | - if ($globalDebug) echo "Routes : Download..."; |
|
| 2172 | + if ($globalDebug) { |
|
| 2173 | + echo "Routes : Download..."; |
|
| 2174 | + } |
|
| 1968 | 2175 | update_db::download('http://www.virtualradarserver.co.uk/Files/StandingData.sqb.gz',$tmp_dir.'StandingData.sqb.gz'); |
| 1969 | 2176 | if (file_exists($tmp_dir.'StandingData.sqb.gz')) { |
| 1970 | - if ($globalDebug) echo "Gunzip..."; |
|
| 2177 | + if ($globalDebug) { |
|
| 2178 | + echo "Gunzip..."; |
|
| 2179 | + } |
|
| 1971 | 2180 | update_db::gunzip($tmp_dir.'StandingData.sqb.gz'); |
| 1972 | - if ($globalDebug) echo "Add to DB..."; |
|
| 2181 | + if ($globalDebug) { |
|
| 2182 | + echo "Add to DB..."; |
|
| 2183 | + } |
|
| 1973 | 2184 | $error = update_db::retrieve_route_sqlite_to_dest($tmp_dir.'StandingData.sqb'); |
| 1974 | - } else $error = "File ".$tmp_dir.'StandingData.sqb.gz'." doesn't exist. Download failed."; |
|
| 2185 | + } else { |
|
| 2186 | + $error = "File ".$tmp_dir.'StandingData.sqb.gz'." doesn't exist. Download failed."; |
|
| 2187 | + } |
|
| 1975 | 2188 | if ($error != '') { |
| 1976 | 2189 | return $error; |
| 1977 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 2190 | + } elseif ($globalDebug) { |
|
| 2191 | + echo "Done\n"; |
|
| 2192 | + } |
|
| 1978 | 2193 | return ''; |
| 1979 | 2194 | } |
| 1980 | 2195 | public static function update_oneworld() { |
| 1981 | 2196 | global $tmp_dir, $globalDebug; |
| 1982 | 2197 | $error = ''; |
| 1983 | - if ($globalDebug) echo "Schedules Oneworld : Download..."; |
|
| 2198 | + if ($globalDebug) { |
|
| 2199 | + echo "Schedules Oneworld : Download..."; |
|
| 2200 | + } |
|
| 1984 | 2201 | update_db::download('http://data.flightairmap.com/data/schedules/oneworld.csv.gz',$tmp_dir.'oneworld.csv.gz'); |
| 1985 | 2202 | if (file_exists($tmp_dir.'oneworld.csv.gz')) { |
| 1986 | - if ($globalDebug) echo "Gunzip..."; |
|
| 2203 | + if ($globalDebug) { |
|
| 2204 | + echo "Gunzip..."; |
|
| 2205 | + } |
|
| 1987 | 2206 | update_db::gunzip($tmp_dir.'oneworld.csv.gz'); |
| 1988 | - if ($globalDebug) echo "Add to DB..."; |
|
| 2207 | + if ($globalDebug) { |
|
| 2208 | + echo "Add to DB..."; |
|
| 2209 | + } |
|
| 1989 | 2210 | $error = update_db::retrieve_route_oneworld($tmp_dir.'oneworld.csv'); |
| 1990 | - } else $error = "File ".$tmp_dir.'oneworld.csv.gz'." doesn't exist. Download failed."; |
|
| 2211 | + } else { |
|
| 2212 | + $error = "File ".$tmp_dir.'oneworld.csv.gz'." doesn't exist. Download failed."; |
|
| 2213 | + } |
|
| 1991 | 2214 | if ($error != '') { |
| 1992 | 2215 | return $error; |
| 1993 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 2216 | + } elseif ($globalDebug) { |
|
| 2217 | + echo "Done\n"; |
|
| 2218 | + } |
|
| 1994 | 2219 | return ''; |
| 1995 | 2220 | } |
| 1996 | 2221 | public static function update_skyteam() { |
| 1997 | 2222 | global $tmp_dir, $globalDebug; |
| 1998 | 2223 | $error = ''; |
| 1999 | - if ($globalDebug) echo "Schedules Skyteam : Download..."; |
|
| 2224 | + if ($globalDebug) { |
|
| 2225 | + echo "Schedules Skyteam : Download..."; |
|
| 2226 | + } |
|
| 2000 | 2227 | update_db::download('http://data.flightairmap.com/data/schedules/skyteam.csv.gz',$tmp_dir.'skyteam.csv.gz'); |
| 2001 | 2228 | if (file_exists($tmp_dir.'skyteam.csv.gz')) { |
| 2002 | - if ($globalDebug) echo "Gunzip..."; |
|
| 2229 | + if ($globalDebug) { |
|
| 2230 | + echo "Gunzip..."; |
|
| 2231 | + } |
|
| 2003 | 2232 | update_db::gunzip($tmp_dir.'skyteam.csv.gz'); |
| 2004 | - if ($globalDebug) echo "Add to DB..."; |
|
| 2233 | + if ($globalDebug) { |
|
| 2234 | + echo "Add to DB..."; |
|
| 2235 | + } |
|
| 2005 | 2236 | $error = update_db::retrieve_route_skyteam($tmp_dir.'skyteam.csv'); |
| 2006 | - } else $error = "File ".$tmp_dir.'skyteam.csv.gz'." doesn't exist. Download failed."; |
|
| 2237 | + } else { |
|
| 2238 | + $error = "File ".$tmp_dir.'skyteam.csv.gz'." doesn't exist. Download failed."; |
|
| 2239 | + } |
|
| 2007 | 2240 | if ($error != '') { |
| 2008 | 2241 | return $error; |
| 2009 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 2242 | + } elseif ($globalDebug) { |
|
| 2243 | + echo "Done\n"; |
|
| 2244 | + } |
|
| 2010 | 2245 | return ''; |
| 2011 | 2246 | } |
| 2012 | 2247 | public static function update_ModeS() { |
@@ -2023,336 +2258,586 @@ discard block |
||
| 2023 | 2258 | exit; |
| 2024 | 2259 | } elseif ($globalDebug) echo "Done\n"; |
| 2025 | 2260 | */ |
| 2026 | - if ($globalDebug) echo "Modes : Download..."; |
|
| 2027 | -// update_db::download('http://planebase.biz/sqb.php?f=basestationall.zip',$tmp_dir.'basestation_latest.zip','http://planebase.biz/bstnsqb'); |
|
| 2261 | + if ($globalDebug) { |
|
| 2262 | + echo "Modes : Download..."; |
|
| 2263 | + } |
|
| 2264 | + // update_db::download('http://planebase.biz/sqb.php?f=basestationall.zip',$tmp_dir.'basestation_latest.zip','http://planebase.biz/bstnsqb'); |
|
| 2028 | 2265 | update_db::download('http://data.flightairmap.com/data/BaseStation.sqb.gz',$tmp_dir.'BaseStation.sqb.gz'); |
| 2029 | 2266 | |
| 2030 | 2267 | // if (file_exists($tmp_dir.'basestation_latest.zip')) { |
| 2031 | 2268 | if (file_exists($tmp_dir.'BaseStation.sqb.gz')) { |
| 2032 | - if ($globalDebug) echo "Unzip..."; |
|
| 2033 | -// update_db::unzip($tmp_dir.'basestation_latest.zip'); |
|
| 2269 | + if ($globalDebug) { |
|
| 2270 | + echo "Unzip..."; |
|
| 2271 | + } |
|
| 2272 | + // update_db::unzip($tmp_dir.'basestation_latest.zip'); |
|
| 2034 | 2273 | update_db::gunzip($tmp_dir.'BaseStation.sqb.gz'); |
| 2035 | - if ($globalDebug) echo "Add to DB..."; |
|
| 2274 | + if ($globalDebug) { |
|
| 2275 | + echo "Add to DB..."; |
|
| 2276 | + } |
|
| 2036 | 2277 | $error = update_db::retrieve_modes_sqlite_to_dest($tmp_dir.'BaseStation.sqb'); |
| 2037 | 2278 | // $error = update_db::retrieve_modes_sqlite_to_dest($tmp_dir.'basestation.sqb'); |
| 2038 | - } else $error = "File ".$tmp_dir.'basestation_latest.zip'." doesn't exist. Download failed."; |
|
| 2279 | + } else { |
|
| 2280 | + $error = "File ".$tmp_dir.'basestation_latest.zip'." doesn't exist. Download failed."; |
|
| 2281 | + } |
|
| 2039 | 2282 | if ($error != '') { |
| 2040 | 2283 | return $error; |
| 2041 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 2284 | + } elseif ($globalDebug) { |
|
| 2285 | + echo "Done\n"; |
|
| 2286 | + } |
|
| 2042 | 2287 | return ''; |
| 2043 | 2288 | } |
| 2044 | 2289 | |
| 2045 | 2290 | public static function update_ModeS_faa() { |
| 2046 | 2291 | global $tmp_dir, $globalDebug; |
| 2047 | - if ($globalDebug) echo "Modes FAA: Download..."; |
|
| 2292 | + if ($globalDebug) { |
|
| 2293 | + echo "Modes FAA: Download..."; |
|
| 2294 | + } |
|
| 2048 | 2295 | update_db::download('http://registry.faa.gov/database/ReleasableAircraft.zip',$tmp_dir.'ReleasableAircraft.zip'); |
| 2049 | 2296 | if (file_exists($tmp_dir.'ReleasableAircraft.zip')) { |
| 2050 | - if ($globalDebug) echo "Unzip..."; |
|
| 2297 | + if ($globalDebug) { |
|
| 2298 | + echo "Unzip..."; |
|
| 2299 | + } |
|
| 2051 | 2300 | update_db::unzip($tmp_dir.'ReleasableAircraft.zip'); |
| 2052 | - if ($globalDebug) echo "Add to DB..."; |
|
| 2301 | + if ($globalDebug) { |
|
| 2302 | + echo "Add to DB..."; |
|
| 2303 | + } |
|
| 2053 | 2304 | $error = update_db::modes_faa(); |
| 2054 | - } else $error = "File ".$tmp_dir.'ReleasableAircraft.zip'." doesn't exist. Download failed."; |
|
| 2305 | + } else { |
|
| 2306 | + $error = "File ".$tmp_dir.'ReleasableAircraft.zip'." doesn't exist. Download failed."; |
|
| 2307 | + } |
|
| 2055 | 2308 | if ($error != '') { |
| 2056 | 2309 | return $error; |
| 2057 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 2310 | + } elseif ($globalDebug) { |
|
| 2311 | + echo "Done\n"; |
|
| 2312 | + } |
|
| 2058 | 2313 | return ''; |
| 2059 | 2314 | } |
| 2060 | 2315 | |
| 2061 | 2316 | public static function update_ModeS_flarm() { |
| 2062 | 2317 | global $tmp_dir, $globalDebug; |
| 2063 | - if ($globalDebug) echo "Modes Flarmnet: Download..."; |
|
| 2318 | + if ($globalDebug) { |
|
| 2319 | + echo "Modes Flarmnet: Download..."; |
|
| 2320 | + } |
|
| 2064 | 2321 | update_db::download('http://flarmnet.org/files/data.fln',$tmp_dir.'data.fln'); |
| 2065 | 2322 | if (file_exists($tmp_dir.'data.fln')) { |
| 2066 | - if ($globalDebug) echo "Add to DB..."; |
|
| 2323 | + if ($globalDebug) { |
|
| 2324 | + echo "Add to DB..."; |
|
| 2325 | + } |
|
| 2067 | 2326 | $error = update_db::retrieve_modes_flarmnet($tmp_dir.'data.fln'); |
| 2068 | - } else $error = "File ".$tmp_dir.'data.fln'." doesn't exist. Download failed."; |
|
| 2327 | + } else { |
|
| 2328 | + $error = "File ".$tmp_dir.'data.fln'." doesn't exist. Download failed."; |
|
| 2329 | + } |
|
| 2069 | 2330 | if ($error != '') { |
| 2070 | 2331 | return $error; |
| 2071 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 2332 | + } elseif ($globalDebug) { |
|
| 2333 | + echo "Done\n"; |
|
| 2334 | + } |
|
| 2072 | 2335 | return ''; |
| 2073 | 2336 | } |
| 2074 | 2337 | |
| 2075 | 2338 | public static function update_ModeS_ogn() { |
| 2076 | 2339 | global $tmp_dir, $globalDebug; |
| 2077 | - if ($globalDebug) echo "Modes OGN: Download..."; |
|
| 2340 | + if ($globalDebug) { |
|
| 2341 | + echo "Modes OGN: Download..."; |
|
| 2342 | + } |
|
| 2078 | 2343 | update_db::download('http://ddb.glidernet.org/download/',$tmp_dir.'ogn.csv'); |
| 2079 | 2344 | if (file_exists($tmp_dir.'ogn.csv')) { |
| 2080 | - if ($globalDebug) echo "Add to DB..."; |
|
| 2345 | + if ($globalDebug) { |
|
| 2346 | + echo "Add to DB..."; |
|
| 2347 | + } |
|
| 2081 | 2348 | $error = update_db::retrieve_modes_ogn($tmp_dir.'ogn.csv'); |
| 2082 | - } else $error = "File ".$tmp_dir.'ogn.csv'." doesn't exist. Download failed."; |
|
| 2349 | + } else { |
|
| 2350 | + $error = "File ".$tmp_dir.'ogn.csv'." doesn't exist. Download failed."; |
|
| 2351 | + } |
|
| 2083 | 2352 | if ($error != '') { |
| 2084 | 2353 | return $error; |
| 2085 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 2354 | + } elseif ($globalDebug) { |
|
| 2355 | + echo "Done\n"; |
|
| 2356 | + } |
|
| 2086 | 2357 | return ''; |
| 2087 | 2358 | } |
| 2088 | 2359 | |
| 2089 | 2360 | public static function update_owner() { |
| 2090 | 2361 | global $tmp_dir, $globalDebug, $globalMasterSource; |
| 2091 | 2362 | |
| 2092 | - if ($globalDebug) echo "Owner France: Download..."; |
|
| 2363 | + if ($globalDebug) { |
|
| 2364 | + echo "Owner France: Download..."; |
|
| 2365 | + } |
|
| 2093 | 2366 | update_db::download('http://antonakis.co.uk/registers/France.txt',$tmp_dir.'owner_f.csv'); |
| 2094 | 2367 | if (file_exists($tmp_dir.'owner_f.csv')) { |
| 2095 | - if ($globalDebug) echo "Add to DB..."; |
|
| 2368 | + if ($globalDebug) { |
|
| 2369 | + echo "Add to DB..."; |
|
| 2370 | + } |
|
| 2096 | 2371 | $error = update_db::retrieve_owner($tmp_dir.'owner_f.csv','F'); |
| 2097 | - } else $error = "File ".$tmp_dir.'owner_f.csv'." doesn't exist. Download failed."; |
|
| 2372 | + } else { |
|
| 2373 | + $error = "File ".$tmp_dir.'owner_f.csv'." doesn't exist. Download failed."; |
|
| 2374 | + } |
|
| 2098 | 2375 | if ($error != '') { |
| 2099 | 2376 | return $error; |
| 2100 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 2377 | + } elseif ($globalDebug) { |
|
| 2378 | + echo "Done\n"; |
|
| 2379 | + } |
|
| 2101 | 2380 | |
| 2102 | - if ($globalDebug) echo "Owner Ireland: Download..."; |
|
| 2381 | + if ($globalDebug) { |
|
| 2382 | + echo "Owner Ireland: Download..."; |
|
| 2383 | + } |
|
| 2103 | 2384 | update_db::download('http://antonakis.co.uk/registers/Ireland.txt',$tmp_dir.'owner_ei.csv'); |
| 2104 | 2385 | if (file_exists($tmp_dir.'owner_ei.csv')) { |
| 2105 | - if ($globalDebug) echo "Add to DB..."; |
|
| 2386 | + if ($globalDebug) { |
|
| 2387 | + echo "Add to DB..."; |
|
| 2388 | + } |
|
| 2106 | 2389 | $error = update_db::retrieve_owner($tmp_dir.'owner_ei.csv','EI'); |
| 2107 | - } else $error = "File ".$tmp_dir.'owner_ei.csv'." doesn't exist. Download failed."; |
|
| 2390 | + } else { |
|
| 2391 | + $error = "File ".$tmp_dir.'owner_ei.csv'." doesn't exist. Download failed."; |
|
| 2392 | + } |
|
| 2108 | 2393 | if ($error != '') { |
| 2109 | 2394 | return $error; |
| 2110 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 2111 | - if ($globalDebug) echo "Owner Switzerland: Download..."; |
|
| 2395 | + } elseif ($globalDebug) { |
|
| 2396 | + echo "Done\n"; |
|
| 2397 | + } |
|
| 2398 | + if ($globalDebug) { |
|
| 2399 | + echo "Owner Switzerland: Download..."; |
|
| 2400 | + } |
|
| 2112 | 2401 | update_db::download('http://antonakis.co.uk/registers/Switzerland.txt',$tmp_dir.'owner_hb.csv'); |
| 2113 | 2402 | if (file_exists($tmp_dir.'owner_hb.csv')) { |
| 2114 | - if ($globalDebug) echo "Add to DB..."; |
|
| 2403 | + if ($globalDebug) { |
|
| 2404 | + echo "Add to DB..."; |
|
| 2405 | + } |
|
| 2115 | 2406 | $error = update_db::retrieve_owner($tmp_dir.'owner_hb.csv','HB'); |
| 2116 | - } else $error = "File ".$tmp_dir.'owner_hb.csv'." doesn't exist. Download failed."; |
|
| 2407 | + } else { |
|
| 2408 | + $error = "File ".$tmp_dir.'owner_hb.csv'." doesn't exist. Download failed."; |
|
| 2409 | + } |
|
| 2117 | 2410 | if ($error != '') { |
| 2118 | 2411 | return $error; |
| 2119 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 2120 | - if ($globalDebug) echo "Owner Czech Republic: Download..."; |
|
| 2412 | + } elseif ($globalDebug) { |
|
| 2413 | + echo "Done\n"; |
|
| 2414 | + } |
|
| 2415 | + if ($globalDebug) { |
|
| 2416 | + echo "Owner Czech Republic: Download..."; |
|
| 2417 | + } |
|
| 2121 | 2418 | update_db::download('http://antonakis.co.uk/registers/CzechRepublic.txt',$tmp_dir.'owner_ok.csv'); |
| 2122 | 2419 | if (file_exists($tmp_dir.'owner_ok.csv')) { |
| 2123 | - if ($globalDebug) echo "Add to DB..."; |
|
| 2420 | + if ($globalDebug) { |
|
| 2421 | + echo "Add to DB..."; |
|
| 2422 | + } |
|
| 2124 | 2423 | $error = update_db::retrieve_owner($tmp_dir.'owner_ok.csv','OK'); |
| 2125 | - } else $error = "File ".$tmp_dir.'owner_ok.csv'." doesn't exist. Download failed."; |
|
| 2424 | + } else { |
|
| 2425 | + $error = "File ".$tmp_dir.'owner_ok.csv'." doesn't exist. Download failed."; |
|
| 2426 | + } |
|
| 2126 | 2427 | if ($error != '') { |
| 2127 | 2428 | return $error; |
| 2128 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 2129 | - if ($globalDebug) echo "Owner Australia: Download..."; |
|
| 2429 | + } elseif ($globalDebug) { |
|
| 2430 | + echo "Done\n"; |
|
| 2431 | + } |
|
| 2432 | + if ($globalDebug) { |
|
| 2433 | + echo "Owner Australia: Download..."; |
|
| 2434 | + } |
|
| 2130 | 2435 | update_db::download('http://antonakis.co.uk/registers/Australia.txt',$tmp_dir.'owner_vh.csv'); |
| 2131 | 2436 | if (file_exists($tmp_dir.'owner_vh.csv')) { |
| 2132 | - if ($globalDebug) echo "Add to DB..."; |
|
| 2437 | + if ($globalDebug) { |
|
| 2438 | + echo "Add to DB..."; |
|
| 2439 | + } |
|
| 2133 | 2440 | $error = update_db::retrieve_owner($tmp_dir.'owner_vh.csv','VH'); |
| 2134 | - } else $error = "File ".$tmp_dir.'owner_vh.csv'." doesn't exist. Download failed."; |
|
| 2441 | + } else { |
|
| 2442 | + $error = "File ".$tmp_dir.'owner_vh.csv'." doesn't exist. Download failed."; |
|
| 2443 | + } |
|
| 2135 | 2444 | if ($error != '') { |
| 2136 | 2445 | return $error; |
| 2137 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 2138 | - if ($globalDebug) echo "Owner Austria: Download..."; |
|
| 2446 | + } elseif ($globalDebug) { |
|
| 2447 | + echo "Done\n"; |
|
| 2448 | + } |
|
| 2449 | + if ($globalDebug) { |
|
| 2450 | + echo "Owner Austria: Download..."; |
|
| 2451 | + } |
|
| 2139 | 2452 | update_db::download('http://antonakis.co.uk/registers/Austria.txt',$tmp_dir.'owner_oe.csv'); |
| 2140 | 2453 | if (file_exists($tmp_dir.'owner_oe.csv')) { |
| 2141 | - if ($globalDebug) echo "Add to DB..."; |
|
| 2454 | + if ($globalDebug) { |
|
| 2455 | + echo "Add to DB..."; |
|
| 2456 | + } |
|
| 2142 | 2457 | $error = update_db::retrieve_owner($tmp_dir.'owner_oe.csv','OE'); |
| 2143 | - } else $error = "File ".$tmp_dir.'owner_oe.csv'." doesn't exist. Download failed."; |
|
| 2458 | + } else { |
|
| 2459 | + $error = "File ".$tmp_dir.'owner_oe.csv'." doesn't exist. Download failed."; |
|
| 2460 | + } |
|
| 2144 | 2461 | if ($error != '') { |
| 2145 | 2462 | return $error; |
| 2146 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 2147 | - if ($globalDebug) echo "Owner Chile: Download..."; |
|
| 2463 | + } elseif ($globalDebug) { |
|
| 2464 | + echo "Done\n"; |
|
| 2465 | + } |
|
| 2466 | + if ($globalDebug) { |
|
| 2467 | + echo "Owner Chile: Download..."; |
|
| 2468 | + } |
|
| 2148 | 2469 | update_db::download('http://antonakis.co.uk/registers/Chile.txt',$tmp_dir.'owner_cc.csv'); |
| 2149 | 2470 | if (file_exists($tmp_dir.'owner_cc.csv')) { |
| 2150 | - if ($globalDebug) echo "Add to DB..."; |
|
| 2471 | + if ($globalDebug) { |
|
| 2472 | + echo "Add to DB..."; |
|
| 2473 | + } |
|
| 2151 | 2474 | $error = update_db::retrieve_owner($tmp_dir.'owner_cc.csv','CC'); |
| 2152 | - } else $error = "File ".$tmp_dir.'owner_cc.csv'." doesn't exist. Download failed."; |
|
| 2475 | + } else { |
|
| 2476 | + $error = "File ".$tmp_dir.'owner_cc.csv'." doesn't exist. Download failed."; |
|
| 2477 | + } |
|
| 2153 | 2478 | if ($error != '') { |
| 2154 | 2479 | return $error; |
| 2155 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 2156 | - if ($globalDebug) echo "Owner Colombia: Download..."; |
|
| 2480 | + } elseif ($globalDebug) { |
|
| 2481 | + echo "Done\n"; |
|
| 2482 | + } |
|
| 2483 | + if ($globalDebug) { |
|
| 2484 | + echo "Owner Colombia: Download..."; |
|
| 2485 | + } |
|
| 2157 | 2486 | update_db::download('http://antonakis.co.uk/registers/Colombia.txt',$tmp_dir.'owner_hj.csv'); |
| 2158 | 2487 | if (file_exists($tmp_dir.'owner_hj.csv')) { |
| 2159 | - if ($globalDebug) echo "Add to DB..."; |
|
| 2488 | + if ($globalDebug) { |
|
| 2489 | + echo "Add to DB..."; |
|
| 2490 | + } |
|
| 2160 | 2491 | $error = update_db::retrieve_owner($tmp_dir.'owner_hj.csv','HJ'); |
| 2161 | - } else $error = "File ".$tmp_dir.'owner_hj.csv'." doesn't exist. Download failed."; |
|
| 2492 | + } else { |
|
| 2493 | + $error = "File ".$tmp_dir.'owner_hj.csv'." doesn't exist. Download failed."; |
|
| 2494 | + } |
|
| 2162 | 2495 | if ($error != '') { |
| 2163 | 2496 | return $error; |
| 2164 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 2165 | - if ($globalDebug) echo "Owner Bosnia Herzegobina: Download..."; |
|
| 2497 | + } elseif ($globalDebug) { |
|
| 2498 | + echo "Done\n"; |
|
| 2499 | + } |
|
| 2500 | + if ($globalDebug) { |
|
| 2501 | + echo "Owner Bosnia Herzegobina: Download..."; |
|
| 2502 | + } |
|
| 2166 | 2503 | update_db::download('http://antonakis.co.uk/registers/BosniaHerzegovina.txt',$tmp_dir.'owner_e7.csv'); |
| 2167 | 2504 | if (file_exists($tmp_dir.'owner_e7.csv')) { |
| 2168 | - if ($globalDebug) echo "Add to DB..."; |
|
| 2505 | + if ($globalDebug) { |
|
| 2506 | + echo "Add to DB..."; |
|
| 2507 | + } |
|
| 2169 | 2508 | $error = update_db::retrieve_owner($tmp_dir.'owner_e7.csv','E7'); |
| 2170 | - } else $error = "File ".$tmp_dir.'owner_e7.csv'." doesn't exist. Download failed."; |
|
| 2509 | + } else { |
|
| 2510 | + $error = "File ".$tmp_dir.'owner_e7.csv'." doesn't exist. Download failed."; |
|
| 2511 | + } |
|
| 2171 | 2512 | if ($error != '') { |
| 2172 | 2513 | return $error; |
| 2173 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 2174 | - if ($globalDebug) echo "Owner Brazil: Download..."; |
|
| 2514 | + } elseif ($globalDebug) { |
|
| 2515 | + echo "Done\n"; |
|
| 2516 | + } |
|
| 2517 | + if ($globalDebug) { |
|
| 2518 | + echo "Owner Brazil: Download..."; |
|
| 2519 | + } |
|
| 2175 | 2520 | update_db::download('http://antonakis.co.uk/registers/Brazil.txt',$tmp_dir.'owner_pp.csv'); |
| 2176 | 2521 | if (file_exists($tmp_dir.'owner_pp.csv')) { |
| 2177 | - if ($globalDebug) echo "Add to DB..."; |
|
| 2522 | + if ($globalDebug) { |
|
| 2523 | + echo "Add to DB..."; |
|
| 2524 | + } |
|
| 2178 | 2525 | $error = update_db::retrieve_owner($tmp_dir.'owner_pp.csv','PP'); |
| 2179 | - } else $error = "File ".$tmp_dir.'owner_pp.csv'." doesn't exist. Download failed."; |
|
| 2526 | + } else { |
|
| 2527 | + $error = "File ".$tmp_dir.'owner_pp.csv'." doesn't exist. Download failed."; |
|
| 2528 | + } |
|
| 2180 | 2529 | if ($error != '') { |
| 2181 | 2530 | return $error; |
| 2182 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 2183 | - if ($globalDebug) echo "Owner Cayman Islands: Download..."; |
|
| 2531 | + } elseif ($globalDebug) { |
|
| 2532 | + echo "Done\n"; |
|
| 2533 | + } |
|
| 2534 | + if ($globalDebug) { |
|
| 2535 | + echo "Owner Cayman Islands: Download..."; |
|
| 2536 | + } |
|
| 2184 | 2537 | update_db::download('http://antonakis.co.uk/registers/CaymanIslands.txt',$tmp_dir.'owner_vp.csv'); |
| 2185 | 2538 | if (file_exists($tmp_dir.'owner_vp.csv')) { |
| 2186 | - if ($globalDebug) echo "Add to DB..."; |
|
| 2539 | + if ($globalDebug) { |
|
| 2540 | + echo "Add to DB..."; |
|
| 2541 | + } |
|
| 2187 | 2542 | $error = update_db::retrieve_owner($tmp_dir.'owner_vp.csv','VP'); |
| 2188 | - } else $error = "File ".$tmp_dir.'owner_vp.csv'." doesn't exist. Download failed."; |
|
| 2543 | + } else { |
|
| 2544 | + $error = "File ".$tmp_dir.'owner_vp.csv'." doesn't exist. Download failed."; |
|
| 2545 | + } |
|
| 2189 | 2546 | if ($error != '') { |
| 2190 | 2547 | return $error; |
| 2191 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 2192 | - if ($globalDebug) echo "Owner Croatia: Download..."; |
|
| 2548 | + } elseif ($globalDebug) { |
|
| 2549 | + echo "Done\n"; |
|
| 2550 | + } |
|
| 2551 | + if ($globalDebug) { |
|
| 2552 | + echo "Owner Croatia: Download..."; |
|
| 2553 | + } |
|
| 2193 | 2554 | update_db::download('http://antonakis.co.uk/registers/Croatia.txt',$tmp_dir.'owner_9a.csv'); |
| 2194 | 2555 | if (file_exists($tmp_dir.'owner_9a.csv')) { |
| 2195 | - if ($globalDebug) echo "Add to DB..."; |
|
| 2556 | + if ($globalDebug) { |
|
| 2557 | + echo "Add to DB..."; |
|
| 2558 | + } |
|
| 2196 | 2559 | $error = update_db::retrieve_owner($tmp_dir.'owner_9a.csv','9A'); |
| 2197 | - } else $error = "File ".$tmp_dir.'owner_9a.csv'." doesn't exist. Download failed."; |
|
| 2560 | + } else { |
|
| 2561 | + $error = "File ".$tmp_dir.'owner_9a.csv'." doesn't exist. Download failed."; |
|
| 2562 | + } |
|
| 2198 | 2563 | if ($error != '') { |
| 2199 | 2564 | return $error; |
| 2200 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 2201 | - if ($globalDebug) echo "Owner Luxembourg: Download..."; |
|
| 2565 | + } elseif ($globalDebug) { |
|
| 2566 | + echo "Done\n"; |
|
| 2567 | + } |
|
| 2568 | + if ($globalDebug) { |
|
| 2569 | + echo "Owner Luxembourg: Download..."; |
|
| 2570 | + } |
|
| 2202 | 2571 | update_db::download('http://antonakis.co.uk/registers/Luxembourg.txt',$tmp_dir.'owner_lx.csv'); |
| 2203 | 2572 | if (file_exists($tmp_dir.'owner_lx.csv')) { |
| 2204 | - if ($globalDebug) echo "Add to DB..."; |
|
| 2573 | + if ($globalDebug) { |
|
| 2574 | + echo "Add to DB..."; |
|
| 2575 | + } |
|
| 2205 | 2576 | $error = update_db::retrieve_owner($tmp_dir.'owner_lx.csv','LX'); |
| 2206 | - } else $error = "File ".$tmp_dir.'owner_lx.csv'." doesn't exist. Download failed."; |
|
| 2577 | + } else { |
|
| 2578 | + $error = "File ".$tmp_dir.'owner_lx.csv'." doesn't exist. Download failed."; |
|
| 2579 | + } |
|
| 2207 | 2580 | if ($error != '') { |
| 2208 | 2581 | return $error; |
| 2209 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 2210 | - if ($globalDebug) echo "Owner Maldives: Download..."; |
|
| 2582 | + } elseif ($globalDebug) { |
|
| 2583 | + echo "Done\n"; |
|
| 2584 | + } |
|
| 2585 | + if ($globalDebug) { |
|
| 2586 | + echo "Owner Maldives: Download..."; |
|
| 2587 | + } |
|
| 2211 | 2588 | update_db::download('http://antonakis.co.uk/registers/Maldives.txt',$tmp_dir.'owner_8q.csv'); |
| 2212 | 2589 | if (file_exists($tmp_dir.'owner_8q.csv')) { |
| 2213 | - if ($globalDebug) echo "Add to DB..."; |
|
| 2590 | + if ($globalDebug) { |
|
| 2591 | + echo "Add to DB..."; |
|
| 2592 | + } |
|
| 2214 | 2593 | $error = update_db::retrieve_owner($tmp_dir.'owner_8q.csv','8Q'); |
| 2215 | - } else $error = "File ".$tmp_dir.'owner_8q.csv'." doesn't exist. Download failed."; |
|
| 2594 | + } else { |
|
| 2595 | + $error = "File ".$tmp_dir.'owner_8q.csv'." doesn't exist. Download failed."; |
|
| 2596 | + } |
|
| 2216 | 2597 | if ($error != '') { |
| 2217 | 2598 | return $error; |
| 2218 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 2219 | - if ($globalDebug) echo "Owner New Zealand: Download..."; |
|
| 2599 | + } elseif ($globalDebug) { |
|
| 2600 | + echo "Done\n"; |
|
| 2601 | + } |
|
| 2602 | + if ($globalDebug) { |
|
| 2603 | + echo "Owner New Zealand: Download..."; |
|
| 2604 | + } |
|
| 2220 | 2605 | update_db::download('http://antonakis.co.uk/registers/NewZealand.txt',$tmp_dir.'owner_zk.csv'); |
| 2221 | 2606 | if (file_exists($tmp_dir.'owner_zk.csv')) { |
| 2222 | - if ($globalDebug) echo "Add to DB..."; |
|
| 2607 | + if ($globalDebug) { |
|
| 2608 | + echo "Add to DB..."; |
|
| 2609 | + } |
|
| 2223 | 2610 | $error = update_db::retrieve_owner($tmp_dir.'owner_zk.csv','ZK'); |
| 2224 | - } else $error = "File ".$tmp_dir.'owner_zk.csv'." doesn't exist. Download failed."; |
|
| 2611 | + } else { |
|
| 2612 | + $error = "File ".$tmp_dir.'owner_zk.csv'." doesn't exist. Download failed."; |
|
| 2613 | + } |
|
| 2225 | 2614 | if ($error != '') { |
| 2226 | 2615 | return $error; |
| 2227 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 2228 | - if ($globalDebug) echo "Owner Papua New Guinea: Download..."; |
|
| 2616 | + } elseif ($globalDebug) { |
|
| 2617 | + echo "Done\n"; |
|
| 2618 | + } |
|
| 2619 | + if ($globalDebug) { |
|
| 2620 | + echo "Owner Papua New Guinea: Download..."; |
|
| 2621 | + } |
|
| 2229 | 2622 | update_db::download('http://antonakis.co.uk/registers/PapuaNewGuinea.txt',$tmp_dir.'owner_p2.csv'); |
| 2230 | 2623 | if (file_exists($tmp_dir.'owner_p2.csv')) { |
| 2231 | - if ($globalDebug) echo "Add to DB..."; |
|
| 2624 | + if ($globalDebug) { |
|
| 2625 | + echo "Add to DB..."; |
|
| 2626 | + } |
|
| 2232 | 2627 | $error = update_db::retrieve_owner($tmp_dir.'owner_p2.csv','P2'); |
| 2233 | - } else $error = "File ".$tmp_dir.'owner_p2.csv'." doesn't exist. Download failed."; |
|
| 2628 | + } else { |
|
| 2629 | + $error = "File ".$tmp_dir.'owner_p2.csv'." doesn't exist. Download failed."; |
|
| 2630 | + } |
|
| 2234 | 2631 | if ($error != '') { |
| 2235 | 2632 | return $error; |
| 2236 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 2237 | - if ($globalDebug) echo "Owner Slovakia: Download..."; |
|
| 2633 | + } elseif ($globalDebug) { |
|
| 2634 | + echo "Done\n"; |
|
| 2635 | + } |
|
| 2636 | + if ($globalDebug) { |
|
| 2637 | + echo "Owner Slovakia: Download..."; |
|
| 2638 | + } |
|
| 2238 | 2639 | update_db::download('http://antonakis.co.uk/registers/Slovakia.txt',$tmp_dir.'owner_om.csv'); |
| 2239 | 2640 | if (file_exists($tmp_dir.'owner_om.csv')) { |
| 2240 | - if ($globalDebug) echo "Add to DB..."; |
|
| 2641 | + if ($globalDebug) { |
|
| 2642 | + echo "Add to DB..."; |
|
| 2643 | + } |
|
| 2241 | 2644 | $error = update_db::retrieve_owner($tmp_dir.'owner_om.csv','OM'); |
| 2242 | - } else $error = "File ".$tmp_dir.'owner_om.csv'." doesn't exist. Download failed."; |
|
| 2645 | + } else { |
|
| 2646 | + $error = "File ".$tmp_dir.'owner_om.csv'." doesn't exist. Download failed."; |
|
| 2647 | + } |
|
| 2243 | 2648 | if ($error != '') { |
| 2244 | 2649 | return $error; |
| 2245 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 2246 | - if ($globalDebug) echo "Owner Ecuador: Download..."; |
|
| 2650 | + } elseif ($globalDebug) { |
|
| 2651 | + echo "Done\n"; |
|
| 2652 | + } |
|
| 2653 | + if ($globalDebug) { |
|
| 2654 | + echo "Owner Ecuador: Download..."; |
|
| 2655 | + } |
|
| 2247 | 2656 | update_db::download('http://antonakis.co.uk/registers/Ecuador.txt',$tmp_dir.'owner_hc.csv'); |
| 2248 | 2657 | if (file_exists($tmp_dir.'owner_hc.csv')) { |
| 2249 | - if ($globalDebug) echo "Add to DB..."; |
|
| 2658 | + if ($globalDebug) { |
|
| 2659 | + echo "Add to DB..."; |
|
| 2660 | + } |
|
| 2250 | 2661 | $error = update_db::retrieve_owner($tmp_dir.'owner_hc.csv','HC'); |
| 2251 | - } else $error = "File ".$tmp_dir.'owner_hc.csv'." doesn't exist. Download failed."; |
|
| 2662 | + } else { |
|
| 2663 | + $error = "File ".$tmp_dir.'owner_hc.csv'." doesn't exist. Download failed."; |
|
| 2664 | + } |
|
| 2252 | 2665 | if ($error != '') { |
| 2253 | 2666 | return $error; |
| 2254 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 2255 | - if ($globalDebug) echo "Owner Iceland: Download..."; |
|
| 2667 | + } elseif ($globalDebug) { |
|
| 2668 | + echo "Done\n"; |
|
| 2669 | + } |
|
| 2670 | + if ($globalDebug) { |
|
| 2671 | + echo "Owner Iceland: Download..."; |
|
| 2672 | + } |
|
| 2256 | 2673 | update_db::download('http://antonakis.co.uk/registers/Iceland.txt',$tmp_dir.'owner_tf.csv'); |
| 2257 | 2674 | if (file_exists($tmp_dir.'owner_tf.csv')) { |
| 2258 | - if ($globalDebug) echo "Add to DB..."; |
|
| 2675 | + if ($globalDebug) { |
|
| 2676 | + echo "Add to DB..."; |
|
| 2677 | + } |
|
| 2259 | 2678 | $error = update_db::retrieve_owner($tmp_dir.'owner_tf.csv','TF'); |
| 2260 | - } else $error = "File ".$tmp_dir.'owner_tf.csv'." doesn't exist. Download failed."; |
|
| 2679 | + } else { |
|
| 2680 | + $error = "File ".$tmp_dir.'owner_tf.csv'." doesn't exist. Download failed."; |
|
| 2681 | + } |
|
| 2261 | 2682 | if ($error != '') { |
| 2262 | 2683 | return $error; |
| 2263 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 2264 | - if ($globalDebug) echo "Owner Isle of Man: Download..."; |
|
| 2684 | + } elseif ($globalDebug) { |
|
| 2685 | + echo "Done\n"; |
|
| 2686 | + } |
|
| 2687 | + if ($globalDebug) { |
|
| 2688 | + echo "Owner Isle of Man: Download..."; |
|
| 2689 | + } |
|
| 2265 | 2690 | update_db::download('http://antonakis.co.uk/registers/IsleOfMan.txt',$tmp_dir.'owner_m.csv'); |
| 2266 | 2691 | if (file_exists($tmp_dir.'owner_m.csv')) { |
| 2267 | - if ($globalDebug) echo "Add to DB..."; |
|
| 2692 | + if ($globalDebug) { |
|
| 2693 | + echo "Add to DB..."; |
|
| 2694 | + } |
|
| 2268 | 2695 | $error = update_db::retrieve_owner($tmp_dir.'owner_m.csv','M'); |
| 2269 | - } else $error = "File ".$tmp_dir.'owner_m.csv'." doesn't exist. Download failed."; |
|
| 2696 | + } else { |
|
| 2697 | + $error = "File ".$tmp_dir.'owner_m.csv'." doesn't exist. Download failed."; |
|
| 2698 | + } |
|
| 2270 | 2699 | if ($error != '') { |
| 2271 | 2700 | return $error; |
| 2272 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 2701 | + } elseif ($globalDebug) { |
|
| 2702 | + echo "Done\n"; |
|
| 2703 | + } |
|
| 2273 | 2704 | if ($globalMasterSource) { |
| 2274 | - if ($globalDebug) echo "ModeS Netherlands: Download..."; |
|
| 2705 | + if ($globalDebug) { |
|
| 2706 | + echo "ModeS Netherlands: Download..."; |
|
| 2707 | + } |
|
| 2275 | 2708 | update_db::download('http://antonakis.co.uk/registers/Netherlands.txt',$tmp_dir.'owner_ph.csv'); |
| 2276 | 2709 | if (file_exists($tmp_dir.'owner_ph.csv')) { |
| 2277 | - if ($globalDebug) echo "Add to DB..."; |
|
| 2710 | + if ($globalDebug) { |
|
| 2711 | + echo "Add to DB..."; |
|
| 2712 | + } |
|
| 2278 | 2713 | $error = update_db::retrieve_owner($tmp_dir.'owner_ph.csv','PH'); |
| 2279 | - } else $error = "File ".$tmp_dir.'owner_ph.csv'." doesn't exist. Download failed."; |
|
| 2714 | + } else { |
|
| 2715 | + $error = "File ".$tmp_dir.'owner_ph.csv'." doesn't exist. Download failed."; |
|
| 2716 | + } |
|
| 2280 | 2717 | if ($error != '') { |
| 2281 | 2718 | return $error; |
| 2282 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 2283 | - if ($globalDebug) echo "ModeS Denmark: Download..."; |
|
| 2719 | + } elseif ($globalDebug) { |
|
| 2720 | + echo "Done\n"; |
|
| 2721 | + } |
|
| 2722 | + if ($globalDebug) { |
|
| 2723 | + echo "ModeS Denmark: Download..."; |
|
| 2724 | + } |
|
| 2284 | 2725 | update_db::download('http://antonakis.co.uk/registers/Denmark.txt',$tmp_dir.'owner_oy.csv'); |
| 2285 | 2726 | if (file_exists($tmp_dir.'owner_oy.csv')) { |
| 2286 | - if ($globalDebug) echo "Add to DB..."; |
|
| 2727 | + if ($globalDebug) { |
|
| 2728 | + echo "Add to DB..."; |
|
| 2729 | + } |
|
| 2287 | 2730 | $error = update_db::retrieve_owner($tmp_dir.'owner_oy.csv','OY'); |
| 2288 | - } else $error = "File ".$tmp_dir.'owner_oy.csv'." doesn't exist. Download failed."; |
|
| 2731 | + } else { |
|
| 2732 | + $error = "File ".$tmp_dir.'owner_oy.csv'." doesn't exist. Download failed."; |
|
| 2733 | + } |
|
| 2289 | 2734 | if ($error != '') { |
| 2290 | 2735 | return $error; |
| 2291 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 2292 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 2736 | + } elseif ($globalDebug) { |
|
| 2737 | + echo "Done\n"; |
|
| 2738 | + } |
|
| 2739 | + } elseif ($globalDebug) { |
|
| 2740 | + echo "Done\n"; |
|
| 2741 | + } |
|
| 2293 | 2742 | return ''; |
| 2294 | 2743 | } |
| 2295 | 2744 | |
| 2296 | 2745 | public static function update_translation() { |
| 2297 | 2746 | global $tmp_dir, $globalDebug; |
| 2298 | 2747 | $error = ''; |
| 2299 | - if ($globalDebug) echo "Translation : Download..."; |
|
| 2748 | + if ($globalDebug) { |
|
| 2749 | + echo "Translation : Download..."; |
|
| 2750 | + } |
|
| 2300 | 2751 | update_db::download('http://www.acarsd.org/download/translation.php',$tmp_dir.'translation.zip'); |
| 2301 | 2752 | if (file_exists($tmp_dir.'translation.zip')) { |
| 2302 | - if ($globalDebug) echo "Unzip..."; |
|
| 2753 | + if ($globalDebug) { |
|
| 2754 | + echo "Unzip..."; |
|
| 2755 | + } |
|
| 2303 | 2756 | update_db::unzip($tmp_dir.'translation.zip'); |
| 2304 | - if ($globalDebug) echo "Add to DB..."; |
|
| 2757 | + if ($globalDebug) { |
|
| 2758 | + echo "Add to DB..."; |
|
| 2759 | + } |
|
| 2305 | 2760 | $error = update_db::translation(); |
| 2306 | - } else $error = "File ".$tmp_dir.'translation.zip'." doesn't exist. Download failed."; |
|
| 2761 | + } else { |
|
| 2762 | + $error = "File ".$tmp_dir.'translation.zip'." doesn't exist. Download failed."; |
|
| 2763 | + } |
|
| 2307 | 2764 | if ($error != '') { |
| 2308 | 2765 | return $error; |
| 2309 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 2766 | + } elseif ($globalDebug) { |
|
| 2767 | + echo "Done\n"; |
|
| 2768 | + } |
|
| 2310 | 2769 | return ''; |
| 2311 | 2770 | } |
| 2312 | 2771 | |
| 2313 | 2772 | public static function update_translation_fam() { |
| 2314 | 2773 | global $tmp_dir, $globalDebug; |
| 2315 | - if ($globalDebug) echo "Translation from FlightAirMap website : Download..."; |
|
| 2774 | + if ($globalDebug) { |
|
| 2775 | + echo "Translation from FlightAirMap website : Download..."; |
|
| 2776 | + } |
|
| 2316 | 2777 | update_db::download('http://data.flightairmap.com/data/translation.tsv.gz',$tmp_dir.'translation.tsv.gz'); |
| 2317 | 2778 | update_db::download('http://data.flightairmap.com/data/translation.tsv.gz.md5',$tmp_dir.'translation.tsv.gz.md5'); |
| 2318 | 2779 | if (file_exists($tmp_dir.'translation.tsv.gz') && file_exists($tmp_dir.'translation.tsv.gz')) { |
| 2319 | 2780 | $translation_md5_file = explode(' ',file_get_contents($tmp_dir.'translation.tsv.gz.md5')); |
| 2320 | 2781 | $translation_md5 = $translation_md5_file[0]; |
| 2321 | 2782 | if (md5_file($tmp_dir.'translation.tsv.gz') == $translation_md5) { |
| 2322 | - if ($globalDebug) echo "Gunzip..."; |
|
| 2783 | + if ($globalDebug) { |
|
| 2784 | + echo "Gunzip..."; |
|
| 2785 | + } |
|
| 2323 | 2786 | update_db::gunzip($tmp_dir.'translation.tsv.gz'); |
| 2324 | - if ($globalDebug) echo "Add to DB..."; |
|
| 2787 | + if ($globalDebug) { |
|
| 2788 | + echo "Add to DB..."; |
|
| 2789 | + } |
|
| 2325 | 2790 | $error = update_db::translation_fam(); |
| 2326 | - } else $error = "File ".$tmp_dir.'translation.tsv.gz'." md5 failed. Download failed."; |
|
| 2327 | - } else $error = "File ".$tmp_dir.'translation.tsv.gz'." doesn't exist. Download failed."; |
|
| 2791 | + } else { |
|
| 2792 | + $error = "File ".$tmp_dir.'translation.tsv.gz'." md5 failed. Download failed."; |
|
| 2793 | + } |
|
| 2794 | + } else { |
|
| 2795 | + $error = "File ".$tmp_dir.'translation.tsv.gz'." doesn't exist. Download failed."; |
|
| 2796 | + } |
|
| 2328 | 2797 | if ($error != '') { |
| 2329 | 2798 | return $error; |
| 2330 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 2799 | + } elseif ($globalDebug) { |
|
| 2800 | + echo "Done\n"; |
|
| 2801 | + } |
|
| 2331 | 2802 | return ''; |
| 2332 | 2803 | } |
| 2333 | 2804 | public static function update_ModeS_fam() { |
| 2334 | 2805 | global $tmp_dir, $globalDebug; |
| 2335 | - if ($globalDebug) echo "ModeS from FlightAirMap website : Download..."; |
|
| 2806 | + if ($globalDebug) { |
|
| 2807 | + echo "ModeS from FlightAirMap website : Download..."; |
|
| 2808 | + } |
|
| 2336 | 2809 | update_db::download('http://data.flightairmap.com/data/modes.tsv.gz',$tmp_dir.'modes.tsv.gz'); |
| 2337 | 2810 | update_db::download('http://data.flightairmap.com/data/modes.tsv.gz.md5',$tmp_dir.'modes.tsv.gz.md5'); |
| 2338 | 2811 | if (file_exists($tmp_dir.'modes.tsv.gz') && file_exists($tmp_dir.'modes.tsv.gz.md5')) { |
| 2339 | 2812 | $modes_md5_file = explode(' ',file_get_contents($tmp_dir.'modes.tsv.gz.md5')); |
| 2340 | 2813 | $modes_md5 = $modes_md5_file[0]; |
| 2341 | 2814 | if (md5_file($tmp_dir.'modes.tsv.gz') == $modes_md5) { |
| 2342 | - if ($globalDebug) echo "Gunzip..."; |
|
| 2815 | + if ($globalDebug) { |
|
| 2816 | + echo "Gunzip..."; |
|
| 2817 | + } |
|
| 2343 | 2818 | update_db::gunzip($tmp_dir.'modes.tsv.gz'); |
| 2344 | - if ($globalDebug) echo "Add to DB..."; |
|
| 2819 | + if ($globalDebug) { |
|
| 2820 | + echo "Add to DB..."; |
|
| 2821 | + } |
|
| 2345 | 2822 | $error = update_db::modes_fam(); |
| 2346 | - } else $error = "File ".$tmp_dir.'modes.tsv.gz'." md5 failed. Download failed."; |
|
| 2347 | - } else $error = "File ".$tmp_dir.'modes.tsv.gz'." doesn't exist. Download failed."; |
|
| 2823 | + } else { |
|
| 2824 | + $error = "File ".$tmp_dir.'modes.tsv.gz'." md5 failed. Download failed."; |
|
| 2825 | + } |
|
| 2826 | + } else { |
|
| 2827 | + $error = "File ".$tmp_dir.'modes.tsv.gz'." doesn't exist. Download failed."; |
|
| 2828 | + } |
|
| 2348 | 2829 | if ($error != '') { |
| 2349 | 2830 | return $error; |
| 2350 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 2831 | + } elseif ($globalDebug) { |
|
| 2832 | + echo "Done\n"; |
|
| 2833 | + } |
|
| 2351 | 2834 | return ''; |
| 2352 | 2835 | } |
| 2353 | 2836 | public static function update_owner_fam() { |
| 2354 | 2837 | global $tmp_dir, $globalDebug, $globalOwner; |
| 2355 | - if ($globalDebug) echo "owner from FlightAirMap website : Download..."; |
|
| 2838 | + if ($globalDebug) { |
|
| 2839 | + echo "owner from FlightAirMap website : Download..."; |
|
| 2840 | + } |
|
| 2356 | 2841 | if ($globalOwner === TRUE) { |
| 2357 | 2842 | update_db::download('http://data.flightairmap.com/data/owners_all.tsv.gz',$tmp_dir.'owners.tsv.gz'); |
| 2358 | 2843 | update_db::download('http://data.flightairmap.com/data/owners_all.tsv.gz.md5',$tmp_dir.'owners.tsv.gz.md5'); |
@@ -2364,35 +2849,57 @@ discard block |
||
| 2364 | 2849 | $owners_md5_file = explode(' ',file_get_contents($tmp_dir.'owners.tsv.gz.md5')); |
| 2365 | 2850 | $owners_md5 = $owners_md5_file[0]; |
| 2366 | 2851 | if (md5_file($tmp_dir.'owners.tsv.gz') == $owners_md5) { |
| 2367 | - if ($globalDebug) echo "Gunzip..."; |
|
| 2852 | + if ($globalDebug) { |
|
| 2853 | + echo "Gunzip..."; |
|
| 2854 | + } |
|
| 2368 | 2855 | update_db::gunzip($tmp_dir.'owners.tsv.gz'); |
| 2369 | - if ($globalDebug) echo "Add to DB..."; |
|
| 2856 | + if ($globalDebug) { |
|
| 2857 | + echo "Add to DB..."; |
|
| 2858 | + } |
|
| 2370 | 2859 | $error = update_db::owner_fam(); |
| 2371 | - } else $error = "File ".$tmp_dir.'owners.tsv.gz'." md5 failed. Download failed."; |
|
| 2372 | - } else $error = "File ".$tmp_dir.'owners.tsv.gz'." doesn't exist. Download failed."; |
|
| 2860 | + } else { |
|
| 2861 | + $error = "File ".$tmp_dir.'owners.tsv.gz'." md5 failed. Download failed."; |
|
| 2862 | + } |
|
| 2863 | + } else { |
|
| 2864 | + $error = "File ".$tmp_dir.'owners.tsv.gz'." doesn't exist. Download failed."; |
|
| 2865 | + } |
|
| 2373 | 2866 | if ($error != '') { |
| 2374 | 2867 | return $error; |
| 2375 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 2868 | + } elseif ($globalDebug) { |
|
| 2869 | + echo "Done\n"; |
|
| 2870 | + } |
|
| 2376 | 2871 | return ''; |
| 2377 | 2872 | } |
| 2378 | 2873 | public static function update_routes_fam() { |
| 2379 | 2874 | global $tmp_dir, $globalDebug; |
| 2380 | - if ($globalDebug) echo "Routes from FlightAirMap website : Download..."; |
|
| 2875 | + if ($globalDebug) { |
|
| 2876 | + echo "Routes from FlightAirMap website : Download..."; |
|
| 2877 | + } |
|
| 2381 | 2878 | update_db::download('http://data.flightairmap.com/data/routes.tsv.gz',$tmp_dir.'routes.tsv.gz'); |
| 2382 | 2879 | update_db::download('http://data.flightairmap.com/data/routes.tsv.gz.md5',$tmp_dir.'routes.tsv.gz.md5'); |
| 2383 | 2880 | if (file_exists($tmp_dir.'routes.tsv.gz') && file_exists($tmp_dir.'routes.tsv.gz.md5')) { |
| 2384 | 2881 | $routes_md5_file = explode(' ',file_get_contents($tmp_dir.'routes.tsv.gz.md5')); |
| 2385 | 2882 | $routes_md5 = $routes_md5_file[0]; |
| 2386 | 2883 | if (md5_file($tmp_dir.'routes.tsv.gz') == $routes_md5) { |
| 2387 | - if ($globalDebug) echo "Gunzip..."; |
|
| 2884 | + if ($globalDebug) { |
|
| 2885 | + echo "Gunzip..."; |
|
| 2886 | + } |
|
| 2388 | 2887 | update_db::gunzip($tmp_dir.'routes.tsv.gz'); |
| 2389 | - if ($globalDebug) echo "Add to DB..."; |
|
| 2888 | + if ($globalDebug) { |
|
| 2889 | + echo "Add to DB..."; |
|
| 2890 | + } |
|
| 2390 | 2891 | $error = update_db::routes_fam(); |
| 2391 | - } else $error = "File ".$tmp_dir.'routes.tsv.gz'." md5 failed. Download failed."; |
|
| 2392 | - } else $error = "File ".$tmp_dir.'routes.tsv.gz'." doesn't exist. Download failed."; |
|
| 2892 | + } else { |
|
| 2893 | + $error = "File ".$tmp_dir.'routes.tsv.gz'." md5 failed. Download failed."; |
|
| 2894 | + } |
|
| 2895 | + } else { |
|
| 2896 | + $error = "File ".$tmp_dir.'routes.tsv.gz'." doesn't exist. Download failed."; |
|
| 2897 | + } |
|
| 2393 | 2898 | if ($error != '') { |
| 2394 | 2899 | return $error; |
| 2395 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 2900 | + } elseif ($globalDebug) { |
|
| 2901 | + echo "Done\n"; |
|
| 2902 | + } |
|
| 2396 | 2903 | return ''; |
| 2397 | 2904 | } |
| 2398 | 2905 | public static function update_marine_identity_fam() { |
@@ -2402,16 +2909,26 @@ discard block |
||
| 2402 | 2909 | $marine_identity_md5_file = explode(' ',file_get_contents($tmp_dir.'marine_identity.tsv.gz.md5')); |
| 2403 | 2910 | $marine_identity_md5 = $marine_identity_md5_file[0]; |
| 2404 | 2911 | if (!update_db::check_marine_identity_version($marine_identity_md5)) { |
| 2405 | - if ($globalDebug) echo "Marine identity from FlightAirMap website : Download..."; |
|
| 2912 | + if ($globalDebug) { |
|
| 2913 | + echo "Marine identity from FlightAirMap website : Download..."; |
|
| 2914 | + } |
|
| 2406 | 2915 | update_db::download('http://data.flightairmap.com/data/marine_identity.tsv.gz',$tmp_dir.'marine_identity.tsv.gz'); |
| 2407 | 2916 | if (file_exists($tmp_dir.'marine_identity.tsv.gz')) { |
| 2408 | 2917 | if (md5_file($tmp_dir.'marine_identity.tsv.gz') == $marine_identity_md5) { |
| 2409 | - if ($globalDebug) echo "Gunzip..."; |
|
| 2918 | + if ($globalDebug) { |
|
| 2919 | + echo "Gunzip..."; |
|
| 2920 | + } |
|
| 2410 | 2921 | update_db::gunzip($tmp_dir.'marine_identity.tsv.gz'); |
| 2411 | - if ($globalDebug) echo "Add to DB..."; |
|
| 2922 | + if ($globalDebug) { |
|
| 2923 | + echo "Add to DB..."; |
|
| 2924 | + } |
|
| 2412 | 2925 | $error = update_db::marine_identity_fam(); |
| 2413 | - } else $error = "File ".$tmp_dir.'marine_identity.tsv.gz'." md5 failed. Download failed."; |
|
| 2414 | - } else $error = "File ".$tmp_dir.'marine_identity.tsv.gz'." doesn't exist. Download failed."; |
|
| 2926 | + } else { |
|
| 2927 | + $error = "File ".$tmp_dir.'marine_identity.tsv.gz'." md5 failed. Download failed."; |
|
| 2928 | + } |
|
| 2929 | + } else { |
|
| 2930 | + $error = "File ".$tmp_dir.'marine_identity.tsv.gz'." doesn't exist. Download failed."; |
|
| 2931 | + } |
|
| 2415 | 2932 | if ($error != '') { |
| 2416 | 2933 | return $error; |
| 2417 | 2934 | } elseif ($globalDebug) { |
@@ -2430,16 +2947,26 @@ discard block |
||
| 2430 | 2947 | $satellite_md5_file = explode(' ',file_get_contents($tmp_dir.'satellite.tsv.gz.md5')); |
| 2431 | 2948 | $satellite_md5 = $satellite_md5_file[0]; |
| 2432 | 2949 | if (!update_db::check_satellite_version($satellite_md5)) { |
| 2433 | - if ($globalDebug) echo "Satellite from FlightAirMap website : Download..."; |
|
| 2950 | + if ($globalDebug) { |
|
| 2951 | + echo "Satellite from FlightAirMap website : Download..."; |
|
| 2952 | + } |
|
| 2434 | 2953 | update_db::download('http://data.flightairmap.com/data/satellite.tsv.gz',$tmp_dir.'satellite.tsv.gz'); |
| 2435 | 2954 | if (file_exists($tmp_dir.'satellite.tsv.gz')) { |
| 2436 | 2955 | if (md5_file($tmp_dir.'satellite.tsv.gz') == $satellite_md5) { |
| 2437 | - if ($globalDebug) echo "Gunzip..."; |
|
| 2956 | + if ($globalDebug) { |
|
| 2957 | + echo "Gunzip..."; |
|
| 2958 | + } |
|
| 2438 | 2959 | update_db::gunzip($tmp_dir.'satellite.tsv.gz'); |
| 2439 | - if ($globalDebug) echo "Add to DB..."; |
|
| 2960 | + if ($globalDebug) { |
|
| 2961 | + echo "Add to DB..."; |
|
| 2962 | + } |
|
| 2440 | 2963 | $error = update_db::satellite_fam(); |
| 2441 | - } else $error = "File ".$tmp_dir.'satellite.tsv.gz'." md5 failed. Download failed."; |
|
| 2442 | - } else $error = "File ".$tmp_dir.'satellite.tsv.gz'." doesn't exist. Download failed."; |
|
| 2964 | + } else { |
|
| 2965 | + $error = "File ".$tmp_dir.'satellite.tsv.gz'." md5 failed. Download failed."; |
|
| 2966 | + } |
|
| 2967 | + } else { |
|
| 2968 | + $error = "File ".$tmp_dir.'satellite.tsv.gz'." doesn't exist. Download failed."; |
|
| 2969 | + } |
|
| 2443 | 2970 | if ($error != '') { |
| 2444 | 2971 | return $error; |
| 2445 | 2972 | } elseif ($globalDebug) { |
@@ -2452,17 +2979,25 @@ discard block |
||
| 2452 | 2979 | } |
| 2453 | 2980 | public static function update_banned_fam() { |
| 2454 | 2981 | global $tmp_dir, $globalDebug; |
| 2455 | - if ($globalDebug) echo "Banned airlines in Europe from FlightAirMap website : Download..."; |
|
| 2982 | + if ($globalDebug) { |
|
| 2983 | + echo "Banned airlines in Europe from FlightAirMap website : Download..."; |
|
| 2984 | + } |
|
| 2456 | 2985 | update_db::download('http://data.flightairmap.com/data/ban-eu.csv',$tmp_dir.'ban_eu.csv'); |
| 2457 | 2986 | if (file_exists($tmp_dir.'ban_eu.csv')) { |
| 2458 | 2987 | //if ($globalDebug) echo "Gunzip..."; |
| 2459 | 2988 | //update_db::gunzip($tmp_dir.'ban_ue.csv'); |
| 2460 | - if ($globalDebug) echo "Add to DB..."; |
|
| 2989 | + if ($globalDebug) { |
|
| 2990 | + echo "Add to DB..."; |
|
| 2991 | + } |
|
| 2461 | 2992 | $error = update_db::banned_fam(); |
| 2462 | - } else $error = "File ".$tmp_dir.'ban_eu.csv'." doesn't exist. Download failed."; |
|
| 2993 | + } else { |
|
| 2994 | + $error = "File ".$tmp_dir.'ban_eu.csv'." doesn't exist. Download failed."; |
|
| 2995 | + } |
|
| 2463 | 2996 | if ($error != '') { |
| 2464 | 2997 | return $error; |
| 2465 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 2998 | + } elseif ($globalDebug) { |
|
| 2999 | + echo "Done\n"; |
|
| 3000 | + } |
|
| 2466 | 3001 | return ''; |
| 2467 | 3002 | } |
| 2468 | 3003 | |
@@ -2470,7 +3005,9 @@ discard block |
||
| 2470 | 3005 | global $tmp_dir, $globalDebug, $globalDBdriver; |
| 2471 | 3006 | include_once('class.create_db.php'); |
| 2472 | 3007 | $error = ''; |
| 2473 | - if ($globalDebug) echo "Airspace from FlightAirMap website : Download..."; |
|
| 3008 | + if ($globalDebug) { |
|
| 3009 | + echo "Airspace from FlightAirMap website : Download..."; |
|
| 3010 | + } |
|
| 2474 | 3011 | if ($globalDBdriver == 'mysql') { |
| 2475 | 3012 | update_db::download('http://data.flightairmap.com/data/airspace_mysql.sql.gz.md5',$tmp_dir.'airspace.sql.gz.md5'); |
| 2476 | 3013 | } else { |
@@ -2487,9 +3024,13 @@ discard block |
||
| 2487 | 3024 | } |
| 2488 | 3025 | if (file_exists($tmp_dir.'airspace.sql.gz')) { |
| 2489 | 3026 | if (md5_file($tmp_dir.'airspace.sql.gz') == $airspace_md5) { |
| 2490 | - if ($globalDebug) echo "Gunzip..."; |
|
| 3027 | + if ($globalDebug) { |
|
| 3028 | + echo "Gunzip..."; |
|
| 3029 | + } |
|
| 2491 | 3030 | update_db::gunzip($tmp_dir.'airspace.sql.gz'); |
| 2492 | - if ($globalDebug) echo "Add to DB..."; |
|
| 3031 | + if ($globalDebug) { |
|
| 3032 | + echo "Add to DB..."; |
|
| 3033 | + } |
|
| 2493 | 3034 | $Connection = new Connection(); |
| 2494 | 3035 | if ($Connection->tableExists('airspace')) { |
| 2495 | 3036 | $query = 'DROP TABLE airspace'; |
@@ -2502,20 +3043,30 @@ discard block |
||
| 2502 | 3043 | } |
| 2503 | 3044 | $error = create_db::import_file($tmp_dir.'airspace.sql'); |
| 2504 | 3045 | update_db::insert_airspace_version($airspace_md5); |
| 2505 | - } else $error = "File ".$tmp_dir.'airspace.sql.gz'." md5 failed. Download failed."; |
|
| 2506 | - } else $error = "File ".$tmp_dir.'airspace.sql.gz'." doesn't exist. Download failed."; |
|
| 3046 | + } else { |
|
| 3047 | + $error = "File ".$tmp_dir.'airspace.sql.gz'." md5 failed. Download failed."; |
|
| 3048 | + } |
|
| 3049 | + } else { |
|
| 3050 | + $error = "File ".$tmp_dir.'airspace.sql.gz'." doesn't exist. Download failed."; |
|
| 3051 | + } |
|
| 2507 | 3052 | } |
| 2508 | - } else $error = "File ".$tmp_dir.'airspace.sql.gz.md5'." doesn't exist. Download failed."; |
|
| 3053 | + } else { |
|
| 3054 | + $error = "File ".$tmp_dir.'airspace.sql.gz.md5'." doesn't exist. Download failed."; |
|
| 3055 | + } |
|
| 2509 | 3056 | if ($error != '') { |
| 2510 | 3057 | return $error; |
| 2511 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 3058 | + } elseif ($globalDebug) { |
|
| 3059 | + echo "Done\n"; |
|
| 3060 | + } |
|
| 2512 | 3061 | return ''; |
| 2513 | 3062 | } |
| 2514 | 3063 | |
| 2515 | 3064 | public static function update_geoid_fam() { |
| 2516 | 3065 | global $tmp_dir, $globalDebug, $globalGeoidSource; |
| 2517 | 3066 | $error = ''; |
| 2518 | - if ($globalDebug) echo "Geoid from FlightAirMap website : Download..."; |
|
| 3067 | + if ($globalDebug) { |
|
| 3068 | + echo "Geoid from FlightAirMap website : Download..."; |
|
| 3069 | + } |
|
| 2519 | 3070 | update_db::download('http://data.flightairmap.com/data/geoid/'.$globalGeoidSource.'.pgm.gz.md5',$tmp_dir.$globalGeoidSource.'.pgm.gz.md5'); |
| 2520 | 3071 | if (file_exists($tmp_dir.$globalGeoidSource.'.pgm.gz.md5')) { |
| 2521 | 3072 | $geoid_md5_file = explode(' ',file_get_contents($tmp_dir.$globalGeoidSource.'.pgm.gz.md5')); |
@@ -2524,76 +3075,116 @@ discard block |
||
| 2524 | 3075 | update_db::download('http://data.flightairmap.com/data/geoid/'.$globalGeoidSource.'.pgm.gz',$tmp_dir.$globalGeoidSource.'.pgm.gz'); |
| 2525 | 3076 | if (file_exists($tmp_dir.$globalGeoidSource.'.pgm.gz')) { |
| 2526 | 3077 | if (md5_file($tmp_dir.$globalGeoidSource.'.pgm.gz') == $geoid_md5) { |
| 2527 | - if ($globalDebug) echo "Gunzip..."; |
|
| 3078 | + if ($globalDebug) { |
|
| 3079 | + echo "Gunzip..."; |
|
| 3080 | + } |
|
| 2528 | 3081 | update_db::gunzip($tmp_dir.$globalGeoidSource.'.pgm.gz',dirname(__FILE__).'/../data/'.$globalGeoidSource.'.pgm'); |
| 2529 | 3082 | if (file_exists(dirname(__FILE__).'/../data/'.$globalGeoidSource.'.pgm')) { |
| 2530 | 3083 | update_db::insert_geoid_version($geoid_md5); |
| 2531 | 3084 | } |
| 2532 | - } else $error = "File ".$tmp_dir.$globalGeoidSource.'.pgm.gz'." md5 failed. Download failed."; |
|
| 2533 | - } else $error = "File ".$tmp_dir.$globalGeoidSource.'.pgm.gz'." doesn't exist. Download failed."; |
|
| 3085 | + } else { |
|
| 3086 | + $error = "File ".$tmp_dir.$globalGeoidSource.'.pgm.gz'." md5 failed. Download failed."; |
|
| 3087 | + } |
|
| 3088 | + } else { |
|
| 3089 | + $error = "File ".$tmp_dir.$globalGeoidSource.'.pgm.gz'." doesn't exist. Download failed."; |
|
| 3090 | + } |
|
| 2534 | 3091 | } |
| 2535 | - } else $error = "File ".$tmp_dir.$globalGeoidSource.'.pgm.gz.md5'." doesn't exist. Download failed."; |
|
| 3092 | + } else { |
|
| 3093 | + $error = "File ".$tmp_dir.$globalGeoidSource.'.pgm.gz.md5'." doesn't exist. Download failed."; |
|
| 3094 | + } |
|
| 2536 | 3095 | if ($error != '') { |
| 2537 | 3096 | return $error; |
| 2538 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 3097 | + } elseif ($globalDebug) { |
|
| 3098 | + echo "Done\n"; |
|
| 3099 | + } |
|
| 2539 | 3100 | return ''; |
| 2540 | 3101 | } |
| 2541 | 3102 | |
| 2542 | 3103 | public static function update_tle() { |
| 2543 | 3104 | global $tmp_dir, $globalDebug; |
| 2544 | - if ($globalDebug) echo "Download TLE : Download..."; |
|
| 3105 | + if ($globalDebug) { |
|
| 3106 | + echo "Download TLE : Download..."; |
|
| 3107 | + } |
|
| 2545 | 3108 | $alltle = array('stations.txt','gps-ops.txt','glo-ops.txt','galileo.txt','weather.txt','noaa.txt','goes.txt','resource.txt','dmc.txt','tdrss.txt','geo.txt','intelsat.txt','gorizont.txt', |
| 2546 | 3109 | 'raduga.txt','molniya.txt','iridium.txt','orbcomm.txt','globalstar.txt','amateur.txt','x-comm.txt','other-comm.txt','sbas.txt','nnss.txt','musson.txt','science.txt','geodetic.txt', |
| 2547 | 3110 | 'engineering.txt','education.txt','military.txt','radar.txt','cubesat.txt','other.txt','tle-new.txt','visual.txt','sarsat.txt','argos.txt','ses.txt','iridium-NEXT.txt','beidou.txt'); |
| 2548 | 3111 | foreach ($alltle as $filename) { |
| 2549 | - if ($globalDebug) echo "downloading ".$filename.'...'; |
|
| 3112 | + if ($globalDebug) { |
|
| 3113 | + echo "downloading ".$filename.'...'; |
|
| 3114 | + } |
|
| 2550 | 3115 | update_db::download('http://celestrak.com/NORAD/elements/'.$filename,$tmp_dir.$filename); |
| 2551 | 3116 | if (file_exists($tmp_dir.$filename)) { |
| 2552 | - if ($globalDebug) echo "Add to DB ".$filename."..."; |
|
| 3117 | + if ($globalDebug) { |
|
| 3118 | + echo "Add to DB ".$filename."..."; |
|
| 3119 | + } |
|
| 2553 | 3120 | $error = update_db::tle($tmp_dir.$filename,str_replace('.txt','',$filename)); |
| 2554 | - } else $error = "File ".$tmp_dir.$filename." doesn't exist. Download failed."; |
|
| 3121 | + } else { |
|
| 3122 | + $error = "File ".$tmp_dir.$filename." doesn't exist. Download failed."; |
|
| 3123 | + } |
|
| 2555 | 3124 | if ($error != '') { |
| 2556 | 3125 | echo $error."\n"; |
| 2557 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 3126 | + } elseif ($globalDebug) { |
|
| 3127 | + echo "Done\n"; |
|
| 3128 | + } |
|
| 2558 | 3129 | } |
| 2559 | 3130 | return ''; |
| 2560 | 3131 | } |
| 2561 | 3132 | |
| 2562 | 3133 | public static function update_ucsdb() { |
| 2563 | 3134 | global $tmp_dir, $globalDebug; |
| 2564 | - if ($globalDebug) echo "Download UCS DB : Download..."; |
|
| 3135 | + if ($globalDebug) { |
|
| 3136 | + echo "Download UCS DB : Download..."; |
|
| 3137 | + } |
|
| 2565 | 3138 | update_db::download('https://s3.amazonaws.com/ucs-documents/nuclear-weapons/sat-database/4-11-17-update/UCS_Satellite_Database_officialname_1-1-17.txt',$tmp_dir.'UCS_Satellite_Database_officialname_1-1-17.txt'); |
| 2566 | 3139 | if (file_exists($tmp_dir.'UCS_Satellite_Database_officialname_1-1-17.txt')) { |
| 2567 | - if ($globalDebug) echo "Add to DB..."; |
|
| 3140 | + if ($globalDebug) { |
|
| 3141 | + echo "Add to DB..."; |
|
| 3142 | + } |
|
| 2568 | 3143 | $error = update_db::satellite_ucsdb($tmp_dir.'UCS_Satellite_Database_officialname_1-1-17.txt'); |
| 2569 | - } else $error = "File ".$tmp_dir.'UCS_Satellite_Database_officialname_1-1-17.txt'." doesn't exist. Download failed."; |
|
| 3144 | + } else { |
|
| 3145 | + $error = "File ".$tmp_dir.'UCS_Satellite_Database_officialname_1-1-17.txt'." doesn't exist. Download failed."; |
|
| 3146 | + } |
|
| 2570 | 3147 | if ($error != '') { |
| 2571 | 3148 | echo $error."\n"; |
| 2572 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 3149 | + } elseif ($globalDebug) { |
|
| 3150 | + echo "Done\n"; |
|
| 3151 | + } |
|
| 2573 | 3152 | return ''; |
| 2574 | 3153 | } |
| 2575 | 3154 | |
| 2576 | 3155 | public static function update_celestrak() { |
| 2577 | 3156 | global $tmp_dir, $globalDebug; |
| 2578 | - if ($globalDebug) echo "Download Celestrak DB : Download..."; |
|
| 3157 | + if ($globalDebug) { |
|
| 3158 | + echo "Download Celestrak DB : Download..."; |
|
| 3159 | + } |
|
| 2579 | 3160 | update_db::download('http://celestrak.com/pub/satcat.txt',$tmp_dir.'satcat.txt'); |
| 2580 | 3161 | if (file_exists($tmp_dir.'satcat.txt')) { |
| 2581 | - if ($globalDebug) echo "Add to DB..."; |
|
| 3162 | + if ($globalDebug) { |
|
| 3163 | + echo "Add to DB..."; |
|
| 3164 | + } |
|
| 2582 | 3165 | $error = update_db::satellite_celestrak($tmp_dir.'satcat.txt'); |
| 2583 | - } else $error = "File ".$tmp_dir.'satcat.txt'." doesn't exist. Download failed."; |
|
| 3166 | + } else { |
|
| 3167 | + $error = "File ".$tmp_dir.'satcat.txt'." doesn't exist. Download failed."; |
|
| 3168 | + } |
|
| 2584 | 3169 | if ($error != '') { |
| 2585 | 3170 | echo $error."\n"; |
| 2586 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 3171 | + } elseif ($globalDebug) { |
|
| 3172 | + echo "Done\n"; |
|
| 3173 | + } |
|
| 2587 | 3174 | return ''; |
| 2588 | 3175 | } |
| 2589 | 3176 | |
| 2590 | 3177 | public static function update_models() { |
| 2591 | 3178 | global $tmp_dir, $globalDebug; |
| 2592 | 3179 | $error = ''; |
| 2593 | - if ($globalDebug) echo "Models from FlightAirMap website : Download..."; |
|
| 3180 | + if ($globalDebug) { |
|
| 3181 | + echo "Models from FlightAirMap website : Download..."; |
|
| 3182 | + } |
|
| 2594 | 3183 | update_db::download('http://data.flightairmap.com/data/models/models.md5sum',$tmp_dir.'models.md5sum'); |
| 2595 | 3184 | if (file_exists($tmp_dir.'models.md5sum')) { |
| 2596 | - if ($globalDebug) echo "Check files...\n"; |
|
| 3185 | + if ($globalDebug) { |
|
| 3186 | + echo "Check files...\n"; |
|
| 3187 | + } |
|
| 2597 | 3188 | $newmodelsdb = array(); |
| 2598 | 3189 | if (($handle = fopen($tmp_dir.'models.md5sum','r')) !== FALSE) { |
| 2599 | 3190 | while (($row = fgetcsv($handle,1000," ")) !== FALSE) { |
@@ -2612,25 +3203,35 @@ discard block |
||
| 2612 | 3203 | } |
| 2613 | 3204 | $diff = array_diff($newmodelsdb,$modelsdb); |
| 2614 | 3205 | foreach ($diff as $key => $value) { |
| 2615 | - if ($globalDebug) echo 'Downloading model '.$key.' ...'."\n"; |
|
| 3206 | + if ($globalDebug) { |
|
| 3207 | + echo 'Downloading model '.$key.' ...'."\n"; |
|
| 3208 | + } |
|
| 2616 | 3209 | update_db::download('http://data.flightairmap.com/data/models/'.$key,dirname(__FILE__).'/../models/'.$key); |
| 2617 | 3210 | |
| 2618 | 3211 | } |
| 2619 | 3212 | update_db::download('http://data.flightairmap.com/data/models/models.md5sum',dirname(__FILE__).'/../models/models.md5sum'); |
| 2620 | - } else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed."; |
|
| 3213 | + } else { |
|
| 3214 | + $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed."; |
|
| 3215 | + } |
|
| 2621 | 3216 | if ($error != '') { |
| 2622 | 3217 | return $error; |
| 2623 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 3218 | + } elseif ($globalDebug) { |
|
| 3219 | + echo "Done\n"; |
|
| 3220 | + } |
|
| 2624 | 3221 | return ''; |
| 2625 | 3222 | } |
| 2626 | 3223 | |
| 2627 | 3224 | public static function update_space_models() { |
| 2628 | 3225 | global $tmp_dir, $globalDebug; |
| 2629 | 3226 | $error = ''; |
| 2630 | - if ($globalDebug) echo "Space models from FlightAirMap website : Download..."; |
|
| 3227 | + if ($globalDebug) { |
|
| 3228 | + echo "Space models from FlightAirMap website : Download..."; |
|
| 3229 | + } |
|
| 2631 | 3230 | update_db::download('http://data.flightairmap.com/data/models/space/space_models.md5sum',$tmp_dir.'space_models.md5sum'); |
| 2632 | 3231 | if (file_exists($tmp_dir.'space_models.md5sum')) { |
| 2633 | - if ($globalDebug) echo "Check files...\n"; |
|
| 3232 | + if ($globalDebug) { |
|
| 3233 | + echo "Check files...\n"; |
|
| 3234 | + } |
|
| 2634 | 3235 | $newmodelsdb = array(); |
| 2635 | 3236 | if (($handle = fopen($tmp_dir.'space_models.md5sum','r')) !== FALSE) { |
| 2636 | 3237 | while (($row = fgetcsv($handle,1000," ")) !== FALSE) { |
@@ -2649,25 +3250,35 @@ discard block |
||
| 2649 | 3250 | } |
| 2650 | 3251 | $diff = array_diff($newmodelsdb,$modelsdb); |
| 2651 | 3252 | foreach ($diff as $key => $value) { |
| 2652 | - if ($globalDebug) echo 'Downloading space model '.$key.' ...'."\n"; |
|
| 3253 | + if ($globalDebug) { |
|
| 3254 | + echo 'Downloading space model '.$key.' ...'."\n"; |
|
| 3255 | + } |
|
| 2653 | 3256 | update_db::download('http://data.flightairmap.com/data/models/space/'.$key,dirname(__FILE__).'/../models/space/'.$key); |
| 2654 | 3257 | |
| 2655 | 3258 | } |
| 2656 | 3259 | update_db::download('http://data.flightairmap.com/data/models/space/space_models.md5sum',dirname(__FILE__).'/../models/space/space_models.md5sum'); |
| 2657 | - } else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed."; |
|
| 3260 | + } else { |
|
| 3261 | + $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed."; |
|
| 3262 | + } |
|
| 2658 | 3263 | if ($error != '') { |
| 2659 | 3264 | return $error; |
| 2660 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 3265 | + } elseif ($globalDebug) { |
|
| 3266 | + echo "Done\n"; |
|
| 3267 | + } |
|
| 2661 | 3268 | return ''; |
| 2662 | 3269 | } |
| 2663 | 3270 | |
| 2664 | 3271 | public static function update_vehicules_models() { |
| 2665 | 3272 | global $tmp_dir, $globalDebug; |
| 2666 | 3273 | $error = ''; |
| 2667 | - if ($globalDebug) echo "Vehicules models from FlightAirMap website : Download..."; |
|
| 3274 | + if ($globalDebug) { |
|
| 3275 | + echo "Vehicules models from FlightAirMap website : Download..."; |
|
| 3276 | + } |
|
| 2668 | 3277 | update_db::download('http://data.flightairmap.com/data/models/vehicules/vehicules_models.md5sum',$tmp_dir.'vehicules_models.md5sum'); |
| 2669 | 3278 | if (file_exists($tmp_dir.'vehicules_models.md5sum')) { |
| 2670 | - if ($globalDebug) echo "Check files...\n"; |
|
| 3279 | + if ($globalDebug) { |
|
| 3280 | + echo "Check files...\n"; |
|
| 3281 | + } |
|
| 2671 | 3282 | $newmodelsdb = array(); |
| 2672 | 3283 | if (($handle = fopen($tmp_dir.'vehicules_models.md5sum','r')) !== FALSE) { |
| 2673 | 3284 | while (($row = fgetcsv($handle,1000," ")) !== FALSE) { |
@@ -2686,15 +3297,21 @@ discard block |
||
| 2686 | 3297 | } |
| 2687 | 3298 | $diff = array_diff($newmodelsdb,$modelsdb); |
| 2688 | 3299 | foreach ($diff as $key => $value) { |
| 2689 | - if ($globalDebug) echo 'Downloading vehicules model '.$key.' ...'."\n"; |
|
| 3300 | + if ($globalDebug) { |
|
| 3301 | + echo 'Downloading vehicules model '.$key.' ...'."\n"; |
|
| 3302 | + } |
|
| 2690 | 3303 | update_db::download('http://data.flightairmap.com/data/models/vehicules/'.$key,dirname(__FILE__).'/../models/vehicules/'.$key); |
| 2691 | 3304 | |
| 2692 | 3305 | } |
| 2693 | 3306 | update_db::download('http://data.flightairmap.com/data/models/vehicules/vehicules_models.md5sum',dirname(__FILE__).'/../models/vehicules/vehicules_models.md5sum'); |
| 2694 | - } else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed."; |
|
| 3307 | + } else { |
|
| 3308 | + $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed."; |
|
| 3309 | + } |
|
| 2695 | 3310 | if ($error != '') { |
| 2696 | 3311 | return $error; |
| 2697 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 3312 | + } elseif ($globalDebug) { |
|
| 3313 | + echo "Done\n"; |
|
| 3314 | + } |
|
| 2698 | 3315 | return ''; |
| 2699 | 3316 | } |
| 2700 | 3317 | |
@@ -2737,7 +3354,9 @@ discard block |
||
| 2737 | 3354 | } |
| 2738 | 3355 | |
| 2739 | 3356 | $error = ''; |
| 2740 | - if ($globalDebug) echo "Notam : Download..."; |
|
| 3357 | + if ($globalDebug) { |
|
| 3358 | + echo "Notam : Download..."; |
|
| 3359 | + } |
|
| 2741 | 3360 | update_db::download($globalNOTAMSource,$tmp_dir.'notam.rss'); |
| 2742 | 3361 | if (file_exists($tmp_dir.'notam.rss')) { |
| 2743 | 3362 | $notams = json_decode(json_encode(simplexml_load_file($tmp_dir.'notam.rss')),true); |
@@ -2752,14 +3371,30 @@ discard block |
||
| 2752 | 3371 | $data['fir'] = $q[0]; |
| 2753 | 3372 | $data['code'] = $q[1]; |
| 2754 | 3373 | $ifrvfr = $q[2]; |
| 2755 | - if ($ifrvfr == 'IV') $data['rules'] = 'IFR/VFR'; |
|
| 2756 | - if ($ifrvfr == 'I') $data['rules'] = 'IFR'; |
|
| 2757 | - if ($ifrvfr == 'V') $data['rules'] = 'VFR'; |
|
| 2758 | - if ($q[4] == 'A') $data['scope'] = 'Airport warning'; |
|
| 2759 | - if ($q[4] == 'E') $data['scope'] = 'Enroute warning'; |
|
| 2760 | - if ($q[4] == 'W') $data['scope'] = 'Navigation warning'; |
|
| 2761 | - if ($q[4] == 'AE') $data['scope'] = 'Airport/Enroute warning'; |
|
| 2762 | - if ($q[4] == 'AW') $data['scope'] = 'Airport/Navigation warning'; |
|
| 3374 | + if ($ifrvfr == 'IV') { |
|
| 3375 | + $data['rules'] = 'IFR/VFR'; |
|
| 3376 | + } |
|
| 3377 | + if ($ifrvfr == 'I') { |
|
| 3378 | + $data['rules'] = 'IFR'; |
|
| 3379 | + } |
|
| 3380 | + if ($ifrvfr == 'V') { |
|
| 3381 | + $data['rules'] = 'VFR'; |
|
| 3382 | + } |
|
| 3383 | + if ($q[4] == 'A') { |
|
| 3384 | + $data['scope'] = 'Airport warning'; |
|
| 3385 | + } |
|
| 3386 | + if ($q[4] == 'E') { |
|
| 3387 | + $data['scope'] = 'Enroute warning'; |
|
| 3388 | + } |
|
| 3389 | + if ($q[4] == 'W') { |
|
| 3390 | + $data['scope'] = 'Navigation warning'; |
|
| 3391 | + } |
|
| 3392 | + if ($q[4] == 'AE') { |
|
| 3393 | + $data['scope'] = 'Airport/Enroute warning'; |
|
| 3394 | + } |
|
| 3395 | + if ($q[4] == 'AW') { |
|
| 3396 | + $data['scope'] = 'Airport/Navigation warning'; |
|
| 3397 | + } |
|
| 2763 | 3398 | //$data['scope'] = $q[4]; |
| 2764 | 3399 | $data['lower_limit'] = $q[5]; |
| 2765 | 3400 | $data['upper_limit'] = $q[6]; |
@@ -2767,8 +3402,12 @@ discard block |
||
| 2767 | 3402 | sscanf($latlonrad,'%4c%c%5c%c%3d',$las,$lac,$lns,$lnc,$radius); |
| 2768 | 3403 | $latitude = $Common->convertDec($las,'latitude'); |
| 2769 | 3404 | $longitude = $Common->convertDec($lns,'longitude'); |
| 2770 | - if ($lac == 'S') $latitude = '-'.$latitude; |
|
| 2771 | - if ($lnc == 'W') $longitude = '-'.$longitude; |
|
| 3405 | + if ($lac == 'S') { |
|
| 3406 | + $latitude = '-'.$latitude; |
|
| 3407 | + } |
|
| 3408 | + if ($lnc == 'W') { |
|
| 3409 | + $longitude = '-'.$longitude; |
|
| 3410 | + } |
|
| 2772 | 3411 | $data['center_latitude'] = $latitude; |
| 2773 | 3412 | $data['center_longitude'] = $longitude; |
| 2774 | 3413 | $data['radius'] = intval($radius); |
@@ -2798,10 +3437,14 @@ discard block |
||
| 2798 | 3437 | $NOTAM->addNOTAM($data['ref'],$data['title'],'',$data['fir'],$data['code'],'',$data['scope'],$data['lower_limit'],$data['upper_limit'],$data['center_latitude'],$data['center_longitude'],$data['radius'],$data['date_begin'],$data['date_end'],$data['permanent'],$data['text'],$data['full_notam']); |
| 2799 | 3438 | unset($data); |
| 2800 | 3439 | } |
| 2801 | - } else $error = "File ".$tmp_dir.'notam.rss'." doesn't exist. Download failed."; |
|
| 3440 | + } else { |
|
| 3441 | + $error = "File ".$tmp_dir.'notam.rss'." doesn't exist. Download failed."; |
|
| 3442 | + } |
|
| 2802 | 3443 | if ($error != '') { |
| 2803 | 3444 | return $error; |
| 2804 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 3445 | + } elseif ($globalDebug) { |
|
| 3446 | + echo "Done\n"; |
|
| 3447 | + } |
|
| 2805 | 3448 | return ''; |
| 2806 | 3449 | } |
| 2807 | 3450 | |
@@ -2826,7 +3469,9 @@ discard block |
||
| 2826 | 3469 | $airspace_lst = $Common->getData('https://raw.githubusercontent.com/XCSoar/xcsoar-data-repository/master/data/airspace.json'); |
| 2827 | 3470 | $airspace_json = json_decode($airspace_lst,true); |
| 2828 | 3471 | foreach ($airspace_json['records'] as $airspace) { |
| 2829 | - if ($globalDebug) echo $airspace['name']."...\n"; |
|
| 3472 | + if ($globalDebug) { |
|
| 3473 | + echo $airspace['name']."...\n"; |
|
| 3474 | + } |
|
| 2830 | 3475 | update_db::download($airspace['uri'],$tmp_dir.$airspace['name']); |
| 2831 | 3476 | if (file_exists($tmp_dir.$airspace['name'])) { |
| 2832 | 3477 | file_put_contents($tmp_dir.$airspace['name'], utf8_encode(file_get_contents($tmp_dir.$airspace['name']))); |
@@ -2870,8 +3515,11 @@ discard block |
||
| 2870 | 3515 | return "error : ".$e->getMessage(); |
| 2871 | 3516 | } |
| 2872 | 3517 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
| 2873 | - if ($row['nb'] > 0) return false; |
|
| 2874 | - else return true; |
|
| 3518 | + if ($row['nb'] > 0) { |
|
| 3519 | + return false; |
|
| 3520 | + } else { |
|
| 3521 | + return true; |
|
| 3522 | + } |
|
| 2875 | 3523 | } |
| 2876 | 3524 | |
| 2877 | 3525 | public static function insert_last_update() { |
@@ -2896,8 +3544,11 @@ discard block |
||
| 2896 | 3544 | return "error : ".$e->getMessage(); |
| 2897 | 3545 | } |
| 2898 | 3546 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
| 2899 | - if ($row['nb'] > 0) return true; |
|
| 2900 | - else return false; |
|
| 3547 | + if ($row['nb'] > 0) { |
|
| 3548 | + return true; |
|
| 3549 | + } else { |
|
| 3550 | + return false; |
|
| 3551 | + } |
|
| 2901 | 3552 | } |
| 2902 | 3553 | |
| 2903 | 3554 | public static function check_geoid_version($version) { |
@@ -2910,8 +3561,11 @@ discard block |
||
| 2910 | 3561 | return "error : ".$e->getMessage(); |
| 2911 | 3562 | } |
| 2912 | 3563 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
| 2913 | - if ($row['nb'] > 0) return true; |
|
| 2914 | - else return false; |
|
| 3564 | + if ($row['nb'] > 0) { |
|
| 3565 | + return true; |
|
| 3566 | + } else { |
|
| 3567 | + return false; |
|
| 3568 | + } |
|
| 2915 | 3569 | } |
| 2916 | 3570 | |
| 2917 | 3571 | public static function check_marine_identity_version($version) { |
@@ -2924,8 +3578,11 @@ discard block |
||
| 2924 | 3578 | return "error : ".$e->getMessage(); |
| 2925 | 3579 | } |
| 2926 | 3580 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
| 2927 | - if ($row['nb'] > 0) return true; |
|
| 2928 | - else return false; |
|
| 3581 | + if ($row['nb'] > 0) { |
|
| 3582 | + return true; |
|
| 3583 | + } else { |
|
| 3584 | + return false; |
|
| 3585 | + } |
|
| 2929 | 3586 | } |
| 2930 | 3587 | |
| 2931 | 3588 | public static function check_satellite_version($version) { |
@@ -2938,8 +3595,11 @@ discard block |
||
| 2938 | 3595 | return "error : ".$e->getMessage(); |
| 2939 | 3596 | } |
| 2940 | 3597 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
| 2941 | - if ($row['nb'] > 0) return true; |
|
| 2942 | - else return false; |
|
| 3598 | + if ($row['nb'] > 0) { |
|
| 3599 | + return true; |
|
| 3600 | + } else { |
|
| 3601 | + return false; |
|
| 3602 | + } |
|
| 2943 | 3603 | } |
| 2944 | 3604 | |
| 2945 | 3605 | |
@@ -3006,8 +3666,11 @@ discard block |
||
| 3006 | 3666 | return "error : ".$e->getMessage(); |
| 3007 | 3667 | } |
| 3008 | 3668 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
| 3009 | - if ($row['nb'] > 0) return false; |
|
| 3010 | - else return true; |
|
| 3669 | + if ($row['nb'] > 0) { |
|
| 3670 | + return false; |
|
| 3671 | + } else { |
|
| 3672 | + return true; |
|
| 3673 | + } |
|
| 3011 | 3674 | } |
| 3012 | 3675 | |
| 3013 | 3676 | public static function insert_last_notam_update() { |
@@ -3037,8 +3700,11 @@ discard block |
||
| 3037 | 3700 | return "error : ".$e->getMessage(); |
| 3038 | 3701 | } |
| 3039 | 3702 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
| 3040 | - if ($row['nb'] > 0) return false; |
|
| 3041 | - else return true; |
|
| 3703 | + if ($row['nb'] > 0) { |
|
| 3704 | + return false; |
|
| 3705 | + } else { |
|
| 3706 | + return true; |
|
| 3707 | + } |
|
| 3042 | 3708 | } |
| 3043 | 3709 | |
| 3044 | 3710 | public static function insert_last_airspace_update() { |
@@ -3068,8 +3734,11 @@ discard block |
||
| 3068 | 3734 | return "error : ".$e->getMessage(); |
| 3069 | 3735 | } |
| 3070 | 3736 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
| 3071 | - if ($row['nb'] > 0) return false; |
|
| 3072 | - else return true; |
|
| 3737 | + if ($row['nb'] > 0) { |
|
| 3738 | + return false; |
|
| 3739 | + } else { |
|
| 3740 | + return true; |
|
| 3741 | + } |
|
| 3073 | 3742 | } |
| 3074 | 3743 | |
| 3075 | 3744 | public static function insert_last_geoid_update() { |
@@ -3099,8 +3768,11 @@ discard block |
||
| 3099 | 3768 | return "error : ".$e->getMessage(); |
| 3100 | 3769 | } |
| 3101 | 3770 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
| 3102 | - if ($row['nb'] > 0) return false; |
|
| 3103 | - else return true; |
|
| 3771 | + if ($row['nb'] > 0) { |
|
| 3772 | + return false; |
|
| 3773 | + } else { |
|
| 3774 | + return true; |
|
| 3775 | + } |
|
| 3104 | 3776 | } |
| 3105 | 3777 | |
| 3106 | 3778 | public static function insert_last_owner_update() { |
@@ -3129,8 +3801,11 @@ discard block |
||
| 3129 | 3801 | return "error : ".$e->getMessage(); |
| 3130 | 3802 | } |
| 3131 | 3803 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
| 3132 | - if ($row['nb'] > 0) return false; |
|
| 3133 | - else return true; |
|
| 3804 | + if ($row['nb'] > 0) { |
|
| 3805 | + return false; |
|
| 3806 | + } else { |
|
| 3807 | + return true; |
|
| 3808 | + } |
|
| 3134 | 3809 | } |
| 3135 | 3810 | |
| 3136 | 3811 | public static function insert_last_schedules_update() { |
@@ -3160,8 +3835,11 @@ discard block |
||
| 3160 | 3835 | return "error : ".$e->getMessage(); |
| 3161 | 3836 | } |
| 3162 | 3837 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
| 3163 | - if ($row['nb'] > 0) return false; |
|
| 3164 | - else return true; |
|
| 3838 | + if ($row['nb'] > 0) { |
|
| 3839 | + return false; |
|
| 3840 | + } else { |
|
| 3841 | + return true; |
|
| 3842 | + } |
|
| 3165 | 3843 | } |
| 3166 | 3844 | |
| 3167 | 3845 | public static function insert_last_tle_update() { |
@@ -3191,8 +3869,11 @@ discard block |
||
| 3191 | 3869 | return "error : ".$e->getMessage(); |
| 3192 | 3870 | } |
| 3193 | 3871 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
| 3194 | - if ($row['nb'] > 0) return false; |
|
| 3195 | - else return true; |
|
| 3872 | + if ($row['nb'] > 0) { |
|
| 3873 | + return false; |
|
| 3874 | + } else { |
|
| 3875 | + return true; |
|
| 3876 | + } |
|
| 3196 | 3877 | } |
| 3197 | 3878 | |
| 3198 | 3879 | public static function insert_last_ucsdb_update() { |
@@ -3222,8 +3903,11 @@ discard block |
||
| 3222 | 3903 | return "error : ".$e->getMessage(); |
| 3223 | 3904 | } |
| 3224 | 3905 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
| 3225 | - if ($row['nb'] > 0) return false; |
|
| 3226 | - else return true; |
|
| 3906 | + if ($row['nb'] > 0) { |
|
| 3907 | + return false; |
|
| 3908 | + } else { |
|
| 3909 | + return true; |
|
| 3910 | + } |
|
| 3227 | 3911 | } |
| 3228 | 3912 | |
| 3229 | 3913 | public static function insert_last_celestrak_update() { |
@@ -3253,8 +3937,11 @@ discard block |
||
| 3253 | 3937 | return "error : ".$e->getMessage(); |
| 3254 | 3938 | } |
| 3255 | 3939 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
| 3256 | - if ($row['nb'] > 0) return false; |
|
| 3257 | - else return true; |
|
| 3940 | + if ($row['nb'] > 0) { |
|
| 3941 | + return false; |
|
| 3942 | + } else { |
|
| 3943 | + return true; |
|
| 3944 | + } |
|
| 3258 | 3945 | } |
| 3259 | 3946 | |
| 3260 | 3947 | public static function check_last_satellite_update() { |
@@ -3272,8 +3959,11 @@ discard block |
||
| 3272 | 3959 | return "error : ".$e->getMessage(); |
| 3273 | 3960 | } |
| 3274 | 3961 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
| 3275 | - if ($row['nb'] > 0) return false; |
|
| 3276 | - else return true; |
|
| 3962 | + if ($row['nb'] > 0) { |
|
| 3963 | + return false; |
|
| 3964 | + } else { |
|
| 3965 | + return true; |
|
| 3966 | + } |
|
| 3277 | 3967 | } |
| 3278 | 3968 | |
| 3279 | 3969 | public static function insert_last_marine_identity_update() { |
@@ -13,10 +13,10 @@ discard block |
||
| 13 | 13 | |
| 14 | 14 | |
| 15 | 15 | /** |
| 16 | - * Get SQL query part for filter used |
|
| 17 | - * @param Array $filter the filter |
|
| 18 | - * @return Array the SQL part |
|
| 19 | - */ |
|
| 16 | + * Get SQL query part for filter used |
|
| 17 | + * @param Array $filter the filter |
|
| 18 | + * @return Array the SQL part |
|
| 19 | + */ |
|
| 20 | 20 | public function getFilter($filter = array(),$where = false,$and = false) { |
| 21 | 21 | global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver; |
| 22 | 22 | $filters = array(); |
@@ -129,11 +129,11 @@ discard block |
||
| 129 | 129 | } |
| 130 | 130 | |
| 131 | 131 | /** |
| 132 | - * Gets all the spotter information based on the latest data entry |
|
| 133 | - * |
|
| 134 | - * @return Array the spotter information |
|
| 135 | - * |
|
| 136 | - */ |
|
| 132 | + * Gets all the spotter information based on the latest data entry |
|
| 133 | + * |
|
| 134 | + * @return Array the spotter information |
|
| 135 | + * |
|
| 136 | + */ |
|
| 137 | 137 | public function getLiveSpotterData($limit = '', $sort = '', $filter = array()) |
| 138 | 138 | { |
| 139 | 139 | global $globalDBdriver, $globalLiveInterval; |
@@ -176,11 +176,11 @@ discard block |
||
| 176 | 176 | } |
| 177 | 177 | |
| 178 | 178 | /** |
| 179 | - * Gets Minimal Live Spotter data |
|
| 180 | - * |
|
| 181 | - * @return Array the spotter information |
|
| 182 | - * |
|
| 183 | - */ |
|
| 179 | + * Gets Minimal Live Spotter data |
|
| 180 | + * |
|
| 181 | + * @return Array the spotter information |
|
| 182 | + * |
|
| 183 | + */ |
|
| 184 | 184 | public function getMinLiveSpotterData($filter = array()) |
| 185 | 185 | { |
| 186 | 186 | global $globalDBdriver, $globalLiveInterval, $globalArchive; |
@@ -217,11 +217,11 @@ discard block |
||
| 217 | 217 | } |
| 218 | 218 | |
| 219 | 219 | /** |
| 220 | - * Gets Minimal Live Spotter data since xx seconds |
|
| 221 | - * |
|
| 222 | - * @return Array the spotter information |
|
| 223 | - * |
|
| 224 | - */ |
|
| 220 | + * Gets Minimal Live Spotter data since xx seconds |
|
| 221 | + * |
|
| 222 | + * @return Array the spotter information |
|
| 223 | + * |
|
| 224 | + */ |
|
| 225 | 225 | public function getMinLastLiveSpotterData($coord = array(),$filter = array(), $limit = false) |
| 226 | 226 | { |
| 227 | 227 | global $globalDBdriver, $globalLiveInterval, $globalArchive, $globalMap3DAircraftsLimit; |
@@ -302,11 +302,11 @@ discard block |
||
| 302 | 302 | } |
| 303 | 303 | |
| 304 | 304 | /** |
| 305 | - * Gets number of latest data entry |
|
| 306 | - * |
|
| 307 | - * @return String number of entry |
|
| 308 | - * |
|
| 309 | - */ |
|
| 305 | + * Gets number of latest data entry |
|
| 306 | + * |
|
| 307 | + * @return String number of entry |
|
| 308 | + * |
|
| 309 | + */ |
|
| 310 | 310 | public function getLiveSpotterCount($filter = array()) |
| 311 | 311 | { |
| 312 | 312 | global $globalDBdriver, $globalLiveInterval; |
@@ -333,11 +333,11 @@ discard block |
||
| 333 | 333 | } |
| 334 | 334 | |
| 335 | 335 | /** |
| 336 | - * Gets all the spotter information based on the latest data entry and coord |
|
| 337 | - * |
|
| 338 | - * @return Array the spotter information |
|
| 339 | - * |
|
| 340 | - */ |
|
| 336 | + * Gets all the spotter information based on the latest data entry and coord |
|
| 337 | + * |
|
| 338 | + * @return Array the spotter information |
|
| 339 | + * |
|
| 340 | + */ |
|
| 341 | 341 | public function getLiveSpotterDatabyCoord($coord, $filter = array()) |
| 342 | 342 | { |
| 343 | 343 | global $globalDBdriver, $globalLiveInterval; |
@@ -362,11 +362,11 @@ discard block |
||
| 362 | 362 | } |
| 363 | 363 | |
| 364 | 364 | /** |
| 365 | - * Gets all the spotter information based on the latest data entry and coord |
|
| 366 | - * |
|
| 367 | - * @return Array the spotter information |
|
| 368 | - * |
|
| 369 | - */ |
|
| 365 | + * Gets all the spotter information based on the latest data entry and coord |
|
| 366 | + * |
|
| 367 | + * @return Array the spotter information |
|
| 368 | + * |
|
| 369 | + */ |
|
| 370 | 370 | public function getMinLiveSpotterDatabyCoord($coord, $filter = array()) |
| 371 | 371 | { |
| 372 | 372 | global $globalDBdriver, $globalLiveInterval, $globalArchive; |
@@ -431,11 +431,11 @@ discard block |
||
| 431 | 431 | } |
| 432 | 432 | |
| 433 | 433 | /** |
| 434 | - * Gets all the spotter information based on a user's latitude and longitude |
|
| 435 | - * |
|
| 436 | - * @return Array the spotter information |
|
| 437 | - * |
|
| 438 | - */ |
|
| 434 | + * Gets all the spotter information based on a user's latitude and longitude |
|
| 435 | + * |
|
| 436 | + * @return Array the spotter information |
|
| 437 | + * |
|
| 438 | + */ |
|
| 439 | 439 | public function getLatestSpotterForLayar($lat, $lng, $radius, $interval) |
| 440 | 440 | { |
| 441 | 441 | $Spotter = new Spotter($this->db); |
@@ -445,98 +445,98 @@ discard block |
||
| 445 | 445 | return false; |
| 446 | 446 | } |
| 447 | 447 | } |
| 448 | - if ($lng != '') |
|
| 449 | - { |
|
| 450 | - if (!is_numeric($lng)) |
|
| 451 | - { |
|
| 452 | - return false; |
|
| 453 | - } |
|
| 454 | - } |
|
| 455 | - |
|
| 456 | - if ($radius != '') |
|
| 457 | - { |
|
| 458 | - if (!is_numeric($radius)) |
|
| 459 | - { |
|
| 460 | - return false; |
|
| 461 | - } |
|
| 462 | - } |
|
| 448 | + if ($lng != '') |
|
| 449 | + { |
|
| 450 | + if (!is_numeric($lng)) |
|
| 451 | + { |
|
| 452 | + return false; |
|
| 453 | + } |
|
| 454 | + } |
|
| 455 | + |
|
| 456 | + if ($radius != '') |
|
| 457 | + { |
|
| 458 | + if (!is_numeric($radius)) |
|
| 459 | + { |
|
| 460 | + return false; |
|
| 461 | + } |
|
| 462 | + } |
|
| 463 | 463 | $additional_query = ''; |
| 464 | - if ($interval != '') |
|
| 465 | - { |
|
| 466 | - if (!is_string($interval)) |
|
| 467 | - { |
|
| 468 | - //$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date '; |
|
| 469 | - return false; |
|
| 470 | - } else { |
|
| 471 | - if ($interval == '1m') |
|
| 472 | - { |
|
| 473 | - $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date '; |
|
| 474 | - } else if ($interval == '15m'){ |
|
| 475 | - $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 MINUTE) <= spotter_live.date '; |
|
| 476 | - } |
|
| 477 | - } |
|
| 478 | - } else { |
|
| 479 | - $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date '; |
|
| 480 | - } |
|
| 481 | - |
|
| 482 | - $query = "SELECT spotter_live.*, ( 6371 * acos( cos( radians(:lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(:lng) ) + sin( radians(:lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM spotter_live |
|
| 464 | + if ($interval != '') |
|
| 465 | + { |
|
| 466 | + if (!is_string($interval)) |
|
| 467 | + { |
|
| 468 | + //$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date '; |
|
| 469 | + return false; |
|
| 470 | + } else { |
|
| 471 | + if ($interval == '1m') |
|
| 472 | + { |
|
| 473 | + $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date '; |
|
| 474 | + } else if ($interval == '15m'){ |
|
| 475 | + $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 MINUTE) <= spotter_live.date '; |
|
| 476 | + } |
|
| 477 | + } |
|
| 478 | + } else { |
|
| 479 | + $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date '; |
|
| 480 | + } |
|
| 481 | + |
|
| 482 | + $query = "SELECT spotter_live.*, ( 6371 * acos( cos( radians(:lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(:lng) ) + sin( radians(:lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM spotter_live |
|
| 483 | 483 | WHERE spotter_live.latitude <> '' |
| 484 | 484 | AND spotter_live.longitude <> '' |
| 485 | 485 | ".$additional_query." |
| 486 | 486 | HAVING distance < :radius |
| 487 | 487 | ORDER BY distance"; |
| 488 | 488 | |
| 489 | - $spotter_array = $Spotter->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng,':radius' => $radius)); |
|
| 489 | + $spotter_array = $Spotter->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng,':radius' => $radius)); |
|
| 490 | 490 | |
| 491 | - return $spotter_array; |
|
| 492 | - } |
|
| 491 | + return $spotter_array; |
|
| 492 | + } |
|
| 493 | 493 | |
| 494 | 494 | |
| 495 | - /** |
|
| 496 | - * Gets all the spotter information based on a particular callsign |
|
| 497 | - * |
|
| 498 | - * @return Array the spotter information |
|
| 499 | - * |
|
| 500 | - */ |
|
| 495 | + /** |
|
| 496 | + * Gets all the spotter information based on a particular callsign |
|
| 497 | + * |
|
| 498 | + * @return Array the spotter information |
|
| 499 | + * |
|
| 500 | + */ |
|
| 501 | 501 | public function getLastLiveSpotterDataByIdent($ident) |
| 502 | 502 | { |
| 503 | 503 | $Spotter = new Spotter($this->db); |
| 504 | 504 | date_default_timezone_set('UTC'); |
| 505 | 505 | |
| 506 | 506 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 507 | - $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC'; |
|
| 507 | + $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC'; |
|
| 508 | 508 | |
| 509 | 509 | $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident),'',true); |
| 510 | 510 | |
| 511 | 511 | return $spotter_array; |
| 512 | 512 | } |
| 513 | 513 | |
| 514 | - /** |
|
| 515 | - * Gets all the spotter information based on a particular callsign |
|
| 516 | - * |
|
| 517 | - * @return Array the spotter information |
|
| 518 | - * |
|
| 519 | - */ |
|
| 514 | + /** |
|
| 515 | + * Gets all the spotter information based on a particular callsign |
|
| 516 | + * |
|
| 517 | + * @return Array the spotter information |
|
| 518 | + * |
|
| 519 | + */ |
|
| 520 | 520 | public function getDateLiveSpotterDataByIdent($ident,$date) |
| 521 | 521 | { |
| 522 | 522 | $Spotter = new Spotter($this->db); |
| 523 | 523 | date_default_timezone_set('UTC'); |
| 524 | 524 | |
| 525 | 525 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 526 | - $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC'; |
|
| 526 | + $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC'; |
|
| 527 | 527 | |
| 528 | - $date = date('c',$date); |
|
| 528 | + $date = date('c',$date); |
|
| 529 | 529 | $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident,':date' => $date)); |
| 530 | 530 | |
| 531 | 531 | return $spotter_array; |
| 532 | 532 | } |
| 533 | 533 | |
| 534 | - /** |
|
| 535 | - * Gets last spotter information based on a particular callsign |
|
| 536 | - * |
|
| 537 | - * @return Array the spotter information |
|
| 538 | - * |
|
| 539 | - */ |
|
| 534 | + /** |
|
| 535 | + * Gets last spotter information based on a particular callsign |
|
| 536 | + * |
|
| 537 | + * @return Array the spotter information |
|
| 538 | + * |
|
| 539 | + */ |
|
| 540 | 540 | public function getLastLiveSpotterDataById($id) |
| 541 | 541 | { |
| 542 | 542 | $Spotter = new Spotter($this->db); |
@@ -547,12 +547,12 @@ discard block |
||
| 547 | 547 | return $spotter_array; |
| 548 | 548 | } |
| 549 | 549 | |
| 550 | - /** |
|
| 551 | - * Gets last spotter information based on a particular callsign |
|
| 552 | - * |
|
| 553 | - * @return Array the spotter information |
|
| 554 | - * |
|
| 555 | - */ |
|
| 550 | + /** |
|
| 551 | + * Gets last spotter information based on a particular callsign |
|
| 552 | + * |
|
| 553 | + * @return Array the spotter information |
|
| 554 | + * |
|
| 555 | + */ |
|
| 556 | 556 | public function getDateLiveSpotterDataById($id,$date) |
| 557 | 557 | { |
| 558 | 558 | $Spotter = new Spotter($this->db); |
@@ -565,21 +565,21 @@ discard block |
||
| 565 | 565 | return $spotter_array; |
| 566 | 566 | } |
| 567 | 567 | |
| 568 | - /** |
|
| 569 | - * Gets altitude information based on a particular callsign |
|
| 570 | - * |
|
| 571 | - * @return Array the spotter information |
|
| 572 | - * |
|
| 573 | - */ |
|
| 568 | + /** |
|
| 569 | + * Gets altitude information based on a particular callsign |
|
| 570 | + * |
|
| 571 | + * @return Array the spotter information |
|
| 572 | + * |
|
| 573 | + */ |
|
| 574 | 574 | public function getAltitudeLiveSpotterDataByIdent($ident) |
| 575 | 575 | { |
| 576 | 576 | |
| 577 | 577 | date_default_timezone_set('UTC'); |
| 578 | 578 | |
| 579 | 579 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 580 | - $query = 'SELECT spotter_live.altitude, spotter_live.date FROM spotter_live WHERE spotter_live.ident = :ident'; |
|
| 580 | + $query = 'SELECT spotter_live.altitude, spotter_live.date FROM spotter_live WHERE spotter_live.ident = :ident'; |
|
| 581 | 581 | |
| 582 | - try { |
|
| 582 | + try { |
|
| 583 | 583 | |
| 584 | 584 | $sth = $this->db->prepare($query); |
| 585 | 585 | $sth->execute(array(':ident' => $ident)); |
@@ -592,12 +592,12 @@ discard block |
||
| 592 | 592 | return $spotter_array; |
| 593 | 593 | } |
| 594 | 594 | |
| 595 | - /** |
|
| 596 | - * Gets all the spotter information based on a particular id |
|
| 597 | - * |
|
| 598 | - * @return Array the spotter information |
|
| 599 | - * |
|
| 600 | - */ |
|
| 595 | + /** |
|
| 596 | + * Gets all the spotter information based on a particular id |
|
| 597 | + * |
|
| 598 | + * @return Array the spotter information |
|
| 599 | + * |
|
| 600 | + */ |
|
| 601 | 601 | public function getAllLiveSpotterDataById($id,$liveinterval = false) |
| 602 | 602 | { |
| 603 | 603 | global $globalDBdriver, $globalLiveInterval; |
@@ -625,18 +625,18 @@ discard block |
||
| 625 | 625 | return $spotter_array; |
| 626 | 626 | } |
| 627 | 627 | |
| 628 | - /** |
|
| 629 | - * Gets all the spotter information based on a particular ident |
|
| 630 | - * |
|
| 631 | - * @return Array the spotter information |
|
| 632 | - * |
|
| 633 | - */ |
|
| 628 | + /** |
|
| 629 | + * Gets all the spotter information based on a particular ident |
|
| 630 | + * |
|
| 631 | + * @return Array the spotter information |
|
| 632 | + * |
|
| 633 | + */ |
|
| 634 | 634 | public function getAllLiveSpotterDataByIdent($ident) |
| 635 | 635 | { |
| 636 | 636 | date_default_timezone_set('UTC'); |
| 637 | 637 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 638 | 638 | $query = self::$global_query.' WHERE spotter_live.ident = :ident'; |
| 639 | - try { |
|
| 639 | + try { |
|
| 640 | 640 | |
| 641 | 641 | $sth = $this->db->prepare($query); |
| 642 | 642 | $sth->execute(array(':ident' => $ident)); |
@@ -650,23 +650,23 @@ discard block |
||
| 650 | 650 | |
| 651 | 651 | |
| 652 | 652 | /** |
| 653 | - * Deletes all info in the table |
|
| 654 | - * |
|
| 655 | - * @return String success or false |
|
| 656 | - * |
|
| 657 | - */ |
|
| 653 | + * Deletes all info in the table |
|
| 654 | + * |
|
| 655 | + * @return String success or false |
|
| 656 | + * |
|
| 657 | + */ |
|
| 658 | 658 | public function deleteLiveSpotterData() |
| 659 | 659 | { |
| 660 | 660 | global $globalDBdriver; |
| 661 | 661 | if ($globalDBdriver == 'mysql') { |
| 662 | 662 | //$query = "DELETE FROM spotter_live WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 MINUTE) >= spotter_live.date"; |
| 663 | 663 | $query = 'DELETE FROM spotter_live WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 9 HOUR) >= spotter_live.date'; |
| 664 | - //$query = "DELETE FROM spotter_live WHERE spotter_live.id IN (SELECT spotter_live.id FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) >= spotter_live.date)"; |
|
| 664 | + //$query = "DELETE FROM spotter_live WHERE spotter_live.id IN (SELECT spotter_live.id FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) >= spotter_live.date)"; |
|
| 665 | 665 | } else { |
| 666 | 666 | $query = "DELETE FROM spotter_live WHERE NOW() AT TIME ZONE 'UTC' - INTERVAL '9 HOURS' >= spotter_live.date"; |
| 667 | 667 | } |
| 668 | 668 | |
| 669 | - try { |
|
| 669 | + try { |
|
| 670 | 670 | |
| 671 | 671 | $sth = $this->db->prepare($query); |
| 672 | 672 | $sth->execute(); |
@@ -678,18 +678,18 @@ discard block |
||
| 678 | 678 | } |
| 679 | 679 | |
| 680 | 680 | /** |
| 681 | - * Deletes all info in the table for aircraft not seen since 2 HOUR |
|
| 682 | - * |
|
| 683 | - * @return String success or false |
|
| 684 | - * |
|
| 685 | - */ |
|
| 681 | + * Deletes all info in the table for aircraft not seen since 2 HOUR |
|
| 682 | + * |
|
| 683 | + * @return String success or false |
|
| 684 | + * |
|
| 685 | + */ |
|
| 686 | 686 | public function deleteLiveSpotterDataNotUpdated() |
| 687 | 687 | { |
| 688 | 688 | global $globalDBdriver, $globalDebug; |
| 689 | 689 | if ($globalDBdriver == 'mysql') { |
| 690 | 690 | //$query = 'SELECT flightaware_id FROM spotter_live WHERE DATE_SUB(UTC_TIMESTAMP(), INTERVAL 1 HOUR) >= spotter_live.date AND spotter_live.flightaware_id NOT IN (SELECT flightaware_id FROM spotter_live WHERE DATE_SUB(UTC_TIMESTAMP(), INTERVAL 1 HOUR) < spotter_live.date) LIMIT 800 OFFSET 0'; |
| 691 | - $query = "SELECT spotter_live.flightaware_id FROM spotter_live INNER JOIN (SELECT flightaware_id,MAX(date) as max_date FROM spotter_live GROUP BY flightaware_id) s ON s.flightaware_id = spotter_live.flightaware_id AND DATE_SUB(UTC_TIMESTAMP(), INTERVAL 2 HOUR) >= s.max_date LIMIT 2000 OFFSET 0"; |
|
| 692 | - try { |
|
| 691 | + $query = "SELECT spotter_live.flightaware_id FROM spotter_live INNER JOIN (SELECT flightaware_id,MAX(date) as max_date FROM spotter_live GROUP BY flightaware_id) s ON s.flightaware_id = spotter_live.flightaware_id AND DATE_SUB(UTC_TIMESTAMP(), INTERVAL 2 HOUR) >= s.max_date LIMIT 2000 OFFSET 0"; |
|
| 692 | + try { |
|
| 693 | 693 | |
| 694 | 694 | $sth = $this->db->prepare($query); |
| 695 | 695 | $sth->execute(); |
@@ -697,8 +697,8 @@ discard block |
||
| 697 | 697 | return "error"; |
| 698 | 698 | } |
| 699 | 699 | $query_delete = 'DELETE FROM spotter_live WHERE flightaware_id IN ('; |
| 700 | - $i = 0; |
|
| 701 | - $j =0; |
|
| 700 | + $i = 0; |
|
| 701 | + $j =0; |
|
| 702 | 702 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 703 | 703 | foreach($all as $row) |
| 704 | 704 | { |
@@ -706,20 +706,20 @@ discard block |
||
| 706 | 706 | $j++; |
| 707 | 707 | if ($j == 30) { |
| 708 | 708 | if ($globalDebug) echo "."; |
| 709 | - try { |
|
| 709 | + try { |
|
| 710 | 710 | |
| 711 | 711 | $sth = $this->db->prepare(substr($query_delete,0,-1).")"); |
| 712 | 712 | $sth->execute(); |
| 713 | 713 | } catch(PDOException $e) { |
| 714 | 714 | return "error"; |
| 715 | 715 | } |
| 716 | - $query_delete = 'DELETE FROM spotter_live WHERE flightaware_id IN ('; |
|
| 717 | - $j = 0; |
|
| 716 | + $query_delete = 'DELETE FROM spotter_live WHERE flightaware_id IN ('; |
|
| 717 | + $j = 0; |
|
| 718 | 718 | } |
| 719 | 719 | $query_delete .= "'".$row['flightaware_id']."',"; |
| 720 | 720 | } |
| 721 | 721 | if ($i > 0) { |
| 722 | - try { |
|
| 722 | + try { |
|
| 723 | 723 | |
| 724 | 724 | $sth = $this->db->prepare(substr($query_delete,0,-1).")"); |
| 725 | 725 | $sth->execute(); |
@@ -730,9 +730,9 @@ discard block |
||
| 730 | 730 | return "success"; |
| 731 | 731 | } elseif ($globalDBdriver == 'pgsql') { |
| 732 | 732 | //$query = "SELECT flightaware_id FROM spotter_live WHERE NOW() AT TIME ZONE 'UTC' - INTERVAL '9 HOURS' >= spotter_live.date AND spotter_live.flightaware_id NOT IN (SELECT flightaware_id FROM spotter_live WHERE NOW() AT TIME ZONE 'UTC' - INTERVAL '9 HOURS' < spotter_live.date) LIMIT 800 OFFSET 0"; |
| 733 | - //$query = "SELECT spotter_live.flightaware_id FROM spotter_live INNER JOIN (SELECT flightaware_id,MAX(date) as max_date FROM spotter_live GROUP BY flightaware_id) s ON s.flightaware_id = spotter_live.flightaware_id AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 800 OFFSET 0"; |
|
| 734 | - $query = "DELETE FROM spotter_live WHERE flightaware_id IN (SELECT spotter_live.flightaware_id FROM spotter_live INNER JOIN (SELECT flightaware_id,MAX(date) as max_date FROM spotter_live GROUP BY flightaware_id) s ON s.flightaware_id = spotter_live.flightaware_id AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 2000 OFFSET 0)"; |
|
| 735 | - try { |
|
| 733 | + //$query = "SELECT spotter_live.flightaware_id FROM spotter_live INNER JOIN (SELECT flightaware_id,MAX(date) as max_date FROM spotter_live GROUP BY flightaware_id) s ON s.flightaware_id = spotter_live.flightaware_id AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 800 OFFSET 0"; |
|
| 734 | + $query = "DELETE FROM spotter_live WHERE flightaware_id IN (SELECT spotter_live.flightaware_id FROM spotter_live INNER JOIN (SELECT flightaware_id,MAX(date) as max_date FROM spotter_live GROUP BY flightaware_id) s ON s.flightaware_id = spotter_live.flightaware_id AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 2000 OFFSET 0)"; |
|
| 735 | + try { |
|
| 736 | 736 | |
| 737 | 737 | $sth = $this->db->prepare($query); |
| 738 | 738 | $sth->execute(); |
@@ -776,17 +776,17 @@ discard block |
||
| 776 | 776 | } |
| 777 | 777 | |
| 778 | 778 | /** |
| 779 | - * Deletes all info in the table for an ident |
|
| 780 | - * |
|
| 781 | - * @return String success or false |
|
| 782 | - * |
|
| 783 | - */ |
|
| 779 | + * Deletes all info in the table for an ident |
|
| 780 | + * |
|
| 781 | + * @return String success or false |
|
| 782 | + * |
|
| 783 | + */ |
|
| 784 | 784 | public function deleteLiveSpotterDataByIdent($ident) |
| 785 | 785 | { |
| 786 | 786 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 787 | 787 | $query = 'DELETE FROM spotter_live WHERE ident = :ident'; |
| 788 | 788 | |
| 789 | - try { |
|
| 789 | + try { |
|
| 790 | 790 | |
| 791 | 791 | $sth = $this->db->prepare($query); |
| 792 | 792 | $sth->execute(array(':ident' => $ident)); |
@@ -798,17 +798,17 @@ discard block |
||
| 798 | 798 | } |
| 799 | 799 | |
| 800 | 800 | /** |
| 801 | - * Deletes all info in the table for an id |
|
| 802 | - * |
|
| 803 | - * @return String success or false |
|
| 804 | - * |
|
| 805 | - */ |
|
| 801 | + * Deletes all info in the table for an id |
|
| 802 | + * |
|
| 803 | + * @return String success or false |
|
| 804 | + * |
|
| 805 | + */ |
|
| 806 | 806 | public function deleteLiveSpotterDataById($id) |
| 807 | 807 | { |
| 808 | 808 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
| 809 | 809 | $query = 'DELETE FROM spotter_live WHERE flightaware_id = :id'; |
| 810 | 810 | |
| 811 | - try { |
|
| 811 | + try { |
|
| 812 | 812 | |
| 813 | 813 | $sth = $this->db->prepare($query); |
| 814 | 814 | $sth->execute(array(':id' => $id)); |
@@ -821,11 +821,11 @@ discard block |
||
| 821 | 821 | |
| 822 | 822 | |
| 823 | 823 | /** |
| 824 | - * Gets the aircraft ident within the last hour |
|
| 825 | - * |
|
| 826 | - * @return String the ident |
|
| 827 | - * |
|
| 828 | - */ |
|
| 824 | + * Gets the aircraft ident within the last hour |
|
| 825 | + * |
|
| 826 | + * @return String the ident |
|
| 827 | + * |
|
| 828 | + */ |
|
| 829 | 829 | public function getIdentFromLastHour($ident) |
| 830 | 830 | { |
| 831 | 831 | global $globalDBdriver, $globalTimezone; |
@@ -851,14 +851,14 @@ discard block |
||
| 851 | 851 | $ident_result = $row['ident']; |
| 852 | 852 | } |
| 853 | 853 | return $ident_result; |
| 854 | - } |
|
| 854 | + } |
|
| 855 | 855 | |
| 856 | 856 | /** |
| 857 | - * Check recent aircraft |
|
| 858 | - * |
|
| 859 | - * @return String the ident |
|
| 860 | - * |
|
| 861 | - */ |
|
| 857 | + * Check recent aircraft |
|
| 858 | + * |
|
| 859 | + * @return String the ident |
|
| 860 | + * |
|
| 861 | + */ |
|
| 862 | 862 | public function checkIdentRecent($ident) |
| 863 | 863 | { |
| 864 | 864 | global $globalDBdriver, $globalTimezone; |
@@ -884,14 +884,14 @@ discard block |
||
| 884 | 884 | $ident_result = $row['flightaware_id']; |
| 885 | 885 | } |
| 886 | 886 | return $ident_result; |
| 887 | - } |
|
| 887 | + } |
|
| 888 | 888 | |
| 889 | 889 | /** |
| 890 | - * Check recent aircraft by id |
|
| 891 | - * |
|
| 892 | - * @return String the ident |
|
| 893 | - * |
|
| 894 | - */ |
|
| 890 | + * Check recent aircraft by id |
|
| 891 | + * |
|
| 892 | + * @return String the ident |
|
| 893 | + * |
|
| 894 | + */ |
|
| 895 | 895 | public function checkIdRecent($id) |
| 896 | 896 | { |
| 897 | 897 | global $globalDBdriver, $globalTimezone; |
@@ -917,14 +917,14 @@ discard block |
||
| 917 | 917 | $ident_result = $row['flightaware_id']; |
| 918 | 918 | } |
| 919 | 919 | return $ident_result; |
| 920 | - } |
|
| 920 | + } |
|
| 921 | 921 | |
| 922 | 922 | /** |
| 923 | - * Check recent aircraft by ModeS |
|
| 924 | - * |
|
| 925 | - * @return String the ModeS |
|
| 926 | - * |
|
| 927 | - */ |
|
| 923 | + * Check recent aircraft by ModeS |
|
| 924 | + * |
|
| 925 | + * @return String the ModeS |
|
| 926 | + * |
|
| 927 | + */ |
|
| 928 | 928 | public function checkModeSRecent($modes) |
| 929 | 929 | { |
| 930 | 930 | global $globalDBdriver, $globalTimezone; |
@@ -951,19 +951,19 @@ discard block |
||
| 951 | 951 | $ident_result = $row['flightaware_id']; |
| 952 | 952 | } |
| 953 | 953 | return $ident_result; |
| 954 | - } |
|
| 954 | + } |
|
| 955 | 955 | |
| 956 | 956 | /** |
| 957 | - * Adds a new spotter data |
|
| 958 | - * |
|
| 959 | - * @param String $flightaware_id the ID from flightaware |
|
| 960 | - * @param String $ident the flight ident |
|
| 961 | - * @param String $aircraft_icao the aircraft type |
|
| 962 | - * @param String $departure_airport_icao the departure airport |
|
| 963 | - * @param String $arrival_airport_icao the arrival airport |
|
| 964 | - * @return String success or false |
|
| 965 | - * |
|
| 966 | - */ |
|
| 957 | + * Adds a new spotter data |
|
| 958 | + * |
|
| 959 | + * @param String $flightaware_id the ID from flightaware |
|
| 960 | + * @param String $ident the flight ident |
|
| 961 | + * @param String $aircraft_icao the aircraft type |
|
| 962 | + * @param String $departure_airport_icao the departure airport |
|
| 963 | + * @param String $arrival_airport_icao the arrival airport |
|
| 964 | + * @return String success or false |
|
| 965 | + * |
|
| 966 | + */ |
|
| 967 | 967 | public function addLiveSpotterData($flightaware_id = '', $ident = '', $aircraft_icao = '', $departure_airport_icao = '', $arrival_airport_icao = '', $latitude = '', $longitude = '', $waypoints = '', $altitude = '', $altitude_real = '',$heading = '', $groundspeed = '', $date = '',$departure_airport_time = '', $arrival_airport_time = '', $squawk = '', $route_stop = '', $ModeS = '', $putinarchive = false,$registration = '',$pilot_id = '', $pilot_name = '', $verticalrate = '', $noarchive = false, $ground = false,$format_source = '', $source_name = '', $over_country = '') |
| 968 | 968 | { |
| 969 | 969 | global $globalURL, $globalArchive, $globalDebug; |
@@ -1106,10 +1106,10 @@ discard block |
||
| 1106 | 1106 | $arrival_airport_country = ''; |
| 1107 | 1107 | |
| 1108 | 1108 | |
| 1109 | - if ($squawk == '' || $Common->isInteger($squawk) === false ) $squawk = NULL; |
|
| 1110 | - if ($verticalrate == '' || $Common->isInteger($verticalrate) === false ) $verticalrate = NULL; |
|
| 1111 | - if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0; |
|
| 1112 | - if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0; |
|
| 1109 | + if ($squawk == '' || $Common->isInteger($squawk) === false ) $squawk = NULL; |
|
| 1110 | + if ($verticalrate == '' || $Common->isInteger($verticalrate) === false ) $verticalrate = NULL; |
|
| 1111 | + if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0; |
|
| 1112 | + if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0; |
|
| 1113 | 1113 | |
| 1114 | 1114 | $query = ''; |
| 1115 | 1115 | if ($globalArchive) { |
@@ -1130,10 +1130,10 @@ discard block |
||
| 1130 | 1130 | return "error : ".$e->getMessage(); |
| 1131 | 1131 | } |
| 1132 | 1132 | if (isset($globalArchive) && $globalArchive && $putinarchive && $noarchive !== true) { |
| 1133 | - if ($globalDebug) echo '(Add to SBS archive : '; |
|
| 1134 | - $SpotterArchive = new SpotterArchive($this->db); |
|
| 1135 | - $result = $SpotterArchive->addSpotterArchiveData($flightaware_id, $ident, $registration, $airline_name, $airline_icao, $airline_country, $airline_type, $aircraft_icao, $aircraft_shadow, $aircraft_name, $aircraft_manufacturer, $departure_airport_icao, $departure_airport_name, $departure_airport_city, $departure_airport_country, $departure_airport_time,$arrival_airport_icao, $arrival_airport_name, $arrival_airport_city, $arrival_airport_country, $arrival_airport_time, $route_stop, $date,$latitude, $longitude, $waypoints, $altitude, $altitude_real,$heading, $groundspeed, $squawk, $ModeS, $pilot_id, $pilot_name,$verticalrate,$format_source,$source_name, $over_country); |
|
| 1136 | - if ($globalDebug) echo $result.')'; |
|
| 1133 | + if ($globalDebug) echo '(Add to SBS archive : '; |
|
| 1134 | + $SpotterArchive = new SpotterArchive($this->db); |
|
| 1135 | + $result = $SpotterArchive->addSpotterArchiveData($flightaware_id, $ident, $registration, $airline_name, $airline_icao, $airline_country, $airline_type, $aircraft_icao, $aircraft_shadow, $aircraft_name, $aircraft_manufacturer, $departure_airport_icao, $departure_airport_name, $departure_airport_city, $departure_airport_country, $departure_airport_time,$arrival_airport_icao, $arrival_airport_name, $arrival_airport_city, $arrival_airport_country, $arrival_airport_time, $route_stop, $date,$latitude, $longitude, $waypoints, $altitude, $altitude_real,$heading, $groundspeed, $squawk, $ModeS, $pilot_id, $pilot_name,$verticalrate,$format_source,$source_name, $over_country); |
|
| 1136 | + if ($globalDebug) echo $result.')'; |
|
| 1137 | 1137 | } elseif ($globalDebug && $putinarchive !== true) { |
| 1138 | 1138 | echo '(Not adding to archive)'; |
| 1139 | 1139 | } elseif ($globalDebug && $noarchive === true) { |
@@ -17,62 +17,62 @@ discard block |
||
| 17 | 17 | * @param Array $filter the filter |
| 18 | 18 | * @return Array the SQL part |
| 19 | 19 | */ |
| 20 | - public function getFilter($filter = array(),$where = false,$and = false) { |
|
| 20 | + public function getFilter($filter = array(), $where = false, $and = false) { |
|
| 21 | 21 | global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver; |
| 22 | 22 | $filters = array(); |
| 23 | 23 | if (is_array($globalStatsFilters) && isset($globalStatsFilters[$globalFilterName])) { |
| 24 | 24 | if (isset($globalStatsFilters[$globalFilterName][0]['source'])) { |
| 25 | 25 | $filters = $globalStatsFilters[$globalFilterName]; |
| 26 | 26 | } else { |
| 27 | - $filter = array_merge($filter,$globalStatsFilters[$globalFilterName]); |
|
| 27 | + $filter = array_merge($filter, $globalStatsFilters[$globalFilterName]); |
|
| 28 | 28 | } |
| 29 | 29 | } |
| 30 | 30 | if (isset($filter[0]['source'])) { |
| 31 | - $filters = array_merge($filters,$filter); |
|
| 31 | + $filters = array_merge($filters, $filter); |
|
| 32 | 32 | } |
| 33 | - if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter); |
|
| 33 | + if (is_array($globalFilter)) $filter = array_merge($filter, $globalFilter); |
|
| 34 | 34 | $filter_query_join = ''; |
| 35 | 35 | $filter_query_where = ''; |
| 36 | - foreach($filters as $flt) { |
|
| 36 | + foreach ($filters as $flt) { |
|
| 37 | 37 | if (isset($flt['airlines']) && !empty($flt['airlines'])) { |
| 38 | 38 | if ($flt['airlines'][0] != '') { |
| 39 | 39 | if (isset($flt['source'])) { |
| 40 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','",$flt['airlines'])."') AND spotter_output.format_source IN ('".implode("','",$flt['source'])."')) saf ON saf.flightaware_id = spotter_live.flightaware_id"; |
|
| 40 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','", $flt['airlines'])."') AND spotter_output.format_source IN ('".implode("','", $flt['source'])."')) saf ON saf.flightaware_id = spotter_live.flightaware_id"; |
|
| 41 | 41 | } else { |
| 42 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','",$flt['airlines'])."')) saf ON saf.flightaware_id = spotter_live.flightaware_id"; |
|
| 42 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','", $flt['airlines'])."')) saf ON saf.flightaware_id = spotter_live.flightaware_id"; |
|
| 43 | 43 | } |
| 44 | 44 | } |
| 45 | 45 | } |
| 46 | 46 | if (isset($flt['pilots_id']) && !empty($flt['pilots_id'])) { |
| 47 | 47 | if (isset($flt['source'])) { |
| 48 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.pilot_id IN ('".implode("','",$flt['pilots_id'])."') AND spotter_output.format_source IN ('".implode("','",$flt['source'])."')) spi ON spi.flightaware_id = spotter_live.flightaware_id"; |
|
| 48 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.pilot_id IN ('".implode("','", $flt['pilots_id'])."') AND spotter_output.format_source IN ('".implode("','", $flt['source'])."')) spi ON spi.flightaware_id = spotter_live.flightaware_id"; |
|
| 49 | 49 | } else { |
| 50 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.pilot_id IN ('".implode("','",$flt['pilots_id'])."')) spi ON spi.flightaware_id = spotter_live.flightaware_id"; |
|
| 50 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.pilot_id IN ('".implode("','", $flt['pilots_id'])."')) spi ON spi.flightaware_id = spotter_live.flightaware_id"; |
|
| 51 | 51 | } |
| 52 | 52 | } |
| 53 | 53 | if (isset($flt['idents']) && !empty($flt['idents'])) { |
| 54 | 54 | if (isset($flt['source'])) { |
| 55 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.ident IN ('".implode("','",$flt['idents'])."') AND spotter_output.format_source IN ('".implode("','",$flt['source'])."')) spid ON spid.flightaware_id = spotter_live.flightaware_id"; |
|
| 55 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.ident IN ('".implode("','", $flt['idents'])."') AND spotter_output.format_source IN ('".implode("','", $flt['source'])."')) spid ON spid.flightaware_id = spotter_live.flightaware_id"; |
|
| 56 | 56 | } else { |
| 57 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.ident IN ('".implode("','",$flt['idents'])."')) spid ON spid.flightaware_id = spotter_live.flightaware_id"; |
|
| 57 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.ident IN ('".implode("','", $flt['idents'])."')) spid ON spid.flightaware_id = spotter_live.flightaware_id"; |
|
| 58 | 58 | } |
| 59 | 59 | } |
| 60 | 60 | if (isset($flt['registrations']) && !empty($flt['registrations'])) { |
| 61 | 61 | if (isset($flt['source'])) { |
| 62 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.registration IN ('".implode("','",$flt['registrations'])."') AND spotter_output.format_source IN ('".implode("','",$flt['source'])."')) sre ON sre.flightaware_id = spotter_live.flightaware_id"; |
|
| 62 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.registration IN ('".implode("','", $flt['registrations'])."') AND spotter_output.format_source IN ('".implode("','", $flt['source'])."')) sre ON sre.flightaware_id = spotter_live.flightaware_id"; |
|
| 63 | 63 | } else { |
| 64 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.registration IN ('".implode("','",$flt['registrations'])."')) sre ON sre.flightaware_id = spotter_live.flightaware_id"; |
|
| 64 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.registration IN ('".implode("','", $flt['registrations'])."')) sre ON sre.flightaware_id = spotter_live.flightaware_id"; |
|
| 65 | 65 | } |
| 66 | 66 | } |
| 67 | 67 | if ((isset($flt['airlines']) && empty($flt['airlines']) && isset($flt['pilots_id']) && empty($flt['pilots_id']) && isset($flt['idents']) && empty($flt['idents'])) || (!isset($flt['airlines']) && !isset($flt['pilots_id']) && !isset($flt['idents']) && !isset($flt['registrations']))) { |
| 68 | 68 | if (isset($flt['source'])) { |
| 69 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.format_source IN ('".implode("','",$flt['source'])."')) ssf ON ssf.flightaware_id = spotter_live.flightaware_id"; |
|
| 69 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.format_source IN ('".implode("','", $flt['source'])."')) ssf ON ssf.flightaware_id = spotter_live.flightaware_id"; |
|
| 70 | 70 | } |
| 71 | 71 | } |
| 72 | 72 | } |
| 73 | 73 | if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
| 74 | 74 | if ($filter['airlines'][0] != '') { |
| 75 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) sai ON sai.flightaware_id = spotter_live.flightaware_id"; |
|
| 75 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','", $filter['airlines'])."')) sai ON sai.flightaware_id = spotter_live.flightaware_id"; |
|
| 76 | 76 | } |
| 77 | 77 | } |
| 78 | 78 | if (isset($filter['alliance']) && !empty($filter['alliance'])) { |
@@ -82,10 +82,10 @@ discard block |
||
| 82 | 82 | $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_live.flightaware_id "; |
| 83 | 83 | } |
| 84 | 84 | if (isset($filter['pilots_id']) && !empty($filter['pilots_id'])) { |
| 85 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.pilot_id IN ('".implode("','",$filter['pilots_id'])."')) sp ON sp.flightaware_id = spotter_live.flightaware_id"; |
|
| 85 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.pilot_id IN ('".implode("','", $filter['pilots_id'])."')) sp ON sp.flightaware_id = spotter_live.flightaware_id"; |
|
| 86 | 86 | } |
| 87 | 87 | if (isset($filter['source']) && !empty($filter['source'])) { |
| 88 | - $filter_query_where .= " AND format_source IN ('".implode("','",$filter['source'])."')"; |
|
| 88 | + $filter_query_where .= " AND format_source IN ('".implode("','", $filter['source'])."')"; |
|
| 89 | 89 | } |
| 90 | 90 | if (isset($filter['ident']) && !empty($filter['ident'])) { |
| 91 | 91 | $filter_query_where .= " AND ident = '".$filter['ident']."'"; |
@@ -114,15 +114,15 @@ discard block |
||
| 114 | 114 | $filter_query_date .= " AND EXTRACT(DAY FROM spotter_output.date) = '".$filter['day']."'"; |
| 115 | 115 | } |
| 116 | 116 | } |
| 117 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output".preg_replace('/^ AND/',' WHERE',$filter_query_date).") sd ON sd.flightaware_id = spotter_live.flightaware_id"; |
|
| 117 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output".preg_replace('/^ AND/', ' WHERE', $filter_query_date).") sd ON sd.flightaware_id = spotter_live.flightaware_id"; |
|
| 118 | 118 | } |
| 119 | 119 | if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
| 120 | - $filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
| 120 | + $filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')"; |
|
| 121 | 121 | } |
| 122 | 122 | if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE'; |
| 123 | 123 | elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND'; |
| 124 | 124 | if ($filter_query_where != '') { |
| 125 | - $filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where); |
|
| 125 | + $filter_query_where = preg_replace('/^ AND/', ' WHERE', $filter_query_where); |
|
| 126 | 126 | } |
| 127 | 127 | $filter_query = $filter_query_join.$filter_query_where; |
| 128 | 128 | return $filter_query; |
@@ -145,8 +145,8 @@ discard block |
||
| 145 | 145 | if ($limit != '') |
| 146 | 146 | { |
| 147 | 147 | $limit_array = explode(',', $limit); |
| 148 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 149 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 148 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
| 149 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
| 150 | 150 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
| 151 | 151 | { |
| 152 | 152 | $limit_query = ' LIMIT '.$limit_array[1].' OFFSET '.$limit_array[0]; |
@@ -170,7 +170,7 @@ discard block |
||
| 170 | 170 | } else { |
| 171 | 171 | $query = "SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate".$filter_query.$orderby_query; |
| 172 | 172 | } |
| 173 | - $spotter_array = $Spotter->getDataFromDB($query.$limit_query,array(),'',true); |
|
| 173 | + $spotter_array = $Spotter->getDataFromDB($query.$limit_query, array(), '', true); |
|
| 174 | 174 | |
| 175 | 175 | return $spotter_array; |
| 176 | 176 | } |
@@ -185,7 +185,7 @@ discard block |
||
| 185 | 185 | { |
| 186 | 186 | global $globalDBdriver, $globalLiveInterval, $globalArchive; |
| 187 | 187 | date_default_timezone_set('UTC'); |
| 188 | - $filter_query = $this->getFilter($filter,true,true); |
|
| 188 | + $filter_query = $this->getFilter($filter, true, true); |
|
| 189 | 189 | if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
| 190 | 190 | if ($globalDBdriver == 'mysql') { |
| 191 | 191 | if (isset($globalArchive) && $globalArchive === TRUE) { |
@@ -208,7 +208,7 @@ discard block |
||
| 208 | 208 | try { |
| 209 | 209 | $sth = $this->db->prepare($query); |
| 210 | 210 | $sth->execute(); |
| 211 | - } catch(PDOException $e) { |
|
| 211 | + } catch (PDOException $e) { |
|
| 212 | 212 | echo $e->getMessage(); |
| 213 | 213 | die; |
| 214 | 214 | } |
@@ -222,17 +222,17 @@ discard block |
||
| 222 | 222 | * @return Array the spotter information |
| 223 | 223 | * |
| 224 | 224 | */ |
| 225 | - public function getMinLastLiveSpotterData($coord = array(),$filter = array(), $limit = false) |
|
| 225 | + public function getMinLastLiveSpotterData($coord = array(), $filter = array(), $limit = false) |
|
| 226 | 226 | { |
| 227 | 227 | global $globalDBdriver, $globalLiveInterval, $globalArchive, $globalMap3DAircraftsLimit; |
| 228 | 228 | date_default_timezone_set('UTC'); |
| 229 | 229 | if (is_array($coord) && !empty($coord)) { |
| 230 | - $minlong = filter_var($coord[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 231 | - $minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 232 | - $maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 233 | - $maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 230 | + $minlong = filter_var($coord[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 231 | + $minlat = filter_var($coord[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 232 | + $maxlong = filter_var($coord[2], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 233 | + $maxlat = filter_var($coord[3], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 234 | 234 | } |
| 235 | - $filter_query = $this->getFilter($filter,true,true); |
|
| 235 | + $filter_query = $this->getFilter($filter, true, true); |
|
| 236 | 236 | |
| 237 | 237 | if (!isset($globalLiveInterval) || $globalLiveInterval == '') $globalLiveInterval = '200'; |
| 238 | 238 | if (!isset($globalMap3DAircraftsLimit) || $globalMap3DAicraftsLimit == '') $globalMap3DAircraftsLimit = '300'; |
@@ -293,7 +293,7 @@ discard block |
||
| 293 | 293 | try { |
| 294 | 294 | $sth = $this->db->prepare($query); |
| 295 | 295 | $sth->execute(); |
| 296 | - } catch(PDOException $e) { |
|
| 296 | + } catch (PDOException $e) { |
|
| 297 | 297 | echo $e->getMessage(); |
| 298 | 298 | die; |
| 299 | 299 | } |
@@ -310,7 +310,7 @@ discard block |
||
| 310 | 310 | public function getLiveSpotterCount($filter = array()) |
| 311 | 311 | { |
| 312 | 312 | global $globalDBdriver, $globalLiveInterval; |
| 313 | - $filter_query = $this->getFilter($filter,true,true); |
|
| 313 | + $filter_query = $this->getFilter($filter, true, true); |
|
| 314 | 314 | |
| 315 | 315 | if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
| 316 | 316 | if ($globalDBdriver == 'mysql') { |
@@ -323,7 +323,7 @@ discard block |
||
| 323 | 323 | try { |
| 324 | 324 | $sth = $this->db->prepare($query); |
| 325 | 325 | $sth->execute(); |
| 326 | - } catch(PDOException $e) { |
|
| 326 | + } catch (PDOException $e) { |
|
| 327 | 327 | echo $e->getMessage(); |
| 328 | 328 | die; |
| 329 | 329 | } |
@@ -346,10 +346,10 @@ discard block |
||
| 346 | 346 | $filter_query = $this->getFilter($filter); |
| 347 | 347 | |
| 348 | 348 | if (is_array($coord)) { |
| 349 | - $minlong = filter_var($coord[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 350 | - $minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 351 | - $maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 352 | - $maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 349 | + $minlong = filter_var($coord[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 350 | + $minlat = filter_var($coord[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 351 | + $maxlong = filter_var($coord[2], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 352 | + $maxlat = filter_var($coord[3], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 353 | 353 | } else return array(); |
| 354 | 354 | if ($globalDBdriver == 'mysql') { |
| 355 | 355 | $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate AND spotter_live.latitude BETWEEN '.$minlat.' AND '.$maxlat.' AND spotter_live.longitude BETWEEN '.$minlong.' AND '.$maxlong.' GROUP BY spotter_live.flightaware_id'.$filter_query; |
@@ -372,23 +372,23 @@ discard block |
||
| 372 | 372 | global $globalDBdriver, $globalLiveInterval, $globalArchive; |
| 373 | 373 | $Spotter = new Spotter($this->db); |
| 374 | 374 | if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
| 375 | - $filter_query = $this->getFilter($filter,true,true); |
|
| 375 | + $filter_query = $this->getFilter($filter, true, true); |
|
| 376 | 376 | |
| 377 | 377 | if (is_array($coord)) { |
| 378 | - $minlong = filter_var($coord[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 379 | - $minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 380 | - $maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 381 | - $maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 378 | + $minlong = filter_var($coord[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 379 | + $minlat = filter_var($coord[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 380 | + $maxlong = filter_var($coord[2], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 381 | + $maxlat = filter_var($coord[3], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 382 | 382 | } else return array(); |
| 383 | 383 | if ($globalDBdriver == 'mysql') { |
| 384 | 384 | if (isset($globalArchive) && $globalArchive === TRUE) { |
| 385 | - $query = 'SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source |
|
| 385 | + $query = 'SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source |
|
| 386 | 386 | FROM spotter_live |
| 387 | 387 | '.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= spotter_live.date |
| 388 | 388 | AND spotter_live.latitude BETWEEN '.$minlat.' AND '.$maxlat.' AND spotter_live.longitude BETWEEN '.$minlong.' AND '.$maxlong.' |
| 389 | 389 | AND spotter_live.latitude <> 0 AND spotter_live.longitude <> 0'; |
| 390 | 390 | } else { |
| 391 | - $query = 'SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source |
|
| 391 | + $query = 'SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source |
|
| 392 | 392 | FROM spotter_live |
| 393 | 393 | INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate |
| 394 | 394 | FROM spotter_live l |
@@ -400,14 +400,14 @@ discard block |
||
| 400 | 400 | } |
| 401 | 401 | } else { |
| 402 | 402 | if (isset($globalArchive) && $globalArchive === TRUE) { |
| 403 | - $query = "SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source |
|
| 403 | + $query = "SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source |
|
| 404 | 404 | FROM spotter_live |
| 405 | 405 | ".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= spotter_live.date |
| 406 | 406 | AND spotter_live.latitude BETWEEN ".$minlat." AND ".$maxlat." |
| 407 | 407 | AND spotter_live.longitude BETWEEN ".$minlong." AND ".$maxlong." |
| 408 | 408 | AND spotter_live.latitude <> '0' AND spotter_live.longitude <> '0'"; |
| 409 | 409 | } else { |
| 410 | - $query = "SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source |
|
| 410 | + $query = "SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source |
|
| 411 | 411 | FROM spotter_live |
| 412 | 412 | INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate |
| 413 | 413 | FROM spotter_live l |
@@ -422,7 +422,7 @@ discard block |
||
| 422 | 422 | try { |
| 423 | 423 | $sth = $this->db->prepare($query); |
| 424 | 424 | $sth->execute(); |
| 425 | - } catch(PDOException $e) { |
|
| 425 | + } catch (PDOException $e) { |
|
| 426 | 426 | echo $e->getMessage(); |
| 427 | 427 | die; |
| 428 | 428 | } |
@@ -471,7 +471,7 @@ discard block |
||
| 471 | 471 | if ($interval == '1m') |
| 472 | 472 | { |
| 473 | 473 | $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date '; |
| 474 | - } else if ($interval == '15m'){ |
|
| 474 | + } else if ($interval == '15m') { |
|
| 475 | 475 | $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 MINUTE) <= spotter_live.date '; |
| 476 | 476 | } |
| 477 | 477 | } |
@@ -479,14 +479,14 @@ discard block |
||
| 479 | 479 | $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date '; |
| 480 | 480 | } |
| 481 | 481 | |
| 482 | - $query = "SELECT spotter_live.*, ( 6371 * acos( cos( radians(:lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(:lng) ) + sin( radians(:lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM spotter_live |
|
| 482 | + $query = "SELECT spotter_live.*, ( 6371 * acos( cos( radians(:lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(:lng) ) + sin( radians(:lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM spotter_live |
|
| 483 | 483 | WHERE spotter_live.latitude <> '' |
| 484 | 484 | AND spotter_live.longitude <> '' |
| 485 | 485 | ".$additional_query." |
| 486 | 486 | HAVING distance < :radius |
| 487 | 487 | ORDER BY distance"; |
| 488 | 488 | |
| 489 | - $spotter_array = $Spotter->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng,':radius' => $radius)); |
|
| 489 | + $spotter_array = $Spotter->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng, ':radius' => $radius)); |
|
| 490 | 490 | |
| 491 | 491 | return $spotter_array; |
| 492 | 492 | } |
@@ -504,9 +504,9 @@ discard block |
||
| 504 | 504 | date_default_timezone_set('UTC'); |
| 505 | 505 | |
| 506 | 506 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 507 | - $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC'; |
|
| 507 | + $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC'; |
|
| 508 | 508 | |
| 509 | - $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident),'',true); |
|
| 509 | + $spotter_array = $Spotter->getDataFromDB($query, array(':ident' => $ident), '', true); |
|
| 510 | 510 | |
| 511 | 511 | return $spotter_array; |
| 512 | 512 | } |
@@ -517,16 +517,16 @@ discard block |
||
| 517 | 517 | * @return Array the spotter information |
| 518 | 518 | * |
| 519 | 519 | */ |
| 520 | - public function getDateLiveSpotterDataByIdent($ident,$date) |
|
| 520 | + public function getDateLiveSpotterDataByIdent($ident, $date) |
|
| 521 | 521 | { |
| 522 | 522 | $Spotter = new Spotter($this->db); |
| 523 | 523 | date_default_timezone_set('UTC'); |
| 524 | 524 | |
| 525 | 525 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 526 | - $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC'; |
|
| 526 | + $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC'; |
|
| 527 | 527 | |
| 528 | - $date = date('c',$date); |
|
| 529 | - $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident,':date' => $date)); |
|
| 528 | + $date = date('c', $date); |
|
| 529 | + $spotter_array = $Spotter->getDataFromDB($query, array(':ident' => $ident, ':date' => $date)); |
|
| 530 | 530 | |
| 531 | 531 | return $spotter_array; |
| 532 | 532 | } |
@@ -542,8 +542,8 @@ discard block |
||
| 542 | 542 | $Spotter = new Spotter($this->db); |
| 543 | 543 | date_default_timezone_set('UTC'); |
| 544 | 544 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
| 545 | - $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.flightaware_id = :id GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC'; |
|
| 546 | - $spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id),'',true); |
|
| 545 | + $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.flightaware_id = :id GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC'; |
|
| 546 | + $spotter_array = $Spotter->getDataFromDB($query, array(':id' => $id), '', true); |
|
| 547 | 547 | return $spotter_array; |
| 548 | 548 | } |
| 549 | 549 | |
@@ -553,15 +553,15 @@ discard block |
||
| 553 | 553 | * @return Array the spotter information |
| 554 | 554 | * |
| 555 | 555 | */ |
| 556 | - public function getDateLiveSpotterDataById($id,$date) |
|
| 556 | + public function getDateLiveSpotterDataById($id, $date) |
|
| 557 | 557 | { |
| 558 | 558 | $Spotter = new Spotter($this->db); |
| 559 | 559 | date_default_timezone_set('UTC'); |
| 560 | 560 | |
| 561 | 561 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
| 562 | - $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.flightaware_id = :id AND l.date <= :date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC'; |
|
| 563 | - $date = date('c',$date); |
|
| 564 | - $spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id,':date' => $date),'',true); |
|
| 562 | + $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.flightaware_id = :id AND l.date <= :date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC'; |
|
| 563 | + $date = date('c', $date); |
|
| 564 | + $spotter_array = $Spotter->getDataFromDB($query, array(':id' => $id, ':date' => $date), '', true); |
|
| 565 | 565 | return $spotter_array; |
| 566 | 566 | } |
| 567 | 567 | |
@@ -577,13 +577,13 @@ discard block |
||
| 577 | 577 | date_default_timezone_set('UTC'); |
| 578 | 578 | |
| 579 | 579 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 580 | - $query = 'SELECT spotter_live.altitude, spotter_live.date FROM spotter_live WHERE spotter_live.ident = :ident'; |
|
| 580 | + $query = 'SELECT spotter_live.altitude, spotter_live.date FROM spotter_live WHERE spotter_live.ident = :ident'; |
|
| 581 | 581 | |
| 582 | 582 | try { |
| 583 | 583 | |
| 584 | 584 | $sth = $this->db->prepare($query); |
| 585 | 585 | $sth->execute(array(':ident' => $ident)); |
| 586 | - } catch(PDOException $e) { |
|
| 586 | + } catch (PDOException $e) { |
|
| 587 | 587 | echo $e->getMessage(); |
| 588 | 588 | die; |
| 589 | 589 | } |
@@ -598,7 +598,7 @@ discard block |
||
| 598 | 598 | * @return Array the spotter information |
| 599 | 599 | * |
| 600 | 600 | */ |
| 601 | - public function getAllLiveSpotterDataById($id,$liveinterval = false) |
|
| 601 | + public function getAllLiveSpotterDataById($id, $liveinterval = false) |
|
| 602 | 602 | { |
| 603 | 603 | global $globalDBdriver, $globalLiveInterval; |
| 604 | 604 | date_default_timezone_set('UTC'); |
@@ -617,7 +617,7 @@ discard block |
||
| 617 | 617 | try { |
| 618 | 618 | $sth = $this->db->prepare($query); |
| 619 | 619 | $sth->execute(array(':id' => $id)); |
| 620 | - } catch(PDOException $e) { |
|
| 620 | + } catch (PDOException $e) { |
|
| 621 | 621 | echo $e->getMessage(); |
| 622 | 622 | die; |
| 623 | 623 | } |
@@ -635,12 +635,12 @@ discard block |
||
| 635 | 635 | { |
| 636 | 636 | date_default_timezone_set('UTC'); |
| 637 | 637 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 638 | - $query = self::$global_query.' WHERE spotter_live.ident = :ident'; |
|
| 638 | + $query = self::$global_query.' WHERE spotter_live.ident = :ident'; |
|
| 639 | 639 | try { |
| 640 | 640 | |
| 641 | 641 | $sth = $this->db->prepare($query); |
| 642 | 642 | $sth->execute(array(':ident' => $ident)); |
| 643 | - } catch(PDOException $e) { |
|
| 643 | + } catch (PDOException $e) { |
|
| 644 | 644 | echo $e->getMessage(); |
| 645 | 645 | die; |
| 646 | 646 | } |
@@ -670,7 +670,7 @@ discard block |
||
| 670 | 670 | |
| 671 | 671 | $sth = $this->db->prepare($query); |
| 672 | 672 | $sth->execute(); |
| 673 | - } catch(PDOException $e) { |
|
| 673 | + } catch (PDOException $e) { |
|
| 674 | 674 | return "error"; |
| 675 | 675 | } |
| 676 | 676 | |
@@ -693,14 +693,14 @@ discard block |
||
| 693 | 693 | |
| 694 | 694 | $sth = $this->db->prepare($query); |
| 695 | 695 | $sth->execute(); |
| 696 | - } catch(PDOException $e) { |
|
| 696 | + } catch (PDOException $e) { |
|
| 697 | 697 | return "error"; |
| 698 | 698 | } |
| 699 | 699 | $query_delete = 'DELETE FROM spotter_live WHERE flightaware_id IN ('; |
| 700 | 700 | $i = 0; |
| 701 | - $j =0; |
|
| 701 | + $j = 0; |
|
| 702 | 702 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 703 | - foreach($all as $row) |
|
| 703 | + foreach ($all as $row) |
|
| 704 | 704 | { |
| 705 | 705 | $i++; |
| 706 | 706 | $j++; |
@@ -708,9 +708,9 @@ discard block |
||
| 708 | 708 | if ($globalDebug) echo "."; |
| 709 | 709 | try { |
| 710 | 710 | |
| 711 | - $sth = $this->db->prepare(substr($query_delete,0,-1).")"); |
|
| 711 | + $sth = $this->db->prepare(substr($query_delete, 0, -1).")"); |
|
| 712 | 712 | $sth->execute(); |
| 713 | - } catch(PDOException $e) { |
|
| 713 | + } catch (PDOException $e) { |
|
| 714 | 714 | return "error"; |
| 715 | 715 | } |
| 716 | 716 | $query_delete = 'DELETE FROM spotter_live WHERE flightaware_id IN ('; |
@@ -721,9 +721,9 @@ discard block |
||
| 721 | 721 | if ($i > 0) { |
| 722 | 722 | try { |
| 723 | 723 | |
| 724 | - $sth = $this->db->prepare(substr($query_delete,0,-1).")"); |
|
| 724 | + $sth = $this->db->prepare(substr($query_delete, 0, -1).")"); |
|
| 725 | 725 | $sth->execute(); |
| 726 | - } catch(PDOException $e) { |
|
| 726 | + } catch (PDOException $e) { |
|
| 727 | 727 | return "error"; |
| 728 | 728 | } |
| 729 | 729 | } |
@@ -736,7 +736,7 @@ discard block |
||
| 736 | 736 | |
| 737 | 737 | $sth = $this->db->prepare($query); |
| 738 | 738 | $sth->execute(); |
| 739 | - } catch(PDOException $e) { |
|
| 739 | + } catch (PDOException $e) { |
|
| 740 | 740 | return "error"; |
| 741 | 741 | } |
| 742 | 742 | /* $query_delete = "DELETE FROM spotter_live WHERE flightaware_id IN ("; |
@@ -784,13 +784,13 @@ discard block |
||
| 784 | 784 | public function deleteLiveSpotterDataByIdent($ident) |
| 785 | 785 | { |
| 786 | 786 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 787 | - $query = 'DELETE FROM spotter_live WHERE ident = :ident'; |
|
| 787 | + $query = 'DELETE FROM spotter_live WHERE ident = :ident'; |
|
| 788 | 788 | |
| 789 | 789 | try { |
| 790 | 790 | |
| 791 | 791 | $sth = $this->db->prepare($query); |
| 792 | 792 | $sth->execute(array(':ident' => $ident)); |
| 793 | - } catch(PDOException $e) { |
|
| 793 | + } catch (PDOException $e) { |
|
| 794 | 794 | return "error"; |
| 795 | 795 | } |
| 796 | 796 | |
@@ -806,13 +806,13 @@ discard block |
||
| 806 | 806 | public function deleteLiveSpotterDataById($id) |
| 807 | 807 | { |
| 808 | 808 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
| 809 | - $query = 'DELETE FROM spotter_live WHERE flightaware_id = :id'; |
|
| 809 | + $query = 'DELETE FROM spotter_live WHERE flightaware_id = :id'; |
|
| 810 | 810 | |
| 811 | 811 | try { |
| 812 | 812 | |
| 813 | 813 | $sth = $this->db->prepare($query); |
| 814 | 814 | $sth->execute(array(':id' => $id)); |
| 815 | - } catch(PDOException $e) { |
|
| 815 | + } catch (PDOException $e) { |
|
| 816 | 816 | return "error"; |
| 817 | 817 | } |
| 818 | 818 | |
@@ -830,13 +830,13 @@ discard block |
||
| 830 | 830 | { |
| 831 | 831 | global $globalDBdriver, $globalTimezone; |
| 832 | 832 | if ($globalDBdriver == 'mysql') { |
| 833 | - $query = 'SELECT spotter_live.ident FROM spotter_live |
|
| 833 | + $query = 'SELECT spotter_live.ident FROM spotter_live |
|
| 834 | 834 | WHERE spotter_live.ident = :ident |
| 835 | 835 | AND spotter_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) |
| 836 | 836 | AND spotter_live.date < UTC_TIMESTAMP()'; |
| 837 | 837 | $query_data = array(':ident' => $ident); |
| 838 | 838 | } else { |
| 839 | - $query = "SELECT spotter_live.ident FROM spotter_live |
|
| 839 | + $query = "SELECT spotter_live.ident FROM spotter_live |
|
| 840 | 840 | WHERE spotter_live.ident = :ident |
| 841 | 841 | AND spotter_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '1 HOURS' |
| 842 | 842 | AND spotter_live.date < now() AT TIME ZONE 'UTC'"; |
@@ -845,8 +845,8 @@ discard block |
||
| 845 | 845 | |
| 846 | 846 | $sth = $this->db->prepare($query); |
| 847 | 847 | $sth->execute($query_data); |
| 848 | - $ident_result=''; |
|
| 849 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 848 | + $ident_result = ''; |
|
| 849 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 850 | 850 | { |
| 851 | 851 | $ident_result = $row['ident']; |
| 852 | 852 | } |
@@ -863,13 +863,13 @@ discard block |
||
| 863 | 863 | { |
| 864 | 864 | global $globalDBdriver, $globalTimezone; |
| 865 | 865 | if ($globalDBdriver == 'mysql') { |
| 866 | - $query = 'SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live |
|
| 866 | + $query = 'SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live |
|
| 867 | 867 | WHERE spotter_live.ident = :ident |
| 868 | 868 | AND spotter_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 MINUTE)'; |
| 869 | 869 | // AND spotter_live.date < UTC_TIMESTAMP()"; |
| 870 | 870 | $query_data = array(':ident' => $ident); |
| 871 | 871 | } else { |
| 872 | - $query = "SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live |
|
| 872 | + $query = "SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live |
|
| 873 | 873 | WHERE spotter_live.ident = :ident |
| 874 | 874 | AND spotter_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '30 MINUTES'"; |
| 875 | 875 | // AND spotter_live.date < now() AT TIME ZONE 'UTC'"; |
@@ -878,8 +878,8 @@ discard block |
||
| 878 | 878 | |
| 879 | 879 | $sth = $this->db->prepare($query); |
| 880 | 880 | $sth->execute($query_data); |
| 881 | - $ident_result=''; |
|
| 882 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 881 | + $ident_result = ''; |
|
| 882 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 883 | 883 | { |
| 884 | 884 | $ident_result = $row['flightaware_id']; |
| 885 | 885 | } |
@@ -896,13 +896,13 @@ discard block |
||
| 896 | 896 | { |
| 897 | 897 | global $globalDBdriver, $globalTimezone; |
| 898 | 898 | if ($globalDBdriver == 'mysql') { |
| 899 | - $query = 'SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live |
|
| 899 | + $query = 'SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live |
|
| 900 | 900 | WHERE spotter_live.flightaware_id = :id |
| 901 | 901 | AND spotter_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 10 HOUR)'; |
| 902 | 902 | // AND spotter_live.date < UTC_TIMESTAMP()"; |
| 903 | 903 | $query_data = array(':id' => $id); |
| 904 | 904 | } else { |
| 905 | - $query = "SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live |
|
| 905 | + $query = "SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live |
|
| 906 | 906 | WHERE spotter_live.flightaware_id = :id |
| 907 | 907 | AND spotter_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '10 HOUR'"; |
| 908 | 908 | // AND spotter_live.date < now() AT TIME ZONE 'UTC'"; |
@@ -911,8 +911,8 @@ discard block |
||
| 911 | 911 | |
| 912 | 912 | $sth = $this->db->prepare($query); |
| 913 | 913 | $sth->execute($query_data); |
| 914 | - $ident_result=''; |
|
| 915 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 914 | + $ident_result = ''; |
|
| 915 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 916 | 916 | { |
| 917 | 917 | $ident_result = $row['flightaware_id']; |
| 918 | 918 | } |
@@ -929,13 +929,13 @@ discard block |
||
| 929 | 929 | { |
| 930 | 930 | global $globalDBdriver, $globalTimezone; |
| 931 | 931 | if ($globalDBdriver == 'mysql') { |
| 932 | - $query = 'SELECT spotter_live.ModeS, spotter_live.flightaware_id FROM spotter_live |
|
| 932 | + $query = 'SELECT spotter_live.ModeS, spotter_live.flightaware_id FROM spotter_live |
|
| 933 | 933 | WHERE spotter_live.ModeS = :modes |
| 934 | 934 | AND spotter_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 MINUTE)'; |
| 935 | 935 | // AND spotter_live.date < UTC_TIMESTAMP()"; |
| 936 | 936 | $query_data = array(':modes' => $modes); |
| 937 | 937 | } else { |
| 938 | - $query = "SELECT spotter_live.ModeS, spotter_live.flightaware_id FROM spotter_live |
|
| 938 | + $query = "SELECT spotter_live.ModeS, spotter_live.flightaware_id FROM spotter_live |
|
| 939 | 939 | WHERE spotter_live.ModeS = :modes |
| 940 | 940 | AND spotter_live.date >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '30 MINUTE'"; |
| 941 | 941 | // // AND spotter_live.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC'"; |
@@ -944,8 +944,8 @@ discard block |
||
| 944 | 944 | |
| 945 | 945 | $sth = $this->db->prepare($query); |
| 946 | 946 | $sth->execute($query_data); |
| 947 | - $ident_result=''; |
|
| 948 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 947 | + $ident_result = ''; |
|
| 948 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 949 | 949 | { |
| 950 | 950 | //$ident_result = $row['spotter_live_id']; |
| 951 | 951 | $ident_result = $row['flightaware_id']; |
@@ -964,7 +964,7 @@ discard block |
||
| 964 | 964 | * @return String success or false |
| 965 | 965 | * |
| 966 | 966 | */ |
| 967 | - public function addLiveSpotterData($flightaware_id = '', $ident = '', $aircraft_icao = '', $departure_airport_icao = '', $arrival_airport_icao = '', $latitude = '', $longitude = '', $waypoints = '', $altitude = '', $altitude_real = '',$heading = '', $groundspeed = '', $date = '',$departure_airport_time = '', $arrival_airport_time = '', $squawk = '', $route_stop = '', $ModeS = '', $putinarchive = false,$registration = '',$pilot_id = '', $pilot_name = '', $verticalrate = '', $noarchive = false, $ground = false,$format_source = '', $source_name = '', $over_country = '') |
|
| 967 | + public function addLiveSpotterData($flightaware_id = '', $ident = '', $aircraft_icao = '', $departure_airport_icao = '', $arrival_airport_icao = '', $latitude = '', $longitude = '', $waypoints = '', $altitude = '', $altitude_real = '', $heading = '', $groundspeed = '', $date = '', $departure_airport_time = '', $arrival_airport_time = '', $squawk = '', $route_stop = '', $ModeS = '', $putinarchive = false, $registration = '', $pilot_id = '', $pilot_name = '', $verticalrate = '', $noarchive = false, $ground = false, $format_source = '', $source_name = '', $over_country = '') |
|
| 968 | 968 | { |
| 969 | 969 | global $globalURL, $globalArchive, $globalDebug; |
| 970 | 970 | $Common = new Common(); |
@@ -1064,27 +1064,27 @@ discard block |
||
| 1064 | 1064 | if ($date == '') $date = date("Y-m-d H:i:s", time()); |
| 1065 | 1065 | |
| 1066 | 1066 | |
| 1067 | - $flightaware_id = filter_var($flightaware_id,FILTER_SANITIZE_STRING); |
|
| 1068 | - $ident = filter_var($ident,FILTER_SANITIZE_STRING); |
|
| 1069 | - $aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING); |
|
| 1070 | - $departure_airport_icao = filter_var($departure_airport_icao,FILTER_SANITIZE_STRING); |
|
| 1071 | - $arrival_airport_icao = filter_var($arrival_airport_icao,FILTER_SANITIZE_STRING); |
|
| 1072 | - $latitude = filter_var($latitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 1073 | - $longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 1074 | - $waypoints = filter_var($waypoints,FILTER_SANITIZE_STRING); |
|
| 1075 | - $altitude = filter_var($altitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 1076 | - $altitude_real = filter_var($altitude_real,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 1077 | - $heading = filter_var($heading,FILTER_SANITIZE_NUMBER_INT); |
|
| 1078 | - $groundspeed = filter_var($groundspeed,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 1079 | - $squawk = filter_var($squawk,FILTER_SANITIZE_NUMBER_INT); |
|
| 1080 | - $route_stop = filter_var($route_stop,FILTER_SANITIZE_STRING); |
|
| 1081 | - $ModeS = filter_var($ModeS,FILTER_SANITIZE_STRING); |
|
| 1082 | - $pilot_id = filter_var($pilot_id,FILTER_SANITIZE_STRING); |
|
| 1083 | - $pilot_name = filter_var($pilot_name,FILTER_SANITIZE_STRING); |
|
| 1084 | - $format_source = filter_var($format_source,FILTER_SANITIZE_STRING); |
|
| 1085 | - $source_name = filter_var($source_name,FILTER_SANITIZE_STRING); |
|
| 1086 | - $over_country = filter_var($over_country,FILTER_SANITIZE_STRING); |
|
| 1087 | - $verticalrate = filter_var($verticalrate,FILTER_SANITIZE_NUMBER_INT); |
|
| 1067 | + $flightaware_id = filter_var($flightaware_id, FILTER_SANITIZE_STRING); |
|
| 1068 | + $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
| 1069 | + $aircraft_icao = filter_var($aircraft_icao, FILTER_SANITIZE_STRING); |
|
| 1070 | + $departure_airport_icao = filter_var($departure_airport_icao, FILTER_SANITIZE_STRING); |
|
| 1071 | + $arrival_airport_icao = filter_var($arrival_airport_icao, FILTER_SANITIZE_STRING); |
|
| 1072 | + $latitude = filter_var($latitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 1073 | + $longitude = filter_var($longitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 1074 | + $waypoints = filter_var($waypoints, FILTER_SANITIZE_STRING); |
|
| 1075 | + $altitude = filter_var($altitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 1076 | + $altitude_real = filter_var($altitude_real, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 1077 | + $heading = filter_var($heading, FILTER_SANITIZE_NUMBER_INT); |
|
| 1078 | + $groundspeed = filter_var($groundspeed, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 1079 | + $squawk = filter_var($squawk, FILTER_SANITIZE_NUMBER_INT); |
|
| 1080 | + $route_stop = filter_var($route_stop, FILTER_SANITIZE_STRING); |
|
| 1081 | + $ModeS = filter_var($ModeS, FILTER_SANITIZE_STRING); |
|
| 1082 | + $pilot_id = filter_var($pilot_id, FILTER_SANITIZE_STRING); |
|
| 1083 | + $pilot_name = filter_var($pilot_name, FILTER_SANITIZE_STRING); |
|
| 1084 | + $format_source = filter_var($format_source, FILTER_SANITIZE_STRING); |
|
| 1085 | + $source_name = filter_var($source_name, FILTER_SANITIZE_STRING); |
|
| 1086 | + $over_country = filter_var($over_country, FILTER_SANITIZE_STRING); |
|
| 1087 | + $verticalrate = filter_var($verticalrate, FILTER_SANITIZE_NUMBER_INT); |
|
| 1088 | 1088 | |
| 1089 | 1089 | $airline_name = ''; |
| 1090 | 1090 | $airline_icao = ''; |
@@ -1106,10 +1106,10 @@ discard block |
||
| 1106 | 1106 | $arrival_airport_country = ''; |
| 1107 | 1107 | |
| 1108 | 1108 | |
| 1109 | - if ($squawk == '' || $Common->isInteger($squawk) === false ) $squawk = NULL; |
|
| 1110 | - if ($verticalrate == '' || $Common->isInteger($verticalrate) === false ) $verticalrate = NULL; |
|
| 1111 | - if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0; |
|
| 1112 | - if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0; |
|
| 1109 | + if ($squawk == '' || $Common->isInteger($squawk) === false) $squawk = NULL; |
|
| 1110 | + if ($verticalrate == '' || $Common->isInteger($verticalrate) === false) $verticalrate = NULL; |
|
| 1111 | + if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0; |
|
| 1112 | + if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0; |
|
| 1113 | 1113 | |
| 1114 | 1114 | $query = ''; |
| 1115 | 1115 | if ($globalArchive) { |
@@ -1120,19 +1120,19 @@ discard block |
||
| 1120 | 1120 | $query .= 'INSERT INTO spotter_live (flightaware_id, ident, registration, airline_name, airline_icao, airline_country, airline_type, aircraft_icao, aircraft_shadow, aircraft_name, aircraft_manufacturer, departure_airport_icao, departure_airport_name, departure_airport_city, departure_airport_country, arrival_airport_icao, arrival_airport_name, arrival_airport_city, arrival_airport_country, latitude, longitude, waypoints, altitude, heading, ground_speed, date, departure_airport_time, arrival_airport_time, squawk, route_stop, ModeS, pilot_id, pilot_name, verticalrate, ground, format_source, source_name, over_country, real_altitude) |
| 1121 | 1121 | VALUES (:flightaware_id,:ident,:registration,:airline_name,:airline_icao,:airline_country,:airline_type,:aircraft_icao,:aircraft_shadow,:aircraft_type,:aircraft_manufacturer,:departure_airport_icao,:departure_airport_name, :departure_airport_city, :departure_airport_country, :arrival_airport_icao, :arrival_airport_name, :arrival_airport_city, :arrival_airport_country, :latitude,:longitude,:waypoints,:altitude,:heading,:groundspeed,:date,:departure_airport_time,:arrival_airport_time,:squawk,:route_stop,:ModeS, :pilot_id, :pilot_name, :verticalrate, :ground, :format_source, :source_name, :over_country, :real_altitude)'; |
| 1122 | 1122 | |
| 1123 | - $query_values = array(':flightaware_id' => $flightaware_id,':ident' => $ident, ':registration' => $registration,':airline_name' => $airline_name,':airline_icao' => $airline_icao,':airline_country' => $airline_country,':airline_type' => $airline_type,':aircraft_icao' => $aircraft_icao,':aircraft_shadow' => $aircraft_shadow,':aircraft_type' => $aircraft_type,':aircraft_manufacturer' => $aircraft_manufacturer,':departure_airport_icao' => $departure_airport_icao,':departure_airport_name' => $departure_airport_name,':departure_airport_city' => $departure_airport_city,':departure_airport_country' => $departure_airport_country,':arrival_airport_icao' => $arrival_airport_icao,':arrival_airport_name' => $arrival_airport_name,':arrival_airport_city' => $arrival_airport_city,':arrival_airport_country' => $arrival_airport_country,':latitude' => $latitude,':longitude' => $longitude, ':waypoints' => $waypoints,':altitude' => $altitude,':heading' => $heading,':groundspeed' => $groundspeed,':date' => $date, ':departure_airport_time' => $departure_airport_time,':arrival_airport_time' => $arrival_airport_time, ':squawk' => $squawk,':route_stop' => $route_stop,':ModeS' => $ModeS, ':pilot_id' => $pilot_id, ':pilot_name' => $pilot_name, ':verticalrate' => $verticalrate, ':format_source' => $format_source,':ground' => $ground, ':source_name' => $source_name, ':over_country' => $over_country,':real_altitude' => $altitude_real); |
|
| 1123 | + $query_values = array(':flightaware_id' => $flightaware_id, ':ident' => $ident, ':registration' => $registration, ':airline_name' => $airline_name, ':airline_icao' => $airline_icao, ':airline_country' => $airline_country, ':airline_type' => $airline_type, ':aircraft_icao' => $aircraft_icao, ':aircraft_shadow' => $aircraft_shadow, ':aircraft_type' => $aircraft_type, ':aircraft_manufacturer' => $aircraft_manufacturer, ':departure_airport_icao' => $departure_airport_icao, ':departure_airport_name' => $departure_airport_name, ':departure_airport_city' => $departure_airport_city, ':departure_airport_country' => $departure_airport_country, ':arrival_airport_icao' => $arrival_airport_icao, ':arrival_airport_name' => $arrival_airport_name, ':arrival_airport_city' => $arrival_airport_city, ':arrival_airport_country' => $arrival_airport_country, ':latitude' => $latitude, ':longitude' => $longitude, ':waypoints' => $waypoints, ':altitude' => $altitude, ':heading' => $heading, ':groundspeed' => $groundspeed, ':date' => $date, ':departure_airport_time' => $departure_airport_time, ':arrival_airport_time' => $arrival_airport_time, ':squawk' => $squawk, ':route_stop' => $route_stop, ':ModeS' => $ModeS, ':pilot_id' => $pilot_id, ':pilot_name' => $pilot_name, ':verticalrate' => $verticalrate, ':format_source' => $format_source, ':ground' => $ground, ':source_name' => $source_name, ':over_country' => $over_country, ':real_altitude' => $altitude_real); |
|
| 1124 | 1124 | try { |
| 1125 | 1125 | |
| 1126 | 1126 | $sth = $this->db->prepare($query); |
| 1127 | 1127 | $sth->execute($query_values); |
| 1128 | 1128 | $sth->closeCursor(); |
| 1129 | - } catch(PDOException $e) { |
|
| 1129 | + } catch (PDOException $e) { |
|
| 1130 | 1130 | return "error : ".$e->getMessage(); |
| 1131 | 1131 | } |
| 1132 | 1132 | if (isset($globalArchive) && $globalArchive && $putinarchive && $noarchive !== true) { |
| 1133 | 1133 | if ($globalDebug) echo '(Add to SBS archive : '; |
| 1134 | 1134 | $SpotterArchive = new SpotterArchive($this->db); |
| 1135 | - $result = $SpotterArchive->addSpotterArchiveData($flightaware_id, $ident, $registration, $airline_name, $airline_icao, $airline_country, $airline_type, $aircraft_icao, $aircraft_shadow, $aircraft_name, $aircraft_manufacturer, $departure_airport_icao, $departure_airport_name, $departure_airport_city, $departure_airport_country, $departure_airport_time,$arrival_airport_icao, $arrival_airport_name, $arrival_airport_city, $arrival_airport_country, $arrival_airport_time, $route_stop, $date,$latitude, $longitude, $waypoints, $altitude, $altitude_real,$heading, $groundspeed, $squawk, $ModeS, $pilot_id, $pilot_name,$verticalrate,$format_source,$source_name, $over_country); |
|
| 1135 | + $result = $SpotterArchive->addSpotterArchiveData($flightaware_id, $ident, $registration, $airline_name, $airline_icao, $airline_country, $airline_type, $aircraft_icao, $aircraft_shadow, $aircraft_name, $aircraft_manufacturer, $departure_airport_icao, $departure_airport_name, $departure_airport_city, $departure_airport_country, $departure_airport_time, $arrival_airport_icao, $arrival_airport_name, $arrival_airport_city, $arrival_airport_country, $arrival_airport_time, $route_stop, $date, $latitude, $longitude, $waypoints, $altitude, $altitude_real, $heading, $groundspeed, $squawk, $ModeS, $pilot_id, $pilot_name, $verticalrate, $format_source, $source_name, $over_country); |
|
| 1136 | 1136 | if ($globalDebug) echo $result.')'; |
| 1137 | 1137 | } elseif ($globalDebug && $putinarchive !== true) { |
| 1138 | 1138 | echo '(Not adding to archive)'; |
@@ -1145,7 +1145,7 @@ discard block |
||
| 1145 | 1145 | |
| 1146 | 1146 | public function getOrderBy() |
| 1147 | 1147 | { |
| 1148 | - $orderby = array("aircraft_asc" => array("key" => "aircraft_asc", "value" => "Aircraft Type - ASC", "sql" => "ORDER BY spotter_live.aircraft_icao ASC"), "aircraft_desc" => array("key" => "aircraft_desc", "value" => "Aircraft Type - DESC", "sql" => "ORDER BY spotter_live.aircraft_icao DESC"),"manufacturer_asc" => array("key" => "manufacturer_asc", "value" => "Aircraft Manufacturer - ASC", "sql" => "ORDER BY spotter_live.aircraft_manufacturer ASC"), "manufacturer_desc" => array("key" => "manufacturer_desc", "value" => "Aircraft Manufacturer - DESC", "sql" => "ORDER BY spotter_live.aircraft_manufacturer DESC"),"airline_name_asc" => array("key" => "airline_name_asc", "value" => "Airline Name - ASC", "sql" => "ORDER BY spotter_live.airline_name ASC"), "airline_name_desc" => array("key" => "airline_name_desc", "value" => "Airline Name - DESC", "sql" => "ORDER BY spotter_live.airline_name DESC"), "ident_asc" => array("key" => "ident_asc", "value" => "Ident - ASC", "sql" => "ORDER BY spotter_live.ident ASC"), "ident_desc" => array("key" => "ident_desc", "value" => "Ident - DESC", "sql" => "ORDER BY spotter_live.ident DESC"), "airport_departure_asc" => array("key" => "airport_departure_asc", "value" => "Departure Airport - ASC", "sql" => "ORDER BY spotter_live.departure_airport_city ASC"), "airport_departure_desc" => array("key" => "airport_departure_desc", "value" => "Departure Airport - DESC", "sql" => "ORDER BY spotter_live.departure_airport_city DESC"), "airport_arrival_asc" => array("key" => "airport_arrival_asc", "value" => "Arrival Airport - ASC", "sql" => "ORDER BY spotter_live.arrival_airport_city ASC"), "airport_arrival_desc" => array("key" => "airport_arrival_desc", "value" => "Arrival Airport - DESC", "sql" => "ORDER BY spotter_live.arrival_airport_city DESC"), "date_asc" => array("key" => "date_asc", "value" => "Date - ASC", "sql" => "ORDER BY spotter_live.date ASC"), "date_desc" => array("key" => "date_desc", "value" => "Date - DESC", "sql" => "ORDER BY spotter_live.date DESC")); |
|
| 1148 | + $orderby = array("aircraft_asc" => array("key" => "aircraft_asc", "value" => "Aircraft Type - ASC", "sql" => "ORDER BY spotter_live.aircraft_icao ASC"), "aircraft_desc" => array("key" => "aircraft_desc", "value" => "Aircraft Type - DESC", "sql" => "ORDER BY spotter_live.aircraft_icao DESC"), "manufacturer_asc" => array("key" => "manufacturer_asc", "value" => "Aircraft Manufacturer - ASC", "sql" => "ORDER BY spotter_live.aircraft_manufacturer ASC"), "manufacturer_desc" => array("key" => "manufacturer_desc", "value" => "Aircraft Manufacturer - DESC", "sql" => "ORDER BY spotter_live.aircraft_manufacturer DESC"), "airline_name_asc" => array("key" => "airline_name_asc", "value" => "Airline Name - ASC", "sql" => "ORDER BY spotter_live.airline_name ASC"), "airline_name_desc" => array("key" => "airline_name_desc", "value" => "Airline Name - DESC", "sql" => "ORDER BY spotter_live.airline_name DESC"), "ident_asc" => array("key" => "ident_asc", "value" => "Ident - ASC", "sql" => "ORDER BY spotter_live.ident ASC"), "ident_desc" => array("key" => "ident_desc", "value" => "Ident - DESC", "sql" => "ORDER BY spotter_live.ident DESC"), "airport_departure_asc" => array("key" => "airport_departure_asc", "value" => "Departure Airport - ASC", "sql" => "ORDER BY spotter_live.departure_airport_city ASC"), "airport_departure_desc" => array("key" => "airport_departure_desc", "value" => "Departure Airport - DESC", "sql" => "ORDER BY spotter_live.departure_airport_city DESC"), "airport_arrival_asc" => array("key" => "airport_arrival_asc", "value" => "Arrival Airport - ASC", "sql" => "ORDER BY spotter_live.arrival_airport_city ASC"), "airport_arrival_desc" => array("key" => "airport_arrival_desc", "value" => "Arrival Airport - DESC", "sql" => "ORDER BY spotter_live.arrival_airport_city DESC"), "date_asc" => array("key" => "date_asc", "value" => "Date - ASC", "sql" => "ORDER BY spotter_live.date ASC"), "date_desc" => array("key" => "date_desc", "value" => "Date - DESC", "sql" => "ORDER BY spotter_live.date DESC")); |
|
| 1149 | 1149 | return $orderby; |
| 1150 | 1150 | } |
| 1151 | 1151 | |
@@ -8,7 +8,9 @@ discard block |
||
| 8 | 8 | public function __construct($dbc = null) { |
| 9 | 9 | $Connection = new Connection($dbc); |
| 10 | 10 | $this->db = $Connection->db(); |
| 11 | - if ($this->db === null) die('Error: No DB connection.'); |
|
| 11 | + if ($this->db === null) { |
|
| 12 | + die('Error: No DB connection.'); |
|
| 13 | + } |
|
| 12 | 14 | } |
| 13 | 15 | |
| 14 | 16 | |
@@ -30,7 +32,9 @@ discard block |
||
| 30 | 32 | if (isset($filter[0]['source'])) { |
| 31 | 33 | $filters = array_merge($filters,$filter); |
| 32 | 34 | } |
| 33 | - if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter); |
|
| 35 | + if (is_array($globalFilter)) { |
|
| 36 | + $filter = array_merge($filter,$globalFilter); |
|
| 37 | + } |
|
| 34 | 38 | $filter_query_join = ''; |
| 35 | 39 | $filter_query_where = ''; |
| 36 | 40 | foreach($filters as $flt) { |
@@ -119,8 +123,11 @@ discard block |
||
| 119 | 123 | if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
| 120 | 124 | $filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
| 121 | 125 | } |
| 122 | - if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE'; |
|
| 123 | - elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND'; |
|
| 126 | + if ($filter_query_where == '' && $where) { |
|
| 127 | + $filter_query_where = ' WHERE'; |
|
| 128 | + } elseif ($filter_query_where != '' && $and) { |
|
| 129 | + $filter_query_where .= ' AND'; |
|
| 130 | + } |
|
| 124 | 131 | if ($filter_query_where != '') { |
| 125 | 132 | $filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where); |
| 126 | 133 | } |
@@ -161,9 +168,13 @@ discard block |
||
| 161 | 168 | $orderby_query = ' '.$search_orderby_array[$sort]['sql']; |
| 162 | 169 | } |
| 163 | 170 | } |
| 164 | - if ($orderby_query == '') $orderby_query = ' ORDER BY date DESC'; |
|
| 171 | + if ($orderby_query == '') { |
|
| 172 | + $orderby_query = ' ORDER BY date DESC'; |
|
| 173 | + } |
|
| 165 | 174 | |
| 166 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
| 175 | + if (!isset($globalLiveInterval)) { |
|
| 176 | + $globalLiveInterval = '200'; |
|
| 177 | + } |
|
| 167 | 178 | if ($globalDBdriver == 'mysql') { |
| 168 | 179 | //$query = "SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate"; |
| 169 | 180 | $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate'.$filter_query.$orderby_query; |
@@ -186,7 +197,9 @@ discard block |
||
| 186 | 197 | global $globalDBdriver, $globalLiveInterval, $globalArchive; |
| 187 | 198 | date_default_timezone_set('UTC'); |
| 188 | 199 | $filter_query = $this->getFilter($filter,true,true); |
| 189 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
| 200 | + if (!isset($globalLiveInterval)) { |
|
| 201 | + $globalLiveInterval = '200'; |
|
| 202 | + } |
|
| 190 | 203 | if ($globalDBdriver == 'mysql') { |
| 191 | 204 | if (isset($globalArchive) && $globalArchive === TRUE) { |
| 192 | 205 | $query = 'SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source |
@@ -234,8 +247,12 @@ discard block |
||
| 234 | 247 | } |
| 235 | 248 | $filter_query = $this->getFilter($filter,true,true); |
| 236 | 249 | |
| 237 | - if (!isset($globalLiveInterval) || $globalLiveInterval == '') $globalLiveInterval = '200'; |
|
| 238 | - if (!isset($globalMap3DAircraftsLimit) || $globalMap3DAicraftsLimit == '') $globalMap3DAircraftsLimit = '300'; |
|
| 250 | + if (!isset($globalLiveInterval) || $globalLiveInterval == '') { |
|
| 251 | + $globalLiveInterval = '200'; |
|
| 252 | + } |
|
| 253 | + if (!isset($globalMap3DAircraftsLimit) || $globalMap3DAicraftsLimit == '') { |
|
| 254 | + $globalMap3DAircraftsLimit = '300'; |
|
| 255 | + } |
|
| 239 | 256 | if ($globalDBdriver == 'mysql') { |
| 240 | 257 | if (isset($globalArchive) && $globalArchive === TRUE) { |
| 241 | 258 | /* |
@@ -246,22 +263,32 @@ discard block |
||
| 246 | 263 | */ |
| 247 | 264 | $query = 'SELECT * FROM (SELECT spotter_archive.ident, spotter_archive.flightaware_id, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk, spotter_archive.date, spotter_archive.format_source |
| 248 | 265 | FROM spotter_archive INNER JOIN (SELECT flightaware_id FROM spotter_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= spotter_live.date) l ON l.flightaware_id = spotter_archive.flightaware_id "; |
| 249 | - if (isset($maxlat)) $query .= "AND spotter_archive.latitude BETWEEN ".$minlat." AND ".$maxlat." AND spotter_archive.longitude BETWEEN ".$minlong." AND ".$maxlong." "; |
|
| 266 | + if (isset($maxlat)) { |
|
| 267 | + $query .= "AND spotter_archive.latitude BETWEEN ".$minlat." AND ".$maxlat." AND spotter_archive.longitude BETWEEN ".$minlong." AND ".$maxlong." "; |
|
| 268 | + } |
|
| 250 | 269 | $query .= "UNION |
| 251 | 270 | SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source |
| 252 | 271 | FROM spotter_live".$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= spotter_live.date"; |
| 253 | - if (isset($maxlat)) $query .= " AND spotter_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND spotter_live.longitude BETWEEN ".$minlong." AND ".$maxlong; |
|
| 272 | + if (isset($maxlat)) { |
|
| 273 | + $query .= " AND spotter_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND spotter_live.longitude BETWEEN ".$minlong." AND ".$maxlong; |
|
| 274 | + } |
|
| 254 | 275 | $query .= ") AS spotter |
| 255 | 276 | WHERE latitude <> '0' AND longitude <> '0' |
| 256 | 277 | ORDER BY flightaware_id, date"; |
| 257 | - if ($limit) $query .= " LIMIT ".$globalMap3DAircraftsLimit; |
|
| 278 | + if ($limit) { |
|
| 279 | + $query .= " LIMIT ".$globalMap3DAircraftsLimit; |
|
| 280 | + } |
|
| 258 | 281 | } else { |
| 259 | 282 | $query = 'SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source |
| 260 | 283 | FROM spotter_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= spotter_live.date "; |
| 261 | - if (isset($maxlat)) $query .= "AND spotter_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND spotter_live.longitude BETWEEN ".$minlong." AND ".$maxlong." "; |
|
| 284 | + if (isset($maxlat)) { |
|
| 285 | + $query .= "AND spotter_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND spotter_live.longitude BETWEEN ".$minlong." AND ".$maxlong." "; |
|
| 286 | + } |
|
| 262 | 287 | $query .= "AND spotter_live.latitude <> '0' AND spotter_live.longitude <> '0' |
| 263 | 288 | ORDER BY spotter_live.flightaware_id, spotter_live.date"; |
| 264 | - if ($limit) $query .= " LIMIT ".$globalMap3DAircraftsLimit; |
|
| 289 | + if ($limit) { |
|
| 290 | + $query .= " LIMIT ".$globalMap3DAircraftsLimit; |
|
| 291 | + } |
|
| 265 | 292 | } |
| 266 | 293 | } else { |
| 267 | 294 | if (isset($globalArchive) && $globalArchive === TRUE) { |
@@ -273,21 +300,31 @@ discard block |
||
| 273 | 300 | */ |
| 274 | 301 | $query = "SELECT * FROM (SELECT spotter_archive.ident, spotter_archive.flightaware_id, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk, spotter_archive.date, spotter_archive.format_source |
| 275 | 302 | FROM spotter_archive INNER JOIN (SELECT flightaware_id FROM spotter_live".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= spotter_live.date) l ON l.flightaware_id = spotter_archive.flightaware_id "; |
| 276 | - if (isset($maxlat)) $query .= "AND spotter_archive.latitude BETWEEN ".$minlat." AND ".$maxlat." AND spotter_archive.longitude BETWEEN ".$minlong." AND ".$maxlong." "; |
|
| 303 | + if (isset($maxlat)) { |
|
| 304 | + $query .= "AND spotter_archive.latitude BETWEEN ".$minlat." AND ".$maxlat." AND spotter_archive.longitude BETWEEN ".$minlong." AND ".$maxlong." "; |
|
| 305 | + } |
|
| 277 | 306 | $query .= "UNION |
| 278 | 307 | SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source |
| 279 | 308 | FROM spotter_live".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= spotter_live.date"; |
| 280 | - if (isset($maxlat)) $query .= " AND spotter_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND spotter_live.longitude BETWEEN ".$minlong." AND ".$maxlong; |
|
| 309 | + if (isset($maxlat)) { |
|
| 310 | + $query .= " AND spotter_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND spotter_live.longitude BETWEEN ".$minlong." AND ".$maxlong; |
|
| 311 | + } |
|
| 281 | 312 | $query .= ") AS spotter WHERE latitude <> '0' AND longitude <> '0' "; |
| 282 | 313 | $query .= "ORDER BY flightaware_id, date"; |
| 283 | - if ($limit) $query .= " LIMIT ".$globalMap3DAircraftsLimit; |
|
| 314 | + if ($limit) { |
|
| 315 | + $query .= " LIMIT ".$globalMap3DAircraftsLimit; |
|
| 316 | + } |
|
| 284 | 317 | } else { |
| 285 | 318 | $query = "SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source |
| 286 | 319 | FROM spotter_live".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= spotter_live.date "; |
| 287 | - if (isset($maxlat)) $query .= "AND spotter_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND spotter_live.longitude BETWEEN ".$minlong." AND ".$maxlong." "; |
|
| 320 | + if (isset($maxlat)) { |
|
| 321 | + $query .= "AND spotter_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND spotter_live.longitude BETWEEN ".$minlong." AND ".$maxlong." "; |
|
| 322 | + } |
|
| 288 | 323 | $query .= "AND spotter_live.latitude <> '0' AND spotter_live.longitude <> '0' |
| 289 | 324 | ORDER BY spotter_live.flightaware_id, spotter_live.date"; |
| 290 | - if ($limit) $query .= " LIMIT ".$globalMap3DAircraftsLimit; |
|
| 325 | + if ($limit) { |
|
| 326 | + $query .= " LIMIT ".$globalMap3DAircraftsLimit; |
|
| 327 | + } |
|
| 291 | 328 | } |
| 292 | 329 | } |
| 293 | 330 | try { |
@@ -312,7 +349,9 @@ discard block |
||
| 312 | 349 | global $globalDBdriver, $globalLiveInterval; |
| 313 | 350 | $filter_query = $this->getFilter($filter,true,true); |
| 314 | 351 | |
| 315 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
| 352 | + if (!isset($globalLiveInterval)) { |
|
| 353 | + $globalLiveInterval = '200'; |
|
| 354 | + } |
|
| 316 | 355 | if ($globalDBdriver == 'mysql') { |
| 317 | 356 | //$query = 'SELECT COUNT(*) as nb FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate'.$filter_query; |
| 318 | 357 | $query = 'SELECT COUNT(DISTINCT spotter_live.flightaware_id) as nb FROM spotter_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date'; |
@@ -342,7 +381,9 @@ discard block |
||
| 342 | 381 | { |
| 343 | 382 | global $globalDBdriver, $globalLiveInterval; |
| 344 | 383 | $Spotter = new Spotter($this->db); |
| 345 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
| 384 | + if (!isset($globalLiveInterval)) { |
|
| 385 | + $globalLiveInterval = '200'; |
|
| 386 | + } |
|
| 346 | 387 | $filter_query = $this->getFilter($filter); |
| 347 | 388 | |
| 348 | 389 | if (is_array($coord)) { |
@@ -350,7 +391,9 @@ discard block |
||
| 350 | 391 | $minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
| 351 | 392 | $maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
| 352 | 393 | $maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
| 353 | - } else return array(); |
|
| 394 | + } else { |
|
| 395 | + return array(); |
|
| 396 | + } |
|
| 354 | 397 | if ($globalDBdriver == 'mysql') { |
| 355 | 398 | $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate AND spotter_live.latitude BETWEEN '.$minlat.' AND '.$maxlat.' AND spotter_live.longitude BETWEEN '.$minlong.' AND '.$maxlong.' GROUP BY spotter_live.flightaware_id'.$filter_query; |
| 356 | 399 | } else { |
@@ -371,7 +414,9 @@ discard block |
||
| 371 | 414 | { |
| 372 | 415 | global $globalDBdriver, $globalLiveInterval, $globalArchive; |
| 373 | 416 | $Spotter = new Spotter($this->db); |
| 374 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
| 417 | + if (!isset($globalLiveInterval)) { |
|
| 418 | + $globalLiveInterval = '200'; |
|
| 419 | + } |
|
| 375 | 420 | $filter_query = $this->getFilter($filter,true,true); |
| 376 | 421 | |
| 377 | 422 | if (is_array($coord)) { |
@@ -379,7 +424,9 @@ discard block |
||
| 379 | 424 | $minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
| 380 | 425 | $maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
| 381 | 426 | $maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
| 382 | - } else return array(); |
|
| 427 | + } else { |
|
| 428 | + return array(); |
|
| 429 | + } |
|
| 383 | 430 | if ($globalDBdriver == 'mysql') { |
| 384 | 431 | if (isset($globalArchive) && $globalArchive === TRUE) { |
| 385 | 432 | $query = 'SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source |
@@ -606,11 +653,15 @@ discard block |
||
| 606 | 653 | //$query = self::$global_query.' WHERE spotter_live.flightaware_id = :id ORDER BY date'; |
| 607 | 654 | if ($globalDBdriver == 'mysql') { |
| 608 | 655 | $query = 'SELECT spotter_live.* FROM spotter_live WHERE spotter_live.flightaware_id = :id'; |
| 609 | - if ($liveinterval) $query .= ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date'; |
|
| 656 | + if ($liveinterval) { |
|
| 657 | + $query .= ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date'; |
|
| 658 | + } |
|
| 610 | 659 | $query .= ' ORDER BY date'; |
| 611 | 660 | } else { |
| 612 | 661 | $query = 'SELECT spotter_live.* FROM spotter_live WHERE spotter_live.flightaware_id = :id'; |
| 613 | - if ($liveinterval) $query .= " AND CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= date"; |
|
| 662 | + if ($liveinterval) { |
|
| 663 | + $query .= " AND CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= date"; |
|
| 664 | + } |
|
| 614 | 665 | $query .= ' ORDER BY date'; |
| 615 | 666 | } |
| 616 | 667 | |
@@ -705,7 +756,9 @@ discard block |
||
| 705 | 756 | $i++; |
| 706 | 757 | $j++; |
| 707 | 758 | if ($j == 30) { |
| 708 | - if ($globalDebug) echo "."; |
|
| 759 | + if ($globalDebug) { |
|
| 760 | + echo "."; |
|
| 761 | + } |
|
| 709 | 762 | try { |
| 710 | 763 | |
| 711 | 764 | $sth = $this->db->prepare(substr($query_delete,0,-1).")"); |
@@ -1012,7 +1065,9 @@ discard block |
||
| 1012 | 1065 | { |
| 1013 | 1066 | return false; |
| 1014 | 1067 | } |
| 1015 | - } else return ''; |
|
| 1068 | + } else { |
|
| 1069 | + return ''; |
|
| 1070 | + } |
|
| 1016 | 1071 | |
| 1017 | 1072 | if ($longitude != '') |
| 1018 | 1073 | { |
@@ -1020,7 +1075,9 @@ discard block |
||
| 1020 | 1075 | { |
| 1021 | 1076 | return false; |
| 1022 | 1077 | } |
| 1023 | - } else return ''; |
|
| 1078 | + } else { |
|
| 1079 | + return ''; |
|
| 1080 | + } |
|
| 1024 | 1081 | |
| 1025 | 1082 | if ($waypoints != '') |
| 1026 | 1083 | { |
@@ -1036,14 +1093,18 @@ discard block |
||
| 1036 | 1093 | { |
| 1037 | 1094 | return false; |
| 1038 | 1095 | } |
| 1039 | - } else $altitude = 0; |
|
| 1096 | + } else { |
|
| 1097 | + $altitude = 0; |
|
| 1098 | + } |
|
| 1040 | 1099 | if ($altitude_real != '') |
| 1041 | 1100 | { |
| 1042 | 1101 | if (!is_numeric($altitude_real)) |
| 1043 | 1102 | { |
| 1044 | 1103 | return false; |
| 1045 | 1104 | } |
| 1046 | - } else $altitude_real = 0; |
|
| 1105 | + } else { |
|
| 1106 | + $altitude_real = 0; |
|
| 1107 | + } |
|
| 1047 | 1108 | |
| 1048 | 1109 | if ($heading != '') |
| 1049 | 1110 | { |
@@ -1051,7 +1112,9 @@ discard block |
||
| 1051 | 1112 | { |
| 1052 | 1113 | return false; |
| 1053 | 1114 | } |
| 1054 | - } else $heading = 0; |
|
| 1115 | + } else { |
|
| 1116 | + $heading = 0; |
|
| 1117 | + } |
|
| 1055 | 1118 | |
| 1056 | 1119 | if ($groundspeed != '') |
| 1057 | 1120 | { |
@@ -1059,9 +1122,13 @@ discard block |
||
| 1059 | 1122 | { |
| 1060 | 1123 | return false; |
| 1061 | 1124 | } |
| 1062 | - } else $groundspeed = 0; |
|
| 1125 | + } else { |
|
| 1126 | + $groundspeed = 0; |
|
| 1127 | + } |
|
| 1063 | 1128 | date_default_timezone_set('UTC'); |
| 1064 | - if ($date == '') $date = date("Y-m-d H:i:s", time()); |
|
| 1129 | + if ($date == '') { |
|
| 1130 | + $date = date("Y-m-d H:i:s", time()); |
|
| 1131 | + } |
|
| 1065 | 1132 | |
| 1066 | 1133 | |
| 1067 | 1134 | $flightaware_id = filter_var($flightaware_id,FILTER_SANITIZE_STRING); |
@@ -1106,14 +1173,24 @@ discard block |
||
| 1106 | 1173 | $arrival_airport_country = ''; |
| 1107 | 1174 | |
| 1108 | 1175 | |
| 1109 | - if ($squawk == '' || $Common->isInteger($squawk) === false ) $squawk = NULL; |
|
| 1110 | - if ($verticalrate == '' || $Common->isInteger($verticalrate) === false ) $verticalrate = NULL; |
|
| 1111 | - if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0; |
|
| 1112 | - if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0; |
|
| 1176 | + if ($squawk == '' || $Common->isInteger($squawk) === false ) { |
|
| 1177 | + $squawk = NULL; |
|
| 1178 | + } |
|
| 1179 | + if ($verticalrate == '' || $Common->isInteger($verticalrate) === false ) { |
|
| 1180 | + $verticalrate = NULL; |
|
| 1181 | + } |
|
| 1182 | + if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) { |
|
| 1183 | + $groundspeed = 0; |
|
| 1184 | + } |
|
| 1185 | + if ($heading == '' || $Common->isInteger($heading) === false ) { |
|
| 1186 | + $heading = 0; |
|
| 1187 | + } |
|
| 1113 | 1188 | |
| 1114 | 1189 | $query = ''; |
| 1115 | 1190 | if ($globalArchive) { |
| 1116 | - if ($globalDebug) echo '-- Delete previous data -- '; |
|
| 1191 | + if ($globalDebug) { |
|
| 1192 | + echo '-- Delete previous data -- '; |
|
| 1193 | + } |
|
| 1117 | 1194 | $query .= 'DELETE FROM spotter_live WHERE flightaware_id = :flightaware_id;'; |
| 1118 | 1195 | } |
| 1119 | 1196 | |
@@ -1130,10 +1207,14 @@ discard block |
||
| 1130 | 1207 | return "error : ".$e->getMessage(); |
| 1131 | 1208 | } |
| 1132 | 1209 | if (isset($globalArchive) && $globalArchive && $putinarchive && $noarchive !== true) { |
| 1133 | - if ($globalDebug) echo '(Add to SBS archive : '; |
|
| 1210 | + if ($globalDebug) { |
|
| 1211 | + echo '(Add to SBS archive : '; |
|
| 1212 | + } |
|
| 1134 | 1213 | $SpotterArchive = new SpotterArchive($this->db); |
| 1135 | 1214 | $result = $SpotterArchive->addSpotterArchiveData($flightaware_id, $ident, $registration, $airline_name, $airline_icao, $airline_country, $airline_type, $aircraft_icao, $aircraft_shadow, $aircraft_name, $aircraft_manufacturer, $departure_airport_icao, $departure_airport_name, $departure_airport_city, $departure_airport_country, $departure_airport_time,$arrival_airport_icao, $arrival_airport_name, $arrival_airport_city, $arrival_airport_country, $arrival_airport_time, $route_stop, $date,$latitude, $longitude, $waypoints, $altitude, $altitude_real,$heading, $groundspeed, $squawk, $ModeS, $pilot_id, $pilot_name,$verticalrate,$format_source,$source_name, $over_country); |
| 1136 | - if ($globalDebug) echo $result.')'; |
|
| 1215 | + if ($globalDebug) { |
|
| 1216 | + echo $result.')'; |
|
| 1217 | + } |
|
| 1137 | 1218 | } elseif ($globalDebug && $putinarchive !== true) { |
| 1138 | 1219 | echo '(Not adding to archive)'; |
| 1139 | 1220 | } elseif ($globalDebug && $noarchive === true) { |
@@ -13,10 +13,10 @@ discard block |
||
| 13 | 13 | |
| 14 | 14 | |
| 15 | 15 | /** |
| 16 | - * Get SQL query part for filter used |
|
| 17 | - * @param Array $filter the filter |
|
| 18 | - * @return Array the SQL part |
|
| 19 | - */ |
|
| 16 | + * Get SQL query part for filter used |
|
| 17 | + * @param Array $filter the filter |
|
| 18 | + * @return Array the SQL part |
|
| 19 | + */ |
|
| 20 | 20 | public function getFilter($filter = array(),$where = false,$and = false) { |
| 21 | 21 | global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver; |
| 22 | 22 | $filters = array(); |
@@ -87,11 +87,11 @@ discard block |
||
| 87 | 87 | } |
| 88 | 88 | |
| 89 | 89 | /** |
| 90 | - * Gets all the spotter information based on the latest data entry |
|
| 91 | - * |
|
| 92 | - * @return Array the spotter information |
|
| 93 | - * |
|
| 94 | - */ |
|
| 90 | + * Gets all the spotter information based on the latest data entry |
|
| 91 | + * |
|
| 92 | + * @return Array the spotter information |
|
| 93 | + * |
|
| 94 | + */ |
|
| 95 | 95 | public function getLiveTrackerData($limit = '', $sort = '', $filter = array()) |
| 96 | 96 | { |
| 97 | 97 | global $globalDBdriver, $globalLiveInterval; |
@@ -133,11 +133,11 @@ discard block |
||
| 133 | 133 | } |
| 134 | 134 | |
| 135 | 135 | /** |
| 136 | - * Gets Minimal Live Spotter data |
|
| 137 | - * |
|
| 138 | - * @return Array the spotter information |
|
| 139 | - * |
|
| 140 | - */ |
|
| 136 | + * Gets Minimal Live Spotter data |
|
| 137 | + * |
|
| 138 | + * @return Array the spotter information |
|
| 139 | + * |
|
| 140 | + */ |
|
| 141 | 141 | public function getMinLiveTrackerData($filter = array()) |
| 142 | 142 | { |
| 143 | 143 | global $globalDBdriver, $globalLiveInterval; |
@@ -171,11 +171,11 @@ discard block |
||
| 171 | 171 | } |
| 172 | 172 | |
| 173 | 173 | /** |
| 174 | - * Gets Minimal Live Spotter data since xx seconds |
|
| 175 | - * |
|
| 176 | - * @return Array the spotter information |
|
| 177 | - * |
|
| 178 | - */ |
|
| 174 | + * Gets Minimal Live Spotter data since xx seconds |
|
| 175 | + * |
|
| 176 | + * @return Array the spotter information |
|
| 177 | + * |
|
| 178 | + */ |
|
| 179 | 179 | public function getMinLastLiveTrackerData($coord,$filter = array(),$limit = false) |
| 180 | 180 | { |
| 181 | 181 | global $globalDBdriver, $globalLiveInterval, $globalArchive, $globalMap3DTrackersLimit; |
@@ -247,11 +247,11 @@ discard block |
||
| 247 | 247 | } |
| 248 | 248 | |
| 249 | 249 | /** |
| 250 | - * Gets number of latest data entry |
|
| 251 | - * |
|
| 252 | - * @return String number of entry |
|
| 253 | - * |
|
| 254 | - */ |
|
| 250 | + * Gets number of latest data entry |
|
| 251 | + * |
|
| 252 | + * @return String number of entry |
|
| 253 | + * |
|
| 254 | + */ |
|
| 255 | 255 | public function getLiveTrackerCount($filter = array()) |
| 256 | 256 | { |
| 257 | 257 | global $globalDBdriver, $globalLiveInterval; |
@@ -276,11 +276,11 @@ discard block |
||
| 276 | 276 | } |
| 277 | 277 | |
| 278 | 278 | /** |
| 279 | - * Gets all the spotter information based on the latest data entry and coord |
|
| 280 | - * |
|
| 281 | - * @return Array the spotter information |
|
| 282 | - * |
|
| 283 | - */ |
|
| 279 | + * Gets all the spotter information based on the latest data entry and coord |
|
| 280 | + * |
|
| 281 | + * @return Array the spotter information |
|
| 282 | + * |
|
| 283 | + */ |
|
| 284 | 284 | public function getLiveTrackerDatabyCoord($coord, $filter = array()) |
| 285 | 285 | { |
| 286 | 286 | global $globalDBdriver, $globalLiveInterval; |
@@ -304,11 +304,11 @@ discard block |
||
| 304 | 304 | } |
| 305 | 305 | |
| 306 | 306 | /** |
| 307 | - * Gets all the spotter information based on the latest data entry and coord |
|
| 308 | - * |
|
| 309 | - * @return Array the spotter information |
|
| 310 | - * |
|
| 311 | - */ |
|
| 307 | + * Gets all the spotter information based on the latest data entry and coord |
|
| 308 | + * |
|
| 309 | + * @return Array the spotter information |
|
| 310 | + * |
|
| 311 | + */ |
|
| 312 | 312 | public function getMinLiveTrackerDatabyCoord($coord, $filter = array()) |
| 313 | 313 | { |
| 314 | 314 | global $globalDBdriver, $globalLiveInterval; |
@@ -335,11 +335,11 @@ discard block |
||
| 335 | 335 | } |
| 336 | 336 | |
| 337 | 337 | /** |
| 338 | - * Gets all the spotter information based on a user's latitude and longitude |
|
| 339 | - * |
|
| 340 | - * @return Array the spotter information |
|
| 341 | - * |
|
| 342 | - */ |
|
| 338 | + * Gets all the spotter information based on a user's latitude and longitude |
|
| 339 | + * |
|
| 340 | + * @return Array the spotter information |
|
| 341 | + * |
|
| 342 | + */ |
|
| 343 | 343 | public function getLatestTrackerForLayar($lat, $lng, $radius, $interval) |
| 344 | 344 | { |
| 345 | 345 | $Tracker = new Tracker($this->db); |
@@ -352,142 +352,142 @@ discard block |
||
| 352 | 352 | if ($lng != '') |
| 353 | 353 | { |
| 354 | 354 | if (!is_numeric($lng)) |
| 355 | - { |
|
| 356 | - return false; |
|
| 357 | - } |
|
| 358 | - } |
|
| 359 | - |
|
| 360 | - if ($radius != '') |
|
| 361 | - { |
|
| 362 | - if (!is_numeric($radius)) |
|
| 363 | - { |
|
| 364 | - return false; |
|
| 365 | - } |
|
| 366 | - } |
|
| 355 | + { |
|
| 356 | + return false; |
|
| 357 | + } |
|
| 358 | + } |
|
| 359 | + |
|
| 360 | + if ($radius != '') |
|
| 361 | + { |
|
| 362 | + if (!is_numeric($radius)) |
|
| 363 | + { |
|
| 364 | + return false; |
|
| 365 | + } |
|
| 366 | + } |
|
| 367 | 367 | $additional_query = ''; |
| 368 | 368 | if ($interval != '') |
| 369 | - { |
|
| 370 | - if (!is_string($interval)) |
|
| 371 | - { |
|
| 372 | - //$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= tracker_live.date '; |
|
| 373 | - return false; |
|
| 374 | - } else { |
|
| 375 | - if ($interval == '1m') |
|
| 376 | - { |
|
| 377 | - $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= tracker_live.date '; |
|
| 378 | - } else if ($interval == '15m'){ |
|
| 379 | - $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 MINUTE) <= tracker_live.date '; |
|
| 380 | - } |
|
| 381 | - } |
|
| 382 | - } else { |
|
| 383 | - $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= tracker_live.date '; |
|
| 384 | - } |
|
| 385 | - |
|
| 386 | - $query = "SELECT tracker_live.*, ( 6371 * acos( cos( radians(:lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(:lng) ) + sin( radians(:lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM tracker_live |
|
| 369 | + { |
|
| 370 | + if (!is_string($interval)) |
|
| 371 | + { |
|
| 372 | + //$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= tracker_live.date '; |
|
| 373 | + return false; |
|
| 374 | + } else { |
|
| 375 | + if ($interval == '1m') |
|
| 376 | + { |
|
| 377 | + $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= tracker_live.date '; |
|
| 378 | + } else if ($interval == '15m'){ |
|
| 379 | + $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 MINUTE) <= tracker_live.date '; |
|
| 380 | + } |
|
| 381 | + } |
|
| 382 | + } else { |
|
| 383 | + $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= tracker_live.date '; |
|
| 384 | + } |
|
| 385 | + |
|
| 386 | + $query = "SELECT tracker_live.*, ( 6371 * acos( cos( radians(:lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(:lng) ) + sin( radians(:lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM tracker_live |
|
| 387 | 387 | WHERE tracker_live.latitude <> '' |
| 388 | 388 | AND tracker_live.longitude <> '' |
| 389 | 389 | ".$additional_query." |
| 390 | 390 | HAVING distance < :radius |
| 391 | 391 | ORDER BY distance"; |
| 392 | 392 | |
| 393 | - $spotter_array = $Tracker->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng,':radius' => $radius)); |
|
| 393 | + $spotter_array = $Tracker->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng,':radius' => $radius)); |
|
| 394 | 394 | |
| 395 | - return $spotter_array; |
|
| 396 | - } |
|
| 395 | + return $spotter_array; |
|
| 396 | + } |
|
| 397 | 397 | |
| 398 | 398 | |
| 399 | - /** |
|
| 400 | - * Gets all the spotter information based on a particular callsign |
|
| 401 | - * |
|
| 402 | - * @return Array the spotter information |
|
| 403 | - * |
|
| 404 | - */ |
|
| 399 | + /** |
|
| 400 | + * Gets all the spotter information based on a particular callsign |
|
| 401 | + * |
|
| 402 | + * @return Array the spotter information |
|
| 403 | + * |
|
| 404 | + */ |
|
| 405 | 405 | public function getLastLiveTrackerDataByIdent($ident) |
| 406 | 406 | { |
| 407 | 407 | $Tracker = new Tracker($this->db); |
| 408 | 408 | date_default_timezone_set('UTC'); |
| 409 | 409 | |
| 410 | 410 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 411 | - $query = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE l.ident = :ident GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate ORDER BY tracker_live.date DESC'; |
|
| 411 | + $query = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE l.ident = :ident GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate ORDER BY tracker_live.date DESC'; |
|
| 412 | 412 | |
| 413 | 413 | $spotter_array = $Tracker->getDataFromDB($query,array(':ident' => $ident),'',true); |
| 414 | 414 | |
| 415 | 415 | return $spotter_array; |
| 416 | 416 | } |
| 417 | 417 | |
| 418 | - /** |
|
| 419 | - * Gets all the spotter information based on a particular callsign |
|
| 420 | - * |
|
| 421 | - * @return Array the spotter information |
|
| 422 | - * |
|
| 423 | - */ |
|
| 418 | + /** |
|
| 419 | + * Gets all the spotter information based on a particular callsign |
|
| 420 | + * |
|
| 421 | + * @return Array the spotter information |
|
| 422 | + * |
|
| 423 | + */ |
|
| 424 | 424 | public function getDateLiveTrackerDataByIdent($ident,$date) |
| 425 | 425 | { |
| 426 | 426 | $Tracker = new Tracker($this->db); |
| 427 | 427 | date_default_timezone_set('UTC'); |
| 428 | 428 | |
| 429 | 429 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 430 | - $query = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate ORDER BY tracker_live.date DESC'; |
|
| 430 | + $query = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate ORDER BY tracker_live.date DESC'; |
|
| 431 | 431 | |
| 432 | - $date = date('c',$date); |
|
| 432 | + $date = date('c',$date); |
|
| 433 | 433 | $spotter_array = $Tracker->getDataFromDB($query,array(':ident' => $ident,':date' => $date)); |
| 434 | 434 | |
| 435 | 435 | return $spotter_array; |
| 436 | 436 | } |
| 437 | 437 | |
| 438 | - /** |
|
| 439 | - * Gets last spotter information based on a particular callsign |
|
| 440 | - * |
|
| 441 | - * @return Array the spotter information |
|
| 442 | - * |
|
| 443 | - */ |
|
| 438 | + /** |
|
| 439 | + * Gets last spotter information based on a particular callsign |
|
| 440 | + * |
|
| 441 | + * @return Array the spotter information |
|
| 442 | + * |
|
| 443 | + */ |
|
| 444 | 444 | public function getLastLiveTrackerDataById($id) |
| 445 | 445 | { |
| 446 | 446 | $Tracker = new Tracker($this->db); |
| 447 | 447 | date_default_timezone_set('UTC'); |
| 448 | 448 | |
| 449 | 449 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
| 450 | - $query = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE l.famtrackid = :id GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate ORDER BY tracker_live.date DESC'; |
|
| 450 | + $query = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE l.famtrackid = :id GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate ORDER BY tracker_live.date DESC'; |
|
| 451 | 451 | |
| 452 | 452 | $spotter_array = $Tracker->getDataFromDB($query,array(':id' => $id),'',true); |
| 453 | 453 | |
| 454 | 454 | return $spotter_array; |
| 455 | 455 | } |
| 456 | 456 | |
| 457 | - /** |
|
| 458 | - * Gets last spotter information based on a particular callsign |
|
| 459 | - * |
|
| 460 | - * @return Array the spotter information |
|
| 461 | - * |
|
| 462 | - */ |
|
| 457 | + /** |
|
| 458 | + * Gets last spotter information based on a particular callsign |
|
| 459 | + * |
|
| 460 | + * @return Array the spotter information |
|
| 461 | + * |
|
| 462 | + */ |
|
| 463 | 463 | public function getDateLiveTrackerDataById($id,$date) |
| 464 | 464 | { |
| 465 | 465 | $Tracker = new Tracker($this->db); |
| 466 | 466 | date_default_timezone_set('UTC'); |
| 467 | 467 | |
| 468 | 468 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
| 469 | - $query = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE l.famtrackid = :id AND l.date <= :date GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate ORDER BY tracker_live.date DESC'; |
|
| 470 | - $date = date('c',$date); |
|
| 469 | + $query = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE l.famtrackid = :id AND l.date <= :date GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate ORDER BY tracker_live.date DESC'; |
|
| 470 | + $date = date('c',$date); |
|
| 471 | 471 | $spotter_array = $Tracker->getDataFromDB($query,array(':id' => $id,':date' => $date),'',true); |
| 472 | 472 | |
| 473 | 473 | return $spotter_array; |
| 474 | 474 | } |
| 475 | 475 | |
| 476 | - /** |
|
| 477 | - * Gets altitude information based on a particular callsign |
|
| 478 | - * |
|
| 479 | - * @return Array the spotter information |
|
| 480 | - * |
|
| 481 | - */ |
|
| 476 | + /** |
|
| 477 | + * Gets altitude information based on a particular callsign |
|
| 478 | + * |
|
| 479 | + * @return Array the spotter information |
|
| 480 | + * |
|
| 481 | + */ |
|
| 482 | 482 | public function getAltitudeLiveTrackerDataByIdent($ident) |
| 483 | 483 | { |
| 484 | 484 | |
| 485 | 485 | date_default_timezone_set('UTC'); |
| 486 | 486 | |
| 487 | 487 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 488 | - $query = 'SELECT tracker_live.altitude, tracker_live.date FROM tracker_live WHERE tracker_live.ident = :ident'; |
|
| 488 | + $query = 'SELECT tracker_live.altitude, tracker_live.date FROM tracker_live WHERE tracker_live.ident = :ident'; |
|
| 489 | 489 | |
| 490 | - try { |
|
| 490 | + try { |
|
| 491 | 491 | |
| 492 | 492 | $sth = $this->db->prepare($query); |
| 493 | 493 | $sth->execute(array(':ident' => $ident)); |
@@ -500,12 +500,12 @@ discard block |
||
| 500 | 500 | return $spotter_array; |
| 501 | 501 | } |
| 502 | 502 | |
| 503 | - /** |
|
| 504 | - * Gets all the spotter information based on a particular id |
|
| 505 | - * |
|
| 506 | - * @return Array the spotter information |
|
| 507 | - * |
|
| 508 | - */ |
|
| 503 | + /** |
|
| 504 | + * Gets all the spotter information based on a particular id |
|
| 505 | + * |
|
| 506 | + * @return Array the spotter information |
|
| 507 | + * |
|
| 508 | + */ |
|
| 509 | 509 | public function getAllLiveTrackerDataById($id,$liveinterval = false) |
| 510 | 510 | { |
| 511 | 511 | global $globalDBdriver, $globalLiveInterval; |
@@ -533,18 +533,18 @@ discard block |
||
| 533 | 533 | return $spotter_array; |
| 534 | 534 | } |
| 535 | 535 | |
| 536 | - /** |
|
| 537 | - * Gets all the spotter information based on a particular ident |
|
| 538 | - * |
|
| 539 | - * @return Array the spotter information |
|
| 540 | - * |
|
| 541 | - */ |
|
| 536 | + /** |
|
| 537 | + * Gets all the spotter information based on a particular ident |
|
| 538 | + * |
|
| 539 | + * @return Array the spotter information |
|
| 540 | + * |
|
| 541 | + */ |
|
| 542 | 542 | public function getAllLiveTrackerDataByIdent($ident) |
| 543 | 543 | { |
| 544 | 544 | date_default_timezone_set('UTC'); |
| 545 | 545 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 546 | 546 | $query = self::$global_query.' WHERE tracker_live.ident = :ident'; |
| 547 | - try { |
|
| 547 | + try { |
|
| 548 | 548 | |
| 549 | 549 | $sth = $this->db->prepare($query); |
| 550 | 550 | $sth->execute(array(':ident' => $ident)); |
@@ -558,23 +558,23 @@ discard block |
||
| 558 | 558 | |
| 559 | 559 | |
| 560 | 560 | /** |
| 561 | - * Deletes all info in the table |
|
| 562 | - * |
|
| 563 | - * @return String success or false |
|
| 564 | - * |
|
| 565 | - */ |
|
| 561 | + * Deletes all info in the table |
|
| 562 | + * |
|
| 563 | + * @return String success or false |
|
| 564 | + * |
|
| 565 | + */ |
|
| 566 | 566 | public function deleteLiveTrackerData() |
| 567 | 567 | { |
| 568 | 568 | global $globalDBdriver; |
| 569 | 569 | if ($globalDBdriver == 'mysql') { |
| 570 | 570 | //$query = "DELETE FROM tracker_live WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 MINUTE) >= tracker_live.date"; |
| 571 | 571 | $query = 'DELETE FROM tracker_live WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 9 HOUR) >= tracker_live.date'; |
| 572 | - //$query = "DELETE FROM tracker_live WHERE tracker_live.id IN (SELECT tracker_live.id FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) >= tracker_live.date)"; |
|
| 572 | + //$query = "DELETE FROM tracker_live WHERE tracker_live.id IN (SELECT tracker_live.id FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) >= tracker_live.date)"; |
|
| 573 | 573 | } else { |
| 574 | 574 | $query = "DELETE FROM tracker_live WHERE NOW() AT TIME ZONE 'UTC' - INTERVAL '9 HOURS' >= tracker_live.date"; |
| 575 | 575 | } |
| 576 | 576 | |
| 577 | - try { |
|
| 577 | + try { |
|
| 578 | 578 | |
| 579 | 579 | $sth = $this->db->prepare($query); |
| 580 | 580 | $sth->execute(); |
@@ -586,18 +586,18 @@ discard block |
||
| 586 | 586 | } |
| 587 | 587 | |
| 588 | 588 | /** |
| 589 | - * Deletes all info in the table for aircraft not seen since 2 HOUR |
|
| 590 | - * |
|
| 591 | - * @return String success or false |
|
| 592 | - * |
|
| 593 | - */ |
|
| 589 | + * Deletes all info in the table for aircraft not seen since 2 HOUR |
|
| 590 | + * |
|
| 591 | + * @return String success or false |
|
| 592 | + * |
|
| 593 | + */ |
|
| 594 | 594 | public function deleteLiveTrackerDataNotUpdated() |
| 595 | 595 | { |
| 596 | 596 | global $globalDBdriver, $globalDebug; |
| 597 | 597 | if ($globalDBdriver == 'mysql') { |
| 598 | 598 | //$query = 'SELECT famtrackid FROM tracker_live WHERE DATE_SUB(UTC_TIMESTAMP(), INTERVAL 1 HOUR) >= tracker_live.date AND tracker_live.famtrackid NOT IN (SELECT famtrackid FROM tracker_live WHERE DATE_SUB(UTC_TIMESTAMP(), INTERVAL 1 HOUR) < tracker_live.date) LIMIT 800 OFFSET 0'; |
| 599 | - $query = "SELECT tracker_live.famtrackid FROM tracker_live INNER JOIN (SELECT famtrackid,MAX(date) as max_date FROM tracker_live GROUP BY famtrackid) s ON s.famtrackid = tracker_live.famtrackid AND DATE_SUB(UTC_TIMESTAMP(), INTERVAL 2 HOUR) >= s.max_date LIMIT 1200 OFFSET 0"; |
|
| 600 | - try { |
|
| 599 | + $query = "SELECT tracker_live.famtrackid FROM tracker_live INNER JOIN (SELECT famtrackid,MAX(date) as max_date FROM tracker_live GROUP BY famtrackid) s ON s.famtrackid = tracker_live.famtrackid AND DATE_SUB(UTC_TIMESTAMP(), INTERVAL 2 HOUR) >= s.max_date LIMIT 1200 OFFSET 0"; |
|
| 600 | + try { |
|
| 601 | 601 | |
| 602 | 602 | $sth = $this->db->prepare($query); |
| 603 | 603 | $sth->execute(); |
@@ -605,8 +605,8 @@ discard block |
||
| 605 | 605 | return "error"; |
| 606 | 606 | } |
| 607 | 607 | $query_delete = 'DELETE FROM tracker_live WHERE famtrackid IN ('; |
| 608 | - $i = 0; |
|
| 609 | - $j =0; |
|
| 608 | + $i = 0; |
|
| 609 | + $j =0; |
|
| 610 | 610 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 611 | 611 | foreach($all as $row) |
| 612 | 612 | { |
@@ -614,20 +614,20 @@ discard block |
||
| 614 | 614 | $j++; |
| 615 | 615 | if ($j == 30) { |
| 616 | 616 | if ($globalDebug) echo "."; |
| 617 | - try { |
|
| 617 | + try { |
|
| 618 | 618 | |
| 619 | 619 | $sth = $this->db->prepare(substr($query_delete,0,-1).")"); |
| 620 | 620 | $sth->execute(); |
| 621 | 621 | } catch(PDOException $e) { |
| 622 | 622 | return "error"; |
| 623 | 623 | } |
| 624 | - $query_delete = 'DELETE FROM tracker_live WHERE famtrackid IN ('; |
|
| 625 | - $j = 0; |
|
| 624 | + $query_delete = 'DELETE FROM tracker_live WHERE famtrackid IN ('; |
|
| 625 | + $j = 0; |
|
| 626 | 626 | } |
| 627 | 627 | $query_delete .= "'".$row['famtrackid']."',"; |
| 628 | 628 | } |
| 629 | 629 | if ($i > 0) { |
| 630 | - try { |
|
| 630 | + try { |
|
| 631 | 631 | |
| 632 | 632 | $sth = $this->db->prepare(substr($query_delete,0,-1).")"); |
| 633 | 633 | $sth->execute(); |
@@ -638,9 +638,9 @@ discard block |
||
| 638 | 638 | return "success"; |
| 639 | 639 | } elseif ($globalDBdriver == 'pgsql') { |
| 640 | 640 | //$query = "SELECT famtrackid FROM tracker_live WHERE NOW() AT TIME ZONE 'UTC' - INTERVAL '9 HOURS' >= tracker_live.date AND tracker_live.famtrackid NOT IN (SELECT famtrackid FROM tracker_live WHERE NOW() AT TIME ZONE 'UTC' - INTERVAL '9 HOURS' < tracker_live.date) LIMIT 800 OFFSET 0"; |
| 641 | - //$query = "SELECT tracker_live.famtrackid FROM tracker_live INNER JOIN (SELECT famtrackid,MAX(date) as max_date FROM tracker_live GROUP BY famtrackid) s ON s.famtrackid = tracker_live.famtrackid AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 800 OFFSET 0"; |
|
| 642 | - $query = "DELETE FROM tracker_live WHERE famtrackid IN (SELECT tracker_live.famtrackid FROM tracker_live INNER JOIN (SELECT famtrackid,MAX(date) as max_date FROM tracker_live GROUP BY famtrackid) s ON s.famtrackid = tracker_live.famtrackid AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 800 OFFSET 0)"; |
|
| 643 | - try { |
|
| 641 | + //$query = "SELECT tracker_live.famtrackid FROM tracker_live INNER JOIN (SELECT famtrackid,MAX(date) as max_date FROM tracker_live GROUP BY famtrackid) s ON s.famtrackid = tracker_live.famtrackid AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 800 OFFSET 0"; |
|
| 642 | + $query = "DELETE FROM tracker_live WHERE famtrackid IN (SELECT tracker_live.famtrackid FROM tracker_live INNER JOIN (SELECT famtrackid,MAX(date) as max_date FROM tracker_live GROUP BY famtrackid) s ON s.famtrackid = tracker_live.famtrackid AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 800 OFFSET 0)"; |
|
| 643 | + try { |
|
| 644 | 644 | |
| 645 | 645 | $sth = $this->db->prepare($query); |
| 646 | 646 | $sth->execute(); |
@@ -684,17 +684,17 @@ discard block |
||
| 684 | 684 | } |
| 685 | 685 | |
| 686 | 686 | /** |
| 687 | - * Deletes all info in the table for an ident |
|
| 688 | - * |
|
| 689 | - * @return String success or false |
|
| 690 | - * |
|
| 691 | - */ |
|
| 687 | + * Deletes all info in the table for an ident |
|
| 688 | + * |
|
| 689 | + * @return String success or false |
|
| 690 | + * |
|
| 691 | + */ |
|
| 692 | 692 | public function deleteLiveTrackerDataByIdent($ident) |
| 693 | 693 | { |
| 694 | 694 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 695 | 695 | $query = 'DELETE FROM tracker_live WHERE ident = :ident'; |
| 696 | 696 | |
| 697 | - try { |
|
| 697 | + try { |
|
| 698 | 698 | |
| 699 | 699 | $sth = $this->db->prepare($query); |
| 700 | 700 | $sth->execute(array(':ident' => $ident)); |
@@ -706,17 +706,17 @@ discard block |
||
| 706 | 706 | } |
| 707 | 707 | |
| 708 | 708 | /** |
| 709 | - * Deletes all info in the table for an id |
|
| 710 | - * |
|
| 711 | - * @return String success or false |
|
| 712 | - * |
|
| 713 | - */ |
|
| 709 | + * Deletes all info in the table for an id |
|
| 710 | + * |
|
| 711 | + * @return String success or false |
|
| 712 | + * |
|
| 713 | + */ |
|
| 714 | 714 | public function deleteLiveTrackerDataById($id) |
| 715 | 715 | { |
| 716 | 716 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
| 717 | 717 | $query = 'DELETE FROM tracker_live WHERE famtrackid = :id'; |
| 718 | 718 | |
| 719 | - try { |
|
| 719 | + try { |
|
| 720 | 720 | |
| 721 | 721 | $sth = $this->db->prepare($query); |
| 722 | 722 | $sth->execute(array(':id' => $id)); |
@@ -729,11 +729,11 @@ discard block |
||
| 729 | 729 | |
| 730 | 730 | |
| 731 | 731 | /** |
| 732 | - * Gets the aircraft ident within the last hour |
|
| 733 | - * |
|
| 734 | - * @return String the ident |
|
| 735 | - * |
|
| 736 | - */ |
|
| 732 | + * Gets the aircraft ident within the last hour |
|
| 733 | + * |
|
| 734 | + * @return String the ident |
|
| 735 | + * |
|
| 736 | + */ |
|
| 737 | 737 | public function getIdentFromLastHour($ident) |
| 738 | 738 | { |
| 739 | 739 | global $globalDBdriver, $globalTimezone; |
@@ -759,14 +759,14 @@ discard block |
||
| 759 | 759 | $ident_result = $row['ident']; |
| 760 | 760 | } |
| 761 | 761 | return $ident_result; |
| 762 | - } |
|
| 762 | + } |
|
| 763 | 763 | |
| 764 | 764 | /** |
| 765 | - * Check recent aircraft |
|
| 766 | - * |
|
| 767 | - * @return String the ident |
|
| 768 | - * |
|
| 769 | - */ |
|
| 765 | + * Check recent aircraft |
|
| 766 | + * |
|
| 767 | + * @return String the ident |
|
| 768 | + * |
|
| 769 | + */ |
|
| 770 | 770 | public function checkIdentRecent($ident) |
| 771 | 771 | { |
| 772 | 772 | global $globalDBdriver, $globalTimezone; |
@@ -792,14 +792,14 @@ discard block |
||
| 792 | 792 | $ident_result = $row['famtrackid']; |
| 793 | 793 | } |
| 794 | 794 | return $ident_result; |
| 795 | - } |
|
| 795 | + } |
|
| 796 | 796 | |
| 797 | 797 | /** |
| 798 | - * Check recent aircraft by id |
|
| 799 | - * |
|
| 800 | - * @return String the ident |
|
| 801 | - * |
|
| 802 | - */ |
|
| 798 | + * Check recent aircraft by id |
|
| 799 | + * |
|
| 800 | + * @return String the ident |
|
| 801 | + * |
|
| 802 | + */ |
|
| 803 | 803 | public function checkIdRecent($id) |
| 804 | 804 | { |
| 805 | 805 | global $globalDBdriver, $globalTimezone; |
@@ -825,19 +825,19 @@ discard block |
||
| 825 | 825 | $ident_result = $row['famtrackid']; |
| 826 | 826 | } |
| 827 | 827 | return $ident_result; |
| 828 | - } |
|
| 828 | + } |
|
| 829 | 829 | |
| 830 | 830 | /** |
| 831 | - * Adds a new spotter data |
|
| 832 | - * |
|
| 833 | - * @param String $famtrackid the ID from flightaware |
|
| 834 | - * @param String $ident the flight ident |
|
| 835 | - * @param String $aircraft_icao the aircraft type |
|
| 836 | - * @param String $departure_airport_icao the departure airport |
|
| 837 | - * @param String $arrival_airport_icao the arrival airport |
|
| 838 | - * @return String success or false |
|
| 839 | - * |
|
| 840 | - */ |
|
| 831 | + * Adds a new spotter data |
|
| 832 | + * |
|
| 833 | + * @param String $famtrackid the ID from flightaware |
|
| 834 | + * @param String $ident the flight ident |
|
| 835 | + * @param String $aircraft_icao the aircraft type |
|
| 836 | + * @param String $departure_airport_icao the departure airport |
|
| 837 | + * @param String $arrival_airport_icao the arrival airport |
|
| 838 | + * @return String success or false |
|
| 839 | + * |
|
| 840 | + */ |
|
| 841 | 841 | public function addLiveTrackerData($famtrackid = '', $ident = '', $latitude = '', $longitude = '', $altitude = '', $heading = '', $groundspeed = '', $date = '', $putinarchive = false, $comment = '', $type = '',$noarchive = false,$format_source = '', $source_name = '', $over_country = '') |
| 842 | 842 | { |
| 843 | 843 | global $globalURL, $globalArchive, $globalDebug; |
@@ -910,8 +910,8 @@ discard block |
||
| 910 | 910 | $comment = filter_var($comment,FILTER_SANITIZE_STRING); |
| 911 | 911 | $type = filter_var($type,FILTER_SANITIZE_STRING); |
| 912 | 912 | |
| 913 | - if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0; |
|
| 914 | - if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0; |
|
| 913 | + if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0; |
|
| 914 | + if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0; |
|
| 915 | 915 | |
| 916 | 916 | $query = ''; |
| 917 | 917 | if ($globalArchive) { |
@@ -926,18 +926,18 @@ discard block |
||
| 926 | 926 | |
| 927 | 927 | $sth = $this->db->prepare($query); |
| 928 | 928 | $sth->execute($query_values); |
| 929 | - } catch(PDOException $e) { |
|
| 930 | - return "error : ".$e->getMessage(); |
|
| 931 | - } |
|
| 932 | - /* |
|
| 929 | + } catch(PDOException $e) { |
|
| 930 | + return "error : ".$e->getMessage(); |
|
| 931 | + } |
|
| 932 | + /* |
|
| 933 | 933 | echo 'putinarchive : '.$putinarchive."\n"; |
| 934 | 934 | echo 'noarchive : '.$noarchive."\n"; |
| 935 | 935 | */ |
| 936 | 936 | if (isset($globalArchive) && $globalArchive && $putinarchive && $noarchive !== true) { |
| 937 | - if ($globalDebug) echo '(Add to Tracker archive '.$famtrackid.' : '; |
|
| 938 | - $TrackerArchive = new TrackerArchive($this->db); |
|
| 939 | - $result = $TrackerArchive->addTrackerArchiveData($famtrackid, $ident,$latitude, $longitude, $altitude, $heading, $groundspeed, $date, $putinarchive, $comment, $type,$noarchive,$format_source, $source_name, $over_country); |
|
| 940 | - if ($globalDebug) echo $result.')'; |
|
| 937 | + if ($globalDebug) echo '(Add to Tracker archive '.$famtrackid.' : '; |
|
| 938 | + $TrackerArchive = new TrackerArchive($this->db); |
|
| 939 | + $result = $TrackerArchive->addTrackerArchiveData($famtrackid, $ident,$latitude, $longitude, $altitude, $heading, $groundspeed, $date, $putinarchive, $comment, $type,$noarchive,$format_source, $source_name, $over_country); |
|
| 940 | + if ($globalDebug) echo $result.')'; |
|
| 941 | 941 | } |
| 942 | 942 | |
| 943 | 943 | return "success"; |
@@ -17,33 +17,33 @@ discard block |
||
| 17 | 17 | * @param Array $filter the filter |
| 18 | 18 | * @return Array the SQL part |
| 19 | 19 | */ |
| 20 | - public function getFilter($filter = array(),$where = false,$and = false) { |
|
| 20 | + public function getFilter($filter = array(), $where = false, $and = false) { |
|
| 21 | 21 | global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver; |
| 22 | 22 | $filters = array(); |
| 23 | 23 | if (is_array($globalStatsFilters) && isset($globalStatsFilters[$globalFilterName])) { |
| 24 | 24 | if (isset($globalStatsFilters[$globalFilterName][0]['source'])) { |
| 25 | 25 | $filters = $globalStatsFilters[$globalFilterName]; |
| 26 | 26 | } else { |
| 27 | - $filter = array_merge($filter,$globalStatsFilters[$globalFilterName]); |
|
| 27 | + $filter = array_merge($filter, $globalStatsFilters[$globalFilterName]); |
|
| 28 | 28 | } |
| 29 | 29 | } |
| 30 | 30 | if (isset($filter[0]['source'])) { |
| 31 | - $filters = array_merge($filters,$filter); |
|
| 31 | + $filters = array_merge($filters, $filter); |
|
| 32 | 32 | } |
| 33 | - if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter); |
|
| 33 | + if (is_array($globalFilter)) $filter = array_merge($filter, $globalFilter); |
|
| 34 | 34 | $filter_query_join = ''; |
| 35 | 35 | $filter_query_where = ''; |
| 36 | - foreach($filters as $flt) { |
|
| 36 | + foreach ($filters as $flt) { |
|
| 37 | 37 | if (isset($flt['idents']) && !empty($flt['idents'])) { |
| 38 | 38 | if (isset($flt['source'])) { |
| 39 | - $filter_query_join .= " INNER JOIN (SELECT famtrackid FROM tracker_output WHERE tracker_output.ident IN ('".implode("','",$flt['idents'])."') AND tracker_output.format_source IN ('".implode("','",$flt['source'])."')) spid ON spid.famtrackid = tracker_live.famtrackid"; |
|
| 39 | + $filter_query_join .= " INNER JOIN (SELECT famtrackid FROM tracker_output WHERE tracker_output.ident IN ('".implode("','", $flt['idents'])."') AND tracker_output.format_source IN ('".implode("','", $flt['source'])."')) spid ON spid.famtrackid = tracker_live.famtrackid"; |
|
| 40 | 40 | } else { |
| 41 | - $filter_query_join .= " INNER JOIN (SELECT famtrackid FROM tracker_output WHERE tracker_output.ident IN ('".implode("','",$flt['idents'])."')) spid ON spid.famtrackid = tracker_live.famtrackid"; |
|
| 41 | + $filter_query_join .= " INNER JOIN (SELECT famtrackid FROM tracker_output WHERE tracker_output.ident IN ('".implode("','", $flt['idents'])."')) spid ON spid.famtrackid = tracker_live.famtrackid"; |
|
| 42 | 42 | } |
| 43 | 43 | } |
| 44 | 44 | } |
| 45 | 45 | if (isset($filter['source']) && !empty($filter['source'])) { |
| 46 | - $filter_query_where .= " AND format_source IN ('".implode("','",$filter['source'])."')"; |
|
| 46 | + $filter_query_where .= " AND format_source IN ('".implode("','", $filter['source'])."')"; |
|
| 47 | 47 | } |
| 48 | 48 | if (isset($filter['ident']) && !empty($filter['ident'])) { |
| 49 | 49 | $filter_query_where .= " AND ident = '".$filter['ident']."'"; |
@@ -72,15 +72,15 @@ discard block |
||
| 72 | 72 | $filter_query_date .= " AND EXTRACT(DAY FROM tracker_output.date) = '".$filter['day']."'"; |
| 73 | 73 | } |
| 74 | 74 | } |
| 75 | - $filter_query_join .= " INNER JOIN (SELECT famtrackid FROM tracker_output".preg_replace('/^ AND/',' WHERE',$filter_query_date).") sd ON sd.famtrackid = tracker_live.famtrackid"; |
|
| 75 | + $filter_query_join .= " INNER JOIN (SELECT famtrackid FROM tracker_output".preg_replace('/^ AND/', ' WHERE', $filter_query_date).") sd ON sd.famtrackid = tracker_live.famtrackid"; |
|
| 76 | 76 | } |
| 77 | 77 | if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
| 78 | - $filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
| 78 | + $filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')"; |
|
| 79 | 79 | } |
| 80 | 80 | if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE'; |
| 81 | 81 | elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND'; |
| 82 | 82 | if ($filter_query_where != '') { |
| 83 | - $filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where); |
|
| 83 | + $filter_query_where = preg_replace('/^ AND/', ' WHERE', $filter_query_where); |
|
| 84 | 84 | } |
| 85 | 85 | $filter_query = $filter_query_join.$filter_query_where; |
| 86 | 86 | return $filter_query; |
@@ -103,8 +103,8 @@ discard block |
||
| 103 | 103 | if ($limit != '') |
| 104 | 104 | { |
| 105 | 105 | $limit_array = explode(',', $limit); |
| 106 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 107 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 106 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
| 107 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
| 108 | 108 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
| 109 | 109 | { |
| 110 | 110 | $limit_query = ' LIMIT '.$limit_array[1].' OFFSET '.$limit_array[0]; |
@@ -127,7 +127,7 @@ discard block |
||
| 127 | 127 | } else { |
| 128 | 128 | $query = "SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= l.date GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate".$filter_query.$orderby_query; |
| 129 | 129 | } |
| 130 | - $spotter_array = $Tracker->getDataFromDB($query.$limit_query,array(),'',true); |
|
| 130 | + $spotter_array = $Tracker->getDataFromDB($query.$limit_query, array(), '', true); |
|
| 131 | 131 | |
| 132 | 132 | return $spotter_array; |
| 133 | 133 | } |
@@ -143,7 +143,7 @@ discard block |
||
| 143 | 143 | global $globalDBdriver, $globalLiveInterval; |
| 144 | 144 | date_default_timezone_set('UTC'); |
| 145 | 145 | |
| 146 | - $filter_query = $this->getFilter($filter,true,true); |
|
| 146 | + $filter_query = $this->getFilter($filter, true, true); |
|
| 147 | 147 | |
| 148 | 148 | if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
| 149 | 149 | if ($globalDBdriver == 'mysql') { |
@@ -161,7 +161,7 @@ discard block |
||
| 161 | 161 | try { |
| 162 | 162 | $sth = $this->db->prepare($query); |
| 163 | 163 | $sth->execute(); |
| 164 | - } catch(PDOException $e) { |
|
| 164 | + } catch (PDOException $e) { |
|
| 165 | 165 | echo $e->getMessage(); |
| 166 | 166 | die; |
| 167 | 167 | } |
@@ -176,23 +176,23 @@ discard block |
||
| 176 | 176 | * @return Array the spotter information |
| 177 | 177 | * |
| 178 | 178 | */ |
| 179 | - public function getMinLastLiveTrackerData($coord,$filter = array(),$limit = false) |
|
| 179 | + public function getMinLastLiveTrackerData($coord, $filter = array(), $limit = false) |
|
| 180 | 180 | { |
| 181 | 181 | global $globalDBdriver, $globalLiveInterval, $globalArchive, $globalMap3DTrackersLimit; |
| 182 | 182 | date_default_timezone_set('UTC'); |
| 183 | 183 | if (is_array($coord) && !empty($coord)) { |
| 184 | - $minlong = filter_var($coord[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 185 | - $minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 186 | - $maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 187 | - $maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 184 | + $minlong = filter_var($coord[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 185 | + $minlat = filter_var($coord[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 186 | + $maxlong = filter_var($coord[2], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 187 | + $maxlat = filter_var($coord[3], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 188 | 188 | } |
| 189 | - $filter_query = $this->getFilter($filter,true,true); |
|
| 189 | + $filter_query = $this->getFilter($filter, true, true); |
|
| 190 | 190 | |
| 191 | 191 | if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
| 192 | 192 | if (!isset($globalMap3DTrackersLimit) || $globalMap3DTrackersLimit == '') $globalMap3DTrackersLimit = '300'; |
| 193 | 193 | if ($globalDBdriver == 'mysql') { |
| 194 | 194 | if (isset($globalArchive) && $globalArchive) { |
| 195 | - $query = "SELECT * FROM ( |
|
| 195 | + $query = "SELECT * FROM ( |
|
| 196 | 196 | SELECT tracker_archive.ident, tracker_archive.famtrackid,tracker_archive.type,tracker_archive.latitude, tracker_archive.longitude, tracker_archive.altitude, tracker_archive.heading, tracker_archive.ground_speed, tracker_archive.date, tracker_archive.format_source |
| 197 | 197 | FROM tracker_archive INNER JOIN (SELECT famtrackid FROM tracker_live".$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= tracker_live.date) l ON l.famtrackid = tracker_archive.famtrackid "; |
| 198 | 198 | if (isset($maxlat)) $query .= "AND tracker_archive.latitude BETWEEN ".$minlat." AND ".$maxlat." AND tracker_archive.longitude BETWEEN ".$minlong." AND ".$maxlong." "; |
@@ -214,7 +214,7 @@ discard block |
||
| 214 | 214 | } |
| 215 | 215 | } else { |
| 216 | 216 | if (isset($globalArchive) && $globalArchive) { |
| 217 | - $query = "SELECT * FROM ( |
|
| 217 | + $query = "SELECT * FROM ( |
|
| 218 | 218 | SELECT tracker_archive.ident, tracker_archive.famtrackid,tracker_archive.type,tracker_archive.latitude, tracker_archive.longitude, tracker_archive.altitude, tracker_archive.heading, tracker_archive.ground_speed, tracker_archive.date, tracker_archive.format_source |
| 219 | 219 | FROM tracker_archive INNER JOIN (SELECT famtrackid FROM tracker_live".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= tracker_live.date) l ON l.famtrackid = tracker_archive.famtrackid "; |
| 220 | 220 | if (isset($maxlat)) $query .= "AND tracker_archive.latitude BETWEEN ".$minlat." AND ".$maxlat." AND tracker_archive.longitude BETWEEN ".$minlong." AND ".$maxlong." "; |
@@ -238,7 +238,7 @@ discard block |
||
| 238 | 238 | try { |
| 239 | 239 | $sth = $this->db->prepare($query); |
| 240 | 240 | $sth->execute(); |
| 241 | - } catch(PDOException $e) { |
|
| 241 | + } catch (PDOException $e) { |
|
| 242 | 242 | echo $e->getMessage(); |
| 243 | 243 | die; |
| 244 | 244 | } |
@@ -255,7 +255,7 @@ discard block |
||
| 255 | 255 | public function getLiveTrackerCount($filter = array()) |
| 256 | 256 | { |
| 257 | 257 | global $globalDBdriver, $globalLiveInterval; |
| 258 | - $filter_query = $this->getFilter($filter,true,true); |
|
| 258 | + $filter_query = $this->getFilter($filter, true, true); |
|
| 259 | 259 | |
| 260 | 260 | if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
| 261 | 261 | if ($globalDBdriver == 'mysql') { |
@@ -266,7 +266,7 @@ discard block |
||
| 266 | 266 | try { |
| 267 | 267 | $sth = $this->db->prepare($query); |
| 268 | 268 | $sth->execute(); |
| 269 | - } catch(PDOException $e) { |
|
| 269 | + } catch (PDOException $e) { |
|
| 270 | 270 | echo $e->getMessage(); |
| 271 | 271 | die; |
| 272 | 272 | } |
@@ -289,10 +289,10 @@ discard block |
||
| 289 | 289 | $filter_query = $this->getFilter($filter); |
| 290 | 290 | |
| 291 | 291 | if (is_array($coord)) { |
| 292 | - $minlong = filter_var($coord[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 293 | - $minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 294 | - $maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 295 | - $maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 292 | + $minlong = filter_var($coord[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 293 | + $minlat = filter_var($coord[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 294 | + $maxlong = filter_var($coord[2], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 295 | + $maxlat = filter_var($coord[3], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 296 | 296 | } else return array(); |
| 297 | 297 | if ($globalDBdriver == 'mysql') { |
| 298 | 298 | $query = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate AND tracker_live.latitude BETWEEN '.$minlat.' AND '.$maxlat.' AND tracker_live.longitude BETWEEN '.$minlong.' AND '.$maxlong.' GROUP BY tracker_live.famtrackid'.$filter_query; |
@@ -317,17 +317,17 @@ discard block |
||
| 317 | 317 | $filter_query = $this->getFilter($filter); |
| 318 | 318 | |
| 319 | 319 | if (is_array($coord)) { |
| 320 | - $minlong = filter_var($coord[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 321 | - $minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 322 | - $maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 323 | - $maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 320 | + $minlong = filter_var($coord[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 321 | + $minlat = filter_var($coord[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 322 | + $maxlong = filter_var($coord[2], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 323 | + $maxlat = filter_var($coord[3], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 324 | 324 | } else return array(); |
| 325 | 325 | if ($globalDBdriver == 'mysql') { |
| 326 | 326 | $query = 'SELECT tracker_live.ident, tracker_live.famtrackid,tracker_live.type, tracker_live.latitude, tracker_live.longitude, tracker_live.altitude, tracker_live.heading, tracker_live.ground_speed, tracker_live.date, tracker_live.format_source |
| 327 | 327 | FROM tracker_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= tracker_live.date AND tracker_live.latitude <> '0' AND tracker_live.longitude <> '0' AND tracker_live.latitude BETWEEN ".$minlat.' AND '.$maxlat.' AND tracker_live.longitude BETWEEN '.$minlong.' AND '.$maxlong." |
| 328 | 328 | ORDER BY tracker_live.famtrackid, tracker_live.date"; |
| 329 | 329 | } else { |
| 330 | - $query = "SELECT tracker_live.ident, tracker_live.type,tracker_live.famtrackid, tracker_live.latitude, tracker_live.longitude, tracker_live.altitude, tracker_live.heading, tracker_live.ground_speed, tracker_live.date, tracker_live.format_source |
|
| 330 | + $query = "SELECT tracker_live.ident, tracker_live.type,tracker_live.famtrackid, tracker_live.latitude, tracker_live.longitude, tracker_live.altitude, tracker_live.heading, tracker_live.ground_speed, tracker_live.date, tracker_live.format_source |
|
| 331 | 331 | FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= l.date l.latitude BETWEEN ".$minlat." AND ".$maxlat." AND l.longitude BETWEEN ".$minlong." AND ".$maxlong." GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate".$filter_query." tracker_live.latitude <> '0' AND tracker_live.longitude <> '0'"; |
| 332 | 332 | } |
| 333 | 333 | $spotter_array = $Spotter->getDataFromDB($query); |
@@ -375,7 +375,7 @@ discard block |
||
| 375 | 375 | if ($interval == '1m') |
| 376 | 376 | { |
| 377 | 377 | $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= tracker_live.date '; |
| 378 | - } else if ($interval == '15m'){ |
|
| 378 | + } else if ($interval == '15m') { |
|
| 379 | 379 | $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 MINUTE) <= tracker_live.date '; |
| 380 | 380 | } |
| 381 | 381 | } |
@@ -383,14 +383,14 @@ discard block |
||
| 383 | 383 | $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= tracker_live.date '; |
| 384 | 384 | } |
| 385 | 385 | |
| 386 | - $query = "SELECT tracker_live.*, ( 6371 * acos( cos( radians(:lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(:lng) ) + sin( radians(:lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM tracker_live |
|
| 386 | + $query = "SELECT tracker_live.*, ( 6371 * acos( cos( radians(:lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(:lng) ) + sin( radians(:lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM tracker_live |
|
| 387 | 387 | WHERE tracker_live.latitude <> '' |
| 388 | 388 | AND tracker_live.longitude <> '' |
| 389 | 389 | ".$additional_query." |
| 390 | 390 | HAVING distance < :radius |
| 391 | 391 | ORDER BY distance"; |
| 392 | 392 | |
| 393 | - $spotter_array = $Tracker->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng,':radius' => $radius)); |
|
| 393 | + $spotter_array = $Tracker->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng, ':radius' => $radius)); |
|
| 394 | 394 | |
| 395 | 395 | return $spotter_array; |
| 396 | 396 | } |
@@ -408,9 +408,9 @@ discard block |
||
| 408 | 408 | date_default_timezone_set('UTC'); |
| 409 | 409 | |
| 410 | 410 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 411 | - $query = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE l.ident = :ident GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate ORDER BY tracker_live.date DESC'; |
|
| 411 | + $query = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE l.ident = :ident GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate ORDER BY tracker_live.date DESC'; |
|
| 412 | 412 | |
| 413 | - $spotter_array = $Tracker->getDataFromDB($query,array(':ident' => $ident),'',true); |
|
| 413 | + $spotter_array = $Tracker->getDataFromDB($query, array(':ident' => $ident), '', true); |
|
| 414 | 414 | |
| 415 | 415 | return $spotter_array; |
| 416 | 416 | } |
@@ -421,16 +421,16 @@ discard block |
||
| 421 | 421 | * @return Array the spotter information |
| 422 | 422 | * |
| 423 | 423 | */ |
| 424 | - public function getDateLiveTrackerDataByIdent($ident,$date) |
|
| 424 | + public function getDateLiveTrackerDataByIdent($ident, $date) |
|
| 425 | 425 | { |
| 426 | 426 | $Tracker = new Tracker($this->db); |
| 427 | 427 | date_default_timezone_set('UTC'); |
| 428 | 428 | |
| 429 | 429 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 430 | - $query = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate ORDER BY tracker_live.date DESC'; |
|
| 430 | + $query = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate ORDER BY tracker_live.date DESC'; |
|
| 431 | 431 | |
| 432 | - $date = date('c',$date); |
|
| 433 | - $spotter_array = $Tracker->getDataFromDB($query,array(':ident' => $ident,':date' => $date)); |
|
| 432 | + $date = date('c', $date); |
|
| 433 | + $spotter_array = $Tracker->getDataFromDB($query, array(':ident' => $ident, ':date' => $date)); |
|
| 434 | 434 | |
| 435 | 435 | return $spotter_array; |
| 436 | 436 | } |
@@ -447,9 +447,9 @@ discard block |
||
| 447 | 447 | date_default_timezone_set('UTC'); |
| 448 | 448 | |
| 449 | 449 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
| 450 | - $query = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE l.famtrackid = :id GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate ORDER BY tracker_live.date DESC'; |
|
| 450 | + $query = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE l.famtrackid = :id GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate ORDER BY tracker_live.date DESC'; |
|
| 451 | 451 | |
| 452 | - $spotter_array = $Tracker->getDataFromDB($query,array(':id' => $id),'',true); |
|
| 452 | + $spotter_array = $Tracker->getDataFromDB($query, array(':id' => $id), '', true); |
|
| 453 | 453 | |
| 454 | 454 | return $spotter_array; |
| 455 | 455 | } |
@@ -460,15 +460,15 @@ discard block |
||
| 460 | 460 | * @return Array the spotter information |
| 461 | 461 | * |
| 462 | 462 | */ |
| 463 | - public function getDateLiveTrackerDataById($id,$date) |
|
| 463 | + public function getDateLiveTrackerDataById($id, $date) |
|
| 464 | 464 | { |
| 465 | 465 | $Tracker = new Tracker($this->db); |
| 466 | 466 | date_default_timezone_set('UTC'); |
| 467 | 467 | |
| 468 | 468 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
| 469 | - $query = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE l.famtrackid = :id AND l.date <= :date GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate ORDER BY tracker_live.date DESC'; |
|
| 470 | - $date = date('c',$date); |
|
| 471 | - $spotter_array = $Tracker->getDataFromDB($query,array(':id' => $id,':date' => $date),'',true); |
|
| 469 | + $query = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE l.famtrackid = :id AND l.date <= :date GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate ORDER BY tracker_live.date DESC'; |
|
| 470 | + $date = date('c', $date); |
|
| 471 | + $spotter_array = $Tracker->getDataFromDB($query, array(':id' => $id, ':date' => $date), '', true); |
|
| 472 | 472 | |
| 473 | 473 | return $spotter_array; |
| 474 | 474 | } |
@@ -485,13 +485,13 @@ discard block |
||
| 485 | 485 | date_default_timezone_set('UTC'); |
| 486 | 486 | |
| 487 | 487 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 488 | - $query = 'SELECT tracker_live.altitude, tracker_live.date FROM tracker_live WHERE tracker_live.ident = :ident'; |
|
| 488 | + $query = 'SELECT tracker_live.altitude, tracker_live.date FROM tracker_live WHERE tracker_live.ident = :ident'; |
|
| 489 | 489 | |
| 490 | 490 | try { |
| 491 | 491 | |
| 492 | 492 | $sth = $this->db->prepare($query); |
| 493 | 493 | $sth->execute(array(':ident' => $ident)); |
| 494 | - } catch(PDOException $e) { |
|
| 494 | + } catch (PDOException $e) { |
|
| 495 | 495 | echo $e->getMessage(); |
| 496 | 496 | die; |
| 497 | 497 | } |
@@ -506,7 +506,7 @@ discard block |
||
| 506 | 506 | * @return Array the spotter information |
| 507 | 507 | * |
| 508 | 508 | */ |
| 509 | - public function getAllLiveTrackerDataById($id,$liveinterval = false) |
|
| 509 | + public function getAllLiveTrackerDataById($id, $liveinterval = false) |
|
| 510 | 510 | { |
| 511 | 511 | global $globalDBdriver, $globalLiveInterval; |
| 512 | 512 | date_default_timezone_set('UTC'); |
@@ -525,7 +525,7 @@ discard block |
||
| 525 | 525 | try { |
| 526 | 526 | $sth = $this->db->prepare($query); |
| 527 | 527 | $sth->execute(array(':id' => $id)); |
| 528 | - } catch(PDOException $e) { |
|
| 528 | + } catch (PDOException $e) { |
|
| 529 | 529 | echo $e->getMessage(); |
| 530 | 530 | die; |
| 531 | 531 | } |
@@ -543,12 +543,12 @@ discard block |
||
| 543 | 543 | { |
| 544 | 544 | date_default_timezone_set('UTC'); |
| 545 | 545 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 546 | - $query = self::$global_query.' WHERE tracker_live.ident = :ident'; |
|
| 546 | + $query = self::$global_query.' WHERE tracker_live.ident = :ident'; |
|
| 547 | 547 | try { |
| 548 | 548 | |
| 549 | 549 | $sth = $this->db->prepare($query); |
| 550 | 550 | $sth->execute(array(':ident' => $ident)); |
| 551 | - } catch(PDOException $e) { |
|
| 551 | + } catch (PDOException $e) { |
|
| 552 | 552 | echo $e->getMessage(); |
| 553 | 553 | die; |
| 554 | 554 | } |
@@ -578,7 +578,7 @@ discard block |
||
| 578 | 578 | |
| 579 | 579 | $sth = $this->db->prepare($query); |
| 580 | 580 | $sth->execute(); |
| 581 | - } catch(PDOException $e) { |
|
| 581 | + } catch (PDOException $e) { |
|
| 582 | 582 | return "error"; |
| 583 | 583 | } |
| 584 | 584 | |
@@ -601,14 +601,14 @@ discard block |
||
| 601 | 601 | |
| 602 | 602 | $sth = $this->db->prepare($query); |
| 603 | 603 | $sth->execute(); |
| 604 | - } catch(PDOException $e) { |
|
| 604 | + } catch (PDOException $e) { |
|
| 605 | 605 | return "error"; |
| 606 | 606 | } |
| 607 | 607 | $query_delete = 'DELETE FROM tracker_live WHERE famtrackid IN ('; |
| 608 | 608 | $i = 0; |
| 609 | - $j =0; |
|
| 609 | + $j = 0; |
|
| 610 | 610 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 611 | - foreach($all as $row) |
|
| 611 | + foreach ($all as $row) |
|
| 612 | 612 | { |
| 613 | 613 | $i++; |
| 614 | 614 | $j++; |
@@ -616,9 +616,9 @@ discard block |
||
| 616 | 616 | if ($globalDebug) echo "."; |
| 617 | 617 | try { |
| 618 | 618 | |
| 619 | - $sth = $this->db->prepare(substr($query_delete,0,-1).")"); |
|
| 619 | + $sth = $this->db->prepare(substr($query_delete, 0, -1).")"); |
|
| 620 | 620 | $sth->execute(); |
| 621 | - } catch(PDOException $e) { |
|
| 621 | + } catch (PDOException $e) { |
|
| 622 | 622 | return "error"; |
| 623 | 623 | } |
| 624 | 624 | $query_delete = 'DELETE FROM tracker_live WHERE famtrackid IN ('; |
@@ -629,9 +629,9 @@ discard block |
||
| 629 | 629 | if ($i > 0) { |
| 630 | 630 | try { |
| 631 | 631 | |
| 632 | - $sth = $this->db->prepare(substr($query_delete,0,-1).")"); |
|
| 632 | + $sth = $this->db->prepare(substr($query_delete, 0, -1).")"); |
|
| 633 | 633 | $sth->execute(); |
| 634 | - } catch(PDOException $e) { |
|
| 634 | + } catch (PDOException $e) { |
|
| 635 | 635 | return "error"; |
| 636 | 636 | } |
| 637 | 637 | } |
@@ -644,7 +644,7 @@ discard block |
||
| 644 | 644 | |
| 645 | 645 | $sth = $this->db->prepare($query); |
| 646 | 646 | $sth->execute(); |
| 647 | - } catch(PDOException $e) { |
|
| 647 | + } catch (PDOException $e) { |
|
| 648 | 648 | return "error"; |
| 649 | 649 | } |
| 650 | 650 | /* $query_delete = "DELETE FROM tracker_live WHERE famtrackid IN ("; |
@@ -692,13 +692,13 @@ discard block |
||
| 692 | 692 | public function deleteLiveTrackerDataByIdent($ident) |
| 693 | 693 | { |
| 694 | 694 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 695 | - $query = 'DELETE FROM tracker_live WHERE ident = :ident'; |
|
| 695 | + $query = 'DELETE FROM tracker_live WHERE ident = :ident'; |
|
| 696 | 696 | |
| 697 | 697 | try { |
| 698 | 698 | |
| 699 | 699 | $sth = $this->db->prepare($query); |
| 700 | 700 | $sth->execute(array(':ident' => $ident)); |
| 701 | - } catch(PDOException $e) { |
|
| 701 | + } catch (PDOException $e) { |
|
| 702 | 702 | return "error"; |
| 703 | 703 | } |
| 704 | 704 | |
@@ -714,13 +714,13 @@ discard block |
||
| 714 | 714 | public function deleteLiveTrackerDataById($id) |
| 715 | 715 | { |
| 716 | 716 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
| 717 | - $query = 'DELETE FROM tracker_live WHERE famtrackid = :id'; |
|
| 717 | + $query = 'DELETE FROM tracker_live WHERE famtrackid = :id'; |
|
| 718 | 718 | |
| 719 | 719 | try { |
| 720 | 720 | |
| 721 | 721 | $sth = $this->db->prepare($query); |
| 722 | 722 | $sth->execute(array(':id' => $id)); |
| 723 | - } catch(PDOException $e) { |
|
| 723 | + } catch (PDOException $e) { |
|
| 724 | 724 | return "error"; |
| 725 | 725 | } |
| 726 | 726 | |
@@ -738,13 +738,13 @@ discard block |
||
| 738 | 738 | { |
| 739 | 739 | global $globalDBdriver, $globalTimezone; |
| 740 | 740 | if ($globalDBdriver == 'mysql') { |
| 741 | - $query = 'SELECT tracker_live.ident FROM tracker_live |
|
| 741 | + $query = 'SELECT tracker_live.ident FROM tracker_live |
|
| 742 | 742 | WHERE tracker_live.ident = :ident |
| 743 | 743 | AND tracker_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) |
| 744 | 744 | AND tracker_live.date < UTC_TIMESTAMP()'; |
| 745 | 745 | $query_data = array(':ident' => $ident); |
| 746 | 746 | } else { |
| 747 | - $query = "SELECT tracker_live.ident FROM tracker_live |
|
| 747 | + $query = "SELECT tracker_live.ident FROM tracker_live |
|
| 748 | 748 | WHERE tracker_live.ident = :ident |
| 749 | 749 | AND tracker_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '1 HOURS' |
| 750 | 750 | AND tracker_live.date < now() AT TIME ZONE 'UTC'"; |
@@ -753,8 +753,8 @@ discard block |
||
| 753 | 753 | |
| 754 | 754 | $sth = $this->db->prepare($query); |
| 755 | 755 | $sth->execute($query_data); |
| 756 | - $ident_result=''; |
|
| 757 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 756 | + $ident_result = ''; |
|
| 757 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 758 | 758 | { |
| 759 | 759 | $ident_result = $row['ident']; |
| 760 | 760 | } |
@@ -771,13 +771,13 @@ discard block |
||
| 771 | 771 | { |
| 772 | 772 | global $globalDBdriver, $globalTimezone; |
| 773 | 773 | if ($globalDBdriver == 'mysql') { |
| 774 | - $query = 'SELECT tracker_live.ident, tracker_live.famtrackid FROM tracker_live |
|
| 774 | + $query = 'SELECT tracker_live.ident, tracker_live.famtrackid FROM tracker_live |
|
| 775 | 775 | WHERE tracker_live.ident = :ident |
| 776 | 776 | AND tracker_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 MINUTE)'; |
| 777 | 777 | // AND tracker_live.date < UTC_TIMESTAMP()"; |
| 778 | 778 | $query_data = array(':ident' => $ident); |
| 779 | 779 | } else { |
| 780 | - $query = "SELECT tracker_live.ident, tracker_live.famtrackid FROM tracker_live |
|
| 780 | + $query = "SELECT tracker_live.ident, tracker_live.famtrackid FROM tracker_live |
|
| 781 | 781 | WHERE tracker_live.ident = :ident |
| 782 | 782 | AND tracker_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '30 MINUTES'"; |
| 783 | 783 | // AND tracker_live.date < now() AT TIME ZONE 'UTC'"; |
@@ -786,8 +786,8 @@ discard block |
||
| 786 | 786 | |
| 787 | 787 | $sth = $this->db->prepare($query); |
| 788 | 788 | $sth->execute($query_data); |
| 789 | - $ident_result=''; |
|
| 790 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 789 | + $ident_result = ''; |
|
| 790 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 791 | 791 | { |
| 792 | 792 | $ident_result = $row['famtrackid']; |
| 793 | 793 | } |
@@ -804,13 +804,13 @@ discard block |
||
| 804 | 804 | { |
| 805 | 805 | global $globalDBdriver, $globalTimezone; |
| 806 | 806 | if ($globalDBdriver == 'mysql') { |
| 807 | - $query = 'SELECT tracker_live.ident, tracker_live.famtrackid FROM tracker_live |
|
| 807 | + $query = 'SELECT tracker_live.ident, tracker_live.famtrackid FROM tracker_live |
|
| 808 | 808 | WHERE tracker_live.famtrackid = :id |
| 809 | 809 | AND tracker_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 10 HOUR)'; |
| 810 | 810 | // AND tracker_live.date < UTC_TIMESTAMP()"; |
| 811 | 811 | $query_data = array(':id' => $id); |
| 812 | 812 | } else { |
| 813 | - $query = "SELECT tracker_live.ident, tracker_live.famtrackid FROM tracker_live |
|
| 813 | + $query = "SELECT tracker_live.ident, tracker_live.famtrackid FROM tracker_live |
|
| 814 | 814 | WHERE tracker_live.famtrackid = :id |
| 815 | 815 | AND tracker_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '10 HOUR'"; |
| 816 | 816 | // AND tracker_live.date < now() AT TIME ZONE 'UTC'"; |
@@ -819,8 +819,8 @@ discard block |
||
| 819 | 819 | |
| 820 | 820 | $sth = $this->db->prepare($query); |
| 821 | 821 | $sth->execute($query_data); |
| 822 | - $ident_result=''; |
|
| 823 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 822 | + $ident_result = ''; |
|
| 823 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 824 | 824 | { |
| 825 | 825 | $ident_result = $row['famtrackid']; |
| 826 | 826 | } |
@@ -838,7 +838,7 @@ discard block |
||
| 838 | 838 | * @return String success or false |
| 839 | 839 | * |
| 840 | 840 | */ |
| 841 | - public function addLiveTrackerData($famtrackid = '', $ident = '', $latitude = '', $longitude = '', $altitude = '', $heading = '', $groundspeed = '', $date = '', $putinarchive = false, $comment = '', $type = '',$noarchive = false,$format_source = '', $source_name = '', $over_country = '') |
|
| 841 | + public function addLiveTrackerData($famtrackid = '', $ident = '', $latitude = '', $longitude = '', $altitude = '', $heading = '', $groundspeed = '', $date = '', $putinarchive = false, $comment = '', $type = '', $noarchive = false, $format_source = '', $source_name = '', $over_country = '') |
|
| 842 | 842 | { |
| 843 | 843 | global $globalURL, $globalArchive, $globalDebug; |
| 844 | 844 | $Common = new Common(); |
@@ -897,21 +897,21 @@ discard block |
||
| 897 | 897 | if ($date == '') $date = date("Y-m-d H:i:s", time()); |
| 898 | 898 | |
| 899 | 899 | |
| 900 | - $famtrackid = filter_var($famtrackid,FILTER_SANITIZE_STRING); |
|
| 901 | - $ident = filter_var($ident,FILTER_SANITIZE_STRING); |
|
| 902 | - $latitude = filter_var($latitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 903 | - $longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 904 | - $altitude = filter_var($altitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 905 | - $heading = filter_var($heading,FILTER_SANITIZE_NUMBER_INT); |
|
| 906 | - $groundspeed = filter_var($groundspeed,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 907 | - $format_source = filter_var($format_source,FILTER_SANITIZE_STRING); |
|
| 908 | - $source_name = filter_var($source_name,FILTER_SANITIZE_STRING); |
|
| 909 | - $over_country = filter_var($over_country,FILTER_SANITIZE_STRING); |
|
| 910 | - $comment = filter_var($comment,FILTER_SANITIZE_STRING); |
|
| 911 | - $type = filter_var($type,FILTER_SANITIZE_STRING); |
|
| 912 | - |
|
| 913 | - if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0; |
|
| 914 | - if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0; |
|
| 900 | + $famtrackid = filter_var($famtrackid, FILTER_SANITIZE_STRING); |
|
| 901 | + $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
| 902 | + $latitude = filter_var($latitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 903 | + $longitude = filter_var($longitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 904 | + $altitude = filter_var($altitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 905 | + $heading = filter_var($heading, FILTER_SANITIZE_NUMBER_INT); |
|
| 906 | + $groundspeed = filter_var($groundspeed, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 907 | + $format_source = filter_var($format_source, FILTER_SANITIZE_STRING); |
|
| 908 | + $source_name = filter_var($source_name, FILTER_SANITIZE_STRING); |
|
| 909 | + $over_country = filter_var($over_country, FILTER_SANITIZE_STRING); |
|
| 910 | + $comment = filter_var($comment, FILTER_SANITIZE_STRING); |
|
| 911 | + $type = filter_var($type, FILTER_SANITIZE_STRING); |
|
| 912 | + |
|
| 913 | + if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0; |
|
| 914 | + if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0; |
|
| 915 | 915 | |
| 916 | 916 | $query = ''; |
| 917 | 917 | if ($globalArchive) { |
@@ -921,12 +921,12 @@ discard block |
||
| 921 | 921 | $query .= 'INSERT INTO tracker_live (famtrackid, ident, latitude, longitude, altitude, heading, ground_speed, date, format_source, source_name, over_country, comment, type) |
| 922 | 922 | VALUES (:famtrackid,:ident,:latitude,:longitude,:altitude,:heading,:groundspeed,:date,:format_source, :source_name, :over_country,:comment,:type)'; |
| 923 | 923 | |
| 924 | - $query_values = array(':famtrackid' => $famtrackid,':ident' => $ident,':latitude' => $latitude,':longitude' => $longitude,':altitude' => $altitude,':heading' => $heading,':groundspeed' => $groundspeed,':date' => $date, ':format_source' => $format_source, ':source_name' => $source_name, ':over_country' => $over_country,':comment' => $comment,':type' => $type); |
|
| 924 | + $query_values = array(':famtrackid' => $famtrackid, ':ident' => $ident, ':latitude' => $latitude, ':longitude' => $longitude, ':altitude' => $altitude, ':heading' => $heading, ':groundspeed' => $groundspeed, ':date' => $date, ':format_source' => $format_source, ':source_name' => $source_name, ':over_country' => $over_country, ':comment' => $comment, ':type' => $type); |
|
| 925 | 925 | try { |
| 926 | 926 | |
| 927 | 927 | $sth = $this->db->prepare($query); |
| 928 | 928 | $sth->execute($query_values); |
| 929 | - } catch(PDOException $e) { |
|
| 929 | + } catch (PDOException $e) { |
|
| 930 | 930 | return "error : ".$e->getMessage(); |
| 931 | 931 | } |
| 932 | 932 | /* |
@@ -936,7 +936,7 @@ discard block |
||
| 936 | 936 | if (isset($globalArchive) && $globalArchive && $putinarchive && $noarchive !== true) { |
| 937 | 937 | if ($globalDebug) echo '(Add to Tracker archive '.$famtrackid.' : '; |
| 938 | 938 | $TrackerArchive = new TrackerArchive($this->db); |
| 939 | - $result = $TrackerArchive->addTrackerArchiveData($famtrackid, $ident,$latitude, $longitude, $altitude, $heading, $groundspeed, $date, $putinarchive, $comment, $type,$noarchive,$format_source, $source_name, $over_country); |
|
| 939 | + $result = $TrackerArchive->addTrackerArchiveData($famtrackid, $ident, $latitude, $longitude, $altitude, $heading, $groundspeed, $date, $putinarchive, $comment, $type, $noarchive, $format_source, $source_name, $over_country); |
|
| 940 | 940 | if ($globalDebug) echo $result.')'; |
| 941 | 941 | } |
| 942 | 942 | |
@@ -946,7 +946,7 @@ discard block |
||
| 946 | 946 | |
| 947 | 947 | public function getOrderBy() |
| 948 | 948 | { |
| 949 | - $orderby = array("aircraft_asc" => array("key" => "aircraft_asc", "value" => "Aircraft Type - ASC", "sql" => "ORDER BY tracker_live.aircraft_icao ASC"), "aircraft_desc" => array("key" => "aircraft_desc", "value" => "Aircraft Type - DESC", "sql" => "ORDER BY tracker_live.aircraft_icao DESC"),"manufacturer_asc" => array("key" => "manufacturer_asc", "value" => "Aircraft Manufacturer - ASC", "sql" => "ORDER BY tracker_live.aircraft_manufacturer ASC"), "manufacturer_desc" => array("key" => "manufacturer_desc", "value" => "Aircraft Manufacturer - DESC", "sql" => "ORDER BY tracker_live.aircraft_manufacturer DESC"),"airline_name_asc" => array("key" => "airline_name_asc", "value" => "Airline Name - ASC", "sql" => "ORDER BY tracker_live.airline_name ASC"), "airline_name_desc" => array("key" => "airline_name_desc", "value" => "Airline Name - DESC", "sql" => "ORDER BY tracker_live.airline_name DESC"), "ident_asc" => array("key" => "ident_asc", "value" => "Ident - ASC", "sql" => "ORDER BY tracker_live.ident ASC"), "ident_desc" => array("key" => "ident_desc", "value" => "Ident - DESC", "sql" => "ORDER BY tracker_live.ident DESC"), "airport_departure_asc" => array("key" => "airport_departure_asc", "value" => "Departure Airport - ASC", "sql" => "ORDER BY tracker_live.departure_airport_city ASC"), "airport_departure_desc" => array("key" => "airport_departure_desc", "value" => "Departure Airport - DESC", "sql" => "ORDER BY tracker_live.departure_airport_city DESC"), "airport_arrival_asc" => array("key" => "airport_arrival_asc", "value" => "Arrival Airport - ASC", "sql" => "ORDER BY tracker_live.arrival_airport_city ASC"), "airport_arrival_desc" => array("key" => "airport_arrival_desc", "value" => "Arrival Airport - DESC", "sql" => "ORDER BY tracker_live.arrival_airport_city DESC"), "date_asc" => array("key" => "date_asc", "value" => "Date - ASC", "sql" => "ORDER BY tracker_live.date ASC"), "date_desc" => array("key" => "date_desc", "value" => "Date - DESC", "sql" => "ORDER BY tracker_live.date DESC")); |
|
| 949 | + $orderby = array("aircraft_asc" => array("key" => "aircraft_asc", "value" => "Aircraft Type - ASC", "sql" => "ORDER BY tracker_live.aircraft_icao ASC"), "aircraft_desc" => array("key" => "aircraft_desc", "value" => "Aircraft Type - DESC", "sql" => "ORDER BY tracker_live.aircraft_icao DESC"), "manufacturer_asc" => array("key" => "manufacturer_asc", "value" => "Aircraft Manufacturer - ASC", "sql" => "ORDER BY tracker_live.aircraft_manufacturer ASC"), "manufacturer_desc" => array("key" => "manufacturer_desc", "value" => "Aircraft Manufacturer - DESC", "sql" => "ORDER BY tracker_live.aircraft_manufacturer DESC"), "airline_name_asc" => array("key" => "airline_name_asc", "value" => "Airline Name - ASC", "sql" => "ORDER BY tracker_live.airline_name ASC"), "airline_name_desc" => array("key" => "airline_name_desc", "value" => "Airline Name - DESC", "sql" => "ORDER BY tracker_live.airline_name DESC"), "ident_asc" => array("key" => "ident_asc", "value" => "Ident - ASC", "sql" => "ORDER BY tracker_live.ident ASC"), "ident_desc" => array("key" => "ident_desc", "value" => "Ident - DESC", "sql" => "ORDER BY tracker_live.ident DESC"), "airport_departure_asc" => array("key" => "airport_departure_asc", "value" => "Departure Airport - ASC", "sql" => "ORDER BY tracker_live.departure_airport_city ASC"), "airport_departure_desc" => array("key" => "airport_departure_desc", "value" => "Departure Airport - DESC", "sql" => "ORDER BY tracker_live.departure_airport_city DESC"), "airport_arrival_asc" => array("key" => "airport_arrival_asc", "value" => "Arrival Airport - ASC", "sql" => "ORDER BY tracker_live.arrival_airport_city ASC"), "airport_arrival_desc" => array("key" => "airport_arrival_desc", "value" => "Arrival Airport - DESC", "sql" => "ORDER BY tracker_live.arrival_airport_city DESC"), "date_asc" => array("key" => "date_asc", "value" => "Date - ASC", "sql" => "ORDER BY tracker_live.date ASC"), "date_desc" => array("key" => "date_desc", "value" => "Date - DESC", "sql" => "ORDER BY tracker_live.date DESC")); |
|
| 950 | 950 | return $orderby; |
| 951 | 951 | } |
| 952 | 952 | |
@@ -8,7 +8,9 @@ discard block |
||
| 8 | 8 | public function __construct($dbc = null) { |
| 9 | 9 | $Connection = new Connection($dbc); |
| 10 | 10 | $this->db = $Connection->db(); |
| 11 | - if ($this->db === null) die('Error: No DB connection.'); |
|
| 11 | + if ($this->db === null) { |
|
| 12 | + die('Error: No DB connection.'); |
|
| 13 | + } |
|
| 12 | 14 | } |
| 13 | 15 | |
| 14 | 16 | |
@@ -30,7 +32,9 @@ discard block |
||
| 30 | 32 | if (isset($filter[0]['source'])) { |
| 31 | 33 | $filters = array_merge($filters,$filter); |
| 32 | 34 | } |
| 33 | - if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter); |
|
| 35 | + if (is_array($globalFilter)) { |
|
| 36 | + $filter = array_merge($filter,$globalFilter); |
|
| 37 | + } |
|
| 34 | 38 | $filter_query_join = ''; |
| 35 | 39 | $filter_query_where = ''; |
| 36 | 40 | foreach($filters as $flt) { |
@@ -77,8 +81,11 @@ discard block |
||
| 77 | 81 | if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
| 78 | 82 | $filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
| 79 | 83 | } |
| 80 | - if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE'; |
|
| 81 | - elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND'; |
|
| 84 | + if ($filter_query_where == '' && $where) { |
|
| 85 | + $filter_query_where = ' WHERE'; |
|
| 86 | + } elseif ($filter_query_where != '' && $and) { |
|
| 87 | + $filter_query_where .= ' AND'; |
|
| 88 | + } |
|
| 82 | 89 | if ($filter_query_where != '') { |
| 83 | 90 | $filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where); |
| 84 | 91 | } |
@@ -120,7 +127,9 @@ discard block |
||
| 120 | 127 | } |
| 121 | 128 | } |
| 122 | 129 | |
| 123 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
| 130 | + if (!isset($globalLiveInterval)) { |
|
| 131 | + $globalLiveInterval = '200'; |
|
| 132 | + } |
|
| 124 | 133 | if ($globalDBdriver == 'mysql') { |
| 125 | 134 | //$query = "SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 SECOND) <= l.date GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate"; |
| 126 | 135 | $query = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate'.$filter_query.$orderby_query; |
@@ -145,7 +154,9 @@ discard block |
||
| 145 | 154 | |
| 146 | 155 | $filter_query = $this->getFilter($filter,true,true); |
| 147 | 156 | |
| 148 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
| 157 | + if (!isset($globalLiveInterval)) { |
|
| 158 | + $globalLiveInterval = '200'; |
|
| 159 | + } |
|
| 149 | 160 | if ($globalDBdriver == 'mysql') { |
| 150 | 161 | $query = 'SELECT tracker_live.ident, tracker_live.type,tracker_live.famtrackid, tracker_live.latitude, tracker_live.longitude, tracker_live.altitude, tracker_live.heading, tracker_live.ground_speed, tracker_live.date, tracker_live.format_source |
| 151 | 162 | FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate'.$filter_query." tracker_live.latitude <> 0 AND tracker_live.longitude <> 0"; |
@@ -188,50 +199,74 @@ discard block |
||
| 188 | 199 | } |
| 189 | 200 | $filter_query = $this->getFilter($filter,true,true); |
| 190 | 201 | |
| 191 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
| 192 | - if (!isset($globalMap3DTrackersLimit) || $globalMap3DTrackersLimit == '') $globalMap3DTrackersLimit = '300'; |
|
| 202 | + if (!isset($globalLiveInterval)) { |
|
| 203 | + $globalLiveInterval = '200'; |
|
| 204 | + } |
|
| 205 | + if (!isset($globalMap3DTrackersLimit) || $globalMap3DTrackersLimit == '') { |
|
| 206 | + $globalMap3DTrackersLimit = '300'; |
|
| 207 | + } |
|
| 193 | 208 | if ($globalDBdriver == 'mysql') { |
| 194 | 209 | if (isset($globalArchive) && $globalArchive) { |
| 195 | 210 | $query = "SELECT * FROM ( |
| 196 | 211 | SELECT tracker_archive.ident, tracker_archive.famtrackid,tracker_archive.type,tracker_archive.latitude, tracker_archive.longitude, tracker_archive.altitude, tracker_archive.heading, tracker_archive.ground_speed, tracker_archive.date, tracker_archive.format_source |
| 197 | 212 | FROM tracker_archive INNER JOIN (SELECT famtrackid FROM tracker_live".$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= tracker_live.date) l ON l.famtrackid = tracker_archive.famtrackid "; |
| 198 | - if (isset($maxlat)) $query .= "AND tracker_archive.latitude BETWEEN ".$minlat." AND ".$maxlat." AND tracker_archive.longitude BETWEEN ".$minlong." AND ".$maxlong." "; |
|
| 213 | + if (isset($maxlat)) { |
|
| 214 | + $query .= "AND tracker_archive.latitude BETWEEN ".$minlat." AND ".$maxlat." AND tracker_archive.longitude BETWEEN ".$minlong." AND ".$maxlong." "; |
|
| 215 | + } |
|
| 199 | 216 | $query .= "UNION |
| 200 | 217 | SELECT tracker_live.ident, tracker_live.famtrackid, tracker_live.type,tracker_live.latitude, tracker_live.longitude, tracker_live.altitude, tracker_live.heading, tracker_live.ground_speed, tracker_live.date, tracker_live.format_source |
| 201 | 218 | FROM tracker_live".$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= tracker_live.date "; |
| 202 | - if (isset($maxlat)) $query .= "AND tracker_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND tracker_live.longitude BETWEEN ".$minlong." AND ".$maxlong; |
|
| 219 | + if (isset($maxlat)) { |
|
| 220 | + $query .= "AND tracker_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND tracker_live.longitude BETWEEN ".$minlong." AND ".$maxlong; |
|
| 221 | + } |
|
| 203 | 222 | $query .= ") AS tracker |
| 204 | 223 | WHERE latitude <> '0' AND longitude <> '0' |
| 205 | 224 | ORDER BY famtrackid, date"; |
| 206 | - if ($limit) $query .= " LIMIT ".$globalMap3DTrackersLimit; |
|
| 225 | + if ($limit) { |
|
| 226 | + $query .= " LIMIT ".$globalMap3DTrackersLimit; |
|
| 227 | + } |
|
| 207 | 228 | } else { |
| 208 | 229 | $query = 'SELECT tracker_live.ident, tracker_live.famtrackid,tracker_live.type, tracker_live.latitude, tracker_live.longitude, tracker_live.altitude, tracker_live.heading, tracker_live.ground_speed, tracker_live.date, tracker_live.format_source |
| 209 | 230 | FROM tracker_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= tracker_live.date "; |
| 210 | - if (isset($maxlat)) $query .= "AND tracker_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND tracker_live.longitude BETWEEN ".$minlong." AND ".$maxlong." "; |
|
| 231 | + if (isset($maxlat)) { |
|
| 232 | + $query .= "AND tracker_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND tracker_live.longitude BETWEEN ".$minlong." AND ".$maxlong." "; |
|
| 233 | + } |
|
| 211 | 234 | $query .= "AND tracker_live.latitude <> '0' AND tracker_live.longitude <> '0' |
| 212 | 235 | ORDER BY tracker_live.famtrackid, tracker_live.date"; |
| 213 | - if ($limit) $query .= " LIMIT ".$globalMap3DTrackersLimit; |
|
| 236 | + if ($limit) { |
|
| 237 | + $query .= " LIMIT ".$globalMap3DTrackersLimit; |
|
| 238 | + } |
|
| 214 | 239 | } |
| 215 | 240 | } else { |
| 216 | 241 | if (isset($globalArchive) && $globalArchive) { |
| 217 | 242 | $query = "SELECT * FROM ( |
| 218 | 243 | SELECT tracker_archive.ident, tracker_archive.famtrackid,tracker_archive.type,tracker_archive.latitude, tracker_archive.longitude, tracker_archive.altitude, tracker_archive.heading, tracker_archive.ground_speed, tracker_archive.date, tracker_archive.format_source |
| 219 | 244 | FROM tracker_archive INNER JOIN (SELECT famtrackid FROM tracker_live".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= tracker_live.date) l ON l.famtrackid = tracker_archive.famtrackid "; |
| 220 | - if (isset($maxlat)) $query .= "AND tracker_archive.latitude BETWEEN ".$minlat." AND ".$maxlat." AND tracker_archive.longitude BETWEEN ".$minlong." AND ".$maxlong." "; |
|
| 245 | + if (isset($maxlat)) { |
|
| 246 | + $query .= "AND tracker_archive.latitude BETWEEN ".$minlat." AND ".$maxlat." AND tracker_archive.longitude BETWEEN ".$minlong." AND ".$maxlong." "; |
|
| 247 | + } |
|
| 221 | 248 | $query .= "UNION |
| 222 | 249 | SELECT tracker_live.ident, tracker_live.famtrackid, tracker_live.type,tracker_live.latitude, tracker_live.longitude, tracker_live.altitude, tracker_live.heading, tracker_live.ground_speed, tracker_live.date, tracker_live.format_source |
| 223 | 250 | FROM tracker_live".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= tracker_live.date"; |
| 224 | - if (isset($maxlat)) $query .= " AND tracker_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND tracker_live.longitude BETWEEN ".$minlong." AND ".$maxlong; |
|
| 251 | + if (isset($maxlat)) { |
|
| 252 | + $query .= " AND tracker_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND tracker_live.longitude BETWEEN ".$minlong." AND ".$maxlong; |
|
| 253 | + } |
|
| 225 | 254 | $query .= ") AS tracker |
| 226 | 255 | WHERE latitude <> '0' AND longitude <> '0' |
| 227 | 256 | ORDER BY famtrackid, date"; |
| 228 | - if ($limit) $query .= " LIMIT ".$globalMap3DTrackersLimit; |
|
| 257 | + if ($limit) { |
|
| 258 | + $query .= " LIMIT ".$globalMap3DTrackersLimit; |
|
| 259 | + } |
|
| 229 | 260 | } else { |
| 230 | 261 | $query = "SELECT tracker_live.ident, tracker_live.famtrackid, tracker_live.type,tracker_live.latitude, tracker_live.longitude, tracker_live.altitude, tracker_live.heading, tracker_live.ground_speed, tracker_live.date, tracker_live.format_source |
| 231 | 262 | FROM tracker_live".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= tracker_live.date AND tracker_live.latitude <> '0' AND tracker_live.longitude <> '0' "; |
| 232 | - if (isset($maxlat)) $query .= "AND tracker_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND tracker_live.longitude BETWEEN ".$minlong." AND ".$maxlong." "; |
|
| 263 | + if (isset($maxlat)) { |
|
| 264 | + $query .= "AND tracker_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND tracker_live.longitude BETWEEN ".$minlong." AND ".$maxlong." "; |
|
| 265 | + } |
|
| 233 | 266 | $query .= "ORDER BY tracker_live.famtrackid, tracker_live.date"; |
| 234 | - if ($limit) $query .= " LIMIT ".$globalMap3DTrackersLimit; |
|
| 267 | + if ($limit) { |
|
| 268 | + $query .= " LIMIT ".$globalMap3DTrackersLimit; |
|
| 269 | + } |
|
| 235 | 270 | } |
| 236 | 271 | } |
| 237 | 272 | |
@@ -257,7 +292,9 @@ discard block |
||
| 257 | 292 | global $globalDBdriver, $globalLiveInterval; |
| 258 | 293 | $filter_query = $this->getFilter($filter,true,true); |
| 259 | 294 | |
| 260 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
| 295 | + if (!isset($globalLiveInterval)) { |
|
| 296 | + $globalLiveInterval = '200'; |
|
| 297 | + } |
|
| 261 | 298 | if ($globalDBdriver == 'mysql') { |
| 262 | 299 | $query = 'SELECT COUNT(DISTINCT tracker_live.famtrackid) as nb FROM tracker_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date'; |
| 263 | 300 | } else { |
@@ -285,7 +322,9 @@ discard block |
||
| 285 | 322 | { |
| 286 | 323 | global $globalDBdriver, $globalLiveInterval; |
| 287 | 324 | $Spotter = new Spotter($this->db); |
| 288 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
| 325 | + if (!isset($globalLiveInterval)) { |
|
| 326 | + $globalLiveInterval = '200'; |
|
| 327 | + } |
|
| 289 | 328 | $filter_query = $this->getFilter($filter); |
| 290 | 329 | |
| 291 | 330 | if (is_array($coord)) { |
@@ -293,7 +332,9 @@ discard block |
||
| 293 | 332 | $minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
| 294 | 333 | $maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
| 295 | 334 | $maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
| 296 | - } else return array(); |
|
| 335 | + } else { |
|
| 336 | + return array(); |
|
| 337 | + } |
|
| 297 | 338 | if ($globalDBdriver == 'mysql') { |
| 298 | 339 | $query = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate AND tracker_live.latitude BETWEEN '.$minlat.' AND '.$maxlat.' AND tracker_live.longitude BETWEEN '.$minlong.' AND '.$maxlong.' GROUP BY tracker_live.famtrackid'.$filter_query; |
| 299 | 340 | } else { |
@@ -313,7 +354,9 @@ discard block |
||
| 313 | 354 | { |
| 314 | 355 | global $globalDBdriver, $globalLiveInterval; |
| 315 | 356 | $Spotter = new Spotter($this->db); |
| 316 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
| 357 | + if (!isset($globalLiveInterval)) { |
|
| 358 | + $globalLiveInterval = '200'; |
|
| 359 | + } |
|
| 317 | 360 | $filter_query = $this->getFilter($filter); |
| 318 | 361 | |
| 319 | 362 | if (is_array($coord)) { |
@@ -321,7 +364,9 @@ discard block |
||
| 321 | 364 | $minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
| 322 | 365 | $maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
| 323 | 366 | $maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
| 324 | - } else return array(); |
|
| 367 | + } else { |
|
| 368 | + return array(); |
|
| 369 | + } |
|
| 325 | 370 | if ($globalDBdriver == 'mysql') { |
| 326 | 371 | $query = 'SELECT tracker_live.ident, tracker_live.famtrackid,tracker_live.type, tracker_live.latitude, tracker_live.longitude, tracker_live.altitude, tracker_live.heading, tracker_live.ground_speed, tracker_live.date, tracker_live.format_source |
| 327 | 372 | FROM tracker_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= tracker_live.date AND tracker_live.latitude <> '0' AND tracker_live.longitude <> '0' AND tracker_live.latitude BETWEEN ".$minlat.' AND '.$maxlat.' AND tracker_live.longitude BETWEEN '.$minlong.' AND '.$maxlong." |
@@ -514,11 +559,15 @@ discard block |
||
| 514 | 559 | //$query = self::$global_query.' WHERE tracker_live.famtrackid = :id ORDER BY date'; |
| 515 | 560 | if ($globalDBdriver == 'mysql') { |
| 516 | 561 | $query = 'SELECT tracker_live.* FROM tracker_live WHERE tracker_live.famtrackid = :id'; |
| 517 | - if ($liveinterval) $query .= ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date'; |
|
| 562 | + if ($liveinterval) { |
|
| 563 | + $query .= ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date'; |
|
| 564 | + } |
|
| 518 | 565 | $query .= ' ORDER BY date'; |
| 519 | 566 | } else { |
| 520 | 567 | $query = 'SELECT tracker_live.* FROM tracker_live WHERE tracker_live.famtrackid = :id'; |
| 521 | - if ($liveinterval) $query .= " AND CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= date"; |
|
| 568 | + if ($liveinterval) { |
|
| 569 | + $query .= " AND CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= date"; |
|
| 570 | + } |
|
| 522 | 571 | $query .= ' ORDER BY date'; |
| 523 | 572 | } |
| 524 | 573 | |
@@ -613,7 +662,9 @@ discard block |
||
| 613 | 662 | $i++; |
| 614 | 663 | $j++; |
| 615 | 664 | if ($j == 30) { |
| 616 | - if ($globalDebug) echo "."; |
|
| 665 | + if ($globalDebug) { |
|
| 666 | + echo "."; |
|
| 667 | + } |
|
| 617 | 668 | try { |
| 618 | 669 | |
| 619 | 670 | $sth = $this->db->prepare(substr($query_delete,0,-1).")"); |
@@ -860,7 +911,9 @@ discard block |
||
| 860 | 911 | { |
| 861 | 912 | return false; |
| 862 | 913 | } |
| 863 | - } else return ''; |
|
| 914 | + } else { |
|
| 915 | + return ''; |
|
| 916 | + } |
|
| 864 | 917 | |
| 865 | 918 | if ($longitude != '') |
| 866 | 919 | { |
@@ -868,7 +921,9 @@ discard block |
||
| 868 | 921 | { |
| 869 | 922 | return false; |
| 870 | 923 | } |
| 871 | - } else return ''; |
|
| 924 | + } else { |
|
| 925 | + return ''; |
|
| 926 | + } |
|
| 872 | 927 | |
| 873 | 928 | if ($altitude != '') |
| 874 | 929 | { |
@@ -876,7 +931,9 @@ discard block |
||
| 876 | 931 | { |
| 877 | 932 | return false; |
| 878 | 933 | } |
| 879 | - } else $altitude = 0; |
|
| 934 | + } else { |
|
| 935 | + $altitude = 0; |
|
| 936 | + } |
|
| 880 | 937 | |
| 881 | 938 | if ($heading != '') |
| 882 | 939 | { |
@@ -884,7 +941,9 @@ discard block |
||
| 884 | 941 | { |
| 885 | 942 | return false; |
| 886 | 943 | } |
| 887 | - } else $heading = 0; |
|
| 944 | + } else { |
|
| 945 | + $heading = 0; |
|
| 946 | + } |
|
| 888 | 947 | |
| 889 | 948 | if ($groundspeed != '') |
| 890 | 949 | { |
@@ -892,9 +951,13 @@ discard block |
||
| 892 | 951 | { |
| 893 | 952 | return false; |
| 894 | 953 | } |
| 895 | - } else $groundspeed = 0; |
|
| 954 | + } else { |
|
| 955 | + $groundspeed = 0; |
|
| 956 | + } |
|
| 896 | 957 | date_default_timezone_set('UTC'); |
| 897 | - if ($date == '') $date = date("Y-m-d H:i:s", time()); |
|
| 958 | + if ($date == '') { |
|
| 959 | + $date = date("Y-m-d H:i:s", time()); |
|
| 960 | + } |
|
| 898 | 961 | |
| 899 | 962 | |
| 900 | 963 | $famtrackid = filter_var($famtrackid,FILTER_SANITIZE_STRING); |
@@ -910,12 +973,18 @@ discard block |
||
| 910 | 973 | $comment = filter_var($comment,FILTER_SANITIZE_STRING); |
| 911 | 974 | $type = filter_var($type,FILTER_SANITIZE_STRING); |
| 912 | 975 | |
| 913 | - if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0; |
|
| 914 | - if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0; |
|
| 976 | + if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) { |
|
| 977 | + $groundspeed = 0; |
|
| 978 | + } |
|
| 979 | + if ($heading == '' || $Common->isInteger($heading) === false ) { |
|
| 980 | + $heading = 0; |
|
| 981 | + } |
|
| 915 | 982 | |
| 916 | 983 | $query = ''; |
| 917 | 984 | if ($globalArchive) { |
| 918 | - if ($globalDebug) echo '-- Delete previous data -- '; |
|
| 985 | + if ($globalDebug) { |
|
| 986 | + echo '-- Delete previous data -- '; |
|
| 987 | + } |
|
| 919 | 988 | $query .= 'DELETE FROM tracker_live WHERE famtrackid = :famtrackid;'; |
| 920 | 989 | } |
| 921 | 990 | $query .= 'INSERT INTO tracker_live (famtrackid, ident, latitude, longitude, altitude, heading, ground_speed, date, format_source, source_name, over_country, comment, type) |
@@ -934,10 +1003,14 @@ discard block |
||
| 934 | 1003 | echo 'noarchive : '.$noarchive."\n"; |
| 935 | 1004 | */ |
| 936 | 1005 | if (isset($globalArchive) && $globalArchive && $putinarchive && $noarchive !== true) { |
| 937 | - if ($globalDebug) echo '(Add to Tracker archive '.$famtrackid.' : '; |
|
| 1006 | + if ($globalDebug) { |
|
| 1007 | + echo '(Add to Tracker archive '.$famtrackid.' : '; |
|
| 1008 | + } |
|
| 938 | 1009 | $TrackerArchive = new TrackerArchive($this->db); |
| 939 | 1010 | $result = $TrackerArchive->addTrackerArchiveData($famtrackid, $ident,$latitude, $longitude, $altitude, $heading, $groundspeed, $date, $putinarchive, $comment, $type,$noarchive,$format_source, $source_name, $over_country); |
| 940 | - if ($globalDebug) echo $result.')'; |
|
| 1011 | + if ($globalDebug) { |
|
| 1012 | + echo $result.')'; |
|
| 1013 | + } |
|
| 941 | 1014 | } |
| 942 | 1015 | |
| 943 | 1016 | return "success"; |
@@ -13,10 +13,10 @@ discard block |
||
| 13 | 13 | |
| 14 | 14 | |
| 15 | 15 | /** |
| 16 | - * Get SQL query part for filter used |
|
| 17 | - * @param Array $filter the filter |
|
| 18 | - * @return Array the SQL part |
|
| 19 | - */ |
|
| 16 | + * Get SQL query part for filter used |
|
| 17 | + * @param Array $filter the filter |
|
| 18 | + * @return Array the SQL part |
|
| 19 | + */ |
|
| 20 | 20 | public function getFilter($filter = array(),$where = false,$and = false) { |
| 21 | 21 | global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver; |
| 22 | 22 | $filters = array(); |
@@ -87,11 +87,11 @@ discard block |
||
| 87 | 87 | } |
| 88 | 88 | |
| 89 | 89 | /** |
| 90 | - * Gets all the spotter information based on the latest data entry |
|
| 91 | - * |
|
| 92 | - * @return Array the spotter information |
|
| 93 | - * |
|
| 94 | - */ |
|
| 90 | + * Gets all the spotter information based on the latest data entry |
|
| 91 | + * |
|
| 92 | + * @return Array the spotter information |
|
| 93 | + * |
|
| 94 | + */ |
|
| 95 | 95 | public function getLiveMarineData($limit = '', $sort = '', $filter = array()) |
| 96 | 96 | { |
| 97 | 97 | global $globalDBdriver, $globalLiveInterval; |
@@ -134,11 +134,11 @@ discard block |
||
| 134 | 134 | } |
| 135 | 135 | |
| 136 | 136 | /** |
| 137 | - * Gets Minimal Live Spotter data |
|
| 138 | - * |
|
| 139 | - * @return Array the spotter information |
|
| 140 | - * |
|
| 141 | - */ |
|
| 137 | + * Gets Minimal Live Spotter data |
|
| 138 | + * |
|
| 139 | + * @return Array the spotter information |
|
| 140 | + * |
|
| 141 | + */ |
|
| 142 | 142 | public function getMinLiveMarineData($filter = array()) |
| 143 | 143 | { |
| 144 | 144 | global $globalDBdriver, $globalLiveInterval; |
@@ -168,11 +168,11 @@ discard block |
||
| 168 | 168 | } |
| 169 | 169 | |
| 170 | 170 | /** |
| 171 | - * Gets Minimal Live Spotter data since xx seconds |
|
| 172 | - * |
|
| 173 | - * @return Array the spotter information |
|
| 174 | - * |
|
| 175 | - */ |
|
| 171 | + * Gets Minimal Live Spotter data since xx seconds |
|
| 172 | + * |
|
| 173 | + * @return Array the spotter information |
|
| 174 | + * |
|
| 175 | + */ |
|
| 176 | 176 | public function getMinLastLiveMarineData($coord = array(),$filter = array(), $limit = false) |
| 177 | 177 | { |
| 178 | 178 | global $globalDBdriver, $globalLiveInterval, $globalMap3DMarinesLimit; |
@@ -241,11 +241,11 @@ discard block |
||
| 241 | 241 | } |
| 242 | 242 | |
| 243 | 243 | /** |
| 244 | - * Gets number of latest data entry |
|
| 245 | - * |
|
| 246 | - * @return String number of entry |
|
| 247 | - * |
|
| 248 | - */ |
|
| 244 | + * Gets number of latest data entry |
|
| 245 | + * |
|
| 246 | + * @return String number of entry |
|
| 247 | + * |
|
| 248 | + */ |
|
| 249 | 249 | public function getLiveMarineCount($filter = array()) |
| 250 | 250 | { |
| 251 | 251 | global $globalDBdriver, $globalLiveInterval; |
@@ -270,11 +270,11 @@ discard block |
||
| 270 | 270 | } |
| 271 | 271 | |
| 272 | 272 | /** |
| 273 | - * Gets all the spotter information based on the latest data entry and coord |
|
| 274 | - * |
|
| 275 | - * @return Array the spotter information |
|
| 276 | - * |
|
| 277 | - */ |
|
| 273 | + * Gets all the spotter information based on the latest data entry and coord |
|
| 274 | + * |
|
| 275 | + * @return Array the spotter information |
|
| 276 | + * |
|
| 277 | + */ |
|
| 278 | 278 | public function getLiveMarineDatabyCoord($coord, $filter = array()) |
| 279 | 279 | { |
| 280 | 280 | global $globalDBdriver, $globalLiveInterval; |
@@ -298,11 +298,11 @@ discard block |
||
| 298 | 298 | } |
| 299 | 299 | |
| 300 | 300 | /** |
| 301 | - * Gets all the spotter information based on the latest data entry and coord |
|
| 302 | - * |
|
| 303 | - * @return Array the spotter information |
|
| 304 | - * |
|
| 305 | - */ |
|
| 301 | + * Gets all the spotter information based on the latest data entry and coord |
|
| 302 | + * |
|
| 303 | + * @return Array the spotter information |
|
| 304 | + * |
|
| 305 | + */ |
|
| 306 | 306 | public function getMinLiveMarineDatabyCoord($coord, $filter = array()) |
| 307 | 307 | { |
| 308 | 308 | global $globalDBdriver, $globalLiveInterval; |
@@ -330,11 +330,11 @@ discard block |
||
| 330 | 330 | } |
| 331 | 331 | |
| 332 | 332 | /** |
| 333 | - * Gets all the spotter information based on a user's latitude and longitude |
|
| 334 | - * |
|
| 335 | - * @return Array the spotter information |
|
| 336 | - * |
|
| 337 | - */ |
|
| 333 | + * Gets all the spotter information based on a user's latitude and longitude |
|
| 334 | + * |
|
| 335 | + * @return Array the spotter information |
|
| 336 | + * |
|
| 337 | + */ |
|
| 338 | 338 | public function getLatestMarineForLayar($lat, $lng, $radius, $interval) |
| 339 | 339 | { |
| 340 | 340 | $Marine = new Marine($this->db); |
@@ -347,134 +347,134 @@ discard block |
||
| 347 | 347 | if ($lng != '') |
| 348 | 348 | { |
| 349 | 349 | if (!is_numeric($lng)) |
| 350 | - { |
|
| 351 | - return false; |
|
| 352 | - } |
|
| 353 | - } |
|
| 354 | - |
|
| 355 | - if ($radius != '') |
|
| 356 | - { |
|
| 357 | - if (!is_numeric($radius)) |
|
| 358 | - { |
|
| 359 | - return false; |
|
| 360 | - } |
|
| 361 | - } |
|
| 350 | + { |
|
| 351 | + return false; |
|
| 352 | + } |
|
| 353 | + } |
|
| 354 | + |
|
| 355 | + if ($radius != '') |
|
| 356 | + { |
|
| 357 | + if (!is_numeric($radius)) |
|
| 358 | + { |
|
| 359 | + return false; |
|
| 360 | + } |
|
| 361 | + } |
|
| 362 | 362 | $additional_query = ''; |
| 363 | 363 | if ($interval != '') |
| 364 | - { |
|
| 365 | - if (!is_string($interval)) |
|
| 366 | - { |
|
| 367 | - //$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= marine_live.date '; |
|
| 368 | - return false; |
|
| 369 | - } else { |
|
| 370 | - if ($interval == '1m') |
|
| 371 | - { |
|
| 372 | - $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= marine_live.date '; |
|
| 373 | - } else if ($interval == '15m'){ |
|
| 374 | - $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 MINUTE) <= marine_live.date '; |
|
| 375 | - } |
|
| 376 | - } |
|
| 377 | - } else { |
|
| 378 | - $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= marine_live.date '; |
|
| 379 | - } |
|
| 380 | - |
|
| 381 | - $query = "SELECT marine_live.*, ( 6371 * acos( cos( radians(:lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(:lng) ) + sin( radians(:lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM marine_live |
|
| 364 | + { |
|
| 365 | + if (!is_string($interval)) |
|
| 366 | + { |
|
| 367 | + //$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= marine_live.date '; |
|
| 368 | + return false; |
|
| 369 | + } else { |
|
| 370 | + if ($interval == '1m') |
|
| 371 | + { |
|
| 372 | + $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= marine_live.date '; |
|
| 373 | + } else if ($interval == '15m'){ |
|
| 374 | + $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 MINUTE) <= marine_live.date '; |
|
| 375 | + } |
|
| 376 | + } |
|
| 377 | + } else { |
|
| 378 | + $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= marine_live.date '; |
|
| 379 | + } |
|
| 380 | + |
|
| 381 | + $query = "SELECT marine_live.*, ( 6371 * acos( cos( radians(:lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(:lng) ) + sin( radians(:lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM marine_live |
|
| 382 | 382 | WHERE marine_live.latitude <> '' |
| 383 | 383 | AND marine_live.longitude <> '' |
| 384 | 384 | ".$additional_query." |
| 385 | 385 | HAVING distance < :radius |
| 386 | 386 | ORDER BY distance"; |
| 387 | 387 | |
| 388 | - $spotter_array = $Marine->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng,':radius' => $radius)); |
|
| 388 | + $spotter_array = $Marine->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng,':radius' => $radius)); |
|
| 389 | 389 | |
| 390 | - return $spotter_array; |
|
| 391 | - } |
|
| 390 | + return $spotter_array; |
|
| 391 | + } |
|
| 392 | 392 | |
| 393 | 393 | |
| 394 | - /** |
|
| 395 | - * Gets all the spotter information based on a particular callsign |
|
| 396 | - * |
|
| 397 | - * @return Array the spotter information |
|
| 398 | - * |
|
| 399 | - */ |
|
| 394 | + /** |
|
| 395 | + * Gets all the spotter information based on a particular callsign |
|
| 396 | + * |
|
| 397 | + * @return Array the spotter information |
|
| 398 | + * |
|
| 399 | + */ |
|
| 400 | 400 | public function getLastLiveMarineDataByIdent($ident) |
| 401 | 401 | { |
| 402 | 402 | $Marine = new Marine($this->db); |
| 403 | 403 | date_default_timezone_set('UTC'); |
| 404 | 404 | |
| 405 | 405 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 406 | - $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.ident = :ident GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC'; |
|
| 406 | + $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.ident = :ident GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC'; |
|
| 407 | 407 | |
| 408 | 408 | $spotter_array = $Marine->getDataFromDB($query,array(':ident' => $ident),'',true); |
| 409 | 409 | |
| 410 | 410 | return $spotter_array; |
| 411 | 411 | } |
| 412 | 412 | |
| 413 | - /** |
|
| 414 | - * Gets all the spotter information based on a particular callsign |
|
| 415 | - * |
|
| 416 | - * @return Array the spotter information |
|
| 417 | - * |
|
| 418 | - */ |
|
| 413 | + /** |
|
| 414 | + * Gets all the spotter information based on a particular callsign |
|
| 415 | + * |
|
| 416 | + * @return Array the spotter information |
|
| 417 | + * |
|
| 418 | + */ |
|
| 419 | 419 | public function getDateLiveMarineDataByIdent($ident,$date) |
| 420 | 420 | { |
| 421 | 421 | $Marine = new Marine($this->db); |
| 422 | 422 | date_default_timezone_set('UTC'); |
| 423 | 423 | |
| 424 | 424 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 425 | - $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC'; |
|
| 425 | + $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC'; |
|
| 426 | 426 | |
| 427 | - $date = date('c',$date); |
|
| 427 | + $date = date('c',$date); |
|
| 428 | 428 | $spotter_array = $Marine->getDataFromDB($query,array(':ident' => $ident,':date' => $date)); |
| 429 | 429 | |
| 430 | 430 | return $spotter_array; |
| 431 | 431 | } |
| 432 | 432 | |
| 433 | - /** |
|
| 434 | - * Gets last spotter information based on a particular callsign |
|
| 435 | - * |
|
| 436 | - * @return Array the spotter information |
|
| 437 | - * |
|
| 438 | - */ |
|
| 433 | + /** |
|
| 434 | + * Gets last spotter information based on a particular callsign |
|
| 435 | + * |
|
| 436 | + * @return Array the spotter information |
|
| 437 | + * |
|
| 438 | + */ |
|
| 439 | 439 | public function getLastLiveMarineDataById($id) |
| 440 | 440 | { |
| 441 | 441 | $Marine = new Marine($this->db); |
| 442 | 442 | date_default_timezone_set('UTC'); |
| 443 | 443 | |
| 444 | 444 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
| 445 | - $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.fammarine_id = :id GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC'; |
|
| 445 | + $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.fammarine_id = :id GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC'; |
|
| 446 | 446 | |
| 447 | 447 | $spotter_array = $Marine->getDataFromDB($query,array(':id' => $id),'',true); |
| 448 | 448 | |
| 449 | 449 | return $spotter_array; |
| 450 | 450 | } |
| 451 | 451 | |
| 452 | - /** |
|
| 453 | - * Gets last spotter information based on a particular callsign |
|
| 454 | - * |
|
| 455 | - * @return Array the spotter information |
|
| 456 | - * |
|
| 457 | - */ |
|
| 452 | + /** |
|
| 453 | + * Gets last spotter information based on a particular callsign |
|
| 454 | + * |
|
| 455 | + * @return Array the spotter information |
|
| 456 | + * |
|
| 457 | + */ |
|
| 458 | 458 | public function getDateLiveMarineDataById($id,$date) |
| 459 | 459 | { |
| 460 | 460 | $Marine = new Marine($this->db); |
| 461 | 461 | date_default_timezone_set('UTC'); |
| 462 | 462 | |
| 463 | 463 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
| 464 | - $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.fammarine_id = :id AND l.date <= :date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC'; |
|
| 465 | - $date = date('c',$date); |
|
| 464 | + $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.fammarine_id = :id AND l.date <= :date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC'; |
|
| 465 | + $date = date('c',$date); |
|
| 466 | 466 | $spotter_array = $Marine->getDataFromDB($query,array(':id' => $id,':date' => $date),'',true); |
| 467 | 467 | |
| 468 | 468 | return $spotter_array; |
| 469 | 469 | } |
| 470 | 470 | |
| 471 | 471 | |
| 472 | - /** |
|
| 473 | - * Gets all the spotter information based on a particular id |
|
| 474 | - * |
|
| 475 | - * @return Array the spotter information |
|
| 476 | - * |
|
| 477 | - */ |
|
| 472 | + /** |
|
| 473 | + * Gets all the spotter information based on a particular id |
|
| 474 | + * |
|
| 475 | + * @return Array the spotter information |
|
| 476 | + * |
|
| 477 | + */ |
|
| 478 | 478 | public function getAllLiveMarineDataById($id,$liveinterval = false) |
| 479 | 479 | { |
| 480 | 480 | global $globalDBdriver, $globalLiveInterval; |
@@ -502,18 +502,18 @@ discard block |
||
| 502 | 502 | return $spotter_array; |
| 503 | 503 | } |
| 504 | 504 | |
| 505 | - /** |
|
| 506 | - * Gets all the spotter information based on a particular ident |
|
| 507 | - * |
|
| 508 | - * @return Array the spotter information |
|
| 509 | - * |
|
| 510 | - */ |
|
| 505 | + /** |
|
| 506 | + * Gets all the spotter information based on a particular ident |
|
| 507 | + * |
|
| 508 | + * @return Array the spotter information |
|
| 509 | + * |
|
| 510 | + */ |
|
| 511 | 511 | public function getAllLiveMarineDataByIdent($ident) |
| 512 | 512 | { |
| 513 | 513 | date_default_timezone_set('UTC'); |
| 514 | 514 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 515 | 515 | $query = self::$global_query.' WHERE marine_live.ident = :ident'; |
| 516 | - try { |
|
| 516 | + try { |
|
| 517 | 517 | |
| 518 | 518 | $sth = $this->db->prepare($query); |
| 519 | 519 | $sth->execute(array(':ident' => $ident)); |
@@ -527,23 +527,23 @@ discard block |
||
| 527 | 527 | |
| 528 | 528 | |
| 529 | 529 | /** |
| 530 | - * Deletes all info in the table |
|
| 531 | - * |
|
| 532 | - * @return String success or false |
|
| 533 | - * |
|
| 534 | - */ |
|
| 530 | + * Deletes all info in the table |
|
| 531 | + * |
|
| 532 | + * @return String success or false |
|
| 533 | + * |
|
| 534 | + */ |
|
| 535 | 535 | public function deleteLiveMarineData() |
| 536 | 536 | { |
| 537 | 537 | global $globalDBdriver; |
| 538 | 538 | if ($globalDBdriver == 'mysql') { |
| 539 | 539 | //$query = "DELETE FROM marine_live WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 MINUTE) >= marine_live.date"; |
| 540 | 540 | $query = 'DELETE FROM marine_live WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 9 HOUR) >= marine_live.date'; |
| 541 | - //$query = "DELETE FROM marine_live WHERE marine_live.id IN (SELECT marine_live.id FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) >= marine_live.date)"; |
|
| 541 | + //$query = "DELETE FROM marine_live WHERE marine_live.id IN (SELECT marine_live.id FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) >= marine_live.date)"; |
|
| 542 | 542 | } else { |
| 543 | 543 | $query = "DELETE FROM marine_live WHERE NOW() AT TIME ZONE 'UTC' - INTERVAL '9 HOURS' >= marine_live.date"; |
| 544 | 544 | } |
| 545 | 545 | |
| 546 | - try { |
|
| 546 | + try { |
|
| 547 | 547 | |
| 548 | 548 | $sth = $this->db->prepare($query); |
| 549 | 549 | $sth->execute(); |
@@ -555,18 +555,18 @@ discard block |
||
| 555 | 555 | } |
| 556 | 556 | |
| 557 | 557 | /** |
| 558 | - * Deletes all info in the table for aircraft not seen since 2 HOUR |
|
| 559 | - * |
|
| 560 | - * @return String success or false |
|
| 561 | - * |
|
| 562 | - */ |
|
| 558 | + * Deletes all info in the table for aircraft not seen since 2 HOUR |
|
| 559 | + * |
|
| 560 | + * @return String success or false |
|
| 561 | + * |
|
| 562 | + */ |
|
| 563 | 563 | public function deleteLiveMarineDataNotUpdated() |
| 564 | 564 | { |
| 565 | 565 | global $globalDBdriver, $globalDebug; |
| 566 | 566 | if ($globalDBdriver == 'mysql') { |
| 567 | 567 | //$query = 'SELECT fammarine_id FROM marine_live WHERE DATE_SUB(UTC_TIMESTAMP(), INTERVAL 1 HOUR) >= marine_live.date AND marine_live.fammarine_id NOT IN (SELECT fammarine_id FROM marine_live WHERE DATE_SUB(UTC_TIMESTAMP(), INTERVAL 1 HOUR) < marine_live.date) LIMIT 800 OFFSET 0'; |
| 568 | - $query = "SELECT marine_live.fammarine_id FROM marine_live INNER JOIN (SELECT fammarine_id,MAX(date) as max_date FROM marine_live GROUP BY fammarine_id) s ON s.fammarine_id = marine_live.fammarine_id AND DATE_SUB(UTC_TIMESTAMP(), INTERVAL 2 HOUR) >= s.max_date LIMIT 1200 OFFSET 0"; |
|
| 569 | - try { |
|
| 568 | + $query = "SELECT marine_live.fammarine_id FROM marine_live INNER JOIN (SELECT fammarine_id,MAX(date) as max_date FROM marine_live GROUP BY fammarine_id) s ON s.fammarine_id = marine_live.fammarine_id AND DATE_SUB(UTC_TIMESTAMP(), INTERVAL 2 HOUR) >= s.max_date LIMIT 1200 OFFSET 0"; |
|
| 569 | + try { |
|
| 570 | 570 | |
| 571 | 571 | $sth = $this->db->prepare($query); |
| 572 | 572 | $sth->execute(); |
@@ -574,8 +574,8 @@ discard block |
||
| 574 | 574 | return "error"; |
| 575 | 575 | } |
| 576 | 576 | $query_delete = 'DELETE FROM marine_live WHERE fammarine_id IN ('; |
| 577 | - $i = 0; |
|
| 578 | - $j =0; |
|
| 577 | + $i = 0; |
|
| 578 | + $j =0; |
|
| 579 | 579 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 580 | 580 | foreach($all as $row) |
| 581 | 581 | { |
@@ -583,20 +583,20 @@ discard block |
||
| 583 | 583 | $j++; |
| 584 | 584 | if ($j == 30) { |
| 585 | 585 | if ($globalDebug) echo "."; |
| 586 | - try { |
|
| 586 | + try { |
|
| 587 | 587 | |
| 588 | 588 | $sth = $this->db->prepare(substr($query_delete,0,-1).")"); |
| 589 | 589 | $sth->execute(); |
| 590 | 590 | } catch(PDOException $e) { |
| 591 | 591 | return "error"; |
| 592 | 592 | } |
| 593 | - $query_delete = 'DELETE FROM marine_live WHERE fammarine_id IN ('; |
|
| 594 | - $j = 0; |
|
| 593 | + $query_delete = 'DELETE FROM marine_live WHERE fammarine_id IN ('; |
|
| 594 | + $j = 0; |
|
| 595 | 595 | } |
| 596 | 596 | $query_delete .= "'".$row['fammarine_id']."',"; |
| 597 | 597 | } |
| 598 | 598 | if ($i > 0) { |
| 599 | - try { |
|
| 599 | + try { |
|
| 600 | 600 | |
| 601 | 601 | $sth = $this->db->prepare(substr($query_delete,0,-1).")"); |
| 602 | 602 | $sth->execute(); |
@@ -607,9 +607,9 @@ discard block |
||
| 607 | 607 | return "success"; |
| 608 | 608 | } elseif ($globalDBdriver == 'pgsql') { |
| 609 | 609 | //$query = "SELECT fammarine_id FROM marine_live WHERE NOW() AT TIME ZONE 'UTC' - INTERVAL '9 HOURS' >= marine_live.date AND marine_live.fammarine_id NOT IN (SELECT fammarine_id FROM marine_live WHERE NOW() AT TIME ZONE 'UTC' - INTERVAL '9 HOURS' < marine_live.date) LIMIT 800 OFFSET 0"; |
| 610 | - //$query = "SELECT marine_live.fammarine_id FROM marine_live INNER JOIN (SELECT fammarine_id,MAX(date) as max_date FROM marine_live GROUP BY fammarine_id) s ON s.fammarine_id = marine_live.fammarine_id AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 800 OFFSET 0"; |
|
| 611 | - $query = "DELETE FROM marine_live WHERE fammarine_id IN (SELECT marine_live.fammarine_id FROM marine_live INNER JOIN (SELECT fammarine_id,MAX(date) as max_date FROM marine_live GROUP BY fammarine_id) s ON s.fammarine_id = marine_live.fammarine_id AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 800 OFFSET 0)"; |
|
| 612 | - try { |
|
| 610 | + //$query = "SELECT marine_live.fammarine_id FROM marine_live INNER JOIN (SELECT fammarine_id,MAX(date) as max_date FROM marine_live GROUP BY fammarine_id) s ON s.fammarine_id = marine_live.fammarine_id AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 800 OFFSET 0"; |
|
| 611 | + $query = "DELETE FROM marine_live WHERE fammarine_id IN (SELECT marine_live.fammarine_id FROM marine_live INNER JOIN (SELECT fammarine_id,MAX(date) as max_date FROM marine_live GROUP BY fammarine_id) s ON s.fammarine_id = marine_live.fammarine_id AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 800 OFFSET 0)"; |
|
| 612 | + try { |
|
| 613 | 613 | |
| 614 | 614 | $sth = $this->db->prepare($query); |
| 615 | 615 | $sth->execute(); |
@@ -653,17 +653,17 @@ discard block |
||
| 653 | 653 | } |
| 654 | 654 | |
| 655 | 655 | /** |
| 656 | - * Deletes all info in the table for an ident |
|
| 657 | - * |
|
| 658 | - * @return String success or false |
|
| 659 | - * |
|
| 660 | - */ |
|
| 656 | + * Deletes all info in the table for an ident |
|
| 657 | + * |
|
| 658 | + * @return String success or false |
|
| 659 | + * |
|
| 660 | + */ |
|
| 661 | 661 | public function deleteLiveMarineDataByIdent($ident) |
| 662 | 662 | { |
| 663 | 663 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 664 | 664 | $query = 'DELETE FROM marine_live WHERE ident = :ident'; |
| 665 | 665 | |
| 666 | - try { |
|
| 666 | + try { |
|
| 667 | 667 | |
| 668 | 668 | $sth = $this->db->prepare($query); |
| 669 | 669 | $sth->execute(array(':ident' => $ident)); |
@@ -675,17 +675,17 @@ discard block |
||
| 675 | 675 | } |
| 676 | 676 | |
| 677 | 677 | /** |
| 678 | - * Deletes all info in the table for an id |
|
| 679 | - * |
|
| 680 | - * @return String success or false |
|
| 681 | - * |
|
| 682 | - */ |
|
| 678 | + * Deletes all info in the table for an id |
|
| 679 | + * |
|
| 680 | + * @return String success or false |
|
| 681 | + * |
|
| 682 | + */ |
|
| 683 | 683 | public function deleteLiveMarineDataById($id) |
| 684 | 684 | { |
| 685 | 685 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
| 686 | 686 | $query = 'DELETE FROM marine_live WHERE fammarine_id = :id'; |
| 687 | 687 | |
| 688 | - try { |
|
| 688 | + try { |
|
| 689 | 689 | |
| 690 | 690 | $sth = $this->db->prepare($query); |
| 691 | 691 | $sth->execute(array(':id' => $id)); |
@@ -698,11 +698,11 @@ discard block |
||
| 698 | 698 | |
| 699 | 699 | |
| 700 | 700 | /** |
| 701 | - * Gets the aircraft ident within the last hour |
|
| 702 | - * |
|
| 703 | - * @return String the ident |
|
| 704 | - * |
|
| 705 | - */ |
|
| 701 | + * Gets the aircraft ident within the last hour |
|
| 702 | + * |
|
| 703 | + * @return String the ident |
|
| 704 | + * |
|
| 705 | + */ |
|
| 706 | 706 | public function getIdentFromLastHour($ident) |
| 707 | 707 | { |
| 708 | 708 | global $globalDBdriver, $globalTimezone; |
@@ -728,14 +728,14 @@ discard block |
||
| 728 | 728 | $ident_result = $row['ident']; |
| 729 | 729 | } |
| 730 | 730 | return $ident_result; |
| 731 | - } |
|
| 731 | + } |
|
| 732 | 732 | |
| 733 | 733 | /** |
| 734 | - * Check recent aircraft |
|
| 735 | - * |
|
| 736 | - * @return String the ident |
|
| 737 | - * |
|
| 738 | - */ |
|
| 734 | + * Check recent aircraft |
|
| 735 | + * |
|
| 736 | + * @return String the ident |
|
| 737 | + * |
|
| 738 | + */ |
|
| 739 | 739 | public function checkIdentRecent($ident) |
| 740 | 740 | { |
| 741 | 741 | global $globalDBdriver, $globalTimezone; |
@@ -761,14 +761,14 @@ discard block |
||
| 761 | 761 | $ident_result = $row['fammarine_id']; |
| 762 | 762 | } |
| 763 | 763 | return $ident_result; |
| 764 | - } |
|
| 764 | + } |
|
| 765 | 765 | |
| 766 | 766 | /** |
| 767 | - * Check recent aircraft by id |
|
| 768 | - * |
|
| 769 | - * @return String the ident |
|
| 770 | - * |
|
| 771 | - */ |
|
| 767 | + * Check recent aircraft by id |
|
| 768 | + * |
|
| 769 | + * @return String the ident |
|
| 770 | + * |
|
| 771 | + */ |
|
| 772 | 772 | public function checkIdRecent($id) |
| 773 | 773 | { |
| 774 | 774 | global $globalDBdriver, $globalTimezone; |
@@ -794,14 +794,14 @@ discard block |
||
| 794 | 794 | $ident_result = $row['fammarine_id']; |
| 795 | 795 | } |
| 796 | 796 | return $ident_result; |
| 797 | - } |
|
| 797 | + } |
|
| 798 | 798 | |
| 799 | 799 | /** |
| 800 | - * Check recent aircraft by mmsi |
|
| 801 | - * |
|
| 802 | - * @return String the ident |
|
| 803 | - * |
|
| 804 | - */ |
|
| 800 | + * Check recent aircraft by mmsi |
|
| 801 | + * |
|
| 802 | + * @return String the ident |
|
| 803 | + * |
|
| 804 | + */ |
|
| 805 | 805 | public function checkMMSIRecent($mmsi) |
| 806 | 806 | { |
| 807 | 807 | global $globalDBdriver, $globalTimezone; |
@@ -827,19 +827,19 @@ discard block |
||
| 827 | 827 | $ident_result = $row['fammarine_id']; |
| 828 | 828 | } |
| 829 | 829 | return $ident_result; |
| 830 | - } |
|
| 830 | + } |
|
| 831 | 831 | |
| 832 | 832 | /** |
| 833 | - * Adds a new spotter data |
|
| 834 | - * |
|
| 835 | - * @param String $fammarine_id the ID from flightaware |
|
| 836 | - * @param String $ident the flight ident |
|
| 837 | - * @param String $aircraft_icao the aircraft type |
|
| 838 | - * @param String $departure_airport_icao the departure airport |
|
| 839 | - * @param String $arrival_airport_icao the arrival airport |
|
| 840 | - * @return String success or false |
|
| 841 | - * |
|
| 842 | - */ |
|
| 833 | + * Adds a new spotter data |
|
| 834 | + * |
|
| 835 | + * @param String $fammarine_id the ID from flightaware |
|
| 836 | + * @param String $ident the flight ident |
|
| 837 | + * @param String $aircraft_icao the aircraft type |
|
| 838 | + * @param String $departure_airport_icao the departure airport |
|
| 839 | + * @param String $arrival_airport_icao the arrival airport |
|
| 840 | + * @return String success or false |
|
| 841 | + * |
|
| 842 | + */ |
|
| 843 | 843 | public function addLiveMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $heading = '', $groundspeed = '', $date = '', $putinarchive = false, $mmsi = '',$type = '',$typeid = '',$imo = '', $callsign = '',$arrival_code = '',$arrival_date = '',$status = '',$statusid = '',$noarchive = false,$format_source = '', $source_name = '', $over_country = '') |
| 844 | 844 | { |
| 845 | 845 | global $globalURL, $globalArchive, $globalDebug; |
@@ -910,10 +910,10 @@ discard block |
||
| 910 | 910 | $arrival_date = filter_var($arrival_date,FILTER_SANITIZE_STRING); |
| 911 | 911 | |
| 912 | 912 | |
| 913 | - if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0; |
|
| 914 | - if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0; |
|
| 915 | - if ($arrival_date == '') $arrival_date = NULL; |
|
| 916 | - $query = ''; |
|
| 913 | + if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0; |
|
| 914 | + if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0; |
|
| 915 | + if ($arrival_date == '') $arrival_date = NULL; |
|
| 916 | + $query = ''; |
|
| 917 | 917 | if ($globalArchive) { |
| 918 | 918 | if ($globalDebug) echo '-- Delete previous data -- '; |
| 919 | 919 | $query .= 'DELETE FROM marine_live WHERE fammarine_id = :fammarine_id;'; |
@@ -17,33 +17,33 @@ discard block |
||
| 17 | 17 | * @param Array $filter the filter |
| 18 | 18 | * @return Array the SQL part |
| 19 | 19 | */ |
| 20 | - public function getFilter($filter = array(),$where = false,$and = false) { |
|
| 20 | + public function getFilter($filter = array(), $where = false, $and = false) { |
|
| 21 | 21 | global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver; |
| 22 | 22 | $filters = array(); |
| 23 | 23 | if (is_array($globalStatsFilters) && isset($globalStatsFilters[$globalFilterName])) { |
| 24 | 24 | if (isset($globalStatsFilters[$globalFilterName][0]['source'])) { |
| 25 | 25 | $filters = $globalStatsFilters[$globalFilterName]; |
| 26 | 26 | } else { |
| 27 | - $filter = array_merge($filter,$globalStatsFilters[$globalFilterName]); |
|
| 27 | + $filter = array_merge($filter, $globalStatsFilters[$globalFilterName]); |
|
| 28 | 28 | } |
| 29 | 29 | } |
| 30 | 30 | if (isset($filter[0]['source'])) { |
| 31 | - $filters = array_merge($filters,$filter); |
|
| 31 | + $filters = array_merge($filters, $filter); |
|
| 32 | 32 | } |
| 33 | - if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter); |
|
| 33 | + if (is_array($globalFilter)) $filter = array_merge($filter, $globalFilter); |
|
| 34 | 34 | $filter_query_join = ''; |
| 35 | 35 | $filter_query_where = ''; |
| 36 | - foreach($filters as $flt) { |
|
| 36 | + foreach ($filters as $flt) { |
|
| 37 | 37 | if (isset($flt['idents']) && !empty($flt['idents'])) { |
| 38 | 38 | if (isset($flt['source'])) { |
| 39 | - $filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output WHERE marine_output.ident IN ('".implode("','",$flt['idents'])."') AND marine_output.format_source IN ('".implode("','",$flt['source'])."')) spid ON spid.fammarine_id = marine_live.fammarine_id"; |
|
| 39 | + $filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output WHERE marine_output.ident IN ('".implode("','", $flt['idents'])."') AND marine_output.format_source IN ('".implode("','", $flt['source'])."')) spid ON spid.fammarine_id = marine_live.fammarine_id"; |
|
| 40 | 40 | } else { |
| 41 | - $filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output WHERE marine_output.ident IN ('".implode("','",$flt['idents'])."')) spid ON spid.fammarine_id = marine_live.fammarine_id"; |
|
| 41 | + $filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output WHERE marine_output.ident IN ('".implode("','", $flt['idents'])."')) spid ON spid.fammarine_id = marine_live.fammarine_id"; |
|
| 42 | 42 | } |
| 43 | 43 | } |
| 44 | 44 | } |
| 45 | 45 | if (isset($filter['source']) && !empty($filter['source'])) { |
| 46 | - $filter_query_where .= " AND format_source IN ('".implode("','",$filter['source'])."')"; |
|
| 46 | + $filter_query_where .= " AND format_source IN ('".implode("','", $filter['source'])."')"; |
|
| 47 | 47 | } |
| 48 | 48 | if (isset($filter['ident']) && !empty($filter['ident'])) { |
| 49 | 49 | $filter_query_where .= " AND ident = '".$filter['ident']."'"; |
@@ -72,15 +72,15 @@ discard block |
||
| 72 | 72 | $filter_query_date .= " AND EXTRACT(DAY FROM marine_output.date) = '".$filter['day']."'"; |
| 73 | 73 | } |
| 74 | 74 | } |
| 75 | - $filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output".preg_replace('/^ AND/',' WHERE',$filter_query_date).") sd ON sd.fammarine_id = marine_live.fammarine_id"; |
|
| 75 | + $filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output".preg_replace('/^ AND/', ' WHERE', $filter_query_date).") sd ON sd.fammarine_id = marine_live.fammarine_id"; |
|
| 76 | 76 | } |
| 77 | 77 | if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
| 78 | - $filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
| 78 | + $filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')"; |
|
| 79 | 79 | } |
| 80 | 80 | if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE'; |
| 81 | 81 | elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND'; |
| 82 | 82 | if ($filter_query_where != '') { |
| 83 | - $filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where); |
|
| 83 | + $filter_query_where = preg_replace('/^ AND/', ' WHERE', $filter_query_where); |
|
| 84 | 84 | } |
| 85 | 85 | $filter_query = $filter_query_join.$filter_query_where; |
| 86 | 86 | return $filter_query; |
@@ -103,8 +103,8 @@ discard block |
||
| 103 | 103 | if ($limit != '') |
| 104 | 104 | { |
| 105 | 105 | $limit_array = explode(',', $limit); |
| 106 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 107 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 106 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
| 107 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
| 108 | 108 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
| 109 | 109 | { |
| 110 | 110 | $limit_query = ' LIMIT '.$limit_array[1].' OFFSET '.$limit_array[0]; |
@@ -119,7 +119,7 @@ discard block |
||
| 119 | 119 | $orderby_query = ' '.$search_orderby_array[$sort]['sql']; |
| 120 | 120 | } |
| 121 | 121 | } |
| 122 | - if ($orderby_query == '') $orderby_query= ' ORDER BY date DESC'; |
|
| 122 | + if ($orderby_query == '') $orderby_query = ' ORDER BY date DESC'; |
|
| 123 | 123 | |
| 124 | 124 | if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
| 125 | 125 | if ($globalDBdriver == 'mysql') { |
@@ -128,7 +128,7 @@ discard block |
||
| 128 | 128 | } else { |
| 129 | 129 | $query = "SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= l.date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate".$filter_query.$orderby_query; |
| 130 | 130 | } |
| 131 | - $spotter_array = $Marine->getDataFromDB($query.$limit_query,array(),'',true); |
|
| 131 | + $spotter_array = $Marine->getDataFromDB($query.$limit_query, array(), '', true); |
|
| 132 | 132 | |
| 133 | 133 | return $spotter_array; |
| 134 | 134 | } |
@@ -144,7 +144,7 @@ discard block |
||
| 144 | 144 | global $globalDBdriver, $globalLiveInterval; |
| 145 | 145 | date_default_timezone_set('UTC'); |
| 146 | 146 | |
| 147 | - $filter_query = $this->getFilter($filter,true,true); |
|
| 147 | + $filter_query = $this->getFilter($filter, true, true); |
|
| 148 | 148 | |
| 149 | 149 | if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
| 150 | 150 | if ($globalDBdriver == 'mysql') { |
@@ -158,7 +158,7 @@ discard block |
||
| 158 | 158 | try { |
| 159 | 159 | $sth = $this->db->prepare($query); |
| 160 | 160 | $sth->execute(); |
| 161 | - } catch(PDOException $e) { |
|
| 161 | + } catch (PDOException $e) { |
|
| 162 | 162 | echo $e->getMessage(); |
| 163 | 163 | die; |
| 164 | 164 | } |
@@ -173,17 +173,17 @@ discard block |
||
| 173 | 173 | * @return Array the spotter information |
| 174 | 174 | * |
| 175 | 175 | */ |
| 176 | - public function getMinLastLiveMarineData($coord = array(),$filter = array(), $limit = false) |
|
| 176 | + public function getMinLastLiveMarineData($coord = array(), $filter = array(), $limit = false) |
|
| 177 | 177 | { |
| 178 | 178 | global $globalDBdriver, $globalLiveInterval, $globalMap3DMarinesLimit; |
| 179 | 179 | date_default_timezone_set('UTC'); |
| 180 | 180 | if (is_array($coord) && !empty($coord)) { |
| 181 | - $minlong = filter_var($coord[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 182 | - $minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 183 | - $maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 184 | - $maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 181 | + $minlong = filter_var($coord[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 182 | + $minlat = filter_var($coord[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 183 | + $maxlong = filter_var($coord[2], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 184 | + $maxlat = filter_var($coord[3], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 185 | 185 | } |
| 186 | - $filter_query = $this->getFilter($filter,true,true); |
|
| 186 | + $filter_query = $this->getFilter($filter, true, true); |
|
| 187 | 187 | |
| 188 | 188 | if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
| 189 | 189 | if (!isset($globalMap3DMarinesLimit) || $globalMap3DMarinesLimit == '') $globalMap3DMarinesLimit = '300'; |
@@ -232,7 +232,7 @@ discard block |
||
| 232 | 232 | try { |
| 233 | 233 | $sth = $this->db->prepare($query); |
| 234 | 234 | $sth->execute(); |
| 235 | - } catch(PDOException $e) { |
|
| 235 | + } catch (PDOException $e) { |
|
| 236 | 236 | echo $e->getMessage(); |
| 237 | 237 | die; |
| 238 | 238 | } |
@@ -249,7 +249,7 @@ discard block |
||
| 249 | 249 | public function getLiveMarineCount($filter = array()) |
| 250 | 250 | { |
| 251 | 251 | global $globalDBdriver, $globalLiveInterval; |
| 252 | - $filter_query = $this->getFilter($filter,true,true); |
|
| 252 | + $filter_query = $this->getFilter($filter, true, true); |
|
| 253 | 253 | |
| 254 | 254 | if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
| 255 | 255 | if ($globalDBdriver == 'mysql') { |
@@ -260,7 +260,7 @@ discard block |
||
| 260 | 260 | try { |
| 261 | 261 | $sth = $this->db->prepare($query); |
| 262 | 262 | $sth->execute(); |
| 263 | - } catch(PDOException $e) { |
|
| 263 | + } catch (PDOException $e) { |
|
| 264 | 264 | echo $e->getMessage(); |
| 265 | 265 | die; |
| 266 | 266 | } |
@@ -283,10 +283,10 @@ discard block |
||
| 283 | 283 | $filter_query = $this->getFilter($filter); |
| 284 | 284 | |
| 285 | 285 | if (is_array($coord)) { |
| 286 | - $minlong = filter_var($coord[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 287 | - $minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 288 | - $maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 289 | - $maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 286 | + $minlong = filter_var($coord[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 287 | + $minlat = filter_var($coord[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 288 | + $maxlong = filter_var($coord[2], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 289 | + $maxlat = filter_var($coord[3], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 290 | 290 | } else return array(); |
| 291 | 291 | if ($globalDBdriver == 'mysql') { |
| 292 | 292 | $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate AND marine_live.latitude BETWEEN '.$minlat.' AND '.$maxlat.' AND marine_live.longitude BETWEEN '.$minlong.' AND '.$maxlong.' GROUP BY marine_live.fammarine_id'.$filter_query; |
@@ -311,17 +311,17 @@ discard block |
||
| 311 | 311 | $filter_query = $this->getFilter($filter); |
| 312 | 312 | |
| 313 | 313 | if (is_array($coord)) { |
| 314 | - $minlong = filter_var($coord[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 315 | - $minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 316 | - $maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 317 | - $maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 314 | + $minlong = filter_var($coord[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 315 | + $minlat = filter_var($coord[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 316 | + $maxlong = filter_var($coord[2], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 317 | + $maxlat = filter_var($coord[3], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 318 | 318 | } else return array(); |
| 319 | 319 | if ($globalDBdriver == 'mysql') { |
| 320 | 320 | $query = 'SELECT marine_live.ident, marine_live.fammarine_id,marine_live.type, marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source |
| 321 | 321 | FROM marine_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= marine_live.date AND marine_live.latitude <> '0' AND marine_live.longitude <> '0' AND marine_live.latitude BETWEEN ".$minlat.' AND '.$maxlat.' AND marine_live.longitude BETWEEN '.$minlong.' AND '.$maxlong." |
| 322 | 322 | ORDER BY marine_live.fammarine_id, marine_live.date"; |
| 323 | 323 | } else { |
| 324 | - $query = "SELECT marine_live.ident, marine_live.fammarine_id, marine_live.type,marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source |
|
| 324 | + $query = "SELECT marine_live.ident, marine_live.fammarine_id, marine_live.type,marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source |
|
| 325 | 325 | FROM marine_live".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= marine_live.date AND marine_live.latitude <> '0' AND marine_live.longitude <> '0' AND marine_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND marine_live.longitude BETWEEN ".$minlong." AND ".$maxlong." |
| 326 | 326 | ORDER BY marine_live.fammarine_id, marine_live.date"; |
| 327 | 327 | } |
@@ -370,7 +370,7 @@ discard block |
||
| 370 | 370 | if ($interval == '1m') |
| 371 | 371 | { |
| 372 | 372 | $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= marine_live.date '; |
| 373 | - } else if ($interval == '15m'){ |
|
| 373 | + } else if ($interval == '15m') { |
|
| 374 | 374 | $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 MINUTE) <= marine_live.date '; |
| 375 | 375 | } |
| 376 | 376 | } |
@@ -378,14 +378,14 @@ discard block |
||
| 378 | 378 | $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= marine_live.date '; |
| 379 | 379 | } |
| 380 | 380 | |
| 381 | - $query = "SELECT marine_live.*, ( 6371 * acos( cos( radians(:lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(:lng) ) + sin( radians(:lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM marine_live |
|
| 381 | + $query = "SELECT marine_live.*, ( 6371 * acos( cos( radians(:lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(:lng) ) + sin( radians(:lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM marine_live |
|
| 382 | 382 | WHERE marine_live.latitude <> '' |
| 383 | 383 | AND marine_live.longitude <> '' |
| 384 | 384 | ".$additional_query." |
| 385 | 385 | HAVING distance < :radius |
| 386 | 386 | ORDER BY distance"; |
| 387 | 387 | |
| 388 | - $spotter_array = $Marine->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng,':radius' => $radius)); |
|
| 388 | + $spotter_array = $Marine->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng, ':radius' => $radius)); |
|
| 389 | 389 | |
| 390 | 390 | return $spotter_array; |
| 391 | 391 | } |
@@ -403,9 +403,9 @@ discard block |
||
| 403 | 403 | date_default_timezone_set('UTC'); |
| 404 | 404 | |
| 405 | 405 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 406 | - $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.ident = :ident GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC'; |
|
| 406 | + $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.ident = :ident GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC'; |
|
| 407 | 407 | |
| 408 | - $spotter_array = $Marine->getDataFromDB($query,array(':ident' => $ident),'',true); |
|
| 408 | + $spotter_array = $Marine->getDataFromDB($query, array(':ident' => $ident), '', true); |
|
| 409 | 409 | |
| 410 | 410 | return $spotter_array; |
| 411 | 411 | } |
@@ -416,16 +416,16 @@ discard block |
||
| 416 | 416 | * @return Array the spotter information |
| 417 | 417 | * |
| 418 | 418 | */ |
| 419 | - public function getDateLiveMarineDataByIdent($ident,$date) |
|
| 419 | + public function getDateLiveMarineDataByIdent($ident, $date) |
|
| 420 | 420 | { |
| 421 | 421 | $Marine = new Marine($this->db); |
| 422 | 422 | date_default_timezone_set('UTC'); |
| 423 | 423 | |
| 424 | 424 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 425 | - $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC'; |
|
| 425 | + $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC'; |
|
| 426 | 426 | |
| 427 | - $date = date('c',$date); |
|
| 428 | - $spotter_array = $Marine->getDataFromDB($query,array(':ident' => $ident,':date' => $date)); |
|
| 427 | + $date = date('c', $date); |
|
| 428 | + $spotter_array = $Marine->getDataFromDB($query, array(':ident' => $ident, ':date' => $date)); |
|
| 429 | 429 | |
| 430 | 430 | return $spotter_array; |
| 431 | 431 | } |
@@ -442,9 +442,9 @@ discard block |
||
| 442 | 442 | date_default_timezone_set('UTC'); |
| 443 | 443 | |
| 444 | 444 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
| 445 | - $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.fammarine_id = :id GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC'; |
|
| 445 | + $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.fammarine_id = :id GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC'; |
|
| 446 | 446 | |
| 447 | - $spotter_array = $Marine->getDataFromDB($query,array(':id' => $id),'',true); |
|
| 447 | + $spotter_array = $Marine->getDataFromDB($query, array(':id' => $id), '', true); |
|
| 448 | 448 | |
| 449 | 449 | return $spotter_array; |
| 450 | 450 | } |
@@ -455,15 +455,15 @@ discard block |
||
| 455 | 455 | * @return Array the spotter information |
| 456 | 456 | * |
| 457 | 457 | */ |
| 458 | - public function getDateLiveMarineDataById($id,$date) |
|
| 458 | + public function getDateLiveMarineDataById($id, $date) |
|
| 459 | 459 | { |
| 460 | 460 | $Marine = new Marine($this->db); |
| 461 | 461 | date_default_timezone_set('UTC'); |
| 462 | 462 | |
| 463 | 463 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
| 464 | - $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.fammarine_id = :id AND l.date <= :date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC'; |
|
| 465 | - $date = date('c',$date); |
|
| 466 | - $spotter_array = $Marine->getDataFromDB($query,array(':id' => $id,':date' => $date),'',true); |
|
| 464 | + $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.fammarine_id = :id AND l.date <= :date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC'; |
|
| 465 | + $date = date('c', $date); |
|
| 466 | + $spotter_array = $Marine->getDataFromDB($query, array(':id' => $id, ':date' => $date), '', true); |
|
| 467 | 467 | |
| 468 | 468 | return $spotter_array; |
| 469 | 469 | } |
@@ -475,7 +475,7 @@ discard block |
||
| 475 | 475 | * @return Array the spotter information |
| 476 | 476 | * |
| 477 | 477 | */ |
| 478 | - public function getAllLiveMarineDataById($id,$liveinterval = false) |
|
| 478 | + public function getAllLiveMarineDataById($id, $liveinterval = false) |
|
| 479 | 479 | { |
| 480 | 480 | global $globalDBdriver, $globalLiveInterval; |
| 481 | 481 | date_default_timezone_set('UTC'); |
@@ -494,7 +494,7 @@ discard block |
||
| 494 | 494 | try { |
| 495 | 495 | $sth = $this->db->prepare($query); |
| 496 | 496 | $sth->execute(array(':id' => $id)); |
| 497 | - } catch(PDOException $e) { |
|
| 497 | + } catch (PDOException $e) { |
|
| 498 | 498 | echo $e->getMessage(); |
| 499 | 499 | die; |
| 500 | 500 | } |
@@ -512,12 +512,12 @@ discard block |
||
| 512 | 512 | { |
| 513 | 513 | date_default_timezone_set('UTC'); |
| 514 | 514 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 515 | - $query = self::$global_query.' WHERE marine_live.ident = :ident'; |
|
| 515 | + $query = self::$global_query.' WHERE marine_live.ident = :ident'; |
|
| 516 | 516 | try { |
| 517 | 517 | |
| 518 | 518 | $sth = $this->db->prepare($query); |
| 519 | 519 | $sth->execute(array(':ident' => $ident)); |
| 520 | - } catch(PDOException $e) { |
|
| 520 | + } catch (PDOException $e) { |
|
| 521 | 521 | echo $e->getMessage(); |
| 522 | 522 | die; |
| 523 | 523 | } |
@@ -547,7 +547,7 @@ discard block |
||
| 547 | 547 | |
| 548 | 548 | $sth = $this->db->prepare($query); |
| 549 | 549 | $sth->execute(); |
| 550 | - } catch(PDOException $e) { |
|
| 550 | + } catch (PDOException $e) { |
|
| 551 | 551 | return "error"; |
| 552 | 552 | } |
| 553 | 553 | |
@@ -570,14 +570,14 @@ discard block |
||
| 570 | 570 | |
| 571 | 571 | $sth = $this->db->prepare($query); |
| 572 | 572 | $sth->execute(); |
| 573 | - } catch(PDOException $e) { |
|
| 573 | + } catch (PDOException $e) { |
|
| 574 | 574 | return "error"; |
| 575 | 575 | } |
| 576 | 576 | $query_delete = 'DELETE FROM marine_live WHERE fammarine_id IN ('; |
| 577 | 577 | $i = 0; |
| 578 | - $j =0; |
|
| 578 | + $j = 0; |
|
| 579 | 579 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 580 | - foreach($all as $row) |
|
| 580 | + foreach ($all as $row) |
|
| 581 | 581 | { |
| 582 | 582 | $i++; |
| 583 | 583 | $j++; |
@@ -585,9 +585,9 @@ discard block |
||
| 585 | 585 | if ($globalDebug) echo "."; |
| 586 | 586 | try { |
| 587 | 587 | |
| 588 | - $sth = $this->db->prepare(substr($query_delete,0,-1).")"); |
|
| 588 | + $sth = $this->db->prepare(substr($query_delete, 0, -1).")"); |
|
| 589 | 589 | $sth->execute(); |
| 590 | - } catch(PDOException $e) { |
|
| 590 | + } catch (PDOException $e) { |
|
| 591 | 591 | return "error"; |
| 592 | 592 | } |
| 593 | 593 | $query_delete = 'DELETE FROM marine_live WHERE fammarine_id IN ('; |
@@ -598,9 +598,9 @@ discard block |
||
| 598 | 598 | if ($i > 0) { |
| 599 | 599 | try { |
| 600 | 600 | |
| 601 | - $sth = $this->db->prepare(substr($query_delete,0,-1).")"); |
|
| 601 | + $sth = $this->db->prepare(substr($query_delete, 0, -1).")"); |
|
| 602 | 602 | $sth->execute(); |
| 603 | - } catch(PDOException $e) { |
|
| 603 | + } catch (PDOException $e) { |
|
| 604 | 604 | return "error"; |
| 605 | 605 | } |
| 606 | 606 | } |
@@ -613,7 +613,7 @@ discard block |
||
| 613 | 613 | |
| 614 | 614 | $sth = $this->db->prepare($query); |
| 615 | 615 | $sth->execute(); |
| 616 | - } catch(PDOException $e) { |
|
| 616 | + } catch (PDOException $e) { |
|
| 617 | 617 | return "error"; |
| 618 | 618 | } |
| 619 | 619 | /* $query_delete = "DELETE FROM marine_live WHERE fammarine_id IN ("; |
@@ -661,13 +661,13 @@ discard block |
||
| 661 | 661 | public function deleteLiveMarineDataByIdent($ident) |
| 662 | 662 | { |
| 663 | 663 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 664 | - $query = 'DELETE FROM marine_live WHERE ident = :ident'; |
|
| 664 | + $query = 'DELETE FROM marine_live WHERE ident = :ident'; |
|
| 665 | 665 | |
| 666 | 666 | try { |
| 667 | 667 | |
| 668 | 668 | $sth = $this->db->prepare($query); |
| 669 | 669 | $sth->execute(array(':ident' => $ident)); |
| 670 | - } catch(PDOException $e) { |
|
| 670 | + } catch (PDOException $e) { |
|
| 671 | 671 | return "error"; |
| 672 | 672 | } |
| 673 | 673 | |
@@ -683,13 +683,13 @@ discard block |
||
| 683 | 683 | public function deleteLiveMarineDataById($id) |
| 684 | 684 | { |
| 685 | 685 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
| 686 | - $query = 'DELETE FROM marine_live WHERE fammarine_id = :id'; |
|
| 686 | + $query = 'DELETE FROM marine_live WHERE fammarine_id = :id'; |
|
| 687 | 687 | |
| 688 | 688 | try { |
| 689 | 689 | |
| 690 | 690 | $sth = $this->db->prepare($query); |
| 691 | 691 | $sth->execute(array(':id' => $id)); |
| 692 | - } catch(PDOException $e) { |
|
| 692 | + } catch (PDOException $e) { |
|
| 693 | 693 | return "error"; |
| 694 | 694 | } |
| 695 | 695 | |
@@ -707,13 +707,13 @@ discard block |
||
| 707 | 707 | { |
| 708 | 708 | global $globalDBdriver, $globalTimezone; |
| 709 | 709 | if ($globalDBdriver == 'mysql') { |
| 710 | - $query = 'SELECT marine_live.ident FROM marine_live |
|
| 710 | + $query = 'SELECT marine_live.ident FROM marine_live |
|
| 711 | 711 | WHERE marine_live.ident = :ident |
| 712 | 712 | AND marine_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) |
| 713 | 713 | AND marine_live.date < UTC_TIMESTAMP()'; |
| 714 | 714 | $query_data = array(':ident' => $ident); |
| 715 | 715 | } else { |
| 716 | - $query = "SELECT marine_live.ident FROM marine_live |
|
| 716 | + $query = "SELECT marine_live.ident FROM marine_live |
|
| 717 | 717 | WHERE marine_live.ident = :ident |
| 718 | 718 | AND marine_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '1 HOURS' |
| 719 | 719 | AND marine_live.date < now() AT TIME ZONE 'UTC'"; |
@@ -722,8 +722,8 @@ discard block |
||
| 722 | 722 | |
| 723 | 723 | $sth = $this->db->prepare($query); |
| 724 | 724 | $sth->execute($query_data); |
| 725 | - $ident_result=''; |
|
| 726 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 725 | + $ident_result = ''; |
|
| 726 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 727 | 727 | { |
| 728 | 728 | $ident_result = $row['ident']; |
| 729 | 729 | } |
@@ -740,13 +740,13 @@ discard block |
||
| 740 | 740 | { |
| 741 | 741 | global $globalDBdriver, $globalTimezone; |
| 742 | 742 | if ($globalDBdriver == 'mysql') { |
| 743 | - $query = 'SELECT marine_live.ident, marine_live.fammarine_id FROM marine_live |
|
| 743 | + $query = 'SELECT marine_live.ident, marine_live.fammarine_id FROM marine_live |
|
| 744 | 744 | WHERE marine_live.ident = :ident |
| 745 | 745 | AND marine_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 MINUTE)'; |
| 746 | 746 | // AND marine_live.date < UTC_TIMESTAMP()"; |
| 747 | 747 | $query_data = array(':ident' => $ident); |
| 748 | 748 | } else { |
| 749 | - $query = "SELECT marine_live.ident, marine_live.fammarine_id FROM marine_live |
|
| 749 | + $query = "SELECT marine_live.ident, marine_live.fammarine_id FROM marine_live |
|
| 750 | 750 | WHERE marine_live.ident = :ident |
| 751 | 751 | AND marine_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '30 MINUTES'"; |
| 752 | 752 | // AND marine_live.date < now() AT TIME ZONE 'UTC'"; |
@@ -755,8 +755,8 @@ discard block |
||
| 755 | 755 | |
| 756 | 756 | $sth = $this->db->prepare($query); |
| 757 | 757 | $sth->execute($query_data); |
| 758 | - $ident_result=''; |
|
| 759 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 758 | + $ident_result = ''; |
|
| 759 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 760 | 760 | { |
| 761 | 761 | $ident_result = $row['fammarine_id']; |
| 762 | 762 | } |
@@ -773,13 +773,13 @@ discard block |
||
| 773 | 773 | { |
| 774 | 774 | global $globalDBdriver, $globalTimezone; |
| 775 | 775 | if ($globalDBdriver == 'mysql') { |
| 776 | - $query = 'SELECT marine_live.ident, marine_live.fammarine_id FROM marine_live |
|
| 776 | + $query = 'SELECT marine_live.ident, marine_live.fammarine_id FROM marine_live |
|
| 777 | 777 | WHERE marine_live.fammarine_id = :id |
| 778 | 778 | AND marine_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 10 HOUR)'; |
| 779 | 779 | // AND marine_live.date < UTC_TIMESTAMP()"; |
| 780 | 780 | $query_data = array(':id' => $id); |
| 781 | 781 | } else { |
| 782 | - $query = "SELECT marine_live.ident, marine_live.fammarine_id FROM marine_live |
|
| 782 | + $query = "SELECT marine_live.ident, marine_live.fammarine_id FROM marine_live |
|
| 783 | 783 | WHERE marine_live.fammarine_id = :id |
| 784 | 784 | AND marine_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '10 HOUR'"; |
| 785 | 785 | // AND marine_live.date < now() AT TIME ZONE 'UTC'"; |
@@ -788,8 +788,8 @@ discard block |
||
| 788 | 788 | |
| 789 | 789 | $sth = $this->db->prepare($query); |
| 790 | 790 | $sth->execute($query_data); |
| 791 | - $ident_result=''; |
|
| 792 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 791 | + $ident_result = ''; |
|
| 792 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 793 | 793 | { |
| 794 | 794 | $ident_result = $row['fammarine_id']; |
| 795 | 795 | } |
@@ -806,13 +806,13 @@ discard block |
||
| 806 | 806 | { |
| 807 | 807 | global $globalDBdriver, $globalTimezone; |
| 808 | 808 | if ($globalDBdriver == 'mysql') { |
| 809 | - $query = 'SELECT marine_live.fammarine_id FROM marine_live |
|
| 809 | + $query = 'SELECT marine_live.fammarine_id FROM marine_live |
|
| 810 | 810 | WHERE marine_live.mmsi = :mmsi |
| 811 | 811 | AND marine_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 10 HOUR)'; |
| 812 | 812 | // AND marine_live.date < UTC_TIMESTAMP()"; |
| 813 | 813 | $query_data = array(':mmsi' => $mmsi); |
| 814 | 814 | } else { |
| 815 | - $query = "SELECT marine_live.fammarine_id FROM marine_live |
|
| 815 | + $query = "SELECT marine_live.fammarine_id FROM marine_live |
|
| 816 | 816 | WHERE marine_live.mmsi = :mmsi |
| 817 | 817 | AND marine_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '10 HOUR'"; |
| 818 | 818 | // AND marine_live.date < now() AT TIME ZONE 'UTC'"; |
@@ -821,8 +821,8 @@ discard block |
||
| 821 | 821 | |
| 822 | 822 | $sth = $this->db->prepare($query); |
| 823 | 823 | $sth->execute($query_data); |
| 824 | - $ident_result=''; |
|
| 825 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 824 | + $ident_result = ''; |
|
| 825 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 826 | 826 | { |
| 827 | 827 | $ident_result = $row['fammarine_id']; |
| 828 | 828 | } |
@@ -840,7 +840,7 @@ discard block |
||
| 840 | 840 | * @return String success or false |
| 841 | 841 | * |
| 842 | 842 | */ |
| 843 | - public function addLiveMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $heading = '', $groundspeed = '', $date = '', $putinarchive = false, $mmsi = '',$type = '',$typeid = '',$imo = '', $callsign = '',$arrival_code = '',$arrival_date = '',$status = '',$statusid = '',$noarchive = false,$format_source = '', $source_name = '', $over_country = '') |
|
| 843 | + public function addLiveMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $heading = '', $groundspeed = '', $date = '', $putinarchive = false, $mmsi = '', $type = '', $typeid = '', $imo = '', $callsign = '', $arrival_code = '', $arrival_date = '', $status = '', $statusid = '', $noarchive = false, $format_source = '', $source_name = '', $over_country = '') |
|
| 844 | 844 | { |
| 845 | 845 | global $globalURL, $globalArchive, $globalDebug; |
| 846 | 846 | $Common = new Common(); |
@@ -892,26 +892,26 @@ discard block |
||
| 892 | 892 | if ($date == '') $date = date("Y-m-d H:i:s", time()); |
| 893 | 893 | |
| 894 | 894 | |
| 895 | - $fammarine_id = filter_var($fammarine_id,FILTER_SANITIZE_STRING); |
|
| 896 | - $ident = filter_var($ident,FILTER_SANITIZE_STRING); |
|
| 897 | - $latitude = filter_var($latitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 898 | - $longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 899 | - $heading = filter_var($heading,FILTER_SANITIZE_NUMBER_INT); |
|
| 900 | - $groundspeed = filter_var($groundspeed,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 901 | - $format_source = filter_var($format_source,FILTER_SANITIZE_STRING); |
|
| 902 | - $source_name = filter_var($source_name,FILTER_SANITIZE_STRING); |
|
| 903 | - $over_country = filter_var($over_country,FILTER_SANITIZE_STRING); |
|
| 904 | - $type = filter_var($type,FILTER_SANITIZE_STRING); |
|
| 905 | - $mmsi = filter_var($mmsi,FILTER_SANITIZE_NUMBER_INT); |
|
| 906 | - $status = filter_var($status,FILTER_SANITIZE_STRING); |
|
| 907 | - $imo = filter_var($imo,FILTER_SANITIZE_STRING); |
|
| 908 | - $callsign = filter_var($callsign,FILTER_SANITIZE_STRING); |
|
| 909 | - $arrival_code = filter_var($arrival_code,FILTER_SANITIZE_STRING); |
|
| 910 | - $arrival_date = filter_var($arrival_date,FILTER_SANITIZE_STRING); |
|
| 895 | + $fammarine_id = filter_var($fammarine_id, FILTER_SANITIZE_STRING); |
|
| 896 | + $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
| 897 | + $latitude = filter_var($latitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 898 | + $longitude = filter_var($longitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 899 | + $heading = filter_var($heading, FILTER_SANITIZE_NUMBER_INT); |
|
| 900 | + $groundspeed = filter_var($groundspeed, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 901 | + $format_source = filter_var($format_source, FILTER_SANITIZE_STRING); |
|
| 902 | + $source_name = filter_var($source_name, FILTER_SANITIZE_STRING); |
|
| 903 | + $over_country = filter_var($over_country, FILTER_SANITIZE_STRING); |
|
| 904 | + $type = filter_var($type, FILTER_SANITIZE_STRING); |
|
| 905 | + $mmsi = filter_var($mmsi, FILTER_SANITIZE_NUMBER_INT); |
|
| 906 | + $status = filter_var($status, FILTER_SANITIZE_STRING); |
|
| 907 | + $imo = filter_var($imo, FILTER_SANITIZE_STRING); |
|
| 908 | + $callsign = filter_var($callsign, FILTER_SANITIZE_STRING); |
|
| 909 | + $arrival_code = filter_var($arrival_code, FILTER_SANITIZE_STRING); |
|
| 910 | + $arrival_date = filter_var($arrival_date, FILTER_SANITIZE_STRING); |
|
| 911 | 911 | |
| 912 | 912 | |
| 913 | - if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0; |
|
| 914 | - if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0; |
|
| 913 | + if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0; |
|
| 914 | + if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0; |
|
| 915 | 915 | if ($arrival_date == '') $arrival_date = NULL; |
| 916 | 916 | $query = ''; |
| 917 | 917 | if ($globalArchive) { |
@@ -921,18 +921,18 @@ discard block |
||
| 921 | 921 | $query .= 'INSERT INTO marine_live (fammarine_id, ident, latitude, longitude, heading, ground_speed, date, format_source, source_name, over_country, mmsi, type,status,imo,arrival_port_name,arrival_port_date) |
| 922 | 922 | VALUES (:fammarine_id,:ident,:latitude,:longitude,:heading,:groundspeed,:date,:format_source, :source_name, :over_country,:mmsi,:type,:status,:imo,:arrival_port_name,:arrival_port_date)'; |
| 923 | 923 | |
| 924 | - $query_values = array(':fammarine_id' => $fammarine_id,':ident' => $ident,':latitude' => $latitude,':longitude' => $longitude,':heading' => $heading,':groundspeed' => $groundspeed,':date' => $date, ':format_source' => $format_source, ':source_name' => $source_name, ':over_country' => $over_country,':mmsi' => $mmsi,':type' => $type,':status' => $status,':imo' => $imo,':arrival_port_name' => $arrival_code,':arrival_port_date' => $arrival_date); |
|
| 924 | + $query_values = array(':fammarine_id' => $fammarine_id, ':ident' => $ident, ':latitude' => $latitude, ':longitude' => $longitude, ':heading' => $heading, ':groundspeed' => $groundspeed, ':date' => $date, ':format_source' => $format_source, ':source_name' => $source_name, ':over_country' => $over_country, ':mmsi' => $mmsi, ':type' => $type, ':status' => $status, ':imo' => $imo, ':arrival_port_name' => $arrival_code, ':arrival_port_date' => $arrival_date); |
|
| 925 | 925 | try { |
| 926 | 926 | $sth = $this->db->prepare($query); |
| 927 | 927 | $sth->execute($query_values); |
| 928 | - } catch(PDOException $e) { |
|
| 928 | + } catch (PDOException $e) { |
|
| 929 | 929 | return "error : ".$e->getMessage(); |
| 930 | 930 | } |
| 931 | 931 | |
| 932 | 932 | if (isset($globalArchive) && $globalArchive && $putinarchive && $noarchive !== true) { |
| 933 | 933 | if ($globalDebug) echo '(Add to Marine archive : '; |
| 934 | 934 | $MarineArchive = new MarineArchive($this->db); |
| 935 | - $result = $MarineArchive->addMarineArchiveData($fammarine_id, $ident, $latitude, $longitude, $heading, $groundspeed, $date, $putinarchive, $mmsi,$type,$typeid,$imo, $callsign,$arrival_code,$arrival_date,$status,$noarchive,$format_source, $source_name, $over_country); |
|
| 935 | + $result = $MarineArchive->addMarineArchiveData($fammarine_id, $ident, $latitude, $longitude, $heading, $groundspeed, $date, $putinarchive, $mmsi, $type, $typeid, $imo, $callsign, $arrival_code, $arrival_date, $status, $noarchive, $format_source, $source_name, $over_country); |
|
| 936 | 936 | if ($globalDebug) echo $result.')'; |
| 937 | 937 | } |
| 938 | 938 | return "success"; |
@@ -940,7 +940,7 @@ discard block |
||
| 940 | 940 | |
| 941 | 941 | public function getOrderBy() |
| 942 | 942 | { |
| 943 | - $orderby = array("aircraft_asc" => array("key" => "aircraft_asc", "value" => "Aircraft Type - ASC", "sql" => "ORDER BY marine_live.aircraft_icao ASC"), "aircraft_desc" => array("key" => "aircraft_desc", "value" => "Aircraft Type - DESC", "sql" => "ORDER BY marine_live.aircraft_icao DESC"),"manufacturer_asc" => array("key" => "manufacturer_asc", "value" => "Aircraft Manufacturer - ASC", "sql" => "ORDER BY marine_live.aircraft_manufacturer ASC"), "manufacturer_desc" => array("key" => "manufacturer_desc", "value" => "Aircraft Manufacturer - DESC", "sql" => "ORDER BY marine_live.aircraft_manufacturer DESC"),"airline_name_asc" => array("key" => "airline_name_asc", "value" => "Airline Name - ASC", "sql" => "ORDER BY marine_live.airline_name ASC"), "airline_name_desc" => array("key" => "airline_name_desc", "value" => "Airline Name - DESC", "sql" => "ORDER BY marine_live.airline_name DESC"), "ident_asc" => array("key" => "ident_asc", "value" => "Ident - ASC", "sql" => "ORDER BY marine_live.ident ASC"), "ident_desc" => array("key" => "ident_desc", "value" => "Ident - DESC", "sql" => "ORDER BY marine_live.ident DESC"), "airport_departure_asc" => array("key" => "airport_departure_asc", "value" => "Departure Airport - ASC", "sql" => "ORDER BY marine_live.departure_airport_city ASC"), "airport_departure_desc" => array("key" => "airport_departure_desc", "value" => "Departure Airport - DESC", "sql" => "ORDER BY marine_live.departure_airport_city DESC"), "airport_arrival_asc" => array("key" => "airport_arrival_asc", "value" => "Arrival Airport - ASC", "sql" => "ORDER BY marine_live.arrival_airport_city ASC"), "airport_arrival_desc" => array("key" => "airport_arrival_desc", "value" => "Arrival Airport - DESC", "sql" => "ORDER BY marine_live.arrival_airport_city DESC"), "date_asc" => array("key" => "date_asc", "value" => "Date - ASC", "sql" => "ORDER BY marine_live.date ASC"), "date_desc" => array("key" => "date_desc", "value" => "Date - DESC", "sql" => "ORDER BY marine_live.date DESC")); |
|
| 943 | + $orderby = array("aircraft_asc" => array("key" => "aircraft_asc", "value" => "Aircraft Type - ASC", "sql" => "ORDER BY marine_live.aircraft_icao ASC"), "aircraft_desc" => array("key" => "aircraft_desc", "value" => "Aircraft Type - DESC", "sql" => "ORDER BY marine_live.aircraft_icao DESC"), "manufacturer_asc" => array("key" => "manufacturer_asc", "value" => "Aircraft Manufacturer - ASC", "sql" => "ORDER BY marine_live.aircraft_manufacturer ASC"), "manufacturer_desc" => array("key" => "manufacturer_desc", "value" => "Aircraft Manufacturer - DESC", "sql" => "ORDER BY marine_live.aircraft_manufacturer DESC"), "airline_name_asc" => array("key" => "airline_name_asc", "value" => "Airline Name - ASC", "sql" => "ORDER BY marine_live.airline_name ASC"), "airline_name_desc" => array("key" => "airline_name_desc", "value" => "Airline Name - DESC", "sql" => "ORDER BY marine_live.airline_name DESC"), "ident_asc" => array("key" => "ident_asc", "value" => "Ident - ASC", "sql" => "ORDER BY marine_live.ident ASC"), "ident_desc" => array("key" => "ident_desc", "value" => "Ident - DESC", "sql" => "ORDER BY marine_live.ident DESC"), "airport_departure_asc" => array("key" => "airport_departure_asc", "value" => "Departure Airport - ASC", "sql" => "ORDER BY marine_live.departure_airport_city ASC"), "airport_departure_desc" => array("key" => "airport_departure_desc", "value" => "Departure Airport - DESC", "sql" => "ORDER BY marine_live.departure_airport_city DESC"), "airport_arrival_asc" => array("key" => "airport_arrival_asc", "value" => "Arrival Airport - ASC", "sql" => "ORDER BY marine_live.arrival_airport_city ASC"), "airport_arrival_desc" => array("key" => "airport_arrival_desc", "value" => "Arrival Airport - DESC", "sql" => "ORDER BY marine_live.arrival_airport_city DESC"), "date_asc" => array("key" => "date_asc", "value" => "Date - ASC", "sql" => "ORDER BY marine_live.date ASC"), "date_desc" => array("key" => "date_desc", "value" => "Date - DESC", "sql" => "ORDER BY marine_live.date DESC")); |
|
| 944 | 944 | return $orderby; |
| 945 | 945 | } |
| 946 | 946 | |
@@ -8,7 +8,9 @@ discard block |
||
| 8 | 8 | public function __construct($dbc = null) { |
| 9 | 9 | $Connection = new Connection($dbc); |
| 10 | 10 | $this->db = $Connection->db(); |
| 11 | - if ($this->db === null) die('Error: No DB connection.'); |
|
| 11 | + if ($this->db === null) { |
|
| 12 | + die('Error: No DB connection.'); |
|
| 13 | + } |
|
| 12 | 14 | } |
| 13 | 15 | |
| 14 | 16 | |
@@ -30,7 +32,9 @@ discard block |
||
| 30 | 32 | if (isset($filter[0]['source'])) { |
| 31 | 33 | $filters = array_merge($filters,$filter); |
| 32 | 34 | } |
| 33 | - if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter); |
|
| 35 | + if (is_array($globalFilter)) { |
|
| 36 | + $filter = array_merge($filter,$globalFilter); |
|
| 37 | + } |
|
| 34 | 38 | $filter_query_join = ''; |
| 35 | 39 | $filter_query_where = ''; |
| 36 | 40 | foreach($filters as $flt) { |
@@ -77,8 +81,11 @@ discard block |
||
| 77 | 81 | if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
| 78 | 82 | $filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
| 79 | 83 | } |
| 80 | - if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE'; |
|
| 81 | - elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND'; |
|
| 84 | + if ($filter_query_where == '' && $where) { |
|
| 85 | + $filter_query_where = ' WHERE'; |
|
| 86 | + } elseif ($filter_query_where != '' && $and) { |
|
| 87 | + $filter_query_where .= ' AND'; |
|
| 88 | + } |
|
| 82 | 89 | if ($filter_query_where != '') { |
| 83 | 90 | $filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where); |
| 84 | 91 | } |
@@ -119,9 +126,13 @@ discard block |
||
| 119 | 126 | $orderby_query = ' '.$search_orderby_array[$sort]['sql']; |
| 120 | 127 | } |
| 121 | 128 | } |
| 122 | - if ($orderby_query == '') $orderby_query= ' ORDER BY date DESC'; |
|
| 129 | + if ($orderby_query == '') { |
|
| 130 | + $orderby_query= ' ORDER BY date DESC'; |
|
| 131 | + } |
|
| 123 | 132 | |
| 124 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
| 133 | + if (!isset($globalLiveInterval)) { |
|
| 134 | + $globalLiveInterval = '200'; |
|
| 135 | + } |
|
| 125 | 136 | if ($globalDBdriver == 'mysql') { |
| 126 | 137 | //$query = "SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 SECOND) <= l.date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate"; |
| 127 | 138 | $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate'.$filter_query.$orderby_query; |
@@ -146,7 +157,9 @@ discard block |
||
| 146 | 157 | |
| 147 | 158 | $filter_query = $this->getFilter($filter,true,true); |
| 148 | 159 | |
| 149 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
| 160 | + if (!isset($globalLiveInterval)) { |
|
| 161 | + $globalLiveInterval = '200'; |
|
| 162 | + } |
|
| 150 | 163 | if ($globalDBdriver == 'mysql') { |
| 151 | 164 | $query = 'SELECT marine_live.mmsi, marine_live.ident, marine_live.type,marine_live.fammarine_id, marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source |
| 152 | 165 | FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate'.$filter_query." marine_live.latitude <> 0 AND marine_live.longitude <> 0"; |
@@ -185,48 +198,72 @@ discard block |
||
| 185 | 198 | } |
| 186 | 199 | $filter_query = $this->getFilter($filter,true,true); |
| 187 | 200 | |
| 188 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
| 189 | - if (!isset($globalMap3DMarinesLimit) || $globalMap3DMarinesLimit == '') $globalMap3DMarinesLimit = '300'; |
|
| 201 | + if (!isset($globalLiveInterval)) { |
|
| 202 | + $globalLiveInterval = '200'; |
|
| 203 | + } |
|
| 204 | + if (!isset($globalMap3DMarinesLimit) || $globalMap3DMarinesLimit == '') { |
|
| 205 | + $globalMap3DMarinesLimit = '300'; |
|
| 206 | + } |
|
| 190 | 207 | if ($globalDBdriver == 'mysql') { |
| 191 | 208 | if (isset($globalArchive) && $globalArchive === TRUE) { |
| 192 | 209 | $query = 'SELECT * FROM (SELECT marine_archive.ident, marine_archive.fammarine_id,marine_archive.type, marine_archive.latitude, marine_archive.longitude, marine_archive.heading, marine_archive.ground_speed, marine_archive.date, marine_archive.format_source |
| 193 | 210 | FROM marine_archive INNER JOIN (SELECT fammarine_id FROM marine_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= marine_live.date) l ON l.flightaware_id = marine_archive.flightaware_id "; |
| 194 | - if (isset($maxlat)) $query .= "AND marine_archive.latitude BETWEEN ".$minlat." AND ".$maxlat." AND marine_archive.longitude BETWEEN ".$minlong." AND ".$maxlong." "; |
|
| 211 | + if (isset($maxlat)) { |
|
| 212 | + $query .= "AND marine_archive.latitude BETWEEN ".$minlat." AND ".$maxlat." AND marine_archive.longitude BETWEEN ".$minlong." AND ".$maxlong." "; |
|
| 213 | + } |
|
| 195 | 214 | $query .= "UNION |
| 196 | 215 | SELECT marine_live.ident, marine_live.fammarine_id,marine_live.type, marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source |
| 197 | 216 | FROM marine_live".$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= marine_live.date"; |
| 198 | - if (isset($maxlat)) $query .= " AND marine_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND marine_live.longitude BETWEEN ".$minlong." AND ".$maxlong; |
|
| 217 | + if (isset($maxlat)) { |
|
| 218 | + $query .= " AND marine_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND marine_live.longitude BETWEEN ".$minlong." AND ".$maxlong; |
|
| 219 | + } |
|
| 199 | 220 | $query .= ") AS marine |
| 200 | 221 | WHERE latitude <> '0' AND longitude <> '0' |
| 201 | 222 | ORDER BY fammarine_id, date"; |
| 202 | - if ($limit) $query .= " LIMIT ".$globalMap3DMarinesLimit; |
|
| 223 | + if ($limit) { |
|
| 224 | + $query .= " LIMIT ".$globalMap3DMarinesLimit; |
|
| 225 | + } |
|
| 203 | 226 | } else { |
| 204 | 227 | $query = 'SELECT marine_live.ident, marine_live.fammarine_id,marine_live.type, marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source |
| 205 | 228 | FROM marine_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= marine_live.date "; |
| 206 | - if (isset($maxlat)) $query .= "AND marine_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND marine_live.longitude BETWEEN ".$minlong." AND ".$maxlong." "; |
|
| 229 | + if (isset($maxlat)) { |
|
| 230 | + $query .= "AND marine_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND marine_live.longitude BETWEEN ".$minlong." AND ".$maxlong." "; |
|
| 231 | + } |
|
| 207 | 232 | $query .= "AND marine_live.latitude <> '0' AND marine_live.longitude <> '0' |
| 208 | 233 | ORDER BY marine_live.fammarine_id, marine_live.date"; |
| 209 | - if ($limit) $query .= " LIMIT ".$globalMap3DMarinesLimit; |
|
| 234 | + if ($limit) { |
|
| 235 | + $query .= " LIMIT ".$globalMap3DMarinesLimit; |
|
| 236 | + } |
|
| 210 | 237 | } |
| 211 | 238 | } else { |
| 212 | 239 | if (isset($globalArchive) && $globalArchive === TRUE) { |
| 213 | 240 | $query = "SELECT * FROM (SELECT marine_archive.ident, marine_archive.fammarine_id, marine_archive.type,marine_archive.latitude, marine_archive.longitude, marine_archive.heading, marine_archive.ground_speed, marine_archive.date, marine_archive.format_source |
| 214 | 241 | FROM marine_archive INNER JOIN (SELECT flightaware_id FROM marine_live".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= marine_live.date) l ON l.flightaware_id = marine_archive.flightaware_id "; |
| 215 | - if (isset($maxlat)) $query .= "AND marine_archive.latitude BETWEEN ".$minlat." AND ".$maxlat." AND marine_archive.longitude BETWEEN ".$minlong." AND ".$maxlong." "; |
|
| 242 | + if (isset($maxlat)) { |
|
| 243 | + $query .= "AND marine_archive.latitude BETWEEN ".$minlat." AND ".$maxlat." AND marine_archive.longitude BETWEEN ".$minlong." AND ".$maxlong." "; |
|
| 244 | + } |
|
| 216 | 245 | $query .= "UNION |
| 217 | 246 | SELECT marine_live.ident, marine_live.fammarine_id, marine_live.type,marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source |
| 218 | 247 | FROM marine_live".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= marine_live.date"; |
| 219 | - if (isset($maxlat)) $query .= " AND marine_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND marine_live.longitude BETWEEN ".$minlong." AND ".$maxlong; |
|
| 248 | + if (isset($maxlat)) { |
|
| 249 | + $query .= " AND marine_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND marine_live.longitude BETWEEN ".$minlong." AND ".$maxlong; |
|
| 250 | + } |
|
| 220 | 251 | $query .= ") AS marine WHERE latitude <> '0' AND longitude <> '0' "; |
| 221 | 252 | $query .= "ORDER BY fammarine_id, date"; |
| 222 | - if ($limit) $query .= " LIMIT ".$globalMap3DMarinesLimit; |
|
| 253 | + if ($limit) { |
|
| 254 | + $query .= " LIMIT ".$globalMap3DMarinesLimit; |
|
| 255 | + } |
|
| 223 | 256 | } else { |
| 224 | 257 | $query = "SELECT marine_live.ident, marine_live.fammarine_id, marine_live.type,marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source |
| 225 | 258 | FROM marine_live".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= marine_live.date "; |
| 226 | - if (isset($maxlat)) $query .= "AND marine_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND marine_live.longitude BETWEEN ".$minlong." AND ".$maxlong." "; |
|
| 259 | + if (isset($maxlat)) { |
|
| 260 | + $query .= "AND marine_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND marine_live.longitude BETWEEN ".$minlong." AND ".$maxlong." "; |
|
| 261 | + } |
|
| 227 | 262 | $query .= "AND marine_live.latitude <> '0' AND marine_live.longitude <> '0' |
| 228 | 263 | ORDER BY marine_live.fammarine_id, marine_live.date"; |
| 229 | - if ($limit) $query .= " LIMIT ".$globalMap3DMarinesLimit; |
|
| 264 | + if ($limit) { |
|
| 265 | + $query .= " LIMIT ".$globalMap3DMarinesLimit; |
|
| 266 | + } |
|
| 230 | 267 | } |
| 231 | 268 | } |
| 232 | 269 | try { |
@@ -251,7 +288,9 @@ discard block |
||
| 251 | 288 | global $globalDBdriver, $globalLiveInterval; |
| 252 | 289 | $filter_query = $this->getFilter($filter,true,true); |
| 253 | 290 | |
| 254 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
| 291 | + if (!isset($globalLiveInterval)) { |
|
| 292 | + $globalLiveInterval = '200'; |
|
| 293 | + } |
|
| 255 | 294 | if ($globalDBdriver == 'mysql') { |
| 256 | 295 | $query = 'SELECT COUNT(DISTINCT marine_live.fammarine_id) as nb FROM marine_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date'; |
| 257 | 296 | } else { |
@@ -279,7 +318,9 @@ discard block |
||
| 279 | 318 | { |
| 280 | 319 | global $globalDBdriver, $globalLiveInterval; |
| 281 | 320 | $Spotter = new Spotter($this->db); |
| 282 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
| 321 | + if (!isset($globalLiveInterval)) { |
|
| 322 | + $globalLiveInterval = '200'; |
|
| 323 | + } |
|
| 283 | 324 | $filter_query = $this->getFilter($filter); |
| 284 | 325 | |
| 285 | 326 | if (is_array($coord)) { |
@@ -287,7 +328,9 @@ discard block |
||
| 287 | 328 | $minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
| 288 | 329 | $maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
| 289 | 330 | $maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
| 290 | - } else return array(); |
|
| 331 | + } else { |
|
| 332 | + return array(); |
|
| 333 | + } |
|
| 291 | 334 | if ($globalDBdriver == 'mysql') { |
| 292 | 335 | $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate AND marine_live.latitude BETWEEN '.$minlat.' AND '.$maxlat.' AND marine_live.longitude BETWEEN '.$minlong.' AND '.$maxlong.' GROUP BY marine_live.fammarine_id'.$filter_query; |
| 293 | 336 | } else { |
@@ -307,7 +350,9 @@ discard block |
||
| 307 | 350 | { |
| 308 | 351 | global $globalDBdriver, $globalLiveInterval; |
| 309 | 352 | $Spotter = new Spotter($this->db); |
| 310 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
| 353 | + if (!isset($globalLiveInterval)) { |
|
| 354 | + $globalLiveInterval = '200'; |
|
| 355 | + } |
|
| 311 | 356 | $filter_query = $this->getFilter($filter); |
| 312 | 357 | |
| 313 | 358 | if (is_array($coord)) { |
@@ -315,7 +360,9 @@ discard block |
||
| 315 | 360 | $minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
| 316 | 361 | $maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
| 317 | 362 | $maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
| 318 | - } else return array(); |
|
| 363 | + } else { |
|
| 364 | + return array(); |
|
| 365 | + } |
|
| 319 | 366 | if ($globalDBdriver == 'mysql') { |
| 320 | 367 | $query = 'SELECT marine_live.ident, marine_live.fammarine_id,marine_live.type, marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source |
| 321 | 368 | FROM marine_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= marine_live.date AND marine_live.latitude <> '0' AND marine_live.longitude <> '0' AND marine_live.latitude BETWEEN ".$minlat.' AND '.$maxlat.' AND marine_live.longitude BETWEEN '.$minlong.' AND '.$maxlong." |
@@ -483,11 +530,15 @@ discard block |
||
| 483 | 530 | //$query = self::$global_query.' WHERE marine_live.fammarine_id = :id ORDER BY date'; |
| 484 | 531 | if ($globalDBdriver == 'mysql') { |
| 485 | 532 | $query = 'SELECT marine_live.* FROM marine_live WHERE marine_live.fammarine_id = :id'; |
| 486 | - if ($liveinterval) $query .= ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date'; |
|
| 533 | + if ($liveinterval) { |
|
| 534 | + $query .= ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date'; |
|
| 535 | + } |
|
| 487 | 536 | $query .= ' ORDER BY date'; |
| 488 | 537 | } else { |
| 489 | 538 | $query = 'SELECT marine_live.* FROM marine_live WHERE marine_live.fammarine_id = :id'; |
| 490 | - if ($liveinterval) $query .= " AND CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= date"; |
|
| 539 | + if ($liveinterval) { |
|
| 540 | + $query .= " AND CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= date"; |
|
| 541 | + } |
|
| 491 | 542 | $query .= ' ORDER BY date'; |
| 492 | 543 | } |
| 493 | 544 | |
@@ -582,7 +633,9 @@ discard block |
||
| 582 | 633 | $i++; |
| 583 | 634 | $j++; |
| 584 | 635 | if ($j == 30) { |
| 585 | - if ($globalDebug) echo "."; |
|
| 636 | + if ($globalDebug) { |
|
| 637 | + echo "."; |
|
| 638 | + } |
|
| 586 | 639 | try { |
| 587 | 640 | |
| 588 | 641 | $sth = $this->db->prepare(substr($query_delete,0,-1).")"); |
@@ -862,7 +915,9 @@ discard block |
||
| 862 | 915 | { |
| 863 | 916 | return false; |
| 864 | 917 | } |
| 865 | - } else return ''; |
|
| 918 | + } else { |
|
| 919 | + return ''; |
|
| 920 | + } |
|
| 866 | 921 | |
| 867 | 922 | if ($longitude != '') |
| 868 | 923 | { |
@@ -870,7 +925,9 @@ discard block |
||
| 870 | 925 | { |
| 871 | 926 | return false; |
| 872 | 927 | } |
| 873 | - } else return ''; |
|
| 928 | + } else { |
|
| 929 | + return ''; |
|
| 930 | + } |
|
| 874 | 931 | |
| 875 | 932 | |
| 876 | 933 | if ($heading != '') |
@@ -879,7 +936,9 @@ discard block |
||
| 879 | 936 | { |
| 880 | 937 | return false; |
| 881 | 938 | } |
| 882 | - } else $heading = 0; |
|
| 939 | + } else { |
|
| 940 | + $heading = 0; |
|
| 941 | + } |
|
| 883 | 942 | |
| 884 | 943 | if ($groundspeed != '') |
| 885 | 944 | { |
@@ -887,9 +946,13 @@ discard block |
||
| 887 | 946 | { |
| 888 | 947 | return false; |
| 889 | 948 | } |
| 890 | - } else $groundspeed = 0; |
|
| 949 | + } else { |
|
| 950 | + $groundspeed = 0; |
|
| 951 | + } |
|
| 891 | 952 | date_default_timezone_set('UTC'); |
| 892 | - if ($date == '') $date = date("Y-m-d H:i:s", time()); |
|
| 953 | + if ($date == '') { |
|
| 954 | + $date = date("Y-m-d H:i:s", time()); |
|
| 955 | + } |
|
| 893 | 956 | |
| 894 | 957 | |
| 895 | 958 | $fammarine_id = filter_var($fammarine_id,FILTER_SANITIZE_STRING); |
@@ -910,12 +973,20 @@ discard block |
||
| 910 | 973 | $arrival_date = filter_var($arrival_date,FILTER_SANITIZE_STRING); |
| 911 | 974 | |
| 912 | 975 | |
| 913 | - if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0; |
|
| 914 | - if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0; |
|
| 915 | - if ($arrival_date == '') $arrival_date = NULL; |
|
| 976 | + if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) { |
|
| 977 | + $groundspeed = 0; |
|
| 978 | + } |
|
| 979 | + if ($heading == '' || $Common->isInteger($heading) === false ) { |
|
| 980 | + $heading = 0; |
|
| 981 | + } |
|
| 982 | + if ($arrival_date == '') { |
|
| 983 | + $arrival_date = NULL; |
|
| 984 | + } |
|
| 916 | 985 | $query = ''; |
| 917 | 986 | if ($globalArchive) { |
| 918 | - if ($globalDebug) echo '-- Delete previous data -- '; |
|
| 987 | + if ($globalDebug) { |
|
| 988 | + echo '-- Delete previous data -- '; |
|
| 989 | + } |
|
| 919 | 990 | $query .= 'DELETE FROM marine_live WHERE fammarine_id = :fammarine_id;'; |
| 920 | 991 | } |
| 921 | 992 | $query .= 'INSERT INTO marine_live (fammarine_id, ident, latitude, longitude, heading, ground_speed, date, format_source, source_name, over_country, mmsi, type,status,imo,arrival_port_name,arrival_port_date) |
@@ -930,10 +1001,14 @@ discard block |
||
| 930 | 1001 | } |
| 931 | 1002 | |
| 932 | 1003 | if (isset($globalArchive) && $globalArchive && $putinarchive && $noarchive !== true) { |
| 933 | - if ($globalDebug) echo '(Add to Marine archive : '; |
|
| 1004 | + if ($globalDebug) { |
|
| 1005 | + echo '(Add to Marine archive : '; |
|
| 1006 | + } |
|
| 934 | 1007 | $MarineArchive = new MarineArchive($this->db); |
| 935 | 1008 | $result = $MarineArchive->addMarineArchiveData($fammarine_id, $ident, $latitude, $longitude, $heading, $groundspeed, $date, $putinarchive, $mmsi,$type,$typeid,$imo, $callsign,$arrival_code,$arrival_date,$status,$noarchive,$format_source, $source_name, $over_country); |
| 936 | - if ($globalDebug) echo $result.')'; |
|
| 1009 | + if ($globalDebug) { |
|
| 1010 | + echo $result.')'; |
|
| 1011 | + } |
|
| 937 | 1012 | } |
| 938 | 1013 | return "success"; |
| 939 | 1014 | } |
@@ -48,11 +48,11 @@ discard block |
||
| 48 | 48 | $s3 = sin($bank/2); |
| 49 | 49 | $c1c2 = $c1*$c2; |
| 50 | 50 | $s1s2 = $s1*$s2; |
| 51 | - $w =$c1c2*$c3 - $s1s2*$s3; |
|
| 52 | - $x =$c1c2*$s3 + $s1s2*$c3; |
|
| 53 | - $y =$s1*$c2*$c3 + $c1*$s2*$s3; |
|
| 54 | - $z =$c1*$s2*$c3 - $s1*$c2*$s3; |
|
| 55 | - return array('x' => $x,'y' => $y,'z' => $z,'w' => $w); |
|
| 51 | + $w = $c1c2*$c3 - $s1s2*$s3; |
|
| 52 | + $x = $c1c2*$s3 + $s1s2*$c3; |
|
| 53 | + $y = $s1*$c2*$c3 + $c1*$s2*$s3; |
|
| 54 | + $z = $c1*$s2*$c3 - $s1*$c2*$s3; |
|
| 55 | + return array('x' => $x, 'y' => $y, 'z' => $z, 'w' => $w); |
|
| 56 | 56 | // return array('x' => '0.0','y' => '-0.931','z' => '0.0','w' => '0.365'); |
| 57 | 57 | |
| 58 | 58 | } |
@@ -73,16 +73,16 @@ discard block |
||
| 73 | 73 | $min = false; |
| 74 | 74 | $allhistory = false; |
| 75 | 75 | $filter['source'] = array(); |
| 76 | -if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalVATSIM) && $globalVATSIM && isset($_COOKIE['filter_ShowVATSIM']) && $_COOKIE['filter_ShowVATSIM'] == 'true') $filter['source'] = array_merge($filter['source'],array('vatsimtxt')); |
|
| 77 | -if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalIVAO) && $globalIVAO && isset($_COOKIE['filter_ShowIVAO']) && $_COOKIE['filter_ShowIVAO'] == 'true') $filter['source'] = array_merge($filter['source'],array('whazzup')); |
|
| 78 | -if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalphpVMS) && $globalphpVMS && isset($_COOKIE['filter_ShowVMS']) && $_COOKIE['filter_ShowVMS'] == 'true') $filter['source'] = array_merge($filter['source'],array('phpvmacars')); |
|
| 79 | -if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalSBS1) && $globalSBS1 && isset($_COOKIE['filter_ShowSBS1']) && $_COOKIE['filter_ShowSBS1'] == 'true') $filter['source'] = array_merge($filter['source'],array('sbs','famaprs')); |
|
| 80 | -if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalAPRS) && $globalAPRS && isset($_COOKIE['filter_ShowAPRS']) && $_COOKIE['filter_ShowAPRS'] == 'true') $filter['source'] = array_merge($filter['source'],array('aprs')); |
|
| 81 | -if (isset($_COOKIE['filter_ident']) && $_COOKIE['filter_ident'] != '') $filter['ident'] = filter_var($_COOKIE['filter_ident'],FILTER_SANITIZE_STRING); |
|
| 82 | -if (isset($_COOKIE['filter_Airlines']) && $_COOKIE['filter_Airlines'] != '') $filter['airlines'] = filter_var_array(explode(',',$_COOKIE['filter_Airlines']),FILTER_SANITIZE_STRING); |
|
| 83 | -if (isset($_COOKIE['filter_Sources']) && $_COOKIE['filter_Sources'] != '') $filter['source_aprs'] = filter_var_array(explode(',',$_COOKIE['filter_Sources']),FILTER_SANITIZE_STRING); |
|
| 84 | -if (isset($_COOKIE['filter_airlinestype']) && $_COOKIE['filter_airlinestype'] != 'all') $filter['airlinestype'] = filter_var($_COOKIE['filter_airlinestype'],FILTER_SANITIZE_STRING); |
|
| 85 | -if (isset($_COOKIE['filter_alliance']) && $_COOKIE['filter_alliance'] != 'all') $filter['alliance'] = filter_var($_COOKIE['filter_alliance'],FILTER_SANITIZE_STRING); |
|
| 76 | +if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalVATSIM) && $globalVATSIM && isset($_COOKIE['filter_ShowVATSIM']) && $_COOKIE['filter_ShowVATSIM'] == 'true') $filter['source'] = array_merge($filter['source'], array('vatsimtxt')); |
|
| 77 | +if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalIVAO) && $globalIVAO && isset($_COOKIE['filter_ShowIVAO']) && $_COOKIE['filter_ShowIVAO'] == 'true') $filter['source'] = array_merge($filter['source'], array('whazzup')); |
|
| 78 | +if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalphpVMS) && $globalphpVMS && isset($_COOKIE['filter_ShowVMS']) && $_COOKIE['filter_ShowVMS'] == 'true') $filter['source'] = array_merge($filter['source'], array('phpvmacars')); |
|
| 79 | +if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalSBS1) && $globalSBS1 && isset($_COOKIE['filter_ShowSBS1']) && $_COOKIE['filter_ShowSBS1'] == 'true') $filter['source'] = array_merge($filter['source'], array('sbs', 'famaprs')); |
|
| 80 | +if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalAPRS) && $globalAPRS && isset($_COOKIE['filter_ShowAPRS']) && $_COOKIE['filter_ShowAPRS'] == 'true') $filter['source'] = array_merge($filter['source'], array('aprs')); |
|
| 81 | +if (isset($_COOKIE['filter_ident']) && $_COOKIE['filter_ident'] != '') $filter['ident'] = filter_var($_COOKIE['filter_ident'], FILTER_SANITIZE_STRING); |
|
| 82 | +if (isset($_COOKIE['filter_Airlines']) && $_COOKIE['filter_Airlines'] != '') $filter['airlines'] = filter_var_array(explode(',', $_COOKIE['filter_Airlines']), FILTER_SANITIZE_STRING); |
|
| 83 | +if (isset($_COOKIE['filter_Sources']) && $_COOKIE['filter_Sources'] != '') $filter['source_aprs'] = filter_var_array(explode(',', $_COOKIE['filter_Sources']), FILTER_SANITIZE_STRING); |
|
| 84 | +if (isset($_COOKIE['filter_airlinestype']) && $_COOKIE['filter_airlinestype'] != 'all') $filter['airlinestype'] = filter_var($_COOKIE['filter_airlinestype'], FILTER_SANITIZE_STRING); |
|
| 85 | +if (isset($_COOKIE['filter_alliance']) && $_COOKIE['filter_alliance'] != 'all') $filter['alliance'] = filter_var($_COOKIE['filter_alliance'], FILTER_SANITIZE_STRING); |
|
| 86 | 86 | /* |
| 87 | 87 | if (isset($globalMapPopup) && !$globalMapPopup && !(isset($_COOKIE['flightpopup']) && $_COOKIE['flightpopup'] == 'true')) { |
| 88 | 88 | $min = true; |
@@ -129,12 +129,12 @@ discard block |
||
| 129 | 129 | $from_archive = true; |
| 130 | 130 | // $begindate = filter_input(INPUT_GET,'begindate',FILTER_VALIDATE_REGEXP,array("options"=>array("regexp"=>'~^\d{4}/\d{2}/\d{2}$~'))); |
| 131 | 131 | // $enddate = filter_input(INPUT_GET,'enddate',FILTER_VALIDATE_REGEXP,array("options"=>array("regexp"=>'~^\d{4}/\d{2}/\d{2}$~'))); |
| 132 | - $begindate = filter_input(INPUT_GET,'begindate',FILTER_SANITIZE_NUMBER_INT); |
|
| 133 | - $enddate = filter_input(INPUT_GET,'enddate',FILTER_SANITIZE_NUMBER_INT); |
|
| 134 | - $archivespeed = filter_input(INPUT_GET,'speed',FILTER_SANITIZE_NUMBER_INT); |
|
| 135 | - $begindate = date('Y-m-d H:i:s',$begindate); |
|
| 136 | - $enddate = date('Y-m-d H:i:s',$enddate); |
|
| 137 | - $spotter_array = $SpotterArchive->getMinLiveSpotterDataPlayback($begindate,$enddate,$filter); |
|
| 132 | + $begindate = filter_input(INPUT_GET, 'begindate', FILTER_SANITIZE_NUMBER_INT); |
|
| 133 | + $enddate = filter_input(INPUT_GET, 'enddate', FILTER_SANITIZE_NUMBER_INT); |
|
| 134 | + $archivespeed = filter_input(INPUT_GET, 'speed', FILTER_SANITIZE_NUMBER_INT); |
|
| 135 | + $begindate = date('Y-m-d H:i:s', $begindate); |
|
| 136 | + $enddate = date('Y-m-d H:i:s', $enddate); |
|
| 137 | + $spotter_array = $SpotterArchive->getMinLiveSpotterDataPlayback($begindate, $enddate, $filter); |
|
| 138 | 138 | } elseif (isset($_COOKIE['archive']) && isset($_COOKIE['archive_begin']) && isset($_COOKIE['archive_end']) && isset($_COOKIE['archive_speed'])) { |
| 139 | 139 | $from_archive = true; |
| 140 | 140 | // $begindate = filter_input(INPUT_GET,'begindate',FILTER_VALIDATE_REGEXP,array("options"=>array("regexp"=>'~^\d{4}/\d{2}/\d{2}$~'))); |
@@ -144,34 +144,34 @@ discard block |
||
| 144 | 144 | $begindate = $_COOKIE['archive_begin']; |
| 145 | 145 | $enddate = $_COOKIE['archive_end']; |
| 146 | 146 | |
| 147 | - $archivespeed = filter_var($_COOKIE['archive_speed'],FILTER_SANITIZE_NUMBER_INT); |
|
| 148 | - $begindate = date('Y-m-d H:i:s',$begindate); |
|
| 149 | - $enddate = date('Y-m-d H:i:s',$enddate); |
|
| 147 | + $archivespeed = filter_var($_COOKIE['archive_speed'], FILTER_SANITIZE_NUMBER_INT); |
|
| 148 | + $begindate = date('Y-m-d H:i:s', $begindate); |
|
| 149 | + $enddate = date('Y-m-d H:i:s', $enddate); |
|
| 150 | 150 | // echo 'Begin : '.$begindate.' - End : '.$enddate."\n"; |
| 151 | - $spotter_array = $SpotterArchive->getMinLiveSpotterData($begindate,$enddate,$filter); |
|
| 151 | + $spotter_array = $SpotterArchive->getMinLiveSpotterData($begindate, $enddate, $filter); |
|
| 152 | 152 | } elseif ($tracker) { |
| 153 | 153 | $coord = array(); |
| 154 | 154 | if (isset($_GET['coord']) && $_GET['coord'] != '') { |
| 155 | - $coord = explode(',',$_GET['coord']); |
|
| 155 | + $coord = explode(',', $_GET['coord']); |
|
| 156 | 156 | } |
| 157 | - $spotter_array = $TrackerLive->getMinLastLiveTrackerData($coord,$filter,true); |
|
| 157 | + $spotter_array = $TrackerLive->getMinLastLiveTrackerData($coord, $filter, true); |
|
| 158 | 158 | } elseif ($marine) { |
| 159 | 159 | $coord = array(); |
| 160 | 160 | if (isset($_GET['coord']) && $_GET['coord'] != '') { |
| 161 | - $coord = explode(',',$_GET['coord']); |
|
| 161 | + $coord = explode(',', $_GET['coord']); |
|
| 162 | 162 | } |
| 163 | - $spotter_array = $MarineLive->getMinLastLiveMarineData($coord,$filter,true); |
|
| 163 | + $spotter_array = $MarineLive->getMinLastLiveMarineData($coord, $filter, true); |
|
| 164 | 164 | } else { |
| 165 | 165 | $coord = array(); |
| 166 | 166 | if (isset($_GET['coord']) && $_GET['coord'] != '') { |
| 167 | - $coord = explode(',',$_GET['coord']); |
|
| 167 | + $coord = explode(',', $_GET['coord']); |
|
| 168 | 168 | } |
| 169 | - $spotter_array = $SpotterLive->getMinLastLiveSpotterData($coord,$filter,true); |
|
| 169 | + $spotter_array = $SpotterLive->getMinLastLiveSpotterData($coord, $filter, true); |
|
| 170 | 170 | } |
| 171 | 171 | //print_r($spotter_array); |
| 172 | 172 | if (!empty($spotter_array) && isset($coord)) { |
| 173 | 173 | if (isset($_GET['archive'])) { |
| 174 | - $flightcnt = $SpotterArchive->getLiveSpotterCount($begindate,$enddate,$filter); |
|
| 174 | + $flightcnt = $SpotterArchive->getLiveSpotterCount($begindate, $enddate, $filter); |
|
| 175 | 175 | } elseif ($tracker) { |
| 176 | 176 | $flightcnt = $TrackerLive->getLiveTrackerCount($filter); |
| 177 | 177 | } elseif ($marine) { |
@@ -182,15 +182,15 @@ discard block |
||
| 182 | 182 | if ($flightcnt == '') $flightcnt = 0; |
| 183 | 183 | } else $flightcnt = 0; |
| 184 | 184 | |
| 185 | -$sqltime = round(microtime(true)-$begintime,2); |
|
| 185 | +$sqltime = round(microtime(true) - $begintime, 2); |
|
| 186 | 186 | $minitime = time(); |
| 187 | 187 | $maxitime = 0; |
| 188 | -$lastupdate = filter_input(INPUT_GET,'update',FILTER_SANITIZE_NUMBER_INT); |
|
| 188 | +$lastupdate = filter_input(INPUT_GET, 'update', FILTER_SANITIZE_NUMBER_INT); |
|
| 189 | 189 | $modelsdb = array(); |
| 190 | 190 | if (file_exists(dirname(__FILE__).'/models/modelsdb')) { |
| 191 | - if (($handle = fopen(dirname(__FILE__).'/models/modelsdb','r')) !== FALSE) { |
|
| 192 | - while (($row = fgetcsv($handle,1000)) !== FALSE) { |
|
| 193 | - if (isset($row[1]) ){ |
|
| 191 | + if (($handle = fopen(dirname(__FILE__).'/models/modelsdb', 'r')) !== FALSE) { |
|
| 192 | + while (($row = fgetcsv($handle, 1000)) !== FALSE) { |
|
| 193 | + if (isset($row[1])) { |
|
| 194 | 194 | $model = $row[0]; |
| 195 | 195 | $modelsdb[$model] = $row[1]; |
| 196 | 196 | } |
@@ -226,7 +226,7 @@ discard block |
||
| 226 | 226 | $output .= '},'; |
| 227 | 227 | if (!empty($spotter_array) && is_array($spotter_array)) |
| 228 | 228 | { |
| 229 | - foreach($spotter_array as $spotter_item) |
|
| 229 | + foreach ($spotter_array as $spotter_item) |
|
| 230 | 230 | { |
| 231 | 231 | $j++; |
| 232 | 232 | //if (isset($spotter_item['format_source']) && $spotter_item['format_source'] == 'airwhere') $heightrelative = 'RELATIVE_TO_GROUND'; |
@@ -258,11 +258,11 @@ discard block |
||
| 258 | 258 | $output .= '"lastupdate": "'.$lastupdate.'",'; |
| 259 | 259 | $output .= '"format": "'.$spotter_item['format_source'].'",'; |
| 260 | 260 | if ($tracker) { |
| 261 | - $output.= '"type": "tracker"'; |
|
| 261 | + $output .= '"type": "tracker"'; |
|
| 262 | 262 | } elseif ($marine) { |
| 263 | - $output.= '"type": "marine"'; |
|
| 263 | + $output .= '"type": "marine"'; |
|
| 264 | 264 | } else { |
| 265 | - $output.= '"type": "flight"'; |
|
| 265 | + $output .= '"type": "flight"'; |
|
| 266 | 266 | } |
| 267 | 267 | $output .= '},'; |
| 268 | 268 | |
@@ -606,8 +606,8 @@ discard block |
||
| 606 | 606 | $output .= '},'; |
| 607 | 607 | } |
| 608 | 608 | } |
| 609 | - if (isset($onground) && $onground) $output = str_replace('%onground%','true',$output); |
|
| 610 | - else $output = str_replace('%onground%','false',$output); |
|
| 609 | + if (isset($onground) && $onground) $output = str_replace('%onground%', 'true', $output); |
|
| 610 | + else $output = str_replace('%onground%', 'false', $output); |
|
| 611 | 611 | |
| 612 | 612 | // $output .= '"heightReference": "CLAMP_TO_GROUND",'; |
| 613 | 613 | //$output .= '"heightReference": "'.$heightrelative.'",'; |
@@ -622,7 +622,7 @@ discard block |
||
| 622 | 622 | $output .= '"cartographicDegrees": ['; |
| 623 | 623 | if ($minitime > strtotime($spotter_item['date'])) $minitime = strtotime($spotter_item['date']); |
| 624 | 624 | if ($maxitime < strtotime($spotter_item['date'])) $maxitime = strtotime($spotter_item['date']); |
| 625 | - $output .= '"'.date("c",strtotime($spotter_item['date'])).'", '; |
|
| 625 | + $output .= '"'.date("c", strtotime($spotter_item['date'])).'", '; |
|
| 626 | 626 | $output .= $spotter_item['longitude'].', '; |
| 627 | 627 | $output .= $spotter_item['latitude']; |
| 628 | 628 | $prevlong = $spotter_item['longitude']; |
@@ -650,7 +650,7 @@ discard block |
||
| 650 | 650 | //$quat = quaternionrotate(deg2rad($spotter_item['heading']),deg2rad(0),deg2rad(0)); |
| 651 | 651 | //$orientation .= '"'.date("c",strtotime($spotter_item['date'])).'",'.$quat['x'].','.$quat['y'].','.$quat['z'].','.$quat['w']; |
| 652 | 652 | } else { |
| 653 | - $output .= ',"'.date("c",strtotime($spotter_item['date'])).'", '; |
|
| 653 | + $output .= ',"'.date("c", strtotime($spotter_item['date'])).'", '; |
|
| 654 | 654 | if ($maxitime < strtotime($spotter_item['date'])) $maxitime = strtotime($spotter_item['date']); |
| 655 | 655 | if ($spotter_item['ground_speed'] == 0) { |
| 656 | 656 | $output .= $prevlong.', '; |
@@ -690,15 +690,15 @@ discard block |
||
| 690 | 690 | } |
| 691 | 691 | $output .= ']'; |
| 692 | 692 | if (isset($globalArchive) && $globalArchive === TRUE) { |
| 693 | - if ((time()-$globalLiveInterval) > $minitime) { |
|
| 694 | - if (time()-$globalLiveInterval > $maxitime) { |
|
| 695 | - $output = str_replace('%minitime%',date("c",$maxitime),$output); |
|
| 693 | + if ((time() - $globalLiveInterval) > $minitime) { |
|
| 694 | + if (time() - $globalLiveInterval > $maxitime) { |
|
| 695 | + $output = str_replace('%minitime%', date("c", $maxitime), $output); |
|
| 696 | 696 | } else { |
| 697 | - $output = str_replace('%minitime%',date("c",time()-$globalLiveInterval),$output); |
|
| 697 | + $output = str_replace('%minitime%', date("c", time() - $globalLiveInterval), $output); |
|
| 698 | 698 | } |
| 699 | 699 | } |
| 700 | - else $output = str_replace('%minitime%',date("c",$minitime),$output); |
|
| 701 | -} else $output = str_replace('%minitime%',date("c",$minitime),$output); |
|
| 702 | -$output = str_replace('%maxitime%',date("c",$maxitime),$output); |
|
| 700 | + else $output = str_replace('%minitime%', date("c", $minitime), $output); |
|
| 701 | +} else $output = str_replace('%minitime%', date("c", $minitime), $output); |
|
| 702 | +$output = str_replace('%maxitime%', date("c", $maxitime), $output); |
|
| 703 | 703 | print $output; |
| 704 | 704 | ?> |
@@ -8,8 +8,12 @@ discard block |
||
| 8 | 8 | } |
| 9 | 9 | $tracker = false; |
| 10 | 10 | $marine = false; |
| 11 | -if (isset($_GET['tracker'])) $tracker = true; |
|
| 12 | -if (isset($_GET['marine'])) $marine = true; |
|
| 11 | +if (isset($_GET['tracker'])) { |
|
| 12 | + $tracker = true; |
|
| 13 | +} |
|
| 14 | +if (isset($_GET['marine'])) { |
|
| 15 | + $marine = true; |
|
| 16 | +} |
|
| 13 | 17 | if ($tracker) { |
| 14 | 18 | require_once('require/class.Tracker.php'); |
| 15 | 19 | require_once('require/class.TrackerLive.php'); |
@@ -66,23 +70,46 @@ discard block |
||
| 66 | 70 | } |
| 67 | 71 | header('Content-Type: text/javascript'); |
| 68 | 72 | |
| 69 | -if (!isset($globalJsonCompress)) $compress = true; |
|
| 70 | -else $compress = $globalJsonCompress; |
|
| 73 | +if (!isset($globalJsonCompress)) { |
|
| 74 | + $compress = true; |
|
| 75 | +} else { |
|
| 76 | + $compress = $globalJsonCompress; |
|
| 77 | +} |
|
| 71 | 78 | |
| 72 | 79 | $from_archive = false; |
| 73 | 80 | $min = false; |
| 74 | 81 | $allhistory = false; |
| 75 | 82 | $filter['source'] = array(); |
| 76 | -if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalVATSIM) && $globalVATSIM && isset($_COOKIE['filter_ShowVATSIM']) && $_COOKIE['filter_ShowVATSIM'] == 'true') $filter['source'] = array_merge($filter['source'],array('vatsimtxt')); |
|
| 77 | -if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalIVAO) && $globalIVAO && isset($_COOKIE['filter_ShowIVAO']) && $_COOKIE['filter_ShowIVAO'] == 'true') $filter['source'] = array_merge($filter['source'],array('whazzup')); |
|
| 78 | -if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalphpVMS) && $globalphpVMS && isset($_COOKIE['filter_ShowVMS']) && $_COOKIE['filter_ShowVMS'] == 'true') $filter['source'] = array_merge($filter['source'],array('phpvmacars')); |
|
| 79 | -if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalSBS1) && $globalSBS1 && isset($_COOKIE['filter_ShowSBS1']) && $_COOKIE['filter_ShowSBS1'] == 'true') $filter['source'] = array_merge($filter['source'],array('sbs','famaprs')); |
|
| 80 | -if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalAPRS) && $globalAPRS && isset($_COOKIE['filter_ShowAPRS']) && $_COOKIE['filter_ShowAPRS'] == 'true') $filter['source'] = array_merge($filter['source'],array('aprs')); |
|
| 81 | -if (isset($_COOKIE['filter_ident']) && $_COOKIE['filter_ident'] != '') $filter['ident'] = filter_var($_COOKIE['filter_ident'],FILTER_SANITIZE_STRING); |
|
| 82 | -if (isset($_COOKIE['filter_Airlines']) && $_COOKIE['filter_Airlines'] != '') $filter['airlines'] = filter_var_array(explode(',',$_COOKIE['filter_Airlines']),FILTER_SANITIZE_STRING); |
|
| 83 | -if (isset($_COOKIE['filter_Sources']) && $_COOKIE['filter_Sources'] != '') $filter['source_aprs'] = filter_var_array(explode(',',$_COOKIE['filter_Sources']),FILTER_SANITIZE_STRING); |
|
| 84 | -if (isset($_COOKIE['filter_airlinestype']) && $_COOKIE['filter_airlinestype'] != 'all') $filter['airlinestype'] = filter_var($_COOKIE['filter_airlinestype'],FILTER_SANITIZE_STRING); |
|
| 85 | -if (isset($_COOKIE['filter_alliance']) && $_COOKIE['filter_alliance'] != 'all') $filter['alliance'] = filter_var($_COOKIE['filter_alliance'],FILTER_SANITIZE_STRING); |
|
| 83 | +if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalVATSIM) && $globalVATSIM && isset($_COOKIE['filter_ShowVATSIM']) && $_COOKIE['filter_ShowVATSIM'] == 'true') { |
|
| 84 | + $filter['source'] = array_merge($filter['source'],array('vatsimtxt')); |
|
| 85 | +} |
|
| 86 | +if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalIVAO) && $globalIVAO && isset($_COOKIE['filter_ShowIVAO']) && $_COOKIE['filter_ShowIVAO'] == 'true') { |
|
| 87 | + $filter['source'] = array_merge($filter['source'],array('whazzup')); |
|
| 88 | +} |
|
| 89 | +if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalphpVMS) && $globalphpVMS && isset($_COOKIE['filter_ShowVMS']) && $_COOKIE['filter_ShowVMS'] == 'true') { |
|
| 90 | + $filter['source'] = array_merge($filter['source'],array('phpvmacars')); |
|
| 91 | +} |
|
| 92 | +if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalSBS1) && $globalSBS1 && isset($_COOKIE['filter_ShowSBS1']) && $_COOKIE['filter_ShowSBS1'] == 'true') { |
|
| 93 | + $filter['source'] = array_merge($filter['source'],array('sbs','famaprs')); |
|
| 94 | +} |
|
| 95 | +if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalAPRS) && $globalAPRS && isset($_COOKIE['filter_ShowAPRS']) && $_COOKIE['filter_ShowAPRS'] == 'true') { |
|
| 96 | + $filter['source'] = array_merge($filter['source'],array('aprs')); |
|
| 97 | +} |
|
| 98 | +if (isset($_COOKIE['filter_ident']) && $_COOKIE['filter_ident'] != '') { |
|
| 99 | + $filter['ident'] = filter_var($_COOKIE['filter_ident'],FILTER_SANITIZE_STRING); |
|
| 100 | +} |
|
| 101 | +if (isset($_COOKIE['filter_Airlines']) && $_COOKIE['filter_Airlines'] != '') { |
|
| 102 | + $filter['airlines'] = filter_var_array(explode(',',$_COOKIE['filter_Airlines']),FILTER_SANITIZE_STRING); |
|
| 103 | +} |
|
| 104 | +if (isset($_COOKIE['filter_Sources']) && $_COOKIE['filter_Sources'] != '') { |
|
| 105 | + $filter['source_aprs'] = filter_var_array(explode(',',$_COOKIE['filter_Sources']),FILTER_SANITIZE_STRING); |
|
| 106 | +} |
|
| 107 | +if (isset($_COOKIE['filter_airlinestype']) && $_COOKIE['filter_airlinestype'] != 'all') { |
|
| 108 | + $filter['airlinestype'] = filter_var($_COOKIE['filter_airlinestype'],FILTER_SANITIZE_STRING); |
|
| 109 | +} |
|
| 110 | +if (isset($_COOKIE['filter_alliance']) && $_COOKIE['filter_alliance'] != 'all') { |
|
| 111 | + $filter['alliance'] = filter_var($_COOKIE['filter_alliance'],FILTER_SANITIZE_STRING); |
|
| 112 | +} |
|
| 86 | 113 | /* |
| 87 | 114 | if (isset($globalMapPopup) && !$globalMapPopup && !(isset($_COOKIE['flightpopup']) && $_COOKIE['flightpopup'] == 'true')) { |
| 88 | 115 | $min = true; |
@@ -179,8 +206,12 @@ discard block |
||
| 179 | 206 | } else { |
| 180 | 207 | $flightcnt = $SpotterLive->getLiveSpotterCount($filter); |
| 181 | 208 | } |
| 182 | - if ($flightcnt == '') $flightcnt = 0; |
|
| 183 | -} else $flightcnt = 0; |
|
| 209 | + if ($flightcnt == '') { |
|
| 210 | + $flightcnt = 0; |
|
| 211 | + } |
|
| 212 | + } else { |
|
| 213 | + $flightcnt = 0; |
|
| 214 | +} |
|
| 184 | 215 | |
| 185 | 216 | $sqltime = round(microtime(true)-$begintime,2); |
| 186 | 217 | $minitime = time(); |
@@ -203,7 +234,9 @@ discard block |
||
| 203 | 234 | $j = 0; |
| 204 | 235 | $prev_flightaware_id = ''; |
| 205 | 236 | $speed = 1; |
| 206 | -if (isset($archivespeed)) $speed = $archivespeed; |
|
| 237 | +if (isset($archivespeed)) { |
|
| 238 | + $speed = $archivespeed; |
|
| 239 | +} |
|
| 207 | 240 | $output = '['; |
| 208 | 241 | if ($tracker) { |
| 209 | 242 | $output .= '{"id" : "document", "name" : "tracker","version" : "1.0"'; |
@@ -238,9 +271,13 @@ discard block |
||
| 238 | 271 | $image = "images/placeholder_thumb.png"; |
| 239 | 272 | } |
| 240 | 273 | |
| 241 | - if (isset($spotter_item['flightaware_id'])) $id = $spotter_item['flightaware_id']; |
|
| 242 | - elseif (isset($spotter_item['famtrackid'])) $id = $spotter_item['famtrackid']; |
|
| 243 | - elseif (isset($spotter_item['fammarine_id'])) $id = $spotter_item['fammarine_id']; |
|
| 274 | + if (isset($spotter_item['flightaware_id'])) { |
|
| 275 | + $id = $spotter_item['flightaware_id']; |
|
| 276 | + } elseif (isset($spotter_item['famtrackid'])) { |
|
| 277 | + $id = $spotter_item['famtrackid']; |
|
| 278 | + } elseif (isset($spotter_item['fammarine_id'])) { |
|
| 279 | + $id = $spotter_item['fammarine_id']; |
|
| 280 | + } |
|
| 244 | 281 | if ($prev_flightaware_id != $id) { |
| 245 | 282 | if ($prev_flightaware_id != '') { |
| 246 | 283 | $output .= ']'; |
@@ -291,7 +328,9 @@ discard block |
||
| 291 | 328 | $spotter_item['engine_type'] = $aircraft_info[0]['engine_type']; |
| 292 | 329 | $spotter_item['wake_category'] = $aircraft_info[0]['wake_category']; |
| 293 | 330 | $spotter_item['engine_count'] = $aircraft_info[0]['engine_count']; |
| 294 | - } else $aircraft_shadow = ''; |
|
| 331 | + } else { |
|
| 332 | + $aircraft_shadow = ''; |
|
| 333 | + } |
|
| 295 | 334 | $output .= ' "billboard" : {"image" : "'.$globalURL.'/images/aircrafts/new/'.$aircraft_shadow.'","scale" : 0.5'; |
| 296 | 335 | if (isset($_COOKIE['IconColorForce']) && $_COOKIE['IconColorForce'] && isset($_COOKIE['IconColor'])) { |
| 297 | 336 | $rgb = $Common->hex2rgb($_COOKIE['IconColor']); |
@@ -299,7 +338,9 @@ discard block |
||
| 299 | 338 | } |
| 300 | 339 | $output .= '},'; |
| 301 | 340 | } |
| 302 | - } else $output .= ' "billboard" : {"image" : "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACgAAAAfCAYAAACVgY94AAAACXBIWXMAAC4jAAAuIwF4pT92AAAKT2lDQ1BQaG90b3Nob3AgSUNDIHByb2ZpbGUAAHjanVNnVFPpFj333vRCS4iAlEtvUhUIIFJCi4AUkSYqIQkQSoghodkVUcERRUUEG8igiAOOjoCMFVEsDIoK2AfkIaKOg6OIisr74Xuja9a89+bN/rXXPues852zzwfACAyWSDNRNYAMqUIeEeCDx8TG4eQuQIEKJHAAEAizZCFz/SMBAPh+PDwrIsAHvgABeNMLCADATZvAMByH/w/qQplcAYCEAcB0kThLCIAUAEB6jkKmAEBGAYCdmCZTAKAEAGDLY2LjAFAtAGAnf+bTAICd+Jl7AQBblCEVAaCRACATZYhEAGg7AKzPVopFAFgwABRmS8Q5ANgtADBJV2ZIALC3AMDOEAuyAAgMADBRiIUpAAR7AGDIIyN4AISZABRG8lc88SuuEOcqAAB4mbI8uSQ5RYFbCC1xB1dXLh4ozkkXKxQ2YQJhmkAuwnmZGTKBNA/g88wAAKCRFRHgg/P9eM4Ors7ONo62Dl8t6r8G/yJiYuP+5c+rcEAAAOF0ftH+LC+zGoA7BoBt/qIl7gRoXgugdfeLZrIPQLUAoOnaV/Nw+H48PEWhkLnZ2eXk5NhKxEJbYcpXff5nwl/AV/1s+X48/Pf14L7iJIEyXYFHBPjgwsz0TKUcz5IJhGLc5o9H/LcL//wd0yLESWK5WCoU41EScY5EmozzMqUiiUKSKcUl0v9k4t8s+wM+3zUAsGo+AXuRLahdYwP2SycQWHTA4vcAAPK7b8HUKAgDgGiD4c93/+8//UegJQCAZkmScQAAXkQkLlTKsz/HCAAARKCBKrBBG/TBGCzABhzBBdzBC/xgNoRCJMTCQhBCCmSAHHJgKayCQiiGzbAdKmAv1EAdNMBRaIaTcA4uwlW4Dj1wD/phCJ7BKLyBCQRByAgTYSHaiAFiilgjjggXmYX4IcFIBBKLJCDJiBRRIkuRNUgxUopUIFVIHfI9cgI5h1xGupE7yAAygvyGvEcxlIGyUT3UDLVDuag3GoRGogvQZHQxmo8WoJvQcrQaPYw2oefQq2gP2o8+Q8cwwOgYBzPEbDAuxsNCsTgsCZNjy7EirAyrxhqwVqwDu4n1Y8+xdwQSgUXACTYEd0IgYR5BSFhMWE7YSKggHCQ0EdoJNwkDhFHCJyKTqEu0JroR+cQYYjIxh1hILCPWEo8TLxB7iEPENyQSiUMyJ7mQAkmxpFTSEtJG0m5SI+ksqZs0SBojk8naZGuyBzmULCAryIXkneTD5DPkG+Qh8lsKnWJAcaT4U+IoUspqShnlEOU05QZlmDJBVaOaUt2ooVQRNY9aQq2htlKvUYeoEzR1mjnNgxZJS6WtopXTGmgXaPdpr+h0uhHdlR5Ol9BX0svpR+iX6AP0dwwNhhWDx4hnKBmbGAcYZxl3GK+YTKYZ04sZx1QwNzHrmOeZD5lvVVgqtip8FZHKCpVKlSaVGyovVKmqpqreqgtV81XLVI+pXlN9rkZVM1PjqQnUlqtVqp1Q61MbU2epO6iHqmeob1Q/pH5Z/YkGWcNMw09DpFGgsV/jvMYgC2MZs3gsIWsNq4Z1gTXEJrHN2Xx2KruY/R27iz2qqaE5QzNKM1ezUvOUZj8H45hx+Jx0TgnnKKeX836K3hTvKeIpG6Y0TLkxZVxrqpaXllirSKtRq0frvTau7aedpr1Fu1n7gQ5Bx0onXCdHZ4/OBZ3nU9lT3acKpxZNPTr1ri6qa6UbobtEd79up+6Ynr5egJ5Mb6feeb3n+hx9L/1U/W36p/VHDFgGswwkBtsMzhg8xTVxbzwdL8fb8VFDXcNAQ6VhlWGX4YSRudE8o9VGjUYPjGnGXOMk423GbcajJgYmISZLTepN7ppSTbmmKaY7TDtMx83MzaLN1pk1mz0x1zLnm+eb15vft2BaeFostqi2uGVJsuRaplnutrxuhVo5WaVYVVpds0atna0l1rutu6cRp7lOk06rntZnw7Dxtsm2qbcZsOXYBtuutm22fWFnYhdnt8Wuw+6TvZN9un2N/T0HDYfZDqsdWh1+c7RyFDpWOt6azpzuP33F9JbpL2dYzxDP2DPjthPLKcRpnVOb00dnF2e5c4PziIuJS4LLLpc+Lpsbxt3IveRKdPVxXeF60vWdm7Obwu2o26/uNu5p7ofcn8w0nymeWTNz0MPIQ+BR5dE/C5+VMGvfrH5PQ0+BZ7XnIy9jL5FXrdewt6V3qvdh7xc+9j5yn+M+4zw33jLeWV/MN8C3yLfLT8Nvnl+F30N/I/9k/3r/0QCngCUBZwOJgUGBWwL7+Hp8Ib+OPzrbZfay2e1BjKC5QRVBj4KtguXBrSFoyOyQrSH355jOkc5pDoVQfujW0Adh5mGLw34MJ4WHhVeGP45wiFga0TGXNXfR3ENz30T6RJZE3ptnMU85ry1KNSo+qi5qPNo3ujS6P8YuZlnM1VidWElsSxw5LiquNm5svt/87fOH4p3iC+N7F5gvyF1weaHOwvSFpxapLhIsOpZATIhOOJTwQRAqqBaMJfITdyWOCnnCHcJnIi/RNtGI2ENcKh5O8kgqTXqS7JG8NXkkxTOlLOW5hCepkLxMDUzdmzqeFpp2IG0yPTq9MYOSkZBxQqohTZO2Z+pn5mZ2y6xlhbL+xW6Lty8elQfJa7OQrAVZLQq2QqboVFoo1yoHsmdlV2a/zYnKOZarnivN7cyzytuQN5zvn//tEsIS4ZK2pYZLVy0dWOa9rGo5sjxxedsK4xUFK4ZWBqw8uIq2Km3VT6vtV5eufr0mek1rgV7ByoLBtQFr6wtVCuWFfevc1+1dT1gvWd+1YfqGnRs+FYmKrhTbF5cVf9go3HjlG4dvyr+Z3JS0qavEuWTPZtJm6ebeLZ5bDpaql+aXDm4N2dq0Dd9WtO319kXbL5fNKNu7g7ZDuaO/PLi8ZafJzs07P1SkVPRU+lQ27tLdtWHX+G7R7ht7vPY07NXbW7z3/T7JvttVAVVN1WbVZftJ+7P3P66Jqun4lvttXa1ObXHtxwPSA/0HIw6217nU1R3SPVRSj9Yr60cOxx++/p3vdy0NNg1VjZzG4iNwRHnk6fcJ3/ceDTradox7rOEH0x92HWcdL2pCmvKaRptTmvtbYlu6T8w+0dbq3nr8R9sfD5w0PFl5SvNUyWna6YLTk2fyz4ydlZ19fi753GDborZ752PO32oPb++6EHTh0kX/i+c7vDvOXPK4dPKy2+UTV7hXmq86X23qdOo8/pPTT8e7nLuarrlca7nuer21e2b36RueN87d9L158Rb/1tWeOT3dvfN6b/fF9/XfFt1+cif9zsu72Xcn7q28T7xf9EDtQdlD3YfVP1v+3Njv3H9qwHeg89HcR/cGhYPP/pH1jw9DBY+Zj8uGDYbrnjg+OTniP3L96fynQ89kzyaeF/6i/suuFxYvfvjV69fO0ZjRoZfyl5O/bXyl/erA6xmv28bCxh6+yXgzMV70VvvtwXfcdx3vo98PT+R8IH8o/2j5sfVT0Kf7kxmTk/8EA5jz/GMzLdsAAAAgY0hSTQAAeiUAAICDAAD5/wAAgOkAAHUwAADqYAAAOpgAABdvkl/FRgAAA7VJREFUeNrEl2uIlWUQx39nXUu0m2uQbZYrbabdLKMs/VBkmHQjioqFIhBS+hKEQpQRgVAf2u5RQkGBRUllRH4I2e5ZUBJlEZVt5i0tTfHStrZ6fn35L70d9n7Obg88vOedmWfmf2bmmZkXlRrtq9V16mZ1iVqqhd5agXvQf1c5zw/V8dXqrqO6dQKwBrgdWApsCb0VqAc2AnOrMVANwIsD4BLgTOBPYB2wHJgEzAG+ANqAu4ZsZYiuX5QwfqI2hvaNulA9J7zLQn8o76vUuuHOwXHqSzH4aIF+TWjnBkSH+nCBf716SP1KPWO4AJ6ltgfIjRW8p9U/1KPz/ry6RT2mIDNF3Zjz19Ya4G1R/J16dgWvQd2pPlXhMdVZPUTgxfCW1wJgXUJpQlvfg8zs8K8r0Caom9QHetG7NGfa1ElDBThRXRtFd/Qh16puKIS3e7+clBjdy7kL1b3q4fzJQQGck5z6Nb97kxujblWf64HXov7Vl/E4YXWccP9AAd6dAx+ox/WTArNzY1t64B0f8K0DyLXuUvRGZfcpCo1VX4tg6wB76WMB0dALf526foAX8cqUot2pGP8B2Kz+krBeNYjS8636dh/8Beo2deoA9TWp76pd6g0q9cDNwKvAD8A84EfglLRBe2g+JWAfcEF68bPABOCoAl/gIPA5MA64FVgGnNhP292W3r0SeB1YVlJXAjcBP8XwyQUj9AKwAzg2+/fQSsBhoJxBAaALaIzenZGnD911wA7gEDAD2FFSpwOzgDHZ5T7+ZSlGd2d6AXgi5+qAn+O5U0PbBVwKtAD3AHuB8f3YGBUdncCGoQ4LE9XtGRqK9LnduVPRIu2BPqwD65IYbS7Qpql7Ql9YoJcy9bwzkgPrfOCj5G33+h54E/g0PAr5thq4ApgyEgNrc27aWwVaPTA1QJ4BjgTGFvhteV40EgPrgvTP7qlmZqFnl9WD+b2posN83E/NrEkOjlI/U1fkfUYa/pe5IE3qZPW8jFOqiyN7p3pAPX04c7AxYSoDDcAjKT2LgLXA6IR2M3Bviv59wDTgQGTPH84Qd8+HXfHcoUws2zM0HMjuUPep+xP2PWpnwtw0GJsldbBpewQwE/gbeDyt7H1gcW53O7AC+A3Yn6+/W+Ld9SnWA15DAVhc8xK2TuA9YHrCuhV4EngFuBx4YagG6qv8cF+T52kB2Zy+e1I8taUacNV+uBdXO7ABmJwJpwx8XQvF9TUCWM64tiQhbq/oMv+7BwFWpQzNT8vbVQul/wwAGzzdmXU1xuUAAAAASUVORK5CYII=","scale" : 0.5},'; |
|
| 341 | + } else { |
|
| 342 | + $output .= ' "billboard" : {"image" : "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACgAAAAfCAYAAACVgY94AAAACXBIWXMAAC4jAAAuIwF4pT92AAAKT2lDQ1BQaG90b3Nob3AgSUNDIHByb2ZpbGUAAHjanVNnVFPpFj333vRCS4iAlEtvUhUIIFJCi4AUkSYqIQkQSoghodkVUcERRUUEG8igiAOOjoCMFVEsDIoK2AfkIaKOg6OIisr74Xuja9a89+bN/rXXPues852zzwfACAyWSDNRNYAMqUIeEeCDx8TG4eQuQIEKJHAAEAizZCFz/SMBAPh+PDwrIsAHvgABeNMLCADATZvAMByH/w/qQplcAYCEAcB0kThLCIAUAEB6jkKmAEBGAYCdmCZTAKAEAGDLY2LjAFAtAGAnf+bTAICd+Jl7AQBblCEVAaCRACATZYhEAGg7AKzPVopFAFgwABRmS8Q5ANgtADBJV2ZIALC3AMDOEAuyAAgMADBRiIUpAAR7AGDIIyN4AISZABRG8lc88SuuEOcqAAB4mbI8uSQ5RYFbCC1xB1dXLh4ozkkXKxQ2YQJhmkAuwnmZGTKBNA/g88wAAKCRFRHgg/P9eM4Ors7ONo62Dl8t6r8G/yJiYuP+5c+rcEAAAOF0ftH+LC+zGoA7BoBt/qIl7gRoXgugdfeLZrIPQLUAoOnaV/Nw+H48PEWhkLnZ2eXk5NhKxEJbYcpXff5nwl/AV/1s+X48/Pf14L7iJIEyXYFHBPjgwsz0TKUcz5IJhGLc5o9H/LcL//wd0yLESWK5WCoU41EScY5EmozzMqUiiUKSKcUl0v9k4t8s+wM+3zUAsGo+AXuRLahdYwP2SycQWHTA4vcAAPK7b8HUKAgDgGiD4c93/+8//UegJQCAZkmScQAAXkQkLlTKsz/HCAAARKCBKrBBG/TBGCzABhzBBdzBC/xgNoRCJMTCQhBCCmSAHHJgKayCQiiGzbAdKmAv1EAdNMBRaIaTcA4uwlW4Dj1wD/phCJ7BKLyBCQRByAgTYSHaiAFiilgjjggXmYX4IcFIBBKLJCDJiBRRIkuRNUgxUopUIFVIHfI9cgI5h1xGupE7yAAygvyGvEcxlIGyUT3UDLVDuag3GoRGogvQZHQxmo8WoJvQcrQaPYw2oefQq2gP2o8+Q8cwwOgYBzPEbDAuxsNCsTgsCZNjy7EirAyrxhqwVqwDu4n1Y8+xdwQSgUXACTYEd0IgYR5BSFhMWE7YSKggHCQ0EdoJNwkDhFHCJyKTqEu0JroR+cQYYjIxh1hILCPWEo8TLxB7iEPENyQSiUMyJ7mQAkmxpFTSEtJG0m5SI+ksqZs0SBojk8naZGuyBzmULCAryIXkneTD5DPkG+Qh8lsKnWJAcaT4U+IoUspqShnlEOU05QZlmDJBVaOaUt2ooVQRNY9aQq2htlKvUYeoEzR1mjnNgxZJS6WtopXTGmgXaPdpr+h0uhHdlR5Ol9BX0svpR+iX6AP0dwwNhhWDx4hnKBmbGAcYZxl3GK+YTKYZ04sZx1QwNzHrmOeZD5lvVVgqtip8FZHKCpVKlSaVGyovVKmqpqreqgtV81XLVI+pXlN9rkZVM1PjqQnUlqtVqp1Q61MbU2epO6iHqmeob1Q/pH5Z/YkGWcNMw09DpFGgsV/jvMYgC2MZs3gsIWsNq4Z1gTXEJrHN2Xx2KruY/R27iz2qqaE5QzNKM1ezUvOUZj8H45hx+Jx0TgnnKKeX836K3hTvKeIpG6Y0TLkxZVxrqpaXllirSKtRq0frvTau7aedpr1Fu1n7gQ5Bx0onXCdHZ4/OBZ3nU9lT3acKpxZNPTr1ri6qa6UbobtEd79up+6Ynr5egJ5Mb6feeb3n+hx9L/1U/W36p/VHDFgGswwkBtsMzhg8xTVxbzwdL8fb8VFDXcNAQ6VhlWGX4YSRudE8o9VGjUYPjGnGXOMk423GbcajJgYmISZLTepN7ppSTbmmKaY7TDtMx83MzaLN1pk1mz0x1zLnm+eb15vft2BaeFostqi2uGVJsuRaplnutrxuhVo5WaVYVVpds0atna0l1rutu6cRp7lOk06rntZnw7Dxtsm2qbcZsOXYBtuutm22fWFnYhdnt8Wuw+6TvZN9un2N/T0HDYfZDqsdWh1+c7RyFDpWOt6azpzuP33F9JbpL2dYzxDP2DPjthPLKcRpnVOb00dnF2e5c4PziIuJS4LLLpc+Lpsbxt3IveRKdPVxXeF60vWdm7Obwu2o26/uNu5p7ofcn8w0nymeWTNz0MPIQ+BR5dE/C5+VMGvfrH5PQ0+BZ7XnIy9jL5FXrdewt6V3qvdh7xc+9j5yn+M+4zw33jLeWV/MN8C3yLfLT8Nvnl+F30N/I/9k/3r/0QCngCUBZwOJgUGBWwL7+Hp8Ib+OPzrbZfay2e1BjKC5QRVBj4KtguXBrSFoyOyQrSH355jOkc5pDoVQfujW0Adh5mGLw34MJ4WHhVeGP45wiFga0TGXNXfR3ENz30T6RJZE3ptnMU85ry1KNSo+qi5qPNo3ujS6P8YuZlnM1VidWElsSxw5LiquNm5svt/87fOH4p3iC+N7F5gvyF1weaHOwvSFpxapLhIsOpZATIhOOJTwQRAqqBaMJfITdyWOCnnCHcJnIi/RNtGI2ENcKh5O8kgqTXqS7JG8NXkkxTOlLOW5hCepkLxMDUzdmzqeFpp2IG0yPTq9MYOSkZBxQqohTZO2Z+pn5mZ2y6xlhbL+xW6Lty8elQfJa7OQrAVZLQq2QqboVFoo1yoHsmdlV2a/zYnKOZarnivN7cyzytuQN5zvn//tEsIS4ZK2pYZLVy0dWOa9rGo5sjxxedsK4xUFK4ZWBqw8uIq2Km3VT6vtV5eufr0mek1rgV7ByoLBtQFr6wtVCuWFfevc1+1dT1gvWd+1YfqGnRs+FYmKrhTbF5cVf9go3HjlG4dvyr+Z3JS0qavEuWTPZtJm6ebeLZ5bDpaql+aXDm4N2dq0Dd9WtO319kXbL5fNKNu7g7ZDuaO/PLi8ZafJzs07P1SkVPRU+lQ27tLdtWHX+G7R7ht7vPY07NXbW7z3/T7JvttVAVVN1WbVZftJ+7P3P66Jqun4lvttXa1ObXHtxwPSA/0HIw6217nU1R3SPVRSj9Yr60cOxx++/p3vdy0NNg1VjZzG4iNwRHnk6fcJ3/ceDTradox7rOEH0x92HWcdL2pCmvKaRptTmvtbYlu6T8w+0dbq3nr8R9sfD5w0PFl5SvNUyWna6YLTk2fyz4ydlZ19fi753GDborZ752PO32oPb++6EHTh0kX/i+c7vDvOXPK4dPKy2+UTV7hXmq86X23qdOo8/pPTT8e7nLuarrlca7nuer21e2b36RueN87d9L158Rb/1tWeOT3dvfN6b/fF9/XfFt1+cif9zsu72Xcn7q28T7xf9EDtQdlD3YfVP1v+3Njv3H9qwHeg89HcR/cGhYPP/pH1jw9DBY+Zj8uGDYbrnjg+OTniP3L96fynQ89kzyaeF/6i/suuFxYvfvjV69fO0ZjRoZfyl5O/bXyl/erA6xmv28bCxh6+yXgzMV70VvvtwXfcdx3vo98PT+R8IH8o/2j5sfVT0Kf7kxmTk/8EA5jz/GMzLdsAAAAgY0hSTQAAeiUAAICDAAD5/wAAgOkAAHUwAADqYAAAOpgAABdvkl/FRgAAA7VJREFUeNrEl2uIlWUQx39nXUu0m2uQbZYrbabdLKMs/VBkmHQjioqFIhBS+hKEQpQRgVAf2u5RQkGBRUllRH4I2e5ZUBJlEZVt5i0tTfHStrZ6fn35L70d9n7Obg88vOedmWfmf2bmmZkXlRrtq9V16mZ1iVqqhd5agXvQf1c5zw/V8dXqrqO6dQKwBrgdWApsCb0VqAc2AnOrMVANwIsD4BLgTOBPYB2wHJgEzAG+ANqAu4ZsZYiuX5QwfqI2hvaNulA9J7zLQn8o76vUuuHOwXHqSzH4aIF+TWjnBkSH+nCBf716SP1KPWO4AJ6ltgfIjRW8p9U/1KPz/ry6RT2mIDNF3Zjz19Ya4G1R/J16dgWvQd2pPlXhMdVZPUTgxfCW1wJgXUJpQlvfg8zs8K8r0Caom9QHetG7NGfa1ElDBThRXRtFd/Qh16puKIS3e7+clBjdy7kL1b3q4fzJQQGck5z6Nb97kxujblWf64HXov7Vl/E4YXWccP9AAd6dAx+ox/WTArNzY1t64B0f8K0DyLXuUvRGZfcpCo1VX4tg6wB76WMB0dALf526foAX8cqUot2pGP8B2Kz+krBeNYjS8636dh/8Beo2deoA9TWp76pd6g0q9cDNwKvAD8A84EfglLRBe2g+JWAfcEF68bPABOCoAl/gIPA5MA64FVgGnNhP292W3r0SeB1YVlJXAjcBP8XwyQUj9AKwAzg2+/fQSsBhoJxBAaALaIzenZGnD911wA7gEDAD2FFSpwOzgDHZ5T7+ZSlGd2d6AXgi5+qAn+O5U0PbBVwKtAD3AHuB8f3YGBUdncCGoQ4LE9XtGRqK9LnduVPRIu2BPqwD65IYbS7Qpql7Ql9YoJcy9bwzkgPrfOCj5G33+h54E/g0PAr5thq4ApgyEgNrc27aWwVaPTA1QJ4BjgTGFvhteV40EgPrgvTP7qlmZqFnl9WD+b2posN83E/NrEkOjlI/U1fkfUYa/pe5IE3qZPW8jFOqiyN7p3pAPX04c7AxYSoDDcAjKT2LgLXA6IR2M3Bviv59wDTgQGTPH84Qd8+HXfHcoUws2zM0HMjuUPep+xP2PWpnwtw0GJsldbBpewQwE/gbeDyt7H1gcW53O7AC+A3Yn6+/W+Ld9SnWA15DAVhc8xK2TuA9YHrCuhV4EngFuBx4YagG6qv8cF+T52kB2Zy+e1I8taUacNV+uBdXO7ABmJwJpwx8XQvF9TUCWM64tiQhbq/oMv+7BwFWpQzNT8vbVQul/wwAGzzdmXU1xuUAAAAASUVORK5CYII=","scale" : 0.5},'; |
|
| 343 | + } |
|
| 303 | 344 | } elseif ($one3dmodel) { |
| 304 | 345 | if (isset($globalMap3DForceModel) && $globalMap3DForceModel != '') { |
| 305 | 346 | $output .= '"model": {"gltf" : "'.$globalURL.'/models/'.$globalMap3DForceModel.'","scale" : 1.0,"minimumPixelSize": 20'; |
@@ -330,7 +371,9 @@ discard block |
||
| 330 | 371 | $spotter_item['engine_type'] = $aircraft_info[0]['engine_type']; |
| 331 | 372 | $spotter_item['wake_category'] = $aircraft_info[0]['wake_category']; |
| 332 | 373 | $spotter_item['engine_count'] = $aircraft_info[0]['engine_count']; |
| 333 | - } else $aircraft_shadow = ''; |
|
| 374 | + } else { |
|
| 375 | + $aircraft_shadow = ''; |
|
| 376 | + } |
|
| 334 | 377 | if ($aircraft_shadow != '') { |
| 335 | 378 | if (isset($modelsdb[$aircraft_shadow])) { |
| 336 | 379 | $output .= '"model": {"gltf" : "'.$globalURL.'/models/'.$modelsdb[$aircraft_shadow].'","scale" : 1.0,"minimumPixelSize": 20'; |
@@ -467,7 +510,9 @@ discard block |
||
| 467 | 510 | } |
| 468 | 511 | $output .= '},'; |
| 469 | 512 | //if ($spotter_item['aircraft_shadow'] != '') $output .= '"aircraft_shadow": "'.$spotter_item['aircraft_shadow'].'",'; |
| 470 | - if ($spotter_item['aircraft_icao'] != '') $output .= '"aircraft_icao": "'.$spotter_item['aircraft_icao'].'",'; |
|
| 513 | + if ($spotter_item['aircraft_icao'] != '') { |
|
| 514 | + $output .= '"aircraft_icao": "'.$spotter_item['aircraft_icao'].'",'; |
|
| 515 | + } |
|
| 471 | 516 | $modelsdb[$aircraft_icao] = 'Cesium_Air.glb'; |
| 472 | 517 | } |
| 473 | 518 | } elseif (isset($spotter_item['format_source']) && $spotter_item['format_source'] == 'aprs') { |
@@ -489,7 +534,9 @@ discard block |
||
| 489 | 534 | } |
| 490 | 535 | $output .= '},'; |
| 491 | 536 | //if ($spotter_item['aircraft_shadow'] != '') $output .= '"aircraft_shadow": "'.$spotter_item['aircraft_shadow'].'",'; |
| 492 | - if ($spotter_item['aircraft_icao'] != '') $output .= '"aircraft_icao": "'.$spotter_item['aircraft_icao'].'",'; |
|
| 537 | + if ($spotter_item['aircraft_icao'] != '') { |
|
| 538 | + $output .= '"aircraft_icao": "'.$spotter_item['aircraft_icao'].'",'; |
|
| 539 | + } |
|
| 493 | 540 | $modelsdb[$aircraft_icao] = 'Cesium_Air.glb'; |
| 494 | 541 | } |
| 495 | 542 | } else { |
@@ -502,7 +549,9 @@ discard block |
||
| 502 | 549 | } |
| 503 | 550 | $output .= '},'; |
| 504 | 551 | //if ($spotter_item['aircraft_shadow'] != '') $output .= '"aircraft_shadow": "'.$spotter_item['aircraft_shadow'].'",'; |
| 505 | - if ($spotter_item['aircraft_icao'] != '') $output .= '"aircraft_icao": "'.$spotter_item['aircraft_icao'].'",'; |
|
| 552 | + if ($spotter_item['aircraft_icao'] != '') { |
|
| 553 | + $output .= '"aircraft_icao": "'.$spotter_item['aircraft_icao'].'",'; |
|
| 554 | + } |
|
| 506 | 555 | $modelsdb[$aircraft_icao] = 'Cesium_Air.glb'; |
| 507 | 556 | } |
| 508 | 557 | } elseif ($tracker && isset($spotter_item['type'])) { |
@@ -606,8 +655,11 @@ discard block |
||
| 606 | 655 | $output .= '},'; |
| 607 | 656 | } |
| 608 | 657 | } |
| 609 | - if (isset($onground) && $onground) $output = str_replace('%onground%','true',$output); |
|
| 610 | - else $output = str_replace('%onground%','false',$output); |
|
| 658 | + if (isset($onground) && $onground) { |
|
| 659 | + $output = str_replace('%onground%','true',$output); |
|
| 660 | + } else { |
|
| 661 | + $output = str_replace('%onground%','false',$output); |
|
| 662 | + } |
|
| 611 | 663 | |
| 612 | 664 | // $output .= '"heightReference": "CLAMP_TO_GROUND",'; |
| 613 | 665 | //$output .= '"heightReference": "'.$heightrelative.'",'; |
@@ -620,8 +672,12 @@ discard block |
||
| 620 | 672 | // $output .= '"interpolationDegree" : 5,'; |
| 621 | 673 | // $output .= '"epoch" : "'.date("c",strtotime($spotter_item['date'])).'", '; |
| 622 | 674 | $output .= '"cartographicDegrees": ['; |
| 623 | - if ($minitime > strtotime($spotter_item['date'])) $minitime = strtotime($spotter_item['date']); |
|
| 624 | - if ($maxitime < strtotime($spotter_item['date'])) $maxitime = strtotime($spotter_item['date']); |
|
| 675 | + if ($minitime > strtotime($spotter_item['date'])) { |
|
| 676 | + $minitime = strtotime($spotter_item['date']); |
|
| 677 | + } |
|
| 678 | + if ($maxitime < strtotime($spotter_item['date'])) { |
|
| 679 | + $maxitime = strtotime($spotter_item['date']); |
|
| 680 | + } |
|
| 625 | 681 | $output .= '"'.date("c",strtotime($spotter_item['date'])).'", '; |
| 626 | 682 | $output .= $spotter_item['longitude'].', '; |
| 627 | 683 | $output .= $spotter_item['latitude']; |
@@ -644,20 +700,27 @@ discard block |
||
| 644 | 700 | $output .= ', '.round($spotter_item['altitude']*30.48); |
| 645 | 701 | $prevalt = round($spotter_item['altitude']*30.48); |
| 646 | 702 | } |
| 647 | - } else $output .= ', 0'; |
|
| 703 | + } else { |
|
| 704 | + $output .= ', 0'; |
|
| 705 | + } |
|
| 648 | 706 | //$orientation = '"orientation" : { '; |
| 649 | 707 | //$orientation .= '"unitQuaternion": ['; |
| 650 | 708 | //$quat = quaternionrotate(deg2rad($spotter_item['heading']),deg2rad(0),deg2rad(0)); |
| 651 | 709 | //$orientation .= '"'.date("c",strtotime($spotter_item['date'])).'",'.$quat['x'].','.$quat['y'].','.$quat['z'].','.$quat['w']; |
| 652 | 710 | } else { |
| 653 | 711 | $output .= ',"'.date("c",strtotime($spotter_item['date'])).'", '; |
| 654 | - if ($maxitime < strtotime($spotter_item['date'])) $maxitime = strtotime($spotter_item['date']); |
|
| 712 | + if ($maxitime < strtotime($spotter_item['date'])) { |
|
| 713 | + $maxitime = strtotime($spotter_item['date']); |
|
| 714 | + } |
|
| 655 | 715 | if ($spotter_item['ground_speed'] == 0) { |
| 656 | 716 | $output .= $prevlong.', '; |
| 657 | 717 | $output .= $prevlat; |
| 658 | 718 | //if (!$marine && (!isset($onground) || !$onground)) $output .= ', '.$prevalt; |
| 659 | - if (!$marine) $output .= ', '.$prevalt; |
|
| 660 | - else $output .= ', 0'; |
|
| 719 | + if (!$marine) { |
|
| 720 | + $output .= ', '.$prevalt; |
|
| 721 | + } else { |
|
| 722 | + $output .= ', 0'; |
|
| 723 | + } |
|
| 661 | 724 | } else { |
| 662 | 725 | $output .= $spotter_item['longitude'].', '; |
| 663 | 726 | $output .= $spotter_item['latitude']; |
@@ -670,14 +733,17 @@ discard block |
||
| 670 | 733 | $output .= ', 0'; |
| 671 | 734 | } |
| 672 | 735 | } else { |
| 673 | - if (isset($spotter_item['real_altitude']) && $spotter_item['real_altitude'] != '') $output .= ', '.round($spotter_item['real_altitude']*0.3048); |
|
| 674 | - elseif ($tracker) { |
|
| 736 | + if (isset($spotter_item['real_altitude']) && $spotter_item['real_altitude'] != '') { |
|
| 737 | + $output .= ', '.round($spotter_item['real_altitude']*0.3048); |
|
| 738 | + } elseif ($tracker) { |
|
| 675 | 739 | $output .= ', '.round($spotter_item['altitude']*0.3048); |
| 676 | 740 | } else { |
| 677 | 741 | $output .= ', '.round($spotter_item['altitude']*30.48); |
| 678 | 742 | } |
| 679 | 743 | } |
| 680 | - } else $output .= ', 0'; |
|
| 744 | + } else { |
|
| 745 | + $output .= ', 0'; |
|
| 746 | + } |
|
| 681 | 747 | } |
| 682 | 748 | //$quat = quaternionrotate(deg2rad($spotter_item['heading']),deg2rad(0),deg2rad(0)); |
| 683 | 749 | //$orientation .= ',"'.date("c",strtotime($spotter_item['date'])).'",'.$quat['x'].','.$quat['y'].','.$quat['z'].','.$quat['w']; |
@@ -696,9 +762,12 @@ discard block |
||
| 696 | 762 | } else { |
| 697 | 763 | $output = str_replace('%minitime%',date("c",time()-$globalLiveInterval),$output); |
| 698 | 764 | } |
| 765 | + } else { |
|
| 766 | + $output = str_replace('%minitime%',date("c",$minitime),$output); |
|
| 699 | 767 | } |
| 700 | - else $output = str_replace('%minitime%',date("c",$minitime),$output); |
|
| 701 | -} else $output = str_replace('%minitime%',date("c",$minitime),$output); |
|
| 768 | + } else { |
|
| 769 | + $output = str_replace('%minitime%',date("c",$minitime),$output); |
|
| 770 | +} |
|
| 702 | 771 | $output = str_replace('%maxitime%',date("c",$maxitime),$output); |
| 703 | 772 | print $output; |
| 704 | 773 | ?> |
@@ -209,21 +209,21 @@ discard block |
||
| 209 | 209 | var entityid = entity.id; |
| 210 | 210 | var lastupdateentity = entity.properties.valueOf('lastupdate')._lastupdate._value; |
| 211 | 211 | <?php |
| 212 | - if (isset($globalMapUseBbox) && $globalMapUseBbox) { |
|
| 212 | + if (isset($globalMapUseBbox) && $globalMapUseBbox) { |
|
| 213 | 213 | ?> |
| 214 | 214 | if (lastupdateentity != lastupdate) { |
| 215 | 215 | viewer.dataSources.get(dsn).entities.remove(entity); |
| 216 | 216 | czmlds.entities.removeById(entityid); |
| 217 | 217 | } |
| 218 | 218 | <?php |
| 219 | - } else { |
|
| 219 | + } else { |
|
| 220 | 220 | ?> |
| 221 | 221 | if (parseInt(lastupdateentity) < Math.floor(Date.now()-<?php if (isset($globalMapRefresh)) print $globalMapRefresh*2000; else print '60000'; ?>)) { |
| 222 | 222 | viewer.dataSources.get(dsn).entities.remove(entity); |
| 223 | 223 | czmlds.entities.removeById(entityid); |
| 224 | 224 | } |
| 225 | 225 | <?php |
| 226 | - } |
|
| 226 | + } |
|
| 227 | 227 | ?> |
| 228 | 228 | } |
| 229 | 229 | } |
@@ -629,12 +629,12 @@ discard block |
||
| 629 | 629 | update_airportsLayer(); |
| 630 | 630 | } |
| 631 | 631 | <?php |
| 632 | - if ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM)) { |
|
| 632 | + if ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM)) { |
|
| 633 | 633 | ?> |
| 634 | 634 | update_atcLayer(); |
| 635 | 635 | setInterval(function(){update_atcLayer()},<?php if (isset($globalMapRefresh)) print $globalMapRefresh*1000*2; else print '60000'; ?>); |
| 636 | 636 | <?php |
| 637 | - } |
|
| 637 | + } |
|
| 638 | 638 | ?> |
| 639 | 639 | |
| 640 | 640 | function iconColor(color) { |
@@ -218,7 +218,12 @@ discard block |
||
| 218 | 218 | <?php |
| 219 | 219 | } else { |
| 220 | 220 | ?> |
| 221 | - if (parseInt(lastupdateentity) < Math.floor(Date.now()-<?php if (isset($globalMapRefresh)) print $globalMapRefresh*2000; else print '60000'; ?>)) { |
|
| 221 | + if (parseInt(lastupdateentity) < Math.floor(Date.now()-<?php if (isset($globalMapRefresh)) { |
|
| 222 | + print $globalMapRefresh*2000; |
|
| 223 | +} else { |
|
| 224 | + print '60000'; |
|
| 225 | +} |
|
| 226 | +?>)) { |
|
| 222 | 227 | viewer.dataSources.get(dsn).entities.remove(entity); |
| 223 | 228 | czmlds.entities.removeById(entityid); |
| 224 | 229 | } |
@@ -502,7 +507,12 @@ discard block |
||
| 502 | 507 | if (!((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS)) && (isset($_COOKIE['polar']) && $_COOKIE['polar'] == 'true')) { |
| 503 | 508 | ?> |
| 504 | 509 | update_polarLayer(); |
| 505 | -setInterval(function(){update_polarLayer()},<?php if (isset($globalMapRefresh)) print $globalMapRefresh*1000*2; else print '60000'; ?>); |
|
| 510 | +setInterval(function(){update_polarLayer()},<?php if (isset($globalMapRefresh)) { |
|
| 511 | + print $globalMapRefresh*1000*2; |
|
| 512 | +} else { |
|
| 513 | + print '60000'; |
|
| 514 | +} |
|
| 515 | +?>); |
|
| 506 | 516 | <?php |
| 507 | 517 | } |
| 508 | 518 | ?> |
@@ -613,7 +623,12 @@ discard block |
||
| 613 | 623 | } |
| 614 | 624 | } |
| 615 | 625 | } |
| 616 | - ,<?php if (isset($globalMapRefresh)) print $globalMapRefresh*1000; else print '30000'; ?>); |
|
| 626 | + ,<?php if (isset($globalMapRefresh)) { |
|
| 627 | + print $globalMapRefresh*1000; |
|
| 628 | +} else { |
|
| 629 | + print '30000'; |
|
| 630 | +} |
|
| 631 | +?>); |
|
| 617 | 632 | } else { |
| 618 | 633 | //var widget = new Cesium.CesiumWidget('archivebox'); |
| 619 | 634 | // var timeline = new Cesium.Timeline(viewer); |
@@ -632,7 +647,12 @@ discard block |
||
| 632 | 647 | if ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM)) { |
| 633 | 648 | ?> |
| 634 | 649 | update_atcLayer(); |
| 635 | -setInterval(function(){update_atcLayer()},<?php if (isset($globalMapRefresh)) print $globalMapRefresh*1000*2; else print '60000'; ?>); |
|
| 650 | +setInterval(function(){update_atcLayer()},<?php if (isset($globalMapRefresh)) { |
|
| 651 | + print $globalMapRefresh*1000*2; |
|
| 652 | +} else { |
|
| 653 | + print '60000'; |
|
| 654 | +} |
|
| 655 | +?>); |
|
| 636 | 656 | <?php |
| 637 | 657 | } |
| 638 | 658 | ?> |
@@ -38,20 +38,20 @@ discard block |
||
| 38 | 38 | var entityid = entity.id; |
| 39 | 39 | var lastupdateentity = entity.properties.valueOf('lastupdate')._lastupdate._value; |
| 40 | 40 | <?php |
| 41 | - if (isset($globalMapUseBbox) && $globalMapUseBbox) { |
|
| 41 | + if (isset($globalMapUseBbox) && $globalMapUseBbox) { |
|
| 42 | 42 | ?> |
| 43 | 43 | if (lastupdateentity != lastupdatemarine) { |
| 44 | 44 | viewer.dataSources.get(dsn).entities.remove(entity); |
| 45 | 45 | czmldsmarine.entities.removeById(entityid); |
| 46 | 46 | } |
| 47 | 47 | <?php |
| 48 | - } else { |
|
| 48 | + } else { |
|
| 49 | 49 | ?> |
| 50 | 50 | if (parseInt(lastupdateentity) < Math.floor(Date.now()-<?php if (isset($globalMapRefresh)) print $globalMapRefresh*2000; else print '60000'; ?>)) { |
| 51 | 51 | viewer.dataSources.get(dsn).entities.remove(entity); |
| 52 | 52 | } |
| 53 | 53 | <?php |
| 54 | - } |
|
| 54 | + } |
|
| 55 | 55 | ?> |
| 56 | 56 | } |
| 57 | 57 | } |
@@ -73,15 +73,15 @@ discard block |
||
| 73 | 73 | function updateMarineData() { |
| 74 | 74 | lastupdatemarine = Date.now(); |
| 75 | 75 | <?php |
| 76 | - if (isset($globalMapUseBbox) && $globalMapUseBbox) { |
|
| 76 | + if (isset($globalMapUseBbox) && $globalMapUseBbox) { |
|
| 77 | 77 | ?> |
| 78 | 78 | var livemarinedata = czmldsmarine.process('<?php print $globalURL; ?>/live-czml.php?marine&coord='+bbox()+'&update=' + lastupdatemarine); |
| 79 | 79 | <?php |
| 80 | - } else { |
|
| 80 | + } else { |
|
| 81 | 81 | ?> |
| 82 | 82 | var livemarinedata = czmldsmarine.process('<?php print $globalURL; ?>/live-czml.php?marine&update=' + lastupdatemarine); |
| 83 | 83 | <?php |
| 84 | - } |
|
| 84 | + } |
|
| 85 | 85 | ?> |
| 86 | 86 | livemarinedata.then(function (data) { |
| 87 | 87 | displayMarineData(data); |
@@ -47,7 +47,12 @@ discard block |
||
| 47 | 47 | <?php |
| 48 | 48 | } else { |
| 49 | 49 | ?> |
| 50 | - if (parseInt(lastupdateentity) < Math.floor(Date.now()-<?php if (isset($globalMapRefresh)) print $globalMapRefresh*2000; else print '60000'; ?>)) { |
|
| 50 | + if (parseInt(lastupdateentity) < Math.floor(Date.now()-<?php if (isset($globalMapRefresh)) { |
|
| 51 | + print $globalMapRefresh*2000; |
|
| 52 | +} else { |
|
| 53 | + print '60000'; |
|
| 54 | +} |
|
| 55 | +?>)) { |
|
| 51 | 56 | viewer.dataSources.get(dsn).entities.remove(entity); |
| 52 | 57 | } |
| 53 | 58 | <?php |
@@ -129,7 +134,12 @@ discard block |
||
| 129 | 134 | function(){ |
| 130 | 135 | updateMarineData(); |
| 131 | 136 | } |
| 132 | - ,<?php if (isset($globalMapRefresh)) print $globalMapRefresh*1000; else print '30000'; ?>); |
|
| 137 | + ,<?php if (isset($globalMapRefresh)) { |
|
| 138 | + print $globalMapRefresh*1000; |
|
| 139 | +} else { |
|
| 140 | + print '30000'; |
|
| 141 | +} |
|
| 142 | +?>); |
|
| 133 | 143 | } else { |
| 134 | 144 | var clockViewModel = new Cesium.ClockViewModel(viewer.clock); |
| 135 | 145 | var animationViewModel = new Cesium.AnimationViewModel(clockViewModel); |
@@ -81,21 +81,21 @@ discard block |
||
| 81 | 81 | var entityid = entity.id; |
| 82 | 82 | var lastupdateentity = entity.properties.valueOf('lastupdate')._lastupdate._value; |
| 83 | 83 | <?php |
| 84 | - if (isset($globalMapUseBbox) && $globalMapUseBbox) { |
|
| 84 | + if (isset($globalMapUseBbox) && $globalMapUseBbox) { |
|
| 85 | 85 | ?> |
| 86 | 86 | if (lastupdateentity != lastupdatetracker) { |
| 87 | 87 | viewer.dataSources.get(dsn).entities.remove(entity); |
| 88 | 88 | czmldstracker.entities.removeById(entityid); |
| 89 | 89 | } |
| 90 | 90 | <?php |
| 91 | - } else { |
|
| 91 | + } else { |
|
| 92 | 92 | ?> |
| 93 | 93 | if (parseInt(lastupdateentity) < Math.floor(Date.now()-<?php if (isset($globalMapRefresh)) print $globalMapRefresh*2000; else print '60000'; ?>)) { |
| 94 | 94 | viewer.dataSources.get(dsn).entities.remove(entity); |
| 95 | 95 | czmldstracker.entities.removeById(entityid); |
| 96 | 96 | } |
| 97 | 97 | <?php |
| 98 | - } |
|
| 98 | + } |
|
| 99 | 99 | ?> |
| 100 | 100 | } |
| 101 | 101 | } |
@@ -116,15 +116,15 @@ discard block |
||
| 116 | 116 | function updateTrackerData() { |
| 117 | 117 | lastupdatetracker = Date.now(); |
| 118 | 118 | <?php |
| 119 | - if (isset($globalMapUseBbox) && $globalMapUseBbox) { |
|
| 119 | + if (isset($globalMapUseBbox) && $globalMapUseBbox) { |
|
| 120 | 120 | ?> |
| 121 | 121 | var livetrackerdata = czmldstracker.process('<?php print $globalURL; ?>/live-czml.php?tracker&coord='+bbox()+'&update=' + lastupdatetracker); |
| 122 | 122 | <?php |
| 123 | - } else { |
|
| 123 | + } else { |
|
| 124 | 124 | ?> |
| 125 | 125 | var livetrackerdata = czmldstracker.process('<?php print $globalURL; ?>/live-czml.php?tracker&update=' + lastupdatetracker); |
| 126 | 126 | <?php |
| 127 | - } |
|
| 127 | + } |
|
| 128 | 128 | ?> |
| 129 | 129 | livetrackerdata.then(function (data) { |
| 130 | 130 | displayTrackerData(data); |
@@ -90,7 +90,12 @@ discard block |
||
| 90 | 90 | <?php |
| 91 | 91 | } else { |
| 92 | 92 | ?> |
| 93 | - if (parseInt(lastupdateentity) < Math.floor(Date.now()-<?php if (isset($globalMapRefresh)) print $globalMapRefresh*2000; else print '60000'; ?>)) { |
|
| 93 | + if (parseInt(lastupdateentity) < Math.floor(Date.now()-<?php if (isset($globalMapRefresh)) { |
|
| 94 | + print $globalMapRefresh*2000; |
|
| 95 | +} else { |
|
| 96 | + print '60000'; |
|
| 97 | +} |
|
| 98 | +?>)) { |
|
| 94 | 99 | viewer.dataSources.get(dsn).entities.remove(entity); |
| 95 | 100 | czmldstracker.entities.removeById(entityid); |
| 96 | 101 | } |
@@ -173,7 +178,12 @@ discard block |
||
| 173 | 178 | function(){ |
| 174 | 179 | updateTrackerData(); |
| 175 | 180 | } |
| 176 | - ,<?php if (isset($globalMapRefresh)) print $globalMapRefresh*1000; else print '30000'; ?>); |
|
| 181 | + ,<?php if (isset($globalMapRefresh)) { |
|
| 182 | + print $globalMapRefresh*1000; |
|
| 183 | +} else { |
|
| 184 | + print '30000'; |
|
| 185 | +} |
|
| 186 | +?>); |
|
| 177 | 187 | } else { |
| 178 | 188 | var clockViewModel = new Cesium.ClockViewModel(viewer.clock); |
| 179 | 189 | var animationViewModel = new Cesium.AnimationViewModel(clockViewModel); |