Completed
Push — master ( ed2ab5...76a3f8 )
by Yannick
29:35
created
statistics.php 1 patch
Braces   +145 added lines, -69 removed lines patch added patch discarded remove patch
@@ -18,11 +18,15 @@  discard block
 block discarded – undo
18 18
 	require_once('require/class.Spotter.php');
19 19
 }
20 20
 
21
-if (!isset($filter_name)) $filter_name = '';
21
+if (!isset($filter_name)) {
22
+	$filter_name = '';
23
+}
22 24
 $airline_icao = (string)filter_input(INPUT_GET,'airline',FILTER_SANITIZE_STRING);
23 25
 if ($type == 'aircraft' && $airline_icao == '' && isset($globalFilter)) {
24
-	if (isset($globalFilter['airline'])) $airline_icao = $globalFilter['airline'][0];
25
-}
26
+	if (isset($globalFilter['airline'])) {
27
+		$airline_icao = $globalFilter['airline'][0];
28
+	}
29
+	}
26 30
 if ($type == 'aircraft' && $airline_icao != '' && $airline_icao != 'all') {
27 31
 	$Spotter = new Spotter();
28 32
 	$airline_info = $Spotter->getAllAirlineInfo($airline_icao);
@@ -53,7 +57,12 @@  discard block
 block discarded – undo
53 57
 <script type="text/javascript" src="<?php echo $globalURL; ?>/js/datamaps.world.min.js"></script>
54 58
 <div class="column">
55 59
     <div class="info">
56
-            <h1><?php if (isset($airline_name)) echo _("Statistics for ").$airline_name; else echo _("Statistics"); ?></h1>
60
+            <h1><?php if (isset($airline_name)) {
61
+	echo _("Statistics for ").$airline_name;
62
+} else {
63
+	echo _("Statistics");
64
+}
65
+?></h1>
57 66
 <?php 
58 67
 	if ($type == 'aircraft') {
59 68
 		$last_update = $Stats->getLastStatsUpdate();
@@ -61,7 +70,9 @@  discard block
 block discarded – undo
61 70
 		if (isset($last_update[0]['value'])) {
62 71
 			date_default_timezone_set('UTC');
63 72
 			$lastupdate = strtotime($last_update[0]['value']);
64
-			if (isset($globalTimezone) && $globalTimezone != '') date_default_timezone_set($globalTimezone);
73
+			if (isset($globalTimezone) && $globalTimezone != '') {
74
+				date_default_timezone_set($globalTimezone);
75
+			}
65 76
 			print '<i>Last update: '.date('Y-m-d G:i:s',$lastupdate).'</i>';
66 77
 		}
67 78
 	}
@@ -139,14 +150,18 @@  discard block
 block discarded – undo
139 150
                 <h2><?php echo _("Top 10 Most Common Aircraft Type"); ?></h2>
140 151
                  <?php
141 152
                   $aircraft_array = $Stats->countAllAircraftTypes(true,$airline_icao,$filter_name,$year,$month);
142
-		    if (count($aircraft_array) == 0) print _("No data available");
143
-		    else {
153
+		    if (count($aircraft_array) == 0) {
154
+		    	print _("No data available");
155
+		    } else {
144 156
                     print '<div id="chart1" class="chart" width="100%"></div><script>';
145 157
                     $aircraft_data = '';
146 158
                     foreach($aircraft_array as $aircraft_item)
147 159
                     {
148
-                        if ($aircraft_item['aircraft_manufacturer'] == 'Not Available') $aircraft_data .= '[" ('.$aircraft_item['aircraft_icao'].')",'.$aircraft_item['aircraft_icao_count'].'],';
149
-                        else $aircraft_data .= '["'.$aircraft_item['aircraft_manufacturer'].' '.$aircraft_item['aircraft_name'].' ('.$aircraft_item['aircraft_icao'].')",'.$aircraft_item['aircraft_icao_count'].'],';
160
+                        if ($aircraft_item['aircraft_manufacturer'] == 'Not Available') {
161
+                        	$aircraft_data .= '[" ('.$aircraft_item['aircraft_icao'].')",'.$aircraft_item['aircraft_icao_count'].'],';
162
+                        } else {
163
+                        	$aircraft_data .= '["'.$aircraft_item['aircraft_manufacturer'].' '.$aircraft_item['aircraft_name'].' ('.$aircraft_item['aircraft_icao'].')",'.$aircraft_item['aircraft_icao_count'].'],';
164
+                        }
150 165
                     }
151 166
                     $aircraft_data = substr($aircraft_data, 0, -1);
152 167
 		    print 'var series = ['.$aircraft_data.'];';
@@ -163,11 +178,17 @@  discard block
 block discarded – undo
163 178
             	    <?php
164 179
             		if ($year != '' && $month != '') {
165 180
             	    ?>
166
-            	    <a href="<?php print $globalURL; ?>/statistics/aircraft<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>/<?php echo $year; ?>/<?php echo $month ?>/" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
181
+            	    <a href="<?php print $globalURL; ?>/statistics/aircraft<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
182
+	echo '/'.$airline_icao;
183
+}
184
+?>/<?php echo $year; ?>/<?php echo $month ?>/" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
167 185
             	    <?php
168 186
             		} else {
169 187
             	    ?>
170
-            	    <a href="<?php print $globalURL; ?>/statistics/aircraft<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
188
+            	    <a href="<?php print $globalURL; ?>/statistics/aircraft<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
189
+	echo '/'.$airline_icao;
190
+}
191
+?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
171 192
             	    <?php
172 193
             		}
173 194
             	    ?>
@@ -198,11 +219,15 @@  discard block
 block discarded – undo
198 219
 				print '</script>';
199 220
 				if ($year != '' && $month != '') {
200 221
 					print '<div class="more"><a href="'.$globalURL.'/statistics/airline';
201
-					if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao;
222
+					if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
223
+						echo '/'.$airline_icao;
224
+					}
202 225
 					print '/'.$year.'/'.$month.'/" class="btn btn-default btn" role="button">'._("See full statistic").'&raquo;</a></div>';
203 226
 				} else {
204 227
 					print '<div class="more"><a href="'.$globalURL.'/statistics/airline';
205
-					if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao;
228
+					if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
229
+						echo '/'.$airline_icao;
230
+					}
206 231
 					print '" class="btn btn-default btn" role="button">'._("See full statistic").'&raquo;</a></div>';
207 232
 				}
208 233
 				print '</div>';
@@ -224,8 +249,9 @@  discard block
 block discarded – undo
224 249
                 <h2><?php echo _("Top 10 Most Common Vessel Type"); ?></h2>
225 250
                  <?php
226 251
                     $marine_array = $Marine->countAllMarineTypes(true,0,'',array(),$year,$month);
227
-		    if (count($marine_array) == 0) print _("No data available");
228
-		    else {
252
+		    if (count($marine_array) == 0) {
253
+		    	print _("No data available");
254
+		    } else {
229 255
                     print '<div id="chart1" class="chart" width="100%"></div><script>';
230 256
                     $marine_data = '';
231 257
                     foreach($marine_array as $marine_item)
@@ -272,8 +298,9 @@  discard block
 block discarded – undo
272 298
                 <h2><?php echo _("Top 10 Most Common Tracker Type"); ?></h2>
273 299
                  <?php
274 300
                   $tracker_array = $Tracker->countAllTrackerTypes(true,0,'',array(),$year,$month);
275
-		    if (count($tracker_array) == 0) print _("No data available");
276
-		    else {
301
+		    if (count($tracker_array) == 0) {
302
+		    	print _("No data available");
303
+		    } else {
277 304
                     print '<div id="chart1" class="chart" width="100%"></div><script>';
278 305
                     $tracker_data = '';
279 306
                     foreach($tracker_array as $tracker_item)
@@ -328,8 +355,9 @@  discard block
 block discarded – undo
328 355
                 <h2><?php echo _("Top 10 Most Common Pilots"); ?></h2>
329 356
 <?php
330 357
 			$pilot_array = $Stats->countAllPilots(true,$airline_icao,$filter_name,$year,$month);
331
-			if (count($pilot_array) == 0) print _("No data available");
332
-			else {
358
+			if (count($pilot_array) == 0) {
359
+				print _("No data available");
360
+			} else {
333 361
 				print '<div id="chart7" class="chart" width="100%"></div><script>';
334 362
 				$pilot_data = '';
335 363
 				foreach($pilot_array as $pilot_item)
@@ -348,7 +376,9 @@  discard block
 block discarded – undo
348 376
 			}
349 377
 			print '<div class="more">';
350 378
 			print '<a href="'.$globalURL.'/statistics/pilot'; 
351
-			if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao;
379
+			if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
380
+				echo '/'.$airline_icao;
381
+			}
352 382
 			print'" class="btn btn-default btn" role="button">'._("See full statistic").'&raquo;</a>';
353 383
 			print '</div>';
354 384
 ?>
@@ -362,8 +392,9 @@  discard block
 block discarded – undo
362 392
                 <h2><?php echo _("Top 10 Most Common Owners"); ?></h2>
363 393
 <?php
364 394
 			$owner_array = $Stats->countAllOwners(true,$airline_icao,$filter_name,$year,$month);
365
-			if (count($owner_array) == 0) print _("No data available");
366
-			else {
395
+			if (count($owner_array) == 0) {
396
+				print _("No data available");
397
+			} else {
367 398
 				print '<div id="chart7" class="chart" width="100%"></div><script>';
368 399
 				$owner_data = '';
369 400
 				foreach($owner_array as $owner_item)
@@ -382,7 +413,10 @@  discard block
 block discarded – undo
382 413
 			}
383 414
 ?>
384 415
                 <div class="more">
385
-                    <a href="<?php print $globalURL; ?>/statistics/owner<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
416
+                    <a href="<?php print $globalURL; ?>/statistics/owner<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
417
+	echo '/'.$airline_icao;
418
+}
419
+?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
386 420
                 </div>
387 421
             </div>
388 422
         
@@ -395,8 +429,9 @@  discard block
 block discarded – undo
395 429
                 <h2><?php echo _("Top 20 Most Common Country a Flight was Over"); ?></h2>
396 430
 <?php
397 431
 	 //$flightover_array = $Stats->countAllFlightOverCountries();
398
-			if (count($flightover_array) == 0) print _("No data available");
399
-			else {
432
+			if (count($flightover_array) == 0) {
433
+				print _("No data available");
434
+			} else {
400 435
 				print '<div id="chart10" class="chart" width="100%"></div><script>';
401 436
 				print 'var series = [';
402 437
 				$flightover_data = '';
@@ -439,7 +474,10 @@  discard block
 block discarded – undo
439 474
 			}
440 475
 ?>
441 476
                 <div class="more">
442
-                    <a href="<?php print $globalURL; ?>/statistics/country<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
477
+                    <a href="<?php print $globalURL; ?>/statistics/country<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
478
+	echo '/'.$airline_icao;
479
+}
480
+?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
443 481
                 </div>
444 482
             </div>
445 483
 <?php
@@ -461,8 +499,9 @@  discard block
 block discarded – undo
461 499
 	<div class="col-md-6">
462 500
             <h2><?php echo _("Top 20 Most Common Country a Vessel was inside"); ?></h2>
463 501
 <?php
464
-		if (count($flightover_array) == 0) print _("No data available");
465
-		else {
502
+		if (count($flightover_array) == 0) {
503
+			print _("No data available");
504
+		} else {
466 505
 			print '<div id="chart10" class="chart" width="100%"></div><script>';
467 506
 			print 'var series = [';
468 507
 			$flightover_data = '';
@@ -521,8 +560,9 @@  discard block
 block discarded – undo
521 560
 	<div class="col-md-6">
522 561
             <h2><?php echo _("Top 20 Most Common Country a Tracker was inside"); ?></h2>
523 562
 <?php
524
-		if (count($flightover_array) == 0) print _("No data available");
525
-		else {
563
+		if (count($flightover_array) == 0) {
564
+			print _("No data available");
565
+		} else {
526 566
 			print '<div id="chart10" class="chart" width="100%"></div><script>';
527 567
 			print 'var series = [';
528 568
 			$flightover_data = '';
@@ -632,7 +672,9 @@  discard block
 block discarded – undo
632 672
 			});";
633 673
 			print '</script>';
634 674
 			print '<div class="more"><a href="'.$globalURL.'/statistics/airport-departure'; 
635
-			if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao;
675
+			if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
676
+				echo '/'.$airline_icao;
677
+			}
636 678
 			print '" class="btn btn-default btn" role="button">'._("See full statistic").'&raquo;</a></div>';
637 679
 		}
638 680
 ?>
@@ -694,7 +736,9 @@  discard block
 block discarded – undo
694 736
 			});";
695 737
 			print '</script>';
696 738
 			print '<div class="more"><a href="'.$globalURL.'/statistics/airport-arrival';
697
-			if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao;
739
+			if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
740
+				echo '/'.$airline_icao;
741
+			}
698 742
 			print '" class="btn btn-default btn" role="button">'._("See full statistic").'&raquo;</a></div>';
699 743
 		}
700 744
 ?>
@@ -715,8 +759,9 @@  discard block
 block discarded – undo
715 759
                 <h2><?php echo _("Busiest Months of the last 12 Months"); ?></h2>
716 760
 <?php
717 761
 			$year_array = $Stats->countAllMonthsLastYear(true,$airline_icao,$filter_name);
718
-			if (count($year_array) == 0) print _("No data available");
719
-			else {
762
+			if (count($year_array) == 0) {
763
+				print _("No data available");
764
+			} else {
720 765
 				print '<div id="chart8" class="chart" width="100%"></div><script>';
721 766
 				$year_data = '';
722 767
 				$year_cnt = '';
@@ -736,7 +781,10 @@  discard block
 block discarded – undo
736 781
 			}
737 782
 ?>
738 783
                 <div class="more">
739
-                    <a href="<?php print $globalURL; ?>/statistics/year<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
784
+                    <a href="<?php print $globalURL; ?>/statistics/year<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
785
+	echo '/'.$airline_icao;
786
+}
787
+?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
740 788
                 </div>
741 789
             </div>
742 790
     <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
@@ -744,8 +792,9 @@  discard block
 block discarded – undo
744 792
                 <h2><?php echo _("Busiest Day in the last Month"); ?></h2>
745 793
 <?php
746 794
 			$month_array = $Stats->countAllDatesLastMonth($airline_icao,$filter_name);
747
-			if (count($month_array) == 0) print _("No data available");
748
-			else {
795
+			if (count($month_array) == 0) {
796
+				print _("No data available");
797
+			} else {
749 798
 				print '<div id="chart9" class="chart" width="100%"></div><script>';
750 799
 				$month_data = '';
751 800
 				$month_cnt = '';
@@ -765,7 +814,10 @@  discard block
 block discarded – undo
765 814
 			}
766 815
 ?>
767 816
                 <div class="more">
768
-                    <a href="<?php print $globalURL; ?>/statistics/month<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
817
+                    <a href="<?php print $globalURL; ?>/statistics/month<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
818
+	echo '/'.$airline_icao;
819
+}
820
+?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
769 821
                 </div>
770 822
             </div>
771 823
     <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
@@ -774,8 +826,9 @@  discard block
 block discarded – undo
774 826
                 <h2><?php echo _("Busiest Day in the last 7 Days"); ?></h2>
775 827
 <?php
776 828
 			$date_array = $Stats->countAllDatesLast7Days($airline_icao,$filter_name);
777
-			if (empty($date_array)) print _("No data available");
778
-			else {
829
+			if (empty($date_array)) {
830
+				print _("No data available");
831
+			} else {
779 832
 				print '<div id="chart5" class="chart" width="100%"></div><script>';
780 833
 				$date_data = '';
781 834
 				$date_cnt = '';
@@ -795,7 +848,10 @@  discard block
 block discarded – undo
795 848
 			}
796 849
 ?>
797 850
                 <div class="more">
798
-                    <a href="<?php print $globalURL; ?>/statistics/date<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
851
+                    <a href="<?php print $globalURL; ?>/statistics/date<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
852
+	echo '/'.$airline_icao;
853
+}
854
+?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
799 855
                 </div>
800 856
             </div>
801 857
     <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
@@ -803,8 +859,9 @@  discard block
 block discarded – undo
803 859
                 <h2><?php echo _("Busiest Time of the Day"); ?></h2>
804 860
 <?php
805 861
 			$hour_array = $Stats->countAllHours('hour',true,$airline_icao,$filter_name);
806
-			if (empty($hour_array)) print _("No data available");
807
-			else {
862
+			if (empty($hour_array)) {
863
+				print _("No data available");
864
+			} else {
808 865
 				print '<div id="chart6" class="chart" width="100%"></div><script>';
809 866
 				$hour_data = '';
810 867
 				$hour_cnt = '';
@@ -824,7 +881,10 @@  discard block
 block discarded – undo
824 881
 			}
825 882
 ?>
826 883
                 <div class="more">
827
-                    <a href="<?php print $globalURL; ?>/statistics/time<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
884
+                    <a href="<?php print $globalURL; ?>/statistics/time<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
885
+	echo '/'.$airline_icao;
886
+}
887
+?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
828 888
                 </div>
829 889
             </div>
830 890
     <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
@@ -846,8 +906,9 @@  discard block
 block discarded – undo
846 906
                 <h2><?php echo _("Busiest Months of the last 12 Months"); ?></h2>
847 907
 <?php
848 908
 			$year_array = $Marine->countAllMonthsLastYear(true,$airline_icao,$filter_name);
849
-			if (count($year_array) == 0) print _("No data available");
850
-			else {
909
+			if (count($year_array) == 0) {
910
+				print _("No data available");
911
+			} else {
851 912
 				print '<div id="chart8" class="chart" width="100%"></div><script>';
852 913
 				$year_data = '';
853 914
 				$year_cnt = '';
@@ -876,8 +937,9 @@  discard block
 block discarded – undo
876 937
                 <h2><?php echo _("Busiest Day in the last Month"); ?></h2>
877 938
 <?php
878 939
 			$month_array = $Marine->countAllDatesLastMonth($airline_icao,$filter_name);
879
-			if (count($month_array) == 0) print _("No data available");
880
-			else {
940
+			if (count($month_array) == 0) {
941
+				print _("No data available");
942
+			} else {
881 943
 				print '<div id="chart9" class="chart" width="100%"></div><script>';
882 944
 				$month_data = '';
883 945
 				$month_cnt = '';
@@ -906,8 +968,9 @@  discard block
 block discarded – undo
906 968
                 <h2><?php echo _("Busiest Day in the last 7 Days"); ?></h2>
907 969
 <?php
908 970
 			$date_array = $Marine->countAllDatesLast7Days($airline_icao,$filter_name);
909
-			if (empty($date_array)) print _("No data available");
910
-			else {
971
+			if (empty($date_array)) {
972
+				print _("No data available");
973
+			} else {
911 974
 				print '<div id="chart5" class="chart" width="100%"></div><script>';
912 975
 				$date_data = '';
913 976
 				$date_cnt = '';
@@ -935,8 +998,9 @@  discard block
 block discarded – undo
935 998
                 <h2><?php echo _("Busiest Time of the Day"); ?></h2>
936 999
 <?php
937 1000
 			$hour_array = $Marine->countAllHours('hour',true,$airline_icao,$filter_name);
938
-			if (empty($hour_array)) print _("No data available");
939
-			else {
1001
+			if (empty($hour_array)) {
1002
+				print _("No data available");
1003
+			} else {
940 1004
 				print '<div id="chart6" class="chart" width="100%"></div><script>';
941 1005
 				$hour_data = '';
942 1006
 				$hour_cnt = '';
@@ -978,8 +1042,9 @@  discard block
 block discarded – undo
978 1042
                 <h2><?php echo _("Busiest Months of the last 12 Months"); ?></h2>
979 1043
 <?php
980 1044
 			$year_array = $Tracker->countAllMonthsLastYear(true);
981
-			if (count($year_array) == 0) print _("No data available");
982
-			else {
1045
+			if (count($year_array) == 0) {
1046
+				print _("No data available");
1047
+			} else {
983 1048
 				print '<div id="chart8" class="chart" width="100%"></div><script>';
984 1049
 				$year_data = '';
985 1050
 				$year_cnt = '';
@@ -1008,8 +1073,9 @@  discard block
 block discarded – undo
1008 1073
                 <h2><?php echo _("Busiest Day in the last Month"); ?></h2>
1009 1074
 <?php
1010 1075
 			$month_array = $Tracker->countAllDatesLastMonth();
1011
-			if (count($month_array) == 0) print _("No data available");
1012
-			else {
1076
+			if (count($month_array) == 0) {
1077
+				print _("No data available");
1078
+			} else {
1013 1079
 				print '<div id="chart9" class="chart" width="100%"></div><script>';
1014 1080
 				$month_data = '';
1015 1081
 				$month_cnt = '';
@@ -1038,8 +1104,9 @@  discard block
 block discarded – undo
1038 1104
                 <h2><?php echo _("Busiest Day in the last 7 Days"); ?></h2>
1039 1105
 <?php
1040 1106
 			$date_array = $Tracker->countAllDatesLast7Days();
1041
-			if (empty($date_array)) print _("No data available");
1042
-			else {
1107
+			if (empty($date_array)) {
1108
+				print _("No data available");
1109
+			} else {
1043 1110
 				print '<div id="chart5" class="chart" width="100%"></div><script>';
1044 1111
 				$date_data = '';
1045 1112
 				$date_cnt = '';
@@ -1067,8 +1134,9 @@  discard block
 block discarded – undo
1067 1134
                 <h2><?php echo _("Busiest Time of the Day"); ?></h2>
1068 1135
 <?php
1069 1136
 			$hour_array = $Tracker->countAllHours('hour',true);
1070
-			if (empty($hour_array)) print _("No data available");
1071
-			else {
1137
+			if (empty($hour_array)) {
1138
+				print _("No data available");
1139
+			} else {
1072 1140
 				print '<div id="chart6" class="chart" width="100%"></div><script>';
1073 1141
 				$hour_data = '';
1074 1142
 				$hour_cnt = '';
@@ -1110,8 +1178,9 @@  discard block
 block discarded – undo
1110 1178
                 <h2><?php echo _("Fatalities by Years"); ?></h2>
1111 1179
 <?php
1112 1180
 			$year_array = $Stats->countFatalitiesByYear();
1113
-			if (count($year_array) == 0) print _("No data available");
1114
-			else {
1181
+			if (count($year_array) == 0) {
1182
+				print _("No data available");
1183
+			} else {
1115 1184
 				print '<div id="chart32" class="chart" width="100%"></div><script>';
1116 1185
 				$year_data = '';
1117 1186
 				$year_cnt = '';
@@ -1141,8 +1210,9 @@  discard block
 block discarded – undo
1141 1210
                 <h2><?php echo _("Fatalities last 12 Months"); ?></h2>
1142 1211
 <?php
1143 1212
 			$year_array = $Stats->countFatalitiesLast12Months();
1144
-			if (count($year_array) == 0) print _("No data available");
1145
-			else {
1213
+			if (count($year_array) == 0) {
1214
+				print _("No data available");
1215
+			} else {
1146 1216
 				print '<div id="chart33" class="chart" width="100%"></div><script>';
1147 1217
 				$year_data = '';
1148 1218
 				$year_cnt = '';
@@ -1212,8 +1282,11 @@  discard block
 block discarded – undo
1212 1282
 							$distance = $distance;
1213 1283
 							$unit = 'km';
1214 1284
 						}
1215
-						if (!isset($polar_data)) $polar_data = '{axis:"'.$direction[0]['direction_shortname'].'",value:'.$key.'}';
1216
-						else $polar_data = $polar_data.',{axis:"'.$direction[0]['direction_shortname'].'",value:'.$key.'}';
1285
+						if (!isset($polar_data)) {
1286
+							$polar_data = '{axis:"'.$direction[0]['direction_shortname'].'",value:'.$key.'}';
1287
+						} else {
1288
+							$polar_data = $polar_data.',{axis:"'.$direction[0]['direction_shortname'].'",value:'.$key.'}';
1289
+						}
1217 1290
 					}
1218 1291
 ?>
1219 1292
             <div class="col-md-6">
@@ -1273,9 +1346,12 @@  discard block
 block discarded – undo
1273 1346
 				foreach ($msg as $eachmsg) {
1274 1347
 					//$eachmsg = $msg[0];
1275 1348
 					$data = $eachmsg['source_data'];
1276
-					if ($data > 500) $max = (round(($data+100)/100))*100;
1277
-					else $max = 500;
1278
-?>
1349
+					if ($data > 500) {
1350
+						$max = (round(($data+100)/100))*100;
1351
+					} else {
1352
+						$max = 500;
1353
+					}
1354
+					?>
1279 1355
         	<div id="msg-<?php print str_replace(' ','_',strtolower($eachmsg['source_name'])); ?>" class="col-md-4"></div>
1280 1356
         	<script>
1281 1357
 		      var g = new JustGage({
Please login to merge, or discard this patch.
require/class.MarineImport.php 1 patch
Braces   +193 added lines, -66 removed lines patch added patch discarded remove patch
@@ -53,7 +53,9 @@  discard block
 block discarded – undo
53 53
 
54 54
     public function checkAll() {
55 55
 	global $globalDebug;
56
-	if ($globalDebug) echo "Update last seen tracked data...\n";
56
+	if ($globalDebug) {
57
+		echo "Update last seen tracked data...\n";
58
+	}
57 59
 	foreach ($this->all_tracked as $key => $flight) {
58 60
 	    if (isset($this->all_tracked[$key]['id'])) {
59 61
 		//echo $this->all_tracked[$key]['id'].' - '.$this->all_tracked[$key]['latitude'].'  '.$this->all_tracked[$key]['longitude']."\n";
@@ -66,13 +68,17 @@  discard block
 block discarded – undo
66 68
     public function del() {
67 69
 	global $globalDebug, $globalNoDB, $globalNoImport;
68 70
 	// Delete old infos
69
-	if ($globalDebug) echo 'Delete old values and update latest data...'."\n";
71
+	if ($globalDebug) {
72
+		echo 'Delete old values and update latest data...'."\n";
73
+	}
70 74
 	foreach ($this->all_tracked as $key => $flight) {
71 75
     	    if (isset($flight['lastupdate'])) {
72 76
         	if ($flight['lastupdate'] < (time()-3000)) {
73 77
             	    if ((!isset($globalNoImport) || $globalNoImport !== TRUE) && (!isset($globalNoDB) || $globalNoDB !== TRUE)) {
74 78
             		if (isset($this->all_tracked[$key]['id'])) {
75
-            		    if ($globalDebug) echo "--- Delete old values with id ".$this->all_tracked[$key]['id']."\n";
79
+            		    if ($globalDebug) {
80
+            		    	echo "--- Delete old values with id ".$this->all_tracked[$key]['id']."\n";
81
+            		    }
76 82
 			    /*
77 83
 			    $MarineLive = new MarineLive();
78 84
             		    $MarineLive->deleteLiveMarineDataById($this->all_tracked[$key]['id']);
@@ -82,7 +88,9 @@  discard block
 block discarded – undo
82 88
             		    $Marine = new Marine($this->db);
83 89
             		    if ($this->all_tracked[$key]['latitude'] != '' && $this->all_tracked[$key]['longitude'] != '') {
84 90
 				$result = $Marine->updateLatestMarineData($this->all_tracked[$key]['id'],$this->all_tracked[$key]['ident'],$this->all_tracked[$key]['latitude'],$this->all_tracked[$key]['longitude'],$this->all_tracked[$key]['speed'],$this->all_tracked[$key]['datetime']);
85
-				if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
91
+				if ($globalDebug && $result != 'success') {
92
+					echo '!!! ERROR : '.$result."\n";
93
+				}
86 94
 			    }
87 95
 			    // Put in archive
88 96
 //				$Marine->db = null;
@@ -96,7 +104,9 @@  discard block
 block discarded – undo
96 104
 
97 105
     public function add($line) {
98 106
 	global $globalFork, $globalDistanceIgnore, $globalDaemon, $globalDebug, $globalCoordMinChange, $globalDebugTimeElapsed, $globalCenterLatitude, $globalCenterLongitude, $globalBeta, $globalSourcesupdate, $globalAllTracked, $globalNoImport, $globalNoDB, $globalServerAPRS,$APRSMarine;
99
-	if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') $globalCoordMinChange = '0.02';
107
+	if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') {
108
+		$globalCoordMinChange = '0.02';
109
+	}
100 110
 	date_default_timezone_set('UTC');
101 111
 	$dataFound = false;
102 112
 	$send = false;
@@ -110,20 +120,30 @@  discard block
 block discarded – undo
110 120
 		// Increment message number
111 121
 		if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE) {
112 122
 		    $current_date = date('Y-m-d');
113
-		    if (isset($line['source_name'])) $source = $line['source_name'];
114
-		    else $source = '';
115
-		    if ($source == '' || $line['format_source'] == 'aprs') $source = $line['format_source'];
123
+		    if (isset($line['source_name'])) {
124
+		    	$source = $line['source_name'];
125
+		    } else {
126
+		    	$source = '';
127
+		    }
128
+		    if ($source == '' || $line['format_source'] == 'aprs') {
129
+		    	$source = $line['format_source'];
130
+		    }
116 131
 		    if (!isset($this->stats[$current_date][$source]['msg'])) {
117 132
 		    	$this->stats[$current_date][$source]['msg']['date'] = time();
118 133
 		    	$this->stats[$current_date][$source]['msg']['nb'] = 1;
119
-		    } else $this->stats[$current_date][$source]['msg']['nb'] += 1;
134
+		    } else {
135
+		    	$this->stats[$current_date][$source]['msg']['nb'] += 1;
136
+		    }
120 137
 		}
121 138
 		
122 139
 		
123 140
 		$Common = new Common();
124 141
 		$AIS = new AIS();
125
-	        if (!isset($line['id'])) $id = trim($line['mmsi']);
126
-	        else $id = trim($line['id']);
142
+	        if (!isset($line['id'])) {
143
+	        	$id = trim($line['mmsi']);
144
+	        } else {
145
+	        	$id = trim($line['id']);
146
+	        }
127 147
 		
128 148
 		if (!isset($this->all_tracked[$id])) {
129 149
 		    $this->all_tracked[$id] = array();
@@ -131,10 +151,16 @@  discard block
 block discarded – undo
131 151
 		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => '','latitude' => '', 'longitude' => '', 'speed' => '0', 'heading' => '', 'format_source' => '','source_name' => '','comment'=> '','type' => '','typeid' => '','noarchive' => false,'putinarchive' => true,'over_country' => '','mmsi' => '','status' => '','status_id' => '','imo' => '','callsign' => '','arrival_code' => '','arrival_date' => '','mmsi_type' => ''));
132 152
 		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('lastupdate' => time()));
133 153
 		    if (!isset($line['id'])) {
134
-			if (!isset($globalDaemon)) $globalDaemon = TRUE;
154
+			if (!isset($globalDaemon)) {
155
+				$globalDaemon = TRUE;
156
+			}
135 157
 			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $id.'-'.date('YmdHi')));
136
-		     } else $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $line['id']));
137
-		    if ($globalAllTracked !== FALSE) $dataFound = true;
158
+		     } else {
159
+		     	$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $line['id']));
160
+		     }
161
+		    if ($globalAllTracked !== FALSE) {
162
+		    	$dataFound = true;
163
+		    }
138 164
 		}
139 165
 		
140 166
 		if (isset($line['mmsi']) && $line['mmsi'] != '' && $line['mmsi'] != $this->all_tracked[$id]['mmsi']) {
@@ -184,34 +210,49 @@  discard block
 block discarded – undo
184 210
 				$Marine = new Marine($this->db);
185 211
 				$fromsource = NULL;
186 212
 				$result = $Marine->updateIdentMarineData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['ident'],$fromsource);
187
-				if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
213
+				if ($globalDebug && $result != 'success') {
214
+					echo '!!! ERROR : '.$result."\n";
215
+				}
188 216
 				$Marine->db = null;
189
-				if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
217
+				if ($globalDebugTimeElapsed) {
218
+					echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
219
+				}
190 220
 			    }
191 221
 			}
192 222
 		    }
193
-		    if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident']));
223
+		    if (!isset($this->all_tracked[$id]['id'])) {
224
+		    	$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident']));
225
+		    }
194 226
 		}
195 227
 
196 228
 		if (isset($line['datetime']) && strtotime($line['datetime']) > time()-20*60 && strtotime($line['datetime']) < time()+20*60) {
197 229
 		    if (!isset($this->all_tracked[$id]['datetime']) || strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime'])) {
198 230
 			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => $line['datetime']));
199 231
 		    } else {
200
-				if (strtotime($line['datetime']) == strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) echo "!!! Date is the same as previous data for ".$this->all_tracked[$id]['mmsi']."\n";
201
-				elseif (strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_tracked[$id]['datetime'].") !!! for ".$this->all_tracked[$id]['hex']." - format : ".$line['format_source']."\n";
232
+				if (strtotime($line['datetime']) == strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) {
233
+					echo "!!! Date is the same as previous data for ".$this->all_tracked[$id]['mmsi']."\n";
234
+				} elseif (strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) {
235
+					echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_tracked[$id]['datetime'].") !!! for ".$this->all_tracked[$id]['hex']." - format : ".$line['format_source']."\n";
236
+				}
202 237
 				return '';
203 238
 		    }
204 239
 		} elseif (isset($line['datetime']) && strtotime($line['datetime']) < time()-20*60) {
205
-			if ($globalDebug) echo "!!! Date is too old ".$this->all_tracked[$id]['mmsi']." - format : ".$line['format_source']."!!!";
240
+			if ($globalDebug) {
241
+				echo "!!! Date is too old ".$this->all_tracked[$id]['mmsi']." - format : ".$line['format_source']."!!!";
242
+			}
206 243
 			return '';
207 244
 		} elseif (isset($line['datetime']) && strtotime($line['datetime']) > time()+20*60) {
208
-			if ($globalDebug) echo "!!! Date is in the future ".$this->all_tracked[$id]['mmsi']." - format : ".$line['format_source']."!!!";
245
+			if ($globalDebug) {
246
+				echo "!!! Date is in the future ".$this->all_tracked[$id]['mmsi']." - format : ".$line['format_source']."!!!";
247
+			}
209 248
 			return '';
210 249
 		} elseif (!isset($line['datetime'])) {
211 250
 			date_default_timezone_set('UTC');
212 251
 			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => date('Y-m-d H:i:s')));
213 252
 		} else {
214
-			if ($globalDebug) echo "!!! Unknow date error ".$this->all_tracked[$id]['mmsi']." - format : ".$line['format_source']."!!!";
253
+			if ($globalDebug) {
254
+				echo "!!! Unknow date error ".$this->all_tracked[$id]['mmsi']." - format : ".$line['format_source']."!!!";
255
+			}
215 256
 			return '';
216 257
 		}
217 258
 
@@ -224,14 +265,21 @@  discard block
 block discarded – undo
224 265
 		    if ($distance > 1000 && $distance < 10000) {
225 266
 			$speed = $distance/(time() - $this->all_tracked[$id]['time_last_coord']);
226 267
 			$speed = $speed*3.6;
227
-			if ($speed < 1000) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($speed)));
228
-  			if ($globalDebug) echo "ø Calculated Speed for ".$this->all_tracked[$id]['hex']." : ".$speed." - distance : ".$distance."\n";
268
+			if ($speed < 1000) {
269
+				$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($speed)));
270
+			}
271
+  			if ($globalDebug) {
272
+  				echo "ø Calculated Speed for ".$this->all_tracked[$id]['hex']." : ".$speed." - distance : ".$distance."\n";
273
+  			}
229 274
 		    }
230 275
 		}
231 276
 
232 277
 	        if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) {
233
-	    	    if (isset($this->all_tracked[$id]['time_last_coord'])) $timediff = round(time()-$this->all_tracked[$id]['time_last_coord']);
234
-	    	    else unset($timediff);
278
+	    	    if (isset($this->all_tracked[$id]['time_last_coord'])) {
279
+	    	    	$timediff = round(time()-$this->all_tracked[$id]['time_last_coord']);
280
+	    	    } else {
281
+	    	    	unset($timediff);
282
+	    	    }
235 283
 	    	    if ($this->tmd > 5 || !isset($timediff) || $timediff > 2000 || ($timediff > 30 && isset($this->all_tracked[$id]['latitude']) && isset($this->all_tracked[$id]['longitude']) && $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')))) {
236 284
 			if (isset($this->all_tracked[$id]['archive_latitude']) && isset($this->all_tracked[$id]['archive_longitude']) && isset($this->all_tracked[$id]['livedb_latitude']) && isset($this->all_tracked[$id]['livedb_longitude'])) {
237 285
 			    if (!$Common->checkLine($this->all_tracked[$id]['archive_latitude'],$this->all_tracked[$id]['archive_longitude'],$this->all_tracked[$id]['livedb_latitude'],$this->all_tracked[$id]['livedb_longitude'],$line['latitude'],$line['longitude'])) {
@@ -239,22 +287,32 @@  discard block
 block discarded – undo
239 287
 				$this->all_tracked[$id]['archive_longitude'] = $line['longitude'];
240 288
 				$this->all_tracked[$id]['putinarchive'] = true;
241 289
 				
242
-				if ($globalDebug) echo "\n".' ------- Check Country for '.$this->all_tracked[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... ';
290
+				if ($globalDebug) {
291
+					echo "\n".' ------- Check Country for '.$this->all_tracked[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... ';
292
+				}
243 293
 				$timeelapsed = microtime(true);
244 294
 				if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
245 295
 				    $Marine = new Marine($this->db);
246 296
 				    $all_country = $Marine->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']);
247
-				    if (!empty($all_country)) $this->all_tracked[$id]['over_country'] = $all_country['iso2'];
297
+				    if (!empty($all_country)) {
298
+				    	$this->all_tracked[$id]['over_country'] = $all_country['iso2'];
299
+				    }
248 300
 				    $Marine->db = null;
249
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
301
+				    if ($globalDebugTimeElapsed) {
302
+				    	echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
303
+				    }
250 304
 				}
251 305
 				$this->tmd = 0;
252
-				if ($globalDebug) echo 'FOUND : '.$this->all_tracked[$id]['over_country'].' ---------------'."\n";
306
+				if ($globalDebug) {
307
+					echo 'FOUND : '.$this->all_tracked[$id]['over_country'].' ---------------'."\n";
308
+				}
253 309
 			    }
254 310
 			}
255 311
 
256 312
 			if (isset($line['latitude']) && $line['latitude'] != '' && $line['latitude'] != 0 && $line['latitude'] < 91 && $line['latitude'] > -90) {
257
-				if (!isset($this->all_tracked[$id]['archive_latitude'])) $this->all_tracked[$id]['archive_latitude'] = $line['latitude'];
313
+				if (!isset($this->all_tracked[$id]['archive_latitude'])) {
314
+					$this->all_tracked[$id]['archive_latitude'] = $line['latitude'];
315
+				}
258 316
 				if (!isset($this->all_tracked[$id]['livedb_latitude']) || abs($this->all_tracked[$id]['livedb_latitude']-$line['latitude']) > $globalCoordMinChange || $this->all_tracked[$id]['format_source'] == 'aprs') {
259 317
 				    $this->all_tracked[$id]['livedb_latitude'] = $line['latitude'];
260 318
 				    $dataFound = true;
@@ -263,8 +321,12 @@  discard block
 block discarded – undo
263 321
 				$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('latitude' => $line['latitude']));
264 322
 			}
265 323
 			if (isset($line['longitude']) && $line['longitude'] != '' && $line['longitude'] != 0 && $line['longitude'] < 360 && $line['longitude'] > -180) {
266
-			    if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360;
267
-				if (!isset($this->all_tracked[$id]['archive_longitude'])) $this->all_tracked[$id]['archive_longitude'] = $line['longitude'];
324
+			    if ($line['longitude'] > 180) {
325
+			    	$line['longitude'] = $line['longitude'] - 360;
326
+			    }
327
+				if (!isset($this->all_tracked[$id]['archive_longitude'])) {
328
+					$this->all_tracked[$id]['archive_longitude'] = $line['longitude'];
329
+				}
268 330
 				if (!isset($this->all_tracked[$id]['livedb_longitude']) || abs($this->all_tracked[$id]['livedb_longitude']-$line['longitude']) > $globalCoordMinChange || $this->all_tracked[$id]['format_source'] == 'aprs') {
269 331
 				    $this->all_tracked[$id]['livedb_longitude'] = $line['longitude'];
270 332
 				    $dataFound = true;
@@ -282,7 +344,9 @@  discard block
 block discarded – undo
282 344
 		    }
283 345
 		}
284 346
 		if (isset($line['last_update']) && $line['last_update'] != '') {
285
-		    if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) $dataFound = true;
347
+		    if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) {
348
+		    	$dataFound = true;
349
+		    }
286 350
 		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('last_update' => $line['last_update']));
287 351
 		}
288 352
 		if (isset($line['format_source']) && $line['format_source'] != '') {
@@ -312,15 +376,21 @@  discard block
 block discarded – undo
312 376
 		}
313 377
 		
314 378
 		if (isset($line['heading']) && $line['heading'] != '') {
315
-		    if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) $this->all_tracked[$id]['putinarchive'] = true;
379
+		    if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) {
380
+		    	$this->all_tracked[$id]['putinarchive'] = true;
381
+		    }
316 382
 		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($line['heading'])));
317 383
 		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading_fromsrc' => true));
318 384
 		    //$dataFound = true;
319 385
   		} elseif (!isset($this->all_tracked[$id]['heading_fromsrc']) && isset($this->all_tracked[$id]['archive_latitude']) && $this->all_tracked[$id]['archive_latitude'] != $this->all_tracked[$id]['latitude'] && isset($this->all_tracked[$id]['archive_longitude']) && $this->all_tracked[$id]['archive_longitude'] != $this->all_tracked[$id]['longitude']) {
320 386
   		    $heading = $Common->getHeading($this->all_tracked[$id]['archive_latitude'],$this->all_tracked[$id]['archive_longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude']);
321 387
 		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($heading)));
322
-		    if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) $this->all_tracked[$id]['putinarchive'] = true;
323
-  		    if ($globalDebug) echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n";
388
+		    if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) {
389
+		    	$this->all_tracked[$id]['putinarchive'] = true;
390
+		    }
391
+  		    if ($globalDebug) {
392
+  		    	echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n";
393
+  		    }
324 394
   		}
325 395
 		//if (isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_tracked[$id]['lastupdate']) && time()-$this->all_tracked[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false;
326 396
 
@@ -332,23 +402,38 @@  discard block
 block discarded – undo
332 402
 		        if (!isset($globalDistanceIgnore['latitude']) || $this->all_tracked[$id]['longitude'] == ''  || $this->all_tracked[$id]['latitude'] == '' || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) {
333 403
 			    if (!isset($this->all_tracked[$id]['forcenew']) || $this->all_tracked[$id]['forcenew'] == 0) {
334 404
 				if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
335
-				    if ($globalDebug) echo "Check if aircraft is already in DB...";
405
+				    if ($globalDebug) {
406
+				    	echo "Check if aircraft is already in DB...";
407
+				    }
336 408
 				    $timeelapsed = microtime(true);
337 409
 				    $MarineLive = new MarineLive($this->db);
338 410
 				    if (isset($line['id'])) {
339 411
 					$recent_ident = $MarineLive->checkIdRecent($line['id']);
340
-					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
412
+					if ($globalDebugTimeElapsed) {
413
+						echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
414
+					}
341 415
 				    } elseif (isset($this->all_tracked[$id]['mmsi']) && $this->all_tracked[$id]['mmsi'] != '') {
342 416
 					$recent_ident = $MarineLive->checkMMSIRecent($this->all_tracked[$id]['mmsi']);
343
-					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
417
+					if ($globalDebugTimeElapsed) {
418
+						echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
419
+					}
344 420
 				    } elseif (isset($this->all_tracked[$id]['ident']) && $this->all_tracked[$id]['ident'] != '') {
345 421
 					$recent_ident = $MarineLive->checkIdentRecent($this->all_tracked[$id]['ident']);
346
-					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
347
-				    } else $recent_ident = '';
422
+					if ($globalDebugTimeElapsed) {
423
+						echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
424
+					}
425
+				    } else {
426
+				    	$recent_ident = '';
427
+				    }
348 428
 				    $MarineLive->db=null;
349
-				    if ($globalDebug && $recent_ident == '') echo " Not in DB.\n";
350
-				    elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n";
351
-				} else $recent_ident = '';
429
+				    if ($globalDebug && $recent_ident == '') {
430
+				    	echo " Not in DB.\n";
431
+				    } elseif ($globalDebug && $recent_ident != '') {
432
+				    	echo " Already in DB.\n";
433
+				    }
434
+				} else {
435
+					$recent_ident = '';
436
+				}
352 437
 			    } else {
353 438
 				$recent_ident = '';
354 439
 				$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('forcenew' => 0));
@@ -356,30 +441,44 @@  discard block
 block discarded – undo
356 441
 			    //if there was no aircraft with the same callsign within the last hour and go post it into the archive
357 442
 			    if($recent_ident == "" && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '')
358 443
 			    {
359
-				if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['mmsi']." in archive DB : ";
444
+				if ($globalDebug) {
445
+					echo "\o/ Add ".$this->all_tracked[$id]['mmsi']." in archive DB : ";
446
+				}
360 447
 				//adds the spotter data for the archive
361 448
 				    $highlight = '';
362
-				    if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['mmsi'].'-'.date('YmdHi')));
449
+				    if (!isset($this->all_tracked[$id]['id'])) {
450
+				    	$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['mmsi'].'-'.date('YmdHi')));
451
+				    }
363 452
 				    if (!isset($globalNoImport) || $globalNoImport !== TRUE) {
364 453
 					if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
365 454
 					    $timeelapsed = microtime(true);
366 455
 					    $Marine = new Marine($this->db);
367 456
 					    $result = $Marine->addMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['mmsi'], $this->all_tracked[$id]['type'],$this->all_tracked[$id]['typeid'],$this->all_tracked[$id]['imo'],$this->all_tracked[$id]['callsign'],$this->all_tracked[$id]['arrival_code'],$this->all_tracked[$id]['arrival_date'], $this->all_tracked[$id]['status'], $this->all_tracked[$id]['status_id'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name']);
368 457
 					    $Marine->db = null;
369
-					    if ($globalDebug && isset($result)) echo $result."\n";
370
-					    if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
458
+					    if ($globalDebug && isset($result)) {
459
+					    	echo $result."\n";
460
+					    }
461
+					    if ($globalDebugTimeElapsed) {
462
+					    	echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
463
+					    }
371 464
 					}
372 465
 				    }
373 466
 				    if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '') {
374 467
 					// Add source stat in DB
375 468
 					$Stats = new Stats($this->db);
376 469
 					if (!empty($this->stats)) {
377
-					    if ($globalDebug) echo 'Add source stats : ';
470
+					    if ($globalDebug) {
471
+					    	echo 'Add source stats : ';
472
+					    }
378 473
 				    	    foreach($this->stats as $date => $data) {
379 474
 						foreach($data as $source => $sourced) {
380 475
 					    	    //print_r($sourced);
381
-				    	    	    if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar_marine',$date);
382
-				    	    	    if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist_marine',$date);
476
+				    	    	    if (isset($sourced['polar'])) {
477
+				    	    	    	echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar_marine',$date);
478
+				    	    	    }
479
+				    	    	    if (isset($sourced['hist'])) {
480
+				    	    	    	echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist_marine',$date);
481
+				    	    	    }
383 482
 				    		    if (isset($sourced['msg'])) {
384 483
 				    			if (time() - $sourced['msg']['date'] > 10) {
385 484
 				    		    	    $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date']));
@@ -392,7 +491,9 @@  discard block
 block discarded – undo
392 491
 			    			    unset($this->stats[$date]);
393 492
 			    			}
394 493
 				    	    }
395
-				    	    if ($globalDebug) echo 'Done'."\n";
494
+				    	    if ($globalDebug) {
495
+				    	    	echo 'Done'."\n";
496
+				    	    }
396 497
 					}
397 498
 					$Stats->db = null;
398 499
 				    }
@@ -402,13 +503,17 @@  discard block
 block discarded – undo
402 503
 				$this->all_tracked[$id]['addedMarine'] = 1;
403 504
 				//print_r($this->all_tracked[$id]);
404 505
 				if ($this->last_delete == 0 || time() - $this->last_delete > 1800) {
405
-				    if ($globalDebug) echo "---- Deleting Live Marine data older than 9 hours...";
506
+				    if ($globalDebug) {
507
+				    	echo "---- Deleting Live Marine data older than 9 hours...";
508
+				    }
406 509
 				    //MarineLive->deleteLiveMarineDataNotUpdated();
407 510
 				    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
408 511
 					$MarineLive = new MarineLive($this->db);
409 512
 					$MarineLive->deleteLiveMarineData();
410 513
 					$MarineLive->db=null;
411
-					if ($globalDebug) echo " Done\n";
514
+					if ($globalDebug) {
515
+						echo " Done\n";
516
+					}
412 517
 				    }
413 518
 				    $this->last_delete = time();
414 519
 				}
@@ -434,15 +539,21 @@  discard block
 block discarded – undo
434 539
 
435 540
 		    if (!$ignoreImport) {
436 541
 			if (!isset($globalDistanceIgnore['latitude']) || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) {
437
-				if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['ident']." from ".$this->all_tracked[$id]['format_source']." in Live DB : ";
542
+				if ($globalDebug) {
543
+					echo "\o/ Add ".$this->all_tracked[$id]['ident']." from ".$this->all_tracked[$id]['format_source']." in Live DB : ";
544
+				}
438 545
 				if (!isset($globalNoImport) || $globalNoImport !== TRUE) {
439 546
 				    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
440 547
 					$timeelapsed = microtime(true);
441 548
 					$MarineLive = new MarineLive($this->db);
442 549
 					$result = $MarineLive->addLiveMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'],$this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['putinarchive'],$this->all_tracked[$id]['mmsi'],$this->all_tracked[$id]['type'],$this->all_tracked[$id]['typeid'],$this->all_tracked[$id]['imo'],$this->all_tracked[$id]['callsign'],$this->all_tracked[$id]['arrival_code'],$this->all_tracked[$id]['arrival_date'],$this->all_tracked[$id]['status'],$this->all_tracked[$id]['status_id'],$this->all_tracked[$id]['noarchive'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name'],$this->all_tracked[$id]['over_country']);
443 550
 					$MarineLive->db = null;
444
-					if ($globalDebug) echo $result."\n";
445
-					if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
551
+					if ($globalDebug) {
552
+						echo $result."\n";
553
+					}
554
+					if ($globalDebugTimeElapsed) {
555
+						echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
556
+					}
446 557
 				    }
447 558
 				}
448 559
 				if (isset($globalServerAPRS) && $globalServerAPRS && $this->all_tracked[$id]['putinarchive']) {
@@ -454,7 +565,9 @@  discard block
 block discarded – undo
454 565
 				
455 566
 				if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE && $line['format_source'] != 'aprs' && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '') {
456 567
 					$source = $this->all_tracked[$id]['source_name'];
457
-					if ($source == '') $source = $this->all_tracked[$id]['format_source'];
568
+					if ($source == '') {
569
+						$source = $this->all_tracked[$id]['format_source'];
570
+					}
458 571
 					if (!isset($this->source_location[$source])) {
459 572
 						$Location = new Source();
460 573
 						$coord = $Location->getLocationInfobySourceName($source);
@@ -475,7 +588,9 @@  discard block
 block discarded – undo
475 588
 					$stats_heading = round($stats_heading/22.5);
476 589
 					$stats_distance = $Common->distance($latitude,$longitude,$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude']);
477 590
 					$current_date = date('Y-m-d');
478
-					if ($stats_heading == 16) $stats_heading = 0;
591
+					if ($stats_heading == 16) {
592
+						$stats_heading = 0;
593
+					}
479 594
 					if (!isset($this->stats[$current_date][$source]['polar'][1])) {
480 595
 						for ($i=0;$i<=15;$i++) {
481 596
 						    $this->stats[$current_date][$source]['polar'][$i] = 0;
@@ -493,7 +608,9 @@  discard block
 block discarded – undo
493 608
 						if (isset($this->stats[$current_date][$source]['hist'][0])) {
494 609
 						    end($this->stats[$current_date][$source]['hist']);
495 610
 						    $mini = key($this->stats[$current_date][$source]['hist'])+10;
496
-						} else $mini = 0;
611
+						} else {
612
+							$mini = 0;
613
+						}
497 614
 						for ($i=$mini;$i<=$distance;$i+=10) {
498 615
 						    $this->stats[$current_date][$source]['hist'][$i] = 0;
499 616
 						}
@@ -505,19 +622,27 @@  discard block
 block discarded – undo
505 622
 				
506 623
 
507 624
 				$this->all_tracked[$id]['lastupdate'] = time();
508
-				if ($this->all_tracked[$id]['putinarchive']) $send = true;
509
-			} elseif (isset($this->all_tracked[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) echo "!! Too far -> Distance : ".$Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n";
625
+				if ($this->all_tracked[$id]['putinarchive']) {
626
+					$send = true;
627
+				}
628
+			} elseif (isset($this->all_tracked[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) {
629
+				echo "!! Too far -> Distance : ".$Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n";
630
+			}
510 631
 			//$this->del();
511 632
 			
512 633
 			
513 634
 			if ($this->last_delete_hourly == 0 || time() - $this->last_delete_hourly > 900) {
514 635
 			    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
515
-				if ($globalDebug) echo "---- Deleting Live Marine data Not updated since 2 hour...";
636
+				if ($globalDebug) {
637
+					echo "---- Deleting Live Marine data Not updated since 2 hour...";
638
+				}
516 639
 				$MarineLive = new MarineLive($this->db);
517 640
 				$MarineLive->deleteLiveMarineDataNotUpdated();
518 641
 				$MarineLive->db = null;
519 642
 				//MarineLive->deleteLiveMarineData();
520
-				if ($globalDebug) echo " Done\n";
643
+				if ($globalDebug) {
644
+					echo " Done\n";
645
+				}
521 646
 			    }
522 647
 			    $this->last_delete_hourly = time();
523 648
 			}
@@ -526,7 +651,9 @@  discard block
 block discarded – undo
526 651
 		    //$ignoreImport = false;
527 652
 		}
528 653
 		//if (function_exists('pcntl_fork') && $globalFork) pcntl_signal(SIGCHLD, SIG_IGN);
529
-		if ($send) return $this->all_tracked[$id];
654
+		if ($send) {
655
+			return $this->all_tracked[$id];
656
+		}
530 657
 	    }
531 658
 	}
532 659
     }
Please login to merge, or discard this patch.
js/map-aircraft.3d.js.php 1 patch
Braces   +30 added lines, -5 removed lines patch added patch discarded remove patch
@@ -202,7 +202,12 @@  discard block
 block discarded – undo
202 202
 //				viewer.dataSources.get(dsn).entities.remove(entity);
203 203
 //			}
204 204
 			//console.log(entity.lastupdate);
205
-			if (parseInt(entity.lastupdate) < Math.floor(Date.now()-<?php if (isset($globalMapRefresh)) print $globalMapRefresh*2000; else print '60000'; ?>)) {
205
+			if (parseInt(entity.lastupdate) < Math.floor(Date.now()-<?php if (isset($globalMapRefresh)) {
206
+	print $globalMapRefresh*2000;
207
+} else {
208
+	print '60000';
209
+}
210
+?>)) {
206 211
 //				console.log('Remove an entity date');
207 212
 				viewer.dataSources.get(dsn).entities.remove(entity);
208 213
 			} else {
@@ -276,7 +281,12 @@  discard block
 block discarded – undo
276 281
 	} else {
277 282
 		for (var i = 0; i < viewer.dataSources.get(dsn).entities.values.length; i++) {
278 283
 			var entity = viewer.dataSources.get(dsn).entities.values[i];
279
-			if (parseInt(entity.lastupdatesat) < Math.floor(Date.now()-<?php if (isset($globalMapRefresh)) print $globalMapRefresh*2000; else print '60000'; ?>)) {
284
+			if (parseInt(entity.lastupdatesat) < Math.floor(Date.now()-<?php if (isset($globalMapRefresh)) {
285
+	print $globalMapRefresh*2000;
286
+} else {
287
+	print '60000';
288
+}
289
+?>)) {
280 290
 				viewer.dataSources.get(dsn).entities.remove(entity);
281 291
 			}
282 292
 		}
@@ -606,7 +616,12 @@  discard block
 block discarded – undo
606 616
 		if (!((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS)) && (isset($_COOKIE['polar']) && $_COOKIE['polar'] == 'true')) {
607 617
 ?>
608 618
 update_polarLayer();
609
-setInterval(function(){update_polarLayer()},<?php if (isset($globalMapRefresh)) print $globalMapRefresh*1000*2; else print '60000'; ?>);
619
+setInterval(function(){update_polarLayer()},<?php if (isset($globalMapRefresh)) {
620
+	print $globalMapRefresh*1000*2;
621
+} else {
622
+	print '60000';
623
+}
624
+?>);
610 625
 <?php
611 626
 		}
612 627
 ?>
@@ -704,7 +719,12 @@  discard block
 block discarded – undo
704 719
 				}
705 720
 			}
706 721
 		}
707
-	,<?php if (isset($globalMapRefresh)) print $globalMapRefresh*1000; else print '30000'; ?>);
722
+	,<?php if (isset($globalMapRefresh)) {
723
+	print $globalMapRefresh*1000;
724
+} else {
725
+	print '30000';
726
+}
727
+?>);
708 728
 } else {
709 729
 	//var widget = new Cesium.CesiumWidget('archivebox');
710 730
 //	var timeline = new Cesium.Timeline(viewer);
@@ -723,7 +743,12 @@  discard block
 block discarded – undo
723 743
     if ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM)) {
724 744
 ?>
725 745
 update_atcLayer();
726
-setInterval(function(){update_atcLayer()},<?php if (isset($globalMapRefresh)) print $globalMapRefresh*1000*2; else print '60000'; ?>);
746
+setInterval(function(){update_atcLayer()},<?php if (isset($globalMapRefresh)) {
747
+	print $globalMapRefresh*1000*2;
748
+} else {
749
+	print '60000';
750
+}
751
+?>);
727 752
 <?php
728 753
     }
729 754
 ?>
Please login to merge, or discard this patch.
atc-data.php 1 patch
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -8,7 +8,9 @@
 block discarded – undo
8 8
 	$atcid = filter_input(INPUT_GET,'atcid',FILTER_SANITIZE_NUMBER_INT);
9 9
 	$atcident = filter_input(INPUT_GET,'atcident',FILTER_SANITIZE_STRING);
10 10
 	$atc_data = $ATC->getById($atcid);
11
-	if (!isset($atc_data[0])) $atc_data = $ATC->getByIdent($atcident);
11
+	if (!isset($atc_data[0])) {
12
+		$atc_data = $ATC->getByIdent($atcident);
13
+	}
12 14
  ?>
13 15
 <div class="alldetails">
14 16
 <button type="button" class="close">&times;</button>
Please login to merge, or discard this patch.
require/class.Source.php 1 patch
Braces   +9 added lines, -3 removed lines patch added patch discarded remove patch
@@ -88,7 +88,9 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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 {
Please login to merge, or discard this patch.
require/class.SpotterLive.php 1 patch
Braces   +86 added lines, -29 removed lines patch added patch discarded remove patch
@@ -29,7 +29,9 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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) {
Please login to merge, or discard this patch.
js/map.2d.js.php 1 patch
Braces   +95 added lines, -25 removed lines patch added patch discarded remove patch
@@ -4,10 +4,15 @@  discard block
 block discarded – undo
4 4
 
5 5
 setcookie("MapFormat",'2d');
6 6
 
7
-if (!isset($globalOpenWeatherMapKey)) $globalOpenWeatherMapKey = '';
7
+if (!isset($globalOpenWeatherMapKey)) {
8
+	$globalOpenWeatherMapKey = '';
9
+}
8 10
 // Compressed GeoJson is used if true
9
-if (!isset($globalJsonCompress)) $compress = true;
10
-else $compress = $globalJsonCompress;
11
+if (!isset($globalJsonCompress)) {
12
+	$compress = true;
13
+} else {
14
+	$compress = $globalJsonCompress;
15
+}
11 16
 if (isset($_GET['archive'])) {
12 17
 	$archive = true;
13 18
 	//$archiveupdatetime = 50;
@@ -18,8 +23,11 @@  discard block
 block discarded – undo
18 23
 	//$lastupd = round(($_GET['enddate']-$_GET['begindate'])/(($_GET['during']*60)/10));
19 24
 	//$lastupd = 20;
20 25
 	$lastupd = $_GET['archivespeed']*$archiveupdatetime;
21
-	if (isset($_GET['enddate']) && $_GET['enddate'] != '') $enddate = $_GET['enddate'];
22
-	else $enddate = time();
26
+	if (isset($_GET['enddate']) && $_GET['enddate'] != '') {
27
+		$enddate = $_GET['enddate'];
28
+	} else {
29
+		$enddate = time();
30
+	}
23 31
 	setcookie("archive_begin",$begindate);
24 32
 	setcookie("archive_end",$enddate);
25 33
 	setcookie("archive_update",$lastupd);
@@ -106,7 +114,17 @@  discard block
 block discarded – undo
106 114
 	}
107 115
 
108 116
 	//create the map
109
-	map = L.map('archive-map', { zoomControl:false }).setView([<?php if (isset($latitude)) print $latitude; else print $globalCenterLatitude; ?>,<?php if (isset($longitude)) print $longitude; else print $globalCenterLongitude; ?>], zoom);
117
+	map = L.map('archive-map', { zoomControl:false }).setView([<?php if (isset($latitude)) {
118
+	print $latitude;
119
+} else {
120
+	print $globalCenterLatitude;
121
+}
122
+?>,<?php if (isset($longitude)) {
123
+	print $longitude;
124
+} else {
125
+	print $globalCenterLongitude;
126
+}
127
+?>], zoom);
110 128
 <?php
111 129
 	} else {
112 130
 ?>
@@ -119,9 +137,19 @@  discard block
 block discarded – undo
119 137
 	     || navigator.userAgent.match(/BlackBerry/i)
120 138
 	     || navigator.userAgent.match(/Windows Phone/i))
121 139
 	{
122
-		var zoom = <?php if (isset($globalLiveZoom)) print $globalLiveZoom-1; else print '8'; ?>;
140
+		var zoom = <?php if (isset($globalLiveZoom)) {
141
+	print $globalLiveZoom-1;
142
+} else {
143
+	print '8';
144
+}
145
+?>;
123 146
 	} else {
124
-		var zoom = <?php if (isset($globalLiveZoom)) print $globalLiveZoom; else print '9'; ?>;
147
+		var zoom = <?php if (isset($globalLiveZoom)) {
148
+	print $globalLiveZoom;
149
+} else {
150
+	print '9';
151
+}
152
+?>;
125 153
 	}
126 154
 
127 155
 	//create the map
@@ -146,16 +174,27 @@  discard block
 block discarded – undo
146 174
 	bounds = L.latLngBounds(southWest,northEast);
147 175
 	//a few title layers
148 176
 <?php
149
-	if (isset($_COOKIE['MapType'])) $MapType = $_COOKIE['MapType'];
150
-	else $MapType = $globalMapProvider;
177
+	if (isset($_COOKIE['MapType'])) {
178
+		$MapType = $_COOKIE['MapType'];
179
+	} else {
180
+		$MapType = $globalMapProvider;
181
+	}
151 182
 
152 183
 	if ($MapType == 'Mapbox') {
153
-		if ($_COOKIE['MapTypeId'] == 'default') $MapBoxId = $globalMapboxId;
154
-		else $MapBoxId = $_COOKIE['MapTypeId'];
155
-?>
184
+		if ($_COOKIE['MapTypeId'] == 'default') {
185
+			$MapBoxId = $globalMapboxId;
186
+		} else {
187
+			$MapBoxId = $_COOKIE['MapTypeId'];
188
+		}
189
+		?>
156 190
 	L.tileLayer('https://{s}.tiles.mapbox.com/v4/{id}/{z}/{x}/{y}.png?access_token={token}', {
157 191
 	    maxZoom: 18,
158
-	    noWrap: <?php if (isset($globalMapWrap) && !$globalMapWrap) print 'false'; else print 'true'; ?>,
192
+	    noWrap: <?php if (isset($globalMapWrap) && !$globalMapWrap) {
193
+	print 'false';
194
+} else {
195
+	print 'true';
196
+}
197
+?>,
159 198
 	    attribution: 'Map data &copy; <a href="http://openstreetmap.org">OpenStreetMap</a> contributors, ' +
160 199
 	      '<a href="http://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a>, ' +
161 200
 	      'Imagery © <a href="http://mapbox.com">Mapbox</a>',
@@ -167,7 +206,12 @@  discard block
 block discarded – undo
167 206
 ?>
168 207
 	L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
169 208
 	    maxZoom: 18,
170
-	    noWrap: <?php if (isset($globalMapWrap) && !$globalMapWrap) print 'false'; else print 'true'; ?>,
209
+	    noWrap: <?php if (isset($globalMapWrap) && !$globalMapWrap) {
210
+	print 'false';
211
+} else {
212
+	print 'true';
213
+}
214
+?>,
171 215
 	    attribution: 'Map data &copy; <a href="http://openstreetmap.org">OpenStreetMap</a> contributors, ' +
172 216
 	      '<a href="www.openstreetmap.org/copyright">Open Database Licence</a>'
173 217
 	}).addTo(map);
@@ -213,20 +257,26 @@  discard block
 block discarded – undo
213 257
 	map.addLayer(yandexLayer);
214 258
 <?php
215 259
 	} elseif ($MapType == 'Bing-Aerial') {
216
-		if (!isset($globalBingMapKey) || $globalBingMapKey == '') setcookie('MapType','OpenStreetMap');
217
-?>
260
+		if (!isset($globalBingMapKey) || $globalBingMapKey == '') {
261
+			setcookie('MapType','OpenStreetMap');
262
+		}
263
+		?>
218 264
 	var bingLayer = new L.tileLayer.bing({bingMapsKey: '<?php print $globalBingMapKey; ?>',imagerySet: 'Aerial'});
219 265
 	map.addLayer(bingLayer);
220 266
 <?php
221 267
 	} elseif ($MapType == 'Bing-Hybrid') {
222
-		if (!isset($globalBingMapKey) || $globalBingMapKey == '') setcookie('MapType','OpenStreetMap');
223
-?>
268
+		if (!isset($globalBingMapKey) || $globalBingMapKey == '') {
269
+			setcookie('MapType','OpenStreetMap');
270
+		}
271
+		?>
224 272
 	var bingLayer = new L.tileLayer.bing({bingMapsKey: '<?php print $globalBingMapKey; ?>',imagerySet: 'AerialWithLabels'});
225 273
 	map.addLayer(bingLayer);
226 274
 <?php
227 275
 	} elseif ($MapType == 'Bing-Road') {
228
-		if (!isset($globalBingMapKey) || $globalBingMapKey == '') setcookie('MapType','OpenStreetMap');
229
-?>
276
+		if (!isset($globalBingMapKey) || $globalBingMapKey == '') {
277
+			setcookie('MapType','OpenStreetMap');
278
+		}
279
+		?>
230 280
 	var bingLayer = new L.tileLayer.bing({bingMapsKey: '<?php print $globalBingMapKey; ?>',imagerySet: 'Road'});
231 281
 	map.addLayer(bingLayer);
232 282
 <?php
@@ -249,9 +299,24 @@  discard block
 block discarded – undo
249 299
 		$customid = $MapType;
250 300
 ?>
251 301
 	L.tileLayer('<?php print $globalMapCustomLayer[$customid]['url']; ?>/{z}/{x}/{y}.png', {
252
-	    maxZoom: <?php if (isset($globalMapCustomLayer[$customid]['maxZoom'])) print $globalMapCustomLayer[$customid]['maxZoom']; else print '18'; ?>,
253
-	    minZoom: <?php if (isset($globalMapCustomLayer[$customid]['minZoom'])) print $globalMapCustomLayer[$customid]['minZoom']; else print '0'; ?>,
254
-	    noWrap: <?php if (isset($globalMapWrap) && !$globalMapWrap) print 'false'; else print 'true'; ?>,
302
+	    maxZoom: <?php if (isset($globalMapCustomLayer[$customid]['maxZoom'])) {
303
+	print $globalMapCustomLayer[$customid]['maxZoom'];
304
+} else {
305
+	print '18';
306
+}
307
+?>,
308
+	    minZoom: <?php if (isset($globalMapCustomLayer[$customid]['minZoom'])) {
309
+	print $globalMapCustomLayer[$customid]['minZoom'];
310
+} else {
311
+	print '0';
312
+}
313
+?>,
314
+	    noWrap: <?php if (isset($globalMapWrap) && !$globalMapWrap) {
315
+	print 'false';
316
+} else {
317
+	print 'true';
318
+}
319
+?>,
255 320
 	    attribution: '<?php print $globalMapCustomLayer[$customid]['attribution']; ?>'
256 321
 	}).addTo(map);
257 322
 
@@ -285,7 +350,12 @@  discard block
 block discarded – undo
285 350
 		}
286 351
 	} elseif ($globalBounding == 'circle') {
287 352
 ?>
288
-	var circle = L.circle([<?php print $globalCenterLatitude; ?>, <?php print $globalCenterLongitude; ?>],<?php if (isset($globalBoundingCircleSize)) print $globalBoundingCircleSize; else print '70000'; ?>,{
353
+	var circle = L.circle([<?php print $globalCenterLatitude; ?>, <?php print $globalCenterLongitude; ?>],<?php if (isset($globalBoundingCircleSize)) {
354
+	print $globalBoundingCircleSize;
355
+} else {
356
+	print '70000';
357
+}
358
+?>,{
289 359
 	    color: '#92C7D1',
290 360
 	    fillColor: '#92C7D1',
291 361
 	    fillOpacity: 0.3,
Please login to merge, or discard this patch.
search.php 1 patch
Braces   +128 added lines, -35 removed lines patch added patch discarded remove patch
@@ -30,8 +30,12 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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>
Please login to merge, or discard this patch.
require/class.Accident.php 1 patch
Braces   +84 added lines, -30 removed lines patch added patch discarded remove patch
@@ -113,8 +113,11 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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() {
Please login to merge, or discard this patch.