Completed
Push — master ( 73f088...7f17b6 )
by Yannick
07:13
created
registration-statistics-arrival-airport.php 2 patches
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -3,16 +3,16 @@  discard block
 block discarded – undo
3 3
 require_once('require/class.Spotter.php');
4 4
 require_once('require/class.Language.php');
5 5
 $Spotter = new Spotter();
6
-$sort=filter_input(INPUT_GET,'sort',FILTER_SANITIZE_STRING);
7
-$registration = filter_input(INPUT_GET,'registration',FILTER_SANITIZE_STRING);
6
+$sort = filter_input(INPUT_GET, 'sort', FILTER_SANITIZE_STRING);
7
+$registration = filter_input(INPUT_GET, 'registration', FILTER_SANITIZE_STRING);
8 8
 if ($registration != '') {
9 9
 	$spotter_array = $Spotter->getSpotterDataByRegistration($registration, "0,1", $sort);
10 10
 	$aircraft_array = $Spotter->getAircraftInfoByRegistration($registration);
11
-} else $spotter_array=array();
11
+} else $spotter_array = array();
12 12
 
13 13
 if (!empty($spotter_array))
14 14
 {
15
-	$title = sprintf(_("Most Common Arrival Airports of aircraft with registration %s"),$registration);
15
+	$title = sprintf(_("Most Common Arrival Airports of aircraft with registration %s"), $registration);
16 16
 
17 17
 	require_once('header.php');
18 18
 		print '<div class="info column">';
@@ -25,7 +25,7 @@  discard block
 block discarded – undo
25 25
 	include('registration-sub-menu.php');
26 26
 	print '<div class="column">';
27 27
 	print '<h2>'._("Most Common Arrival Airports").'</h2>';
28
-	print '<p>'.sprintf(_("The statistic below shows all arrival airports of flights with aircraft registration <strong>%s</strong>."),$registration).'</p>';
28
+	print '<p>'.sprintf(_("The statistic below shows all arrival airports of flights with aircraft registration <strong>%s</strong>."), $registration).'</p>';
29 29
 	$airport_airport_array = $Spotter->countAllArrivalAirportsByRegistration($registration);
30 30
 	print '<script type="text/javascript" src="https://www.google.com/jsapi"></script>
31 31
     	<script>
@@ -40,7 +40,7 @@  discard block
 block discarded – undo
40 40
         	["'._("Airport").'", "'._("# of times").'"],';
41 41
 
42 42
 	$airport_data = '';
43
-	foreach($airport_airport_array as $airport_item)
43
+	foreach ($airport_airport_array as $airport_item)
44 44
 	{
45 45
 		$name = $airport_item['airport_arrival_city'].', '.$airport_item['airport_arrival_country'].' ('.$airport_item['airport_arrival_icao'].')';
46 46
 		$name = str_replace("'", "", $name);
@@ -78,7 +78,7 @@  discard block
 block discarded – undo
78 78
 	print '</thead>';
79 79
 	print '<tbody>';
80 80
 	$i = 1;
81
-	foreach($airport_airport_array as $airport_item)
81
+	foreach ($airport_airport_array as $airport_item)
82 82
 	{
83 83
 		print '<tr>';
84 84
 		print '<td><strong>'.$i.'</strong></td>';
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -8,7 +8,9 @@
 block discarded – undo
8 8
 if ($registration != '') {
9 9
 	$spotter_array = $Spotter->getSpotterDataByRegistration($registration, "0,1", $sort);
10 10
 	$aircraft_array = $Spotter->getAircraftInfoByRegistration($registration);
11
-} else $spotter_array=array();
11
+} else {
12
+	$spotter_array=array();
13
+}
12 14
 
13 15
 if (!empty($spotter_array))
14 16
 {
Please login to merge, or discard this patch.
statistics-airport-departure-country.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
26 26
         	["'._("Country").'", "'._("# of times").'"],';
27 27
 
28 28
 $country_data = '';
29
-foreach($airport_country_array as $airport_item)
29
+foreach ($airport_country_array as $airport_item)
30 30
 {
31 31
 	$country_data .= '[ "'.$airport_item['airport_departure_country'].'",'.$airport_item['airport_departure_country_count'].'],';
32 32
 }
@@ -61,7 +61,7 @@  discard block
 block discarded – undo
61 61
 print '</thead>';
62 62
 print '<tbody>';
63 63
 $i = 1;
64
-foreach($airport_country_array as $airport_item)
64
+foreach ($airport_country_array as $airport_item)
65 65
 {
66 66
 	print '<tr>';
67 67
 	print '<td><strong>'.$i.'</strong></td>';
Please login to merge, or discard this patch.
sitemap.php 2 patches
Indentation   +107 added lines, -107 removed lines patch added patch discarded remove patch
@@ -15,9 +15,9 @@  discard block
 block discarded – undo
15 15
 		foreach($spotter_array as $spotter_item)
16 16
 		{
17 17
 			$output .= '<url>';
18
-			    $output .= '<loc>'.'http://'.$_SERVER['HTTP_HOST'].$globalURL.'/flightid/'.$spotter_item['spotter_id'].'</loc>';
19
-			    $output .= '<lastmod>'.date("c", time()).'</lastmod>';
20
-			    $output .= '<changefreq>weekly</changefreq>';
18
+				$output .= '<loc>'.'http://'.$_SERVER['HTTP_HOST'].$globalURL.'/flightid/'.$spotter_item['spotter_id'].'</loc>';
19
+				$output .= '<lastmod>'.date("c", time()).'</lastmod>';
20
+				$output .= '<changefreq>weekly</changefreq>';
21 21
 			$output .= '</url>';
22 22
 		}
23 23
 	$output .= '</urlset>';
@@ -32,9 +32,9 @@  discard block
 block discarded – undo
32 32
 		foreach($aircraft_types as $aircraft_item)
33 33
 		{
34 34
 			$output .= '<url>';
35
-			    $output .= '<loc>'.'http://'.$_SERVER['HTTP_HOST'].$globalURL.'/aircraft/'.$aircraft_item['aircraft_icao'].'</loc>';
36
-			    $output .= '<lastmod>'.date("c", time()).'</lastmod>';
37
-			    $output .= '<changefreq>daily</changefreq>';
35
+				$output .= '<loc>'.'http://'.$_SERVER['HTTP_HOST'].$globalURL.'/aircraft/'.$aircraft_item['aircraft_icao'].'</loc>';
36
+				$output .= '<lastmod>'.date("c", time()).'</lastmod>';
37
+				$output .= '<changefreq>daily</changefreq>';
38 38
 			$output .= '</url>';
39 39
 		}
40 40
 	$output .= '</urlset>';
@@ -49,9 +49,9 @@  discard block
 block discarded – undo
49 49
 		foreach($aircraft_registrations as $aircraft_item)
50 50
 		{
51 51
 			$output .= '<url>';
52
-			    $output .= '<loc>'.'http://'.$_SERVER['HTTP_HOST'].$globalURL.'/registration/'.$aircraft_item['registration'].'</loc>';
53
-			    $output .= '<lastmod>'.date("c", time()).'</lastmod>';
54
-			    $output .= '<changefreq>daily</changefreq>';
52
+				$output .= '<loc>'.'http://'.$_SERVER['HTTP_HOST'].$globalURL.'/registration/'.$aircraft_item['registration'].'</loc>';
53
+				$output .= '<lastmod>'.date("c", time()).'</lastmod>';
54
+				$output .= '<changefreq>daily</changefreq>';
55 55
 			$output .= '</url>';
56 56
 		}
57 57
 	$output .= '</urlset>';
@@ -65,9 +65,9 @@  discard block
 block discarded – undo
65 65
 		foreach($airline_names as $airline_item)
66 66
 		{
67 67
 			$output .= '<url>';
68
-			    $output .= '<loc>'.'http://'.$_SERVER['HTTP_HOST'].$globalURL.'/airline/'.$airline_item['airline_icao'].'</loc>';
69
-			    $output .= '<lastmod>'.date("c", time()).'</lastmod>';
70
-			    $output .= '<changefreq>daily</changefreq>';
68
+				$output .= '<loc>'.'http://'.$_SERVER['HTTP_HOST'].$globalURL.'/airline/'.$airline_item['airline_icao'].'</loc>';
69
+				$output .= '<lastmod>'.date("c", time()).'</lastmod>';
70
+				$output .= '<changefreq>daily</changefreq>';
71 71
 			$output .= '</url>';
72 72
 		}
73 73
 	$output .= '</urlset>';
@@ -81,9 +81,9 @@  discard block
 block discarded – undo
81 81
 		foreach($airport_names as $airport_item)
82 82
 		{
83 83
 			$output .= '<url>';
84
-			    $output .= '<loc>'.'http://'.$_SERVER['HTTP_HOST'].$globalURL.'/airport/'.$airport_item['airport_icao'].'</loc>';
85
-			    $output .= '<lastmod>'.date("c", time()).'</lastmod>';
86
-			    $output .= '<changefreq>daily</changefreq>';
84
+				$output .= '<loc>'.'http://'.$_SERVER['HTTP_HOST'].$globalURL.'/airport/'.$airport_item['airport_icao'].'</loc>';
85
+				$output .= '<lastmod>'.date("c", time()).'</lastmod>';
86
+				$output .= '<changefreq>daily</changefreq>';
87 87
 			$output .= '</url>';
88 88
 		}
89 89
 	$output .= '</urlset>';
@@ -97,9 +97,9 @@  discard block
 block discarded – undo
97 97
 		foreach($manufacturer_names as $manufacturer_item)
98 98
 		{
99 99
 			$output .= '<url>';
100
-			    $output .= '<loc>'.'http://'.$_SERVER['HTTP_HOST'].$globalURL.'/manufacturer/'.strtolower(str_replace(" ", "-", $manufacturer_item['aircraft_manufacturer'])).'</loc>';
101
-			    $output .= '<lastmod>'.date("c", time()).'</lastmod>';
102
-			    $output .= '<changefreq>daily</changefreq>';
100
+				$output .= '<loc>'.'http://'.$_SERVER['HTTP_HOST'].$globalURL.'/manufacturer/'.strtolower(str_replace(" ", "-", $manufacturer_item['aircraft_manufacturer'])).'</loc>';
101
+				$output .= '<lastmod>'.date("c", time()).'</lastmod>';
102
+				$output .= '<changefreq>daily</changefreq>';
103 103
 			$output .= '</url>';
104 104
 		}
105 105
 	$output .= '</urlset>';
@@ -113,9 +113,9 @@  discard block
 block discarded – undo
113 113
 		foreach($country_names as $country_item)
114 114
 		{
115 115
 			$output .= '<url>';
116
-			    $output .= '<loc>'.'http://'.$_SERVER['HTTP_HOST'].$globalURL.'/country/'.strtolower(str_replace(" ", "-", $country_item['country'])).'</loc>';
117
-			    $output .= '<lastmod>'.date("c", time()).'</lastmod>';
118
-			    $output .= '<changefreq>daily</changefreq>';
116
+				$output .= '<loc>'.'http://'.$_SERVER['HTTP_HOST'].$globalURL.'/country/'.strtolower(str_replace(" ", "-", $country_item['country'])).'</loc>';
117
+				$output .= '<lastmod>'.date("c", time()).'</lastmod>';
118
+				$output .= '<changefreq>daily</changefreq>';
119 119
 			$output .= '</url>';
120 120
 		}
121 121
 	$output .= '</urlset>';
@@ -130,9 +130,9 @@  discard block
 block discarded – undo
130 130
 		{
131 131
 			if (ctype_alnum($ident_item['ident'])) {
132 132
 				$output .= '<url>';
133
-				    $output .= '<loc>'.'http://'.$_SERVER['HTTP_HOST'].$globalURL.'/ident/'.$ident_item['ident'].'</loc>';
134
-				    $output .= '<lastmod>'.date("c", time()).'</lastmod>';
135
-				    $output .= '<changefreq>daily</changefreq>';
133
+					$output .= '<loc>'.'http://'.$_SERVER['HTTP_HOST'].$globalURL.'/ident/'.$ident_item['ident'].'</loc>';
134
+					$output .= '<lastmod>'.date("c", time()).'</lastmod>';
135
+					$output .= '<changefreq>daily</changefreq>';
136 136
 				$output .= '</url>';
137 137
 			}
138 138
 		}
@@ -147,9 +147,9 @@  discard block
 block discarded – undo
147 147
 		foreach($date_names as $date_item)
148 148
 		{
149 149
 			$output .= '<url>';
150
-			    $output .= '<loc>'.'http://'.$_SERVER['HTTP_HOST'].$globalURL.'/date/'.date("Y-m-d", strtotime($date_item['date'])).'</loc>';
151
-			    $output .= '<lastmod>'.date("c", time()).'</lastmod>';
152
-			    $output .= '<changefreq>daily</changefreq>';
150
+				$output .= '<loc>'.'http://'.$_SERVER['HTTP_HOST'].$globalURL.'/date/'.date("Y-m-d", strtotime($date_item['date'])).'</loc>';
151
+				$output .= '<lastmod>'.date("c", time()).'</lastmod>';
152
+				$output .= '<changefreq>daily</changefreq>';
153 153
 			$output .= '</url>';
154 154
 		}
155 155
 	$output .= '</urlset>';
@@ -163,9 +163,9 @@  discard block
 block discarded – undo
163 163
 		foreach($route_names as $route_item)
164 164
 		{
165 165
 			$output .= '<url>';
166
-			    $output .= '<loc>'.'http://'.$_SERVER['HTTP_HOST'].$globalURL.'/route/'.$route_item['airport_departure_icao'].'/'.$route_item['airport_arrival_icao'].'</loc>';
167
-			    $output .= '<lastmod>'.date("c", time()).'</lastmod>';
168
-			    $output .= '<changefreq>daily</changefreq>';
166
+				$output .= '<loc>'.'http://'.$_SERVER['HTTP_HOST'].$globalURL.'/route/'.$route_item['airport_departure_icao'].'/'.$route_item['airport_arrival_icao'].'</loc>';
167
+				$output .= '<lastmod>'.date("c", time()).'</lastmod>';
168
+				$output .= '<changefreq>daily</changefreq>';
169 169
 			$output .= '</url>';
170 170
 		}
171 171
 	$output .= '</urlset>';
@@ -177,117 +177,117 @@  discard block
 block discarded – undo
177 177
 		
178 178
 		/* STATIC PAGES */
179 179
 		$output .= '<url>';
180
-		    $output .= '<loc>'.'http://'.$_SERVER['HTTP_HOST'].$globalURL.'/</loc>';
181
-		    $output .= '<lastmod>'.date("c", time()).'</lastmod>';
182
-		    $output .= '<changefreq>daily</changefreq>';
180
+			$output .= '<loc>'.'http://'.$_SERVER['HTTP_HOST'].$globalURL.'/</loc>';
181
+			$output .= '<lastmod>'.date("c", time()).'</lastmod>';
182
+			$output .= '<changefreq>daily</changefreq>';
183 183
 		$output .= '</url>';
184 184
 		$output .= '<url>';
185
-		    $output .= '<loc>'.'http://'.$_SERVER['HTTP_HOST'].$globalURL.'/latest</loc>';
186
-		    $output .= '<lastmod>'.date("c", time()).'</lastmod>';
187
-		    $output .= '<changefreq>daily</changefreq>';
185
+			$output .= '<loc>'.'http://'.$_SERVER['HTTP_HOST'].$globalURL.'/latest</loc>';
186
+			$output .= '<lastmod>'.date("c", time()).'</lastmod>';
187
+			$output .= '<changefreq>daily</changefreq>';
188 188
 		$output .= '</url>';
189 189
 		$output .= '<url>';
190
-		    $output .= '<loc>'.'http://'.$_SERVER['HTTP_HOST'].$globalURL.'/highlights</loc>';
191
-		    $output .= '<lastmod>'.date("c", time()).'</lastmod>';
192
-		    $output .= '<changefreq>daily</changefreq>';
190
+			$output .= '<loc>'.'http://'.$_SERVER['HTTP_HOST'].$globalURL.'/highlights</loc>';
191
+			$output .= '<lastmod>'.date("c", time()).'</lastmod>';
192
+			$output .= '<changefreq>daily</changefreq>';
193 193
 		$output .= '</url>';
194 194
 		$output .= '<url>';
195
-		    $output .= '<loc>'.'http://'.$_SERVER['HTTP_HOST'].$globalURL.'/aircraft</loc>';
196
-		    $output .= '<lastmod>'.date("c", time()).'</lastmod>';
197
-		    $output .= '<changefreq>daily</changefreq>';
195
+			$output .= '<loc>'.'http://'.$_SERVER['HTTP_HOST'].$globalURL.'/aircraft</loc>';
196
+			$output .= '<lastmod>'.date("c", time()).'</lastmod>';
197
+			$output .= '<changefreq>daily</changefreq>';
198 198
 		$output .= '</url>';
199 199
 		$output .= '<url>';
200
-		    $output .= '<loc>'.'http://'.$_SERVER['HTTP_HOST'].$globalURL.'/airline</loc>';
201
-		    $output .= '<lastmod>'.date("c", time()).'</lastmod>';
202
-		    $output .= '<changefreq>daily</changefreq>';
200
+			$output .= '<loc>'.'http://'.$_SERVER['HTTP_HOST'].$globalURL.'/airline</loc>';
201
+			$output .= '<lastmod>'.date("c", time()).'</lastmod>';
202
+			$output .= '<changefreq>daily</changefreq>';
203 203
 		$output .= '</url>';
204 204
 		$output .= '<url>';
205
-		    $output .= '<loc>'.'http://'.$_SERVER['HTTP_HOST'].$globalURL.'/airport</loc>';
206
-		    $output .= '<lastmod>'.date("c", time()).'</lastmod>';
207
-		    $output .= '<changefreq>daily</changefreq>';
205
+			$output .= '<loc>'.'http://'.$_SERVER['HTTP_HOST'].$globalURL.'/airport</loc>';
206
+			$output .= '<lastmod>'.date("c", time()).'</lastmod>';
207
+			$output .= '<changefreq>daily</changefreq>';
208 208
 		$output .= '</url>';
209 209
 		$output .= '<url>';
210
-		    $output .= '<loc>'.'http://'.$_SERVER['HTTP_HOST'].$globalURL.'/search</loc>';
211
-		    $output .= '<lastmod>'.date("c", time()).'</lastmod>';
212
-		    $output .= '<changefreq>daily</changefreq>';
210
+			$output .= '<loc>'.'http://'.$_SERVER['HTTP_HOST'].$globalURL.'/search</loc>';
211
+			$output .= '<lastmod>'.date("c", time()).'</lastmod>';
212
+			$output .= '<changefreq>daily</changefreq>';
213 213
 		$output .= '</url>';
214 214
 		$output .= '<url>';
215
-		    $output .= '<loc>'.'http://'.$_SERVER['HTTP_HOST'].$globalURL.'/about</loc>';
216
-		    $output .= '<lastmod>'.date("c", time()).'</lastmod>';
217
-		    $output .= '<changefreq>weekly</changefreq>';
215
+			$output .= '<loc>'.'http://'.$_SERVER['HTTP_HOST'].$globalURL.'/about</loc>';
216
+			$output .= '<lastmod>'.date("c", time()).'</lastmod>';
217
+			$output .= '<changefreq>weekly</changefreq>';
218 218
 		$output .= '</url>';
219 219
 		
220 220
 		
221 221
 		/* STATISTIC PAGES */
222 222
 		$output .= '<url>';
223
-		    $output .= '<loc>'.'http://'.$_SERVER['HTTP_HOST'].$globalURL.'/statistics/aircraft</loc>';
224
-		    $output .= '<lastmod>'.date("c", time()).'</lastmod>';
225
-		    $output .= '<changefreq>daily</changefreq>';
223
+			$output .= '<loc>'.'http://'.$_SERVER['HTTP_HOST'].$globalURL.'/statistics/aircraft</loc>';
224
+			$output .= '<lastmod>'.date("c", time()).'</lastmod>';
225
+			$output .= '<changefreq>daily</changefreq>';
226 226
 		$output .= '</url>';
227 227
 		$output .= '<url>';
228
-		    $output .= '<loc>'.'http://'.$_SERVER['HTTP_HOST'].$globalURL.'/statistics/registration</loc>';
229
-		    $output .= '<lastmod>'.date("c", time()).'</lastmod>';
230
-		    $output .= '<changefreq>daily</changefreq>';
228
+			$output .= '<loc>'.'http://'.$_SERVER['HTTP_HOST'].$globalURL.'/statistics/registration</loc>';
229
+			$output .= '<lastmod>'.date("c", time()).'</lastmod>';
230
+			$output .= '<changefreq>daily</changefreq>';
231 231
 		$output .= '</url>';
232 232
 		$output .= '<url>';
233
-		    $output .= '<loc>'.'http://'.$_SERVER['HTTP_HOST'].$globalURL.'/statistics/manufacturer</loc>';
234
-		    $output .= '<lastmod>'.date("c", time()).'</lastmod>';
235
-		    $output .= '<changefreq>daily</changefreq>';
233
+			$output .= '<loc>'.'http://'.$_SERVER['HTTP_HOST'].$globalURL.'/statistics/manufacturer</loc>';
234
+			$output .= '<lastmod>'.date("c", time()).'</lastmod>';
235
+			$output .= '<changefreq>daily</changefreq>';
236 236
 		$output .= '</url>';
237 237
 		$output .= '<url>';
238
-		    $output .= '<loc>'.'http://'.$_SERVER['HTTP_HOST'].$globalURL.'/statistics/airline</loc>';
239
-		    $output .= '<lastmod>'.date("c", time()).'</lastmod>';
240
-		    $output .= '<changefreq>daily</changefreq>';
238
+			$output .= '<loc>'.'http://'.$_SERVER['HTTP_HOST'].$globalURL.'/statistics/airline</loc>';
239
+			$output .= '<lastmod>'.date("c", time()).'</lastmod>';
240
+			$output .= '<changefreq>daily</changefreq>';
241 241
 		$output .= '</url>';
242 242
 		$output .= '<url>';
243
-		    $output .= '<loc>'.'http://'.$_SERVER['HTTP_HOST'].$globalURL.'/statistics/airline-country</loc>';
244
-		    $output .= '<lastmod>'.date("c", time()).'</lastmod>';
245
-		    $output .= '<changefreq>daily</changefreq>';
243
+			$output .= '<loc>'.'http://'.$_SERVER['HTTP_HOST'].$globalURL.'/statistics/airline-country</loc>';
244
+			$output .= '<lastmod>'.date("c", time()).'</lastmod>';
245
+			$output .= '<changefreq>daily</changefreq>';
246 246
 		$output .= '</url>';
247 247
 		$output .= '<url>';
248
-		    $output .= '<loc>'.'http://'.$_SERVER['HTTP_HOST'].$globalURL.'/statistics/airport-departure</loc>';
249
-		    $output .= '<lastmod>'.date("c", time()).'</lastmod>';
250
-		    $output .= '<changefreq>daily</changefreq>';
248
+			$output .= '<loc>'.'http://'.$_SERVER['HTTP_HOST'].$globalURL.'/statistics/airport-departure</loc>';
249
+			$output .= '<lastmod>'.date("c", time()).'</lastmod>';
250
+			$output .= '<changefreq>daily</changefreq>';
251 251
 		$output .= '</url>';
252 252
 		$output .= '<url>';
253
-		    $output .= '<loc>'.'http://'.$_SERVER['HTTP_HOST'].$globalURL.'/statistics/airport-departure-country</loc>';
254
-		    $output .= '<lastmod>'.date("c", time()).'</lastmod>';
255
-		    $output .= '<changefreq>daily</changefreq>';
253
+			$output .= '<loc>'.'http://'.$_SERVER['HTTP_HOST'].$globalURL.'/statistics/airport-departure-country</loc>';
254
+			$output .= '<lastmod>'.date("c", time()).'</lastmod>';
255
+			$output .= '<changefreq>daily</changefreq>';
256 256
 		$output .= '</url>';
257 257
 		$output .= '<url>';
258
-		    $output .= '<loc>'.'http://'.$_SERVER['HTTP_HOST'].$globalURL.'/statistics/airport-arrival</loc>';
259
-		    $output .= '<lastmod>'.date("c", time()).'</lastmod>';
260
-		    $output .= '<changefreq>daily</changefreq>';
258
+			$output .= '<loc>'.'http://'.$_SERVER['HTTP_HOST'].$globalURL.'/statistics/airport-arrival</loc>';
259
+			$output .= '<lastmod>'.date("c", time()).'</lastmod>';
260
+			$output .= '<changefreq>daily</changefreq>';
261 261
 		$output .= '</url>';
262 262
 		$output .= '<url>';
263
-		    $output .= '<loc>'.'http://'.$_SERVER['HTTP_HOST'].$globalURL.'/statistics/airport-arrival-country</loc>';
264
-		    $output .= '<lastmod>'.date("c", time()).'</lastmod>';
265
-		    $output .= '<changefreq>daily</changefreq>';
263
+			$output .= '<loc>'.'http://'.$_SERVER['HTTP_HOST'].$globalURL.'/statistics/airport-arrival-country</loc>';
264
+			$output .= '<lastmod>'.date("c", time()).'</lastmod>';
265
+			$output .= '<changefreq>daily</changefreq>';
266 266
 		$output .= '</url>';
267 267
 		$output .= '<url>';
268
-		    $output .= '<loc>'.'http://'.$_SERVER['HTTP_HOST'].$globalURL.'/statistics/route-airport</loc>';
269
-		    $output .= '<lastmod>'.date("c", time()).'</lastmod>';
270
-		    $output .= '<changefreq>daily</changefreq>';
268
+			$output .= '<loc>'.'http://'.$_SERVER['HTTP_HOST'].$globalURL.'/statistics/route-airport</loc>';
269
+			$output .= '<lastmod>'.date("c", time()).'</lastmod>';
270
+			$output .= '<changefreq>daily</changefreq>';
271 271
 		$output .= '</url>';
272 272
 		$output .= '<url>';
273
-		    $output .= '<loc>'.'http://'.$_SERVER['HTTP_HOST'].$globalURL.'/statistics/route-waypoint</loc>';
274
-		    $output .= '<lastmod>'.date("c", time()).'</lastmod>';
275
-		    $output .= '<changefreq>daily</changefreq>';
273
+			$output .= '<loc>'.'http://'.$_SERVER['HTTP_HOST'].$globalURL.'/statistics/route-waypoint</loc>';
274
+			$output .= '<lastmod>'.date("c", time()).'</lastmod>';
275
+			$output .= '<changefreq>daily</changefreq>';
276 276
 		$output .= '</url>';
277 277
 		$output .= '<url>';
278
-		    $output .= '<loc>'.'http://'.$_SERVER['HTTP_HOST'].$globalURL.'/statistics/callsign</loc>';
279
-		    $output .= '<lastmod>'.date("c", time()).'</lastmod>';
280
-		    $output .= '<changefreq>daily</changefreq>';
278
+			$output .= '<loc>'.'http://'.$_SERVER['HTTP_HOST'].$globalURL.'/statistics/callsign</loc>';
279
+			$output .= '<lastmod>'.date("c", time()).'</lastmod>';
280
+			$output .= '<changefreq>daily</changefreq>';
281 281
 		$output .= '</url>';
282 282
 		$output .= '<url>';
283
-		    $output .= '<loc>'.'http://'.$_SERVER['HTTP_HOST'].$globalURL.'/statistics/date</loc>';
284
-		    $output .= '<lastmod>'.date("c", time()).'</lastmod>';
285
-		    $output .= '<changefreq>daily</changefreq>';
283
+			$output .= '<loc>'.'http://'.$_SERVER['HTTP_HOST'].$globalURL.'/statistics/date</loc>';
284
+			$output .= '<lastmod>'.date("c", time()).'</lastmod>';
285
+			$output .= '<changefreq>daily</changefreq>';
286 286
 		$output .= '</url>';
287 287
 		$output .= '<url>';
288
-		    $output .= '<loc>'.'http://'.$_SERVER['HTTP_HOST'].$globalURL.'/statistics/time</loc>';
289
-		    $output .= '<lastmod>'.date("c", time()).'</lastmod>';
290
-		    $output .= '<changefreq>daily</changefreq>';
288
+			$output .= '<loc>'.'http://'.$_SERVER['HTTP_HOST'].$globalURL.'/statistics/time</loc>';
289
+			$output .= '<lastmod>'.date("c", time()).'</lastmod>';
290
+			$output .= '<changefreq>daily</changefreq>';
291 291
 		$output .= '</url>';
292 292
 	$output .= '</urlset>';
293 293
 	
@@ -297,37 +297,37 @@  discard block
 block discarded – undo
297 297
 	$output .= '<?xml version="1.0" encoding="UTF-8"?>';
298 298
 	$output .= '<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">';
299 299
 		$output .= '<sitemap>';
300
-	    	$output .= '<loc>'.'http://'.$_SERVER['HTTP_HOST'].$globalURL.'/sitemap/static</loc>';
300
+			$output .= '<loc>'.'http://'.$_SERVER['HTTP_HOST'].$globalURL.'/sitemap/static</loc>';
301 301
 		$output .= '</sitemap>';
302 302
 		$output .= '<sitemap>';
303
-	    	$output .= '<loc>'.'http://'.$_SERVER['HTTP_HOST'].$globalURL.'/sitemap/flight</loc>';
303
+			$output .= '<loc>'.'http://'.$_SERVER['HTTP_HOST'].$globalURL.'/sitemap/flight</loc>';
304 304
 		$output .= '</sitemap>';
305 305
 		$output .= '<sitemap>';
306
-	    	$output .= '<loc>'.'http://'.$_SERVER['HTTP_HOST'].$globalURL.'/sitemap/aircraft</loc>';
306
+			$output .= '<loc>'.'http://'.$_SERVER['HTTP_HOST'].$globalURL.'/sitemap/aircraft</loc>';
307 307
 		$output .= '</sitemap>';
308 308
 		$output .= '<sitemap>';
309
-	    	$output .= '<loc>'.'http://'.$_SERVER['HTTP_HOST'].$globalURL.'/sitemap/registration</loc>';
309
+			$output .= '<loc>'.'http://'.$_SERVER['HTTP_HOST'].$globalURL.'/sitemap/registration</loc>';
310 310
 		$output .= '</sitemap>';
311 311
 		$output .= '<sitemap>';
312
-	    	$output .= '<loc>'.'http://'.$_SERVER['HTTP_HOST'].$globalURL.'/sitemap/airline</loc>';
312
+			$output .= '<loc>'.'http://'.$_SERVER['HTTP_HOST'].$globalURL.'/sitemap/airline</loc>';
313 313
 		$output .= '</sitemap>';
314 314
 		$output .= '<sitemap>';
315
-	    	$output .= '<loc>'.'http://'.$_SERVER['HTTP_HOST'].$globalURL.'/sitemap/airport</loc>';
315
+			$output .= '<loc>'.'http://'.$_SERVER['HTTP_HOST'].$globalURL.'/sitemap/airport</loc>';
316 316
 		$output .= '</sitemap>';
317 317
 		$output .= '<sitemap>';
318
-	    	$output .= '<loc>'.'http://'.$_SERVER['HTTP_HOST'].$globalURL.'/sitemap/manufacturer</loc>';
318
+			$output .= '<loc>'.'http://'.$_SERVER['HTTP_HOST'].$globalURL.'/sitemap/manufacturer</loc>';
319 319
 		$output .= '</sitemap>';
320 320
 		$output .= '<sitemap>';
321
-	    	$output .= '<loc>'.'http://'.$_SERVER['HTTP_HOST'].$globalURL.'/sitemap/country</loc>';
321
+			$output .= '<loc>'.'http://'.$_SERVER['HTTP_HOST'].$globalURL.'/sitemap/country</loc>';
322 322
 		$output .= '</sitemap>';
323 323
 		$output .= '<sitemap>';
324
-	    	$output .= '<loc>'.'http://'.$_SERVER['HTTP_HOST'].$globalURL.'/sitemap/ident</loc>';
324
+			$output .= '<loc>'.'http://'.$_SERVER['HTTP_HOST'].$globalURL.'/sitemap/ident</loc>';
325 325
 		$output .= '</sitemap>';
326 326
 		$output .= '<sitemap>';
327
-	    	$output .= '<loc>'.'http://'.$_SERVER['HTTP_HOST'].$globalURL.'/sitemap/date</loc>';
327
+			$output .= '<loc>'.'http://'.$_SERVER['HTTP_HOST'].$globalURL.'/sitemap/date</loc>';
328 328
 		$output .= '</sitemap>';
329 329
 		$output .= '<sitemap>';
330
-	    	$output .= '<loc>'.'http://'.$_SERVER['HTTP_HOST'].$globalURL.'/sitemap/route</loc>';
330
+			$output .= '<loc>'.'http://'.$_SERVER['HTTP_HOST'].$globalURL.'/sitemap/route</loc>';
331 331
 		$output .= '</sitemap>';
332 332
 	$output .= '</sitemapindex>';
333 333
 	
Please login to merge, or discard this patch.
Spacing   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@  discard block
 block discarded – undo
12 12
 	$output .= '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:image="http://www.google.com/schemas/sitemap-image/1.1">';
13 13
 
14 14
 		$spotter_array = $Spotter->getAllFlightsforSitemap();
15
-		foreach($spotter_array as $spotter_item)
15
+		foreach ($spotter_array as $spotter_item)
16 16
 		{
17 17
 			$output .= '<url>';
18 18
 			    $output .= '<loc>'.'http://'.$_SERVER['HTTP_HOST'].$globalURL.'/flightid/'.$spotter_item['spotter_id'].'</loc>';
@@ -23,13 +23,13 @@  discard block
 block discarded – undo
23 23
 	$output .= '</urlset>';
24 24
 	
25 25
 	
26
-} else if (isset($_GET['type']) && $_GET['type'] == "aircraft"){
26
+} else if (isset($_GET['type']) && $_GET['type'] == "aircraft") {
27 27
 
28 28
 	$output .= '<?xml version="1.0" encoding="UTF-8"?>';
29 29
 	$output .= '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:image="http://www.google.com/schemas/sitemap-image/1.1">';
30 30
 
31 31
 		$aircraft_types = $Spotter->getAllAircraftTypes();
32
-		foreach($aircraft_types as $aircraft_item)
32
+		foreach ($aircraft_types as $aircraft_item)
33 33
 		{
34 34
 			$output .= '<url>';
35 35
 			    $output .= '<loc>'.'http://'.$_SERVER['HTTP_HOST'].$globalURL.'/aircraft/'.$aircraft_item['aircraft_icao'].'</loc>';
@@ -40,13 +40,13 @@  discard block
 block discarded – undo
40 40
 	$output .= '</urlset>';
41 41
 	
42 42
 	
43
-} else if (isset($_GET['type']) && $_GET['type'] == "registration"){
43
+} else if (isset($_GET['type']) && $_GET['type'] == "registration") {
44 44
 
45 45
 	$output .= '<?xml version="1.0" encoding="UTF-8"?>';
46 46
 	$output .= '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:image="http://www.google.com/schemas/sitemap-image/1.1">';
47 47
 
48 48
 		$aircraft_registrations = $Spotter->getAllAircraftRegistrations();
49
-		foreach($aircraft_registrations as $aircraft_item)
49
+		foreach ($aircraft_registrations as $aircraft_item)
50 50
 		{
51 51
 			$output .= '<url>';
52 52
 			    $output .= '<loc>'.'http://'.$_SERVER['HTTP_HOST'].$globalURL.'/registration/'.$aircraft_item['registration'].'</loc>';
@@ -56,13 +56,13 @@  discard block
 block discarded – undo
56 56
 		}
57 57
 	$output .= '</urlset>';
58 58
 	
59
-} else if (isset($_GET['type']) && $_GET['type'] == "airline"){
59
+} else if (isset($_GET['type']) && $_GET['type'] == "airline") {
60 60
 
61 61
 	$output .= '<?xml version="1.0" encoding="UTF-8"?>';
62 62
 	$output .= '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:image="http://www.google.com/schemas/sitemap-image/1.1">';
63 63
 
64 64
 		$airline_names = $Spotter->getAllAirlineNames();
65
-		foreach($airline_names as $airline_item)
65
+		foreach ($airline_names as $airline_item)
66 66
 		{
67 67
 			$output .= '<url>';
68 68
 			    $output .= '<loc>'.'http://'.$_SERVER['HTTP_HOST'].$globalURL.'/airline/'.$airline_item['airline_icao'].'</loc>';
@@ -72,13 +72,13 @@  discard block
 block discarded – undo
72 72
 		}
73 73
 	$output .= '</urlset>';
74 74
 	
75
-} else if (isset($_GET['type']) && $_GET['type'] == "airport"){
75
+} else if (isset($_GET['type']) && $_GET['type'] == "airport") {
76 76
 
77 77
 	$output .= '<?xml version="1.0" encoding="UTF-8"?>';
78 78
 	$output .= '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:image="http://www.google.com/schemas/sitemap-image/1.1">';
79 79
 
80 80
 		$airport_names = $Spotter->getAllAirportNames();
81
-		foreach($airport_names as $airport_item)
81
+		foreach ($airport_names as $airport_item)
82 82
 		{
83 83
 			$output .= '<url>';
84 84
 			    $output .= '<loc>'.'http://'.$_SERVER['HTTP_HOST'].$globalURL.'/airport/'.$airport_item['airport_icao'].'</loc>';
@@ -88,13 +88,13 @@  discard block
 block discarded – undo
88 88
 		}
89 89
 	$output .= '</urlset>';
90 90
 	
91
-} else if (isset($_GET['type']) && $_GET['type'] == "manufacturer"){
91
+} else if (isset($_GET['type']) && $_GET['type'] == "manufacturer") {
92 92
 
93 93
 	$output .= '<?xml version="1.0" encoding="UTF-8"?>';
94 94
 	$output .= '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:image="http://www.google.com/schemas/sitemap-image/1.1">';
95 95
 
96 96
 		$manufacturer_names = $Spotter->getAllManufacturers();
97
-		foreach($manufacturer_names as $manufacturer_item)
97
+		foreach ($manufacturer_names as $manufacturer_item)
98 98
 		{
99 99
 			$output .= '<url>';
100 100
 			    $output .= '<loc>'.'http://'.$_SERVER['HTTP_HOST'].$globalURL.'/manufacturer/'.strtolower(str_replace(" ", "-", $manufacturer_item['aircraft_manufacturer'])).'</loc>';
@@ -104,13 +104,13 @@  discard block
 block discarded – undo
104 104
 		}
105 105
 	$output .= '</urlset>';
106 106
 	
107
-} else if (isset($_GET['type']) && $_GET['type'] == "country"){
107
+} else if (isset($_GET['type']) && $_GET['type'] == "country") {
108 108
 
109 109
 	$output .= '<?xml version="1.0" encoding="UTF-8"?>';
110 110
 	$output .= '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:image="http://www.google.com/schemas/sitemap-image/1.1">';
111 111
 
112 112
 		$country_names = $Spotter->getAllCountries();
113
-		foreach($country_names as $country_item)
113
+		foreach ($country_names as $country_item)
114 114
 		{
115 115
 			$output .= '<url>';
116 116
 			    $output .= '<loc>'.'http://'.$_SERVER['HTTP_HOST'].$globalURL.'/country/'.strtolower(str_replace(" ", "-", $country_item['country'])).'</loc>';
@@ -120,13 +120,13 @@  discard block
 block discarded – undo
120 120
 		}
121 121
 	$output .= '</urlset>';
122 122
 	
123
-} else if (isset($_GET['type']) && $_GET['type'] == "ident"){
123
+} else if (isset($_GET['type']) && $_GET['type'] == "ident") {
124 124
 
125 125
 	$output .= '<?xml version="1.0" encoding="UTF-8"?>';
126 126
 	$output .= '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:image="http://www.google.com/schemas/sitemap-image/1.1">';
127 127
 
128 128
 		$ident_names = $Spotter->getAllIdents();
129
-		foreach($ident_names as $ident_item)
129
+		foreach ($ident_names as $ident_item)
130 130
 		{
131 131
 			if (ctype_alnum($ident_item['ident'])) {
132 132
 				$output .= '<url>';
@@ -138,13 +138,13 @@  discard block
 block discarded – undo
138 138
 		}
139 139
 	$output .= '</urlset>';
140 140
 	
141
-} else if (isset($_GET['type']) && $_GET['type'] == "date"){
141
+} else if (isset($_GET['type']) && $_GET['type'] == "date") {
142 142
 
143 143
 	$output .= '<?xml version="1.0" encoding="UTF-8"?>';
144 144
 	$output .= '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:image="http://www.google.com/schemas/sitemap-image/1.1">';
145 145
 
146 146
 		$date_names = $Spotter->getAllDates();
147
-		foreach($date_names as $date_item)
147
+		foreach ($date_names as $date_item)
148 148
 		{
149 149
 			$output .= '<url>';
150 150
 			    $output .= '<loc>'.'http://'.$_SERVER['HTTP_HOST'].$globalURL.'/date/'.date("Y-m-d", strtotime($date_item['date'])).'</loc>';
@@ -154,13 +154,13 @@  discard block
 block discarded – undo
154 154
 		}
155 155
 	$output .= '</urlset>';
156 156
 	
157
-} else if (isset($_GET['type']) && $_GET['type'] == "route"){
157
+} else if (isset($_GET['type']) && $_GET['type'] == "route") {
158 158
 
159 159
 	$output .= '<?xml version="1.0" encoding="UTF-8"?>';
160 160
 	$output .= '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:image="http://www.google.com/schemas/sitemap-image/1.1">';
161 161
 
162 162
 		$route_names = $Spotter->getAllRoutes();
163
-		foreach($route_names as $route_item)
163
+		foreach ($route_names as $route_item)
164 164
 		{
165 165
 			$output .= '<url>';
166 166
 			    $output .= '<loc>'.'http://'.$_SERVER['HTTP_HOST'].$globalURL.'/route/'.$route_item['airport_departure_icao'].'/'.$route_item['airport_arrival_icao'].'</loc>';
@@ -170,7 +170,7 @@  discard block
 block discarded – undo
170 170
 		}
171 171
 	$output .= '</urlset>';
172 172
 	
173
-} else if (isset($_GET['type']) && $_GET['type'] == "static"){
173
+} else if (isset($_GET['type']) && $_GET['type'] == "static") {
174 174
 
175 175
 	$output .= '<?xml version="1.0" encoding="UTF-8"?>';
176 176
 	$output .= '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:image="http://www.google.com/schemas/sitemap-image/1.1">';
Please login to merge, or discard this patch.
statistics-airport-arrival-country.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
26 26
         	["'._("Country").'", "'._("# of times").'"],';
27 27
 
28 28
 $country_data = '';
29
-foreach($airport_country_array as $airport_item)
29
+foreach ($airport_country_array as $airport_item)
30 30
 {
31 31
 	$country_data .= '[ "'.$airport_item['airport_departure_country'].'",'.$airport_item['airport_departure_country_count'].'],';
32 32
 }
@@ -61,7 +61,7 @@  discard block
 block discarded – undo
61 61
 print '</thead>';
62 62
 print '<tbody>';
63 63
 $i = 1;
64
-foreach($airport_country_array as $airport_item)
64
+foreach ($airport_country_array as $airport_item)
65 65
 {
66 66
 	print '<tr>';
67 67
 	print '<td><strong>'.$i.'</strong></td>';
Please login to merge, or discard this patch.
search-gpx.php 3 patches
Indentation   +40 added lines, -40 removed lines patch added patch discarded remove patch
@@ -4,55 +4,55 @@
 block discarded – undo
4 4
 require_once('require/class.Language.php');
5 5
 $Spotter = new Spotter();
6 6
 if (isset($_GET['start_date'])) {
7
-        //for the date manipulation into the query
8
-        if($_GET['start_date'] != "" && $_GET['end_date'] != ""){
9
-                $start_date = $_GET['start_date'].":00";
10
-                $end_date = $_GET['end_date'].":00";
11
-                $sql_date = $start_date.",".$end_date;
12
-        } else if($_GET['start_date'] != ""){
13
-                $start_date = $_GET['start_date'].":00";
14
-                $sql_date = $start_date;
15
-        } else if($_GET['start_date'] == "" && $_GET['end_date'] != ""){
16
-                $end_date = date("Y-m-d H:i:s", strtotime("2014-04-12")).",".$_GET['end_date'].":00";
17
-                $sql_date = $end_date;
18
-        } else $sql_date = '';
7
+		//for the date manipulation into the query
8
+		if($_GET['start_date'] != "" && $_GET['end_date'] != ""){
9
+				$start_date = $_GET['start_date'].":00";
10
+				$end_date = $_GET['end_date'].":00";
11
+				$sql_date = $start_date.",".$end_date;
12
+		} else if($_GET['start_date'] != ""){
13
+				$start_date = $_GET['start_date'].":00";
14
+				$sql_date = $start_date;
15
+		} else if($_GET['start_date'] == "" && $_GET['end_date'] != ""){
16
+				$end_date = date("Y-m-d H:i:s", strtotime("2014-04-12")).",".$_GET['end_date'].":00";
17
+				$sql_date = $end_date;
18
+		} else $sql_date = '';
19 19
 } else $sql_date = '';
20 20
 
21 21
 if (isset($_GET['highest_altitude'])) {
22
-        //for altitude manipulation
23
-        if($_GET['highest_altitude'] != "" && $_GET['lowest_altitude'] != ""){
24
-                $end_altitude = $_GET['highest_altitude'];
25
-                $start_altitude = $_GET['lowest_altitude'];
26
-                $sql_altitude = $start_altitude.",".$end_altitude;
27
-        } else if($_GET['highest_altitude'] != ""){
28
-                $end_altitude = $_GET['highest_altitude'];
29
-                $sql_altitude = $end_altitude;
30
-        } else if($_GET['highest_altitude'] == "" && $_GET['lowest_altitude'] != ""){
31
-                $start_altitude = $_GET['lowest_altitude'].",60000";
32
-                $sql_altitude = $start_altitude;
33
-        } else $sql_altitude = '';
22
+		//for altitude manipulation
23
+		if($_GET['highest_altitude'] != "" && $_GET['lowest_altitude'] != ""){
24
+				$end_altitude = $_GET['highest_altitude'];
25
+				$start_altitude = $_GET['lowest_altitude'];
26
+				$sql_altitude = $start_altitude.",".$end_altitude;
27
+		} else if($_GET['highest_altitude'] != ""){
28
+				$end_altitude = $_GET['highest_altitude'];
29
+				$sql_altitude = $end_altitude;
30
+		} else if($_GET['highest_altitude'] == "" && $_GET['lowest_altitude'] != ""){
31
+				$start_altitude = $_GET['lowest_altitude'].",60000";
32
+				$sql_altitude = $start_altitude;
33
+		} else $sql_altitude = '';
34 34
 } else $sql_altitude = '';
35 35
 
36 36
 //calculuation for the pagination
37 37
 if(!isset($_GET['limit']))
38 38
 {
39
-        if (!isset($_GET['number_results']))
40
-        {
41
-                $limit_start = 0;
42
-                $limit_end = 25;
43
-                $absolute_difference = 25;
44
-        } else {
45
-                if ($_GET['number_results'] > 1000){
46
-                        $_GET['number_results'] = 1000;
47
-                }
48
-                $limit_start = 0;
49
-                $limit_end = $_GET['number_results'];
50
-                $absolute_difference = $_GET['number_results'];
51
-        }
39
+		if (!isset($_GET['number_results']))
40
+		{
41
+				$limit_start = 0;
42
+				$limit_end = 25;
43
+				$absolute_difference = 25;
44
+		} else {
45
+				if ($_GET['number_results'] > 1000){
46
+						$_GET['number_results'] = 1000;
47
+				}
48
+				$limit_start = 0;
49
+				$limit_end = $_GET['number_results'];
50
+				$absolute_difference = $_GET['number_results'];
51
+		}
52 52
 }  else {
53
-        $limit_explode = explode(",", $_GET['limit']);
54
-        $limit_start = $limit_explode[0];
55
-        $limit_end = $limit_explode[1];
53
+		$limit_explode = explode(",", $_GET['limit']);
54
+		$limit_start = $limit_explode[0];
55
+		$limit_end = $limit_explode[1];
56 56
 }
57 57
 
58 58
 $absolute_difference = abs($limit_start - $limit_end);
Please login to merge, or discard this patch.
Spacing   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -5,14 +5,14 @@  discard block
 block discarded – undo
5 5
 $Spotter = new Spotter();
6 6
 if (isset($_GET['start_date'])) {
7 7
         //for the date manipulation into the query
8
-        if($_GET['start_date'] != "" && $_GET['end_date'] != ""){
8
+        if ($_GET['start_date'] != "" && $_GET['end_date'] != "") {
9 9
                 $start_date = $_GET['start_date'].":00";
10 10
                 $end_date = $_GET['end_date'].":00";
11 11
                 $sql_date = $start_date.",".$end_date;
12
-        } else if($_GET['start_date'] != ""){
12
+        } else if ($_GET['start_date'] != "") {
13 13
                 $start_date = $_GET['start_date'].":00";
14 14
                 $sql_date = $start_date;
15
-        } else if($_GET['start_date'] == "" && $_GET['end_date'] != ""){
15
+        } else if ($_GET['start_date'] == "" && $_GET['end_date'] != "") {
16 16
                 $end_date = date("Y-m-d H:i:s", strtotime("2014-04-12")).",".$_GET['end_date'].":00";
17 17
                 $sql_date = $end_date;
18 18
         } else $sql_date = '';
@@ -20,21 +20,21 @@  discard block
 block discarded – undo
20 20
 
21 21
 if (isset($_GET['highest_altitude'])) {
22 22
         //for altitude manipulation
23
-        if($_GET['highest_altitude'] != "" && $_GET['lowest_altitude'] != ""){
23
+        if ($_GET['highest_altitude'] != "" && $_GET['lowest_altitude'] != "") {
24 24
                 $end_altitude = $_GET['highest_altitude'];
25 25
                 $start_altitude = $_GET['lowest_altitude'];
26 26
                 $sql_altitude = $start_altitude.",".$end_altitude;
27
-        } else if($_GET['highest_altitude'] != ""){
27
+        } else if ($_GET['highest_altitude'] != "") {
28 28
                 $end_altitude = $_GET['highest_altitude'];
29 29
                 $sql_altitude = $end_altitude;
30
-        } else if($_GET['highest_altitude'] == "" && $_GET['lowest_altitude'] != ""){
30
+        } else if ($_GET['highest_altitude'] == "" && $_GET['lowest_altitude'] != "") {
31 31
                 $start_altitude = $_GET['lowest_altitude'].",60000";
32 32
                 $sql_altitude = $start_altitude;
33 33
         } else $sql_altitude = '';
34 34
 } else $sql_altitude = '';
35 35
 
36 36
 //calculuation for the pagination
37
-if(!isset($_GET['limit']))
37
+if (!isset($_GET['limit']))
38 38
 {
39 39
         if (!isset($_GET['number_results']))
40 40
         {
@@ -42,14 +42,14 @@  discard block
 block discarded – undo
42 42
                 $limit_end = 25;
43 43
                 $absolute_difference = 25;
44 44
         } else {
45
-                if ($_GET['number_results'] > 1000){
45
+                if ($_GET['number_results'] > 1000) {
46 46
                         $_GET['number_results'] = 1000;
47 47
                 }
48 48
                 $limit_start = 0;
49 49
                 $limit_end = $_GET['number_results'];
50 50
                 $absolute_difference = $_GET['number_results'];
51 51
         }
52
-}  else {
52
+} else {
53 53
         $limit_explode = explode(",", $_GET['limit']);
54 54
         $limit_start = $limit_explode[0];
55 55
         $limit_end = $limit_explode[1];
@@ -69,30 +69,30 @@  discard block
 block discarded – undo
69 69
 
70 70
 if (isset($_GET['sort'])) $sort = $_GET['sort'];
71 71
 else $sort = '';
72
-$q = filter_input(INPUT_GET,'q',FILTER_SANITIZE_STRING);
73
-$registration = filter_input(INPUT_GET,'registratrion',FILTER_SANITIZE_STRING);
74
-$aircraft = filter_input(INPUT_GET,'aircraft',FILTER_SANITIZE_STRING);
75
-$manufacturer = filter_input(INPUT_GET,'manufacturer',FILTER_SANITIZE_STRING);
76
-$highlights = filter_input(INPUT_GET,'highlights',FILTER_SANITIZE_STRING);
77
-$airline = filter_input(INPUT_GET,'airline',FILTER_SANITIZE_STRING);
78
-$airline_country = filter_input(INPUT_GET,'airline_country',FILTER_SANITIZE_STRING);
79
-$airline_type = filter_input(INPUT_GET,'airline_type',FILTER_SANITIZE_STRING);
80
-$airport = filter_input(INPUT_GET,'airport',FILTER_SANITIZE_STRING);
81
-$airport_country = filter_input(INPUT_GET,'airport_country',FILTER_SANITIZE_STRING);
82
-$callsign = filter_input(INPUT_GET,'callsign',FILTER_SANITIZE_STRING);
83
-$owner = filter_input(INPUT_GET,'owner',FILTER_SANITIZE_STRING);
84
-$pilot_id = filter_input(INPUT_GET,'pilot_id',FILTER_SANITIZE_STRING);
85
-$pilot_name = filter_input(INPUT_GET,'pilot_name',FILTER_SANITIZE_STRING);
86
-$departure_airport_route = filter_input(INPUT_GET,'departure_airport_route',FILTER_SANITIZE_STRING);
87
-$arrival_airport_route = filter_input(INPUT_GET,'arrival_airport_route',FILTER_SANITIZE_STRING);
88
-$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,'');
72
+$q = filter_input(INPUT_GET, 'q', FILTER_SANITIZE_STRING);
73
+$registration = filter_input(INPUT_GET, 'registratrion', FILTER_SANITIZE_STRING);
74
+$aircraft = filter_input(INPUT_GET, 'aircraft', FILTER_SANITIZE_STRING);
75
+$manufacturer = filter_input(INPUT_GET, 'manufacturer', FILTER_SANITIZE_STRING);
76
+$highlights = filter_input(INPUT_GET, 'highlights', FILTER_SANITIZE_STRING);
77
+$airline = filter_input(INPUT_GET, 'airline', FILTER_SANITIZE_STRING);
78
+$airline_country = filter_input(INPUT_GET, 'airline_country', FILTER_SANITIZE_STRING);
79
+$airline_type = filter_input(INPUT_GET, 'airline_type', FILTER_SANITIZE_STRING);
80
+$airport = filter_input(INPUT_GET, 'airport', FILTER_SANITIZE_STRING);
81
+$airport_country = filter_input(INPUT_GET, 'airport_country', FILTER_SANITIZE_STRING);
82
+$callsign = filter_input(INPUT_GET, 'callsign', FILTER_SANITIZE_STRING);
83
+$owner = filter_input(INPUT_GET, 'owner', FILTER_SANITIZE_STRING);
84
+$pilot_id = filter_input(INPUT_GET, 'pilot_id', FILTER_SANITIZE_STRING);
85
+$pilot_name = filter_input(INPUT_GET, 'pilot_name', FILTER_SANITIZE_STRING);
86
+$departure_airport_route = filter_input(INPUT_GET, 'departure_airport_route', FILTER_SANITIZE_STRING);
87
+$arrival_airport_route = filter_input(INPUT_GET, 'arrival_airport_route', FILTER_SANITIZE_STRING);
88
+$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, '');
89 89
        
90 90
 $i = 1;      
91 91
 //$output .= "oid;Line\n";
92 92
 $output = '';
93 93
 if (!empty($spotter_array))
94 94
 {
95
-	foreach($spotter_array as $spotter_item)
95
+	foreach ($spotter_array as $spotter_item)
96 96
 	{
97 97
 		if ($spotter_item['waypoints'] != '') {
98 98
 			$waypoint_pieces = explode(' ', $spotter_item['waypoints']);
Please login to merge, or discard this patch.
Braces   +18 added lines, -7 removed lines patch added patch discarded remove patch
@@ -15,8 +15,12 @@  discard block
 block discarded – undo
15 15
         } else if($_GET['start_date'] == "" && $_GET['end_date'] != ""){
16 16
                 $end_date = date("Y-m-d H:i:s", strtotime("2014-04-12")).",".$_GET['end_date'].":00";
17 17
                 $sql_date = $end_date;
18
-        } else $sql_date = '';
19
-} else $sql_date = '';
18
+        } else {
19
+        	$sql_date = '';
20
+        }
21
+        } else {
22
+	$sql_date = '';
23
+}
20 24
 
21 25
 if (isset($_GET['highest_altitude'])) {
22 26
         //for altitude manipulation
@@ -30,8 +34,12 @@  discard block
 block discarded – undo
30 34
         } else if($_GET['highest_altitude'] == "" && $_GET['lowest_altitude'] != ""){
31 35
                 $start_altitude = $_GET['lowest_altitude'].",60000";
32 36
                 $sql_altitude = $start_altitude;
33
-        } else $sql_altitude = '';
34
-} else $sql_altitude = '';
37
+        } else {
38
+        	$sql_altitude = '';
39
+        }
40
+        } else {
41
+	$sql_altitude = '';
42
+}
35 43
 
36 44
 //calculuation for the pagination
37 45
 if(!isset($_GET['limit']))
@@ -49,7 +57,7 @@  discard block
 block discarded – undo
49 57
                 $limit_end = $_GET['number_results'];
50 58
                 $absolute_difference = $_GET['number_results'];
51 59
         }
52
-}  else {
60
+} else {
53 61
         $limit_explode = explode(",", $_GET['limit']);
54 62
         $limit_start = $limit_explode[0];
55 63
         $limit_end = $limit_explode[1];
@@ -67,8 +75,11 @@  discard block
 block discarded – undo
67 75
 
68 76
 header("Content-type: text/yaml");
69 77
 
70
-if (isset($_GET['sort'])) $sort = $_GET['sort'];
71
-else $sort = '';
78
+if (isset($_GET['sort'])) {
79
+	$sort = $_GET['sort'];
80
+} else {
81
+	$sort = '';
82
+}
72 83
 $q = filter_input(INPUT_GET,'q',FILTER_SANITIZE_STRING);
73 84
 $registration = filter_input(INPUT_GET,'registratrion',FILTER_SANITIZE_STRING);
74 85
 $aircraft = filter_input(INPUT_GET,'aircraft',FILTER_SANITIZE_STRING);
Please login to merge, or discard this patch.
statistics-airport-arrival.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
26 26
         	["'._("Airport").'", "'._("# of times").'"],';
27 27
 
28 28
 $airport_data = '';
29
-foreach($airport_airport_array as $airport_item)
29
+foreach ($airport_airport_array as $airport_item)
30 30
 {
31 31
 	$name = $airport_item['airport_departure_city'].', '.$airport_item['airport_departure_country'].' ('.$airport_item['airport_departure_icao'].')';
32 32
 	$name = str_replace("'", "", $name);
@@ -64,7 +64,7 @@  discard block
 block discarded – undo
64 64
 print '</thead>';
65 65
 print '<tbody>';
66 66
 $i = 1;
67
-foreach($airport_airport_array as $airport_item)
67
+foreach ($airport_airport_array as $airport_item)
68 68
 {
69 69
 	print '<tr>';
70 70
 	print '<td><strong>'.$i.'</strong></td>';
Please login to merge, or discard this patch.
statistics-airline.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
             var data = google.visualization.arrayToDataTable([
24 24
             	["'._("Country").'", "'._("# of times").'"], ';
25 25
 $country_data = '';
26
-foreach($airline_array as $airline_item)
26
+foreach ($airline_array as $airline_item)
27 27
 {
28 28
 	$country_data .= '[ "'.$airline_item['airline_country'].'",'.$airline_item['airline_country_count'].'],';
29 29
 }
@@ -57,7 +57,7 @@  discard block
 block discarded – undo
57 57
 	print '</thead>';
58 58
 	print '<tbody>';
59 59
 	$i = 1;
60
-	foreach($airline_array as $airline_item)
60
+	foreach ($airline_array as $airline_item)
61 61
 	{
62 62
 		print '<tr>';
63 63
 		print '<td><strong>'.$i.'</strong></td>';
Please login to merge, or discard this patch.
require/class.SpotterArchive.php 3 patches
Spacing   +78 added lines, -78 removed lines patch added patch discarded remove patch
@@ -11,28 +11,28 @@  discard block
 block discarded – undo
11 11
 
12 12
     // Spotter_archive
13 13
     
14
-    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 = '') {
14
+    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 = '') {
15 15
 	require_once(dirname(__FILE__).'/class.Spotter.php');
16 16
         if ($over_country == '') {
17 17
 	        $Spotter = new Spotter($this->db);
18
-	        $data_country = $Spotter->getCountryFromLatitudeLongitude($latitude,$longitude);
18
+	        $data_country = $Spotter->getCountryFromLatitudeLongitude($latitude, $longitude);
19 19
 		if (!empty($data_country)) $country = $data_country['iso2'];
20 20
 		else $country = '';
21 21
 	} else $country = $over_country;
22
-	if ($airline_type === NULL) $airline_type ='';
22
+	if ($airline_type === NULL) $airline_type = '';
23 23
 	
24 24
 	//if ($country == '') echo "\n".'************ UNKNOW COUNTRY ****************'."\n";
25 25
 	//else echo "\n".'*/*/*/*/*/*/*/ Country : '.$country.' */*/*/*/*/*/*/*/*/'."\n";
26 26
 
27 27
 	// Route is not added in spotter_archive
28
-	$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)
28
+	$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)
29 29
                 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)";
30 30
 
31
-        $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);
31
+        $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);
32 32
         try {
33 33
             $sth = $this->db->prepare($query);
34 34
             $sth->execute($query_values);
35
-        } catch(PDOException $e) {
35
+        } catch (PDOException $e) {
36 36
             return "error : ".$e->getMessage();
37 37
         }
38 38
         return "success";
@@ -52,9 +52,9 @@  discard block
 block discarded – undo
52 52
 
53 53
                 $ident = filter_var($ident, FILTER_SANITIZE_STRING);
54 54
                 //$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";
55
-                $query  = "SELECT spotter_archive.* FROM spotter_archive WHERE ident = :ident ORDER BY date DESC LIMIT 1";
55
+                $query = "SELECT spotter_archive.* FROM spotter_archive WHERE ident = :ident ORDER BY date DESC LIMIT 1";
56 56
 
57
-                $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident));
57
+                $spotter_array = $Spotter->getDataFromDB($query, array(':ident' => $ident));
58 58
 
59 59
                 return $spotter_array;
60 60
         }
@@ -73,7 +73,7 @@  discard block
 block discarded – undo
73 73
                 $id = filter_var($id, FILTER_SANITIZE_STRING);
74 74
                 //$query  = SpotterArchive->$global_query." WHERE spotter_archive.flightaware_id = :id";
75 75
                 //$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";
76
-                $query  = "SELECT * FROM spotter_archive WHERE flightaware_id = :id ORDER BY date DESC LIMIT 1";
76
+                $query = "SELECT * FROM spotter_archive WHERE flightaware_id = :id ORDER BY date DESC LIMIT 1";
77 77
 
78 78
 //              $spotter_array = Spotter->getDataFromDB($query,array(':id' => $id));
79 79
                   /*
@@ -86,7 +86,7 @@  discard block
 block discarded – undo
86 86
                 }
87 87
                 $spotter_array = $sth->fetchAll(PDO->FETCH_ASSOC);
88 88
                 */
89
-                $spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id));
89
+                $spotter_array = $Spotter->getDataFromDB($query, array(':id' => $id));
90 90
 
91 91
                 return $spotter_array;
92 92
         }
@@ -101,14 +101,14 @@  discard block
 block discarded – undo
101 101
         {
102 102
                 date_default_timezone_set('UTC');
103 103
                 $id = filter_var($id, FILTER_SANITIZE_STRING);
104
-                $query  = $this->global_query." WHERE spotter_archive.flightaware_id = :id";
104
+                $query = $this->global_query." WHERE spotter_archive.flightaware_id = :id";
105 105
 
106 106
 //              $spotter_array = Spotter->getDataFromDB($query,array(':id' => $id));
107 107
 
108 108
                 try {
109 109
                         $sth = $this->db->prepare($query);
110 110
                         $sth->execute(array(':id' => $id));
111
-                } catch(PDOException $e) {
111
+                } catch (PDOException $e) {
112 112
                         return "error";
113 113
                 }
114 114
                 $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -126,14 +126,14 @@  discard block
 block discarded – undo
126 126
         {
127 127
                 date_default_timezone_set('UTC');
128 128
                 $id = filter_var($id, FILTER_SANITIZE_STRING);
129
-                $query  = "SELECT spotter_archive.latitude, spotter_archive.longitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id";
129
+                $query = "SELECT spotter_archive.latitude, spotter_archive.longitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id";
130 130
 
131 131
 //              $spotter_array = Spotter->getDataFromDB($query,array(':id' => $id));
132 132
 
133 133
                 try {
134 134
                         $sth = $this->db->prepare($query);
135 135
                         $sth->execute(array(':id' => $id));
136
-                } catch(PDOException $e) {
136
+                } catch (PDOException $e) {
137 137
                         return $e->getMessage();
138 138
                 }
139 139
                 $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -154,12 +154,12 @@  discard block
 block discarded – undo
154 154
                 date_default_timezone_set('UTC');
155 155
 
156 156
                 $ident = filter_var($ident, FILTER_SANITIZE_STRING);
157
-                $query  = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.ident = :ident";
157
+                $query = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.ident = :ident";
158 158
 
159 159
                 try {
160 160
                         $sth = $this->db->prepare($query);
161 161
                         $sth->execute(array(':ident' => $ident));
162
-                } catch(PDOException $e) {
162
+                } catch (PDOException $e) {
163 163
                         return "error";
164 164
                 }
165 165
                 $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -179,12 +179,12 @@  discard block
 block discarded – undo
179 179
                 date_default_timezone_set('UTC');
180 180
 
181 181
                 $id = filter_var($id, FILTER_SANITIZE_STRING);
182
-                $query  = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id";
182
+                $query = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id";
183 183
 
184 184
                 try {
185 185
                         $sth = $this->db->prepare($query);
186 186
                         $sth->execute(array(':id' => $id));
187
-                } catch(PDOException $e) {
187
+                } catch (PDOException $e) {
188 188
                         return "error";
189 189
                 }
190 190
                 $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -204,12 +204,12 @@  discard block
 block discarded – undo
204 204
                 date_default_timezone_set('UTC');
205 205
 
206 206
                 $id = filter_var($id, FILTER_SANITIZE_STRING);
207
-                $query  = "SELECT spotter_archive.altitude, spotter_archive.ground_speed, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id";
207
+                $query = "SELECT spotter_archive.altitude, spotter_archive.ground_speed, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id";
208 208
 
209 209
                 try {
210 210
                         $sth = $this->db->prepare($query);
211 211
                         $sth->execute(array(':id' => $id));
212
-                } catch(PDOException $e) {
212
+                } catch (PDOException $e) {
213 213
 		        return "error : ".$e->getMessage();
214 214
                 }
215 215
                 $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -230,13 +230,13 @@  discard block
 block discarded – undo
230 230
                 date_default_timezone_set('UTC');
231 231
 
232 232
                 $ident = filter_var($ident, FILTER_SANITIZE_STRING);
233
-                $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";
233
+                $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";
234 234
 //                $query  = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.ident = :ident";
235 235
 
236 236
                 try {
237 237
                         $sth = $this->db->prepare($query);
238 238
                         $sth->execute(array(':ident' => $ident));
239
-                } catch(PDOException $e) {
239
+                } catch (PDOException $e) {
240 240
                         return "error";
241 241
                 }
242 242
                 $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -252,13 +252,13 @@  discard block
 block discarded – undo
252 252
         * @return Array the spotter information
253 253
         *
254 254
         */
255
-        public function getSpotterArchiveData($ident,$flightaware_id,$date)
255
+        public function getSpotterArchiveData($ident, $flightaware_id, $date)
256 256
         {
257 257
     		$Spotter = new Spotter($this->db);
258 258
                 $ident = filter_var($ident, FILTER_SANITIZE_STRING);
259
-                $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";
259
+                $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";
260 260
 
261
-                $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident,':flightaware_id' => $flightaware_id,':date' => $date.'%'));
261
+                $spotter_array = $Spotter->getDataFromDB($query, array(':ident' => $ident, ':flightaware_id' => $flightaware_id, ':date' => $date.'%'));
262 262
 
263 263
                 return $spotter_array;
264 264
         }
@@ -271,7 +271,7 @@  discard block
 block discarded – undo
271 271
                 try {
272 272
                         $sth = $this->db->prepare($query);
273 273
                         $sth->execute();
274
-                } catch(PDOException $e) {
274
+                } catch (PDOException $e) {
275 275
                         return "error";
276 276
                 }
277 277
 	}
@@ -282,24 +282,24 @@  discard block
 block discarded – undo
282 282
         * @return Array the spotter information
283 283
         *
284 284
         */
285
-        public function getMinLiveSpotterData($begindate,$enddate,$filter = array())
285
+        public function getMinLiveSpotterData($begindate, $enddate, $filter = array())
286 286
         {
287 287
                 global $globalDBdriver, $globalLiveInterval;
288 288
                 date_default_timezone_set('UTC');
289 289
 
290 290
                 $filter_query = '';
291 291
                 if (isset($filter['source']) && !empty($filter['source'])) {
292
-                        $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') ";
292
+                        $filter_query .= " AND format_source IN ('".implode("','", $filter['source'])."') ";
293 293
                 }
294 294
                 // Use spotter_output also ?
295 295
                 if (isset($filter['airlines']) && !empty($filter['airlines'])) {
296
-                        $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 ";
296
+                        $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 ";
297 297
                 }
298 298
                 if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) {
299 299
                         $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 ";
300 300
                 }
301 301
                 if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
302
-                        $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
302
+                        $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')";
303 303
                 }
304 304
 
305 305
                 //if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
@@ -309,7 +309,7 @@  discard block
 block discarded – undo
309 309
                     		    FROM spotter_archive 
310 310
                     		    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';
311 311
 			*/
312
-			$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 
312
+			$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 
313 313
 				    FROM spotter_archive 
314 314
 				    INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate 
315 315
 						FROM spotter_archive l 
@@ -317,13 +317,13 @@  discard block
 block discarded – undo
317 317
 						GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id 
318 318
 				    AND spotter_archive.date = s.maxdate '.$filter_query.'LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON spotter_archive.aircraft_icao = a.icao';
319 319
                 } else if ($globalDBdriver == 'pgsql') {
320
-                        $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';
320
+                        $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';
321 321
                 }
322 322
                 //echo $query;
323 323
                 try {
324 324
                         $sth = $this->db->prepare($query);
325 325
                         $sth->execute();
326
-                } catch(PDOException $e) {
326
+                } catch (PDOException $e) {
327 327
                         return "error";
328 328
                 }
329 329
                 $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -337,24 +337,24 @@  discard block
 block discarded – undo
337 337
         * @return Array the spotter information
338 338
         *
339 339
         */
340
-        public function getMinLiveSpotterDataPlayback($begindate,$enddate,$filter = array())
340
+        public function getMinLiveSpotterDataPlayback($begindate, $enddate, $filter = array())
341 341
         {
342 342
                 global $globalDBdriver, $globalLiveInterval;
343 343
                 date_default_timezone_set('UTC');
344 344
 
345 345
                 $filter_query = '';
346 346
                 if (isset($filter['source']) && !empty($filter['source'])) {
347
-                        $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') ";
347
+                        $filter_query .= " AND format_source IN ('".implode("','", $filter['source'])."') ";
348 348
                 }
349 349
                 // FIXME : use spotter_output also
350 350
                 if (isset($filter['airlines']) && !empty($filter['airlines'])) {
351
-                        $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 ";
351
+                        $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 ";
352 352
                 }
353 353
                 if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) {
354 354
                         $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 ";
355 355
                 }
356 356
                 if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
357
-                        $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
357
+                        $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')";
358 358
                 }
359 359
 
360 360
                 //if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
@@ -364,7 +364,7 @@  discard block
 block discarded – undo
364 364
                     		    FROM spotter_archive 
365 365
                     		    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';
366 366
 			*/
367
-			$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 
367
+			$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 
368 368
 				    FROM spotter_archive_output 
369 369
 				    LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON spotter_archive_output.aircraft_icao = a.icao 
370 370
 				    WHERE (spotter_archive_output.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') 
@@ -372,12 +372,12 @@  discard block
 block discarded – undo
372 372
 
373 373
                 } else if ($globalDBdriver == 'pgsql') {
374 374
                         //$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';
375
-                        $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
375
+                        $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
376 376
                         	    FROM spotter_archive_output 
377 377
                         	    INNER JOIN (SELECT * FROM aircraft) a on spotter_archive_output.aircraft_icao = a.icao
378 378
                         	    WHERE spotter_archive_output.date >= '."'".$begindate."'".' AND spotter_archive_output.date <= '."'".$enddate."'".'
379 379
                         	    '.$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';
380
-                        $query  = 'SELECT DISTINCT spotter_output.flightaware_id, spotter_output.ident, spotter_output.aircraft_icao, spotter_output.departure_airport_icao as departure_airport, spotter_output.arrival_airport_icao as arrival_airport, spotter_output.latitude, spotter_output.longitude, spotter_output.altitude, spotter_output.heading, spotter_output.ground_speed, spotter_output.squawk, a.aircraft_shadow
380
+                        $query = 'SELECT DISTINCT spotter_output.flightaware_id, spotter_output.ident, spotter_output.aircraft_icao, spotter_output.departure_airport_icao as departure_airport, spotter_output.arrival_airport_icao as arrival_airport, spotter_output.latitude, spotter_output.longitude, spotter_output.altitude, spotter_output.heading, spotter_output.ground_speed, spotter_output.squawk, a.aircraft_shadow
381 381
                         	    FROM spotter_output 
382 382
                         	    INNER JOIN (SELECT * FROM aircraft) a on spotter_output.aircraft_icao = a.icao
383 383
                         	    WHERE spotter_output.date >= '."'".$begindate."'".' AND spotter_output.date <= '."'".$enddate."'".'
@@ -389,7 +389,7 @@  discard block
 block discarded – undo
389 389
                 try {
390 390
                         $sth = $this->db->prepare($query);
391 391
                         $sth->execute();
392
-                } catch(PDOException $e) {
392
+                } catch (PDOException $e) {
393 393
                         return $e->getMessage();
394 394
                 }
395 395
                 $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -403,23 +403,23 @@  discard block
 block discarded – undo
403 403
         * @return Array the spotter information
404 404
         *
405 405
         */
406
-        public function getLiveSpotterCount($begindate,$enddate,$filter = array())
406
+        public function getLiveSpotterCount($begindate, $enddate, $filter = array())
407 407
         {
408 408
                 global $globalDBdriver, $globalLiveInterval;
409 409
                 date_default_timezone_set('UTC');
410 410
 
411 411
                 $filter_query = '';
412 412
                 if (isset($filter['source']) && !empty($filter['source'])) {
413
-                        $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') ";
413
+                        $filter_query .= " AND format_source IN ('".implode("','", $filter['source'])."') ";
414 414
                 }
415 415
                 if (isset($filter['airlines']) && !empty($filter['airlines'])) {
416
-                        $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 ";
416
+                        $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 ";
417 417
                 }
418 418
                 if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) {
419 419
                         $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 ";
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';
@@ -435,7 +435,7 @@  discard block
 block discarded – undo
435 435
                 try {
436 436
                         $sth = $this->db->prepare($query);
437 437
                         $sth->execute();
438
-                } catch(PDOException $e) {
438
+                } catch (PDOException $e) {
439 439
                         return "error";
440 440
                 }
441 441
 		$result = $sth->fetch(PDO::FETCH_ASSOC);
@@ -453,7 +453,7 @@  discard block
 block discarded – undo
453 453
     * @return Array the spotter information
454 454
     *
455 455
     */
456
-    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 = '')
456
+    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 = '')
457 457
     {
458 458
 	global $globalTimezone, $globalDbdriver;
459 459
 	require_once(dirname(__FILE__).'/class.Translation.php');
@@ -472,7 +472,7 @@  discard block
 block discarded – undo
472 472
 	        
473 473
 		$q_array = explode(" ", $q);
474 474
 		
475
-		foreach ($q_array as $q_item){
475
+		foreach ($q_array as $q_item) {
476 476
 		    $additional_query .= " AND (";
477 477
 		    $additional_query .= "(spotter_archive_output.spotter_id like '%".$q_item."%') OR ";
478 478
 		    $additional_query .= "(spotter_archive_output.aircraft_icao like '%".$q_item."%') OR ";
@@ -504,7 +504,7 @@  discard block
 block discarded – undo
504 504
 	
505 505
 	if ($registration != "")
506 506
 	{
507
-	    $registration = filter_var($registration,FILTER_SANITIZE_STRING);
507
+	    $registration = filter_var($registration, FILTER_SANITIZE_STRING);
508 508
 	    if (!is_string($registration))
509 509
 	    {
510 510
 		return false;
@@ -515,7 +515,7 @@  discard block
 block discarded – undo
515 515
 	
516 516
 	if ($aircraft_icao != "")
517 517
 	{
518
-	    $aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING);
518
+	    $aircraft_icao = filter_var($aircraft_icao, FILTER_SANITIZE_STRING);
519 519
 	    if (!is_string($aircraft_icao))
520 520
 	    {
521 521
 		return false;
@@ -526,7 +526,7 @@  discard block
 block discarded – undo
526 526
 	
527 527
 	if ($aircraft_manufacturer != "")
528 528
 	{
529
-	    $aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING);
529
+	    $aircraft_manufacturer = filter_var($aircraft_manufacturer, FILTER_SANITIZE_STRING);
530 530
 	    if (!is_string($aircraft_manufacturer))
531 531
 	    {
532 532
 		return false;
@@ -547,7 +547,7 @@  discard block
 block discarded – undo
547 547
 	
548 548
 	if ($airline_icao != "")
549 549
 	{
550
-	    $registration = filter_var($airline_icao,FILTER_SANITIZE_STRING);
550
+	    $registration = filter_var($airline_icao, FILTER_SANITIZE_STRING);
551 551
 	    if (!is_string($airline_icao))
552 552
 	    {
553 553
 		return false;
@@ -558,7 +558,7 @@  discard block
 block discarded – undo
558 558
 	
559 559
 	if ($airline_country != "")
560 560
 	{
561
-	    $airline_country = filter_var($airline_country,FILTER_SANITIZE_STRING);
561
+	    $airline_country = filter_var($airline_country, FILTER_SANITIZE_STRING);
562 562
 	    if (!is_string($airline_country))
563 563
 	    {
564 564
 		return false;
@@ -569,7 +569,7 @@  discard block
 block discarded – undo
569 569
 	
570 570
 	if ($airline_type != "")
571 571
 	{
572
-	    $airline_type = filter_var($airline_type,FILTER_SANITIZE_STRING);
572
+	    $airline_type = filter_var($airline_type, FILTER_SANITIZE_STRING);
573 573
 	    if (!is_string($airline_type))
574 574
 	    {
575 575
 		return false;
@@ -591,7 +591,7 @@  discard block
 block discarded – undo
591 591
 	
592 592
 	if ($airport != "")
593 593
 	{
594
-	    $airport = filter_var($airport,FILTER_SANITIZE_STRING);
594
+	    $airport = filter_var($airport, FILTER_SANITIZE_STRING);
595 595
 	    if (!is_string($airport))
596 596
 	    {
597 597
 		return false;
@@ -602,7 +602,7 @@  discard block
 block discarded – undo
602 602
 	
603 603
 	if ($airport_country != "")
604 604
 	{
605
-	    $airport_country = filter_var($airport_country,FILTER_SANITIZE_STRING);
605
+	    $airport_country = filter_var($airport_country, FILTER_SANITIZE_STRING);
606 606
 	    if (!is_string($airport_country))
607 607
 	    {
608 608
 		return false;
@@ -613,7 +613,7 @@  discard block
 block discarded – undo
613 613
     
614 614
 	if ($callsign != "")
615 615
 	{
616
-	    $callsign = filter_var($callsign,FILTER_SANITIZE_STRING);
616
+	    $callsign = filter_var($callsign, FILTER_SANITIZE_STRING);
617 617
 	    if (!is_string($callsign))
618 618
 	    {
619 619
 		return false;
@@ -621,7 +621,7 @@  discard block
 block discarded – undo
621 621
 		$translate = $Translation->ident2icao($callsign);
622 622
 		if ($translate != $callsign) {
623 623
 			$additional_query .= " AND (spotter_archive_output.ident = :callsign OR spotter_archive_output.ident = :translate)";
624
-			$query_values = array_merge($query_values,array(':callsign' => $callsign,':translate' => $translate));
624
+			$query_values = array_merge($query_values, array(':callsign' => $callsign, ':translate' => $translate));
625 625
 		} else {
626 626
 			$additional_query .= " AND (spotter_archive_output.ident = '".$callsign."')";
627 627
 		}
@@ -630,7 +630,7 @@  discard block
 block discarded – undo
630 630
 
631 631
 	if ($owner != "")
632 632
 	{
633
-	    $owner = filter_var($owner,FILTER_SANITIZE_STRING);
633
+	    $owner = filter_var($owner, FILTER_SANITIZE_STRING);
634 634
 	    if (!is_string($owner))
635 635
 	    {
636 636
 		return false;
@@ -641,7 +641,7 @@  discard block
 block discarded – undo
641 641
 
642 642
 	if ($pilot_name != "")
643 643
 	{
644
-	    $pilot_name = filter_var($pilot_name,FILTER_SANITIZE_STRING);
644
+	    $pilot_name = filter_var($pilot_name, FILTER_SANITIZE_STRING);
645 645
 	    if (!is_string($pilot_name))
646 646
 	    {
647 647
 		return false;
@@ -652,7 +652,7 @@  discard block
 block discarded – undo
652 652
 	
653 653
 	if ($pilot_id != "")
654 654
 	{
655
-	    $pilot_id = filter_var($pilot_id,FILTER_SANITIZE_NUMBER_INT);
655
+	    $pilot_id = filter_var($pilot_id, FILTER_SANITIZE_NUMBER_INT);
656 656
 	    if (!is_string($pilot_id))
657 657
 	    {
658 658
 		return false;
@@ -663,7 +663,7 @@  discard block
 block discarded – undo
663 663
 	
664 664
 	if ($departure_airport_route != "")
665 665
 	{
666
-	    $departure_airport_route = filter_var($departure_airport_route,FILTER_SANITIZE_STRING);
666
+	    $departure_airport_route = filter_var($departure_airport_route, FILTER_SANITIZE_STRING);
667 667
 	    if (!is_string($departure_airport_route))
668 668
 	    {
669 669
 		return false;
@@ -674,7 +674,7 @@  discard block
 block discarded – undo
674 674
 	
675 675
 	if ($arrival_airport_route != "")
676 676
 	{
677
-	    $arrival_airport_route = filter_var($arrival_airport_route,FILTER_SANITIZE_STRING);
677
+	    $arrival_airport_route = filter_var($arrival_airport_route, FILTER_SANITIZE_STRING);
678 678
 	    if (!is_string($arrival_airport_route))
679 679
 	    {
680 680
 		return false;
@@ -687,8 +687,8 @@  discard block
 block discarded – undo
687 687
 	{
688 688
 	    $altitude_array = explode(",", $altitude);
689 689
 	    
690
-	    $altitude_array[0] = filter_var($altitude_array[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
691
-	    $altitude_array[1] = filter_var($altitude_array[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
690
+	    $altitude_array[0] = filter_var($altitude_array[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
691
+	    $altitude_array[1] = filter_var($altitude_array[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
692 692
 	    
693 693
 
694 694
 	    if ($altitude_array[1] != "")
@@ -706,8 +706,8 @@  discard block
 block discarded – undo
706 706
 	{
707 707
 	    $date_array = explode(",", $date_posted);
708 708
 	    
709
-	    $date_array[0] = filter_var($date_array[0],FILTER_SANITIZE_STRING);
710
-	    $date_array[1] = filter_var($date_array[1],FILTER_SANITIZE_STRING);
709
+	    $date_array[0] = filter_var($date_array[0], FILTER_SANITIZE_STRING);
710
+	    $date_array[1] = filter_var($date_array[1], FILTER_SANITIZE_STRING);
711 711
 	    
712 712
 	    if ($globalTimezone != '') {
713 713
 		date_default_timezone_set($globalTimezone);
@@ -739,8 +739,8 @@  discard block
 block discarded – undo
739 739
 	{
740 740
 	    $limit_array = explode(",", $limit);
741 741
 	    
742
-	    $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
743
-	    $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
742
+	    $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
743
+	    $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
744 744
 	    
745 745
 	    if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
746 746
 	    {
@@ -751,8 +751,8 @@  discard block
 block discarded – undo
751 751
 	
752 752
 
753 753
 	if ($origLat != "" && $origLon != "" && $dist != "") {
754
-		$dist = number_format($dist*0.621371,2,'.','');
755
-		$query="SELECT spotter_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 
754
+		$dist = number_format($dist*0.621371, 2, '.', '');
755
+		$query = "SELECT spotter_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 
756 756
                           FROM spotter_output_archive, 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)) 
757 757
                           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 ORDER BY distance";
758 758
 	} else {
@@ -769,13 +769,13 @@  discard block
 block discarded – undo
769 769
 			$additional_query .= " AND (spotter_archive_output.waypoints <> '')";
770 770
 		}
771 771
 
772
-		$query  = "SELECT spotter_archive_output.* FROM spotter_archive_output 
772
+		$query = "SELECT spotter_archive_output.* FROM spotter_archive_output 
773 773
 		    WHERE spotter_archive_output.ident <> '' 
774 774
 		    ".$additional_query."
775 775
 		    ".$orderby_query;
776 776
 	}
777 777
 	$Spotter = new Spotter($this->db);
778
-	$spotter_array = $Spotter->getDataFromDB($query, array(),$limit_query);
778
+	$spotter_array = $Spotter->getDataFromDB($query, array(), $limit_query);
779 779
 
780 780
 	return $spotter_array;
781 781
     }
@@ -792,7 +792,7 @@  discard block
 block discarded – undo
792 792
                 try {
793 793
                         $sth = $this->db->prepare($query);
794 794
                         $sth->execute();
795
-                } catch(PDOException $e) {
795
+                } catch (PDOException $e) {
796 796
                         return "error";
797 797
                 }
798 798
 	}
@@ -826,8 +826,8 @@  discard block
 block discarded – undo
826 826
 	{
827 827
 	    $limit_array = explode(",", $limit);
828 828
 	    
829
-	    $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
830
-	    $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
829
+	    $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
830
+	    $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
831 831
 	    
832 832
 	    if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
833 833
 	    {
@@ -858,7 +858,7 @@  discard block
 block discarded – undo
858 858
     * @return Array the airline country list
859 859
     *
860 860
     */
861
-    public function countAllFlightOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '')
861
+    public function countAllFlightOverCountries($limit = true, $olderthanmonths = 0, $sincedate = '')
862 862
     {
863 863
 	global $globalDBdriver;
864 864
 	/*
@@ -887,7 +887,7 @@  discard block
 block discarded – undo
887 887
 	$flight_array = array();
888 888
 	$temp_array = array();
889 889
         
890
-	while($row = $sth->fetch(PDO::FETCH_ASSOC))
890
+	while ($row = $sth->fetch(PDO::FETCH_ASSOC))
891 891
 	{
892 892
 	    $temp_array['flight_count'] = $row['nb'];
893 893
 	    $temp_array['flight_country'] = $row['name'];
Please login to merge, or discard this patch.
Braces   +23 added lines, -8 removed lines patch added patch discarded remove patch
@@ -16,10 +16,17 @@  discard block
 block discarded – undo
16 16
         if ($over_country == '') {
17 17
 	        $Spotter = new Spotter($this->db);
18 18
 	        $data_country = $Spotter->getCountryFromLatitudeLongitude($latitude,$longitude);
19
-		if (!empty($data_country)) $country = $data_country['iso2'];
20
-		else $country = '';
21
-	} else $country = $over_country;
22
-	if ($airline_type === NULL) $airline_type ='';
19
+		if (!empty($data_country)) {
20
+			$country = $data_country['iso2'];
21
+		} else {
22
+			$country = '';
23
+		}
24
+	} else {
25
+		$country = $over_country;
26
+	}
27
+	if ($airline_type === NULL) {
28
+		$airline_type ='';
29
+	}
23 30
 	
24 31
 	//if ($country == '') echo "\n".'************ UNKNOW COUNTRY ****************'."\n";
25 32
 	//else echo "\n".'*/*/*/*/*/*/*/ Country : '.$country.' */*/*/*/*/*/*/*/*/'."\n";
@@ -495,7 +502,9 @@  discard block
 block discarded – undo
495 502
 		    $additional_query .= "(spotter_archive_output.pilot_name like '%".$q_item."%') OR ";
496 503
 		    $additional_query .= "(spotter_archive_output.ident like '%".$q_item."%') OR ";
497 504
 		    $translate = $Translation->ident2icao($q_item);
498
-		    if ($translate != $q_item) $additional_query .= "(spotter_archive_output.ident like '%".$translate."%') OR ";
505
+		    if ($translate != $q_item) {
506
+		    	$additional_query .= "(spotter_archive_output.ident like '%".$translate."%') OR ";
507
+		    }
499 508
 		    $additional_query .= "(spotter_archive_output.highlight like '%".$q_item."%')";
500 509
 		    $additional_query .= ")";
501 510
 		}
@@ -713,7 +722,9 @@  discard block
 block discarded – undo
713 722
 		date_default_timezone_set($globalTimezone);
714 723
 		$datetime = new DateTime();
715 724
 		$offset = $datetime->format('P');
716
-	    } else $offset = '+00:00';
725
+	    } else {
726
+	    	$offset = '+00:00';
727
+	    }
717 728
 
718 729
 
719 730
 	    if ($date_array[1] != "")
@@ -876,9 +887,13 @@  discard block
 block discarded – undo
876 887
 				$query .= "AND date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'";
877 888
 			}
878 889
 		}
879
-                if ($sincedate != '') $query .= "AND date > '".$sincedate."' ";
890
+                if ($sincedate != '') {
891
+                	$query .= "AND date > '".$sincedate."' ";
892
+                }
880 893
 	$query .= "GROUP BY c.name, c.iso3, c.iso2 ORDER BY nb DESC";
881
-	if ($limit) $query .= " LIMIT 0,10";
894
+	if ($limit) {
895
+		$query .= " LIMIT 0,10";
896
+	}
882 897
       
883 898
 	
884 899
 	$sth = $this->db->prepare($query);
Please login to merge, or discard this patch.
Indentation   +514 added lines, -514 removed lines patch added patch discarded remove patch
@@ -1,21 +1,21 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 class SpotterArchive {
3
-    public $global_query = "SELECT spotter_archive.* FROM spotter_archive";
4
-    public $db;
3
+	public $global_query = "SELECT spotter_archive.* FROM spotter_archive";
4
+	public $db;
5 5
 
6
-    function __construct($dbc = null) {
7
-            $Connection = new Connection($dbc);
8
-            $this->db = $Connection->db;
9
-    }
6
+	function __construct($dbc = null) {
7
+			$Connection = new Connection($dbc);
8
+			$this->db = $Connection->db;
9
+	}
10 10
 
11 11
 
12
-    // Spotter_archive
12
+	// Spotter_archive
13 13
     
14
-    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 = '') {
14
+	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 = '') {
15 15
 	require_once(dirname(__FILE__).'/class.Spotter.php');
16
-        if ($over_country == '') {
17
-	        $Spotter = new Spotter($this->db);
18
-	        $data_country = $Spotter->getCountryFromLatitudeLongitude($latitude,$longitude);
16
+		if ($over_country == '') {
17
+			$Spotter = new Spotter($this->db);
18
+			$data_country = $Spotter->getCountryFromLatitudeLongitude($latitude,$longitude);
19 19
 		if (!empty($data_country)) $country = $data_country['iso2'];
20 20
 		else $country = '';
21 21
 	} else $country = $over_country;
@@ -28,55 +28,55 @@  discard block
 block discarded – undo
28 28
 	$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)
29 29
                 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)";
30 30
 
31
-        $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);
32
-        try {
33
-            $sth = $this->db->prepare($query);
34
-            $sth->execute($query_values);
35
-        } catch(PDOException $e) {
36
-            return "error : ".$e->getMessage();
37
-        }
38
-        return "success";
39
-    }
40
-
41
-
42
-        /**
43
-        * Gets all the spotter information based on a particular callsign
44
-        *
45
-        * @return Array the spotter information
46
-        *
47
-        */
48
-        public function getLastArchiveSpotterDataByIdent($ident)
49
-        {
31
+		$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);
32
+		try {
33
+			$sth = $this->db->prepare($query);
34
+			$sth->execute($query_values);
35
+		} catch(PDOException $e) {
36
+			return "error : ".$e->getMessage();
37
+		}
38
+		return "success";
39
+	}
40
+
41
+
42
+		/**
43
+		 * Gets all the spotter information based on a particular callsign
44
+		 *
45
+		 * @return Array the spotter information
46
+		 *
47
+		 */
48
+		public function getLastArchiveSpotterDataByIdent($ident)
49
+		{
50 50
 		$Spotter = new Spotter($this->db);
51
-                date_default_timezone_set('UTC');
51
+				date_default_timezone_set('UTC');
52 52
 
53
-                $ident = filter_var($ident, FILTER_SANITIZE_STRING);
54
-                //$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";
55
-                $query  = "SELECT spotter_archive.* FROM spotter_archive WHERE ident = :ident ORDER BY date DESC LIMIT 1";
53
+				$ident = filter_var($ident, FILTER_SANITIZE_STRING);
54
+				//$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";
55
+				$query  = "SELECT spotter_archive.* FROM spotter_archive WHERE ident = :ident ORDER BY date DESC LIMIT 1";
56 56
 
57
-                $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident));
57
+				$spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident));
58 58
 
59
-                return $spotter_array;
60
-        }
59
+				return $spotter_array;
60
+		}
61 61
 
62 62
 
63
-        /**
64
-        * Gets last the spotter information based on a particular id
65
-        *
66
-        * @return Array the spotter information
67
-        *
68
-        */
69
-        public function getLastArchiveSpotterDataById($id)
70
-        {
71
-    		$Spotter = new Spotter($this->db);
72
-                date_default_timezone_set('UTC');
73
-                $id = filter_var($id, FILTER_SANITIZE_STRING);
74
-                //$query  = SpotterArchive->$global_query." WHERE spotter_archive.flightaware_id = :id";
75
-                //$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";
76
-                $query  = "SELECT * FROM spotter_archive WHERE flightaware_id = :id ORDER BY date DESC LIMIT 1";
63
+		/**
64
+		 * Gets last the spotter information based on a particular id
65
+		 *
66
+		 * @return Array the spotter information
67
+		 *
68
+		 */
69
+		public function getLastArchiveSpotterDataById($id)
70
+		{
71
+			$Spotter = new Spotter($this->db);
72
+				date_default_timezone_set('UTC');
73
+				$id = filter_var($id, FILTER_SANITIZE_STRING);
74
+				//$query  = SpotterArchive->$global_query." WHERE spotter_archive.flightaware_id = :id";
75
+				//$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";
76
+				$query  = "SELECT * FROM spotter_archive WHERE flightaware_id = :id ORDER BY date DESC LIMIT 1";
77 77
 
78 78
 //              $spotter_array = Spotter->getDataFromDB($query,array(':id' => $id));
79
-                  /*
79
+				  /*
80 80
                 try {
81 81
                         $Connection = new Connection();
82 82
                         $sth = Connection->$db->prepare($query);
@@ -86,225 +86,225 @@  discard block
 block discarded – undo
86 86
                 }
87 87
                 $spotter_array = $sth->fetchAll(PDO->FETCH_ASSOC);
88 88
                 */
89
-                $spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id));
90
-
91
-                return $spotter_array;
92
-        }
93
-
94
-        /**
95
-        * Gets all the spotter information based on a particular id
96
-        *
97
-        * @return Array the spotter information
98
-        *
99
-        */
100
-        public function getAllArchiveSpotterDataById($id)
101
-        {
102
-                date_default_timezone_set('UTC');
103
-                $id = filter_var($id, FILTER_SANITIZE_STRING);
104
-                $query  = $this->global_query." WHERE spotter_archive.flightaware_id = :id";
89
+				$spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id));
90
+
91
+				return $spotter_array;
92
+		}
93
+
94
+		/**
95
+		 * Gets all the spotter information based on a particular id
96
+		 *
97
+		 * @return Array the spotter information
98
+		 *
99
+		 */
100
+		public function getAllArchiveSpotterDataById($id)
101
+		{
102
+				date_default_timezone_set('UTC');
103
+				$id = filter_var($id, FILTER_SANITIZE_STRING);
104
+				$query  = $this->global_query." WHERE spotter_archive.flightaware_id = :id";
105 105
 
106 106
 //              $spotter_array = Spotter->getDataFromDB($query,array(':id' => $id));
107 107
 
108
-                try {
109
-                        $sth = $this->db->prepare($query);
110
-                        $sth->execute(array(':id' => $id));
111
-                } catch(PDOException $e) {
112
-                        return "error";
113
-                }
114
-                $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
115
-
116
-                return $spotter_array;
117
-        }
118
-
119
-        /**
120
-        * Gets coordinate & time spotter information based on a particular id
121
-        *
122
-        * @return Array the spotter information
123
-        *
124
-        */
125
-        public function getCoordArchiveSpotterDataById($id)
126
-        {
127
-                date_default_timezone_set('UTC');
128
-                $id = filter_var($id, FILTER_SANITIZE_STRING);
129
-                $query  = "SELECT spotter_archive.latitude, spotter_archive.longitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id";
108
+				try {
109
+						$sth = $this->db->prepare($query);
110
+						$sth->execute(array(':id' => $id));
111
+				} catch(PDOException $e) {
112
+						return "error";
113
+				}
114
+				$spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
115
+
116
+				return $spotter_array;
117
+		}
118
+
119
+		/**
120
+		 * Gets coordinate & time spotter information based on a particular id
121
+		 *
122
+		 * @return Array the spotter information
123
+		 *
124
+		 */
125
+		public function getCoordArchiveSpotterDataById($id)
126
+		{
127
+				date_default_timezone_set('UTC');
128
+				$id = filter_var($id, FILTER_SANITIZE_STRING);
129
+				$query  = "SELECT spotter_archive.latitude, spotter_archive.longitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id";
130 130
 
131 131
 //              $spotter_array = Spotter->getDataFromDB($query,array(':id' => $id));
132 132
 
133
-                try {
134
-                        $sth = $this->db->prepare($query);
135
-                        $sth->execute(array(':id' => $id));
136
-                } catch(PDOException $e) {
137
-                        return $e->getMessage();
138
-                }
139
-                $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
133
+				try {
134
+						$sth = $this->db->prepare($query);
135
+						$sth->execute(array(':id' => $id));
136
+				} catch(PDOException $e) {
137
+						return $e->getMessage();
138
+				}
139
+				$spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
140 140
 
141
-                return $spotter_array;
142
-        }
141
+				return $spotter_array;
142
+		}
143 143
 
144 144
 
145
-        /**
146
-        * Gets altitude information based on a particular callsign
147
-        *
148
-        * @return Array the spotter information
149
-        *
150
-        */
151
-        public function getAltitudeArchiveSpotterDataByIdent($ident)
152
-        {
145
+		/**
146
+		 * Gets altitude information based on a particular callsign
147
+		 *
148
+		 * @return Array the spotter information
149
+		 *
150
+		 */
151
+		public function getAltitudeArchiveSpotterDataByIdent($ident)
152
+		{
153 153
 
154
-                date_default_timezone_set('UTC');
154
+				date_default_timezone_set('UTC');
155 155
 
156
-                $ident = filter_var($ident, FILTER_SANITIZE_STRING);
157
-                $query  = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.ident = :ident";
156
+				$ident = filter_var($ident, FILTER_SANITIZE_STRING);
157
+				$query  = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.ident = :ident";
158 158
 
159
-                try {
160
-                        $sth = $this->db->prepare($query);
161
-                        $sth->execute(array(':ident' => $ident));
162
-                } catch(PDOException $e) {
163
-                        return "error";
164
-                }
165
-                $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
159
+				try {
160
+						$sth = $this->db->prepare($query);
161
+						$sth->execute(array(':ident' => $ident));
162
+				} catch(PDOException $e) {
163
+						return "error";
164
+				}
165
+				$spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
166 166
 
167
-                return $spotter_array;
168
-        }
167
+				return $spotter_array;
168
+		}
169 169
 
170
-        /**
171
-        * Gets altitude information based on a particular id
172
-        *
173
-        * @return Array the spotter information
174
-        *
175
-        */
176
-        public function getAltitudeArchiveSpotterDataById($id)
177
-        {
170
+		/**
171
+		 * Gets altitude information based on a particular id
172
+		 *
173
+		 * @return Array the spotter information
174
+		 *
175
+		 */
176
+		public function getAltitudeArchiveSpotterDataById($id)
177
+		{
178 178
 
179
-                date_default_timezone_set('UTC');
179
+				date_default_timezone_set('UTC');
180 180
 
181
-                $id = filter_var($id, FILTER_SANITIZE_STRING);
182
-                $query  = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id";
181
+				$id = filter_var($id, FILTER_SANITIZE_STRING);
182
+				$query  = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id";
183 183
 
184
-                try {
185
-                        $sth = $this->db->prepare($query);
186
-                        $sth->execute(array(':id' => $id));
187
-                } catch(PDOException $e) {
188
-                        return "error";
189
-                }
190
-                $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
184
+				try {
185
+						$sth = $this->db->prepare($query);
186
+						$sth->execute(array(':id' => $id));
187
+				} catch(PDOException $e) {
188
+						return "error";
189
+				}
190
+				$spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
191 191
 
192
-                return $spotter_array;
193
-        }
192
+				return $spotter_array;
193
+		}
194 194
 
195
-        /**
196
-        * Gets altitude & speed information based on a particular id
197
-        *
198
-        * @return Array the spotter information
199
-        *
200
-        */
201
-        public function getAltitudeSpeedArchiveSpotterDataById($id)
202
-        {
195
+		/**
196
+		 * Gets altitude & speed information based on a particular id
197
+		 *
198
+		 * @return Array the spotter information
199
+		 *
200
+		 */
201
+		public function getAltitudeSpeedArchiveSpotterDataById($id)
202
+		{
203 203
 
204
-                date_default_timezone_set('UTC');
204
+				date_default_timezone_set('UTC');
205 205
 
206
-                $id = filter_var($id, FILTER_SANITIZE_STRING);
207
-                $query  = "SELECT spotter_archive.altitude, spotter_archive.ground_speed, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id";
206
+				$id = filter_var($id, FILTER_SANITIZE_STRING);
207
+				$query  = "SELECT spotter_archive.altitude, spotter_archive.ground_speed, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id";
208 208
 
209
-                try {
210
-                        $sth = $this->db->prepare($query);
211
-                        $sth->execute(array(':id' => $id));
212
-                } catch(PDOException $e) {
213
-		        return "error : ".$e->getMessage();
214
-                }
215
-                $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
209
+				try {
210
+						$sth = $this->db->prepare($query);
211
+						$sth->execute(array(':id' => $id));
212
+				} catch(PDOException $e) {
213
+				return "error : ".$e->getMessage();
214
+				}
215
+				$spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
216 216
 
217
-                return $spotter_array;
218
-        }
217
+				return $spotter_array;
218
+		}
219 219
 
220 220
 
221
-        /**
222
-        * Gets altitude information based on a particular callsign
223
-        *
224
-        * @return Array the spotter information
225
-        *
226
-        */
227
-        public function getLastAltitudeArchiveSpotterDataByIdent($ident)
228
-        {
221
+		/**
222
+		 * Gets altitude information based on a particular callsign
223
+		 *
224
+		 * @return Array the spotter information
225
+		 *
226
+		 */
227
+		public function getLastAltitudeArchiveSpotterDataByIdent($ident)
228
+		{
229 229
 
230
-                date_default_timezone_set('UTC');
230
+				date_default_timezone_set('UTC');
231 231
 
232
-                $ident = filter_var($ident, FILTER_SANITIZE_STRING);
233
-                $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";
232
+				$ident = filter_var($ident, FILTER_SANITIZE_STRING);
233
+				$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";
234 234
 //                $query  = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.ident = :ident";
235 235
 
236
-                try {
237
-                        $sth = $this->db->prepare($query);
238
-                        $sth->execute(array(':ident' => $ident));
239
-                } catch(PDOException $e) {
240
-                        return "error";
241
-                }
242
-                $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
236
+				try {
237
+						$sth = $this->db->prepare($query);
238
+						$sth->execute(array(':ident' => $ident));
239
+				} catch(PDOException $e) {
240
+						return "error";
241
+				}
242
+				$spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
243 243
 
244
-                return $spotter_array;
245
-        }
244
+				return $spotter_array;
245
+		}
246 246
 
247 247
 
248 248
 
249
-       /**
250
-        * Gets all the archive spotter information
251
-        *
252
-        * @return Array the spotter information
253
-        *
254
-        */
255
-        public function getSpotterArchiveData($ident,$flightaware_id,$date)
256
-        {
257
-    		$Spotter = new Spotter($this->db);
258
-                $ident = filter_var($ident, FILTER_SANITIZE_STRING);
259
-                $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";
249
+	   /**
250
+	    * Gets all the archive spotter information
251
+	    *
252
+	    * @return Array the spotter information
253
+	    *
254
+	    */
255
+		public function getSpotterArchiveData($ident,$flightaware_id,$date)
256
+		{
257
+			$Spotter = new Spotter($this->db);
258
+				$ident = filter_var($ident, FILTER_SANITIZE_STRING);
259
+				$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";
260 260
 
261
-                $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident,':flightaware_id' => $flightaware_id,':date' => $date.'%'));
261
+				$spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident,':flightaware_id' => $flightaware_id,':date' => $date.'%'));
262 262
 
263
-                return $spotter_array;
264
-        }
263
+				return $spotter_array;
264
+		}
265 265
         
266
-        public function deleteSpotterArchiveTrackData()
267
-        {
266
+		public function deleteSpotterArchiveTrackData()
267
+		{
268 268
 		global $globalArchiveKeepTrackMonths;
269
-                date_default_timezone_set('UTC');
269
+				date_default_timezone_set('UTC');
270 270
 		$query = 'DELETE FROM spotter_archive WHERE spotter_archive.date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL '.$globalArchiveKeepTrackMonths.' MONTH)';
271
-                try {
272
-                        $sth = $this->db->prepare($query);
273
-                        $sth->execute();
274
-                } catch(PDOException $e) {
275
-                        return "error";
276
-                }
271
+				try {
272
+						$sth = $this->db->prepare($query);
273
+						$sth->execute();
274
+				} catch(PDOException $e) {
275
+						return "error";
276
+				}
277 277
 	}
278 278
 
279 279
 	/**
280
-        * Gets Minimal Live Spotter data
281
-        *
282
-        * @return Array the spotter information
283
-        *
284
-        */
285
-        public function getMinLiveSpotterData($begindate,$enddate,$filter = array())
286
-        {
287
-                global $globalDBdriver, $globalLiveInterval;
288
-                date_default_timezone_set('UTC');
289
-
290
-                $filter_query = '';
291
-                if (isset($filter['source']) && !empty($filter['source'])) {
292
-                        $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') ";
293
-                }
294
-                // Use spotter_output also ?
295
-                if (isset($filter['airlines']) && !empty($filter['airlines'])) {
296
-                        $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 ";
297
-                }
298
-                if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) {
299
-                        $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 ";
300
-                }
301
-                if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
302
-                        $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
303
-                }
304
-
305
-                //if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
306
-                if ($globalDBdriver == 'mysql') {
307
-                        /*
280
+	 * Gets Minimal Live Spotter data
281
+	 *
282
+	 * @return Array the spotter information
283
+	 *
284
+	 */
285
+		public function getMinLiveSpotterData($begindate,$enddate,$filter = array())
286
+		{
287
+				global $globalDBdriver, $globalLiveInterval;
288
+				date_default_timezone_set('UTC');
289
+
290
+				$filter_query = '';
291
+				if (isset($filter['source']) && !empty($filter['source'])) {
292
+						$filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') ";
293
+				}
294
+				// Use spotter_output also ?
295
+				if (isset($filter['airlines']) && !empty($filter['airlines'])) {
296
+						$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 ";
297
+				}
298
+				if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) {
299
+						$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 ";
300
+				}
301
+				if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
302
+						$filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
303
+				}
304
+
305
+				//if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
306
+				if ($globalDBdriver == 'mysql') {
307
+						/*
308 308
                         $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 
309 309
                     		    FROM spotter_archive 
310 310
                     		    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';
@@ -316,50 +316,50 @@  discard block
 block discarded – undo
316 316
 						WHERE (l.date BETWEEN DATE_SUB('."'".$begindate."'".',INTERVAL '.$globalLiveInterval.' SECOND) AND '."'".$begindate."'".') 
317 317
 						GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id 
318 318
 				    AND spotter_archive.date = s.maxdate '.$filter_query.'LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON spotter_archive.aircraft_icao = a.icao';
319
-                } else if ($globalDBdriver == 'pgsql') {
320
-                        $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';
321
-                }
322
-                //echo $query;
323
-                try {
324
-                        $sth = $this->db->prepare($query);
325
-                        $sth->execute();
326
-                } catch(PDOException $e) {
327
-                        return "error";
328
-                }
329
-                $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
330
-
331
-                return $spotter_array;
332
-        }
319
+				} else if ($globalDBdriver == 'pgsql') {
320
+						$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';
321
+				}
322
+				//echo $query;
323
+				try {
324
+						$sth = $this->db->prepare($query);
325
+						$sth->execute();
326
+				} catch(PDOException $e) {
327
+						return "error";
328
+				}
329
+				$spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
330
+
331
+				return $spotter_array;
332
+		}
333 333
 
334 334
 	/**
335
-        * Gets Minimal Live Spotter data
336
-        *
337
-        * @return Array the spotter information
338
-        *
339
-        */
340
-        public function getMinLiveSpotterDataPlayback($begindate,$enddate,$filter = array())
341
-        {
342
-                global $globalDBdriver, $globalLiveInterval;
343
-                date_default_timezone_set('UTC');
344
-
345
-                $filter_query = '';
346
-                if (isset($filter['source']) && !empty($filter['source'])) {
347
-                        $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') ";
348
-                }
349
-                // Should use spotter_output also ?
350
-                if (isset($filter['airlines']) && !empty($filter['airlines'])) {
351
-                        $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 ";
352
-                }
353
-                if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) {
354
-                        $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 ";
355
-                }
356
-                if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
357
-                        $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
358
-                }
359
-
360
-                //if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
361
-                if ($globalDBdriver == 'mysql') {
362
-                        /*
335
+	 * Gets Minimal Live Spotter data
336
+	 *
337
+	 * @return Array the spotter information
338
+	 *
339
+	 */
340
+		public function getMinLiveSpotterDataPlayback($begindate,$enddate,$filter = array())
341
+		{
342
+				global $globalDBdriver, $globalLiveInterval;
343
+				date_default_timezone_set('UTC');
344
+
345
+				$filter_query = '';
346
+				if (isset($filter['source']) && !empty($filter['source'])) {
347
+						$filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') ";
348
+				}
349
+				// Should use spotter_output also ?
350
+				if (isset($filter['airlines']) && !empty($filter['airlines'])) {
351
+						$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 ";
352
+				}
353
+				if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) {
354
+						$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 ";
355
+				}
356
+				if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
357
+						$filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
358
+				}
359
+
360
+				//if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
361
+				if ($globalDBdriver == 'mysql') {
362
+						/*
363 363
                         $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 
364 364
                     		    FROM spotter_archive 
365 365
                     		    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';
@@ -370,91 +370,91 @@  discard block
 block discarded – undo
370 370
 				    WHERE (spotter_archive_output.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') 
371 371
                         	    '.$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';
372 372
 
373
-                } else if ($globalDBdriver == 'pgsql') {
374
-                        //$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';
375
-                        $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
373
+				} else if ($globalDBdriver == 'pgsql') {
374
+						//$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';
375
+						$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
376 376
                         	    FROM spotter_archive_output 
377 377
                         	    INNER JOIN (SELECT * FROM aircraft) a on spotter_archive_output.aircraft_icao = a.icao
378 378
                         	    WHERE spotter_archive_output.date >= '."'".$begindate."'".' AND spotter_archive_output.date <= '."'".$enddate."'".'
379 379
                         	    '.$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';
380
-                        $query  = 'SELECT DISTINCT spotter_output.flightaware_id, spotter_output.ident, spotter_output.aircraft_icao, spotter_output.departure_airport_icao as departure_airport, spotter_output.arrival_airport_icao as arrival_airport, spotter_output.latitude, spotter_output.longitude, spotter_output.altitude, spotter_output.heading, spotter_output.ground_speed, spotter_output.squawk, a.aircraft_shadow
380
+						$query  = 'SELECT DISTINCT spotter_output.flightaware_id, spotter_output.ident, spotter_output.aircraft_icao, spotter_output.departure_airport_icao as departure_airport, spotter_output.arrival_airport_icao as arrival_airport, spotter_output.latitude, spotter_output.longitude, spotter_output.altitude, spotter_output.heading, spotter_output.ground_speed, spotter_output.squawk, a.aircraft_shadow
381 381
                         	    FROM spotter_output 
382 382
                         	    INNER JOIN (SELECT * FROM aircraft) a on spotter_output.aircraft_icao = a.icao
383 383
                         	    WHERE spotter_output.date >= '."'".$begindate."'".' AND spotter_output.date <= '."'".$enddate."'".'
384 384
                         	    '.$filter_query.' LIMIT 200 OFFSET 0';
385 385
 //                        	    .' 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';
386 386
                         	    
387
-                }
388
-                //echo $query;
389
-                try {
390
-                        $sth = $this->db->prepare($query);
391
-                        $sth->execute();
392
-                } catch(PDOException $e) {
393
-                        return $e->getMessage();
394
-                }
395
-                $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
396
-
397
-                return $spotter_array;
398
-        }
387
+				}
388
+				//echo $query;
389
+				try {
390
+						$sth = $this->db->prepare($query);
391
+						$sth->execute();
392
+				} catch(PDOException $e) {
393
+						return $e->getMessage();
394
+				}
395
+				$spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
396
+
397
+				return $spotter_array;
398
+		}
399 399
 
400 400
 	 /**
401
-        * Gets count Live Spotter data
402
-        *
403
-        * @return Array the spotter information
404
-        *
405
-        */
406
-        public function getLiveSpotterCount($begindate,$enddate,$filter = array())
407
-        {
408
-                global $globalDBdriver, $globalLiveInterval;
409
-                date_default_timezone_set('UTC');
410
-
411
-                $filter_query = '';
412
-                if (isset($filter['source']) && !empty($filter['source'])) {
413
-                        $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') ";
414
-                }
415
-                if (isset($filter['airlines']) && !empty($filter['airlines'])) {
416
-                        $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 ";
417
-                }
418
-                if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) {
419
-                        $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 ";
420
-                }
421
-                if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
422
-                        $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
423
-                }
424
-
425
-                //if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
426
-                if ($globalDBdriver == 'mysql') {
401
+	  * Gets count Live Spotter data
402
+	  *
403
+	  * @return Array the spotter information
404
+	  *
405
+	  */
406
+		public function getLiveSpotterCount($begindate,$enddate,$filter = array())
407
+		{
408
+				global $globalDBdriver, $globalLiveInterval;
409
+				date_default_timezone_set('UTC');
410
+
411
+				$filter_query = '';
412
+				if (isset($filter['source']) && !empty($filter['source'])) {
413
+						$filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') ";
414
+				}
415
+				if (isset($filter['airlines']) && !empty($filter['airlines'])) {
416
+						$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 ";
417
+				}
418
+				if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) {
419
+						$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 ";
420
+				}
421
+				if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
422
+						$filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
423
+				}
424
+
425
+				//if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
426
+				if ($globalDBdriver == 'mysql') {
427 427
 			$query = 'SELECT COUNT(DISTINCT flightaware_id) as nb 
428 428
 			FROM spotter_archive l 
429 429
 			WHERE (l.date BETWEEN DATE_SUB('."'".$begindate."'".',INTERVAL '.$globalLiveInterval.' SECOND) AND '."'".$begindate."'".')'.$filter_query;
430 430
 
431
-                } else if ($globalDBdriver == 'pgsql') {
431
+				} else if ($globalDBdriver == 'pgsql') {
432 432
 			$query = 'SELECT COUNT(DISTINCT flightaware_id) as nb FROM spotter_archive l WHERE (l.date BETWEEN '."'".$begindate."' - INTERVAL '".$globalLiveInterval." SECONDS' AND "."'".$enddate."'".')'.$filter_query;
433
-                }
434
-                //echo $query;
435
-                try {
436
-                        $sth = $this->db->prepare($query);
437
-                        $sth->execute();
438
-                } catch(PDOException $e) {
439
-                        return "error";
440
-                }
433
+				}
434
+				//echo $query;
435
+				try {
436
+						$sth = $this->db->prepare($query);
437
+						$sth->execute();
438
+				} catch(PDOException $e) {
439
+						return "error";
440
+				}
441 441
 		$result = $sth->fetch(PDO::FETCH_ASSOC);
442
-                return $result['nb'];
442
+				return $result['nb'];
443 443
 
444
-        }
444
+		}
445 445
 
446 446
 
447 447
 
448 448
 	// Spotter_Archive_output
449 449
 	
450
-    /**
451
-    * Gets all the spotter information
452
-    *
453
-    * @return Array the spotter information
454
-    *
455
-    */
456
-    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 = '')
457
-    {
450
+	/**
451
+	 * Gets all the spotter information
452
+	 *
453
+	 * @return Array the spotter information
454
+	 *
455
+	 */
456
+	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 = '')
457
+	{
458 458
 	global $globalTimezone, $globalDbdriver;
459 459
 	require_once(dirname(__FILE__).'/class.Translation.php');
460 460
 	$Translation = new Translation();
@@ -465,159 +465,159 @@  discard block
 block discarded – undo
465 465
 	$additional_query = '';
466 466
 	if ($q != "")
467 467
 	{
468
-	    if (!is_string($q))
469
-	    {
468
+		if (!is_string($q))
469
+		{
470 470
 		return false;
471
-	    } else {
471
+		} else {
472 472
 	        
473 473
 		$q_array = explode(" ", $q);
474 474
 		
475 475
 		foreach ($q_array as $q_item){
476
-		    $additional_query .= " AND (";
477
-		    $additional_query .= "(spotter_archive_output.spotter_id like '%".$q_item."%') OR ";
478
-		    $additional_query .= "(spotter_archive_output.aircraft_icao like '%".$q_item."%') OR ";
479
-		    $additional_query .= "(spotter_archive_output.aircraft_name like '%".$q_item."%') OR ";
480
-		    $additional_query .= "(spotter_archive_output.aircraft_manufacturer like '%".$q_item."%') OR ";
481
-		    $additional_query .= "(spotter_archive_output.airline_icao like '%".$q_item."%') OR ";
482
-		    $additional_query .= "(spotter_archive_output.airline_name like '%".$q_item."%') OR ";
483
-		    $additional_query .= "(spotter_archive_output.airline_country like '%".$q_item."%') OR ";
484
-		    $additional_query .= "(spotter_archive_output.departure_airport_icao like '%".$q_item."%') OR ";
485
-		    $additional_query .= "(spotter_archive_output.departure_airport_name like '%".$q_item."%') OR ";
486
-		    $additional_query .= "(spotter_archive_output.departure_airport_city like '%".$q_item."%') OR ";
487
-		    $additional_query .= "(spotter_archive_output.departure_airport_country like '%".$q_item."%') OR ";
488
-		    $additional_query .= "(spotter_archive_output.arrival_airport_icao like '%".$q_item."%') OR ";
489
-		    $additional_query .= "(spotter_archive_output.arrival_airport_name like '%".$q_item."%') OR ";
490
-		    $additional_query .= "(spotter_archive_output.arrival_airport_city like '%".$q_item."%') OR ";
491
-		    $additional_query .= "(spotter_archive_output.arrival_airport_country like '%".$q_item."%') OR ";
492
-		    $additional_query .= "(spotter_archive_output.registration like '%".$q_item."%') OR ";
493
-		    $additional_query .= "(spotter_archive_output.owner_name like '%".$q_item."%') OR ";
494
-		    $additional_query .= "(spotter_archive_output.pilot_id like '%".$q_item."%') OR ";
495
-		    $additional_query .= "(spotter_archive_output.pilot_name like '%".$q_item."%') OR ";
496
-		    $additional_query .= "(spotter_archive_output.ident like '%".$q_item."%') OR ";
497
-		    $translate = $Translation->ident2icao($q_item);
498
-		    if ($translate != $q_item) $additional_query .= "(spotter_archive_output.ident like '%".$translate."%') OR ";
499
-		    $additional_query .= "(spotter_archive_output.highlight like '%".$q_item."%')";
500
-		    $additional_query .= ")";
501
-		}
502
-	    }
476
+			$additional_query .= " AND (";
477
+			$additional_query .= "(spotter_archive_output.spotter_id like '%".$q_item."%') OR ";
478
+			$additional_query .= "(spotter_archive_output.aircraft_icao like '%".$q_item."%') OR ";
479
+			$additional_query .= "(spotter_archive_output.aircraft_name like '%".$q_item."%') OR ";
480
+			$additional_query .= "(spotter_archive_output.aircraft_manufacturer like '%".$q_item."%') OR ";
481
+			$additional_query .= "(spotter_archive_output.airline_icao like '%".$q_item."%') OR ";
482
+			$additional_query .= "(spotter_archive_output.airline_name like '%".$q_item."%') OR ";
483
+			$additional_query .= "(spotter_archive_output.airline_country like '%".$q_item."%') OR ";
484
+			$additional_query .= "(spotter_archive_output.departure_airport_icao like '%".$q_item."%') OR ";
485
+			$additional_query .= "(spotter_archive_output.departure_airport_name like '%".$q_item."%') OR ";
486
+			$additional_query .= "(spotter_archive_output.departure_airport_city like '%".$q_item."%') OR ";
487
+			$additional_query .= "(spotter_archive_output.departure_airport_country like '%".$q_item."%') OR ";
488
+			$additional_query .= "(spotter_archive_output.arrival_airport_icao like '%".$q_item."%') OR ";
489
+			$additional_query .= "(spotter_archive_output.arrival_airport_name like '%".$q_item."%') OR ";
490
+			$additional_query .= "(spotter_archive_output.arrival_airport_city like '%".$q_item."%') OR ";
491
+			$additional_query .= "(spotter_archive_output.arrival_airport_country like '%".$q_item."%') OR ";
492
+			$additional_query .= "(spotter_archive_output.registration like '%".$q_item."%') OR ";
493
+			$additional_query .= "(spotter_archive_output.owner_name like '%".$q_item."%') OR ";
494
+			$additional_query .= "(spotter_archive_output.pilot_id like '%".$q_item."%') OR ";
495
+			$additional_query .= "(spotter_archive_output.pilot_name like '%".$q_item."%') OR ";
496
+			$additional_query .= "(spotter_archive_output.ident like '%".$q_item."%') OR ";
497
+			$translate = $Translation->ident2icao($q_item);
498
+			if ($translate != $q_item) $additional_query .= "(spotter_archive_output.ident like '%".$translate."%') OR ";
499
+			$additional_query .= "(spotter_archive_output.highlight like '%".$q_item."%')";
500
+			$additional_query .= ")";
501
+		}
502
+		}
503 503
 	}
504 504
 	
505 505
 	if ($registration != "")
506 506
 	{
507
-	    $registration = filter_var($registration,FILTER_SANITIZE_STRING);
508
-	    if (!is_string($registration))
509
-	    {
507
+		$registration = filter_var($registration,FILTER_SANITIZE_STRING);
508
+		if (!is_string($registration))
509
+		{
510 510
 		return false;
511
-	    } else {
511
+		} else {
512 512
 		$additional_query .= " AND (spotter_archive_output.registration = '".$registration."')";
513
-	    }
513
+		}
514 514
 	}
515 515
 	
516 516
 	if ($aircraft_icao != "")
517 517
 	{
518
-	    $aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING);
519
-	    if (!is_string($aircraft_icao))
520
-	    {
518
+		$aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING);
519
+		if (!is_string($aircraft_icao))
520
+		{
521 521
 		return false;
522
-	    } else {
522
+		} else {
523 523
 		$additional_query .= " AND (spotter_archive_output.aircraft_icao = '".$aircraft_icao."')";
524
-	    }
524
+		}
525 525
 	}
526 526
 	
527 527
 	if ($aircraft_manufacturer != "")
528 528
 	{
529
-	    $aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING);
530
-	    if (!is_string($aircraft_manufacturer))
531
-	    {
529
+		$aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING);
530
+		if (!is_string($aircraft_manufacturer))
531
+		{
532 532
 		return false;
533
-	    } else {
533
+		} else {
534 534
 		$additional_query .= " AND (spotter_archive_output.aircraft_manufacturer = '".$aircraft_manufacturer."')";
535
-	    }
535
+		}
536 536
 	}
537 537
 	
538 538
 	if ($highlights == "true")
539 539
 	{
540
-	    if (!is_string($highlights))
541
-	    {
540
+		if (!is_string($highlights))
541
+		{
542 542
 		return false;
543
-	    } else {
543
+		} else {
544 544
 		$additional_query .= " AND (spotter_archive_output.highlight <> '')";
545
-	    }
545
+		}
546 546
 	}
547 547
 	
548 548
 	if ($airline_icao != "")
549 549
 	{
550
-	    $registration = filter_var($airline_icao,FILTER_SANITIZE_STRING);
551
-	    if (!is_string($airline_icao))
552
-	    {
550
+		$registration = filter_var($airline_icao,FILTER_SANITIZE_STRING);
551
+		if (!is_string($airline_icao))
552
+		{
553 553
 		return false;
554
-	    } else {
554
+		} else {
555 555
 		$additional_query .= " AND (spotter_archive_output.airline_icao = '".$airline_icao."')";
556
-	    }
556
+		}
557 557
 	}
558 558
 	
559 559
 	if ($airline_country != "")
560 560
 	{
561
-	    $airline_country = filter_var($airline_country,FILTER_SANITIZE_STRING);
562
-	    if (!is_string($airline_country))
563
-	    {
561
+		$airline_country = filter_var($airline_country,FILTER_SANITIZE_STRING);
562
+		if (!is_string($airline_country))
563
+		{
564 564
 		return false;
565
-	    } else {
565
+		} else {
566 566
 		$additional_query .= " AND (spotter_archive_output.airline_country = '".$airline_country."')";
567
-	    }
567
+		}
568 568
 	}
569 569
 	
570 570
 	if ($airline_type != "")
571 571
 	{
572
-	    $airline_type = filter_var($airline_type,FILTER_SANITIZE_STRING);
573
-	    if (!is_string($airline_type))
574
-	    {
572
+		$airline_type = filter_var($airline_type,FILTER_SANITIZE_STRING);
573
+		if (!is_string($airline_type))
574
+		{
575 575
 		return false;
576
-	    } else {
576
+		} else {
577 577
 		if ($airline_type == "passenger")
578 578
 		{
579
-		    $additional_query .= " AND (spotter_archive_output.airline_type = 'passenger')";
579
+			$additional_query .= " AND (spotter_archive_output.airline_type = 'passenger')";
580 580
 		}
581 581
 		if ($airline_type == "cargo")
582 582
 		{
583
-		    $additional_query .= " AND (spotter_archive_output.airline_type = 'cargo')";
583
+			$additional_query .= " AND (spotter_archive_output.airline_type = 'cargo')";
584 584
 		}
585 585
 		if ($airline_type == "military")
586 586
 		{
587
-		    $additional_query .= " AND (spotter_archive_output.airline_type = 'military')";
587
+			$additional_query .= " AND (spotter_archive_output.airline_type = 'military')";
588
+		}
588 589
 		}
589
-	    }
590 590
 	}
591 591
 	
592 592
 	if ($airport != "")
593 593
 	{
594
-	    $airport = filter_var($airport,FILTER_SANITIZE_STRING);
595
-	    if (!is_string($airport))
596
-	    {
594
+		$airport = filter_var($airport,FILTER_SANITIZE_STRING);
595
+		if (!is_string($airport))
596
+		{
597 597
 		return false;
598
-	    } else {
598
+		} else {
599 599
 		$additional_query .= " AND ((spotter_archive_output.departure_airport_icao = '".$airport."') OR (spotter_archive_output.arrival_airport_icao = '".$airport."'))";
600
-	    }
600
+		}
601 601
 	}
602 602
 	
603 603
 	if ($airport_country != "")
604 604
 	{
605
-	    $airport_country = filter_var($airport_country,FILTER_SANITIZE_STRING);
606
-	    if (!is_string($airport_country))
607
-	    {
605
+		$airport_country = filter_var($airport_country,FILTER_SANITIZE_STRING);
606
+		if (!is_string($airport_country))
607
+		{
608 608
 		return false;
609
-	    } else {
609
+		} else {
610 610
 		$additional_query .= " AND ((spotter_archive_output.departure_airport_country = '".$airport_country."') OR (spotter_archive_output.arrival_airport_country = '".$airport_country."'))";
611
-	    }
611
+		}
612 612
 	}
613 613
     
614 614
 	if ($callsign != "")
615 615
 	{
616
-	    $callsign = filter_var($callsign,FILTER_SANITIZE_STRING);
617
-	    if (!is_string($callsign))
618
-	    {
616
+		$callsign = filter_var($callsign,FILTER_SANITIZE_STRING);
617
+		if (!is_string($callsign))
618
+		{
619 619
 		return false;
620
-	    } else {
620
+		} else {
621 621
 		$translate = $Translation->ident2icao($callsign);
622 622
 		if ($translate != $callsign) {
623 623
 			$additional_query .= " AND (spotter_archive_output.ident = :callsign OR spotter_archive_output.ident = :translate)";
@@ -625,99 +625,99 @@  discard block
 block discarded – undo
625 625
 		} else {
626 626
 			$additional_query .= " AND (spotter_archive_output.ident = '".$callsign."')";
627 627
 		}
628
-	    }
628
+		}
629 629
 	}
630 630
 
631 631
 	if ($owner != "")
632 632
 	{
633
-	    $owner = filter_var($owner,FILTER_SANITIZE_STRING);
634
-	    if (!is_string($owner))
635
-	    {
633
+		$owner = filter_var($owner,FILTER_SANITIZE_STRING);
634
+		if (!is_string($owner))
635
+		{
636 636
 		return false;
637
-	    } else {
637
+		} else {
638 638
 		$additional_query .= " AND (spotter_archive_output.owner_name = '".$owner."')";
639
-	    }
639
+		}
640 640
 	}
641 641
 
642 642
 	if ($pilot_name != "")
643 643
 	{
644
-	    $pilot_name = filter_var($pilot_name,FILTER_SANITIZE_STRING);
645
-	    if (!is_string($pilot_name))
646
-	    {
644
+		$pilot_name = filter_var($pilot_name,FILTER_SANITIZE_STRING);
645
+		if (!is_string($pilot_name))
646
+		{
647 647
 		return false;
648
-	    } else {
648
+		} else {
649 649
 		$additional_query .= " AND (spotter_archive_output.pilot_name = '".$pilot_name."')";
650
-	    }
650
+		}
651 651
 	}
652 652
 	
653 653
 	if ($pilot_id != "")
654 654
 	{
655
-	    $pilot_id = filter_var($pilot_id,FILTER_SANITIZE_NUMBER_INT);
656
-	    if (!is_string($pilot_id))
657
-	    {
655
+		$pilot_id = filter_var($pilot_id,FILTER_SANITIZE_NUMBER_INT);
656
+		if (!is_string($pilot_id))
657
+		{
658 658
 		return false;
659
-	    } else {
659
+		} else {
660 660
 		$additional_query .= " AND (spotter_archive_output.pilot_id = '".$pilot_id."')";
661
-	    }
661
+		}
662 662
 	}
663 663
 	
664 664
 	if ($departure_airport_route != "")
665 665
 	{
666
-	    $departure_airport_route = filter_var($departure_airport_route,FILTER_SANITIZE_STRING);
667
-	    if (!is_string($departure_airport_route))
668
-	    {
666
+		$departure_airport_route = filter_var($departure_airport_route,FILTER_SANITIZE_STRING);
667
+		if (!is_string($departure_airport_route))
668
+		{
669 669
 		return false;
670
-	    } else {
670
+		} else {
671 671
 		$additional_query .= " AND (spotter_archive_output.departure_airport_icao = '".$departure_airport_route."')";
672
-	    }
672
+		}
673 673
 	}
674 674
 	
675 675
 	if ($arrival_airport_route != "")
676 676
 	{
677
-	    $arrival_airport_route = filter_var($arrival_airport_route,FILTER_SANITIZE_STRING);
678
-	    if (!is_string($arrival_airport_route))
679
-	    {
677
+		$arrival_airport_route = filter_var($arrival_airport_route,FILTER_SANITIZE_STRING);
678
+		if (!is_string($arrival_airport_route))
679
+		{
680 680
 		return false;
681
-	    } else {
681
+		} else {
682 682
 		$additional_query .= " AND (spotter_archive_output.arrival_airport_icao = '".$arrival_airport_route."')";
683
-	    }
683
+		}
684 684
 	}
685 685
 	
686 686
 	if ($altitude != "")
687 687
 	{
688
-	    $altitude_array = explode(",", $altitude);
688
+		$altitude_array = explode(",", $altitude);
689 689
 	    
690
-	    $altitude_array[0] = filter_var($altitude_array[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
691
-	    $altitude_array[1] = filter_var($altitude_array[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
690
+		$altitude_array[0] = filter_var($altitude_array[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
691
+		$altitude_array[1] = filter_var($altitude_array[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
692 692
 	    
693 693
 
694
-	    if ($altitude_array[1] != "")
695
-	    {                
694
+		if ($altitude_array[1] != "")
695
+		{                
696 696
 		$altitude_array[0] = substr($altitude_array[0], 0, -2);
697 697
 		$altitude_array[1] = substr($altitude_array[1], 0, -2);
698 698
 		$additional_query .= " AND altitude BETWEEN '".$altitude_array[0]."' AND '".$altitude_array[1]."' ";
699
-	    } else {
699
+		} else {
700 700
 		$altitude_array[0] = substr($altitude_array[0], 0, -2);
701 701
 		$additional_query .= " AND altitude <= '".$altitude_array[0]."' ";
702
-	    }
702
+		}
703 703
 	}
704 704
 	
705 705
 	if ($date_posted != "")
706 706
 	{
707
-	    $date_array = explode(",", $date_posted);
707
+		$date_array = explode(",", $date_posted);
708 708
 	    
709
-	    $date_array[0] = filter_var($date_array[0],FILTER_SANITIZE_STRING);
710
-	    $date_array[1] = filter_var($date_array[1],FILTER_SANITIZE_STRING);
709
+		$date_array[0] = filter_var($date_array[0],FILTER_SANITIZE_STRING);
710
+		$date_array[1] = filter_var($date_array[1],FILTER_SANITIZE_STRING);
711 711
 	    
712
-	    if ($globalTimezone != '') {
712
+		if ($globalTimezone != '') {
713 713
 		date_default_timezone_set($globalTimezone);
714 714
 		$datetime = new DateTime();
715 715
 		$offset = $datetime->format('P');
716
-	    } else $offset = '+00:00';
716
+		} else $offset = '+00:00';
717 717
 
718 718
 
719
-	    if ($date_array[1] != "")
720
-	    {                
719
+		if ($date_array[1] != "")
720
+		{                
721 721
 		$date_array[0] = date("Y-m-d H:i:s", strtotime($date_array[0]));
722 722
 		$date_array[1] = date("Y-m-d H:i:s", strtotime($date_array[1]));
723 723
 		if ($globalDBdriver == 'mysql') {
@@ -725,28 +725,28 @@  discard block
 block discarded – undo
725 725
 		} else {
726 726
 			$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) ";
727 727
 		}
728
-	    } else {
728
+		} else {
729 729
 		$date_array[0] = date("Y-m-d H:i:s", strtotime($date_array[0]));
730
-                if ($globalDBdriver == 'mysql') {
730
+				if ($globalDBdriver == 'mysql') {
731 731
 			$additional_query .= " AND TIMESTAMP(CONVERT_TZ(spotter_archive_output.date,'+00:00', '".$offset."')) >= '".$date_array[0]."' ";
732 732
 		} else {
733 733
 			$additional_query .= " AND spotter_archive_output.date::timestamp AT TIME ZONE INTERVAL ".$offset." >= CAST('".$date_array[0]."' AS TIMESTAMP) ";
734 734
 		}
735
-	    }
735
+		}
736 736
 	}
737 737
 	
738 738
 	if ($limit != "")
739 739
 	{
740
-	    $limit_array = explode(",", $limit);
740
+		$limit_array = explode(",", $limit);
741 741
 	    
742
-	    $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
743
-	    $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
742
+		$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
743
+		$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
744 744
 	    
745
-	    if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
746
-	    {
745
+		if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
746
+		{
747 747
 		//$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1];
748 748
 		$limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0];
749
-	    }
749
+		}
750 750
 	}
751 751
 	
752 752
 
@@ -778,33 +778,33 @@  discard block
 block discarded – undo
778 778
 	$spotter_array = $Spotter->getDataFromDB($query, array(),$limit_query);
779 779
 
780 780
 	return $spotter_array;
781
-    }
781
+	}
782 782
 
783
-    public function deleteSpotterArchiveData()
784
-    {
783
+	public function deleteSpotterArchiveData()
784
+	{
785 785
 		global $globalArchiveKeepMonths, $globalDBdriver;
786
-                date_default_timezone_set('UTC');
787
-                if ($globalDBdriver == 'mysql') {
786
+				date_default_timezone_set('UTC');
787
+				if ($globalDBdriver == 'mysql') {
788 788
 			$query = 'DELETE FROM spotter_archive_output WHERE spotter_archive_output.date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL '.$globalArchiveKeepMonths.' MONTH)';
789 789
 		} else {
790 790
 			$query = "DELETE FROM spotter_archive_output WHERE spotter_archive_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalArchiveKeepMonths." MONTH'";
791 791
 		}
792
-                try {
793
-                        $sth = $this->db->prepare($query);
794
-                        $sth->execute();
795
-                } catch(PDOException $e) {
796
-                        return "error";
797
-                }
792
+				try {
793
+						$sth = $this->db->prepare($query);
794
+						$sth->execute();
795
+				} catch(PDOException $e) {
796
+						return "error";
797
+				}
798 798
 	}
799 799
 
800
-    /**
801
-    * Gets all the spotter information based on the callsign
802
-    *
803
-    * @return Array the spotter information
804
-    *
805
-    */
806
-    public function getSpotterDataByIdent($ident = '', $limit = '', $sort = '')
807
-    {
800
+	/**
801
+	 * Gets all the spotter information based on the callsign
802
+	 *
803
+	 * @return Array the spotter information
804
+	 *
805
+	 */
806
+	public function getSpotterDataByIdent($ident = '', $limit = '', $sort = '')
807
+	{
808 808
 	$global_query = "SELECT spotter_archive_output.* FROM spotter_archive_output";
809 809
 	
810 810
 	date_default_timezone_set('UTC');
@@ -813,35 +813,35 @@  discard block
 block discarded – undo
813 813
 	
814 814
 	if ($ident != "")
815 815
 	{
816
-	    if (!is_string($ident))
817
-	    {
816
+		if (!is_string($ident))
817
+		{
818 818
 		return false;
819
-	    } else {
819
+		} else {
820 820
 		$additional_query = " AND (spotter_archive_output.ident = :ident)";
821 821
 		$query_values = array(':ident' => $ident);
822
-	    }
822
+		}
823 823
 	}
824 824
 	
825 825
 	if ($limit != "")
826 826
 	{
827
-	    $limit_array = explode(",", $limit);
827
+		$limit_array = explode(",", $limit);
828 828
 	    
829
-	    $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
830
-	    $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
829
+		$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
830
+		$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
831 831
 	    
832
-	    if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
833
-	    {
832
+		if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
833
+		{
834 834
 		//$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1];
835 835
 		$limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0];
836
-	    }
836
+		}
837 837
 	}
838 838
 
839 839
 	if ($sort != "")
840 840
 	{
841
-	    $search_orderby_array = $this->getOrderBy();
842
-	    $orderby_query = $search_orderby_array[$sort]['sql'];
841
+		$search_orderby_array = $this->getOrderBy();
842
+		$orderby_query = $search_orderby_array[$sort]['sql'];
843 843
 	} else {
844
-	    $orderby_query = " ORDER BY spotter_archive_output.date DESC";
844
+		$orderby_query = " ORDER BY spotter_archive_output.date DESC";
845 845
 	}
846 846
 
847 847
 	$query = $global_query." WHERE spotter_archive_output.ident <> '' ".$additional_query." ".$orderby_query;
@@ -850,16 +850,16 @@  discard block
 block discarded – undo
850 850
 	$spotter_array = $Spotter->getDataFromDB($query, $query_values, $limit_query);
851 851
 
852 852
 	return $spotter_array;
853
-    }
854
-
855
-    /**
856
-    * Gets all number of flight over countries
857
-    *
858
-    * @return Array the airline country list
859
-    *
860
-    */
861
-    public function countAllFlightOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '')
862
-    {
853
+	}
854
+
855
+	/**
856
+	 * Gets all number of flight over countries
857
+	 *
858
+	 * @return Array the airline country list
859
+	 *
860
+	 */
861
+	public function countAllFlightOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '')
862
+	{
863 863
 	global $globalDBdriver;
864 864
 	/*
865 865
 	$query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb 
@@ -869,14 +869,14 @@  discard block
 block discarded – undo
869 869
 	$query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb
870 870
 		    FROM countries c, spotter_archive s
871 871
 		    WHERE c.iso2 = s.over_country ";
872
-                if ($olderthanmonths > 0) {
873
-            		if ($globalDBdriver == 'mysql') {
872
+				if ($olderthanmonths > 0) {
873
+					if ($globalDBdriver == 'mysql') {
874 874
 				$query .= 'AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) ';
875 875
 			} else {
876 876
 				$query .= "AND date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'";
877 877
 			}
878 878
 		}
879
-                if ($sincedate != '') $query .= "AND date > '".$sincedate."' ";
879
+				if ($sincedate != '') $query .= "AND date > '".$sincedate."' ";
880 880
 	$query .= "GROUP BY c.name, c.iso3, c.iso2 ORDER BY nb DESC";
881 881
 	if ($limit) $query .= " LIMIT 0,10";
882 882
       
@@ -889,14 +889,14 @@  discard block
 block discarded – undo
889 889
         
890 890
 	while($row = $sth->fetch(PDO::FETCH_ASSOC))
891 891
 	{
892
-	    $temp_array['flight_count'] = $row['nb'];
893
-	    $temp_array['flight_country'] = $row['name'];
894
-	    $temp_array['flight_country_iso3'] = $row['iso3'];
895
-	    $temp_array['flight_country_iso2'] = $row['iso2'];
896
-	    $flight_array[] = $temp_array;
892
+		$temp_array['flight_count'] = $row['nb'];
893
+		$temp_array['flight_country'] = $row['name'];
894
+		$temp_array['flight_country_iso3'] = $row['iso3'];
895
+		$temp_array['flight_country_iso2'] = $row['iso2'];
896
+		$flight_array[] = $temp_array;
897 897
 	}
898 898
 	return $flight_array;
899
-    }
899
+	}
900 900
 
901 901
 }
902 902
 ?>
903 903
\ No newline at end of file
Please login to merge, or discard this patch.
install/libs/simple_html_dom.php 4 patches
Indentation   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -824,11 +824,11 @@
 block discarded – undo
824 824
 	}
825 825
 
826 826
 	/**
827
-	* Returns true if $string is valid UTF-8 and false otherwise.
828
-	*
829
-	* @param mixed $str String to be tested
830
-	* @return boolean
831
-	*/
827
+	 * Returns true if $string is valid UTF-8 and false otherwise.
828
+	 *
829
+	 * @param mixed $str String to be tested
830
+	 * @return boolean
831
+	 */
832 832
 	static function is_utf8($str)
833 833
 	{
834 834
 		$c=0; $b=0;
Please login to merge, or discard this patch.
Spacing   +238 added lines, -238 removed lines patch added patch discarded remove patch
@@ -45,21 +45,21 @@  discard block
 block discarded – undo
45 45
  */
46 46
 define('HDOM_TYPE_ELEMENT', 1);
47 47
 define('HDOM_TYPE_COMMENT', 2);
48
-define('HDOM_TYPE_TEXT',	3);
49
-define('HDOM_TYPE_ENDTAG',  4);
50
-define('HDOM_TYPE_ROOT',	5);
48
+define('HDOM_TYPE_TEXT', 3);
49
+define('HDOM_TYPE_ENDTAG', 4);
50
+define('HDOM_TYPE_ROOT', 5);
51 51
 define('HDOM_TYPE_UNKNOWN', 6);
52 52
 define('HDOM_QUOTE_DOUBLE', 0);
53 53
 define('HDOM_QUOTE_SINGLE', 1);
54
-define('HDOM_QUOTE_NO',	 3);
55
-define('HDOM_INFO_BEGIN',   0);
56
-define('HDOM_INFO_END',	 1);
57
-define('HDOM_INFO_QUOTE',   2);
58
-define('HDOM_INFO_SPACE',   3);
59
-define('HDOM_INFO_TEXT',	4);
60
-define('HDOM_INFO_INNER',   5);
61
-define('HDOM_INFO_OUTER',   6);
62
-define('HDOM_INFO_ENDSPACE',7);
54
+define('HDOM_QUOTE_NO', 3);
55
+define('HDOM_INFO_BEGIN', 0);
56
+define('HDOM_INFO_END', 1);
57
+define('HDOM_INFO_QUOTE', 2);
58
+define('HDOM_INFO_SPACE', 3);
59
+define('HDOM_INFO_TEXT', 4);
60
+define('HDOM_INFO_INNER', 5);
61
+define('HDOM_INFO_OUTER', 6);
62
+define('HDOM_INFO_ENDSPACE', 7);
63 63
 define('DEFAULT_TARGET_CHARSET', 'UTF-8');
64 64
 define('DEFAULT_BR_TEXT', "\r\n");
65 65
 define('DEFAULT_SPAN_TEXT', " ");
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
 // -----------------------------------------------------------------------------
69 69
 // get html dom from file
70 70
 // $maxlen is defined in the code as PHP_STREAM_COPY_ALL which is defined as -1.
71
-function file_get_html($url, $use_include_path = false, $context=null, $offset = -1, $maxLen=-1, $lowercase = true, $forceTagsClosed=true, $target_charset = DEFAULT_TARGET_CHARSET, $stripRN=true, $defaultBRText=DEFAULT_BR_TEXT, $defaultSpanText=DEFAULT_SPAN_TEXT)
71
+function file_get_html($url, $use_include_path = false, $context = null, $offset = -1, $maxLen = -1, $lowercase = true, $forceTagsClosed = true, $target_charset = DEFAULT_TARGET_CHARSET, $stripRN = true, $defaultBRText = DEFAULT_BR_TEXT, $defaultSpanText = DEFAULT_SPAN_TEXT)
72 72
 {
73 73
 	// We DO force the tags to be terminated.
74 74
 	$dom = new simple_html_dom(null, $lowercase, $forceTagsClosed, $target_charset, $stripRN, $defaultBRText, $defaultSpanText);
@@ -86,7 +86,7 @@  discard block
 block discarded – undo
86 86
 }
87 87
 
88 88
 // get html dom from string
89
-function str_get_html($str, $lowercase=true, $forceTagsClosed=true, $target_charset = DEFAULT_TARGET_CHARSET, $stripRN=true, $defaultBRText=DEFAULT_BR_TEXT, $defaultSpanText=DEFAULT_SPAN_TEXT)
89
+function str_get_html($str, $lowercase = true, $forceTagsClosed = true, $target_charset = DEFAULT_TARGET_CHARSET, $stripRN = true, $defaultBRText = DEFAULT_BR_TEXT, $defaultSpanText = DEFAULT_SPAN_TEXT)
90 90
 {
91 91
 	$dom = new simple_html_dom(null, $lowercase, $forceTagsClosed, $target_charset, $stripRN, $defaultBRText, $defaultSpanText);
92 92
 	if (empty($str) || strlen($str) > MAX_FILE_SIZE)
@@ -99,7 +99,7 @@  discard block
 block discarded – undo
99 99
 }
100 100
 
101 101
 // dump html dom tree
102
-function dump_html_tree($node, $show_attr=true, $deep=0)
102
+function dump_html_tree($node, $show_attr = true, $deep = 0)
103 103
 {
104 104
 	$node->dump($node);
105 105
 }
@@ -151,12 +151,12 @@  discard block
 block discarded – undo
151 151
 	}
152 152
 
153 153
 	// dump node's tree
154
-	function dump($show_attr=true, $deep=0)
154
+	function dump($show_attr = true, $deep = 0)
155 155
 	{
156 156
 		$lead = str_repeat('	', $deep);
157 157
 
158 158
 		echo $lead.$this->tag;
159
-		if ($show_attr && count($this->attr)>0)
159
+		if ($show_attr && count($this->attr) > 0)
160 160
 		{
161 161
 			echo '(';
162 162
 			foreach ($this->attr as $k=>$v)
@@ -169,18 +169,18 @@  discard block
 block discarded – undo
169 169
 		{
170 170
 			foreach ($this->nodes as $c)
171 171
 			{
172
-				$c->dump($show_attr, $deep+1);
172
+				$c->dump($show_attr, $deep + 1);
173 173
 			}
174 174
 		}
175 175
 	}
176 176
 
177 177
 
178 178
 	// Debugging function to dump a single dom node with a bunch of information about it.
179
-	function dump_node($echo=true)
179
+	function dump_node($echo = true)
180 180
 	{
181 181
 
182 182
 		$string = $this->tag;
183
-		if (count($this->attr)>0)
183
+		if (count($this->attr) > 0)
184 184
 		{
185 185
 			$string .= '(';
186 186
 			foreach ($this->attr as $k=>$v)
@@ -189,7 +189,7 @@  discard block
 block discarded – undo
189 189
 			}
190 190
 			$string .= ')';
191 191
 		}
192
-		if (count($this->_)>0)
192
+		if (count($this->_) > 0)
193 193
 		{
194 194
 			$string .= ' $_ (';
195 195
 			foreach ($this->_ as $k=>$v)
@@ -211,22 +211,22 @@  discard block
 block discarded – undo
211 211
 
212 212
 		if (isset($this->text))
213 213
 		{
214
-			$string .= " text: (" . $this->text . ")";
214
+			$string .= " text: (".$this->text.")";
215 215
 		}
216 216
 
217 217
 		$string .= " HDOM_INNER_INFO: '";
218 218
 		if (isset($node->_[HDOM_INFO_INNER]))
219 219
 		{
220
-			$string .= $node->_[HDOM_INFO_INNER] . "'";
220
+			$string .= $node->_[HDOM_INFO_INNER]."'";
221 221
 		}
222 222
 		else
223 223
 		{
224 224
 			$string .= ' NULL ';
225 225
 		}
226 226
 
227
-		$string .= " children: " . count($this->children);
228
-		$string .= " nodes: " . count($this->nodes);
229
-		$string .= " tag_start: " . $this->tag_start;
227
+		$string .= " children: ".count($this->children);
228
+		$string .= " nodes: ".count($this->nodes);
229
+		$string .= " tag_start: ".$this->tag_start;
230 230
 		$string .= "\n";
231 231
 
232 232
 		if ($echo)
@@ -242,7 +242,7 @@  discard block
 block discarded – undo
242 242
 
243 243
 	// returns the parent of node
244 244
 	// If a node is passed in, it will reset the parent of the current node to that one.
245
-	function parent($parent=null)
245
+	function parent($parent = null)
246 246
 	{
247 247
 		// I am SURE that this doesn't work properly.
248 248
 		// It fails to unset the current node from it's current parents nodes or children list first.
@@ -263,9 +263,9 @@  discard block
 block discarded – undo
263 263
 	}
264 264
 
265 265
 	// returns children of node
266
-	function children($idx=-1)
266
+	function children($idx = -1)
267 267
 	{
268
-		if ($idx===-1)
268
+		if ($idx === -1)
269 269
 		{
270 270
 			return $this->children;
271 271
 		}
@@ -279,7 +279,7 @@  discard block
 block discarded – undo
279 279
 	// returns the first child of node
280 280
 	function first_child()
281 281
 	{
282
-		if (count($this->children)>0)
282
+		if (count($this->children) > 0)
283 283
 		{
284 284
 			return $this->children[0];
285 285
 		}
@@ -289,9 +289,9 @@  discard block
 block discarded – undo
289 289
 	// returns the last child of node
290 290
 	function last_child()
291 291
 	{
292
-		if (($count=count($this->children))>0)
292
+		if (($count = count($this->children)) > 0)
293 293
 		{
294
-			return $this->children[$count-1];
294
+			return $this->children[$count - 1];
295 295
 		}
296 296
 		return null;
297 297
 	}
@@ -299,18 +299,18 @@  discard block
 block discarded – undo
299 299
 	// returns the next sibling of node
300 300
 	function next_sibling()
301 301
 	{
302
-		if ($this->parent===null)
302
+		if ($this->parent === null)
303 303
 		{
304 304
 			return null;
305 305
 		}
306 306
 
307 307
 		$idx = 0;
308 308
 		$count = count($this->parent->children);
309
-		while ($idx<$count && $this!==$this->parent->children[$idx])
309
+		while ($idx < $count && $this !== $this->parent->children[$idx])
310 310
 		{
311 311
 			++$idx;
312 312
 		}
313
-		if (++$idx>=$count)
313
+		if (++$idx >= $count)
314 314
 		{
315 315
 			return null;
316 316
 		}
@@ -320,12 +320,12 @@  discard block
 block discarded – undo
320 320
 	// returns the previous sibling of node
321 321
 	function prev_sibling()
322 322
 	{
323
-		if ($this->parent===null) return null;
323
+		if ($this->parent === null) return null;
324 324
 		$idx = 0;
325 325
 		$count = count($this->parent->children);
326
-		while ($idx<$count && $this!==$this->parent->children[$idx])
326
+		while ($idx < $count && $this !== $this->parent->children[$idx])
327 327
 			++$idx;
328
-		if (--$idx<0) return null;
328
+		if (--$idx < 0) return null;
329 329
 		return $this->parent->children[$idx];
330 330
 	}
331 331
 
@@ -340,7 +340,7 @@  discard block
 block discarded – undo
340 340
 
341 341
 		while (!is_null($returnDom))
342 342
 		{
343
-			if (is_object($debug_object)) { $debug_object->debug_log(2, "Current tag is: " . $returnDom->tag); }
343
+			if (is_object($debug_object)) { $debug_object->debug_log(2, "Current tag is: ".$returnDom->tag); }
344 344
 
345 345
 			if ($returnDom->tag == $tag)
346 346
 			{
@@ -374,16 +374,16 @@  discard block
 block discarded – undo
374 374
 			{
375 375
 				if (!empty($this->text))
376 376
 				{
377
-					$text = " with text: " . $this->text;
377
+					$text = " with text: ".$this->text;
378 378
 				}
379 379
 			}
380
-			$debug_object->debug_log(1, 'Innertext of tag: ' . $this->tag . $text);
380
+			$debug_object->debug_log(1, 'Innertext of tag: '.$this->tag.$text);
381 381
 		}
382 382
 
383
-		if ($this->tag==='root') return $this->innertext();
383
+		if ($this->tag === 'root') return $this->innertext();
384 384
 
385 385
 		// trigger callback
386
-		if ($this->dom && $this->dom->callback!==null)
386
+		if ($this->dom && $this->dom->callback !== null)
387 387
 		{
388 388
 			call_user_func_array($this->dom->callback, array($this));
389 389
 		}
@@ -418,7 +418,7 @@  discard block
 block discarded – undo
418 418
 		}
419 419
 
420 420
 		// render end tag
421
-		if (isset($this->_[HDOM_INFO_END]) && $this->_[HDOM_INFO_END]!=0)
421
+		if (isset($this->_[HDOM_INFO_END]) && $this->_[HDOM_INFO_END] != 0)
422 422
 			$ret .= '</'.$this->tag.'>';
423 423
 		return $ret;
424 424
 	}
@@ -433,8 +433,8 @@  discard block
 block discarded – undo
433 433
 			case HDOM_TYPE_COMMENT: return '';
434 434
 			case HDOM_TYPE_UNKNOWN: return '';
435 435
 		}
436
-		if (strcasecmp($this->tag, 'script')===0) return '';
437
-		if (strcasecmp($this->tag, 'style')===0) return '';
436
+		if (strcasecmp($this->tag, 'script') === 0) return '';
437
+		if (strcasecmp($this->tag, 'style') === 0) return '';
438 438
 
439 439
 		$ret = '';
440 440
 		// In rare cases, (always node type 1 or HDOM_TYPE_ELEMENT - observed for some span tags, and some p tags) $this->nodes is set to NULL.
@@ -480,12 +480,12 @@  discard block
 block discarded – undo
480 480
 			++$i;
481 481
 
482 482
 			// skip removed attribute
483
-			if ($val===null || $val===false)
483
+			if ($val === null || $val === false)
484 484
 				continue;
485 485
 
486 486
 			$ret .= $this->_[HDOM_INFO_SPACE][$i][0];
487 487
 			//no value attr: nowrap, checked selected...
488
-			if ($val===true)
488
+			if ($val === true)
489 489
 				$ret .= $key;
490 490
 			else {
491 491
 				switch ($this->_[HDOM_INFO_QUOTE][$i])
@@ -498,34 +498,34 @@  discard block
 block discarded – undo
498 498
 			}
499 499
 		}
500 500
 		$ret = $this->dom->restore_noise($ret);
501
-		return $ret . $this->_[HDOM_INFO_ENDSPACE] . '>';
501
+		return $ret.$this->_[HDOM_INFO_ENDSPACE].'>';
502 502
 	}
503 503
 
504 504
 	// find elements by css selector
505 505
 	//PaperG - added ability for find to lowercase the value of the selector.
506
-	function find($selector, $idx=null, $lowercase=false)
506
+	function find($selector, $idx = null, $lowercase = false)
507 507
 	{
508 508
 		$selectors = $this->parse_selector($selector);
509
-		if (($count=count($selectors))===0) return array();
509
+		if (($count = count($selectors)) === 0) return array();
510 510
 		$found_keys = array();
511 511
 
512 512
 		// find each selector
513
-		for ($c=0; $c<$count; ++$c)
513
+		for ($c = 0; $c < $count; ++$c)
514 514
 		{
515 515
 			// The change on the below line was documented on the sourceforge code tracker id 2788009
516 516
 			// used to be: if (($levle=count($selectors[0]))===0) return array();
517
-			if (($levle=count($selectors[$c]))===0) return array();
517
+			if (($levle = count($selectors[$c])) === 0) return array();
518 518
 			if (!isset($this->_[HDOM_INFO_BEGIN])) return array();
519 519
 
520 520
 			$head = array($this->_[HDOM_INFO_BEGIN]=>1);
521 521
 
522 522
 			// handle descendant selectors, no recursive!
523
-			for ($l=0; $l<$levle; ++$l)
523
+			for ($l = 0; $l < $levle; ++$l)
524 524
 			{
525 525
 				$ret = array();
526 526
 				foreach ($head as $k=>$v)
527 527
 				{
528
-					$n = ($k===-1) ? $this->dom->root : $this->dom->nodes[$k];
528
+					$n = ($k === -1) ? $this->dom->root : $this->dom->nodes[$k];
529 529
 					//PaperG - Pass this optional parameter on to the seek function.
530 530
 					$n->seek($selectors[$c][$l], $ret, $lowercase);
531 531
 				}
@@ -550,13 +550,13 @@  discard block
 block discarded – undo
550 550
 
551 551
 		// return nth-element or array
552 552
 		if (is_null($idx)) return $found;
553
-		else if ($idx<0) $idx = count($found) + $idx;
553
+		else if ($idx < 0) $idx = count($found) + $idx;
554 554
 		return (isset($found[$idx])) ? $found[$idx] : null;
555 555
 	}
556 556
 
557 557
 	// seek for given conditions
558 558
 	// PaperG - added parameter to allow for case insensitive testing of the value of a selector.
559
-	protected function seek($selector, &$ret, $lowercase=false)
559
+	protected function seek($selector, &$ret, $lowercase = false)
560 560
 	{
561 561
 		global $debug_object;
562 562
 		if (is_object($debug_object)) { $debug_object->debug_log_entry(1); }
@@ -569,8 +569,8 @@  discard block
 block discarded – undo
569 569
 			$count = 0;
570 570
 			foreach ($this->children as $c)
571 571
 			{
572
-				if ($tag==='*' || $tag===$c->tag) {
573
-					if (++$count==$key) {
572
+				if ($tag === '*' || $tag === $c->tag) {
573
+					if (++$count == $key) {
574 574
 						$ret[$c->_[HDOM_INFO_BEGIN]] = 1;
575 575
 						return;
576 576
 					}
@@ -580,38 +580,38 @@  discard block
 block discarded – undo
580 580
 		}
581 581
 
582 582
 		$end = (!empty($this->_[HDOM_INFO_END])) ? $this->_[HDOM_INFO_END] : 0;
583
-		if ($end==0) {
583
+		if ($end == 0) {
584 584
 			$parent = $this->parent;
585
-			while (!isset($parent->_[HDOM_INFO_END]) && $parent!==null) {
585
+			while (!isset($parent->_[HDOM_INFO_END]) && $parent !== null) {
586 586
 				$end -= 1;
587 587
 				$parent = $parent->parent;
588 588
 			}
589 589
 			$end += $parent->_[HDOM_INFO_END];
590 590
 		}
591 591
 
592
-		for ($i=$this->_[HDOM_INFO_BEGIN]+1; $i<$end; ++$i) {
592
+		for ($i = $this->_[HDOM_INFO_BEGIN] + 1; $i < $end; ++$i) {
593 593
 			$node = $this->dom->nodes[$i];
594 594
 
595 595
 			$pass = true;
596 596
 
597
-			if ($tag==='*' && !$key) {
597
+			if ($tag === '*' && !$key) {
598 598
 				if (in_array($node, $this->children, true))
599 599
 					$ret[$i] = 1;
600 600
 				continue;
601 601
 			}
602 602
 
603 603
 			// compare tag
604
-			if ($tag && $tag!=$node->tag && $tag!=='*') {$pass=false;}
604
+			if ($tag && $tag != $node->tag && $tag !== '*') {$pass = false; }
605 605
 			// compare key
606 606
 			if ($pass && $key) {
607 607
 				if ($no_key) {
608
-					if (isset($node->attr[$key])) $pass=false;
608
+					if (isset($node->attr[$key])) $pass = false;
609 609
 				} else {
610
-					if (($key != "plaintext") && !isset($node->attr[$key])) $pass=false;
610
+					if (($key != "plaintext") && !isset($node->attr[$key])) $pass = false;
611 611
 				}
612 612
 			}
613 613
 			// compare value
614
-			if ($pass && $key && $val  && $val!=='*') {
614
+			if ($pass && $key && $val && $val !== '*') {
615 615
 				// If they have told us that this is a "plaintext" search then we want the plaintext of the node - right?
616 616
 				if ($key == "plaintext") {
617 617
 					// $node->plaintext actually returns $node->text();
@@ -620,7 +620,7 @@  discard block
 block discarded – undo
620 620
 					// this is a normal search, we want the value of that attribute of the tag.
621 621
 					$nodeKeyValue = $node->attr[$key];
622 622
 				}
623
-				if (is_object($debug_object)) {$debug_object->debug_log(2, "testing node: " . $node->tag . " for attribute: " . $key . $exp . $val . " where nodes value is: " . $nodeKeyValue);}
623
+				if (is_object($debug_object)) {$debug_object->debug_log(2, "testing node: ".$node->tag." for attribute: ".$key.$exp.$val." where nodes value is: ".$nodeKeyValue); }
624 624
 
625 625
 				//PaperG - If lowercase is set, do a case insensitive test of the value of the selector.
626 626
 				if ($lowercase) {
@@ -628,11 +628,11 @@  discard block
 block discarded – undo
628 628
 				} else {
629 629
 					$check = $this->match($exp, $val, $nodeKeyValue);
630 630
 				}
631
-				if (is_object($debug_object)) {$debug_object->debug_log(2, "after match: " . ($check ? "true" : "false"));}
631
+				if (is_object($debug_object)) {$debug_object->debug_log(2, "after match: ".($check ? "true" : "false")); }
632 632
 
633 633
 				// handle multiple class
634
-				if (!$check && strcasecmp($key, 'class')===0) {
635
-					foreach (explode(' ',$node->attr[$key]) as $k) {
634
+				if (!$check && strcasecmp($key, 'class') === 0) {
635
+					foreach (explode(' ', $node->attr[$key]) as $k) {
636 636
 						// Without this, there were cases where leading, trailing, or double spaces lead to our comparing blanks - bad form.
637 637
 						if (!empty($k)) {
638 638
 							if ($lowercase) {
@@ -650,24 +650,24 @@  discard block
 block discarded – undo
650 650
 			unset($node);
651 651
 		}
652 652
 		// It's passed by reference so this is actually what this function returns.
653
-		if (is_object($debug_object)) {$debug_object->debug_log(1, "EXIT - ret: ", $ret);}
653
+		if (is_object($debug_object)) {$debug_object->debug_log(1, "EXIT - ret: ", $ret); }
654 654
 	}
655 655
 
656 656
 	protected function match($exp, $pattern, $value) {
657 657
 		global $debug_object;
658
-		if (is_object($debug_object)) {$debug_object->debug_log_entry(1);}
658
+		if (is_object($debug_object)) {$debug_object->debug_log_entry(1); }
659 659
 
660 660
 		switch ($exp) {
661 661
 			case '=':
662
-				return ($value===$pattern);
662
+				return ($value === $pattern);
663 663
 			case '!=':
664
-				return ($value!==$pattern);
664
+				return ($value !== $pattern);
665 665
 			case '^=':
666
-				return preg_match("/^".preg_quote($pattern,'/')."/", $value);
666
+				return preg_match("/^".preg_quote($pattern, '/')."/", $value);
667 667
 			case '$=':
668
-				return preg_match("/".preg_quote($pattern,'/')."$/", $value);
668
+				return preg_match("/".preg_quote($pattern, '/')."$/", $value);
669 669
 			case '*=':
670
-				if ($pattern[0]=='/') {
670
+				if ($pattern[0] == '/') {
671 671
 					return preg_match($pattern, $value);
672 672
 				}
673 673
 				return preg_match("/".$pattern."/i", $value);
@@ -677,7 +677,7 @@  discard block
 block discarded – undo
677 677
 
678 678
 	protected function parse_selector($selector_string) {
679 679
 		global $debug_object;
680
-		if (is_object($debug_object)) {$debug_object->debug_log_entry(1);}
680
+		if (is_object($debug_object)) {$debug_object->debug_log_entry(1); }
681 681
 
682 682
 		// pattern of CSS selectors, modified from mootools
683 683
 		// Paperg: Add the colon to the attrbute, so that it properly finds <tag attr:ibute="something" > like google does.
@@ -688,7 +688,7 @@  discard block
 block discarded – undo
688 688
 //		$pattern = "/([\w-:\*]*)(?:\#([\w-]+)|\.([\w-]+))?(?:\[@?(!?[\w-]+)(?:([!*^$]?=)[\"']?(.*?)[\"']?)?\])?([\/, ]+)/is";
689 689
 		$pattern = "/([\w-:\*]*)(?:\#([\w-]+)|\.([\w-]+))?(?:\[@?(!?[\w-:]+)(?:([!*^$]?=)[\"']?(.*?)[\"']?)?\])?([\/, ]+)/is";
690 690
 		preg_match_all($pattern, trim($selector_string).' ', $matches, PREG_SET_ORDER);
691
-		if (is_object($debug_object)) {$debug_object->debug_log(2, "Matches Array: ", $matches);}
691
+		if (is_object($debug_object)) {$debug_object->debug_log(2, "Matches Array: ", $matches); }
692 692
 
693 693
 		$selectors = array();
694 694
 		$result = array();
@@ -696,29 +696,29 @@  discard block
 block discarded – undo
696 696
 
697 697
 		foreach ($matches as $m) {
698 698
 			$m[0] = trim($m[0]);
699
-			if ($m[0]==='' || $m[0]==='/' || $m[0]==='//') continue;
699
+			if ($m[0] === '' || $m[0] === '/' || $m[0] === '//') continue;
700 700
 			// for browser generated xpath
701
-			if ($m[1]==='tbody') continue;
701
+			if ($m[1] === 'tbody') continue;
702 702
 
703 703
 			list($tag, $key, $val, $exp, $no_key) = array($m[1], null, null, '=', false);
704
-			if (!empty($m[2])) {$key='id'; $val=$m[2];}
705
-			if (!empty($m[3])) {$key='class'; $val=$m[3];}
706
-			if (!empty($m[4])) {$key=$m[4];}
707
-			if (!empty($m[5])) {$exp=$m[5];}
708
-			if (!empty($m[6])) {$val=$m[6];}
704
+			if (!empty($m[2])) {$key = 'id'; $val = $m[2]; }
705
+			if (!empty($m[3])) {$key = 'class'; $val = $m[3]; }
706
+			if (!empty($m[4])) {$key = $m[4]; }
707
+			if (!empty($m[5])) {$exp = $m[5]; }
708
+			if (!empty($m[6])) {$val = $m[6]; }
709 709
 
710 710
 			// convert to lowercase
711
-			if ($this->dom->lowercase) {$tag=strtolower($tag); $key=strtolower($key);}
711
+			if ($this->dom->lowercase) {$tag = strtolower($tag); $key = strtolower($key); }
712 712
 			//elements that do NOT have the specified attribute
713
-			if (isset($key[0]) && $key[0]==='!') {$key=substr($key, 1); $no_key=true;}
713
+			if (isset($key[0]) && $key[0] === '!') {$key = substr($key, 1); $no_key = true; }
714 714
 
715 715
 			$result[] = array($tag, $key, $val, $exp, $no_key);
716
-			if (trim($m[7])===',') {
716
+			if (trim($m[7]) === ',') {
717 717
 				$selectors[] = $result;
718 718
 				$result = array();
719 719
 			}
720 720
 		}
721
-		if (count($result)>0)
721
+		if (count($result) > 0)
722 722
 			$selectors[] = $result;
723 723
 		return $selectors;
724 724
 	}
@@ -742,7 +742,7 @@  discard block
 block discarded – undo
742 742
 	function __set($name, $value)
743 743
 	{
744 744
 		global $debug_object;
745
-		if (is_object($debug_object)) {$debug_object->debug_log_entry(1);}
745
+		if (is_object($debug_object)) {$debug_object->debug_log_entry(1); }
746 746
 
747 747
 		switch ($name)
748 748
 		{
@@ -780,7 +780,7 @@  discard block
 block discarded – undo
780 780
 	function convert_text($text)
781 781
 	{
782 782
 		global $debug_object;
783
-		if (is_object($debug_object)) {$debug_object->debug_log_entry(1);}
783
+		if (is_object($debug_object)) {$debug_object->debug_log_entry(1); }
784 784
 
785 785
 		$converted_text = $text;
786 786
 
@@ -792,7 +792,7 @@  discard block
 block discarded – undo
792 792
 			$sourceCharset = strtoupper($this->dom->_charset);
793 793
 			$targetCharset = strtoupper($this->dom->_target_charset);
794 794
 		}
795
-		if (is_object($debug_object)) {$debug_object->debug_log(3, "source charset: " . $sourceCharset . " target charaset: " . $targetCharset);}
795
+		if (is_object($debug_object)) {$debug_object->debug_log(3, "source charset: ".$sourceCharset." target charaset: ".$targetCharset); }
796 796
 
797 797
 		if (!empty($sourceCharset) && !empty($targetCharset) && (strcasecmp($sourceCharset, $targetCharset) != 0))
798 798
 		{
@@ -831,27 +831,27 @@  discard block
 block discarded – undo
831 831
 	*/
832 832
 	static function is_utf8($str)
833 833
 	{
834
-		$c=0; $b=0;
835
-		$bits=0;
836
-		$len=strlen($str);
837
-		for($i=0; $i<$len; $i++)
834
+		$c = 0; $b = 0;
835
+		$bits = 0;
836
+		$len = strlen($str);
837
+		for ($i = 0; $i < $len; $i++)
838 838
 		{
839
-			$c=ord($str[$i]);
840
-			if($c > 128)
839
+			$c = ord($str[$i]);
840
+			if ($c > 128)
841 841
 			{
842
-				if(($c >= 254)) return false;
843
-				elseif($c >= 252) $bits=6;
844
-				elseif($c >= 248) $bits=5;
845
-				elseif($c >= 240) $bits=4;
846
-				elseif($c >= 224) $bits=3;
847
-				elseif($c >= 192) $bits=2;
842
+				if (($c >= 254)) return false;
843
+				elseif ($c >= 252) $bits = 6;
844
+				elseif ($c >= 248) $bits = 5;
845
+				elseif ($c >= 240) $bits = 4;
846
+				elseif ($c >= 224) $bits = 3;
847
+				elseif ($c >= 192) $bits = 2;
848 848
 				else return false;
849
-				if(($i+$bits) > $len) return false;
850
-				while($bits > 1)
849
+				if (($i + $bits) > $len) return false;
850
+				while ($bits > 1)
851 851
 				{
852 852
 					$i++;
853
-					$b=ord($str[$i]);
854
-					if($b < 128 || $b > 191) return false;
853
+					$b = ord($str[$i]);
854
+					if ($b < 128 || $b > 191) return false;
855 855
 					$bits--;
856 856
 				}
857 857
 			}
@@ -955,24 +955,24 @@  discard block
 block discarded – undo
955 955
 	}
956 956
 
957 957
 	// camel naming conventions
958
-	function getAllAttributes() {return $this->attr;}
959
-	function getAttribute($name) {return $this->__get($name);}
960
-	function setAttribute($name, $value) {$this->__set($name, $value);}
961
-	function hasAttribute($name) {return $this->__isset($name);}
962
-	function removeAttribute($name) {$this->__set($name, null);}
963
-	function getElementById($id) {return $this->find("#$id", 0);}
964
-	function getElementsById($id, $idx=null) {return $this->find("#$id", $idx);}
965
-	function getElementByTagName($name) {return $this->find($name, 0);}
966
-	function getElementsByTagName($name, $idx=null) {return $this->find($name, $idx);}
967
-	function parentNode() {return $this->parent();}
968
-	function childNodes($idx=-1) {return $this->children($idx);}
969
-	function firstChild() {return $this->first_child();}
970
-	function lastChild() {return $this->last_child();}
971
-	function nextSibling() {return $this->next_sibling();}
972
-	function previousSibling() {return $this->prev_sibling();}
973
-	function hasChildNodes() {return $this->has_child();}
974
-	function nodeName() {return $this->tag;}
975
-	function appendChild($node) {$node->parent($this); return $node;}
958
+	function getAllAttributes() {return $this->attr; }
959
+	function getAttribute($name) {return $this->__get($name); }
960
+	function setAttribute($name, $value) {$this->__set($name, $value); }
961
+	function hasAttribute($name) {return $this->__isset($name); }
962
+	function removeAttribute($name) {$this->__set($name, null); }
963
+	function getElementById($id) {return $this->find("#$id", 0); }
964
+	function getElementsById($id, $idx = null) {return $this->find("#$id", $idx); }
965
+	function getElementByTagName($name) {return $this->find($name, 0); }
966
+	function getElementsByTagName($name, $idx = null) {return $this->find($name, $idx); }
967
+	function parentNode() {return $this->parent(); }
968
+	function childNodes($idx = -1) {return $this->children($idx); }
969
+	function firstChild() {return $this->first_child(); }
970
+	function lastChild() {return $this->last_child(); }
971
+	function nextSibling() {return $this->next_sibling(); }
972
+	function previousSibling() {return $this->prev_sibling(); }
973
+	function hasChildNodes() {return $this->has_child(); }
974
+	function nodeName() {return $this->tag; }
975
+	function appendChild($node) {$node->parent($this); return $node; }
976 976
 
977 977
 }
978 978
 
@@ -1028,11 +1028,11 @@  discard block
 block discarded – undo
1028 1028
 		'option'=>array('option'=>1),
1029 1029
 	);
1030 1030
 
1031
-	function __construct($str=null, $lowercase=true, $forceTagsClosed=true, $target_charset=DEFAULT_TARGET_CHARSET, $stripRN=true, $defaultBRText=DEFAULT_BR_TEXT, $defaultSpanText=DEFAULT_SPAN_TEXT)
1031
+	function __construct($str = null, $lowercase = true, $forceTagsClosed = true, $target_charset = DEFAULT_TARGET_CHARSET, $stripRN = true, $defaultBRText = DEFAULT_BR_TEXT, $defaultSpanText = DEFAULT_SPAN_TEXT)
1032 1032
 	{
1033 1033
 		if ($str)
1034 1034
 		{
1035
-			if (preg_match("/^http:\/\//i",$str) || is_file($str))
1035
+			if (preg_match("/^http:\/\//i", $str) || is_file($str))
1036 1036
 			{
1037 1037
 				$this->load_file($str);
1038 1038
 			}
@@ -1043,7 +1043,7 @@  discard block
 block discarded – undo
1043 1043
 		}
1044 1044
 		// Forcing tags to be closed implies that we don't trust the html, but it can lead to parsing errors if we SHOULD trust the html.
1045 1045
 		if (!$forceTagsClosed) {
1046
-			$this->optional_closing_array=array();
1046
+			$this->optional_closing_array = array();
1047 1047
 		}
1048 1048
 		$this->_target_charset = $target_charset;
1049 1049
 	}
@@ -1054,7 +1054,7 @@  discard block
 block discarded – undo
1054 1054
 	}
1055 1055
 
1056 1056
 	// load html from string
1057
-	function load($str, $lowercase=true, $stripRN=true, $defaultBRText=DEFAULT_BR_TEXT, $defaultSpanText=DEFAULT_SPAN_TEXT)
1057
+	function load($str, $lowercase = true, $stripRN = true, $defaultBRText = DEFAULT_BR_TEXT, $defaultSpanText = DEFAULT_SPAN_TEXT)
1058 1058
 	{
1059 1059
 		global $debug_object;
1060 1060
 
@@ -1096,7 +1096,7 @@  discard block
 block discarded – undo
1096 1096
 		$args = func_get_args();
1097 1097
 		$this->load(call_user_func_array('file_get_contents', $args), true);
1098 1098
 		// Throw an error if we can't properly load the dom.
1099
-		if (($error=error_get_last())!==null) {
1099
+		if (($error = error_get_last()) !== null) {
1100 1100
 			$this->clear();
1101 1101
 			return false;
1102 1102
 		}
@@ -1115,16 +1115,16 @@  discard block
 block discarded – undo
1115 1115
 	}
1116 1116
 
1117 1117
 	// save dom as string
1118
-	function save($filepath='')
1118
+	function save($filepath = '')
1119 1119
 	{
1120 1120
 		$ret = $this->root->innertext();
1121
-		if ($filepath!=='') file_put_contents($filepath, $ret, LOCK_EX);
1121
+		if ($filepath !== '') file_put_contents($filepath, $ret, LOCK_EX);
1122 1122
 		return $ret;
1123 1123
 	}
1124 1124
 
1125 1125
 	// find dom node by css selector
1126 1126
 	// Paperg - allow us to specify that we want case insensitive testing of the value of the selector.
1127
-	function find($selector, $idx=null, $lowercase=false)
1127
+	function find($selector, $idx = null, $lowercase = false)
1128 1128
 	{
1129 1129
 		return $this->root->find($selector, $idx, $lowercase);
1130 1130
 	}
@@ -1132,22 +1132,22 @@  discard block
 block discarded – undo
1132 1132
 	// clean up memory due to php5 circular references memory leak...
1133 1133
 	function clear()
1134 1134
 	{
1135
-		foreach ($this->nodes as $n) {$n->clear(); $n = null;}
1135
+		foreach ($this->nodes as $n) {$n->clear(); $n = null; }
1136 1136
 		// This add next line is documented in the sourceforge repository. 2977248 as a fix for ongoing memory leaks that occur even with the use of clear.
1137
-		if (isset($this->children)) foreach ($this->children as $n) {$n->clear(); $n = null;}
1138
-		if (isset($this->parent)) {$this->parent->clear(); unset($this->parent);}
1139
-		if (isset($this->root)) {$this->root->clear(); unset($this->root);}
1137
+		if (isset($this->children)) foreach ($this->children as $n) {$n->clear(); $n = null; }
1138
+		if (isset($this->parent)) {$this->parent->clear(); unset($this->parent); }
1139
+		if (isset($this->root)) {$this->root->clear(); unset($this->root); }
1140 1140
 		unset($this->doc);
1141 1141
 		unset($this->noise);
1142 1142
 	}
1143 1143
 
1144
-	function dump($show_attr=true)
1144
+	function dump($show_attr = true)
1145 1145
 	{
1146 1146
 		$this->root->dump($show_attr);
1147 1147
 	}
1148 1148
 
1149 1149
 	// prepare HTML data and init everything
1150
-	protected function prepare($str, $lowercase=true, $stripRN=true, $defaultBRText=DEFAULT_BR_TEXT, $defaultSpanText=DEFAULT_SPAN_TEXT)
1150
+	protected function prepare($str, $lowercase = true, $stripRN = true, $defaultBRText = DEFAULT_BR_TEXT, $defaultSpanText = DEFAULT_SPAN_TEXT)
1151 1151
 	{
1152 1152
 		$this->clear();
1153 1153
 
@@ -1178,13 +1178,13 @@  discard block
 block discarded – undo
1178 1178
 		$this->root->_[HDOM_INFO_BEGIN] = -1;
1179 1179
 		$this->root->nodetype = HDOM_TYPE_ROOT;
1180 1180
 		$this->parent = $this->root;
1181
-		if ($this->size>0) $this->char = $this->doc[0];
1181
+		if ($this->size > 0) $this->char = $this->doc[0];
1182 1182
 	}
1183 1183
 
1184 1184
 	// parse html content
1185 1185
 	protected function parse()
1186 1186
 	{
1187
-		if (($s = $this->copy_until_char('<'))==='')
1187
+		if (($s = $this->copy_until_char('<')) === '')
1188 1188
 		{
1189 1189
 			return $this->read_tag();
1190 1190
 		}
@@ -1213,18 +1213,18 @@  discard block
 block discarded – undo
1213 1213
 			if ($success)
1214 1214
 			{
1215 1215
 				$charset = $matches[1];
1216
-				if (is_object($debug_object)) {$debug_object->debug_log(2, 'header content-type found charset of: ' . $charset);}
1216
+				if (is_object($debug_object)) {$debug_object->debug_log(2, 'header content-type found charset of: '.$charset); }
1217 1217
 			}
1218 1218
 
1219 1219
 		}
1220 1220
 
1221 1221
 		if (empty($charset))
1222 1222
 		{
1223
-			$el = $this->root->find('meta[http-equiv=Content-Type]',0, true);
1223
+			$el = $this->root->find('meta[http-equiv=Content-Type]', 0, true);
1224 1224
 			if (!empty($el))
1225 1225
 			{
1226 1226
 				$fullvalue = $el->content;
1227
-				if (is_object($debug_object)) {$debug_object->debug_log(2, 'meta content-type tag found' . $fullvalue);}
1227
+				if (is_object($debug_object)) {$debug_object->debug_log(2, 'meta content-type tag found'.$fullvalue); }
1228 1228
 
1229 1229
 				if (!empty($fullvalue))
1230 1230
 				{
@@ -1236,7 +1236,7 @@  discard block
 block discarded – undo
1236 1236
 					else
1237 1237
 					{
1238 1238
 						// If there is a meta tag, and they don't specify the character set, research says that it's typically ISO-8859-1
1239
-						if (is_object($debug_object)) {$debug_object->debug_log(2, 'meta content-type tag couldn\'t be parsed. using iso-8859 default.');}
1239
+						if (is_object($debug_object)) {$debug_object->debug_log(2, 'meta content-type tag couldn\'t be parsed. using iso-8859 default.'); }
1240 1240
 						$charset = 'ISO-8859-1';
1241 1241
 					}
1242 1242
 				}
@@ -1251,14 +1251,14 @@  discard block
 block discarded – undo
1251 1251
 			if (function_exists('mb_detect_encoding'))
1252 1252
 			{
1253 1253
 				// Have php try to detect the encoding from the text given to us.
1254
-				$charset = mb_detect_encoding($this->root->plaintext . "ascii", $encoding_list = array( "UTF-8", "CP1252" ) );
1255
-				if (is_object($debug_object)) {$debug_object->debug_log(2, 'mb_detect found: ' . $charset);}
1254
+				$charset = mb_detect_encoding($this->root->plaintext."ascii", $encoding_list = array("UTF-8", "CP1252"));
1255
+				if (is_object($debug_object)) {$debug_object->debug_log(2, 'mb_detect found: '.$charset); }
1256 1256
 			}
1257 1257
 
1258 1258
 			// and if this doesn't work...  then we need to just wrongheadedly assume it's UTF-8 so that we can move on - cause this will usually give us most of what we need...
1259 1259
 			if ($charset === false)
1260 1260
 			{
1261
-				if (is_object($debug_object)) {$debug_object->debug_log(2, 'since mb_detect failed - using default of utf-8');}
1261
+				if (is_object($debug_object)) {$debug_object->debug_log(2, 'since mb_detect failed - using default of utf-8'); }
1262 1262
 				$charset = 'UTF-8';
1263 1263
 			}
1264 1264
 		}
@@ -1266,11 +1266,11 @@  discard block
 block discarded – undo
1266 1266
 		// Since CP1252 is a superset, if we get one of it's subsets, we want it instead.
1267 1267
 		if ((strtolower($charset) == strtolower('ISO-8859-1')) || (strtolower($charset) == strtolower('Latin1')) || (strtolower($charset) == strtolower('Latin-1')))
1268 1268
 		{
1269
-			if (is_object($debug_object)) {$debug_object->debug_log(2, 'replacing ' . $charset . ' with CP1252 as its a superset');}
1269
+			if (is_object($debug_object)) {$debug_object->debug_log(2, 'replacing '.$charset.' with CP1252 as its a superset'); }
1270 1270
 			$charset = 'CP1252';
1271 1271
 		}
1272 1272
 
1273
-		if (is_object($debug_object)) {$debug_object->debug_log(1, 'EXIT - ' . $charset);}
1273
+		if (is_object($debug_object)) {$debug_object->debug_log(1, 'EXIT - '.$charset); }
1274 1274
 
1275 1275
 		return $this->_charset = $charset;
1276 1276
 	}
@@ -1278,41 +1278,41 @@  discard block
 block discarded – undo
1278 1278
 	// read tag info
1279 1279
 	protected function read_tag()
1280 1280
 	{
1281
-		if ($this->char!=='<')
1281
+		if ($this->char !== '<')
1282 1282
 		{
1283 1283
 			$this->root->_[HDOM_INFO_END] = $this->cursor;
1284 1284
 			return false;
1285 1285
 		}
1286 1286
 		$begin_tag_pos = $this->pos;
1287
-		$this->char = (++$this->pos<$this->size) ? $this->doc[$this->pos] : null; // next
1287
+		$this->char = (++$this->pos < $this->size) ? $this->doc[$this->pos] : null; // next
1288 1288
 
1289 1289
 		// end tag
1290
-		if ($this->char==='/')
1290
+		if ($this->char === '/')
1291 1291
 		{
1292
-			$this->char = (++$this->pos<$this->size) ? $this->doc[$this->pos] : null; // next
1292
+			$this->char = (++$this->pos < $this->size) ? $this->doc[$this->pos] : null; // next
1293 1293
 			// This represents the change in the simple_html_dom trunk from revision 180 to 181.
1294 1294
 			// $this->skip($this->token_blank_t);
1295 1295
 			$this->skip($this->token_blank);
1296 1296
 			$tag = $this->copy_until_char('>');
1297 1297
 
1298 1298
 			// skip attributes in end tag
1299
-			if (($pos = strpos($tag, ' '))!==false)
1299
+			if (($pos = strpos($tag, ' ')) !== false)
1300 1300
 				$tag = substr($tag, 0, $pos);
1301 1301
 
1302 1302
 			$parent_lower = strtolower($this->parent->tag);
1303 1303
 			$tag_lower = strtolower($tag);
1304 1304
 
1305
-			if ($parent_lower!==$tag_lower)
1305
+			if ($parent_lower !== $tag_lower)
1306 1306
 			{
1307 1307
 				if (isset($this->optional_closing_tags[$parent_lower]) && isset($this->block_tags[$tag_lower]))
1308 1308
 				{
1309 1309
 					$this->parent->_[HDOM_INFO_END] = 0;
1310 1310
 					$org_parent = $this->parent;
1311 1311
 
1312
-					while (($this->parent->parent) && strtolower($this->parent->tag)!==$tag_lower)
1312
+					while (($this->parent->parent) && strtolower($this->parent->tag) !== $tag_lower)
1313 1313
 						$this->parent = $this->parent->parent;
1314 1314
 
1315
-					if (strtolower($this->parent->tag)!==$tag_lower) {
1315
+					if (strtolower($this->parent->tag) !== $tag_lower) {
1316 1316
 						$this->parent = $org_parent; // restore origonal parent
1317 1317
 						if ($this->parent->parent) $this->parent = $this->parent->parent;
1318 1318
 						$this->parent->_[HDOM_INFO_END] = $this->cursor;
@@ -1324,17 +1324,17 @@  discard block
 block discarded – undo
1324 1324
 					$this->parent->_[HDOM_INFO_END] = 0;
1325 1325
 					$org_parent = $this->parent;
1326 1326
 
1327
-					while (($this->parent->parent) && strtolower($this->parent->tag)!==$tag_lower)
1327
+					while (($this->parent->parent) && strtolower($this->parent->tag) !== $tag_lower)
1328 1328
 						$this->parent = $this->parent->parent;
1329 1329
 
1330
-					if (strtolower($this->parent->tag)!==$tag_lower)
1330
+					if (strtolower($this->parent->tag) !== $tag_lower)
1331 1331
 					{
1332 1332
 						$this->parent = $org_parent; // restore origonal parent
1333 1333
 						$this->parent->_[HDOM_INFO_END] = $this->cursor;
1334 1334
 						return $this->as_text_node($tag);
1335 1335
 					}
1336 1336
 				}
1337
-				else if (($this->parent->parent) && strtolower($this->parent->parent->tag)===$tag_lower)
1337
+				else if (($this->parent->parent) && strtolower($this->parent->parent->tag) === $tag_lower)
1338 1338
 				{
1339 1339
 					$this->parent->_[HDOM_INFO_END] = 0;
1340 1340
 					$this->parent = $this->parent->parent;
@@ -1346,7 +1346,7 @@  discard block
 block discarded – undo
1346 1346
 			$this->parent->_[HDOM_INFO_END] = $this->cursor;
1347 1347
 			if ($this->parent->parent) $this->parent = $this->parent->parent;
1348 1348
 
1349
-			$this->char = (++$this->pos<$this->size) ? $this->doc[$this->pos] : null; // next
1349
+			$this->char = (++$this->pos < $this->size) ? $this->doc[$this->pos] : null; // next
1350 1350
 			return true;
1351 1351
 		}
1352 1352
 
@@ -1357,25 +1357,25 @@  discard block
 block discarded – undo
1357 1357
 		$node->tag_start = $begin_tag_pos;
1358 1358
 
1359 1359
 		// doctype, cdata & comments...
1360
-		if (isset($tag[0]) && $tag[0]==='!') {
1361
-			$node->_[HDOM_INFO_TEXT] = '<' . $tag . $this->copy_until_char('>');
1360
+		if (isset($tag[0]) && $tag[0] === '!') {
1361
+			$node->_[HDOM_INFO_TEXT] = '<'.$tag.$this->copy_until_char('>');
1362 1362
 
1363
-			if (isset($tag[2]) && $tag[1]==='-' && $tag[2]==='-') {
1363
+			if (isset($tag[2]) && $tag[1] === '-' && $tag[2] === '-') {
1364 1364
 				$node->nodetype = HDOM_TYPE_COMMENT;
1365 1365
 				$node->tag = 'comment';
1366 1366
 			} else {
1367 1367
 				$node->nodetype = HDOM_TYPE_UNKNOWN;
1368 1368
 				$node->tag = 'unknown';
1369 1369
 			}
1370
-			if ($this->char==='>') $node->_[HDOM_INFO_TEXT].='>';
1370
+			if ($this->char === '>') $node->_[HDOM_INFO_TEXT] .= '>';
1371 1371
 			$this->link_nodes($node, true);
1372
-			$this->char = (++$this->pos<$this->size) ? $this->doc[$this->pos] : null; // next
1372
+			$this->char = (++$this->pos < $this->size) ? $this->doc[$this->pos] : null; // next
1373 1373
 			return true;
1374 1374
 		}
1375 1375
 
1376 1376
 		// text
1377
-		if ($pos=strpos($tag, '<')!==false) {
1378
-			$tag = '<' . substr($tag, 0, -1);
1377
+		if ($pos = strpos($tag, '<') !== false) {
1378
+			$tag = '<'.substr($tag, 0, -1);
1379 1379
 			$node->_[HDOM_INFO_TEXT] = $tag;
1380 1380
 			$this->link_nodes($node, false);
1381 1381
 			$this->char = $this->doc[--$this->pos]; // prev
@@ -1383,15 +1383,15 @@  discard block
 block discarded – undo
1383 1383
 		}
1384 1384
 
1385 1385
 		if (!preg_match("/^[\w-:]+$/", $tag)) {
1386
-			$node->_[HDOM_INFO_TEXT] = '<' . $tag . $this->copy_until('<>');
1387
-			if ($this->char==='<') {
1386
+			$node->_[HDOM_INFO_TEXT] = '<'.$tag.$this->copy_until('<>');
1387
+			if ($this->char === '<') {
1388 1388
 				$this->link_nodes($node, false);
1389 1389
 				return true;
1390 1390
 			}
1391 1391
 
1392
-			if ($this->char==='>') $node->_[HDOM_INFO_TEXT].='>';
1392
+			if ($this->char === '>') $node->_[HDOM_INFO_TEXT] .= '>';
1393 1393
 			$this->link_nodes($node, false);
1394
-			$this->char = (++$this->pos<$this->size) ? $this->doc[$this->pos] : null; // next
1394
+			$this->char = (++$this->pos < $this->size) ? $this->doc[$this->pos] : null; // next
1395 1395
 			return true;
1396 1396
 		}
1397 1397
 
@@ -1401,7 +1401,7 @@  discard block
 block discarded – undo
1401 1401
 		$node->tag = ($this->lowercase) ? $tag_lower : $tag;
1402 1402
 
1403 1403
 		// handle optional closing tags
1404
-		if (isset($this->optional_closing_tags[$tag_lower]) )
1404
+		if (isset($this->optional_closing_tags[$tag_lower]))
1405 1405
 		{
1406 1406
 			while (isset($this->optional_closing_tags[$tag_lower][strtolower($this->parent->tag)]))
1407 1407
 			{
@@ -1417,67 +1417,67 @@  discard block
 block discarded – undo
1417 1417
 		// attributes
1418 1418
 		do
1419 1419
 		{
1420
-			if ($this->char!==null && $space[0]==='')
1420
+			if ($this->char !== null && $space[0] === '')
1421 1421
 			{
1422 1422
 				break;
1423 1423
 			}
1424 1424
 			$name = $this->copy_until($this->token_equal);
1425
-			if ($guard===$this->pos)
1425
+			if ($guard === $this->pos)
1426 1426
 			{
1427
-				$this->char = (++$this->pos<$this->size) ? $this->doc[$this->pos] : null; // next
1427
+				$this->char = (++$this->pos < $this->size) ? $this->doc[$this->pos] : null; // next
1428 1428
 				continue;
1429 1429
 			}
1430 1430
 			$guard = $this->pos;
1431 1431
 
1432 1432
 			// handle endless '<'
1433
-			if ($this->pos>=$this->size-1 && $this->char!=='>') {
1433
+			if ($this->pos >= $this->size - 1 && $this->char !== '>') {
1434 1434
 				$node->nodetype = HDOM_TYPE_TEXT;
1435 1435
 				$node->_[HDOM_INFO_END] = 0;
1436
-				$node->_[HDOM_INFO_TEXT] = '<'.$tag . $space[0] . $name;
1436
+				$node->_[HDOM_INFO_TEXT] = '<'.$tag.$space[0].$name;
1437 1437
 				$node->tag = 'text';
1438 1438
 				$this->link_nodes($node, false);
1439 1439
 				return true;
1440 1440
 			}
1441 1441
 
1442 1442
 			// handle mismatch '<'
1443
-			if ($this->doc[$this->pos-1]=='<') {
1443
+			if ($this->doc[$this->pos - 1] == '<') {
1444 1444
 				$node->nodetype = HDOM_TYPE_TEXT;
1445 1445
 				$node->tag = 'text';
1446 1446
 				$node->attr = array();
1447 1447
 				$node->_[HDOM_INFO_END] = 0;
1448
-				$node->_[HDOM_INFO_TEXT] = substr($this->doc, $begin_tag_pos, $this->pos-$begin_tag_pos-1);
1448
+				$node->_[HDOM_INFO_TEXT] = substr($this->doc, $begin_tag_pos, $this->pos - $begin_tag_pos - 1);
1449 1449
 				$this->pos -= 2;
1450
-				$this->char = (++$this->pos<$this->size) ? $this->doc[$this->pos] : null; // next
1450
+				$this->char = (++$this->pos < $this->size) ? $this->doc[$this->pos] : null; // next
1451 1451
 				$this->link_nodes($node, false);
1452 1452
 				return true;
1453 1453
 			}
1454 1454
 
1455
-			if ($name!=='/' && $name!=='') {
1455
+			if ($name !== '/' && $name !== '') {
1456 1456
 				$space[1] = $this->copy_skip($this->token_blank);
1457 1457
 				$name = $this->restore_noise($name);
1458 1458
 				if ($this->lowercase) $name = strtolower($name);
1459
-				if ($this->char==='=') {
1460
-					$this->char = (++$this->pos<$this->size) ? $this->doc[$this->pos] : null; // next
1459
+				if ($this->char === '=') {
1460
+					$this->char = (++$this->pos < $this->size) ? $this->doc[$this->pos] : null; // next
1461 1461
 					$this->parse_attr($node, $name, $space);
1462 1462
 				}
1463 1463
 				else {
1464 1464
 					//no value attr: nowrap, checked selected...
1465 1465
 					$node->_[HDOM_INFO_QUOTE][] = HDOM_QUOTE_NO;
1466 1466
 					$node->attr[$name] = true;
1467
-					if ($this->char!='>') $this->char = $this->doc[--$this->pos]; // prev
1467
+					if ($this->char != '>') $this->char = $this->doc[--$this->pos]; // prev
1468 1468
 				}
1469 1469
 				$node->_[HDOM_INFO_SPACE][] = $space;
1470 1470
 				$space = array($this->copy_skip($this->token_blank), '', '');
1471 1471
 			}
1472 1472
 			else
1473 1473
 				break;
1474
-		} while ($this->char!=='>' && $this->char!=='/');
1474
+		} while ($this->char !== '>' && $this->char !== '/');
1475 1475
 
1476 1476
 		$this->link_nodes($node, true);
1477 1477
 		$node->_[HDOM_INFO_ENDSPACE] = $space[0];
1478 1478
 
1479 1479
 		// check self closing
1480
-		if ($this->copy_until_char_escape('>')==='/')
1480
+		if ($this->copy_until_char_escape('>') === '/')
1481 1481
 		{
1482 1482
 			$node->_[HDOM_INFO_ENDSPACE] .= '/';
1483 1483
 			$node->_[HDOM_INFO_END] = 0;
@@ -1487,7 +1487,7 @@  discard block
 block discarded – undo
1487 1487
 			// reset parent
1488 1488
 			if (!isset($this->self_closing_tags[strtolower($node->tag)])) $this->parent = $node;
1489 1489
 		}
1490
-		$this->char = (++$this->pos<$this->size) ? $this->doc[$this->pos] : null; // next
1490
+		$this->char = (++$this->pos < $this->size) ? $this->doc[$this->pos] : null; // next
1491 1491
 
1492 1492
 		// If it's a BR tag, we need to set it's text to the default text.
1493 1493
 		// This way when we see it in plaintext, we can generate formatting that the user wants.
@@ -1514,15 +1514,15 @@  discard block
 block discarded – undo
1514 1514
 		switch ($this->char) {
1515 1515
 			case '"':
1516 1516
 				$node->_[HDOM_INFO_QUOTE][] = HDOM_QUOTE_DOUBLE;
1517
-				$this->char = (++$this->pos<$this->size) ? $this->doc[$this->pos] : null; // next
1517
+				$this->char = (++$this->pos < $this->size) ? $this->doc[$this->pos] : null; // next
1518 1518
 				$node->attr[$name] = $this->restore_noise($this->copy_until_char_escape('"'));
1519
-				$this->char = (++$this->pos<$this->size) ? $this->doc[$this->pos] : null; // next
1519
+				$this->char = (++$this->pos < $this->size) ? $this->doc[$this->pos] : null; // next
1520 1520
 				break;
1521 1521
 			case '\'':
1522 1522
 				$node->_[HDOM_INFO_QUOTE][] = HDOM_QUOTE_SINGLE;
1523
-				$this->char = (++$this->pos<$this->size) ? $this->doc[$this->pos] : null; // next
1523
+				$this->char = (++$this->pos < $this->size) ? $this->doc[$this->pos] : null; // next
1524 1524
 				$node->attr[$name] = $this->restore_noise($this->copy_until_char_escape('\''));
1525
-				$this->char = (++$this->pos<$this->size) ? $this->doc[$this->pos] : null; // next
1525
+				$this->char = (++$this->pos < $this->size) ? $this->doc[$this->pos] : null; // next
1526 1526
 				break;
1527 1527
 			default:
1528 1528
 				$node->_[HDOM_INFO_QUOTE][] = HDOM_QUOTE_NO;
@@ -1553,16 +1553,16 @@  discard block
 block discarded – undo
1553 1553
 	{
1554 1554
 		$node = new simple_html_dom_node($this);
1555 1555
 		++$this->cursor;
1556
-		$node->_[HDOM_INFO_TEXT] = '</' . $tag . '>';
1556
+		$node->_[HDOM_INFO_TEXT] = '</'.$tag.'>';
1557 1557
 		$this->link_nodes($node, false);
1558
-		$this->char = (++$this->pos<$this->size) ? $this->doc[$this->pos] : null; // next
1558
+		$this->char = (++$this->pos < $this->size) ? $this->doc[$this->pos] : null; // next
1559 1559
 		return true;
1560 1560
 	}
1561 1561
 
1562 1562
 	protected function skip($chars)
1563 1563
 	{
1564 1564
 		$this->pos += strspn($this->doc, $chars, $this->pos);
1565
-		$this->char = ($this->pos<$this->size) ? $this->doc[$this->pos] : null; // next
1565
+		$this->char = ($this->pos < $this->size) ? $this->doc[$this->pos] : null; // next
1566 1566
 	}
1567 1567
 
1568 1568
 	protected function copy_skip($chars)
@@ -1570,8 +1570,8 @@  discard block
 block discarded – undo
1570 1570
 		$pos = $this->pos;
1571 1571
 		$len = strspn($this->doc, $chars, $pos);
1572 1572
 		$this->pos += $len;
1573
-		$this->char = ($this->pos<$this->size) ? $this->doc[$this->pos] : null; // next
1574
-		if ($len===0) return '';
1573
+		$this->char = ($this->pos < $this->size) ? $this->doc[$this->pos] : null; // next
1574
+		if ($len === 0) return '';
1575 1575
 		return substr($this->doc, $pos, $len);
1576 1576
 	}
1577 1577
 
@@ -1580,70 +1580,70 @@  discard block
 block discarded – undo
1580 1580
 		$pos = $this->pos;
1581 1581
 		$len = strcspn($this->doc, $chars, $pos);
1582 1582
 		$this->pos += $len;
1583
-		$this->char = ($this->pos<$this->size) ? $this->doc[$this->pos] : null; // next
1583
+		$this->char = ($this->pos < $this->size) ? $this->doc[$this->pos] : null; // next
1584 1584
 		return substr($this->doc, $pos, $len);
1585 1585
 	}
1586 1586
 
1587 1587
 	protected function copy_until_char($char)
1588 1588
 	{
1589
-		if ($this->char===null) return '';
1589
+		if ($this->char === null) return '';
1590 1590
 
1591
-		if (($pos = strpos($this->doc, $char, $this->pos))===false) {
1592
-			$ret = substr($this->doc, $this->pos, $this->size-$this->pos);
1591
+		if (($pos = strpos($this->doc, $char, $this->pos)) === false) {
1592
+			$ret = substr($this->doc, $this->pos, $this->size - $this->pos);
1593 1593
 			$this->char = null;
1594 1594
 			$this->pos = $this->size;
1595 1595
 			return $ret;
1596 1596
 		}
1597 1597
 
1598
-		if ($pos===$this->pos) return '';
1598
+		if ($pos === $this->pos) return '';
1599 1599
 		$pos_old = $this->pos;
1600 1600
 		$this->char = $this->doc[$pos];
1601 1601
 		$this->pos = $pos;
1602
-		return substr($this->doc, $pos_old, $pos-$pos_old);
1602
+		return substr($this->doc, $pos_old, $pos - $pos_old);
1603 1603
 	}
1604 1604
 
1605 1605
 	protected function copy_until_char_escape($char)
1606 1606
 	{
1607
-		if ($this->char===null) return '';
1607
+		if ($this->char === null) return '';
1608 1608
 
1609 1609
 		$start = $this->pos;
1610 1610
 		while (1)
1611 1611
 		{
1612
-			if (($pos = strpos($this->doc, $char, $start))===false)
1612
+			if (($pos = strpos($this->doc, $char, $start)) === false)
1613 1613
 			{
1614
-				$ret = substr($this->doc, $this->pos, $this->size-$this->pos);
1614
+				$ret = substr($this->doc, $this->pos, $this->size - $this->pos);
1615 1615
 				$this->char = null;
1616 1616
 				$this->pos = $this->size;
1617 1617
 				return $ret;
1618 1618
 			}
1619 1619
 
1620
-			if ($pos===$this->pos) return '';
1620
+			if ($pos === $this->pos) return '';
1621 1621
 
1622
-			if ($this->doc[$pos-1]==='\\') {
1623
-				$start = $pos+1;
1622
+			if ($this->doc[$pos - 1] === '\\') {
1623
+				$start = $pos + 1;
1624 1624
 				continue;
1625 1625
 			}
1626 1626
 
1627 1627
 			$pos_old = $this->pos;
1628 1628
 			$this->char = $this->doc[$pos];
1629 1629
 			$this->pos = $pos;
1630
-			return substr($this->doc, $pos_old, $pos-$pos_old);
1630
+			return substr($this->doc, $pos_old, $pos - $pos_old);
1631 1631
 		}
1632 1632
 	}
1633 1633
 
1634 1634
 	// remove noise from html content
1635 1635
 	// save the noise in the $this->noise array.
1636
-	protected function remove_noise($pattern, $remove_tag=false)
1636
+	protected function remove_noise($pattern, $remove_tag = false)
1637 1637
 	{
1638 1638
 		global $debug_object;
1639 1639
 		if (is_object($debug_object)) { $debug_object->debug_log_entry(1); }
1640 1640
 
1641 1641
 		$count = preg_match_all($pattern, $this->doc, $matches, PREG_SET_ORDER|PREG_OFFSET_CAPTURE);
1642 1642
 
1643
-		for ($i=$count-1; $i>-1; --$i)
1643
+		for ($i = $count - 1; $i > -1; --$i)
1644 1644
 		{
1645
-			$key = '___noise___'.sprintf('% 5d', count($this->noise)+1000);
1646
-			if (is_object($debug_object)) { $debug_object->debug_log(2, 'key is: ' . $key); }
1645
+			$key = '___noise___'.sprintf('% 5d', count($this->noise) + 1000);
1646
+			if (is_object($debug_object)) { $debug_object->debug_log(2, 'key is: '.$key); }
1647 1647
 			$idx = ($remove_tag) ? 0 : 1;
1648 1648
 			$this->noise[$key] = $matches[$i][$idx][0];
1649 1649
 			$this->doc = substr_replace($this->doc, $key, $matches[$i][$idx][1], strlen($matches[$i][$idx][0]));
@@ -1651,7 +1651,7 @@  discard block
 block discarded – undo
1651 1651
 
1652 1652
 		// reset the length of content
1653 1653
 		$this->size = strlen($this->doc);
1654
-		if ($this->size>0)
1654
+		if ($this->size > 0)
1655 1655
 		{
1656 1656
 			$this->char = $this->doc[0];
1657 1657
 		}
@@ -1663,28 +1663,28 @@  discard block
 block discarded – undo
1663 1663
 		global $debug_object;
1664 1664
 		if (is_object($debug_object)) { $debug_object->debug_log_entry(1); }
1665 1665
 
1666
-		while (($pos=strpos($text, '___noise___'))!==false)
1666
+		while (($pos = strpos($text, '___noise___')) !== false)
1667 1667
 		{
1668 1668
 			// Sometimes there is a broken piece of markup, and we don't GET the pos+11 etc... token which indicates a problem outside of us...
1669
-			if (strlen($text) > $pos+15)
1669
+			if (strlen($text) > $pos + 15)
1670 1670
 			{
1671
-				$key = '___noise___'.$text[$pos+11].$text[$pos+12].$text[$pos+13].$text[$pos+14].$text[$pos+15];
1672
-				if (is_object($debug_object)) { $debug_object->debug_log(2, 'located key of: ' . $key); }
1671
+				$key = '___noise___'.$text[$pos + 11].$text[$pos + 12].$text[$pos + 13].$text[$pos + 14].$text[$pos + 15];
1672
+				if (is_object($debug_object)) { $debug_object->debug_log(2, 'located key of: '.$key); }
1673 1673
 
1674 1674
 				if (isset($this->noise[$key]))
1675 1675
 				{
1676
-					$text = substr($text, 0, $pos).$this->noise[$key].substr($text, $pos+16);
1676
+					$text = substr($text, 0, $pos).$this->noise[$key].substr($text, $pos + 16);
1677 1677
 				}
1678 1678
 				else
1679 1679
 				{
1680 1680
 					// do this to prevent an infinite loop.
1681
-					$text = substr($text, 0, $pos).'UNDEFINED NOISE FOR KEY: '.$key . substr($text, $pos+16);
1681
+					$text = substr($text, 0, $pos).'UNDEFINED NOISE FOR KEY: '.$key.substr($text, $pos + 16);
1682 1682
 				}
1683 1683
 			}
1684 1684
 			else
1685 1685
 			{
1686 1686
 				// There is no valid key being given back to us... We must get rid of the ___noise___ or we will have a problem.
1687
-				$text = substr($text, 0, $pos).'NO NUMERIC NOISE KEY' . substr($text, $pos+11);
1687
+				$text = substr($text, 0, $pos).'NO NUMERIC NOISE KEY'.substr($text, $pos + 11);
1688 1688
 			}
1689 1689
 		}
1690 1690
 		return $text;
@@ -1696,9 +1696,9 @@  discard block
 block discarded – undo
1696 1696
 		global $debug_object;
1697 1697
 		if (is_object($debug_object)) { $debug_object->debug_log_entry(1); }
1698 1698
 
1699
-		foreach($this->noise as $noiseElement)
1699
+		foreach ($this->noise as $noiseElement)
1700 1700
 		{
1701
-			if (strpos($noiseElement, $text)!==false)
1701
+			if (strpos($noiseElement, $text) !== false)
1702 1702
 			{
1703 1703
 				return $noiseElement;
1704 1704
 			}
@@ -1727,16 +1727,16 @@  discard block
 block discarded – undo
1727 1727
 	}
1728 1728
 
1729 1729
 	// camel naming conventions
1730
-	function childNodes($idx=-1) {return $this->root->childNodes($idx);}
1731
-	function firstChild() {return $this->root->first_child();}
1732
-	function lastChild() {return $this->root->last_child();}
1733
-	function createElement($name, $value=null) {return @str_get_html("<$name>$value</$name>")->first_child();}
1734
-	function createTextNode($value) {return @end(str_get_html($value)->nodes);}
1735
-	function getElementById($id) {return $this->find("#$id", 0);}
1736
-	function getElementsById($id, $idx=null) {return $this->find("#$id", $idx);}
1737
-	function getElementByTagName($name) {return $this->find($name, 0);}
1738
-	function getElementsByTagName($name, $idx=-1) {return $this->find($name, $idx);}
1739
-	function loadFile() {$args = func_get_args();$this->load_file($args);}
1730
+	function childNodes($idx = -1) {return $this->root->childNodes($idx); }
1731
+	function firstChild() {return $this->root->first_child(); }
1732
+	function lastChild() {return $this->root->last_child(); }
1733
+	function createElement($name, $value = null) {return @str_get_html("<$name>$value</$name>")->first_child(); }
1734
+	function createTextNode($value) {return @end(str_get_html($value)->nodes); }
1735
+	function getElementById($id) {return $this->find("#$id", 0); }
1736
+	function getElementsById($id, $idx = null) {return $this->find("#$id", $idx); }
1737
+	function getElementByTagName($name) {return $this->find($name, 0); }
1738
+	function getElementsByTagName($name, $idx = -1) {return $this->find($name, $idx); }
1739
+	function loadFile() {$args = func_get_args(); $this->load_file($args); }
1740 1740
 }
1741 1741
 
1742 1742
 ?>
1743 1743
\ No newline at end of file
Please login to merge, or discard this patch.
Braces   +193 added lines, -101 removed lines patch added patch discarded remove patch
@@ -159,8 +159,9 @@  discard block
 block discarded – undo
159 159
 		if ($show_attr && count($this->attr)>0)
160 160
 		{
161 161
 			echo '(';
162
-			foreach ($this->attr as $k=>$v)
163
-				echo "[$k]=>\"".$this->$k.'", ';
162
+			foreach ($this->attr as $k=>$v) {
163
+							echo "[$k]=>\"".$this->$k.'", ';
164
+			}
164 165
 			echo ')';
165 166
 		}
166 167
 		echo "\n";
@@ -218,8 +219,7 @@  discard block
 block discarded – undo
218 219
 		if (isset($node->_[HDOM_INFO_INNER]))
219 220
 		{
220 221
 			$string .= $node->_[HDOM_INFO_INNER] . "'";
221
-		}
222
-		else
222
+		} else
223 223
 		{
224 224
 			$string .= ' NULL ';
225 225
 		}
@@ -233,8 +233,7 @@  discard block
 block discarded – undo
233 233
 		{
234 234
 			echo $string;
235 235
 			return;
236
-		}
237
-		else
236
+		} else
238 237
 		{
239 238
 			return $string;
240 239
 		}
@@ -320,12 +319,17 @@  discard block
 block discarded – undo
320 319
 	// returns the previous sibling of node
321 320
 	function prev_sibling()
322 321
 	{
323
-		if ($this->parent===null) return null;
322
+		if ($this->parent===null) {
323
+			return null;
324
+		}
324 325
 		$idx = 0;
325 326
 		$count = count($this->parent->children);
326
-		while ($idx<$count && $this!==$this->parent->children[$idx])
327
-			++$idx;
328
-		if (--$idx<0) return null;
327
+		while ($idx<$count && $this!==$this->parent->children[$idx]) {
328
+					++$idx;
329
+		}
330
+		if (--$idx<0) {
331
+			return null;
332
+		}
329 333
 		return $this->parent->children[$idx];
330 334
 	}
331 335
 
@@ -354,12 +358,17 @@  discard block
 block discarded – undo
354 358
 	// get dom node's inner html
355 359
 	function innertext()
356 360
 	{
357
-		if (isset($this->_[HDOM_INFO_INNER])) return $this->_[HDOM_INFO_INNER];
358
-		if (isset($this->_[HDOM_INFO_TEXT])) return $this->dom->restore_noise($this->_[HDOM_INFO_TEXT]);
361
+		if (isset($this->_[HDOM_INFO_INNER])) {
362
+			return $this->_[HDOM_INFO_INNER];
363
+		}
364
+		if (isset($this->_[HDOM_INFO_TEXT])) {
365
+			return $this->dom->restore_noise($this->_[HDOM_INFO_TEXT]);
366
+		}
359 367
 
360 368
 		$ret = '';
361
-		foreach ($this->nodes as $n)
362
-			$ret .= $n->outertext();
369
+		foreach ($this->nodes as $n) {
370
+					$ret .= $n->outertext();
371
+		}
363 372
 		return $ret;
364 373
 	}
365 374
 
@@ -380,7 +389,9 @@  discard block
 block discarded – undo
380 389
 			$debug_object->debug_log(1, 'Innertext of tag: ' . $this->tag . $text);
381 390
 		}
382 391
 
383
-		if ($this->tag==='root') return $this->innertext();
392
+		if ($this->tag==='root') {
393
+			return $this->innertext();
394
+		}
384 395
 
385 396
 		// trigger callback
386 397
 		if ($this->dom && $this->dom->callback!==null)
@@ -388,8 +399,12 @@  discard block
 block discarded – undo
388 399
 			call_user_func_array($this->dom->callback, array($this));
389 400
 		}
390 401
 
391
-		if (isset($this->_[HDOM_INFO_OUTER])) return $this->_[HDOM_INFO_OUTER];
392
-		if (isset($this->_[HDOM_INFO_TEXT])) return $this->dom->restore_noise($this->_[HDOM_INFO_TEXT]);
402
+		if (isset($this->_[HDOM_INFO_OUTER])) {
403
+			return $this->_[HDOM_INFO_OUTER];
404
+		}
405
+		if (isset($this->_[HDOM_INFO_TEXT])) {
406
+			return $this->dom->restore_noise($this->_[HDOM_INFO_TEXT]);
407
+		}
393 408
 
394 409
 		// render begin tag
395 410
 		if ($this->dom && $this->dom->nodes[$this->_[HDOM_INFO_BEGIN]])
@@ -418,23 +433,30 @@  discard block
 block discarded – undo
418 433
 		}
419 434
 
420 435
 		// render end tag
421
-		if (isset($this->_[HDOM_INFO_END]) && $this->_[HDOM_INFO_END]!=0)
422
-			$ret .= '</'.$this->tag.'>';
436
+		if (isset($this->_[HDOM_INFO_END]) && $this->_[HDOM_INFO_END]!=0) {
437
+					$ret .= '</'.$this->tag.'>';
438
+		}
423 439
 		return $ret;
424 440
 	}
425 441
 
426 442
 	// get dom node's plain text
427 443
 	function text()
428 444
 	{
429
-		if (isset($this->_[HDOM_INFO_INNER])) return $this->_[HDOM_INFO_INNER];
445
+		if (isset($this->_[HDOM_INFO_INNER])) {
446
+			return $this->_[HDOM_INFO_INNER];
447
+		}
430 448
 		switch ($this->nodetype)
431 449
 		{
432 450
 			case HDOM_TYPE_TEXT: return $this->dom->restore_noise($this->_[HDOM_INFO_TEXT]);
433 451
 			case HDOM_TYPE_COMMENT: return '';
434 452
 			case HDOM_TYPE_UNKNOWN: return '';
435 453
 		}
436
-		if (strcasecmp($this->tag, 'script')===0) return '';
437
-		if (strcasecmp($this->tag, 'style')===0) return '';
454
+		if (strcasecmp($this->tag, 'script')===0) {
455
+			return '';
456
+		}
457
+		if (strcasecmp($this->tag, 'style')===0) {
458
+			return '';
459
+		}
438 460
 
439 461
 		$ret = '';
440 462
 		// In rare cases, (always node type 1 or HDOM_TYPE_ELEMENT - observed for some span tags, and some p tags) $this->nodes is set to NULL.
@@ -470,7 +492,9 @@  discard block
 block discarded – undo
470 492
 	function makeup()
471 493
 	{
472 494
 		// text, comment, unknown
473
-		if (isset($this->_[HDOM_INFO_TEXT])) return $this->dom->restore_noise($this->_[HDOM_INFO_TEXT]);
495
+		if (isset($this->_[HDOM_INFO_TEXT])) {
496
+			return $this->dom->restore_noise($this->_[HDOM_INFO_TEXT]);
497
+		}
474 498
 
475 499
 		$ret = '<'.$this->tag;
476 500
 		$i = -1;
@@ -480,14 +504,15 @@  discard block
 block discarded – undo
480 504
 			++$i;
481 505
 
482 506
 			// skip removed attribute
483
-			if ($val===null || $val===false)
484
-				continue;
507
+			if ($val===null || $val===false) {
508
+							continue;
509
+			}
485 510
 
486 511
 			$ret .= $this->_[HDOM_INFO_SPACE][$i][0];
487 512
 			//no value attr: nowrap, checked selected...
488
-			if ($val===true)
489
-				$ret .= $key;
490
-			else {
513
+			if ($val===true) {
514
+							$ret .= $key;
515
+			} else {
491 516
 				switch ($this->_[HDOM_INFO_QUOTE][$i])
492 517
 				{
493 518
 					case HDOM_QUOTE_DOUBLE: $quote = '"'; break;
@@ -506,7 +531,9 @@  discard block
 block discarded – undo
506 531
 	function find($selector, $idx=null, $lowercase=false)
507 532
 	{
508 533
 		$selectors = $this->parse_selector($selector);
509
-		if (($count=count($selectors))===0) return array();
534
+		if (($count=count($selectors))===0) {
535
+			return array();
536
+		}
510 537
 		$found_keys = array();
511 538
 
512 539
 		// find each selector
@@ -514,8 +541,12 @@  discard block
 block discarded – undo
514 541
 		{
515 542
 			// The change on the below line was documented on the sourceforge code tracker id 2788009
516 543
 			// used to be: if (($levle=count($selectors[0]))===0) return array();
517
-			if (($levle=count($selectors[$c]))===0) return array();
518
-			if (!isset($this->_[HDOM_INFO_BEGIN])) return array();
544
+			if (($levle=count($selectors[$c]))===0) {
545
+				return array();
546
+			}
547
+			if (!isset($this->_[HDOM_INFO_BEGIN])) {
548
+				return array();
549
+			}
519 550
 
520 551
 			$head = array($this->_[HDOM_INFO_BEGIN]=>1);
521 552
 
@@ -545,12 +576,16 @@  discard block
 block discarded – undo
545 576
 		ksort($found_keys);
546 577
 
547 578
 		$found = array();
548
-		foreach ($found_keys as $k=>$v)
549
-			$found[] = $this->dom->nodes[$k];
579
+		foreach ($found_keys as $k=>$v) {
580
+					$found[] = $this->dom->nodes[$k];
581
+		}
550 582
 
551 583
 		// return nth-element or array
552
-		if (is_null($idx)) return $found;
553
-		else if ($idx<0) $idx = count($found) + $idx;
584
+		if (is_null($idx)) {
585
+			return $found;
586
+		} else if ($idx<0) {
587
+			$idx = count($found) + $idx;
588
+		}
554 589
 		return (isset($found[$idx])) ? $found[$idx] : null;
555 590
 	}
556 591
 
@@ -595,8 +630,9 @@  discard block
 block discarded – undo
595 630
 			$pass = true;
596 631
 
597 632
 			if ($tag==='*' && !$key) {
598
-				if (in_array($node, $this->children, true))
599
-					$ret[$i] = 1;
633
+				if (in_array($node, $this->children, true)) {
634
+									$ret[$i] = 1;
635
+				}
600 636
 				continue;
601 637
 			}
602 638
 
@@ -605,9 +641,13 @@  discard block
 block discarded – undo
605 641
 			// compare key
606 642
 			if ($pass && $key) {
607 643
 				if ($no_key) {
608
-					if (isset($node->attr[$key])) $pass=false;
644
+					if (isset($node->attr[$key])) {
645
+						$pass=false;
646
+					}
609 647
 				} else {
610
-					if (($key != "plaintext") && !isset($node->attr[$key])) $pass=false;
648
+					if (($key != "plaintext") && !isset($node->attr[$key])) {
649
+						$pass=false;
650
+					}
611 651
 				}
612 652
 			}
613 653
 			// compare value
@@ -640,13 +680,19 @@  discard block
 block discarded – undo
640 680
 							} else {
641 681
 								$check = $this->match($exp, $val, $k);
642 682
 							}
643
-							if ($check) break;
683
+							if ($check) {
684
+								break;
685
+							}
644 686
 						}
645 687
 					}
646 688
 				}
647
-				if (!$check) $pass = false;
689
+				if (!$check) {
690
+					$pass = false;
691
+				}
692
+			}
693
+			if ($pass) {
694
+				$ret[$i] = 1;
648 695
 			}
649
-			if ($pass) $ret[$i] = 1;
650 696
 			unset($node);
651 697
 		}
652 698
 		// It's passed by reference so this is actually what this function returns.
@@ -696,9 +742,13 @@  discard block
 block discarded – undo
696 742
 
697 743
 		foreach ($matches as $m) {
698 744
 			$m[0] = trim($m[0]);
699
-			if ($m[0]==='' || $m[0]==='/' || $m[0]==='//') continue;
745
+			if ($m[0]==='' || $m[0]==='/' || $m[0]==='//') {
746
+				continue;
747
+			}
700 748
 			// for browser generated xpath
701
-			if ($m[1]==='tbody') continue;
749
+			if ($m[1]==='tbody') {
750
+				continue;
751
+			}
702 752
 
703 753
 			list($tag, $key, $val, $exp, $no_key) = array($m[1], null, null, '=', false);
704 754
 			if (!empty($m[2])) {$key='id'; $val=$m[2];}
@@ -718,8 +768,9 @@  discard block
 block discarded – undo
718 768
 				$result = array();
719 769
 			}
720 770
 		}
721
-		if (count($result)>0)
722
-			$selectors[] = $result;
771
+		if (count($result)>0) {
772
+					$selectors[] = $result;
773
+		}
723 774
 		return $selectors;
724 775
 	}
725 776
 
@@ -748,7 +799,9 @@  discard block
 block discarded – undo
748 799
 		{
749 800
 			case 'outertext': return $this->_[HDOM_INFO_OUTER] = $value;
750 801
 			case 'innertext':
751
-				if (isset($this->_[HDOM_INFO_TEXT])) return $this->_[HDOM_INFO_TEXT] = $value;
802
+				if (isset($this->_[HDOM_INFO_TEXT])) {
803
+					return $this->_[HDOM_INFO_TEXT] = $value;
804
+				}
752 805
 				return $this->_[HDOM_INFO_INNER] = $value;
753 806
 		}
754 807
 		if (!isset($this->attr[$name]))
@@ -772,8 +825,9 @@  discard block
 block discarded – undo
772 825
 	}
773 826
 
774 827
 	function __unset($name) {
775
-		if (isset($this->attr[$name]))
776
-			unset($this->attr[$name]);
828
+		if (isset($this->attr[$name])) {
829
+					unset($this->attr[$name]);
830
+		}
777 831
 	}
778 832
 
779 833
 	// PaperG - Function to convert the text from one character set to another if the two sets are not the same.
@@ -800,8 +854,7 @@  discard block
 block discarded – undo
800 854
 			if ((strcasecmp($targetCharset, 'UTF-8') == 0) && ($this->is_utf8($text)))
801 855
 			{
802 856
 				$converted_text = $text;
803
-			}
804
-			else
857
+			} else
805 858
 			{
806 859
 				$converted_text = iconv($sourceCharset, $targetCharset, $text);
807 860
 			}
@@ -839,19 +892,31 @@  discard block
 block discarded – undo
839 892
 			$c=ord($str[$i]);
840 893
 			if($c > 128)
841 894
 			{
842
-				if(($c >= 254)) return false;
843
-				elseif($c >= 252) $bits=6;
844
-				elseif($c >= 248) $bits=5;
845
-				elseif($c >= 240) $bits=4;
846
-				elseif($c >= 224) $bits=3;
847
-				elseif($c >= 192) $bits=2;
848
-				else return false;
849
-				if(($i+$bits) > $len) return false;
895
+				if(($c >= 254)) {
896
+					return false;
897
+				} elseif($c >= 252) {
898
+					$bits=6;
899
+				} elseif($c >= 248) {
900
+					$bits=5;
901
+				} elseif($c >= 240) {
902
+					$bits=4;
903
+				} elseif($c >= 224) {
904
+					$bits=3;
905
+				} elseif($c >= 192) {
906
+					$bits=2;
907
+				} else {
908
+					return false;
909
+				}
910
+				if(($i+$bits) > $len) {
911
+					return false;
912
+				}
850 913
 				while($bits > 1)
851 914
 				{
852 915
 					$i++;
853 916
 					$b=ord($str[$i]);
854
-					if($b < 128 || $b > 191) return false;
917
+					if($b < 128 || $b > 191) {
918
+						return false;
919
+					}
855 920
 					$bits--;
856 921
 				}
857 922
 			}
@@ -1035,8 +1100,7 @@  discard block
 block discarded – undo
1035 1100
 			if (preg_match("/^http:\/\//i",$str) || is_file($str))
1036 1101
 			{
1037 1102
 				$this->load_file($str);
1038
-			}
1039
-			else
1103
+			} else
1040 1104
 			{
1041 1105
 				$this->load($str, $lowercase, $stripRN, $defaultBRText, $defaultSpanText);
1042 1106
 			}
@@ -1118,7 +1182,9 @@  discard block
 block discarded – undo
1118 1182
 	function save($filepath='')
1119 1183
 	{
1120 1184
 		$ret = $this->root->innertext();
1121
-		if ($filepath!=='') file_put_contents($filepath, $ret, LOCK_EX);
1185
+		if ($filepath!=='') {
1186
+			file_put_contents($filepath, $ret, LOCK_EX);
1187
+		}
1122 1188
 		return $ret;
1123 1189
 	}
1124 1190
 
@@ -1134,7 +1200,10 @@  discard block
 block discarded – undo
1134 1200
 	{
1135 1201
 		foreach ($this->nodes as $n) {$n->clear(); $n = null;}
1136 1202
 		// This add next line is documented in the sourceforge repository. 2977248 as a fix for ongoing memory leaks that occur even with the use of clear.
1137
-		if (isset($this->children)) foreach ($this->children as $n) {$n->clear(); $n = null;}
1203
+		if (isset($this->children)) {
1204
+			foreach ($this->children as $n) {$n->clear();
1205
+		}
1206
+		$n = null;}
1138 1207
 		if (isset($this->parent)) {$this->parent->clear(); unset($this->parent);}
1139 1208
 		if (isset($this->root)) {$this->root->clear(); unset($this->root);}
1140 1209
 		unset($this->doc);
@@ -1178,7 +1247,9 @@  discard block
 block discarded – undo
1178 1247
 		$this->root->_[HDOM_INFO_BEGIN] = -1;
1179 1248
 		$this->root->nodetype = HDOM_TYPE_ROOT;
1180 1249
 		$this->parent = $this->root;
1181
-		if ($this->size>0) $this->char = $this->doc[0];
1250
+		if ($this->size>0) {
1251
+			$this->char = $this->doc[0];
1252
+		}
1182 1253
 	}
1183 1254
 
1184 1255
 	// parse html content
@@ -1232,8 +1303,7 @@  discard block
 block discarded – undo
1232 1303
 					if ($success)
1233 1304
 					{
1234 1305
 						$charset = $matches[1];
1235
-					}
1236
-					else
1306
+					} else
1237 1307
 					{
1238 1308
 						// If there is a meta tag, and they don't specify the character set, research says that it's typically ISO-8859-1
1239 1309
 						if (is_object($debug_object)) {$debug_object->debug_log(2, 'meta content-type tag couldn\'t be parsed. using iso-8859 default.');}
@@ -1296,8 +1366,9 @@  discard block
 block discarded – undo
1296 1366
 			$tag = $this->copy_until_char('>');
1297 1367
 
1298 1368
 			// skip attributes in end tag
1299
-			if (($pos = strpos($tag, ' '))!==false)
1300
-				$tag = substr($tag, 0, $pos);
1369
+			if (($pos = strpos($tag, ' '))!==false) {
1370
+							$tag = substr($tag, 0, $pos);
1371
+			}
1301 1372
 
1302 1373
 			$parent_lower = strtolower($this->parent->tag);
1303 1374
 			$tag_lower = strtolower($tag);
@@ -1309,23 +1380,26 @@  discard block
 block discarded – undo
1309 1380
 					$this->parent->_[HDOM_INFO_END] = 0;
1310 1381
 					$org_parent = $this->parent;
1311 1382
 
1312
-					while (($this->parent->parent) && strtolower($this->parent->tag)!==$tag_lower)
1313
-						$this->parent = $this->parent->parent;
1383
+					while (($this->parent->parent) && strtolower($this->parent->tag)!==$tag_lower) {
1384
+											$this->parent = $this->parent->parent;
1385
+					}
1314 1386
 
1315 1387
 					if (strtolower($this->parent->tag)!==$tag_lower) {
1316 1388
 						$this->parent = $org_parent; // restore origonal parent
1317
-						if ($this->parent->parent) $this->parent = $this->parent->parent;
1389
+						if ($this->parent->parent) {
1390
+							$this->parent = $this->parent->parent;
1391
+						}
1318 1392
 						$this->parent->_[HDOM_INFO_END] = $this->cursor;
1319 1393
 						return $this->as_text_node($tag);
1320 1394
 					}
1321
-				}
1322
-				else if (($this->parent->parent) && isset($this->block_tags[$tag_lower]))
1395
+				} else if (($this->parent->parent) && isset($this->block_tags[$tag_lower]))
1323 1396
 				{
1324 1397
 					$this->parent->_[HDOM_INFO_END] = 0;
1325 1398
 					$org_parent = $this->parent;
1326 1399
 
1327
-					while (($this->parent->parent) && strtolower($this->parent->tag)!==$tag_lower)
1328
-						$this->parent = $this->parent->parent;
1400
+					while (($this->parent->parent) && strtolower($this->parent->tag)!==$tag_lower) {
1401
+											$this->parent = $this->parent->parent;
1402
+					}
1329 1403
 
1330 1404
 					if (strtolower($this->parent->tag)!==$tag_lower)
1331 1405
 					{
@@ -1333,18 +1407,19 @@  discard block
 block discarded – undo
1333 1407
 						$this->parent->_[HDOM_INFO_END] = $this->cursor;
1334 1408
 						return $this->as_text_node($tag);
1335 1409
 					}
1336
-				}
1337
-				else if (($this->parent->parent) && strtolower($this->parent->parent->tag)===$tag_lower)
1410
+				} else if (($this->parent->parent) && strtolower($this->parent->parent->tag)===$tag_lower)
1338 1411
 				{
1339 1412
 					$this->parent->_[HDOM_INFO_END] = 0;
1340 1413
 					$this->parent = $this->parent->parent;
1414
+				} else {
1415
+									return $this->as_text_node($tag);
1341 1416
 				}
1342
-				else
1343
-					return $this->as_text_node($tag);
1344 1417
 			}
1345 1418
 
1346 1419
 			$this->parent->_[HDOM_INFO_END] = $this->cursor;
1347
-			if ($this->parent->parent) $this->parent = $this->parent->parent;
1420
+			if ($this->parent->parent) {
1421
+				$this->parent = $this->parent->parent;
1422
+			}
1348 1423
 
1349 1424
 			$this->char = (++$this->pos<$this->size) ? $this->doc[$this->pos] : null; // next
1350 1425
 			return true;
@@ -1367,7 +1442,9 @@  discard block
 block discarded – undo
1367 1442
 				$node->nodetype = HDOM_TYPE_UNKNOWN;
1368 1443
 				$node->tag = 'unknown';
1369 1444
 			}
1370
-			if ($this->char==='>') $node->_[HDOM_INFO_TEXT].='>';
1445
+			if ($this->char==='>') {
1446
+				$node->_[HDOM_INFO_TEXT].='>';
1447
+			}
1371 1448
 			$this->link_nodes($node, true);
1372 1449
 			$this->char = (++$this->pos<$this->size) ? $this->doc[$this->pos] : null; // next
1373 1450
 			return true;
@@ -1389,7 +1466,9 @@  discard block
 block discarded – undo
1389 1466
 				return true;
1390 1467
 			}
1391 1468
 
1392
-			if ($this->char==='>') $node->_[HDOM_INFO_TEXT].='>';
1469
+			if ($this->char==='>') {
1470
+				$node->_[HDOM_INFO_TEXT].='>';
1471
+			}
1393 1472
 			$this->link_nodes($node, false);
1394 1473
 			$this->char = (++$this->pos<$this->size) ? $this->doc[$this->pos] : null; // next
1395 1474
 			return true;
@@ -1455,22 +1534,26 @@  discard block
 block discarded – undo
1455 1534
 			if ($name!=='/' && $name!=='') {
1456 1535
 				$space[1] = $this->copy_skip($this->token_blank);
1457 1536
 				$name = $this->restore_noise($name);
1458
-				if ($this->lowercase) $name = strtolower($name);
1537
+				if ($this->lowercase) {
1538
+					$name = strtolower($name);
1539
+				}
1459 1540
 				if ($this->char==='=') {
1460 1541
 					$this->char = (++$this->pos<$this->size) ? $this->doc[$this->pos] : null; // next
1461 1542
 					$this->parse_attr($node, $name, $space);
1462
-				}
1463
-				else {
1543
+				} else {
1464 1544
 					//no value attr: nowrap, checked selected...
1465 1545
 					$node->_[HDOM_INFO_QUOTE][] = HDOM_QUOTE_NO;
1466 1546
 					$node->attr[$name] = true;
1467
-					if ($this->char!='>') $this->char = $this->doc[--$this->pos]; // prev
1547
+					if ($this->char!='>') {
1548
+						$this->char = $this->doc[--$this->pos];
1549
+					}
1550
+					// prev
1468 1551
 				}
1469 1552
 				$node->_[HDOM_INFO_SPACE][] = $space;
1470 1553
 				$space = array($this->copy_skip($this->token_blank), '', '');
1554
+			} else {
1555
+							break;
1471 1556
 			}
1472
-			else
1473
-				break;
1474 1557
 		} while ($this->char!=='>' && $this->char!=='/');
1475 1558
 
1476 1559
 		$this->link_nodes($node, true);
@@ -1481,11 +1564,12 @@  discard block
 block discarded – undo
1481 1564
 		{
1482 1565
 			$node->_[HDOM_INFO_ENDSPACE] .= '/';
1483 1566
 			$node->_[HDOM_INFO_END] = 0;
1484
-		}
1485
-		else
1567
+		} else
1486 1568
 		{
1487 1569
 			// reset parent
1488
-			if (!isset($this->self_closing_tags[strtolower($node->tag)])) $this->parent = $node;
1570
+			if (!isset($this->self_closing_tags[strtolower($node->tag)])) {
1571
+				$this->parent = $node;
1572
+			}
1489 1573
 		}
1490 1574
 		$this->char = (++$this->pos<$this->size) ? $this->doc[$this->pos] : null; // next
1491 1575
 
@@ -1571,7 +1655,9 @@  discard block
 block discarded – undo
1571 1655
 		$len = strspn($this->doc, $chars, $pos);
1572 1656
 		$this->pos += $len;
1573 1657
 		$this->char = ($this->pos<$this->size) ? $this->doc[$this->pos] : null; // next
1574
-		if ($len===0) return '';
1658
+		if ($len===0) {
1659
+			return '';
1660
+		}
1575 1661
 		return substr($this->doc, $pos, $len);
1576 1662
 	}
1577 1663
 
@@ -1586,7 +1672,9 @@  discard block
 block discarded – undo
1586 1672
 
1587 1673
 	protected function copy_until_char($char)
1588 1674
 	{
1589
-		if ($this->char===null) return '';
1675
+		if ($this->char===null) {
1676
+			return '';
1677
+		}
1590 1678
 
1591 1679
 		if (($pos = strpos($this->doc, $char, $this->pos))===false) {
1592 1680
 			$ret = substr($this->doc, $this->pos, $this->size-$this->pos);
@@ -1595,7 +1683,9 @@  discard block
 block discarded – undo
1595 1683
 			return $ret;
1596 1684
 		}
1597 1685
 
1598
-		if ($pos===$this->pos) return '';
1686
+		if ($pos===$this->pos) {
1687
+			return '';
1688
+		}
1599 1689
 		$pos_old = $this->pos;
1600 1690
 		$this->char = $this->doc[$pos];
1601 1691
 		$this->pos = $pos;
@@ -1604,7 +1694,9 @@  discard block
 block discarded – undo
1604 1694
 
1605 1695
 	protected function copy_until_char_escape($char)
1606 1696
 	{
1607
-		if ($this->char===null) return '';
1697
+		if ($this->char===null) {
1698
+			return '';
1699
+		}
1608 1700
 
1609 1701
 		$start = $this->pos;
1610 1702
 		while (1)
@@ -1617,7 +1709,9 @@  discard block
 block discarded – undo
1617 1709
 				return $ret;
1618 1710
 			}
1619 1711
 
1620
-			if ($pos===$this->pos) return '';
1712
+			if ($pos===$this->pos) {
1713
+				return '';
1714
+			}
1621 1715
 
1622 1716
 			if ($this->doc[$pos-1]==='\\') {
1623 1717
 				$start = $pos+1;
@@ -1674,14 +1768,12 @@  discard block
 block discarded – undo
1674 1768
 				if (isset($this->noise[$key]))
1675 1769
 				{
1676 1770
 					$text = substr($text, 0, $pos).$this->noise[$key].substr($text, $pos+16);
1677
-				}
1678
-				else
1771
+				} else
1679 1772
 				{
1680 1773
 					// do this to prevent an infinite loop.
1681 1774
 					$text = substr($text, 0, $pos).'UNDEFINED NOISE FOR KEY: '.$key . substr($text, $pos+16);
1682 1775
 				}
1683
-			}
1684
-			else
1776
+			} else
1685 1777
 			{
1686 1778
 				// There is no valid key being given back to us... We must get rid of the ___noise___ or we will have a problem.
1687 1779
 				$text = substr($text, 0, $pos).'NO NUMERIC NOISE KEY' . substr($text, $pos+11);
Please login to merge, or discard this patch.
Doc Comments   +40 added lines patch added patch discarded remove patch
@@ -125,6 +125,9 @@  discard block
 block discarded – undo
125 125
 	public $tag_start = 0;
126 126
 	private $dom = null;
127 127
 
128
+	/**
129
+	 * @param simple_html_dom $dom
130
+	 */
128 131
 	function __construct($dom)
129 132
 	{
130 133
 		$this->dom = $dom;
@@ -1501,6 +1504,11 @@  discard block
 block discarded – undo
1501 1504
 	}
1502 1505
 
1503 1506
 	// parse attributes
1507
+
1508
+	/**
1509
+	 * @param simple_html_dom_node $node
1510
+	 * @param string[] $space
1511
+	 */
1504 1512
 	protected function parse_attr($node, $name, &$space)
1505 1513
 	{
1506 1514
 		// Per sourceforge: http://sourceforge.net/tracker/?func=detail&aid=3061408&group_id=218559&atid=1044037
@@ -1538,6 +1546,11 @@  discard block
 block discarded – undo
1538 1546
 	}
1539 1547
 
1540 1548
 	// link node's parent
1549
+
1550
+	/**
1551
+	 * @param simple_html_dom_node $node
1552
+	 * @param boolean $is_child
1553
+	 */
1541 1554
 	protected function link_nodes(&$node, $is_child)
1542 1555
 	{
1543 1556
 		$node->parent = $this->parent;
@@ -1549,6 +1562,10 @@  discard block
 block discarded – undo
1549 1562
 	}
1550 1563
 
1551 1564
 	// as a text node
1565
+
1566
+	/**
1567
+	 * @param string $tag
1568
+	 */
1552 1569
 	protected function as_text_node($tag)
1553 1570
 	{
1554 1571
 		$node = new simple_html_dom_node($this);
@@ -1559,12 +1576,18 @@  discard block
 block discarded – undo
1559 1576
 		return true;
1560 1577
 	}
1561 1578
 
1579
+	/**
1580
+	 * @param string $chars
1581
+	 */
1562 1582
 	protected function skip($chars)
1563 1583
 	{
1564 1584
 		$this->pos += strspn($this->doc, $chars, $this->pos);
1565 1585
 		$this->char = ($this->pos<$this->size) ? $this->doc[$this->pos] : null; // next
1566 1586
 	}
1567 1587
 
1588
+	/**
1589
+	 * @param string $chars
1590
+	 */
1568 1591
 	protected function copy_skip($chars)
1569 1592
 	{
1570 1593
 		$pos = $this->pos;
@@ -1575,6 +1598,9 @@  discard block
 block discarded – undo
1575 1598
 		return substr($this->doc, $pos, $len);
1576 1599
 	}
1577 1600
 
1601
+	/**
1602
+	 * @param string $chars
1603
+	 */
1578 1604
 	protected function copy_until($chars)
1579 1605
 	{
1580 1606
 		$pos = $this->pos;
@@ -1584,6 +1610,9 @@  discard block
 block discarded – undo
1584 1610
 		return substr($this->doc, $pos, $len);
1585 1611
 	}
1586 1612
 
1613
+	/**
1614
+	 * @param string $char
1615
+	 */
1587 1616
 	protected function copy_until_char($char)
1588 1617
 	{
1589 1618
 		if ($this->char===null) return '';
@@ -1602,6 +1631,9 @@  discard block
 block discarded – undo
1602 1631
 		return substr($this->doc, $pos_old, $pos-$pos_old);
1603 1632
 	}
1604 1633
 
1634
+	/**
1635
+	 * @param string $char
1636
+	 */
1605 1637
 	protected function copy_until_char_escape($char)
1606 1638
 	{
1607 1639
 		if ($this->char===null) return '';
@@ -1633,6 +1665,10 @@  discard block
 block discarded – undo
1633 1665
 
1634 1666
 	// remove noise from html content
1635 1667
 	// save the noise in the $this->noise array.
1668
+
1669
+	/**
1670
+	 * @param string $pattern
1671
+	 */
1636 1672
 	protected function remove_noise($pattern, $remove_tag=false)
1637 1673
 	{
1638 1674
 		global $debug_object;
@@ -1658,6 +1694,10 @@  discard block
 block discarded – undo
1658 1694
 	}
1659 1695
 
1660 1696
 	// restore noise to html content
1697
+
1698
+	/**
1699
+	 * @param string|null $text
1700
+	 */
1661 1701
 	function restore_noise($text)
1662 1702
 	{
1663 1703
 		global $debug_object;
Please login to merge, or discard this patch.