@@ -88,8 +88,11 @@ discard block |
||
88 | 88 | $data = array(); |
89 | 89 | if ($row['registration'] != '') { |
90 | 90 | $image_array = $Image->getSpotterImage($row['registration']); |
91 | - 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'])); |
|
92 | - else $data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => '')); |
|
91 | + if (count($image_array) > 0) { |
|
92 | + $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'])); |
|
93 | + } else { |
|
94 | + $data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => '')); |
|
95 | + } |
|
93 | 96 | $aircraft_type = $Spotter->getAllAircraftTypeByRegistration($row['registration']); |
94 | 97 | $aircraft_info = $Spotter->getAllAircraftInfo($aircraft_type); |
95 | 98 | if (!empty($aircraft_info)) { |
@@ -105,17 +108,30 @@ discard block |
||
105 | 108 | $data['aircraft_base'] = $owner_data['base']; |
106 | 109 | $data['aircraft_date_first_reg'] = $owner_data['date_first_reg']; |
107 | 110 | } |
108 | - } else $data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => '')); |
|
109 | - if ($row['registration'] == '') $row['registration'] = 'NA'; |
|
110 | - if ($row['ident'] == '') $row['ident'] = 'NA'; |
|
111 | + } else { |
|
112 | + $data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => '')); |
|
113 | + } |
|
114 | + if ($row['registration'] == '') { |
|
115 | + $row['registration'] = 'NA'; |
|
116 | + } |
|
117 | + if ($row['ident'] == '') { |
|
118 | + $row['ident'] = 'NA'; |
|
119 | + } |
|
111 | 120 | $identicao = $Spotter->getAllAirlineInfo(substr($row['ident'],0,3)); |
112 | 121 | if (isset($identicao[0])) { |
113 | 122 | if (substr($row['ident'],0,2) == 'AF') { |
114 | - if (filter_var(substr($row['ident'],2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $row['ident']; |
|
115 | - else $icao = 'AFR'.ltrim(substr($row['ident'],2),'0'); |
|
116 | - } else $icao = $identicao[0]['icao'].ltrim(substr($row['ident'],2),'0'); |
|
123 | + if (filter_var(substr($row['ident'],2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) { |
|
124 | + $icao = $row['ident']; |
|
125 | + } else { |
|
126 | + $icao = 'AFR'.ltrim(substr($row['ident'],2),'0'); |
|
127 | + } |
|
128 | + } else { |
|
129 | + $icao = $identicao[0]['icao'].ltrim(substr($row['ident'],2),'0'); |
|
130 | + } |
|
117 | 131 | $data = array_merge($data,array('airline_icao' => $identicao[0]['icao'],'airline_name' => $identicao[0]['name'])); |
118 | - } else $icao = $row['ident']; |
|
132 | + } else { |
|
133 | + $icao = $row['ident']; |
|
134 | + } |
|
119 | 135 | $icao = $Translation->checkTranslation($icao,false); |
120 | 136 | //$data = array_merge($data,array('registration' => $row['registration'], 'date' => $row['date'], 'ident' => $icao,'url' => $row['url'])); |
121 | 137 | if ($row['airline_name'] != '' && !isset($data['airline_name'])) { |
@@ -130,18 +146,23 @@ discard block |
||
130 | 146 | //else echo 'No data...'."\n"; |
131 | 147 | } |
132 | 148 | $data = array_merge($row,$data); |
133 | - if ($data['ident'] == null) $data['ident'] = $icao; |
|
149 | + if ($data['ident'] == null) { |
|
150 | + $data['ident'] = $icao; |
|
151 | + } |
|
134 | 152 | if ($data['title'] == null) { |
135 | 153 | $data['message'] = $row['type'].' of '.$row['registration'].' at '.$row['place'].','.$row['country']; |
136 | - } else $data['message'] = strtolower($data['title']); |
|
154 | + } else { |
|
155 | + $data['message'] = strtolower($data['title']); |
|
156 | + } |
|
137 | 157 | $result[] = $data; |
138 | 158 | $i++; |
139 | 159 | } |
140 | 160 | if (isset($result)) { |
141 | 161 | $result[0]['query_number_rows'] = $i; |
142 | 162 | return $result; |
163 | + } else { |
|
164 | + return array(); |
|
143 | 165 | } |
144 | - else return array(); |
|
145 | 166 | } |
146 | 167 | |
147 | 168 | /* |
@@ -180,7 +201,9 @@ discard block |
||
180 | 201 | */ |
181 | 202 | public function import($file) { |
182 | 203 | global $globalTransaction, $globalDebug; |
183 | - if ($globalDebug) echo 'Import '.$file."\n"; |
|
204 | + if ($globalDebug) { |
|
205 | + echo 'Import '.$file."\n"; |
|
206 | + } |
|
184 | 207 | $result = array(); |
185 | 208 | if (file_exists($file)) { |
186 | 209 | if (($handle = fopen($file,'r')) !== FALSE) { |
@@ -191,8 +214,11 @@ discard block |
||
191 | 214 | } |
192 | 215 | fclose($handle); |
193 | 216 | } |
194 | - if (!empty($result)) $this->add($result,true); |
|
195 | - elseif ($globalDebug) echo 'Nothing to import'; |
|
217 | + if (!empty($result)) { |
|
218 | + $this->add($result,true); |
|
219 | + } elseif ($globalDebug) { |
|
220 | + echo 'Nothing to import'; |
|
221 | + } |
|
196 | 222 | } |
197 | 223 | } |
198 | 224 | |
@@ -228,14 +254,23 @@ discard block |
||
228 | 254 | } |
229 | 255 | } |
230 | 256 | fclose($handle); |
231 | - } elseif ($globalDebug) echo "Can't open ".dirname(__FILE__).'/../install/tmp/cr-all.md5'; |
|
232 | - } elseif ($globalDebug) echo 'Download cr-all.md5 failed. '.dirname(__FILE__).'/../install/tmp/cr-all.md5 not here.'; |
|
257 | + } elseif ($globalDebug) { |
|
258 | + echo "Can't open ".dirname(__FILE__).'/../install/tmp/cr-all.md5'; |
|
259 | + } |
|
260 | + } elseif ($globalDebug) { |
|
261 | + echo 'Download cr-all.md5 failed. '.dirname(__FILE__).'/../install/tmp/cr-all.md5 not here.'; |
|
262 | + } |
|
233 | 263 | $result = $Common->arr_diff($all_md5_new,$all_md5); |
234 | - if (empty($result) && $globalDebug) echo 'Nothing to update'; |
|
264 | + if (empty($result) && $globalDebug) { |
|
265 | + echo 'Nothing to update'; |
|
266 | + } |
|
235 | 267 | foreach ($result as $file => $md5) { |
236 | 268 | $Common->download('http://data.flightairmap.fr/data/cr/'.$file,dirname(__FILE__).'/../install/tmp/'.$file); |
237 | - if (file_exists(dirname(__FILE__).'/../install/tmp/'.$file)) $this->import(dirname(__FILE__).'/../install/tmp/'.$file); |
|
238 | - elseif ($globalDebug) echo 'Download '.$file.' failed'; |
|
269 | + if (file_exists(dirname(__FILE__).'/../install/tmp/'.$file)) { |
|
270 | + $this->import(dirname(__FILE__).'/../install/tmp/'.$file); |
|
271 | + } elseif ($globalDebug) { |
|
272 | + echo 'Download '.$file.' failed'; |
|
273 | + } |
|
239 | 274 | } |
240 | 275 | } |
241 | 276 | |
@@ -252,13 +287,17 @@ discard block |
||
252 | 287 | $Image = new Image(); |
253 | 288 | $Spotter = new Spotter(); |
254 | 289 | |
255 | - if (empty($crash)) return false; |
|
290 | + if (empty($crash)) { |
|
291 | + return false; |
|
292 | + } |
|
256 | 293 | if (!$new) { |
257 | 294 | $query_delete = 'DELETE FROM accidents WHERE source = :source'; |
258 | 295 | $sthd = $Connection->db->prepare($query_delete); |
259 | 296 | $sthd->execute(array(':source' => $crash[0]['source'])); |
260 | 297 | } |
261 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
298 | + if ($globalTransaction) { |
|
299 | + $Connection->db->beginTransaction(); |
|
300 | + } |
|
262 | 301 | $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); |
263 | 302 | $query_check = 'SELECT COUNT(*) as nb FROM accidents WHERE registration = :registration AND date = :date AND type = :type AND source = :source'; |
264 | 303 | $sth_check = $Connection->db->prepare($query_check); |
@@ -273,7 +312,9 @@ discard block |
||
273 | 312 | return $value === "" ? NULL : $value; |
274 | 313 | }, $cr); |
275 | 314 | if ($cr['date'] != '' && $cr['registration'] != null && $cr['registration'] != '' && $cr['registration'] != '?' && $cr['registration'] != '-' && strtolower($cr['registration']) != 'unknown' && $cr['date'] < time() && !preg_match('/\s/',$cr['registration'])) { |
276 | - if (strpos($cr['registration'],'-') === FALSE) $cr['registration'] = $Spotter->convertAircraftRegistration($cr['registration']); |
|
315 | + if (strpos($cr['registration'],'-') === FALSE) { |
|
316 | + $cr['registration'] = $Spotter->convertAircraftRegistration($cr['registration']); |
|
317 | + } |
|
277 | 318 | $query_check_values = array(':registration' => $cr['registration'],':date' => date('Y-m-d',$cr['date']),':type' => $cr['type'],':source' => $cr['source']); |
278 | 319 | $sth_check->execute($query_check_values); |
279 | 320 | $result_check = $sth_check->fetch(PDO::FETCH_ASSOC); |
@@ -295,9 +336,13 @@ discard block |
||
295 | 336 | $Connection->db->beginTransaction(); |
296 | 337 | } |
297 | 338 | } |
298 | - if ($globalTransaction) $Connection->db->commit(); |
|
339 | + if ($globalTransaction) { |
|
340 | + $Connection->db->commit(); |
|
341 | + } |
|
299 | 342 | } catch(PDOException $e) { |
300 | - if ($globalTransaction) $Connection->db->rollBack(); |
|
343 | + if ($globalTransaction) { |
|
344 | + $Connection->db->rollBack(); |
|
345 | + } |
|
301 | 346 | echo $e->getMessage(); |
302 | 347 | } |
303 | 348 | $sth_check->closeCursor(); |
@@ -336,8 +381,11 @@ discard block |
||
336 | 381 | return "error : ".$e->getMessage(); |
337 | 382 | } |
338 | 383 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
339 | - if ($row['nb'] > 0) return false; |
|
340 | - else return true; |
|
384 | + if ($row['nb'] > 0) { |
|
385 | + return false; |
|
386 | + } else { |
|
387 | + return true; |
|
388 | + } |
|
341 | 389 | } |
342 | 390 | |
343 | 391 | public static function insert_last_accidents_update() { |
@@ -6,7 +6,9 @@ discard block |
||
6 | 6 | $Stats = new Stats(); |
7 | 7 | $title = _("Statistics"); |
8 | 8 | |
9 | -if (!isset($filter_name)) $filter_name = ''; |
|
9 | +if (!isset($filter_name)) { |
|
10 | + $filter_name = ''; |
|
11 | +} |
|
10 | 12 | $airline_icao = (string)filter_input(INPUT_GET,'airline',FILTER_SANITIZE_STRING); |
11 | 13 | if ($airline_icao == 'all') { |
12 | 14 | unset($_COOKIE['stats_airline_icao']); |
@@ -15,8 +17,10 @@ discard block |
||
15 | 17 | } elseif ($airline_icao == '' && isset($_COOKIE['stats_airline_icao'])) { |
16 | 18 | $airline_icao = $_COOKIE['stats_airline_icao']; |
17 | 19 | } elseif ($airline_icao == '' && isset($globalFilter)) { |
18 | - if (isset($globalFilter['airline'])) $airline_icao = $globalFilter['airline'][0]; |
|
19 | -} |
|
20 | + if (isset($globalFilter['airline'])) { |
|
21 | + $airline_icao = $globalFilter['airline'][0]; |
|
22 | + } |
|
23 | + } |
|
20 | 24 | setcookie('stats_airline_icao',$airline_icao); |
21 | 25 | require_once('header.php'); |
22 | 26 | |
@@ -36,7 +40,9 @@ discard block |
||
36 | 40 | if (isset($last_update[0]['value'])) { |
37 | 41 | date_default_timezone_set('UTC'); |
38 | 42 | $lastupdate = strtotime($last_update[0]['value']); |
39 | - if (isset($globalTimezone) && $globalTimezone != '') date_default_timezone_set($globalTimezone); |
|
43 | + if (isset($globalTimezone) && $globalTimezone != '') { |
|
44 | + date_default_timezone_set($globalTimezone); |
|
45 | + } |
|
40 | 46 | print '<i>Last update: '.date('Y-m-d G:i:s',$lastupdate).'</i>'; |
41 | 47 | } |
42 | 48 | ?> |
@@ -89,8 +95,9 @@ discard block |
||
89 | 95 | <h2><?php echo _("Top 10 Most Common Aircraft Type"); ?></h2> |
90 | 96 | <?php |
91 | 97 | $aircraft_array = $Stats->countAllAircraftTypes(true,$airline_icao,$filter_name); |
92 | - if (count($aircraft_array) == 0) print _("No data available"); |
|
93 | - else { |
|
98 | + if (count($aircraft_array) == 0) { |
|
99 | + print _("No data available"); |
|
100 | + } else { |
|
94 | 101 | |
95 | 102 | print '<div id="chart1" class="chart" width="100%"></div> |
96 | 103 | <script> |
@@ -186,8 +193,9 @@ discard block |
||
186 | 193 | <h2><?php echo _("Top 10 Most Common Pilots"); ?></h2> |
187 | 194 | <?php |
188 | 195 | $pilot_array = $Stats->countAllPilots(true,$airline_icao,$filter_name); |
189 | - if (count($pilot_array) == 0) print _("No data available"); |
|
190 | - else { |
|
196 | + if (count($pilot_array) == 0) { |
|
197 | + print _("No data available"); |
|
198 | + } else { |
|
191 | 199 | print '<div id="chart7" class="chart" width="100%"></div> |
192 | 200 | <script> |
193 | 201 | google.load("visualization", "1", {packages:["corechart"]}); |
@@ -232,8 +240,9 @@ discard block |
||
232 | 240 | <h2><?php echo _("Top 10 Most Common Owners"); ?></h2> |
233 | 241 | <?php |
234 | 242 | $owner_array = $Stats->countAllOwners(true,$airline_icao,$filter_name); |
235 | - if (count($owner_array) == 0) print _("No data available"); |
|
236 | - else { |
|
243 | + if (count($owner_array) == 0) { |
|
244 | + print _("No data available"); |
|
245 | + } else { |
|
237 | 246 | print '<div id="chart7" class="chart" width="100%"></div> |
238 | 247 | <script> |
239 | 248 | google.load("visualization", "1", {packages:["corechart"]}); |
@@ -279,8 +288,9 @@ discard block |
||
279 | 288 | <h2><?php echo _("Top 20 Most Common Country a Flight was Over"); ?></h2> |
280 | 289 | <?php |
281 | 290 | //$flightover_array = $Stats->countAllFlightOverCountries(); |
282 | - if (count($flightover_array) == 0) print _("No data available"); |
|
283 | - else { |
|
291 | + if (count($flightover_array) == 0) { |
|
292 | + print _("No data available"); |
|
293 | + } else { |
|
284 | 294 | print '<div id="chart10" class="chart" width="100%"></div> |
285 | 295 | <script> |
286 | 296 | google.load("visualization", "1", {packages:["corechart"]}); |
@@ -424,8 +434,9 @@ discard block |
||
424 | 434 | <h2><?php echo _("Busiest Months of the last 12 Months"); ?></h2> |
425 | 435 | <?php |
426 | 436 | $year_array = $Stats->countAllMonthsLastYear(true,$airline_icao,$filter_name); |
427 | - if (count($year_array) == 0) print _("No data available"); |
|
428 | - else { |
|
437 | + if (count($year_array) == 0) { |
|
438 | + print _("No data available"); |
|
439 | + } else { |
|
429 | 440 | print '<div id="chart8" class="chart" width="100%"></div> |
430 | 441 | <script> |
431 | 442 | google.load("visualization", "1", {packages:["corechart"]}); |
@@ -470,8 +481,9 @@ discard block |
||
470 | 481 | <h2><?php echo _("Busiest Day in the last Month"); ?></h2> |
471 | 482 | <?php |
472 | 483 | $month_array = $Stats->countAllDatesLastMonth($airline_icao,$filter_name); |
473 | - if (count($month_array) == 0) print _("No data available"); |
|
474 | - else { |
|
484 | + if (count($month_array) == 0) { |
|
485 | + print _("No data available"); |
|
486 | + } else { |
|
475 | 487 | print '<div id="chart9" class="chart" width="100%"></div> |
476 | 488 | <script> |
477 | 489 | google.load("visualization", "1", {packages:["corechart"]}); |
@@ -516,8 +528,9 @@ discard block |
||
516 | 528 | <h2><?php echo _("Busiest Day in the last 7 Days"); ?></h2> |
517 | 529 | <?php |
518 | 530 | $date_array = $Stats->countAllDatesLast7Days($airline_icao,$filter_name); |
519 | - if (empty($date_array)) print _("No data available"); |
|
520 | - else { |
|
531 | + if (empty($date_array)) { |
|
532 | + print _("No data available"); |
|
533 | + } else { |
|
521 | 534 | print '<div id="chart5" class="chart" width="100%"></div> |
522 | 535 | <script> |
523 | 536 | google.load("visualization", "1", {packages:["corechart"]}); |
@@ -563,8 +576,9 @@ discard block |
||
563 | 576 | <h2><?php echo _("Busiest Time of the Day"); ?></h2> |
564 | 577 | <?php |
565 | 578 | $hour_array = $Stats->countAllHours('hour',true,$airline_icao,$filter_name); |
566 | - if (empty($hour_array)) print _("No data available"); |
|
567 | - else { |
|
579 | + if (empty($hour_array)) { |
|
580 | + print _("No data available"); |
|
581 | + } else { |
|
568 | 582 | |
569 | 583 | print '<div id="chart6" class="chart" width="100%"></div> |
570 | 584 | <script> |
@@ -616,8 +630,9 @@ discard block |
||
616 | 630 | require_once('require/class.Accident.php'); |
617 | 631 | $Accident = new Accident(); |
618 | 632 | $year_array = $Accident->countFatalitiesByYear($filter_name); |
619 | - if (count($year_array) == 0) print _("No data available"); |
|
620 | - else { |
|
633 | + if (count($year_array) == 0) { |
|
634 | + print _("No data available"); |
|
635 | + } else { |
|
621 | 636 | print '<div id="chart32" class="chart" width="100%"></div> |
622 | 637 | <script> |
623 | 638 | google.load("visualization", "1", {packages:["corechart"]}); |
@@ -665,8 +680,9 @@ discard block |
||
665 | 680 | require_once('require/class.Accident.php'); |
666 | 681 | $Accident = new Accident(); |
667 | 682 | $year_array = $Accident->countFatalitiesLast12Months($filter_name); |
668 | - if (count($year_array) == 0) print _("No data available"); |
|
669 | - else { |
|
683 | + if (count($year_array) == 0) { |
|
684 | + print _("No data available"); |
|
685 | + } else { |
|
670 | 686 | print '<div id="chart33" class="chart" width="100%"></div> |
671 | 687 | <script> |
672 | 688 | google.load("visualization", "1", {packages:["corechart"]}); |
@@ -737,8 +753,11 @@ discard block |
||
737 | 753 | $distance = $distance; |
738 | 754 | $unit = 'km'; |
739 | 755 | } |
740 | - if (!isset($polar_data)) $polar_data = '{axis:"'.$direction[0]['direction_shortname'].'",value:'.$key.'}'; |
|
741 | - else $polar_data = $polar_data.',{axis:"'.$direction[0]['direction_shortname'].'",value:'.$key.'}'; |
|
756 | + if (!isset($polar_data)) { |
|
757 | + $polar_data = '{axis:"'.$direction[0]['direction_shortname'].'",value:'.$key.'}'; |
|
758 | + } else { |
|
759 | + $polar_data = $polar_data.',{axis:"'.$direction[0]['direction_shortname'].'",value:'.$key.'}'; |
|
760 | + } |
|
742 | 761 | } |
743 | 762 | ?> |
744 | 763 | <div class="col-md-6"> |
@@ -785,8 +804,11 @@ discard block |
||
785 | 804 | foreach ($msg as $eachmsg) { |
786 | 805 | //$eachmsg = $msg[0]; |
787 | 806 | $data = $eachmsg['source_data']; |
788 | - if ($data > 500) $max = (round(($data+100)/100))*100; |
|
789 | - else $max = 500; |
|
807 | + if ($data > 500) { |
|
808 | + $max = (round(($data+100)/100))*100; |
|
809 | + } else { |
|
810 | + $max = 500; |
|
811 | + } |
|
790 | 812 | ?> |
791 | 813 | <div id="msg-<?php print str_replace(' ','_',strtolower($eachmsg['source_name'])); ?>" class="col-md-4"></div> |
792 | 814 | <script> |