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