Completed
Push — master ( e17801...597a61 )
by Yannick
25:55
created
notam-geojson.php 1 patch
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -74,7 +74,9 @@
 block discarded – undo
74 74
 			$radius = $spotter_item['radius']*1852;
75 75
 			$output .= '"radiusm": "'.$radius.'",';
76 76
 			$output .= '"radiusnm": "'.$spotter_item['radius'].'",';
77
-			if ($radius > 25000) $radius = 25000;
77
+			if ($radius > 25000) {
78
+				$radius = 25000;
79
+			}
78 80
 			$output .= '"radius": '.$radius.'';
79 81
 		    $output .= '},';
80 82
 		    $output .= '"geometry": {';
Please login to merge, or discard this patch.
manufacturer-statistics-arrival-airport.php 1 patch
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -22,7 +22,9 @@
 block discarded – undo
22 22
 	print '<select name="aircraft_manufacturer" class="selectpicker" data-live-search="true">';
23 23
 	$Stats = new Stats();
24 24
 	$all_manufacturers = $Stats->getAllManufacturers();
25
-	if (empty($all_manufacturers)) $all_manufacturers = $Spotter->getAllManufacturers();
25
+	if (empty($all_manufacturers)) {
26
+		$all_manufacturers = $Spotter->getAllManufacturers();
27
+	}
26 28
 	foreach($all_manufacturers as $all_manufacturer)
27 29
 	{
28 30
 		if($_GET['aircraft_manufacturer'] == strtolower(str_replace(" ", "-", $all_manufacturer['aircraft_manufacturer'])))
Please login to merge, or discard this patch.
date-statistics-aircraft.php 1 patch
Braces   +5 added lines, -2 removed lines patch added patch discarded remove patch
@@ -5,8 +5,11 @@
 block discarded – undo
5 5
 $Spotter = new Spotter();
6 6
 $sort = filter_input(INPUT_GET,'sort',FILTER_SANITIZE_STRING);
7 7
 $date = filter_input(INPUT_GET,'date',FILTER_SANITIZE_STRING);
8
-if (isset($_GET['date'])) $spotter_array = $Spotter->getSpotterDataByDate($date,"0,1", $sort);
9
-else $spotter_array = array();
8
+if (isset($_GET['date'])) {
9
+	$spotter_array = $Spotter->getSpotterDataByDate($date,"0,1", $sort);
10
+} else {
11
+	$spotter_array = array();
12
+}
10 13
 
11 14
 if (!empty($spotter_array))
12 15
 {
Please login to merge, or discard this patch.
accident-detailed.php 1 patch
Braces   +6 added lines, -2 removed lines patch added patch discarded remove patch
@@ -58,8 +58,12 @@
 block discarded – undo
58 58
 if (!empty($spotter_array) && isset($spotter_array[0]['query_number_rows']) && $spotter_array[0]['query_number_rows'] != 0) {
59 59
 	include('table-output.php');
60 60
 	print '<div class="pagination">';
61
-	if ($limit_previous_1 >= 0) print '<a href="'.$page_url.'/'.$limit_previous_1.','.$limit_previous_2.'">&laquo;'._("Previous Page").'</a>';
62
-	if ($spotter_array[0]['query_number_rows'] == $absolute_difference) print '<a href="'.$page_url.'/'.$limit_end.','.$limit_next.'">'._("Next Page").'&raquo;</a>';
61
+	if ($limit_previous_1 >= 0) {
62
+		print '<a href="'.$page_url.'/'.$limit_previous_1.','.$limit_previous_2.'">&laquo;'._("Previous Page").'</a>';
63
+	}
64
+	if ($spotter_array[0]['query_number_rows'] == $absolute_difference) {
65
+		print '<a href="'.$page_url.'/'.$limit_end.','.$limit_next.'">'._("Next Page").'&raquo;</a>';
66
+	}
63 67
 	print '</div>';
64 68
 }
65 69
 print '</div>';
Please login to merge, or discard this patch.
manufacturer-statistics-arrival-airport-country.php 1 patch
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -22,7 +22,9 @@
 block discarded – undo
22 22
 	print '<select name="aircraft_manufacturer" class="selectpicker" data-live-search="true">';
23 23
 	$Stats = new Stats();
24 24
 	$all_manufacturers = $Stats->getAllManufacturers();
25
-	if (empty($all_manufacturers)) $all_manufacturers = $Spotter->getAllManufacturers();
25
+	if (empty($all_manufacturers)) {
26
+		$all_manufacturers = $Spotter->getAllManufacturers();
27
+	}
26 28
 	foreach($all_manufacturers as $all_manufacturer)
27 29
 	{
28 30
 		if($_GET['aircraft_manufacturer'] == strtolower(str_replace(" ", "-", $all_manufacturer['aircraft_manufacturer'])))
Please login to merge, or discard this patch.
aircraft-statistics-time.php 1 patch
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -22,7 +22,9 @@
 block discarded – undo
22 22
 	print '<option></option>';
23 23
 	$Stats = new Stats();
24 24
 	$aircraft_types = $Stats->getAllAircraftTypes();
25
-	if (empty($aircraft_types)) $aircraft_types = $Spotter->getAllAircraftTypes();
25
+	if (empty($aircraft_types)) {
26
+		$aircraft_types = $Spotter->getAllAircraftTypes();
27
+	}
26 28
 	foreach($aircraft_types as $aircraft_type)
27 29
 	{
28 30
 		if($aircraft_type == $aircrafttype['aircraft_icao'])
Please login to merge, or discard this patch.
live-santa-geojson.php 1 patch
Braces   +5 added lines, -2 removed lines patch added patch discarded remove patch
@@ -8,8 +8,11 @@
 block discarded – undo
8 8
 }
9 9
 header('Content-Type: text/javascript');
10 10
 $timearray = array();
11
-if (isset($_GET['now'])) $begin = time();
12
-else $begin = strtotime(date("Y").'-12-24T02:00:00Z');
11
+if (isset($_GET['now'])) {
12
+	$begin = time();
13
+} else {
14
+	$begin = strtotime(date("Y").'-12-24T02:00:00Z');
15
+}
13 16
 for ($i =0; $i <= 288; $i++) {
14 17
 	$timearray[] = ($begin + $i*300)*1000;
15 18
 }
Please login to merge, or discard this patch.
require/class.Scheduler.php 1 patch
Braces   +164 added lines, -56 removed lines patch added patch discarded remove patch
@@ -123,7 +123,9 @@  discard block
 block discarded – undo
123 123
 		$sth->closeCursor();
124 124
 		if (count($row) > 0) {
125 125
 			return $row;
126
-		} else return array();
126
+		} else {
127
+			return array();
128
+		}
127 129
 	}
128 130
 
129 131
 	public function checkSchedule($ident) {
@@ -159,7 +161,9 @@  discard block
 block discarded – undo
159 161
 		$Common = new Common();
160 162
 		$check_date = new Datetime($date);
161 163
 		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
162
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
164
+		if (!filter_var($numvol,FILTER_VALIDATE_INT)) {
165
+			return array();
166
+		}
163 167
 		$url = "http://www.airfrance.fr/cgi-bin/AF/FR/fr/local/resainfovol/infovols/detailsVolJson.do?codeCompagnie[0]=".$carrier."&numeroVol[0]=".$numvol."&dayFlightDate=".$check_date->format('d')."&yearMonthFlightDate=".$check_date->format('Ym');
164 168
 		$json = $Common->getData($url);
165 169
 	
@@ -186,7 +190,9 @@  discard block
 block discarded – undo
186 190
 			*/
187 191
 		
188 192
 			return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_airfrance');
189
-		} else return array();
193
+		} else {
194
+			return array();
195
+		}
190 196
 	}
191 197
 
192 198
 	/**
@@ -201,7 +207,9 @@  discard block
 block discarded – undo
201 207
 		date_default_timezone_set($globalTimezone);
202 208
 		$check_date = new Datetime($date);
203 209
 		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
204
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
210
+		if (!filter_var($numvol,FILTER_VALIDATE_INT)) {
211
+			return array();
212
+		}
205 213
 		$url = "http://www.easyjet.com/ft/api/flights?date=".$check_date->format('Y-m-d')."&fn=".$callsign;
206 214
 		$json = $Common->getData($url);
207 215
 		$parsed_json = json_decode($json);
@@ -214,7 +222,9 @@  discard block
 block discarded – undo
214 222
 			$arrivalTime = $parsed_json->{'flights'}[0]->{'dates'}->{'fsta'};
215 223
 
216 224
 			return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_easyjet');
217
-		} else return array();
225
+		} else {
226
+			return array();
227
+		}
218 228
 	}
219 229
 
220 230
 	/**
@@ -225,7 +235,9 @@  discard block
 block discarded – undo
225 235
 	private function getRyanair($callsign) {
226 236
 		$Common = new Common();
227 237
 		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
228
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
238
+		if (!filter_var($numvol,FILTER_VALIDATE_INT)) {
239
+			return array();
240
+		}
229 241
 		$url = "http://www.ryanair.com/fr/api/2/flight-info/0/50/";
230 242
 		$post = '{"flight":"'.$numvol.'","minDepartureTime":"00:00","maxDepartureTime":"23:59"}';
231 243
 		$headers = array('Content-Type: application/json','Content-Length: ' . strlen($post));
@@ -239,8 +251,12 @@  discard block
 block discarded – undo
239 251
 				$departureTime = $parsed_json->{'flightInfo'}[0]->{'departureTime'};
240 252
 				$arrivalTime = $parsed_json->{'flightInfo'}[0]->{'arrivalTime'};
241 253
 				return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime, 'Source' => 'website_ryanair');
242
-			} else return array();
243
-		} else return array();
254
+			} else {
255
+				return array();
256
+			}
257
+		} else {
258
+			return array();
259
+		}
244 260
 	}
245 261
 
246 262
 	/**
@@ -251,7 +267,9 @@  discard block
 block discarded – undo
251 267
 	private function getSwiss($callsign) {
252 268
 		$Common = new Common();
253 269
 		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
254
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
270
+		if (!filter_var($numvol,FILTER_VALIDATE_INT)) {
271
+			return array();
272
+		}
255 273
 		$url = "http://www.world-of-swiss.com/fr/routenetwork.json";
256 274
 		$json = $Common->getData($url);
257 275
 		$parsed_json = json_decode($json);
@@ -271,8 +289,12 @@  discard block
 block discarded – undo
271 289
 			}
272 290
 			if (isset($DepartureAirportIata) && isset($ArrivalAirportIata)) {
273 291
 				return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_swiss');
274
-			} else return array();
275
-		} else return array();
292
+			} else {
293
+				return array();
294
+			}
295
+		} else {
296
+			return array();
297
+		}
276 298
 	}
277 299
 	
278 300
 	/**
@@ -286,12 +308,18 @@  discard block
 block discarded – undo
286 308
 		$Common = new Common();
287 309
 		$check_date = new Datetime($date);
288 310
 		$numvol = sprintf('%04d',preg_replace('/^[A-Z]*/','',$callsign));
289
-		if (!filter_var(preg_replace('/^[A-Z]*/','',$callsign),FILTER_VALIDATE_INT)) return array();
290
-		if ($globalBritishAirwaysKey == '') return array();
311
+		if (!filter_var(preg_replace('/^[A-Z]*/','',$callsign),FILTER_VALIDATE_INT)) {
312
+			return array();
313
+		}
314
+		if ($globalBritishAirwaysKey == '') {
315
+			return array();
316
+		}
291 317
 		$url = "https://api.ba.com/rest-v1/v1/flights;flightNumber=".$numvol.";scheduledDepartureDate=".$check_date->format('Y-m-d').".json";
292 318
 		$headers = array('Client-Key: '.$globalBritishAirwaysKey);
293 319
 		$json = $Common->getData($url,'get','',$headers);
294
-		if ($json == '') return array();
320
+		if ($json == '') {
321
+			return array();
322
+		}
295 323
 		$parsed_json = json_decode($json);
296 324
 		$flights = $parsed_json->{'FlightsResponse'};
297 325
 		if (count($flights) > 0) {
@@ -300,7 +328,9 @@  discard block
 block discarded – undo
300 328
 			$departureTime = date('H:i',strtotime($parsed_json->{'FlightsResponse'}->{'Flight'}->{'Sector'}->{'ScheduledDepartureDateTime'}));
301 329
 			$arrivalTime = date('H:i',strtotime($parsed_json->{'FlightsResponse'}->{'Flight'}->{'Sector'}->{'ScheduledArrivalDateTime'}));
302 330
 			return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_britishairways');
303
-		} else return array();
331
+		} else {
332
+			return array();
333
+		}
304 334
 	}
305 335
 
306 336
 	/**
@@ -314,19 +344,27 @@  discard block
 block discarded – undo
314 344
 		$Common = new Common();
315 345
 		$check_date = new Datetime($date);
316 346
 		$numvol = sprintf('%04d',preg_replace('/^[A-Z]*/','',$callsign));
317
-		if (!filter_var(preg_replace('/^[A-Z]*/','',$callsign),FILTER_VALIDATE_INT)) return array();
318
-		if (!isset($globalLufthansaKey) || $globalLufthansaKey == '' || !isset($globalLufthansaKey['key']) || $globalLufthansaKey['key'] == '') return array();
347
+		if (!filter_var(preg_replace('/^[A-Z]*/','',$callsign),FILTER_VALIDATE_INT)) {
348
+			return array();
349
+		}
350
+		if (!isset($globalLufthansaKey) || $globalLufthansaKey == '' || !isset($globalLufthansaKey['key']) || $globalLufthansaKey['key'] == '') {
351
+			return array();
352
+		}
319 353
 		$url = "https://api.lufthansa.com/v1/oauth/token";
320 354
 		$post = array('client_id' => $globalLufthansaKey['key'],'client_secret' => $globalLufthansaKey['secret'],'grant_type' => 'client_credentials');
321 355
 		$data = $Common->getData($url,'post',$post);
322 356
 		$parsed_data = json_decode($data);
323
-		if (!isset($parsed_data->{'access_token'})) return array();
357
+		if (!isset($parsed_data->{'access_token'})) {
358
+			return array();
359
+		}
324 360
 		$token = $parsed_data->{'access_token'};
325 361
 		
326 362
 		$url = "https://api.lufthansa.com/v1/operations/flightstatus/LH".$numvol."/".$check_date->format('Y-m-d');
327 363
 		$headers = array('Authorization: Bearer '.$token,'Accept: application/json');
328 364
 		$json = $Common->getData($url,'get','',$headers);
329
-		if ($json == '') return array();
365
+		if ($json == '') {
366
+			return array();
367
+		}
330 368
 		$parsed_json = json_decode($json);
331 369
 		if (isset($parsed_json->{'FlightStatusResource'}) && count($parsed_json->{'FlightStatusResource'}) > 0) {
332 370
 			$DepartureAirportIata = $parsed_json->{'FlightStatusResource'}->{'Flights'}->{'Flight'}->{'Departure'}->{'AirportCode'};
@@ -334,7 +372,9 @@  discard block
 block discarded – undo
334 372
 			$ArrivalAirportIata = $parsed_json->{'FlightStatusResource'}->{'Flights'}->{'Flight'}->{'Arrival'}->{'AirportCode'};
335 373
 			$arrivalTime = date('H:i',strtotime($parsed_json->{'FlightStatusResource'}->{'Flights'}->{'Flight'}->{'Arrival'}->{'ScheduledTimeLocal'}->{'DateTime'}));
336 374
 			return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_lufthansa');
337
-		} else return array();
375
+		} else {
376
+			return array();
377
+		}
338 378
 	}
339 379
 
340 380
 	/**
@@ -348,14 +388,20 @@  discard block
 block discarded – undo
348 388
 		$Common = new Common();
349 389
 		$check_date = new Datetime($date);
350 390
 		$numvol = sprintf('%04d',preg_replace('/^[A-Z]*/','',$callsign));
351
-		if (!filter_var(preg_replace('/^[A-Z]*/','',$callsign),FILTER_VALIDATE_INT)) return array();
352
-		if ($globalTransaviaKey == '') return array();
391
+		if (!filter_var(preg_replace('/^[A-Z]*/','',$callsign),FILTER_VALIDATE_INT)) {
392
+			return array();
393
+		}
394
+		if ($globalTransaviaKey == '') {
395
+			return array();
396
+		}
353 397
 		$url = "https://tst.api.transavia.com/v1/flightstatus/departuredate/".$check_date->format('Ymd').'/flightnumber/HV'.$numvol;
354 398
 		//$url = "https://api.transavia.com/v1/flightstatus/departuredate/".$check_date->format('Ymd').'/flightnumber/HV'.$numvol;
355 399
 		$headers = array('apikey: '.$globalTransaviaKey);
356 400
 		$json = $Common->getData($url,'get','',$headers);
357 401
 		//echo 'result : '.$json;
358
-		if ($json == '') return array();
402
+		if ($json == '') {
403
+			return array();
404
+		}
359 405
 		$parsed_json = json_decode($json);
360 406
 		
361 407
 		if (isset($parsed_json->{'data'}[0])) {
@@ -364,7 +410,9 @@  discard block
 block discarded – undo
364 410
 			$ArrivalAirportIata = $parsed_json->{'data'}[0]->{'flight'}->{'arrivalAirport'}->{'locationCode'};
365 411
 			$arrivalTime = date('H:i',strtotime($parsed_json->{'data'}[0]->{'flight'}->{'arrivalDateTime'}));
366 412
 			return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_transavia');
367
-		} else return array();
413
+		} else {
414
+			return array();
415
+		}
368 416
 	}
369 417
 
370 418
 	/**
@@ -375,7 +423,9 @@  discard block
 block discarded – undo
375 423
 	public function getTunisair($callsign) {
376 424
 		$Common = new Common();
377 425
 		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
378
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
426
+		if (!filter_var($numvol,FILTER_VALIDATE_INT)) {
427
+			return array();
428
+		}
379 429
 		$url = "http://www.tunisair.com/site/publish/module/Volj/fr/Flight_List.asp";
380 430
 		$data = $Common->getData($url);
381 431
 		$table = $Common->table2array($data);
@@ -396,7 +446,9 @@  discard block
 block discarded – undo
396 446
 		$Common = new Common();
397 447
 		$check_date = new Datetime($date);
398 448
 		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
399
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
449
+		if (!filter_var($numvol,FILTER_VALIDATE_INT)) {
450
+			return array();
451
+		}
400 452
 		$final_date = str_replace('/','%2F',$check_date->format('d/m/Y'));
401 453
 		$url = "http://www.vueling.com/Base/BaseProxy/RenderMacro/?macroalias=FlightStatusResult&searchBy=bycode&date=".$final_date."&flightNumber=".$numvol."&idioma=en-GB";
402 454
 		$data = $Common->getData($url);
@@ -406,8 +458,11 @@  discard block
 block discarded – undo
406 458
 			$DepartureAirportIata = str_replace('flightOri=','',$result[0]);
407 459
 			preg_match('/flightDest=[A-Z]{3}/',$data,$result);
408 460
 			$ArrivalAirportIata = str_replace('flightDest=','',$result[0]);
409
-			if ($DepartureAirportIata != '' && $ArrivalAirportIata != '') return array('DepartureAirportIATA' => $DepartureAirportIata,'ArrivalAirportIATA' => $ArrivalAirportIata,'Source' => 'website_vueling');
410
-			else return array();
461
+			if ($DepartureAirportIata != '' && $ArrivalAirportIata != '') {
462
+				return array('DepartureAirportIATA' => $DepartureAirportIata,'ArrivalAirportIATA' => $ArrivalAirportIata,'Source' => 'website_vueling');
463
+			} else {
464
+				return array();
465
+			}
411 466
 		}
412 467
 		return array();
413 468
 	}
@@ -422,7 +477,9 @@  discard block
 block discarded – undo
422 477
 		$Common = new Common();
423 478
 		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
424 479
 		$check_date = new Datetime($date);
425
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
480
+		if (!filter_var($numvol,FILTER_VALIDATE_INT)) {
481
+			return array();
482
+		}
426 483
 		$url = "https://www.iberia.com/web/flightDetail.do";
427 484
 		$post = array('numvuelo' => $numvol,'fecha' => $check_date->format('Ymd'),'airlineID' => 'IB');
428 485
 		$data = $Common->getData($url,'post',$post);
@@ -439,7 +496,9 @@  discard block
 block discarded – undo
439 496
 				$arrivalTime = trim(str_replace(' lunes','',str_replace('&nbsp;','',$flight[5][1])));
440 497
 				if ($arrivalTime == 'Hora estimada de llegada') {
441 498
 					$arrivalTime = substr(trim(str_replace(' lunes','',str_replace('&nbsp;','',$flight[5][2]))),0,5);
442
-				} else $arrivalTime = substr($arrivalTime,0,5);
499
+				} else {
500
+					$arrivalTime = substr($arrivalTime,0,5);
501
+				}
443 502
 				return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_iberia');
444 503
 			}
445 504
 		}
@@ -457,7 +516,9 @@  discard block
 block discarded – undo
457 516
 		$Common = new Common();
458 517
 		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
459 518
 		$check_date = new Datetime($date);
460
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
519
+		if (!filter_var($numvol,FILTER_VALIDATE_INT)) {
520
+			return array();
521
+		}
461 522
 		$url = "http://www.staralliance.com/flifoQueryAction.do?myAirline=&airlineCode=".$carrier."&flightNo=".$numvol."&day=".$check_date->format('d')."&month=".$check_date->format('m')."&year=".$check_date->format('Y')."&departuredate=".$check_date->format('d-M-Y');
462 523
 		$data = $Common->getData($url);
463 524
 		if ($data != '') {
@@ -473,7 +534,9 @@  discard block
 block discarded – undo
473 534
 					$departureTime = substr(trim(str_replace('Scheduled: ','',$flight[29][0])),0,5);
474 535
 					$arrivalTime = substr(trim(str_replace('Scheduled: ','',$flight[29][1])),0,5);
475 536
 					return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_staralliance');
476
-				} else return array();
537
+				} else {
538
+					return array();
539
+				}
477 540
 			}
478 541
 			
479 542
 
@@ -493,7 +556,9 @@  discard block
 block discarded – undo
493 556
 		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
494 557
 		$check_date = new Datetime($date);
495 558
 		$url= "http://booking.alitalia.com/FlightStatus/fr_fr/FlightInfo?Brand=az&NumeroVolo=".$numvol."&DataCompleta=".$check_date->format('d/m/Y');
496
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
559
+		if (!filter_var($numvol,FILTER_VALIDATE_INT)) {
560
+			return array();
561
+		}
497 562
 		$data = $Common->getData($url);
498 563
 		if ($data != '') {
499 564
 			$table = $Common->text2array($data);
@@ -517,7 +582,9 @@  discard block
 block discarded – undo
517 582
 		$check_date = new Datetime($date);
518 583
 		$url= "http://www.brusselsairlines.com/api/flightstatus/getresults?from=NA&to=NA&date=".$check_date->format('d/m/Y')."&hour=NA&lookup=flightnumber&flightnumber=".$numvol."&publicationID=302";
519 584
 		//http://www.brusselsairlines.com/fr-fr/informations-pratiques/statut-de-votre-vol/resultat.aspx?flightnumber=".$numvol."&date=".$check_date->format('d/m/Y')."&lookup=flightnumber";
520
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
585
+		if (!filter_var($numvol,FILTER_VALIDATE_INT)) {
586
+			return array();
587
+		}
521 588
 		$data = $Common->getData($url);
522 589
 		if ($data != '') {
523 590
 		    //echo $data;
@@ -607,7 +674,9 @@  discard block
 block discarded – undo
607 674
 		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
608 675
 		$url= "http://www.flytap.com/France/fr/PlanifierEtReserver/Outils/DepartsEtArrivees";
609 676
 		//$check_date = new Datetime($date);
610
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
677
+		if (!filter_var($numvol,FILTER_VALIDATE_INT)) {
678
+			return array();
679
+		}
611 680
 		$post = array('arrivalsdepartures_content' => 'number','arrivalsdepartures_tp' => $numvol,'arrivalsdepartures_trk' => 'ARR','arrivalsdepartures_date_trk' => '1','aptCode' => '','arrivalsdepartures' => 'DEP','arrivalsdepartures_date' => '1','aptCodeFrom' => '','aptCodeTo' => '','arrivalsdepartures2' => 'DEP','arrivalsdepartures_date2' => '1');
612 681
 		$data = $Common->getData($url,'post',$post);
613 682
 		if ($data != '') {
@@ -639,11 +708,15 @@  discard block
 block discarded – undo
639 708
 				$airline_icao = substr($callsign, 0, 3);
640 709
 			} 
641 710
 		}
642
-		if ($airline_icao == '') return array();
711
+		if ($airline_icao == '') {
712
+			return array();
713
+		}
643 714
 		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
644 715
 		$url= "http://info.flightmapper.net/flight/".$airline_icao.'_'.$numvol;
645 716
 		//$check_date = new Datetime($date);
646
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
717
+		if (!filter_var($numvol,FILTER_VALIDATE_INT)) {
718
+			return array();
719
+		}
647 720
 		$data = $Common->getData($url);
648 721
 		if ($data != '') {
649 722
 			$table = $Common->table2array($data);
@@ -686,7 +759,9 @@  discard block
 block discarded – undo
686 759
 		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
687 760
 		$url= "http://fr.flightaware.com/live/flight/".$callsign;
688 761
 		//$check_date = new Datetime($date);
689
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
762
+		if (!filter_var($numvol,FILTER_VALIDATE_INT)) {
763
+			return array();
764
+		}
690 765
 		$data = $Common->getData($url);
691 766
 		if ($data != '') {
692 767
 			$table = $Common->table2array($data);
@@ -739,11 +814,15 @@  discard block
 block discarded – undo
739 814
 		$check_date = new Datetime($date);
740 815
 		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
741 816
 		$url= "http://services.aircanada.com/portal/rest/getFlightsByFlightNumber?forceTimetable=true&flightNumber=".$numvol."&carrierCode=AC&date=".$check_date->format('m-d-Y')."&app_key=AE919FDCC80311DF9BABC975DFD72085&cache=74249";
742
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
817
+		if (!filter_var($numvol,FILTER_VALIDATE_INT)) {
818
+			return array();
819
+		}
743 820
 		$data = $Common->getData($url);
744 821
 		$dom = new DomDocument();
745 822
 		$dom->loadXML($data);
746
-		if ($dom->getElementsByTagName('DepartureStationInfo')->length == 0) return array();
823
+		if ($dom->getElementsByTagName('DepartureStationInfo')->length == 0) {
824
+			return array();
825
+		}
747 826
 		$departure = $dom->getElementsByTagName('DepartureStationInfo')->item(0);
748 827
 		if (isset($departure->getElementsByTagName('Airport')->item(0)->firstChild->nodeValue)) {
749 828
 			$DepartureAirportIata = $departure->getElementsByTagName('Airport')->item(0)->firstChild->nodeValue;
@@ -752,7 +831,9 @@  discard block
 block discarded – undo
752 831
 			$ArrivalAirportIata = $arrival->getElementsByTagName('Airport')->item(0)->firstChild->nodeValue;
753 832
 			$arrivalTime = date('H:i',strtotime($arrival->getElementsByTagName('ScheduledTime')->item(0)->firstChild->nodeValue));
754 833
 			return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_aircanada');
755
-		} else return array();
834
+		} else {
835
+			return array();
836
+		}
756 837
 	}
757 838
 
758 839
 	/**
@@ -766,7 +847,9 @@  discard block
 block discarded – undo
766 847
 		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
767 848
 		$check_date = new Datetime($date);
768 849
 		$url= "https://cat.sabresonicweb.com/SSWVN/meridia?posid=VNVN&page=flifoFlightInfoDetailsMessage_learn&action=flightInfoDetails&airline=VN&language=fr&depDay=".$check_date->format('j')."&depMonth=".strtoupper($check_date->format('M'))."&=&flight=".$numvol."&";
769
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
850
+		if (!filter_var($numvol,FILTER_VALIDATE_INT)) {
851
+			return array();
852
+		}
770 853
 		$data = $Common->getData($url);
771 854
 		if ($data != '') {
772 855
 			$table = $Common->table2array($data);
@@ -795,7 +878,9 @@  discard block
 block discarded – undo
795 878
 		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
796 879
 		$check_date = new Datetime($date);
797 880
 		$url= "http://www.airberlin.com/en-US/site/aims.php";
798
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
881
+		if (!filter_var($numvol,FILTER_VALIDATE_INT)) {
882
+			return array();
883
+		}
799 884
 		$post = array('type' => 'departure','searchFlightNo' => '1','requestsent' => 'true', 'flightno' => $numvol,'date' => $check_date->format('Y-m-d'),'carrier' => $carrier);
800 885
 		$data = $Common->getData($url,'post',$post);
801 886
 		//echo $data;
@@ -805,11 +890,19 @@  discard block
 block discarded – undo
805 890
 		if ($data != '') {
806 891
 			$table = $Common->table2array($data);
807 892
 			$flight = $table;
808
-			if (isset($flight[5][4])) $departureTime = $flight[5][4];
809
-			else $departureTime = '';
810
-			if (isset($flight[5][2])) $departureAirport = $flight[5][2];
811
-			else $departureAirport = '';
812
-		} else return array();
893
+			if (isset($flight[5][4])) {
894
+				$departureTime = $flight[5][4];
895
+			} else {
896
+				$departureTime = '';
897
+			}
898
+			if (isset($flight[5][2])) {
899
+				$departureAirport = $flight[5][2];
900
+			} else {
901
+				$departureAirport = '';
902
+			}
903
+		} else {
904
+			return array();
905
+		}
813 906
 		$post = array('type' => 'arrival','searchFlightNo' => '1','requestsent' => 'true', 'flightno' => $numvol,'date' => $check_date->format('Y-m-d'),'carrier' => 'AB');
814 907
 		$data = $Common->getData($url,'post',$post);
815 908
 		if ($data != '') {
@@ -822,10 +915,14 @@  discard block
 block discarded – undo
822 915
 			    $arrivalTime = '';
823 916
 			    $arrivalAirport = '';
824 917
 			}
825
-		} else return array();
918
+		} else {
919
+			return array();
920
+		}
826 921
 		$url = 'http://www.airberlin.com/en-US/site/json/suggestAirport.php?searchfor=departures&searchflightid=0&departures%5B%5D=&suggestsource%5B0%5D=activeairports&withcountries=0&withoutroutings=0&promotion%5Bid%5D=&promotion%5Btype%5D=&routesource%5B0%5D=airberlin&routesource%5B1%5D=partner';
827 922
 		$json = $Common->getData($url);
828
-		if ($json == '') return array();
923
+		if ($json == '') {
924
+			return array();
925
+		}
829 926
 		$parsed_json = json_decode($json);
830 927
 		$airports = $parsed_json->{'suggestList'};
831 928
 		if (count($airports) > 0) {
@@ -840,7 +937,9 @@  discard block
 block discarded – undo
840 937
 		}
841 938
 		if (isset($DepartureAirportIata)) {
842 939
 			return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_airberlin');
843
-		} else return array();
940
+		} else {
941
+			return array();
942
+		}
844 943
 	}
845 944
 
846 945
 
@@ -848,7 +947,9 @@  discard block
 block discarded – undo
848 947
 	public function fetchSchedule($ident,$date = 'NOW') {
849 948
 		global $globalSchedulesSources, $globalSchedulesFetch;
850 949
 		//$Common = new Common();
851
-		if (!$globalSchedulesFetch) return array();
950
+		if (!$globalSchedulesFetch) {
951
+			return array();
952
+		}
852 953
 		$airline_icao = '';
853 954
 		if (!is_numeric(substr($ident, 0, 3)))
854 955
 		{
@@ -1076,14 +1177,21 @@  discard block
 block discarded – undo
1076 1177
 				default:
1077 1178
 					// Randomly use a generic function to get hours
1078 1179
 					if (strlen($airline_icao) == 2) {
1079
-						if (!isset($globalSchedulesSources)) $globalSchedulesSources = array('flightmapper','costtotravel','flightradar24','flightaware');
1180
+						if (!isset($globalSchedulesSources)) {
1181
+							$globalSchedulesSources = array('flightmapper','costtotravel','flightradar24','flightaware');
1182
+						}
1080 1183
 						if (count($globalSchedulesSources) > 0) {
1081 1184
 							$rand = mt_rand(0,count($globalSchedulesSources)-1);
1082 1185
 							$source = $globalSchedulesSources[$rand];
1083
-							if ($source == 'flightmapper') return $this->getFlightMapper($ident);
1084
-							elseif ($source == 'costtotravel') return $this->getCostToTravel($ident);
1186
+							if ($source == 'flightmapper') {
1187
+								return $this->getFlightMapper($ident);
1188
+							} elseif ($source == 'costtotravel') {
1189
+								return $this->getCostToTravel($ident);
1190
+							}
1085 1191
 							//elseif ($source == 'flightradar24') return $this->getFlightRadar24($ident,$date);
1086
-							elseif ($source == 'flightaware') return $this->getFlightAware($ident);
1192
+							elseif ($source == 'flightaware') {
1193
+								return $this->getFlightAware($ident);
1194
+							}
1087 1195
 						}
1088 1196
 					}
1089 1197
 			}
Please login to merge, or discard this patch.
require/libs/simple_html_dom.php 1 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.