@@ -88,7 +88,9 @@ discard block |
||
88 | 88 | } |
89 | 89 | |
90 | 90 | public function addLocation($name,$latitude,$longitude,$altitude,$city,$country,$source,$logo = 'antenna.png',$type = '',$source_id = 0,$location_id = 0,$last_seen = '', $description = '') { |
91 | - if ($last_seen == '') $last_seen = date('Y-m-d H:i:s'); |
|
91 | + if ($last_seen == '') { |
|
92 | + $last_seen = date('Y-m-d H:i:s'); |
|
93 | + } |
|
92 | 94 | $query = "INSERT INTO source_location (name,latitude,longitude,altitude,country,city,logo,source,type,source_id,last_seen,location_id,description) VALUES (:name,:latitude,:longitude,:altitude,:country,:city,:logo,:source,:type,:source_id,:last_seen,:location_id,:description)"; |
93 | 95 | $query_values = array(':name' => $name,':latitude' => $latitude, ':longitude' => $longitude,':altitude' => $altitude,':city' => $city,':country' => $country,':logo' => $logo,':source' => $source,':type' => $type,':source_id' => $source_id,':last_seen' => $last_seen,':location_id' => $location_id,':description' => $description); |
94 | 96 | try { |
@@ -100,7 +102,9 @@ discard block |
||
100 | 102 | } |
101 | 103 | |
102 | 104 | public function updateLocation($name,$latitude,$longitude,$altitude,$city,$country,$source,$logo = 'antenna.png',$type = '',$source_id = 0,$location_id = 0,$last_seen = '',$description = '') { |
103 | - if ($last_seen == '') $last_seen = date('Y-m-d H:i:s'); |
|
105 | + if ($last_seen == '') { |
|
106 | + $last_seen = date('Y-m-d H:i:s'); |
|
107 | + } |
|
104 | 108 | $query = "UPDATE source_location SET latitude = :latitude,longitude = :longitude,altitude = :altitude,country = :country,city = :city,logo = :logo,type = :type, source_id = :source_id, last_seen = :last_seen,location_id = :location_id, description = :description WHERE name = :name AND source = :source"; |
105 | 109 | $query_values = array(':name' => $name,':latitude' => $latitude, ':longitude' => $longitude,':altitude' => $altitude,':city' => $city,':country' => $country,':logo' => $logo,':source' => $source,':type' => $type,':source_id' => $source_id,':last_seen' => $last_seen,':location_id' => $location_id,':description' => $description); |
106 | 110 | try { |
@@ -123,7 +127,9 @@ discard block |
||
123 | 127 | } |
124 | 128 | |
125 | 129 | public function updateLocationByLocationID($name,$latitude,$longitude,$altitude,$city,$country,$source,$logo = 'antenna.png',$type = '',$source_id = 0, $location_id,$last_seen = '',$description = '') { |
126 | - if ($last_seen == '') $last_seen = date('Y-m-d H:i:s'); |
|
130 | + if ($last_seen == '') { |
|
131 | + $last_seen = date('Y-m-d H:i:s'); |
|
132 | + } |
|
127 | 133 | $query = "UPDATE source_location SET latitude = :latitude,longitude = :longitude,altitude = :altitude,country = :country,city = :city,logo = :logo,type = :type, last_seen = :last_seen, description = :description WHERE location_id = :location_id AND source = :source AND source_id = :source_id"; |
128 | 134 | $query_values = array(':source_id' => $source_id,':latitude' => $latitude, ':longitude' => $longitude,':altitude' => $altitude,':city' => $city,':country' => $country,':logo' => $logo,':source' => $source,':type' => $type,':last_seen' => $last_seen,':location_id' => $location_id,':description' => $description); |
129 | 135 | try { |
@@ -29,7 +29,9 @@ discard block |
||
29 | 29 | if (isset($filter[0]['source'])) { |
30 | 30 | $filters = array_merge($filters,$filter); |
31 | 31 | } |
32 | - if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter); |
|
32 | + if (is_array($globalFilter)) { |
|
33 | + $filter = array_merge($filter,$globalFilter); |
|
34 | + } |
|
33 | 35 | $filter_query_join = ''; |
34 | 36 | $filter_query_where = ''; |
35 | 37 | foreach($filters as $flt) { |
@@ -118,8 +120,11 @@ discard block |
||
118 | 120 | if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
119 | 121 | $filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
120 | 122 | } |
121 | - if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE'; |
|
122 | - elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND'; |
|
123 | + if ($filter_query_where == '' && $where) { |
|
124 | + $filter_query_where = ' WHERE'; |
|
125 | + } elseif ($filter_query_where != '' && $and) { |
|
126 | + $filter_query_where .= ' AND'; |
|
127 | + } |
|
123 | 128 | if ($filter_query_where != '') { |
124 | 129 | $filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where); |
125 | 130 | } |
@@ -160,9 +165,13 @@ discard block |
||
160 | 165 | $orderby_query = ' '.$search_orderby_array[$sort]['sql']; |
161 | 166 | } |
162 | 167 | } |
163 | - if ($orderby_query == '') $orderby_query = ' ORDER BY date DESC'; |
|
168 | + if ($orderby_query == '') { |
|
169 | + $orderby_query = ' ORDER BY date DESC'; |
|
170 | + } |
|
164 | 171 | |
165 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
172 | + if (!isset($globalLiveInterval)) { |
|
173 | + $globalLiveInterval = '200'; |
|
174 | + } |
|
166 | 175 | if ($globalDBdriver == 'mysql') { |
167 | 176 | //$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"; |
168 | 177 | $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; |
@@ -185,7 +194,9 @@ discard block |
||
185 | 194 | global $globalDBdriver, $globalLiveInterval, $globalArchive; |
186 | 195 | date_default_timezone_set('UTC'); |
187 | 196 | $filter_query = $this->getFilter($filter,true,true); |
188 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
197 | + if (!isset($globalLiveInterval)) { |
|
198 | + $globalLiveInterval = '200'; |
|
199 | + } |
|
189 | 200 | if ($globalDBdriver == 'mysql') { |
190 | 201 | if (isset($globalArchive) && $globalArchive === TRUE) { |
191 | 202 | $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 |
@@ -228,7 +239,9 @@ discard block |
||
228 | 239 | |
229 | 240 | $filter_query = $this->getFilter($filter,true,true); |
230 | 241 | |
231 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
242 | + if (!isset($globalLiveInterval)) { |
|
243 | + $globalLiveInterval = '200'; |
|
244 | + } |
|
232 | 245 | if ($globalDBdriver == 'mysql') { |
233 | 246 | if (isset($globalArchive) && $globalArchive === TRUE) { |
234 | 247 | /* |
@@ -296,7 +309,9 @@ discard block |
||
296 | 309 | global $globalDBdriver, $globalLiveInterval; |
297 | 310 | $filter_query = $this->getFilter($filter,true,true); |
298 | 311 | |
299 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
312 | + if (!isset($globalLiveInterval)) { |
|
313 | + $globalLiveInterval = '200'; |
|
314 | + } |
|
300 | 315 | if ($globalDBdriver == 'mysql') { |
301 | 316 | //$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; |
302 | 317 | $query = 'SELECT COUNT(DISTINCT spotter_live.flightaware_id) as nb FROM spotter_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date'; |
@@ -326,7 +341,9 @@ discard block |
||
326 | 341 | { |
327 | 342 | global $globalDBdriver, $globalLiveInterval; |
328 | 343 | $Spotter = new Spotter($this->db); |
329 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
344 | + if (!isset($globalLiveInterval)) { |
|
345 | + $globalLiveInterval = '200'; |
|
346 | + } |
|
330 | 347 | $filter_query = $this->getFilter($filter); |
331 | 348 | |
332 | 349 | if (is_array($coord)) { |
@@ -334,7 +351,9 @@ discard block |
||
334 | 351 | $minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
335 | 352 | $maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
336 | 353 | $maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
337 | - } else return array(); |
|
354 | + } else { |
|
355 | + return array(); |
|
356 | + } |
|
338 | 357 | if ($globalDBdriver == 'mysql') { |
339 | 358 | $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; |
340 | 359 | } else { |
@@ -355,7 +374,9 @@ discard block |
||
355 | 374 | { |
356 | 375 | global $globalDBdriver, $globalLiveInterval, $globalArchive; |
357 | 376 | $Spotter = new Spotter($this->db); |
358 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
377 | + if (!isset($globalLiveInterval)) { |
|
378 | + $globalLiveInterval = '200'; |
|
379 | + } |
|
359 | 380 | $filter_query = $this->getFilter($filter,true,true); |
360 | 381 | |
361 | 382 | if (is_array($coord)) { |
@@ -363,7 +384,9 @@ discard block |
||
363 | 384 | $minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
364 | 385 | $maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
365 | 386 | $maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
366 | - } else return array(); |
|
387 | + } else { |
|
388 | + return array(); |
|
389 | + } |
|
367 | 390 | if ($globalDBdriver == 'mysql') { |
368 | 391 | if (isset($globalArchive) && $globalArchive === TRUE) { |
369 | 392 | $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 |
@@ -593,11 +616,15 @@ discard block |
||
593 | 616 | //$query = self::$global_query.' WHERE spotter_live.flightaware_id = :id ORDER BY date'; |
594 | 617 | if ($globalDBdriver == 'mysql') { |
595 | 618 | $query = 'SELECT spotter_live.* FROM spotter_live WHERE spotter_live.flightaware_id = :id'; |
596 | - if ($liveinterval) $query .= ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date'; |
|
619 | + if ($liveinterval) { |
|
620 | + $query .= ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date'; |
|
621 | + } |
|
597 | 622 | $query .= ' ORDER BY date'; |
598 | 623 | } else { |
599 | 624 | $query = 'SELECT spotter_live.* FROM spotter_live WHERE spotter_live.flightaware_id = :id'; |
600 | - if ($liveinterval) $query .= " AND CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= date"; |
|
625 | + if ($liveinterval) { |
|
626 | + $query .= " AND CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= date"; |
|
627 | + } |
|
601 | 628 | $query .= ' ORDER BY date'; |
602 | 629 | } |
603 | 630 | |
@@ -692,7 +719,9 @@ discard block |
||
692 | 719 | $i++; |
693 | 720 | $j++; |
694 | 721 | if ($j == 30) { |
695 | - if ($globalDebug) echo "."; |
|
722 | + if ($globalDebug) { |
|
723 | + echo "."; |
|
724 | + } |
|
696 | 725 | try { |
697 | 726 | |
698 | 727 | $sth = $this->db->prepare(substr($query_delete,0,-1).")"); |
@@ -999,7 +1028,9 @@ discard block |
||
999 | 1028 | { |
1000 | 1029 | return false; |
1001 | 1030 | } |
1002 | - } else return ''; |
|
1031 | + } else { |
|
1032 | + return ''; |
|
1033 | + } |
|
1003 | 1034 | |
1004 | 1035 | if ($longitude != '') |
1005 | 1036 | { |
@@ -1007,7 +1038,9 @@ discard block |
||
1007 | 1038 | { |
1008 | 1039 | return false; |
1009 | 1040 | } |
1010 | - } else return ''; |
|
1041 | + } else { |
|
1042 | + return ''; |
|
1043 | + } |
|
1011 | 1044 | |
1012 | 1045 | if ($waypoints != '') |
1013 | 1046 | { |
@@ -1023,14 +1056,18 @@ discard block |
||
1023 | 1056 | { |
1024 | 1057 | return false; |
1025 | 1058 | } |
1026 | - } else $altitude = 0; |
|
1059 | + } else { |
|
1060 | + $altitude = 0; |
|
1061 | + } |
|
1027 | 1062 | if ($altitude_real != '') |
1028 | 1063 | { |
1029 | 1064 | if (!is_numeric($altitude_real)) |
1030 | 1065 | { |
1031 | 1066 | return false; |
1032 | 1067 | } |
1033 | - } else $altitude_real = 0; |
|
1068 | + } else { |
|
1069 | + $altitude_real = 0; |
|
1070 | + } |
|
1034 | 1071 | |
1035 | 1072 | if ($heading != '') |
1036 | 1073 | { |
@@ -1038,7 +1075,9 @@ discard block |
||
1038 | 1075 | { |
1039 | 1076 | return false; |
1040 | 1077 | } |
1041 | - } else $heading = 0; |
|
1078 | + } else { |
|
1079 | + $heading = 0; |
|
1080 | + } |
|
1042 | 1081 | |
1043 | 1082 | if ($groundspeed != '') |
1044 | 1083 | { |
@@ -1046,9 +1085,13 @@ discard block |
||
1046 | 1085 | { |
1047 | 1086 | return false; |
1048 | 1087 | } |
1049 | - } else $groundspeed = 0; |
|
1088 | + } else { |
|
1089 | + $groundspeed = 0; |
|
1090 | + } |
|
1050 | 1091 | date_default_timezone_set('UTC'); |
1051 | - if ($date == '') $date = date("Y-m-d H:i:s", time()); |
|
1092 | + if ($date == '') { |
|
1093 | + $date = date("Y-m-d H:i:s", time()); |
|
1094 | + } |
|
1052 | 1095 | |
1053 | 1096 | |
1054 | 1097 | $flightaware_id = filter_var($flightaware_id,FILTER_SANITIZE_STRING); |
@@ -1093,14 +1136,24 @@ discard block |
||
1093 | 1136 | $arrival_airport_country = ''; |
1094 | 1137 | |
1095 | 1138 | |
1096 | - if ($squawk == '' || $Common->isInteger($squawk) === false ) $squawk = NULL; |
|
1097 | - if ($verticalrate == '' || $Common->isInteger($verticalrate) === false ) $verticalrate = NULL; |
|
1098 | - if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0; |
|
1099 | - if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0; |
|
1139 | + if ($squawk == '' || $Common->isInteger($squawk) === false ) { |
|
1140 | + $squawk = NULL; |
|
1141 | + } |
|
1142 | + if ($verticalrate == '' || $Common->isInteger($verticalrate) === false ) { |
|
1143 | + $verticalrate = NULL; |
|
1144 | + } |
|
1145 | + if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) { |
|
1146 | + $groundspeed = 0; |
|
1147 | + } |
|
1148 | + if ($heading == '' || $Common->isInteger($heading) === false ) { |
|
1149 | + $heading = 0; |
|
1150 | + } |
|
1100 | 1151 | |
1101 | 1152 | $query = ''; |
1102 | 1153 | if ($globalArchive) { |
1103 | - if ($globalDebug) echo '-- Delete previous data -- '; |
|
1154 | + if ($globalDebug) { |
|
1155 | + echo '-- Delete previous data -- '; |
|
1156 | + } |
|
1104 | 1157 | $query .= 'DELETE FROM spotter_live WHERE flightaware_id = :flightaware_id;'; |
1105 | 1158 | } |
1106 | 1159 | |
@@ -1117,10 +1170,14 @@ discard block |
||
1117 | 1170 | return "error : ".$e->getMessage(); |
1118 | 1171 | } |
1119 | 1172 | if (isset($globalArchive) && $globalArchive && $putinarchive && $noarchive !== true) { |
1120 | - if ($globalDebug) echo '(Add to SBS archive : '; |
|
1173 | + if ($globalDebug) { |
|
1174 | + echo '(Add to SBS archive : '; |
|
1175 | + } |
|
1121 | 1176 | $SpotterArchive = new SpotterArchive($this->db); |
1122 | 1177 | $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); |
1123 | - if ($globalDebug) echo $result.')'; |
|
1178 | + if ($globalDebug) { |
|
1179 | + echo $result.')'; |
|
1180 | + } |
|
1124 | 1181 | } elseif ($globalDebug && $putinarchive !== true) { |
1125 | 1182 | echo '(Not adding to archive)'; |
1126 | 1183 | } elseif ($globalDebug && $noarchive === true) { |
@@ -30,8 +30,12 @@ discard block |
||
30 | 30 | //$end_date = date("Y-m-d H:i:s", strtotime("2014-04-12")).",".$_GET['end_date']." 00:00:00"; |
31 | 31 | $end_date = date("Y-m-d H:i:s", strtotime("2014-04-12")).",".date("Y-m-d",strtotime($_GET['end_date']))." 00:00:00"; |
32 | 32 | $sql_date = $end_date; |
33 | - } else $sql_date = ''; |
|
34 | -} else $sql_date = ''; |
|
33 | + } else { |
|
34 | + $sql_date = ''; |
|
35 | + } |
|
36 | + } else { |
|
37 | + $sql_date = ''; |
|
38 | +} |
|
35 | 39 | |
36 | 40 | if (isset($_GET['highest_altitude'])) { |
37 | 41 | //for altitude manipulation |
@@ -45,8 +49,12 @@ discard block |
||
45 | 49 | } else if($_GET['highest_altitude'] == "" && $_GET['lowest_altitude'] != ""){ |
46 | 50 | $start_altitude = filter_input(INPUT_GET,'lowest_altitude',FILTER_SANITIZE_NUMBER_INT).",60000"; |
47 | 51 | $sql_altitude = $start_altitude; |
48 | - } else $sql_altitude = ''; |
|
49 | -} else $sql_altitude = ''; |
|
52 | + } else { |
|
53 | + $sql_altitude = ''; |
|
54 | + } |
|
55 | + } else { |
|
56 | + $sql_altitude = ''; |
|
57 | +} |
|
50 | 58 | |
51 | 59 | //calculuation for the pagination |
52 | 60 | if(!isset($_GET['limit'])) |
@@ -64,7 +72,7 @@ discard block |
||
64 | 72 | $limit_end = filter_input(INPUT_GET,'number_results',FILTER_SANITIZE_NUMBER_INT); |
65 | 73 | $absolute_difference = filter_input(INPUT_GET,'number_results',FILTER_SANITIZE_NUMBER_INT); |
66 | 74 | } |
67 | -} else { |
|
75 | +} else { |
|
68 | 76 | $limit_explode = explode(",", $_GET['limit']); |
69 | 77 | $limit_start = filter_var($limit_explode[0],FILTER_SANITIZE_NUMBER_INT); |
70 | 78 | $limit_end = filter_var($limit_explode[1],FILTER_SANITIZE_NUMBER_INT); |
@@ -97,10 +105,15 @@ discard block |
||
97 | 105 | $origlon = filter_input(INPUT_GET,'origlon',FILTER_SANITIZE_STRING); |
98 | 106 | $dist = filter_input(INPUT_GET,'dist',FILTER_SANITIZE_NUMBER_INT); |
99 | 107 | if ($dist != '') { |
100 | - if (isset($globalDistanceUnit) && $globalDistanceUnit == 'mi') $dist = $dist*1.60934; |
|
101 | - elseif (isset($globalDistanceUnit) && $globalDistanceUnit == 'nm') $dist = $dist*1.852; |
|
108 | + if (isset($globalDistanceUnit) && $globalDistanceUnit == 'mi') { |
|
109 | + $dist = $dist*1.60934; |
|
110 | + } elseif (isset($globalDistanceUnit) && $globalDistanceUnit == 'nm') { |
|
111 | + $dist = $dist*1.852; |
|
112 | + } |
|
113 | + } |
|
114 | + if (!isset($sql_date)) { |
|
115 | + $sql_date = ''; |
|
102 | 116 | } |
103 | - if (!isset($sql_date)) $sql_date = ''; |
|
104 | 117 | if ($archive == 1) { |
105 | 118 | $SpotterArchive = new SpotterArchive(); |
106 | 119 | $spotter_array = $SpotterArchive->searchSpotterData($q,$registration,$aircraft,strtolower(str_replace("-", " ", $manufacturer)),$highlights,$airline,$airline_country,$airline_type,$airport,$airport_country,$callsign,$departure_airport_route,$arrival_airport_route,$owner,$pilot_id,$pilot_name,$sql_altitude,$sql_date,$limit_start.",".$absolute_difference,$sort,'',$origlat,$origlon,$dist); |
@@ -168,7 +181,10 @@ discard block |
||
168 | 181 | if (isset($_GET['aircraft']) && $_GET['aircraft'] != ""){ print _("Aircraft:").' <span>'.$aircraft.'</span> '; } |
169 | 182 | if (isset($_GET['manufacturer']) && $_GET['manufacturer'] != ""){ print _("Manufacturer:").' <span>'.$manufacturer.'</span> '; } |
170 | 183 | if (isset($_GET['registration']) && $_GET['registration'] != ""){ print _("Registration:").' <span>'.$registration.'</span> '; } |
171 | - if (isset($_GET['highlights'])) if ($_GET['highlights'] == "true"){ print _("Highlights:").' <span>'.$highlights.'</span> '; } |
|
184 | + if (isset($_GET['highlights'])) { |
|
185 | + if ($_GET['highlights'] == "true"){ print _("Highlights:").' <span>'.$highlights.'</span> '; |
|
186 | + } |
|
187 | + } |
|
172 | 188 | if (isset($_GET['airline']) && $_GET['airline'] != ""){ print _("Airline:").' <span>'.$airline.'</span> '; } |
173 | 189 | if (isset($_GET['airline_country']) && $_GET['airline_country'] != ""){ print _("Airline country:").' <span>'.$airline_country.'</span> '; } |
174 | 190 | if (isset($_GET['airline_type']) && $_GET['airline_type'] != ""){ print _("Airline type:").' <span>'.$airline_type.'</span> '; } |
@@ -279,7 +295,10 @@ discard block |
||
279 | 295 | <div class="form-group"> |
280 | 296 | <label class="control-label col-sm-2"><?php echo _("Keywords"); ?></label> |
281 | 297 | <div class="col-sm-10"> |
282 | - <input type="text" class="form-control" id="q" name="q" value="<?php if (isset($_GET['q'])) print $q; ?>" size="10" placeholder="<?php echo _("Keywords"); ?>" /> |
|
298 | + <input type="text" class="form-control" id="q" name="q" value="<?php if (isset($_GET['q'])) { |
|
299 | + print $q; |
|
300 | +} |
|
301 | +?>" size="10" placeholder="<?php echo _("Keywords"); ?>" /> |
|
283 | 302 | </div> |
284 | 303 | </div> |
285 | 304 | </fieldset> |
@@ -294,7 +313,10 @@ discard block |
||
294 | 313 | </select> |
295 | 314 | </div> |
296 | 315 | </div> |
297 | - <script type="text/javascript">getSelect('manufacturer','<?php if(isset($_GET['manufacturer'])) print $manufacturer; ?>')</script> |
|
316 | + <script type="text/javascript">getSelect('manufacturer','<?php if(isset($_GET['manufacturer'])) { |
|
317 | + print $manufacturer; |
|
318 | +} |
|
319 | +?>')</script> |
|
298 | 320 | <div class="form-group"> |
299 | 321 | <label class="control-label col-sm-2"><?php echo _("Type"); ?></label> |
300 | 322 | <div class="col-sm-10"> |
@@ -303,11 +325,17 @@ discard block |
||
303 | 325 | </select> |
304 | 326 | </div> |
305 | 327 | </div> |
306 | - <script type="text/javascript">getSelect('aircrafttypes','<?php if(isset($_GET['aircraft_icao'])) print $aircraft_icao; ?>');</script> |
|
328 | + <script type="text/javascript">getSelect('aircrafttypes','<?php if(isset($_GET['aircraft_icao'])) { |
|
329 | + print $aircraft_icao; |
|
330 | +} |
|
331 | +?>');</script> |
|
307 | 332 | <div class="form-group"> |
308 | 333 | <label class="control-label col-sm-2"><?php echo _("Registration"); ?></label> |
309 | 334 | <div class="col-sm-10"> |
310 | - <input type="text" class="form-control" name="registration" value="<?php if (isset($_GET['registration'])) print $registration; ?>" size="8" placeholder="<?php echo _("Registration"); ?>" /> |
|
335 | + <input type="text" class="form-control" name="registration" value="<?php if (isset($_GET['registration'])) { |
|
336 | + print $registration; |
|
337 | +} |
|
338 | +?>" size="8" placeholder="<?php echo _("Registration"); ?>" /> |
|
311 | 339 | </div> |
312 | 340 | </div> |
313 | 341 | <?php |
@@ -316,22 +344,31 @@ discard block |
||
316 | 344 | <div class="form-group"> |
317 | 345 | <label class="control-label col-sm-2"><?php echo _("Pilot id"); ?></label> |
318 | 346 | <div class="col-sm-10"> |
319 | - <input type="text" class="form-control" name="pilot_id" value="<?php if (isset($_GET['pilot_id'])) print $pilot_id; ?>" size="15" placeholder="<?php echo _("Pilot id"); ?>" /> |
|
347 | + <input type="text" class="form-control" name="pilot_id" value="<?php if (isset($_GET['pilot_id'])) { |
|
348 | + print $pilot_id; |
|
349 | +} |
|
350 | +?>" size="15" placeholder="<?php echo _("Pilot id"); ?>" /> |
|
320 | 351 | </div> |
321 | 352 | </div> |
322 | 353 | <div class="form-group"> |
323 | 354 | <label class="control-label col-sm-2"><?php echo _("Pilot name"); ?></label> |
324 | 355 | <div class="col-sm-10"> |
325 | - <input type="text" class="form-control" name="pilot_name" value="<?php if (isset($_GET['pilot_name'])) print $pilot_name; ?>" size="15" placeholder="<?php echo _("Pilot name"); ?>" /> |
|
356 | + <input type="text" class="form-control" name="pilot_name" value="<?php if (isset($_GET['pilot_name'])) { |
|
357 | + print $pilot_name; |
|
358 | +} |
|
359 | +?>" size="15" placeholder="<?php echo _("Pilot name"); ?>" /> |
|
326 | 360 | </div> |
327 | 361 | </div> |
328 | 362 | <?php |
329 | -}else { |
|
363 | +} else { |
|
330 | 364 | ?> |
331 | 365 | <div class="form-group"> |
332 | 366 | <label class="control-label col-sm-2"><?php echo _("Owner name"); ?></label> |
333 | 367 | <div class="col-sm-10"> |
334 | - <input type="text" class="form-control" name="owner" value="<?php if (isset($_GET['owner'])) print $owner; ?>" size="15" placeholder="<?php echo _("Owner name"); ?>" /> |
|
368 | + <input type="text" class="form-control" name="owner" value="<?php if (isset($_GET['owner'])) { |
|
369 | + print $owner; |
|
370 | +} |
|
371 | +?>" size="15" placeholder="<?php echo _("Owner name"); ?>" /> |
|
335 | 372 | </div> |
336 | 373 | </div> |
337 | 374 | <?php |
@@ -339,8 +376,14 @@ discard block |
||
339 | 376 | ?> |
340 | 377 | <div class="form-group"> |
341 | 378 | <div class="col-sm-offset-2 col-sm-10"> |
342 | - <!--<div><input type="checkbox" class="form-control" name="highlights" value="true" id="highlights" <?php if (isset($_GET['highlights'])) if ($_GET['highlights'] == "true"){ print 'checked="checked"'; } ?>> <label for="highlights"><?php echo _("Include only aircrafts with special highlights (unique liveries, destinations etc.)"); ?></label></div>--> |
|
343 | - <label class="checkbox-inline"><input type="checkbox" name="highlights" value="true" id="highlights" <?php if (isset($_GET['highlights'])) if ($_GET['highlights'] == "true"){ print 'checked="checked"'; } ?>> <?php echo _("Include only aircrafts with special highlights (unique liveries, destinations etc.)"); ?></label> |
|
379 | + <!--<div><input type="checkbox" class="form-control" name="highlights" value="true" id="highlights" <?php if (isset($_GET['highlights'])) { |
|
380 | + if ($_GET['highlights'] == "true"){ print 'checked="checked"'; |
|
381 | +} |
|
382 | +} ?>> <label for="highlights"><?php echo _("Include only aircrafts with special highlights (unique liveries, destinations etc.)"); ?></label></div>--> |
|
383 | + <label class="checkbox-inline"><input type="checkbox" name="highlights" value="true" id="highlights" <?php if (isset($_GET['highlights'])) { |
|
384 | + if ($_GET['highlights'] == "true"){ print 'checked="checked"'; |
|
385 | +} |
|
386 | +} ?>> <?php echo _("Include only aircrafts with special highlights (unique liveries, destinations etc.)"); ?></label> |
|
344 | 387 | </div> |
345 | 388 | </div> |
346 | 389 | </fieldset> |
@@ -354,7 +397,10 @@ discard block |
||
354 | 397 | </select> |
355 | 398 | </div> |
356 | 399 | </div> |
357 | - <script type="text/javascript">getSelect('airlinenames','<?php if(isset($_GET['airline'])) print $airline; ?>');</script> |
|
400 | + <script type="text/javascript">getSelect('airlinenames','<?php if(isset($_GET['airline'])) { |
|
401 | + print $airline; |
|
402 | +} |
|
403 | +?>');</script> |
|
358 | 404 | <div class="form-group"> |
359 | 405 | <label class="control-label col-sm-2"><?php echo _("Country"); ?></label> |
360 | 406 | <div class="col-sm-10"> |
@@ -363,19 +409,34 @@ discard block |
||
363 | 409 | </select> |
364 | 410 | </div> |
365 | 411 | </div> |
366 | - <script type="text/javascript">getSelect('airlinecountries','<?php if(isset($_GET['airline_country'])) print $airline_country; ?>');</script> |
|
412 | + <script type="text/javascript">getSelect('airlinecountries','<?php if(isset($_GET['airline_country'])) { |
|
413 | + print $airline_country; |
|
414 | +} |
|
415 | +?>');</script> |
|
367 | 416 | <div class="form-group"> |
368 | 417 | <label class="control-label col-sm-2"><?php echo _("Callsign"); ?></label> |
369 | 418 | <div class="col-sm-10"> |
370 | - <input type="text" name="callsign" class="form-control" value="<?php if (isset($_GET['callsign'])) print $callsign; ?>" size="8" placeholder="<?php echo _("Callsign"); ?>" /> |
|
419 | + <input type="text" name="callsign" class="form-control" value="<?php if (isset($_GET['callsign'])) { |
|
420 | + print $callsign; |
|
421 | +} |
|
422 | +?>" size="8" placeholder="<?php echo _("Callsign"); ?>" /> |
|
371 | 423 | </div> |
372 | 424 | </div> |
373 | 425 | <div class="form-group"> |
374 | 426 | <div class="col-sm-offset-2 col-sm-10"> |
375 | 427 | <label class="radio-inline"><input type="radio" name="airline_type" value="all" id="airline_type_all" <?php if (!isset($_GET['airline_type']) || $_GET['airline_type'] == "all"){ print 'checked="checked"'; } ?>> <?php echo _("All airlines types"); ?></label> |
376 | - <label class="radio-inline"><input type="radio" name="airline_type" value="passenger" id="airline_type_passenger" <?php if (isset($_GET['airline_type'])) if ($_GET['airline_type'] == "passenger"){ print 'checked="checked"'; } ?>> <?php echo _("Only Passenger airlines"); ?></label> |
|
377 | - <label class="radio-inline"><input type="radio" name="airline_type" value="cargo" id="airline_type_cargo" <?php if (isset($_GET['airline_type'])) if ( $_GET['airline_type'] == "cargo"){ print 'checked="checked"'; } ?>> <?php echo _("Only Cargo airlines"); ?></label> |
|
378 | - <label class="radio-inline"><input type="radio" name="airline_type" value="military" id="airline_type_military" <?php if (isset($_GET['airline_type'])) if ( $_GET['airline_type'] == "military"){ print 'checked="checked"'; } ?>> <?php echo _("Only Military airlines"); ?></label> |
|
428 | + <label class="radio-inline"><input type="radio" name="airline_type" value="passenger" id="airline_type_passenger" <?php if (isset($_GET['airline_type'])) { |
|
429 | + if ($_GET['airline_type'] == "passenger"){ print 'checked="checked"'; |
|
430 | +} |
|
431 | +} ?>> <?php echo _("Only Passenger airlines"); ?></label> |
|
432 | + <label class="radio-inline"><input type="radio" name="airline_type" value="cargo" id="airline_type_cargo" <?php if (isset($_GET['airline_type'])) { |
|
433 | + if ( $_GET['airline_type'] == "cargo"){ print 'checked="checked"'; |
|
434 | +} |
|
435 | +} ?>> <?php echo _("Only Cargo airlines"); ?></label> |
|
436 | + <label class="radio-inline"><input type="radio" name="airline_type" value="military" id="airline_type_military" <?php if (isset($_GET['airline_type'])) { |
|
437 | + if ( $_GET['airline_type'] == "military"){ print 'checked="checked"'; |
|
438 | +} |
|
439 | +} ?>> <?php echo _("Only Military airlines"); ?></label> |
|
379 | 440 | </div> |
380 | 441 | </div> |
381 | 442 | </fieldset> |
@@ -389,7 +450,10 @@ discard block |
||
389 | 450 | </select> |
390 | 451 | </div> |
391 | 452 | </div> |
392 | - <script type="text/javascript">getSelect('airportnames','<?php if(isset($_GET['airport_icao'])) print $airport_icao; ?>');</script> |
|
453 | + <script type="text/javascript">getSelect('airportnames','<?php if(isset($_GET['airport_icao'])) { |
|
454 | + print $airport_icao; |
|
455 | +} |
|
456 | +?>');</script> |
|
393 | 457 | <div class="form-group"> |
394 | 458 | <label class="control-label col-sm-2"><?php echo _("Country"); ?></label> |
395 | 459 | <div class="col-sm-10"> |
@@ -398,7 +462,10 @@ discard block |
||
398 | 462 | </select> |
399 | 463 | </div> |
400 | 464 | </div> |
401 | - <script type="text/javascript">getSelect('airportcountries','<?php if(isset($_GET['airport_country'])) print $airport_country; ?>');</script> |
|
465 | + <script type="text/javascript">getSelect('airportcountries','<?php if(isset($_GET['airport_country'])) { |
|
466 | + print $airport_country; |
|
467 | +} |
|
468 | +?>');</script> |
|
402 | 469 | </fieldset> |
403 | 470 | <fieldset> |
404 | 471 | <legend><?php echo _("Route"); ?></legend> |
@@ -410,7 +477,10 @@ discard block |
||
410 | 477 | </select> |
411 | 478 | </div> |
412 | 479 | </div> |
413 | - <script type="text/javascript">getSelect('departureairportnames','<?php if(isset($_GET['departure_airport_route'])) print $departure_airport_route; ?>');</script> |
|
480 | + <script type="text/javascript">getSelect('departureairportnames','<?php if(isset($_GET['departure_airport_route'])) { |
|
481 | + print $departure_airport_route; |
|
482 | +} |
|
483 | +?>');</script> |
|
414 | 484 | <div class="form-group"> |
415 | 485 | <label class="control-label col-sm-2"><?php echo _("Arrival Airport"); ?></label> |
416 | 486 | <div class="col-sm-10"> |
@@ -419,7 +489,10 @@ discard block |
||
419 | 489 | </select> |
420 | 490 | </div> |
421 | 491 | </div> |
422 | - <script type="text/javascript">getSelect('arrivalairportnames','<?php if(isset($_GET['arrival_airport_route'])) print $arrival_airport_route; ?>');</script> |
|
492 | + <script type="text/javascript">getSelect('arrivalairportnames','<?php if(isset($_GET['arrival_airport_route'])) { |
|
493 | + print $arrival_airport_route; |
|
494 | +} |
|
495 | +?>');</script> |
|
423 | 496 | </fieldset> |
424 | 497 | <fieldset> |
425 | 498 | <legend><?php echo _("Date"); ?></legend> |
@@ -427,7 +500,10 @@ discard block |
||
427 | 500 | <label class="control-label col-sm-2"><?php echo _("Start Date"); ?></label> |
428 | 501 | <div class="col-sm-10"> |
429 | 502 | <div class='input-group date' id='datetimepicker1'> |
430 | - <input type='text' name="start_date" class="form-control" value="<?php if (isset($_GET['start_date'])) print $start_date; ?>" placeholder="<?php echo _("Start Date/Time"); ?>" /> |
|
503 | + <input type='text' name="start_date" class="form-control" value="<?php if (isset($_GET['start_date'])) { |
|
504 | + print $start_date; |
|
505 | +} |
|
506 | +?>" placeholder="<?php echo _("Start Date/Time"); ?>" /> |
|
431 | 507 | <span class="input-group-addon"> |
432 | 508 | <span class="glyphicon glyphicon-calendar"></span> |
433 | 509 | </span> |
@@ -438,7 +514,10 @@ discard block |
||
438 | 514 | <label class="control-label col-sm-2"><?php echo _("End Date"); ?></label> |
439 | 515 | <div class="col-sm-10"> |
440 | 516 | <div class='input-group date' id='datetimepicker2'> |
441 | - <input type='text' name="end_date" class="form-control" value="<?php if (isset($_GET['end_date'])) print $end_date; ?>" placeholder="<?php echo _("End Date/Time"); ?>" /> |
|
517 | + <input type='text' name="end_date" class="form-control" value="<?php if (isset($_GET['end_date'])) { |
|
518 | + print $end_date; |
|
519 | +} |
|
520 | +?>" placeholder="<?php echo _("End Date/Time"); ?>" /> |
|
442 | 521 | <span class="input-group-addon"> |
443 | 522 | <span class="glyphicon glyphicon-calendar"></span> |
444 | 523 | </span> |
@@ -511,19 +590,33 @@ discard block |
||
511 | 590 | <div class="form-group"> |
512 | 591 | <label class="control-label col-sm-2"><?php echo _("Latitude"); ?></label> |
513 | 592 | <div class="col-sm-10"> |
514 | - <input type="text" name="origlat" class="form-control" placeholder="<?php echo _("Center point latitude"); ?>" value="<?php if (isset($_GET['origlat'])) print $origlat; ?>" /> |
|
593 | + <input type="text" name="origlat" class="form-control" placeholder="<?php echo _("Center point latitude"); ?>" value="<?php if (isset($_GET['origlat'])) { |
|
594 | + print $origlat; |
|
595 | +} |
|
596 | +?>" /> |
|
515 | 597 | </div> |
516 | 598 | </div> |
517 | 599 | <div class="form-group"> |
518 | 600 | <label class="control-label col-sm-2"><?php echo _("Longitude"); ?></label> |
519 | 601 | <div class="col-sm-10"> |
520 | - <input type="text" name="origlon" class="form-control" placeholder="<?php echo _("Center point longitude"); ?>" value="<?php if (isset($_GET['origlon'])) print $origlon; ?>" /> |
|
602 | + <input type="text" name="origlon" class="form-control" placeholder="<?php echo _("Center point longitude"); ?>" value="<?php if (isset($_GET['origlon'])) { |
|
603 | + print $origlon; |
|
604 | +} |
|
605 | +?>" /> |
|
521 | 606 | </div> |
522 | 607 | </div> |
523 | 608 | <div class="form-group"> |
524 | - <label class="control-label col-sm-2"><?php echo _("Distance").' ('; if (isset($globalDistanceUnit)) print $globalDistanceUnit; else print 'km'; print ')'; ?></label> |
|
609 | + <label class="control-label col-sm-2"><?php echo _("Distance").' ('; if (isset($globalDistanceUnit)) { |
|
610 | + print $globalDistanceUnit; |
|
611 | +} else { |
|
612 | + print 'km'; |
|
613 | +} |
|
614 | +print ')'; ?></label> |
|
525 | 615 | <div class="col-sm-10"> |
526 | - <input type="text" name="dist" class="form-control" placeholder="<?php echo _("Distance from center point"); ?>" value="<?php if (isset($_GET['distance'])) print $distance; ?>" /> |
|
616 | + <input type="text" name="dist" class="form-control" placeholder="<?php echo _("Distance from center point"); ?>" value="<?php if (isset($_GET['distance'])) { |
|
617 | + print $distance; |
|
618 | +} |
|
619 | +?>" /> |
|
527 | 620 | </div> |
528 | 621 | </div> |
529 | 622 | </fieldset> |
@@ -113,8 +113,11 @@ discard block |
||
113 | 113 | $data = array(); |
114 | 114 | if ($row['registration'] != '') { |
115 | 115 | $image_array = $Image->getSpotterImage($row['registration']); |
116 | - if (count($image_array) > 0) $data = array_merge($data,array('image' => $image_array[0]['image'],'image_thumbnail' => $image_array[0]['image_thumbnail'],'image_copyright' => $image_array[0]['image_copyright'],'image_source' => $image_array[0]['image_source'],'image_source_website' => $image_array[0]['image_source_website'])); |
|
117 | - else $data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => '')); |
|
116 | + if (count($image_array) > 0) { |
|
117 | + $data = array_merge($data,array('image' => $image_array[0]['image'],'image_thumbnail' => $image_array[0]['image_thumbnail'],'image_copyright' => $image_array[0]['image_copyright'],'image_source' => $image_array[0]['image_source'],'image_source_website' => $image_array[0]['image_source_website'])); |
|
118 | + } else { |
|
119 | + $data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => '')); |
|
120 | + } |
|
118 | 121 | $aircraft_type = $Spotter->getAllAircraftTypeByRegistration($row['registration']); |
119 | 122 | $aircraft_info = $Spotter->getAllAircraftInfo($aircraft_type); |
120 | 123 | if (!empty($aircraft_info)) { |
@@ -130,17 +133,30 @@ discard block |
||
130 | 133 | $data['aircraft_base'] = $owner_data['base']; |
131 | 134 | $data['aircraft_date_first_reg'] = $owner_data['date_first_reg']; |
132 | 135 | } |
133 | - } else $data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => '')); |
|
134 | - if ($row['registration'] == '') $row['registration'] = 'NA'; |
|
135 | - if ($row['ident'] == '') $row['ident'] = 'NA'; |
|
136 | + } else { |
|
137 | + $data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => '')); |
|
138 | + } |
|
139 | + if ($row['registration'] == '') { |
|
140 | + $row['registration'] = 'NA'; |
|
141 | + } |
|
142 | + if ($row['ident'] == '') { |
|
143 | + $row['ident'] = 'NA'; |
|
144 | + } |
|
136 | 145 | $identicao = $Spotter->getAllAirlineInfo(substr($row['ident'],0,3)); |
137 | 146 | if (isset($identicao[0])) { |
138 | 147 | if (substr($row['ident'],0,2) == 'AF') { |
139 | - if (filter_var(substr($row['ident'],2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $row['ident']; |
|
140 | - else $icao = 'AFR'.ltrim(substr($row['ident'],2),'0'); |
|
141 | - } else $icao = $identicao[0]['icao'].ltrim(substr($row['ident'],2),'0'); |
|
148 | + if (filter_var(substr($row['ident'],2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) { |
|
149 | + $icao = $row['ident']; |
|
150 | + } else { |
|
151 | + $icao = 'AFR'.ltrim(substr($row['ident'],2),'0'); |
|
152 | + } |
|
153 | + } else { |
|
154 | + $icao = $identicao[0]['icao'].ltrim(substr($row['ident'],2),'0'); |
|
155 | + } |
|
142 | 156 | $data = array_merge($data,array('airline_icao' => $identicao[0]['icao'],'airline_name' => $identicao[0]['name'])); |
143 | - } else $icao = $row['ident']; |
|
157 | + } else { |
|
158 | + $icao = $row['ident']; |
|
159 | + } |
|
144 | 160 | $icao = $Translation->checkTranslation($icao,false); |
145 | 161 | //$data = array_merge($data,array('registration' => $row['registration'], 'date' => $row['date'], 'ident' => $icao,'url' => $row['url'])); |
146 | 162 | if ($row['airline_name'] != '' && !isset($data['airline_name'])) { |
@@ -155,10 +171,14 @@ discard block |
||
155 | 171 | //else echo 'No data...'."\n"; |
156 | 172 | } |
157 | 173 | $data = array_merge($row,$data); |
158 | - if ($data['ident'] == null) $data['ident'] = $icao; |
|
174 | + if ($data['ident'] == null) { |
|
175 | + $data['ident'] = $icao; |
|
176 | + } |
|
159 | 177 | if ($data['title'] == null) { |
160 | 178 | $data['message'] = $row['type'].' of '.$row['registration'].' at '.$row['place'].','.$row['country']; |
161 | - } else $data['message'] = strtolower($data['title']); |
|
179 | + } else { |
|
180 | + $data['message'] = strtolower($data['title']); |
|
181 | + } |
|
162 | 182 | $ids = $Spotter->getAllIDByRegistration($data['registration']); |
163 | 183 | $date = $data['date']; |
164 | 184 | if (isset($ids[$date])) { |
@@ -177,8 +197,9 @@ discard block |
||
177 | 197 | if (isset($result)) { |
178 | 198 | $result[0]['query_number_rows'] = $i; |
179 | 199 | return $result; |
200 | + } else { |
|
201 | + return array(); |
|
180 | 202 | } |
181 | - else return array(); |
|
182 | 203 | } |
183 | 204 | |
184 | 205 | /* |
@@ -222,7 +243,9 @@ discard block |
||
222 | 243 | */ |
223 | 244 | public function import($file) { |
224 | 245 | global $globalTransaction, $globalDebug; |
225 | - if ($globalDebug) echo 'Import '.$file."\n"; |
|
246 | + if ($globalDebug) { |
|
247 | + echo 'Import '.$file."\n"; |
|
248 | + } |
|
226 | 249 | $result = array(); |
227 | 250 | if (file_exists($file)) { |
228 | 251 | if (($handle = fopen($file,'r')) !== FALSE) { |
@@ -233,8 +256,11 @@ discard block |
||
233 | 256 | } |
234 | 257 | fclose($handle); |
235 | 258 | } |
236 | - if (!empty($result)) $this->add($result,true); |
|
237 | - elseif ($globalDebug) echo 'Nothing to import'; |
|
259 | + if (!empty($result)) { |
|
260 | + $this->add($result,true); |
|
261 | + } elseif ($globalDebug) { |
|
262 | + echo 'Nothing to import'; |
|
263 | + } |
|
238 | 264 | } |
239 | 265 | } |
240 | 266 | |
@@ -270,14 +296,23 @@ discard block |
||
270 | 296 | } |
271 | 297 | } |
272 | 298 | fclose($handle); |
273 | - } elseif ($globalDebug) echo "Can't open ".dirname(__FILE__).'/../install/tmp/cr-all.md5'; |
|
274 | - } elseif ($globalDebug) echo 'Download cr-all.md5 failed. '.dirname(__FILE__).'/../install/tmp/cr-all.md5 not here.'; |
|
299 | + } elseif ($globalDebug) { |
|
300 | + echo "Can't open ".dirname(__FILE__).'/../install/tmp/cr-all.md5'; |
|
301 | + } |
|
302 | + } elseif ($globalDebug) { |
|
303 | + echo 'Download cr-all.md5 failed. '.dirname(__FILE__).'/../install/tmp/cr-all.md5 not here.'; |
|
304 | + } |
|
275 | 305 | $result = $Common->arr_diff($all_md5_new,$all_md5); |
276 | - if (empty($result) && $globalDebug) echo 'Nothing to update'; |
|
306 | + if (empty($result) && $globalDebug) { |
|
307 | + echo 'Nothing to update'; |
|
308 | + } |
|
277 | 309 | foreach ($result as $file => $md5) { |
278 | 310 | $Common->download('http://data.flightairmap.fr/data/cr/'.$file,dirname(__FILE__).'/../install/tmp/'.$file); |
279 | - if (file_exists(dirname(__FILE__).'/../install/tmp/'.$file)) $this->import(dirname(__FILE__).'/../install/tmp/'.$file); |
|
280 | - elseif ($globalDebug) echo 'Download '.$file.' failed'; |
|
311 | + if (file_exists(dirname(__FILE__).'/../install/tmp/'.$file)) { |
|
312 | + $this->import(dirname(__FILE__).'/../install/tmp/'.$file); |
|
313 | + } elseif ($globalDebug) { |
|
314 | + echo 'Download '.$file.' failed'; |
|
315 | + } |
|
281 | 316 | } |
282 | 317 | } |
283 | 318 | |
@@ -294,13 +329,17 @@ discard block |
||
294 | 329 | $Image = new Image(); |
295 | 330 | $Spotter = new Spotter(); |
296 | 331 | |
297 | - if (empty($crash)) return false; |
|
332 | + if (empty($crash)) { |
|
333 | + return false; |
|
334 | + } |
|
298 | 335 | if (!$new) { |
299 | 336 | $query_delete = 'DELETE FROM accidents WHERE source = :source'; |
300 | 337 | $sthd = $Connection->db->prepare($query_delete); |
301 | 338 | $sthd->execute(array(':source' => $crash[0]['source'])); |
302 | 339 | } |
303 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
340 | + if ($globalTransaction) { |
|
341 | + $Connection->db->beginTransaction(); |
|
342 | + } |
|
304 | 343 | $initial_array = array('ident' => null,'type' => 'accident','url' => null,'registration' => null, 'date' => null, 'place' => null,'country' => null, 'latitude' => null, 'longitude' => null, 'fatalities' => null, 'title' => '','source' => '','aircraft_manufacturer' => null,'aircraft_name' => null,'operator' => null); |
305 | 344 | $query_check = 'SELECT COUNT(*) as nb FROM accidents WHERE registration = :registration AND date = :date AND type = :type AND source = :source'; |
306 | 345 | $sth_check = $Connection->db->prepare($query_check); |
@@ -315,7 +354,9 @@ discard block |
||
315 | 354 | return $value === "" ? NULL : $value; |
316 | 355 | }, $cr); |
317 | 356 | if ($cr['date'] != '' && $cr['registration'] != null && $cr['registration'] != '' && $cr['registration'] != '?' && $cr['registration'] != '-' && strtolower($cr['registration']) != 'unknown' && $cr['date'] < time() && !preg_match('/\s/',$cr['registration'])) { |
318 | - if (strpos($cr['registration'],'-') === FALSE) $cr['registration'] = $Spotter->convertAircraftRegistration($cr['registration']); |
|
357 | + if (strpos($cr['registration'],'-') === FALSE) { |
|
358 | + $cr['registration'] = $Spotter->convertAircraftRegistration($cr['registration']); |
|
359 | + } |
|
319 | 360 | $query_check_values = array(':registration' => $cr['registration'],':date' => date('Y-m-d',$cr['date']),':type' => $cr['type'],':source' => $cr['source']); |
320 | 361 | $sth_check->execute($query_check_values); |
321 | 362 | $result_check = $sth_check->fetch(PDO::FETCH_ASSOC); |
@@ -324,13 +365,19 @@ discard block |
||
324 | 365 | $sth->execute($query_values); |
325 | 366 | if ($cr['date'] > time()-(30*86400)) { |
326 | 367 | if (empty($Image->getSpotterImage($cr['registration']))) { |
327 | - if ($globalDebug) echo "\t".'Get image for '.$cr['registration'].'...'; |
|
368 | + if ($globalDebug) { |
|
369 | + echo "\t".'Get image for '.$cr['registration'].'...'; |
|
370 | + } |
|
328 | 371 | $Image->addSpotterImage($cr['registration']); |
329 | - if ($globalDebug) echo "\t".'Done'."\n"; |
|
372 | + if ($globalDebug) { |
|
373 | + echo "\t".'Done'."\n"; |
|
374 | + } |
|
330 | 375 | } |
331 | 376 | // elseif ($globalDebug) echo 'Image already in DB'."\n"; |
332 | 377 | } |
333 | - if ($cr['title'] == '') $cr['title'] = $cr['registration'].' '.$cr['type']; |
|
378 | + if ($cr['title'] == '') { |
|
379 | + $cr['title'] = $cr['registration'].' '.$cr['type']; |
|
380 | + } |
|
334 | 381 | $Spotter->setHighlightFlightByRegistration($cr['registration'],$cr['title'],date('Y-m-d',$cr['date'])); |
335 | 382 | } |
336 | 383 | } |
@@ -339,9 +386,13 @@ discard block |
||
339 | 386 | $Connection->db->beginTransaction(); |
340 | 387 | } |
341 | 388 | } |
342 | - if ($globalTransaction) $Connection->db->commit(); |
|
389 | + if ($globalTransaction) { |
|
390 | + $Connection->db->commit(); |
|
391 | + } |
|
343 | 392 | } catch(PDOException $e) { |
344 | - if ($globalTransaction) $Connection->db->rollBack(); |
|
393 | + if ($globalTransaction) { |
|
394 | + $Connection->db->rollBack(); |
|
395 | + } |
|
345 | 396 | echo $e->getMessage(); |
346 | 397 | } |
347 | 398 | $sth_check->closeCursor(); |
@@ -380,8 +431,11 @@ discard block |
||
380 | 431 | return "error : ".$e->getMessage(); |
381 | 432 | } |
382 | 433 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
383 | - if ($row['nb'] > 0) return false; |
|
384 | - else return true; |
|
434 | + if ($row['nb'] > 0) { |
|
435 | + return false; |
|
436 | + } else { |
|
437 | + return true; |
|
438 | + } |
|
385 | 439 | } |
386 | 440 | |
387 | 441 | public static function insert_last_accidents_update() { |
@@ -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> |
@@ -37,8 +37,11 @@ discard block |
||
37 | 37 | } else { |
38 | 38 | curl_setopt($ch, CURLOPT_USERAGENT, $useragent); |
39 | 39 | } |
40 | - if ($timeout == '') curl_setopt($ch, CURLOPT_TIMEOUT, 10); |
|
41 | - else curl_setopt($ch, CURLOPT_TIMEOUT, $timeout); |
|
40 | + if ($timeout == '') { |
|
41 | + curl_setopt($ch, CURLOPT_TIMEOUT, 10); |
|
42 | + } else { |
|
43 | + curl_setopt($ch, CURLOPT_TIMEOUT, $timeout); |
|
44 | + } |
|
42 | 45 | curl_setopt($ch, CURLOPT_HEADERFUNCTION, array('Common',"curlResponseHeaderCallback")); |
43 | 46 | if ($type == 'post') { |
44 | 47 | curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST"); |
@@ -85,8 +88,9 @@ discard block |
||
85 | 88 | private function curlResponseHeaderCallback($ch, $headerLine) { |
86 | 89 | //global $cookies; |
87 | 90 | $cookies = array(); |
88 | - if (preg_match('/^Set-Cookie:\s*([^;]*)/mi', $headerLine, $cookie) == 1) |
|
89 | - $cookies[] = $cookie; |
|
91 | + if (preg_match('/^Set-Cookie:\s*([^;]*)/mi', $headerLine, $cookie) == 1) { |
|
92 | + $cookies[] = $cookie; |
|
93 | + } |
|
90 | 94 | return strlen($headerLine); // Needed by curl |
91 | 95 | } |
92 | 96 | |
@@ -97,11 +101,15 @@ discard block |
||
97 | 101 | curl_setopt($ch, CURLOPT_URL, $url); |
98 | 102 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); |
99 | 103 | curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); |
100 | - if ($referer != '') curl_setopt($ch, CURLOPT_REFERER, $referer); |
|
104 | + if ($referer != '') { |
|
105 | + curl_setopt($ch, CURLOPT_REFERER, $referer); |
|
106 | + } |
|
101 | 107 | 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'); |
102 | 108 | curl_setopt($ch, CURLOPT_FILE, $fp); |
103 | 109 | curl_exec($ch); |
104 | - if (curl_errno($ch) && $globalDebug) echo 'Download error: '.curl_error($ch); |
|
110 | + if (curl_errno($ch) && $globalDebug) { |
|
111 | + echo 'Download error: '.curl_error($ch); |
|
112 | + } |
|
105 | 113 | curl_close($ch); |
106 | 114 | fclose($fp); |
107 | 115 | } |
@@ -109,12 +117,16 @@ discard block |
||
109 | 117 | public static function gunzip($in_file,$out_file_name = '') { |
110 | 118 | //echo $in_file.' -> '.$out_file_name."\n"; |
111 | 119 | $buffer_size = 4096; // read 4kb at a time |
112 | - if ($out_file_name == '') $out_file_name = str_replace('.gz', '', $in_file); |
|
120 | + if ($out_file_name == '') { |
|
121 | + $out_file_name = str_replace('.gz', '', $in_file); |
|
122 | + } |
|
113 | 123 | if ($in_file != '' && file_exists($in_file)) { |
114 | 124 | // PHP version of Ubuntu use gzopen64 instead of gzopen |
115 | - if (function_exists('gzopen')) $file = gzopen($in_file,'rb'); |
|
116 | - elseif (function_exists('gzopen64')) $file = gzopen64($in_file,'rb'); |
|
117 | - else { |
|
125 | + if (function_exists('gzopen')) { |
|
126 | + $file = gzopen($in_file,'rb'); |
|
127 | + } elseif (function_exists('gzopen64')) { |
|
128 | + $file = gzopen64($in_file,'rb'); |
|
129 | + } else { |
|
118 | 130 | echo 'gzopen not available'; |
119 | 131 | die; |
120 | 132 | } |
@@ -130,11 +142,14 @@ discard block |
||
130 | 142 | public static function bunzip2($in_file,$out_file_name = '') { |
131 | 143 | //echo $in_file.' -> '.$out_file_name."\n"; |
132 | 144 | $buffer_size = 4096; // read 4kb at a time |
133 | - if ($out_file_name == '') $out_file_name = str_replace('.bz2', '', $in_file); |
|
145 | + if ($out_file_name == '') { |
|
146 | + $out_file_name = str_replace('.bz2', '', $in_file); |
|
147 | + } |
|
134 | 148 | if ($in_file != '' && file_exists($in_file)) { |
135 | 149 | // PHP version of Ubuntu use gzopen64 instead of gzopen |
136 | - if (function_exists('bzopen')) $file = bzopen($in_file,'rb'); |
|
137 | - else { |
|
150 | + if (function_exists('bzopen')) { |
|
151 | + $file = bzopen($in_file,'rb'); |
|
152 | + } else { |
|
138 | 153 | echo 'bzopen not available'; |
139 | 154 | die; |
140 | 155 | } |
@@ -153,10 +168,16 @@ discard block |
||
153 | 168 | * @return Array array of the tables in HTML page |
154 | 169 | */ |
155 | 170 | public function table2array($data) { |
156 | - if (!is_string($data)) return array(); |
|
157 | - if ($data == '') return array(); |
|
171 | + if (!is_string($data)) { |
|
172 | + return array(); |
|
173 | + } |
|
174 | + if ($data == '') { |
|
175 | + return array(); |
|
176 | + } |
|
158 | 177 | $html = str_get_html($data); |
159 | - if ($html === false) return array(); |
|
178 | + if ($html === false) { |
|
179 | + return array(); |
|
180 | + } |
|
160 | 181 | $tabledata=array(); |
161 | 182 | foreach($html->find('tr') as $element) |
162 | 183 | { |
@@ -191,7 +212,9 @@ discard block |
||
191 | 212 | */ |
192 | 213 | public function text2array($data) { |
193 | 214 | $html = str_get_html($data); |
194 | - if ($html === false) return array(); |
|
215 | + if ($html === false) { |
|
216 | + return array(); |
|
217 | + } |
|
195 | 218 | $tabledata=array(); |
196 | 219 | foreach($html->find('p') as $element) |
197 | 220 | { |
@@ -212,7 +235,9 @@ discard block |
||
212 | 235 | * @return Float Distance in $unit |
213 | 236 | */ |
214 | 237 | public function distance($lat, $lon, $latc, $lonc, $unit = 'km') { |
215 | - if ($lat == $latc && $lon == $lonc) return 0; |
|
238 | + if ($lat == $latc && $lon == $lonc) { |
|
239 | + return 0; |
|
240 | + } |
|
216 | 241 | $dist = rad2deg(acos(sin(deg2rad(floatval($lat)))*sin(deg2rad(floatval($latc)))+ cos(deg2rad(floatval($lat)))*cos(deg2rad(floatval($latc)))*cos(deg2rad(floatval($lon)-floatval($lonc)))))*60*1.1515; |
217 | 242 | if ($unit == "km") { |
218 | 243 | return round($dist * 1.609344); |
@@ -236,10 +261,16 @@ discard block |
||
236 | 261 | public function withinThreshold ($timeDifference, $distance) { |
237 | 262 | $x = abs($timeDifference); |
238 | 263 | $d = abs($distance); |
239 | - if ($x == 0 || $d == 0) return true; |
|
264 | + if ($x == 0 || $d == 0) { |
|
265 | + return true; |
|
266 | + } |
|
240 | 267 | // may be due to Internet jitter; distance is realistic |
241 | - if ($x < 0.7 && $d < 2000) return true; |
|
242 | - else return $d/$x < 1500*0.27778; // 1500 km/h max |
|
268 | + if ($x < 0.7 && $d < 2000) { |
|
269 | + return true; |
|
270 | + } else { |
|
271 | + return $d/$x < 1500*0.27778; |
|
272 | + } |
|
273 | + // 1500 km/h max |
|
243 | 274 | } |
244 | 275 | |
245 | 276 | |
@@ -267,11 +298,17 @@ discard block |
||
267 | 298 | |
268 | 299 | public function convertDM($coord,$latlong) { |
269 | 300 | if ($latlong == 'latitude') { |
270 | - if ($coord < 0) $NSEW = 'S'; |
|
271 | - else $NSEW = 'N'; |
|
301 | + if ($coord < 0) { |
|
302 | + $NSEW = 'S'; |
|
303 | + } else { |
|
304 | + $NSEW = 'N'; |
|
305 | + } |
|
272 | 306 | } elseif ($latlong == 'longitude') { |
273 | - if ($coord < 0) $NSEW = 'W'; |
|
274 | - else $NSEW = 'E'; |
|
307 | + if ($coord < 0) { |
|
308 | + $NSEW = 'W'; |
|
309 | + } else { |
|
310 | + $NSEW = 'E'; |
|
311 | + } |
|
275 | 312 | } |
276 | 313 | $coord = abs($coord); |
277 | 314 | $deg = floor($coord); |
@@ -314,7 +351,9 @@ discard block |
||
314 | 351 | public function hex2str($hex) { |
315 | 352 | $str = ''; |
316 | 353 | $hexln = strlen($hex); |
317 | - for($i=0;$i<$hexln;$i+=2) $str .= chr(hexdec(substr($hex,$i,2))); |
|
354 | + for($i=0;$i<$hexln;$i+=2) { |
|
355 | + $str .= chr(hexdec(substr($hex,$i,2))); |
|
356 | + } |
|
318 | 357 | return $str; |
319 | 358 | } |
320 | 359 | |
@@ -351,8 +390,11 @@ discard block |
||
351 | 390 | $b = $lat2 - $lat1; |
352 | 391 | $c = -($a*$lat1+$b*$lon1); |
353 | 392 | $d = $a*$lat3+$b*$lon3+$c; |
354 | - if ($d > -$approx && $d < $approx) return true; |
|
355 | - else return false; |
|
393 | + if ($d > -$approx && $d < $approx) { |
|
394 | + return true; |
|
395 | + } else { |
|
396 | + return false; |
|
397 | + } |
|
356 | 398 | } |
357 | 399 | |
358 | 400 | public function array_merge_noappend() { |
@@ -411,7 +453,9 @@ discard block |
||
411 | 453 | return $result; |
412 | 454 | } |
413 | 455 | $handle = @opendir('./locale'); |
414 | - if ($handle === false) return $result; |
|
456 | + if ($handle === false) { |
|
457 | + return $result; |
|
458 | + } |
|
415 | 459 | while (false !== ($file = readdir($handle))) { |
416 | 460 | $path = './locale'.'/'.$file.'/LC_MESSAGES/fam.mo'; |
417 | 461 | if ($file != "." && $file != ".." && @file_exists($path)) { |
@@ -478,8 +522,9 @@ discard block |
||
478 | 522 | $error = false; |
479 | 523 | if ($fp_out = gzopen($dest, $mode)) { |
480 | 524 | if ($fp_in = fopen($source,'rb')) { |
481 | - while (!feof($fp_in)) |
|
482 | - gzwrite($fp_out, fread($fp_in, 1024 * 512)); |
|
525 | + while (!feof($fp_in)) { |
|
526 | + gzwrite($fp_out, fread($fp_in, 1024 * 512)); |
|
527 | + } |
|
483 | 528 | fclose($fp_in); |
484 | 529 | } else { |
485 | 530 | $error = true; |
@@ -488,14 +533,17 @@ discard block |
||
488 | 533 | } else { |
489 | 534 | $error = true; |
490 | 535 | } |
491 | - if ($error) |
|
492 | - return false; |
|
493 | - else |
|
494 | - return $dest; |
|
536 | + if ($error) { |
|
537 | + return false; |
|
538 | + } else { |
|
539 | + return $dest; |
|
540 | + } |
|
495 | 541 | } |
496 | 542 | |
497 | 543 | public function remove_accents($string) { |
498 | - if ( !preg_match('/[\x80-\xff]/', $string) ) return $string; |
|
544 | + if ( !preg_match('/[\x80-\xff]/', $string) ) { |
|
545 | + return $string; |
|
546 | + } |
|
499 | 547 | $chars = array( |
500 | 548 | // Decompositions for Latin-1 Supplement |
501 | 549 | chr(195).chr(128) => 'A', chr(195).chr(129) => 'A', |
@@ -619,7 +667,9 @@ discard block |
||
619 | 667 | $ip = gethostbyname($host); |
620 | 668 | $s = socket_create(AF_INET, SOCK_STREAM, 0); |
621 | 669 | $r = @socket_connect($s, $ip, $port); |
622 | - if (!socket_set_nonblock($s)) echo "Unable to set nonblock on socket\n"; |
|
670 | + if (!socket_set_nonblock($s)) { |
|
671 | + echo "Unable to set nonblock on socket\n"; |
|
672 | + } |
|
623 | 673 | if ($r || socket_last_error() == 114 || socket_last_error() == 115) { |
624 | 674 | return $s; |
625 | 675 | } |
@@ -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)); |