Completed
Push — master ( 73f088...7f17b6 )
by Yannick
07:13
created
require/settings.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -29,7 +29,7 @@  discard block
 block discarded – undo
29 29
 $globalLongitudeMin = '1.0'; //the minimum longitude (east)
30 30
 
31 31
 $globalCenterLatitude = '46.38'; //the latitude center of your coverage area
32
-$globalCenterLongitude = '5.29';//the longitude center of your coverage area
32
+$globalCenterLongitude = '5.29'; //the longitude center of your coverage area
33 33
 
34 34
 $globalLiveZoom = '9'; //default zoom on Live Map
35 35
 
@@ -126,7 +126,7 @@  discard block
 block discarded – undo
126 126
 $globalACARS = FALSE;
127 127
 $globalACARSHost = '0.0.0.0'; // Local IP to listen
128 128
 $globalACARSPort = '9999';
129
-$globalACARSArchive = array('10','80','81','82','3F'); // labels of messages to archive
129
+$globalACARSArchive = array('10', '80', '81', '82', '3F'); // labels of messages to archive
130 130
 $globalACARSArchiveKeepMonths = '0';
131 131
 
132 132
 //APRS configuration (for glidernet)
@@ -201,7 +201,7 @@  discard block
 block discarded – undo
201 201
 //Retrieve Image from externals sources
202 202
 $globalAircraftImageFetch = TRUE;
203 203
 //Sources for Aircraft image
204
-$globalAircraftImageSources = array('ivaomtl','wikimedia','airportdata','deviantart','flickr','bing','jetphotos','planepictures','planespotters','customsources');
204
+$globalAircraftImageSources = array('ivaomtl', 'wikimedia', 'airportdata', 'deviantart', 'flickr', 'bing', 'jetphotos', 'planepictures', 'planespotters', 'customsources');
205 205
 // Custom source configuration {registration} will be replaced by aircraft registration (exif get copyright from exif data for each pic)
206 206
 // example of config : $globalAircraftImageCustomSources = array('thumbnail' => 'http://pics.myurl.com/thumbnail/{registration}.jpg','original' => 'http://myurl/original/{registration}.jpg','source_website' => 'https://www.myurl.com', 'source' => 'customsite', 'exif' => true);
207 207
 // ************************
@@ -209,7 +209,7 @@  discard block
 block discarded – undo
209 209
 //Retrieve schedules from externals sources (set to FALSE for IVAO or if $globalFork = FALSE)
210 210
 $globalSchedulesFetch = TRUE;
211 211
 //Sources for airline schedule if not official airline site
212
-$globalSchedulesSources = array('flightmapper','costtotravel','flightradar24','flightaware');
212
+$globalSchedulesSources = array('flightmapper', 'costtotravel', 'flightradar24', 'flightaware');
213 213
 
214 214
 //Retrieve translation from external sources (set to FALSE for IVAO)
215 215
 $globalTranslationFetch = TRUE;
Please login to merge, or discard this patch.
require/class.SBS.php 1 patch
Spacing   +50 added lines, -50 removed lines patch added patch discarded remove patch
@@ -5,83 +5,83 @@  discard block
 block discarded – undo
5 5
     function parse($buffer) {
6 6
 	// Not yet finished, no CRC checks
7 7
 	//echo $buffer."\n";
8
-	$typehex = substr($buffer,0,1);
9
-	if ($typehex == '*' || $typehex == ':') $hex = substr($buffer,1,-1);
10
-	elseif ($typehex == '@' || $typehex == '%') $hex = substr($buffer,13,-13);
11
-	else $hex = substr($buffer,1,-1);
12
-	$bin = gmp_strval( gmp_init($hex,16), 2);
8
+	$typehex = substr($buffer, 0, 1);
9
+	if ($typehex == '*' || $typehex == ':') $hex = substr($buffer, 1, -1);
10
+	elseif ($typehex == '@' || $typehex == '%') $hex = substr($buffer, 13, -13);
11
+	else $hex = substr($buffer, 1, -1);
12
+	$bin = gmp_strval(gmp_init($hex, 16), 2);
13 13
 	//if (strlen($hex) == 28 && $this->parityCheck($hex,$bin)) {
14 14
 	if (strlen($hex) == 28) {
15
-	    $df = intval(substr($bin,0,5),2);
16
-	    $ca = intval(substr($bin,5,3),2);
15
+	    $df = intval(substr($bin, 0, 5), 2);
16
+	    $ca = intval(substr($bin, 5, 3), 2);
17 17
 	    // Only support DF17 for now
18 18
 	    //if ($df == 17 || ($df == 18 && ($ca == 0 || $ca == 1 || $ca == 6))) {
19
-	    if (($df == 17 || $df == 18) && ($this->parityCheck($hex,$bin) || $typehex == '@')) {
20
-		$icao = substr($hex,2,6);
19
+	    if (($df == 17 || $df == 18) && ($this->parityCheck($hex, $bin) || $typehex == '@')) {
20
+		$icao = substr($hex, 2, 6);
21 21
 		$data['hex'] = $icao;
22
-		$tc = intval(substr($bin,32,5),2);
22
+		$tc = intval(substr($bin, 32, 5), 2);
23 23
 		if ($tc >= 1 && $tc <= 4) {
24 24
 		    //callsign
25
-		    $csbin = substr($bin,40,56);
25
+		    $csbin = substr($bin, 40, 56);
26 26
 		    $charset = str_split('#ABCDEFGHIJKLMNOPQRSTUVWXYZ#####_###############0123456789######');
27 27
 		    $cs = '';
28
-		    $cs .= $charset[intval(substr($csbin,0,6),2)];
29
-		    $cs .= $charset[intval(substr($csbin,6,6),2)];
30
-		    $cs .= $charset[intval(substr($csbin,12,6),2)];
31
-		    $cs .= $charset[intval(substr($csbin,18,6),2)];
32
-		    $cs .= $charset[intval(substr($csbin,24,6),2)];
33
-		    $cs .= $charset[intval(substr($csbin,30,6),2)];
34
-		    $cs .= $charset[intval(substr($csbin,36,6),2)];
35
-		    $cs .= $charset[intval(substr($csbin,42,6),2)];
36
-		    $cs = str_replace('_','',$cs);
37
-		    $cs = str_replace('#','',$cs);
28
+		    $cs .= $charset[intval(substr($csbin, 0, 6), 2)];
29
+		    $cs .= $charset[intval(substr($csbin, 6, 6), 2)];
30
+		    $cs .= $charset[intval(substr($csbin, 12, 6), 2)];
31
+		    $cs .= $charset[intval(substr($csbin, 18, 6), 2)];
32
+		    $cs .= $charset[intval(substr($csbin, 24, 6), 2)];
33
+		    $cs .= $charset[intval(substr($csbin, 30, 6), 2)];
34
+		    $cs .= $charset[intval(substr($csbin, 36, 6), 2)];
35
+		    $cs .= $charset[intval(substr($csbin, 42, 6), 2)];
36
+		    $cs = str_replace('_', '', $cs);
37
+		    $cs = str_replace('#', '', $cs);
38 38
 		    $callsign = $cs;
39 39
 		    $data['ident'] = $callsign;
40 40
 		} elseif ($tc >= 9 && $tc <= 18) {
41 41
 		    // Check Q-bit
42
-		    $q = substr($bin,47,1);
42
+		    $q = substr($bin, 47, 1);
43 43
 		    if ($q) {
44
-			$n = intval(substr($bin,40,7).substr($bin,48,4),2);
45
-			$alt = $n*25-1000;
44
+			$n = intval(substr($bin, 40, 7).substr($bin, 48, 4), 2);
45
+			$alt = $n*25 - 1000;
46 46
 			$data['altitude'] = $alt;
47 47
 		    }
48 48
 		    // Check odd/even flag
49
-		    $oe = substr($bin,53,1);
49
+		    $oe = substr($bin, 53, 1);
50 50
 		    //if ($oe) => odd else even
51 51
 		    //  131072 is 2^17 since CPR latitude and longitude are encoded in 17 bits.
52
-		    $cprlat = intval(substr($bin,54,17),2)/131072.0;
53
-		    $cprlon = intval(substr($bin,71,17),2)/131072.0;
54
-		    if ($oe == 0) $this::$latlon[$icao] = array('latitude' => $cprlat,'longitude' => $cprlon,'created' => time());
52
+		    $cprlat = intval(substr($bin, 54, 17), 2)/131072.0;
53
+		    $cprlon = intval(substr($bin, 71, 17), 2)/131072.0;
54
+		    if ($oe == 0) $this::$latlon[$icao] = array('latitude' => $cprlat, 'longitude' => $cprlon, 'created' => time());
55 55
 		    elseif (isset($this::$latlon[$icao]) && (time() - $this::$latlon[$icao]['created']) < 10) {
56 56
 			$cprlat_odd = $cprlat;
57 57
 			$cprlon_odd = $cprlon;
58 58
 			$cprlat_even = $this::$latlon[$icao]['latitude'];
59 59
 			$cprlon_even = $this::$latlon[$icao]['longitude'];
60 60
 		    
61
-			$j = 59*$cprlat_even-60*$cprlat_odd+0.5;
62
-			$lat_even = (360.0/60)*($j%60+$cprlat_even);
63
-			$lat_odd = (360.0/59)*($j%59+$cprlat_odd);
61
+			$j = 59*$cprlat_even - 60*$cprlat_odd + 0.5;
62
+			$lat_even = (360.0/60)*($j%60 + $cprlat_even);
63
+			$lat_odd = (360.0/59)*($j%59 + $cprlat_odd);
64 64
 			if ($lat_even >= 270) $lat_even = $lat_even - 360;
65 65
 			if ($lat_odd >= 270) $lat_odd = $lat_odd - 360;
66 66
 			// check latitude zone
67 67
 			if ($this->cprNL($lat_even) == $this->cprNL($lat_odd)) {
68 68
 			    if ($this::$latlon[$icao]['created'] > time()) {
69
-				$ni = $this->cprN($lat_even,0);
70
-				$m = floor($cprlon_even*($this->cprNL($lat_even)-1) - $cprlon_odd * $this->cprNL($lat_even)+0.5);
71
-				$lon = (360.0/$ni)*($m%$ni+$cprlon_even);
69
+				$ni = $this->cprN($lat_even, 0);
70
+				$m = floor($cprlon_even*($this->cprNL($lat_even) - 1) - $cprlon_odd*$this->cprNL($lat_even) + 0.5);
71
+				$lon = (360.0/$ni)*($m%$ni + $cprlon_even);
72 72
 				$lat = $lat_even;
73
-				if ($lon > 180) $lon = $lon -360;
73
+				if ($lon > 180) $lon = $lon - 360;
74 74
 				if ($lat > -91 && $lat < 91 && $lon > -181 && $lon < 181) {
75 75
 				    //if ($globalDebug) echo 'cs : '.$cs.' - hex : '.$hex.' - lat : '.$lat.' - lon : '.$lon;
76 76
 				    $data['latitude'] = $lat;
77 77
 				    $data['longitude'] = $lon;
78 78
 				}
79 79
 			    } else {
80
-				$ni = $this->cprN($lat_odd,1);
81
-				$m = floor($cprlon_even*($this->cprNL($lat_odd)-1) - $cprlon_odd * $this->cprNL($lat_odd)+0.5);
82
-				$lon = (360.0/$ni)*($m%$ni+$cprlon_odd);
80
+				$ni = $this->cprN($lat_odd, 1);
81
+				$m = floor($cprlon_even*($this->cprNL($lat_odd) - 1) - $cprlon_odd*$this->cprNL($lat_odd) + 0.5);
82
+				$lon = (360.0/$ni)*($m%$ni + $cprlon_odd);
83 83
 				$lat = $lat_odd;
84
-				if ($lon > 180) $lon = $lon -360;
84
+				if ($lon > 180) $lon = $lon - 360;
85 85
 				if ($lat > -91 && $lat < 91 && $lon > -181 && $lon < 181) {
86 86
 				    //if ($globalDebug) echo 'icao : '.$icao.' - hex : '.$hex.' - lat : '.$lat.' - lon : '.$lon.' second'."\n";
87 87
 				    $data['latitude'] = $lat;
@@ -93,15 +93,15 @@  discard block
 block discarded – undo
93 93
 		    }
94 94
 		} elseif ($tc == 19) {
95 95
 		    // speed & heading
96
-		    $v_ew_dir = intval(substr($bin,45,1));
97
-		    $v_ew = intval(substr($bin,46,10),2);
98
-		    $v_ns_dir = intval(substr($bin,56,1));
99
-		    $v_ns = intval(substr($bin,57,10),2);
96
+		    $v_ew_dir = intval(substr($bin, 45, 1));
97
+		    $v_ew = intval(substr($bin, 46, 10), 2);
98
+		    $v_ns_dir = intval(substr($bin, 56, 1));
99
+		    $v_ns = intval(substr($bin, 57, 10), 2);
100 100
 		    if ($v_ew_dir) $v_ew = -1*$v_ew;
101 101
 		    if ($v_ns_dir) $v_ns = -1*$v_ns;
102
-		    $speed = sqrt($v_ns*$v_ns+$v_ew*$v_ew);
103
-		    $heading = atan2($v_ew,$v_ns)*360.0/(2*pi());
104
-		    if ($heading <0) $heading = $heading+360;
102
+		    $speed = sqrt($v_ns*$v_ns + $v_ew*$v_ew);
103
+		    $heading = atan2($v_ew, $v_ns)*360.0/(2*pi());
104
+		    if ($heading < 0) $heading = $heading + 360;
105 105
 		    $data['speed'] = $speed;
106 106
 		    $data['heading'] = $heading;
107 107
 		}
@@ -116,7 +116,7 @@  discard block
 block discarded – undo
116 116
 
117 117
     function cprNL($lat) {
118 118
 	//Lookup table to convert the latitude to index.
119
-	if ($lat < 0) $lat = -$lat;             // Table is simmetric about the equator.
119
+	if ($lat < 0) $lat = -$lat; // Table is simmetric about the equator.
120 120
 	if ($lat < 10.47047130) return 59;
121 121
 	if ($lat < 14.82817437) return 58;
122 122
 	if ($lat < 18.18626357) return 57;
@@ -178,7 +178,7 @@  discard block
 block discarded – undo
178 178
 	return 1;
179 179
     }
180 180
     
181
-    function cprN($lat,$isodd) {
181
+    function cprN($lat, $isodd) {
182 182
 	$nl = $this->cprNL($lat) - $isodd;
183 183
 	if ($nl > 1) return $nl;
184 184
 	else return 1;
@@ -204,10 +204,10 @@  discard block
 block discarded – undo
204 204
 );
205 205
 
206 206
 	$crc = 0;
207
-	$checksum = intval(substr($msg,22,6),16);
207
+	$checksum = intval(substr($msg, 22, 6), 16);
208 208
 
209 209
 	for ($j = 0; $j < strlen($bin); $j++) {
210
-	    if ($bin[$j]) $crc = $crc^intval($modes_checksum_table[$j],0);
210
+	    if ($bin[$j]) $crc = $crc^intval($modes_checksum_table[$j], 0);
211 211
 	}
212 212
 	if ($crc == $checksum) return true;
213 213
 	else {
Please login to merge, or discard this patch.
require/class.Stats.php 1 patch
Spacing   +204 added lines, -204 removed lines patch added patch discarded remove patch
@@ -13,14 +13,14 @@  discard block
 block discarded – undo
13 13
 		$this->db = $Connection->db;
14 14
         }
15 15
               
16
-	public function addLastStatsUpdate($type,$stats_date) {
16
+	public function addLastStatsUpdate($type, $stats_date) {
17 17
                 $query = "DELETE FROM config WHERE name = :type;
18 18
             		INSERT INTO config (name,value) VALUES (:type,:stats_date);";
19
-                $query_values = array('type' => $type,':stats_date' => $stats_date);
19
+                $query_values = array('type' => $type, ':stats_date' => $stats_date);
20 20
                  try {
21 21
                         $sth = $this->db->prepare($query);
22 22
                         $sth->execute($query_values);
23
-                } catch(PDOException $e) {
23
+                } catch (PDOException $e) {
24 24
                         return "error : ".$e->getMessage();
25 25
                 }
26 26
         }
@@ -30,7 +30,7 @@  discard block
 block discarded – undo
30 30
                  try {
31 31
                         $sth = $this->db->prepare($query);
32 32
                         $sth->execute(array(':type' => $type));
33
-                } catch(PDOException $e) {
33
+                } catch (PDOException $e) {
34 34
                         echo "error : ".$e->getMessage();
35 35
                 }
36 36
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -41,7 +41,7 @@  discard block
 block discarded – undo
41 41
                  try {
42 42
                         $sth = $this->db->prepare($query);
43 43
                         $sth->execute();
44
-                } catch(PDOException $e) {
44
+                } catch (PDOException $e) {
45 45
                         echo "error : ".$e->getMessage();
46 46
                 }
47 47
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -52,7 +52,7 @@  discard block
 block discarded – undo
52 52
                  try {
53 53
                         $sth = $this->db->prepare($query);
54 54
                         $sth->execute();
55
-                } catch(PDOException $e) {
55
+                } catch (PDOException $e) {
56 56
                         echo "error : ".$e->getMessage();
57 57
                 }
58 58
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -63,7 +63,7 @@  discard block
 block discarded – undo
63 63
                  try {
64 64
                         $sth = $this->db->prepare($query);
65 65
                         $sth->execute();
66
-                } catch(PDOException $e) {
66
+                } catch (PDOException $e) {
67 67
                         echo "error : ".$e->getMessage();
68 68
                 }
69 69
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -77,7 +77,7 @@  discard block
 block discarded – undo
77 77
                  try {
78 78
                         $sth = $this->db->prepare($query);
79 79
                         $sth->execute();
80
-                } catch(PDOException $e) {
80
+                } catch (PDOException $e) {
81 81
                         echo "error : ".$e->getMessage();
82 82
                 }
83 83
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -93,7 +93,7 @@  discard block
 block discarded – undo
93 93
                  try {
94 94
                         $sth = $this->db->prepare($query);
95 95
                         $sth->execute();
96
-                } catch(PDOException $e) {
96
+                } catch (PDOException $e) {
97 97
                         echo "error : ".$e->getMessage();
98 98
                 }
99 99
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -110,7 +110,7 @@  discard block
 block discarded – undo
110 110
                  try {
111 111
                         $sth = $this->db->prepare($query);
112 112
                         $sth->execute();
113
-                } catch(PDOException $e) {
113
+                } catch (PDOException $e) {
114 114
                         echo "error : ".$e->getMessage();
115 115
                 }
116 116
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -127,7 +127,7 @@  discard block
 block discarded – undo
127 127
                  try {
128 128
                         $sth = $this->db->prepare($query);
129 129
                         $sth->execute();
130
-                } catch(PDOException $e) {
130
+                } catch (PDOException $e) {
131 131
                         echo "error : ".$e->getMessage();
132 132
                 }
133 133
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -143,7 +143,7 @@  discard block
 block discarded – undo
143 143
                  try {
144 144
                         $sth = $this->db->prepare($query);
145 145
                         $sth->execute();
146
-                } catch(PDOException $e) {
146
+                } catch (PDOException $e) {
147 147
                         echo "error : ".$e->getMessage();
148 148
                 }
149 149
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -160,7 +160,7 @@  discard block
 block discarded – undo
160 160
                  try {
161 161
                         $sth = $this->db->prepare($query);
162 162
                         $sth->execute();
163
-                } catch(PDOException $e) {
163
+                } catch (PDOException $e) {
164 164
                         echo "error : ".$e->getMessage();
165 165
                 }
166 166
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -176,7 +176,7 @@  discard block
 block discarded – undo
176 176
                  try {
177 177
                         $sth = $this->db->prepare($query);
178 178
                         $sth->execute();
179
-                } catch(PDOException $e) {
179
+                } catch (PDOException $e) {
180 180
                         echo "error : ".$e->getMessage();
181 181
                 }
182 182
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -192,7 +192,7 @@  discard block
 block discarded – undo
192 192
                  try {
193 193
                         $sth = $this->db->prepare($query);
194 194
                         $sth->execute();
195
-                } catch(PDOException $e) {
195
+                } catch (PDOException $e) {
196 196
                         echo "error : ".$e->getMessage();
197 197
                 }
198 198
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -210,7 +210,7 @@  discard block
 block discarded – undo
210 210
 			 try {
211 211
 				$sth = $this->db->prepare($query);
212 212
 				$sth->execute();
213
-			} catch(PDOException $e) {
213
+			} catch (PDOException $e) {
214 214
 				echo "error : ".$e->getMessage();
215 215
 			}
216 216
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -231,7 +231,7 @@  discard block
 block discarded – undo
231 231
                  try {
232 232
                         $sth = $this->db->prepare($query);
233 233
                         $sth->execute();
234
-                } catch(PDOException $e) {
234
+                } catch (PDOException $e) {
235 235
                         echo "error : ".$e->getMessage();
236 236
                 }
237 237
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -247,7 +247,7 @@  discard block
 block discarded – undo
247 247
                  try {
248 248
                         $sth = $this->db->prepare($query);
249 249
                         $sth->execute();
250
-                } catch(PDOException $e) {
250
+                } catch (PDOException $e) {
251 251
                         echo "error : ".$e->getMessage();
252 252
                 }
253 253
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -263,7 +263,7 @@  discard block
 block discarded – undo
263 263
                  try {
264 264
                         $sth = $this->db->prepare($query);
265 265
                         $sth->execute();
266
-                } catch(PDOException $e) {
266
+                } catch (PDOException $e) {
267 267
                         echo "error : ".$e->getMessage();
268 268
                 }
269 269
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -287,7 +287,7 @@  discard block
 block discarded – undo
287 287
         		foreach ($all as $key => $row) {
288 288
         			$count[$key] = $row['airport_departure_icao_count'];
289 289
         		}
290
-        		array_multisort($count,SORT_DESC,$all);
290
+        		array_multisort($count, SORT_DESC, $all);
291 291
                 }
292 292
                 return $all;
293 293
 	}
@@ -297,7 +297,7 @@  discard block
 block discarded – undo
297 297
                  try {
298 298
                         $sth = $this->db->prepare($query);
299 299
                         $sth->execute();
300
-                } catch(PDOException $e) {
300
+                } catch (PDOException $e) {
301 301
                         echo "error : ".$e->getMessage();
302 302
                 }
303 303
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -321,7 +321,7 @@  discard block
 block discarded – undo
321 321
         		foreach ($all as $key => $row) {
322 322
         			$count[$key] = $row['airport_arrival_icao_count'];
323 323
         		}
324
-        		array_multisort($count,SORT_DESC,$all);
324
+        		array_multisort($count, SORT_DESC, $all);
325 325
                 }
326 326
                 return $all;
327 327
 	}
@@ -338,7 +338,7 @@  discard block
 block discarded – undo
338 338
                  try {
339 339
                         $sth = $this->db->prepare($query);
340 340
                         $sth->execute($query_data);
341
-                } catch(PDOException $e) {
341
+                } catch (PDOException $e) {
342 342
                         echo "error : ".$e->getMessage();
343 343
                 }
344 344
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -355,7 +355,7 @@  discard block
 block discarded – undo
355 355
                  try {
356 356
                         $sth = $this->db->prepare($query);
357 357
                         $sth->execute($query_data);
358
-                } catch(PDOException $e) {
358
+                } catch (PDOException $e) {
359 359
                         echo "error : ".$e->getMessage();
360 360
                 }
361 361
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -376,7 +376,7 @@  discard block
 block discarded – undo
376 376
                  try {
377 377
                         $sth = $this->db->prepare($query);
378 378
                         $sth->execute($query_data);
379
-                } catch(PDOException $e) {
379
+                } catch (PDOException $e) {
380 380
                         echo "error : ".$e->getMessage();
381 381
                 }
382 382
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -392,7 +392,7 @@  discard block
 block discarded – undo
392 392
                  try {
393 393
                         $sth = $this->db->prepare($query);
394 394
                         $sth->execute($query_data);
395
-                } catch(PDOException $e) {
395
+                } catch (PDOException $e) {
396 396
                         echo "error : ".$e->getMessage();
397 397
                 }
398 398
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -407,7 +407,7 @@  discard block
 block discarded – undo
407 407
                  try {
408 408
                         $sth = $this->db->prepare($query);
409 409
                         $sth->execute();
410
-                } catch(PDOException $e) {
410
+                } catch (PDOException $e) {
411 411
                         echo "error : ".$e->getMessage();
412 412
                 }
413 413
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -422,7 +422,7 @@  discard block
 block discarded – undo
422 422
                  try {
423 423
                         $sth = $this->db->prepare($query);
424 424
                         $sth->execute();
425
-                } catch(PDOException $e) {
425
+                } catch (PDOException $e) {
426 426
                         echo "error : ".$e->getMessage();
427 427
                 }
428 428
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -432,7 +432,7 @@  discard block
 block discarded – undo
432 432
                 }
433 433
                 return $all;
434 434
 	}
435
-	public function countAllHours($orderby = 'hour',$limit = true) {
435
+	public function countAllHours($orderby = 'hour', $limit = true) {
436 436
 		global $globalTimezone;
437 437
 		if ($limit) $query = "SELECT flight_date as hour_name, cnt as hour_count FROM stats_flight WHERE stats_type = 'hour'";
438 438
 		else $query = "SELECT flight_date as hour_name, cnt as hour_count FROM stats_flight WHERE stats_type = 'hour'";
@@ -441,19 +441,19 @@  discard block
 block discarded – undo
441 441
                  try {
442 442
                         $sth = $this->db->prepare($query);
443 443
                         $sth->execute();
444
-                } catch(PDOException $e) {
444
+                } catch (PDOException $e) {
445 445
                         echo "error : ".$e->getMessage();
446 446
                 }
447 447
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
448 448
                 if (empty($all)) {
449 449
             		$Spotter = new Spotter($this->db);
450
-            		$all = $Spotter->countAllHours($orderby,$limit);
450
+            		$all = $Spotter->countAllHours($orderby, $limit);
451 451
                 }
452 452
                 return $all;
453 453
 	}
454 454
 	
455 455
 	public function countOverallFlights() {
456
-		$all = $this->getSumStats('flights_bymonth',date('Y'));
456
+		$all = $this->getSumStats('flights_bymonth', date('Y'));
457 457
 		if (empty($all)) {
458 458
 			$Spotter = new Spotter($this->db);
459 459
 			$all = $Spotter->countOverallFlights();
@@ -461,7 +461,7 @@  discard block
 block discarded – undo
461 461
 		return $all;
462 462
 	}
463 463
 	public function countOverallMilitaryFlights() {
464
-		$all = $this->getSumStats('military_flights_bymonth',date('Y'));
464
+		$all = $this->getSumStats('military_flights_bymonth', date('Y'));
465 465
 		if (empty($all)) {
466 466
 			$Spotter = new Spotter($this->db);
467 467
 			$all = $Spotter->countOverallMilitaryFlights();
@@ -469,7 +469,7 @@  discard block
 block discarded – undo
469 469
 		return $all;
470 470
 	}
471 471
 	public function countOverallArrival() {
472
-		$all = $this->getSumStats('realarrivals_bymonth',date('Y'));
472
+		$all = $this->getSumStats('realarrivals_bymonth', date('Y'));
473 473
 		if (empty($all)) {
474 474
 			$Spotter = new Spotter($this->db);
475 475
 			$all = $Spotter->countOverallArrival();
@@ -477,7 +477,7 @@  discard block
 block discarded – undo
477 477
 		return $all;
478 478
 	}
479 479
 	public function countOverallAircrafts() {
480
-		$all = $this->getSumStats('aircrafts_bymonth',date('Y'));
480
+		$all = $this->getSumStats('aircrafts_bymonth', date('Y'));
481 481
 		if (empty($all)) {
482 482
 			$Spotter = new Spotter($this->db);
483 483
 			$all = $Spotter->countOverallAircrafts();
@@ -485,7 +485,7 @@  discard block
 block discarded – undo
485 485
 		return $all;
486 486
 	}
487 487
 	public function countOverallAirlines() {
488
-		$all = $this->getSumStats('airlines_bymonth',date('Y'));
488
+		$all = $this->getSumStats('airlines_bymonth', date('Y'));
489 489
 		if (empty($all)) {
490 490
 			$Spotter = new Spotter($this->db);
491 491
 			$all = $Spotter->countOverallAirlines();
@@ -493,7 +493,7 @@  discard block
 block discarded – undo
493 493
 		return $all;
494 494
 	}
495 495
 	public function countOverallOwners() {
496
-		$all = $this->getSumStats('owners_bymonth',date('Y'));
496
+		$all = $this->getSumStats('owners_bymonth', date('Y'));
497 497
 		if (empty($all)) {
498 498
 			$Spotter = new Spotter($this->db);
499 499
 			$all = $Spotter->countOverallOwners();
@@ -501,7 +501,7 @@  discard block
 block discarded – undo
501 501
 		return $all;
502 502
 	}
503 503
 	public function countOverallPilots() {
504
-		$all = $this->getSumStats('pilots_bymonth',date('Y'));
504
+		$all = $this->getSumStats('pilots_bymonth', date('Y'));
505 505
 		if (empty($all)) {
506 506
 			$Spotter = new Spotter($this->db);
507 507
 			$all = $Spotter->countOverallPilots();
@@ -515,7 +515,7 @@  discard block
 block discarded – undo
515 515
                  try {
516 516
                         $sth = $this->db->prepare($query);
517 517
                         $sth->execute($query_values);
518
-                } catch(PDOException $e) {
518
+                } catch (PDOException $e) {
519 519
                         echo "error : ".$e->getMessage();
520 520
                 }
521 521
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -527,13 +527,13 @@  discard block
 block discarded – undo
527 527
                  try {
528 528
                         $sth = $this->db->prepare($query);
529 529
                         $sth->execute($query_values);
530
-                } catch(PDOException $e) {
530
+                } catch (PDOException $e) {
531 531
                         echo "error : ".$e->getMessage();
532 532
                 }
533 533
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
534 534
                 return $all;
535 535
         }
536
-	public function getSumStats($type,$year) {
536
+	public function getSumStats($type, $year) {
537 537
     		global $globalArchiveMonths, $globalDBdriver;
538 538
     		if ($globalDBdriver == 'mysql') {
539 539
 	                $query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND YEAR(stats_date) = :year";
@@ -544,7 +544,7 @@  discard block
 block discarded – undo
544 544
                  try {
545 545
                         $sth = $this->db->prepare($query);
546 546
                         $sth->execute($query_values);
547
-                } catch(PDOException $e) {
547
+                } catch (PDOException $e) {
548 548
                         echo "error : ".$e->getMessage();
549 549
                 }
550 550
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -561,7 +561,7 @@  discard block
 block discarded – undo
561 561
                  try {
562 562
                         $sth = $this->db->prepare($query);
563 563
                         $sth->execute($query_values);
564
-                } catch(PDOException $e) {
564
+                } catch (PDOException $e) {
565 565
                         echo "error : ".$e->getMessage();
566 566
                 }
567 567
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -577,7 +577,7 @@  discard block
 block discarded – undo
577 577
                  try {
578 578
                         $sth = $this->db->prepare($query);
579 579
                         $sth->execute();
580
-                } catch(PDOException $e) {
580
+                } catch (PDOException $e) {
581 581
                         echo "error : ".$e->getMessage();
582 582
                 }
583 583
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -593,7 +593,7 @@  discard block
 block discarded – undo
593 593
                  try {
594 594
                         $sth = $this->db->prepare($query);
595 595
                         $sth->execute();
596
-                } catch(PDOException $e) {
596
+                } catch (PDOException $e) {
597 597
                         echo "error : ".$e->getMessage();
598 598
                 }
599 599
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -609,7 +609,7 @@  discard block
 block discarded – undo
609 609
                  try {
610 610
                         $sth = $this->db->prepare($query);
611 611
                         $sth->execute();
612
-                } catch(PDOException $e) {
612
+                } catch (PDOException $e) {
613 613
                         echo "error : ".$e->getMessage();
614 614
                 }
615 615
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -625,29 +625,29 @@  discard block
 block discarded – undo
625 625
                  try {
626 626
                         $sth = $this->db->prepare($query);
627 627
                         $sth->execute();
628
-                } catch(PDOException $e) {
628
+                } catch (PDOException $e) {
629 629
                         echo "error : ".$e->getMessage();
630 630
                 }
631 631
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
632 632
                 return $all[0]['total'];
633 633
         }
634 634
 
635
-	public function addStat($type,$cnt,$stats_date) {
635
+	public function addStat($type, $cnt, $stats_date) {
636 636
 		global $globalDBdriver;
637 637
 		if ($globalDBdriver == 'mysql') {
638 638
 			$query = "INSERT INTO stats (stats_type,cnt,stats_date) VALUES (:type,:cnt,:stats_date) ON DUPLICATE KEY UPDATE cnt = :cnt";
639 639
                 } else {
640 640
 			$query = "UPDATE stats SET cnt = :cnt WHERE stats_type = :type AND stats_date = :stats_date; INSERT INTO stats (stats_type,cnt,stats_date) SELECT :type,:cnt,:stats_date WHERE NOT EXISTS (SELECT 1 FROM stats WHERE  stats_type = :type AND stats_date = :stats_date);"; 
641 641
 		}
642
-                $query_values = array(':type' => $type,':cnt' => $cnt,':stats_date' => $stats_date);
642
+                $query_values = array(':type' => $type, ':cnt' => $cnt, ':stats_date' => $stats_date);
643 643
                  try {
644 644
                         $sth = $this->db->prepare($query);
645 645
                         $sth->execute($query_values);
646
-                } catch(PDOException $e) {
646
+                } catch (PDOException $e) {
647 647
                         return "error : ".$e->getMessage();
648 648
                 }
649 649
         }
650
-	public function updateStat($type,$cnt,$stats_date) {
650
+	public function updateStat($type, $cnt, $stats_date) {
651 651
 		global $globalDBdriver;
652 652
 		if ($globalDBdriver == 'mysql') {
653 653
 			$query = "INSERT INTO stats (stats_type,cnt,stats_date) VALUES (:type,:cnt,:stats_date) ON DUPLICATE KEY UPDATE cnt = cnt+:cnt, stats_date = :date";
@@ -655,219 +655,219 @@  discard block
 block discarded – undo
655 655
             		//$query = "INSERT INTO stats (stats_type,cnt,stats_date) VALUES (:type,:cnt,:stats_date) ON DUPLICATE KEY UPDATE cnt = cnt+:cnt, stats_date = :date";
656 656
 			$query = "UPDATE stats SET cnt = cnt+:cnt WHERE stats_type = :type AND stats_date = :stats_date; INSERT INTO stats (stats_type,cnt,stats_date) SELECT :type,:cnt,:stats_date WHERE NOT EXISTS (SELECT 1 FROM stats WHERE  stats_type = :type AND stats_date = :stats_date);"; 
657 657
                 }
658
-                $query_values = array(':type' => $type,':cnt' => $cnt,':stats_date' => $stats_date);
658
+                $query_values = array(':type' => $type, ':cnt' => $cnt, ':stats_date' => $stats_date);
659 659
                  try {
660 660
                         $sth = $this->db->prepare($query);
661 661
                         $sth->execute($query_values);
662
-                } catch(PDOException $e) {
662
+                } catch (PDOException $e) {
663 663
                         return "error : ".$e->getMessage();
664 664
                 }
665 665
         }
666
-	public function getStatsSource($date,$stats_type = '') {
666
+	public function getStatsSource($date, $stats_type = '') {
667 667
 		if ($stats_type == '') {
668 668
 			$query = "SELECT * FROM stats_source WHERE stats_date = :date ORDER BY source_name";
669 669
 			$query_values = array(':date' => $date);
670 670
 		} else {
671 671
 			$query = "SELECT * FROM stats_source WHERE stats_date = :date AND stats_type = :stats_type ORDER BY source_name";
672
-			$query_values = array(':date' => $date,':stats_type' => $stats_type);
672
+			$query_values = array(':date' => $date, ':stats_type' => $stats_type);
673 673
 		}
674 674
                  try {
675 675
                         $sth = $this->db->prepare($query);
676 676
                         $sth->execute($query_values);
677
-                } catch(PDOException $e) {
677
+                } catch (PDOException $e) {
678 678
                         echo "error : ".$e->getMessage();
679 679
                 }
680 680
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
681 681
                 return $all;
682 682
         }
683 683
 
684
-	public function addStatSource($data,$source_name,$stats_type,$date) {
684
+	public function addStatSource($data, $source_name, $stats_type, $date) {
685 685
 		global $globalDBdriver;
686 686
 		if ($globalDBdriver == 'mysql') {
687 687
 			$query = "INSERT INTO stats_source (source_data,source_name,stats_type,stats_date) VALUES (:data,:source_name,:stats_type,:stats_date) ON DUPLICATE KEY UPDATE source_data = :data";
688 688
 		} else {
689 689
 			$query = "UPDATE stats_source SET source_data = :data WHERE stats_date = :stats_date AND source_name = :source_name AND stats_type = :stats_type; INSERT INTO stats_source (source_data,source_name,stats_type,stats_date) SELECT :data,:source_name,:stats_type,:stats_date WHERE NOT EXISTS (SELECT 1 FROM stats_source WHERE stats_date = :stats_date AND source_name = :source_name AND stats_type = :stats_type);"; 
690 690
                 }
691
-                $query_values = array(':data' => $data,':stats_date' => $date,':source_name' => $source_name,':stats_type' => $stats_type);
691
+                $query_values = array(':data' => $data, ':stats_date' => $date, ':source_name' => $source_name, ':stats_type' => $stats_type);
692 692
                  try {
693 693
                         $sth = $this->db->prepare($query);
694 694
                         $sth->execute($query_values);
695
-                } catch(PDOException $e) {
695
+                } catch (PDOException $e) {
696 696
                         return "error : ".$e->getMessage();
697 697
                 }
698 698
         }
699
-	public function addStatFlight($type,$date_name,$cnt) {
699
+	public function addStatFlight($type, $date_name, $cnt) {
700 700
                 $query = "INSERT INTO stats_flight (stats_type,flight_date,cnt) VALUES (:type,:flight_date,:cnt)";
701
-                $query_values = array(':type' => $type,':flight_date' => $date_name,':cnt' => $cnt);
701
+                $query_values = array(':type' => $type, ':flight_date' => $date_name, ':cnt' => $cnt);
702 702
                  try {
703 703
                         $sth = $this->db->prepare($query);
704 704
                         $sth->execute($query_values);
705
-                } catch(PDOException $e) {
705
+                } catch (PDOException $e) {
706 706
                         return "error : ".$e->getMessage();
707 707
                 }
708 708
         }
709
-	public function addStatAircraftRegistration($registration,$cnt,$aircraft_icao = '') {
709
+	public function addStatAircraftRegistration($registration, $cnt, $aircraft_icao = '') {
710 710
 		global $globalDBdriver;
711 711
 		if ($globalDBdriver == 'mysql') {
712 712
 			$query = "INSERT INTO stats_registration (aircraft_icao,registration,cnt) VALUES (:aircraft_icao,:registration,:cnt) ON DUPLICATE KEY UPDATE cnt = cnt+:cnt";
713 713
 		} else {
714 714
 			$query = "UPDATE stats_registration SET cnt = cnt+:cnt WHERE registration = :registration; INSERT INTO stats_registration (aircraft_icao,registration,cnt) SELECT :aircraft_icao,:registration,:cnt WHERE NOT EXISTS (SELECT 1 FROM stats_registration WHERE registration = :registration);"; 
715 715
 		}
716
-                $query_values = array(':aircraft_icao' => $aircraft_icao,':registration' => $registration,':cnt' => $cnt);
716
+                $query_values = array(':aircraft_icao' => $aircraft_icao, ':registration' => $registration, ':cnt' => $cnt);
717 717
                  try {
718 718
                         $sth = $this->db->prepare($query);
719 719
                         $sth->execute($query_values);
720
-                } catch(PDOException $e) {
720
+                } catch (PDOException $e) {
721 721
                         return "error : ".$e->getMessage();
722 722
                 }
723 723
         }
724
-	public function addStatCallsign($callsign_icao,$cnt,$airline_icao = '') {
724
+	public function addStatCallsign($callsign_icao, $cnt, $airline_icao = '') {
725 725
 		global $globalDBdriver;
726 726
 		if ($globalDBdriver == 'mysql') {
727 727
 			$query = "INSERT INTO stats_callsign (callsign_icao,airline_icao,cnt) VALUES (:callsign_icao,:airline_icao,:cnt) ON DUPLICATE KEY UPDATE cnt = cnt+:cnt";
728 728
 		} else {
729 729
 			$query = "UPDATE stats_callsign SET cnt = cnt+:cnt WHERE callsign_icao = :callsign_icao; INSERT INTO stats_callsign (callsign_icao,airline_icao,cnt) SELECT :callsign_icao,:airline_icao,:cnt WHERE NOT EXISTS (SELECT 1 FROM stats_callsign WHERE callsign_icao = :callsign_icao);"; 
730 730
 		}
731
-                $query_values = array(':callsign_icao' => $callsign_icao,':airline_icao' => $airline_icao,':cnt' => $cnt);
731
+                $query_values = array(':callsign_icao' => $callsign_icao, ':airline_icao' => $airline_icao, ':cnt' => $cnt);
732 732
                  try {
733 733
                         $sth = $this->db->prepare($query);
734 734
                         $sth->execute($query_values);
735
-                } catch(PDOException $e) {
735
+                } catch (PDOException $e) {
736 736
                         return "error : ".$e->getMessage();
737 737
                 }
738 738
         }
739
-	public function addStatCountry($iso2,$iso3,$name,$cnt) {
739
+	public function addStatCountry($iso2, $iso3, $name, $cnt) {
740 740
 		global $globalDBdriver;
741 741
 		if ($globalDBdriver == 'mysql') {
742 742
 			$query = "INSERT INTO stats_country (iso2,iso3,name,cnt) VALUES (:iso2,:iso3,:name,:cnt) ON DUPLICATE KEY UPDATE cnt = cnt+:cnt";
743 743
 		} else {
744 744
 			$query = "UPDATE stats_country SET cnt = cnt+:cnt WHERE iso2 = :iso2; INSERT INTO stats_country (iso2,iso3,name,cnt) SELECT :iso2,:iso3,:name,:cnt WHERE NOT EXISTS (SELECT 1 FROM stats_country WHERE iso2 = :iso2);"; 
745 745
 		}
746
-                $query_values = array(':iso2' => $iso2,':iso3' => $iso3,':name' => $name,':cnt' => $cnt);
746
+                $query_values = array(':iso2' => $iso2, ':iso3' => $iso3, ':name' => $name, ':cnt' => $cnt);
747 747
                  try {
748 748
                         $sth = $this->db->prepare($query);
749 749
                         $sth->execute($query_values);
750
-                } catch(PDOException $e) {
750
+                } catch (PDOException $e) {
751 751
                         return "error : ".$e->getMessage();
752 752
                 }
753 753
         }
754
-	public function addStatAircraft($aircraft_icao,$cnt,$aircraft_name = '') {
754
+	public function addStatAircraft($aircraft_icao, $cnt, $aircraft_name = '') {
755 755
 		global $globalDBdriver;
756 756
 		if ($globalDBdriver == 'mysql') {
757 757
 			$query = "INSERT INTO stats_aircraft (aircraft_icao,aircraft_name,cnt) VALUES (:aircraft_icao,:aircraft_name,:cnt) ON DUPLICATE KEY UPDATE cnt = cnt+:cnt";
758 758
 		} else {
759 759
 			$query = "UPDATE stats_aircraft SET cnt = cnt+:cnt WHERE aircraft_icao = :aircraft_icao; INSERT INTO stats_aircraft (aircraft_icao,aircraft_name,cnt) SELECT :aircraft_icao,:aircraft_name,:cnt WHERE NOT EXISTS (SELECT 1 FROM stats_aircraft WHERE aircraft_icao = :aircraft_icao);"; 
760 760
 		}
761
-                $query_values = array(':aircraft_icao' => $aircraft_icao,':aircraft_name' => $aircraft_name,':cnt' => $cnt);
761
+                $query_values = array(':aircraft_icao' => $aircraft_icao, ':aircraft_name' => $aircraft_name, ':cnt' => $cnt);
762 762
                  try {
763 763
                         $sth = $this->db->prepare($query);
764 764
                         $sth->execute($query_values);
765
-                } catch(PDOException $e) {
765
+                } catch (PDOException $e) {
766 766
                         return "error : ".$e->getMessage();
767 767
                 }
768 768
         }
769
-	public function addStatAirline($airline_icao,$cnt,$airline_name = '') {
769
+	public function addStatAirline($airline_icao, $cnt, $airline_name = '') {
770 770
 		global $globalDBdriver;
771 771
 		if ($globalDBdriver == 'mysql') {
772 772
 			$query = "INSERT INTO stats_airline (airline_icao,airline_name,cnt) VALUES (:airline_icao,:airline_name,:cnt) ON DUPLICATE KEY UPDATE cnt = cnt+:cnt,airline_name = :airline_name";
773 773
 		} else {
774 774
 			$query = "UPDATE stats_airline SET cnt = cnt+:cnt WHERE airline_icao = :airline_icao; INSERT INTO stats_airline (airline_icao,airline_name,cnt) SELECT :airline_icao,:airline_name,:cnt WHERE NOT EXISTS (SELECT 1 FROM stats_airline WHERE airline_icao = :airline_icao);"; 
775 775
 		}
776
-                $query_values = array(':airline_icao' => $airline_icao,':airline_name' => $airline_name,':cnt' => $cnt);
776
+                $query_values = array(':airline_icao' => $airline_icao, ':airline_name' => $airline_name, ':cnt' => $cnt);
777 777
                  try {
778 778
                         $sth = $this->db->prepare($query);
779 779
                         $sth->execute($query_values);
780
-                } catch(PDOException $e) {
780
+                } catch (PDOException $e) {
781 781
                         return "error : ".$e->getMessage();
782 782
                 }
783 783
         }
784
-	public function addStatOwner($owner_name,$cnt) {
784
+	public function addStatOwner($owner_name, $cnt) {
785 785
 		global $globalDBdriver;
786 786
 		if ($globalDBdriver == 'mysql') {
787 787
 			$query = "INSERT INTO stats_owner (owner_name,cnt) VALUES (:owner_name,:cnt) ON DUPLICATE KEY UPDATE cnt = cnt+:cnt";
788 788
 		} else {
789 789
 			$query = "UPDATE stats_owner SET cnt = cnt+:cnt WHERE owner_name = :owner_name; INSERT INTO stats_owner (owner_name,cnt) SELECT :owner_name,:cnt WHERE NOT EXISTS (SELECT 1 FROM stats_owner WHERE owner_name = :owner_name);"; 
790 790
 		}
791
-                $query_values = array(':owner_name' => $owner_name,':cnt' => $cnt);
791
+                $query_values = array(':owner_name' => $owner_name, ':cnt' => $cnt);
792 792
                  try {
793 793
                         $sth = $this->db->prepare($query);
794 794
                         $sth->execute($query_values);
795
-                } catch(PDOException $e) {
795
+                } catch (PDOException $e) {
796 796
                         return "error : ".$e->getMessage();
797 797
                 }
798 798
         }
799
-	public function addStatPilot($pilot_id,$cnt) {
799
+	public function addStatPilot($pilot_id, $cnt) {
800 800
 		global $globalDBdriver;
801 801
 		if ($globalDBdriver == 'mysql') {
802 802
 			$query = "INSERT INTO stats_pilot (pilot_id,cnt) VALUES (:pilot_id,:cnt) ON DUPLICATE KEY UPDATE cnt = cnt+:cnt";
803 803
 		} else {
804 804
 			$query = "UPDATE stats_pilot SET cnt = cnt+:cnt WHERE pilot_id = :pilot_id; INSERT INTO stats_pilot (pilot_id,cnt) SELECT :pilot_id,:cnt WHERE NOT EXISTS (SELECT 1 FROM stats_pilot WHERE pilot_id = :pilot_id);"; 
805 805
 		}
806
-                $query_values = array(':pilot_id' => $pilot_id,':cnt' => $cnt);
806
+                $query_values = array(':pilot_id' => $pilot_id, ':cnt' => $cnt);
807 807
                  try {
808 808
                         $sth = $this->db->prepare($query);
809 809
                         $sth->execute($query_values);
810
-                } catch(PDOException $e) {
810
+                } catch (PDOException $e) {
811 811
                         return "error : ".$e->getMessage();
812 812
                 }
813 813
         }
814
-	public function addStatDepartureAirports($airport_icao,$airport_name,$airport_city,$airport_country,$departure) {
814
+	public function addStatDepartureAirports($airport_icao, $airport_name, $airport_city, $airport_country, $departure) {
815 815
 		global $globalDBdriver;
816 816
 		if ($globalDBdriver == 'mysql') {
817 817
 			$query = "INSERT INTO stats_airport (airport_icao,airport_name,airport_city,airport_country,departure,stats_type,date) VALUES (:airport_icao,:airport_name,:airport_city,:airport_country,:departure,'yearly',:date) ON DUPLICATE KEY UPDATE departure = departure+:departure";
818 818
 		} else {
819 819
 			$query = "UPDATE stats_airport SET departure = departure+:departure WHERE airport_icao = :airport_icao AND stats_type = 'yearly'; INSERT INTO stats_airport (airport_icao,airport_name,airport_city,airport_country,departure,stats_type,date) SELECT :airport_icao,:airport_name,:airport_city,:airport_country,:departure,'yearly',:date WHERE NOT EXISTS (SELECT 1 FROM stats_airline WHERE airport_icao = :airport_icao AND stats_type = 'yearly');"; 
820 820
 		}
821
-                $query_values = array(':airport_icao' => $airport_icao,':airport_name' => $airport_name,':airport_city' => $airport_city,':airport_country' => $airport_country,':departure' => $departure,':date' => date('Y').'-01-01 00:00:00');
821
+                $query_values = array(':airport_icao' => $airport_icao, ':airport_name' => $airport_name, ':airport_city' => $airport_city, ':airport_country' => $airport_country, ':departure' => $departure, ':date' => date('Y').'-01-01 00:00:00');
822 822
                  try {
823 823
                         $sth = $this->db->prepare($query);
824 824
                         $sth->execute($query_values);
825
-                } catch(PDOException $e) {
825
+                } catch (PDOException $e) {
826 826
                         return "error : ".$e->getMessage();
827 827
                 }
828 828
         }
829
-	public function addStatDepartureAirportsDaily($date,$airport_icao,$airport_name,$airport_city,$airport_country,$departure) {
829
+	public function addStatDepartureAirportsDaily($date, $airport_icao, $airport_name, $airport_city, $airport_country, $departure) {
830 830
 		global $globalDBdriver;
831 831
 		if ($globalDBdriver == 'mysql') {
832 832
 			$query = "INSERT INTO stats_airport (airport_icao,airport_name,airport_city,airport_country,departure,stats_type,date) VALUES (:airport_icao,:airport_name,:airport_city,:airport_country,:departure,'daily',:date) ON DUPLICATE KEY UPDATE departure = :departure";
833 833
 		} else {
834 834
 			$query = "UPDATE stats_airport SET departure = departure+:departure WHERE airport_icao = :airport_icao AND stats_type = 'daily'; INSERT INTO stats_airport (airport_icao,airport_name,airport_city,airport_country,departure,stats_type,date) SELECT :airport_icao,:airport_name,:airport_city,:airport_country,:departure,'daily',:date WHERE NOT EXISTS (SELECT 1 FROM stats_airline WHERE airport_icao = :airport_icao AND stats_type = 'daily');"; 
835 835
 		}
836
-                $query_values = array(':airport_icao' => $airport_icao,':airport_name' => $airport_name,':airport_city' => $airport_city,':airport_country' => $airport_country,':departure' => $departure,':date' => $date);
836
+                $query_values = array(':airport_icao' => $airport_icao, ':airport_name' => $airport_name, ':airport_city' => $airport_city, ':airport_country' => $airport_country, ':departure' => $departure, ':date' => $date);
837 837
                  try {
838 838
                         $sth = $this->db->prepare($query);
839 839
                         $sth->execute($query_values);
840
-                } catch(PDOException $e) {
840
+                } catch (PDOException $e) {
841 841
                         return "error : ".$e->getMessage();
842 842
                 }
843 843
         }
844
-	public function addStatArrivalAirports($airport_icao,$airport_name,$airport_city,$airport_country,$arrival) {
844
+	public function addStatArrivalAirports($airport_icao, $airport_name, $airport_city, $airport_country, $arrival) {
845 845
 		global $globalDBdriver;
846 846
 		if ($globalDBdriver == 'mysql') {
847 847
 			$query = "INSERT INTO stats_airport (airport_icao,airport_name,airport_city,airport_country,arrival,stats_type,date) VALUES (:airport_icao,:airport_name,:airport_city,:airport_country,:arrival,'yearly',:date) ON DUPLICATE KEY UPDATE arrival = arrival+:arrival";
848 848
 		} else {
849 849
 			$query = "UPDATE stats_airport SET arrival = arrival+:arrival WHERE airport_icao = :airport_icao AND stats_type = 'yearly'; INSERT INTO stats_airport (airport_icao,airport_name,airport_city,airport_country,arrival,stats_type,date) SELECT :airport_icao,:airport_name,:airport_city,:airport_country,:arrival,'yearly',:date WHERE NOT EXISTS (SELECT 1 FROM stats_airline WHERE airport_icao = :airport_icao AND stats_type = 'yearly');"; 
850 850
 		}
851
-                $query_values = array(':airport_icao' => $airport_icao,':airport_name' => $airport_name,':airport_city' => $airport_city,':airport_country' => $airport_country,':arrival' => $arrival,':date' => date('Y').'-01-01 00:00:00');
851
+                $query_values = array(':airport_icao' => $airport_icao, ':airport_name' => $airport_name, ':airport_city' => $airport_city, ':airport_country' => $airport_country, ':arrival' => $arrival, ':date' => date('Y').'-01-01 00:00:00');
852 852
                  try {
853 853
                         $sth = $this->db->prepare($query);
854 854
                         $sth->execute($query_values);
855
-                } catch(PDOException $e) {
855
+                } catch (PDOException $e) {
856 856
                         return "error : ".$e->getMessage();
857 857
                 }
858 858
         }
859
-	public function addStatArrivalAirportsDaily($date,$airport_icao,$airport_name,$airport_city,$airport_country,$arrival) {
859
+	public function addStatArrivalAirportsDaily($date, $airport_icao, $airport_name, $airport_city, $airport_country, $arrival) {
860 860
 		global $globalDBdriver;
861 861
 		if ($globalDBdriver == 'mysql') {
862 862
 			$query = "INSERT INTO stats_airport (airport_icao,airport_name,airport_city,airport_country,arrival,stats_type,date) VALUES (:airport_icao,:airport_name,:airport_city,:airport_country,:arrival,'daily',:date) ON DUPLICATE KEY UPDATE arrival = :arrival";
863 863
 		} else {
864 864
 			$query = "UPDATE stats_airport SET arrival = arrival+:arrival WHERE airport_icao = :airport_icao AND stats_type = 'daily'; INSERT INTO stats_airport (airport_icao,airport_name,airport_city,airport_country,arrival,stats_type,date) SELECT :airport_icao,:airport_name,:airport_city,:airport_country,:arrival,'yearly',:date WHERE NOT EXISTS (SELECT 1 FROM stats_airline WHERE airport_icao = :airport_icao AND stats_type = 'daily');"; 
865 865
 		}
866
-                $query_values = array(':airport_icao' => $airport_icao,':airport_name' => $airport_name,':airport_city' => $airport_city,':airport_country' => $airport_country,':arrival' => $arrival, ':date' => $date);
866
+                $query_values = array(':airport_icao' => $airport_icao, ':airport_name' => $airport_name, ':airport_city' => $airport_city, ':airport_country' => $airport_country, ':arrival' => $arrival, ':date' => $date);
867 867
                  try {
868 868
                         $sth = $this->db->prepare($query);
869 869
                         $sth->execute($query_values);
870
-                } catch(PDOException $e) {
870
+                } catch (PDOException $e) {
871 871
                         return "error : ".$e->getMessage();
872 872
                 }
873 873
         }
@@ -878,7 +878,7 @@  discard block
 block discarded – undo
878 878
                  try {
879 879
                         $sth = $this->db->prepare($query);
880 880
                         $sth->execute($query_values);
881
-                } catch(PDOException $e) {
881
+                } catch (PDOException $e) {
882 882
                         return "error : ".$e->getMessage();
883 883
                 }
884 884
         }
@@ -888,7 +888,7 @@  discard block
 block discarded – undo
888 888
                  try {
889 889
                         $sth = $this->db->prepare($query);
890 890
                         $sth->execute($query_values);
891
-                } catch(PDOException $e) {
891
+                } catch (PDOException $e) {
892 892
                         return "error : ".$e->getMessage();
893 893
                 }
894 894
         }
@@ -898,7 +898,7 @@  discard block
 block discarded – undo
898 898
                  try {
899 899
                         $sth = $this->db->prepare($query);
900 900
                         $sth->execute($query_values);
901
-                } catch(PDOException $e) {
901
+                } catch (PDOException $e) {
902 902
                         return "error : ".$e->getMessage();
903 903
                 }
904 904
         }
@@ -918,86 +918,86 @@  discard block
 block discarded – undo
918 918
 			$lastyear = false;
919 919
 			foreach ($alldata as $number) {
920 920
 				if ($number['year_name'] != date('Y')) $lastyear = true;
921
-				$this->addStat('flights_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])));
921
+				$this->addStat('flights_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])));
922 922
 			}
923 923
 			$alldata = $Spotter->countAllMilitaryMonths();
924 924
 			$lastyear = false;
925 925
 			foreach ($alldata as $number) {
926 926
 				if ($number['year_name'] != date('Y')) $lastyear = true;
927
-				$this->addStat('military_flights_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])));
927
+				$this->addStat('military_flights_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])));
928 928
 			}
929 929
 			$alldata = $Spotter->countAllMonthsOwners();
930 930
 			foreach ($alldata as $number) {
931
-				$this->addStat('owners_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])));
931
+				$this->addStat('owners_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])));
932 932
 			}
933 933
 			$alldata = $Spotter->countAllMonthsPilots();
934 934
 			foreach ($alldata as $number) {
935
-				$this->addStat('pilots_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])));
935
+				$this->addStat('pilots_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])));
936 936
 			}
937 937
 			$alldata = $Spotter->countAllMonthsAirlines();
938 938
 			foreach ($alldata as $number) {
939
-				$this->addStat('airlines_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])));
939
+				$this->addStat('airlines_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])));
940 940
 			}
941 941
 			$alldata = $Spotter->countAllMonthsAircrafts();
942 942
 			foreach ($alldata as $number) {
943
-				$this->addStat('aircrafts_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])));
943
+				$this->addStat('aircrafts_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])));
944 944
 			}
945 945
 			$alldata = $Spotter->countAllMonthsRealArrivals();
946 946
 			foreach ($alldata as $number) {
947
-				$this->addStat('realarrivals_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])));
947
+				$this->addStat('realarrivals_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])));
948 948
 			}
949 949
 			$this->deleteStatFlight('month');
950 950
 			$alldata = $Spotter->countAllDatesLastMonth();
951 951
 			foreach ($alldata as $number) {
952
-				$this->addStatFlight('month',$number['date_name'],$number['date_count']);
952
+				$this->addStatFlight('month', $number['date_name'], $number['date_count']);
953 953
 			}
954 954
 			$previousdata = $this->countAllDates();
955 955
 			$this->deleteStatFlight('date');
956
-			$alldata = $Common->array_merge_noappend($previousdata,$Spotter->countAllDates());
956
+			$alldata = $Common->array_merge_noappend($previousdata, $Spotter->countAllDates());
957 957
 			$values = array();
958 958
 			foreach ($alldata as $cnt) {
959 959
 				$values[] = $cnt['date_count'];
960 960
 			}
961
-			array_multisort($values,SORT_DESC,$alldata);
962
-			array_splice($alldata,11);
961
+			array_multisort($values, SORT_DESC, $alldata);
962
+			array_splice($alldata, 11);
963 963
 			foreach ($alldata as $number) {
964
-				$this->addStatFlight('date',$number['date_name'],$number['date_count']);
964
+				$this->addStatFlight('date', $number['date_name'], $number['date_count']);
965 965
 			}
966 966
 			$this->deleteStatFlight('hour');
967 967
 			$alldata = $Spotter->countAllHours('hour');
968 968
 			foreach ($alldata as $number) {
969
-				$this->addStatFlight('hour',$number['hour_name'],$number['hour_count']);
969
+				$this->addStatFlight('hour', $number['hour_name'], $number['hour_count']);
970 970
 			}
971 971
 			if ($lastyear) {
972 972
 				$monthsSinceLastYear = date('n');
973
-				$alldata = $Spotter->countAllAircraftTypes(false,$monthsSinceLastYear);
973
+				$alldata = $Spotter->countAllAircraftTypes(false, $monthsSinceLastYear);
974 974
 				foreach ($alldata as $number) {
975
-					$this->addStatAircraft($number['aircraft_icao'],$number['aircraft_icao_count'],$number['aircraft_name']);
975
+					$this->addStatAircraft($number['aircraft_icao'], $number['aircraft_icao_count'], $number['aircraft_name']);
976 976
 				}
977
-				$alldata = $Spotter->countAllAirlines(false,$monthsSinceLastYear);
977
+				$alldata = $Spotter->countAllAirlines(false, $monthsSinceLastYear);
978 978
 				foreach ($alldata as $number) {
979
-					$this->addStatAirline($number['airline_icao'],$number['airline_count'],$number['airline_name']);
979
+					$this->addStatAirline($number['airline_icao'], $number['airline_count'], $number['airline_name']);
980 980
 				}
981 981
 				if ($Connection->tableExists('countries')) {
982
-					$alldata = $Spotter->countAllFlightOverCountries(false,$monthsSinceLastYear);
982
+					$alldata = $Spotter->countAllFlightOverCountries(false, $monthsSinceLastYear);
983 983
 					foreach ($alldata as $number) {
984
-						$this->addStatCountry($number['flight_country_iso2'],$number['flight_country_iso3'],$number['flight_country'],$number['flight_count']);
984
+						$this->addStatCountry($number['flight_country_iso2'], $number['flight_country_iso3'], $number['flight_country'], $number['flight_count']);
985 985
 					}
986 986
 				}
987
-				$alldata = $Spotter->countAllOwners(false,$monthsSinceLastYear);
987
+				$alldata = $Spotter->countAllOwners(false, $monthsSinceLastYear);
988 988
 				foreach ($alldata as $number) {
989
-					$this->addStatOwner($number['owner_name'],$number['owner_count']);
989
+					$this->addStatOwner($number['owner_name'], $number['owner_count']);
990 990
 				}
991
-				$alldata = $Spotter->countAllPilots(false,$monthsSinceLastYear);
991
+				$alldata = $Spotter->countAllPilots(false, $monthsSinceLastYear);
992 992
 				foreach ($alldata as $number) {
993
-					$this->addStatPilot($number['pilot_id'],$number['pilot_count']);
993
+					$this->addStatPilot($number['pilot_id'], $number['pilot_count']);
994 994
 				}
995 995
 				$previous_year = date('Y');
996 996
 				$previous_year--;
997
-				$this->addStat('aircrafts_byyear',$this->getStatsAircraftTotal(),$previous_year.'-01-01 00:00:00');
998
-				$this->addStat('airlines_byyear',$this->getStatsAirlineTotal(),$previous_year.'-01-01 00:00:00');
999
-				$this->addStat('owner_byyear',$this->getStatsOwnerTotal(),$previous_year.'-01-01 00:00:00');
1000
-				$this->addStat('pilot_byyear',$this->getStatsPilotTotal(),$previous_year.'-01-01 00:00:00');
997
+				$this->addStat('aircrafts_byyear', $this->getStatsAircraftTotal(), $previous_year.'-01-01 00:00:00');
998
+				$this->addStat('airlines_byyear', $this->getStatsAirlineTotal(), $previous_year.'-01-01 00:00:00');
999
+				$this->addStat('owner_byyear', $this->getStatsOwnerTotal(), $previous_year.'-01-01 00:00:00');
1000
+				$this->addStat('pilot_byyear', $this->getStatsPilotTotal(), $previous_year.'-01-01 00:00:00');
1001 1001
 				
1002 1002
 				if (isset($globalArchiveYear) && $globalArchiveYear) {
1003 1003
 					if ($globalArchive) {
@@ -1006,7 +1006,7 @@  discard block
 block discarded – undo
1006 1006
 						try {
1007 1007
 							$sth = $this->db->prepare($query);
1008 1008
 							$sth->execute();
1009
-						} catch(PDOException $e) {
1009
+						} catch (PDOException $e) {
1010 1010
 							return "error : ".$e->getMessage().' - query : '.$query."\n";
1011 1011
 						}
1012 1012
 					}
@@ -1014,45 +1014,45 @@  discard block
 block discarded – undo
1014 1014
 					try {
1015 1015
 						$sth = $this->db->prepare($query);
1016 1016
 						$sth->execute();
1017
-					} catch(PDOException $e) {
1017
+					} catch (PDOException $e) {
1018 1018
 						return "error : ".$e->getMessage().' - query : '.$query."\n";
1019 1019
 					}
1020 1020
 				}
1021 1021
 			}
1022 1022
 			if (!isset($globalArchiveMonths) || $globalArchiveMonths == '') $globalArchiveMonths = 2;
1023 1023
 			if ($globalArchiveMonths > 0) {
1024
-				$alldata = $Spotter->countAllAircraftTypes(false,$globalArchiveMonths);
1024
+				$alldata = $Spotter->countAllAircraftTypes(false, $globalArchiveMonths);
1025 1025
 				foreach ($alldata as $number) {
1026
-					$this->addStatAircraft($number['aircraft_icao'],$number['aircraft_icao_count'],$number['aircraft_name']);
1026
+					$this->addStatAircraft($number['aircraft_icao'], $number['aircraft_icao_count'], $number['aircraft_name']);
1027 1027
 				}
1028
-				$alldata = $Spotter->countAllAirlines(false,$globalArchiveMonths);
1028
+				$alldata = $Spotter->countAllAirlines(false, $globalArchiveMonths);
1029 1029
 				foreach ($alldata as $number) {
1030
-					$this->addStatAirline($number['airline_icao'],$number['airline_count'],$number['airline_name']);
1030
+					$this->addStatAirline($number['airline_icao'], $number['airline_count'], $number['airline_name']);
1031 1031
 				}
1032
-				$alldata = $Spotter->countAllAircraftRegistrations(false,$globalArchiveMonths);
1032
+				$alldata = $Spotter->countAllAircraftRegistrations(false, $globalArchiveMonths);
1033 1033
 				foreach ($alldata as $number) {
1034
-					$this->addStatAircraftRegistration($number['registration'],$number['aircraft_registration_count'],$number['aircraft_icao']);
1034
+					$this->addStatAircraftRegistration($number['registration'], $number['aircraft_registration_count'], $number['aircraft_icao']);
1035 1035
 				}
1036
-				$alldata = $Spotter->countAllCallsigns(false,$globalArchiveMonths);
1036
+				$alldata = $Spotter->countAllCallsigns(false, $globalArchiveMonths);
1037 1037
 				foreach ($alldata as $number) {
1038
-					$this->addStatCallsign($number['callsign_icao'],$number['callsign_icao_count'],$number['airline_icao']);
1038
+					$this->addStatCallsign($number['callsign_icao'], $number['callsign_icao_count'], $number['airline_icao']);
1039 1039
 				}
1040
-				$alldata = $Spotter->countAllOwners(false,$globalArchiveMonths);
1040
+				$alldata = $Spotter->countAllOwners(false, $globalArchiveMonths);
1041 1041
 				foreach ($alldata as $number) {
1042
-					$this->addStatOwner($number['owner_name'],$number['owner_count']);
1042
+					$this->addStatOwner($number['owner_name'], $number['owner_count']);
1043 1043
 				}
1044 1044
 				if ($Connection->tableExists('countries')) {
1045
-					$alldata = $Spotter->countAllFlightOverCountries(false,$globalArchiveMonths);
1045
+					$alldata = $Spotter->countAllFlightOverCountries(false, $globalArchiveMonths);
1046 1046
 					foreach ($alldata as $number) {
1047
-						$this->addStatCountry($number['flight_country_iso2'],$number['flight_country_iso3'],$number['flight_country'],$number['flight_count']);
1047
+						$this->addStatCountry($number['flight_country_iso2'], $number['flight_country_iso3'], $number['flight_country'], $number['flight_count']);
1048 1048
 					}
1049 1049
 				}
1050
-				$alldata = $Spotter->countAllPilots(false,$globalArchiveMonths);
1050
+				$alldata = $Spotter->countAllPilots(false, $globalArchiveMonths);
1051 1051
 				foreach ($alldata as $number) {
1052
-					$this->addStatPilot($number['pilot_id'],$number['pilot_count']);
1052
+					$this->addStatPilot($number['pilot_id'], $number['pilot_count']);
1053 1053
 				}
1054
-				$pall = $Spotter->countAllDepartureAirports(false,$globalArchiveMonths);
1055
-        			$dall = $Spotter->countAllDetectedDepartureAirports(false,$globalArchiveMonths);
1054
+				$pall = $Spotter->countAllDepartureAirports(false, $globalArchiveMonths);
1055
+        			$dall = $Spotter->countAllDetectedDepartureAirports(false, $globalArchiveMonths);
1056 1056
 	        		$alldata = array();
1057 1057
     				foreach ($pall as $value) {
1058 1058
 	        			$icao = $value['airport_departure_icao'];
@@ -1068,14 +1068,14 @@  discard block
 block discarded – undo
1068 1068
         			foreach ($alldata as $key => $row) {
1069 1069
         				$count[$key] = $row['airport_departure_icao_count'];
1070 1070
 	        		}
1071
-    				array_multisort($count,SORT_DESC,$alldata);
1071
+    				array_multisort($count, SORT_DESC, $alldata);
1072 1072
 
1073 1073
 				//print_r($alldate);
1074 1074
 				foreach ($alldata as $number) {
1075
-					$this->addStatDepartureAirports($number['airport_departure_icao'],$number['airport_departure_name'],$number['airport_departure_city'],$number['airport_departure_country'],$number['airport_departure_icao_count']);
1075
+					$this->addStatDepartureAirports($number['airport_departure_icao'], $number['airport_departure_name'], $number['airport_departure_city'], $number['airport_departure_country'], $number['airport_departure_icao_count']);
1076 1076
 				}
1077
-				$pdata = $Spotter->countAllArrivalAirports(false,$globalArchiveMonths);
1078
-        			$dall = $Spotter->countAllDetectedArrivalAirports(false,$globalArchiveMonths);
1077
+				$pdata = $Spotter->countAllArrivalAirports(false, $globalArchiveMonths);
1078
+        			$dall = $Spotter->countAllDetectedArrivalAirports(false, $globalArchiveMonths);
1079 1079
 	        		$alldata = array();
1080 1080
     				foreach ($pdata as $value) {
1081 1081
 	        			$icao = $value['airport_arrival_icao'];
@@ -1091,14 +1091,14 @@  discard block
 block discarded – undo
1091 1091
         			foreach ($alldata as $key => $row) {
1092 1092
         				$count[$key] = $row['airport_arrival_icao_count'];
1093 1093
 	        		}
1094
-    				array_multisort($count,SORT_DESC,$alldata);
1094
+    				array_multisort($count, SORT_DESC, $alldata);
1095 1095
 				foreach ($alldata as $number) {
1096
-					$this->addStatArrivalAirports($number['airport_arrival_icao'],$number['airport_arrival_name'],$number['airport_arrival_city'],$number['airport_arrival_country'],$number['airport_arrival_icao_count']);
1096
+					$this->addStatArrivalAirports($number['airport_arrival_icao'], $number['airport_arrival_name'], $number['airport_arrival_city'], $number['airport_arrival_country'], $number['airport_arrival_icao_count']);
1097 1097
 				}
1098
-				$this->addStat('aircrafts_byyear',$this->getStatsAircraftTotal(),date('Y').'-01-01 00:00:00');
1099
-				$this->addStat('airlines_byyear',$this->getStatsAirlineTotal(),date('Y').'-01-01 00:00:00');
1100
-				$this->addStat('owner_byyear',$this->getStatsOwnerTotal(),date('Y').'-01-01 00:00:00');
1101
-				$this->addStat('pilot_byyear',$this->getStatsPilotTotal(),date('Y').'-01-01 00:00:00');
1098
+				$this->addStat('aircrafts_byyear', $this->getStatsAircraftTotal(), date('Y').'-01-01 00:00:00');
1099
+				$this->addStat('airlines_byyear', $this->getStatsAirlineTotal(), date('Y').'-01-01 00:00:00');
1100
+				$this->addStat('owner_byyear', $this->getStatsOwnerTotal(), date('Y').'-01-01 00:00:00');
1101
+				$this->addStat('pilot_byyear', $this->getStatsPilotTotal(), date('Y').'-01-01 00:00:00');
1102 1102
 			
1103 1103
 				if ($globalArchive) {
1104 1104
 					if ($globalDBdriver == 'mysql') {
@@ -1109,7 +1109,7 @@  discard block
 block discarded – undo
1109 1109
 					try {
1110 1110
 						$sth = $this->db->prepare($query);
1111 1111
 						$sth->execute();
1112
-					} catch(PDOException $e) {
1112
+					} catch (PDOException $e) {
1113 1113
 						return "error : ".$e->getMessage().' - query : '.$query."\n";
1114 1114
 					}
1115 1115
 				}
@@ -1123,43 +1123,43 @@  discard block
 block discarded – undo
1123 1123
 				try {
1124 1124
 					$sth = $this->db->prepare($query);
1125 1125
 					$sth->execute();
1126
-				} catch(PDOException $e) {
1126
+				} catch (PDOException $e) {
1127 1127
 					return "error : ".$e->getMessage().' - query : '.$query."\n";
1128 1128
 				}
1129 1129
 			}
1130
-			$this->addLastStatsUpdate('last_update_stats',date('Y-m-d G:i:s'));
1130
+			$this->addLastStatsUpdate('last_update_stats', date('Y-m-d G:i:s'));
1131 1131
 		} else {
1132 1132
 			echo 'Update stats !'."\n";
1133 1133
 			if (isset($last_update[0]['value'])) {
1134 1134
 				$last_update_day = $last_update[0]['value'];
1135 1135
 			} else $last_update_day = '2012-12-12 12:12:12';
1136 1136
 			$Spotter = new Spotter($this->db);
1137
-			$alldata = $Spotter->countAllAircraftTypes(false,0,$last_update_day);
1137
+			$alldata = $Spotter->countAllAircraftTypes(false, 0, $last_update_day);
1138 1138
 			foreach ($alldata as $number) {
1139
-				$this->addStatAircraft($number['aircraft_icao'],$number['aircraft_icao_count'],$number['aircraft_name']);
1139
+				$this->addStatAircraft($number['aircraft_icao'], $number['aircraft_icao_count'], $number['aircraft_name']);
1140 1140
 			}
1141
-			$alldata = $Spotter->countAllAirlines(false,0,$last_update_day);
1141
+			$alldata = $Spotter->countAllAirlines(false, 0, $last_update_day);
1142 1142
 			foreach ($alldata as $number) {
1143
-				$this->addStatAirline($number['airline_icao'],$number['airline_count'],$number['airline_name']);
1143
+				$this->addStatAirline($number['airline_icao'], $number['airline_count'], $number['airline_name']);
1144 1144
 			}
1145
-			$alldata = $Spotter->countAllAircraftRegistrations(false,0,$last_update_day);
1145
+			$alldata = $Spotter->countAllAircraftRegistrations(false, 0, $last_update_day);
1146 1146
 			foreach ($alldata as $number) {
1147
-				$this->addStatAircraftRegistration($number['registration'],$number['aircraft_registration_count'],$number['aircraft_icao']);
1147
+				$this->addStatAircraftRegistration($number['registration'], $number['aircraft_registration_count'], $number['aircraft_icao']);
1148 1148
 			}
1149
-			$alldata = $Spotter->countAllCallsigns(false,0,$last_update_day);
1149
+			$alldata = $Spotter->countAllCallsigns(false, 0, $last_update_day);
1150 1150
 			foreach ($alldata as $number) {
1151
-				$this->addStatCallsign($number['callsign_icao'],$number['callsign_icao_count'],$number['airline_icao']);
1151
+				$this->addStatCallsign($number['callsign_icao'], $number['callsign_icao_count'], $number['airline_icao']);
1152 1152
 			}
1153
-			$alldata = $Spotter->countAllOwners(false,0,$last_update_day);
1153
+			$alldata = $Spotter->countAllOwners(false, 0, $last_update_day);
1154 1154
 			foreach ($alldata as $number) {
1155
-				$this->addStatOwner($number['owner_name'],$number['owner_count']);
1155
+				$this->addStatOwner($number['owner_name'], $number['owner_count']);
1156 1156
 			}
1157
-			$alldata = $Spotter->countAllPilots(false,0,$last_update_day);
1157
+			$alldata = $Spotter->countAllPilots(false, 0, $last_update_day);
1158 1158
 			foreach ($alldata as $number) {
1159
-				$this->addStatPilot($number['pilot_id'],$number['pilot_count']);
1159
+				$this->addStatPilot($number['pilot_id'], $number['pilot_count']);
1160 1160
 			}
1161
-			$pall = $Spotter->countAllDepartureAirports(false,0,$last_update_day);
1162
-        		$dall = $Spotter->countAllDetectedDepartureAirports(false,0,$last_update_day);
1161
+			$pall = $Spotter->countAllDepartureAirports(false, 0, $last_update_day);
1162
+        		$dall = $Spotter->countAllDetectedDepartureAirports(false, 0, $last_update_day);
1163 1163
 	        	$alldata = array();
1164 1164
     			foreach ($pall as $value) {
1165 1165
 	        		$icao = $value['airport_departure_icao'];
@@ -1175,13 +1175,13 @@  discard block
 block discarded – undo
1175 1175
     			foreach ($alldata as $key => $row) {
1176 1176
     				$count[$key] = $row['airport_departure_icao_count'];
1177 1177
         		}
1178
-			array_multisort($count,SORT_DESC,$alldata);
1178
+			array_multisort($count, SORT_DESC, $alldata);
1179 1179
 
1180 1180
 			foreach ($alldata as $number) {
1181
-				$this->addStatDepartureAirports($number['airport_departure_icao'],$number['airport_departure_name'],$number['airport_departure_city'],$number['airport_departure_country'],$number['airport_departure_icao_count']);
1181
+				$this->addStatDepartureAirports($number['airport_departure_icao'], $number['airport_departure_name'], $number['airport_departure_city'], $number['airport_departure_country'], $number['airport_departure_icao_count']);
1182 1182
 			}
1183
-			$pall = $Spotter->countAllArrivalAirports(false,0,$last_update_day);
1184
-        		$dall = $Spotter->countAllDetectedArrivalAirports(false,0,$last_update_day);
1183
+			$pall = $Spotter->countAllArrivalAirports(false, 0, $last_update_day);
1184
+        		$dall = $Spotter->countAllDetectedArrivalAirports(false, 0, $last_update_day);
1185 1185
 	        	$alldata = array();
1186 1186
     			foreach ($pall as $value) {
1187 1187
 	        		$icao = $value['airport_arrival_icao'];
@@ -1197,15 +1197,15 @@  discard block
 block discarded – undo
1197 1197
         		foreach ($alldata as $key => $row) {
1198 1198
         			$count[$key] = $row['airport_arrival_icao_count'];
1199 1199
 	        	}
1200
-    			array_multisort($count,SORT_DESC,$alldata);
1200
+    			array_multisort($count, SORT_DESC, $alldata);
1201 1201
                         foreach ($alldata as $number) {
1202
-				$this->addStatArrivalAirports($number['airport_arrival_icao'],$number['airport_arrival_name'],$number['airport_arrival_city'],$number['airport_arrival_country'],$number['airport_arrival_icao_count']);
1202
+				$this->addStatArrivalAirports($number['airport_arrival_icao'], $number['airport_arrival_name'], $number['airport_arrival_city'], $number['airport_arrival_country'], $number['airport_arrival_icao_count']);
1203 1203
 			}
1204 1204
 			if ($Connection->tableExists('countries')) {
1205 1205
 				$SpotterArchive = new SpotterArchive();
1206
-				$alldata = $SpotterArchive->countAllFlightOverCountries(false,0,$last_update_day);
1206
+				$alldata = $SpotterArchive->countAllFlightOverCountries(false, 0, $last_update_day);
1207 1207
 				foreach ($alldata as $number) {
1208
-					$this->addStatCountry($number['flight_country_iso2'],$number['flight_country_iso3'],$number['flight_country'],$number['flight_count']);
1208
+					$this->addStatCountry($number['flight_country_iso2'], $number['flight_country_iso3'], $number['flight_country'], $number['flight_count']);
1209 1209
 				}
1210 1210
 			}
1211 1211
 			
@@ -1218,31 +1218,31 @@  discard block
 block discarded – undo
1218 1218
 			$lastyear = false;
1219 1219
 			foreach ($alldata as $number) {
1220 1220
 				if ($number['year_name'] != date('Y')) $lastyear = true;
1221
-				$this->addStat('flights_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])));
1221
+				$this->addStat('flights_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])));
1222 1222
 			}
1223 1223
 			$alldata = $Spotter->countAllMilitaryMonths();
1224 1224
 			foreach ($alldata as $number) {
1225
-				$this->addStat('military_flights_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])));
1225
+				$this->addStat('military_flights_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])));
1226 1226
 			}
1227 1227
 			$alldata = $Spotter->countAllMonthsOwners();
1228 1228
 			foreach ($alldata as $number) {
1229
-				$this->addStat('owners_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])));
1229
+				$this->addStat('owners_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])));
1230 1230
 			}
1231 1231
 			$alldata = $Spotter->countAllMonthsPilots();
1232 1232
 			foreach ($alldata as $number) {
1233
-				$this->addStat('pilots_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])));
1233
+				$this->addStat('pilots_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])));
1234 1234
 			}
1235 1235
 			$alldata = $Spotter->countAllMonthsAirlines();
1236 1236
 			foreach ($alldata as $number) {
1237
-				$this->addStat('airlines_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])));
1237
+				$this->addStat('airlines_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])));
1238 1238
 			}
1239 1239
 			$alldata = $Spotter->countAllMonthsAircrafts();
1240 1240
 			foreach ($alldata as $number) {
1241
-				$this->addStat('aircrafts_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])));
1241
+				$this->addStat('aircrafts_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])));
1242 1242
 			}
1243 1243
 			$alldata = $Spotter->countAllMonthsRealArrivals();
1244 1244
 			foreach ($alldata as $number) {
1245
-				$this->addStat('realarrivals_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])));
1245
+				$this->addStat('realarrivals_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])));
1246 1246
 			}
1247 1247
 			echo 'Airports data...'."\n";
1248 1248
 			echo '...Departure'."\n";
@@ -1264,9 +1264,9 @@  discard block
 block discarded – undo
1264 1264
         		foreach ($alldata as $key => $row) {
1265 1265
         			$count[$key] = $row['departure_airport_count'];
1266 1266
 	        	}
1267
-    			array_multisort($count,SORT_DESC,$alldata);
1267
+    			array_multisort($count, SORT_DESC, $alldata);
1268 1268
 			foreach ($alldata as $number) {
1269
-				$this->addStatDepartureAirportsDaily($number['date'],$number['departure_airport_icao'],$number['departure_airport_name'],$number['departure_airport_city'],$number['departure_airport_country'],$number['departure_airport_count']);
1269
+				$this->addStatDepartureAirportsDaily($number['date'], $number['departure_airport_icao'], $number['departure_airport_name'], $number['departure_airport_city'], $number['departure_airport_country'], $number['departure_airport_count']);
1270 1270
 			}
1271 1271
 			echo '...Arrival'."\n";
1272 1272
 			$pall = $Spotter->getLast7DaysAirportsArrival();
@@ -1286,10 +1286,10 @@  discard block
 block discarded – undo
1286 1286
         		foreach ($alldata as $key => $row) {
1287 1287
         			$count[$key] = $row['arrival_airport_count'];
1288 1288
 	        	}
1289
-    			array_multisort($count,SORT_DESC,$alldata);
1289
+    			array_multisort($count, SORT_DESC, $alldata);
1290 1290
 
1291 1291
 			foreach ($alldata as $number) {
1292
-				$this->addStatArrivalAirportsDaily($number['date'],$number['arrival_airport_icao'],$number['arrival_airport_name'],$number['arrival_airport_city'],$number['arrival_airport_country'],$number['arrival_airport_count']);
1292
+				$this->addStatArrivalAirportsDaily($number['date'], $number['arrival_airport_icao'], $number['arrival_airport_name'], $number['arrival_airport_city'], $number['arrival_airport_country'], $number['arrival_airport_count']);
1293 1293
 			}
1294 1294
 
1295 1295
 			echo 'Flights data...'."\n";
@@ -1297,37 +1297,37 @@  discard block
 block discarded – undo
1297 1297
 			echo '-> countAllDatesLastMonth...'."\n";
1298 1298
 			$alldata = $Spotter->countAllDatesLastMonth();
1299 1299
 			foreach ($alldata as $number) {
1300
-				$this->addStatFlight('month',$number['date_name'],$number['date_count']);
1300
+				$this->addStatFlight('month', $number['date_name'], $number['date_count']);
1301 1301
 			}
1302 1302
 			echo '-> countAllDates...'."\n";
1303 1303
 			$previousdata = $this->countAllDates();
1304 1304
 			$this->deleteStatFlight('date');
1305
-			$alldata = $Common->array_merge_noappend($previousdata,$Spotter->countAllDates());
1305
+			$alldata = $Common->array_merge_noappend($previousdata, $Spotter->countAllDates());
1306 1306
 			$values = array();
1307 1307
 			foreach ($alldata as $cnt) {
1308 1308
 				$values[] = $cnt['date_count'];
1309 1309
 			}
1310
-			array_multisort($values,SORT_DESC,$alldata);
1311
-			array_splice($alldata,11);
1310
+			array_multisort($values, SORT_DESC, $alldata);
1311
+			array_splice($alldata, 11);
1312 1312
 			foreach ($alldata as $number) {
1313
-				$this->addStatFlight('date',$number['date_name'],$number['date_count']);
1313
+				$this->addStatFlight('date', $number['date_name'], $number['date_count']);
1314 1314
 			}
1315 1315
 			
1316 1316
 			$this->deleteStatFlight('hour');
1317 1317
 			echo '-> countAllHours...'."\n";
1318 1318
 			$alldata = $Spotter->countAllHours('hour');
1319 1319
 			foreach ($alldata as $number) {
1320
-				$this->addStatFlight('hour',$number['hour_name'],$number['hour_count']);
1320
+				$this->addStatFlight('hour', $number['hour_name'], $number['hour_count']);
1321 1321
 			}
1322 1322
 			if ($lastyear) {
1323 1323
 				echo 'Data from last year...'."\n";
1324 1324
 				// SUM all previous month to put as year
1325 1325
 				$previous_year = date('Y');
1326 1326
 				$previous_year--;
1327
-				$this->addStat('aircrafts_byyear',$this->getSumStats('aircrafts_bymonth',$previous_year),$previous_year.'-01-01 00:00:00');
1328
-				$this->addStat('airlines_byyear',$this->getSumStats('airlines_bymonth',$previous_year),$previous_year.'-01-01 00:00:00');
1329
-				$this->addStat('owner_byyear',$this->getSumStats('owner_bymonth',$previous_year),$previous_year.'-01-01 00:00:00');
1330
-				$this->addStat('pilot_byyear',$this->getSumStats('pilot_bymonth',$previous_year),$previous_year.'-01-01 00:00:00');
1327
+				$this->addStat('aircrafts_byyear', $this->getSumStats('aircrafts_bymonth', $previous_year), $previous_year.'-01-01 00:00:00');
1328
+				$this->addStat('airlines_byyear', $this->getSumStats('airlines_bymonth', $previous_year), $previous_year.'-01-01 00:00:00');
1329
+				$this->addStat('owner_byyear', $this->getSumStats('owner_bymonth', $previous_year), $previous_year.'-01-01 00:00:00');
1330
+				$this->addStat('pilot_byyear', $this->getSumStats('pilot_bymonth', $previous_year), $previous_year.'-01-01 00:00:00');
1331 1331
 				
1332 1332
 				if (isset($globalArchiveYear) && $globalArchiveYear) {
1333 1333
 					if ($globalArchive) {
@@ -1335,7 +1335,7 @@  discard block
 block discarded – undo
1335 1335
 						try {
1336 1336
 							$sth = $this->db->prepare($query);
1337 1337
 							$sth->execute();
1338
-						} catch(PDOException $e) {
1338
+						} catch (PDOException $e) {
1339 1339
 							return "error : ".$e->getMessage().' - query : '.$query."\n";
1340 1340
 						}
1341 1341
 					}
@@ -1344,7 +1344,7 @@  discard block
 block discarded – undo
1344 1344
 					try {
1345 1345
 						$sth = $this->db->prepare($query);
1346 1346
 						$sth->execute();
1347
-					} catch(PDOException $e) {
1347
+					} catch (PDOException $e) {
1348 1348
 						return "error : ".$e->getMessage().' - query : '.$query."\n";
1349 1349
 					}
1350 1350
 				}
@@ -1366,7 +1366,7 @@  discard block
 block discarded – undo
1366 1366
 					try {
1367 1367
 						$sth = $this->db->prepare($query);
1368 1368
 						$sth->execute();
1369
-					} catch(PDOException $e) {
1369
+					} catch (PDOException $e) {
1370 1370
 						return "error : ".$e->getMessage();
1371 1371
 					}
1372 1372
 				}
@@ -1380,13 +1380,13 @@  discard block
 block discarded – undo
1380 1380
 				try {
1381 1381
 					$sth = $this->db->prepare($query);
1382 1382
 					$sth->execute();
1383
-				} catch(PDOException $e) {
1383
+				} catch (PDOException $e) {
1384 1384
 					return "error : ".$e->getMessage();
1385 1385
 				}
1386 1386
 			}
1387 1387
 			echo 'Insert last stats update date...'."\n";
1388 1388
 			date_default_timezone_set('UTC');
1389
-			$this->addLastStatsUpdate('last_update_stats',date('Y-m-d G:i:s'));
1389
+			$this->addLastStatsUpdate('last_update_stats', date('Y-m-d G:i:s'));
1390 1390
 		}
1391 1391
 	}
1392 1392
 }
Please login to merge, or discard this patch.
require/class.METAR.php 1 patch
Spacing   +44 added lines, -44 removed lines patch added patch discarded remove patch
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
                         $Connection = new Connection();
55 55
                         $sth = $Connection->db->prepare($query);
56 56
                         $sth->execute();
57
-                } catch(PDOException $e) {
57
+                } catch (PDOException $e) {
58 58
                         return "error : ".$e->getMessage();
59 59
                 }
60 60
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
                         $Connection = new Connection();
70 70
                         $sth = $Connection->db->prepare($query);
71 71
                         $sth->execute();
72
-                } catch(PDOException $e) {
72
+                } catch (PDOException $e) {
73 73
                         return "error : ".$e->getMessage();
74 74
                 }
75 75
         }
@@ -79,34 +79,34 @@  discard block
 block discarded – undo
79 79
         public function parse($data) {
80 80
     		//$data = str_replace(array('\n','\r','\r','\n'),'',$data);
81 81
     		$codes = implode('|', array_keys($this->texts));
82
-    		$regWeather = '#^(\+|\-|VC)?(' . $codes . ')(' . $codes . ')?$#';
82
+    		$regWeather = '#^(\+|\-|VC)?('.$codes.')('.$codes.')?$#';
83 83
     		//$pieces = explode(' ',$data);
84
-    		$pieces = preg_split('/\s/',$data);
84
+    		$pieces = preg_split('/\s/', $data);
85 85
     		$pos = 0;
86 86
     		if ($pieces[0] == 'METAR') $pos++;
87 87
     		elseif ($pieces[0] == 'SPECI') $pos++;
88 88
     		if (strlen($pieces[$pos]) != 4) $pos++;
89 89
     		$result['location'] = $pieces[$pos];
90 90
     		$pos++;
91
-    		$result['dayofmonth'] = substr($pieces[$pos],0,2);
92
-    		$result['time'] = substr($pieces[$pos],2,4);
91
+    		$result['dayofmonth'] = substr($pieces[$pos], 0, 2);
92
+    		$result['time'] = substr($pieces[$pos], 2, 4);
93 93
     		$c = count($pieces);
94
-    		for($pos++; $pos < $c; $pos++) {
94
+    		for ($pos++; $pos < $c; $pos++) {
95 95
     			$piece = $pieces[$pos];
96 96
     			if ($piece == 'RMK') break;
97 97
     			if ($piece == 'AUTO') $result['auto'] = true;
98 98
     			if ($piece == 'COR') $result['correction'] = true;
99 99
     			// Wind Speed
100 100
     			if (preg_match('#(VRB|\d\d\d)(\d\d)(?:G(\d\d))?(KT|MPS|KPH)(?: (\d{1,3})V(\d{1,3}))?$#', $piece, $matches)) {
101
-    				$result['wind']['direction'] = (float)$matches[1];
101
+    				$result['wind']['direction'] = (float) $matches[1];
102 102
 				$result['wind']['unit'] = $matches[4];
103
-    				if ($result['wind']['unit'] == 'KT') $result['wind']['speed'] = round(((float)$matches[2])*0.51444444444,2);
104
-    				elseif ($result['wind']['unit'] == 'KPH') $result['wind']['speed'] = round(((float)$matches[2])*1000,2);
105
-    				elseif ($result['wind']['unit'] == 'MPS') $result['wind']['speed'] = round(((float)$matches[2]),2);
106
-				$result['wind']['gust'] = (float)$matches[3];
103
+    				if ($result['wind']['unit'] == 'KT') $result['wind']['speed'] = round(((float) $matches[2])*0.51444444444, 2);
104
+    				elseif ($result['wind']['unit'] == 'KPH') $result['wind']['speed'] = round(((float) $matches[2])*1000, 2);
105
+    				elseif ($result['wind']['unit'] == 'MPS') $result['wind']['speed'] = round(((float) $matches[2]), 2);
106
+				$result['wind']['gust'] = (float) $matches[3];
107 107
 				$result['wind']['unit'] = $matches[4];
108
-				$result['wind']['min_variation'] = array_key_exists(5,$matches) ? $matches[5] : 0;
109
-				$result['wind']['max_variation'] = array_key_exists(6,$matches) ? $matches[6] : 0;
108
+				$result['wind']['min_variation'] = array_key_exists(5, $matches) ? $matches[5] : 0;
109
+				$result['wind']['max_variation'] = array_key_exists(6, $matches) ? $matches[6] : 0;
110 110
     			}
111 111
 
112 112
 /*    			if (preg_match('#^([0-9]{3})([0-9]{2})(G([0-9]{2}))?(KT|MPS)$#', $piece, $matches)) {
@@ -126,14 +126,14 @@  discard block
 block discarded – undo
126 126
     			*/
127 127
     			// Temperature
128 128
     			if (preg_match('#^(M?[0-9]{2,})/(M?[0-9]{2,})$#', $piece, $matches)) {
129
-    				$temp = (float)$matches[1];
129
+    				$temp = (float) $matches[1];
130 130
 				if ($matches[1]{0} == 'M') {
131
-					$temp = ((float)substr($matches[1], 1)) * -1;
131
+					$temp = ((float) substr($matches[1], 1))*-1;
132 132
 				}
133 133
     				$result['temperature'] = $temp;
134
-    				$dew = (float)$matches[2];
134
+    				$dew = (float) $matches[2];
135 135
 				if ($matches[2]{0} == 'M') {
136
-					$dew = ((float)substr($matches[2], 1)) * -1;
136
+					$dew = ((float) substr($matches[2], 1))*-1;
137 137
 				}
138 138
 				$result['dew'] = $dew;
139 139
     			}
@@ -145,7 +145,7 @@  discard block
 block discarded – undo
145 145
     					$result['QNH'] = $matches[2];
146 146
     				} else {
147 147
     					// inHg
148
-    					$result['QNH'] = round(($matches[2] / 100)*33.86389,2);
148
+    					$result['QNH'] = round(($matches[2]/100)*33.86389, 2);
149 149
 				}
150 150
     				/*
151 151
     				$result['QNH'] = $matches[1] == 'Q' ? $matches[2] : ($matches[2] / 100);
@@ -166,12 +166,12 @@  discard block
 block discarded – undo
166 166
     			// Visibility
167 167
     			if (preg_match('#^([0-9]{4})|(([0-9]{1,4})SM)$#', $piece, $matches)) {
168 168
     				if (isset($matches[3]) && strlen($matches[3]) > 0) {
169
-					$result['visibility'] = (float)$matches[3] * 1609.34;
169
+					$result['visibility'] = (float) $matches[3]*1609.34;
170 170
 				} else {
171 171
 					if ($matches[1] == '9999') {
172 172
 						$result['visibility'] = '> 10000';
173 173
 					} else {
174
-						$result['visibility'] = (float)$matches[1];
174
+						$result['visibility'] = (float) $matches[1];
175 175
 					}
176 176
 				}
177 177
 				if (preg_match('#^CAVOK$#', $piece, $matches)) {
@@ -192,7 +192,7 @@  discard block
 block discarded – undo
192 192
     				elseif ($type == 'OVC') $cloud['type'] = 'Overcast/Full cloud coverage';
193 193
     				elseif ($type == 'VV') $cloud['type'] = 'Vertical visibility';
194 194
     				$cloud['type_code'] = $type;
195
-    				$cloud['level'] = round(((float)$matches[2]) * 100 * 0.3048);
195
+    				$cloud['level'] = round(((float) $matches[2])*100*0.3048);
196 196
     				$cloud['significant'] = isset($matches[3]) ? $matches[3] : '';
197 197
     				$result['cloud'][] = $cloud;
198 198
     			}
@@ -201,8 +201,8 @@  discard block
 block discarded – undo
201 201
 				$rvr['runway'] = $matches[1];
202 202
 				$rvr['assessment'] = $matches[2];
203 203
 				$rvr['rvr'] = $matches[3];
204
-				$rvr['rvr_max'] = array_key_exists(4,$matches) ? $matches[4] : 0;
205
-				$rvr['unit'] = array_key_exists(5,$matches) ? $matches[5] : '';
204
+				$rvr['rvr_max'] = array_key_exists(4, $matches) ? $matches[4] : 0;
205
+				$rvr['unit'] = array_key_exists(5, $matches) ? $matches[5] : '';
206 206
 				$result['RVR'] = $rvr;
207 207
 			}
208 208
     			
@@ -219,12 +219,12 @@  discard block
 block discarded – undo
219 219
     			if (preg_match('#^(R[A-Z0-9]{2,3})/([0-9]{4})(V([0-9]{4}))?(FT)?$#', $piece, $matches)) {
220 220
     				//echo $piece;
221 221
     				//print_r($matches);
222
-    				if (isset($matches[5])) $range = array('exact' => (float)$matches[2], 'unit' => $matches[5] ? 'FT' : 'M');
223
-    				else $range = array('exact' => (float)$matches[2], 'unit' => 'M');
222
+    				if (isset($matches[5])) $range = array('exact' => (float) $matches[2], 'unit' => $matches[5] ? 'FT' : 'M');
223
+    				else $range = array('exact' => (float) $matches[2], 'unit' => 'M');
224 224
 				if (isset($matches[3])) {
225 225
 					$range = Array(
226
-					    'from' => (float)$matches[2],
227
-					    'to'   => (float)$matches[4],
226
+					    'from' => (float) $matches[2],
227
+					    'to'   => (float) $matches[4],
228 228
 					    'unit' => $matches[5] ? 'FT' : 'M'
229 229
 					);
230 230
 				}
@@ -273,7 +273,7 @@  discard block
 block discarded – undo
273 273
                  try {
274 274
                         $sth = $this->db->prepare($query);
275 275
                         $sth->execute($query_values);
276
-                } catch(PDOException $e) {
276
+                } catch (PDOException $e) {
277 277
                         return "error : ".$e->getMessage();
278 278
                 }
279 279
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -283,19 +283,19 @@  discard block
 block discarded – undo
283 283
                 return $all;
284 284
         }
285 285
 
286
-       public function addMETAR($location,$metar,$date) {
286
+       public function addMETAR($location, $metar, $date) {
287 287
 		global $globalDBdriver;
288
-		$date = date('Y-m-d H:i:s',strtotime($date));
288
+		$date = date('Y-m-d H:i:s', strtotime($date));
289 289
 		if ($globalDBdriver == 'mysql') {
290 290
 			$query = "INSERT INTO metar (metar_location,metar_date,metar) VALUES (:location,:date,:metar) ON DUPLICATE KEY UPDATE metar_date = :date, metar = :metar";
291 291
 		} else {
292 292
 			$query = "UPDATE metar SET metar_date = :date, metar = metar WHERE metar_location = :location;INSERT INTO metar (metar_location,metar_date,metar) SELECT :location,:date,:metar WHERE NOT EXISTS (SELECT 1 FROM metar WHERE metar_location = :location);";
293 293
 		}
294
-                $query_values = array(':location' => $location,':date' => $date,':metar' => $metar);
294
+                $query_values = array(':location' => $location, ':date' => $date, ':metar' => $metar);
295 295
                  try {
296 296
                         $sth = $this->db->prepare($query);
297 297
                         $sth->execute($query_values);
298
-                } catch(PDOException $e) {
298
+                } catch (PDOException $e) {
299 299
                         return "error : ".$e->getMessage();
300 300
                 }
301 301
         }
@@ -306,7 +306,7 @@  discard block
 block discarded – undo
306 306
                  try {
307 307
                         $sth = $this->db->prepare($query);
308 308
                         $sth->execute($query_values);
309
-                } catch(PDOException $e) {
309
+                } catch (PDOException $e) {
310 310
                         return "error : ".$e->getMessage();
311 311
                 }
312 312
         }
@@ -315,7 +315,7 @@  discard block
 block discarded – undo
315 315
                  try {
316 316
                         $sth = $this->db->prepare($query);
317 317
                         $sth->execute();
318
-                } catch(PDOException $e) {
318
+                } catch (PDOException $e) {
319 319
                         return "error : ".$e->getMessage();
320 320
                 }
321 321
         }
@@ -332,8 +332,8 @@  discard block
 block discarded – undo
332 332
     		}
333 333
     		if (isset($globalDebug) && $globalDebug) echo "Done - Updating DB...";
334 334
     		$date = '';
335
-    		foreach(explode("\n",$cycle) as $line) {
336
-    			if (preg_match('#^([0-9]{4})/([0-9]{2})/([0-9]{2}) ([0-9]{2}):([0-9]{2})$#',$line)) {
335
+    		foreach (explode("\n", $cycle) as $line) {
336
+    			if (preg_match('#^([0-9]{4})/([0-9]{2})/([0-9]{2}) ([0-9]{2}):([0-9]{2})$#', $line)) {
337 337
     				//echo "date : ".$line."\n";
338 338
     				$date = $line;
339 339
     			} elseif ($line != '') {
@@ -341,11 +341,11 @@  discard block
 block discarded – undo
341 341
     			    //echo $line;
342 342
     			    if ($date == '') $date = date('Y/m/d H:m');
343 343
     			    $pos = 0;
344
-    			    $pieces = preg_split('/\s/',$line);
344
+    			    $pieces = preg_split('/\s/', $line);
345 345
     			    if ($pieces[0] == 'METAR') $pos++;
346 346
     			    if (strlen($pieces[$pos]) != 4) $pos++;
347 347
 	        	    $location = $pieces[$pos];
348
-	        	    echo $this->addMETAR($location,$line,$date);
348
+	        	    echo $this->addMETAR($location, $line, $date);
349 349
     			}
350 350
     			//echo $line."\n";
351 351
     		}
@@ -357,11 +357,11 @@  discard block
 block discarded – undo
357 357
     		if ($globalMETARurl == '') return array();
358 358
     		date_default_timezone_set("UTC");
359 359
     		$Common = new Common();
360
-    		$url = str_replace('{icao}',$icao,$globalMETARurl);
360
+    		$url = str_replace('{icao}', $icao, $globalMETARurl);
361 361
     		$cycle = $Common->getData($url);
362 362
     		$date = '';
363
-    		foreach(explode("\n",$cycle) as $line) {
364
-    			if (preg_match('#^([0-9]{4})/([0-9]{2})/([0-9]{2}) ([0-9]{2}):([0-9]{2})$#',$line)) {
363
+    		foreach (explode("\n", $cycle) as $line) {
364
+    			if (preg_match('#^([0-9]{4})/([0-9]{2})/([0-9]{2}) ([0-9]{2}):([0-9]{2})$#', $line)) {
365 365
     				echo "date : ".$line."\n";
366 366
     				$date = $line;
367 367
     			} elseif ($line != '') {
@@ -369,12 +369,12 @@  discard block
 block discarded – undo
369 369
     			    //echo $line;
370 370
     			    if ($date == '') $date = date('Y/m/d H:m');
371 371
     			    $pos = 0;
372
-    			    $pieces = preg_split('/\s/',$line);
372
+    			    $pieces = preg_split('/\s/', $line);
373 373
     			    if ($pieces[0] == 'METAR') $pos++;
374 374
     			    if (strlen($pieces[$pos]) != 4) $pos++;
375 375
 	        	    $location = $pieces[$pos];
376 376
 	        	    if (strlen($location == 4)) {
377
-	        		$this->addMETAR($location,$line,$date);
377
+	        		$this->addMETAR($location, $line, $date);
378 378
 	        		return array('0' => array('metar_date' => $date, 'metar_location' => $location, 'metar' => $line));
379 379
 	        	    } else return array();
380 380
     			}
Please login to merge, or discard this patch.
require/class.APRS.php 1 patch
Spacing   +56 added lines, -57 removed lines patch added patch discarded remove patch
@@ -1,8 +1,7 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 class aprs {
3 3
     private function urshift($n, $s) {
4
-	return ($n >= 0) ? ($n >> $s) :
5
-    	    (($n & 0x7fffffff) >> $s) | 
4
+	return ($n >= 0) ? ($n >> $s) : (($n&0x7fffffff) >> $s)| 
6 5
         	(0x40000000 >> ($s - 1));
7 6
     }
8 7
 
@@ -13,7 +12,7 @@  discard block
 block discarded – undo
13 12
 	$split_input = str_split($input);
14 13
 
15 14
 	/* Find the end of header checking for NULL bytes while doing it. */
16
-	$splitpos = strpos($input,':');
15
+	$splitpos = strpos($input, ':');
17 16
 	
18 17
 	/* Check that end was found and body has at least one byte. */
19 18
 	if ($splitpos == 0 || $splitpos + 1 == $input_len || $splitpos === FALSE) {
@@ -22,36 +21,36 @@  discard block
 block discarded – undo
22 21
 	}
23 22
 	
24 23
 	/* Save header and body. */
25
-	$body = substr($input,$splitpos+1,$input_len);
24
+	$body = substr($input, $splitpos + 1, $input_len);
26 25
 	$body_len = strlen($body);
27
-	$header = substr($input,0,$splitpos);
26
+	$header = substr($input, 0, $splitpos);
28 27
 	$header_len = strlen($header);
29 28
 	if ($debug) echo 'header : '.$header."\n";
30 29
 	
31 30
 	/* Parse source, target and path. */
32 31
 	//FLRDF0A52>APRS,qAS,LSTB
33
-	if (preg_match('/^([A-Z0-9\\-]{1,9})>(.*)$/',$header,$matches)) {
32
+	if (preg_match('/^([A-Z0-9\\-]{1,9})>(.*)$/', $header, $matches)) {
34 33
 	    $ident = $matches[1];
35 34
 	    $all_elements = $matches[2];
36 35
 	    if ($debug) echo 'ident : '.$ident."\n";
37 36
 	    $result['ident'] = $ident;
38 37
 	} else return false;
39
-	$elements = explode(',',$all_elements);
38
+	$elements = explode(',', $all_elements);
40 39
 	$source = end($elements);
41 40
 	$result['source'] = $source;
42 41
 	foreach ($elements as $element) {
43
-	    if (preg_match('/^([a-zA-Z0-9-]{1,9})([*]?)$/',$element)) {
42
+	    if (preg_match('/^([a-zA-Z0-9-]{1,9})([*]?)$/', $element)) {
44 43
 	        //echo "ok";
45 44
 	        if ($element == 'TCPIP*') return false;
46
-	    } elseif (preg_match('/^([0-9A-F]{32})$/',$element)) {
45
+	    } elseif (preg_match('/^([0-9A-F]{32})$/', $element)) {
47 46
 		//echo "ok";
48 47
 	    } else {
49 48
 	        return false;
50 49
 	    }
51 50
 	}
52 51
 	// Check for Timestamp
53
-	$body_parse = substr($body,1);
54
-	if (preg_match('/^([0-9]{2})([0-9]{2})([0-9]{2})([zh\\/])/',$body_parse,$matches)) {
52
+	$body_parse = substr($body, 1);
53
+	if (preg_match('/^([0-9]{2})([0-9]{2})([0-9]{2})([zh\\/])/', $body_parse, $matches)) {
55 54
 	    $timestamp = $matches[0];
56 55
 	    if ($matches[4] == 'h') {
57 56
 		$timestamp = strtotime($matches[1].':'.$matches[2].':'.$matches[3]);
@@ -64,11 +63,11 @@  discard block
 block discarded – undo
64 63
 		// FIXME : fix this...
65 64
 		$timestamp = strtotime($matches[1].' '.$matches[2].':'.$matches[3]);
66 65
 	    }
67
-	    $body_parse = substr($body_parse,7);
66
+	    $body_parse = substr($body_parse, 7);
68 67
 	    $result['timestamp'] = $timestamp;
69 68
 	}
70 69
 	if (strlen($body_parse) > 19) {
71
-	    if (preg_match('/^([0-9]{2})([0-7 ][0-9 ]\\.[0-9 ]{2})([NnSs])(.)([0-9]{3})([0-7 ][0-9 ]\\.[0-9 ]{2})([EeWw])(.)/',$body_parse,$matches)) {
70
+	    if (preg_match('/^([0-9]{2})([0-7 ][0-9 ]\\.[0-9 ]{2})([NnSs])(.)([0-9]{3})([0-7 ][0-9 ]\\.[0-9 ]{2})([EeWw])(.)/', $body_parse, $matches)) {
72 71
 		// 4658.70N/00707.78Ez
73 72
 		//print_r(str_split($body_parse));
74 73
 		$latlon = $matches[0];
@@ -92,8 +91,8 @@  discard block
 block discarded – undo
92 91
 	    */
93 92
 		$latitude = $lat + floatval($lat_min)/60;
94 93
 		$longitude = $lon + floatval($lon_min)/60;
95
-		if ($sind == 'S') $latitude = 0-$latitude;
96
-		if ($wind == 'W') $longitude = 0-$longitude;
94
+		if ($sind == 'S') $latitude = 0 - $latitude;
95
+		if ($wind == 'W') $longitude = 0 - $longitude;
97 96
 		$result['latitude'] = $latitude;
98 97
 		$result['longitude'] = $longitude;
99 98
 	    }
@@ -101,63 +100,63 @@  discard block
 block discarded – undo
101 100
 		$body_split = str_split($body_parse);
102 101
 		$symbol_code = $body_split[18];
103 102
 		if ($symbol_code != '_') {
104
-		    $body_parse = substr($body_parse,19);
103
+		    $body_parse = substr($body_parse, 19);
105 104
 		    $body_parse_len = strlen($body_parse);
106 105
 		    if ($body_parse_len >= 7) {
107 106
 			
108
-		        if (preg_match('/^([0-9\\. ]{3})\\/([0-9\\. ]{3})/',$body_parse)) {
109
-		    	    $course = substr($body_parse,0,3);
107
+		        if (preg_match('/^([0-9\\. ]{3})\\/([0-9\\. ]{3})/', $body_parse)) {
108
+		    	    $course = substr($body_parse, 0, 3);
110 109
 		    	    $tmp_s = intval($course);
111 110
 		    	    if ($tmp_s >= 1 && $tmp_s <= 360) $result['course'] = intval($course);
112
-		    	    $speed = substr($body_parse,4,3);
111
+		    	    $speed = substr($body_parse, 4, 3);
113 112
 		    	    $result['speed'] = round($speed*1.852);
114
-		    	    $body_parse = substr($body_parse,7);
113
+		    	    $body_parse = substr($body_parse, 7);
115 114
 		        }
116 115
 		        // Check PHGR, PHG, RNG
117 116
 		    } else if ($body_parse_len > 0) {
118 117
 			$rest = $body_parse;
119 118
 		    }
120 119
 		    if (strlen($body_parse) > 0) {
121
-		        if (preg_match('/\\/A=(-[0-9]{5}|[0-9]{6})/',$body_parse,$matches)) {
120
+		        if (preg_match('/\\/A=(-[0-9]{5}|[0-9]{6})/', $body_parse, $matches)) {
122 121
 		            $altitude = intval($matches[1]);
123 122
 		            $result['altitude'] = round($altitude*0.3048);
124
-		            $body_parse = substr($body_parse,strlen($matches[0])+1);
123
+		            $body_parse = substr($body_parse, strlen($matches[0]) + 1);
125 124
 		        }
126 125
 		    }
127 126
 		    
128 127
 		    // Telemetry
129
-		    if (preg_match('/^([0-9]+),(-?)([0-9]{1,6}|[0-9]+\\.[0-9]+|\\.[0-9]+)?,(-?)([0-9]{1,6}|[0-9]+\\.[0-9]+|\\.[0-9]+)?,(-?)([0-9]{1,6}|[0-9]+\\.[0-9]+|\\.[0-9]+)?,(-?)([0-9]{1,6}|[0-9]+\\.[0-9]+|\\.[0-9]+)?,(-?)([0-9]{1,6}|[0-9]+\\.[0-9]+|\\.[0-9]+)?,([01]{0,8})/',$body_parse,$matches)) {
128
+		    if (preg_match('/^([0-9]+),(-?)([0-9]{1,6}|[0-9]+\\.[0-9]+|\\.[0-9]+)?,(-?)([0-9]{1,6}|[0-9]+\\.[0-9]+|\\.[0-9]+)?,(-?)([0-9]{1,6}|[0-9]+\\.[0-9]+|\\.[0-9]+)?,(-?)([0-9]{1,6}|[0-9]+\\.[0-9]+|\\.[0-9]+)?,(-?)([0-9]{1,6}|[0-9]+\\.[0-9]+|\\.[0-9]+)?,([01]{0,8})/', $body_parse, $matches)) {
130 129
 		        // Nothing yet...
131 130
 		    }
132 131
 		    // DAO
133
-		    if (preg_match('/^!([0-9A-Z]{3})/',$body_parse,$matches)) {
132
+		    if (preg_match('/^!([0-9A-Z]{3})/', $body_parse, $matches)) {
134 133
 			    $dao = $matches[1];
135 134
 			    $dao_split = str_split($dao);
136
-			    if (preg_match('/^([A-Z])([0-9]{2})/',$dao)) {
137
-			        $lat_off = (($dao[1])-48.0)*0.001/60.0;
138
-			        $lon_off = (($dao[2])-48.0)*0.001/60.0;
135
+			    if (preg_match('/^([A-Z])([0-9]{2})/', $dao)) {
136
+			        $lat_off = (($dao[1]) - 48.0)*0.001/60.0;
137
+			        $lon_off = (($dao[2]) - 48.0)*0.001/60.0;
139 138
 			    
140 139
 			    }
141 140
 			    if ($result['latitude'] < 0) $result['latitude'] -= $lat_off;
142 141
 			    else $result['latitude'] += $lat_off;
143 142
 			    if ($result['longitude'] < 0) $result['longitude'] -= $lon_off;
144 143
 			    else $result['longitude'] += $lon_off;
145
-		            $body_parse = substr($body_parse,6);
144
+		            $body_parse = substr($body_parse, 6);
146 145
 		    }
147 146
 		    
148 147
 		    // OGN comment
149 148
 		   // echo "Before OGN : ".$body_parse."\n";
150
-		    if (preg_match('/^id([0-9A-F]{8}) ([+-])([0-9]{3,4})fpm ([+-])([0-9.]{3,4})rot (.*)$/',$body_parse,$matches)) {
149
+		    if (preg_match('/^id([0-9A-F]{8}) ([+-])([0-9]{3,4})fpm ([+-])([0-9.]{3,4})rot (.*)$/', $body_parse, $matches)) {
151 150
 			$id = $matches[1];
152
-			$mode = substr($id,0,2);
153
-			$address = substr($id,2);
151
+			$mode = substr($id, 0, 2);
152
+			$address = substr($id, 2);
154 153
 			//print_r($matches);
155
-			$addressType = (intval(substr($id,0,2),16))&3;
154
+			$addressType = (intval(substr($id, 0, 2), 16))&3;
156 155
 			if ($addressType == 0) $result['addresstype'] = "RANDOM";
157 156
 			elseif ($addressType == 1) $result['addresstype'] = "ICAO";
158 157
 			elseif ($addressType == 2) $result['addresstype'] = "FLARM";
159 158
 			elseif ($addressType == 3) $result['addresstype'] = "OGN";
160
-			$aircraftType = $this->urshift(((intval(substr($id,0,2),16)) & 0b1111100),2);
159
+			$aircraftType = $this->urshift(((intval(substr($id, 0, 2), 16))&0b1111100), 2);
161 160
 			$result['aircrafttype_code'] = $aircraftType;
162 161
 			if ($aircraftType == 0) $result['aircrafttype'] = "UNKNOWN";
163 162
 			elseif ($aircraftType == 1) $result['aircrafttype'] = "GLIDER";
@@ -174,7 +173,7 @@  discard block
 block discarded – undo
174 173
 			elseif ($aircraftType == 12) $result['aircrafttype'] = "AIRSHIP";
175 174
 			elseif ($aircraftType == 13) $result['aircrafttype'] = "UAV";
176 175
 			elseif ($aircraftType == 15) $result['aircrafttype'] = "STATIC_OBJECT";
177
-			$stealth = (intval(substr($id,0,2), 16) & 0b10000000) != 0;
176
+			$stealth = (intval(substr($id, 0, 2), 16)&0b10000000) != 0;
178 177
 			$result['stealth'] = $stealth;
179 178
 			$result['address'] = $address;
180 179
 		    }
@@ -183,40 +182,40 @@  discard block
 block discarded – undo
183 182
 		    $result['comment'] = $body_parse;
184 183
 		} else {
185 184
 		    // parse weather
186
-		    $body_parse = substr($body_parse,19);
185
+		    $body_parse = substr($body_parse, 19);
187 186
 		    $body_parse_len = strlen($body_parse);
188 187
 
189
-		    if (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})g([0-9 \\.]+)t(-{0,1}[0-9 \\.]+)/',$body_parse,$matches)) {
188
+		    if (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})g([0-9 \\.]+)t(-{0,1}[0-9 \\.]+)/', $body_parse, $matches)) {
190 189
 			$result['wind_dir'] = $matches[1];
191
-			$result['wind_speed'] = round($matches[2]*1.60934,1);
192
-			$result['wind_gust'] = round($matches[3]*1.60934,1);
193
-			$result['temp'] = round(5/9*(($matches[4])-32),1);
194
-		        $body_parse = substr($body_parse,strlen($matches[0])+1);
195
-		    } elseif (preg_match('/^_{0,1}c([0-9 \\.\\-]{3})s([0-9 \\.]{3})g([0-9 \\.]+)t(-{0,1}[0-9 \\.]+)/',$body_parse,$matches)) {
190
+			$result['wind_speed'] = round($matches[2]*1.60934, 1);
191
+			$result['wind_gust'] = round($matches[3]*1.60934, 1);
192
+			$result['temp'] = round(5/9*(($matches[4]) - 32), 1);
193
+		        $body_parse = substr($body_parse, strlen($matches[0]) + 1);
194
+		    } elseif (preg_match('/^_{0,1}c([0-9 \\.\\-]{3})s([0-9 \\.]{3})g([0-9 \\.]+)t(-{0,1}[0-9 \\.]+)/', $body_parse, $matches)) {
196 195
 			$result['wind_dir'] = $matches[1];
197
-			$result['wind_speed'] = round($matches[2]*1.60934,1);
198
-			$result['wind_gust'] = round($matches[3]*1.60934,1);
199
-			$result['temp'] = round(5/9*(($matches[4])-32),1);
200
-		        $body_parse = substr($body_parse,strlen($matches[0])+1);
201
-		    } elseif (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})t(-{0,1}[0-9 \\.]+)/',$body_parse,$matches)) {
196
+			$result['wind_speed'] = round($matches[2]*1.60934, 1);
197
+			$result['wind_gust'] = round($matches[3]*1.60934, 1);
198
+			$result['temp'] = round(5/9*(($matches[4]) - 32), 1);
199
+		        $body_parse = substr($body_parse, strlen($matches[0]) + 1);
200
+		    } elseif (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})t(-{0,1}[0-9 \\.]+)/', $body_parse, $matches)) {
202 201
 			$result['wind_dir'] = $matches[1];
203
-			$result['wind_speed'] = round($matches[2]*1.60934,1);
204
-			$result['wind_gust'] = round($matches[3]*1.60934,1);
205
-		        $body_parse = substr($body_parse,strlen($matches[0])+1);
206
-		    } elseif (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})g([0-9 \\.]+)/',$body_parse,$matches)) {
202
+			$result['wind_speed'] = round($matches[2]*1.60934, 1);
203
+			$result['wind_gust'] = round($matches[3]*1.60934, 1);
204
+		        $body_parse = substr($body_parse, strlen($matches[0]) + 1);
205
+		    } elseif (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})g([0-9 \\.]+)/', $body_parse, $matches)) {
207 206
 			$result['wind_dir'] = $matches[1];
208
-			$result['wind_speed'] = round($matches[2]*1.60934,1);
209
-			$result['wind_gust'] = round($matches[3]*1.60934,1);
210
-		        $body_parse = substr($body_parse,strlen($matches[0])+1);
207
+			$result['wind_speed'] = round($matches[2]*1.60934, 1);
208
+			$result['wind_gust'] = round($matches[3]*1.60934, 1);
209
+		        $body_parse = substr($body_parse, strlen($matches[0]) + 1);
211 210
 		    }
212
-		    if (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9]+)t(-?[0-9 \\.]{1,3})/',$body_parse,$matches)) {
213
-			$result['temp'] = round(5/9*(($matches[1])-32),1);
211
+		    if (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9]+)t(-?[0-9 \\.]{1,3})/', $body_parse, $matches)) {
212
+			$result['temp'] = round(5/9*(($matches[1]) - 32), 1);
214 213
 		    }
215 214
 		}
216 215
 	    }
217 216
 	}
218
-	if (isset($result['latitude'])) $result['latitude'] = round($result['latitude'],4);
219
-	if (isset($result['longitude'])) $result['longitude'] = round($result['longitude'],4);
217
+	if (isset($result['latitude'])) $result['latitude'] = round($result['latitude'], 4);
218
+	if (isset($result['longitude'])) $result['longitude'] = round($result['longitude'], 4);
220 219
 	//print_r($result);
221 220
 	return $result;
222 221
     }
Please login to merge, or discard this patch.
require/class.Scheduler.php 1 patch
Spacing   +169 added lines, -169 removed lines patch added patch discarded remove patch
@@ -25,9 +25,9 @@  discard block
 block discarded – undo
25 25
 	/ @param String $source source of data
26 26
 	*/
27 27
 	
28
-	public function addSchedule($ident,$departure_airport_icao,$departure_airport_time,$arrival_airport_icao,$arrival_airport_time,$source = 'website') {
28
+	public function addSchedule($ident, $departure_airport_icao, $departure_airport_time, $arrival_airport_icao, $arrival_airport_time, $source = 'website') {
29 29
 		date_default_timezone_set('UTC');
30
-		$date = date("Y-m-d H:i:s",time());
30
+		$date = date("Y-m-d H:i:s", time());
31 31
 	        //if ($departure_airport_time == '' && $arrival_airport_time == '') exit;
32 32
 	        //$query = "SELECT COUNT(*) FROM schedule WHERE ident = :ident";
33 33
 	        $query = "SELECT COUNT(*) FROM routes WHERE CallSign = :ident";
@@ -35,70 +35,70 @@  discard block
 block discarded – undo
35 35
 		 try {
36 36
 			$sth = $this->db->prepare($query);
37 37
 			$sth->execute($query_values);
38
-		} catch(PDOException $e) {
38
+		} catch (PDOException $e) {
39 39
 			return "error : ".$e->getMessage();
40 40
 		}
41 41
 		if ($sth->fetchColumn() > 0) {
42 42
 			if ($departure_airport_time == '' && $arrival_airport_time == '') {
43 43
 			    $query = "SELECT COUNT(*) FROM routes WHERE CallSign = :ident AND FromAirport_ICAO = :departure_airport_icao AND ToAirport_ICAO = :arrival_airport_icao";
44
-			    $query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':arrival_airport_icao' => $arrival_airport_icao);
44
+			    $query_values = array(':ident' => $ident, ':departure_airport_icao' => $departure_airport_icao, ':arrival_airport_icao' => $arrival_airport_icao);
45 45
 			} elseif ($arrival_airport_time == '') {
46 46
 			    $query = "SELECT COUNT(*) FROM routes WHERE CallSign = :ident AND FromAirport_ICAO = :departure_airport_icao AND FromAirport_Time = :departure_airport_time AND ToAirport_ICAO = :arrival_airport_icao";
47
-			    $query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':departure_airport_time' => $departure_airport_time,':arrival_airport_icao' => $arrival_airport_icao);
47
+			    $query_values = array(':ident' => $ident, ':departure_airport_icao' => $departure_airport_icao, ':departure_airport_time' => $departure_airport_time, ':arrival_airport_icao' => $arrival_airport_icao);
48 48
 			} elseif ($departure_airport_time == '') {
49 49
 			    $query = "SELECT COUNT(*) FROM routes WHERE CallSign = :ident AND FromAirport_ICAO = :departure_airport_icao AND ToAirport_ICAO = :arrival_airport_icao AND ToAirport_Time = :arrival_airport_time";
50
-			    $query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':arrival_airport_icao' => $arrival_airport_icao,':arrival_airport_time' => $arrival_airport_time);
50
+			    $query_values = array(':ident' => $ident, ':departure_airport_icao' => $departure_airport_icao, ':arrival_airport_icao' => $arrival_airport_icao, ':arrival_airport_time' => $arrival_airport_time);
51 51
 			} else {
52 52
 			    //$query = "SELECT COUNT(*) FROM schedule WHERE ident = :ident AND departure_airport_icao = :departure_airport_icao AND departure_airport_time = :departure_airport_time AND arrival_airport_icao = :arrival_airport_icao AND arrival_airport_time = :arrival_airport_time";
53 53
 			    $query = "SELECT COUNT(*) FROM routes WHERE CallSign = :ident AND FromAirport_ICAO = :departure_airport_icao AND FromAirport_Time = :departure_airport_time AND ToAirport_ICAO = :arrival_airport_icao AND ToAirport_Time = :arrival_airport_time";
54
-			    $query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':departure_airport_time' => $departure_airport_time,':arrival_airport_icao' => $arrival_airport_icao,':arrival_airport_time' => $arrival_airport_time);
54
+			    $query_values = array(':ident' => $ident, ':departure_airport_icao' => $departure_airport_icao, ':departure_airport_time' => $departure_airport_time, ':arrival_airport_icao' => $arrival_airport_icao, ':arrival_airport_time' => $arrival_airport_time);
55 55
 			}
56 56
 			try {
57 57
 				$sth = $this->db->prepare($query);
58 58
 				$sth->execute($query_values);
59
-			} catch(PDOException $e) {
59
+			} catch (PDOException $e) {
60 60
 				return "error : ".$e->getMessage();
61 61
 			}
62 62
 			if ($sth->fetchColumn() == 0) {
63 63
 				//$query = 'UPDATE schedule SET departure_airport_icao = :departure_airport_icao, departure_airport_time = :departure_airport_time, arrival_airport_icao = :arrival_airport_icao, arrival_airport_time = :arrival_airport_time, date_modified = :date, source = :source WHERE ident = :ident';
64 64
 				if ($departure_airport_time == '' && $arrival_airport_time == '') {
65 65
                             	    $query = 'UPDATE routes SET FromAirport_ICAO = :departure_airport_icao, ToAirport_ICAO = :arrival_airport_icao, date_modified = :date, Source = :source WHERE CallSign = :ident';
66
-				    $query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':arrival_airport_icao' => $arrival_airport_icao, ':date' => $date, ':source' => $source);
66
+				    $query_values = array(':ident' => $ident, ':departure_airport_icao' => $departure_airport_icao, ':arrival_airport_icao' => $arrival_airport_icao, ':date' => $date, ':source' => $source);
67 67
 				} elseif ($arrival_airport_time == '') {
68 68
                             	    $query = 'UPDATE routes SET FromAirport_ICAO = :departure_airport_icao, FromAiport_Time = :departure_airport_time, ToAirport_ICAO = :arrival_airport_icao, date_modified = :date, Source = :source WHERE CallSign = :ident';
69
-				    $query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':departure_airport_time' => $departure_airport_time,':arrival_airport_icao' => $arrival_airport_icao, ':date' => $date, ':source' => $source);
69
+				    $query_values = array(':ident' => $ident, ':departure_airport_icao' => $departure_airport_icao, ':departure_airport_time' => $departure_airport_time, ':arrival_airport_icao' => $arrival_airport_icao, ':date' => $date, ':source' => $source);
70 70
 				} elseif ($departure_airport_time == '') {
71 71
                             	    $query = 'UPDATE routes SET FromAirport_ICAO = :departure_airport_icao, ToAirport_ICAO = :arrival_airport_icao, ToAirport_Time = :arrival_airport_time, date_modified = :date, Source = :source WHERE CallSign = :ident';
72
-				    $query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':arrival_airport_icao' => $arrival_airport_icao,':arrival_airport_time' => $arrival_airport_time, ':date' => $date, ':source' => $source);
72
+				    $query_values = array(':ident' => $ident, ':departure_airport_icao' => $departure_airport_icao, ':arrival_airport_icao' => $arrival_airport_icao, ':arrival_airport_time' => $arrival_airport_time, ':date' => $date, ':source' => $source);
73 73
 				} else {
74 74
                             	    $query = 'UPDATE routes SET FromAirport_ICAO = :departure_airport_icao, FromAiport_Time = :departure_airport_time, ToAirport_ICAO = :arrival_airport_icao, ToAirport_Time = :arrival_airport_time, date_modified = :date, Source = :source WHERE CallSign = :ident';
75
-				    $query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':departure_airport_time' => $departure_airport_time,':arrival_airport_icao' => $arrival_airport_icao,':arrival_airport_time' => $arrival_airport_time, ':date' => $date, ':source' => $source);
75
+				    $query_values = array(':ident' => $ident, ':departure_airport_icao' => $departure_airport_icao, ':departure_airport_time' => $departure_airport_time, ':arrival_airport_icao' => $arrival_airport_icao, ':arrival_airport_time' => $arrival_airport_time, ':date' => $date, ':source' => $source);
76 76
 				}
77 77
 				 try {
78 78
 					$sth = $this->db->prepare($query);
79 79
 					$sth->execute($query_values);
80
-				} catch(PDOException $e) {
80
+				} catch (PDOException $e) {
81 81
 					return "error : ".$e->getMessage();
82 82
 				}
83 83
 			} else {
84 84
 				//$query = 'UPDATE schedule SET date_lastseen = :date WHERE ident = :ident';
85 85
 				$query = 'UPDATE routes SET date_lastseen = :date WHERE CallSign = :ident';
86
-				$query_values = array(':ident' => $ident,':date' => $date);
86
+				$query_values = array(':ident' => $ident, ':date' => $date);
87 87
 				 try {
88 88
 					$sth = $this->db->prepare($query);
89 89
 					$sth->execute($query_values);
90
-				} catch(PDOException $e) {
90
+				} catch (PDOException $e) {
91 91
 					return "error : ".$e->getMessage();
92 92
 				}
93 93
 			}
94 94
 		} else {
95 95
 			//$query = 'INSERT INTO  schedule (ident,departure_airport_icao, departure_airport_time, arrival_airport_icao, arrival_airport_time,date_added,source)  VALUES (:ident,:departure_airport_icao,:departure_airport_time,:arrival_airport_icao,:arrival_airport_time,:date,:source)';
96 96
 			$query = 'INSERT INTO  routes (CallSign,FromAirport_ICAO, FromAirport_Time, ToAirport_ICAO, ToAirport_Time,date_added,source)  VALUES (:ident,:departure_airport_icao,:departure_airport_time,:arrival_airport_icao,:arrival_airport_time,:date,:source)';
97
-			$query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':departure_airport_time' => $departure_airport_time,':arrival_airport_icao' => $arrival_airport_icao,':arrival_airport_time' => $arrival_airport_time, ':date' => $date, ':source' => $source);
97
+			$query_values = array(':ident' => $ident, ':departure_airport_icao' => $departure_airport_icao, ':departure_airport_time' => $departure_airport_time, ':arrival_airport_icao' => $arrival_airport_icao, ':arrival_airport_time' => $arrival_airport_time, ':date' => $date, ':source' => $source);
98 98
 			 try {
99 99
 				$sth = $this->db->prepare($query);
100 100
 				$sth->execute($query_values);
101
-			} catch(PDOException $e) {
101
+			} catch (PDOException $e) {
102 102
 				return "error : ".$e->getMessage();
103 103
 			}
104 104
 			// FIXME : add to routes
@@ -109,10 +109,10 @@  discard block
 block discarded – undo
109 109
 	public function getSchedule($ident) {
110 110
 	        //$query = "SELECT * FROM schedule WHERE ident = :ident LIMIT 1";
111 111
 	        $Translation = new Translation($this->db);
112
-	        $operator = $Translation->checkTranslation($ident,false);
112
+	        $operator = $Translation->checkTranslation($ident, false);
113 113
 	        if ($ident != $operator) {
114 114
 	    		$query = "SELECT FromAirport_ICAO as departure_airport_icao, ToAirport_ICAO as arrival_airport_icao, FromAirport_Time as departure_airport_time, ToAirport_Time as arrival_airport_time FROM routes WHERE CallSign = :operator OR CallSign = :ident LIMIT 1";
115
-	    		$query_values = array(':ident' => $ident,'operator' => $operator);
115
+	    		$query_values = array(':ident' => $ident, 'operator' => $operator);
116 116
 	    	} else {
117 117
 		        $query = "SELECT FromAirport_ICAO as departure_airport_icao, ToAirport_ICAO as arrival_airport_icao, FromAirport_Time as departure_airport_time, ToAirport_Time as arrival_airport_time FROM routes WHERE CallSign = :ident LIMIT 1";
118 118
 	    		$query_values = array(':ident' => $ident);
@@ -120,7 +120,7 @@  discard block
 block discarded – undo
120 120
 		 try {
121 121
 			$sth = $this->db->prepare($query);
122 122
 			$sth->execute($query_values);
123
-		} catch(PDOException $e) {
123
+		} catch (PDOException $e) {
124 124
 			return "error : ".$e->getMessage();
125 125
 		}
126 126
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -143,7 +143,7 @@  discard block
 block discarded – undo
143 143
 		 try {
144 144
 			$sth = $this->db->prepare($query);
145 145
 			$sth->execute($query_values);
146
-		} catch(PDOException $e) {
146
+		} catch (PDOException $e) {
147 147
 			return "error : ".$e->getMessage();
148 148
 		}
149 149
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -157,16 +157,16 @@  discard block
 block discarded – undo
157 157
 	* @param String $carrier IATA code
158 158
 	* @return Flight departure and arrival airports and time
159 159
 	*/
160
-	private function getAirFrance($callsign, $date = 'NOW',$carrier = 'AF') {
160
+	private function getAirFrance($callsign, $date = 'NOW', $carrier = 'AF') {
161 161
 		$Common = new Common();
162 162
 		$check_date = new Datetime($date);
163
-		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
164
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
163
+		$numvol = preg_replace('/^[A-Z]*/', '', $callsign);
164
+		if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array();
165 165
 		$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');
166 166
 		$json = $Common->getData($url);
167 167
 	
168 168
 		$parsed_json = json_decode($json);
169
-		if (property_exists($parsed_json,'errors') === false) {
169
+		if (property_exists($parsed_json, 'errors') === false) {
170 170
 			$originLong = $parsed_json->{'flightsList'}[0]->{'segmentsList'}[0]->{'originLong'};
171 171
 			$originShort = $parsed_json->{'flightsList'}[0]->{'segmentsList'}[0]->{'originShort'};
172 172
 			$departureDateMedium = $parsed_json->{'flightsList'}[0]->{'segmentsList'}[0]->{'departureDateMedium'};
@@ -176,9 +176,9 @@  discard block
 block discarded – undo
176 176
 			$arrivalDateMedium = $parsed_json->{'flightsList'}[0]->{'segmentsList'}[0]->{'arrivalDateMedium'};
177 177
 			$arrivalTime = $parsed_json->{'flightsList'}[0]->{'segmentsList'}[0]->{'arrivalTime'};
178 178
 
179
-			preg_match('/\((.*?)\)/',$originShort,$originiata);
179
+			preg_match('/\((.*?)\)/', $originShort, $originiata);
180 180
 			$DepartureAirportIata = $originiata[1];
181
-			preg_match('/\((.*?)\)/',$destinationShort,$destinationiata);
181
+			preg_match('/\((.*?)\)/', $destinationShort, $destinationiata);
182 182
 			$ArrivalAirportIata = $destinationiata[1];
183 183
 
184 184
 			/*
@@ -187,7 +187,7 @@  discard block
 block discarded – undo
187 187
 			$arrivalTime = gmdate('H:i',strtotime($arrivalTime));
188 188
 			*/
189 189
 		
190
-			return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_airfrance');
190
+			return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_airfrance');
191 191
 		} else return array();
192 192
 	}
193 193
 
@@ -202,8 +202,8 @@  discard block
 block discarded – undo
202 202
 		$Common = new Common();
203 203
 		date_default_timezone_set($globalTimezone);
204 204
 		$check_date = new Datetime($date);
205
-		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
206
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
205
+		$numvol = preg_replace('/^[A-Z]*/', '', $callsign);
206
+		if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array();
207 207
 		$url = "http://www.easyjet.com/ft/api/flights?date=".$check_date->format('Y-m-d')."&fn=".$callsign;
208 208
 		$json = $Common->getData($url);
209 209
 		$parsed_json = json_decode($json);
@@ -215,7 +215,7 @@  discard block
 block discarded – undo
215 215
 			$departureTime = $parsed_json->{'flights'}[0]->{'dates'}->{'fstd'};
216 216
 			$arrivalTime = $parsed_json->{'flights'}[0]->{'dates'}->{'fsta'};
217 217
 
218
-			return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_easyjet');
218
+			return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_easyjet');
219 219
 		} else return array();
220 220
 	}
221 221
 
@@ -226,12 +226,12 @@  discard block
 block discarded – undo
226 226
 	*/
227 227
 	private function getRyanair($callsign) {
228 228
 		$Common = new Common();
229
-		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
230
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
229
+		$numvol = preg_replace('/^[A-Z]*/', '', $callsign);
230
+		if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array();
231 231
 		$url = "http://www.ryanair.com/fr/api/2/flight-info/0/50/";
232 232
 		$post = '{"flight":"'.$numvol.'","minDepartureTime":"00:00","maxDepartureTime":"23:59"}';
233
-		$headers = array('Content-Type: application/json','Content-Length: ' . strlen($post));
234
-		$json = $Common->getData($url,'post',$post,$headers);
233
+		$headers = array('Content-Type: application/json', 'Content-Length: '.strlen($post));
234
+		$json = $Common->getData($url, 'post', $post, $headers);
235 235
 		$parsed_json = json_decode($json);
236 236
 		if (isset($parsed_json->{'flightInfo'})) {
237 237
 			$flights = $parsed_json->{'flightInfo'};
@@ -240,7 +240,7 @@  discard block
 block discarded – undo
240 240
 				$ArrivalAirportIata = $parsed_json->{'flightInfo'}[0]->{'arrivalAirport'}->{'iata'}; //name
241 241
 				$departureTime = $parsed_json->{'flightInfo'}[0]->{'departureTime'};
242 242
 				$arrivalTime = $parsed_json->{'flightInfo'}[0]->{'arrivalTime'};
243
-				return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime, 'Source' => 'website_ryanair');
243
+				return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_ryanair');
244 244
 			} else return array();
245 245
 		} else return array();
246 246
 	}
@@ -252,8 +252,8 @@  discard block
 block discarded – undo
252 252
 	*/
253 253
 	private function getSwiss($callsign) {
254 254
 		$Common = new Common();
255
-		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
256
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
255
+		$numvol = preg_replace('/^[A-Z]*/', '', $callsign);
256
+		if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array();
257 257
 		$url = "http://www.world-of-swiss.com/fr/routenetwork.json";
258 258
 		$json = $Common->getData($url);
259 259
 		$parsed_json = json_decode($json);
@@ -265,12 +265,12 @@  discard block
 block discarded – undo
265 265
 				if ($flight->{'no'} == "Vol LX ".$numvol) {
266 266
 					$DepartureAirportIata = $flight->{'from'}->{'code'}; //city
267 267
 					$ArrivalAirportIata = $flight->{'to'}->{'code'}; //city
268
-					$departureTime = substr($flight->{'from'}->{'hour'},0,5);
269
-					$arrivalTime = substr($flight->{'to'}->{'hour'},0,5);
268
+					$departureTime = substr($flight->{'from'}->{'hour'},0, 5);
269
+					$arrivalTime = substr($flight->{'to'}->{'hour'},0, 5);
270 270
 				}
271 271
 			}
272 272
 			if (isset($DepartureAirportIata)) {
273
-				return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_swiss');
273
+				return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_swiss');
274 274
 			} else return array();
275 275
 		} else return array();
276 276
 	}
@@ -285,21 +285,21 @@  discard block
 block discarded – undo
285 285
 		global $globalBritishAirwaysKey;
286 286
 		$Common = new Common();
287 287
 		$check_date = new Datetime($date);
288
-		$numvol = sprintf('%04d',preg_replace('/^[A-Z]*/','',$callsign));
289
-		if (!filter_var(preg_replace('/^[A-Z]*/','',$callsign),FILTER_VALIDATE_INT)) return array();
288
+		$numvol = sprintf('%04d', preg_replace('/^[A-Z]*/', '', $callsign));
289
+		if (!filter_var(preg_replace('/^[A-Z]*/', '', $callsign), FILTER_VALIDATE_INT)) return array();
290 290
 		if ($globalBritishAirwaysKey == '') return array();
291 291
 		$url = "https://api.ba.com/rest-v1/v1/flights;flightNumber=".$numvol.";scheduledDepartureDate=".$check_date->format('Y-m-d').".json";
292 292
 		$headers = array('Client-Key: '.$globalBritishAirwaysKey);
293
-		$json = $Common->getData($url,'get','',$headers);
293
+		$json = $Common->getData($url, 'get', '', $headers);
294 294
 		if ($json == '') return array();
295 295
 		$parsed_json = json_decode($json);
296 296
 		$flights = $parsed_json->{'FlightsResponse'};
297 297
 		if (count($flights) > 0) {
298 298
 			$DepartureAirportIata = $parsed_json->{'FlightsResponse'}->{'Flight'}->{'Sector'}->{'DepartureAirport'};
299 299
 			$ArrivalAirportIata = $parsed_json->{'FlightsResponse'}->{'Flight'}->{'Sector'}->{'ArrivalAirport'};
300
-			$departureTime = date('H:i',strtotime($parsed_json->{'FlightsResponse'}->{'Flight'}->{'Sector'}->{'ScheduledDepartureDateTime'}));
301
-			$arrivalTime = date('H:i',strtotime($parsed_json->{'FlightsResponse'}->{'Flight'}->{'Sector'}->{'ScheduledArrivalDateTime'}));
302
-			return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_britishairways');
300
+			$departureTime = date('H:i', strtotime($parsed_json->{'FlightsResponse'}->{'Flight'}->{'Sector'}->{'ScheduledDepartureDateTime'}));
301
+			$arrivalTime = date('H:i', strtotime($parsed_json->{'FlightsResponse'}->{'Flight'}->{'Sector'}->{'ScheduledArrivalDateTime'}));
302
+			return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_britishairways');
303 303
 		} else return array();
304 304
 	}
305 305
 
@@ -313,27 +313,27 @@  discard block
 block discarded – undo
313 313
 		global $globalLufthansaKey;
314 314
 		$Common = new Common();
315 315
 		$check_date = new Datetime($date);
316
-		$numvol = sprintf('%04d',preg_replace('/^[A-Z]*/','',$callsign));
317
-		if (!filter_var(preg_replace('/^[A-Z]*/','',$callsign),FILTER_VALIDATE_INT)) return array();
316
+		$numvol = sprintf('%04d', preg_replace('/^[A-Z]*/', '', $callsign));
317
+		if (!filter_var(preg_replace('/^[A-Z]*/', '', $callsign), FILTER_VALIDATE_INT)) return array();
318 318
 		if (!isset($globalLufthansaKey) || $globalLufthansaKey == '' || !isset($globalLufthansaKey['key']) || $globalLufthansaKey['key'] == '') return array();
319 319
 		$url = "https://api.lufthansa.com/v1/oauth/token";
320
-		$post = array('client_id' => $globalLufthansaKey['key'],'client_secret' => $globalLufthansaKey['secret'],'grant_type' => 'client_credentials');
321
-		$data = $Common->getData($url,'post',$post);
320
+		$post = array('client_id' => $globalLufthansaKey['key'], 'client_secret' => $globalLufthansaKey['secret'], 'grant_type' => 'client_credentials');
321
+		$data = $Common->getData($url, 'post', $post);
322 322
 		$parsed_data = json_decode($data);
323 323
 		if (!isset($parsed_data->{'access_token'})) return array();
324 324
 		$token = $parsed_data->{'access_token'};
325 325
 		
326 326
 		$url = "https://api.lufthansa.com/v1/operations/flightstatus/LH".$numvol."/".$check_date->format('Y-m-d');
327
-		$headers = array('Authorization: Bearer '.$token,'Accept: application/json');
328
-		$json = $Common->getData($url,'get','',$headers);
327
+		$headers = array('Authorization: Bearer '.$token, 'Accept: application/json');
328
+		$json = $Common->getData($url, 'get', '', $headers);
329 329
 		if ($json == '') return array();
330 330
 		$parsed_json = json_decode($json);
331 331
 		if (isset($parsed_json->{'FlightStatusResource'}) && count($parsed_json->{'FlightStatusResource'}) > 0) {
332 332
 			$DepartureAirportIata = $parsed_json->{'FlightStatusResource'}->{'Flights'}->{'Flight'}->{'Departure'}->{'AirportCode'};
333
-			$departureTime = date('H:i',strtotime($parsed_json->{'FlightStatusResource'}->{'Flights'}->{'Flight'}->{'Departure'}->{'ScheduledTimeLocal'}->{'DateTime'}));
333
+			$departureTime = date('H:i', strtotime($parsed_json->{'FlightStatusResource'}->{'Flights'}->{'Flight'}->{'Departure'}->{'ScheduledTimeLocal'}->{'DateTime'}));
334 334
 			$ArrivalAirportIata = $parsed_json->{'FlightStatusResource'}->{'Flights'}->{'Flight'}->{'Arrival'}->{'AirportCode'};
335
-			$arrivalTime = date('H:i',strtotime($parsed_json->{'FlightStatusResource'}->{'Flights'}->{'Flight'}->{'Arrival'}->{'ScheduledTimeLocal'}->{'DateTime'}));
336
-			return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_lufthansa');
335
+			$arrivalTime = date('H:i', strtotime($parsed_json->{'FlightStatusResource'}->{'Flights'}->{'Flight'}->{'Arrival'}->{'ScheduledTimeLocal'}->{'DateTime'}));
336
+			return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_lufthansa');
337 337
 		} else return array();
338 338
 	}
339 339
 
@@ -347,21 +347,21 @@  discard block
 block discarded – undo
347 347
 		global $globalTransaviaKey;
348 348
 		$Common = new Common();
349 349
 		$check_date = new Datetime($date);
350
-		$numvol = sprintf('%04d',preg_replace('/^[A-Z]*/','',$callsign));
351
-		if (!filter_var(preg_replace('/^[A-Z]*/','',$callsign),FILTER_VALIDATE_INT)) return array();
350
+		$numvol = sprintf('%04d', preg_replace('/^[A-Z]*/', '', $callsign));
351
+		if (!filter_var(preg_replace('/^[A-Z]*/', '', $callsign), FILTER_VALIDATE_INT)) return array();
352 352
 		if ($globalTransaviaKey == '') return array();
353 353
 		$url = "https://tst.api.transavia.com/v1/flightstatus/departuredate/".$check_date->format('Ymd').'/flightnumber/HV'.$numvol;
354 354
 		$headers = array('apikey: '.$globalTransaviaKey);
355
-		$json = $Common->getData($url,'get','',$headers);
355
+		$json = $Common->getData($url, 'get', '', $headers);
356 356
 		if ($json == '') return array();
357 357
 		$parsed_json = json_decode($json);
358 358
 		
359 359
 		if (isset($parsed_json->{'data'}[0])) {
360 360
 			$DepartureAirportIata = $parsed_json->{'data'}[0]->{'flight'}->{'departureAirport'}->{'locationCode'};
361
-			$departureTime = date('H:i',strtotime($parsed_json->{'data'}[0]->{'flight'}->{'departureDateTime'}));
361
+			$departureTime = date('H:i', strtotime($parsed_json->{'data'}[0]->{'flight'}->{'departureDateTime'}));
362 362
 			$ArrivalAirportIata = $parsed_json->{'data'}[0]->{'flight'}->{'arrivalAirport'}->{'locationCode'};
363
-			$arrivalTime = date('H:i',strtotime($parsed_json->{'data'}[0]->{'flight'}->{'arrivalDateTime'}));
364
-			return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_transavia');
363
+			$arrivalTime = date('H:i', strtotime($parsed_json->{'data'}[0]->{'flight'}->{'arrivalDateTime'}));
364
+			return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_transavia');
365 365
 		} else return array();
366 366
 	}
367 367
 
@@ -372,14 +372,14 @@  discard block
 block discarded – undo
372 372
 	*/
373 373
 	private function getTunisair($callsign) {
374 374
 		$Common = new Common();
375
-		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
376
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
375
+		$numvol = preg_replace('/^[A-Z]*/', '', $callsign);
376
+		if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array();
377 377
 		$url = "http://www.tunisair.com/site/publish/module/Volj/fr/Flight_List.asp";
378 378
 		$data = $Common->getData($url);
379 379
 		$table = $Common->table2array($data);
380 380
 		foreach ($table as $flight) {
381
-			if (isset($flight[1]) && $flight[1] == "TU ".sprintf('%04d',$numvol)) {
382
-				return array('DepartureAirportIATA' => $flight[2],'DepartureTime' => str_replace('.',':',$flight[5]),'ArrivalAirportIATA' => $flight[3],'ArrivalTime' => str_replace('.',':',$flight[6]),'Source' => 'website_tunisair');
381
+			if (isset($flight[1]) && $flight[1] == "TU ".sprintf('%04d', $numvol)) {
382
+				return array('DepartureAirportIATA' => $flight[2], 'DepartureTime' => str_replace('.', ':', $flight[5]), 'ArrivalAirportIATA' => $flight[3], 'ArrivalTime' => str_replace('.', ':', $flight[6]), 'Source' => 'website_tunisair');
383 383
 			}
384 384
 		}
385 385
 		return array();
@@ -392,19 +392,19 @@  discard block
 block discarded – undo
392 392
 	*/
393 393
 	private function getVueling($callsign) {
394 394
 		$Common = new Common();
395
-		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
396
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
395
+		$numvol = preg_replace('/^[A-Z]*/', '', $callsign);
396
+		if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array();
397 397
 		$url = "https://www.vueling.com/Base/BaseProxy/RenderMacro/?macroalias=DailyFlights&OriginSelected=&DestinationSelected=&idioma=en-GB&pageid=30694&ItemsByPage=50&FlightNumberFilter=".$numvol;
398 398
 		$data = $Common->getData($url);
399 399
 		if ($data != '') {
400 400
 			$table = $Common->table2array($data);
401 401
 			foreach ($table as $flight) {
402 402
 				if (count($flight) > 0 && $flight[0] == "VY".$numvol && isset($flight[13])) {
403
-					preg_match('/flightOri=[A-Z]{3}/',$flight[13],$result);
404
-					$DepartureAirportIata = str_replace('flightOri=','',$result[0]);
405
-					preg_match('/flightDest=[A-Z]{3}/',$flight[13],$result);
406
-					$ArrivalAirportIata = str_replace('flightDest=','',$result[0]);
407
-					return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $flight[3],'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $flight[4],'Source' => 'website_vueling');
403
+					preg_match('/flightOri=[A-Z]{3}/', $flight[13], $result);
404
+					$DepartureAirportIata = str_replace('flightOri=', '', $result[0]);
405
+					preg_match('/flightDest=[A-Z]{3}/', $flight[13], $result);
406
+					$ArrivalAirportIata = str_replace('flightDest=', '', $result[0]);
407
+					return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $flight[3], 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $flight[4], 'Source' => 'website_vueling');
408 408
 				}
409 409
 			}
410 410
 		}
@@ -419,27 +419,27 @@  discard block
 block discarded – undo
419 419
 	*/
420 420
 	private function getIberia($callsign, $date = 'NOW') {
421 421
 		$Common = new Common();
422
-		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
422
+		$numvol = preg_replace('/^[A-Z]*/', '', $callsign);
423 423
 		$check_date = new Datetime($date);
424
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
424
+		if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array();
425 425
 		$url = "https://www.iberia.com/web/flightDetail.do";
426
-		$post = array('numvuelo' => $numvol,'fecha' => $check_date->format('Ymd'),'airlineID' => 'IB');
427
-		$data = $Common->getData($url,'post',$post);
426
+		$post = array('numvuelo' => $numvol, 'fecha' => $check_date->format('Ymd'), 'airlineID' => 'IB');
427
+		$data = $Common->getData($url, 'post', $post);
428 428
 		if ($data != '') {
429 429
 			$table = $Common->table2array($data);
430 430
 			//print_r($table);
431 431
 			if (count($table) > 0) {
432 432
 				$flight = $table;
433
-				preg_match('/([A-Z]{3})/',$flight[3][0],$DepartureAirportIataMatch);
434
-				preg_match('/([A-Z]{3})/',$flight[5][0],$ArrivalAirportIataMatch);
433
+				preg_match('/([A-Z]{3})/', $flight[3][0], $DepartureAirportIataMatch);
434
+				preg_match('/([A-Z]{3})/', $flight[5][0], $ArrivalAirportIataMatch);
435 435
 				$DepartureAirportIata = $DepartureAirportIataMatch[0];
436 436
 				$ArrivalAirportIata = $ArrivalAirportIataMatch[0];
437
-				$departureTime = substr(trim(str_replace(' lunes','',str_replace('&nbsp;','',$flight[3][2]))),0,5);
438
-				$arrivalTime = trim(str_replace(' lunes','',str_replace('&nbsp;','',$flight[5][1])));
437
+				$departureTime = substr(trim(str_replace(' lunes', '', str_replace('&nbsp;', '', $flight[3][2]))), 0, 5);
438
+				$arrivalTime = trim(str_replace(' lunes', '', str_replace('&nbsp;', '', $flight[5][1])));
439 439
 				if ($arrivalTime == 'Hora estimada de llegada') {
440
-					$arrivalTime = substr(trim(str_replace(' lunes','',str_replace('&nbsp;','',$flight[5][2]))),0,5);
441
-				} else $arrivalTime = substr($arrivalTime,0,5);
442
-				return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_iberia');
440
+					$arrivalTime = substr(trim(str_replace(' lunes', '', str_replace('&nbsp;', '', $flight[5][2]))), 0, 5);
441
+				} else $arrivalTime = substr($arrivalTime, 0, 5);
442
+				return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_iberia');
443 443
 			}
444 444
 		}
445 445
 		return array();
@@ -451,11 +451,11 @@  discard block
 block discarded – undo
451 451
 	* @param String $date date we want flight number info
452 452
 	* @return Flight departure and arrival airports and time
453 453
 	*/
454
-	private function getStarAlliance($callsign, $date = 'NOW',$carrier = '') {
454
+	private function getStarAlliance($callsign, $date = 'NOW', $carrier = '') {
455 455
 		$Common = new Common();
456
-		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
456
+		$numvol = preg_replace('/^[A-Z]*/', '', $callsign);
457 457
 		$check_date = new Datetime($date);
458
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
458
+		if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array();
459 459
 		$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');
460 460
 		$data = $Common->getData($url);
461 461
 		if ($data != '') {
@@ -464,13 +464,13 @@  discard block
 block discarded – undo
464 464
 				$flight = $table;
465 465
 				//print_r($table);
466 466
 				if (isset($flight[25]) && isset($flight[29])) {
467
-					preg_match('/([A-Z]{3})/',$flight[25][1],$DepartureAirportIataMatch);
468
-					preg_match('/([A-Z]{3})/',$flight[25][3],$ArrivalAirportIataMatch);
467
+					preg_match('/([A-Z]{3})/', $flight[25][1], $DepartureAirportIataMatch);
468
+					preg_match('/([A-Z]{3})/', $flight[25][3], $ArrivalAirportIataMatch);
469 469
 					$DepartureAirportIata = $DepartureAirportIataMatch[0];
470 470
 					$ArrivalAirportIata = $ArrivalAirportIataMatch[0];
471
-					$departureTime = substr(trim(str_replace('Scheduled: ','',$flight[29][0])),0,5);
472
-					$arrivalTime = substr(trim(str_replace('Scheduled: ','',$flight[29][1])),0,5);
473
-					return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_staralliance');
471
+					$departureTime = substr(trim(str_replace('Scheduled: ', '', $flight[29][0])), 0, 5);
472
+					$arrivalTime = substr(trim(str_replace('Scheduled: ', '', $flight[29][1])), 0, 5);
473
+					return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_staralliance');
474 474
 				} else return array();
475 475
 			}
476 476
 			
@@ -487,10 +487,10 @@  discard block
 block discarded – undo
487 487
 	*/
488 488
 	private function getAlitalia($callsign, $date = 'NOW') {
489 489
 		$Common = new Common();
490
-		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
490
+		$numvol = preg_replace('/^[A-Z]*/', '', $callsign);
491 491
 		$check_date = new Datetime($date);
492
-		$url= "http://booking.alitalia.com/FlightStatus/fr_fr/FlightInfo?Brand=az&NumeroVolo=".$numvol."&DataCompleta=".$check_date->format('d/m/Y');
493
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
492
+		$url = "http://booking.alitalia.com/FlightStatus/fr_fr/FlightInfo?Brand=az&NumeroVolo=".$numvol."&DataCompleta=".$check_date->format('d/m/Y');
493
+		if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array();
494 494
 		$data = $Common->getData($url);
495 495
 		if ($data != '') {
496 496
 			$table = $Common->text2array($data);
@@ -498,7 +498,7 @@  discard block
 block discarded – undo
498 498
 			$ArrivalAirportIata = '';
499 499
 			$departureTime = $table[4];
500 500
 			$arrivalTime = $table[5];
501
-			return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_alitalia');
501
+			return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_alitalia');
502 502
 		}
503 503
 	}
504 504
 
@@ -510,11 +510,11 @@  discard block
 block discarded – undo
510 510
 	*/
511 511
 	private function getBrussels($callsign, $date = 'NOW') {
512 512
 		$Common = new Common();
513
-		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
513
+		$numvol = preg_replace('/^[A-Z]*/', '', $callsign);
514 514
 		$check_date = new Datetime($date);
515
-		$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";
515
+		$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";
516 516
 		//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";
517
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
517
+		if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array();
518 518
 		$data = $Common->getData($url);
519 519
 		if ($data != '') {
520 520
 		    //echo $data;
@@ -522,9 +522,9 @@  discard block
 block discarded – undo
522 522
 		    if (isset($parsed_json[0]->FromAirportCode)) {
523 523
 			$DepartureAirportIata = $parsed_json[0]->FromAirportCode;
524 524
 			$ArrivalAirportIata = $parsed_json[0]->ToAirportCode;
525
-			$departureTime = date('H:i',strtotime($parsed_json[0]->ScheduledDepatureDate));
526
-			$arrivalTime = date('H:i',strtotime($parsed_json[0]->ScheduledArrivalDate));
527
-			return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_brussels');
525
+			$departureTime = date('H:i', strtotime($parsed_json[0]->ScheduledDepatureDate));
526
+			$arrivalTime = date('H:i', strtotime($parsed_json[0]->ScheduledArrivalDate));
527
+			return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_brussels');
528 528
 		    }
529 529
 		}
530 530
 	}
@@ -602,21 +602,21 @@  discard block
 block discarded – undo
602 602
 	*/
603 603
 	private function getFlyTap($callsign, $date = 'NOW') {
604 604
 		$Common = new Common();
605
-		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
606
-		$url= "http://www.flytap.com/France/fr/PlanifierEtReserver/Outils/DepartsEtArrivees";
605
+		$numvol = preg_replace('/^[A-Z]*/', '', $callsign);
606
+		$url = "http://www.flytap.com/France/fr/PlanifierEtReserver/Outils/DepartsEtArrivees";
607 607
 		$check_date = new Datetime($date);
608
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
609
-		$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');
610
-		$data = $Common->getData($url,'post',$post);
608
+		if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array();
609
+		$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');
610
+		$data = $Common->getData($url, 'post', $post);
611 611
 		if ($data != '') {
612 612
 			$table = $Common->table2array($data);
613
-			$departureTime = trim(substr($table[15][0],0,5));
614
-			$arrivalTime = trim(substr($table[35][0],0,5));
615
-			preg_match('/([A-Z]{3})/',$table[11][0],$DepartureAirportIataMatch);
616
-			preg_match('/([A-Z]{3})/',$table[31][0],$ArrivalAirportIataMatch);
613
+			$departureTime = trim(substr($table[15][0], 0, 5));
614
+			$arrivalTime = trim(substr($table[35][0], 0, 5));
615
+			preg_match('/([A-Z]{3})/', $table[11][0], $DepartureAirportIataMatch);
616
+			preg_match('/([A-Z]{3})/', $table[31][0], $ArrivalAirportIataMatch);
617 617
 			$DepartureAirportIata = $DepartureAirportIataMatch[0];
618 618
 			$ArrivalAirportIata = $ArrivalAirportIataMatch[0];
619
-			return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_flytap');
619
+			return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_flytap');
620 620
 		}
621 621
 		return array();
622 622
 	}
@@ -637,22 +637,22 @@  discard block
 block discarded – undo
637 637
 				$airline_icao = substr($callsign, 0, 3);
638 638
 			} 
639 639
 		}
640
-		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
641
-		$url= "http://info.flightmapper.net/flight/".$airline_icao.'_'.$numvol;
640
+		$numvol = preg_replace('/^[A-Z]*/', '', $callsign);
641
+		$url = "http://info.flightmapper.net/flight/".$airline_icao.'_'.$numvol;
642 642
 		$check_date = new Datetime($date);
643
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
643
+		if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array();
644 644
 		$data = $Common->getData($url);
645 645
 		if ($data != '') {
646 646
 			$table = $Common->table2array($data);
647 647
 			if (isset($table[5][0])) {
648 648
 				$sched = $table[5][0];
649
-				$n = sscanf($sched,'%*s %5[0-9:] %*[^()] (%3[A-Z]) %5[0-9:] %*[^()] (%3[A-Z])',$dhour,$darr,$ahour,$aarr);
649
+				$n = sscanf($sched, '%*s %5[0-9:] %*[^()] (%3[A-Z]) %5[0-9:] %*[^()] (%3[A-Z])', $dhour, $darr, $ahour, $aarr);
650 650
 				if ($n == 7) {
651 651
 				    $departureTime = $dhour;
652 652
 				    $arrivalTime = $ahour;
653
-				    $DepartureAirportIata = str_replace(array('(',')'),'',$darr);
654
-				    $ArrivalAirportIata = str_replace(array('(',')'),'',$aarr);
655
-				    return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_flightmapper');
653
+				    $DepartureAirportIata = str_replace(array('(', ')'), '', $darr);
654
+				    $ArrivalAirportIata = str_replace(array('(', ')'), '', $aarr);
655
+				    return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_flightmapper');
656 656
 				}
657 657
 			}
658 658
 		}
@@ -675,20 +675,20 @@  discard block
 block discarded – undo
675 675
 				$airline_icao = substr($callsign, 0, 3);
676 676
 			} 
677 677
 		}
678
-		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
679
-		$url= "http://fr.flightaware.com/live/flight/".$callsign;
678
+		$numvol = preg_replace('/^[A-Z]*/', '', $callsign);
679
+		$url = "http://fr.flightaware.com/live/flight/".$callsign;
680 680
 		$check_date = new Datetime($date);
681
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
681
+		if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array();
682 682
 		$data = $Common->getData($url);
683 683
 		if ($data != '') {
684 684
 			$table = $Common->table2array($data);
685 685
 			if (isset($table[11][0])) {
686
-				$departureTime = str_replace('h',':',substr($table[5][0],0,5));
687
-				$arrivalTime = str_replace('h',':',substr($table[5][1],0,5));
686
+				$departureTime = str_replace('h', ':', substr($table[5][0], 0, 5));
687
+				$arrivalTime = str_replace('h', ':', substr($table[5][1], 0, 5));
688 688
 				echo $table[3][0];
689
-				sscanf($table[3][0],'%*[^(] (%3[A-Z] / %*4[A-Z])',$DepartureAirportIata);
690
-				sscanf($table[3][1],'%*[^(] (%3[A-Z] / %*4[A-Z])',$ArrivalAirportIata);
691
-				return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_flightaware');
689
+				sscanf($table[3][0], '%*[^(] (%3[A-Z] / %*4[A-Z])', $DepartureAirportIata);
690
+				sscanf($table[3][1], '%*[^(] (%3[A-Z] / %*4[A-Z])', $ArrivalAirportIata);
691
+				return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_flightaware');
692 692
 			}
693 693
 		}
694 694
 		return array();
@@ -702,7 +702,7 @@  discard block
 block discarded – undo
702 702
 	*/
703 703
 	public function getCostToTravel($callsign, $date = 'NOW') {
704 704
 		$Common = new Common();
705
-		$url= "http://www.costtotravel.com/flight-number/".$callsign;
705
+		$url = "http://www.costtotravel.com/flight-number/".$callsign;
706 706
 		$check_date = new Datetime($date);
707 707
 		//if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
708 708
 		$data = $Common->getData($url);
@@ -710,11 +710,11 @@  discard block
 block discarded – undo
710 710
 			$table = $Common->table2array($data);
711 711
 			//print_r($table);
712 712
 			if (isset($table[11][1])) {
713
-				$departureTime = substr($table[11][1],0,5);
714
-				$arrivalTime = substr($table[17][1],0,5);
715
-				$DepartureAirportIata = substr($table[13][1],0,3);
716
-				$ArrivalAirportIata = substr($table[15][1],0,3);
717
-				return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_costtotravel');
713
+				$departureTime = substr($table[11][1], 0, 5);
714
+				$arrivalTime = substr($table[17][1], 0, 5);
715
+				$DepartureAirportIata = substr($table[13][1], 0, 3);
716
+				$ArrivalAirportIata = substr($table[15][1], 0, 3);
717
+				return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_costtotravel');
718 718
 			}
719 719
 		}
720 720
 		return array();
@@ -726,13 +726,13 @@  discard block
 block discarded – undo
726 726
 	* @param String $date date we want flight number info
727 727
 	* @return Flight departure and arrival airports and time
728 728
 	*/
729
-	private function getAirCanada($callsign,$date = 'NOW') {
729
+	private function getAirCanada($callsign, $date = 'NOW') {
730 730
 		$Common = new Common();
731 731
 		date_default_timezone_set('UTC');
732 732
 		$check_date = new Datetime($date);
733
-		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
734
-		$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";
735
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
733
+		$numvol = preg_replace('/^[A-Z]*/', '', $callsign);
734
+		$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";
735
+		if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array();
736 736
 		$data = $Common->getData($url);
737 737
 		$dom = new DomDocument();
738 738
 		$dom->loadXML($data);
@@ -740,11 +740,11 @@  discard block
 block discarded – undo
740 740
 		$departure = $dom->getElementsByTagName('DepartureStationInfo')->item(0);
741 741
 		if (isset($departure->getElementsByTagName('Airport')->item(0)->firstChild->nodeValue)) {
742 742
 			$DepartureAirportIata = $departure->getElementsByTagName('Airport')->item(0)->firstChild->nodeValue;
743
-			$departureTime = date('H:i',strtotime($departure->getElementsByTagName('ScheduledTime')->item(0)->firstChild->nodeValue));
743
+			$departureTime = date('H:i', strtotime($departure->getElementsByTagName('ScheduledTime')->item(0)->firstChild->nodeValue));
744 744
 			$arrival = $dom->getElementsByTagName('ArrivalStationInfo')->item(0);
745 745
 			$ArrivalAirportIata = $arrival->getElementsByTagName('Airport')->item(0)->firstChild->nodeValue;
746
-			$arrivalTime = date('H:i',strtotime($arrival->getElementsByTagName('ScheduledTime')->item(0)->firstChild->nodeValue));
747
-			return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_aircanada');
746
+			$arrivalTime = date('H:i', strtotime($arrival->getElementsByTagName('ScheduledTime')->item(0)->firstChild->nodeValue));
747
+			return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_aircanada');
748 748
 		} else return array();
749 749
 	}
750 750
 
@@ -756,21 +756,21 @@  discard block
 block discarded – undo
756 756
 	*/
757 757
 	private function getVietnamAirlines($callsign, $date = 'NOW') {
758 758
 		$Common = new Common();
759
-		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
759
+		$numvol = preg_replace('/^[A-Z]*/', '', $callsign);
760 760
 		$check_date = new Datetime($date);
761
-		$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."&";
762
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
761
+		$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."&";
762
+		if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array();
763 763
 		$data = $Common->getData($url);
764 764
 		if ($data != '') {
765 765
 			$table = $Common->table2array($data);
766 766
 			$flight = $table;
767
-			preg_match('/([A-Z]{3})/',$flight[3][0],$DepartureAirportIataMatch);
768
-			preg_match('/([A-Z]{3})/',$flight[21][0],$ArrivalAirportIataMatch);
767
+			preg_match('/([A-Z]{3})/', $flight[3][0], $DepartureAirportIataMatch);
768
+			preg_match('/([A-Z]{3})/', $flight[21][0], $ArrivalAirportIataMatch);
769 769
 			$DepartureAirportIata = $DepartureAirportIataMatch[0];
770 770
 			$ArrivalAirportIata = $ArrivalAirportIataMatch[0];
771 771
 			$departureTime = $flight[5][1];
772 772
 			$arrivalTime = $flight[23][1];
773
-			return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_vietnamairlines');
773
+			return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_vietnamairlines');
774 774
 		}
775 775
 	}
776 776
 
@@ -785,12 +785,12 @@  discard block
 block discarded – undo
785 785
 		$Common = new Common();
786 786
 		date_default_timezone_set('UTC');
787 787
 		//AB = airberlin, HG/NLY = NIKI, 4T/BHP = Belair 
788
-		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
788
+		$numvol = preg_replace('/^[A-Z]*/', '', $callsign);
789 789
 		$check_date = new Datetime($date);
790
-		$url= "http://www.airberlin.com/en-US/site/aims.php";
791
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
792
-		$post = array('type' => 'departure','searchFlightNo' => '1','requestsent' => 'true', 'flightno' => $numvol,'date' => $check_date->format('Y-m-d'),'carrier' => 'AB');
793
-		$data = $Common->getData($url,'post',$post);
790
+		$url = "http://www.airberlin.com/en-US/site/aims.php";
791
+		if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array();
792
+		$post = array('type' => 'departure', 'searchFlightNo' => '1', 'requestsent' => 'true', 'flightno' => $numvol, 'date' => $check_date->format('Y-m-d'), 'carrier' => 'AB');
793
+		$data = $Common->getData($url, 'post', $post);
794 794
 		//echo $data;
795 795
 		$DepartureAirportIata = '';
796 796
 		$ArrivalAirportIata = '';
@@ -803,8 +803,8 @@  discard block
 block discarded – undo
803 803
 			if (isset($flight[5][2])) $departureAirport = $flight[5][2];
804 804
 			else $departureAirport = '';
805 805
 		}
806
-		$post = array('type' => 'arrival','searchFlightNo' => '1','requestsent' => 'true', 'flightno' => $numvol,'date' => $check_date->format('Y-m-d'),'carrier' => 'AB');
807
-		$data = $Common->getData($url,'post',$post);
806
+		$post = array('type' => 'arrival', 'searchFlightNo' => '1', 'requestsent' => 'true', 'flightno' => $numvol, 'date' => $check_date->format('Y-m-d'), 'carrier' => 'AB');
807
+		$data = $Common->getData($url, 'post', $post);
808 808
 		if ($data != '') {
809 809
 			$table = $Common->table2array($data);
810 810
 			$flight = $table;
@@ -832,13 +832,13 @@  discard block
 block discarded – undo
832 832
 			}
833 833
 		}
834 834
 		if (isset($DepartureAirportIata)) {
835
-			return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_airberlin');
835
+			return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_airberlin');
836 836
 		} else return array();
837 837
 	}
838 838
 
839 839
 
840 840
 	
841
-	public function fetchSchedule($ident,$date = 'NOW') {
841
+	public function fetchSchedule($ident, $date = 'NOW') {
842 842
 		global $globalSchedulesSources, $globalSchedulesFetch;
843 843
 		$Common = new Common();
844 844
 		if (!$globalSchedulesFetch) return array();
@@ -908,7 +908,7 @@  discard block
 block discarded – undo
908 908
 				// Brussels Airlines
909 909
 				case "BEL":
910 910
 				case "SN":
911
-					return $this->getBrussels($ident,$date,'SN');
911
+					return $this->getBrussels($ident, $date, 'SN');
912 912
 					break;
913 913
 /*
914 914
 				// Copa Airlines
@@ -971,7 +971,7 @@  discard block
 block discarded – undo
971 971
 				// TAP Portugal
972 972
 				case "TAP":
973 973
 				case "TP":
974
-					return $this->getFlyTap($ident,$date);
974
+					return $this->getFlyTap($ident, $date);
975 975
 					break;
976 976
 /*
977 977
 				// Thai Airways International
@@ -993,19 +993,19 @@  discard block
 block discarded – undo
993 993
 				// Air France
994 994
 				case "AF":
995 995
 				case "AFR":
996
-					return $this->getAirFrance($ident,$date,'AF');
996
+					return $this->getAirFrance($ident, $date, 'AF');
997 997
 					break;
998 998
 				// HOP
999 999
 				case "A5":
1000 1000
 				case "HOP":
1001
-					return $this->getAirFrance($ident,$date,'A5');
1001
+					return $this->getAirFrance($ident, $date, 'A5');
1002 1002
 					break;
1003 1003
 				// EasyJet
1004 1004
 				case "U2":
1005 1005
 				case "DS":
1006 1006
 				case "EZY":
1007 1007
 				case "EZS":
1008
-					return $this->getEasyJet($ident,$date);
1008
+					return $this->getEasyJet($ident, $date);
1009 1009
 					break;
1010 1010
 				// Ryanair
1011 1011
 				case "FR":
@@ -1063,34 +1063,34 @@  discard block
 block discarded – undo
1063 1063
 					break;
1064 1064
 				// Vietnam Airlines
1065 1065
 				case "HVN":
1066
-					return $this->getVietnamAirlines($ident,$date);
1066
+					return $this->getVietnamAirlines($ident, $date);
1067 1067
 					break;
1068 1068
 				// Air Berlin
1069 1069
 				case "AB":
1070 1070
 				case "BER":
1071
-					return $this->getAirBerlin($ident,$date,'AB');
1071
+					return $this->getAirBerlin($ident, $date, 'AB');
1072 1072
 					break;
1073 1073
 				// NIKI
1074 1074
 				case "HG":
1075 1075
 				case "NLY":
1076
-					return $this->getAirBerlin($ident,$date,'HG');
1076
+					return $this->getAirBerlin($ident, $date, 'HG');
1077 1077
 					break;
1078 1078
 				// BelAir
1079 1079
 				case "4T":
1080 1080
 				case "BHP":
1081
-					return $this->getAirBerlin($ident,$date,'4T');
1081
+					return $this->getAirBerlin($ident, $date, '4T');
1082 1082
 					break;
1083 1083
 				default:
1084 1084
 					// Randomly use a generic function to get hours
1085 1085
 					if (strlen($airline_icao) == 2) {
1086
-						if (!isset($globalSchedulesSources)) $globalSchedulesSources = array('flightmapper','costtotravel','flightradar24','flightaware');
1086
+						if (!isset($globalSchedulesSources)) $globalSchedulesSources = array('flightmapper', 'costtotravel', 'flightradar24', 'flightaware');
1087 1087
 						if (count($globalSchedulesSources) > 0) {
1088
-							$rand = mt_rand(0,count($globalSchedulesSources)-1);
1088
+							$rand = mt_rand(0, count($globalSchedulesSources) - 1);
1089 1089
 							$source = $globalSchedulesSources[$rand];
1090
-							if ($source == 'flightmapper') return $this->getFlightMapper($ident,$date);
1091
-							elseif ($source == 'costtotravel') return $this->getCostToTravel($ident,$date);
1090
+							if ($source == 'flightmapper') return $this->getFlightMapper($ident, $date);
1091
+							elseif ($source == 'costtotravel') return $this->getCostToTravel($ident, $date);
1092 1092
 							//elseif ($source == 'flightradar24') return $this->getFlightRadar24($ident,$date);
1093
-							elseif ($source == 'flightaware') return $this->getFlightAware($ident,$date);
1093
+							elseif ($source == 'flightaware') return $this->getFlightAware($ident, $date);
1094 1094
 						}
1095 1095
 					}
1096 1096
 			}
Please login to merge, or discard this patch.
require/class.Language.php 1 patch
Spacing   +49 added lines, -49 removed lines patch added patch discarded remove patch
@@ -24,54 +24,54 @@  discard block
 block discarded – undo
24 24
 }
25 25
 
26 26
 class Language {
27
-	public $all_languages = array('ar_SA' => array('العَرَبِيَّةُ',	'ar',	'arabic'),
28
-				'bg_BG' => array('Български',		'bg',	'bulgarian'),
29
-				'id_ID' => array('Bahasa Indonesia',	'id',	'indonesian'),
30
-				'ms_MY' => array('Bahasa Melayu',	'ms',	'malay'),
31
-				'ca_ES' => array('Català',		'ca',	'catalan'), // ca_CA
32
-				'cs_CZ' => array('Čeština',		'cs',	'czech'),
33
-				'de_DE' => array('Deutsch',		'de',	'german'),
34
-				'da_DK' => array('Dansk',		'da',	'danish')     , // dk_DK
35
-				'et_EE' => array('Eesti',		'et',	'estonian'), // ee_ET
36
-				'en_GB' => array('English',		'en',	'english'),
37
-				'en_US' => array('English (US)',	'en',	'english'),
38
-				'es_AR' => array('Español (Argentina)',	'es',	'spanish'),
39
-				'es_CO' => array('Español (Colombia)',	'es',	'spanish'),
40
-				'es_ES' => array('Español (España)',	'es',	'spanish'),
41
-				'es_419' => array('Español (América Latina)',	'es',	'spanish'),
42
-				'es_MX' => array('Español (Mexico)',	'es',	'spanish'),
43
-				'es_VE' => array('Español (Venezuela)',	'es',	'spanish'),
44
-				'eu_ES' => array('Euskara',		'en',	'basque'),
45
-				'fr_FR' => array('Français',		'fr',	'french'),
46
-				'gl_ES' => array('Galego',		'gl',	'galician'),
47
-				'el_GR' => array('Ελληνικά',		'el',	'greek'), // el_EL
48
-				'he_IL' => array('עברית',		'he',	'hebrew'), // he_HE
49
-				'hr_HR' => array('Hrvatski',		'hr',	'croatian'),
50
-				'hu_HU' => array('Magyar',		'hu',	'hungarian'),
51
-				'it_IT' => array('Italiano',		'it',	'italian'),
52
-				'lv_LV' => array('Latviešu',		'lv',	'latvian'),
53
-				'lt_LT' => array('Lietuvių',		'lt',	'lithuanian'),
54
-				'nl_NL' => array('Nederlands',		'nl',	'dutch'),
55
-				'nb_NO' => array('Norsk (Bokmål)',	'nb',	'norwegian'), // no_NB
56
-				'nn_NO' => array('Norsk (Nynorsk)',	'nn',	'norwegian'), // no_NN
57
-				'fa_IR' => array('فارسی',		'fa',	'persian'),
58
-				'pl_PL' => array('Polski',		'pl',	'polish'),
59
-				'pt_PT' => array('Português',		'pt',	'portuguese'),
60
-				'pt_BR' => array('Português do Brasil',	'pt',	'brazilian portuguese'),
61
-				'ro_RO' => array('Română',		'en',	'romanian'),
62
-				'ru_RU' => array('Pусский',		'ru',	'russian'),
63
-				'sk_SK' => array('Slovenčina',		'sk',	'slovak'),
64
-				'sl_SI' => array('Slovenščina',		'sl',	'slovenian slovene'),
65
-				'sr_RS' => array('Srpski',		'sr',	'serbian'),
66
-				'fi_FI' => array('Suomi',		'fi',	'finish'),
67
-				'sv_SE' => array('Svenska',		'sv',	'swedish'),
68
-				'vi_VN' => array('Tiếng Việt',		'vi',	'vietnamese'),
69
-				'th_TH' => array('ภาษาไทย',		'th',	'thai'),
70
-				'tr_TR' => array('Türkçe',		'tr',	'turkish'),
71
-				'uk_UA' => array('Українська',		'en',	'ukrainian'), // ua_UA
72
-				'ja_JP' => array('日本語',		'ja',	'japanese'),
73
-				'zh_CN' => array('简体中文',		'zh',	'chinese'),
74
-				'zh_TW' => array('繁體中文',		'zh',	'chinese')
27
+	public $all_languages = array('ar_SA' => array('العَرَبِيَّةُ', 'ar', 'arabic'),
28
+				'bg_BG' => array('Български', 'bg', 'bulgarian'),
29
+				'id_ID' => array('Bahasa Indonesia', 'id', 'indonesian'),
30
+				'ms_MY' => array('Bahasa Melayu', 'ms', 'malay'),
31
+				'ca_ES' => array('Català', 'ca', 'catalan'), // ca_CA
32
+				'cs_CZ' => array('Čeština', 'cs', 'czech'),
33
+				'de_DE' => array('Deutsch', 'de', 'german'),
34
+				'da_DK' => array('Dansk', 'da', 'danish'), // dk_DK
35
+				'et_EE' => array('Eesti', 'et', 'estonian'), // ee_ET
36
+				'en_GB' => array('English', 'en', 'english'),
37
+				'en_US' => array('English (US)', 'en', 'english'),
38
+				'es_AR' => array('Español (Argentina)', 'es', 'spanish'),
39
+				'es_CO' => array('Español (Colombia)', 'es', 'spanish'),
40
+				'es_ES' => array('Español (España)', 'es', 'spanish'),
41
+				'es_419' => array('Español (América Latina)', 'es', 'spanish'),
42
+				'es_MX' => array('Español (Mexico)', 'es', 'spanish'),
43
+				'es_VE' => array('Español (Venezuela)', 'es', 'spanish'),
44
+				'eu_ES' => array('Euskara', 'en', 'basque'),
45
+				'fr_FR' => array('Français', 'fr', 'french'),
46
+				'gl_ES' => array('Galego', 'gl', 'galician'),
47
+				'el_GR' => array('Ελληνικά', 'el', 'greek'), // el_EL
48
+				'he_IL' => array('עברית', 'he', 'hebrew'), // he_HE
49
+				'hr_HR' => array('Hrvatski', 'hr', 'croatian'),
50
+				'hu_HU' => array('Magyar', 'hu', 'hungarian'),
51
+				'it_IT' => array('Italiano', 'it', 'italian'),
52
+				'lv_LV' => array('Latviešu', 'lv', 'latvian'),
53
+				'lt_LT' => array('Lietuvių', 'lt', 'lithuanian'),
54
+				'nl_NL' => array('Nederlands', 'nl', 'dutch'),
55
+				'nb_NO' => array('Norsk (Bokmål)', 'nb', 'norwegian'), // no_NB
56
+				'nn_NO' => array('Norsk (Nynorsk)', 'nn', 'norwegian'), // no_NN
57
+				'fa_IR' => array('فارسی', 'fa', 'persian'),
58
+				'pl_PL' => array('Polski', 'pl', 'polish'),
59
+				'pt_PT' => array('Português', 'pt', 'portuguese'),
60
+				'pt_BR' => array('Português do Brasil', 'pt', 'brazilian portuguese'),
61
+				'ro_RO' => array('Română', 'en', 'romanian'),
62
+				'ru_RU' => array('Pусский', 'ru', 'russian'),
63
+				'sk_SK' => array('Slovenčina', 'sk', 'slovak'),
64
+				'sl_SI' => array('Slovenščina', 'sl', 'slovenian slovene'),
65
+				'sr_RS' => array('Srpski', 'sr', 'serbian'),
66
+				'fi_FI' => array('Suomi', 'fi', 'finish'),
67
+				'sv_SE' => array('Svenska', 'sv', 'swedish'),
68
+				'vi_VN' => array('Tiếng Việt', 'vi', 'vietnamese'),
69
+				'th_TH' => array('ภาษาไทย', 'th', 'thai'),
70
+				'tr_TR' => array('Türkçe', 'tr', 'turkish'),
71
+				'uk_UA' => array('Українська', 'en', 'ukrainian'), // ua_UA
72
+				'ja_JP' => array('日本語', 'ja', 'japanese'),
73
+				'zh_CN' => array('简体中文', 'zh', 'chinese'),
74
+				'zh_TW' => array('繁體中文', 'zh', 'chinese')
75 75
 			);
76 76
 
77 77
 	/**
@@ -99,7 +99,7 @@  discard block
 block discarded – undo
99 99
 
100 100
 	public function getLocale($locale)
101 101
 	{
102
-		return array($locale,$this->all_languages[$locale][1],$this->all_languages[$locale][2],$locale.'.utf8',$locale.'.UTF8');
102
+		return array($locale, $this->all_languages[$locale][1], $this->all_languages[$locale][2], $locale.'.utf8', $locale.'.UTF8');
103 103
 	}
104 104
 
105 105
 	/**
Please login to merge, or discard this patch.
require/class.Source.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -14,7 +14,7 @@  discard block
 block discarded – undo
14 14
                  try {
15 15
                         $sth = $this->db->prepare($query);
16 16
                         $sth->execute($query_values);
17
-                } catch(PDOException $e) {
17
+                } catch (PDOException $e) {
18 18
                         return "error : ".$e->getMessage();
19 19
                 }
20 20
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
26 26
                  try {
27 27
                         $sth = $this->db->prepare($query);
28 28
                         $sth->execute($query_values);
29
-                } catch(PDOException $e) {
29
+                } catch (PDOException $e) {
30 30
                         return "error : ".$e->getMessage();
31 31
                 }
32 32
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -38,20 +38,20 @@  discard block
 block discarded – undo
38 38
                  try {
39 39
                         $sth = $this->db->prepare($query);
40 40
                         $sth->execute($query_values);
41
-                } catch(PDOException $e) {
41
+                } catch (PDOException $e) {
42 42
                         return "error : ".$e->getMessage();
43 43
                 }
44 44
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
45 45
                 return $all;
46 46
         }
47 47
   
48
-       public function addLocation($name,$latitude,$longitude,$altitude,$city,$country,$source,$logo = 'antenna.png') {
48
+       public function addLocation($name, $latitude, $longitude, $altitude, $city, $country, $source, $logo = 'antenna.png') {
49 49
                 $query = "INSERT INTO source_location (name,latitude,longitude,altitude,country,city,logo,source) VALUES (:name,:latitude,:longitude,:altitude,:country,:city,:logo,:source)";
50
-                $query_values = array(':name' => $name,':latitude' => $latitude, ':longitude' => $longitude,':altitude' => $altitude,':city' => $city,':country' => $country,':logo' => $logo,':source' => $source);
50
+                $query_values = array(':name' => $name, ':latitude' => $latitude, ':longitude' => $longitude, ':altitude' => $altitude, ':city' => $city, ':country' => $country, ':logo' => $logo, ':source' => $source);
51 51
                  try {
52 52
                         $sth = $this->db->prepare($query);
53 53
                         $sth->execute($query_values);
54
-                } catch(PDOException $e) {
54
+                } catch (PDOException $e) {
55 55
                         return "error : ".$e->getMessage();
56 56
                 }
57 57
         }
@@ -62,7 +62,7 @@  discard block
 block discarded – undo
62 62
                  try {
63 63
                         $sth = $this->db->prepare($query);
64 64
                         $sth->execute($query_values);
65
-                } catch(PDOException $e) {
65
+                } catch (PDOException $e) {
66 66
                         return "error : ".$e->getMessage();
67 67
                 }
68 68
         }
@@ -71,7 +71,7 @@  discard block
 block discarded – undo
71 71
                  try {
72 72
                         $sth = $this->db->prepare($query);
73 73
                         $sth->execute();
74
-                } catch(PDOException $e) {
74
+                } catch (PDOException $e) {
75 75
                         return "error : ".$e->getMessage();
76 76
                 }
77 77
         }
Please login to merge, or discard this patch.
require/libs/simple_html_dom.php 1 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.