Completed
Push — master ( 2874a1...1a51fc )
by Yannick
09:22
created
statistics-manufacturer.php 3 patches
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@
 block discarded – undo
8 8
 if (!isset($filter_name)) $filter_name = '';
9 9
 $airline_icao = (string)filter_input(INPUT_GET,'airline',FILTER_SANITIZE_STRING);
10 10
 if ($airline_icao == '' && isset($globalFilter)) {
11
-    if (isset($globalFilter['airline'])) $airline_icao = $globalFilter['airline'][0];
11
+	if (isset($globalFilter['airline'])) $airline_icao = $globalFilter['airline'][0];
12 12
 }
13 13
 
14 14
 $year = filter_input(INPUT_GET,'year',FILTER_SANITIZE_NUMBER_INT);
Please login to merge, or discard this patch.
Braces   +7 added lines, -3 removed lines patch added patch discarded remove patch
@@ -5,11 +5,15 @@
 block discarded – undo
5 5
 $Stats = new Stats();
6 6
 $title = _("Statistics").' - '._("Most common Aircraft Manufacturer");
7 7
 
8
-if (!isset($filter_name)) $filter_name = '';
8
+if (!isset($filter_name)) {
9
+	$filter_name = '';
10
+}
9 11
 $airline_icao = (string)filter_input(INPUT_GET,'airline',FILTER_SANITIZE_STRING);
10 12
 if ($airline_icao == '' && isset($globalFilter)) {
11
-    if (isset($globalFilter['airline'])) $airline_icao = $globalFilter['airline'][0];
12
-}
13
+    if (isset($globalFilter['airline'])) {
14
+    	$airline_icao = $globalFilter['airline'][0];
15
+    }
16
+    }
13 17
 
14 18
 $year = filter_input(INPUT_GET,'year',FILTER_SANITIZE_NUMBER_INT);
15 19
 $month = filter_input(INPUT_GET,'month',FILTER_SANITIZE_NUMBER_INT);
Please login to merge, or discard this patch.
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -6,13 +6,13 @@  discard block
 block discarded – undo
6 6
 $title = _("Statistics").' - '._("Most common Aircraft Manufacturer");
7 7
 
8 8
 if (!isset($filter_name)) $filter_name = '';
9
-$airline_icao = (string)filter_input(INPUT_GET,'airline',FILTER_SANITIZE_STRING);
9
+$airline_icao = (string) filter_input(INPUT_GET, 'airline', FILTER_SANITIZE_STRING);
10 10
 if ($airline_icao == '' && isset($globalFilter)) {
11 11
     if (isset($globalFilter['airline'])) $airline_icao = $globalFilter['airline'][0];
12 12
 }
13 13
 
14
-$year = filter_input(INPUT_GET,'year',FILTER_SANITIZE_NUMBER_INT);
15
-$month = filter_input(INPUT_GET,'month',FILTER_SANITIZE_NUMBER_INT);
14
+$year = filter_input(INPUT_GET, 'year', FILTER_SANITIZE_NUMBER_INT);
15
+$month = filter_input(INPUT_GET, 'month', FILTER_SANITIZE_NUMBER_INT);
16 16
 
17 17
 require_once('header.php');
18 18
 include('statistics-sub-menu.php'); 
@@ -24,10 +24,10 @@  discard block
 block discarded – undo
24 24
 		 </div>
25 25
     	<p>'._("Below are the <strong>Top 10</strong> most common aircraft manufacturers.").'</p>';
26 26
  
27
-$manufacturers_array = $Stats->countAllAircraftManufacturers(true,$airline_icao,$filter_name,$year,$month);
27
+$manufacturers_array = $Stats->countAllAircraftManufacturers(true, $airline_icao, $filter_name, $year, $month);
28 28
 print '<div id="chart" class="chart" width="100%"></div><script>';
29 29
 $manufacturer_data = '';
30
-foreach($manufacturers_array as $manufacturer_item)
30
+foreach ($manufacturers_array as $manufacturer_item)
31 31
 {
32 32
 	$manufacturer_data .= '[ "'.$manufacturer_item['aircraft_manufacturer'].'",'.$manufacturer_item['aircraft_manufacturer_count'].'],';
33 33
 }
@@ -52,7 +52,7 @@  discard block
 block discarded – undo
52 52
 	print '</thead>';
53 53
 	print '<tbody>';
54 54
 	$i = 1;
55
-	foreach($manufacturers_array as $manufacturer_item)
55
+	foreach ($manufacturers_array as $manufacturer_item)
56 56
 	{
57 57
 		print '<tr>';
58 58
 		print '<td><strong>'.$i.'</strong></td>';
Please login to merge, or discard this patch.
statistics-pilot.php 3 patches
Braces   +7 added lines, -3 removed lines patch added patch discarded remove patch
@@ -5,11 +5,15 @@
 block discarded – undo
5 5
 $Stats = new Stats();
6 6
 $title = _("Statistics").' - '._("Most common Pilots");
7 7
 
8
-if (!isset($filter_name)) $filter_name = '';
8
+if (!isset($filter_name)) {
9
+	$filter_name = '';
10
+}
9 11
 $airline_icao = (string)filter_input(INPUT_GET,'airline',FILTER_SANITIZE_STRING);
10 12
 if ($airline_icao == '' && isset($globalFilter)) {
11
-    if (isset($globalFilter['airline'])) $airline_icao = $globalFilter['airline'][0];
12
-}
13
+    if (isset($globalFilter['airline'])) {
14
+    	$airline_icao = $globalFilter['airline'][0];
15
+    }
16
+    }
13 17
 setcookie('stats_airline_icao',$airline_icao,time()+60*60*24,'/');
14 18
 $year = filter_input(INPUT_GET,'year',FILTER_SANITIZE_NUMBER_INT);
15 19
 $month = filter_input(INPUT_GET,'month',FILTER_SANITIZE_NUMBER_INT);
Please login to merge, or discard this patch.
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@
 block discarded – undo
8 8
 if (!isset($filter_name)) $filter_name = '';
9 9
 $airline_icao = (string)filter_input(INPUT_GET,'airline',FILTER_SANITIZE_STRING);
10 10
 if ($airline_icao == '' && isset($globalFilter)) {
11
-    if (isset($globalFilter['airline'])) $airline_icao = $globalFilter['airline'][0];
11
+	if (isset($globalFilter['airline'])) $airline_icao = $globalFilter['airline'][0];
12 12
 }
13 13
 setcookie('stats_airline_icao',$airline_icao,time()+60*60*24,'/');
14 14
 $year = filter_input(INPUT_GET,'year',FILTER_SANITIZE_NUMBER_INT);
Please login to merge, or discard this patch.
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -6,13 +6,13 @@  discard block
 block discarded – undo
6 6
 $title = _("Statistics").' - '._("Most common Pilots");
7 7
 
8 8
 if (!isset($filter_name)) $filter_name = '';
9
-$airline_icao = (string)filter_input(INPUT_GET,'airline',FILTER_SANITIZE_STRING);
9
+$airline_icao = (string) filter_input(INPUT_GET, 'airline', FILTER_SANITIZE_STRING);
10 10
 if ($airline_icao == '' && isset($globalFilter)) {
11 11
     if (isset($globalFilter['airline'])) $airline_icao = $globalFilter['airline'][0];
12 12
 }
13
-setcookie('stats_airline_icao',$airline_icao,time()+60*60*24,'/');
14
-$year = filter_input(INPUT_GET,'year',FILTER_SANITIZE_NUMBER_INT);
15
-$month = filter_input(INPUT_GET,'month',FILTER_SANITIZE_NUMBER_INT);
13
+setcookie('stats_airline_icao', $airline_icao, time() + 60*60*24, '/');
14
+$year = filter_input(INPUT_GET, 'year', FILTER_SANITIZE_NUMBER_INT);
15
+$month = filter_input(INPUT_GET, 'month', FILTER_SANITIZE_NUMBER_INT);
16 16
 require_once('header.php');
17 17
 include('statistics-sub-menu.php');
18 18
 print '<script type="text/javascript" src="'.$globalURL.'/js/d3.min.js"></script>';
@@ -22,10 +22,10 @@  discard block
 block discarded – undo
22 22
 	</div>
23 23
 	<p>'._("Below are the <strong>Top 10</strong> most common pilot.").'</p>';
24 24
 	  
25
-$pilot_array = $Stats->countAllPilots(true,$airline_icao,$filter_name,$year,$month);
25
+$pilot_array = $Stats->countAllPilots(true, $airline_icao, $filter_name, $year, $month);
26 26
 print '<div id="chart" class="chart" width="100%"></div><script>';
27 27
 $pilot_data = '';
28
-foreach($pilot_array as $pilot_item)
28
+foreach ($pilot_array as $pilot_item)
29 29
 {
30 30
 	$pilot_data .= '["'.$pilot_item['pilot_name'].' ('.$pilot_item['pilot_id'].')",'.$pilot_item['pilot_count'].'],';
31 31
 }
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
50 50
 	print '</thead>';
51 51
 	print '<tbody>';
52 52
 	$i = 1;
53
-	foreach($pilot_array as $pilot_item)
53
+	foreach ($pilot_array as $pilot_item)
54 54
 	{
55 55
 		print '<tr>';
56 56
 		print '<td><strong>'.$i.'</strong></td>';
Please login to merge, or discard this patch.
statistics-time.php 3 patches
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@
 block discarded – undo
8 8
 if (!isset($filter_name)) $filter_name = '';
9 9
 $airline_icao = (string)filter_input(INPUT_GET,'airline',FILTER_SANITIZE_STRING);
10 10
 if ($airline_icao == '' && isset($globalFilter)) {
11
-    if (isset($globalFilter['airline'])) $airline_icao = $globalFilter['airline'][0];
11
+	if (isset($globalFilter['airline'])) $airline_icao = $globalFilter['airline'][0];
12 12
 }
13 13
 
14 14
 require_once('header.php');
Please login to merge, or discard this patch.
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -17,7 +17,7 @@  discard block
 block discarded – undo
17 17
 }
18 18
 
19 19
 if (!isset($filter_name)) $filter_name = '';
20
-$airline_icao = (string)filter_input(INPUT_GET,'airline',FILTER_SANITIZE_STRING);
20
+$airline_icao = (string) filter_input(INPUT_GET, 'airline', FILTER_SANITIZE_STRING);
21 21
 if ($airline_icao == '' && isset($globalFilter)) {
22 22
     if (isset($globalFilter['airline'])) $airline_icao = $globalFilter['airline'][0];
23 23
 }
@@ -33,19 +33,19 @@  discard block
 block discarded – undo
33 33
 	</div>
34 34
 	<p>'._("Below is a list of the most common <strong>time of day</strong>.").'</p>';
35 35
 
36
-if ($type == 'aircraft') $hour_array = $Stats->countAllHours('hour',true,$airline_icao,$filter_name);
37
-elseif ($type == 'marine') $hour_array = $Marine->countAllHours('hour',true);
38
-elseif ($type == 'tracker') $hour_array = $Tracker->countAllHours('hour',true);
36
+if ($type == 'aircraft') $hour_array = $Stats->countAllHours('hour', true, $airline_icao, $filter_name);
37
+elseif ($type == 'marine') $hour_array = $Marine->countAllHours('hour', true);
38
+elseif ($type == 'tracker') $hour_array = $Tracker->countAllHours('hour', true);
39 39
 print '<div id="chartHour" class="chart" width="100%"></div><script>';
40 40
 $hour_data = '';
41 41
 $hour_cnt = '';
42
-foreach($hour_array as $hour_item)
42
+foreach ($hour_array as $hour_item)
43 43
 {
44 44
 	$hour_data .= '"'.$hour_item['hour_name'].':00",';
45 45
 	$hour_cnt .= $hour_item['hour_count'].',';
46 46
 }
47 47
 $hour_data = "[".substr($hour_data, 0, -1)."]";
48
-$hour_cnt = "['flights',".substr($hour_cnt,0,-1)."]";
48
+$hour_cnt = "['flights',".substr($hour_cnt, 0, -1)."]";
49 49
 print 'c3.generate({
50 50
     bindto: "#chartHour",
51 51
     data: {
@@ -53,9 +53,9 @@  discard block
 block discarded – undo
53 53
     axis: { x: { type: "category", categories: '.$hour_data.'},y: { label: "# of Flights"}},legend: { show: false }});';
54 54
 print '</script>';
55 55
 
56
-if ($type == 'aircraft') $hour_array = $Stats->countAllHours('count',true,$airline_icao,$filter_name);
57
-elseif ($type == 'marine') $hour_array = $Marine->countAllHours('count',true);
58
-elseif ($type == 'tracker') $hour_array = $Tracker->countAllHours('count',true);
56
+if ($type == 'aircraft') $hour_array = $Stats->countAllHours('count', true, $airline_icao, $filter_name);
57
+elseif ($type == 'marine') $hour_array = $Marine->countAllHours('count', true);
58
+elseif ($type == 'tracker') $hour_array = $Tracker->countAllHours('count', true);
59 59
 if (!empty($hour_array))
60 60
 {
61 61
 	print '<div class="table-responsive">';
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
67 67
 	print '</thead>';
68 68
 	print '<tbody>';
69 69
 	$i = 1;
70
-	foreach($hour_array as $hour_item)
70
+	foreach ($hour_array as $hour_item)
71 71
 	{
72 72
 		print '<tr>';
73 73
 		print '<td><strong>'.$i.'</strong></td>';
Please login to merge, or discard this patch.
Braces   +21 added lines, -9 removed lines patch added patch discarded remove patch
@@ -16,11 +16,15 @@  discard block
 block discarded – undo
16 16
 	$Tracker = new Tracker();
17 17
 }
18 18
 
19
-if (!isset($filter_name)) $filter_name = '';
19
+if (!isset($filter_name)) {
20
+	$filter_name = '';
21
+}
20 22
 $airline_icao = (string)filter_input(INPUT_GET,'airline',FILTER_SANITIZE_STRING);
21 23
 if ($airline_icao == '' && isset($globalFilter)) {
22
-    if (isset($globalFilter['airline'])) $airline_icao = $globalFilter['airline'][0];
23
-}
24
+    if (isset($globalFilter['airline'])) {
25
+    	$airline_icao = $globalFilter['airline'][0];
26
+    }
27
+    }
24 28
 
25 29
 require_once('header.php');
26 30
 include('statistics-sub-menu.php');
@@ -33,9 +37,13 @@  discard block
 block discarded – undo
33 37
 	</div>
34 38
 	<p>'._("Below is a list of the most common <strong>time of day</strong>.").'</p>';
35 39
 
36
-if ($type == 'aircraft') $hour_array = $Stats->countAllHours('hour',true,$airline_icao,$filter_name);
37
-elseif ($type == 'marine') $hour_array = $Marine->countAllHours('hour',true);
38
-elseif ($type == 'tracker') $hour_array = $Tracker->countAllHours('hour',true);
40
+if ($type == 'aircraft') {
41
+	$hour_array = $Stats->countAllHours('hour',true,$airline_icao,$filter_name);
42
+} elseif ($type == 'marine') {
43
+	$hour_array = $Marine->countAllHours('hour',true);
44
+} elseif ($type == 'tracker') {
45
+	$hour_array = $Tracker->countAllHours('hour',true);
46
+}
39 47
 print '<div id="chartHour" class="chart" width="100%"></div><script>';
40 48
 $hour_data = '';
41 49
 $hour_cnt = '';
@@ -53,9 +61,13 @@  discard block
 block discarded – undo
53 61
     axis: { x: { type: "category", categories: '.$hour_data.'},y: { label: "# of Flights"}},legend: { show: false }});';
54 62
 print '</script>';
55 63
 
56
-if ($type == 'aircraft') $hour_array = $Stats->countAllHours('count',true,$airline_icao,$filter_name);
57
-elseif ($type == 'marine') $hour_array = $Marine->countAllHours('count',true);
58
-elseif ($type == 'tracker') $hour_array = $Tracker->countAllHours('count',true);
64
+if ($type == 'aircraft') {
65
+	$hour_array = $Stats->countAllHours('count',true,$airline_icao,$filter_name);
66
+} elseif ($type == 'marine') {
67
+	$hour_array = $Marine->countAllHours('count',true);
68
+} elseif ($type == 'tracker') {
69
+	$hour_array = $Tracker->countAllHours('count',true);
70
+}
59 71
 if (!empty($hour_array))
60 72
 {
61 73
 	print '<div class="table-responsive">';
Please login to merge, or discard this patch.
statistics-date.php 3 patches
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@
 block discarded – undo
8 8
 if (!isset($filter_name)) $filter_name = '';
9 9
 $airline_icao = (string)filter_input(INPUT_GET,'airline',FILTER_SANITIZE_STRING);
10 10
 if ($airline_icao == '' && isset($globalFilter)) {
11
-    if (isset($globalFilter['airline'])) $airline_icao = $globalFilter['airline'][0];
11
+	if (isset($globalFilter['airline'])) $airline_icao = $globalFilter['airline'][0];
12 12
 }
13 13
 
14 14
 require_once('header.php');
Please login to merge, or discard this patch.
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -17,7 +17,7 @@  discard block
 block discarded – undo
17 17
 }
18 18
 
19 19
 if (!isset($filter_name)) $filter_name = '';
20
-$airline_icao = (string)filter_input(INPUT_GET,'airline',FILTER_SANITIZE_STRING);
20
+$airline_icao = (string) filter_input(INPUT_GET, 'airline', FILTER_SANITIZE_STRING);
21 21
 if ($airline_icao == '' && isset($globalFilter)) {
22 22
     if (isset($globalFilter['airline'])) $airline_icao = $globalFilter['airline'][0];
23 23
 }
@@ -33,7 +33,7 @@  discard block
 block discarded – undo
33 33
 	  </div>
34 34
       <p>'._("Below is a chart that plots the busiest day during the <strong>last 7 days</strong>.").'</p>';
35 35
 
36
-if ($type == 'aircraft') $date_array = $Stats->countAllDatesLast7Days($airline_icao,$filter_name);
36
+if ($type == 'aircraft') $date_array = $Stats->countAllDatesLast7Days($airline_icao, $filter_name);
37 37
 elseif ($type == 'marine') $date_array = $Marine->countAllDatesLast7Days();
38 38
 elseif ($type == 'tracker') $date_array = $Tracker->countAllDatesLast7Days();
39 39
 if (count($date_array) == 0) {
@@ -42,13 +42,13 @@  discard block
 block discarded – undo
42 42
 print '<div id="chart" class="chart" width="100%"></div><script>';
43 43
 $date_data = '';
44 44
 $date_cnt = '';
45
-foreach($date_array as $date_item)
45
+foreach ($date_array as $date_item)
46 46
 {
47 47
 	$date_data .= '"'.$date_item['date_name'].'",';
48 48
 	$date_cnt .= $date_item['date_count'].',';
49 49
 }
50 50
 $date_data = "['x',".substr($date_data, 0, -1)."]";
51
-$date_cnt = "['flights',".substr($date_cnt,0,-1)."]";
51
+$date_cnt = "['flights',".substr($date_cnt, 0, -1)."]";
52 52
 print 'c3.generate({
53 53
     bindto: "#chart",
54 54
     data: { x: "x",
@@ -57,11 +57,11 @@  discard block
 block discarded – undo
57 57
 print '</script>';
58 58
 }
59 59
 if (isset($globalDBArchiveMonths) && $globalDBArchiveMonths > 0) {
60
-	print '<p>'.sprintf(_("Below are the <strong>Top 10</strong> most busiest dates of last %d month(s)."),$globalDBArchiveMonths).'</p>';
60
+	print '<p>'.sprintf(_("Below are the <strong>Top 10</strong> most busiest dates of last %d month(s)."), $globalDBArchiveMonths).'</p>';
61 61
 } else {
62 62
 	print '<p>'._("Below are the <strong>Top 10</strong> most busiest dates.").'</p>';
63 63
 }
64
-if ($type == 'aircraft') $date_array = $Stats->countAllDates($airline_icao,$filter_name);
64
+if ($type == 'aircraft') $date_array = $Stats->countAllDates($airline_icao, $filter_name);
65 65
 elseif ($type == 'marine') $date_array = $Marine->countAllDates();
66 66
 elseif ($type == 'tracker') $date_array = $Tracker->countAllDates();
67 67
 if (!empty($date_array))
@@ -75,7 +75,7 @@  discard block
 block discarded – undo
75 75
 	print '</thead>';
76 76
 	print '<tbody>';
77 77
 	$i = 1;
78
-	foreach($date_array as $date_item)
78
+	foreach ($date_array as $date_item)
79 79
 	{
80 80
 		print '<tr>';
81 81
 		print '<td><strong>'.$i.'</strong></td>';
Please login to merge, or discard this patch.
Braces   +21 added lines, -9 removed lines patch added patch discarded remove patch
@@ -16,11 +16,15 @@  discard block
 block discarded – undo
16 16
 	$Tracker = new Tracker();
17 17
 }
18 18
 
19
-if (!isset($filter_name)) $filter_name = '';
19
+if (!isset($filter_name)) {
20
+	$filter_name = '';
21
+}
20 22
 $airline_icao = (string)filter_input(INPUT_GET,'airline',FILTER_SANITIZE_STRING);
21 23
 if ($airline_icao == '' && isset($globalFilter)) {
22
-    if (isset($globalFilter['airline'])) $airline_icao = $globalFilter['airline'][0];
23
-}
24
+    if (isset($globalFilter['airline'])) {
25
+    	$airline_icao = $globalFilter['airline'][0];
26
+    }
27
+    }
24 28
 
25 29
 require_once('header.php');
26 30
 include('statistics-sub-menu.php'); 
@@ -33,9 +37,13 @@  discard block
 block discarded – undo
33 37
 	  </div>
34 38
       <p>'._("Below is a chart that plots the busiest day during the <strong>last 7 days</strong>.").'</p>';
35 39
 
36
-if ($type == 'aircraft') $date_array = $Stats->countAllDatesLast7Days($airline_icao,$filter_name);
37
-elseif ($type == 'marine') $date_array = $Marine->countAllDatesLast7Days();
38
-elseif ($type == 'tracker') $date_array = $Tracker->countAllDatesLast7Days();
40
+if ($type == 'aircraft') {
41
+	$date_array = $Stats->countAllDatesLast7Days($airline_icao,$filter_name);
42
+} elseif ($type == 'marine') {
43
+	$date_array = $Marine->countAllDatesLast7Days();
44
+} elseif ($type == 'tracker') {
45
+	$date_array = $Tracker->countAllDatesLast7Days();
46
+}
39 47
 if (count($date_array) == 0) {
40 48
 	print _("No data available");
41 49
 } else {
@@ -61,9 +69,13 @@  discard block
 block discarded – undo
61 69
 } else {
62 70
 	print '<p>'._("Below are the <strong>Top 10</strong> most busiest dates.").'</p>';
63 71
 }
64
-if ($type == 'aircraft') $date_array = $Stats->countAllDates($airline_icao,$filter_name);
65
-elseif ($type == 'marine') $date_array = $Marine->countAllDates();
66
-elseif ($type == 'tracker') $date_array = $Tracker->countAllDates();
72
+if ($type == 'aircraft') {
73
+	$date_array = $Stats->countAllDates($airline_icao,$filter_name);
74
+} elseif ($type == 'marine') {
75
+	$date_array = $Marine->countAllDates();
76
+} elseif ($type == 'tracker') {
77
+	$date_array = $Tracker->countAllDates();
78
+}
67 79
 if (!empty($date_array))
68 80
 {
69 81
 	print '<div class="table-responsive">';
Please login to merge, or discard this patch.
statistics-year.php 3 patches
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@
 block discarded – undo
8 8
 if (!isset($filter_name)) $filter_name = '';
9 9
 $airline_icao = (string)filter_input(INPUT_GET,'airline',FILTER_SANITIZE_STRING);
10 10
 if ($airline_icao == '' && isset($globalFilter)) {
11
-    if (isset($globalFilter['airline'])) $airline_icao = $globalFilter['airline'][0];
11
+	if (isset($globalFilter['airline'])) $airline_icao = $globalFilter['airline'][0];
12 12
 }
13 13
 
14 14
 require_once('header.php');
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -18,7 +18,7 @@  discard block
 block discarded – undo
18 18
 
19 19
 
20 20
 if (!isset($filter_name)) $filter_name = '';
21
-$airline_icao = (string)filter_input(INPUT_GET,'airline',FILTER_SANITIZE_STRING);
21
+$airline_icao = (string) filter_input(INPUT_GET, 'airline', FILTER_SANITIZE_STRING);
22 22
 if ($airline_icao == '' && isset($globalFilter)) {
23 23
     if (isset($globalFilter['airline'])) $airline_icao = $globalFilter['airline'][0];
24 24
 }
@@ -33,19 +33,19 @@  discard block
 block discarded – undo
33 33
 	</div>
34 34
       <p>'._("Below is a chart that plots the busiest month during the <strong>last year</strong>.").'</p>';
35 35
 
36
-if ($type == 'aircraft') $date_array = $Stats->countAllMonthsLastYear(true,$airline_icao,$filter_name);
36
+if ($type == 'aircraft') $date_array = $Stats->countAllMonthsLastYear(true, $airline_icao, $filter_name);
37 37
 elseif ($type == 'marine') $date_array = $Marine->countAllMonthsLastYear(true);
38 38
 elseif ($type == 'tracker') $date_array = $Tracker->countAllMonthsLastYear(true);
39 39
 print '<div id="chart" class="chart" width="100%"></div><script>';
40 40
 $year_data = '';
41 41
 $year_cnt = '';
42
-foreach($date_array as $year_item)
42
+foreach ($date_array as $year_item)
43 43
 {
44 44
 	$year_data .= '"'.$year_item['year_name'].'-'.$year_item['month_name'].'-01'.'",';
45 45
 	$year_cnt .= $year_item['date_count'].',';
46 46
 }
47 47
 $year_data = "['x',".substr($year_data, 0, -1)."]";
48
-$year_cnt = "['flights',".substr($year_cnt,0,-1)."]";
48
+$year_cnt = "['flights',".substr($year_cnt, 0, -1)."]";
49 49
 print 'c3.generate({
50 50
     bindto: "#chart",
51 51
     data: { x: "x",
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
 	print '</thead>';
69 69
 	print '<tbody>';
70 70
 	$i = 1;
71
-	foreach($date_array as $date_item)
71
+	foreach ($date_array as $date_item)
72 72
 	{
73 73
 		print '<tr>';
74 74
 		print '<td><strong>'.$i.'</strong></td>';
Please login to merge, or discard this patch.
Braces   +21 added lines, -9 removed lines patch added patch discarded remove patch
@@ -17,11 +17,15 @@  discard block
 block discarded – undo
17 17
 $title = _("Statistics").' - '._("Busiest Month of Last Year");
18 18
 
19 19
 
20
-if (!isset($filter_name)) $filter_name = '';
20
+if (!isset($filter_name)) {
21
+	$filter_name = '';
22
+}
21 23
 $airline_icao = (string)filter_input(INPUT_GET,'airline',FILTER_SANITIZE_STRING);
22 24
 if ($airline_icao == '' && isset($globalFilter)) {
23
-    if (isset($globalFilter['airline'])) $airline_icao = $globalFilter['airline'][0];
24
-}
25
+    if (isset($globalFilter['airline'])) {
26
+    	$airline_icao = $globalFilter['airline'][0];
27
+    }
28
+    }
25 29
 
26 30
 require_once('header.php');
27 31
 include('statistics-sub-menu.php');
@@ -33,9 +37,13 @@  discard block
 block discarded – undo
33 37
 	</div>
34 38
       <p>'._("Below is a chart that plots the busiest month during the <strong>last year</strong>.").'</p>';
35 39
 
36
-if ($type == 'aircraft') $date_array = $Stats->countAllMonthsLastYear(true,$airline_icao,$filter_name);
37
-elseif ($type == 'marine') $date_array = $Marine->countAllMonthsLastYear(true);
38
-elseif ($type == 'tracker') $date_array = $Tracker->countAllMonthsLastYear(true);
40
+if ($type == 'aircraft') {
41
+	$date_array = $Stats->countAllMonthsLastYear(true,$airline_icao,$filter_name);
42
+} elseif ($type == 'marine') {
43
+	$date_array = $Marine->countAllMonthsLastYear(true);
44
+} elseif ($type == 'tracker') {
45
+	$date_array = $Tracker->countAllMonthsLastYear(true);
46
+}
39 47
 print '<div id="chart" class="chart" width="100%"></div><script>';
40 48
 $year_data = '';
41 49
 $year_cnt = '';
@@ -53,9 +61,13 @@  discard block
 block discarded – undo
53 61
     axis: { x: { type: "timeseries", localtime: false,tick: { format: "%Y-%m"}}, y: { label: "#"}},legend: { show: false }});';
54 62
 print '</script>';
55 63
 
56
-if ($type == 'aircraft') $date_array = $Stats->countAllMonths($airline_icao);
57
-elseif ($type == 'marine') $date_array = $Marine->countAllMonths();
58
-elseif ($type == 'tracker') $date_array = $Tracker->countAllMonths();
64
+if ($type == 'aircraft') {
65
+	$date_array = $Stats->countAllMonths($airline_icao);
66
+} elseif ($type == 'marine') {
67
+	$date_array = $Marine->countAllMonths();
68
+} elseif ($type == 'tracker') {
69
+	$date_array = $Tracker->countAllMonths();
70
+}
59 71
 
60 72
 if (!empty($date_array))
61 73
 {
Please login to merge, or discard this patch.
require/class.METAR.php 3 patches
Indentation   +263 added lines, -263 removed lines patch added patch discarded remove patch
@@ -7,109 +7,109 @@  discard block
 block discarded – undo
7 7
 	public $db;
8 8
 	
9 9
 	protected $texts = Array(
10
-	    'MI' => 'Shallow',
11
-	    'PR' => 'Partial',
12
-	    'BC' => 'Low drifting',
13
-	    'BL' => 'Blowing',
14
-	    'SH' => 'Showers',
15
-	    'TS' => 'Thunderstorm',
16
-	    'FZ' => 'Freezing',
17
-	    'DZ' => 'Drizzle',
18
-	    'RA' => 'Rain',
19
-	    'SN' => 'Snow',
20
-	    'SG' => 'Snow Grains',
21
-	    'IC' => 'Ice crystals',
22
-	    'PL' => 'Ice pellets',
23
-	    'GR' => 'Hail',
24
-	    'GS' => 'Small hail',
25
-	    'UP' => 'Unknown',
26
-	    'BR' => 'Mist',
27
-	    'FG' => 'Fog',
28
-	    'FU' => 'Smoke',
29
-	    'VA' => 'Volcanic ash',
30
-	    'DU' => 'Widespread dust',
31
-	    'SA' => 'Sand',
32
-	    'HZ' => 'Haze',
33
-	    'PY' => 'Spray',
34
-	    'PO' => 'Well developed dust / sand whirls',
35
-	    'SQ' => 'Squalls',
36
-	    'FC' => 'Funnel clouds inc tornadoes or waterspouts',
37
-	    'SS' => 'Sandstorm',
38
-	    'DS' => 'Duststorm'
10
+		'MI' => 'Shallow',
11
+		'PR' => 'Partial',
12
+		'BC' => 'Low drifting',
13
+		'BL' => 'Blowing',
14
+		'SH' => 'Showers',
15
+		'TS' => 'Thunderstorm',
16
+		'FZ' => 'Freezing',
17
+		'DZ' => 'Drizzle',
18
+		'RA' => 'Rain',
19
+		'SN' => 'Snow',
20
+		'SG' => 'Snow Grains',
21
+		'IC' => 'Ice crystals',
22
+		'PL' => 'Ice pellets',
23
+		'GR' => 'Hail',
24
+		'GS' => 'Small hail',
25
+		'UP' => 'Unknown',
26
+		'BR' => 'Mist',
27
+		'FG' => 'Fog',
28
+		'FU' => 'Smoke',
29
+		'VA' => 'Volcanic ash',
30
+		'DU' => 'Widespread dust',
31
+		'SA' => 'Sand',
32
+		'HZ' => 'Haze',
33
+		'PY' => 'Spray',
34
+		'PO' => 'Well developed dust / sand whirls',
35
+		'SQ' => 'Squalls',
36
+		'FC' => 'Funnel clouds inc tornadoes or waterspouts',
37
+		'SS' => 'Sandstorm',
38
+		'DS' => 'Duststorm'
39 39
 	);
40 40
 	
41 41
 	public function __construct($dbc = null) {
42
-                $Connection = new Connection($dbc);
43
-                $this->db = $Connection->db;
44
-        }
42
+				$Connection = new Connection($dbc);
43
+				$this->db = $Connection->db;
44
+		}
45 45
 
46
-       public static function check_last_update() {
47
-    		global $globalDBdriver;
48
-    		if ($globalDBdriver == 'mysql') {
46
+	   public static function check_last_update() {
47
+			global $globalDBdriver;
48
+			if ($globalDBdriver == 'mysql') {
49 49
 			$query = "SELECT COUNT(*) as nb FROM config WHERE name = 'last_update_metar' AND value > DATE_SUB(NOW(), INTERVAL 20 MINUTE)";
50 50
 		} else {
51 51
 			$query = "SELECT COUNT(*) as nb FROM config WHERE name = 'last_update_metar' AND value::timestamp > CURRENT_TIMESTAMP - INTERVAL '20 MINUTES'";
52 52
 		}
53
-                try {
54
-                        $Connection = new Connection();
55
-                        $sth = $Connection->db->prepare($query);
56
-                        $sth->execute();
57
-                } catch(PDOException $e) {
58
-                        return "error : ".$e->getMessage();
59
-                }
60
-                $row = $sth->fetch(PDO::FETCH_ASSOC);
61
-                $sth->closeCursor();
62
-                if ($row['nb'] > 0) return false;
63
-                else return true;
64
-        }
53
+				try {
54
+						$Connection = new Connection();
55
+						$sth = $Connection->db->prepare($query);
56
+						$sth->execute();
57
+				} catch(PDOException $e) {
58
+						return "error : ".$e->getMessage();
59
+				}
60
+				$row = $sth->fetch(PDO::FETCH_ASSOC);
61
+				$sth->closeCursor();
62
+				if ($row['nb'] > 0) return false;
63
+				else return true;
64
+		}
65 65
 
66
-        public static function insert_last_update() {
67
-                $query = "DELETE FROM config WHERE name = 'last_update_metar';
66
+		public static function insert_last_update() {
67
+				$query = "DELETE FROM config WHERE name = 'last_update_metar';
68 68
                         INSERT INTO config (name,value) VALUES ('last_update_metar',NOW());";
69
-                try {
70
-                        $Connection = new Connection();
71
-                        $sth = $Connection->db->prepare($query);
72
-                        $sth->execute();
73
-                } catch(PDOException $e) {
74
-                        return "error : ".$e->getMessage();
75
-                }
76
-        }
69
+				try {
70
+						$Connection = new Connection();
71
+						$sth = $Connection->db->prepare($query);
72
+						$sth->execute();
73
+				} catch(PDOException $e) {
74
+						return "error : ".$e->getMessage();
75
+				}
76
+		}
77 77
 
78 78
 
79 79
         
80
-        public function parse($data) {
81
-    		//$data = str_replace(array('\n','\r','\r','\n'),'',$data);
82
-    		$codes = implode('|', array_keys($this->texts));
83
-    		$regWeather = '#^(\+|\-|VC)?(' . $codes . ')(' . $codes . ')?$#';
84
-    		//$pieces = explode(' ',$data);
85
-    		$pieces = preg_split('/\s/',$data);
86
-    		$pos = 0;
87
-    		if ($pieces[0] == 'METAR') $pos++;
88
-    		elseif ($pieces[0] == 'SPECI') $pos++;
89
-    		if (strlen($pieces[$pos]) != 4) $pos++;
90
-    		$result = array();
91
-    		$result['location'] = $pieces[$pos];
92
-    		$pos++;
93
-    		$result['dayofmonth'] = substr($pieces[$pos],0,2);
94
-    		$result['time'] = substr($pieces[$pos],2,4);
95
-    		$c = count($pieces);
96
-    		for($pos++; $pos < $c; $pos++) {
97
-    			$piece = $pieces[$pos];
98
-    			if ($piece == 'RMK') break;
99
-    			if ($piece == 'AUTO') $result['auto'] = true;
100
-    			if ($piece == 'COR') $result['correction'] = true;
101
-    			// Wind Speed
102
-    			if (preg_match('#(VRB|\d\d\d)(\d\d)(?:G(\d\d))?(KT|MPS|KPH)(?: (\d{1,3})V(\d{1,3}))?$#', $piece, $matches)) {
103
-    				$result['wind']['direction'] = (float)$matches[1];
80
+		public function parse($data) {
81
+			//$data = str_replace(array('\n','\r','\r','\n'),'',$data);
82
+			$codes = implode('|', array_keys($this->texts));
83
+			$regWeather = '#^(\+|\-|VC)?(' . $codes . ')(' . $codes . ')?$#';
84
+			//$pieces = explode(' ',$data);
85
+			$pieces = preg_split('/\s/',$data);
86
+			$pos = 0;
87
+			if ($pieces[0] == 'METAR') $pos++;
88
+			elseif ($pieces[0] == 'SPECI') $pos++;
89
+			if (strlen($pieces[$pos]) != 4) $pos++;
90
+			$result = array();
91
+			$result['location'] = $pieces[$pos];
92
+			$pos++;
93
+			$result['dayofmonth'] = substr($pieces[$pos],0,2);
94
+			$result['time'] = substr($pieces[$pos],2,4);
95
+			$c = count($pieces);
96
+			for($pos++; $pos < $c; $pos++) {
97
+				$piece = $pieces[$pos];
98
+				if ($piece == 'RMK') break;
99
+				if ($piece == 'AUTO') $result['auto'] = true;
100
+				if ($piece == 'COR') $result['correction'] = true;
101
+				// Wind Speed
102
+				if (preg_match('#(VRB|\d\d\d)(\d\d)(?:G(\d\d))?(KT|MPS|KPH)(?: (\d{1,3})V(\d{1,3}))?$#', $piece, $matches)) {
103
+					$result['wind']['direction'] = (float)$matches[1];
104 104
 				$result['wind']['unit'] = $matches[4];
105
-    				if ($result['wind']['unit'] == 'KT') $result['wind']['speed'] = round(((float)$matches[2])*0.51444444444,2);
106
-    				elseif ($result['wind']['unit'] == 'KPH') $result['wind']['speed'] = round(((float)$matches[2])*1000,2);
107
-    				elseif ($result['wind']['unit'] == 'MPS') $result['wind']['speed'] = round(((float)$matches[2]),2);
105
+					if ($result['wind']['unit'] == 'KT') $result['wind']['speed'] = round(((float)$matches[2])*0.51444444444,2);
106
+					elseif ($result['wind']['unit'] == 'KPH') $result['wind']['speed'] = round(((float)$matches[2])*1000,2);
107
+					elseif ($result['wind']['unit'] == 'MPS') $result['wind']['speed'] = round(((float)$matches[2]),2);
108 108
 				$result['wind']['gust'] = (float)$matches[3];
109 109
 				$result['wind']['unit'] = $matches[4];
110 110
 				$result['wind']['min_variation'] = array_key_exists(5,$matches) ? $matches[5] : 0;
111 111
 				$result['wind']['max_variation'] = array_key_exists(6,$matches) ? $matches[6] : 0;
112
-    			}
112
+				}
113 113
 
114 114
 /*    			if (preg_match('#^([0-9]{3})([0-9]{2})(G([0-9]{2}))?(KT|MPS)$#', $piece, $matches)) {
115 115
     				$result['wind_direction'] = (float)$matches[1];
@@ -126,35 +126,35 @@  discard block
 block discarded – undo
126 126
     				}
127 127
     			}
128 128
     			*/
129
-    			// Temperature
130
-    			if (preg_match('#^(M?[0-9]{2,})/(M?[0-9]{2,})$#', $piece, $matches)) {
131
-    				$temp = (float)$matches[1];
129
+				// Temperature
130
+				if (preg_match('#^(M?[0-9]{2,})/(M?[0-9]{2,})$#', $piece, $matches)) {
131
+					$temp = (float)$matches[1];
132 132
 				if ($matches[1]{0} == 'M') {
133 133
 					$temp = ((float)substr($matches[1], 1)) * -1;
134 134
 				}
135
-    				$result['temperature'] = $temp;
136
-    				$dew = (float)$matches[2];
135
+					$result['temperature'] = $temp;
136
+					$dew = (float)$matches[2];
137 137
 				if ($matches[2]{0} == 'M') {
138 138
 					$dew = ((float)substr($matches[2], 1)) * -1;
139 139
 				}
140 140
 				$result['dew'] = $dew;
141
-    			}
142
-    			// QNH
143
-    			if (preg_match('#^(A|Q)([0-9]{4})$#', $piece, $matches)) {
144
-    			// #^(Q|A)(////|[0-9]{4})( )#
145
-    				if ($matches[1] == 'Q') {
146
-    					// hPa
147
-    					$result['QNH'] = $matches[2];
148
-    				} else {
149
-    					// inHg
150
-    					$result['QNH'] = round(($matches[2] / 100)*33.86389,2);
151 141
 				}
152
-    				/*
142
+				// QNH
143
+				if (preg_match('#^(A|Q)([0-9]{4})$#', $piece, $matches)) {
144
+				// #^(Q|A)(////|[0-9]{4})( )#
145
+					if ($matches[1] == 'Q') {
146
+						// hPa
147
+						$result['QNH'] = $matches[2];
148
+					} else {
149
+						// inHg
150
+						$result['QNH'] = round(($matches[2] / 100)*33.86389,2);
151
+				}
152
+					/*
153 153
     				$result['QNH'] = $matches[1] == 'Q' ? $matches[2] : ($matches[2] / 100);
154 154
     				$result['QNH_format'] = $matches[1] == 'Q' ? 'hPa' : 'inHg';
155 155
     				*/
156
-    			}
157
-                     /*
156
+				}
157
+					 /*
158 158
     			// Wind Direction
159 159
     			if (preg_match('#^([0-9]{3})V([0-9]{3})$#', $piece, $matches)) {
160 160
     				$result['wind_direction'] = $matches[1];
@@ -165,9 +165,9 @@  discard block
 block discarded – undo
165 165
     				$result['speed_variable'] = $matches[1];
166 166
     			}
167 167
     			*/
168
-    			// Visibility
169
-    			if (preg_match('#^([0-9]{4})|(([0-9]{1,4})SM)$#', $piece, $matches)) {
170
-    				if (isset($matches[3]) && strlen($matches[3]) > 0) {
168
+				// Visibility
169
+				if (preg_match('#^([0-9]{4})|(([0-9]{1,4})SM)$#', $piece, $matches)) {
170
+					if (isset($matches[3]) && strlen($matches[3]) > 0) {
171 171
 					$result['visibility'] = (float)$matches[3] * 1609.34;
172 172
 				} else {
173 173
 					if ($matches[1] == '9999') {
@@ -180,28 +180,28 @@  discard block
 block discarded – undo
180 180
 					$result['visibility'] = '> 10000';
181 181
 					$result['weather'] = "CAVOK";
182 182
 				}
183
-    			}
184
-    			// Cloud Coverage
185
-    			if (preg_match('#^(SKC|CLR|FEW|SCT|BKN|OVC|VV)([0-9]{3})(CB|TCU|CU|CI)?$#', $piece, $matches)) {
186
-    				//$this->addCloudCover($matches[1], ((float)$matches[2]) * 100, isset($matches[3]) ? $matches[3] : '');
187
-    				$type = $matches[1];
188
-    				$cloud = array();
189
-    				if ($type == 'SKC') $cloud['type'] = 'No cloud/Sky clear';
190
-    				elseif ($type == 'CLR') $cloud['type'] = 'No cloud below 12,000ft (3700m)';
191
-    				elseif ($type == 'NSC') $cloud['type'] = 'No significant cloud';
192
-    				elseif ($type == 'FEW') $cloud['type'] = 'Few';
193
-    				elseif ($type == 'SCT') $cloud['type'] = 'Scattered';
194
-    				elseif ($type == 'BKN') $cloud['type'] = 'Broken';
195
-    				elseif ($type == 'OVC') $cloud['type'] = 'Overcast/Full cloud coverage';
196
-    				elseif ($type == 'VV') $cloud['type'] = 'Vertical visibility';
197
-    				$cloud['type_code'] = $type;
198
-    				$cloud['level'] = round(((float)$matches[2]) * 100 * 0.3048);
199
-    				$cloud['significant'] = isset($matches[3]) ? $matches[3] : '';
200
-    				$result['cloud'][] = $cloud;
201
-    			}
202
-    			// RVR
203
-    			 if (preg_match('#^(R.+)/([M|P])?(\d{4})(?:V(\d+)|[UDN])?(FT)?$#', $piece, $matches)) {
204
-    				$rvr = array();
183
+				}
184
+				// Cloud Coverage
185
+				if (preg_match('#^(SKC|CLR|FEW|SCT|BKN|OVC|VV)([0-9]{3})(CB|TCU|CU|CI)?$#', $piece, $matches)) {
186
+					//$this->addCloudCover($matches[1], ((float)$matches[2]) * 100, isset($matches[3]) ? $matches[3] : '');
187
+					$type = $matches[1];
188
+					$cloud = array();
189
+					if ($type == 'SKC') $cloud['type'] = 'No cloud/Sky clear';
190
+					elseif ($type == 'CLR') $cloud['type'] = 'No cloud below 12,000ft (3700m)';
191
+					elseif ($type == 'NSC') $cloud['type'] = 'No significant cloud';
192
+					elseif ($type == 'FEW') $cloud['type'] = 'Few';
193
+					elseif ($type == 'SCT') $cloud['type'] = 'Scattered';
194
+					elseif ($type == 'BKN') $cloud['type'] = 'Broken';
195
+					elseif ($type == 'OVC') $cloud['type'] = 'Overcast/Full cloud coverage';
196
+					elseif ($type == 'VV') $cloud['type'] = 'Vertical visibility';
197
+					$cloud['type_code'] = $type;
198
+					$cloud['level'] = round(((float)$matches[2]) * 100 * 0.3048);
199
+					$cloud['significant'] = isset($matches[3]) ? $matches[3] : '';
200
+					$result['cloud'][] = $cloud;
201
+				}
202
+				// RVR
203
+				 if (preg_match('#^(R.+)/([M|P])?(\d{4})(?:V(\d+)|[UDN])?(FT)?$#', $piece, $matches)) {
204
+					$rvr = array();
205 205
 				$rvr['runway'] = $matches[1];
206 206
 				$rvr['assessment'] = $matches[2];
207 207
 				$rvr['rvr'] = $matches[3];
@@ -210,33 +210,33 @@  discard block
 block discarded – undo
210 210
 				$result['RVR'] = $rvr;
211 211
 			}
212 212
     			
213
-    			//if (preg_match('#^(R[A-Z0-9]{2,3})/([0-9]{4})(V([0-9]{4}))?(FT)?$#', $piece, $matches)) {
214
-    			if (preg_match('#^R(\d{2}[LRC]?)/([\d/])([\d/])([\d/]{2})([\d/]{2})$#', $piece, $matches)) {
215
-    				//print_r($matches);
216
-    				// https://github.com/davidmegginson/metar-taf/blob/master/Metar.php
217
-    				$result['RVR']['runway'] = $matches[1];
218
-        			$result['RVR']['deposits'] = $matches[2];
219
-        			$result['RVR']['extent'] = $matches[3];
220
-        			$result['RVR']['depth'] = $matches[4];
221
-        			$result['RVR']['friction'] = $matches[5];
222
-    			}
223
-    			if (preg_match('#^(R[A-Z0-9]{2,3})/([0-9]{4})(V([0-9]{4}))?(FT)?$#', $piece, $matches)) {
224
-    				//echo $piece;
225
-    				//print_r($matches);
226
-    				if (isset($matches[5])) $range = array('exact' => (float)$matches[2], 'unit' => $matches[5] ? 'FT' : 'M');
227
-    				else $range = array('exact' => (float)$matches[2], 'unit' => 'M');
213
+				//if (preg_match('#^(R[A-Z0-9]{2,3})/([0-9]{4})(V([0-9]{4}))?(FT)?$#', $piece, $matches)) {
214
+				if (preg_match('#^R(\d{2}[LRC]?)/([\d/])([\d/])([\d/]{2})([\d/]{2})$#', $piece, $matches)) {
215
+					//print_r($matches);
216
+					// https://github.com/davidmegginson/metar-taf/blob/master/Metar.php
217
+					$result['RVR']['runway'] = $matches[1];
218
+					$result['RVR']['deposits'] = $matches[2];
219
+					$result['RVR']['extent'] = $matches[3];
220
+					$result['RVR']['depth'] = $matches[4];
221
+					$result['RVR']['friction'] = $matches[5];
222
+				}
223
+				if (preg_match('#^(R[A-Z0-9]{2,3})/([0-9]{4})(V([0-9]{4}))?(FT)?$#', $piece, $matches)) {
224
+					//echo $piece;
225
+					//print_r($matches);
226
+					if (isset($matches[5])) $range = array('exact' => (float)$matches[2], 'unit' => $matches[5] ? 'FT' : 'M');
227
+					else $range = array('exact' => (float)$matches[2], 'unit' => 'M');
228 228
 				if (isset($matches[3])) {
229 229
 					$range = Array(
230
-					    'from' => (float)$matches[2],
231
-					    'to'   => (float)$matches[4],
232
-					    'unit' => $matches[5] ? 'FT' : 'M'
230
+						'from' => (float)$matches[2],
231
+						'to'   => (float)$matches[4],
232
+						'unit' => $matches[5] ? 'FT' : 'M'
233 233
 					);
234 234
 				}
235 235
 				$result['RVR'] = $matches[1];
236 236
 				$result['RVR_range'] = $range;
237
-    			}
238
-    			// Weather
239
-    			if (preg_match($regWeather, $piece, $matches)) {
237
+				}
238
+				// Weather
239
+				if (preg_match($regWeather, $piece, $matches)) {
240 240
 				$text = Array();
241 241
 				switch ($matches[1]) {
242 242
 					case '+':
@@ -259,35 +259,35 @@  discard block
 block discarded – undo
259 259
 				}
260 260
 				if (!isset($result['weather'])) $result['weather'] = implode(' ', $text);
261 261
 				else $result['weather'] = $result['weather'].' / '.implode(' ', $text);
262
-    			}
263
-    		}
264
-    		return $result;
262
+				}
263
+			}
264
+			return $result;
265 265
         
266
-        }
266
+		}
267 267
         
268 268
 	public function getMETAR($icao) {
269
-    		global $globalMETARcycle, $globalDBdriver;
270
-    		if (isset($globalMETARcycle) && $globalMETARcycle) {
271
-            		$query = "SELECT * FROM metar WHERE metar_location = :icao";
272
-                } else {
273
-            		if ($globalDBdriver == 'mysql') $query = "SELECT * FROM metar WHERE metar_location = :icao AND metar_date >= DATE_SUB(UTC_TIMESTAMP(), INTERVAL 10 HOUR) LIMIT 1";
274
-            		else $query = "SELECT * FROM metar WHERE metar_location = :icao AND metar_date >= now() AT TIMEZONE 'UTC' - '10 HOUR'->INTERVAL LIMIT 0,1";
275
-                }
276
-                $query_values = array(':icao' => $icao);
277
-                 try {
278
-                        $sth = $this->db->prepare($query);
279
-                        $sth->execute($query_values);
280
-                } catch(PDOException $e) {
281
-                        return "error : ".$e->getMessage();
282
-                }
283
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
284
-                if ((!isset($globalMETARcycle) || $globalMETARcycle === false) && count($all) == 0) {
285
-            		$all = $this->downloadMETAR($icao);
286
-                }
287
-                return $all;
288
-        }
269
+			global $globalMETARcycle, $globalDBdriver;
270
+			if (isset($globalMETARcycle) && $globalMETARcycle) {
271
+					$query = "SELECT * FROM metar WHERE metar_location = :icao";
272
+				} else {
273
+					if ($globalDBdriver == 'mysql') $query = "SELECT * FROM metar WHERE metar_location = :icao AND metar_date >= DATE_SUB(UTC_TIMESTAMP(), INTERVAL 10 HOUR) LIMIT 1";
274
+					else $query = "SELECT * FROM metar WHERE metar_location = :icao AND metar_date >= now() AT TIMEZONE 'UTC' - '10 HOUR'->INTERVAL LIMIT 0,1";
275
+				}
276
+				$query_values = array(':icao' => $icao);
277
+				 try {
278
+						$sth = $this->db->prepare($query);
279
+						$sth->execute($query_values);
280
+				} catch(PDOException $e) {
281
+						return "error : ".$e->getMessage();
282
+				}
283
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
284
+				if ((!isset($globalMETARcycle) || $globalMETARcycle === false) && count($all) == 0) {
285
+					$all = $this->downloadMETAR($icao);
286
+				}
287
+				return $all;
288
+		}
289 289
 
290
-       public function addMETAR($location,$metar,$date) {
290
+	   public function addMETAR($location,$metar,$date) {
291 291
 		global $globalDBdriver;
292 292
 		$date = date('Y-m-d H:i:s',strtotime($date));
293 293
 		if ($globalDBdriver == 'mysql') {
@@ -295,106 +295,106 @@  discard block
 block discarded – undo
295 295
 		} else {
296 296
 			$query = "UPDATE metar SET metar_date = :date, metar = metar WHERE metar_location = :location;INSERT INTO metar (metar_location,metar_date,metar) SELECT :location,:date,:metar WHERE NOT EXISTS (SELECT 1 FROM metar WHERE metar_location = :location);";
297 297
 		}
298
-                $query_values = array(':location' => $location,':date' => $date,':metar' => utf8_encode($metar));
299
-                 try {
300
-                        $sth = $this->db->prepare($query);
301
-                        $sth->execute($query_values);
302
-                } catch(PDOException $e) {
303
-                        return "error : ".$e->getMessage();
304
-                }
305
-        }
298
+				$query_values = array(':location' => $location,':date' => $date,':metar' => utf8_encode($metar));
299
+				 try {
300
+						$sth = $this->db->prepare($query);
301
+						$sth->execute($query_values);
302
+				} catch(PDOException $e) {
303
+						return "error : ".$e->getMessage();
304
+				}
305
+		}
306 306
 
307
-       public function deleteMETAR($id) {
308
-                $query = "DELETE FROM metar WHERE id = :id";
309
-                $query_values = array(':id' => $id);
310
-                 try {
311
-                        $sth = $this->db->prepare($query);
312
-                        $sth->execute($query_values);
313
-                } catch(PDOException $e) {
314
-                        return "error : ".$e->getMessage();
315
-                }
316
-        }
317
-       public function deleteAllMETARLocation() {
318
-                $query = "DELETE FROM metar";
319
-                 try {
320
-                        $sth = $this->db->prepare($query);
321
-                        $sth->execute();
322
-                } catch(PDOException $e) {
323
-                        return "error : ".$e->getMessage();
324
-                }
325
-        }
307
+	   public function deleteMETAR($id) {
308
+				$query = "DELETE FROM metar WHERE id = :id";
309
+				$query_values = array(':id' => $id);
310
+				 try {
311
+						$sth = $this->db->prepare($query);
312
+						$sth->execute($query_values);
313
+				} catch(PDOException $e) {
314
+						return "error : ".$e->getMessage();
315
+				}
316
+		}
317
+	   public function deleteAllMETARLocation() {
318
+				$query = "DELETE FROM metar";
319
+				 try {
320
+						$sth = $this->db->prepare($query);
321
+						$sth->execute();
322
+				} catch(PDOException $e) {
323
+						return "error : ".$e->getMessage();
324
+				}
325
+		}
326 326
         
327
-        public function addMETARCycle() {
328
-    		global $globalDebug, $globalIVAO, $globalTransaction;
329
-    		if (isset($globalDebug) && $globalDebug) echo "Downloading METAR cycle...";
330
-    		date_default_timezone_set("UTC");
331
-    		$Common = new Common();
332
-    		if (isset($globalIVAO) && $globalIVAO) {
333
-        		//$cycle = $Common->getData('http://wx.ivao.aero/metar.php');
327
+		public function addMETARCycle() {
328
+			global $globalDebug, $globalIVAO, $globalTransaction;
329
+			if (isset($globalDebug) && $globalDebug) echo "Downloading METAR cycle...";
330
+			date_default_timezone_set("UTC");
331
+			$Common = new Common();
332
+			if (isset($globalIVAO) && $globalIVAO) {
333
+				//$cycle = $Common->getData('http://wx.ivao.aero/metar.php');
334 334
 			$Common->download('http://wx.ivao.aero/metar.php',dirname(__FILE__).'/../install/tmp/ivaometar.txt');
335
-    			$handle = fopen(dirname(__FILE__).'/../install/tmp/ivaometar.txt',"r");
336
-    		} else {
335
+				$handle = fopen(dirname(__FILE__).'/../install/tmp/ivaometar.txt',"r");
336
+			} else {
337 337
 			//$cycle = $Common->getData('http://tgftp.nws.noaa.gov/data/observations/metar/cycles/'.date('H').'Z.TXT');
338 338
 			$Common->download('http://tgftp.nws.noaa.gov/data/observations/metar/cycles/'.date('H').'Z.TXT',dirname(__FILE__).'/../install/tmp/'.date('H').'Z.TXT');
339
-    			$handle = fopen(dirname(__FILE__).'/../install/tmp/'.date('H').'Z.TXT',"r");
340
-    		}
341
-    		if ($handle) {
339
+				$handle = fopen(dirname(__FILE__).'/../install/tmp/'.date('H').'Z.TXT',"r");
340
+			}
341
+			if ($handle) {
342 342
 			if (isset($globalDebug) && $globalDebug) echo "Done - Updating DB...";
343 343
 			$date = '';
344
-    			//foreach(explode("\n",$cycle) as $line) {
345
-    			if ($globalTransaction) $this->db->beginTransaction();
346
-	    		while(($line = fgets($handle,4096)) !== false) {
344
+				//foreach(explode("\n",$cycle) as $line) {
345
+				if ($globalTransaction) $this->db->beginTransaction();
346
+				while(($line = fgets($handle,4096)) !== false) {
347 347
 				if (preg_match('#^([0-9]{4})/([0-9]{2})/([0-9]{2}) ([0-9]{2}):([0-9]{2})$#',$line)) {
348 348
 					$date = $line;
349
-    				} elseif ($line != '') {
350
-    				    //$this->parse($line);
351
-    				    if ($date == '') $date = date('Y/m/d H:m');
352
-        			    $pos = 0;
353
-        			    $pieces = preg_split('/\s/',$line);
354
-        			    if ($pieces[0] == 'METAR') $pos++;
355
-        			    if (strlen($pieces[$pos]) != 4) $pos++;
356
-		        	    $location = $pieces[$pos];
357
-        	        	    echo $this->addMETAR($location,$line,$date);
358
-    				}
359
-    			}
360
-    			fclose($handle);
361
-    			if ($globalTransaction) $this->db->commit();
362
-    		}
363
-    		if (isset($globalDebug) && $globalDebug) echo "Done\n";
349
+					} elseif ($line != '') {
350
+						//$this->parse($line);
351
+						if ($date == '') $date = date('Y/m/d H:m');
352
+						$pos = 0;
353
+						$pieces = preg_split('/\s/',$line);
354
+						if ($pieces[0] == 'METAR') $pos++;
355
+						if (strlen($pieces[$pos]) != 4) $pos++;
356
+						$location = $pieces[$pos];
357
+							echo $this->addMETAR($location,$line,$date);
358
+					}
359
+				}
360
+				fclose($handle);
361
+				if ($globalTransaction) $this->db->commit();
362
+			}
363
+			if (isset($globalDebug) && $globalDebug) echo "Done\n";
364 364
         
365
-        }
366
-        public function downloadMETAR($icao) {
367
-    		global $globalMETARurl;
368
-    		if ($globalMETARurl == '') return array();
369
-    		date_default_timezone_set("UTC");
370
-    		$Common = new Common();
371
-    		$url = str_replace('{icao}',$icao,$globalMETARurl);
372
-    		$cycle = $Common->getData($url);
373
-    		$date = '';
374
-    		foreach(explode("\n",$cycle) as $line) {
375
-    			if (preg_match('#^([0-9]{4})/([0-9]{2})/([0-9]{2}) ([0-9]{2}):([0-9]{2})$#',$line)) {
376
-    				//echo "date : ".$line."\n";
377
-    				$date = $line;
378
-    			} 
379
-    			if ($line != '') {
380
-    			    //$this->parse($line);
381
-    			    //echo $line;
382
-    			    if ($date == '') $date = date('Y/m/d H:m');
383
-    			    $pos = 0;
384
-    			    $pieces = preg_split('/\s/',$line);
385
-    			    if ($pieces[0] == 'METAR') $pos++;
386
-    			    if (strlen($pieces[$pos]) != 4) $pos++;
387
-	        	    $location = $pieces[$pos];
388
-	        	    if (strlen($location == 4)) {
389
-	        		$this->addMETAR($location,$line,$date);
390
-	        		return array('0' => array('metar_date' => $date, 'metar_location' => $location, 'metar' => $line));
391
-	        	    } else return array();
392
-    			}
393
-    			//echo $line."\n";
394
-    		}
395
-    		return array();
365
+		}
366
+		public function downloadMETAR($icao) {
367
+			global $globalMETARurl;
368
+			if ($globalMETARurl == '') return array();
369
+			date_default_timezone_set("UTC");
370
+			$Common = new Common();
371
+			$url = str_replace('{icao}',$icao,$globalMETARurl);
372
+			$cycle = $Common->getData($url);
373
+			$date = '';
374
+			foreach(explode("\n",$cycle) as $line) {
375
+				if (preg_match('#^([0-9]{4})/([0-9]{2})/([0-9]{2}) ([0-9]{2}):([0-9]{2})$#',$line)) {
376
+					//echo "date : ".$line."\n";
377
+					$date = $line;
378
+				} 
379
+				if ($line != '') {
380
+					//$this->parse($line);
381
+					//echo $line;
382
+					if ($date == '') $date = date('Y/m/d H:m');
383
+					$pos = 0;
384
+					$pieces = preg_split('/\s/',$line);
385
+					if ($pieces[0] == 'METAR') $pos++;
386
+					if (strlen($pieces[$pos]) != 4) $pos++;
387
+					$location = $pieces[$pos];
388
+					if (strlen($location == 4)) {
389
+					$this->addMETAR($location,$line,$date);
390
+					return array('0' => array('metar_date' => $date, 'metar_location' => $location, 'metar' => $line));
391
+					} else return array();
392
+				}
393
+				//echo $line."\n";
394
+			}
395
+			return array();
396 396
         
397
-        }
397
+		}
398 398
 }
399 399
 /*
400 400
 $METAR = new METAR();
Please login to merge, or discard this patch.
Spacing   +48 added lines, -48 removed lines patch added patch discarded remove patch
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
                         $Connection = new Connection();
55 55
                         $sth = $Connection->db->prepare($query);
56 56
                         $sth->execute();
57
-                } catch(PDOException $e) {
57
+                } catch (PDOException $e) {
58 58
                         return "error : ".$e->getMessage();
59 59
                 }
60 60
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -70,7 +70,7 @@  discard block
 block discarded – undo
70 70
                         $Connection = new Connection();
71 71
                         $sth = $Connection->db->prepare($query);
72 72
                         $sth->execute();
73
-                } catch(PDOException $e) {
73
+                } catch (PDOException $e) {
74 74
                         return "error : ".$e->getMessage();
75 75
                 }
76 76
         }
@@ -80,9 +80,9 @@  discard block
 block discarded – undo
80 80
         public function parse($data) {
81 81
     		//$data = str_replace(array('\n','\r','\r','\n'),'',$data);
82 82
     		$codes = implode('|', array_keys($this->texts));
83
-    		$regWeather = '#^(\+|\-|VC)?(' . $codes . ')(' . $codes . ')?$#';
83
+    		$regWeather = '#^(\+|\-|VC)?('.$codes.')('.$codes.')?$#';
84 84
     		//$pieces = explode(' ',$data);
85
-    		$pieces = preg_split('/\s/',$data);
85
+    		$pieces = preg_split('/\s/', $data);
86 86
     		$pos = 0;
87 87
     		if ($pieces[0] == 'METAR') $pos++;
88 88
     		elseif ($pieces[0] == 'SPECI') $pos++;
@@ -90,25 +90,25 @@  discard block
 block discarded – undo
90 90
     		$result = array();
91 91
     		$result['location'] = $pieces[$pos];
92 92
     		$pos++;
93
-    		$result['dayofmonth'] = substr($pieces[$pos],0,2);
94
-    		$result['time'] = substr($pieces[$pos],2,4);
93
+    		$result['dayofmonth'] = substr($pieces[$pos], 0, 2);
94
+    		$result['time'] = substr($pieces[$pos], 2, 4);
95 95
     		$c = count($pieces);
96
-    		for($pos++; $pos < $c; $pos++) {
96
+    		for ($pos++; $pos < $c; $pos++) {
97 97
     			$piece = $pieces[$pos];
98 98
     			if ($piece == 'RMK') break;
99 99
     			if ($piece == 'AUTO') $result['auto'] = true;
100 100
     			if ($piece == 'COR') $result['correction'] = true;
101 101
     			// Wind Speed
102 102
     			if (preg_match('#(VRB|\d\d\d)(\d\d)(?:G(\d\d))?(KT|MPS|KPH)(?: (\d{1,3})V(\d{1,3}))?$#', $piece, $matches)) {
103
-    				$result['wind']['direction'] = (float)$matches[1];
103
+    				$result['wind']['direction'] = (float) $matches[1];
104 104
 				$result['wind']['unit'] = $matches[4];
105
-    				if ($result['wind']['unit'] == 'KT') $result['wind']['speed'] = round(((float)$matches[2])*0.51444444444,2);
106
-    				elseif ($result['wind']['unit'] == 'KPH') $result['wind']['speed'] = round(((float)$matches[2])*1000,2);
107
-    				elseif ($result['wind']['unit'] == 'MPS') $result['wind']['speed'] = round(((float)$matches[2]),2);
108
-				$result['wind']['gust'] = (float)$matches[3];
105
+    				if ($result['wind']['unit'] == 'KT') $result['wind']['speed'] = round(((float) $matches[2])*0.51444444444, 2);
106
+    				elseif ($result['wind']['unit'] == 'KPH') $result['wind']['speed'] = round(((float) $matches[2])*1000, 2);
107
+    				elseif ($result['wind']['unit'] == 'MPS') $result['wind']['speed'] = round(((float) $matches[2]), 2);
108
+				$result['wind']['gust'] = (float) $matches[3];
109 109
 				$result['wind']['unit'] = $matches[4];
110
-				$result['wind']['min_variation'] = array_key_exists(5,$matches) ? $matches[5] : 0;
111
-				$result['wind']['max_variation'] = array_key_exists(6,$matches) ? $matches[6] : 0;
110
+				$result['wind']['min_variation'] = array_key_exists(5, $matches) ? $matches[5] : 0;
111
+				$result['wind']['max_variation'] = array_key_exists(6, $matches) ? $matches[6] : 0;
112 112
     			}
113 113
 
114 114
 /*    			if (preg_match('#^([0-9]{3})([0-9]{2})(G([0-9]{2}))?(KT|MPS)$#', $piece, $matches)) {
@@ -128,14 +128,14 @@  discard block
 block discarded – undo
128 128
     			*/
129 129
     			// Temperature
130 130
     			if (preg_match('#^(M?[0-9]{2,})/(M?[0-9]{2,})$#', $piece, $matches)) {
131
-    				$temp = (float)$matches[1];
131
+    				$temp = (float) $matches[1];
132 132
 				if ($matches[1]{0} == 'M') {
133
-					$temp = ((float)substr($matches[1], 1)) * -1;
133
+					$temp = ((float) substr($matches[1], 1))*-1;
134 134
 				}
135 135
     				$result['temperature'] = $temp;
136
-    				$dew = (float)$matches[2];
136
+    				$dew = (float) $matches[2];
137 137
 				if ($matches[2]{0} == 'M') {
138
-					$dew = ((float)substr($matches[2], 1)) * -1;
138
+					$dew = ((float) substr($matches[2], 1))*-1;
139 139
 				}
140 140
 				$result['dew'] = $dew;
141 141
     			}
@@ -147,7 +147,7 @@  discard block
 block discarded – undo
147 147
     					$result['QNH'] = $matches[2];
148 148
     				} else {
149 149
     					// inHg
150
-    					$result['QNH'] = round(($matches[2] / 100)*33.86389,2);
150
+    					$result['QNH'] = round(($matches[2]/100)*33.86389, 2);
151 151
 				}
152 152
     				/*
153 153
     				$result['QNH'] = $matches[1] == 'Q' ? $matches[2] : ($matches[2] / 100);
@@ -168,12 +168,12 @@  discard block
 block discarded – undo
168 168
     			// Visibility
169 169
     			if (preg_match('#^([0-9]{4})|(([0-9]{1,4})SM)$#', $piece, $matches)) {
170 170
     				if (isset($matches[3]) && strlen($matches[3]) > 0) {
171
-					$result['visibility'] = (float)$matches[3] * 1609.34;
171
+					$result['visibility'] = (float) $matches[3]*1609.34;
172 172
 				} else {
173 173
 					if ($matches[1] == '9999') {
174 174
 						$result['visibility'] = '> 10000';
175 175
 					} else {
176
-						$result['visibility'] = (float)$matches[1];
176
+						$result['visibility'] = (float) $matches[1];
177 177
 					}
178 178
 				}
179 179
 				if (preg_match('#^CAVOK$#', $piece, $matches)) {
@@ -195,7 +195,7 @@  discard block
 block discarded – undo
195 195
     				elseif ($type == 'OVC') $cloud['type'] = 'Overcast/Full cloud coverage';
196 196
     				elseif ($type == 'VV') $cloud['type'] = 'Vertical visibility';
197 197
     				$cloud['type_code'] = $type;
198
-    				$cloud['level'] = round(((float)$matches[2]) * 100 * 0.3048);
198
+    				$cloud['level'] = round(((float) $matches[2])*100*0.3048);
199 199
     				$cloud['significant'] = isset($matches[3]) ? $matches[3] : '';
200 200
     				$result['cloud'][] = $cloud;
201 201
     			}
@@ -205,8 +205,8 @@  discard block
 block discarded – undo
205 205
 				$rvr['runway'] = $matches[1];
206 206
 				$rvr['assessment'] = $matches[2];
207 207
 				$rvr['rvr'] = $matches[3];
208
-				$rvr['rvr_max'] = array_key_exists(4,$matches) ? $matches[4] : 0;
209
-				$rvr['unit'] = array_key_exists(5,$matches) ? $matches[5] : '';
208
+				$rvr['rvr_max'] = array_key_exists(4, $matches) ? $matches[4] : 0;
209
+				$rvr['unit'] = array_key_exists(5, $matches) ? $matches[5] : '';
210 210
 				$result['RVR'] = $rvr;
211 211
 			}
212 212
     			
@@ -223,12 +223,12 @@  discard block
 block discarded – undo
223 223
     			if (preg_match('#^(R[A-Z0-9]{2,3})/([0-9]{4})(V([0-9]{4}))?(FT)?$#', $piece, $matches)) {
224 224
     				//echo $piece;
225 225
     				//print_r($matches);
226
-    				if (isset($matches[5])) $range = array('exact' => (float)$matches[2], 'unit' => $matches[5] ? 'FT' : 'M');
227
-    				else $range = array('exact' => (float)$matches[2], 'unit' => 'M');
226
+    				if (isset($matches[5])) $range = array('exact' => (float) $matches[2], 'unit' => $matches[5] ? 'FT' : 'M');
227
+    				else $range = array('exact' => (float) $matches[2], 'unit' => 'M');
228 228
 				if (isset($matches[3])) {
229 229
 					$range = Array(
230
-					    'from' => (float)$matches[2],
231
-					    'to'   => (float)$matches[4],
230
+					    'from' => (float) $matches[2],
231
+					    'to'   => (float) $matches[4],
232 232
 					    'unit' => $matches[5] ? 'FT' : 'M'
233 233
 					);
234 234
 				}
@@ -277,7 +277,7 @@  discard block
 block discarded – undo
277 277
                  try {
278 278
                         $sth = $this->db->prepare($query);
279 279
                         $sth->execute($query_values);
280
-                } catch(PDOException $e) {
280
+                } catch (PDOException $e) {
281 281
                         return "error : ".$e->getMessage();
282 282
                 }
283 283
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -287,19 +287,19 @@  discard block
 block discarded – undo
287 287
                 return $all;
288 288
         }
289 289
 
290
-       public function addMETAR($location,$metar,$date) {
290
+       public function addMETAR($location, $metar, $date) {
291 291
 		global $globalDBdriver;
292
-		$date = date('Y-m-d H:i:s',strtotime($date));
292
+		$date = date('Y-m-d H:i:s', strtotime($date));
293 293
 		if ($globalDBdriver == 'mysql') {
294 294
 			$query = "INSERT INTO metar (metar_location,metar_date,metar) VALUES (:location,:date,:metar) ON DUPLICATE KEY UPDATE metar_date = :date, metar = :metar";
295 295
 		} else {
296 296
 			$query = "UPDATE metar SET metar_date = :date, metar = metar WHERE metar_location = :location;INSERT INTO metar (metar_location,metar_date,metar) SELECT :location,:date,:metar WHERE NOT EXISTS (SELECT 1 FROM metar WHERE metar_location = :location);";
297 297
 		}
298
-                $query_values = array(':location' => $location,':date' => $date,':metar' => utf8_encode($metar));
298
+                $query_values = array(':location' => $location, ':date' => $date, ':metar' => utf8_encode($metar));
299 299
                  try {
300 300
                         $sth = $this->db->prepare($query);
301 301
                         $sth->execute($query_values);
302
-                } catch(PDOException $e) {
302
+                } catch (PDOException $e) {
303 303
                         return "error : ".$e->getMessage();
304 304
                 }
305 305
         }
@@ -310,7 +310,7 @@  discard block
 block discarded – undo
310 310
                  try {
311 311
                         $sth = $this->db->prepare($query);
312 312
                         $sth->execute($query_values);
313
-                } catch(PDOException $e) {
313
+                } catch (PDOException $e) {
314 314
                         return "error : ".$e->getMessage();
315 315
                 }
316 316
         }
@@ -319,7 +319,7 @@  discard block
 block discarded – undo
319 319
                  try {
320 320
                         $sth = $this->db->prepare($query);
321 321
                         $sth->execute();
322
-                } catch(PDOException $e) {
322
+                } catch (PDOException $e) {
323 323
                         return "error : ".$e->getMessage();
324 324
                 }
325 325
         }
@@ -331,30 +331,30 @@  discard block
 block discarded – undo
331 331
     		$Common = new Common();
332 332
     		if (isset($globalIVAO) && $globalIVAO) {
333 333
         		//$cycle = $Common->getData('http://wx.ivao.aero/metar.php');
334
-			$Common->download('http://wx.ivao.aero/metar.php',dirname(__FILE__).'/../install/tmp/ivaometar.txt');
335
-    			$handle = fopen(dirname(__FILE__).'/../install/tmp/ivaometar.txt',"r");
334
+			$Common->download('http://wx.ivao.aero/metar.php', dirname(__FILE__).'/../install/tmp/ivaometar.txt');
335
+    			$handle = fopen(dirname(__FILE__).'/../install/tmp/ivaometar.txt', "r");
336 336
     		} else {
337 337
 			//$cycle = $Common->getData('http://tgftp.nws.noaa.gov/data/observations/metar/cycles/'.date('H').'Z.TXT');
338
-			$Common->download('http://tgftp.nws.noaa.gov/data/observations/metar/cycles/'.date('H').'Z.TXT',dirname(__FILE__).'/../install/tmp/'.date('H').'Z.TXT');
339
-    			$handle = fopen(dirname(__FILE__).'/../install/tmp/'.date('H').'Z.TXT',"r");
338
+			$Common->download('http://tgftp.nws.noaa.gov/data/observations/metar/cycles/'.date('H').'Z.TXT', dirname(__FILE__).'/../install/tmp/'.date('H').'Z.TXT');
339
+    			$handle = fopen(dirname(__FILE__).'/../install/tmp/'.date('H').'Z.TXT', "r");
340 340
     		}
341 341
     		if ($handle) {
342 342
 			if (isset($globalDebug) && $globalDebug) echo "Done - Updating DB...";
343 343
 			$date = '';
344 344
     			//foreach(explode("\n",$cycle) as $line) {
345 345
     			if ($globalTransaction) $this->db->beginTransaction();
346
-	    		while(($line = fgets($handle,4096)) !== false) {
347
-				if (preg_match('#^([0-9]{4})/([0-9]{2})/([0-9]{2}) ([0-9]{2}):([0-9]{2})$#',$line)) {
346
+	    		while (($line = fgets($handle, 4096)) !== false) {
347
+				if (preg_match('#^([0-9]{4})/([0-9]{2})/([0-9]{2}) ([0-9]{2}):([0-9]{2})$#', $line)) {
348 348
 					$date = $line;
349 349
     				} elseif ($line != '') {
350 350
     				    //$this->parse($line);
351 351
     				    if ($date == '') $date = date('Y/m/d H:m');
352 352
         			    $pos = 0;
353
-        			    $pieces = preg_split('/\s/',$line);
353
+        			    $pieces = preg_split('/\s/', $line);
354 354
         			    if ($pieces[0] == 'METAR') $pos++;
355 355
         			    if (strlen($pieces[$pos]) != 4) $pos++;
356 356
 		        	    $location = $pieces[$pos];
357
-        	        	    echo $this->addMETAR($location,$line,$date);
357
+        	        	    echo $this->addMETAR($location, $line, $date);
358 358
     				}
359 359
     			}
360 360
     			fclose($handle);
@@ -368,11 +368,11 @@  discard block
 block discarded – undo
368 368
     		if ($globalMETARurl == '') return array();
369 369
     		date_default_timezone_set("UTC");
370 370
     		$Common = new Common();
371
-    		$url = str_replace('{icao}',$icao,$globalMETARurl);
371
+    		$url = str_replace('{icao}', $icao, $globalMETARurl);
372 372
     		$cycle = $Common->getData($url);
373 373
     		$date = '';
374
-    		foreach(explode("\n",$cycle) as $line) {
375
-    			if (preg_match('#^([0-9]{4})/([0-9]{2})/([0-9]{2}) ([0-9]{2}):([0-9]{2})$#',$line)) {
374
+    		foreach (explode("\n", $cycle) as $line) {
375
+    			if (preg_match('#^([0-9]{4})/([0-9]{2})/([0-9]{2}) ([0-9]{2}):([0-9]{2})$#', $line)) {
376 376
     				//echo "date : ".$line."\n";
377 377
     				$date = $line;
378 378
     			} 
@@ -381,12 +381,12 @@  discard block
 block discarded – undo
381 381
     			    //echo $line;
382 382
     			    if ($date == '') $date = date('Y/m/d H:m');
383 383
     			    $pos = 0;
384
-    			    $pieces = preg_split('/\s/',$line);
384
+    			    $pieces = preg_split('/\s/', $line);
385 385
     			    if ($pieces[0] == 'METAR') $pos++;
386 386
     			    if (strlen($pieces[$pos]) != 4) $pos++;
387 387
 	        	    $location = $pieces[$pos];
388 388
 	        	    if (strlen($location == 4)) {
389
-	        		$this->addMETAR($location,$line,$date);
389
+	        		$this->addMETAR($location, $line, $date);
390 390
 	        		return array('0' => array('metar_date' => $date, 'metar_location' => $location, 'metar' => $line));
391 391
 	        	    } else return array();
392 392
     			}
Please login to merge, or discard this patch.
Braces   +100 added lines, -38 removed lines patch added patch discarded remove patch
@@ -59,8 +59,11 @@  discard block
 block discarded – undo
59 59
                 }
60 60
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
61 61
                 $sth->closeCursor();
62
-                if ($row['nb'] > 0) return false;
63
-                else return true;
62
+                if ($row['nb'] > 0) {
63
+                	return false;
64
+                } else {
65
+                	return true;
66
+                }
64 67
         }
65 68
 
66 69
         public static function insert_last_update() {
@@ -84,9 +87,14 @@  discard block
 block discarded – undo
84 87
     		//$pieces = explode(' ',$data);
85 88
     		$pieces = preg_split('/\s/',$data);
86 89
     		$pos = 0;
87
-    		if ($pieces[0] == 'METAR') $pos++;
88
-    		elseif ($pieces[0] == 'SPECI') $pos++;
89
-    		if (strlen($pieces[$pos]) != 4) $pos++;
90
+    		if ($pieces[0] == 'METAR') {
91
+    			$pos++;
92
+    		} elseif ($pieces[0] == 'SPECI') {
93
+    			$pos++;
94
+    		}
95
+    		if (strlen($pieces[$pos]) != 4) {
96
+    			$pos++;
97
+    		}
90 98
     		$result = array();
91 99
     		$result['location'] = $pieces[$pos];
92 100
     		$pos++;
@@ -95,16 +103,26 @@  discard block
 block discarded – undo
95 103
     		$c = count($pieces);
96 104
     		for($pos++; $pos < $c; $pos++) {
97 105
     			$piece = $pieces[$pos];
98
-    			if ($piece == 'RMK') break;
99
-    			if ($piece == 'AUTO') $result['auto'] = true;
100
-    			if ($piece == 'COR') $result['correction'] = true;
106
+    			if ($piece == 'RMK') {
107
+    				break;
108
+    			}
109
+    			if ($piece == 'AUTO') {
110
+    				$result['auto'] = true;
111
+    			}
112
+    			if ($piece == 'COR') {
113
+    				$result['correction'] = true;
114
+    			}
101 115
     			// Wind Speed
102 116
     			if (preg_match('#(VRB|\d\d\d)(\d\d)(?:G(\d\d))?(KT|MPS|KPH)(?: (\d{1,3})V(\d{1,3}))?$#', $piece, $matches)) {
103 117
     				$result['wind']['direction'] = (float)$matches[1];
104 118
 				$result['wind']['unit'] = $matches[4];
105
-    				if ($result['wind']['unit'] == 'KT') $result['wind']['speed'] = round(((float)$matches[2])*0.51444444444,2);
106
-    				elseif ($result['wind']['unit'] == 'KPH') $result['wind']['speed'] = round(((float)$matches[2])*1000,2);
107
-    				elseif ($result['wind']['unit'] == 'MPS') $result['wind']['speed'] = round(((float)$matches[2]),2);
119
+    				if ($result['wind']['unit'] == 'KT') {
120
+    					$result['wind']['speed'] = round(((float)$matches[2])*0.51444444444,2);
121
+    				} elseif ($result['wind']['unit'] == 'KPH') {
122
+    					$result['wind']['speed'] = round(((float)$matches[2])*1000,2);
123
+    				} elseif ($result['wind']['unit'] == 'MPS') {
124
+    					$result['wind']['speed'] = round(((float)$matches[2]),2);
125
+    				}
108 126
 				$result['wind']['gust'] = (float)$matches[3];
109 127
 				$result['wind']['unit'] = $matches[4];
110 128
 				$result['wind']['min_variation'] = array_key_exists(5,$matches) ? $matches[5] : 0;
@@ -186,14 +204,23 @@  discard block
 block discarded – undo
186 204
     				//$this->addCloudCover($matches[1], ((float)$matches[2]) * 100, isset($matches[3]) ? $matches[3] : '');
187 205
     				$type = $matches[1];
188 206
     				$cloud = array();
189
-    				if ($type == 'SKC') $cloud['type'] = 'No cloud/Sky clear';
190
-    				elseif ($type == 'CLR') $cloud['type'] = 'No cloud below 12,000ft (3700m)';
191
-    				elseif ($type == 'NSC') $cloud['type'] = 'No significant cloud';
192
-    				elseif ($type == 'FEW') $cloud['type'] = 'Few';
193
-    				elseif ($type == 'SCT') $cloud['type'] = 'Scattered';
194
-    				elseif ($type == 'BKN') $cloud['type'] = 'Broken';
195
-    				elseif ($type == 'OVC') $cloud['type'] = 'Overcast/Full cloud coverage';
196
-    				elseif ($type == 'VV') $cloud['type'] = 'Vertical visibility';
207
+    				if ($type == 'SKC') {
208
+    					$cloud['type'] = 'No cloud/Sky clear';
209
+    				} elseif ($type == 'CLR') {
210
+    					$cloud['type'] = 'No cloud below 12,000ft (3700m)';
211
+    				} elseif ($type == 'NSC') {
212
+    					$cloud['type'] = 'No significant cloud';
213
+    				} elseif ($type == 'FEW') {
214
+    					$cloud['type'] = 'Few';
215
+    				} elseif ($type == 'SCT') {
216
+    					$cloud['type'] = 'Scattered';
217
+    				} elseif ($type == 'BKN') {
218
+    					$cloud['type'] = 'Broken';
219
+    				} elseif ($type == 'OVC') {
220
+    					$cloud['type'] = 'Overcast/Full cloud coverage';
221
+    				} elseif ($type == 'VV') {
222
+    					$cloud['type'] = 'Vertical visibility';
223
+    				}
197 224
     				$cloud['type_code'] = $type;
198 225
     				$cloud['level'] = round(((float)$matches[2]) * 100 * 0.3048);
199 226
     				$cloud['significant'] = isset($matches[3]) ? $matches[3] : '';
@@ -223,8 +250,11 @@  discard block
 block discarded – undo
223 250
     			if (preg_match('#^(R[A-Z0-9]{2,3})/([0-9]{4})(V([0-9]{4}))?(FT)?$#', $piece, $matches)) {
224 251
     				//echo $piece;
225 252
     				//print_r($matches);
226
-    				if (isset($matches[5])) $range = array('exact' => (float)$matches[2], 'unit' => $matches[5] ? 'FT' : 'M');
227
-    				else $range = array('exact' => (float)$matches[2], 'unit' => 'M');
253
+    				if (isset($matches[5])) {
254
+    					$range = array('exact' => (float)$matches[2], 'unit' => $matches[5] ? 'FT' : 'M');
255
+    				} else {
256
+    					$range = array('exact' => (float)$matches[2], 'unit' => 'M');
257
+    				}
228 258
 				if (isset($matches[3])) {
229 259
 					$range = Array(
230 260
 					    'from' => (float)$matches[2],
@@ -257,8 +287,11 @@  discard block
 block discarded – undo
257 287
 				if (isset($matches[3])) {
258 288
 					$text[] = $this->texts[$matches[3]];
259 289
 				}
260
-				if (!isset($result['weather'])) $result['weather'] = implode(' ', $text);
261
-				else $result['weather'] = $result['weather'].' / '.implode(' ', $text);
290
+				if (!isset($result['weather'])) {
291
+					$result['weather'] = implode(' ', $text);
292
+				} else {
293
+					$result['weather'] = $result['weather'].' / '.implode(' ', $text);
294
+				}
262 295
     			}
263 296
     		}
264 297
     		return $result;
@@ -270,8 +303,11 @@  discard block
 block discarded – undo
270 303
     		if (isset($globalMETARcycle) && $globalMETARcycle) {
271 304
             		$query = "SELECT * FROM metar WHERE metar_location = :icao";
272 305
                 } else {
273
-            		if ($globalDBdriver == 'mysql') $query = "SELECT * FROM metar WHERE metar_location = :icao AND metar_date >= DATE_SUB(UTC_TIMESTAMP(), INTERVAL 10 HOUR) LIMIT 1";
274
-            		else $query = "SELECT * FROM metar WHERE metar_location = :icao AND metar_date >= now() AT TIMEZONE 'UTC' - '10 HOUR'->INTERVAL LIMIT 0,1";
306
+            		if ($globalDBdriver == 'mysql') {
307
+            			$query = "SELECT * FROM metar WHERE metar_location = :icao AND metar_date >= DATE_SUB(UTC_TIMESTAMP(), INTERVAL 10 HOUR) LIMIT 1";
308
+            		} else {
309
+            			$query = "SELECT * FROM metar WHERE metar_location = :icao AND metar_date >= now() AT TIMEZONE 'UTC' - '10 HOUR'->INTERVAL LIMIT 0,1";
310
+            		}
275 311
                 }
276 312
                 $query_values = array(':icao' => $icao);
277 313
                  try {
@@ -326,7 +362,9 @@  discard block
 block discarded – undo
326 362
         
327 363
         public function addMETARCycle() {
328 364
     		global $globalDebug, $globalIVAO, $globalTransaction;
329
-    		if (isset($globalDebug) && $globalDebug) echo "Downloading METAR cycle...";
365
+    		if (isset($globalDebug) && $globalDebug) {
366
+    			echo "Downloading METAR cycle...";
367
+    		}
330 368
     		date_default_timezone_set("UTC");
331 369
     		$Common = new Common();
332 370
     		if (isset($globalIVAO) && $globalIVAO) {
@@ -339,33 +377,49 @@  discard block
 block discarded – undo
339 377
     			$handle = fopen(dirname(__FILE__).'/../install/tmp/'.date('H').'Z.TXT',"r");
340 378
     		}
341 379
     		if ($handle) {
342
-			if (isset($globalDebug) && $globalDebug) echo "Done - Updating DB...";
380
+			if (isset($globalDebug) && $globalDebug) {
381
+				echo "Done - Updating DB...";
382
+			}
343 383
 			$date = '';
344 384
     			//foreach(explode("\n",$cycle) as $line) {
345
-    			if ($globalTransaction) $this->db->beginTransaction();
385
+    			if ($globalTransaction) {
386
+    				$this->db->beginTransaction();
387
+    			}
346 388
 	    		while(($line = fgets($handle,4096)) !== false) {
347 389
 				if (preg_match('#^([0-9]{4})/([0-9]{2})/([0-9]{2}) ([0-9]{2}):([0-9]{2})$#',$line)) {
348 390
 					$date = $line;
349 391
     				} elseif ($line != '') {
350 392
     				    //$this->parse($line);
351
-    				    if ($date == '') $date = date('Y/m/d H:m');
393
+    				    if ($date == '') {
394
+    				    	$date = date('Y/m/d H:m');
395
+    				    }
352 396
         			    $pos = 0;
353 397
         			    $pieces = preg_split('/\s/',$line);
354
-        			    if ($pieces[0] == 'METAR') $pos++;
355
-        			    if (strlen($pieces[$pos]) != 4) $pos++;
398
+        			    if ($pieces[0] == 'METAR') {
399
+        			    	$pos++;
400
+        			    }
401
+        			    if (strlen($pieces[$pos]) != 4) {
402
+        			    	$pos++;
403
+        			    }
356 404
 		        	    $location = $pieces[$pos];
357 405
         	        	    echo $this->addMETAR($location,$line,$date);
358 406
     				}
359 407
     			}
360 408
     			fclose($handle);
361
-    			if ($globalTransaction) $this->db->commit();
409
+    			if ($globalTransaction) {
410
+    				$this->db->commit();
411
+    			}
412
+    		}
413
+    		if (isset($globalDebug) && $globalDebug) {
414
+    			echo "Done\n";
362 415
     		}
363
-    		if (isset($globalDebug) && $globalDebug) echo "Done\n";
364 416
         
365 417
         }
366 418
         public function downloadMETAR($icao) {
367 419
     		global $globalMETARurl;
368
-    		if ($globalMETARurl == '') return array();
420
+    		if ($globalMETARurl == '') {
421
+    			return array();
422
+    		}
369 423
     		date_default_timezone_set("UTC");
370 424
     		$Common = new Common();
371 425
     		$url = str_replace('{icao}',$icao,$globalMETARurl);
@@ -379,16 +433,24 @@  discard block
 block discarded – undo
379 433
     			if ($line != '') {
380 434
     			    //$this->parse($line);
381 435
     			    //echo $line;
382
-    			    if ($date == '') $date = date('Y/m/d H:m');
436
+    			    if ($date == '') {
437
+    			    	$date = date('Y/m/d H:m');
438
+    			    }
383 439
     			    $pos = 0;
384 440
     			    $pieces = preg_split('/\s/',$line);
385
-    			    if ($pieces[0] == 'METAR') $pos++;
386
-    			    if (strlen($pieces[$pos]) != 4) $pos++;
441
+    			    if ($pieces[0] == 'METAR') {
442
+    			    	$pos++;
443
+    			    }
444
+    			    if (strlen($pieces[$pos]) != 4) {
445
+    			    	$pos++;
446
+    			    }
387 447
 	        	    $location = $pieces[$pos];
388 448
 	        	    if (strlen($location == 4)) {
389 449
 	        		$this->addMETAR($location,$line,$date);
390 450
 	        		return array('0' => array('metar_date' => $date, 'metar_location' => $location, 'metar' => $line));
391
-	        	    } else return array();
451
+	        	    } else {
452
+	        	    	return array();
453
+	        	    }
392 454
     			}
393 455
     			//echo $line."\n";
394 456
     		}
Please login to merge, or discard this patch.
require/class.SpotterLive.php 4 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -14,7 +14,7 @@
 block discarded – undo
14 14
 	/**
15 15
 	* Get SQL query part for filter used
16 16
 	* @param Array $filter the filter
17
-	* @return Array the SQL part
17
+	* @return string the SQL part
18 18
 	*/
19 19
 	public function getFilter($filter = array(),$where = false,$and = false) {
20 20
 		global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver;
Please login to merge, or discard this patch.
Indentation   +206 added lines, -206 removed lines patch added patch discarded remove patch
@@ -12,10 +12,10 @@  discard block
 block discarded – undo
12 12
 
13 13
 
14 14
 	/**
15
-	* Get SQL query part for filter used
16
-	* @param Array $filter the filter
17
-	* @return Array the SQL part
18
-	*/
15
+	 * Get SQL query part for filter used
16
+	 * @param Array $filter the filter
17
+	 * @return Array the SQL part
18
+	 */
19 19
 	public function getFilter($filter = array(),$where = false,$and = false) {
20 20
 		global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver;
21 21
 		$filters = array();
@@ -128,11 +128,11 @@  discard block
 block discarded – undo
128 128
 	}
129 129
 
130 130
 	/**
131
-	* Gets all the spotter information based on the latest data entry
132
-	*
133
-	* @return Array the spotter information
134
-	*
135
-	*/
131
+	 * Gets all the spotter information based on the latest data entry
132
+	 *
133
+	 * @return Array the spotter information
134
+	 *
135
+	 */
136 136
 	public function getLiveSpotterData($limit = '', $sort = '', $filter = array())
137 137
 	{
138 138
 		global $globalDBdriver, $globalLiveInterval;
@@ -174,11 +174,11 @@  discard block
 block discarded – undo
174 174
 	}
175 175
 
176 176
 	/**
177
-	* Gets Minimal Live Spotter data
178
-	*
179
-	* @return Array the spotter information
180
-	*
181
-	*/
177
+	 * Gets Minimal Live Spotter data
178
+	 *
179
+	 * @return Array the spotter information
180
+	 *
181
+	 */
182 182
 	public function getMinLiveSpotterData($filter = array())
183 183
 	{
184 184
 		global $globalDBdriver, $globalLiveInterval, $globalArchive;
@@ -215,11 +215,11 @@  discard block
 block discarded – undo
215 215
 	}
216 216
 
217 217
 	/**
218
-	* Gets Minimal Live Spotter data since xx seconds
219
-	*
220
-	* @return Array the spotter information
221
-	*
222
-	*/
218
+	 * Gets Minimal Live Spotter data since xx seconds
219
+	 *
220
+	 * @return Array the spotter information
221
+	 *
222
+	 */
223 223
 	public function getMinLastLiveSpotterData($filter = array())
224 224
 	{
225 225
 		global $globalDBdriver, $globalLiveInterval, $globalArchive;
@@ -238,7 +238,7 @@  discard block
 block discarded – undo
238 238
 				FROM spotter_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= spotter_live.date AND spotter_live.latitude <> '0' AND spotter_live.longitude <> '0' 
239 239
 				ORDER BY spotter_live.flightaware_id, spotter_live.date";
240 240
 			}
241
-                } else {
241
+				} else {
242 242
 			if (isset($globalArchive) && $globalArchive === TRUE) {
243 243
 				$query  = "SELECT spotter_archive.ident, spotter_archive.flightaware_id, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk, spotter_archive.date, spotter_archive.format_source 
244 244
 				FROM spotter_archive INNER JOIN (SELECT flightaware_id FROM spotter_live".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= spotter_live.date) l ON l.flightaware_id = spotter_archive.flightaware_id WHERE spotter_archive.latitude <> '0' AND spotter_archive.longitude <> '0' 
@@ -250,7 +250,7 @@  discard block
 block discarded – undo
250 250
 			}
251 251
 		}
252 252
 
253
-    		try {
253
+			try {
254 254
 			$sth = $this->db->prepare($query);
255 255
 			$sth->execute();
256 256
 		} catch(PDOException $e) {
@@ -262,11 +262,11 @@  discard block
 block discarded – undo
262 262
 	}
263 263
 
264 264
 	/**
265
-	* Gets number of latest data entry
266
-	*
267
-	* @return String number of entry
268
-	*
269
-	*/
265
+	 * Gets number of latest data entry
266
+	 *
267
+	 * @return String number of entry
268
+	 *
269
+	 */
270 270
 	public function getLiveSpotterCount($filter = array())
271 271
 	{
272 272
 		global $globalDBdriver, $globalLiveInterval;
@@ -293,11 +293,11 @@  discard block
 block discarded – undo
293 293
 	}
294 294
 
295 295
 	/**
296
-	* Gets all the spotter information based on the latest data entry and coord
297
-	*
298
-	* @return Array the spotter information
299
-	*
300
-	*/
296
+	 * Gets all the spotter information based on the latest data entry and coord
297
+	 *
298
+	 * @return Array the spotter information
299
+	 *
300
+	 */
301 301
 	public function getLiveSpotterDatabyCoord($coord, $filter = array())
302 302
 	{
303 303
 		global $globalDBdriver, $globalLiveInterval;
@@ -322,11 +322,11 @@  discard block
 block discarded – undo
322 322
 	}
323 323
 
324 324
 	/**
325
-	* Gets all the spotter information based on the latest data entry and coord
326
-	*
327
-	* @return Array the spotter information
328
-	*
329
-	*/
325
+	 * Gets all the spotter information based on the latest data entry and coord
326
+	 *
327
+	 * @return Array the spotter information
328
+	 *
329
+	 */
330 330
 	public function getMinLiveSpotterDatabyCoord($coord, $filter = array())
331 331
 	{
332 332
 		global $globalDBdriver, $globalLiveInterval, $globalArchive;
@@ -391,11 +391,11 @@  discard block
 block discarded – undo
391 391
 	}
392 392
 
393 393
 	/**
394
-	* Gets all the spotter information based on a user's latitude and longitude
395
-	*
396
-	* @return Array the spotter information
397
-	*
398
-	*/
394
+	 * Gets all the spotter information based on a user's latitude and longitude
395
+	 *
396
+	 * @return Array the spotter information
397
+	 *
398
+	 */
399 399
 	public function getLatestSpotterForLayar($lat, $lng, $radius, $interval)
400 400
 	{
401 401
 		$Spotter = new Spotter($this->db);
@@ -405,145 +405,145 @@  discard block
 block discarded – undo
405 405
 				return false;
406 406
 			}
407 407
 		}
408
-        if ($lng != '')
409
-                {
410
-                        if (!is_numeric($lng))
411
-                        {
412
-                                return false;
413
-                        }
414
-                }
415
-
416
-                if ($radius != '')
417
-                {
418
-                        if (!is_numeric($radius))
419
-                        {
420
-                                return false;
421
-                        }
422
-                }
408
+		if ($lng != '')
409
+				{
410
+						if (!is_numeric($lng))
411
+						{
412
+								return false;
413
+						}
414
+				}
415
+
416
+				if ($radius != '')
417
+				{
418
+						if (!is_numeric($radius))
419
+						{
420
+								return false;
421
+						}
422
+				}
423 423
 		$additional_query = '';
424
-        if ($interval != '')
425
-                {
426
-                        if (!is_string($interval))
427
-                        {
428
-                                //$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date ';
429
-			        return false;
430
-                        } else {
431
-                if ($interval == '1m')
432
-                {
433
-                    $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date ';
434
-                } else if ($interval == '15m'){
435
-                    $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 MINUTE) <= spotter_live.date ';
436
-                } 
437
-            }
438
-                } else {
439
-         $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date ';   
440
-        }
441
-
442
-                $query  = "SELECT spotter_live.*, ( 6371 * acos( cos( radians(:lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(:lng) ) + sin( radians(:lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM spotter_live 
424
+		if ($interval != '')
425
+				{
426
+						if (!is_string($interval))
427
+						{
428
+								//$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date ';
429
+					return false;
430
+						} else {
431
+				if ($interval == '1m')
432
+				{
433
+					$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date ';
434
+				} else if ($interval == '15m'){
435
+					$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 MINUTE) <= spotter_live.date ';
436
+				} 
437
+			}
438
+				} else {
439
+		 $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date ';   
440
+		}
441
+
442
+				$query  = "SELECT spotter_live.*, ( 6371 * acos( cos( radians(:lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(:lng) ) + sin( radians(:lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM spotter_live 
443 443
                    WHERE spotter_live.latitude <> '' 
444 444
                                    AND spotter_live.longitude <> '' 
445 445
                    ".$additional_query."
446 446
                    HAVING distance < :radius  
447 447
                                    ORDER BY distance";
448 448
 
449
-                $spotter_array = $Spotter->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng,':radius' => $radius));
449
+				$spotter_array = $Spotter->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng,':radius' => $radius));
450 450
 
451
-                return $spotter_array;
452
-        }
451
+				return $spotter_array;
452
+		}
453 453
 
454 454
     
455
-        /**
456
-	* Gets all the spotter information based on a particular callsign
457
-	*
458
-	* @return Array the spotter information
459
-	*
460
-	*/
455
+		/**
456
+		 * Gets all the spotter information based on a particular callsign
457
+		 *
458
+		 * @return Array the spotter information
459
+		 *
460
+		 */
461 461
 	public function getLastLiveSpotterDataByIdent($ident)
462 462
 	{
463 463
 		$Spotter = new Spotter($this->db);
464 464
 		date_default_timezone_set('UTC');
465 465
 
466 466
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
467
-                $query  = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC';
467
+				$query  = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC';
468 468
 
469 469
 		$spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident),'',true);
470 470
 
471 471
 		return $spotter_array;
472 472
 	}
473 473
 
474
-        /**
475
-	* Gets all the spotter information based on a particular callsign
476
-	*
477
-	* @return Array the spotter information
478
-	*
479
-	*/
474
+		/**
475
+		 * Gets all the spotter information based on a particular callsign
476
+		 *
477
+		 * @return Array the spotter information
478
+		 *
479
+		 */
480 480
 	public function getDateLiveSpotterDataByIdent($ident,$date)
481 481
 	{
482 482
 		$Spotter = new Spotter($this->db);
483 483
 		date_default_timezone_set('UTC');
484 484
 
485 485
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
486
-                $query  = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC';
486
+				$query  = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC';
487 487
 
488
-                $date = date('c',$date);
488
+				$date = date('c',$date);
489 489
 		$spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident,':date' => $date));
490 490
 
491 491
 		return $spotter_array;
492 492
 	}
493 493
 
494
-        /**
495
-	* Gets last spotter information based on a particular callsign
496
-	*
497
-	* @return Array the spotter information
498
-	*
499
-	*/
494
+		/**
495
+		 * Gets last spotter information based on a particular callsign
496
+		 *
497
+		 * @return Array the spotter information
498
+		 *
499
+		 */
500 500
 	public function getLastLiveSpotterDataById($id)
501 501
 	{
502 502
 		$Spotter = new Spotter($this->db);
503 503
 		date_default_timezone_set('UTC');
504 504
 
505 505
 		$id = filter_var($id, FILTER_SANITIZE_STRING);
506
-                $query  = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.flightaware_id = :id GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC';
506
+				$query  = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.flightaware_id = :id GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC';
507 507
 
508 508
 		$spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id),'',true);
509 509
 
510 510
 		return $spotter_array;
511 511
 	}
512 512
 
513
-        /**
514
-	* Gets last spotter information based on a particular callsign
515
-	*
516
-	* @return Array the spotter information
517
-	*
518
-	*/
513
+		/**
514
+		 * Gets last spotter information based on a particular callsign
515
+		 *
516
+		 * @return Array the spotter information
517
+		 *
518
+		 */
519 519
 	public function getDateLiveSpotterDataById($id,$date)
520 520
 	{
521 521
 		$Spotter = new Spotter($this->db);
522 522
 		date_default_timezone_set('UTC');
523 523
 
524 524
 		$id = filter_var($id, FILTER_SANITIZE_STRING);
525
-                $query  = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.flightaware_id = :id AND l.date <= :date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC';
526
-                $date = date('c',$date);
525
+				$query  = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.flightaware_id = :id AND l.date <= :date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC';
526
+				$date = date('c',$date);
527 527
 		$spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id,':date' => $date),'',true);
528 528
 
529 529
 		return $spotter_array;
530 530
 	}
531 531
 
532
-        /**
533
-	* Gets altitude information based on a particular callsign
534
-	*
535
-	* @return Array the spotter information
536
-	*
537
-	*/
532
+		/**
533
+		 * Gets altitude information based on a particular callsign
534
+		 *
535
+		 * @return Array the spotter information
536
+		 *
537
+		 */
538 538
 	public function getAltitudeLiveSpotterDataByIdent($ident)
539 539
 	{
540 540
 
541 541
 		date_default_timezone_set('UTC');
542 542
 
543 543
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
544
-                $query  = 'SELECT spotter_live.altitude, spotter_live.date FROM spotter_live WHERE spotter_live.ident = :ident';
544
+				$query  = 'SELECT spotter_live.altitude, spotter_live.date FROM spotter_live WHERE spotter_live.ident = :ident';
545 545
 
546
-    		try {
546
+			try {
547 547
 			
548 548
 			$sth = $this->db->prepare($query);
549 549
 			$sth->execute(array(':ident' => $ident));
@@ -556,12 +556,12 @@  discard block
 block discarded – undo
556 556
 		return $spotter_array;
557 557
 	}
558 558
 
559
-        /**
560
-	* Gets all the spotter information based on a particular id
561
-	*
562
-	* @return Array the spotter information
563
-	*
564
-	*/
559
+		/**
560
+		 * Gets all the spotter information based on a particular id
561
+		 *
562
+		 * @return Array the spotter information
563
+		 *
564
+		 */
565 565
 	public function getAllLiveSpotterDataById($id,$liveinterval = false)
566 566
 	{
567 567
 		global $globalDBdriver, $globalLiveInterval;
@@ -589,18 +589,18 @@  discard block
 block discarded – undo
589 589
 		return $spotter_array;
590 590
 	}
591 591
 
592
-        /**
593
-	* Gets all the spotter information based on a particular ident
594
-	*
595
-	* @return Array the spotter information
596
-	*
597
-	*/
592
+		/**
593
+		 * Gets all the spotter information based on a particular ident
594
+		 *
595
+		 * @return Array the spotter information
596
+		 *
597
+		 */
598 598
 	public function getAllLiveSpotterDataByIdent($ident)
599 599
 	{
600 600
 		date_default_timezone_set('UTC');
601 601
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
602 602
 		$query  = self::$global_query.' WHERE spotter_live.ident = :ident';
603
-    		try {
603
+			try {
604 604
 			
605 605
 			$sth = $this->db->prepare($query);
606 606
 			$sth->execute(array(':ident' => $ident));
@@ -614,23 +614,23 @@  discard block
 block discarded – undo
614 614
 
615 615
 
616 616
 	/**
617
-	* Deletes all info in the table
618
-	*
619
-	* @return String success or false
620
-	*
621
-	*/
617
+	 * Deletes all info in the table
618
+	 *
619
+	 * @return String success or false
620
+	 *
621
+	 */
622 622
 	public function deleteLiveSpotterData()
623 623
 	{
624 624
 		global $globalDBdriver;
625 625
 		if ($globalDBdriver == 'mysql') {
626 626
 			//$query  = "DELETE FROM spotter_live WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 MINUTE) >= spotter_live.date";
627 627
 			$query  = 'DELETE FROM spotter_live WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 9 HOUR) >= spotter_live.date';
628
-            		//$query  = "DELETE FROM spotter_live WHERE spotter_live.id IN (SELECT spotter_live.id FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) >= spotter_live.date)";
628
+					//$query  = "DELETE FROM spotter_live WHERE spotter_live.id IN (SELECT spotter_live.id FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) >= spotter_live.date)";
629 629
 		} else {
630 630
 			$query  = "DELETE FROM spotter_live WHERE NOW() AT TIME ZONE 'UTC' - INTERVAL '9 HOURS' >= spotter_live.date";
631 631
 		}
632 632
         
633
-    		try {
633
+			try {
634 634
 			
635 635
 			$sth = $this->db->prepare($query);
636 636
 			$sth->execute();
@@ -642,18 +642,18 @@  discard block
 block discarded – undo
642 642
 	}
643 643
 
644 644
 	/**
645
-	* Deletes all info in the table for aircraft not seen since 2 HOUR
646
-	*
647
-	* @return String success or false
648
-	*
649
-	*/
645
+	 * Deletes all info in the table for aircraft not seen since 2 HOUR
646
+	 *
647
+	 * @return String success or false
648
+	 *
649
+	 */
650 650
 	public function deleteLiveSpotterDataNotUpdated()
651 651
 	{
652 652
 		global $globalDBdriver, $globalDebug;
653 653
 		if ($globalDBdriver == 'mysql') {
654 654
 			//$query = 'SELECT flightaware_id FROM spotter_live WHERE DATE_SUB(UTC_TIMESTAMP(), INTERVAL 1 HOUR) >= spotter_live.date AND spotter_live.flightaware_id NOT IN (SELECT flightaware_id FROM spotter_live WHERE DATE_SUB(UTC_TIMESTAMP(), INTERVAL 1 HOUR) < spotter_live.date) LIMIT 800 OFFSET 0';
655
-    			$query = "SELECT spotter_live.flightaware_id FROM spotter_live INNER JOIN (SELECT flightaware_id,MAX(date) as max_date FROM spotter_live GROUP BY flightaware_id) s ON s.flightaware_id = spotter_live.flightaware_id AND DATE_SUB(UTC_TIMESTAMP(), INTERVAL 2 HOUR) >= s.max_date LIMIT 2000 OFFSET 0";
656
-    			try {
655
+				$query = "SELECT spotter_live.flightaware_id FROM spotter_live INNER JOIN (SELECT flightaware_id,MAX(date) as max_date FROM spotter_live GROUP BY flightaware_id) s ON s.flightaware_id = spotter_live.flightaware_id AND DATE_SUB(UTC_TIMESTAMP(), INTERVAL 2 HOUR) >= s.max_date LIMIT 2000 OFFSET 0";
656
+				try {
657 657
 				
658 658
 				$sth = $this->db->prepare($query);
659 659
 				$sth->execute();
@@ -661,8 +661,8 @@  discard block
 block discarded – undo
661 661
 				return "error";
662 662
 			}
663 663
 			$query_delete = 'DELETE FROM spotter_live WHERE flightaware_id IN (';
664
-                        $i = 0;
665
-                        $j =0;
664
+						$i = 0;
665
+						$j =0;
666 666
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
667 667
 			foreach($all as $row)
668 668
 			{
@@ -670,20 +670,20 @@  discard block
 block discarded – undo
670 670
 				$j++;
671 671
 				if ($j == 30) {
672 672
 					if ($globalDebug) echo ".";
673
-				    	try {
673
+						try {
674 674
 						
675 675
 						$sth = $this->db->prepare(substr($query_delete,0,-1).")");
676 676
 						$sth->execute();
677 677
 					} catch(PDOException $e) {
678 678
 						return "error";
679 679
 					}
680
-                                	$query_delete = 'DELETE FROM spotter_live WHERE flightaware_id IN (';
681
-                                	$j = 0;
680
+									$query_delete = 'DELETE FROM spotter_live WHERE flightaware_id IN (';
681
+									$j = 0;
682 682
 				}
683 683
 				$query_delete .= "'".$row['flightaware_id']."',";
684 684
 			}
685 685
 			if ($i > 0) {
686
-    				try {
686
+					try {
687 687
 					
688 688
 					$sth = $this->db->prepare(substr($query_delete,0,-1).")");
689 689
 					$sth->execute();
@@ -694,9 +694,9 @@  discard block
 block discarded – undo
694 694
 			return "success";
695 695
 		} elseif ($globalDBdriver == 'pgsql') {
696 696
 			//$query = "SELECT flightaware_id FROM spotter_live WHERE NOW() AT TIME ZONE 'UTC' - INTERVAL '9 HOURS' >= spotter_live.date AND spotter_live.flightaware_id NOT IN (SELECT flightaware_id FROM spotter_live WHERE NOW() AT TIME ZONE 'UTC' - INTERVAL '9 HOURS' < spotter_live.date) LIMIT 800 OFFSET 0";
697
-    			//$query = "SELECT spotter_live.flightaware_id FROM spotter_live INNER JOIN (SELECT flightaware_id,MAX(date) as max_date FROM spotter_live GROUP BY flightaware_id) s ON s.flightaware_id = spotter_live.flightaware_id AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 800 OFFSET 0";
698
-    			$query = "DELETE FROM spotter_live WHERE flightaware_id IN (SELECT spotter_live.flightaware_id FROM spotter_live INNER JOIN (SELECT flightaware_id,MAX(date) as max_date FROM spotter_live GROUP BY flightaware_id) s ON s.flightaware_id = spotter_live.flightaware_id AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 2000 OFFSET 0)";
699
-    			try {
697
+				//$query = "SELECT spotter_live.flightaware_id FROM spotter_live INNER JOIN (SELECT flightaware_id,MAX(date) as max_date FROM spotter_live GROUP BY flightaware_id) s ON s.flightaware_id = spotter_live.flightaware_id AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 800 OFFSET 0";
698
+				$query = "DELETE FROM spotter_live WHERE flightaware_id IN (SELECT spotter_live.flightaware_id FROM spotter_live INNER JOIN (SELECT flightaware_id,MAX(date) as max_date FROM spotter_live GROUP BY flightaware_id) s ON s.flightaware_id = spotter_live.flightaware_id AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 2000 OFFSET 0)";
699
+				try {
700 700
 				
701 701
 				$sth = $this->db->prepare($query);
702 702
 				$sth->execute();
@@ -740,17 +740,17 @@  discard block
 block discarded – undo
740 740
 	}
741 741
 
742 742
 	/**
743
-	* Deletes all info in the table for an ident
744
-	*
745
-	* @return String success or false
746
-	*
747
-	*/
743
+	 * Deletes all info in the table for an ident
744
+	 *
745
+	 * @return String success or false
746
+	 *
747
+	 */
748 748
 	public function deleteLiveSpotterDataByIdent($ident)
749 749
 	{
750 750
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
751 751
 		$query  = 'DELETE FROM spotter_live WHERE ident = :ident';
752 752
         
753
-    		try {
753
+			try {
754 754
 			
755 755
 			$sth = $this->db->prepare($query);
756 756
 			$sth->execute(array(':ident' => $ident));
@@ -762,17 +762,17 @@  discard block
 block discarded – undo
762 762
 	}
763 763
 
764 764
 	/**
765
-	* Deletes all info in the table for an id
766
-	*
767
-	* @return String success or false
768
-	*
769
-	*/
765
+	 * Deletes all info in the table for an id
766
+	 *
767
+	 * @return String success or false
768
+	 *
769
+	 */
770 770
 	public function deleteLiveSpotterDataById($id)
771 771
 	{
772 772
 		$id = filter_var($id, FILTER_SANITIZE_STRING);
773 773
 		$query  = 'DELETE FROM spotter_live WHERE flightaware_id = :id';
774 774
         
775
-    		try {
775
+			try {
776 776
 			
777 777
 			$sth = $this->db->prepare($query);
778 778
 			$sth->execute(array(':id' => $id));
@@ -785,11 +785,11 @@  discard block
 block discarded – undo
785 785
 
786 786
 
787 787
 	/**
788
-	* Gets the aircraft ident within the last hour
789
-	*
790
-	* @return String the ident
791
-	*
792
-	*/
788
+	 * Gets the aircraft ident within the last hour
789
+	 *
790
+	 * @return String the ident
791
+	 *
792
+	 */
793 793
 	public function getIdentFromLastHour($ident)
794 794
 	{
795 795
 		global $globalDBdriver, $globalTimezone;
@@ -815,14 +815,14 @@  discard block
 block discarded – undo
815 815
 			$ident_result = $row['ident'];
816 816
 		}
817 817
 		return $ident_result;
818
-        }
818
+		}
819 819
 
820 820
 	/**
821
-	* Check recent aircraft
822
-	*
823
-	* @return String the ident
824
-	*
825
-	*/
821
+	 * Check recent aircraft
822
+	 *
823
+	 * @return String the ident
824
+	 *
825
+	 */
826 826
 	public function checkIdentRecent($ident)
827 827
 	{
828 828
 		global $globalDBdriver, $globalTimezone;
@@ -848,14 +848,14 @@  discard block
 block discarded – undo
848 848
 			$ident_result = $row['flightaware_id'];
849 849
 		}
850 850
 		return $ident_result;
851
-        }
851
+		}
852 852
 
853 853
 	/**
854
-	* Check recent aircraft by id
855
-	*
856
-	* @return String the ident
857
-	*
858
-	*/
854
+	 * Check recent aircraft by id
855
+	 *
856
+	 * @return String the ident
857
+	 *
858
+	 */
859 859
 	public function checkIdRecent($id)
860 860
 	{
861 861
 		global $globalDBdriver, $globalTimezone;
@@ -881,14 +881,14 @@  discard block
 block discarded – undo
881 881
 			$ident_result = $row['flightaware_id'];
882 882
 		}
883 883
 		return $ident_result;
884
-        }
884
+		}
885 885
 
886 886
 	/**
887
-	* Check recent aircraft by ModeS
888
-	*
889
-	* @return String the ModeS
890
-	*
891
-	*/
887
+	 * Check recent aircraft by ModeS
888
+	 *
889
+	 * @return String the ModeS
890
+	 *
891
+	 */
892 892
 	public function checkModeSRecent($modes)
893 893
 	{
894 894
 		global $globalDBdriver, $globalTimezone;
@@ -915,19 +915,19 @@  discard block
 block discarded – undo
915 915
 			$ident_result = $row['flightaware_id'];
916 916
 		}
917 917
 		return $ident_result;
918
-        }
918
+		}
919 919
 
920 920
 	/**
921
-	* Adds a new spotter data
922
-	*
923
-	* @param String $flightaware_id the ID from flightaware
924
-	* @param String $ident the flight ident
925
-	* @param String $aircraft_icao the aircraft type
926
-	* @param String $departure_airport_icao the departure airport
927
-	* @param String $arrival_airport_icao the arrival airport
928
-	* @return String success or false
929
-	*
930
-	*/
921
+	 * Adds a new spotter data
922
+	 *
923
+	 * @param String $flightaware_id the ID from flightaware
924
+	 * @param String $ident the flight ident
925
+	 * @param String $aircraft_icao the aircraft type
926
+	 * @param String $departure_airport_icao the departure airport
927
+	 * @param String $arrival_airport_icao the arrival airport
928
+	 * @return String success or false
929
+	 *
930
+	 */
931 931
 	public function addLiveSpotterData($flightaware_id = '', $ident = '', $aircraft_icao = '', $departure_airport_icao = '', $arrival_airport_icao = '', $latitude = '', $longitude = '', $waypoints = '', $altitude = '', $altitude_real = '',$heading = '', $groundspeed = '', $date = '',$departure_airport_time = '', $arrival_airport_time = '', $squawk = '', $route_stop = '', $ModeS = '', $putinarchive = false,$registration = '',$pilot_id = '', $pilot_name = '', $verticalrate = '', $noarchive = false, $ground = false,$format_source = '', $source_name = '', $over_country = '')
932 932
 	{
933 933
 		global $globalURL, $globalArchive, $globalDebug;
@@ -1062,10 +1062,10 @@  discard block
 block discarded – undo
1062 1062
 		$arrival_airport_country = '';
1063 1063
 		
1064 1064
             	
1065
-            	if ($squawk == '' || $Common->isInteger($squawk) === false ) $squawk = NULL;
1066
-            	if ($verticalrate == '' || $Common->isInteger($verticalrate) === false ) $verticalrate = NULL;
1067
-            	if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0;
1068
-            	if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0;
1065
+				if ($squawk == '' || $Common->isInteger($squawk) === false ) $squawk = NULL;
1066
+				if ($verticalrate == '' || $Common->isInteger($verticalrate) === false ) $verticalrate = NULL;
1067
+				if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0;
1068
+				if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0;
1069 1069
 		
1070 1070
 		$query = '';
1071 1071
 		if ($globalArchive) {
@@ -1086,10 +1086,10 @@  discard block
 block discarded – undo
1086 1086
 			return "error : ".$e->getMessage();
1087 1087
 		}
1088 1088
 		if (isset($globalArchive) && $globalArchive && $putinarchive && $noarchive !== true) {
1089
-		    if ($globalDebug) echo '(Add to SBS archive : ';
1090
-		    $SpotterArchive = new SpotterArchive($this->db);
1091
-		    $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, $heading, $groundspeed, $squawk, $ModeS, $pilot_id, $pilot_name,$verticalrate,$format_source,$source_name, $over_country);
1092
-		    if ($globalDebug) echo $result.')';
1089
+			if ($globalDebug) echo '(Add to SBS archive : ';
1090
+			$SpotterArchive = new SpotterArchive($this->db);
1091
+			$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, $heading, $groundspeed, $squawk, $ModeS, $pilot_id, $pilot_name,$verticalrate,$format_source,$source_name, $over_country);
1092
+			if ($globalDebug) echo $result.')';
1093 1093
 		}
1094 1094
 		return "success";
1095 1095
 
Please login to merge, or discard this patch.
Spacing   +126 added lines, -126 removed lines patch added patch discarded remove patch
@@ -16,62 +16,62 @@  discard block
 block discarded – undo
16 16
 	* @param Array $filter the filter
17 17
 	* @return Array the SQL part
18 18
 	*/
19
-	public function getFilter($filter = array(),$where = false,$and = false) {
19
+	public function getFilter($filter = array(), $where = false, $and = false) {
20 20
 		global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver;
21 21
 		$filters = array();
22 22
 		if (is_array($globalStatsFilters) && isset($globalStatsFilters[$globalFilterName])) {
23 23
 			if (isset($globalStatsFilters[$globalFilterName][0]['source'])) {
24 24
 				$filters = $globalStatsFilters[$globalFilterName];
25 25
 			} else {
26
-				$filter = array_merge($filter,$globalStatsFilters[$globalFilterName]);
26
+				$filter = array_merge($filter, $globalStatsFilters[$globalFilterName]);
27 27
 			}
28 28
 		}
29 29
 		if (isset($filter[0]['source'])) {
30
-			$filters = array_merge($filters,$filter);
30
+			$filters = array_merge($filters, $filter);
31 31
 		}
32
-		if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter);
32
+		if (is_array($globalFilter)) $filter = array_merge($filter, $globalFilter);
33 33
 		$filter_query_join = '';
34 34
 		$filter_query_where = '';
35
-		foreach($filters as $flt) {
35
+		foreach ($filters as $flt) {
36 36
 			if (isset($flt['airlines']) && !empty($flt['airlines'])) {
37 37
 				if ($flt['airlines'][0] != '') {
38 38
 					if (isset($flt['source'])) {
39
-						$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','",$flt['airlines'])."') AND spotter_output.format_source IN ('".implode("','",$flt['source'])."')) saf ON saf.flightaware_id = spotter_live.flightaware_id";
39
+						$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','", $flt['airlines'])."') AND spotter_output.format_source IN ('".implode("','", $flt['source'])."')) saf ON saf.flightaware_id = spotter_live.flightaware_id";
40 40
 					} else {
41
-						$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','",$flt['airlines'])."')) saf ON saf.flightaware_id = spotter_live.flightaware_id";
41
+						$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','", $flt['airlines'])."')) saf ON saf.flightaware_id = spotter_live.flightaware_id";
42 42
 					}
43 43
 				}
44 44
 			}
45 45
 			if (isset($flt['pilots_id']) && !empty($flt['pilots_id'])) {
46 46
 				if (isset($flt['source'])) {
47
-					$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.pilot_id IN ('".implode("','",$flt['pilots_id'])."') AND spotter_output.format_source IN ('".implode("','",$flt['source'])."')) spi ON spi.flightaware_id = spotter_live.flightaware_id";
47
+					$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.pilot_id IN ('".implode("','", $flt['pilots_id'])."') AND spotter_output.format_source IN ('".implode("','", $flt['source'])."')) spi ON spi.flightaware_id = spotter_live.flightaware_id";
48 48
 				} else {
49
-					$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.pilot_id IN ('".implode("','",$flt['pilots_id'])."')) spi ON spi.flightaware_id = spotter_live.flightaware_id";
49
+					$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.pilot_id IN ('".implode("','", $flt['pilots_id'])."')) spi ON spi.flightaware_id = spotter_live.flightaware_id";
50 50
 				}
51 51
 			}
52 52
 			if (isset($flt['idents']) && !empty($flt['idents'])) {
53 53
 				if (isset($flt['source'])) {
54
-					$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.ident IN ('".implode("','",$flt['idents'])."') AND spotter_output.format_source IN ('".implode("','",$flt['source'])."')) spid ON spid.flightaware_id = spotter_live.flightaware_id";
54
+					$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.ident IN ('".implode("','", $flt['idents'])."') AND spotter_output.format_source IN ('".implode("','", $flt['source'])."')) spid ON spid.flightaware_id = spotter_live.flightaware_id";
55 55
 				} else {
56
-					$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.ident IN ('".implode("','",$flt['idents'])."')) spid ON spid.flightaware_id = spotter_live.flightaware_id";
56
+					$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.ident IN ('".implode("','", $flt['idents'])."')) spid ON spid.flightaware_id = spotter_live.flightaware_id";
57 57
 				}
58 58
 			}
59 59
 			if (isset($flt['registrations']) && !empty($flt['registrations'])) {
60 60
 				if (isset($flt['source'])) {
61
-					$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.registration IN ('".implode("','",$flt['registrations'])."') AND spotter_output.format_source IN ('".implode("','",$flt['source'])."')) sre ON sre.flightaware_id = spotter_live.flightaware_id";
61
+					$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.registration IN ('".implode("','", $flt['registrations'])."') AND spotter_output.format_source IN ('".implode("','", $flt['source'])."')) sre ON sre.flightaware_id = spotter_live.flightaware_id";
62 62
 				} else {
63
-					$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.registration IN ('".implode("','",$flt['registrations'])."')) sre ON sre.flightaware_id = spotter_live.flightaware_id";
63
+					$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.registration IN ('".implode("','", $flt['registrations'])."')) sre ON sre.flightaware_id = spotter_live.flightaware_id";
64 64
 				}
65 65
 			}
66 66
 			if ((isset($flt['airlines']) && empty($flt['airlines']) && isset($flt['pilots_id']) && empty($flt['pilots_id']) && isset($flt['idents']) && empty($flt['idents'])) || (!isset($flt['airlines']) && !isset($flt['pilots_id']) && !isset($flt['idents']) && !isset($flt['registrations']))) {
67 67
 				if (isset($flt['source'])) {
68
-					$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.format_source IN ('".implode("','",$flt['source'])."')) ssf ON ssf.flightaware_id = spotter_live.flightaware_id";
68
+					$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.format_source IN ('".implode("','", $flt['source'])."')) ssf ON ssf.flightaware_id = spotter_live.flightaware_id";
69 69
 				}
70 70
 			}
71 71
 		}
72 72
 		if (isset($filter['airlines']) && !empty($filter['airlines'])) {
73 73
 			if ($filter['airlines'][0] != '') {
74
-				$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) sai ON sai.flightaware_id = spotter_live.flightaware_id";
74
+				$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','", $filter['airlines'])."')) sai ON sai.flightaware_id = spotter_live.flightaware_id";
75 75
 			}
76 76
 		}
77 77
 		if (isset($filter['alliance']) && !empty($filter['alliance'])) {
@@ -81,10 +81,10 @@  discard block
 block discarded – undo
81 81
 			$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_live.flightaware_id ";
82 82
 		}
83 83
 		if (isset($filter['pilots_id']) && !empty($filter['pilots_id'])) {
84
-			$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.pilot_id IN ('".implode("','",$filter['pilots_id'])."')) sp ON sp.flightaware_id = spotter_live.flightaware_id";
84
+			$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.pilot_id IN ('".implode("','", $filter['pilots_id'])."')) sp ON sp.flightaware_id = spotter_live.flightaware_id";
85 85
 		}
86 86
 		if (isset($filter['source']) && !empty($filter['source'])) {
87
-			$filter_query_where .= " AND format_source IN ('".implode("','",$filter['source'])."')";
87
+			$filter_query_where .= " AND format_source IN ('".implode("','", $filter['source'])."')";
88 88
 		}
89 89
 		if (isset($filter['ident']) && !empty($filter['ident'])) {
90 90
 			$filter_query_where .= " AND ident = '".$filter['ident']."'";
@@ -113,15 +113,15 @@  discard block
 block discarded – undo
113 113
 					$filter_query_date .= " AND EXTRACT(DAY FROM spotter_output.date) = '".$filter['day']."'";
114 114
 				}
115 115
 			}
116
-			$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output".preg_replace('/^ AND/',' WHERE',$filter_query_date).") sd ON sd.flightaware_id = spotter_live.flightaware_id";
116
+			$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output".preg_replace('/^ AND/', ' WHERE', $filter_query_date).") sd ON sd.flightaware_id = spotter_live.flightaware_id";
117 117
 		}
118 118
 		if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
119
-			$filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
119
+			$filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')";
120 120
 		}
121 121
 		if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE';
122 122
 		elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND';
123 123
 		if ($filter_query_where != '') {
124
-			$filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where);
124
+			$filter_query_where = preg_replace('/^ AND/', ' WHERE', $filter_query_where);
125 125
 		}
126 126
 		$filter_query = $filter_query_join.$filter_query_where;
127 127
 		return $filter_query;
@@ -144,8 +144,8 @@  discard block
 block discarded – undo
144 144
 		if ($limit != '')
145 145
 		{
146 146
 			$limit_array = explode(',', $limit);
147
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
148
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
147
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
148
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
149 149
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
150 150
 			{
151 151
 				$limit_query = ' LIMIT '.$limit_array[1].' OFFSET '.$limit_array[0];
@@ -168,7 +168,7 @@  discard block
 block discarded – undo
168 168
 		} else {
169 169
 			$query  = "SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate".$filter_query.$orderby_query;
170 170
 		}
171
-		$spotter_array = $Spotter->getDataFromDB($query.$limit_query,array(),'',true);
171
+		$spotter_array = $Spotter->getDataFromDB($query.$limit_query, array(), '', true);
172 172
 
173 173
 		return $spotter_array;
174 174
 	}
@@ -183,7 +183,7 @@  discard block
 block discarded – undo
183 183
 	{
184 184
 		global $globalDBdriver, $globalLiveInterval, $globalArchive;
185 185
 		date_default_timezone_set('UTC');
186
-		$filter_query = $this->getFilter($filter,true,true);
186
+		$filter_query = $this->getFilter($filter, true, true);
187 187
 		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
188 188
 		if ($globalDBdriver == 'mysql') {
189 189
 			if (isset($globalArchive) && $globalArchive === TRUE) {
@@ -206,7 +206,7 @@  discard block
 block discarded – undo
206 206
 		try {
207 207
 			$sth = $this->db->prepare($query);
208 208
 			$sth->execute();
209
-		} catch(PDOException $e) {
209
+		} catch (PDOException $e) {
210 210
 			echo $e->getMessage();
211 211
 			die;
212 212
 		}
@@ -225,26 +225,26 @@  discard block
 block discarded – undo
225 225
 		global $globalDBdriver, $globalLiveInterval, $globalArchive;
226 226
 		date_default_timezone_set('UTC');
227 227
 
228
-		$filter_query = $this->getFilter($filter,true,true);
228
+		$filter_query = $this->getFilter($filter, true, true);
229 229
 
230 230
 		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
231 231
 		if ($globalDBdriver == 'mysql') {
232 232
 			if (isset($globalArchive) && $globalArchive === TRUE) {
233
-				$query  = 'SELECT spotter_archive.ident, spotter_archive.flightaware_id, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk, spotter_archive.date, spotter_archive.format_source 
233
+				$query = 'SELECT spotter_archive.ident, spotter_archive.flightaware_id, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk, spotter_archive.date, spotter_archive.format_source 
234 234
 				FROM spotter_archive INNER JOIN (SELECT flightaware_id FROM spotter_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= spotter_live.date) l ON l.flightaware_id = spotter_archive.flightaware_id AND spotter_archive.latitude <> '0' AND spotter_archive.longitude <> '0' 
235 235
 				ORDER BY spotter_archive.flightaware_id, spotter_archive.date";
236 236
 			} else {
237
-				$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 
237
+				$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 
238 238
 				FROM spotter_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= spotter_live.date AND spotter_live.latitude <> '0' AND spotter_live.longitude <> '0' 
239 239
 				ORDER BY spotter_live.flightaware_id, spotter_live.date";
240 240
 			}
241 241
                 } else {
242 242
 			if (isset($globalArchive) && $globalArchive === TRUE) {
243
-				$query  = "SELECT spotter_archive.ident, spotter_archive.flightaware_id, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk, spotter_archive.date, spotter_archive.format_source 
243
+				$query = "SELECT spotter_archive.ident, spotter_archive.flightaware_id, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk, spotter_archive.date, spotter_archive.format_source 
244 244
 				FROM spotter_archive INNER JOIN (SELECT flightaware_id FROM spotter_live".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= spotter_live.date) l ON l.flightaware_id = spotter_archive.flightaware_id WHERE spotter_archive.latitude <> '0' AND spotter_archive.longitude <> '0' 
245 245
 				ORDER BY spotter_archive.flightaware_id, spotter_archive.date";
246 246
 			} else {
247
-				$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 
247
+				$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 
248 248
 				FROM spotter_live".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= spotter_live.date AND spotter_live.latitude <> '0' AND spotter_live.longitude <> '0' 
249 249
 				ORDER BY spotter_live.flightaware_id, spotter_live.date";
250 250
 			}
@@ -253,7 +253,7 @@  discard block
 block discarded – undo
253 253
     		try {
254 254
 			$sth = $this->db->prepare($query);
255 255
 			$sth->execute();
256
-		} catch(PDOException $e) {
256
+		} catch (PDOException $e) {
257 257
 			echo $e->getMessage();
258 258
 			die;
259 259
 		}
@@ -270,7 +270,7 @@  discard block
 block discarded – undo
270 270
 	public function getLiveSpotterCount($filter = array())
271 271
 	{
272 272
 		global $globalDBdriver, $globalLiveInterval;
273
-		$filter_query = $this->getFilter($filter,true,true);
273
+		$filter_query = $this->getFilter($filter, true, true);
274 274
 
275 275
 		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
276 276
 		if ($globalDBdriver == 'mysql') {
@@ -283,7 +283,7 @@  discard block
 block discarded – undo
283 283
 		try {
284 284
 			$sth = $this->db->prepare($query);
285 285
 			$sth->execute();
286
-		} catch(PDOException $e) {
286
+		} catch (PDOException $e) {
287 287
 			echo $e->getMessage();
288 288
 			die;
289 289
 		}
@@ -306,10 +306,10 @@  discard block
 block discarded – undo
306 306
 		$filter_query = $this->getFilter($filter);
307 307
 
308 308
 		if (is_array($coord)) {
309
-			$minlong = filter_var($coord[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
310
-			$minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
311
-			$maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
312
-			$maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
309
+			$minlong = filter_var($coord[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
310
+			$minlat = filter_var($coord[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
311
+			$maxlong = filter_var($coord[2], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
312
+			$maxlat = filter_var($coord[3], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
313 313
 		} else return array();
314 314
 		if ($globalDBdriver == 'mysql') {
315 315
 			$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;
@@ -332,23 +332,23 @@  discard block
 block discarded – undo
332 332
 		global $globalDBdriver, $globalLiveInterval, $globalArchive;
333 333
 		$Spotter = new Spotter($this->db);
334 334
 		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
335
-		$filter_query = $this->getFilter($filter,true,true);
335
+		$filter_query = $this->getFilter($filter, true, true);
336 336
 
337 337
 		if (is_array($coord)) {
338
-			$minlong = filter_var($coord[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
339
-			$minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
340
-			$maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
341
-			$maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
338
+			$minlong = filter_var($coord[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
339
+			$minlat = filter_var($coord[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
340
+			$maxlong = filter_var($coord[2], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
341
+			$maxlat = filter_var($coord[3], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
342 342
 		} else return array();
343 343
 		if ($globalDBdriver == 'mysql') {
344 344
 			if (isset($globalArchive) && $globalArchive === TRUE) {
345
-				$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 
345
+				$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 
346 346
 				FROM spotter_live 
347 347
 				'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= spotter_live.date 
348 348
 				AND spotter_live.latitude BETWEEN '.$minlat.' AND '.$maxlat.' AND spotter_live.longitude BETWEEN '.$minlong.' AND '.$maxlong.'
349 349
 				AND spotter_live.latitude <> 0 AND spotter_live.longitude <> 0';
350 350
 			} else {
351
-				$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 
351
+				$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 
352 352
 				FROM spotter_live 
353 353
 				INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate 
354 354
 				    FROM spotter_live l 
@@ -360,14 +360,14 @@  discard block
 block discarded – undo
360 360
 			}
361 361
 		} else {
362 362
 			if (isset($globalArchive) && $globalArchive === TRUE) {
363
-				$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 
363
+				$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 
364 364
 				FROM spotter_live 
365 365
 				".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= spotter_live.date 
366 366
 				AND spotter_live.latitude BETWEEN ".$minlat." AND ".$maxlat." 
367 367
 				AND spotter_live.longitude BETWEEN ".$minlong." AND ".$maxlong." 
368 368
 				AND spotter_live.latitude <> '0' AND spotter_live.longitude <> '0'";
369 369
 			} else {
370
-				$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 
370
+				$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 
371 371
 				FROM spotter_live 
372 372
 				INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate 
373 373
 				    FROM spotter_live l 
@@ -382,7 +382,7 @@  discard block
 block discarded – undo
382 382
 		try {
383 383
 			$sth = $this->db->prepare($query);
384 384
 			$sth->execute();
385
-		} catch(PDOException $e) {
385
+		} catch (PDOException $e) {
386 386
 			echo $e->getMessage();
387 387
 			die;
388 388
 		}
@@ -431,7 +431,7 @@  discard block
 block discarded – undo
431 431
                 if ($interval == '1m')
432 432
                 {
433 433
                     $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date ';
434
-                } else if ($interval == '15m'){
434
+                } else if ($interval == '15m') {
435 435
                     $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 MINUTE) <= spotter_live.date ';
436 436
                 } 
437 437
             }
@@ -439,14 +439,14 @@  discard block
 block discarded – undo
439 439
          $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date ';   
440 440
         }
441 441
 
442
-                $query  = "SELECT spotter_live.*, ( 6371 * acos( cos( radians(:lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(:lng) ) + sin( radians(:lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM spotter_live 
442
+                $query = "SELECT spotter_live.*, ( 6371 * acos( cos( radians(:lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(:lng) ) + sin( radians(:lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM spotter_live 
443 443
                    WHERE spotter_live.latitude <> '' 
444 444
                                    AND spotter_live.longitude <> '' 
445 445
                    ".$additional_query."
446 446
                    HAVING distance < :radius  
447 447
                                    ORDER BY distance";
448 448
 
449
-                $spotter_array = $Spotter->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng,':radius' => $radius));
449
+                $spotter_array = $Spotter->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng, ':radius' => $radius));
450 450
 
451 451
                 return $spotter_array;
452 452
         }
@@ -464,9 +464,9 @@  discard block
 block discarded – undo
464 464
 		date_default_timezone_set('UTC');
465 465
 
466 466
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
467
-                $query  = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC';
467
+                $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC';
468 468
 
469
-		$spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident),'',true);
469
+		$spotter_array = $Spotter->getDataFromDB($query, array(':ident' => $ident), '', true);
470 470
 
471 471
 		return $spotter_array;
472 472
 	}
@@ -477,16 +477,16 @@  discard block
 block discarded – undo
477 477
 	* @return Array the spotter information
478 478
 	*
479 479
 	*/
480
-	public function getDateLiveSpotterDataByIdent($ident,$date)
480
+	public function getDateLiveSpotterDataByIdent($ident, $date)
481 481
 	{
482 482
 		$Spotter = new Spotter($this->db);
483 483
 		date_default_timezone_set('UTC');
484 484
 
485 485
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
486
-                $query  = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC';
486
+                $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC';
487 487
 
488
-                $date = date('c',$date);
489
-		$spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident,':date' => $date));
488
+                $date = date('c', $date);
489
+		$spotter_array = $Spotter->getDataFromDB($query, array(':ident' => $ident, ':date' => $date));
490 490
 
491 491
 		return $spotter_array;
492 492
 	}
@@ -503,9 +503,9 @@  discard block
 block discarded – undo
503 503
 		date_default_timezone_set('UTC');
504 504
 
505 505
 		$id = filter_var($id, FILTER_SANITIZE_STRING);
506
-                $query  = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.flightaware_id = :id GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC';
506
+                $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.flightaware_id = :id GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC';
507 507
 
508
-		$spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id),'',true);
508
+		$spotter_array = $Spotter->getDataFromDB($query, array(':id' => $id), '', true);
509 509
 
510 510
 		return $spotter_array;
511 511
 	}
@@ -516,15 +516,15 @@  discard block
 block discarded – undo
516 516
 	* @return Array the spotter information
517 517
 	*
518 518
 	*/
519
-	public function getDateLiveSpotterDataById($id,$date)
519
+	public function getDateLiveSpotterDataById($id, $date)
520 520
 	{
521 521
 		$Spotter = new Spotter($this->db);
522 522
 		date_default_timezone_set('UTC');
523 523
 
524 524
 		$id = filter_var($id, FILTER_SANITIZE_STRING);
525
-                $query  = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.flightaware_id = :id AND l.date <= :date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC';
526
-                $date = date('c',$date);
527
-		$spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id,':date' => $date),'',true);
525
+                $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.flightaware_id = :id AND l.date <= :date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC';
526
+                $date = date('c', $date);
527
+		$spotter_array = $Spotter->getDataFromDB($query, array(':id' => $id, ':date' => $date), '', true);
528 528
 
529 529
 		return $spotter_array;
530 530
 	}
@@ -541,13 +541,13 @@  discard block
 block discarded – undo
541 541
 		date_default_timezone_set('UTC');
542 542
 
543 543
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
544
-                $query  = 'SELECT spotter_live.altitude, spotter_live.date FROM spotter_live WHERE spotter_live.ident = :ident';
544
+                $query = 'SELECT spotter_live.altitude, spotter_live.date FROM spotter_live WHERE spotter_live.ident = :ident';
545 545
 
546 546
     		try {
547 547
 			
548 548
 			$sth = $this->db->prepare($query);
549 549
 			$sth->execute(array(':ident' => $ident));
550
-		} catch(PDOException $e) {
550
+		} catch (PDOException $e) {
551 551
 			echo $e->getMessage();
552 552
 			die;
553 553
 		}
@@ -562,7 +562,7 @@  discard block
 block discarded – undo
562 562
 	* @return Array the spotter information
563 563
 	*
564 564
 	*/
565
-	public function getAllLiveSpotterDataById($id,$liveinterval = false)
565
+	public function getAllLiveSpotterDataById($id, $liveinterval = false)
566 566
 	{
567 567
 		global $globalDBdriver, $globalLiveInterval;
568 568
 		date_default_timezone_set('UTC');
@@ -581,7 +581,7 @@  discard block
 block discarded – undo
581 581
 		try {
582 582
 			$sth = $this->db->prepare($query);
583 583
 			$sth->execute(array(':id' => $id));
584
-		} catch(PDOException $e) {
584
+		} catch (PDOException $e) {
585 585
 			echo $e->getMessage();
586 586
 			die;
587 587
 		}
@@ -599,12 +599,12 @@  discard block
 block discarded – undo
599 599
 	{
600 600
 		date_default_timezone_set('UTC');
601 601
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
602
-		$query  = self::$global_query.' WHERE spotter_live.ident = :ident';
602
+		$query = self::$global_query.' WHERE spotter_live.ident = :ident';
603 603
     		try {
604 604
 			
605 605
 			$sth = $this->db->prepare($query);
606 606
 			$sth->execute(array(':ident' => $ident));
607
-		} catch(PDOException $e) {
607
+		} catch (PDOException $e) {
608 608
 			echo $e->getMessage();
609 609
 			die;
610 610
 		}
@@ -634,7 +634,7 @@  discard block
 block discarded – undo
634 634
 			
635 635
 			$sth = $this->db->prepare($query);
636 636
 			$sth->execute();
637
-		} catch(PDOException $e) {
637
+		} catch (PDOException $e) {
638 638
 			return "error";
639 639
 		}
640 640
 
@@ -657,14 +657,14 @@  discard block
 block discarded – undo
657 657
 				
658 658
 				$sth = $this->db->prepare($query);
659 659
 				$sth->execute();
660
-			} catch(PDOException $e) {
660
+			} catch (PDOException $e) {
661 661
 				return "error";
662 662
 			}
663 663
 			$query_delete = 'DELETE FROM spotter_live WHERE flightaware_id IN (';
664 664
                         $i = 0;
665
-                        $j =0;
665
+                        $j = 0;
666 666
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
667
-			foreach($all as $row)
667
+			foreach ($all as $row)
668 668
 			{
669 669
 				$i++;
670 670
 				$j++;
@@ -672,9 +672,9 @@  discard block
 block discarded – undo
672 672
 					if ($globalDebug) echo ".";
673 673
 				    	try {
674 674
 						
675
-						$sth = $this->db->prepare(substr($query_delete,0,-1).")");
675
+						$sth = $this->db->prepare(substr($query_delete, 0, -1).")");
676 676
 						$sth->execute();
677
-					} catch(PDOException $e) {
677
+					} catch (PDOException $e) {
678 678
 						return "error";
679 679
 					}
680 680
                                 	$query_delete = 'DELETE FROM spotter_live WHERE flightaware_id IN (';
@@ -685,9 +685,9 @@  discard block
 block discarded – undo
685 685
 			if ($i > 0) {
686 686
     				try {
687 687
 					
688
-					$sth = $this->db->prepare(substr($query_delete,0,-1).")");
688
+					$sth = $this->db->prepare(substr($query_delete, 0, -1).")");
689 689
 					$sth->execute();
690
-				} catch(PDOException $e) {
690
+				} catch (PDOException $e) {
691 691
 					return "error";
692 692
 				}
693 693
 			}
@@ -700,7 +700,7 @@  discard block
 block discarded – undo
700 700
 				
701 701
 				$sth = $this->db->prepare($query);
702 702
 				$sth->execute();
703
-			} catch(PDOException $e) {
703
+			} catch (PDOException $e) {
704 704
 				return "error";
705 705
 			}
706 706
 /*			$query_delete = "DELETE FROM spotter_live WHERE flightaware_id IN (";
@@ -748,13 +748,13 @@  discard block
 block discarded – undo
748 748
 	public function deleteLiveSpotterDataByIdent($ident)
749 749
 	{
750 750
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
751
-		$query  = 'DELETE FROM spotter_live WHERE ident = :ident';
751
+		$query = 'DELETE FROM spotter_live WHERE ident = :ident';
752 752
         
753 753
     		try {
754 754
 			
755 755
 			$sth = $this->db->prepare($query);
756 756
 			$sth->execute(array(':ident' => $ident));
757
-		} catch(PDOException $e) {
757
+		} catch (PDOException $e) {
758 758
 			return "error";
759 759
 		}
760 760
 
@@ -770,13 +770,13 @@  discard block
 block discarded – undo
770 770
 	public function deleteLiveSpotterDataById($id)
771 771
 	{
772 772
 		$id = filter_var($id, FILTER_SANITIZE_STRING);
773
-		$query  = 'DELETE FROM spotter_live WHERE flightaware_id = :id';
773
+		$query = 'DELETE FROM spotter_live WHERE flightaware_id = :id';
774 774
         
775 775
     		try {
776 776
 			
777 777
 			$sth = $this->db->prepare($query);
778 778
 			$sth->execute(array(':id' => $id));
779
-		} catch(PDOException $e) {
779
+		} catch (PDOException $e) {
780 780
 			return "error";
781 781
 		}
782 782
 
@@ -794,13 +794,13 @@  discard block
 block discarded – undo
794 794
 	{
795 795
 		global $globalDBdriver, $globalTimezone;
796 796
 		if ($globalDBdriver == 'mysql') {
797
-			$query  = 'SELECT spotter_live.ident FROM spotter_live 
797
+			$query = 'SELECT spotter_live.ident FROM spotter_live 
798 798
 				WHERE spotter_live.ident = :ident 
799 799
 				AND spotter_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) 
800 800
 				AND spotter_live.date < UTC_TIMESTAMP()';
801 801
 			$query_data = array(':ident' => $ident);
802 802
 		} else {
803
-			$query  = "SELECT spotter_live.ident FROM spotter_live 
803
+			$query = "SELECT spotter_live.ident FROM spotter_live 
804 804
 				WHERE spotter_live.ident = :ident 
805 805
 				AND spotter_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '1 HOURS'
806 806
 				AND spotter_live.date < now() AT TIME ZONE 'UTC'";
@@ -809,8 +809,8 @@  discard block
 block discarded – undo
809 809
 		
810 810
 		$sth = $this->db->prepare($query);
811 811
 		$sth->execute($query_data);
812
-		$ident_result='';
813
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
812
+		$ident_result = '';
813
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
814 814
 		{
815 815
 			$ident_result = $row['ident'];
816 816
 		}
@@ -827,13 +827,13 @@  discard block
 block discarded – undo
827 827
 	{
828 828
 		global $globalDBdriver, $globalTimezone;
829 829
 		if ($globalDBdriver == 'mysql') {
830
-			$query  = 'SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live 
830
+			$query = 'SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live 
831 831
 				WHERE spotter_live.ident = :ident 
832 832
 				AND spotter_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 MINUTE)'; 
833 833
 //				AND spotter_live.date < UTC_TIMESTAMP()";
834 834
 			$query_data = array(':ident' => $ident);
835 835
 		} else {
836
-			$query  = "SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live 
836
+			$query = "SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live 
837 837
 				WHERE spotter_live.ident = :ident 
838 838
 				AND spotter_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '30 MINUTES'";
839 839
 //				AND spotter_live.date < now() AT TIME ZONE 'UTC'";
@@ -842,8 +842,8 @@  discard block
 block discarded – undo
842 842
 		
843 843
 		$sth = $this->db->prepare($query);
844 844
 		$sth->execute($query_data);
845
-		$ident_result='';
846
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
845
+		$ident_result = '';
846
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
847 847
 		{
848 848
 			$ident_result = $row['flightaware_id'];
849 849
 		}
@@ -860,13 +860,13 @@  discard block
 block discarded – undo
860 860
 	{
861 861
 		global $globalDBdriver, $globalTimezone;
862 862
 		if ($globalDBdriver == 'mysql') {
863
-			$query  = 'SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live 
863
+			$query = 'SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live 
864 864
 				WHERE spotter_live.flightaware_id = :id 
865 865
 				AND spotter_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 10 HOUR)'; 
866 866
 //				AND spotter_live.date < UTC_TIMESTAMP()";
867 867
 			$query_data = array(':id' => $id);
868 868
 		} else {
869
-			$query  = "SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live 
869
+			$query = "SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live 
870 870
 				WHERE spotter_live.flightaware_id = :id 
871 871
 				AND spotter_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '10 HOUR'";
872 872
 //				AND spotter_live.date < now() AT TIME ZONE 'UTC'";
@@ -875,8 +875,8 @@  discard block
 block discarded – undo
875 875
 		
876 876
 		$sth = $this->db->prepare($query);
877 877
 		$sth->execute($query_data);
878
-		$ident_result='';
879
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
878
+		$ident_result = '';
879
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
880 880
 		{
881 881
 			$ident_result = $row['flightaware_id'];
882 882
 		}
@@ -893,13 +893,13 @@  discard block
 block discarded – undo
893 893
 	{
894 894
 		global $globalDBdriver, $globalTimezone;
895 895
 		if ($globalDBdriver == 'mysql') {
896
-			$query  = 'SELECT spotter_live.ModeS, spotter_live.flightaware_id FROM spotter_live 
896
+			$query = 'SELECT spotter_live.ModeS, spotter_live.flightaware_id FROM spotter_live 
897 897
 				WHERE spotter_live.ModeS = :modes 
898 898
 				AND spotter_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 MINUTE)'; 
899 899
 //				AND spotter_live.date < UTC_TIMESTAMP()";
900 900
 			$query_data = array(':modes' => $modes);
901 901
 		} else {
902
-			$query  = "SELECT spotter_live.ModeS, spotter_live.flightaware_id FROM spotter_live 
902
+			$query = "SELECT spotter_live.ModeS, spotter_live.flightaware_id FROM spotter_live 
903 903
 				WHERE spotter_live.ModeS = :modes 
904 904
 				AND spotter_live.date >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '30 MINUTE'";
905 905
 //			//	AND spotter_live.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC'";
@@ -908,8 +908,8 @@  discard block
 block discarded – undo
908 908
 		
909 909
 		$sth = $this->db->prepare($query);
910 910
 		$sth->execute($query_data);
911
-		$ident_result='';
912
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
911
+		$ident_result = '';
912
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
913 913
 		{
914 914
 			//$ident_result = $row['spotter_live_id'];
915 915
 			$ident_result = $row['flightaware_id'];
@@ -928,7 +928,7 @@  discard block
 block discarded – undo
928 928
 	* @return String success or false
929 929
 	*
930 930
 	*/
931
-	public function addLiveSpotterData($flightaware_id = '', $ident = '', $aircraft_icao = '', $departure_airport_icao = '', $arrival_airport_icao = '', $latitude = '', $longitude = '', $waypoints = '', $altitude = '', $altitude_real = '',$heading = '', $groundspeed = '', $date = '',$departure_airport_time = '', $arrival_airport_time = '', $squawk = '', $route_stop = '', $ModeS = '', $putinarchive = false,$registration = '',$pilot_id = '', $pilot_name = '', $verticalrate = '', $noarchive = false, $ground = false,$format_source = '', $source_name = '', $over_country = '')
931
+	public function addLiveSpotterData($flightaware_id = '', $ident = '', $aircraft_icao = '', $departure_airport_icao = '', $arrival_airport_icao = '', $latitude = '', $longitude = '', $waypoints = '', $altitude = '', $altitude_real = '', $heading = '', $groundspeed = '', $date = '', $departure_airport_time = '', $arrival_airport_time = '', $squawk = '', $route_stop = '', $ModeS = '', $putinarchive = false, $registration = '', $pilot_id = '', $pilot_name = '', $verticalrate = '', $noarchive = false, $ground = false, $format_source = '', $source_name = '', $over_country = '')
932 932
 	{
933 933
 		global $globalURL, $globalArchive, $globalDebug;
934 934
 		$Common = new Common();
@@ -1021,26 +1021,26 @@  discard block
 block discarded – undo
1021 1021
 		if ($date == '') $date = date("Y-m-d H:i:s", time());
1022 1022
 
1023 1023
         
1024
-		$flightaware_id = filter_var($flightaware_id,FILTER_SANITIZE_STRING);
1025
-		$ident = filter_var($ident,FILTER_SANITIZE_STRING);
1026
-		$aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING);
1027
-		$departure_airport_icao = filter_var($departure_airport_icao,FILTER_SANITIZE_STRING);
1028
-		$arrival_airport_icao = filter_var($arrival_airport_icao,FILTER_SANITIZE_STRING);
1029
-		$latitude = filter_var($latitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
1030
-		$longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
1031
-		$waypoints = filter_var($waypoints,FILTER_SANITIZE_STRING);
1032
-		$altitude = filter_var($altitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
1033
-		$heading = filter_var($heading,FILTER_SANITIZE_NUMBER_INT);
1034
-		$groundspeed = filter_var($groundspeed,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
1035
-		$squawk = filter_var($squawk,FILTER_SANITIZE_NUMBER_INT);
1036
-		$route_stop = filter_var($route_stop,FILTER_SANITIZE_STRING);
1037
-		$ModeS = filter_var($ModeS,FILTER_SANITIZE_STRING);
1038
-		$pilot_id = filter_var($pilot_id,FILTER_SANITIZE_STRING);
1039
-		$pilot_name = filter_var($pilot_name,FILTER_SANITIZE_STRING);
1040
-		$format_source = filter_var($format_source,FILTER_SANITIZE_STRING);
1041
-		$source_name = filter_var($source_name,FILTER_SANITIZE_STRING);
1042
-		$over_country = filter_var($over_country,FILTER_SANITIZE_STRING);
1043
-		$verticalrate = filter_var($verticalrate,FILTER_SANITIZE_NUMBER_INT);
1024
+		$flightaware_id = filter_var($flightaware_id, FILTER_SANITIZE_STRING);
1025
+		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
1026
+		$aircraft_icao = filter_var($aircraft_icao, FILTER_SANITIZE_STRING);
1027
+		$departure_airport_icao = filter_var($departure_airport_icao, FILTER_SANITIZE_STRING);
1028
+		$arrival_airport_icao = filter_var($arrival_airport_icao, FILTER_SANITIZE_STRING);
1029
+		$latitude = filter_var($latitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
1030
+		$longitude = filter_var($longitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
1031
+		$waypoints = filter_var($waypoints, FILTER_SANITIZE_STRING);
1032
+		$altitude = filter_var($altitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
1033
+		$heading = filter_var($heading, FILTER_SANITIZE_NUMBER_INT);
1034
+		$groundspeed = filter_var($groundspeed, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
1035
+		$squawk = filter_var($squawk, FILTER_SANITIZE_NUMBER_INT);
1036
+		$route_stop = filter_var($route_stop, FILTER_SANITIZE_STRING);
1037
+		$ModeS = filter_var($ModeS, FILTER_SANITIZE_STRING);
1038
+		$pilot_id = filter_var($pilot_id, FILTER_SANITIZE_STRING);
1039
+		$pilot_name = filter_var($pilot_name, FILTER_SANITIZE_STRING);
1040
+		$format_source = filter_var($format_source, FILTER_SANITIZE_STRING);
1041
+		$source_name = filter_var($source_name, FILTER_SANITIZE_STRING);
1042
+		$over_country = filter_var($over_country, FILTER_SANITIZE_STRING);
1043
+		$verticalrate = filter_var($verticalrate, FILTER_SANITIZE_NUMBER_INT);
1044 1044
 
1045 1045
 		$airline_name = '';
1046 1046
 		$airline_icao = '';
@@ -1062,10 +1062,10 @@  discard block
 block discarded – undo
1062 1062
 		$arrival_airport_country = '';
1063 1063
 		
1064 1064
             	
1065
-            	if ($squawk == '' || $Common->isInteger($squawk) === false ) $squawk = NULL;
1066
-            	if ($verticalrate == '' || $Common->isInteger($verticalrate) === false ) $verticalrate = NULL;
1067
-            	if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0;
1068
-            	if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0;
1065
+            	if ($squawk == '' || $Common->isInteger($squawk) === false) $squawk = NULL;
1066
+            	if ($verticalrate == '' || $Common->isInteger($verticalrate) === false) $verticalrate = NULL;
1067
+            	if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0;
1068
+            	if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0;
1069 1069
 		
1070 1070
 		$query = '';
1071 1071
 		if ($globalArchive) {
@@ -1076,19 +1076,19 @@  discard block
 block discarded – undo
1076 1076
 		$query  .= 'INSERT INTO spotter_live (flightaware_id, ident, registration, airline_name, airline_icao, airline_country, airline_type, aircraft_icao, aircraft_shadow, aircraft_name, aircraft_manufacturer, departure_airport_icao, departure_airport_name, departure_airport_city, departure_airport_country, arrival_airport_icao, arrival_airport_name, arrival_airport_city, arrival_airport_country, latitude, longitude, waypoints, altitude, heading, ground_speed, date, departure_airport_time, arrival_airport_time, squawk, route_stop, ModeS, pilot_id, pilot_name, verticalrate, ground, format_source, source_name, over_country) 
1077 1077
 		VALUES (:flightaware_id,:ident,:registration,:airline_name,:airline_icao,:airline_country,:airline_type,:aircraft_icao,:aircraft_shadow,:aircraft_type,:aircraft_manufacturer,:departure_airport_icao,:departure_airport_name, :departure_airport_city, :departure_airport_country, :arrival_airport_icao, :arrival_airport_name, :arrival_airport_city, :arrival_airport_country, :latitude,:longitude,:waypoints,:altitude,:heading,:groundspeed,:date,:departure_airport_time,:arrival_airport_time,:squawk,:route_stop,:ModeS, :pilot_id, :pilot_name, :verticalrate, :ground, :format_source, :source_name, :over_country)';
1078 1078
 
1079
-		$query_values = array(':flightaware_id' => $flightaware_id,':ident' => $ident, ':registration' => $registration,':airline_name' => $airline_name,':airline_icao' => $airline_icao,':airline_country' => $airline_country,':airline_type' => $airline_type,':aircraft_icao' => $aircraft_icao,':aircraft_shadow' => $aircraft_shadow,':aircraft_type' => $aircraft_type,':aircraft_manufacturer' => $aircraft_manufacturer,':departure_airport_icao' => $departure_airport_icao,':departure_airport_name' => $departure_airport_name,':departure_airport_city' => $departure_airport_city,':departure_airport_country' => $departure_airport_country,':arrival_airport_icao' => $arrival_airport_icao,':arrival_airport_name' => $arrival_airport_name,':arrival_airport_city' => $arrival_airport_city,':arrival_airport_country' => $arrival_airport_country,':latitude' => $latitude,':longitude' => $longitude, ':waypoints' => $waypoints,':altitude' => $altitude,':heading' => $heading,':groundspeed' => $groundspeed,':date' => $date, ':departure_airport_time' => $departure_airport_time,':arrival_airport_time' => $arrival_airport_time, ':squawk' => $squawk,':route_stop' => $route_stop,':ModeS' => $ModeS, ':pilot_id' => $pilot_id, ':pilot_name' => $pilot_name, ':verticalrate' => $verticalrate, ':format_source' => $format_source,':ground' => $ground, ':source_name' => $source_name, ':over_country' => $over_country);
1079
+		$query_values = array(':flightaware_id' => $flightaware_id, ':ident' => $ident, ':registration' => $registration, ':airline_name' => $airline_name, ':airline_icao' => $airline_icao, ':airline_country' => $airline_country, ':airline_type' => $airline_type, ':aircraft_icao' => $aircraft_icao, ':aircraft_shadow' => $aircraft_shadow, ':aircraft_type' => $aircraft_type, ':aircraft_manufacturer' => $aircraft_manufacturer, ':departure_airport_icao' => $departure_airport_icao, ':departure_airport_name' => $departure_airport_name, ':departure_airport_city' => $departure_airport_city, ':departure_airport_country' => $departure_airport_country, ':arrival_airport_icao' => $arrival_airport_icao, ':arrival_airport_name' => $arrival_airport_name, ':arrival_airport_city' => $arrival_airport_city, ':arrival_airport_country' => $arrival_airport_country, ':latitude' => $latitude, ':longitude' => $longitude, ':waypoints' => $waypoints, ':altitude' => $altitude, ':heading' => $heading, ':groundspeed' => $groundspeed, ':date' => $date, ':departure_airport_time' => $departure_airport_time, ':arrival_airport_time' => $arrival_airport_time, ':squawk' => $squawk, ':route_stop' => $route_stop, ':ModeS' => $ModeS, ':pilot_id' => $pilot_id, ':pilot_name' => $pilot_name, ':verticalrate' => $verticalrate, ':format_source' => $format_source, ':ground' => $ground, ':source_name' => $source_name, ':over_country' => $over_country);
1080 1080
 		try {
1081 1081
 			
1082 1082
 			$sth = $this->db->prepare($query);
1083 1083
 			$sth->execute($query_values);
1084 1084
 			$sth->closeCursor();
1085
-		} catch(PDOException $e) {
1085
+		} catch (PDOException $e) {
1086 1086
 			return "error : ".$e->getMessage();
1087 1087
 		}
1088 1088
 		if (isset($globalArchive) && $globalArchive && $putinarchive && $noarchive !== true) {
1089 1089
 		    if ($globalDebug) echo '(Add to SBS archive : ';
1090 1090
 		    $SpotterArchive = new SpotterArchive($this->db);
1091
-		    $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, $heading, $groundspeed, $squawk, $ModeS, $pilot_id, $pilot_name,$verticalrate,$format_source,$source_name, $over_country);
1091
+		    $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, $heading, $groundspeed, $squawk, $ModeS, $pilot_id, $pilot_name, $verticalrate, $format_source, $source_name, $over_country);
1092 1092
 		    if ($globalDebug) echo $result.')';
1093 1093
 		}
1094 1094
 		return "success";
@@ -1097,7 +1097,7 @@  discard block
 block discarded – undo
1097 1097
 
1098 1098
 	public function getOrderBy()
1099 1099
 	{
1100
-		$orderby = array("aircraft_asc" => array("key" => "aircraft_asc", "value" => "Aircraft Type - ASC", "sql" => "ORDER BY spotter_live.aircraft_icao ASC"), "aircraft_desc" => array("key" => "aircraft_desc", "value" => "Aircraft Type - DESC", "sql" => "ORDER BY spotter_live.aircraft_icao DESC"),"manufacturer_asc" => array("key" => "manufacturer_asc", "value" => "Aircraft Manufacturer - ASC", "sql" => "ORDER BY spotter_live.aircraft_manufacturer ASC"), "manufacturer_desc" => array("key" => "manufacturer_desc", "value" => "Aircraft Manufacturer - DESC", "sql" => "ORDER BY spotter_live.aircraft_manufacturer DESC"),"airline_name_asc" => array("key" => "airline_name_asc", "value" => "Airline Name - ASC", "sql" => "ORDER BY spotter_live.airline_name ASC"), "airline_name_desc" => array("key" => "airline_name_desc", "value" => "Airline Name - DESC", "sql" => "ORDER BY spotter_live.airline_name DESC"), "ident_asc" => array("key" => "ident_asc", "value" => "Ident - ASC", "sql" => "ORDER BY spotter_live.ident ASC"), "ident_desc" => array("key" => "ident_desc", "value" => "Ident - DESC", "sql" => "ORDER BY spotter_live.ident DESC"), "airport_departure_asc" => array("key" => "airport_departure_asc", "value" => "Departure Airport - ASC", "sql" => "ORDER BY spotter_live.departure_airport_city ASC"), "airport_departure_desc" => array("key" => "airport_departure_desc", "value" => "Departure Airport - DESC", "sql" => "ORDER BY spotter_live.departure_airport_city DESC"), "airport_arrival_asc" => array("key" => "airport_arrival_asc", "value" => "Arrival Airport - ASC", "sql" => "ORDER BY spotter_live.arrival_airport_city ASC"), "airport_arrival_desc" => array("key" => "airport_arrival_desc", "value" => "Arrival Airport - DESC", "sql" => "ORDER BY spotter_live.arrival_airport_city DESC"), "date_asc" => array("key" => "date_asc", "value" => "Date - ASC", "sql" => "ORDER BY spotter_live.date ASC"), "date_desc" => array("key" => "date_desc", "value" => "Date - DESC", "sql" => "ORDER BY spotter_live.date DESC"));
1100
+		$orderby = array("aircraft_asc" => array("key" => "aircraft_asc", "value" => "Aircraft Type - ASC", "sql" => "ORDER BY spotter_live.aircraft_icao ASC"), "aircraft_desc" => array("key" => "aircraft_desc", "value" => "Aircraft Type - DESC", "sql" => "ORDER BY spotter_live.aircraft_icao DESC"), "manufacturer_asc" => array("key" => "manufacturer_asc", "value" => "Aircraft Manufacturer - ASC", "sql" => "ORDER BY spotter_live.aircraft_manufacturer ASC"), "manufacturer_desc" => array("key" => "manufacturer_desc", "value" => "Aircraft Manufacturer - DESC", "sql" => "ORDER BY spotter_live.aircraft_manufacturer DESC"), "airline_name_asc" => array("key" => "airline_name_asc", "value" => "Airline Name - ASC", "sql" => "ORDER BY spotter_live.airline_name ASC"), "airline_name_desc" => array("key" => "airline_name_desc", "value" => "Airline Name - DESC", "sql" => "ORDER BY spotter_live.airline_name DESC"), "ident_asc" => array("key" => "ident_asc", "value" => "Ident - ASC", "sql" => "ORDER BY spotter_live.ident ASC"), "ident_desc" => array("key" => "ident_desc", "value" => "Ident - DESC", "sql" => "ORDER BY spotter_live.ident DESC"), "airport_departure_asc" => array("key" => "airport_departure_asc", "value" => "Departure Airport - ASC", "sql" => "ORDER BY spotter_live.departure_airport_city ASC"), "airport_departure_desc" => array("key" => "airport_departure_desc", "value" => "Departure Airport - DESC", "sql" => "ORDER BY spotter_live.departure_airport_city DESC"), "airport_arrival_asc" => array("key" => "airport_arrival_asc", "value" => "Arrival Airport - ASC", "sql" => "ORDER BY spotter_live.arrival_airport_city ASC"), "airport_arrival_desc" => array("key" => "airport_arrival_desc", "value" => "Arrival Airport - DESC", "sql" => "ORDER BY spotter_live.arrival_airport_city DESC"), "date_asc" => array("key" => "date_asc", "value" => "Date - ASC", "sql" => "ORDER BY spotter_live.date ASC"), "date_desc" => array("key" => "date_desc", "value" => "Date - DESC", "sql" => "ORDER BY spotter_live.date DESC"));
1101 1101
 		return $orderby;
1102 1102
 	}
1103 1103
 
Please login to merge, or discard this patch.
Braces   +83 added lines, -28 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
 				$query  = 'SELECT spotter_archive.ident, spotter_archive.flightaware_id, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk, spotter_archive.date, spotter_archive.format_source 
@@ -273,7 +286,9 @@  discard block
 block discarded – undo
273 286
 		global $globalDBdriver, $globalLiveInterval;
274 287
 		$filter_query = $this->getFilter($filter,true,true);
275 288
 
276
-		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
289
+		if (!isset($globalLiveInterval)) {
290
+			$globalLiveInterval = '200';
291
+		}
277 292
 		if ($globalDBdriver == 'mysql') {
278 293
 			//$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;
279 294
 			$query = 'SELECT COUNT(DISTINCT spotter_live.flightaware_id) as nb FROM spotter_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date';
@@ -303,7 +318,9 @@  discard block
 block discarded – undo
303 318
 	{
304 319
 		global $globalDBdriver, $globalLiveInterval;
305 320
 		$Spotter = new Spotter($this->db);
306
-		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
321
+		if (!isset($globalLiveInterval)) {
322
+			$globalLiveInterval = '200';
323
+		}
307 324
 		$filter_query = $this->getFilter($filter);
308 325
 
309 326
 		if (is_array($coord)) {
@@ -311,7 +328,9 @@  discard block
 block discarded – undo
311 328
 			$minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
312 329
 			$maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
313 330
 			$maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
314
-		} else return array();
331
+		} else {
332
+			return array();
333
+		}
315 334
 		if ($globalDBdriver == 'mysql') {
316 335
 			$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;
317 336
 		} else {
@@ -332,7 +351,9 @@  discard block
 block discarded – undo
332 351
 	{
333 352
 		global $globalDBdriver, $globalLiveInterval, $globalArchive;
334 353
 		$Spotter = new Spotter($this->db);
335
-		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
354
+		if (!isset($globalLiveInterval)) {
355
+			$globalLiveInterval = '200';
356
+		}
336 357
 		$filter_query = $this->getFilter($filter,true,true);
337 358
 
338 359
 		if (is_array($coord)) {
@@ -340,7 +361,9 @@  discard block
 block discarded – undo
340 361
 			$minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
341 362
 			$maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
342 363
 			$maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
343
-		} else return array();
364
+		} else {
365
+			return array();
366
+		}
344 367
 		if ($globalDBdriver == 'mysql') {
345 368
 			if (isset($globalArchive) && $globalArchive === TRUE) {
346 369
 				$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 
@@ -571,11 +594,15 @@  discard block
 block discarded – undo
571 594
 		//$query  = self::$global_query.' WHERE spotter_live.flightaware_id = :id ORDER BY date';
572 595
 		if ($globalDBdriver == 'mysql') {
573 596
 			$query = 'SELECT spotter_live.* FROM spotter_live WHERE spotter_live.flightaware_id = :id';
574
-			if ($liveinterval) $query .= ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date';
597
+			if ($liveinterval) {
598
+				$query .= ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date';
599
+			}
575 600
 			$query .= ' ORDER BY date';
576 601
 		} else {
577 602
 			$query = 'SELECT spotter_live.* FROM spotter_live WHERE spotter_live.flightaware_id = :id';
578
-			if ($liveinterval) $query .= " AND CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= date";
603
+			if ($liveinterval) {
604
+				$query .= " AND CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= date";
605
+			}
579 606
 			$query .= ' ORDER BY date';
580 607
 		}
581 608
 
@@ -670,7 +697,9 @@  discard block
 block discarded – undo
670 697
 				$i++;
671 698
 				$j++;
672 699
 				if ($j == 30) {
673
-					if ($globalDebug) echo ".";
700
+					if ($globalDebug) {
701
+						echo ".";
702
+					}
674 703
 				    	try {
675 704
 						
676 705
 						$sth = $this->db->prepare(substr($query_delete,0,-1).")");
@@ -977,7 +1006,9 @@  discard block
 block discarded – undo
977 1006
 			{
978 1007
 				return false;
979 1008
 			}
980
-		} else return '';
1009
+		} else {
1010
+			return '';
1011
+		}
981 1012
 
982 1013
 		if ($longitude != '')
983 1014
 		{
@@ -985,7 +1016,9 @@  discard block
 block discarded – undo
985 1016
 			{
986 1017
 				return false;
987 1018
 			}
988
-		} else return '';
1019
+		} else {
1020
+			return '';
1021
+		}
989 1022
 
990 1023
 		if ($waypoints != '')
991 1024
 		{
@@ -1001,7 +1034,9 @@  discard block
 block discarded – undo
1001 1034
 			{
1002 1035
 				return false;
1003 1036
 			}
1004
-		} else $altitude = 0;
1037
+		} else {
1038
+			$altitude = 0;
1039
+		}
1005 1040
 
1006 1041
 		if ($heading != '')
1007 1042
 		{
@@ -1009,7 +1044,9 @@  discard block
 block discarded – undo
1009 1044
 			{
1010 1045
 				return false;
1011 1046
 			}
1012
-		} else $heading = 0;
1047
+		} else {
1048
+			$heading = 0;
1049
+		}
1013 1050
 
1014 1051
 		if ($groundspeed != '')
1015 1052
 		{
@@ -1017,9 +1054,13 @@  discard block
 block discarded – undo
1017 1054
 			{
1018 1055
 				return false;
1019 1056
 			}
1020
-		} else $groundspeed = 0;
1057
+		} else {
1058
+			$groundspeed = 0;
1059
+		}
1021 1060
 		date_default_timezone_set('UTC');
1022
-		if ($date == '') $date = date("Y-m-d H:i:s", time());
1061
+		if ($date == '') {
1062
+			$date = date("Y-m-d H:i:s", time());
1063
+		}
1023 1064
 
1024 1065
         
1025 1066
 		$flightaware_id = filter_var($flightaware_id,FILTER_SANITIZE_STRING);
@@ -1063,14 +1104,24 @@  discard block
 block discarded – undo
1063 1104
 		$arrival_airport_country = '';
1064 1105
 		
1065 1106
             	
1066
-            	if ($squawk == '' || $Common->isInteger($squawk) === false ) $squawk = NULL;
1067
-            	if ($verticalrate == '' || $Common->isInteger($verticalrate) === false ) $verticalrate = NULL;
1068
-            	if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0;
1069
-            	if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0;
1107
+            	if ($squawk == '' || $Common->isInteger($squawk) === false ) {
1108
+            		$squawk = NULL;
1109
+            	}
1110
+            	if ($verticalrate == '' || $Common->isInteger($verticalrate) === false ) {
1111
+            		$verticalrate = NULL;
1112
+            	}
1113
+            	if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) {
1114
+            		$groundspeed = 0;
1115
+            	}
1116
+            	if ($heading == '' || $Common->isInteger($heading) === false ) {
1117
+            		$heading = 0;
1118
+            	}
1070 1119
 		
1071 1120
 		$query = '';
1072 1121
 		if ($globalArchive) {
1073
-			if ($globalDebug) echo '-- Delete previous data -- ';
1122
+			if ($globalDebug) {
1123
+				echo '-- Delete previous data -- ';
1124
+			}
1074 1125
 			$query .= 'DELETE FROM spotter_live WHERE flightaware_id = :flightaware_id;';
1075 1126
 		}
1076 1127
 
@@ -1087,10 +1138,14 @@  discard block
 block discarded – undo
1087 1138
 			return "error : ".$e->getMessage();
1088 1139
 		}
1089 1140
 		if (isset($globalArchive) && $globalArchive && $putinarchive && $noarchive !== true) {
1090
-		    if ($globalDebug) echo '(Add to SBS archive : ';
1141
+		    if ($globalDebug) {
1142
+		    	echo '(Add to SBS archive : ';
1143
+		    }
1091 1144
 		    $SpotterArchive = new SpotterArchive($this->db);
1092 1145
 		    $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, $heading, $groundspeed, $squawk, $ModeS, $pilot_id, $pilot_name,$verticalrate,$format_source,$source_name, $over_country);
1093
-		    if ($globalDebug) echo $result.')';
1146
+		    if ($globalDebug) {
1147
+		    	echo $result.')';
1148
+		    }
1094 1149
 		}
1095 1150
 		return "success";
1096 1151
 
Please login to merge, or discard this patch.
require/class.SpotterArchive.php 4 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@
 block discarded – undo
11 11
     /**
12 12
     * Get SQL query part for filter used
13 13
     * @param Array $filter the filter
14
-    * @return Array the SQL part
14
+    * @return string the SQL part
15 15
     */
16 16
     public function getFilter($filter = array(),$where = false,$and = false) {
17 17
 	global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver;
Please login to merge, or discard this patch.
Braces   +37 added lines, -13 removed lines patch added patch discarded remove patch
@@ -26,7 +26,9 @@  discard block
 block discarded – undo
26 26
 	if (isset($filter[0]['source'])) {
27 27
 		$filters = array_merge($filters,$filter);
28 28
 	}
29
-	if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter);
29
+	if (is_array($globalFilter)) {
30
+		$filter = array_merge($filter,$globalFilter);
31
+	}
30 32
 	$filter_query_join = '';
31 33
 	$filter_query_where = '';
32 34
 	foreach($filters as $flt) {
@@ -99,8 +101,11 @@  discard block
 block discarded – undo
99 101
 	    }
100 102
 	    $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output".preg_replace('/^ AND/',' WHERE',$filter_query_date).") sd ON sd.flightaware_id = spotter_archive_output.flightaware_id";
101 103
 	}
102
-	if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE';
103
-	elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND';
104
+	if ($filter_query_where == '' && $where) {
105
+		$filter_query_where = ' WHERE';
106
+	} elseif ($filter_query_where != '' && $and) {
107
+		$filter_query_where .= ' AND';
108
+	}
104 109
 	if ($filter_query_where != '') {
105 110
 		$filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where);
106 111
 	}
@@ -114,10 +119,17 @@  discard block
 block discarded – undo
114 119
 		if ($over_country == '') {
115 120
 			$Spotter = new Spotter($this->db);
116 121
 			$data_country = $Spotter->getCountryFromLatitudeLongitude($latitude,$longitude);
117
-			if (!empty($data_country)) $country = $data_country['iso2'];
118
-			else $country = '';
119
-		} else $country = $over_country;
120
-		if ($airline_type === NULL) $airline_type ='';
122
+			if (!empty($data_country)) {
123
+				$country = $data_country['iso2'];
124
+			} else {
125
+				$country = '';
126
+			}
127
+		} else {
128
+			$country = $over_country;
129
+		}
130
+		if ($airline_type === NULL) {
131
+			$airline_type ='';
132
+		}
121 133
 	
122 134
 		//if ($country == '') echo "\n".'************ UNKNOW COUNTRY ****************'."\n";
123 135
 		//else echo "\n".'*/*/*/*/*/*/*/ Country : '.$country.' */*/*/*/*/*/*/*/*/'."\n";
@@ -620,7 +632,9 @@  discard block
 block discarded – undo
620 632
 		    $additional_query .= "(spotter_archive_output.pilot_name like '%".$q_item."%') OR ";
621 633
 		    $additional_query .= "(spotter_archive_output.ident like '%".$q_item."%') OR ";
622 634
 		    $translate = $Translation->ident2icao($q_item);
623
-		    if ($translate != $q_item) $additional_query .= "(spotter_archive_output.ident like '%".$translate."%') OR ";
635
+		    if ($translate != $q_item) {
636
+		    	$additional_query .= "(spotter_archive_output.ident like '%".$translate."%') OR ";
637
+		    }
624 638
 		    $additional_query .= "(spotter_archive_output.highlight like '%".$q_item."%')";
625 639
 		    $additional_query .= ")";
626 640
 		}
@@ -838,7 +852,9 @@  discard block
 block discarded – undo
838 852
 		date_default_timezone_set($globalTimezone);
839 853
 		$datetime = new DateTime();
840 854
 		$offset = $datetime->format('P');
841
-	    } else $offset = '+00:00';
855
+	    } else {
856
+	    	$offset = '+00:00';
857
+	    }
842 858
 
843 859
 
844 860
 	    if ($date_array[1] != "")
@@ -1114,9 +1130,13 @@  discard block
 block discarded – undo
1114 1130
 				$query .= "AND date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'";
1115 1131
 			}
1116 1132
 		}
1117
-                if ($sincedate != '') $query .= "AND date > '".$sincedate."' ";
1133
+                if ($sincedate != '') {
1134
+                	$query .= "AND date > '".$sincedate."' ";
1135
+                }
1118 1136
 	$query .= "GROUP BY c.name, c.iso3, c.iso2 ORDER BY nb DESC";
1119
-	if ($limit) $query .= " LIMIT 0,10";
1137
+	if ($limit) {
1138
+		$query .= " LIMIT 0,10";
1139
+	}
1120 1140
       
1121 1141
 	
1122 1142
 	$sth = $this->db->prepare($query);
@@ -1160,9 +1180,13 @@  discard block
 block discarded – undo
1160 1180
 				$query .= "AND s.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'";
1161 1181
 			}
1162 1182
 		}
1163
-                if ($sincedate != '') $query .= "AND s.date > '".$sincedate."' ";
1183
+                if ($sincedate != '') {
1184
+                	$query .= "AND s.date > '".$sincedate."' ";
1185
+                }
1164 1186
 	$query .= "GROUP BY o.airline_icao,c.name, c.iso3, c.iso2 ORDER BY nb DESC";
1165
-	if ($limit) $query .= " LIMIT 0,10";
1187
+	if ($limit) {
1188
+		$query .= " LIMIT 0,10";
1189
+	}
1166 1190
       
1167 1191
 	
1168 1192
 	$sth = $this->db->prepare($query);
Please login to merge, or discard this patch.
Indentation   +652 added lines, -652 removed lines patch added patch discarded remove patch
@@ -8,12 +8,12 @@  discard block
 block discarded – undo
8 8
 		$this->db = $Connection->db;
9 9
 	}
10 10
 
11
-    /**
12
-    * Get SQL query part for filter used
13
-    * @param Array $filter the filter
14
-    * @return Array the SQL part
15
-    */
16
-    public function getFilter($filter = array(),$where = false,$and = false) {
11
+	/**
12
+	 * Get SQL query part for filter used
13
+	 * @param Array $filter the filter
14
+	 * @return Array the SQL part
15
+	 */
16
+	public function getFilter($filter = array(),$where = false,$and = false) {
17 17
 	global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver;
18 18
 	$filters = array();
19 19
 	if (is_array($globalStatsFilters) && isset($globalStatsFilters[$globalFilterName])) {
@@ -30,88 +30,88 @@  discard block
 block discarded – undo
30 30
 	$filter_query_join = '';
31 31
 	$filter_query_where = '';
32 32
 	foreach($filters as $flt) {
33
-	    if (isset($flt['airlines']) && !empty($flt['airlines'])) {
33
+		if (isset($flt['airlines']) && !empty($flt['airlines'])) {
34 34
 		if ($flt['airlines'][0] != '') {
35
-		    if (isset($flt['source'])) {
35
+			if (isset($flt['source'])) {
36 36
 			$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','",$flt['airlines'])."') AND spotter_archive_output.format_source IN ('".implode("','",$flt['source'])."')) saff ON saff.flightaware_id = spotter_archive_output.flightaware_id";
37
-		    } else {
37
+			} else {
38 38
 			$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','",$flt['airlines'])."')) saff ON saff.flightaware_id = spotter_archive_output.flightaware_id";
39
-		    }
39
+			}
40
+		}
40 41
 		}
41
-	    }
42
-	    if (isset($flt['pilots_id']) && !empty($flt['pilots_id'])) {
42
+		if (isset($flt['pilots_id']) && !empty($flt['pilots_id'])) {
43 43
 		if (isset($flt['source'])) {
44
-		    $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.pilot_id IN ('".implode("','",$flt['pilots_id'])."') AND spotter_archive_output.format_source IN ('".implode("','",$flt['source'])."')) sp ON sp.flightaware_id = spotter_archive_output.flightaware_id";
44
+			$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.pilot_id IN ('".implode("','",$flt['pilots_id'])."') AND spotter_archive_output.format_source IN ('".implode("','",$flt['source'])."')) sp ON sp.flightaware_id = spotter_archive_output.flightaware_id";
45 45
 		} else {
46
-		    $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.pilot_id IN ('".implode("','",$flt['pilots_id'])."')) sp ON sp.flightaware_id = spotter_archive_output.flightaware_id";
46
+			$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.pilot_id IN ('".implode("','",$flt['pilots_id'])."')) sp ON sp.flightaware_id = spotter_archive_output.flightaware_id";
47 47
 		}
48
-	    }
49
-	    if (isset($flt['idents']) && !empty($flt['idents'])) {
48
+		}
49
+		if (isset($flt['idents']) && !empty($flt['idents'])) {
50 50
 		if (isset($flt['source'])) {
51
-		    $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.ident IN ('".implode("','",$flt['idents'])."') AND spotter_archive_output.format_source IN ('".implode("','",$flt['source'])."')) spi ON spi.flightaware_id = spotter_archive_output.flightaware_id";
51
+			$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.ident IN ('".implode("','",$flt['idents'])."') AND spotter_archive_output.format_source IN ('".implode("','",$flt['source'])."')) spi ON spi.flightaware_id = spotter_archive_output.flightaware_id";
52 52
 		} else {
53
-		    $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.ident IN ('".implode("','",$flt['idents'])."')) spi ON spi.flightaware_id = spotter_archive_output.flightaware_id";
53
+			$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.ident IN ('".implode("','",$flt['idents'])."')) spi ON spi.flightaware_id = spotter_archive_output.flightaware_id";
54
+		}
54 55
 		}
55
-	    }
56
-	    if (isset($flt['registrations']) && !empty($flt['registrations'])) {
56
+		if (isset($flt['registrations']) && !empty($flt['registrations'])) {
57 57
 		if (isset($flt['source'])) {
58
-		    $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.registration IN ('".implode("','",$flt['registrations'])."') AND spotter_archive_output.format_source IN ('".implode("','",$flt['source'])."')) sre ON sre.flightaware_id = spotter_archive_output.flightaware_id";
58
+			$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.registration IN ('".implode("','",$flt['registrations'])."') AND spotter_archive_output.format_source IN ('".implode("','",$flt['source'])."')) sre ON sre.flightaware_id = spotter_archive_output.flightaware_id";
59 59
 		} else {
60
-		    $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.registration IN ('".implode("','",$flt['registrations'])."')) sre ON sre.flightaware_id = spotter_archive_output.flightaware_id";
60
+			$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.registration IN ('".implode("','",$flt['registrations'])."')) sre ON sre.flightaware_id = spotter_archive_output.flightaware_id";
61
+		}
61 62
 		}
62
-	    }
63
-	    if ((isset($flt['airlines']) && empty($flt['airlines']) && isset($flt['pilots_id']) && empty($flt['pilots_id']) && isset($flt['idents']) && empty($flt['idents']) && isset($flt['registrations']) && empty($flt['registrations'])) || (!isset($flt['airlines']) && !isset($flt['pilots_id']) && !isset($flt['idents']) && !isset($flt['registrations']))) {
63
+		if ((isset($flt['airlines']) && empty($flt['airlines']) && isset($flt['pilots_id']) && empty($flt['pilots_id']) && isset($flt['idents']) && empty($flt['idents']) && isset($flt['registrations']) && empty($flt['registrations'])) || (!isset($flt['airlines']) && !isset($flt['pilots_id']) && !isset($flt['idents']) && !isset($flt['registrations']))) {
64 64
 		if (isset($flt['source'])) {
65
-		    $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_output.format_source IN ('".implode("','",$flt['source'])."')) saa ON saa.flightaware_id = spotter_archive_output.flightaware_id";
65
+			$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_output.format_source IN ('".implode("','",$flt['source'])."')) saa ON saa.flightaware_id = spotter_archive_output.flightaware_id";
66
+		}
66 67
 		}
67
-	    }
68 68
 	}
69 69
 	if (isset($filter['airlines']) && !empty($filter['airlines'])) {
70
-	    if ($filter['airlines'][0] != '') {
70
+		if ($filter['airlines'][0] != '') {
71 71
 		$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) saf ON saf.flightaware_id = spotter_archive_output.flightaware_id";
72
-	    }
72
+		}
73 73
 	}
74 74
 	
75 75
 	if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) {
76
-	    $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_archive_output.flightaware_id ";
76
+		$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_archive_output.flightaware_id ";
77 77
 	}
78 78
 	if (isset($filter['pilots_id']) && !empty($filter['pilots_id'])) {
79
-	    $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.pilot_id IN ('".implode("','",$filter['pilots_id'])."')) spi ON spi.flightaware_id = spotter_archive_output.flightaware_id";
79
+		$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.pilot_id IN ('".implode("','",$filter['pilots_id'])."')) spi ON spi.flightaware_id = spotter_archive_output.flightaware_id";
80 80
 	}
81 81
 	if (isset($filter['source']) && !empty($filter['source'])) {
82
-	    $filter_query_where .= " AND format_source IN ('".implode("','",$filter['source'])."')";
82
+		$filter_query_where .= " AND format_source IN ('".implode("','",$filter['source'])."')";
83 83
 	}
84 84
 	if (isset($filter['ident']) && !empty($filter['ident'])) {
85
-	    $filter_query_where .= " AND ident = '".$filter['ident']."'";
85
+		$filter_query_where .= " AND ident = '".$filter['ident']."'";
86 86
 	}
87 87
 	if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
88 88
 		$filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
89 89
 	}
90 90
 	if ((isset($filter['year']) && $filter['year'] != '') || (isset($filter['month']) && $filter['month'] != '') || (isset($filter['day']) && $filter['day'] != '')) {
91
-	    $filter_query_date = '';
91
+		$filter_query_date = '';
92 92
 	    
93
-	    if (isset($filter['year']) && $filter['year'] != '') {
93
+		if (isset($filter['year']) && $filter['year'] != '') {
94 94
 		if ($globalDBdriver == 'mysql') {
95
-		    $filter_query_date .= " AND YEAR(spotter_archive_output.date) = '".$filter['year']."'";
95
+			$filter_query_date .= " AND YEAR(spotter_archive_output.date) = '".$filter['year']."'";
96 96
 		} else {
97
-		    $filter_query_date .= " AND EXTRACT(YEAR FROM spotter_archive_output.date) = '".$filter['year']."'";
97
+			$filter_query_date .= " AND EXTRACT(YEAR FROM spotter_archive_output.date) = '".$filter['year']."'";
98
+		}
98 99
 		}
99
-	    }
100
-	    if (isset($filter['month']) && $filter['month'] != '') {
100
+		if (isset($filter['month']) && $filter['month'] != '') {
101 101
 		if ($globalDBdriver == 'mysql') {
102
-		    $filter_query_date .= " AND MONTH(spotter_archive_output.date) = '".$filter['month']."'";
102
+			$filter_query_date .= " AND MONTH(spotter_archive_output.date) = '".$filter['month']."'";
103 103
 		} else {
104
-		    $filter_query_date .= " AND EXTRACT(MONTH FROM spotter_archive_output.date) = '".$filter['month']."'";
104
+			$filter_query_date .= " AND EXTRACT(MONTH FROM spotter_archive_output.date) = '".$filter['month']."'";
105 105
 		}
106
-	    }
107
-	    if (isset($filter['day']) && $filter['day'] != '') {
106
+		}
107
+		if (isset($filter['day']) && $filter['day'] != '') {
108 108
 		if ($globalDBdriver == 'mysql') {
109
-		    $filter_query_date .= " AND DAY(spotter_archive_output.date) = '".$filter['day']."'";
109
+			$filter_query_date .= " AND DAY(spotter_archive_output.date) = '".$filter['day']."'";
110 110
 		} else {
111
-		    $filter_query_date .= " AND EXTRACT(DAY FROM spotter_archive_output.date) = '".$filter['day']."'";
111
+			$filter_query_date .= " AND EXTRACT(DAY FROM spotter_archive_output.date) = '".$filter['day']."'";
112
+		}
112 113
 		}
113
-	    }
114
-	    $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output".preg_replace('/^ AND/',' WHERE',$filter_query_date).") sd ON sd.flightaware_id = spotter_archive_output.flightaware_id";
114
+		$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output".preg_replace('/^ AND/',' WHERE',$filter_query_date).") sd ON sd.flightaware_id = spotter_archive_output.flightaware_id";
115 115
 	}
116 116
 	if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE';
117 117
 	elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND';
@@ -120,7 +120,7 @@  discard block
 block discarded – undo
120 120
 	}
121 121
 	$filter_query = $filter_query_join.$filter_query_where;
122 122
 	return $filter_query;
123
-    }
123
+	}
124 124
 
125 125
 	// Spotter_archive
126 126
 	public function 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 = '', $heading = '', $ground_speed = '', $squawk = '', $ModeS = '', $pilot_id = '', $pilot_name = '',$verticalrate = '',$format_source = '', $source_name = '', $over_country = '') {
@@ -152,44 +152,44 @@  discard block
 block discarded – undo
152 152
 	}
153 153
 
154 154
 
155
-        /**
156
-        * Gets all the spotter information based on a particular callsign
157
-        *
158
-        * @return Array the spotter information
159
-        *
160
-        */
161
-        public function getLastArchiveSpotterDataByIdent($ident)
162
-        {
155
+		/**
156
+		 * Gets all the spotter information based on a particular callsign
157
+		 *
158
+		 * @return Array the spotter information
159
+		 *
160
+		 */
161
+		public function getLastArchiveSpotterDataByIdent($ident)
162
+		{
163 163
 		$Spotter = new Spotter($this->db);
164
-                date_default_timezone_set('UTC');
164
+				date_default_timezone_set('UTC');
165 165
 
166
-                $ident = filter_var($ident, FILTER_SANITIZE_STRING);
167
-                //$query  = "SELECT spotter_archive.* FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.ident = :ident GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate LIMIT 1";
168
-                $query  = "SELECT spotter_archive.* FROM spotter_archive WHERE ident = :ident ORDER BY date DESC LIMIT 1";
166
+				$ident = filter_var($ident, FILTER_SANITIZE_STRING);
167
+				//$query  = "SELECT spotter_archive.* FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.ident = :ident GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate LIMIT 1";
168
+				$query  = "SELECT spotter_archive.* FROM spotter_archive WHERE ident = :ident ORDER BY date DESC LIMIT 1";
169 169
 
170
-                $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident));
170
+				$spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident));
171 171
 
172
-                return $spotter_array;
173
-        }
172
+				return $spotter_array;
173
+		}
174 174
 
175 175
 
176
-        /**
177
-        * Gets last the spotter information based on a particular id
178
-        *
179
-        * @return Array the spotter information
180
-        *
181
-        */
182
-        public function getLastArchiveSpotterDataById($id)
183
-        {
184
-    		$Spotter = new Spotter($this->db);
185
-                date_default_timezone_set('UTC');
186
-                $id = filter_var($id, FILTER_SANITIZE_STRING);
187
-                //$query  = SpotterArchive->$global_query." WHERE spotter_archive.flightaware_id = :id";
188
-                //$query  = "SELECT spotter_archive.* FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.flightaware_id = :id GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate LIMIT 1";
189
-                $query  = "SELECT * FROM spotter_archive WHERE flightaware_id = :id ORDER BY date DESC LIMIT 1";
176
+		/**
177
+		 * Gets last the spotter information based on a particular id
178
+		 *
179
+		 * @return Array the spotter information
180
+		 *
181
+		 */
182
+		public function getLastArchiveSpotterDataById($id)
183
+		{
184
+			$Spotter = new Spotter($this->db);
185
+				date_default_timezone_set('UTC');
186
+				$id = filter_var($id, FILTER_SANITIZE_STRING);
187
+				//$query  = SpotterArchive->$global_query." WHERE spotter_archive.flightaware_id = :id";
188
+				//$query  = "SELECT spotter_archive.* FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.flightaware_id = :id GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate LIMIT 1";
189
+				$query  = "SELECT * FROM spotter_archive WHERE flightaware_id = :id ORDER BY date DESC LIMIT 1";
190 190
 
191 191
 //              $spotter_array = Spotter->getDataFromDB($query,array(':id' => $id));
192
-                  /*
192
+				  /*
193 193
                 try {
194 194
                         $Connection = new Connection();
195 195
                         $sth = Connection->$db->prepare($query);
@@ -199,232 +199,232 @@  discard block
 block discarded – undo
199 199
                 }
200 200
                 $spotter_array = $sth->fetchAll(PDO->FETCH_ASSOC);
201 201
                 */
202
-                $spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id));
203
-
204
-                return $spotter_array;
205
-        }
206
-
207
-        /**
208
-        * Gets all the spotter information based on a particular id
209
-        *
210
-        * @return Array the spotter information
211
-        *
212
-        */
213
-        public function getAllArchiveSpotterDataById($id)
202
+				$spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id));
203
+
204
+				return $spotter_array;
205
+		}
206
+
207
+		/**
208
+		 * Gets all the spotter information based on a particular id
209
+		 *
210
+		 * @return Array the spotter information
211
+		 *
212
+		 */
213
+		public function getAllArchiveSpotterDataById($id)
214 214
 	{
215
-                date_default_timezone_set('UTC');
216
-                $id = filter_var($id, FILTER_SANITIZE_STRING);
217
-                $query  = $this->global_query." WHERE spotter_archive.flightaware_id = :id ORDER BY date";
215
+				date_default_timezone_set('UTC');
216
+				$id = filter_var($id, FILTER_SANITIZE_STRING);
217
+				$query  = $this->global_query." WHERE spotter_archive.flightaware_id = :id ORDER BY date";
218 218
 
219 219
 //              $spotter_array = Spotter->getDataFromDB($query,array(':id' => $id));
220 220
 
221
-                try {
222
-                        $sth = $this->db->prepare($query);
223
-                        $sth->execute(array(':id' => $id));
224
-                } catch(PDOException $e) {
225
-                        echo $e->getMessage();
226
-                        die;
227
-                }
228
-                $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
229
-
230
-                return $spotter_array;
231
-        }
232
-
233
-        /**
234
-        * Gets coordinate & time spotter information based on a particular id
235
-        *
236
-        * @return Array the spotter information
237
-        *
238
-        */
239
-        public function getCoordArchiveSpotterDataById($id)
240
-        {
241
-                date_default_timezone_set('UTC');
242
-                $id = filter_var($id, FILTER_SANITIZE_STRING);
243
-                $query  = "SELECT spotter_archive.latitude, spotter_archive.longitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id";
221
+				try {
222
+						$sth = $this->db->prepare($query);
223
+						$sth->execute(array(':id' => $id));
224
+				} catch(PDOException $e) {
225
+						echo $e->getMessage();
226
+						die;
227
+				}
228
+				$spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
229
+
230
+				return $spotter_array;
231
+		}
232
+
233
+		/**
234
+		 * Gets coordinate & time spotter information based on a particular id
235
+		 *
236
+		 * @return Array the spotter information
237
+		 *
238
+		 */
239
+		public function getCoordArchiveSpotterDataById($id)
240
+		{
241
+				date_default_timezone_set('UTC');
242
+				$id = filter_var($id, FILTER_SANITIZE_STRING);
243
+				$query  = "SELECT spotter_archive.latitude, spotter_archive.longitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id";
244 244
 
245 245
 //              $spotter_array = Spotter->getDataFromDB($query,array(':id' => $id));
246 246
 
247
-                try {
248
-                        $sth = $this->db->prepare($query);
249
-                        $sth->execute(array(':id' => $id));
250
-                } catch(PDOException $e) {
251
-                        echo $e->getMessage();
252
-                        die;
253
-                }
254
-                $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
247
+				try {
248
+						$sth = $this->db->prepare($query);
249
+						$sth->execute(array(':id' => $id));
250
+				} catch(PDOException $e) {
251
+						echo $e->getMessage();
252
+						die;
253
+				}
254
+				$spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
255 255
 
256
-                return $spotter_array;
257
-        }
256
+				return $spotter_array;
257
+		}
258 258
 
259 259
 
260
-        /**
261
-        * Gets altitude information based on a particular callsign
262
-        *
263
-        * @return Array the spotter information
264
-        *
265
-        */
266
-        public function getAltitudeArchiveSpotterDataByIdent($ident)
267
-        {
260
+		/**
261
+		 * Gets altitude information based on a particular callsign
262
+		 *
263
+		 * @return Array the spotter information
264
+		 *
265
+		 */
266
+		public function getAltitudeArchiveSpotterDataByIdent($ident)
267
+		{
268 268
 
269
-                date_default_timezone_set('UTC');
269
+				date_default_timezone_set('UTC');
270 270
 
271
-                $ident = filter_var($ident, FILTER_SANITIZE_STRING);
272
-                $query  = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.ident = :ident AND spotter_archive.latitude <> 0 AND spotter_archive.longitude <> 0 ORDER BY date";
271
+				$ident = filter_var($ident, FILTER_SANITIZE_STRING);
272
+				$query  = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.ident = :ident AND spotter_archive.latitude <> 0 AND spotter_archive.longitude <> 0 ORDER BY date";
273 273
 
274
-                try {
275
-                        $sth = $this->db->prepare($query);
276
-                        $sth->execute(array(':ident' => $ident));
277
-                } catch(PDOException $e) {
278
-                        echo $e->getMessage();
279
-                        die;
280
-                }
281
-                $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
274
+				try {
275
+						$sth = $this->db->prepare($query);
276
+						$sth->execute(array(':ident' => $ident));
277
+				} catch(PDOException $e) {
278
+						echo $e->getMessage();
279
+						die;
280
+				}
281
+				$spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
282 282
 
283
-                return $spotter_array;
284
-        }
283
+				return $spotter_array;
284
+		}
285 285
 
286
-        /**
287
-        * Gets altitude information based on a particular id
288
-        *
289
-        * @return Array the spotter information
290
-        *
291
-        */
292
-        public function getAltitudeArchiveSpotterDataById($id)
293
-        {
286
+		/**
287
+		 * Gets altitude information based on a particular id
288
+		 *
289
+		 * @return Array the spotter information
290
+		 *
291
+		 */
292
+		public function getAltitudeArchiveSpotterDataById($id)
293
+		{
294 294
 
295
-                date_default_timezone_set('UTC');
295
+				date_default_timezone_set('UTC');
296 296
 
297
-                $id = filter_var($id, FILTER_SANITIZE_STRING);
298
-                $query  = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id AND spotter_archive.latitude <> 0 AND spotter_archive.longitude <> 0 ORDER BY date";
297
+				$id = filter_var($id, FILTER_SANITIZE_STRING);
298
+				$query  = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id AND spotter_archive.latitude <> 0 AND spotter_archive.longitude <> 0 ORDER BY date";
299 299
 
300
-                try {
301
-                        $sth = $this->db->prepare($query);
302
-                        $sth->execute(array(':id' => $id));
303
-                } catch(PDOException $e) {
304
-                        echo $e->getMessage();
305
-                        die;
306
-                }
307
-                $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
300
+				try {
301
+						$sth = $this->db->prepare($query);
302
+						$sth->execute(array(':id' => $id));
303
+				} catch(PDOException $e) {
304
+						echo $e->getMessage();
305
+						die;
306
+				}
307
+				$spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
308 308
 
309
-                return $spotter_array;
310
-        }
309
+				return $spotter_array;
310
+		}
311 311
 
312
-        /**
313
-        * Gets altitude & speed information based on a particular id
314
-        *
315
-        * @return Array the spotter information
316
-        *
317
-        */
318
-        public function getAltitudeSpeedArchiveSpotterDataById($id)
319
-        {
312
+		/**
313
+		 * Gets altitude & speed information based on a particular id
314
+		 *
315
+		 * @return Array the spotter information
316
+		 *
317
+		 */
318
+		public function getAltitudeSpeedArchiveSpotterDataById($id)
319
+		{
320 320
 
321
-                date_default_timezone_set('UTC');
321
+				date_default_timezone_set('UTC');
322 322
 
323
-                $id = filter_var($id, FILTER_SANITIZE_STRING);
324
-                $query  = "SELECT spotter_archive.altitude, spotter_archive.ground_speed, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id ORDER BY date";
323
+				$id = filter_var($id, FILTER_SANITIZE_STRING);
324
+				$query  = "SELECT spotter_archive.altitude, spotter_archive.ground_speed, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id ORDER BY date";
325 325
 
326
-                try {
327
-                        $sth = $this->db->prepare($query);
328
-                        $sth->execute(array(':id' => $id));
329
-                } catch(PDOException $e) {
330
-                        echo $e->getMessage();
331
-                        die;
332
-                }
333
-                $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
326
+				try {
327
+						$sth = $this->db->prepare($query);
328
+						$sth->execute(array(':id' => $id));
329
+				} catch(PDOException $e) {
330
+						echo $e->getMessage();
331
+						die;
332
+				}
333
+				$spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
334 334
 
335
-                return $spotter_array;
336
-        }
335
+				return $spotter_array;
336
+		}
337 337
 
338 338
 
339
-        /**
340
-        * Gets altitude information based on a particular callsign
341
-        *
342
-        * @return Array the spotter information
343
-        *
344
-        */
345
-        public function getLastAltitudeArchiveSpotterDataByIdent($ident)
346
-        {
339
+		/**
340
+		 * Gets altitude information based on a particular callsign
341
+		 *
342
+		 * @return Array the spotter information
343
+		 *
344
+		 */
345
+		public function getLastAltitudeArchiveSpotterDataByIdent($ident)
346
+		{
347 347
 
348
-                date_default_timezone_set('UTC');
348
+				date_default_timezone_set('UTC');
349 349
 
350
-                $ident = filter_var($ident, FILTER_SANITIZE_STRING);
351
-                $query  = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.ident = :ident GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate LIMIT 1";
350
+				$ident = filter_var($ident, FILTER_SANITIZE_STRING);
351
+				$query  = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.ident = :ident GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate LIMIT 1";
352 352
 //                $query  = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.ident = :ident";
353 353
 
354
-                try {
355
-                        $sth = $this->db->prepare($query);
356
-                        $sth->execute(array(':ident' => $ident));
357
-                } catch(PDOException $e) {
358
-                        echo $e->getMessage();
359
-                        die;
360
-                }
361
-                $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
354
+				try {
355
+						$sth = $this->db->prepare($query);
356
+						$sth->execute(array(':ident' => $ident));
357
+				} catch(PDOException $e) {
358
+						echo $e->getMessage();
359
+						die;
360
+				}
361
+				$spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
362 362
 
363
-                return $spotter_array;
364
-        }
363
+				return $spotter_array;
364
+		}
365 365
 
366 366
 
367 367
 
368
-       /**
369
-        * Gets all the archive spotter information
370
-        *
371
-        * @return Array the spotter information
372
-        *
373
-        */
374
-        public function getSpotterArchiveData($ident,$flightaware_id,$date)
375
-        {
376
-    		$Spotter = new Spotter($this->db);
377
-                $ident = filter_var($ident, FILTER_SANITIZE_STRING);
378
-                $query  = "SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident AND l.flightaware_id = :flightaware_id AND l.date LIKE :date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate";
368
+	   /**
369
+	    * Gets all the archive spotter information
370
+	    *
371
+	    * @return Array the spotter information
372
+	    *
373
+	    */
374
+		public function getSpotterArchiveData($ident,$flightaware_id,$date)
375
+		{
376
+			$Spotter = new Spotter($this->db);
377
+				$ident = filter_var($ident, FILTER_SANITIZE_STRING);
378
+				$query  = "SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident AND l.flightaware_id = :flightaware_id AND l.date LIKE :date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate";
379 379
 
380
-                $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident,':flightaware_id' => $flightaware_id,':date' => $date.'%'));
380
+				$spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident,':flightaware_id' => $flightaware_id,':date' => $date.'%'));
381 381
 
382
-                return $spotter_array;
383
-        }
382
+				return $spotter_array;
383
+		}
384 384
         
385
-        public function deleteSpotterArchiveTrackData()
386
-        {
385
+		public function deleteSpotterArchiveTrackData()
386
+		{
387 387
 		global $globalArchiveKeepTrackMonths;
388
-                date_default_timezone_set('UTC');
388
+				date_default_timezone_set('UTC');
389 389
 		$query = 'DELETE FROM spotter_archive WHERE spotter_archive.date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL '.$globalArchiveKeepTrackMonths.' MONTH)';
390
-                try {
391
-                        $sth = $this->db->prepare($query);
392
-                        $sth->execute();
393
-                } catch(PDOException $e) {
394
-                        echo $e->getMessage();
395
-                        die;
396
-                }
390
+				try {
391
+						$sth = $this->db->prepare($query);
392
+						$sth->execute();
393
+				} catch(PDOException $e) {
394
+						echo $e->getMessage();
395
+						die;
396
+				}
397 397
 	}
398 398
 
399 399
 	/**
400
-        * Gets Minimal Live Spotter data
401
-        *
402
-        * @return Array the spotter information
403
-        *
404
-        */
405
-        public function getMinLiveSpotterData($begindate,$enddate,$filter = array())
406
-        {
407
-                global $globalDBdriver, $globalLiveInterval;
408
-                date_default_timezone_set('UTC');
409
-
410
-                $filter_query = '';
411
-                if (isset($filter['source']) && !empty($filter['source'])) {
412
-                        $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') ";
413
-                }
414
-                // Use spotter_output also ?
415
-                if (isset($filter['airlines']) && !empty($filter['airlines'])) {
416
-                        $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id ";
417
-                }
418
-                if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) {
419
-                        $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_archive.flightaware_id ";
420
-                }
421
-                if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
422
-                        $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
423
-                }
424
-
425
-                //if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
426
-                if ($globalDBdriver == 'mysql') {
427
-                        /*
400
+	 * Gets Minimal Live Spotter data
401
+	 *
402
+	 * @return Array the spotter information
403
+	 *
404
+	 */
405
+		public function getMinLiveSpotterData($begindate,$enddate,$filter = array())
406
+		{
407
+				global $globalDBdriver, $globalLiveInterval;
408
+				date_default_timezone_set('UTC');
409
+
410
+				$filter_query = '';
411
+				if (isset($filter['source']) && !empty($filter['source'])) {
412
+						$filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') ";
413
+				}
414
+				// Use spotter_output also ?
415
+				if (isset($filter['airlines']) && !empty($filter['airlines'])) {
416
+						$filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id ";
417
+				}
418
+				if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) {
419
+						$filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_archive.flightaware_id ";
420
+				}
421
+				if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
422
+						$filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
423
+				}
424
+
425
+				//if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
426
+				if ($globalDBdriver == 'mysql') {
427
+						/*
428 428
                         $query  = 'SELECT a.aircraft_shadow, spotter_archive.ident, spotter_archive.flightaware_id, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk 
429 429
                     		    FROM spotter_archive 
430 430
                     		    INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE (l.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate '.$filter_query.'LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON spotter_archive.aircraft_icao = a.icao';
@@ -443,56 +443,56 @@  discard block
 block discarded – undo
443 443
 				    INNER JOIN (SELECT * FROM aircraft) a on spotter_archive.aircraft_icao = a.icao
444 444
 				    WHERE spotter_archive.date BETWEEN '."'".$begindate."'".' AND '."'".$begindate."'".' 
445 445
                         	    '.$filter_query.' ORDER BY flightaware_id';
446
-                } else {
447
-                        //$query  = 'SELECT spotter_archive.ident, spotter_archive.flightaware_id, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk, a.aircraft_shadow FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate '.$filter_query.'INNER JOIN (SELECT * FROM aircraft) a on spotter_archive.aircraft_icao = a.icao';
448
-                        $query  = 'SELECT spotter_archive.date,spotter_archive.flightaware_id, spotter_archive.ident, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category 
446
+				} else {
447
+						//$query  = 'SELECT spotter_archive.ident, spotter_archive.flightaware_id, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk, a.aircraft_shadow FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate '.$filter_query.'INNER JOIN (SELECT * FROM aircraft) a on spotter_archive.aircraft_icao = a.icao';
448
+						$query  = 'SELECT spotter_archive.date,spotter_archive.flightaware_id, spotter_archive.ident, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category 
449 449
                         	    FROM spotter_archive 
450 450
                         	    INNER JOIN (SELECT * FROM aircraft) a on spotter_archive.aircraft_icao = a.icao
451 451
                         	    WHERE spotter_archive.date >= '."'".$begindate."'".' AND spotter_archive.date <= '."'".$enddate."'".'
452 452
                         	    '.$filter_query.' ORDER BY flightaware_id';
453
-                }
454
-                //echo $query;
455
-                try {
456
-                        $sth = $this->db->prepare($query);
457
-                        $sth->execute();
458
-                } catch(PDOException $e) {
459
-                        echo $e->getMessage();
460
-                        die;
461
-                }
462
-                $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
463
-
464
-                return $spotter_array;
465
-        }
453
+				}
454
+				//echo $query;
455
+				try {
456
+						$sth = $this->db->prepare($query);
457
+						$sth->execute();
458
+				} catch(PDOException $e) {
459
+						echo $e->getMessage();
460
+						die;
461
+				}
462
+				$spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
463
+
464
+				return $spotter_array;
465
+		}
466 466
 
467 467
 	/**
468
-        * Gets Minimal Live Spotter data
469
-        *
470
-        * @return Array the spotter information
471
-        *
472
-        */
473
-        public function getMinLiveSpotterDataPlayback($begindate,$enddate,$filter = array())
474
-        {
475
-                global $globalDBdriver, $globalLiveInterval;
476
-                date_default_timezone_set('UTC');
477
-
478
-                $filter_query = '';
479
-                if (isset($filter['source']) && !empty($filter['source'])) {
480
-                        $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') ";
481
-                }
482
-                // Should use spotter_output also ?
483
-                if (isset($filter['airlines']) && !empty($filter['airlines'])) {
484
-                        $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id ";
485
-                }
486
-                if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) {
487
-                        $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_archive.flightaware_id ";
488
-                }
489
-                if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
490
-                        $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
491
-                }
492
-
493
-                //if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
494
-                if ($globalDBdriver == 'mysql') {
495
-                        /*
468
+	 * Gets Minimal Live Spotter data
469
+	 *
470
+	 * @return Array the spotter information
471
+	 *
472
+	 */
473
+		public function getMinLiveSpotterDataPlayback($begindate,$enddate,$filter = array())
474
+		{
475
+				global $globalDBdriver, $globalLiveInterval;
476
+				date_default_timezone_set('UTC');
477
+
478
+				$filter_query = '';
479
+				if (isset($filter['source']) && !empty($filter['source'])) {
480
+						$filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') ";
481
+				}
482
+				// Should use spotter_output also ?
483
+				if (isset($filter['airlines']) && !empty($filter['airlines'])) {
484
+						$filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id ";
485
+				}
486
+				if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) {
487
+						$filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_archive.flightaware_id ";
488
+				}
489
+				if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
490
+						$filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
491
+				}
492
+
493
+				//if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
494
+				if ($globalDBdriver == 'mysql') {
495
+						/*
496 496
                         $query  = 'SELECT a.aircraft_shadow, spotter_archive.ident, spotter_archive.flightaware_id, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk 
497 497
                     		    FROM spotter_archive 
498 498
                     		    INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE (l.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate '.$filter_query.'LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON spotter_archive.aircraft_icao = a.icao';
@@ -503,95 +503,95 @@  discard block
 block discarded – undo
503 503
 				    WHERE (spotter_archive_output.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') 
504 504
                         	    '.$filter_query.' GROUP BY spotter_archive_output.flightaware_id, spotter_archive_output.ident, spotter_archive_output.aircraft_icao, spotter_archive_output.departure_airport_icao, spotter_archive_output.arrival_airport_icao, spotter_archive_output.latitude, spotter_archive_output.longitude, spotter_archive_output.altitude, spotter_archive_output.heading, spotter_archive_output.ground_speed, spotter_archive_output.squawk, a.aircraft_shadow';
505 505
 
506
-                } else {
507
-                        //$query  = 'SELECT spotter_archive_output.ident, spotter_archive_output.flightaware_id, spotter_archive_output.aircraft_icao, spotter_archive_output.departure_airport_icao as departure_airport, spotter_archive_output.arrival_airport_icao as arrival_airport, spotter_archive_output.latitude, spotter_archive_output.longitude, spotter_archive_output.altitude, spotter_archive_output.heading, spotter_archive_output.ground_speed, spotter_archive_output.squawk, a.aircraft_shadow FROM spotter_archive_output INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive_output l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_archive_output.flightaware_id = s.flightaware_id AND spotter_archive_output.date = s.maxdate '.$filter_query.'INNER JOIN (SELECT * FROM aircraft) a on spotter_archive_output.aircraft_icao = a.icao';
508
-                       /*
506
+				} else {
507
+						//$query  = 'SELECT spotter_archive_output.ident, spotter_archive_output.flightaware_id, spotter_archive_output.aircraft_icao, spotter_archive_output.departure_airport_icao as departure_airport, spotter_archive_output.arrival_airport_icao as arrival_airport, spotter_archive_output.latitude, spotter_archive_output.longitude, spotter_archive_output.altitude, spotter_archive_output.heading, spotter_archive_output.ground_speed, spotter_archive_output.squawk, a.aircraft_shadow FROM spotter_archive_output INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive_output l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_archive_output.flightaware_id = s.flightaware_id AND spotter_archive_output.date = s.maxdate '.$filter_query.'INNER JOIN (SELECT * FROM aircraft) a on spotter_archive_output.aircraft_icao = a.icao';
508
+					   /*
509 509
                         $query  = 'SELECT spotter_archive_output.ident, spotter_archive_output.flightaware_id, spotter_archive_output.aircraft_icao, spotter_archive_output.departure_airport_icao as departure_airport, spotter_archive_output.arrival_airport_icao as arrival_airport, spotter_archive_output.latitude, spotter_archive_output.longitude, spotter_archive_output.altitude, spotter_archive_output.heading, spotter_archive_output.ground_speed, spotter_archive_output.squawk, a.aircraft_shadow
510 510
                         	    FROM spotter_archive_output 
511 511
                         	    INNER JOIN (SELECT * FROM aircraft) a on spotter_archive_output.aircraft_icao = a.icao
512 512
                         	    WHERE spotter_archive_output.date >= '."'".$begindate."'".' AND spotter_archive_output.date <= '."'".$enddate."'".'
513 513
                         	    '.$filter_query.' GROUP BY spotter_archive_output.flightaware_id, spotter_archive_output.ident, spotter_archive_output.aircraft_icao, spotter_archive_output.departure_airport_icao, spotter_archive_output.arrival_airport_icao, spotter_archive_output.latitude, spotter_archive_output.longitude, spotter_archive_output.altitude, spotter_archive_output.heading, spotter_archive_output.ground_speed, spotter_archive_output.squawk, a.aircraft_shadow';
514 514
                         */
515
-                        $query  = 'SELECT DISTINCT spotter_archive_output.flightaware_id, spotter_archive_output.ident, spotter_archive_output.aircraft_icao, spotter_archive_output.departure_airport_icao as departure_airport, spotter_archive_output.arrival_airport_icao as arrival_airport, spotter_archive_output.latitude, spotter_archive_output.longitude, spotter_archive_output.altitude, spotter_archive_output.heading, spotter_archive_output.ground_speed, spotter_archive_output.squawk, a.aircraft_shadow
515
+						$query  = 'SELECT DISTINCT spotter_archive_output.flightaware_id, spotter_archive_output.ident, spotter_archive_output.aircraft_icao, spotter_archive_output.departure_airport_icao as departure_airport, spotter_archive_output.arrival_airport_icao as arrival_airport, spotter_archive_output.latitude, spotter_archive_output.longitude, spotter_archive_output.altitude, spotter_archive_output.heading, spotter_archive_output.ground_speed, spotter_archive_output.squawk, a.aircraft_shadow
516 516
                         	    FROM spotter_archive_output 
517 517
                         	    INNER JOIN (SELECT * FROM aircraft) a on spotter_archive_output.aircraft_icao = a.icao
518 518
                         	    WHERE spotter_archive_output.date >= '."'".$begindate."'".' AND spotter_archive_output.date <= '."'".$enddate."'".'
519 519
                         	    '.$filter_query.' LIMIT 200 OFFSET 0';
520 520
 //                        	    .' GROUP BY spotter_output.flightaware_id, spotter_output.ident, spotter_output.aircraft_icao, spotter_output.departure_airport_icao, spotter_output.arrival_airport_icao, spotter_output.latitude, spotter_output.longitude, spotter_output.altitude, spotter_output.heading, spotter_output.ground_speed, spotter_output.squawk, a.aircraft_shadow';
521 521
                         	    
522
-                }
523
-                //echo $query;
524
-                try {
525
-                        $sth = $this->db->prepare($query);
526
-                        $sth->execute();
527
-                } catch(PDOException $e) {
528
-                        echo $e->getMessage();
529
-                        die;
530
-                }
531
-                $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
532
-
533
-                return $spotter_array;
534
-        }
522
+				}
523
+				//echo $query;
524
+				try {
525
+						$sth = $this->db->prepare($query);
526
+						$sth->execute();
527
+				} catch(PDOException $e) {
528
+						echo $e->getMessage();
529
+						die;
530
+				}
531
+				$spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
532
+
533
+				return $spotter_array;
534
+		}
535 535
 
536 536
 	 /**
537
-        * Gets count Live Spotter data
538
-        *
539
-        * @return Array the spotter information
540
-        *
541
-        */
542
-        public function getLiveSpotterCount($begindate,$enddate,$filter = array())
543
-        {
544
-                global $globalDBdriver, $globalLiveInterval;
545
-                date_default_timezone_set('UTC');
546
-
547
-                $filter_query = '';
548
-                if (isset($filter['source']) && !empty($filter['source'])) {
549
-                        $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') ";
550
-                }
551
-                if (isset($filter['airlines']) && !empty($filter['airlines'])) {
552
-                        $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id ";
553
-                }
554
-                if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) {
555
-                        $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_archive.flightaware_id ";
556
-                }
557
-                if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
558
-                        $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
559
-                }
560
-
561
-                //if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
562
-                if ($globalDBdriver == 'mysql') {
537
+	  * Gets count Live Spotter data
538
+	  *
539
+	  * @return Array the spotter information
540
+	  *
541
+	  */
542
+		public function getLiveSpotterCount($begindate,$enddate,$filter = array())
543
+		{
544
+				global $globalDBdriver, $globalLiveInterval;
545
+				date_default_timezone_set('UTC');
546
+
547
+				$filter_query = '';
548
+				if (isset($filter['source']) && !empty($filter['source'])) {
549
+						$filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') ";
550
+				}
551
+				if (isset($filter['airlines']) && !empty($filter['airlines'])) {
552
+						$filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id ";
553
+				}
554
+				if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) {
555
+						$filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_archive.flightaware_id ";
556
+				}
557
+				if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
558
+						$filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
559
+				}
560
+
561
+				//if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
562
+				if ($globalDBdriver == 'mysql') {
563 563
 			$query = 'SELECT COUNT(DISTINCT flightaware_id) as nb 
564 564
 			FROM spotter_archive l 
565 565
 			WHERE (l.date BETWEEN DATE_SUB('."'".$begindate."'".',INTERVAL '.$globalLiveInterval.' SECOND) AND '."'".$begindate."'".')'.$filter_query;
566
-                } else {
566
+				} else {
567 567
 			$query = 'SELECT COUNT(DISTINCT flightaware_id) as nb FROM spotter_archive l WHERE (l.date BETWEEN '."'".$begindate."' - INTERVAL '".$globalLiveInterval." SECONDS' AND "."'".$enddate."'".')'.$filter_query;
568
-                }
569
-                //echo $query;
570
-                try {
571
-                        $sth = $this->db->prepare($query);
572
-                        $sth->execute();
573
-                } catch(PDOException $e) {
574
-                        echo $e->getMessage();
575
-                        die;
576
-                }
568
+				}
569
+				//echo $query;
570
+				try {
571
+						$sth = $this->db->prepare($query);
572
+						$sth->execute();
573
+				} catch(PDOException $e) {
574
+						echo $e->getMessage();
575
+						die;
576
+				}
577 577
 		$result = $sth->fetch(PDO::FETCH_ASSOC);
578 578
 		$sth->closeCursor();
579
-                return $result['nb'];
579
+				return $result['nb'];
580 580
 
581
-        }
581
+		}
582 582
 
583 583
 
584 584
 
585 585
 	// Spotter_Archive_output
586 586
 	
587
-    /**
588
-    * Gets all the spotter information
589
-    *
590
-    * @return Array the spotter information
591
-    *
592
-    */
593
-    public function searchSpotterData($q = '', $registration = '', $aircraft_icao = '', $aircraft_manufacturer = '', $highlights = '', $airline_icao = '', $airline_country = '', $airline_type = '', $airport = '', $airport_country = '', $callsign = '', $departure_airport_route = '', $arrival_airport_route = '', $owner = '',$pilot_id = '',$pilot_name = '',$altitude = '', $date_posted = '', $limit = '', $sort = '', $includegeodata = '',$origLat = '',$origLon = '',$dist = '', $filters=array())
594
-    {
587
+	/**
588
+	 * Gets all the spotter information
589
+	 *
590
+	 * @return Array the spotter information
591
+	 *
592
+	 */
593
+	public function searchSpotterData($q = '', $registration = '', $aircraft_icao = '', $aircraft_manufacturer = '', $highlights = '', $airline_icao = '', $airline_country = '', $airline_type = '', $airport = '', $airport_country = '', $callsign = '', $departure_airport_route = '', $arrival_airport_route = '', $owner = '',$pilot_id = '',$pilot_name = '',$altitude = '', $date_posted = '', $limit = '', $sort = '', $includegeodata = '',$origLat = '',$origLon = '',$dist = '', $filters=array())
594
+	{
595 595
 	global $globalTimezone, $globalDBdriver;
596 596
 	require_once(dirname(__FILE__).'/class.Translation.php');
597 597
 	$Translation = new Translation();
@@ -605,159 +605,159 @@  discard block
 block discarded – undo
605 605
 	$filter_query = $this->getFilter($filters);
606 606
 	if ($q != "")
607 607
 	{
608
-	    if (!is_string($q))
609
-	    {
608
+		if (!is_string($q))
609
+		{
610 610
 		return false;
611
-	    } else {
611
+		} else {
612 612
 	        
613 613
 		$q_array = explode(" ", $q);
614 614
 		
615 615
 		foreach ($q_array as $q_item){
616
-		    $additional_query .= " AND (";
617
-		    $additional_query .= "(spotter_archive_output.spotter_id like '%".$q_item."%') OR ";
618
-		    $additional_query .= "(spotter_archive_output.aircraft_icao like '%".$q_item."%') OR ";
619
-		    $additional_query .= "(spotter_archive_output.aircraft_name like '%".$q_item."%') OR ";
620
-		    $additional_query .= "(spotter_archive_output.aircraft_manufacturer like '%".$q_item."%') OR ";
621
-		    $additional_query .= "(spotter_archive_output.airline_icao like '%".$q_item."%') OR ";
622
-		    $additional_query .= "(spotter_archive_output.airline_name like '%".$q_item."%') OR ";
623
-		    $additional_query .= "(spotter_archive_output.airline_country like '%".$q_item."%') OR ";
624
-		    $additional_query .= "(spotter_archive_output.departure_airport_icao like '%".$q_item."%') OR ";
625
-		    $additional_query .= "(spotter_archive_output.departure_airport_name like '%".$q_item."%') OR ";
626
-		    $additional_query .= "(spotter_archive_output.departure_airport_city like '%".$q_item."%') OR ";
627
-		    $additional_query .= "(spotter_archive_output.departure_airport_country like '%".$q_item."%') OR ";
628
-		    $additional_query .= "(spotter_archive_output.arrival_airport_icao like '%".$q_item."%') OR ";
629
-		    $additional_query .= "(spotter_archive_output.arrival_airport_name like '%".$q_item."%') OR ";
630
-		    $additional_query .= "(spotter_archive_output.arrival_airport_city like '%".$q_item."%') OR ";
631
-		    $additional_query .= "(spotter_archive_output.arrival_airport_country like '%".$q_item."%') OR ";
632
-		    $additional_query .= "(spotter_archive_output.registration like '%".$q_item."%') OR ";
633
-		    $additional_query .= "(spotter_archive_output.owner_name like '%".$q_item."%') OR ";
634
-		    $additional_query .= "(spotter_archive_output.pilot_id like '%".$q_item."%') OR ";
635
-		    $additional_query .= "(spotter_archive_output.pilot_name like '%".$q_item."%') OR ";
636
-		    $additional_query .= "(spotter_archive_output.ident like '%".$q_item."%') OR ";
637
-		    $translate = $Translation->ident2icao($q_item);
638
-		    if ($translate != $q_item) $additional_query .= "(spotter_archive_output.ident like '%".$translate."%') OR ";
639
-		    $additional_query .= "(spotter_archive_output.highlight like '%".$q_item."%')";
640
-		    $additional_query .= ")";
641
-		}
642
-	    }
616
+			$additional_query .= " AND (";
617
+			$additional_query .= "(spotter_archive_output.spotter_id like '%".$q_item."%') OR ";
618
+			$additional_query .= "(spotter_archive_output.aircraft_icao like '%".$q_item."%') OR ";
619
+			$additional_query .= "(spotter_archive_output.aircraft_name like '%".$q_item."%') OR ";
620
+			$additional_query .= "(spotter_archive_output.aircraft_manufacturer like '%".$q_item."%') OR ";
621
+			$additional_query .= "(spotter_archive_output.airline_icao like '%".$q_item."%') OR ";
622
+			$additional_query .= "(spotter_archive_output.airline_name like '%".$q_item."%') OR ";
623
+			$additional_query .= "(spotter_archive_output.airline_country like '%".$q_item."%') OR ";
624
+			$additional_query .= "(spotter_archive_output.departure_airport_icao like '%".$q_item."%') OR ";
625
+			$additional_query .= "(spotter_archive_output.departure_airport_name like '%".$q_item."%') OR ";
626
+			$additional_query .= "(spotter_archive_output.departure_airport_city like '%".$q_item."%') OR ";
627
+			$additional_query .= "(spotter_archive_output.departure_airport_country like '%".$q_item."%') OR ";
628
+			$additional_query .= "(spotter_archive_output.arrival_airport_icao like '%".$q_item."%') OR ";
629
+			$additional_query .= "(spotter_archive_output.arrival_airport_name like '%".$q_item."%') OR ";
630
+			$additional_query .= "(spotter_archive_output.arrival_airport_city like '%".$q_item."%') OR ";
631
+			$additional_query .= "(spotter_archive_output.arrival_airport_country like '%".$q_item."%') OR ";
632
+			$additional_query .= "(spotter_archive_output.registration like '%".$q_item."%') OR ";
633
+			$additional_query .= "(spotter_archive_output.owner_name like '%".$q_item."%') OR ";
634
+			$additional_query .= "(spotter_archive_output.pilot_id like '%".$q_item."%') OR ";
635
+			$additional_query .= "(spotter_archive_output.pilot_name like '%".$q_item."%') OR ";
636
+			$additional_query .= "(spotter_archive_output.ident like '%".$q_item."%') OR ";
637
+			$translate = $Translation->ident2icao($q_item);
638
+			if ($translate != $q_item) $additional_query .= "(spotter_archive_output.ident like '%".$translate."%') OR ";
639
+			$additional_query .= "(spotter_archive_output.highlight like '%".$q_item."%')";
640
+			$additional_query .= ")";
641
+		}
642
+		}
643 643
 	}
644 644
 	
645 645
 	if ($registration != "")
646 646
 	{
647
-	    $registration = filter_var($registration,FILTER_SANITIZE_STRING);
648
-	    if (!is_string($registration))
649
-	    {
647
+		$registration = filter_var($registration,FILTER_SANITIZE_STRING);
648
+		if (!is_string($registration))
649
+		{
650 650
 		return false;
651
-	    } else {
651
+		} else {
652 652
 		$additional_query .= " AND (spotter_archive_output.registration = '".$registration."')";
653
-	    }
653
+		}
654 654
 	}
655 655
 	
656 656
 	if ($aircraft_icao != "")
657 657
 	{
658
-	    $aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING);
659
-	    if (!is_string($aircraft_icao))
660
-	    {
658
+		$aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING);
659
+		if (!is_string($aircraft_icao))
660
+		{
661 661
 		return false;
662
-	    } else {
662
+		} else {
663 663
 		$additional_query .= " AND (spotter_archive_output.aircraft_icao = '".$aircraft_icao."')";
664
-	    }
664
+		}
665 665
 	}
666 666
 	
667 667
 	if ($aircraft_manufacturer != "")
668 668
 	{
669
-	    $aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING);
670
-	    if (!is_string($aircraft_manufacturer))
671
-	    {
669
+		$aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING);
670
+		if (!is_string($aircraft_manufacturer))
671
+		{
672 672
 		return false;
673
-	    } else {
673
+		} else {
674 674
 		$additional_query .= " AND (spotter_archive_output.aircraft_manufacturer = '".$aircraft_manufacturer."')";
675
-	    }
675
+		}
676 676
 	}
677 677
 	
678 678
 	if ($highlights == "true")
679 679
 	{
680
-	    if (!is_string($highlights))
681
-	    {
680
+		if (!is_string($highlights))
681
+		{
682 682
 		return false;
683
-	    } else {
683
+		} else {
684 684
 		$additional_query .= " AND (spotter_archive_output.highlight <> '')";
685
-	    }
685
+		}
686 686
 	}
687 687
 	
688 688
 	if ($airline_icao != "")
689 689
 	{
690
-	    $airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING);
691
-	    if (!is_string($airline_icao))
692
-	    {
690
+		$airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING);
691
+		if (!is_string($airline_icao))
692
+		{
693 693
 		return false;
694
-	    } else {
694
+		} else {
695 695
 		$additional_query .= " AND (spotter_archive_output.airline_icao = '".$airline_icao."')";
696
-	    }
696
+		}
697 697
 	}
698 698
 	
699 699
 	if ($airline_country != "")
700 700
 	{
701
-	    $airline_country = filter_var($airline_country,FILTER_SANITIZE_STRING);
702
-	    if (!is_string($airline_country))
703
-	    {
701
+		$airline_country = filter_var($airline_country,FILTER_SANITIZE_STRING);
702
+		if (!is_string($airline_country))
703
+		{
704 704
 		return false;
705
-	    } else {
705
+		} else {
706 706
 		$additional_query .= " AND (spotter_archive_output.airline_country = '".$airline_country."')";
707
-	    }
707
+		}
708 708
 	}
709 709
 	
710 710
 	if ($airline_type != "")
711 711
 	{
712
-	    $airline_type = filter_var($airline_type,FILTER_SANITIZE_STRING);
713
-	    if (!is_string($airline_type))
714
-	    {
712
+		$airline_type = filter_var($airline_type,FILTER_SANITIZE_STRING);
713
+		if (!is_string($airline_type))
714
+		{
715 715
 		return false;
716
-	    } else {
716
+		} else {
717 717
 		if ($airline_type == "passenger")
718 718
 		{
719
-		    $additional_query .= " AND (spotter_archive_output.airline_type = 'passenger')";
719
+			$additional_query .= " AND (spotter_archive_output.airline_type = 'passenger')";
720 720
 		}
721 721
 		if ($airline_type == "cargo")
722 722
 		{
723
-		    $additional_query .= " AND (spotter_archive_output.airline_type = 'cargo')";
723
+			$additional_query .= " AND (spotter_archive_output.airline_type = 'cargo')";
724 724
 		}
725 725
 		if ($airline_type == "military")
726 726
 		{
727
-		    $additional_query .= " AND (spotter_archive_output.airline_type = 'military')";
727
+			$additional_query .= " AND (spotter_archive_output.airline_type = 'military')";
728
+		}
728 729
 		}
729
-	    }
730 730
 	}
731 731
 	
732 732
 	if ($airport != "")
733 733
 	{
734
-	    $airport = filter_var($airport,FILTER_SANITIZE_STRING);
735
-	    if (!is_string($airport))
736
-	    {
734
+		$airport = filter_var($airport,FILTER_SANITIZE_STRING);
735
+		if (!is_string($airport))
736
+		{
737 737
 		return false;
738
-	    } else {
738
+		} else {
739 739
 		$additional_query .= " AND ((spotter_archive_output.departure_airport_icao = '".$airport."') OR (spotter_archive_output.arrival_airport_icao = '".$airport."'))";
740
-	    }
740
+		}
741 741
 	}
742 742
 	
743 743
 	if ($airport_country != "")
744 744
 	{
745
-	    $airport_country = filter_var($airport_country,FILTER_SANITIZE_STRING);
746
-	    if (!is_string($airport_country))
747
-	    {
745
+		$airport_country = filter_var($airport_country,FILTER_SANITIZE_STRING);
746
+		if (!is_string($airport_country))
747
+		{
748 748
 		return false;
749
-	    } else {
749
+		} else {
750 750
 		$additional_query .= " AND ((spotter_archive_output.departure_airport_country = '".$airport_country."') OR (spotter_archive_output.arrival_airport_country = '".$airport_country."'))";
751
-	    }
751
+		}
752 752
 	}
753 753
     
754 754
 	if ($callsign != "")
755 755
 	{
756
-	    $callsign = filter_var($callsign,FILTER_SANITIZE_STRING);
757
-	    if (!is_string($callsign))
758
-	    {
756
+		$callsign = filter_var($callsign,FILTER_SANITIZE_STRING);
757
+		if (!is_string($callsign))
758
+		{
759 759
 		return false;
760
-	    } else {
760
+		} else {
761 761
 		$translate = $Translation->ident2icao($callsign);
762 762
 		if ($translate != $callsign) {
763 763
 			$additional_query .= " AND (spotter_archive_output.ident = :callsign OR spotter_archive_output.ident = :translate)";
@@ -765,99 +765,99 @@  discard block
 block discarded – undo
765 765
 		} else {
766 766
 			$additional_query .= " AND (spotter_archive_output.ident = '".$callsign."')";
767 767
 		}
768
-	    }
768
+		}
769 769
 	}
770 770
 
771 771
 	if ($owner != "")
772 772
 	{
773
-	    $owner = filter_var($owner,FILTER_SANITIZE_STRING);
774
-	    if (!is_string($owner))
775
-	    {
773
+		$owner = filter_var($owner,FILTER_SANITIZE_STRING);
774
+		if (!is_string($owner))
775
+		{
776 776
 		return false;
777
-	    } else {
777
+		} else {
778 778
 		$additional_query .= " AND (spotter_archive_output.owner_name = '".$owner."')";
779
-	    }
779
+		}
780 780
 	}
781 781
 
782 782
 	if ($pilot_name != "")
783 783
 	{
784
-	    $pilot_name = filter_var($pilot_name,FILTER_SANITIZE_STRING);
785
-	    if (!is_string($pilot_name))
786
-	    {
784
+		$pilot_name = filter_var($pilot_name,FILTER_SANITIZE_STRING);
785
+		if (!is_string($pilot_name))
786
+		{
787 787
 		return false;
788
-	    } else {
788
+		} else {
789 789
 		$additional_query .= " AND (spotter_archive_output.pilot_name = '".$pilot_name."')";
790
-	    }
790
+		}
791 791
 	}
792 792
 	
793 793
 	if ($pilot_id != "")
794 794
 	{
795
-	    $pilot_id = filter_var($pilot_id,FILTER_SANITIZE_NUMBER_INT);
796
-	    if (!is_string($pilot_id))
797
-	    {
795
+		$pilot_id = filter_var($pilot_id,FILTER_SANITIZE_NUMBER_INT);
796
+		if (!is_string($pilot_id))
797
+		{
798 798
 		return false;
799
-	    } else {
799
+		} else {
800 800
 		$additional_query .= " AND (spotter_archive_output.pilot_id = '".$pilot_id."')";
801
-	    }
801
+		}
802 802
 	}
803 803
 	
804 804
 	if ($departure_airport_route != "")
805 805
 	{
806
-	    $departure_airport_route = filter_var($departure_airport_route,FILTER_SANITIZE_STRING);
807
-	    if (!is_string($departure_airport_route))
808
-	    {
806
+		$departure_airport_route = filter_var($departure_airport_route,FILTER_SANITIZE_STRING);
807
+		if (!is_string($departure_airport_route))
808
+		{
809 809
 		return false;
810
-	    } else {
810
+		} else {
811 811
 		$additional_query .= " AND (spotter_archive_output.departure_airport_icao = '".$departure_airport_route."')";
812
-	    }
812
+		}
813 813
 	}
814 814
 	
815 815
 	if ($arrival_airport_route != "")
816 816
 	{
817
-	    $arrival_airport_route = filter_var($arrival_airport_route,FILTER_SANITIZE_STRING);
818
-	    if (!is_string($arrival_airport_route))
819
-	    {
817
+		$arrival_airport_route = filter_var($arrival_airport_route,FILTER_SANITIZE_STRING);
818
+		if (!is_string($arrival_airport_route))
819
+		{
820 820
 		return false;
821
-	    } else {
821
+		} else {
822 822
 		$additional_query .= " AND (spotter_archive_output.arrival_airport_icao = '".$arrival_airport_route."')";
823
-	    }
823
+		}
824 824
 	}
825 825
 	
826 826
 	if ($altitude != "")
827 827
 	{
828
-	    $altitude_array = explode(",", $altitude);
828
+		$altitude_array = explode(",", $altitude);
829 829
 	    
830
-	    $altitude_array[0] = filter_var($altitude_array[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
831
-	    $altitude_array[1] = filter_var($altitude_array[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
830
+		$altitude_array[0] = filter_var($altitude_array[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
831
+		$altitude_array[1] = filter_var($altitude_array[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
832 832
 	    
833 833
 
834
-	    if ($altitude_array[1] != "")
835
-	    {                
834
+		if ($altitude_array[1] != "")
835
+		{                
836 836
 		$altitude_array[0] = substr($altitude_array[0], 0, -2);
837 837
 		$altitude_array[1] = substr($altitude_array[1], 0, -2);
838 838
 		$additional_query .= " AND altitude BETWEEN '".$altitude_array[0]."' AND '".$altitude_array[1]."' ";
839
-	    } else {
839
+		} else {
840 840
 		$altitude_array[0] = substr($altitude_array[0], 0, -2);
841 841
 		$additional_query .= " AND altitude <= '".$altitude_array[0]."' ";
842
-	    }
842
+		}
843 843
 	}
844 844
 	
845 845
 	if ($date_posted != "")
846 846
 	{
847
-	    $date_array = explode(",", $date_posted);
847
+		$date_array = explode(",", $date_posted);
848 848
 	    
849
-	    $date_array[0] = filter_var($date_array[0],FILTER_SANITIZE_STRING);
850
-	    $date_array[1] = filter_var($date_array[1],FILTER_SANITIZE_STRING);
849
+		$date_array[0] = filter_var($date_array[0],FILTER_SANITIZE_STRING);
850
+		$date_array[1] = filter_var($date_array[1],FILTER_SANITIZE_STRING);
851 851
 	    
852
-	    if ($globalTimezone != '') {
852
+		if ($globalTimezone != '') {
853 853
 		date_default_timezone_set($globalTimezone);
854 854
 		$datetime = new DateTime();
855 855
 		$offset = $datetime->format('P');
856
-	    } else $offset = '+00:00';
856
+		} else $offset = '+00:00';
857 857
 
858 858
 
859
-	    if ($date_array[1] != "")
860
-	    {                
859
+		if ($date_array[1] != "")
860
+		{                
861 861
 		$date_array[0] = date("Y-m-d H:i:s", strtotime($date_array[0]));
862 862
 		$date_array[1] = date("Y-m-d H:i:s", strtotime($date_array[1]));
863 863
 		if ($globalDBdriver == 'mysql') {
@@ -865,28 +865,28 @@  discard block
 block discarded – undo
865 865
 		} else {
866 866
 			$additional_query .= " AND spotter_archive_output.date::timestamp AT TIME ZONE INTERVAL ".$offset." >= CAST('".$date_array[0]."' AS TIMESTAMP) AND spotter_archive_output.date::timestamp AT TIME ZONE INTERVAL ".$offset." <= CAST('".$date_array[1]."' AS TIMESTAMP) ";
867 867
 		}
868
-	    } else {
868
+		} else {
869 869
 		$date_array[0] = date("Y-m-d H:i:s", strtotime($date_array[0]));
870
-                if ($globalDBdriver == 'mysql') {
870
+				if ($globalDBdriver == 'mysql') {
871 871
 			$additional_query .= " AND TIMESTAMP(CONVERT_TZ(spotter_archive_output.date,'+00:00', '".$offset."')) >= '".$date_array[0]."' ";
872 872
 		} else {
873 873
 			$additional_query .= " AND spotter_archive_output.date::timestamp AT TIME ZONE INTERVAL ".$offset." >= CAST('".$date_array[0]."' AS TIMESTAMP) ";
874 874
 		}
875
-	    }
875
+		}
876 876
 	}
877 877
 	
878 878
 	if ($limit != "")
879 879
 	{
880
-	    $limit_array = explode(",", $limit);
880
+		$limit_array = explode(",", $limit);
881 881
 	    
882
-	    $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
883
-	    $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
882
+		$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
883
+		$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
884 884
 	    
885
-	    if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
886
-	    {
885
+		if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
886
+		{
887 887
 		//$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1];
888 888
 		$limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0];
889
-	    }
889
+		}
890 890
 	}
891 891
 	
892 892
 
@@ -917,33 +917,33 @@  discard block
 block discarded – undo
917 917
 	$spotter_array = $Spotter->getDataFromDB($query, $query_values,$limit_query);
918 918
 
919 919
 	return $spotter_array;
920
-    }
920
+	}
921 921
 
922
-    public function deleteSpotterArchiveData()
923
-    {
922
+	public function deleteSpotterArchiveData()
923
+	{
924 924
 		global $globalArchiveKeepMonths, $globalDBdriver;
925
-                date_default_timezone_set('UTC');
926
-                if ($globalDBdriver == 'mysql') {
925
+				date_default_timezone_set('UTC');
926
+				if ($globalDBdriver == 'mysql') {
927 927
 			$query = 'DELETE FROM spotter_archive_output WHERE spotter_archive_output.date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL '.$globalArchiveKeepMonths.' MONTH)';
928 928
 		} else {
929 929
 			$query = "DELETE FROM spotter_archive_output WHERE spotter_archive_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalArchiveKeepMonths." MONTH'";
930 930
 		}
931
-                try {
932
-                        $sth = $this->db->prepare($query);
933
-                        $sth->execute();
934
-                } catch(PDOException $e) {
935
-                        return "error";
936
-                }
931
+				try {
932
+						$sth = $this->db->prepare($query);
933
+						$sth->execute();
934
+				} catch(PDOException $e) {
935
+						return "error";
936
+				}
937 937
 	}
938 938
 
939
-    /**
940
-    * Gets all the spotter information based on the callsign
941
-    *
942
-    * @return Array the spotter information
943
-    *
944
-    */
945
-    public function getSpotterDataByIdent($ident = '', $limit = '', $sort = '')
946
-    {
939
+	/**
940
+	 * Gets all the spotter information based on the callsign
941
+	 *
942
+	 * @return Array the spotter information
943
+	 *
944
+	 */
945
+	public function getSpotterDataByIdent($ident = '', $limit = '', $sort = '')
946
+	{
947 947
 	$global_query = "SELECT spotter_archive_output.* FROM spotter_archive_output";
948 948
 	
949 949
 	date_default_timezone_set('UTC');
@@ -955,35 +955,35 @@  discard block
 block discarded – undo
955 955
 	
956 956
 	if ($ident != "")
957 957
 	{
958
-	    if (!is_string($ident))
959
-	    {
958
+		if (!is_string($ident))
959
+		{
960 960
 		return false;
961
-	    } else {
961
+		} else {
962 962
 		$additional_query = " AND (spotter_archive_output.ident = :ident)";
963 963
 		$query_values = array(':ident' => $ident);
964
-	    }
964
+		}
965 965
 	}
966 966
 	
967 967
 	if ($limit != "")
968 968
 	{
969
-	    $limit_array = explode(",", $limit);
969
+		$limit_array = explode(",", $limit);
970 970
 	    
971
-	    $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
972
-	    $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
971
+		$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
972
+		$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
973 973
 	    
974
-	    if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
975
-	    {
974
+		if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
975
+		{
976 976
 		//$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1];
977 977
 		$limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0];
978
-	    }
978
+		}
979 979
 	}
980 980
 
981 981
 	if ($sort != "")
982 982
 	{
983
-	    $search_orderby_array = $Spotter->getOrderBy();
984
-	    $orderby_query = $search_orderby_array[$sort]['sql'];
983
+		$search_orderby_array = $Spotter->getOrderBy();
984
+		$orderby_query = $search_orderby_array[$sort]['sql'];
985 985
 	} else {
986
-	    $orderby_query = " ORDER BY spotter_archive_output.date DESC";
986
+		$orderby_query = " ORDER BY spotter_archive_output.date DESC";
987 987
 	}
988 988
 
989 989
 	$query = $global_query." WHERE spotter_archive_output.ident <> '' ".$additional_query." ".$orderby_query;
@@ -991,17 +991,17 @@  discard block
 block discarded – undo
991 991
 	$spotter_array = $Spotter->getDataFromDB($query, $query_values, $limit_query);
992 992
 
993 993
 	return $spotter_array;
994
-    }
994
+	}
995 995
 
996 996
 
997
-    /**
998
-    * Gets all the spotter information based on the owner
999
-    *
1000
-    * @return Array the spotter information
1001
-    *
1002
-    */
1003
-    public function getSpotterDataByOwner($owner = '', $limit = '', $sort = '', $filter = array())
1004
-    {
997
+	/**
998
+	 * Gets all the spotter information based on the owner
999
+	 *
1000
+	 * @return Array the spotter information
1001
+	 *
1002
+	 */
1003
+	public function getSpotterDataByOwner($owner = '', $limit = '', $sort = '', $filter = array())
1004
+	{
1005 1005
 	$global_query = "SELECT spotter_archive_output.* FROM spotter_archive_output";
1006 1006
 	
1007 1007
 	date_default_timezone_set('UTC');
@@ -1014,35 +1014,35 @@  discard block
 block discarded – undo
1014 1014
 	
1015 1015
 	if ($owner != "")
1016 1016
 	{
1017
-	    if (!is_string($owner))
1018
-	    {
1017
+		if (!is_string($owner))
1018
+		{
1019 1019
 		return false;
1020
-	    } else {
1020
+		} else {
1021 1021
 		$additional_query = " AND (spotter_archive_output.owner_name = :owner)";
1022 1022
 		$query_values = array(':owner' => $owner);
1023
-	    }
1023
+		}
1024 1024
 	}
1025 1025
 	
1026 1026
 	if ($limit != "")
1027 1027
 	{
1028
-	    $limit_array = explode(",", $limit);
1028
+		$limit_array = explode(",", $limit);
1029 1029
 	    
1030
-	    $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1031
-	    $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1030
+		$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1031
+		$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1032 1032
 	    
1033
-	    if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1034
-	    {
1033
+		if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1034
+		{
1035 1035
 		//$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1];
1036 1036
 		$limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0];
1037
-	    }
1037
+		}
1038 1038
 	}
1039 1039
 
1040 1040
 	if ($sort != "")
1041 1041
 	{
1042
-	    $search_orderby_array = $Spotter->getOrderBy();
1043
-	    $orderby_query = $search_orderby_array[$sort]['sql'];
1042
+		$search_orderby_array = $Spotter->getOrderBy();
1043
+		$orderby_query = $search_orderby_array[$sort]['sql'];
1044 1044
 	} else {
1045
-	    $orderby_query = " ORDER BY spotter_archive_output.date DESC";
1045
+		$orderby_query = " ORDER BY spotter_archive_output.date DESC";
1046 1046
 	}
1047 1047
 
1048 1048
 	$query = $global_query.$filter_query." spotter_archive_output.owner_name <> '' ".$additional_query." ".$orderby_query;
@@ -1050,16 +1050,16 @@  discard block
 block discarded – undo
1050 1050
 	$spotter_array = $Spotter->getDataFromDB($query, $query_values, $limit_query);
1051 1051
 
1052 1052
 	return $spotter_array;
1053
-    }
1054
-
1055
-    /**
1056
-    * Gets all the spotter information based on the pilot
1057
-    *
1058
-    * @return Array the spotter information
1059
-    *
1060
-    */
1061
-    public function getSpotterDataByPilot($pilot = '', $limit = '', $sort = '', $filter = array())
1062
-    {
1053
+	}
1054
+
1055
+	/**
1056
+	 * Gets all the spotter information based on the pilot
1057
+	 *
1058
+	 * @return Array the spotter information
1059
+	 *
1060
+	 */
1061
+	public function getSpotterDataByPilot($pilot = '', $limit = '', $sort = '', $filter = array())
1062
+	{
1063 1063
 	$global_query = "SELECT spotter_archive_output.* FROM spotter_archive_output";
1064 1064
 	
1065 1065
 	date_default_timezone_set('UTC');
@@ -1078,24 +1078,24 @@  discard block
 block discarded – undo
1078 1078
 	
1079 1079
 	if ($limit != "")
1080 1080
 	{
1081
-	    $limit_array = explode(",", $limit);
1081
+		$limit_array = explode(",", $limit);
1082 1082
 	    
1083
-	    $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1084
-	    $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1083
+		$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1084
+		$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1085 1085
 	    
1086
-	    if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1087
-	    {
1086
+		if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1087
+		{
1088 1088
 		//$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1];
1089 1089
 		$limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0];
1090
-	    }
1090
+		}
1091 1091
 	}
1092 1092
 
1093 1093
 	if ($sort != "")
1094 1094
 	{
1095
-	    $search_orderby_array = $Spotter->getOrderBy();
1096
-	    $orderby_query = $search_orderby_array[$sort]['sql'];
1095
+		$search_orderby_array = $Spotter->getOrderBy();
1096
+		$orderby_query = $search_orderby_array[$sort]['sql'];
1097 1097
 	} else {
1098
-	    $orderby_query = " ORDER BY spotter_archive_output.date DESC";
1098
+		$orderby_query = " ORDER BY spotter_archive_output.date DESC";
1099 1099
 	}
1100 1100
 
1101 1101
 	$query = $global_query.$filter_query." spotter_archive_output.pilot_name <> '' ".$additional_query." ".$orderby_query;
@@ -1103,16 +1103,16 @@  discard block
 block discarded – undo
1103 1103
 	$spotter_array = $Spotter->getDataFromDB($query, $query_values, $limit_query);
1104 1104
 
1105 1105
 	return $spotter_array;
1106
-    }
1107
-
1108
-    /**
1109
-    * Gets all number of flight over countries
1110
-    *
1111
-    * @return Array the airline country list
1112
-    *
1113
-    */
1114
-    public function countAllFlightOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '')
1115
-    {
1106
+	}
1107
+
1108
+	/**
1109
+	 * Gets all number of flight over countries
1110
+	 *
1111
+	 * @return Array the airline country list
1112
+	 *
1113
+	 */
1114
+	public function countAllFlightOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '')
1115
+	{
1116 1116
 	global $globalDBdriver;
1117 1117
 	/*
1118 1118
 	$query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb 
@@ -1122,14 +1122,14 @@  discard block
 block discarded – undo
1122 1122
 	$query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb
1123 1123
 		    FROM countries c, spotter_archive s
1124 1124
 		    WHERE c.iso2 = s.over_country ";
1125
-                if ($olderthanmonths > 0) {
1126
-            		if ($globalDBdriver == 'mysql') {
1125
+				if ($olderthanmonths > 0) {
1126
+					if ($globalDBdriver == 'mysql') {
1127 1127
 				$query .= 'AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) ';
1128 1128
 			} else {
1129 1129
 				$query .= "AND date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'";
1130 1130
 			}
1131 1131
 		}
1132
-                if ($sincedate != '') $query .= "AND date > '".$sincedate."' ";
1132
+				if ($sincedate != '') $query .= "AND date > '".$sincedate."' ";
1133 1133
 	$query .= "GROUP BY c.name, c.iso3, c.iso2 ORDER BY nb DESC";
1134 1134
 	if ($limit) $query .= " LIMIT 0,10";
1135 1135
       
@@ -1142,23 +1142,23 @@  discard block
 block discarded – undo
1142 1142
         
1143 1143
 	while($row = $sth->fetch(PDO::FETCH_ASSOC))
1144 1144
 	{
1145
-	    $temp_array['flight_count'] = $row['nb'];
1146
-	    $temp_array['flight_country'] = $row['name'];
1147
-	    $temp_array['flight_country_iso3'] = $row['iso3'];
1148
-	    $temp_array['flight_country_iso2'] = $row['iso2'];
1149
-	    $flight_array[] = $temp_array;
1145
+		$temp_array['flight_count'] = $row['nb'];
1146
+		$temp_array['flight_country'] = $row['name'];
1147
+		$temp_array['flight_country_iso3'] = $row['iso3'];
1148
+		$temp_array['flight_country_iso2'] = $row['iso2'];
1149
+		$flight_array[] = $temp_array;
1150 1150
 	}
1151 1151
 	return $flight_array;
1152
-    }
1153
-
1154
-    /**
1155
-    * Gets all number of flight over countries
1156
-    *
1157
-    * @return Array the airline country list
1158
-    *
1159
-    */
1160
-    public function countAllFlightOverCountriesByAirlines($limit = true,$olderthanmonths = 0,$sincedate = '')
1161
-    {
1152
+	}
1153
+
1154
+	/**
1155
+	 * Gets all number of flight over countries
1156
+	 *
1157
+	 * @return Array the airline country list
1158
+	 *
1159
+	 */
1160
+	public function countAllFlightOverCountriesByAirlines($limit = true,$olderthanmonths = 0,$sincedate = '')
1161
+	{
1162 1162
 	global $globalDBdriver;
1163 1163
 	/*
1164 1164
 	$query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb 
@@ -1168,14 +1168,14 @@  discard block
 block discarded – undo
1168 1168
 	$query = "SELECT o.airline_icao,c.name, c.iso3, c.iso2, count(c.name) as nb
1169 1169
 		    FROM countries c, spotter_archive s, spotter_output o
1170 1170
 		    WHERE c.iso2 = s.over_country AND o.airline_icao <> '' AND o.flightaware_id = s.flightaware_id ";
1171
-                if ($olderthanmonths > 0) {
1172
-            		if ($globalDBdriver == 'mysql') {
1171
+				if ($olderthanmonths > 0) {
1172
+					if ($globalDBdriver == 'mysql') {
1173 1173
 				$query .= 'AND s.date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) ';
1174 1174
 			} else {
1175 1175
 				$query .= "AND s.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'";
1176 1176
 			}
1177 1177
 		}
1178
-                if ($sincedate != '') $query .= "AND s.date > '".$sincedate."' ";
1178
+				if ($sincedate != '') $query .= "AND s.date > '".$sincedate."' ";
1179 1179
 	$query .= "GROUP BY o.airline_icao,c.name, c.iso3, c.iso2 ORDER BY nb DESC";
1180 1180
 	if ($limit) $query .= " LIMIT 0,10";
1181 1181
       
@@ -1188,24 +1188,24 @@  discard block
 block discarded – undo
1188 1188
         
1189 1189
 	while($row = $sth->fetch(PDO::FETCH_ASSOC))
1190 1190
 	{
1191
-	    $temp_array['airline_icao'] = $row['airline_icao'];
1192
-	    $temp_array['flight_count'] = $row['nb'];
1193
-	    $temp_array['flight_country'] = $row['name'];
1194
-	    $temp_array['flight_country_iso3'] = $row['iso3'];
1195
-	    $temp_array['flight_country_iso2'] = $row['iso2'];
1196
-	    $flight_array[] = $temp_array;
1191
+		$temp_array['airline_icao'] = $row['airline_icao'];
1192
+		$temp_array['flight_count'] = $row['nb'];
1193
+		$temp_array['flight_country'] = $row['name'];
1194
+		$temp_array['flight_country_iso3'] = $row['iso3'];
1195
+		$temp_array['flight_country_iso2'] = $row['iso2'];
1196
+		$flight_array[] = $temp_array;
1197 1197
 	}
1198 1198
 	return $flight_array;
1199
-    }
1200
-
1201
-    /**
1202
-    * Gets last spotter information based on a particular callsign
1203
-    *
1204
-    * @return Array the spotter information
1205
-    *
1206
-    */
1207
-    public function getDateArchiveSpotterDataById($id,$date)
1208
-    {
1199
+	}
1200
+
1201
+	/**
1202
+	 * Gets last spotter information based on a particular callsign
1203
+	 *
1204
+	 * @return Array the spotter information
1205
+	 *
1206
+	 */
1207
+	public function getDateArchiveSpotterDataById($id,$date)
1208
+	{
1209 1209
 	$Spotter = new Spotter($this->db);
1210 1210
 	date_default_timezone_set('UTC');
1211 1211
 	$id = filter_var($id, FILTER_SANITIZE_STRING);
@@ -1213,16 +1213,16 @@  discard block
 block discarded – undo
1213 1213
 	$date = date('c',$date);
1214 1214
 	$spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id,':date' => $date));
1215 1215
 	return $spotter_array;
1216
-    }
1217
-
1218
-    /**
1219
-    * Gets all the spotter information based on a particular callsign
1220
-    *
1221
-    * @return Array the spotter information
1222
-    *
1223
-    */
1224
-    public function getDateArchiveSpotterDataByIdent($ident,$date)
1225
-    {
1216
+	}
1217
+
1218
+	/**
1219
+	 * Gets all the spotter information based on a particular callsign
1220
+	 *
1221
+	 * @return Array the spotter information
1222
+	 *
1223
+	 */
1224
+	public function getDateArchiveSpotterDataByIdent($ident,$date)
1225
+	{
1226 1226
 	$Spotter = new Spotter($this->db);
1227 1227
 	date_default_timezone_set('UTC');
1228 1228
 	$ident = filter_var($ident, FILTER_SANITIZE_STRING);
@@ -1230,16 +1230,16 @@  discard block
 block discarded – undo
1230 1230
 	$date = date('c',$date);
1231 1231
 	$spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident,':date' => $date));
1232 1232
 	return $spotter_array;
1233
-    }
1234
-
1235
-    /**
1236
-    * Gets all the spotter information based on the airport
1237
-    *
1238
-    * @return Array the spotter information
1239
-    *
1240
-    */
1241
-    public function getSpotterDataByAirport($airport = '', $limit = '', $sort = '',$filters = array())
1242
-    {
1233
+	}
1234
+
1235
+	/**
1236
+	 * Gets all the spotter information based on the airport
1237
+	 *
1238
+	 * @return Array the spotter information
1239
+	 *
1240
+	 */
1241
+	public function getSpotterDataByAirport($airport = '', $limit = '', $sort = '',$filters = array())
1242
+	{
1243 1243
 	global $global_query;
1244 1244
 	$Spotter = new Spotter();
1245 1245
 	date_default_timezone_set('UTC');
@@ -1250,35 +1250,35 @@  discard block
 block discarded – undo
1250 1250
 	
1251 1251
 	if ($airport != "")
1252 1252
 	{
1253
-	    if (!is_string($airport))
1254
-	    {
1253
+		if (!is_string($airport))
1254
+		{
1255 1255
 		return false;
1256
-	    } else {
1256
+		} else {
1257 1257
 		$additional_query .= " AND ((spotter_archive_output.departure_airport_icao = :airport) OR (spotter_archive_output.arrival_airport_icao = :airport))";
1258 1258
 		$query_values = array(':airport' => $airport);
1259
-	    }
1259
+		}
1260 1260
 	}
1261 1261
 	
1262 1262
 	if ($limit != "")
1263 1263
 	{
1264
-	    $limit_array = explode(",", $limit);
1264
+		$limit_array = explode(",", $limit);
1265 1265
 	    
1266
-	    $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1267
-	    $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1266
+		$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1267
+		$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1268 1268
 	    
1269
-	    if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1270
-	    {
1269
+		if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1270
+		{
1271 1271
 		//$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1];
1272 1272
 		$limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0];
1273
-	    }
1273
+		}
1274 1274
 	}
1275 1275
 	
1276 1276
 	if ($sort != "")
1277 1277
 	{
1278
-	    $search_orderby_array = $Spotter->getOrderBy();
1279
-	    $orderby_query = $search_orderby_array[$sort]['sql'];
1278
+		$search_orderby_array = $Spotter->getOrderBy();
1279
+		$orderby_query = $search_orderby_array[$sort]['sql'];
1280 1280
 	} else {
1281
-	    $orderby_query = " ORDER BY spotter_archive_output.date DESC";
1281
+		$orderby_query = " ORDER BY spotter_archive_output.date DESC";
1282 1282
 	}
1283 1283
 
1284 1284
 	$query = $global_query.$filter_query." spotter_archive_output.ident <> '' ".$additional_query." AND ((spotter_archive_output.departure_airport_icao <> 'NA') AND (spotter_archive_output.arrival_airport_icao <> 'NA')) ".$orderby_query;
@@ -1286,6 +1286,6 @@  discard block
 block discarded – undo
1286 1286
 	$spotter_array = $Spotter->getDataFromDB($query, $query_values, $limit_query);
1287 1287
 
1288 1288
 	return $spotter_array;
1289
-    }
1289
+	}
1290 1290
 }
1291 1291
 ?>
1292 1292
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +117 added lines, -117 removed lines patch added patch discarded remove patch
@@ -13,62 +13,62 @@  discard block
 block discarded – undo
13 13
     * @param Array $filter the filter
14 14
     * @return Array the SQL part
15 15
     */
16
-    public function getFilter($filter = array(),$where = false,$and = false) {
16
+    public function getFilter($filter = array(), $where = false, $and = false) {
17 17
 	global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver;
18 18
 	$filters = array();
19 19
 	if (is_array($globalStatsFilters) && isset($globalStatsFilters[$globalFilterName])) {
20 20
 		if (isset($globalStatsFilters[$globalFilterName][0]['source'])) {
21 21
 			$filters = $globalStatsFilters[$globalFilterName];
22 22
 		} else {
23
-			$filter = array_merge($filter,$globalStatsFilters[$globalFilterName]);
23
+			$filter = array_merge($filter, $globalStatsFilters[$globalFilterName]);
24 24
 		}
25 25
 	}
26 26
 	if (isset($filter[0]['source'])) {
27
-		$filters = array_merge($filters,$filter);
27
+		$filters = array_merge($filters, $filter);
28 28
 	}
29
-	if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter);
29
+	if (is_array($globalFilter)) $filter = array_merge($filter, $globalFilter);
30 30
 	$filter_query_join = '';
31 31
 	$filter_query_where = '';
32
-	foreach($filters as $flt) {
32
+	foreach ($filters as $flt) {
33 33
 	    if (isset($flt['airlines']) && !empty($flt['airlines'])) {
34 34
 		if ($flt['airlines'][0] != '') {
35 35
 		    if (isset($flt['source'])) {
36
-			$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','",$flt['airlines'])."') AND spotter_archive_output.format_source IN ('".implode("','",$flt['source'])."')) saff ON saff.flightaware_id = spotter_archive_output.flightaware_id";
36
+			$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','", $flt['airlines'])."') AND spotter_archive_output.format_source IN ('".implode("','", $flt['source'])."')) saff ON saff.flightaware_id = spotter_archive_output.flightaware_id";
37 37
 		    } else {
38
-			$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','",$flt['airlines'])."')) saff ON saff.flightaware_id = spotter_archive_output.flightaware_id";
38
+			$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','", $flt['airlines'])."')) saff ON saff.flightaware_id = spotter_archive_output.flightaware_id";
39 39
 		    }
40 40
 		}
41 41
 	    }
42 42
 	    if (isset($flt['pilots_id']) && !empty($flt['pilots_id'])) {
43 43
 		if (isset($flt['source'])) {
44
-		    $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.pilot_id IN ('".implode("','",$flt['pilots_id'])."') AND spotter_archive_output.format_source IN ('".implode("','",$flt['source'])."')) sp ON sp.flightaware_id = spotter_archive_output.flightaware_id";
44
+		    $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.pilot_id IN ('".implode("','", $flt['pilots_id'])."') AND spotter_archive_output.format_source IN ('".implode("','", $flt['source'])."')) sp ON sp.flightaware_id = spotter_archive_output.flightaware_id";
45 45
 		} else {
46
-		    $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.pilot_id IN ('".implode("','",$flt['pilots_id'])."')) sp ON sp.flightaware_id = spotter_archive_output.flightaware_id";
46
+		    $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.pilot_id IN ('".implode("','", $flt['pilots_id'])."')) sp ON sp.flightaware_id = spotter_archive_output.flightaware_id";
47 47
 		}
48 48
 	    }
49 49
 	    if (isset($flt['idents']) && !empty($flt['idents'])) {
50 50
 		if (isset($flt['source'])) {
51
-		    $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.ident IN ('".implode("','",$flt['idents'])."') AND spotter_archive_output.format_source IN ('".implode("','",$flt['source'])."')) spi ON spi.flightaware_id = spotter_archive_output.flightaware_id";
51
+		    $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.ident IN ('".implode("','", $flt['idents'])."') AND spotter_archive_output.format_source IN ('".implode("','", $flt['source'])."')) spi ON spi.flightaware_id = spotter_archive_output.flightaware_id";
52 52
 		} else {
53
-		    $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.ident IN ('".implode("','",$flt['idents'])."')) spi ON spi.flightaware_id = spotter_archive_output.flightaware_id";
53
+		    $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.ident IN ('".implode("','", $flt['idents'])."')) spi ON spi.flightaware_id = spotter_archive_output.flightaware_id";
54 54
 		}
55 55
 	    }
56 56
 	    if (isset($flt['registrations']) && !empty($flt['registrations'])) {
57 57
 		if (isset($flt['source'])) {
58
-		    $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.registration IN ('".implode("','",$flt['registrations'])."') AND spotter_archive_output.format_source IN ('".implode("','",$flt['source'])."')) sre ON sre.flightaware_id = spotter_archive_output.flightaware_id";
58
+		    $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.registration IN ('".implode("','", $flt['registrations'])."') AND spotter_archive_output.format_source IN ('".implode("','", $flt['source'])."')) sre ON sre.flightaware_id = spotter_archive_output.flightaware_id";
59 59
 		} else {
60
-		    $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.registration IN ('".implode("','",$flt['registrations'])."')) sre ON sre.flightaware_id = spotter_archive_output.flightaware_id";
60
+		    $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.registration IN ('".implode("','", $flt['registrations'])."')) sre ON sre.flightaware_id = spotter_archive_output.flightaware_id";
61 61
 		}
62 62
 	    }
63 63
 	    if ((isset($flt['airlines']) && empty($flt['airlines']) && isset($flt['pilots_id']) && empty($flt['pilots_id']) && isset($flt['idents']) && empty($flt['idents']) && isset($flt['registrations']) && empty($flt['registrations'])) || (!isset($flt['airlines']) && !isset($flt['pilots_id']) && !isset($flt['idents']) && !isset($flt['registrations']))) {
64 64
 		if (isset($flt['source'])) {
65
-		    $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_output.format_source IN ('".implode("','",$flt['source'])."')) saa ON saa.flightaware_id = spotter_archive_output.flightaware_id";
65
+		    $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_output.format_source IN ('".implode("','", $flt['source'])."')) saa ON saa.flightaware_id = spotter_archive_output.flightaware_id";
66 66
 		}
67 67
 	    }
68 68
 	}
69 69
 	if (isset($filter['airlines']) && !empty($filter['airlines'])) {
70 70
 	    if ($filter['airlines'][0] != '') {
71
-		$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) saf ON saf.flightaware_id = spotter_archive_output.flightaware_id";
71
+		$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','", $filter['airlines'])."')) saf ON saf.flightaware_id = spotter_archive_output.flightaware_id";
72 72
 	    }
73 73
 	}
74 74
 	
@@ -76,16 +76,16 @@  discard block
 block discarded – undo
76 76
 	    $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_archive_output.flightaware_id ";
77 77
 	}
78 78
 	if (isset($filter['pilots_id']) && !empty($filter['pilots_id'])) {
79
-	    $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.pilot_id IN ('".implode("','",$filter['pilots_id'])."')) spi ON spi.flightaware_id = spotter_archive_output.flightaware_id";
79
+	    $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.pilot_id IN ('".implode("','", $filter['pilots_id'])."')) spi ON spi.flightaware_id = spotter_archive_output.flightaware_id";
80 80
 	}
81 81
 	if (isset($filter['source']) && !empty($filter['source'])) {
82
-	    $filter_query_where .= " AND format_source IN ('".implode("','",$filter['source'])."')";
82
+	    $filter_query_where .= " AND format_source IN ('".implode("','", $filter['source'])."')";
83 83
 	}
84 84
 	if (isset($filter['ident']) && !empty($filter['ident'])) {
85 85
 	    $filter_query_where .= " AND ident = '".$filter['ident']."'";
86 86
 	}
87 87
 	if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
88
-		$filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
88
+		$filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')";
89 89
 	}
90 90
 	if ((isset($filter['year']) && $filter['year'] != '') || (isset($filter['month']) && $filter['month'] != '') || (isset($filter['day']) && $filter['day'] != '')) {
91 91
 	    $filter_query_date = '';
@@ -111,41 +111,41 @@  discard block
 block discarded – undo
111 111
 		    $filter_query_date .= " AND EXTRACT(DAY FROM spotter_archive_output.date) = '".$filter['day']."'";
112 112
 		}
113 113
 	    }
114
-	    $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output".preg_replace('/^ AND/',' WHERE',$filter_query_date).") sd ON sd.flightaware_id = spotter_archive_output.flightaware_id";
114
+	    $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output".preg_replace('/^ AND/', ' WHERE', $filter_query_date).") sd ON sd.flightaware_id = spotter_archive_output.flightaware_id";
115 115
 	}
116 116
 	if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE';
117 117
 	elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND';
118 118
 	if ($filter_query_where != '') {
119
-		$filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where);
119
+		$filter_query_where = preg_replace('/^ AND/', ' WHERE', $filter_query_where);
120 120
 	}
121 121
 	$filter_query = $filter_query_join.$filter_query_where;
122 122
 	return $filter_query;
123 123
     }
124 124
 
125 125
 	// Spotter_archive
126
-	public function 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 = '', $heading = '', $ground_speed = '', $squawk = '', $ModeS = '', $pilot_id = '', $pilot_name = '',$verticalrate = '',$format_source = '', $source_name = '', $over_country = '') {
126
+	public function 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 = '', $heading = '', $ground_speed = '', $squawk = '', $ModeS = '', $pilot_id = '', $pilot_name = '', $verticalrate = '', $format_source = '', $source_name = '', $over_country = '') {
127 127
 		require_once(dirname(__FILE__).'/class.Spotter.php');
128 128
 		if ($over_country == '') {
129 129
 			$Spotter = new Spotter($this->db);
130
-			$data_country = $Spotter->getCountryFromLatitudeLongitude($latitude,$longitude);
130
+			$data_country = $Spotter->getCountryFromLatitudeLongitude($latitude, $longitude);
131 131
 			if (!empty($data_country)) $country = $data_country['iso2'];
132 132
 			else $country = '';
133 133
 		} else $country = $over_country;
134
-		if ($airline_type === NULL) $airline_type ='';
134
+		if ($airline_type === NULL) $airline_type = '';
135 135
 	
136 136
 		//if ($country == '') echo "\n".'************ UNKNOW COUNTRY ****************'."\n";
137 137
 		//else echo "\n".'*/*/*/*/*/*/*/ Country : '.$country.' */*/*/*/*/*/*/*/*/'."\n";
138 138
 
139 139
 		// Route is not added in spotter_archive
140
-		$query  = "INSERT INTO spotter_archive (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, heading, ground_speed, squawk, ModeS, pilot_id, pilot_name, verticalrate,format_source,over_country,source_name)
140
+		$query = "INSERT INTO spotter_archive (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, heading, ground_speed, squawk, ModeS, pilot_id, pilot_name, verticalrate,format_source,over_country,source_name)
141 141
 		        VALUES (: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, :heading, :ground_speed, :squawk, :ModeS, :pilot_id, :pilot_name, :verticalrate, :format_source, :over_country, :source_name)";
142 142
 
143
-		$query_values = array(':flightaware_id' => $flightaware_id, ':ident' => $ident, ':registration' => $registration, ':airline_name' => $airline_name, ':airline_icao' => $airline_icao, ':airline_country' => $airline_country, ':airline_type' => $airline_type, ':aircraft_icao' => $aircraft_icao, ':aircraft_shadow' => $aircraft_shadow, ':aircraft_name' => $aircraft_name, ':aircraft_manufacturer' => $aircraft_manufacturer, ':departure_airport_icao' => $departure_airport_icao, ':departure_airport_name' => $departure_airport_name, ':departure_airport_city' => $departure_airport_city, ':departure_airport_country' => $departure_airport_country, ':departure_airport_time' => $departure_airport_time,':arrival_airport_icao' => $arrival_airport_icao, ':arrival_airport_name' => $arrival_airport_name, ':arrival_airport_city' => $arrival_airport_city, ':arrival_airport_country' => $arrival_airport_country, ':arrival_airport_time' => $arrival_airport_time, ':route_stop' => $route_stop, ':date' => $date,':latitude' => $latitude, ':longitude' => $longitude, ':waypoints' => $waypoints, ':altitude' => $altitude, ':heading' => $heading, ':ground_speed' => $ground_speed, ':squawk' => $squawk, ':ModeS' => $ModeS, ':pilot_id' => $pilot_id, ':pilot_name' => $pilot_name, ':verticalrate' => $verticalrate, ':format_source' => $format_source, ':over_country' => $country, ':source_name' => $source_name);
143
+		$query_values = array(':flightaware_id' => $flightaware_id, ':ident' => $ident, ':registration' => $registration, ':airline_name' => $airline_name, ':airline_icao' => $airline_icao, ':airline_country' => $airline_country, ':airline_type' => $airline_type, ':aircraft_icao' => $aircraft_icao, ':aircraft_shadow' => $aircraft_shadow, ':aircraft_name' => $aircraft_name, ':aircraft_manufacturer' => $aircraft_manufacturer, ':departure_airport_icao' => $departure_airport_icao, ':departure_airport_name' => $departure_airport_name, ':departure_airport_city' => $departure_airport_city, ':departure_airport_country' => $departure_airport_country, ':departure_airport_time' => $departure_airport_time, ':arrival_airport_icao' => $arrival_airport_icao, ':arrival_airport_name' => $arrival_airport_name, ':arrival_airport_city' => $arrival_airport_city, ':arrival_airport_country' => $arrival_airport_country, ':arrival_airport_time' => $arrival_airport_time, ':route_stop' => $route_stop, ':date' => $date, ':latitude' => $latitude, ':longitude' => $longitude, ':waypoints' => $waypoints, ':altitude' => $altitude, ':heading' => $heading, ':ground_speed' => $ground_speed, ':squawk' => $squawk, ':ModeS' => $ModeS, ':pilot_id' => $pilot_id, ':pilot_name' => $pilot_name, ':verticalrate' => $verticalrate, ':format_source' => $format_source, ':over_country' => $country, ':source_name' => $source_name);
144 144
 		try {
145 145
 			$sth = $this->db->prepare($query);
146 146
 			$sth->execute($query_values);
147 147
 			$sth->closeCursor();
148
-		} catch(PDOException $e) {
148
+		} catch (PDOException $e) {
149 149
 			return "error : ".$e->getMessage();
150 150
 		}
151 151
 		return "success";
@@ -165,9 +165,9 @@  discard block
 block discarded – undo
165 165
 
166 166
                 $ident = filter_var($ident, FILTER_SANITIZE_STRING);
167 167
                 //$query  = "SELECT spotter_archive.* FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.ident = :ident GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate LIMIT 1";
168
-                $query  = "SELECT spotter_archive.* FROM spotter_archive WHERE ident = :ident ORDER BY date DESC LIMIT 1";
168
+                $query = "SELECT spotter_archive.* FROM spotter_archive WHERE ident = :ident ORDER BY date DESC LIMIT 1";
169 169
 
170
-                $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident));
170
+                $spotter_array = $Spotter->getDataFromDB($query, array(':ident' => $ident));
171 171
 
172 172
                 return $spotter_array;
173 173
         }
@@ -186,7 +186,7 @@  discard block
 block discarded – undo
186 186
                 $id = filter_var($id, FILTER_SANITIZE_STRING);
187 187
                 //$query  = SpotterArchive->$global_query." WHERE spotter_archive.flightaware_id = :id";
188 188
                 //$query  = "SELECT spotter_archive.* FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.flightaware_id = :id GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate LIMIT 1";
189
-                $query  = "SELECT * FROM spotter_archive WHERE flightaware_id = :id ORDER BY date DESC LIMIT 1";
189
+                $query = "SELECT * FROM spotter_archive WHERE flightaware_id = :id ORDER BY date DESC LIMIT 1";
190 190
 
191 191
 //              $spotter_array = Spotter->getDataFromDB($query,array(':id' => $id));
192 192
                   /*
@@ -199,7 +199,7 @@  discard block
 block discarded – undo
199 199
                 }
200 200
                 $spotter_array = $sth->fetchAll(PDO->FETCH_ASSOC);
201 201
                 */
202
-                $spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id));
202
+                $spotter_array = $Spotter->getDataFromDB($query, array(':id' => $id));
203 203
 
204 204
                 return $spotter_array;
205 205
         }
@@ -214,14 +214,14 @@  discard block
 block discarded – undo
214 214
 	{
215 215
                 date_default_timezone_set('UTC');
216 216
                 $id = filter_var($id, FILTER_SANITIZE_STRING);
217
-                $query  = $this->global_query." WHERE spotter_archive.flightaware_id = :id ORDER BY date";
217
+                $query = $this->global_query." WHERE spotter_archive.flightaware_id = :id ORDER BY date";
218 218
 
219 219
 //              $spotter_array = Spotter->getDataFromDB($query,array(':id' => $id));
220 220
 
221 221
                 try {
222 222
                         $sth = $this->db->prepare($query);
223 223
                         $sth->execute(array(':id' => $id));
224
-                } catch(PDOException $e) {
224
+                } catch (PDOException $e) {
225 225
                         echo $e->getMessage();
226 226
                         die;
227 227
                 }
@@ -240,14 +240,14 @@  discard block
 block discarded – undo
240 240
         {
241 241
                 date_default_timezone_set('UTC');
242 242
                 $id = filter_var($id, FILTER_SANITIZE_STRING);
243
-                $query  = "SELECT spotter_archive.latitude, spotter_archive.longitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id";
243
+                $query = "SELECT spotter_archive.latitude, spotter_archive.longitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id";
244 244
 
245 245
 //              $spotter_array = Spotter->getDataFromDB($query,array(':id' => $id));
246 246
 
247 247
                 try {
248 248
                         $sth = $this->db->prepare($query);
249 249
                         $sth->execute(array(':id' => $id));
250
-                } catch(PDOException $e) {
250
+                } catch (PDOException $e) {
251 251
                         echo $e->getMessage();
252 252
                         die;
253 253
                 }
@@ -269,12 +269,12 @@  discard block
 block discarded – undo
269 269
                 date_default_timezone_set('UTC');
270 270
 
271 271
                 $ident = filter_var($ident, FILTER_SANITIZE_STRING);
272
-                $query  = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.ident = :ident AND spotter_archive.latitude <> 0 AND spotter_archive.longitude <> 0 ORDER BY date";
272
+                $query = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.ident = :ident AND spotter_archive.latitude <> 0 AND spotter_archive.longitude <> 0 ORDER BY date";
273 273
 
274 274
                 try {
275 275
                         $sth = $this->db->prepare($query);
276 276
                         $sth->execute(array(':ident' => $ident));
277
-                } catch(PDOException $e) {
277
+                } catch (PDOException $e) {
278 278
                         echo $e->getMessage();
279 279
                         die;
280 280
                 }
@@ -295,12 +295,12 @@  discard block
 block discarded – undo
295 295
                 date_default_timezone_set('UTC');
296 296
 
297 297
                 $id = filter_var($id, FILTER_SANITIZE_STRING);
298
-                $query  = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id AND spotter_archive.latitude <> 0 AND spotter_archive.longitude <> 0 ORDER BY date";
298
+                $query = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id AND spotter_archive.latitude <> 0 AND spotter_archive.longitude <> 0 ORDER BY date";
299 299
 
300 300
                 try {
301 301
                         $sth = $this->db->prepare($query);
302 302
                         $sth->execute(array(':id' => $id));
303
-                } catch(PDOException $e) {
303
+                } catch (PDOException $e) {
304 304
                         echo $e->getMessage();
305 305
                         die;
306 306
                 }
@@ -321,12 +321,12 @@  discard block
 block discarded – undo
321 321
                 date_default_timezone_set('UTC');
322 322
 
323 323
                 $id = filter_var($id, FILTER_SANITIZE_STRING);
324
-                $query  = "SELECT spotter_archive.altitude, spotter_archive.ground_speed, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id ORDER BY date";
324
+                $query = "SELECT spotter_archive.altitude, spotter_archive.ground_speed, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id ORDER BY date";
325 325
 
326 326
                 try {
327 327
                         $sth = $this->db->prepare($query);
328 328
                         $sth->execute(array(':id' => $id));
329
-                } catch(PDOException $e) {
329
+                } catch (PDOException $e) {
330 330
                         echo $e->getMessage();
331 331
                         die;
332 332
                 }
@@ -348,13 +348,13 @@  discard block
 block discarded – undo
348 348
                 date_default_timezone_set('UTC');
349 349
 
350 350
                 $ident = filter_var($ident, FILTER_SANITIZE_STRING);
351
-                $query  = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.ident = :ident GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate LIMIT 1";
351
+                $query = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.ident = :ident GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate LIMIT 1";
352 352
 //                $query  = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.ident = :ident";
353 353
 
354 354
                 try {
355 355
                         $sth = $this->db->prepare($query);
356 356
                         $sth->execute(array(':ident' => $ident));
357
-                } catch(PDOException $e) {
357
+                } catch (PDOException $e) {
358 358
                         echo $e->getMessage();
359 359
                         die;
360 360
                 }
@@ -371,13 +371,13 @@  discard block
 block discarded – undo
371 371
         * @return Array the spotter information
372 372
         *
373 373
         */
374
-        public function getSpotterArchiveData($ident,$flightaware_id,$date)
374
+        public function getSpotterArchiveData($ident, $flightaware_id, $date)
375 375
         {
376 376
     		$Spotter = new Spotter($this->db);
377 377
                 $ident = filter_var($ident, FILTER_SANITIZE_STRING);
378
-                $query  = "SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident AND l.flightaware_id = :flightaware_id AND l.date LIKE :date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate";
378
+                $query = "SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident AND l.flightaware_id = :flightaware_id AND l.date LIKE :date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate";
379 379
 
380
-                $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident,':flightaware_id' => $flightaware_id,':date' => $date.'%'));
380
+                $spotter_array = $Spotter->getDataFromDB($query, array(':ident' => $ident, ':flightaware_id' => $flightaware_id, ':date' => $date.'%'));
381 381
 
382 382
                 return $spotter_array;
383 383
         }
@@ -390,7 +390,7 @@  discard block
 block discarded – undo
390 390
                 try {
391 391
                         $sth = $this->db->prepare($query);
392 392
                         $sth->execute();
393
-                } catch(PDOException $e) {
393
+                } catch (PDOException $e) {
394 394
                         echo $e->getMessage();
395 395
                         die;
396 396
                 }
@@ -402,24 +402,24 @@  discard block
 block discarded – undo
402 402
         * @return Array the spotter information
403 403
         *
404 404
         */
405
-        public function getMinLiveSpotterData($begindate,$enddate,$filter = array())
405
+        public function getMinLiveSpotterData($begindate, $enddate, $filter = array())
406 406
         {
407 407
                 global $globalDBdriver, $globalLiveInterval;
408 408
                 date_default_timezone_set('UTC');
409 409
 
410 410
                 $filter_query = '';
411 411
                 if (isset($filter['source']) && !empty($filter['source'])) {
412
-                        $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') ";
412
+                        $filter_query .= " AND format_source IN ('".implode("','", $filter['source'])."') ";
413 413
                 }
414 414
                 // Use spotter_output also ?
415 415
                 if (isset($filter['airlines']) && !empty($filter['airlines'])) {
416
-                        $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id ";
416
+                        $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','", $filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id ";
417 417
                 }
418 418
                 if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) {
419 419
                         $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_archive.flightaware_id ";
420 420
                 }
421 421
                 if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
422
-                        $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
422
+                        $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')";
423 423
                 }
424 424
 
425 425
                 //if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
@@ -438,14 +438,14 @@  discard block
 block discarded – undo
438 438
 						GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id 
439 439
 				    AND spotter_archive.date = s.maxdate '.$filter_query.'LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON spotter_archive.aircraft_icao = a.icao';
440 440
 */
441
-			$query  = 'SELECT spotter_archive.date,spotter_archive.flightaware_id, spotter_archive.ident, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category 
441
+			$query = 'SELECT spotter_archive.date,spotter_archive.flightaware_id, spotter_archive.ident, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category 
442 442
 				    FROM spotter_archive 
443 443
 				    INNER JOIN (SELECT * FROM aircraft) a on spotter_archive.aircraft_icao = a.icao
444 444
 				    WHERE spotter_archive.date BETWEEN '."'".$begindate."'".' AND '."'".$begindate."'".' 
445 445
                         	    '.$filter_query.' ORDER BY flightaware_id';
446 446
                 } else {
447 447
                         //$query  = 'SELECT spotter_archive.ident, spotter_archive.flightaware_id, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk, a.aircraft_shadow FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate '.$filter_query.'INNER JOIN (SELECT * FROM aircraft) a on spotter_archive.aircraft_icao = a.icao';
448
-                        $query  = 'SELECT spotter_archive.date,spotter_archive.flightaware_id, spotter_archive.ident, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category 
448
+                        $query = 'SELECT spotter_archive.date,spotter_archive.flightaware_id, spotter_archive.ident, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category 
449 449
                         	    FROM spotter_archive 
450 450
                         	    INNER JOIN (SELECT * FROM aircraft) a on spotter_archive.aircraft_icao = a.icao
451 451
                         	    WHERE spotter_archive.date >= '."'".$begindate."'".' AND spotter_archive.date <= '."'".$enddate."'".'
@@ -455,7 +455,7 @@  discard block
 block discarded – undo
455 455
                 try {
456 456
                         $sth = $this->db->prepare($query);
457 457
                         $sth->execute();
458
-                } catch(PDOException $e) {
458
+                } catch (PDOException $e) {
459 459
                         echo $e->getMessage();
460 460
                         die;
461 461
                 }
@@ -470,24 +470,24 @@  discard block
 block discarded – undo
470 470
         * @return Array the spotter information
471 471
         *
472 472
         */
473
-        public function getMinLiveSpotterDataPlayback($begindate,$enddate,$filter = array())
473
+        public function getMinLiveSpotterDataPlayback($begindate, $enddate, $filter = array())
474 474
         {
475 475
                 global $globalDBdriver, $globalLiveInterval;
476 476
                 date_default_timezone_set('UTC');
477 477
 
478 478
                 $filter_query = '';
479 479
                 if (isset($filter['source']) && !empty($filter['source'])) {
480
-                        $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') ";
480
+                        $filter_query .= " AND format_source IN ('".implode("','", $filter['source'])."') ";
481 481
                 }
482 482
                 // Should use spotter_output also ?
483 483
                 if (isset($filter['airlines']) && !empty($filter['airlines'])) {
484
-                        $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id ";
484
+                        $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','", $filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id ";
485 485
                 }
486 486
                 if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) {
487 487
                         $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_archive.flightaware_id ";
488 488
                 }
489 489
                 if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
490
-                        $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
490
+                        $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')";
491 491
                 }
492 492
 
493 493
                 //if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
@@ -497,7 +497,7 @@  discard block
 block discarded – undo
497 497
                     		    FROM spotter_archive 
498 498
                     		    INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE (l.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate '.$filter_query.'LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON spotter_archive.aircraft_icao = a.icao';
499 499
 			*/
500
-			$query  = 'SELECT a.aircraft_shadow, spotter_archive_output.ident, spotter_archive_output.flightaware_id, spotter_archive_output.aircraft_icao, spotter_archive_output.departure_airport_icao as departure_airport, spotter_archive_output.arrival_airport_icao as arrival_airport, spotter_archive_output.latitude, spotter_archive_output.longitude, spotter_archive_output.altitude, spotter_archive_output.heading, spotter_archive_output.ground_speed, spotter_archive_output.squawk 
500
+			$query = 'SELECT a.aircraft_shadow, spotter_archive_output.ident, spotter_archive_output.flightaware_id, spotter_archive_output.aircraft_icao, spotter_archive_output.departure_airport_icao as departure_airport, spotter_archive_output.arrival_airport_icao as arrival_airport, spotter_archive_output.latitude, spotter_archive_output.longitude, spotter_archive_output.altitude, spotter_archive_output.heading, spotter_archive_output.ground_speed, spotter_archive_output.squawk 
501 501
 				    FROM spotter_archive_output 
502 502
 				    LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON spotter_archive_output.aircraft_icao = a.icao 
503 503
 				    WHERE (spotter_archive_output.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') 
@@ -512,7 +512,7 @@  discard block
 block discarded – undo
512 512
                         	    WHERE spotter_archive_output.date >= '."'".$begindate."'".' AND spotter_archive_output.date <= '."'".$enddate."'".'
513 513
                         	    '.$filter_query.' GROUP BY spotter_archive_output.flightaware_id, spotter_archive_output.ident, spotter_archive_output.aircraft_icao, spotter_archive_output.departure_airport_icao, spotter_archive_output.arrival_airport_icao, spotter_archive_output.latitude, spotter_archive_output.longitude, spotter_archive_output.altitude, spotter_archive_output.heading, spotter_archive_output.ground_speed, spotter_archive_output.squawk, a.aircraft_shadow';
514 514
                         */
515
-                        $query  = 'SELECT DISTINCT spotter_archive_output.flightaware_id, spotter_archive_output.ident, spotter_archive_output.aircraft_icao, spotter_archive_output.departure_airport_icao as departure_airport, spotter_archive_output.arrival_airport_icao as arrival_airport, spotter_archive_output.latitude, spotter_archive_output.longitude, spotter_archive_output.altitude, spotter_archive_output.heading, spotter_archive_output.ground_speed, spotter_archive_output.squawk, a.aircraft_shadow
515
+                        $query = 'SELECT DISTINCT spotter_archive_output.flightaware_id, spotter_archive_output.ident, spotter_archive_output.aircraft_icao, spotter_archive_output.departure_airport_icao as departure_airport, spotter_archive_output.arrival_airport_icao as arrival_airport, spotter_archive_output.latitude, spotter_archive_output.longitude, spotter_archive_output.altitude, spotter_archive_output.heading, spotter_archive_output.ground_speed, spotter_archive_output.squawk, a.aircraft_shadow
516 516
                         	    FROM spotter_archive_output 
517 517
                         	    INNER JOIN (SELECT * FROM aircraft) a on spotter_archive_output.aircraft_icao = a.icao
518 518
                         	    WHERE spotter_archive_output.date >= '."'".$begindate."'".' AND spotter_archive_output.date <= '."'".$enddate."'".'
@@ -524,7 +524,7 @@  discard block
 block discarded – undo
524 524
                 try {
525 525
                         $sth = $this->db->prepare($query);
526 526
                         $sth->execute();
527
-                } catch(PDOException $e) {
527
+                } catch (PDOException $e) {
528 528
                         echo $e->getMessage();
529 529
                         die;
530 530
                 }
@@ -539,23 +539,23 @@  discard block
 block discarded – undo
539 539
         * @return Array the spotter information
540 540
         *
541 541
         */
542
-        public function getLiveSpotterCount($begindate,$enddate,$filter = array())
542
+        public function getLiveSpotterCount($begindate, $enddate, $filter = array())
543 543
         {
544 544
                 global $globalDBdriver, $globalLiveInterval;
545 545
                 date_default_timezone_set('UTC');
546 546
 
547 547
                 $filter_query = '';
548 548
                 if (isset($filter['source']) && !empty($filter['source'])) {
549
-                        $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') ";
549
+                        $filter_query .= " AND format_source IN ('".implode("','", $filter['source'])."') ";
550 550
                 }
551 551
                 if (isset($filter['airlines']) && !empty($filter['airlines'])) {
552
-                        $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id ";
552
+                        $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','", $filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id ";
553 553
                 }
554 554
                 if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) {
555 555
                         $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_archive.flightaware_id ";
556 556
                 }
557 557
                 if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
558
-                        $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
558
+                        $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')";
559 559
                 }
560 560
 
561 561
                 //if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
@@ -570,7 +570,7 @@  discard block
 block discarded – undo
570 570
                 try {
571 571
                         $sth = $this->db->prepare($query);
572 572
                         $sth->execute();
573
-                } catch(PDOException $e) {
573
+                } catch (PDOException $e) {
574 574
                         echo $e->getMessage();
575 575
                         die;
576 576
                 }
@@ -590,7 +590,7 @@  discard block
 block discarded – undo
590 590
     * @return Array the spotter information
591 591
     *
592 592
     */
593
-    public function searchSpotterData($q = '', $registration = '', $aircraft_icao = '', $aircraft_manufacturer = '', $highlights = '', $airline_icao = '', $airline_country = '', $airline_type = '', $airport = '', $airport_country = '', $callsign = '', $departure_airport_route = '', $arrival_airport_route = '', $owner = '',$pilot_id = '',$pilot_name = '',$altitude = '', $date_posted = '', $limit = '', $sort = '', $includegeodata = '',$origLat = '',$origLon = '',$dist = '', $filters=array())
593
+    public function searchSpotterData($q = '', $registration = '', $aircraft_icao = '', $aircraft_manufacturer = '', $highlights = '', $airline_icao = '', $airline_country = '', $airline_type = '', $airport = '', $airport_country = '', $callsign = '', $departure_airport_route = '', $arrival_airport_route = '', $owner = '', $pilot_id = '', $pilot_name = '', $altitude = '', $date_posted = '', $limit = '', $sort = '', $includegeodata = '', $origLat = '', $origLon = '', $dist = '', $filters = array())
594 594
     {
595 595
 	global $globalTimezone, $globalDBdriver;
596 596
 	require_once(dirname(__FILE__).'/class.Translation.php');
@@ -612,7 +612,7 @@  discard block
 block discarded – undo
612 612
 	        
613 613
 		$q_array = explode(" ", $q);
614 614
 		
615
-		foreach ($q_array as $q_item){
615
+		foreach ($q_array as $q_item) {
616 616
 		    $additional_query .= " AND (";
617 617
 		    $additional_query .= "(spotter_archive_output.spotter_id like '%".$q_item."%') OR ";
618 618
 		    $additional_query .= "(spotter_archive_output.aircraft_icao like '%".$q_item."%') OR ";
@@ -644,7 +644,7 @@  discard block
 block discarded – undo
644 644
 	
645 645
 	if ($registration != "")
646 646
 	{
647
-	    $registration = filter_var($registration,FILTER_SANITIZE_STRING);
647
+	    $registration = filter_var($registration, FILTER_SANITIZE_STRING);
648 648
 	    if (!is_string($registration))
649 649
 	    {
650 650
 		return false;
@@ -655,7 +655,7 @@  discard block
 block discarded – undo
655 655
 	
656 656
 	if ($aircraft_icao != "")
657 657
 	{
658
-	    $aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING);
658
+	    $aircraft_icao = filter_var($aircraft_icao, FILTER_SANITIZE_STRING);
659 659
 	    if (!is_string($aircraft_icao))
660 660
 	    {
661 661
 		return false;
@@ -666,7 +666,7 @@  discard block
 block discarded – undo
666 666
 	
667 667
 	if ($aircraft_manufacturer != "")
668 668
 	{
669
-	    $aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING);
669
+	    $aircraft_manufacturer = filter_var($aircraft_manufacturer, FILTER_SANITIZE_STRING);
670 670
 	    if (!is_string($aircraft_manufacturer))
671 671
 	    {
672 672
 		return false;
@@ -687,7 +687,7 @@  discard block
 block discarded – undo
687 687
 	
688 688
 	if ($airline_icao != "")
689 689
 	{
690
-	    $airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING);
690
+	    $airline_icao = filter_var($airline_icao, FILTER_SANITIZE_STRING);
691 691
 	    if (!is_string($airline_icao))
692 692
 	    {
693 693
 		return false;
@@ -698,7 +698,7 @@  discard block
 block discarded – undo
698 698
 	
699 699
 	if ($airline_country != "")
700 700
 	{
701
-	    $airline_country = filter_var($airline_country,FILTER_SANITIZE_STRING);
701
+	    $airline_country = filter_var($airline_country, FILTER_SANITIZE_STRING);
702 702
 	    if (!is_string($airline_country))
703 703
 	    {
704 704
 		return false;
@@ -709,7 +709,7 @@  discard block
 block discarded – undo
709 709
 	
710 710
 	if ($airline_type != "")
711 711
 	{
712
-	    $airline_type = filter_var($airline_type,FILTER_SANITIZE_STRING);
712
+	    $airline_type = filter_var($airline_type, FILTER_SANITIZE_STRING);
713 713
 	    if (!is_string($airline_type))
714 714
 	    {
715 715
 		return false;
@@ -731,7 +731,7 @@  discard block
 block discarded – undo
731 731
 	
732 732
 	if ($airport != "")
733 733
 	{
734
-	    $airport = filter_var($airport,FILTER_SANITIZE_STRING);
734
+	    $airport = filter_var($airport, FILTER_SANITIZE_STRING);
735 735
 	    if (!is_string($airport))
736 736
 	    {
737 737
 		return false;
@@ -742,7 +742,7 @@  discard block
 block discarded – undo
742 742
 	
743 743
 	if ($airport_country != "")
744 744
 	{
745
-	    $airport_country = filter_var($airport_country,FILTER_SANITIZE_STRING);
745
+	    $airport_country = filter_var($airport_country, FILTER_SANITIZE_STRING);
746 746
 	    if (!is_string($airport_country))
747 747
 	    {
748 748
 		return false;
@@ -753,7 +753,7 @@  discard block
 block discarded – undo
753 753
     
754 754
 	if ($callsign != "")
755 755
 	{
756
-	    $callsign = filter_var($callsign,FILTER_SANITIZE_STRING);
756
+	    $callsign = filter_var($callsign, FILTER_SANITIZE_STRING);
757 757
 	    if (!is_string($callsign))
758 758
 	    {
759 759
 		return false;
@@ -761,7 +761,7 @@  discard block
 block discarded – undo
761 761
 		$translate = $Translation->ident2icao($callsign);
762 762
 		if ($translate != $callsign) {
763 763
 			$additional_query .= " AND (spotter_archive_output.ident = :callsign OR spotter_archive_output.ident = :translate)";
764
-			$query_values = array_merge($query_values,array(':callsign' => $callsign,':translate' => $translate));
764
+			$query_values = array_merge($query_values, array(':callsign' => $callsign, ':translate' => $translate));
765 765
 		} else {
766 766
 			$additional_query .= " AND (spotter_archive_output.ident = '".$callsign."')";
767 767
 		}
@@ -770,7 +770,7 @@  discard block
 block discarded – undo
770 770
 
771 771
 	if ($owner != "")
772 772
 	{
773
-	    $owner = filter_var($owner,FILTER_SANITIZE_STRING);
773
+	    $owner = filter_var($owner, FILTER_SANITIZE_STRING);
774 774
 	    if (!is_string($owner))
775 775
 	    {
776 776
 		return false;
@@ -781,7 +781,7 @@  discard block
 block discarded – undo
781 781
 
782 782
 	if ($pilot_name != "")
783 783
 	{
784
-	    $pilot_name = filter_var($pilot_name,FILTER_SANITIZE_STRING);
784
+	    $pilot_name = filter_var($pilot_name, FILTER_SANITIZE_STRING);
785 785
 	    if (!is_string($pilot_name))
786 786
 	    {
787 787
 		return false;
@@ -792,7 +792,7 @@  discard block
 block discarded – undo
792 792
 	
793 793
 	if ($pilot_id != "")
794 794
 	{
795
-	    $pilot_id = filter_var($pilot_id,FILTER_SANITIZE_NUMBER_INT);
795
+	    $pilot_id = filter_var($pilot_id, FILTER_SANITIZE_NUMBER_INT);
796 796
 	    if (!is_string($pilot_id))
797 797
 	    {
798 798
 		return false;
@@ -803,7 +803,7 @@  discard block
 block discarded – undo
803 803
 	
804 804
 	if ($departure_airport_route != "")
805 805
 	{
806
-	    $departure_airport_route = filter_var($departure_airport_route,FILTER_SANITIZE_STRING);
806
+	    $departure_airport_route = filter_var($departure_airport_route, FILTER_SANITIZE_STRING);
807 807
 	    if (!is_string($departure_airport_route))
808 808
 	    {
809 809
 		return false;
@@ -814,7 +814,7 @@  discard block
 block discarded – undo
814 814
 	
815 815
 	if ($arrival_airport_route != "")
816 816
 	{
817
-	    $arrival_airport_route = filter_var($arrival_airport_route,FILTER_SANITIZE_STRING);
817
+	    $arrival_airport_route = filter_var($arrival_airport_route, FILTER_SANITIZE_STRING);
818 818
 	    if (!is_string($arrival_airport_route))
819 819
 	    {
820 820
 		return false;
@@ -827,8 +827,8 @@  discard block
 block discarded – undo
827 827
 	{
828 828
 	    $altitude_array = explode(",", $altitude);
829 829
 	    
830
-	    $altitude_array[0] = filter_var($altitude_array[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
831
-	    $altitude_array[1] = filter_var($altitude_array[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
830
+	    $altitude_array[0] = filter_var($altitude_array[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
831
+	    $altitude_array[1] = filter_var($altitude_array[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
832 832
 	    
833 833
 
834 834
 	    if ($altitude_array[1] != "")
@@ -846,8 +846,8 @@  discard block
 block discarded – undo
846 846
 	{
847 847
 	    $date_array = explode(",", $date_posted);
848 848
 	    
849
-	    $date_array[0] = filter_var($date_array[0],FILTER_SANITIZE_STRING);
850
-	    $date_array[1] = filter_var($date_array[1],FILTER_SANITIZE_STRING);
849
+	    $date_array[0] = filter_var($date_array[0], FILTER_SANITIZE_STRING);
850
+	    $date_array[1] = filter_var($date_array[1], FILTER_SANITIZE_STRING);
851 851
 	    
852 852
 	    if ($globalTimezone != '') {
853 853
 		date_default_timezone_set($globalTimezone);
@@ -879,8 +879,8 @@  discard block
 block discarded – undo
879 879
 	{
880 880
 	    $limit_array = explode(",", $limit);
881 881
 	    
882
-	    $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
883
-	    $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
882
+	    $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
883
+	    $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
884 884
 	    
885 885
 	    if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
886 886
 	    {
@@ -891,8 +891,8 @@  discard block
 block discarded – undo
891 891
 	
892 892
 
893 893
 	if ($origLat != "" && $origLon != "" && $dist != "") {
894
-		$dist = number_format($dist*0.621371,2,'.','');
895
-		$query="SELECT spotter_archive_output.*, 3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - ABS(CAST(spotter_archive.latitude as double precision)))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(ABS(CAST(spotter_archive.latitude as double precision))*pi()/180)*POWER(SIN(($origLon-CAST(spotter_archive.longitude as double precision))*pi()/180/2),2))) as distance 
894
+		$dist = number_format($dist*0.621371, 2, '.', '');
895
+		$query = "SELECT spotter_archive_output.*, 3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - ABS(CAST(spotter_archive.latitude as double precision)))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(ABS(CAST(spotter_archive.latitude as double precision))*pi()/180)*POWER(SIN(($origLon-CAST(spotter_archive.longitude as double precision))*pi()/180/2),2))) as distance 
896 896
                           FROM spotter_archive_output, spotter_archive WHERE spotter_output_archive.flightaware_id = spotter_archive.flightaware_id AND spotter_output.ident <> '' ".$additional_query."AND CAST(spotter_archive.longitude as double precision) between ($origLon-$dist/ABS(cos(radians($origLat))*69)) and ($origLon+$dist/ABS(cos(radians($origLat))*69)) and CAST(spotter_archive.latitude as double precision) between ($origLat-($dist/69)) and ($origLat+($dist/69)) 
897 897
                           AND (3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - ABS(CAST(spotter_archive.latitude as double precision)))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(ABS(CAST(spotter_archive.latitude as double precision))*pi()/180)*POWER(SIN(($origLon-CAST(spotter_archive.longitude as double precision))*pi()/180/2),2)))) < $dist".$filter_query." ORDER BY distance";
898 898
 	} else {
@@ -909,12 +909,12 @@  discard block
 block discarded – undo
909 909
 			$additional_query .= " AND (spotter_archive_output.waypoints <> '')";
910 910
 		}
911 911
 
912
-		$query  = "SELECT spotter_archive_output.* FROM spotter_archive_output 
912
+		$query = "SELECT spotter_archive_output.* FROM spotter_archive_output 
913 913
 		    WHERE spotter_archive_output.ident <> '' 
914 914
 		    ".$additional_query."
915 915
 		    ".$filter_query.$orderby_query;
916 916
 	}
917
-	$spotter_array = $Spotter->getDataFromDB($query, $query_values,$limit_query);
917
+	$spotter_array = $Spotter->getDataFromDB($query, $query_values, $limit_query);
918 918
 
919 919
 	return $spotter_array;
920 920
     }
@@ -931,7 +931,7 @@  discard block
 block discarded – undo
931 931
                 try {
932 932
                         $sth = $this->db->prepare($query);
933 933
                         $sth->execute();
934
-                } catch(PDOException $e) {
934
+                } catch (PDOException $e) {
935 935
                         return "error";
936 936
                 }
937 937
 	}
@@ -968,8 +968,8 @@  discard block
 block discarded – undo
968 968
 	{
969 969
 	    $limit_array = explode(",", $limit);
970 970
 	    
971
-	    $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
972
-	    $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
971
+	    $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
972
+	    $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
973 973
 	    
974 974
 	    if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
975 975
 	    {
@@ -1010,7 +1010,7 @@  discard block
 block discarded – undo
1010 1010
 	$query_values = array();
1011 1011
 	$limit_query = '';
1012 1012
 	$additional_query = '';
1013
-	$filter_query = $this->getFilter($filter,true,true);
1013
+	$filter_query = $this->getFilter($filter, true, true);
1014 1014
 	
1015 1015
 	if ($owner != "")
1016 1016
 	{
@@ -1027,8 +1027,8 @@  discard block
 block discarded – undo
1027 1027
 	{
1028 1028
 	    $limit_array = explode(",", $limit);
1029 1029
 	    
1030
-	    $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1031
-	    $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1030
+	    $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
1031
+	    $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
1032 1032
 	    
1033 1033
 	    if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1034 1034
 	    {
@@ -1068,7 +1068,7 @@  discard block
 block discarded – undo
1068 1068
 	$query_values = array();
1069 1069
 	$limit_query = '';
1070 1070
 	$additional_query = '';
1071
-	$filter_query = $this->getFilter($filter,true,true);
1071
+	$filter_query = $this->getFilter($filter, true, true);
1072 1072
 	
1073 1073
 	if ($pilot != "")
1074 1074
 	{
@@ -1080,8 +1080,8 @@  discard block
 block discarded – undo
1080 1080
 	{
1081 1081
 	    $limit_array = explode(",", $limit);
1082 1082
 	    
1083
-	    $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1084
-	    $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1083
+	    $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
1084
+	    $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
1085 1085
 	    
1086 1086
 	    if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1087 1087
 	    {
@@ -1111,7 +1111,7 @@  discard block
 block discarded – undo
1111 1111
     * @return Array the airline country list
1112 1112
     *
1113 1113
     */
1114
-    public function countAllFlightOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '')
1114
+    public function countAllFlightOverCountries($limit = true, $olderthanmonths = 0, $sincedate = '')
1115 1115
     {
1116 1116
 	global $globalDBdriver;
1117 1117
 	/*
@@ -1140,7 +1140,7 @@  discard block
 block discarded – undo
1140 1140
 	$flight_array = array();
1141 1141
 	$temp_array = array();
1142 1142
         
1143
-	while($row = $sth->fetch(PDO::FETCH_ASSOC))
1143
+	while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1144 1144
 	{
1145 1145
 	    $temp_array['flight_count'] = $row['nb'];
1146 1146
 	    $temp_array['flight_country'] = $row['name'];
@@ -1157,7 +1157,7 @@  discard block
 block discarded – undo
1157 1157
     * @return Array the airline country list
1158 1158
     *
1159 1159
     */
1160
-    public function countAllFlightOverCountriesByAirlines($limit = true,$olderthanmonths = 0,$sincedate = '')
1160
+    public function countAllFlightOverCountriesByAirlines($limit = true, $olderthanmonths = 0, $sincedate = '')
1161 1161
     {
1162 1162
 	global $globalDBdriver;
1163 1163
 	/*
@@ -1186,7 +1186,7 @@  discard block
 block discarded – undo
1186 1186
 	$flight_array = array();
1187 1187
 	$temp_array = array();
1188 1188
         
1189
-	while($row = $sth->fetch(PDO::FETCH_ASSOC))
1189
+	while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1190 1190
 	{
1191 1191
 	    $temp_array['airline_icao'] = $row['airline_icao'];
1192 1192
 	    $temp_array['flight_count'] = $row['nb'];
@@ -1204,14 +1204,14 @@  discard block
 block discarded – undo
1204 1204
     * @return Array the spotter information
1205 1205
     *
1206 1206
     */
1207
-    public function getDateArchiveSpotterDataById($id,$date)
1207
+    public function getDateArchiveSpotterDataById($id, $date)
1208 1208
     {
1209 1209
 	$Spotter = new Spotter($this->db);
1210 1210
 	date_default_timezone_set('UTC');
1211 1211
 	$id = filter_var($id, FILTER_SANITIZE_STRING);
1212
-	$query  = 'SELECT spotter_archive.* FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.flightaware_id = :id AND l.date <= :date GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate ORDER BY spotter_archive.date DESC';
1213
-	$date = date('c',$date);
1214
-	$spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id,':date' => $date));
1212
+	$query = 'SELECT spotter_archive.* FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.flightaware_id = :id AND l.date <= :date GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate ORDER BY spotter_archive.date DESC';
1213
+	$date = date('c', $date);
1214
+	$spotter_array = $Spotter->getDataFromDB($query, array(':id' => $id, ':date' => $date));
1215 1215
 	return $spotter_array;
1216 1216
     }
1217 1217
 
@@ -1221,14 +1221,14 @@  discard block
 block discarded – undo
1221 1221
     * @return Array the spotter information
1222 1222
     *
1223 1223
     */
1224
-    public function getDateArchiveSpotterDataByIdent($ident,$date)
1224
+    public function getDateArchiveSpotterDataByIdent($ident, $date)
1225 1225
     {
1226 1226
 	$Spotter = new Spotter($this->db);
1227 1227
 	date_default_timezone_set('UTC');
1228 1228
 	$ident = filter_var($ident, FILTER_SANITIZE_STRING);
1229
-	$query  = 'SELECT spotter_archive.* FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate ORDER BY spotter_archive.date DESC';
1230
-	$date = date('c',$date);
1231
-	$spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident,':date' => $date));
1229
+	$query = 'SELECT spotter_archive.* FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate ORDER BY spotter_archive.date DESC';
1230
+	$date = date('c', $date);
1231
+	$spotter_array = $Spotter->getDataFromDB($query, array(':ident' => $ident, ':date' => $date));
1232 1232
 	return $spotter_array;
1233 1233
     }
1234 1234
 
@@ -1238,7 +1238,7 @@  discard block
 block discarded – undo
1238 1238
     * @return Array the spotter information
1239 1239
     *
1240 1240
     */
1241
-    public function getSpotterDataByAirport($airport = '', $limit = '', $sort = '',$filters = array())
1241
+    public function getSpotterDataByAirport($airport = '', $limit = '', $sort = '', $filters = array())
1242 1242
     {
1243 1243
 	global $global_query;
1244 1244
 	$Spotter = new Spotter();
@@ -1246,7 +1246,7 @@  discard block
 block discarded – undo
1246 1246
 	$query_values = array();
1247 1247
 	$limit_query = '';
1248 1248
 	$additional_query = '';
1249
-	$filter_query = $this->getFilter($filters,true,true);
1249
+	$filter_query = $this->getFilter($filters, true, true);
1250 1250
 	
1251 1251
 	if ($airport != "")
1252 1252
 	{
@@ -1263,8 +1263,8 @@  discard block
 block discarded – undo
1263 1263
 	{
1264 1264
 	    $limit_array = explode(",", $limit);
1265 1265
 	    
1266
-	    $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1267
-	    $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1266
+	    $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
1267
+	    $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
1268 1268
 	    
1269 1269
 	    if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1270 1270
 	    {
Please login to merge, or discard this patch.
owner-detailed.php 2 patches
Spacing   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -7,14 +7,14 @@  discard block
 block discarded – undo
7 7
 //require_once('require/class.SpotterLive.php');
8 8
 require_once('require/class.SpotterArchive.php');
9 9
 
10
-if (!isset($_GET['owner'])){
10
+if (!isset($_GET['owner'])) {
11 11
 	header('Location: '.$globalURL.'');
12 12
 } else {
13 13
 	$Spotter = new Spotter();
14 14
 	$SpotterArchive = new SpotterArchive();
15 15
 	//$Translation = new Translation();
16 16
 	//calculuation for the pagination
17
-	if(!isset($_GET['limit']))
17
+	if (!isset($_GET['limit']))
18 18
 	{
19 19
 		$limit_start = 0;
20 20
 		$limit_end = 25;
@@ -35,29 +35,29 @@  discard block
 block discarded – undo
35 35
 	
36 36
 	$page_url = $globalURL.'/owner/'.$_GET['owner'];
37 37
 	
38
-	$owner = filter_input(INPUT_GET,'owner',FILTER_SANITIZE_STRING);
39
-	$sort = filter_input(INPUT_GET,'sort',FILTER_SANITIZE_STRING);
40
-	$year = filter_input(INPUT_GET,'year',FILTER_SANITIZE_NUMBER_INT);
41
-	$month = filter_input(INPUT_GET,'month',FILTER_SANITIZE_NUMBER_INT);
38
+	$owner = filter_input(INPUT_GET, 'owner', FILTER_SANITIZE_STRING);
39
+	$sort = filter_input(INPUT_GET, 'sort', FILTER_SANITIZE_STRING);
40
+	$year = filter_input(INPUT_GET, 'year', FILTER_SANITIZE_NUMBER_INT);
41
+	$month = filter_input(INPUT_GET, 'month', FILTER_SANITIZE_NUMBER_INT);
42 42
 	$filter = array();
43
-	if ($year != '') $filter = array_merge($filter,array('year' => $year));
44
-	if ($month != '') $filter = array_merge($filter,array('month' => $month));
43
+	if ($year != '') $filter = array_merge($filter, array('year' => $year));
44
+	if ($month != '') $filter = array_merge($filter, array('month' => $month));
45 45
 	if ($sort != '') 
46 46
 	{
47
-		$spotter_array = $Spotter->getSpotterDataByOwner($owner,$limit_start.",".$absolute_difference, $sort,$filter);
47
+		$spotter_array = $Spotter->getSpotterDataByOwner($owner, $limit_start.",".$absolute_difference, $sort, $filter);
48 48
 		if (empty($spotter_array)) {
49
-			$spotter_array = $SpotterArchive->getSpotterDataByOwner($owner,$limit_start.",".$absolute_difference, $sort,$filter);
49
+			$spotter_array = $SpotterArchive->getSpotterDataByOwner($owner, $limit_start.",".$absolute_difference, $sort, $filter);
50 50
 		}
51 51
 	} else {
52
-		$spotter_array = $Spotter->getSpotterDataByOwner($owner,$limit_start.",".$absolute_difference,'',$filter);
52
+		$spotter_array = $Spotter->getSpotterDataByOwner($owner, $limit_start.",".$absolute_difference, '', $filter);
53 53
 		if (empty($spotter_array)) {
54
-			$spotter_array = $SpotterArchive->getSpotterDataByOwner($owner,$limit_start.",".$absolute_difference,'',$filter);
54
+			$spotter_array = $SpotterArchive->getSpotterDataByOwner($owner, $limit_start.",".$absolute_difference, '', $filter);
55 55
 		}
56 56
 	}
57 57
 
58 58
 	if (!empty($spotter_array))
59 59
 	{
60
-		$title = sprintf(_("Detailed View for %s"),$spotter_array[0]['aircraft_owner']);
60
+		$title = sprintf(_("Detailed View for %s"), $spotter_array[0]['aircraft_owner']);
61 61
 		//$ident = $spotter_array[0]['ident'];
62 62
 		if (isset($spotter_array[0]['latitude'])) $latitude = $spotter_array[0]['latitude'];
63 63
 		if (isset($spotter_array[0]['longitude'])) $longitude = $spotter_array[0]['longitude'];
@@ -117,23 +117,23 @@  discard block
 block discarded – undo
117 117
 		$Stats = new Stats();
118 118
 		if ($year == '' && $month == '') $flights = $Stats->getStatsOwner($owner);
119 119
 		else $flights = 0;
120
-		if ($flights == 0) $flights = $Spotter->countFlightsByOwner($owner,$filter);
120
+		if ($flights == 0) $flights = $Spotter->countFlightsByOwner($owner, $filter);
121 121
 		print '<div><span class="label">'._("Flights").'</span>'.$flights.'</div>';
122
-		$aircraft_type = count($Spotter->countAllAircraftTypesByOwner($owner,$filter));
122
+		$aircraft_type = count($Spotter->countAllAircraftTypesByOwner($owner, $filter));
123 123
 		print '<div><span class="label">'._("Aircrafts type").'</span>'.$aircraft_type.'</div>';
124
-		$aircraft_registration = count($Spotter->countAllAircraftRegistrationByOwner($owner,$filter));
124
+		$aircraft_registration = count($Spotter->countAllAircraftRegistrationByOwner($owner, $filter));
125 125
 		print '<div><span class="label">'._("Aircrafts").'</span>'.$aircraft_registration.'</div>';
126
-		$aircraft_manufacturer = count($Spotter->countAllAircraftManufacturerByOwner($owner,$filter));
126
+		$aircraft_manufacturer = count($Spotter->countAllAircraftManufacturerByOwner($owner, $filter));
127 127
 		print '<div><span class="label">'._("Manufacturers").'</span>'.$aircraft_manufacturer.'</div>';
128
-		$airlines = count($Spotter->countAllAirlinesByOwner($owner,$filter));
128
+		$airlines = count($Spotter->countAllAirlinesByOwner($owner, $filter));
129 129
 		print '<div><span class="label">'._("Airlines").'</span>'.$airlines.'</div>';
130
-		$duration = $Spotter->getFlightDurationByOwner($owner,$filter);
130
+		$duration = $Spotter->getFlightDurationByOwner($owner, $filter);
131 131
 		if ($duration != '0') print '<div><span class="label">'._("Total flights spotted duration").'</span>'.$duration.'</div>';
132 132
 		print '</div>';
133 133
 	
134 134
 		include('owner-sub-menu.php');
135 135
 		print '<div class="table column">';
136
-		print '<p>'.sprintf(_("The table below shows the detailed information of all flights with the owner <strong>%s</strong>."),$spotter_array[0]['aircraft_owner']).'</p>';
136
+		print '<p>'.sprintf(_("The table below shows the detailed information of all flights with the owner <strong>%s</strong>."), $spotter_array[0]['aircraft_owner']).'</p>';
137 137
 
138 138
 		include('table-output.php'); 
139 139
 		print '<div class="pagination">';
Please login to merge, or discard this patch.
Braces   +23 added lines, -8 removed lines patch added patch discarded remove patch
@@ -40,8 +40,12 @@  discard block
 block discarded – undo
40 40
 	$year = filter_input(INPUT_GET,'year',FILTER_SANITIZE_NUMBER_INT);
41 41
 	$month = filter_input(INPUT_GET,'month',FILTER_SANITIZE_NUMBER_INT);
42 42
 	$filter = array();
43
-	if ($year != '') $filter = array_merge($filter,array('year' => $year));
44
-	if ($month != '') $filter = array_merge($filter,array('month' => $month));
43
+	if ($year != '') {
44
+		$filter = array_merge($filter,array('year' => $year));
45
+	}
46
+	if ($month != '') {
47
+		$filter = array_merge($filter,array('month' => $month));
48
+	}
45 49
 	if ($sort != '') 
46 50
 	{
47 51
 		$spotter_array = $Spotter->getSpotterDataByOwner($owner,$limit_start.",".$absolute_difference, $sort,$filter);
@@ -59,8 +63,12 @@  discard block
 block discarded – undo
59 63
 	{
60 64
 		$title = sprintf(_("Detailed View for %s"),$spotter_array[0]['aircraft_owner']);
61 65
 		//$ident = $spotter_array[0]['ident'];
62
-		if (isset($spotter_array[0]['latitude'])) $latitude = $spotter_array[0]['latitude'];
63
-		if (isset($spotter_array[0]['longitude'])) $longitude = $spotter_array[0]['longitude'];
66
+		if (isset($spotter_array[0]['latitude'])) {
67
+			$latitude = $spotter_array[0]['latitude'];
68
+		}
69
+		if (isset($spotter_array[0]['longitude'])) {
70
+			$longitude = $spotter_array[0]['longitude'];
71
+		}
64 72
 		require_once('header.php');
65 73
 		/*
66 74
 		if (isset($globalArchive) && $globalArchive) {
@@ -115,9 +123,14 @@  discard block
 block discarded – undo
115 123
 		print '<h1>'.$spotter_array[0]['aircraft_owner'].'</h1>';
116 124
 		//print '<div><span class="label">'._("Owner").'</span>'.$spotter_array[0]['aircraft_owner'].'</div>';
117 125
 		$Stats = new Stats();
118
-		if ($year == '' && $month == '') $flights = $Stats->getStatsOwner($owner);
119
-		else $flights = 0;
120
-		if ($flights == 0) $flights = $Spotter->countFlightsByOwner($owner,$filter);
126
+		if ($year == '' && $month == '') {
127
+			$flights = $Stats->getStatsOwner($owner);
128
+		} else {
129
+			$flights = 0;
130
+		}
131
+		if ($flights == 0) {
132
+			$flights = $Spotter->countFlightsByOwner($owner,$filter);
133
+		}
121 134
 		print '<div><span class="label">'._("Flights").'</span>'.$flights.'</div>';
122 135
 		$aircraft_type = count($Spotter->countAllAircraftTypesByOwner($owner,$filter));
123 136
 		print '<div><span class="label">'._("Aircrafts type").'</span>'.$aircraft_type.'</div>';
@@ -128,7 +141,9 @@  discard block
 block discarded – undo
128 141
 		$airlines = count($Spotter->countAllAirlinesByOwner($owner,$filter));
129 142
 		print '<div><span class="label">'._("Airlines").'</span>'.$airlines.'</div>';
130 143
 		$duration = $Spotter->getFlightDurationByOwner($owner,$filter);
131
-		if ($duration != '0') print '<div><span class="label">'._("Total flights spotted duration").'</span>'.$duration.'</div>';
144
+		if ($duration != '0') {
145
+			print '<div><span class="label">'._("Total flights spotted duration").'</span>'.$duration.'</div>';
146
+		}
132 147
 		print '</div>';
133 148
 	
134 149
 		include('owner-sub-menu.php');
Please login to merge, or discard this patch.