@@ -16,11 +16,15 @@ discard block |
||
| 16 | 16 | $Tracker = new Tracker(); |
| 17 | 17 | } |
| 18 | 18 | |
| 19 | -if (!isset($filter_name)) $filter_name = ''; |
|
| 19 | +if (!isset($filter_name)) { |
|
| 20 | + $filter_name = ''; |
|
| 21 | +} |
|
| 20 | 22 | $airline_icao = (string)filter_input(INPUT_GET,'airline',FILTER_SANITIZE_STRING); |
| 21 | 23 | if ($airline_icao == '' && isset($globalFilter)) { |
| 22 | - if (isset($globalFilter['airline'])) $airline_icao = $globalFilter['airline'][0]; |
|
| 23 | -} |
|
| 24 | + if (isset($globalFilter['airline'])) { |
|
| 25 | + $airline_icao = $globalFilter['airline'][0]; |
|
| 26 | + } |
|
| 27 | + } |
|
| 24 | 28 | |
| 25 | 29 | require_once('header.php'); |
| 26 | 30 | include('statistics-sub-menu.php'); |
@@ -33,9 +37,13 @@ discard block |
||
| 33 | 37 | </div> |
| 34 | 38 | <p>'._("Below is a list of the most common <strong>time of day</strong>.").'</p>'; |
| 35 | 39 | |
| 36 | -if ($type == 'aircraft') $hour_array = $Stats->countAllHours('hour',true,$airline_icao,$filter_name); |
|
| 37 | -elseif ($type == 'marine') $hour_array = $Marine->countAllHours('hour',true); |
|
| 38 | -elseif ($type == 'tracker') $hour_array = $Tracker->countAllHours('hour',true); |
|
| 40 | +if ($type == 'aircraft') { |
|
| 41 | + $hour_array = $Stats->countAllHours('hour',true,$airline_icao,$filter_name); |
|
| 42 | +} elseif ($type == 'marine') { |
|
| 43 | + $hour_array = $Marine->countAllHours('hour',true); |
|
| 44 | +} elseif ($type == 'tracker') { |
|
| 45 | + $hour_array = $Tracker->countAllHours('hour',true); |
|
| 46 | +} |
|
| 39 | 47 | print '<div id="chartHour" class="chart" width="100%"></div><script>'; |
| 40 | 48 | $hour_data = ''; |
| 41 | 49 | $hour_cnt = ''; |
@@ -53,9 +61,13 @@ discard block |
||
| 53 | 61 | axis: { x: { type: "category", categories: '.$hour_data.'},y: { label: "# of Flights"}},legend: { show: false }});'; |
| 54 | 62 | print '</script>'; |
| 55 | 63 | |
| 56 | -if ($type == 'aircraft') $hour_array = $Stats->countAllHours('count',true,$airline_icao,$filter_name); |
|
| 57 | -elseif ($type == 'marine') $hour_array = $Marine->countAllHours('count',true); |
|
| 58 | -elseif ($type == 'tracker') $hour_array = $Tracker->countAllHours('count',true); |
|
| 64 | +if ($type == 'aircraft') { |
|
| 65 | + $hour_array = $Stats->countAllHours('count',true,$airline_icao,$filter_name); |
|
| 66 | +} elseif ($type == 'marine') { |
|
| 67 | + $hour_array = $Marine->countAllHours('count',true); |
|
| 68 | +} elseif ($type == 'tracker') { |
|
| 69 | + $hour_array = $Tracker->countAllHours('count',true); |
|
| 70 | +} |
|
| 59 | 71 | if (!empty($hour_array)) |
| 60 | 72 | { |
| 61 | 73 | print '<div class="table-responsive">'; |
@@ -5,11 +5,15 @@ discard block |
||
| 5 | 5 | $Stats = new Stats(); |
| 6 | 6 | $title = _("Statistics").' - '._("Most common Aircraft"); |
| 7 | 7 | |
| 8 | -if (!isset($filter_name)) $filter_name = ''; |
|
| 8 | +if (!isset($filter_name)) { |
|
| 9 | + $filter_name = ''; |
|
| 10 | +} |
|
| 9 | 11 | $airline_icao = (string)filter_input(INPUT_GET,'airline',FILTER_SANITIZE_STRING); |
| 10 | 12 | if ($airline_icao == '' && isset($globalFilter)) { |
| 11 | - if (isset($globalFilter['airline'])) $airline_icao = $globalFilter['airline'][0]; |
|
| 12 | -} |
|
| 13 | + if (isset($globalFilter['airline'])) { |
|
| 14 | + $airline_icao = $globalFilter['airline'][0]; |
|
| 15 | + } |
|
| 16 | + } |
|
| 13 | 17 | $year = filter_input(INPUT_GET,'year',FILTER_SANITIZE_NUMBER_INT); |
| 14 | 18 | $month = filter_input(INPUT_GET,'month',FILTER_SANITIZE_NUMBER_INT); |
| 15 | 19 | |
@@ -28,9 +32,12 @@ discard block |
||
| 28 | 32 | $aircraft_data = ''; |
| 29 | 33 | foreach($aircraft_array as $aircraft_item) |
| 30 | 34 | { |
| 31 | - if ($aircraft_item['aircraft_manufacturer'] == 'Not Available') $aircraft_data .= '[" ('.$aircraft_item['aircraft_icao'].')",'.$aircraft_item['aircraft_icao_count'].'],'; |
|
| 32 | - else $aircraft_data .= '["'.$aircraft_item['aircraft_manufacturer'].' '.$aircraft_item['aircraft_name'].' ('.$aircraft_item['aircraft_icao'].')",'.$aircraft_item['aircraft_icao_count'].'],'; |
|
| 33 | -} |
|
| 35 | + if ($aircraft_item['aircraft_manufacturer'] == 'Not Available') { |
|
| 36 | + $aircraft_data .= '[" ('.$aircraft_item['aircraft_icao'].')",'.$aircraft_item['aircraft_icao_count'].'],'; |
|
| 37 | + } else { |
|
| 38 | + $aircraft_data .= '["'.$aircraft_item['aircraft_manufacturer'].' '.$aircraft_item['aircraft_name'].' ('.$aircraft_item['aircraft_icao'].')",'.$aircraft_item['aircraft_icao_count'].'],'; |
|
| 39 | + } |
|
| 40 | + } |
|
| 34 | 41 | $aircraft_data = substr($aircraft_data, 0, -1); |
| 35 | 42 | print 'var series = ['.$aircraft_data.'];'; |
| 36 | 43 | print 'var dataset = [];var onlyValues = series.map(function(obj){ return obj[1]; });var minValue = Math.min.apply(null, onlyValues), maxValue = Math.max.apply(null, onlyValues);'; |
@@ -8,7 +8,9 @@ |
||
| 8 | 8 | $atcid = filter_input(INPUT_GET,'atcid',FILTER_SANITIZE_NUMBER_INT); |
| 9 | 9 | $atcident = filter_input(INPUT_GET,'atcident',FILTER_SANITIZE_STRING); |
| 10 | 10 | $atc_data = $ATC->getById($atcid); |
| 11 | - if (!isset($atc_data[0])) $atc_data = $ATC->getByIdent($atcident); |
|
| 11 | + if (!isset($atc_data[0])) { |
|
| 12 | + $atc_data = $ATC->getByIdent($atcident); |
|
| 13 | + } |
|
| 12 | 14 | ?> |
| 13 | 15 | <div class="alldetails"> |
| 14 | 16 | <button type="button" class="close">×</button> |
@@ -57,7 +57,9 @@ discard block |
||
| 57 | 57 | { |
| 58 | 58 | if ($spotter_item['image_source'] == 'flickr' || $spotter_item['image_source'] == 'wikimedia' || $spotter_item['image_source'] == 'devianart') { |
| 59 | 59 | $image = preg_replace("/^http:/i","https:",$spotter_item['image_thumbnail']); |
| 60 | - } else $image = $spotter_item['image_thumbnail']; |
|
| 60 | + } else { |
|
| 61 | + $image = $spotter_item['image_thumbnail']; |
|
| 62 | + } |
|
| 61 | 63 | |
| 62 | 64 | } |
| 63 | 65 | /* else { |
@@ -70,8 +72,12 @@ discard block |
||
| 70 | 72 | } |
| 71 | 73 | print '<div class="right">'; |
| 72 | 74 | print '<div class="callsign-details">'; |
| 73 | -if ($spotter_item['ident'] != 'Not Available') print '<div class="callsign"><a href="'.$globalURL.'/redirect/'.$spotter_item['flightaware_id'].'" target="_blank">'.$spotter_item['ident'].'</a></div>'; |
|
| 74 | -if (isset($spotter_item['airline_name']) && $spotter_item['airline_name'] != 'Not Available') print '<div class="airline">'.$spotter_item['airline_name'].'</div>'; |
|
| 75 | +if ($spotter_item['ident'] != 'Not Available') { |
|
| 76 | + print '<div class="callsign"><a href="'.$globalURL.'/redirect/'.$spotter_item['flightaware_id'].'" target="_blank">'.$spotter_item['ident'].'</a></div>'; |
|
| 77 | +} |
|
| 78 | +if (isset($spotter_item['airline_name']) && $spotter_item['airline_name'] != 'Not Available') { |
|
| 79 | + print '<div class="airline">'.$spotter_item['airline_name'].'</div>'; |
|
| 80 | +} |
|
| 75 | 81 | print '</div>'; |
| 76 | 82 | if ($spotter_item['departure_airport'] != 'NA' && $spotter_item['arrival_airport'] != 'NA') { |
| 77 | 83 | print '<div class="nomobile airports"><div class="airport"><span class="code"><a href="'.$globalURL.'/airport/'.$spotter_item['departure_airport'].'" target="_blank">'.$spotter_item['departure_airport'].'</a></span>'.$spotter_item['departure_airport_city'].' '.$spotter_item['departure_airport_country']; |
@@ -103,10 +109,16 @@ discard block |
||
| 103 | 109 | print '</div>'; |
| 104 | 110 | print '<div id="aircraft">'; |
| 105 | 111 | print '<span>'._("Aircraft").'</span>'; |
| 106 | -if (isset($spotter_item['aircraft_wiki'])) print '<a href="'.$spotter_item['aircraft_wiki'].'">'.$spotter_item['aircraft_name'].'</a>'; |
|
| 107 | -if (isset($spotter_item['aircraft_type']) && isset($spotter_item['aircraft_manufacturer']) && $spotter_item['aircraft_manufacturer'] != 'N/A' && isset($spotter_item['aircraft_name']) && $spotter_item['aircraft_name'] != 'N/A') print '<a href="'.$globalURL.'/aircraft/'.$spotter_item['aircraft_type'].'">'.$spotter_item['aircraft_manufacturer'].' '.$spotter_item['aircraft_name'].' ('.$spotter_item['aircraft_type'].')</a>'; |
|
| 108 | -elseif (isset($spotter_item['aircraft_type'])) print '<a href="'.$globalURL.'/aircraft/'.$spotter_item['aircraft_type'].'">'.$spotter_item['aircraft_type'].'</a>'; |
|
| 109 | -else print $spotter_item['aircraft_manufacturer'].' '.$spotter_item['aircraft_name']; |
|
| 112 | +if (isset($spotter_item['aircraft_wiki'])) { |
|
| 113 | + print '<a href="'.$spotter_item['aircraft_wiki'].'">'.$spotter_item['aircraft_name'].'</a>'; |
|
| 114 | +} |
|
| 115 | +if (isset($spotter_item['aircraft_type']) && isset($spotter_item['aircraft_manufacturer']) && $spotter_item['aircraft_manufacturer'] != 'N/A' && isset($spotter_item['aircraft_name']) && $spotter_item['aircraft_name'] != 'N/A') { |
|
| 116 | + print '<a href="'.$globalURL.'/aircraft/'.$spotter_item['aircraft_type'].'">'.$spotter_item['aircraft_manufacturer'].' '.$spotter_item['aircraft_name'].' ('.$spotter_item['aircraft_type'].')</a>'; |
|
| 117 | +} elseif (isset($spotter_item['aircraft_type'])) { |
|
| 118 | + print '<a href="'.$globalURL.'/aircraft/'.$spotter_item['aircraft_type'].'">'.$spotter_item['aircraft_type'].'</a>'; |
|
| 119 | +} else { |
|
| 120 | + print $spotter_item['aircraft_manufacturer'].' '.$spotter_item['aircraft_name']; |
|
| 121 | +} |
|
| 110 | 122 | print '</div>'; |
| 111 | 123 | print '<div id ="altitude"><span>'._("Altitude").'</span>'; |
| 112 | 124 | if (isset($globalGroundAltitude) && $globalGroundAltitude) { |
@@ -117,12 +129,18 @@ discard block |
||
| 117 | 129 | } |
| 118 | 130 | |
| 119 | 131 | if ((!isset($_COOKIE['unitaltitude']) && isset($globalUnitAltitude) && $globalUnitAltitude == 'feet') || (isset($_COOKIE['unitaltitude']) && $_COOKIE['unitaltitude'] == 'feet')) { |
| 120 | - if (isset($spotter_item['real_altitude']) && $spotter_item['real_altitude'] != '') print $spotter_item['real_altitude'].' feet (FL'.$spotter_item['altitude'].')'; |
|
| 121 | - else print $spotter_item['altitude'].'00 feet (FL'.$spotter_item['altitude'].')'; |
|
| 122 | -} else { |
|
| 123 | - if (isset($spotter_item['real_altitude']) && $spotter_item['real_altitude'] != '') print round($spotter_item['real_altitude']*0.3048).' m (FL'.$spotter_item['altitude'].')'; |
|
| 124 | - else print round($spotter_item['altitude']*30.48).' m (FL'.$spotter_item['altitude'].')'; |
|
| 125 | -} |
|
| 132 | + if (isset($spotter_item['real_altitude']) && $spotter_item['real_altitude'] != '') { |
|
| 133 | + print $spotter_item['real_altitude'].' feet (FL'.$spotter_item['altitude'].')'; |
|
| 134 | + } else { |
|
| 135 | + print $spotter_item['altitude'].'00 feet (FL'.$spotter_item['altitude'].')'; |
|
| 136 | + } |
|
| 137 | + } else { |
|
| 138 | + if (isset($spotter_item['real_altitude']) && $spotter_item['real_altitude'] != '') { |
|
| 139 | + print round($spotter_item['real_altitude']*0.3048).' m (FL'.$spotter_item['altitude'].')'; |
|
| 140 | + } else { |
|
| 141 | + print round($spotter_item['altitude']*30.48).' m (FL'.$spotter_item['altitude'].')'; |
|
| 142 | + } |
|
| 143 | + } |
|
| 126 | 144 | |
| 127 | 145 | if (isset($groundAltitude) && $groundAltitude < $spotter_item['altitude']*30.48) { |
| 128 | 146 | print '<br>'; |
@@ -136,7 +154,9 @@ discard block |
||
| 136 | 154 | } |
| 137 | 155 | |
| 138 | 156 | print '</div>'; |
| 139 | -if (isset($spotter_item['registration']) && $spotter_item['registration'] != '') print '<div><span>'._("Registration").'</span><a href="'.$globalURL.'/registration/'.$spotter_item['registration'].'" target="_blank">'.$spotter_item['registration'].'</a></div>'; |
|
| 157 | +if (isset($spotter_item['registration']) && $spotter_item['registration'] != '') { |
|
| 158 | + print '<div><span>'._("Registration").'</span><a href="'.$globalURL.'/registration/'.$spotter_item['registration'].'" target="_blank">'.$spotter_item['registration'].'</a></div>'; |
|
| 159 | +} |
|
| 140 | 160 | print '<div id="speed"><span>'._("Speed").'</span>'; |
| 141 | 161 | if ((!isset($_COOKIE['unitspeed']) && isset($globalUnitSpeed) && $globalUnitSpeed == 'mph') || (isset($_COOKIE['unitspeed']) && $_COOKIE['unitspeed'] == 'mph')) { |
| 142 | 162 | print round($spotter_item['ground_speed']*1.15078).' mph'; |
@@ -150,8 +170,11 @@ discard block |
||
| 150 | 170 | print '<div id="heading"><span>'._("Heading").'</span>'.$spotter_item['heading'].'°</div>'; |
| 151 | 171 | if (isset($spotter_item['pilot_name']) && $spotter_item['pilot_name'] != '') { |
| 152 | 172 | print '<div id="pilot"><span>'._("Pilot").'</span>'; |
| 153 | - if (isset($spotter_item['pilot_id'])) print $spotter_item['pilot_name'].' ('.$spotter_item['pilot_id'].')'; |
|
| 154 | - else print $spotter_item['pilot_name']; |
|
| 173 | + if (isset($spotter_item['pilot_id'])) { |
|
| 174 | + print $spotter_item['pilot_name'].' ('.$spotter_item['pilot_id'].')'; |
|
| 175 | + } else { |
|
| 176 | + print $spotter_item['pilot_name']; |
|
| 177 | + } |
|
| 155 | 178 | print '</div>'; |
| 156 | 179 | } |
| 157 | 180 | |
@@ -179,10 +202,18 @@ discard block |
||
| 179 | 202 | print '</div>'; |
| 180 | 203 | print '</div>'; |
| 181 | 204 | |
| 182 | -if (isset($globalVA) && $globalVA && isset($globalphpVMS) && $globalphpVMS && isset($globalVATSIM) && $globalVATSIM && isset($globalIVAO) && $globalIVAO && isset($spotter_item['format_source']) && $spotter_item['format_source'] != '' && $spotter_item['format_source'] != 'pireps') print '<div class="waypoints"><span>'._("Source").'</span>'.$spotter_item['format_source'].'</div>'; |
|
| 183 | -if (isset($spotter_item['waypoints']) && $spotter_item['waypoints'] != '') print '<div class="waypoints"><span>'._("Route").'</span>'.$spotter_item['waypoints'].'</div>'; |
|
| 184 | -if (isset($spotter_item['acars']['message'])) print '<div class="acars"><span>'._("Latest ACARS message").'</span>'.trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'<br/>',$spotter_item['acars']['message'])).'</div>'; |
|
| 185 | -if (isset($spotter_item['squawk']) && $spotter_item['squawk'] != '' && $spotter_item['squawk'] != 0) print '<div class="bottom">'._("Squawk:").' '.$spotter_item['squawk'].' - '.$spotter_item['squawk_usage'].'</div>'; |
|
| 205 | +if (isset($globalVA) && $globalVA && isset($globalphpVMS) && $globalphpVMS && isset($globalVATSIM) && $globalVATSIM && isset($globalIVAO) && $globalIVAO && isset($spotter_item['format_source']) && $spotter_item['format_source'] != '' && $spotter_item['format_source'] != 'pireps') { |
|
| 206 | + print '<div class="waypoints"><span>'._("Source").'</span>'.$spotter_item['format_source'].'</div>'; |
|
| 207 | +} |
|
| 208 | +if (isset($spotter_item['waypoints']) && $spotter_item['waypoints'] != '') { |
|
| 209 | + print '<div class="waypoints"><span>'._("Route").'</span>'.$spotter_item['waypoints'].'</div>'; |
|
| 210 | +} |
|
| 211 | +if (isset($spotter_item['acars']['message'])) { |
|
| 212 | + print '<div class="acars"><span>'._("Latest ACARS message").'</span>'.trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'<br/>',$spotter_item['acars']['message'])).'</div>'; |
|
| 213 | +} |
|
| 214 | +if (isset($spotter_item['squawk']) && $spotter_item['squawk'] != '' && $spotter_item['squawk'] != 0) { |
|
| 215 | + print '<div class="bottom">'._("Squawk:").' '.$spotter_item['squawk'].' - '.$spotter_item['squawk_usage'].'</div>'; |
|
| 216 | +} |
|
| 186 | 217 | print '</div>'; |
| 187 | 218 | ?> |
| 188 | 219 | </div> |
| 189 | 220 | \ No newline at end of file |
@@ -1,8 +1,10 @@ discard block |
||
| 1 | 1 | </section> |
| 2 | 2 | <div class="pub onmap"> |
| 3 | 3 | <?php |
| 4 | - if (isset($globalPub)) print $globalPub; |
|
| 5 | -?> |
|
| 4 | + if (isset($globalPub)) { |
|
| 5 | + print $globalPub; |
|
| 6 | + } |
|
| 7 | + ?> |
|
| 6 | 8 | </div> |
| 7 | 9 | <footer class="container"> |
| 8 | 10 | <?php |
@@ -13,7 +15,10 @@ discard block |
||
| 13 | 15 | <?php |
| 14 | 16 | } |
| 15 | 17 | ?> |
| 16 | - <span>Developed in Barrie by <a href="http://mtru.nz/" target="_blank">Mario Trunz</a> & at <a href="http://www.zugaina.com" target="_blank">Zugaina</a> by Ycarus</span> - <span><a href="<?php if (isset($globalURL)) print $globalURL; ?>/about#source">Source & Credits</a></span> - <span><a href="https://www.flightairmap.fr/" target="_blank">Get source code</a></span> |
|
| 18 | + <span>Developed in Barrie by <a href="http://mtru.nz/" target="_blank">Mario Trunz</a> & at <a href="http://www.zugaina.com" target="_blank">Zugaina</a> by Ycarus</span> - <span><a href="<?php if (isset($globalURL)) { |
|
| 19 | + print $globalURL; |
|
| 20 | +} |
|
| 21 | +?>/about#source">Source & Credits</a></span> - <span><a href="https://www.flightairmap.fr/" target="_blank">Get source code</a></span> |
|
| 17 | 22 | </footer> |
| 18 | 23 | |
| 19 | 24 | <div class="notifications bottom-left"></div> |
@@ -28,7 +28,9 @@ discard block |
||
| 28 | 28 | private $openedFiles = []; |
| 29 | 29 | |
| 30 | 30 | public function __construct($htgFilesDestination = '', $resolution = 3) { |
| 31 | - if ($htgFilesDestination == '') $htgFilesDestination = dirname(__FILE__).'/../data/'; |
|
| 31 | + if ($htgFilesDestination == '') { |
|
| 32 | + $htgFilesDestination = dirname(__FILE__).'/../data/'; |
|
| 33 | + } |
|
| 32 | 34 | $this->htgFilesDestination = $htgFilesDestination; |
| 33 | 35 | $this->resolution = $resolution; |
| 34 | 36 | switch ($resolution) { |
@@ -171,16 +173,26 @@ discard block |
||
| 171 | 173 | $fileName = "N{$N}E{$E}.hgt"; |
| 172 | 174 | if (!file_exists($this->htgFilesDestination . DIRECTORY_SEPARATOR . $fileName)) { |
| 173 | 175 | $Common = new Common(); |
| 174 | - if ($debug) echo 'Downloading '.$fileName.'.gz ...'; |
|
| 176 | + if ($debug) { |
|
| 177 | + echo 'Downloading '.$fileName.'.gz ...'; |
|
| 178 | + } |
|
| 175 | 179 | $Common->download('https://s3.amazonaws.com/elevation-tiles-prod/skadi/N'.$N.'/'.$fileName.'.gz',$this->htgFilesDestination . DIRECTORY_SEPARATOR . $fileName . '.gz'); |
| 176 | 180 | if (!file_exists($this->htgFilesDestination . DIRECTORY_SEPARATOR . $fileName . '.gz')) { |
| 177 | - if ($debug) echo "File '{$fileName}.gz' not exists."; |
|
| 181 | + if ($debug) { |
|
| 182 | + echo "File '{$fileName}.gz' not exists."; |
|
| 183 | + } |
|
| 178 | 184 | return false; |
| 179 | 185 | } |
| 180 | - if ($debug) echo 'Done'."\n"; |
|
| 181 | - if ($debug) echo 'Decompress '.$fileName.' ....'; |
|
| 186 | + if ($debug) { |
|
| 187 | + echo 'Done'."\n"; |
|
| 188 | + } |
|
| 189 | + if ($debug) { |
|
| 190 | + echo 'Decompress '.$fileName.' ....'; |
|
| 191 | + } |
|
| 182 | 192 | $Common->gunzip($this->htgFilesDestination . DIRECTORY_SEPARATOR . $fileName . '.gz',$this->htgFilesDestination . DIRECTORY_SEPARATOR . $fileName); |
| 183 | - if ($debug) echo 'Done'."\n"; |
|
| 193 | + if ($debug) { |
|
| 194 | + echo 'Done'."\n"; |
|
| 195 | + } |
|
| 184 | 196 | unlink($this->htgFilesDestination . DIRECTORY_SEPARATOR . $fileName . '.gz'); |
| 185 | 197 | } |
| 186 | 198 | return true; |
@@ -38,8 +38,11 @@ discard block |
||
| 38 | 38 | global $globalGeoidSource; |
| 39 | 39 | //if ($name == '') $name = dirname(__FILE__).'/../install/tmp/egm2008-1.pgm'; |
| 40 | 40 | if ($name == '') { |
| 41 | - if (isset($globalGeoidSource) && $globalGeoidSource != '') $name = dirname(__FILE__).'/../data/'.$globalGeoidSource.'.pgm'; |
|
| 42 | - else $name = dirname(__FILE__).'/../data/egm96-15.pgm'; |
|
| 41 | + if (isset($globalGeoidSource) && $globalGeoidSource != '') { |
|
| 42 | + $name = dirname(__FILE__).'/../data/'.$globalGeoidSource.'.pgm'; |
|
| 43 | + } else { |
|
| 44 | + $name = dirname(__FILE__).'/../data/egm96-15.pgm'; |
|
| 45 | + } |
|
| 43 | 46 | } |
| 44 | 47 | |
| 45 | 48 | $f = @fopen($name,"r"); |
@@ -156,7 +159,9 @@ discard block |
||
| 156 | 159 | } |
| 157 | 160 | } |
| 158 | 161 | $this->t = $t; |
| 159 | - } else $t = $this->t; |
|
| 162 | + } else { |
|
| 163 | + $t = $this->t; |
|
| 164 | + } |
|
| 160 | 165 | if (!($cubic)) { |
| 161 | 166 | $a = (((1 - $fx) * $this->v00) + ($fx * $this->v01)); |
| 162 | 167 | $b = (((1 - $fx) * $this->v10) + ($fx * $this->v11)); |
@@ -1033,8 +1033,11 @@ discard block |
||
| 1033 | 1033 | $data = file_get_contents($filename); |
| 1034 | 1034 | preg_match_all("/%%(.+?)%%/is", $data, $matches); |
| 1035 | 1035 | //print_r($matches); |
| 1036 | - if (isset($matches[1])) return $matches[1]; |
|
| 1037 | - else return array(); |
|
| 1036 | + if (isset($matches[1])) { |
|
| 1037 | + return $matches[1]; |
|
| 1038 | + } else { |
|
| 1039 | + return array(); |
|
| 1040 | + } |
|
| 1038 | 1041 | } |
| 1039 | 1042 | public function getAllNOTAMbyScope($scope) { |
| 1040 | 1043 | global $globalDBdriver; |
@@ -1071,7 +1074,9 @@ discard block |
||
| 1071 | 1074 | $minlong = $maxlong; |
| 1072 | 1075 | $maxlong = $tmplong; |
| 1073 | 1076 | } |
| 1074 | - } else return array(); |
|
| 1077 | + } else { |
|
| 1078 | + return array(); |
|
| 1079 | + } |
|
| 1075 | 1080 | if ($globalDBdriver == 'mysql') { |
| 1076 | 1081 | $query = 'SELECT * FROM notam WHERE center_latitude BETWEEN '.$minlat.' AND '.$maxlat.' AND center_longitude BETWEEN '.$minlong.' AND '.$maxlong.' AND radius > 0 AND date_end > UTC_TIMESTAMP() AND date_begin < UTC_TIMESTAMP()'; |
| 1077 | 1082 | } else { |
@@ -1095,7 +1100,9 @@ discard block |
||
| 1095 | 1100 | $minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
| 1096 | 1101 | $maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
| 1097 | 1102 | $maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
| 1098 | - } else return array(); |
|
| 1103 | + } else { |
|
| 1104 | + return array(); |
|
| 1105 | + } |
|
| 1099 | 1106 | if ($globalDBdriver == 'mysql') { |
| 1100 | 1107 | $query = 'SELECT * FROM notam WHERE center_latitude BETWEEN '.$minlat.' AND '.$maxlat.' AND center_longitude BETWEEN '.$minlong.' AND '.$maxlong.' AND radius > 0 AND date_end > UTC_TIMESTAMP() AND date_begin < UTC_TIMESTAMP() AND scope = :scope'; |
| 1101 | 1108 | } else { |
@@ -1122,8 +1129,11 @@ discard block |
||
| 1122 | 1129 | return "error : ".$e->getMessage(); |
| 1123 | 1130 | } |
| 1124 | 1131 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 1125 | - if (isset($all[0])) return $all[0]; |
|
| 1126 | - else return array(); |
|
| 1132 | + if (isset($all[0])) { |
|
| 1133 | + return $all[0]; |
|
| 1134 | + } else { |
|
| 1135 | + return array(); |
|
| 1136 | + } |
|
| 1127 | 1137 | } |
| 1128 | 1138 | |
| 1129 | 1139 | public function addNOTAM($ref,$title,$type,$fir,$code,$rules,$scope,$lower_limit,$upper_limit,$center_latitude,$center_longitude,$radius,$date_begin,$date_end,$permanent,$text,$full_notam) { |
@@ -1201,7 +1211,9 @@ discard block |
||
| 1201 | 1211 | foreach ($alldata as $initial_data) { |
| 1202 | 1212 | $data = $this->parse($initial_data); |
| 1203 | 1213 | $notamref = $this->getNOTAMbyRef($data['ref']); |
| 1204 | - if (count($notamref) == 0) $this->addNOTAM($data['ref'],$data['title'],'',$data['fir'],$data['code'],'',$data['scope'],$data['lower_limit'],$data['upper_limit'],$data['latitude'],$data['longitude'],$data['radius'],$data['date_begin'],$data['date_end'],$data['permanent'],$data['text'],$data['full_notam']); |
|
| 1214 | + if (count($notamref) == 0) { |
|
| 1215 | + $this->addNOTAM($data['ref'],$data['title'],'',$data['fir'],$data['code'],'',$data['scope'],$data['lower_limit'],$data['upper_limit'],$data['latitude'],$data['longitude'],$data['radius'],$data['date_begin'],$data['date_end'],$data['permanent'],$data['text'],$data['full_notam']); |
|
| 1216 | + } |
|
| 1205 | 1217 | } |
| 1206 | 1218 | } |
| 1207 | 1219 | } |
@@ -1214,7 +1226,9 @@ discard block |
||
| 1214 | 1226 | foreach ($alldata as $initial_data) { |
| 1215 | 1227 | $data = $this->parse($initial_data); |
| 1216 | 1228 | $notamref = $this->getNOTAMbyRef($data['ref']); |
| 1217 | - if (!isset($notamref['notam_id'])) $this->addNOTAM($data['ref'],$data['title'],'',$data['fir'],$data['code'],'',$data['scope'],$data['lower_limit'],$data['upper_limit'],$data['latitude'],$data['longitude'],$data['radius'],$data['date_begin'],$data['date_end'],$data['permanent'],$data['text'],$data['full_notam']); |
|
| 1229 | + if (!isset($notamref['notam_id'])) { |
|
| 1230 | + $this->addNOTAM($data['ref'],$data['title'],'',$data['fir'],$data['code'],'',$data['scope'],$data['lower_limit'],$data['upper_limit'],$data['latitude'],$data['longitude'],$data['radius'],$data['date_begin'],$data['date_end'],$data['permanent'],$data['text'],$data['full_notam']); |
|
| 1231 | + } |
|
| 1218 | 1232 | } |
| 1219 | 1233 | } |
| 1220 | 1234 | } |
@@ -1226,11 +1240,15 @@ discard block |
||
| 1226 | 1240 | foreach (array_chunk($allairports,20) as $airport) { |
| 1227 | 1241 | $airports_icao = array(); |
| 1228 | 1242 | foreach($airport as $icao) { |
| 1229 | - if (isset($icao['icao'])) $airports_icao[] = $icao['icao']; |
|
| 1243 | + if (isset($icao['icao'])) { |
|
| 1244 | + $airports_icao[] = $icao['icao']; |
|
| 1245 | + } |
|
| 1230 | 1246 | } |
| 1231 | 1247 | $airport_icao = implode(',',$airports_icao); |
| 1232 | 1248 | $alldata = $this->downloadNOTAM($airport_icao); |
| 1233 | - if ($globalTransaction) $this->db->beginTransaction(); |
|
| 1249 | + if ($globalTransaction) { |
|
| 1250 | + $this->db->beginTransaction(); |
|
| 1251 | + } |
|
| 1234 | 1252 | if (count($alldata) > 0) { |
| 1235 | 1253 | foreach ($alldata as $initial_data) { |
| 1236 | 1254 | //print_r($initial_data); |
@@ -1239,14 +1257,23 @@ discard block |
||
| 1239 | 1257 | if (isset($data['ref'])) { |
| 1240 | 1258 | $notamref = $this->getNOTAMbyRef($data['ref']); |
| 1241 | 1259 | if (count($notamref) == 0) { |
| 1242 | - if (isset($data['ref_replaced'])) $this->deleteNOTAMbyRef($data['ref_replaced']); |
|
| 1243 | - if (isset($data['ref_cancelled'])) $this->deleteNOTAMbyRef($data['ref_cancelled']); |
|
| 1244 | - elseif (isset($data['latitude']) && isset($data['scope']) && isset($data['text']) && isset($data['permanent'])) echo $this->addNOTAM($data['ref'],'','',$data['fir'],$data['code'],'',$data['scope'],$data['lower_limit'],$data['upper_limit'],$data['latitude'],$data['longitude'],$data['radius'],$data['date_begin'],$data['date_end'],$data['permanent'],$data['text'],$data['full_notam']); |
|
| 1260 | + if (isset($data['ref_replaced'])) { |
|
| 1261 | + $this->deleteNOTAMbyRef($data['ref_replaced']); |
|
| 1262 | + } |
|
| 1263 | + if (isset($data['ref_cancelled'])) { |
|
| 1264 | + $this->deleteNOTAMbyRef($data['ref_cancelled']); |
|
| 1265 | + } elseif (isset($data['latitude']) && isset($data['scope']) && isset($data['text']) && isset($data['permanent'])) { |
|
| 1266 | + echo $this->addNOTAM($data['ref'],'','',$data['fir'],$data['code'],'',$data['scope'],$data['lower_limit'],$data['upper_limit'],$data['latitude'],$data['longitude'],$data['radius'],$data['date_begin'],$data['date_end'],$data['permanent'],$data['text'],$data['full_notam']); |
|
| 1267 | + } |
|
| 1245 | 1268 | } |
| 1246 | 1269 | } |
| 1247 | 1270 | } |
| 1248 | - } else echo 'Error on download. Nothing matches for '.$airport_icao."\n"; |
|
| 1249 | - if ($globalTransaction) $this->db->commit(); |
|
| 1271 | + } else { |
|
| 1272 | + echo 'Error on download. Nothing matches for '.$airport_icao."\n"; |
|
| 1273 | + } |
|
| 1274 | + if ($globalTransaction) { |
|
| 1275 | + $this->db->commit(); |
|
| 1276 | + } |
|
| 1250 | 1277 | sleep(5); |
| 1251 | 1278 | } |
| 1252 | 1279 | } |
@@ -1259,8 +1286,11 @@ discard block |
||
| 1259 | 1286 | $data = $Common->getData($url); |
| 1260 | 1287 | preg_match_all("/<pre>(.+?)<\/pre>/is", $data, $matches); |
| 1261 | 1288 | //print_r($matches); |
| 1262 | - if (isset($matches[1])) return $matches[1]; |
|
| 1263 | - else return array(); |
|
| 1289 | + if (isset($matches[1])) { |
|
| 1290 | + return $matches[1]; |
|
| 1291 | + } else { |
|
| 1292 | + return array(); |
|
| 1293 | + } |
|
| 1264 | 1294 | } |
| 1265 | 1295 | |
| 1266 | 1296 | public function parse($data) { |
@@ -1294,99 +1324,156 @@ discard block |
||
| 1294 | 1324 | $rules = str_split($matches[3]); |
| 1295 | 1325 | foreach ($rules as $rule) { |
| 1296 | 1326 | if ($rule == 'I') { |
| 1297 | - if (isset($result['rules'])) $result['rules'] = $result['rules'].'/IFR'; |
|
| 1298 | - else $result['rules'] = 'IFR'; |
|
| 1327 | + if (isset($result['rules'])) { |
|
| 1328 | + $result['rules'] = $result['rules'].'/IFR'; |
|
| 1329 | + } else { |
|
| 1330 | + $result['rules'] = 'IFR'; |
|
| 1331 | + } |
|
| 1299 | 1332 | } elseif ($rule == 'V') { |
| 1300 | - if (isset($result['rules'])) $result['rules'] = $result['rules'].'/VFR'; |
|
| 1301 | - else $result['rules'] = 'VFR'; |
|
| 1333 | + if (isset($result['rules'])) { |
|
| 1334 | + $result['rules'] = $result['rules'].'/VFR'; |
|
| 1335 | + } else { |
|
| 1336 | + $result['rules'] = 'VFR'; |
|
| 1337 | + } |
|
| 1302 | 1338 | } elseif ($rule == 'K') { |
| 1303 | - if (isset($result['rules'])) $result['rules'] = $result['rules'].'/Checklist'; |
|
| 1304 | - else $result['rules'] = 'Checklist'; |
|
| 1339 | + if (isset($result['rules'])) { |
|
| 1340 | + $result['rules'] = $result['rules'].'/Checklist'; |
|
| 1341 | + } else { |
|
| 1342 | + $result['rules'] = 'Checklist'; |
|
| 1343 | + } |
|
| 1305 | 1344 | } |
| 1306 | 1345 | } |
| 1307 | 1346 | $attentions = str_split($matches[4]); |
| 1308 | 1347 | foreach ($attentions as $attention) { |
| 1309 | 1348 | if ($attention == 'N') { |
| 1310 | - if (isset($result['attention'])) $result['attention'] = $result['attention'].' / Immediate attention'; |
|
| 1311 | - else $result['rules'] = 'Immediate attention'; |
|
| 1349 | + if (isset($result['attention'])) { |
|
| 1350 | + $result['attention'] = $result['attention'].' / Immediate attention'; |
|
| 1351 | + } else { |
|
| 1352 | + $result['rules'] = 'Immediate attention'; |
|
| 1353 | + } |
|
| 1312 | 1354 | } elseif ($attention == 'B') { |
| 1313 | - if (isset($result['attention'])) $result['attention'] = $result['attention'].' / Operational significance'; |
|
| 1314 | - else $result['rules'] = 'Operational significance'; |
|
| 1355 | + if (isset($result['attention'])) { |
|
| 1356 | + $result['attention'] = $result['attention'].' / Operational significance'; |
|
| 1357 | + } else { |
|
| 1358 | + $result['rules'] = 'Operational significance'; |
|
| 1359 | + } |
|
| 1315 | 1360 | } elseif ($attention == 'O') { |
| 1316 | - if (isset($result['attention'])) $result['attention'] = $result['attention'].' / Flight operations'; |
|
| 1317 | - else $result['rules'] = 'Flight operations'; |
|
| 1361 | + if (isset($result['attention'])) { |
|
| 1362 | + $result['attention'] = $result['attention'].' / Flight operations'; |
|
| 1363 | + } else { |
|
| 1364 | + $result['rules'] = 'Flight operations'; |
|
| 1365 | + } |
|
| 1318 | 1366 | } elseif ($attention == 'M') { |
| 1319 | - if (isset($result['attention'])) $result['attention'] = $result['attention'].' / Misc'; |
|
| 1320 | - else $result['rules'] = 'Misc'; |
|
| 1367 | + if (isset($result['attention'])) { |
|
| 1368 | + $result['attention'] = $result['attention'].' / Misc'; |
|
| 1369 | + } else { |
|
| 1370 | + $result['rules'] = 'Misc'; |
|
| 1371 | + } |
|
| 1321 | 1372 | } elseif ($attention == 'K') { |
| 1322 | - if (isset($result['attention'])) $result['attention'] = $result['attention'].' / Checklist'; |
|
| 1323 | - else $result['rules'] = 'Checklist'; |
|
| 1373 | + if (isset($result['attention'])) { |
|
| 1374 | + $result['attention'] = $result['attention'].' / Checklist'; |
|
| 1375 | + } else { |
|
| 1376 | + $result['rules'] = 'Checklist'; |
|
| 1377 | + } |
|
| 1324 | 1378 | } |
| 1325 | 1379 | } |
| 1326 | - if ($matches[5] == 'A') $result['scope'] = 'Airport warning'; |
|
| 1327 | - elseif ($matches[5] == 'E') $result['scope'] = 'Enroute warning'; |
|
| 1328 | - elseif ($matches[5] == 'W') $result['scope'] = 'Navigation warning'; |
|
| 1329 | - elseif ($matches[5] == 'K') $result['scope'] = 'Checklist'; |
|
| 1330 | - elseif ($matches[5] == 'AE') $result['scope'] = 'Airport/Enroute warning'; |
|
| 1331 | - elseif ($matches[5] == 'AW') $result['scope'] = 'Airport/Navigation warning'; |
|
| 1380 | + if ($matches[5] == 'A') { |
|
| 1381 | + $result['scope'] = 'Airport warning'; |
|
| 1382 | + } elseif ($matches[5] == 'E') { |
|
| 1383 | + $result['scope'] = 'Enroute warning'; |
|
| 1384 | + } elseif ($matches[5] == 'W') { |
|
| 1385 | + $result['scope'] = 'Navigation warning'; |
|
| 1386 | + } elseif ($matches[5] == 'K') { |
|
| 1387 | + $result['scope'] = 'Checklist'; |
|
| 1388 | + } elseif ($matches[5] == 'AE') { |
|
| 1389 | + $result['scope'] = 'Airport/Enroute warning'; |
|
| 1390 | + } elseif ($matches[5] == 'AW') { |
|
| 1391 | + $result['scope'] = 'Airport/Navigation warning'; |
|
| 1392 | + } |
|
| 1332 | 1393 | $result['lower_limit'] = $matches[6]; |
| 1333 | 1394 | $result['upper_limit'] = $matches[7]; |
| 1334 | 1395 | $latitude = $Common->convertDec($matches[8],'latitude'); |
| 1335 | - if ($matches[9] == 'S') $latitude = -$latitude; |
|
| 1396 | + if ($matches[9] == 'S') { |
|
| 1397 | + $latitude = -$latitude; |
|
| 1398 | + } |
|
| 1336 | 1399 | $longitude = $Common->convertDec($matches[10],'longitude'); |
| 1337 | - if ($matches[11] == 'W') $longitude = -$longitude; |
|
| 1400 | + if ($matches[11] == 'W') { |
|
| 1401 | + $longitude = -$longitude; |
|
| 1402 | + } |
|
| 1338 | 1403 | $result['latitude'] = $latitude; |
| 1339 | 1404 | $result['longitude'] = $longitude; |
| 1340 | - if ($matches[12] != '') $result['radius'] = intval($matches[12]); |
|
| 1341 | - else $result['radius'] = 0; |
|
| 1405 | + if ($matches[12] != '') { |
|
| 1406 | + $result['radius'] = intval($matches[12]); |
|
| 1407 | + } else { |
|
| 1408 | + $result['radius'] = 0; |
|
| 1409 | + } |
|
| 1342 | 1410 | $q = true; |
| 1343 | 1411 | } elseif ($globalDebug) { |
| 1344 | 1412 | echo 'NOTAM error : '.$result['full_notam']."\n"; |
| 1345 | 1413 | echo "Can't parse : ".$line."\n"; |
| 1346 | 1414 | } |
| 1347 | - } |
|
| 1348 | - elseif (preg_match('#(^|\s)A\) (.*)#',$line,$matches) && $a === false) { |
|
| 1415 | + } elseif (preg_match('#(^|\s)A\) (.*)#',$line,$matches) && $a === false) { |
|
| 1349 | 1416 | $result['icao'] = $matches[2]; |
| 1350 | 1417 | $a = true; |
| 1351 | - } |
|
| 1352 | - elseif (preg_match('#(^|\s)B\) ([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})#',$line,$matches) && $b === false) { |
|
| 1353 | - if ($matches[1] > 50) $year = '19'.$matches[2]; |
|
| 1354 | - else $year = '20'.$matches[2]; |
|
| 1418 | + } elseif (preg_match('#(^|\s)B\) ([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})#',$line,$matches) && $b === false) { |
|
| 1419 | + if ($matches[1] > 50) { |
|
| 1420 | + $year = '19'.$matches[2]; |
|
| 1421 | + } else { |
|
| 1422 | + $year = '20'.$matches[2]; |
|
| 1423 | + } |
|
| 1355 | 1424 | $result['date_begin'] = $year.'/'.$matches[3].'/'.$matches[4].' '.$matches[5].':'.$matches[6]; |
| 1356 | 1425 | $b = true; |
| 1357 | - } |
|
| 1358 | - elseif (preg_match('#(^|\s)C\) ([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})$#',$line,$matches) && $c === false) { |
|
| 1359 | - if ($matches[2] > 50) $year = '19'.$matches[2]; |
|
| 1360 | - else $year = '20'.$matches[2]; |
|
| 1426 | + } elseif (preg_match('#(^|\s)C\) ([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})$#',$line,$matches) && $c === false) { |
|
| 1427 | + if ($matches[2] > 50) { |
|
| 1428 | + $year = '19'.$matches[2]; |
|
| 1429 | + } else { |
|
| 1430 | + $year = '20'.$matches[2]; |
|
| 1431 | + } |
|
| 1361 | 1432 | $result['date_end'] = $year.'/'.$matches[3].'/'.$matches[4].' '.$matches[5].':'.$matches[6]; |
| 1362 | 1433 | $result['permanent'] = 0; |
| 1363 | 1434 | $c = true; |
| 1364 | - } |
|
| 1365 | - elseif (preg_match('#(^|\s)C\) ([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2}) (EST|PERM)$#',$line,$matches) && $c === false) { |
|
| 1366 | - if ($matches[2] > 50) $year = '19'.$matches[2]; |
|
| 1367 | - else $year = '20'.$matches[2]; |
|
| 1435 | + } elseif (preg_match('#(^|\s)C\) ([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2}) (EST|PERM)$#',$line,$matches) && $c === false) { |
|
| 1436 | + if ($matches[2] > 50) { |
|
| 1437 | + $year = '19'.$matches[2]; |
|
| 1438 | + } else { |
|
| 1439 | + $year = '20'.$matches[2]; |
|
| 1440 | + } |
|
| 1368 | 1441 | $result['date_end'] = $year.'/'.$matches[3].'/'.$matches[4].' '.$matches[5].':'.$matches[6]; |
| 1369 | - if ($matches[7] == 'EST') $result['estimated'] = 1; |
|
| 1370 | - else $result['estimated'] = 0; |
|
| 1371 | - if ($matches[7] == 'PERM') $result['permanent'] = 1; |
|
| 1372 | - else $result['permanent'] = 0; |
|
| 1442 | + if ($matches[7] == 'EST') { |
|
| 1443 | + $result['estimated'] = 1; |
|
| 1444 | + } else { |
|
| 1445 | + $result['estimated'] = 0; |
|
| 1446 | + } |
|
| 1447 | + if ($matches[7] == 'PERM') { |
|
| 1448 | + $result['permanent'] = 1; |
|
| 1449 | + } else { |
|
| 1450 | + $result['permanent'] = 0; |
|
| 1451 | + } |
|
| 1373 | 1452 | $c = true; |
| 1374 | - } |
|
| 1375 | - elseif (preg_match('#(^|\s)C\) (EST|PERM)$#',$line,$matches) && $c === false) { |
|
| 1453 | + } elseif (preg_match('#(^|\s)C\) (EST|PERM)$#',$line,$matches) && $c === false) { |
|
| 1376 | 1454 | $result['date_end'] = '2030/12/20 12:00'; |
| 1377 | - if ($matches[2] == 'EST') $result['estimated'] = 1; |
|
| 1378 | - else $result['estimated'] = 0; |
|
| 1379 | - if ($matches[2] == 'PERM') $result['permanent'] = 1; |
|
| 1380 | - else $result['permanent'] = 0; |
|
| 1455 | + if ($matches[2] == 'EST') { |
|
| 1456 | + $result['estimated'] = 1; |
|
| 1457 | + } else { |
|
| 1458 | + $result['estimated'] = 0; |
|
| 1459 | + } |
|
| 1460 | + if ($matches[2] == 'PERM') { |
|
| 1461 | + $result['permanent'] = 1; |
|
| 1462 | + } else { |
|
| 1463 | + $result['permanent'] = 0; |
|
| 1464 | + } |
|
| 1381 | 1465 | $c = true; |
| 1382 | - } |
|
| 1383 | - elseif (preg_match('#(^|\s)E\) (.*)#',$line,$matches) && $e === false) { |
|
| 1466 | + } elseif (preg_match('#(^|\s)E\) (.*)#',$line,$matches) && $e === false) { |
|
| 1384 | 1467 | $rtext = array(); |
| 1385 | 1468 | $text = explode(' ',$matches[2]); |
| 1386 | 1469 | foreach ($text as $word) { |
| 1387 | - if (isset($this->abbr[$word])) $rtext[] = strtoupper($this->abbr[$word]); |
|
| 1388 | - elseif (ctype_digit(strval(substr($word,3))) && isset($this->abbr[substr($word,0,3)])) $rtext[] = strtoupper($this->abbr[substr($word,0,3)]).' '.substr($word,3); |
|
| 1389 | - else $rtext[] = $word; |
|
| 1470 | + if (isset($this->abbr[$word])) { |
|
| 1471 | + $rtext[] = strtoupper($this->abbr[$word]); |
|
| 1472 | + } elseif (ctype_digit(strval(substr($word,3))) && isset($this->abbr[substr($word,0,3)])) { |
|
| 1473 | + $rtext[] = strtoupper($this->abbr[substr($word,0,3)]).' '.substr($word,3); |
|
| 1474 | + } else { |
|
| 1475 | + $rtext[] = $word; |
|
| 1476 | + } |
|
| 1390 | 1477 | } |
| 1391 | 1478 | $result['text'] = implode(' ',$rtext); |
| 1392 | 1479 | $e = true; |
@@ -1395,7 +1482,9 @@ discard block |
||
| 1395 | 1482 | } elseif (preg_match('#(NOTAMN|NOTAMR|NOTAMC)#',$line,$matches)) { |
| 1396 | 1483 | $text = explode(' ',$line); |
| 1397 | 1484 | $result['ref'] = $text[0]; |
| 1398 | - if ($matches[1] == 'NOTAMN') $result['type'] = 'new'; |
|
| 1485 | + if ($matches[1] == 'NOTAMN') { |
|
| 1486 | + $result['type'] = 'new'; |
|
| 1487 | + } |
|
| 1399 | 1488 | if ($matches[1] == 'NOTAMC') { |
| 1400 | 1489 | $result['type'] = 'cancel'; |
| 1401 | 1490 | $result['ref_cancelled'] = $text[2]; |
@@ -1417,69 +1506,101 @@ discard block |
||
| 1417 | 1506 | switch ($code[1]) { |
| 1418 | 1507 | case 'A': |
| 1419 | 1508 | $result = 'Airspace organization '; |
| 1420 | - if (isset($this->code_airspace[$code_fp])) $result .= $this->code_airspace[$code_fp]; |
|
| 1509 | + if (isset($this->code_airspace[$code_fp])) { |
|
| 1510 | + $result .= $this->code_airspace[$code_fp]; |
|
| 1511 | + } |
|
| 1421 | 1512 | break; |
| 1422 | 1513 | case 'C': |
| 1423 | 1514 | $result = 'Communications and radar facilities '; |
| 1424 | - if (isset($this->code_comradar[$code_fp])) $result .= $this->code_comradar[$code_fp]; |
|
| 1515 | + if (isset($this->code_comradar[$code_fp])) { |
|
| 1516 | + $result .= $this->code_comradar[$code_fp]; |
|
| 1517 | + } |
|
| 1425 | 1518 | break; |
| 1426 | 1519 | case 'F': |
| 1427 | 1520 | $result = 'Facilities and services '; |
| 1428 | - if (isset($this->code_facilities[$code_fp])) $result .= $this->code_facilities[$code_fp]; |
|
| 1521 | + if (isset($this->code_facilities[$code_fp])) { |
|
| 1522 | + $result .= $this->code_facilities[$code_fp]; |
|
| 1523 | + } |
|
| 1429 | 1524 | break; |
| 1430 | 1525 | case 'I': |
| 1431 | 1526 | $result = 'Instrument and Microwave Landing System '; |
| 1432 | - if (isset($this->code_instrumentlanding[$code_fp])) $result .= $this->code_instrumentlanding[$code_fp]; |
|
| 1527 | + if (isset($this->code_instrumentlanding[$code_fp])) { |
|
| 1528 | + $result .= $this->code_instrumentlanding[$code_fp]; |
|
| 1529 | + } |
|
| 1433 | 1530 | break; |
| 1434 | 1531 | case 'L': |
| 1435 | 1532 | $result = 'Lighting facilities '; |
| 1436 | - if (isset($this->code_lightingfacilities[$code_fp])) $result .= $this->code_lightingfacilities[$code_fp]; |
|
| 1533 | + if (isset($this->code_lightingfacilities[$code_fp])) { |
|
| 1534 | + $result .= $this->code_lightingfacilities[$code_fp]; |
|
| 1535 | + } |
|
| 1437 | 1536 | break; |
| 1438 | 1537 | case 'M': |
| 1439 | 1538 | $result = 'Movement and landing areas '; |
| 1440 | - if (isset($this->code_movementareas[$code_fp])) $result .= $this->code_movementareas[$code_fp]; |
|
| 1539 | + if (isset($this->code_movementareas[$code_fp])) { |
|
| 1540 | + $result .= $this->code_movementareas[$code_fp]; |
|
| 1541 | + } |
|
| 1441 | 1542 | break; |
| 1442 | 1543 | case 'N': |
| 1443 | 1544 | $result = 'Terminal and En Route Navigation Facilities '; |
| 1444 | - if (isset($this->code_terminalfacilities[$code_fp])) $result .= $this->code_terminalfacilities[$code_fp]; |
|
| 1545 | + if (isset($this->code_terminalfacilities[$code_fp])) { |
|
| 1546 | + $result .= $this->code_terminalfacilities[$code_fp]; |
|
| 1547 | + } |
|
| 1445 | 1548 | break; |
| 1446 | 1549 | case 'O': |
| 1447 | 1550 | $result = 'Other information '; |
| 1448 | - if (isset($this->code_information[$code_fp])) $result .= $this->code_information[$code_fp]; |
|
| 1551 | + if (isset($this->code_information[$code_fp])) { |
|
| 1552 | + $result .= $this->code_information[$code_fp]; |
|
| 1553 | + } |
|
| 1449 | 1554 | break; |
| 1450 | 1555 | case 'P': |
| 1451 | 1556 | $result = 'Air Traffic procedures '; |
| 1452 | - if (isset($this->code_airtraffic[$code_fp])) $result .= $this->code_airtraffic[$code_fp]; |
|
| 1557 | + if (isset($this->code_airtraffic[$code_fp])) { |
|
| 1558 | + $result .= $this->code_airtraffic[$code_fp]; |
|
| 1559 | + } |
|
| 1453 | 1560 | break; |
| 1454 | 1561 | case 'R': |
| 1455 | 1562 | $result = 'Navigation Warnings: Airspace Restrictions '; |
| 1456 | - if (isset($this->code_navigationw[$code_fp])) $result .= $this->code_navigationw[$code_fp]; |
|
| 1563 | + if (isset($this->code_navigationw[$code_fp])) { |
|
| 1564 | + $result .= $this->code_navigationw[$code_fp]; |
|
| 1565 | + } |
|
| 1457 | 1566 | break; |
| 1458 | 1567 | case 'S': |
| 1459 | 1568 | $result = 'Air Traffic and VOLMET Services '; |
| 1460 | - if (isset($this->code_volmet[$code_fp])) $result .= $this->code_volmet[$code_fp]; |
|
| 1569 | + if (isset($this->code_volmet[$code_fp])) { |
|
| 1570 | + $result .= $this->code_volmet[$code_fp]; |
|
| 1571 | + } |
|
| 1461 | 1572 | break; |
| 1462 | 1573 | case 'W': |
| 1463 | 1574 | $result = 'Navigation Warnings: Warnings '; |
| 1464 | - if (isset($this->code_warnings[$code_fp])) $result .= $this->code_warnings[$code_fp]; |
|
| 1575 | + if (isset($this->code_warnings[$code_fp])) { |
|
| 1576 | + $result .= $this->code_warnings[$code_fp]; |
|
| 1577 | + } |
|
| 1465 | 1578 | break; |
| 1466 | 1579 | } |
| 1467 | 1580 | switch ($code[3]) { |
| 1468 | 1581 | case 'A': |
| 1469 | 1582 | // Availability |
| 1470 | - if (isset($this->code_sp_availabity[$code_sp])) $result .= ' '.$this->code_sp_availabity[$code_sp]; |
|
| 1583 | + if (isset($this->code_sp_availabity[$code_sp])) { |
|
| 1584 | + $result .= ' '.$this->code_sp_availabity[$code_sp]; |
|
| 1585 | + } |
|
| 1471 | 1586 | break; |
| 1472 | 1587 | case 'C': |
| 1473 | 1588 | // Changes |
| 1474 | - if (isset($this->code_sp_changes[$code_sp])) $result .= ' '.$this->code_sp_changes[$code_sp]; |
|
| 1589 | + if (isset($this->code_sp_changes[$code_sp])) { |
|
| 1590 | + $result .= ' '.$this->code_sp_changes[$code_sp]; |
|
| 1591 | + } |
|
| 1475 | 1592 | break; |
| 1476 | 1593 | case 'H': |
| 1477 | 1594 | // Hazardous conditions |
| 1478 | - if (isset($this->code_sp_hazardous[$code_sp])) $result .= ' '.$this->code_sp_hazardous[$code_sp]; |
|
| 1595 | + if (isset($this->code_sp_hazardous[$code_sp])) { |
|
| 1596 | + $result .= ' '.$this->code_sp_hazardous[$code_sp]; |
|
| 1597 | + } |
|
| 1479 | 1598 | break; |
| 1480 | 1599 | case 'L': |
| 1481 | 1600 | // Limitations |
| 1482 | - if (isset($this->code_sp_limitations[$code_sp])) $result .= ' '.$this->code_sp_limitations[$code_sp]; |
|
| 1601 | + if (isset($this->code_sp_limitations[$code_sp])) { |
|
| 1602 | + $result .= ' '.$this->code_sp_limitations[$code_sp]; |
|
| 1603 | + } |
|
| 1483 | 1604 | break; |
| 1484 | 1605 | case 'X': |
| 1485 | 1606 | // Other Information |
@@ -27,15 +27,21 @@ discard block |
||
| 27 | 27 | } |
| 28 | 28 | } |
| 29 | 29 | } |
| 30 | -if ($authorize === false) die; |
|
| 30 | +if ($authorize === false) { |
|
| 31 | + die; |
|
| 32 | +} |
|
| 31 | 33 | |
| 32 | -if (isset($globalTracker) && $globalTracker) require_once(dirname(__FILE__).'/../require/class.TrackerImport.php'); |
|
| 34 | +if (isset($globalTracker) && $globalTracker) { |
|
| 35 | + require_once(dirname(__FILE__).'/../require/class.TrackerImport.php'); |
|
| 36 | +} |
|
| 33 | 37 | if (isset($globalMarine) && $globalMarine) { |
| 34 | 38 | require_once(dirname(__FILE__).'/../require/class.AIS.php'); |
| 35 | 39 | require_once(dirname(__FILE__).'/../require/class.MarineImport.php'); |
| 36 | 40 | } |
| 37 | 41 | |
| 38 | -if (!isset($globalDebug)) $globalDebug = FALSE; |
|
| 42 | +if (!isset($globalDebug)) { |
|
| 43 | + $globalDebug = FALSE; |
|
| 44 | +} |
|
| 39 | 45 | |
| 40 | 46 | // Check if schema is at latest version |
| 41 | 47 | $Connection = new Connection(); |
@@ -45,10 +51,16 @@ discard block |
||
| 45 | 51 | } |
| 46 | 52 | |
| 47 | 53 | if (isset($globalServer) && $globalServer) { |
| 48 | - if ($globalDebug) echo "Using Server Mode\n"; |
|
| 54 | + if ($globalDebug) { |
|
| 55 | + echo "Using Server Mode\n"; |
|
| 56 | + } |
|
| 49 | 57 | $SI=new SpotterServer(); |
| 50 | -} else $SI=new SpotterImport($Connection->db); |
|
| 51 | -if (isset($globalTracker) && $globalTracker) $TI = new TrackerImport($Connection->db); |
|
| 58 | +} else { |
|
| 59 | + $SI=new SpotterImport($Connection->db); |
|
| 60 | +} |
|
| 61 | +if (isset($globalTracker) && $globalTracker) { |
|
| 62 | + $TI = new TrackerImport($Connection->db); |
|
| 63 | +} |
|
| 52 | 64 | if (isset($globalMarine) && $globalMarine) { |
| 53 | 65 | $AIS = new AIS(); |
| 54 | 66 | $MI = new MarineImport($Connection->db); |
@@ -57,7 +69,9 @@ discard block |
||
| 57 | 69 | date_default_timezone_set('UTC'); |
| 58 | 70 | |
| 59 | 71 | $buffer = ''; |
| 60 | -if (isset($_POST)) $buffer = $_POST; |
|
| 72 | +if (isset($_POST)) { |
|
| 73 | + $buffer = $_POST; |
|
| 74 | +} |
|
| 61 | 75 | $data = array(); |
| 62 | 76 | if (isset($buffer['type_event']) && isset($buffer['lat']) && isset($buffer['lon'])) { |
| 63 | 77 | $data['ident'] = $buffer['device_id']; |
@@ -68,15 +82,27 @@ discard block |
||
| 68 | 82 | //$data['heading'] = $buffer['cap']; // Only N/S/E/W |
| 69 | 83 | $data['datetime'] = date('Y-m-d H:i:s',$buffer['timestamp']); |
| 70 | 84 | $data['comment'] = ''; |
| 71 | - if (isset($buffer['battery']) && $buffer['battery'] != '') $data['comment'] .= 'Battery: '.$buffer['battery'].'% '; |
|
| 85 | + if (isset($buffer['battery']) && $buffer['battery'] != '') { |
|
| 86 | + $data['comment'] .= 'Battery: '.$buffer['battery'].'% '; |
|
| 87 | + } |
|
| 72 | 88 | //if (isset($buffer['snr']) && $buffer['snr'] != '') $data['comment'] .= 'SNR: '.$buffer['snr'].' '; |
| 73 | - if (isset($buffer['temp']) && $buffer['temp'] != '') $data['comment'] .= 'Temperature: '.$buffer['temp'].'°C '; |
|
| 74 | - if (isset($buffer['press']) && $buffer['press'] != '') $data['comment'] .= 'Pressure: '.$buffer['press'].'hPa '; |
|
| 89 | + if (isset($buffer['temp']) && $buffer['temp'] != '') { |
|
| 90 | + $data['comment'] .= 'Temperature: '.$buffer['temp'].'°C '; |
|
| 91 | + } |
|
| 92 | + if (isset($buffer['press']) && $buffer['press'] != '') { |
|
| 93 | + $data['comment'] .= 'Pressure: '.$buffer['press'].'hPa '; |
|
| 94 | + } |
|
| 75 | 95 | $TI->add($data); |
| 76 | 96 | unset($data); |
| 77 | 97 | } |
| 78 | -if (isset($SI)) $SI->checkAll(); |
|
| 79 | -if (isset($MI)) $MI->checkAll(); |
|
| 80 | -if (isset($TI)) $TI->checkAll(); |
|
| 98 | +if (isset($SI)) { |
|
| 99 | + $SI->checkAll(); |
|
| 100 | +} |
|
| 101 | +if (isset($MI)) { |
|
| 102 | + $MI->checkAll(); |
|
| 103 | +} |
|
| 104 | +if (isset($TI)) { |
|
| 105 | + $TI->checkAll(); |
|
| 106 | +} |
|
| 81 | 107 | |
| 82 | 108 | ?> |