Completed
Push — master ( 64b871...55f75d )
by Yannick
11:40
created
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   +204 added lines, -204 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;
@@ -175,11 +175,11 @@  discard block
 block discarded – undo
175 175
 	}
176 176
 
177 177
 	/**
178
-	* Gets Minimal Live Spotter data
179
-	*
180
-	* @return Array the spotter information
181
-	*
182
-	*/
178
+	 * Gets Minimal Live Spotter data
179
+	 *
180
+	 * @return Array the spotter information
181
+	 *
182
+	 */
183 183
 	public function getMinLiveSpotterData($filter = array())
184 184
 	{
185 185
 		global $globalDBdriver, $globalLiveInterval, $globalArchive;
@@ -216,11 +216,11 @@  discard block
 block discarded – undo
216 216
 	}
217 217
 
218 218
 	/**
219
-	* Gets Minimal Live Spotter data since xx seconds
220
-	*
221
-	* @return Array the spotter information
222
-	*
223
-	*/
219
+	 * Gets Minimal Live Spotter data since xx seconds
220
+	 *
221
+	 * @return Array the spotter information
222
+	 *
223
+	 */
224 224
 	public function getMinLastLiveSpotterData($filter = array())
225 225
 	{
226 226
 		global $globalDBdriver, $globalLiveInterval, $globalArchive;
@@ -239,7 +239,7 @@  discard block
 block discarded – undo
239 239
 				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' 
240 240
 				ORDER BY spotter_live.flightaware_id, spotter_live.date";
241 241
 			}
242
-                } else {
242
+				} else {
243 243
 			if (isset($globalArchive) && $globalArchive === TRUE) {
244 244
 				$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 
245 245
 				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 
@@ -252,7 +252,7 @@  discard block
 block discarded – undo
252 252
 			}
253 253
 		}
254 254
 
255
-    		try {
255
+			try {
256 256
 			$sth = $this->db->prepare($query);
257 257
 			$sth->execute();
258 258
 		} catch(PDOException $e) {
@@ -264,11 +264,11 @@  discard block
 block discarded – undo
264 264
 	}
265 265
 
266 266
 	/**
267
-	* Gets number of latest data entry
268
-	*
269
-	* @return String number of entry
270
-	*
271
-	*/
267
+	 * Gets number of latest data entry
268
+	 *
269
+	 * @return String number of entry
270
+	 *
271
+	 */
272 272
 	public function getLiveSpotterCount($filter = array())
273 273
 	{
274 274
 		global $globalDBdriver, $globalLiveInterval;
@@ -295,11 +295,11 @@  discard block
 block discarded – undo
295 295
 	}
296 296
 
297 297
 	/**
298
-	* Gets all the spotter information based on the latest data entry and coord
299
-	*
300
-	* @return Array the spotter information
301
-	*
302
-	*/
298
+	 * Gets all the spotter information based on the latest data entry and coord
299
+	 *
300
+	 * @return Array the spotter information
301
+	 *
302
+	 */
303 303
 	public function getLiveSpotterDatabyCoord($coord, $filter = array())
304 304
 	{
305 305
 		global $globalDBdriver, $globalLiveInterval;
@@ -324,11 +324,11 @@  discard block
 block discarded – undo
324 324
 	}
325 325
 
326 326
 	/**
327
-	* Gets all the spotter information based on the latest data entry and coord
328
-	*
329
-	* @return Array the spotter information
330
-	*
331
-	*/
327
+	 * Gets all the spotter information based on the latest data entry and coord
328
+	 *
329
+	 * @return Array the spotter information
330
+	 *
331
+	 */
332 332
 	public function getMinLiveSpotterDatabyCoord($coord, $filter = array())
333 333
 	{
334 334
 		global $globalDBdriver, $globalLiveInterval, $globalArchive;
@@ -393,11 +393,11 @@  discard block
 block discarded – undo
393 393
 	}
394 394
 
395 395
 	/**
396
-	* Gets all the spotter information based on a user's latitude and longitude
397
-	*
398
-	* @return Array the spotter information
399
-	*
400
-	*/
396
+	 * Gets all the spotter information based on a user's latitude and longitude
397
+	 *
398
+	 * @return Array the spotter information
399
+	 *
400
+	 */
401 401
 	public function getLatestSpotterForLayar($lat, $lng, $radius, $interval)
402 402
 	{
403 403
 		$Spotter = new Spotter($this->db);
@@ -407,117 +407,117 @@  discard block
 block discarded – undo
407 407
 				return false;
408 408
 			}
409 409
 		}
410
-        if ($lng != '')
411
-                {
412
-                        if (!is_numeric($lng))
413
-                        {
414
-                                return false;
415
-                        }
416
-                }
417
-
418
-                if ($radius != '')
419
-                {
420
-                        if (!is_numeric($radius))
421
-                        {
422
-                                return false;
423
-                        }
424
-                }
410
+		if ($lng != '')
411
+				{
412
+						if (!is_numeric($lng))
413
+						{
414
+								return false;
415
+						}
416
+				}
417
+
418
+				if ($radius != '')
419
+				{
420
+						if (!is_numeric($radius))
421
+						{
422
+								return false;
423
+						}
424
+				}
425 425
 		$additional_query = '';
426
-        if ($interval != '')
427
-                {
428
-                        if (!is_string($interval))
429
-                        {
430
-                                //$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date ';
431
-			        return false;
432
-                        } else {
433
-                if ($interval == '1m')
434
-                {
435
-                    $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date ';
436
-                } else if ($interval == '15m'){
437
-                    $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 MINUTE) <= spotter_live.date ';
438
-                } 
439
-            }
440
-                } else {
441
-         $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date ';   
442
-        }
443
-
444
-                $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 
426
+		if ($interval != '')
427
+				{
428
+						if (!is_string($interval))
429
+						{
430
+								//$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date ';
431
+					return false;
432
+						} else {
433
+				if ($interval == '1m')
434
+				{
435
+					$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date ';
436
+				} else if ($interval == '15m'){
437
+					$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 MINUTE) <= spotter_live.date ';
438
+				} 
439
+			}
440
+				} else {
441
+		 $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date ';   
442
+		}
443
+
444
+				$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 
445 445
                    WHERE spotter_live.latitude <> '' 
446 446
                                    AND spotter_live.longitude <> '' 
447 447
                    ".$additional_query."
448 448
                    HAVING distance < :radius  
449 449
                                    ORDER BY distance";
450 450
 
451
-                $spotter_array = $Spotter->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng,':radius' => $radius));
451
+				$spotter_array = $Spotter->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng,':radius' => $radius));
452 452
 
453
-                return $spotter_array;
454
-        }
453
+				return $spotter_array;
454
+		}
455 455
 
456 456
     
457
-        /**
458
-	* Gets all the spotter information based on a particular callsign
459
-	*
460
-	* @return Array the spotter information
461
-	*
462
-	*/
457
+		/**
458
+		 * Gets all the spotter information based on a particular callsign
459
+		 *
460
+		 * @return Array the spotter information
461
+		 *
462
+		 */
463 463
 	public function getLastLiveSpotterDataByIdent($ident)
464 464
 	{
465 465
 		$Spotter = new Spotter($this->db);
466 466
 		date_default_timezone_set('UTC');
467 467
 
468 468
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
469
-                $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';
469
+				$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';
470 470
 
471 471
 		$spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident),'',true);
472 472
 
473 473
 		return $spotter_array;
474 474
 	}
475 475
 
476
-        /**
477
-	* Gets all the spotter information based on a particular callsign
478
-	*
479
-	* @return Array the spotter information
480
-	*
481
-	*/
476
+		/**
477
+		 * Gets all the spotter information based on a particular callsign
478
+		 *
479
+		 * @return Array the spotter information
480
+		 *
481
+		 */
482 482
 	public function getDateLiveSpotterDataByIdent($ident,$date)
483 483
 	{
484 484
 		$Spotter = new Spotter($this->db);
485 485
 		date_default_timezone_set('UTC');
486 486
 
487 487
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
488
-                $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';
488
+				$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';
489 489
 
490
-                $date = date('c',$date);
490
+				$date = date('c',$date);
491 491
 		$spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident,':date' => $date));
492 492
 
493 493
 		return $spotter_array;
494 494
 	}
495 495
 
496
-        /**
497
-	* Gets last spotter information based on a particular callsign
498
-	*
499
-	* @return Array the spotter information
500
-	*
501
-	*/
496
+		/**
497
+		 * Gets last spotter information based on a particular callsign
498
+		 *
499
+		 * @return Array the spotter information
500
+		 *
501
+		 */
502 502
 	public function getLastLiveSpotterDataById($id)
503 503
 	{
504 504
 		$Spotter = new Spotter($this->db);
505 505
 		date_default_timezone_set('UTC');
506 506
 
507 507
 		$id = filter_var($id, FILTER_SANITIZE_STRING);
508
-                $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';
508
+				$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';
509 509
 
510 510
 		$spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id),'',true);
511 511
 
512 512
 		return $spotter_array;
513 513
 	}
514 514
 
515
-        /**
516
-	* Gets last spotter information based on a particular callsign
517
-	*
518
-	* @return Array the spotter information
519
-	*
520
-	*/
515
+		/**
516
+		 * Gets last spotter information based on a particular callsign
517
+		 *
518
+		 * @return Array the spotter information
519
+		 *
520
+		 */
521 521
 	public function getDateLiveSpotterDataById($id,$date)
522 522
 	{
523 523
 		$Spotter = new Spotter($this->db);
@@ -530,21 +530,21 @@  discard block
 block discarded – undo
530 530
 		return $spotter_array;
531 531
 	}
532 532
 
533
-        /**
534
-	* Gets altitude information based on a particular callsign
535
-	*
536
-	* @return Array the spotter information
537
-	*
538
-	*/
533
+		/**
534
+		 * Gets altitude information based on a particular callsign
535
+		 *
536
+		 * @return Array the spotter information
537
+		 *
538
+		 */
539 539
 	public function getAltitudeLiveSpotterDataByIdent($ident)
540 540
 	{
541 541
 
542 542
 		date_default_timezone_set('UTC');
543 543
 
544 544
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
545
-                $query  = 'SELECT spotter_live.altitude, spotter_live.date FROM spotter_live WHERE spotter_live.ident = :ident';
545
+				$query  = 'SELECT spotter_live.altitude, spotter_live.date FROM spotter_live WHERE spotter_live.ident = :ident';
546 546
 
547
-    		try {
547
+			try {
548 548
 			
549 549
 			$sth = $this->db->prepare($query);
550 550
 			$sth->execute(array(':ident' => $ident));
@@ -557,12 +557,12 @@  discard block
 block discarded – undo
557 557
 		return $spotter_array;
558 558
 	}
559 559
 
560
-        /**
561
-	* Gets all the spotter information based on a particular id
562
-	*
563
-	* @return Array the spotter information
564
-	*
565
-	*/
560
+		/**
561
+		 * Gets all the spotter information based on a particular id
562
+		 *
563
+		 * @return Array the spotter information
564
+		 *
565
+		 */
566 566
 	public function getAllLiveSpotterDataById($id,$liveinterval = false)
567 567
 	{
568 568
 		global $globalDBdriver, $globalLiveInterval;
@@ -590,18 +590,18 @@  discard block
 block discarded – undo
590 590
 		return $spotter_array;
591 591
 	}
592 592
 
593
-        /**
594
-	* Gets all the spotter information based on a particular ident
595
-	*
596
-	* @return Array the spotter information
597
-	*
598
-	*/
593
+		/**
594
+		 * Gets all the spotter information based on a particular ident
595
+		 *
596
+		 * @return Array the spotter information
597
+		 *
598
+		 */
599 599
 	public function getAllLiveSpotterDataByIdent($ident)
600 600
 	{
601 601
 		date_default_timezone_set('UTC');
602 602
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
603 603
 		$query  = self::$global_query.' WHERE spotter_live.ident = :ident';
604
-    		try {
604
+			try {
605 605
 			
606 606
 			$sth = $this->db->prepare($query);
607 607
 			$sth->execute(array(':ident' => $ident));
@@ -615,23 +615,23 @@  discard block
 block discarded – undo
615 615
 
616 616
 
617 617
 	/**
618
-	* Deletes all info in the table
619
-	*
620
-	* @return String success or false
621
-	*
622
-	*/
618
+	 * Deletes all info in the table
619
+	 *
620
+	 * @return String success or false
621
+	 *
622
+	 */
623 623
 	public function deleteLiveSpotterData()
624 624
 	{
625 625
 		global $globalDBdriver;
626 626
 		if ($globalDBdriver == 'mysql') {
627 627
 			//$query  = "DELETE FROM spotter_live WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 MINUTE) >= spotter_live.date";
628 628
 			$query  = 'DELETE FROM spotter_live WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 9 HOUR) >= spotter_live.date';
629
-            		//$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
+					//$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)";
630 630
 		} else {
631 631
 			$query  = "DELETE FROM spotter_live WHERE NOW() AT TIME ZONE 'UTC' - INTERVAL '9 HOURS' >= spotter_live.date";
632 632
 		}
633 633
         
634
-    		try {
634
+			try {
635 635
 			
636 636
 			$sth = $this->db->prepare($query);
637 637
 			$sth->execute();
@@ -643,18 +643,18 @@  discard block
 block discarded – undo
643 643
 	}
644 644
 
645 645
 	/**
646
-	* Deletes all info in the table for aircraft not seen since 2 HOUR
647
-	*
648
-	* @return String success or false
649
-	*
650
-	*/
646
+	 * Deletes all info in the table for aircraft not seen since 2 HOUR
647
+	 *
648
+	 * @return String success or false
649
+	 *
650
+	 */
651 651
 	public function deleteLiveSpotterDataNotUpdated()
652 652
 	{
653 653
 		global $globalDBdriver, $globalDebug;
654 654
 		if ($globalDBdriver == 'mysql') {
655 655
 			//$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';
656
-    			$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";
657
-    			try {
656
+				$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";
657
+				try {
658 658
 				
659 659
 				$sth = $this->db->prepare($query);
660 660
 				$sth->execute();
@@ -662,8 +662,8 @@  discard block
 block discarded – undo
662 662
 				return "error";
663 663
 			}
664 664
 			$query_delete = 'DELETE FROM spotter_live WHERE flightaware_id IN (';
665
-                        $i = 0;
666
-                        $j =0;
665
+						$i = 0;
666
+						$j =0;
667 667
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
668 668
 			foreach($all as $row)
669 669
 			{
@@ -671,20 +671,20 @@  discard block
 block discarded – undo
671 671
 				$j++;
672 672
 				if ($j == 30) {
673 673
 					if ($globalDebug) echo ".";
674
-				    	try {
674
+						try {
675 675
 						
676 676
 						$sth = $this->db->prepare(substr($query_delete,0,-1).")");
677 677
 						$sth->execute();
678 678
 					} catch(PDOException $e) {
679 679
 						return "error";
680 680
 					}
681
-                                	$query_delete = 'DELETE FROM spotter_live WHERE flightaware_id IN (';
682
-                                	$j = 0;
681
+									$query_delete = 'DELETE FROM spotter_live WHERE flightaware_id IN (';
682
+									$j = 0;
683 683
 				}
684 684
 				$query_delete .= "'".$row['flightaware_id']."',";
685 685
 			}
686 686
 			if ($i > 0) {
687
-    				try {
687
+					try {
688 688
 					
689 689
 					$sth = $this->db->prepare(substr($query_delete,0,-1).")");
690 690
 					$sth->execute();
@@ -695,9 +695,9 @@  discard block
 block discarded – undo
695 695
 			return "success";
696 696
 		} elseif ($globalDBdriver == 'pgsql') {
697 697
 			//$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";
698
-    			//$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";
699
-    			$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)";
700
-    			try {
698
+				//$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";
699
+				$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)";
700
+				try {
701 701
 				
702 702
 				$sth = $this->db->prepare($query);
703 703
 				$sth->execute();
@@ -741,17 +741,17 @@  discard block
 block discarded – undo
741 741
 	}
742 742
 
743 743
 	/**
744
-	* Deletes all info in the table for an ident
745
-	*
746
-	* @return String success or false
747
-	*
748
-	*/
744
+	 * Deletes all info in the table for an ident
745
+	 *
746
+	 * @return String success or false
747
+	 *
748
+	 */
749 749
 	public function deleteLiveSpotterDataByIdent($ident)
750 750
 	{
751 751
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
752 752
 		$query  = 'DELETE FROM spotter_live WHERE ident = :ident';
753 753
         
754
-    		try {
754
+			try {
755 755
 			
756 756
 			$sth = $this->db->prepare($query);
757 757
 			$sth->execute(array(':ident' => $ident));
@@ -763,17 +763,17 @@  discard block
 block discarded – undo
763 763
 	}
764 764
 
765 765
 	/**
766
-	* Deletes all info in the table for an id
767
-	*
768
-	* @return String success or false
769
-	*
770
-	*/
766
+	 * Deletes all info in the table for an id
767
+	 *
768
+	 * @return String success or false
769
+	 *
770
+	 */
771 771
 	public function deleteLiveSpotterDataById($id)
772 772
 	{
773 773
 		$id = filter_var($id, FILTER_SANITIZE_STRING);
774 774
 		$query  = 'DELETE FROM spotter_live WHERE flightaware_id = :id';
775 775
         
776
-    		try {
776
+			try {
777 777
 			
778 778
 			$sth = $this->db->prepare($query);
779 779
 			$sth->execute(array(':id' => $id));
@@ -786,11 +786,11 @@  discard block
 block discarded – undo
786 786
 
787 787
 
788 788
 	/**
789
-	* Gets the aircraft ident within the last hour
790
-	*
791
-	* @return String the ident
792
-	*
793
-	*/
789
+	 * Gets the aircraft ident within the last hour
790
+	 *
791
+	 * @return String the ident
792
+	 *
793
+	 */
794 794
 	public function getIdentFromLastHour($ident)
795 795
 	{
796 796
 		global $globalDBdriver, $globalTimezone;
@@ -816,14 +816,14 @@  discard block
 block discarded – undo
816 816
 			$ident_result = $row['ident'];
817 817
 		}
818 818
 		return $ident_result;
819
-        }
819
+		}
820 820
 
821 821
 	/**
822
-	* Check recent aircraft
823
-	*
824
-	* @return String the ident
825
-	*
826
-	*/
822
+	 * Check recent aircraft
823
+	 *
824
+	 * @return String the ident
825
+	 *
826
+	 */
827 827
 	public function checkIdentRecent($ident)
828 828
 	{
829 829
 		global $globalDBdriver, $globalTimezone;
@@ -849,14 +849,14 @@  discard block
 block discarded – undo
849 849
 			$ident_result = $row['flightaware_id'];
850 850
 		}
851 851
 		return $ident_result;
852
-        }
852
+		}
853 853
 
854 854
 	/**
855
-	* Check recent aircraft by id
856
-	*
857
-	* @return String the ident
858
-	*
859
-	*/
855
+	 * Check recent aircraft by id
856
+	 *
857
+	 * @return String the ident
858
+	 *
859
+	 */
860 860
 	public function checkIdRecent($id)
861 861
 	{
862 862
 		global $globalDBdriver, $globalTimezone;
@@ -882,14 +882,14 @@  discard block
 block discarded – undo
882 882
 			$ident_result = $row['flightaware_id'];
883 883
 		}
884 884
 		return $ident_result;
885
-        }
885
+		}
886 886
 
887 887
 	/**
888
-	* Check recent aircraft by ModeS
889
-	*
890
-	* @return String the ModeS
891
-	*
892
-	*/
888
+	 * Check recent aircraft by ModeS
889
+	 *
890
+	 * @return String the ModeS
891
+	 *
892
+	 */
893 893
 	public function checkModeSRecent($modes)
894 894
 	{
895 895
 		global $globalDBdriver, $globalTimezone;
@@ -916,19 +916,19 @@  discard block
 block discarded – undo
916 916
 			$ident_result = $row['flightaware_id'];
917 917
 		}
918 918
 		return $ident_result;
919
-        }
919
+		}
920 920
 
921 921
 	/**
922
-	* Adds a new spotter data
923
-	*
924
-	* @param String $flightaware_id the ID from flightaware
925
-	* @param String $ident the flight ident
926
-	* @param String $aircraft_icao the aircraft type
927
-	* @param String $departure_airport_icao the departure airport
928
-	* @param String $arrival_airport_icao the arrival airport
929
-	* @return String success or false
930
-	*
931
-	*/
922
+	 * Adds a new spotter data
923
+	 *
924
+	 * @param String $flightaware_id the ID from flightaware
925
+	 * @param String $ident the flight ident
926
+	 * @param String $aircraft_icao the aircraft type
927
+	 * @param String $departure_airport_icao the departure airport
928
+	 * @param String $arrival_airport_icao the arrival airport
929
+	 * @return String success or false
930
+	 *
931
+	 */
932 932
 	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 = '')
933 933
 	{
934 934
 		global $globalURL, $globalArchive, $globalDebug;
@@ -1064,10 +1064,10 @@  discard block
 block discarded – undo
1064 1064
 		$arrival_airport_country = '';
1065 1065
 		
1066 1066
             	
1067
-            	if ($squawk == '' || $Common->isInteger($squawk) === false ) $squawk = NULL;
1068
-            	if ($verticalrate == '' || $Common->isInteger($verticalrate) === false ) $verticalrate = NULL;
1069
-            	if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0;
1070
-            	if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0;
1067
+				if ($squawk == '' || $Common->isInteger($squawk) === false ) $squawk = NULL;
1068
+				if ($verticalrate == '' || $Common->isInteger($verticalrate) === false ) $verticalrate = NULL;
1069
+				if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0;
1070
+				if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0;
1071 1071
 		
1072 1072
 		$query = '';
1073 1073
 		if ($globalArchive) {
@@ -1088,10 +1088,10 @@  discard block
 block discarded – undo
1088 1088
 			return "error : ".$e->getMessage();
1089 1089
 		}
1090 1090
 		if (isset($globalArchive) && $globalArchive && $putinarchive && $noarchive !== true) {
1091
-		    if ($globalDebug) echo '(Add to SBS archive : ';
1092
-		    $SpotterArchive = new SpotterArchive($this->db);
1093
-		    $result =  $SpotterArchive->addSpotterArchiveData($flightaware_id, $ident, $registration, $airline_name, $airline_icao, $airline_country, $airline_type, $aircraft_icao, $aircraft_shadow, $aircraft_name, $aircraft_manufacturer, $departure_airport_icao, $departure_airport_name, $departure_airport_city, $departure_airport_country, $departure_airport_time,$arrival_airport_icao, $arrival_airport_name, $arrival_airport_city, $arrival_airport_country, $arrival_airport_time, $route_stop, $date,$latitude, $longitude, $waypoints, $altitude, $altitude_real,$heading, $groundspeed, $squawk, $ModeS, $pilot_id, $pilot_name,$verticalrate,$format_source,$source_name, $over_country);
1094
-		    if ($globalDebug) echo $result.')';
1091
+			if ($globalDebug) echo '(Add to SBS archive : ';
1092
+			$SpotterArchive = new SpotterArchive($this->db);
1093
+			$result =  $SpotterArchive->addSpotterArchiveData($flightaware_id, $ident, $registration, $airline_name, $airline_icao, $airline_country, $airline_type, $aircraft_icao, $aircraft_shadow, $aircraft_name, $aircraft_manufacturer, $departure_airport_icao, $departure_airport_name, $departure_airport_city, $departure_airport_country, $departure_airport_time,$arrival_airport_icao, $arrival_airport_name, $arrival_airport_city, $arrival_airport_country, $arrival_airport_time, $route_stop, $date,$latitude, $longitude, $waypoints, $altitude, $altitude_real,$heading, $groundspeed, $squawk, $ModeS, $pilot_id, $pilot_name,$verticalrate,$format_source,$source_name, $over_country);
1094
+			if ($globalDebug) echo $result.')';
1095 1095
 		}
1096 1096
 		return "success";
1097 1097
 
Please login to merge, or discard this patch.
Spacing   +127 added lines, -127 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];
@@ -169,7 +169,7 @@  discard block
 block discarded – undo
169 169
 		} else {
170 170
 			$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;
171 171
 		}
172
-		$spotter_array = $Spotter->getDataFromDB($query.$limit_query,array(),'',true);
172
+		$spotter_array = $Spotter->getDataFromDB($query.$limit_query, array(), '', true);
173 173
 
174 174
 		return $spotter_array;
175 175
 	}
@@ -184,7 +184,7 @@  discard block
 block discarded – undo
184 184
 	{
185 185
 		global $globalDBdriver, $globalLiveInterval, $globalArchive;
186 186
 		date_default_timezone_set('UTC');
187
-		$filter_query = $this->getFilter($filter,true,true);
187
+		$filter_query = $this->getFilter($filter, true, true);
188 188
 		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
189 189
 		if ($globalDBdriver == 'mysql') {
190 190
 			if (isset($globalArchive) && $globalArchive === TRUE) {
@@ -207,7 +207,7 @@  discard block
 block discarded – undo
207 207
 		try {
208 208
 			$sth = $this->db->prepare($query);
209 209
 			$sth->execute();
210
-		} catch(PDOException $e) {
210
+		} catch (PDOException $e) {
211 211
 			echo $e->getMessage();
212 212
 			die;
213 213
 		}
@@ -226,27 +226,27 @@  discard block
 block discarded – undo
226 226
 		global $globalDBdriver, $globalLiveInterval, $globalArchive;
227 227
 		date_default_timezone_set('UTC');
228 228
 
229
-		$filter_query = $this->getFilter($filter,true,true);
229
+		$filter_query = $this->getFilter($filter, true, true);
230 230
 
231 231
 		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
232 232
 		if ($globalDBdriver == 'mysql') {
233 233
 			if (isset($globalArchive) && $globalArchive === TRUE) {
234
-				$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
+				$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 
235 235
 				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' 
236 236
 				ORDER BY spotter_archive.flightaware_id, spotter_archive.date";
237 237
 			} else {
238
-				$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
+				$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 
239 239
 				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' 
240 240
 				ORDER BY spotter_live.flightaware_id, spotter_live.date";
241 241
 			}
242 242
                 } else {
243 243
 			if (isset($globalArchive) && $globalArchive === TRUE) {
244
-				$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
+				$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 
245 245
 				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 
246 246
 				WHERE spotter_archive.latitude <> '0' AND spotter_archive.longitude <> '0' 
247 247
 				ORDER BY spotter_archive.flightaware_id, spotter_archive.date";
248 248
 			} else {
249
-				$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 
249
+				$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 
250 250
 				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' 
251 251
 				ORDER BY spotter_live.flightaware_id, spotter_live.date";
252 252
 			}
@@ -255,7 +255,7 @@  discard block
 block discarded – undo
255 255
     		try {
256 256
 			$sth = $this->db->prepare($query);
257 257
 			$sth->execute();
258
-		} catch(PDOException $e) {
258
+		} catch (PDOException $e) {
259 259
 			echo $e->getMessage();
260 260
 			die;
261 261
 		}
@@ -272,7 +272,7 @@  discard block
 block discarded – undo
272 272
 	public function getLiveSpotterCount($filter = array())
273 273
 	{
274 274
 		global $globalDBdriver, $globalLiveInterval;
275
-		$filter_query = $this->getFilter($filter,true,true);
275
+		$filter_query = $this->getFilter($filter, true, true);
276 276
 
277 277
 		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
278 278
 		if ($globalDBdriver == 'mysql') {
@@ -285,7 +285,7 @@  discard block
 block discarded – undo
285 285
 		try {
286 286
 			$sth = $this->db->prepare($query);
287 287
 			$sth->execute();
288
-		} catch(PDOException $e) {
288
+		} catch (PDOException $e) {
289 289
 			echo $e->getMessage();
290 290
 			die;
291 291
 		}
@@ -308,10 +308,10 @@  discard block
 block discarded – undo
308 308
 		$filter_query = $this->getFilter($filter);
309 309
 
310 310
 		if (is_array($coord)) {
311
-			$minlong = filter_var($coord[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
312
-			$minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
313
-			$maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
314
-			$maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
311
+			$minlong = filter_var($coord[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
312
+			$minlat = filter_var($coord[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
313
+			$maxlong = filter_var($coord[2], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
314
+			$maxlat = filter_var($coord[3], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
315 315
 		} else return array();
316 316
 		if ($globalDBdriver == 'mysql') {
317 317
 			$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;
@@ -334,23 +334,23 @@  discard block
 block discarded – undo
334 334
 		global $globalDBdriver, $globalLiveInterval, $globalArchive;
335 335
 		$Spotter = new Spotter($this->db);
336 336
 		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
337
-		$filter_query = $this->getFilter($filter,true,true);
337
+		$filter_query = $this->getFilter($filter, true, true);
338 338
 
339 339
 		if (is_array($coord)) {
340
-			$minlong = filter_var($coord[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
341
-			$minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
342
-			$maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
343
-			$maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
340
+			$minlong = filter_var($coord[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
341
+			$minlat = filter_var($coord[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
342
+			$maxlong = filter_var($coord[2], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
343
+			$maxlat = filter_var($coord[3], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
344 344
 		} else return array();
345 345
 		if ($globalDBdriver == 'mysql') {
346 346
 			if (isset($globalArchive) && $globalArchive === TRUE) {
347
-				$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 
347
+				$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 
348 348
 				FROM spotter_live 
349 349
 				'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= spotter_live.date 
350 350
 				AND spotter_live.latitude BETWEEN '.$minlat.' AND '.$maxlat.' AND spotter_live.longitude BETWEEN '.$minlong.' AND '.$maxlong.'
351 351
 				AND spotter_live.latitude <> 0 AND spotter_live.longitude <> 0';
352 352
 			} else {
353
-				$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 
353
+				$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 
354 354
 				FROM spotter_live 
355 355
 				INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate 
356 356
 				    FROM spotter_live l 
@@ -362,14 +362,14 @@  discard block
 block discarded – undo
362 362
 			}
363 363
 		} else {
364 364
 			if (isset($globalArchive) && $globalArchive === TRUE) {
365
-				$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 
365
+				$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 
366 366
 				FROM spotter_live 
367 367
 				".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= spotter_live.date 
368 368
 				AND spotter_live.latitude BETWEEN ".$minlat." AND ".$maxlat." 
369 369
 				AND spotter_live.longitude BETWEEN ".$minlong." AND ".$maxlong." 
370 370
 				AND spotter_live.latitude <> '0' AND spotter_live.longitude <> '0'";
371 371
 			} else {
372
-				$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 
372
+				$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 
373 373
 				FROM spotter_live 
374 374
 				INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate 
375 375
 				    FROM spotter_live l 
@@ -384,7 +384,7 @@  discard block
 block discarded – undo
384 384
 		try {
385 385
 			$sth = $this->db->prepare($query);
386 386
 			$sth->execute();
387
-		} catch(PDOException $e) {
387
+		} catch (PDOException $e) {
388 388
 			echo $e->getMessage();
389 389
 			die;
390 390
 		}
@@ -433,7 +433,7 @@  discard block
 block discarded – undo
433 433
                 if ($interval == '1m')
434 434
                 {
435 435
                     $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date ';
436
-                } else if ($interval == '15m'){
436
+                } else if ($interval == '15m') {
437 437
                     $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 MINUTE) <= spotter_live.date ';
438 438
                 } 
439 439
             }
@@ -441,14 +441,14 @@  discard block
 block discarded – undo
441 441
          $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date ';   
442 442
         }
443 443
 
444
-                $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 
444
+                $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 
445 445
                    WHERE spotter_live.latitude <> '' 
446 446
                                    AND spotter_live.longitude <> '' 
447 447
                    ".$additional_query."
448 448
                    HAVING distance < :radius  
449 449
                                    ORDER BY distance";
450 450
 
451
-                $spotter_array = $Spotter->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng,':radius' => $radius));
451
+                $spotter_array = $Spotter->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng, ':radius' => $radius));
452 452
 
453 453
                 return $spotter_array;
454 454
         }
@@ -466,9 +466,9 @@  discard block
 block discarded – undo
466 466
 		date_default_timezone_set('UTC');
467 467
 
468 468
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
469
-                $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';
469
+                $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';
470 470
 
471
-		$spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident),'',true);
471
+		$spotter_array = $Spotter->getDataFromDB($query, array(':ident' => $ident), '', true);
472 472
 
473 473
 		return $spotter_array;
474 474
 	}
@@ -479,16 +479,16 @@  discard block
 block discarded – undo
479 479
 	* @return Array the spotter information
480 480
 	*
481 481
 	*/
482
-	public function getDateLiveSpotterDataByIdent($ident,$date)
482
+	public function getDateLiveSpotterDataByIdent($ident, $date)
483 483
 	{
484 484
 		$Spotter = new Spotter($this->db);
485 485
 		date_default_timezone_set('UTC');
486 486
 
487 487
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
488
-                $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';
488
+                $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';
489 489
 
490
-                $date = date('c',$date);
491
-		$spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident,':date' => $date));
490
+                $date = date('c', $date);
491
+		$spotter_array = $Spotter->getDataFromDB($query, array(':ident' => $ident, ':date' => $date));
492 492
 
493 493
 		return $spotter_array;
494 494
 	}
@@ -505,9 +505,9 @@  discard block
 block discarded – undo
505 505
 		date_default_timezone_set('UTC');
506 506
 
507 507
 		$id = filter_var($id, FILTER_SANITIZE_STRING);
508
-                $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';
508
+                $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';
509 509
 
510
-		$spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id),'',true);
510
+		$spotter_array = $Spotter->getDataFromDB($query, array(':id' => $id), '', true);
511 511
 
512 512
 		return $spotter_array;
513 513
 	}
@@ -518,15 +518,15 @@  discard block
 block discarded – undo
518 518
 	* @return Array the spotter information
519 519
 	*
520 520
 	*/
521
-	public function getDateLiveSpotterDataById($id,$date)
521
+	public function getDateLiveSpotterDataById($id, $date)
522 522
 	{
523 523
 		$Spotter = new Spotter($this->db);
524 524
 		date_default_timezone_set('UTC');
525 525
 
526 526
 		$id = filter_var($id, FILTER_SANITIZE_STRING);
527
-		$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';
528
-		$date = date('c',$date);
529
-		$spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id,':date' => $date),'',true);
527
+		$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';
528
+		$date = date('c', $date);
529
+		$spotter_array = $Spotter->getDataFromDB($query, array(':id' => $id, ':date' => $date), '', true);
530 530
 		return $spotter_array;
531 531
 	}
532 532
 
@@ -542,13 +542,13 @@  discard block
 block discarded – undo
542 542
 		date_default_timezone_set('UTC');
543 543
 
544 544
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
545
-                $query  = 'SELECT spotter_live.altitude, spotter_live.date FROM spotter_live WHERE spotter_live.ident = :ident';
545
+                $query = 'SELECT spotter_live.altitude, spotter_live.date FROM spotter_live WHERE spotter_live.ident = :ident';
546 546
 
547 547
     		try {
548 548
 			
549 549
 			$sth = $this->db->prepare($query);
550 550
 			$sth->execute(array(':ident' => $ident));
551
-		} catch(PDOException $e) {
551
+		} catch (PDOException $e) {
552 552
 			echo $e->getMessage();
553 553
 			die;
554 554
 		}
@@ -563,7 +563,7 @@  discard block
 block discarded – undo
563 563
 	* @return Array the spotter information
564 564
 	*
565 565
 	*/
566
-	public function getAllLiveSpotterDataById($id,$liveinterval = false)
566
+	public function getAllLiveSpotterDataById($id, $liveinterval = false)
567 567
 	{
568 568
 		global $globalDBdriver, $globalLiveInterval;
569 569
 		date_default_timezone_set('UTC');
@@ -582,7 +582,7 @@  discard block
 block discarded – undo
582 582
 		try {
583 583
 			$sth = $this->db->prepare($query);
584 584
 			$sth->execute(array(':id' => $id));
585
-		} catch(PDOException $e) {
585
+		} catch (PDOException $e) {
586 586
 			echo $e->getMessage();
587 587
 			die;
588 588
 		}
@@ -600,12 +600,12 @@  discard block
 block discarded – undo
600 600
 	{
601 601
 		date_default_timezone_set('UTC');
602 602
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
603
-		$query  = self::$global_query.' WHERE spotter_live.ident = :ident';
603
+		$query = self::$global_query.' WHERE spotter_live.ident = :ident';
604 604
     		try {
605 605
 			
606 606
 			$sth = $this->db->prepare($query);
607 607
 			$sth->execute(array(':ident' => $ident));
608
-		} catch(PDOException $e) {
608
+		} catch (PDOException $e) {
609 609
 			echo $e->getMessage();
610 610
 			die;
611 611
 		}
@@ -635,7 +635,7 @@  discard block
 block discarded – undo
635 635
 			
636 636
 			$sth = $this->db->prepare($query);
637 637
 			$sth->execute();
638
-		} catch(PDOException $e) {
638
+		} catch (PDOException $e) {
639 639
 			return "error";
640 640
 		}
641 641
 
@@ -658,14 +658,14 @@  discard block
 block discarded – undo
658 658
 				
659 659
 				$sth = $this->db->prepare($query);
660 660
 				$sth->execute();
661
-			} catch(PDOException $e) {
661
+			} catch (PDOException $e) {
662 662
 				return "error";
663 663
 			}
664 664
 			$query_delete = 'DELETE FROM spotter_live WHERE flightaware_id IN (';
665 665
                         $i = 0;
666
-                        $j =0;
666
+                        $j = 0;
667 667
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
668
-			foreach($all as $row)
668
+			foreach ($all as $row)
669 669
 			{
670 670
 				$i++;
671 671
 				$j++;
@@ -673,9 +673,9 @@  discard block
 block discarded – undo
673 673
 					if ($globalDebug) echo ".";
674 674
 				    	try {
675 675
 						
676
-						$sth = $this->db->prepare(substr($query_delete,0,-1).")");
676
+						$sth = $this->db->prepare(substr($query_delete, 0, -1).")");
677 677
 						$sth->execute();
678
-					} catch(PDOException $e) {
678
+					} catch (PDOException $e) {
679 679
 						return "error";
680 680
 					}
681 681
                                 	$query_delete = 'DELETE FROM spotter_live WHERE flightaware_id IN (';
@@ -686,9 +686,9 @@  discard block
 block discarded – undo
686 686
 			if ($i > 0) {
687 687
     				try {
688 688
 					
689
-					$sth = $this->db->prepare(substr($query_delete,0,-1).")");
689
+					$sth = $this->db->prepare(substr($query_delete, 0, -1).")");
690 690
 					$sth->execute();
691
-				} catch(PDOException $e) {
691
+				} catch (PDOException $e) {
692 692
 					return "error";
693 693
 				}
694 694
 			}
@@ -701,7 +701,7 @@  discard block
 block discarded – undo
701 701
 				
702 702
 				$sth = $this->db->prepare($query);
703 703
 				$sth->execute();
704
-			} catch(PDOException $e) {
704
+			} catch (PDOException $e) {
705 705
 				return "error";
706 706
 			}
707 707
 /*			$query_delete = "DELETE FROM spotter_live WHERE flightaware_id IN (";
@@ -749,13 +749,13 @@  discard block
 block discarded – undo
749 749
 	public function deleteLiveSpotterDataByIdent($ident)
750 750
 	{
751 751
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
752
-		$query  = 'DELETE FROM spotter_live WHERE ident = :ident';
752
+		$query = 'DELETE FROM spotter_live WHERE ident = :ident';
753 753
         
754 754
     		try {
755 755
 			
756 756
 			$sth = $this->db->prepare($query);
757 757
 			$sth->execute(array(':ident' => $ident));
758
-		} catch(PDOException $e) {
758
+		} catch (PDOException $e) {
759 759
 			return "error";
760 760
 		}
761 761
 
@@ -771,13 +771,13 @@  discard block
 block discarded – undo
771 771
 	public function deleteLiveSpotterDataById($id)
772 772
 	{
773 773
 		$id = filter_var($id, FILTER_SANITIZE_STRING);
774
-		$query  = 'DELETE FROM spotter_live WHERE flightaware_id = :id';
774
+		$query = 'DELETE FROM spotter_live WHERE flightaware_id = :id';
775 775
         
776 776
     		try {
777 777
 			
778 778
 			$sth = $this->db->prepare($query);
779 779
 			$sth->execute(array(':id' => $id));
780
-		} catch(PDOException $e) {
780
+		} catch (PDOException $e) {
781 781
 			return "error";
782 782
 		}
783 783
 
@@ -795,13 +795,13 @@  discard block
 block discarded – undo
795 795
 	{
796 796
 		global $globalDBdriver, $globalTimezone;
797 797
 		if ($globalDBdriver == 'mysql') {
798
-			$query  = 'SELECT spotter_live.ident FROM spotter_live 
798
+			$query = 'SELECT spotter_live.ident FROM spotter_live 
799 799
 				WHERE spotter_live.ident = :ident 
800 800
 				AND spotter_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) 
801 801
 				AND spotter_live.date < UTC_TIMESTAMP()';
802 802
 			$query_data = array(':ident' => $ident);
803 803
 		} else {
804
-			$query  = "SELECT spotter_live.ident FROM spotter_live 
804
+			$query = "SELECT spotter_live.ident FROM spotter_live 
805 805
 				WHERE spotter_live.ident = :ident 
806 806
 				AND spotter_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '1 HOURS'
807 807
 				AND spotter_live.date < now() AT TIME ZONE 'UTC'";
@@ -810,8 +810,8 @@  discard block
 block discarded – undo
810 810
 		
811 811
 		$sth = $this->db->prepare($query);
812 812
 		$sth->execute($query_data);
813
-		$ident_result='';
814
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
813
+		$ident_result = '';
814
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
815 815
 		{
816 816
 			$ident_result = $row['ident'];
817 817
 		}
@@ -828,13 +828,13 @@  discard block
 block discarded – undo
828 828
 	{
829 829
 		global $globalDBdriver, $globalTimezone;
830 830
 		if ($globalDBdriver == 'mysql') {
831
-			$query  = 'SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live 
831
+			$query = 'SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live 
832 832
 				WHERE spotter_live.ident = :ident 
833 833
 				AND spotter_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 MINUTE)'; 
834 834
 //				AND spotter_live.date < UTC_TIMESTAMP()";
835 835
 			$query_data = array(':ident' => $ident);
836 836
 		} else {
837
-			$query  = "SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live 
837
+			$query = "SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live 
838 838
 				WHERE spotter_live.ident = :ident 
839 839
 				AND spotter_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '30 MINUTES'";
840 840
 //				AND spotter_live.date < now() AT TIME ZONE 'UTC'";
@@ -843,8 +843,8 @@  discard block
 block discarded – undo
843 843
 		
844 844
 		$sth = $this->db->prepare($query);
845 845
 		$sth->execute($query_data);
846
-		$ident_result='';
847
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
846
+		$ident_result = '';
847
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
848 848
 		{
849 849
 			$ident_result = $row['flightaware_id'];
850 850
 		}
@@ -861,13 +861,13 @@  discard block
 block discarded – undo
861 861
 	{
862 862
 		global $globalDBdriver, $globalTimezone;
863 863
 		if ($globalDBdriver == 'mysql') {
864
-			$query  = 'SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live 
864
+			$query = 'SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live 
865 865
 				WHERE spotter_live.flightaware_id = :id 
866 866
 				AND spotter_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 10 HOUR)'; 
867 867
 //				AND spotter_live.date < UTC_TIMESTAMP()";
868 868
 			$query_data = array(':id' => $id);
869 869
 		} else {
870
-			$query  = "SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live 
870
+			$query = "SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live 
871 871
 				WHERE spotter_live.flightaware_id = :id 
872 872
 				AND spotter_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '10 HOUR'";
873 873
 //				AND spotter_live.date < now() AT TIME ZONE 'UTC'";
@@ -876,8 +876,8 @@  discard block
 block discarded – undo
876 876
 		
877 877
 		$sth = $this->db->prepare($query);
878 878
 		$sth->execute($query_data);
879
-		$ident_result='';
880
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
879
+		$ident_result = '';
880
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
881 881
 		{
882 882
 			$ident_result = $row['flightaware_id'];
883 883
 		}
@@ -894,13 +894,13 @@  discard block
 block discarded – undo
894 894
 	{
895 895
 		global $globalDBdriver, $globalTimezone;
896 896
 		if ($globalDBdriver == 'mysql') {
897
-			$query  = 'SELECT spotter_live.ModeS, spotter_live.flightaware_id FROM spotter_live 
897
+			$query = 'SELECT spotter_live.ModeS, spotter_live.flightaware_id FROM spotter_live 
898 898
 				WHERE spotter_live.ModeS = :modes 
899 899
 				AND spotter_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 MINUTE)'; 
900 900
 //				AND spotter_live.date < UTC_TIMESTAMP()";
901 901
 			$query_data = array(':modes' => $modes);
902 902
 		} else {
903
-			$query  = "SELECT spotter_live.ModeS, spotter_live.flightaware_id FROM spotter_live 
903
+			$query = "SELECT spotter_live.ModeS, spotter_live.flightaware_id FROM spotter_live 
904 904
 				WHERE spotter_live.ModeS = :modes 
905 905
 				AND spotter_live.date >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '30 MINUTE'";
906 906
 //			//	AND spotter_live.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC'";
@@ -909,8 +909,8 @@  discard block
 block discarded – undo
909 909
 		
910 910
 		$sth = $this->db->prepare($query);
911 911
 		$sth->execute($query_data);
912
-		$ident_result='';
913
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
912
+		$ident_result = '';
913
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
914 914
 		{
915 915
 			//$ident_result = $row['spotter_live_id'];
916 916
 			$ident_result = $row['flightaware_id'];
@@ -929,7 +929,7 @@  discard block
 block discarded – undo
929 929
 	* @return String success or false
930 930
 	*
931 931
 	*/
932
-	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
+	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 = '')
933 933
 	{
934 934
 		global $globalURL, $globalArchive, $globalDebug;
935 935
 		$Common = new Common();
@@ -1022,27 +1022,27 @@  discard block
 block discarded – undo
1022 1022
 		if ($date == '') $date = date("Y-m-d H:i:s", time());
1023 1023
 
1024 1024
         
1025
-		$flightaware_id = filter_var($flightaware_id,FILTER_SANITIZE_STRING);
1026
-		$ident = filter_var($ident,FILTER_SANITIZE_STRING);
1027
-		$aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING);
1028
-		$departure_airport_icao = filter_var($departure_airport_icao,FILTER_SANITIZE_STRING);
1029
-		$arrival_airport_icao = filter_var($arrival_airport_icao,FILTER_SANITIZE_STRING);
1030
-		$latitude = filter_var($latitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
1031
-		$longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
1032
-		$waypoints = filter_var($waypoints,FILTER_SANITIZE_STRING);
1033
-		$altitude = filter_var($altitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
1034
-		$altitude_real = filter_var($altitude_real,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
1035
-		$heading = filter_var($heading,FILTER_SANITIZE_NUMBER_INT);
1036
-		$groundspeed = filter_var($groundspeed,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
1037
-		$squawk = filter_var($squawk,FILTER_SANITIZE_NUMBER_INT);
1038
-		$route_stop = filter_var($route_stop,FILTER_SANITIZE_STRING);
1039
-		$ModeS = filter_var($ModeS,FILTER_SANITIZE_STRING);
1040
-		$pilot_id = filter_var($pilot_id,FILTER_SANITIZE_STRING);
1041
-		$pilot_name = filter_var($pilot_name,FILTER_SANITIZE_STRING);
1042
-		$format_source = filter_var($format_source,FILTER_SANITIZE_STRING);
1043
-		$source_name = filter_var($source_name,FILTER_SANITIZE_STRING);
1044
-		$over_country = filter_var($over_country,FILTER_SANITIZE_STRING);
1045
-		$verticalrate = filter_var($verticalrate,FILTER_SANITIZE_NUMBER_INT);
1025
+		$flightaware_id = filter_var($flightaware_id, FILTER_SANITIZE_STRING);
1026
+		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
1027
+		$aircraft_icao = filter_var($aircraft_icao, FILTER_SANITIZE_STRING);
1028
+		$departure_airport_icao = filter_var($departure_airport_icao, FILTER_SANITIZE_STRING);
1029
+		$arrival_airport_icao = filter_var($arrival_airport_icao, FILTER_SANITIZE_STRING);
1030
+		$latitude = filter_var($latitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
1031
+		$longitude = filter_var($longitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
1032
+		$waypoints = filter_var($waypoints, FILTER_SANITIZE_STRING);
1033
+		$altitude = filter_var($altitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
1034
+		$altitude_real = filter_var($altitude_real, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
1035
+		$heading = filter_var($heading, FILTER_SANITIZE_NUMBER_INT);
1036
+		$groundspeed = filter_var($groundspeed, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
1037
+		$squawk = filter_var($squawk, FILTER_SANITIZE_NUMBER_INT);
1038
+		$route_stop = filter_var($route_stop, FILTER_SANITIZE_STRING);
1039
+		$ModeS = filter_var($ModeS, FILTER_SANITIZE_STRING);
1040
+		$pilot_id = filter_var($pilot_id, FILTER_SANITIZE_STRING);
1041
+		$pilot_name = filter_var($pilot_name, FILTER_SANITIZE_STRING);
1042
+		$format_source = filter_var($format_source, FILTER_SANITIZE_STRING);
1043
+		$source_name = filter_var($source_name, FILTER_SANITIZE_STRING);
1044
+		$over_country = filter_var($over_country, FILTER_SANITIZE_STRING);
1045
+		$verticalrate = filter_var($verticalrate, FILTER_SANITIZE_NUMBER_INT);
1046 1046
 
1047 1047
 		$airline_name = '';
1048 1048
 		$airline_icao = '';
@@ -1064,10 +1064,10 @@  discard block
 block discarded – undo
1064 1064
 		$arrival_airport_country = '';
1065 1065
 		
1066 1066
             	
1067
-            	if ($squawk == '' || $Common->isInteger($squawk) === false ) $squawk = NULL;
1068
-            	if ($verticalrate == '' || $Common->isInteger($verticalrate) === false ) $verticalrate = NULL;
1069
-            	if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0;
1070
-            	if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0;
1067
+            	if ($squawk == '' || $Common->isInteger($squawk) === false) $squawk = NULL;
1068
+            	if ($verticalrate == '' || $Common->isInteger($verticalrate) === false) $verticalrate = NULL;
1069
+            	if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0;
1070
+            	if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0;
1071 1071
 		
1072 1072
 		$query = '';
1073 1073
 		if ($globalArchive) {
@@ -1078,19 +1078,19 @@  discard block
 block discarded – undo
1078 1078
 		$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, real_altitude) 
1079 1079
 		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, :real_altitude)';
1080 1080
 
1081
-		$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,':real_altitude' => $altitude_real);
1081
+		$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, ':real_altitude' => $altitude_real);
1082 1082
 		try {
1083 1083
 			
1084 1084
 			$sth = $this->db->prepare($query);
1085 1085
 			$sth->execute($query_values);
1086 1086
 			$sth->closeCursor();
1087
-		} catch(PDOException $e) {
1087
+		} catch (PDOException $e) {
1088 1088
 			return "error : ".$e->getMessage();
1089 1089
 		}
1090 1090
 		if (isset($globalArchive) && $globalArchive && $putinarchive && $noarchive !== true) {
1091 1091
 		    if ($globalDebug) echo '(Add to SBS archive : ';
1092 1092
 		    $SpotterArchive = new SpotterArchive($this->db);
1093
-		    $result =  $SpotterArchive->addSpotterArchiveData($flightaware_id, $ident, $registration, $airline_name, $airline_icao, $airline_country, $airline_type, $aircraft_icao, $aircraft_shadow, $aircraft_name, $aircraft_manufacturer, $departure_airport_icao, $departure_airport_name, $departure_airport_city, $departure_airport_country, $departure_airport_time,$arrival_airport_icao, $arrival_airport_name, $arrival_airport_city, $arrival_airport_country, $arrival_airport_time, $route_stop, $date,$latitude, $longitude, $waypoints, $altitude, $altitude_real,$heading, $groundspeed, $squawk, $ModeS, $pilot_id, $pilot_name,$verticalrate,$format_source,$source_name, $over_country);
1093
+		    $result = $SpotterArchive->addSpotterArchiveData($flightaware_id, $ident, $registration, $airline_name, $airline_icao, $airline_country, $airline_type, $aircraft_icao, $aircraft_shadow, $aircraft_name, $aircraft_manufacturer, $departure_airport_icao, $departure_airport_name, $departure_airport_city, $departure_airport_country, $departure_airport_time, $arrival_airport_icao, $arrival_airport_name, $arrival_airport_city, $arrival_airport_country, $arrival_airport_time, $route_stop, $date, $latitude, $longitude, $waypoints, $altitude, $altitude_real, $heading, $groundspeed, $squawk, $ModeS, $pilot_id, $pilot_name, $verticalrate, $format_source, $source_name, $over_country);
1094 1094
 		    if ($globalDebug) echo $result.')';
1095 1095
 		}
1096 1096
 		return "success";
@@ -1099,7 +1099,7 @@  discard block
 block discarded – undo
1099 1099
 
1100 1100
 	public function getOrderBy()
1101 1101
 	{
1102
-		$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"));
1102
+		$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"));
1103 1103
 		return $orderby;
1104 1104
 	}
1105 1105
 
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 
@@ -274,7 +287,9 @@  discard block
 block discarded – undo
274 287
 		global $globalDBdriver, $globalLiveInterval;
275 288
 		$filter_query = $this->getFilter($filter,true,true);
276 289
 
277
-		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
290
+		if (!isset($globalLiveInterval)) {
291
+			$globalLiveInterval = '200';
292
+		}
278 293
 		if ($globalDBdriver == 'mysql') {
279 294
 			//$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;
280 295
 			$query = 'SELECT COUNT(DISTINCT spotter_live.flightaware_id) as nb FROM spotter_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date';
@@ -304,7 +319,9 @@  discard block
 block discarded – undo
304 319
 	{
305 320
 		global $globalDBdriver, $globalLiveInterval;
306 321
 		$Spotter = new Spotter($this->db);
307
-		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
322
+		if (!isset($globalLiveInterval)) {
323
+			$globalLiveInterval = '200';
324
+		}
308 325
 		$filter_query = $this->getFilter($filter);
309 326
 
310 327
 		if (is_array($coord)) {
@@ -312,7 +329,9 @@  discard block
 block discarded – undo
312 329
 			$minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
313 330
 			$maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
314 331
 			$maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
315
-		} else return array();
332
+		} else {
333
+			return array();
334
+		}
316 335
 		if ($globalDBdriver == 'mysql') {
317 336
 			$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;
318 337
 		} else {
@@ -333,7 +352,9 @@  discard block
 block discarded – undo
333 352
 	{
334 353
 		global $globalDBdriver, $globalLiveInterval, $globalArchive;
335 354
 		$Spotter = new Spotter($this->db);
336
-		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
355
+		if (!isset($globalLiveInterval)) {
356
+			$globalLiveInterval = '200';
357
+		}
337 358
 		$filter_query = $this->getFilter($filter,true,true);
338 359
 
339 360
 		if (is_array($coord)) {
@@ -341,7 +362,9 @@  discard block
 block discarded – undo
341 362
 			$minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
342 363
 			$maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
343 364
 			$maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
344
-		} else return array();
365
+		} else {
366
+			return array();
367
+		}
345 368
 		if ($globalDBdriver == 'mysql') {
346 369
 			if (isset($globalArchive) && $globalArchive === TRUE) {
347 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 
@@ -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);
@@ -1064,14 +1105,24 @@  discard block
 block discarded – undo
1064 1105
 		$arrival_airport_country = '';
1065 1106
 		
1066 1107
             	
1067
-            	if ($squawk == '' || $Common->isInteger($squawk) === false ) $squawk = NULL;
1068
-            	if ($verticalrate == '' || $Common->isInteger($verticalrate) === false ) $verticalrate = NULL;
1069
-            	if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0;
1070
-            	if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0;
1108
+            	if ($squawk == '' || $Common->isInteger($squawk) === false ) {
1109
+            		$squawk = NULL;
1110
+            	}
1111
+            	if ($verticalrate == '' || $Common->isInteger($verticalrate) === false ) {
1112
+            		$verticalrate = NULL;
1113
+            	}
1114
+            	if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) {
1115
+            		$groundspeed = 0;
1116
+            	}
1117
+            	if ($heading == '' || $Common->isInteger($heading) === false ) {
1118
+            		$heading = 0;
1119
+            	}
1071 1120
 		
1072 1121
 		$query = '';
1073 1122
 		if ($globalArchive) {
1074
-			if ($globalDebug) echo '-- Delete previous data -- ';
1123
+			if ($globalDebug) {
1124
+				echo '-- Delete previous data -- ';
1125
+			}
1075 1126
 			$query .= 'DELETE FROM spotter_live WHERE flightaware_id = :flightaware_id;';
1076 1127
 		}
1077 1128
 
@@ -1088,10 +1139,14 @@  discard block
 block discarded – undo
1088 1139
 			return "error : ".$e->getMessage();
1089 1140
 		}
1090 1141
 		if (isset($globalArchive) && $globalArchive && $putinarchive && $noarchive !== true) {
1091
-		    if ($globalDebug) echo '(Add to SBS archive : ';
1142
+		    if ($globalDebug) {
1143
+		    	echo '(Add to SBS archive : ';
1144
+		    }
1092 1145
 		    $SpotterArchive = new SpotterArchive($this->db);
1093 1146
 		    $result =  $SpotterArchive->addSpotterArchiveData($flightaware_id, $ident, $registration, $airline_name, $airline_icao, $airline_country, $airline_type, $aircraft_icao, $aircraft_shadow, $aircraft_name, $aircraft_manufacturer, $departure_airport_icao, $departure_airport_name, $departure_airport_city, $departure_airport_country, $departure_airport_time,$arrival_airport_icao, $arrival_airport_name, $arrival_airport_city, $arrival_airport_country, $arrival_airport_time, $route_stop, $date,$latitude, $longitude, $waypoints, $altitude, $altitude_real,$heading, $groundspeed, $squawk, $ModeS, $pilot_id, $pilot_name,$verticalrate,$format_source,$source_name, $over_country);
1094
-		    if ($globalDebug) echo $result.')';
1147
+		    if ($globalDebug) {
1148
+		    	echo $result.')';
1149
+		    }
1095 1150
 		}
1096 1151
 		return "success";
1097 1152
 
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 = '', $real_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 = '', $real_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 = '', $real_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,real_altitude)
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,real_altitude)
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,:real_altitude)";
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,':real_altitude' => $real_altitude);
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, ':real_altitude' => $real_altitude);
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.
search.php 2 patches
Spacing   +94 added lines, -94 removed lines patch added patch discarded remove patch
@@ -16,40 +16,40 @@  discard block
 block discarded – undo
16 16
 
17 17
 if (isset($_GET['start_date'])) {
18 18
 	//for the date manipulation into the query
19
-	if($_GET['start_date'] != "" && $_GET['end_date'] != ""){
19
+	if ($_GET['start_date'] != "" && $_GET['end_date'] != "") {
20 20
 		//$start_date = $_GET['start_date']." 00:00:00";
21
-		$start_date = date("Y-m-d",strtotime($_GET['start_date']))." 00:00:00";
21
+		$start_date = date("Y-m-d", strtotime($_GET['start_date']))." 00:00:00";
22 22
 		//$end_date = $_GET['end_date']." 00:00:00";
23
-		$end_date = date("Y-m-d",strtotime($_GET['end_date']))." 00:00:00";
23
+		$end_date = date("Y-m-d", strtotime($_GET['end_date']))." 00:00:00";
24 24
 		$sql_date = $start_date.",".$end_date;
25
-	} else if($_GET['start_date'] != ""){
25
+	} else if ($_GET['start_date'] != "") {
26 26
 		//$start_date = $_GET['start_date']." 00:00:00";
27
-		$start_date = date("Y-m-d",strtotime($_GET['start_date']))." 00:00:00";
27
+		$start_date = date("Y-m-d", strtotime($_GET['start_date']))." 00:00:00";
28 28
 		$sql_date = $start_date;
29
-	} else if($_GET['start_date'] == "" && $_GET['end_date'] != ""){
29
+	} else if ($_GET['start_date'] == "" && $_GET['end_date'] != "") {
30 30
 		//$end_date = date("Y-m-d H:i:s", strtotime("2014-04-12")).",".$_GET['end_date']." 00:00:00";
31
-		$end_date = date("Y-m-d H:i:s", strtotime("2014-04-12")).",".date("Y-m-d",strtotime($_GET['end_date']))." 00:00:00";
31
+		$end_date = date("Y-m-d H:i:s", strtotime("2014-04-12")).",".date("Y-m-d", strtotime($_GET['end_date']))." 00:00:00";
32 32
 		$sql_date = $end_date;
33 33
 	} else $sql_date = '';
34 34
 } else $sql_date = '';
35 35
 
36 36
 if (isset($_GET['highest_altitude'])) {
37 37
 	//for altitude manipulation
38
-	if($_GET['highest_altitude'] != "" && $_GET['lowest_altitude'] != ""){
39
-		$end_altitude = filter_input(INPUT_GET,'highest_altitude',FILTER_SANITIZE_NUMBER_INT);
40
-		$start_altitude = filter_input(INPUT_GET,'lowest_altitude',FILTER_SANITIZE_NUMBER_INT);
38
+	if ($_GET['highest_altitude'] != "" && $_GET['lowest_altitude'] != "") {
39
+		$end_altitude = filter_input(INPUT_GET, 'highest_altitude', FILTER_SANITIZE_NUMBER_INT);
40
+		$start_altitude = filter_input(INPUT_GET, 'lowest_altitude', FILTER_SANITIZE_NUMBER_INT);
41 41
 		$sql_altitude = $start_altitude.",".$end_altitude;
42
-	} else if($_GET['highest_altitude'] != ""){
43
-		$end_altitude = filter_input(INPUT_GET,'highest_altitude',FILTER_SANITIZE_NUMBER_INT);
42
+	} else if ($_GET['highest_altitude'] != "") {
43
+		$end_altitude = filter_input(INPUT_GET, 'highest_altitude', FILTER_SANITIZE_NUMBER_INT);
44 44
 		$sql_altitude = $end_altitude;
45
-	} else if($_GET['highest_altitude'] == "" && $_GET['lowest_altitude'] != ""){
46
-		$start_altitude = filter_input(INPUT_GET,'lowest_altitude',FILTER_SANITIZE_NUMBER_INT).",60000";
45
+	} else if ($_GET['highest_altitude'] == "" && $_GET['lowest_altitude'] != "") {
46
+		$start_altitude = filter_input(INPUT_GET, 'lowest_altitude', FILTER_SANITIZE_NUMBER_INT).",60000";
47 47
 		$sql_altitude = $start_altitude;
48 48
 	} else $sql_altitude = '';
49 49
 } else $sql_altitude = '';
50 50
 
51 51
 //calculuation for the pagination
52
-if(!isset($_GET['limit']))
52
+if (!isset($_GET['limit']))
53 53
 {
54 54
 	if (!isset($_GET['number_results']))
55 55
 	{
@@ -57,45 +57,45 @@  discard block
 block discarded – undo
57 57
 		$limit_end = 25;
58 58
 		$absolute_difference = 25;
59 59
 	} else {
60
-		if ($_GET['number_results'] > 1000){
60
+		if ($_GET['number_results'] > 1000) {
61 61
 			$_GET['number_results'] = 1000;
62 62
 		}
63 63
 		$limit_start = 0;
64
-		$limit_end = filter_input(INPUT_GET,'number_results',FILTER_SANITIZE_NUMBER_INT);
65
-		$absolute_difference = filter_input(INPUT_GET,'number_results',FILTER_SANITIZE_NUMBER_INT);
64
+		$limit_end = filter_input(INPUT_GET, 'number_results', FILTER_SANITIZE_NUMBER_INT);
65
+		$absolute_difference = filter_input(INPUT_GET, 'number_results', FILTER_SANITIZE_NUMBER_INT);
66 66
 	}
67
-}  else {
67
+} else {
68 68
 	$limit_explode = explode(",", $_GET['limit']);
69
-	$limit_start = filter_var($limit_explode[0],FILTER_SANITIZE_NUMBER_INT);
70
-	$limit_end = filter_var($limit_explode[1],FILTER_SANITIZE_NUMBER_INT);
69
+	$limit_start = filter_var($limit_explode[0], FILTER_SANITIZE_NUMBER_INT);
70
+	$limit_end = filter_var($limit_explode[1], FILTER_SANITIZE_NUMBER_INT);
71 71
 }
72 72
 $absolute_difference = abs($limit_start - $limit_end);
73 73
 $limit_next = $limit_end + $absolute_difference;
74 74
 $limit_previous_1 = $limit_start - $absolute_difference;
75 75
 $limit_previous_2 = $limit_end - $absolute_difference;
76 76
 
77
-if (!empty($_GET)){  
78
-	$q = filter_input(INPUT_GET, 'q',FILTER_SANITIZE_STRING);
79
-	$registration = filter_input(INPUT_GET, 'registration',FILTER_SANITIZE_STRING);
80
-	$aircraft = filter_input(INPUT_GET, 'aircraft',FILTER_SANITIZE_STRING);
81
-	$manufacturer = filter_input(INPUT_GET, 'manufacturer',FILTER_SANITIZE_STRING);
82
-	$highlights = filter_input(INPUT_GET, 'highlights',FILTER_SANITIZE_STRING);
83
-	$airline = filter_input(INPUT_GET, 'airline',FILTER_SANITIZE_STRING);
84
-	$airline_country = filter_input(INPUT_GET, 'airline_country',FILTER_SANITIZE_STRING);
85
-	$airline_type = filter_input(INPUT_GET, 'airline_type',FILTER_SANITIZE_STRING);
86
-	$airport = filter_input(INPUT_GET, 'airport',FILTER_SANITIZE_STRING);
87
-	$airport_country = filter_input(INPUT_GET, 'airport_country',FILTER_SANITIZE_STRING);
88
-	$callsign = filter_input(INPUT_GET, 'callsign',FILTER_SANITIZE_STRING);
89
-	$owner = filter_input(INPUT_GET, 'owner',FILTER_SANITIZE_STRING);
90
-	$pilot_name = filter_input(INPUT_GET, 'pilot_name',FILTER_SANITIZE_STRING);
91
-	$pilot_id = filter_input(INPUT_GET, 'pilot_id',FILTER_SANITIZE_STRING);
92
-	$departure_airport_route = filter_input(INPUT_GET, 'departure_airport_route',FILTER_SANITIZE_STRING);
93
-	$arrival_airport_route = filter_input(INPUT_GET, 'arrival_airport_route',FILTER_SANITIZE_STRING);
94
-	$sort = filter_input(INPUT_GET,'sort',FILTER_SANITIZE_STRING);
95
-	$archive = filter_input(INPUT_GET,'archive',FILTER_SANITIZE_NUMBER_INT);
96
-	$origlat = filter_input(INPUT_GET,'origlat',FILTER_SANITIZE_STRING);
97
-	$origlon = filter_input(INPUT_GET,'origlon',FILTER_SANITIZE_STRING);
98
-	$dist = filter_input(INPUT_GET,'dist',FILTER_SANITIZE_NUMBER_INT);
77
+if (!empty($_GET)) {  
78
+	$q = filter_input(INPUT_GET, 'q', FILTER_SANITIZE_STRING);
79
+	$registration = filter_input(INPUT_GET, 'registration', FILTER_SANITIZE_STRING);
80
+	$aircraft = filter_input(INPUT_GET, 'aircraft', FILTER_SANITIZE_STRING);
81
+	$manufacturer = filter_input(INPUT_GET, 'manufacturer', FILTER_SANITIZE_STRING);
82
+	$highlights = filter_input(INPUT_GET, 'highlights', FILTER_SANITIZE_STRING);
83
+	$airline = filter_input(INPUT_GET, 'airline', FILTER_SANITIZE_STRING);
84
+	$airline_country = filter_input(INPUT_GET, 'airline_country', FILTER_SANITIZE_STRING);
85
+	$airline_type = filter_input(INPUT_GET, 'airline_type', FILTER_SANITIZE_STRING);
86
+	$airport = filter_input(INPUT_GET, 'airport', FILTER_SANITIZE_STRING);
87
+	$airport_country = filter_input(INPUT_GET, 'airport_country', FILTER_SANITIZE_STRING);
88
+	$callsign = filter_input(INPUT_GET, 'callsign', FILTER_SANITIZE_STRING);
89
+	$owner = filter_input(INPUT_GET, 'owner', FILTER_SANITIZE_STRING);
90
+	$pilot_name = filter_input(INPUT_GET, 'pilot_name', FILTER_SANITIZE_STRING);
91
+	$pilot_id = filter_input(INPUT_GET, 'pilot_id', FILTER_SANITIZE_STRING);
92
+	$departure_airport_route = filter_input(INPUT_GET, 'departure_airport_route', FILTER_SANITIZE_STRING);
93
+	$arrival_airport_route = filter_input(INPUT_GET, 'arrival_airport_route', FILTER_SANITIZE_STRING);
94
+	$sort = filter_input(INPUT_GET, 'sort', FILTER_SANITIZE_STRING);
95
+	$archive = filter_input(INPUT_GET, 'archive', FILTER_SANITIZE_NUMBER_INT);
96
+	$origlat = filter_input(INPUT_GET, 'origlat', FILTER_SANITIZE_STRING);
97
+	$origlon = filter_input(INPUT_GET, 'origlon', FILTER_SANITIZE_STRING);
98
+	$dist = filter_input(INPUT_GET, 'dist', FILTER_SANITIZE_NUMBER_INT);
99 99
 	if ($dist != '') {
100 100
 		if (isset($globalDistanceUnit) && $globalDistanceUnit == 'mi') $dist = $dist*1.60934;
101 101
 		elseif (isset($globalDistanceUnit) && $globalDistanceUnit == 'nm') $dist = $dist*1.852;
@@ -103,9 +103,9 @@  discard block
 block discarded – undo
103 103
 	if (!isset($sql_date)) $sql_date = '';
104 104
 	if ($archive == 1) {
105 105
 		$SpotterArchive = new SpotterArchive();
106
-		$spotter_array = $SpotterArchive->searchSpotterData($q,$registration,$aircraft,strtolower(str_replace("-", " ", $manufacturer)),$highlights,$airline,$airline_country,$airline_type,$airport,$airport_country,$callsign,$departure_airport_route,$arrival_airport_route,$owner,$pilot_id,$pilot_name,$sql_altitude,$sql_date,$limit_start.",".$absolute_difference,$sort,'',$origlat,$origlon,$dist);
106
+		$spotter_array = $SpotterArchive->searchSpotterData($q, $registration, $aircraft, strtolower(str_replace("-", " ", $manufacturer)), $highlights, $airline, $airline_country, $airline_type, $airport, $airport_country, $callsign, $departure_airport_route, $arrival_airport_route, $owner, $pilot_id, $pilot_name, $sql_altitude, $sql_date, $limit_start.",".$absolute_difference, $sort, '', $origlat, $origlon, $dist);
107 107
 	} else {
108
-		$spotter_array = $Spotter->searchSpotterData($q,$registration,$aircraft,strtolower(str_replace("-", " ", $manufacturer)),$highlights,$airline,$airline_country,$airline_type,$airport,$airport_country,$callsign,$departure_airport_route,$arrival_airport_route,$owner,$pilot_id,$pilot_name,$sql_altitude,$sql_date,$limit_start.",".$absolute_difference,$sort,'',$origlat,$origlon,$dist);
108
+		$spotter_array = $Spotter->searchSpotterData($q, $registration, $aircraft, strtolower(str_replace("-", " ", $manufacturer)), $highlights, $airline, $airline_country, $airline_type, $airport, $airport_country, $callsign, $departure_airport_route, $arrival_airport_route, $owner, $pilot_id, $pilot_name, $sql_altitude, $sql_date, $limit_start.",".$absolute_difference, $sort, '', $origlat, $origlon, $dist);
109 109
 	}
110 110
 	 
111 111
 	print '<span class="sub-menu-statistic column mobile">';
@@ -138,12 +138,12 @@  discard block
 block discarded – undo
138 138
 	//remove 3D=true parameter
139 139
 	$no3D = str_replace("&3D=true", "", $_SERVER['QUERY_STRING']);
140 140
 	$kmlURL = str_replace("http://", "kml://", $globalURL);
141
-	if (!isset($_GET['3D'])){
141
+	if (!isset($_GET['3D'])) {
142 142
 		print '<li><a href="'.$globalURL.'/search?'.$no3D.'" class="active"><i class="fa fa-table"></i> '._("Table").'</a></li>';
143 143
 	} else {
144 144
 		print '<li><span class="notablet"><a href="'.$globalURL.'/search?'.$no3D.'"><i class="fa fa-table"></i> '._("Table").'</a></span></li>';
145 145
 	}
146
-	if (isset($_GET['3D'])){
146
+	if (isset($_GET['3D'])) {
147 147
 		print '<li><a href="'.$globalURL.'/search?'.$no3D.'&3D=true" class="active"><i class="fa fa-globe"></i> '._("3D Map").'</a></li>';
148 148
 	} else {
149 149
 		print '<li ><a href="'.$globalURL.'/search?'.$no3D.'&3D=true" class="notablet nomobile"><i class="fa fa-globe"></i> '._("3D Map").'</a><a href="'.$kmlURL.'/search/kml?'.htmlentities($_SERVER['QUERY_STRING']).'" class="tablet mobile"><i class="fa fa-globe"></i> 3D Map</a></li>';
@@ -164,30 +164,30 @@  discard block
 block discarded – undo
164 164
 		print '<div class="column">';
165 165
 		print '<div class="info">';
166 166
 		print '<h1>'._("Search Results for").' ';
167
-		if (isset($_GET['q']) && $_GET['q'] != ""){ print _("Keyword:").' <span>'.$q.'</span> '; }
168
-		if (isset($_GET['aircraft']) && $_GET['aircraft'] != ""){ print _("Aircraft:").' <span>'.$aircraft.'</span> '; }
169
-		if (isset($_GET['manufacturer']) && $_GET['manufacturer'] != ""){ print _("Manufacturer:").' <span>'.$manufacturer.'</span> '; }
170
-		if (isset($_GET['registration']) && $_GET['registration'] != ""){ print _("Registration:").' <span>'.$registration.'</span> '; }
171
-		if (isset($_GET['highlights'])) if ($_GET['highlights'] == "true"){ print _("Highlights:").' <span>'.$highlights.'</span> '; }
172
-		if (isset($_GET['airline']) && $_GET['airline'] != ""){ print _("Airline:").' <span>'.$airline.'</span> '; }
173
-		if (isset($_GET['airline_country']) && $_GET['airline_country'] != ""){ print _("Airline country:").' <span>'.$airline_country.'</span> '; }
174
-		if (isset($_GET['airline_type']) && $_GET['airline_type'] != ""){ print _("Airline type:").' <span>'.$airline_type.'</span> '; }
175
-		if (isset($_GET['airport']) && $_GET['airport'] != ""){ print _("Airport:").' <span>'.$airport.'</span> '; }
176
-		if (isset($_GET['airport_country']) && $_GET['airport_country'] != ""){ print _("Airport country:").' <span>'.$airport_country.'</span> '; }
177
-		if (isset($_GET['callsign']) && $_GET['callsign'] != ""){ print _("Callsign:").' <span>'.$callsign.'</span> '; }
178
-		if (isset($_GET['owner']) && $_GET['owner'] != ""){ print _("Owner:").' <span>'.$owner.'</span> '; }
179
-		if (isset($_GET['pilot_id']) && $_GET['pilot_id'] != ""){ print _("Pilot id:").' <span>'.$pilot_id.'</span> '; }
180
-		if (isset($_GET['pilot_name']) && $_GET['pilot_name'] != ""){ print _("Pilot name:").' <span>'.$pilot_name.'</span> '; }
181
-		if (isset($_GET['departure_airport_route']) && $_GET['departure_airport_route'] != "" && (!isset($_GET['arrival_airport_route']) || $_GET['arrival_airport_route'] == "")){ print _("Route out of:").' <span>'.$departure_airport_route.'</span> '; }
182
-		if (isset($_GET['departure_airport_route']) && $_GET['departure_airport_route'] == "" && isset($_GET['arrival_airport_route']) && $_GET['arrival_airport_route'] != ""){ print _("Route into:").' <span>'.$arrival_airport_route.'</span> '; }
183
-		if (isset($_GET['departure_airport_route']) && $_GET['departure_airport_route'] != "" && isset($_GET['arrival_airport_route']) && $_GET['arrival_airport_route'] != ""){ print _("Route between:").' <span>'.$departure_airport_route.'</span> and <span>'.$_GET['arrival_airport_route'].'</span> '; }
184
-		if (isset($_GET['start_date']) && $_GET['start_date'] != "" && isset($_GET['end_date']) && $_GET['end_date'] == ""){ print _("Date starting at:").' <span>'.$start_date.'</span> '; }
185
-		if (isset($_GET['start_date']) && $_GET['start_date'] == "" && isset($_GET['end_date']) && $_GET['end_date'] != ""){ print _("Date ending at:").' <span>'.$end_date.'</span> '; }
186
-		if (isset($_GET['start_date']) && $_GET['start_date'] != "" && isset($_GET['end_date']) && $_GET['end_date'] != ""){ print _("Date between:").' <span>'.$start_date.'</span> and <span>'.$end_date.'</span> '; }
187
-		if (isset($_GET['lowest_altitude']) && $_GET['lowest_altitude'] != "" && isset($_GET['highest_altitude']) && $_GET['highest_altitude'] == ""){ print _("Altitude starting at:").' <span>'.number_format($lowest_altitude).' feet</span> '; }
188
-		if (isset($_GET['lowest_altitude']) && $_GET['lowest_altitude'] == "" && isset($_GET['highest_altitude']) && $_GET['highest_altitude'] != ""){ print _("Altitude ending at:").' <span>'.number_format($highest_altitude).' feet</span> '; }
189
-		if (isset($_GET['lowest_altitude']) && $_GET['lowest_altitude'] != "" && isset($_GET['highest_altitude']) && $_GET['highest_altitude'] != ""){ print _("Altitude between:").' <span>'.number_format($lowest_altitude).' feet</span> '._("and").' <span>'.number_format($highest_altitude).' feet</span> '; }
190
-		if (isset($_GET['number_results']) && $_GET['number_results'] != ""){ print _("limit per page:").' <span>'.$number_results.'</span> '; }
167
+		if (isset($_GET['q']) && $_GET['q'] != "") { print _("Keyword:").' <span>'.$q.'</span> '; }
168
+		if (isset($_GET['aircraft']) && $_GET['aircraft'] != "") { print _("Aircraft:").' <span>'.$aircraft.'</span> '; }
169
+		if (isset($_GET['manufacturer']) && $_GET['manufacturer'] != "") { print _("Manufacturer:").' <span>'.$manufacturer.'</span> '; }
170
+		if (isset($_GET['registration']) && $_GET['registration'] != "") { print _("Registration:").' <span>'.$registration.'</span> '; }
171
+		if (isset($_GET['highlights'])) if ($_GET['highlights'] == "true") { print _("Highlights:").' <span>'.$highlights.'</span> '; }
172
+		if (isset($_GET['airline']) && $_GET['airline'] != "") { print _("Airline:").' <span>'.$airline.'</span> '; }
173
+		if (isset($_GET['airline_country']) && $_GET['airline_country'] != "") { print _("Airline country:").' <span>'.$airline_country.'</span> '; }
174
+		if (isset($_GET['airline_type']) && $_GET['airline_type'] != "") { print _("Airline type:").' <span>'.$airline_type.'</span> '; }
175
+		if (isset($_GET['airport']) && $_GET['airport'] != "") { print _("Airport:").' <span>'.$airport.'</span> '; }
176
+		if (isset($_GET['airport_country']) && $_GET['airport_country'] != "") { print _("Airport country:").' <span>'.$airport_country.'</span> '; }
177
+		if (isset($_GET['callsign']) && $_GET['callsign'] != "") { print _("Callsign:").' <span>'.$callsign.'</span> '; }
178
+		if (isset($_GET['owner']) && $_GET['owner'] != "") { print _("Owner:").' <span>'.$owner.'</span> '; }
179
+		if (isset($_GET['pilot_id']) && $_GET['pilot_id'] != "") { print _("Pilot id:").' <span>'.$pilot_id.'</span> '; }
180
+		if (isset($_GET['pilot_name']) && $_GET['pilot_name'] != "") { print _("Pilot name:").' <span>'.$pilot_name.'</span> '; }
181
+		if (isset($_GET['departure_airport_route']) && $_GET['departure_airport_route'] != "" && (!isset($_GET['arrival_airport_route']) || $_GET['arrival_airport_route'] == "")) { print _("Route out of:").' <span>'.$departure_airport_route.'</span> '; }
182
+		if (isset($_GET['departure_airport_route']) && $_GET['departure_airport_route'] == "" && isset($_GET['arrival_airport_route']) && $_GET['arrival_airport_route'] != "") { print _("Route into:").' <span>'.$arrival_airport_route.'</span> '; }
183
+		if (isset($_GET['departure_airport_route']) && $_GET['departure_airport_route'] != "" && isset($_GET['arrival_airport_route']) && $_GET['arrival_airport_route'] != "") { print _("Route between:").' <span>'.$departure_airport_route.'</span> and <span>'.$_GET['arrival_airport_route'].'</span> '; }
184
+		if (isset($_GET['start_date']) && $_GET['start_date'] != "" && isset($_GET['end_date']) && $_GET['end_date'] == "") { print _("Date starting at:").' <span>'.$start_date.'</span> '; }
185
+		if (isset($_GET['start_date']) && $_GET['start_date'] == "" && isset($_GET['end_date']) && $_GET['end_date'] != "") { print _("Date ending at:").' <span>'.$end_date.'</span> '; }
186
+		if (isset($_GET['start_date']) && $_GET['start_date'] != "" && isset($_GET['end_date']) && $_GET['end_date'] != "") { print _("Date between:").' <span>'.$start_date.'</span> and <span>'.$end_date.'</span> '; }
187
+		if (isset($_GET['lowest_altitude']) && $_GET['lowest_altitude'] != "" && isset($_GET['highest_altitude']) && $_GET['highest_altitude'] == "") { print _("Altitude starting at:").' <span>'.number_format($lowest_altitude).' feet</span> '; }
188
+		if (isset($_GET['lowest_altitude']) && $_GET['lowest_altitude'] == "" && isset($_GET['highest_altitude']) && $_GET['highest_altitude'] != "") { print _("Altitude ending at:").' <span>'.number_format($highest_altitude).' feet</span> '; }
189
+		if (isset($_GET['lowest_altitude']) && $_GET['lowest_altitude'] != "" && isset($_GET['highest_altitude']) && $_GET['highest_altitude'] != "") { print _("Altitude between:").' <span>'.number_format($lowest_altitude).' feet</span> '._("and").' <span>'.number_format($highest_altitude).' feet</span> '; }
190
+		if (isset($_GET['number_results']) && $_GET['number_results'] != "") { print _("limit per page:").' <span>'.$number_results.'</span> '; }
191 191
 		print '</h1>';
192 192
 		print '</div>';
193 193
 
@@ -294,7 +294,7 @@  discard block
 block discarded – undo
294 294
 					    </select>
295 295
 					</div>
296 296
 				</div>
297
-				<script type="text/javascript">getSelect('manufacturer','<?php if(isset($_GET['manufacturer'])) print $manufacturer; ?>')</script>
297
+				<script type="text/javascript">getSelect('manufacturer','<?php if (isset($_GET['manufacturer'])) print $manufacturer; ?>')</script>
298 298
 				<div class="form-group">
299 299
 					<label class="control-label col-sm-2"><?php echo _("Type"); ?></label>
300 300
 						<div class="col-sm-10">
@@ -303,7 +303,7 @@  discard block
 block discarded – undo
303 303
 							</select>
304 304
 						</div>
305 305
 				</div>
306
-				<script type="text/javascript">getSelect('aircrafttypes','<?php if(isset($_GET['aircraft_icao'])) print $aircraft_icao; ?>');</script>
306
+				<script type="text/javascript">getSelect('aircrafttypes','<?php if (isset($_GET['aircraft_icao'])) print $aircraft_icao; ?>');</script>
307 307
 				<div class="form-group">
308 308
 					<label class="control-label col-sm-2"><?php echo _("Registration"); ?></label> 
309 309
 					<div class="col-sm-10">
@@ -326,7 +326,7 @@  discard block
 block discarded – undo
326 326
 					</div>
327 327
 				</div>
328 328
 <?php
329
-}else {
329
+} else {
330 330
 ?>
331 331
 				<div class="form-group">
332 332
 					<label class="control-label col-sm-2"><?php echo _("Owner name"); ?></label> 
@@ -339,8 +339,8 @@  discard block
 block discarded – undo
339 339
 ?>
340 340
 				<div class="form-group">
341 341
 					<div class="col-sm-offset-2 col-sm-10">
342
-					<!--<div><input type="checkbox" class="form-control" name="highlights" value="true" id="highlights" <?php if (isset($_GET['highlights'])) if ($_GET['highlights'] == "true"){ print 'checked="checked"'; } ?>> <label for="highlights"><?php echo _("Include only aircrafts with special highlights (unique liveries, destinations etc.)"); ?></label></div>-->
343
-					<label class="checkbox-inline"><input type="checkbox" name="highlights" value="true" id="highlights" <?php if (isset($_GET['highlights'])) if ($_GET['highlights'] == "true"){ print 'checked="checked"'; } ?>> <?php echo _("Include only aircrafts with special highlights (unique liveries, destinations etc.)"); ?></label>
342
+					<!--<div><input type="checkbox" class="form-control" name="highlights" value="true" id="highlights" <?php if (isset($_GET['highlights'])) if ($_GET['highlights'] == "true") { print 'checked="checked"'; } ?>> <label for="highlights"><?php echo _("Include only aircrafts with special highlights (unique liveries, destinations etc.)"); ?></label></div>-->
343
+					<label class="checkbox-inline"><input type="checkbox" name="highlights" value="true" id="highlights" <?php if (isset($_GET['highlights'])) if ($_GET['highlights'] == "true") { print 'checked="checked"'; } ?>> <?php echo _("Include only aircrafts with special highlights (unique liveries, destinations etc.)"); ?></label>
344 344
 					</div>
345 345
 				</div>
346 346
 			</fieldset>
@@ -354,7 +354,7 @@  discard block
 block discarded – undo
354 354
 						</select>
355 355
 					</div>
356 356
 				</div>
357
-				<script type="text/javascript">getSelect('airlinenames','<?php if(isset($_GET['airline'])) print $airline; ?>');</script>
357
+				<script type="text/javascript">getSelect('airlinenames','<?php if (isset($_GET['airline'])) print $airline; ?>');</script>
358 358
 				<div class="form-group">
359 359
 					<label class="control-label col-sm-2"><?php echo _("Country"); ?></label> 
360 360
 					<div class="col-sm-10">
@@ -363,7 +363,7 @@  discard block
 block discarded – undo
363 363
 						</select>
364 364
 					</div>
365 365
 				</div>
366
-				<script type="text/javascript">getSelect('airlinecountries','<?php if(isset($_GET['airline_country'])) print $airline_country; ?>');</script>
366
+				<script type="text/javascript">getSelect('airlinecountries','<?php if (isset($_GET['airline_country'])) print $airline_country; ?>');</script>
367 367
 				<div class="form-group">
368 368
 					<label class="control-label col-sm-2"><?php echo _("Callsign"); ?></label> 
369 369
 					<div class="col-sm-10">
@@ -372,10 +372,10 @@  discard block
 block discarded – undo
372 372
 				</div>
373 373
 				<div class="form-group">
374 374
 					<div class="col-sm-offset-2 col-sm-10">
375
-						<label class="radio-inline"><input type="radio" name="airline_type" value="all" id="airline_type_all" <?php if (!isset($_GET['airline_type']) || $_GET['airline_type'] == "all"){ print 'checked="checked"'; } ?>> <?php echo _("All airlines types"); ?></label>
376
-						<label class="radio-inline"><input type="radio" name="airline_type" value="passenger" id="airline_type_passenger" <?php if (isset($_GET['airline_type'])) if ($_GET['airline_type'] == "passenger"){ print 'checked="checked"'; } ?>> <?php echo _("Only Passenger airlines"); ?></label>
377
-						<label class="radio-inline"><input type="radio" name="airline_type" value="cargo" id="airline_type_cargo" <?php if (isset($_GET['airline_type'])) if ( $_GET['airline_type'] == "cargo"){ print 'checked="checked"'; } ?>> <?php echo _("Only Cargo airlines"); ?></label>
378
-						<label class="radio-inline"><input type="radio" name="airline_type" value="military" id="airline_type_military" <?php if (isset($_GET['airline_type'])) if ( $_GET['airline_type'] == "military"){ print 'checked="checked"'; } ?>> <?php echo _("Only Military airlines"); ?></label>
375
+						<label class="radio-inline"><input type="radio" name="airline_type" value="all" id="airline_type_all" <?php if (!isset($_GET['airline_type']) || $_GET['airline_type'] == "all") { print 'checked="checked"'; } ?>> <?php echo _("All airlines types"); ?></label>
376
+						<label class="radio-inline"><input type="radio" name="airline_type" value="passenger" id="airline_type_passenger" <?php if (isset($_GET['airline_type'])) if ($_GET['airline_type'] == "passenger") { print 'checked="checked"'; } ?>> <?php echo _("Only Passenger airlines"); ?></label>
377
+						<label class="radio-inline"><input type="radio" name="airline_type" value="cargo" id="airline_type_cargo" <?php if (isset($_GET['airline_type'])) if ($_GET['airline_type'] == "cargo") { print 'checked="checked"'; } ?>> <?php echo _("Only Cargo airlines"); ?></label>
378
+						<label class="radio-inline"><input type="radio" name="airline_type" value="military" id="airline_type_military" <?php if (isset($_GET['airline_type'])) if ($_GET['airline_type'] == "military") { print 'checked="checked"'; } ?>> <?php echo _("Only Military airlines"); ?></label>
379 379
 					</div>
380 380
 				</div>
381 381
 			</fieldset>
@@ -389,7 +389,7 @@  discard block
 block discarded – undo
389 389
 						</select>
390 390
 					</div>
391 391
 				</div>
392
-				<script type="text/javascript">getSelect('airportnames','<?php if(isset($_GET['airport_icao'])) print $airport_icao; ?>');</script>
392
+				<script type="text/javascript">getSelect('airportnames','<?php if (isset($_GET['airport_icao'])) print $airport_icao; ?>');</script>
393 393
 				<div class="form-group">
394 394
 					<label class="control-label col-sm-2"><?php echo _("Country"); ?></label> 
395 395
 					<div class="col-sm-10">
@@ -398,7 +398,7 @@  discard block
 block discarded – undo
398 398
 						</select>
399 399
 					</div>
400 400
 				</div>
401
-				<script type="text/javascript">getSelect('airportcountries','<?php if(isset($_GET['airport_country'])) print $airport_country; ?>');</script>
401
+				<script type="text/javascript">getSelect('airportcountries','<?php if (isset($_GET['airport_country'])) print $airport_country; ?>');</script>
402 402
 			</fieldset>
403 403
 			<fieldset>
404 404
 				<legend><?php echo _("Route"); ?></legend>
@@ -410,7 +410,7 @@  discard block
 block discarded – undo
410 410
 						</select>
411 411
 					</div>
412 412
 				</div>
413
-				<script type="text/javascript">getSelect('departureairportnames','<?php if(isset($_GET['departure_airport_route'])) print $departure_airport_route; ?>');</script>
413
+				<script type="text/javascript">getSelect('departureairportnames','<?php if (isset($_GET['departure_airport_route'])) print $departure_airport_route; ?>');</script>
414 414
 				<div class="form-group">
415 415
 					<label class="control-label col-sm-2"><?php echo _("Arrival Airport"); ?></label> 
416 416
 					<div class="col-sm-10">
@@ -419,7 +419,7 @@  discard block
 block discarded – undo
419 419
 						</select>
420 420
 					</div>
421 421
 				</div>
422
-				<script type="text/javascript">getSelect('arrivalairportnames','<?php if(isset($_GET['arrival_airport_route'])) print $arrival_airport_route; ?>');</script>
422
+				<script type="text/javascript">getSelect('arrivalairportnames','<?php if (isset($_GET['arrival_airport_route'])) print $arrival_airport_route; ?>');</script>
423 423
 			</fieldset>
424 424
 			<fieldset>
425 425
 				<legend><?php echo _("Date"); ?></legend>
@@ -473,9 +473,9 @@  discard block
 block discarded – undo
473 473
 						<option></option>
474 474
 <?php
475 475
 $altitude_array = Array(1000, 5000, 10000, 15000, 20000, 25000, 30000, 35000, 40000, 45000, 50000);
476
-foreach($altitude_array as $altitude)
476
+foreach ($altitude_array as $altitude)
477 477
 {
478
-	if(isset($_GET['lowest_altitude']) && $_GET['lowest_altitude'] == $altitude)
478
+	if (isset($_GET['lowest_altitude']) && $_GET['lowest_altitude'] == $altitude)
479 479
 	{
480 480
 		print '<option value="'.$altitude.'" selected="selected">'.number_format($altitude).' feet</option>';
481 481
 	} else {
@@ -493,9 +493,9 @@  discard block
 block discarded – undo
493 493
 					<option></option>
494 494
 <?php
495 495
 $altitude_array = Array(1000, 5000, 10000, 15000, 20000, 25000, 30000, 35000, 40000, 45000, 50000);
496
-foreach($altitude_array as $altitude)
496
+foreach ($altitude_array as $altitude)
497 497
 {
498
-	if(isset($_GET['highest_altitude']) && $_GET['highest_altitude'] == $altitude)
498
+	if (isset($_GET['highest_altitude']) && $_GET['highest_altitude'] == $altitude)
499 499
 	{
500 500
 		print '<option value="'.$altitude.'" selected="selected">'.number_format($altitude).' feet</option>';
501 501
 	} else {
@@ -534,10 +534,10 @@  discard block
 block discarded – undo
534 534
 				<div class="col-sm-10">
535 535
 					<select class="form-control" name="number_results">
536 536
 <?php
537
-$number_results_array = Array(25, 50, 100, 150, 200, 250, 300, 400, 500,  600, 700, 800, 900, 1000);
538
-foreach($number_results_array as $number)
537
+$number_results_array = Array(25, 50, 100, 150, 200, 250, 300, 400, 500, 600, 700, 800, 900, 1000);
538
+foreach ($number_results_array as $number)
539 539
 {
540
-	if(isset($_GET['number_results']) && $_GET['number_results'] == $number)
540
+	if (isset($_GET['number_results']) && $_GET['number_results'] == $number)
541 541
 	{
542 542
 		print '<option value="'.$number.'" selected="selected">'.$number.'</option>';
543 543
 	} else {
@@ -555,7 +555,7 @@  discard block
 block discarded – undo
555 555
 		<fieldset>
556 556
 			<div class="form-group">
557 557
 				<div class="col-sm-offset-2 col-sm-10">
558
-					<label class="checkbox-inline"><input type="checkbox" name="archive" value="1" /><?php echo sprintf(_("Search in archive (older than %s months)"),$globalArchiveKeepMonths); ?></label>
558
+					<label class="checkbox-inline"><input type="checkbox" name="archive" value="1" /><?php echo sprintf(_("Search in archive (older than %s months)"), $globalArchiveKeepMonths); ?></label>
559 559
 				</div>
560 560
 			</div>
561 561
 		</fieldset>
Please login to merge, or discard this patch.
Braces   +128 added lines, -35 removed lines patch added patch discarded remove patch
@@ -30,8 +30,12 @@  discard block
 block discarded – undo
30 30
 		//$end_date = date("Y-m-d H:i:s", strtotime("2014-04-12")).",".$_GET['end_date']." 00:00:00";
31 31
 		$end_date = date("Y-m-d H:i:s", strtotime("2014-04-12")).",".date("Y-m-d",strtotime($_GET['end_date']))." 00:00:00";
32 32
 		$sql_date = $end_date;
33
-	} else $sql_date = '';
34
-} else $sql_date = '';
33
+	} else {
34
+		$sql_date = '';
35
+	}
36
+	} else {
37
+	$sql_date = '';
38
+}
35 39
 
36 40
 if (isset($_GET['highest_altitude'])) {
37 41
 	//for altitude manipulation
@@ -45,8 +49,12 @@  discard block
 block discarded – undo
45 49
 	} else if($_GET['highest_altitude'] == "" && $_GET['lowest_altitude'] != ""){
46 50
 		$start_altitude = filter_input(INPUT_GET,'lowest_altitude',FILTER_SANITIZE_NUMBER_INT).",60000";
47 51
 		$sql_altitude = $start_altitude;
48
-	} else $sql_altitude = '';
49
-} else $sql_altitude = '';
52
+	} else {
53
+		$sql_altitude = '';
54
+	}
55
+	} else {
56
+	$sql_altitude = '';
57
+}
50 58
 
51 59
 //calculuation for the pagination
52 60
 if(!isset($_GET['limit']))
@@ -64,7 +72,7 @@  discard block
 block discarded – undo
64 72
 		$limit_end = filter_input(INPUT_GET,'number_results',FILTER_SANITIZE_NUMBER_INT);
65 73
 		$absolute_difference = filter_input(INPUT_GET,'number_results',FILTER_SANITIZE_NUMBER_INT);
66 74
 	}
67
-}  else {
75
+} else {
68 76
 	$limit_explode = explode(",", $_GET['limit']);
69 77
 	$limit_start = filter_var($limit_explode[0],FILTER_SANITIZE_NUMBER_INT);
70 78
 	$limit_end = filter_var($limit_explode[1],FILTER_SANITIZE_NUMBER_INT);
@@ -97,10 +105,15 @@  discard block
 block discarded – undo
97 105
 	$origlon = filter_input(INPUT_GET,'origlon',FILTER_SANITIZE_STRING);
98 106
 	$dist = filter_input(INPUT_GET,'dist',FILTER_SANITIZE_NUMBER_INT);
99 107
 	if ($dist != '') {
100
-		if (isset($globalDistanceUnit) && $globalDistanceUnit == 'mi') $dist = $dist*1.60934;
101
-		elseif (isset($globalDistanceUnit) && $globalDistanceUnit == 'nm') $dist = $dist*1.852;
108
+		if (isset($globalDistanceUnit) && $globalDistanceUnit == 'mi') {
109
+			$dist = $dist*1.60934;
110
+		} elseif (isset($globalDistanceUnit) && $globalDistanceUnit == 'nm') {
111
+			$dist = $dist*1.852;
112
+		}
113
+	}
114
+	if (!isset($sql_date)) {
115
+		$sql_date = '';
102 116
 	}
103
-	if (!isset($sql_date)) $sql_date = '';
104 117
 	if ($archive == 1) {
105 118
 		$SpotterArchive = new SpotterArchive();
106 119
 		$spotter_array = $SpotterArchive->searchSpotterData($q,$registration,$aircraft,strtolower(str_replace("-", " ", $manufacturer)),$highlights,$airline,$airline_country,$airline_type,$airport,$airport_country,$callsign,$departure_airport_route,$arrival_airport_route,$owner,$pilot_id,$pilot_name,$sql_altitude,$sql_date,$limit_start.",".$absolute_difference,$sort,'',$origlat,$origlon,$dist);
@@ -168,7 +181,10 @@  discard block
 block discarded – undo
168 181
 		if (isset($_GET['aircraft']) && $_GET['aircraft'] != ""){ print _("Aircraft:").' <span>'.$aircraft.'</span> '; }
169 182
 		if (isset($_GET['manufacturer']) && $_GET['manufacturer'] != ""){ print _("Manufacturer:").' <span>'.$manufacturer.'</span> '; }
170 183
 		if (isset($_GET['registration']) && $_GET['registration'] != ""){ print _("Registration:").' <span>'.$registration.'</span> '; }
171
-		if (isset($_GET['highlights'])) if ($_GET['highlights'] == "true"){ print _("Highlights:").' <span>'.$highlights.'</span> '; }
184
+		if (isset($_GET['highlights'])) {
185
+			if ($_GET['highlights'] == "true"){ print _("Highlights:").' <span>'.$highlights.'</span> ';
186
+		}
187
+		}
172 188
 		if (isset($_GET['airline']) && $_GET['airline'] != ""){ print _("Airline:").' <span>'.$airline.'</span> '; }
173 189
 		if (isset($_GET['airline_country']) && $_GET['airline_country'] != ""){ print _("Airline country:").' <span>'.$airline_country.'</span> '; }
174 190
 		if (isset($_GET['airline_type']) && $_GET['airline_type'] != ""){ print _("Airline type:").' <span>'.$airline_type.'</span> '; }
@@ -279,7 +295,10 @@  discard block
 block discarded – undo
279 295
 			<div class="form-group">
280 296
 				<label class="control-label col-sm-2"><?php echo _("Keywords"); ?></label>
281 297
 				<div class="col-sm-10">
282
-					<input type="text" class="form-control" id="q" name="q" value="<?php if (isset($_GET['q'])) print $q; ?>" size="10" placeholder="<?php echo _("Keywords"); ?>" />
298
+					<input type="text" class="form-control" id="q" name="q" value="<?php if (isset($_GET['q'])) {
299
+	print $q;
300
+}
301
+?>" size="10" placeholder="<?php echo _("Keywords"); ?>" />
283 302
 				</div>
284 303
 			</div>
285 304
 		</fieldset>
@@ -294,7 +313,10 @@  discard block
 block discarded – undo
294 313
 					    </select>
295 314
 					</div>
296 315
 				</div>
297
-				<script type="text/javascript">getSelect('manufacturer','<?php if(isset($_GET['manufacturer'])) print $manufacturer; ?>')</script>
316
+				<script type="text/javascript">getSelect('manufacturer','<?php if(isset($_GET['manufacturer'])) {
317
+	print $manufacturer;
318
+}
319
+?>')</script>
298 320
 				<div class="form-group">
299 321
 					<label class="control-label col-sm-2"><?php echo _("Type"); ?></label>
300 322
 						<div class="col-sm-10">
@@ -303,11 +325,17 @@  discard block
 block discarded – undo
303 325
 							</select>
304 326
 						</div>
305 327
 				</div>
306
-				<script type="text/javascript">getSelect('aircrafttypes','<?php if(isset($_GET['aircraft_icao'])) print $aircraft_icao; ?>');</script>
328
+				<script type="text/javascript">getSelect('aircrafttypes','<?php if(isset($_GET['aircraft_icao'])) {
329
+	print $aircraft_icao;
330
+}
331
+?>');</script>
307 332
 				<div class="form-group">
308 333
 					<label class="control-label col-sm-2"><?php echo _("Registration"); ?></label> 
309 334
 					<div class="col-sm-10">
310
-						<input type="text" class="form-control" name="registration" value="<?php if (isset($_GET['registration'])) print $registration; ?>" size="8" placeholder="<?php echo _("Registration"); ?>" />
335
+						<input type="text" class="form-control" name="registration" value="<?php if (isset($_GET['registration'])) {
336
+	print $registration;
337
+}
338
+?>" size="8" placeholder="<?php echo _("Registration"); ?>" />
311 339
 					</div>
312 340
 				</div>
313 341
 <?php
@@ -316,22 +344,31 @@  discard block
 block discarded – undo
316 344
 				<div class="form-group">
317 345
 					<label class="control-label col-sm-2"><?php echo _("Pilot id"); ?></label> 
318 346
 					<div class="col-sm-10">
319
-						<input type="text" class="form-control" name="pilot_id" value="<?php if (isset($_GET['pilot_id'])) print $pilot_id; ?>" size="15" placeholder="<?php echo _("Pilot id"); ?>" />
347
+						<input type="text" class="form-control" name="pilot_id" value="<?php if (isset($_GET['pilot_id'])) {
348
+	print $pilot_id;
349
+}
350
+?>" size="15" placeholder="<?php echo _("Pilot id"); ?>" />
320 351
 					</div>
321 352
 				</div>
322 353
 				<div class="form-group">
323 354
 					<label class="control-label col-sm-2"><?php echo _("Pilot name"); ?></label> 
324 355
 					<div class="col-sm-10">
325
-						<input type="text" class="form-control" name="pilot_name" value="<?php if (isset($_GET['pilot_name'])) print $pilot_name; ?>" size="15" placeholder="<?php echo _("Pilot nmae"); ?>" />
356
+						<input type="text" class="form-control" name="pilot_name" value="<?php if (isset($_GET['pilot_name'])) {
357
+	print $pilot_name;
358
+}
359
+?>" size="15" placeholder="<?php echo _("Pilot nmae"); ?>" />
326 360
 					</div>
327 361
 				</div>
328 362
 <?php
329
-}else {
363
+} else {
330 364
 ?>
331 365
 				<div class="form-group">
332 366
 					<label class="control-label col-sm-2"><?php echo _("Owner name"); ?></label> 
333 367
 					<div class="col-sm-10">
334
-						<input type="text" class="form-control" name="owner" value="<?php if (isset($_GET['owner'])) print $owner; ?>" size="15" placeholder="<?php echo _("Owner name"); ?>" />
368
+						<input type="text" class="form-control" name="owner" value="<?php if (isset($_GET['owner'])) {
369
+	print $owner;
370
+}
371
+?>" size="15" placeholder="<?php echo _("Owner name"); ?>" />
335 372
 					</div>
336 373
 				</div>
337 374
 <?php
@@ -339,8 +376,14 @@  discard block
 block discarded – undo
339 376
 ?>
340 377
 				<div class="form-group">
341 378
 					<div class="col-sm-offset-2 col-sm-10">
342
-					<!--<div><input type="checkbox" class="form-control" name="highlights" value="true" id="highlights" <?php if (isset($_GET['highlights'])) if ($_GET['highlights'] == "true"){ print 'checked="checked"'; } ?>> <label for="highlights"><?php echo _("Include only aircrafts with special highlights (unique liveries, destinations etc.)"); ?></label></div>-->
343
-					<label class="checkbox-inline"><input type="checkbox" name="highlights" value="true" id="highlights" <?php if (isset($_GET['highlights'])) if ($_GET['highlights'] == "true"){ print 'checked="checked"'; } ?>> <?php echo _("Include only aircrafts with special highlights (unique liveries, destinations etc.)"); ?></label>
379
+					<!--<div><input type="checkbox" class="form-control" name="highlights" value="true" id="highlights" <?php if (isset($_GET['highlights'])) {
380
+	if ($_GET['highlights'] == "true"){ print 'checked="checked"';
381
+}
382
+} ?>> <label for="highlights"><?php echo _("Include only aircrafts with special highlights (unique liveries, destinations etc.)"); ?></label></div>-->
383
+					<label class="checkbox-inline"><input type="checkbox" name="highlights" value="true" id="highlights" <?php if (isset($_GET['highlights'])) {
384
+	if ($_GET['highlights'] == "true"){ print 'checked="checked"';
385
+}
386
+} ?>> <?php echo _("Include only aircrafts with special highlights (unique liveries, destinations etc.)"); ?></label>
344 387
 					</div>
345 388
 				</div>
346 389
 			</fieldset>
@@ -354,7 +397,10 @@  discard block
 block discarded – undo
354 397
 						</select>
355 398
 					</div>
356 399
 				</div>
357
-				<script type="text/javascript">getSelect('airlinenames','<?php if(isset($_GET['airline'])) print $airline; ?>');</script>
400
+				<script type="text/javascript">getSelect('airlinenames','<?php if(isset($_GET['airline'])) {
401
+	print $airline;
402
+}
403
+?>');</script>
358 404
 				<div class="form-group">
359 405
 					<label class="control-label col-sm-2"><?php echo _("Country"); ?></label> 
360 406
 					<div class="col-sm-10">
@@ -363,19 +409,34 @@  discard block
 block discarded – undo
363 409
 						</select>
364 410
 					</div>
365 411
 				</div>
366
-				<script type="text/javascript">getSelect('airlinecountries','<?php if(isset($_GET['airline_country'])) print $airline_country; ?>');</script>
412
+				<script type="text/javascript">getSelect('airlinecountries','<?php if(isset($_GET['airline_country'])) {
413
+	print $airline_country;
414
+}
415
+?>');</script>
367 416
 				<div class="form-group">
368 417
 					<label class="control-label col-sm-2"><?php echo _("Callsign"); ?></label> 
369 418
 					<div class="col-sm-10">
370
-						<input type="text" name="callsign" class="form-control" value="<?php if (isset($_GET['callsign'])) print $callsign; ?>" size="8" placeholder="<?php echo _("Callsign"); ?>" />
419
+						<input type="text" name="callsign" class="form-control" value="<?php if (isset($_GET['callsign'])) {
420
+	print $callsign;
421
+}
422
+?>" size="8" placeholder="<?php echo _("Callsign"); ?>" />
371 423
 					</div>
372 424
 				</div>
373 425
 				<div class="form-group">
374 426
 					<div class="col-sm-offset-2 col-sm-10">
375 427
 						<label class="radio-inline"><input type="radio" name="airline_type" value="all" id="airline_type_all" <?php if (!isset($_GET['airline_type']) || $_GET['airline_type'] == "all"){ print 'checked="checked"'; } ?>> <?php echo _("All airlines types"); ?></label>
376
-						<label class="radio-inline"><input type="radio" name="airline_type" value="passenger" id="airline_type_passenger" <?php if (isset($_GET['airline_type'])) if ($_GET['airline_type'] == "passenger"){ print 'checked="checked"'; } ?>> <?php echo _("Only Passenger airlines"); ?></label>
377
-						<label class="radio-inline"><input type="radio" name="airline_type" value="cargo" id="airline_type_cargo" <?php if (isset($_GET['airline_type'])) if ( $_GET['airline_type'] == "cargo"){ print 'checked="checked"'; } ?>> <?php echo _("Only Cargo airlines"); ?></label>
378
-						<label class="radio-inline"><input type="radio" name="airline_type" value="military" id="airline_type_military" <?php if (isset($_GET['airline_type'])) if ( $_GET['airline_type'] == "military"){ print 'checked="checked"'; } ?>> <?php echo _("Only Military airlines"); ?></label>
428
+						<label class="radio-inline"><input type="radio" name="airline_type" value="passenger" id="airline_type_passenger" <?php if (isset($_GET['airline_type'])) {
429
+	if ($_GET['airline_type'] == "passenger"){ print 'checked="checked"';
430
+}
431
+} ?>> <?php echo _("Only Passenger airlines"); ?></label>
432
+						<label class="radio-inline"><input type="radio" name="airline_type" value="cargo" id="airline_type_cargo" <?php if (isset($_GET['airline_type'])) {
433
+	if ( $_GET['airline_type'] == "cargo"){ print 'checked="checked"';
434
+}
435
+} ?>> <?php echo _("Only Cargo airlines"); ?></label>
436
+						<label class="radio-inline"><input type="radio" name="airline_type" value="military" id="airline_type_military" <?php if (isset($_GET['airline_type'])) {
437
+	if ( $_GET['airline_type'] == "military"){ print 'checked="checked"';
438
+}
439
+} ?>> <?php echo _("Only Military airlines"); ?></label>
379 440
 					</div>
380 441
 				</div>
381 442
 			</fieldset>
@@ -389,7 +450,10 @@  discard block
 block discarded – undo
389 450
 						</select>
390 451
 					</div>
391 452
 				</div>
392
-				<script type="text/javascript">getSelect('airportnames','<?php if(isset($_GET['airport_icao'])) print $airport_icao; ?>');</script>
453
+				<script type="text/javascript">getSelect('airportnames','<?php if(isset($_GET['airport_icao'])) {
454
+	print $airport_icao;
455
+}
456
+?>');</script>
393 457
 				<div class="form-group">
394 458
 					<label class="control-label col-sm-2"><?php echo _("Country"); ?></label> 
395 459
 					<div class="col-sm-10">
@@ -398,7 +462,10 @@  discard block
 block discarded – undo
398 462
 						</select>
399 463
 					</div>
400 464
 				</div>
401
-				<script type="text/javascript">getSelect('airportcountries','<?php if(isset($_GET['airport_country'])) print $airport_country; ?>');</script>
465
+				<script type="text/javascript">getSelect('airportcountries','<?php if(isset($_GET['airport_country'])) {
466
+	print $airport_country;
467
+}
468
+?>');</script>
402 469
 			</fieldset>
403 470
 			<fieldset>
404 471
 				<legend><?php echo _("Route"); ?></legend>
@@ -410,7 +477,10 @@  discard block
 block discarded – undo
410 477
 						</select>
411 478
 					</div>
412 479
 				</div>
413
-				<script type="text/javascript">getSelect('departureairportnames','<?php if(isset($_GET['departure_airport_route'])) print $departure_airport_route; ?>');</script>
480
+				<script type="text/javascript">getSelect('departureairportnames','<?php if(isset($_GET['departure_airport_route'])) {
481
+	print $departure_airport_route;
482
+}
483
+?>');</script>
414 484
 				<div class="form-group">
415 485
 					<label class="control-label col-sm-2"><?php echo _("Arrival Airport"); ?></label> 
416 486
 					<div class="col-sm-10">
@@ -419,7 +489,10 @@  discard block
 block discarded – undo
419 489
 						</select>
420 490
 					</div>
421 491
 				</div>
422
-				<script type="text/javascript">getSelect('arrivalairportnames','<?php if(isset($_GET['arrival_airport_route'])) print $arrival_airport_route; ?>');</script>
492
+				<script type="text/javascript">getSelect('arrivalairportnames','<?php if(isset($_GET['arrival_airport_route'])) {
493
+	print $arrival_airport_route;
494
+}
495
+?>');</script>
423 496
 			</fieldset>
424 497
 			<fieldset>
425 498
 				<legend><?php echo _("Date"); ?></legend>
@@ -427,7 +500,10 @@  discard block
 block discarded – undo
427 500
 					<label class="control-label col-sm-2"><?php echo _("Start Date"); ?></label>
428 501
 					<div class="col-sm-10">
429 502
 						<div class='input-group date' id='datetimepicker1'>
430
-							<input type='text' name="start_date" class="form-control" value="<?php if (isset($_GET['start_date'])) print $start_date; ?>" placeholder="<?php echo _("Start Date/Time"); ?>" />
503
+							<input type='text' name="start_date" class="form-control" value="<?php if (isset($_GET['start_date'])) {
504
+	print $start_date;
505
+}
506
+?>" placeholder="<?php echo _("Start Date/Time"); ?>" />
431 507
 							<span class="input-group-addon">
432 508
 								<span class="glyphicon glyphicon-calendar"></span>
433 509
 							</span>
@@ -438,7 +514,10 @@  discard block
 block discarded – undo
438 514
 					<label class="control-label col-sm-2"><?php echo _("End Date"); ?></label>
439 515
 					<div class="col-sm-10">
440 516
 						<div class='input-group date' id='datetimepicker2'>
441
-						<input type='text' name="end_date" class="form-control" value="<?php if (isset($_GET['end_date'])) print $end_date; ?>" placeholder="<?php echo _("End Date/Time"); ?>" />
517
+						<input type='text' name="end_date" class="form-control" value="<?php if (isset($_GET['end_date'])) {
518
+	print $end_date;
519
+}
520
+?>" placeholder="<?php echo _("End Date/Time"); ?>" />
442 521
 						<span class="input-group-addon">
443 522
 							<span class="glyphicon glyphicon-calendar"></span>
444 523
 						</span>
@@ -511,19 +590,33 @@  discard block
 block discarded – undo
511 590
 			<div class="form-group">
512 591
 				<label class="control-label col-sm-2"><?php echo _("Latitude"); ?></label>
513 592
 				<div class="col-sm-10">
514
-					<input type="text" name="origlat" class="form-control" placeholder="<?php echo _("Center point latitude"); ?>" value="<?php if (isset($_GET['origlat'])) print $origlat; ?>" />
593
+					<input type="text" name="origlat" class="form-control" placeholder="<?php echo _("Center point latitude"); ?>" value="<?php if (isset($_GET['origlat'])) {
594
+	print $origlat;
595
+}
596
+?>" />
515 597
 				</div>
516 598
 			</div>
517 599
 			<div class="form-group">
518 600
 				<label class="control-label col-sm-2"><?php echo _("Longitude"); ?></label>
519 601
 				<div class="col-sm-10">
520
-					<input type="text" name="origlon" class="form-control" placeholder="<?php echo _("Center point longitude"); ?>" value="<?php if (isset($_GET['origlon'])) print $origlon; ?>" />
602
+					<input type="text" name="origlon" class="form-control" placeholder="<?php echo _("Center point longitude"); ?>" value="<?php if (isset($_GET['origlon'])) {
603
+	print $origlon;
604
+}
605
+?>" />
521 606
 				</div>
522 607
 			</div>
523 608
 			<div class="form-group">
524
-				<label class="control-label col-sm-2"><?php echo _("Distance").' ('; if (isset($globalDistanceUnit)) print $globalDistanceUnit; else print 'km'; print ')'; ?></label>
609
+				<label class="control-label col-sm-2"><?php echo _("Distance").' ('; if (isset($globalDistanceUnit)) {
610
+	print $globalDistanceUnit;
611
+} else {
612
+	print 'km';
613
+}
614
+print ')'; ?></label>
525 615
 				<div class="col-sm-10">
526
-					<input type="text" name="dist" class="form-control" placeholder="<?php echo _("Distance from center point"); ?>" value="<?php if (isset($_GET['distance'])) print $distance; ?>" />
616
+					<input type="text" name="dist" class="form-control" placeholder="<?php echo _("Distance from center point"); ?>" value="<?php if (isset($_GET['distance'])) {
617
+	print $distance;
618
+}
619
+?>" />
527 620
 				</div>
528 621
 			</div>
529 622
 		</fieldset>
Please login to merge, or discard this patch.
flightid-sub-menu.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -3,7 +3,7 @@
 block discarded – undo
3 3
 </span>
4 4
 <div class="sub-menu sub-menu-container">
5 5
 	<ul class="nav nav-pills">
6
-		<li><a href="<?php print $globalURL; ?>/flightid/<?php print $id; ?>" <?php if (strtolower($current_page) == "flightid-overview"){ print 'class="active"'; } ?>><?php echo _("Detailed"); ?></a></li>
6
+		<li><a href="<?php print $globalURL; ?>/flightid/<?php print $id; ?>" <?php if (strtolower($current_page) == "flightid-overview") { print 'class="active"'; } ?>><?php echo _("Detailed"); ?></a></li>
7 7
 		<?php if ($globalFlightAware) { ?>
8 8
 		<li><a href="http://flightaware.com/live/flight/id/<?php print $spotter_array[0]['flightaware_id']; ?>" target="_blank"><?php echo _("Flight Status"); ?>&raquo;</a></li>
9 9
 		<li><a href="http://flightaware.com/live/flight/id/<?php print $spotter_array[0]['flightaware_id']; ?>/tracklog" target="_blank"><?php echo _("Flight Log"); ?>&raquo;</a></li>
Please login to merge, or discard this patch.