@@ -28,16 +28,25 @@ discard block |
||
28 | 28 | } elseif (is_numeric(substr(substr($ident, 0, 4), -1, 1))) { |
29 | 29 | //$airline_icao = substr($ident, 0, 3); |
30 | 30 | return $ident; |
31 | - } else return $ident; |
|
32 | - } else return $ident; |
|
31 | + } else { |
|
32 | + return $ident; |
|
33 | + } |
|
34 | + } else { |
|
35 | + return $ident; |
|
36 | + } |
|
33 | 37 | if ($airline_icao == 'AF') { |
34 | - if (filter_var(substr($ident,2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $ident; |
|
35 | - else $icao = 'AFR'.ltrim(substr($ident,2),'0'); |
|
38 | + if (filter_var(substr($ident,2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) { |
|
39 | + $icao = $ident; |
|
40 | + } else { |
|
41 | + $icao = 'AFR'.ltrim(substr($ident,2),'0'); |
|
42 | + } |
|
36 | 43 | } else { |
37 | 44 | $identicao = $Spotter->getAllAirlineInfo($airline_icao); |
38 | 45 | if (isset($identicao[0])) { |
39 | 46 | $icao = $identicao[0]['icao'].ltrim(substr($ident,2),'0'); |
40 | - } else $icao = $ident; |
|
47 | + } else { |
|
48 | + $icao = $ident; |
|
49 | + } |
|
41 | 50 | } |
42 | 51 | return $icao; |
43 | 52 | } |
@@ -55,7 +64,9 @@ discard block |
||
55 | 64 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
56 | 65 | if (count($row) > 0) { |
57 | 66 | return $row['operator_correct']; |
58 | - } else return $ident; |
|
67 | + } else { |
|
68 | + return $ident; |
|
69 | + } |
|
59 | 70 | } |
60 | 71 | |
61 | 72 | public function addOperator($ident,$correct_ident,$source) { |
@@ -84,7 +95,9 @@ discard block |
||
84 | 95 | global $globalTranslationSources, $globalTranslationFetch; |
85 | 96 | //if (!isset($globalTranslationSources)) $globalTranslationSources = array('planefinder'); |
86 | 97 | $globalTranslationSources = array(); |
87 | - if (!isset($globalTranslationFetch)) $globalTranslationFetch = TRUE; |
|
98 | + if (!isset($globalTranslationFetch)) { |
|
99 | + $globalTranslationFetch = TRUE; |
|
100 | + } |
|
88 | 101 | //echo "Check Translation for ".$ident."..."; |
89 | 102 | $correct = $this->getOperator($ident); |
90 | 103 | if ($correct != '' && $correct != $ident) { |
@@ -6,9 +6,13 @@ discard block |
||
6 | 6 | // Not yet finished, no CRC checks |
7 | 7 | //echo $buffer."\n"; |
8 | 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); |
|
9 | + if ($typehex == '*' || $typehex == ':') { |
|
10 | + $hex = substr($buffer,1,-1); |
|
11 | + } elseif ($typehex == '@' || $typehex == '%') { |
|
12 | + $hex = substr($buffer,13,-13); |
|
13 | + } else { |
|
14 | + $hex = substr($buffer,1,-1); |
|
15 | + } |
|
12 | 16 | $bin = gmp_strval( gmp_init($hex,16), 2); |
13 | 17 | //if (strlen($hex) == 28 && $this->parityCheck($hex,$bin)) { |
14 | 18 | if (strlen($hex) == 28) { |
@@ -51,8 +55,9 @@ discard block |
||
51 | 55 | // 131072 is 2^17 since CPR latitude and longitude are encoded in 17 bits. |
52 | 56 | $cprlat = intval(substr($bin,54,17),2)/131072.0; |
53 | 57 | $cprlon = intval(substr($bin,71,17),2)/131072.0; |
54 | - if ($oe == 0) $this::$latlon[$icao] = array('latitude' => $cprlat,'longitude' => $cprlon,'created' => time()); |
|
55 | - elseif (isset($this::$latlon[$icao]) && (time() - $this::$latlon[$icao]['created']) < 10) { |
|
58 | + if ($oe == 0) { |
|
59 | + $this::$latlon[$icao] = array('latitude' => $cprlat,'longitude' => $cprlon,'created' => time()); |
|
60 | + } elseif (isset($this::$latlon[$icao]) && (time() - $this::$latlon[$icao]['created']) < 10) { |
|
56 | 61 | $cprlat_odd = $cprlat; |
57 | 62 | $cprlon_odd = $cprlon; |
58 | 63 | $cprlat_even = $this::$latlon[$icao]['latitude']; |
@@ -61,8 +66,12 @@ discard block |
||
61 | 66 | $j = 59*$cprlat_even-60*$cprlat_odd+0.5; |
62 | 67 | $lat_even = (360.0/60)*($j%60+$cprlat_even); |
63 | 68 | $lat_odd = (360.0/59)*($j%59+$cprlat_odd); |
64 | - if ($lat_even >= 270) $lat_even = $lat_even - 360; |
|
65 | - if ($lat_odd >= 270) $lat_odd = $lat_odd - 360; |
|
69 | + if ($lat_even >= 270) { |
|
70 | + $lat_even = $lat_even - 360; |
|
71 | + } |
|
72 | + if ($lat_odd >= 270) { |
|
73 | + $lat_odd = $lat_odd - 360; |
|
74 | + } |
|
66 | 75 | // check latitude zone |
67 | 76 | if ($this->cprNL($lat_even) == $this->cprNL($lat_odd)) { |
68 | 77 | if ($this::$latlon[$icao]['created'] > time()) { |
@@ -70,7 +79,9 @@ discard block |
||
70 | 79 | $m = floor($cprlon_even*($this->cprNL($lat_even)-1) - $cprlon_odd * $this->cprNL($lat_even)+0.5); |
71 | 80 | $lon = (360.0/$ni)*($m%$ni+$cprlon_even); |
72 | 81 | $lat = $lat_even; |
73 | - if ($lon > 180) $lon = $lon -360; |
|
82 | + if ($lon > 180) { |
|
83 | + $lon = $lon -360; |
|
84 | + } |
|
74 | 85 | if ($lat > -91 && $lat < 91 && $lon > -181 && $lon < 181) { |
75 | 86 | //if ($globalDebug) echo 'cs : '.$cs.' - hex : '.$hex.' - lat : '.$lat.' - lon : '.$lon; |
76 | 87 | $data['latitude'] = $lat; |
@@ -81,14 +92,18 @@ discard block |
||
81 | 92 | $m = floor($cprlon_even*($this->cprNL($lat_odd)-1) - $cprlon_odd * $this->cprNL($lat_odd)+0.5); |
82 | 93 | $lon = (360.0/$ni)*($m%$ni+$cprlon_odd); |
83 | 94 | $lat = $lat_odd; |
84 | - if ($lon > 180) $lon = $lon -360; |
|
95 | + if ($lon > 180) { |
|
96 | + $lon = $lon -360; |
|
97 | + } |
|
85 | 98 | if ($lat > -91 && $lat < 91 && $lon > -181 && $lon < 181) { |
86 | 99 | //if ($globalDebug) echo 'icao : '.$icao.' - hex : '.$hex.' - lat : '.$lat.' - lon : '.$lon.' second'."\n"; |
87 | 100 | $data['latitude'] = $lat; |
88 | 101 | $data['longitude'] = $lon; |
89 | 102 | } |
90 | 103 | } |
91 | - } else echo "Not cprNL"; |
|
104 | + } else { |
|
105 | + echo "Not cprNL"; |
|
106 | + } |
|
92 | 107 | unset($this::$latlon[$icao]); |
93 | 108 | } |
94 | 109 | } elseif ($tc == 19) { |
@@ -97,11 +112,17 @@ discard block |
||
97 | 112 | $v_ew = intval(substr($bin,46,10),2); |
98 | 113 | $v_ns_dir = intval(substr($bin,56,1)); |
99 | 114 | $v_ns = intval(substr($bin,57,10),2); |
100 | - if ($v_ew_dir) $v_ew = -1*$v_ew; |
|
101 | - if ($v_ns_dir) $v_ns = -1*$v_ns; |
|
115 | + if ($v_ew_dir) { |
|
116 | + $v_ew = -1*$v_ew; |
|
117 | + } |
|
118 | + if ($v_ns_dir) { |
|
119 | + $v_ns = -1*$v_ns; |
|
120 | + } |
|
102 | 121 | $speed = sqrt($v_ns*$v_ns+$v_ew*$v_ew); |
103 | 122 | $heading = atan2($v_ew,$v_ns)*360.0/(2*pi()); |
104 | - if ($heading <0) $heading = $heading+360; |
|
123 | + if ($heading <0) { |
|
124 | + $heading = $heading+360; |
|
125 | + } |
|
105 | 126 | $data['speed'] = $speed; |
106 | 127 | $data['heading'] = $heading; |
107 | 128 | } |
@@ -116,72 +137,194 @@ discard block |
||
116 | 137 | |
117 | 138 | function cprNL($lat) { |
118 | 139 | //Lookup table to convert the latitude to index. |
119 | - if ($lat < 0) $lat = -$lat; // Table is simmetric about the equator. |
|
120 | - if ($lat < 10.47047130) return 59; |
|
121 | - if ($lat < 14.82817437) return 58; |
|
122 | - if ($lat < 18.18626357) return 57; |
|
123 | - if ($lat < 21.02939493) return 56; |
|
124 | - if ($lat < 23.54504487) return 55; |
|
125 | - if ($lat < 25.82924707) return 54; |
|
126 | - if ($lat < 27.93898710) return 53; |
|
127 | - if ($lat < 29.91135686) return 52; |
|
128 | - if ($lat < 31.77209708) return 51; |
|
129 | - if ($lat < 33.53993436) return 50; |
|
130 | - if ($lat < 35.22899598) return 49; |
|
131 | - if ($lat < 36.85025108) return 48; |
|
132 | - if ($lat < 38.41241892) return 47; |
|
133 | - if ($lat < 39.92256684) return 46; |
|
134 | - if ($lat < 41.38651832) return 45; |
|
135 | - if ($lat < 42.80914012) return 44; |
|
136 | - if ($lat < 44.19454951) return 43; |
|
137 | - if ($lat < 45.54626723) return 42; |
|
138 | - if ($lat < 46.86733252) return 41; |
|
139 | - if ($lat < 48.16039128) return 40; |
|
140 | - if ($lat < 49.42776439) return 39; |
|
141 | - if ($lat < 50.67150166) return 38; |
|
142 | - if ($lat < 51.89342469) return 37; |
|
143 | - if ($lat < 53.09516153) return 36; |
|
144 | - if ($lat < 54.27817472) return 35; |
|
145 | - if ($lat < 55.44378444) return 34; |
|
146 | - if ($lat < 56.59318756) return 33; |
|
147 | - if ($lat < 57.72747354) return 32; |
|
148 | - if ($lat < 58.84763776) return 31; |
|
149 | - if ($lat < 59.95459277) return 30; |
|
150 | - if ($lat < 61.04917774) return 29; |
|
151 | - if ($lat < 62.13216659) return 28; |
|
152 | - if ($lat < 63.20427479) return 27; |
|
153 | - if ($lat < 64.26616523) return 26; |
|
154 | - if ($lat < 65.31845310) return 25; |
|
155 | - if ($lat < 66.36171008) return 24; |
|
156 | - if ($lat < 67.39646774) return 23; |
|
157 | - if ($lat < 68.42322022) return 22; |
|
158 | - if ($lat < 69.44242631) return 21; |
|
159 | - if ($lat < 70.45451075) return 20; |
|
160 | - if ($lat < 71.45986473) return 19; |
|
161 | - if ($lat < 72.45884545) return 18; |
|
162 | - if ($lat < 73.45177442) return 17; |
|
163 | - if ($lat < 74.43893416) return 16; |
|
164 | - if ($lat < 75.42056257) return 15; |
|
165 | - if ($lat < 76.39684391) return 14; |
|
166 | - if ($lat < 77.36789461) return 13; |
|
167 | - if ($lat < 78.33374083) return 12; |
|
168 | - if ($lat < 79.29428225) return 11; |
|
169 | - if ($lat < 80.24923213) return 10; |
|
170 | - if ($lat < 81.19801349) return 9; |
|
171 | - if ($lat < 82.13956981) return 8; |
|
172 | - if ($lat < 83.07199445) return 7; |
|
173 | - if ($lat < 83.99173563) return 6; |
|
174 | - if ($lat < 84.89166191) return 5; |
|
175 | - if ($lat < 85.75541621) return 4; |
|
176 | - if ($lat < 86.53536998) return 3; |
|
177 | - if ($lat < 87.00000000) return 2; |
|
140 | + if ($lat < 0) { |
|
141 | + $lat = -$lat; |
|
142 | + } |
|
143 | + // Table is simmetric about the equator. |
|
144 | + if ($lat < 10.47047130) { |
|
145 | + return 59; |
|
146 | + } |
|
147 | + if ($lat < 14.82817437) { |
|
148 | + return 58; |
|
149 | + } |
|
150 | + if ($lat < 18.18626357) { |
|
151 | + return 57; |
|
152 | + } |
|
153 | + if ($lat < 21.02939493) { |
|
154 | + return 56; |
|
155 | + } |
|
156 | + if ($lat < 23.54504487) { |
|
157 | + return 55; |
|
158 | + } |
|
159 | + if ($lat < 25.82924707) { |
|
160 | + return 54; |
|
161 | + } |
|
162 | + if ($lat < 27.93898710) { |
|
163 | + return 53; |
|
164 | + } |
|
165 | + if ($lat < 29.91135686) { |
|
166 | + return 52; |
|
167 | + } |
|
168 | + if ($lat < 31.77209708) { |
|
169 | + return 51; |
|
170 | + } |
|
171 | + if ($lat < 33.53993436) { |
|
172 | + return 50; |
|
173 | + } |
|
174 | + if ($lat < 35.22899598) { |
|
175 | + return 49; |
|
176 | + } |
|
177 | + if ($lat < 36.85025108) { |
|
178 | + return 48; |
|
179 | + } |
|
180 | + if ($lat < 38.41241892) { |
|
181 | + return 47; |
|
182 | + } |
|
183 | + if ($lat < 39.92256684) { |
|
184 | + return 46; |
|
185 | + } |
|
186 | + if ($lat < 41.38651832) { |
|
187 | + return 45; |
|
188 | + } |
|
189 | + if ($lat < 42.80914012) { |
|
190 | + return 44; |
|
191 | + } |
|
192 | + if ($lat < 44.19454951) { |
|
193 | + return 43; |
|
194 | + } |
|
195 | + if ($lat < 45.54626723) { |
|
196 | + return 42; |
|
197 | + } |
|
198 | + if ($lat < 46.86733252) { |
|
199 | + return 41; |
|
200 | + } |
|
201 | + if ($lat < 48.16039128) { |
|
202 | + return 40; |
|
203 | + } |
|
204 | + if ($lat < 49.42776439) { |
|
205 | + return 39; |
|
206 | + } |
|
207 | + if ($lat < 50.67150166) { |
|
208 | + return 38; |
|
209 | + } |
|
210 | + if ($lat < 51.89342469) { |
|
211 | + return 37; |
|
212 | + } |
|
213 | + if ($lat < 53.09516153) { |
|
214 | + return 36; |
|
215 | + } |
|
216 | + if ($lat < 54.27817472) { |
|
217 | + return 35; |
|
218 | + } |
|
219 | + if ($lat < 55.44378444) { |
|
220 | + return 34; |
|
221 | + } |
|
222 | + if ($lat < 56.59318756) { |
|
223 | + return 33; |
|
224 | + } |
|
225 | + if ($lat < 57.72747354) { |
|
226 | + return 32; |
|
227 | + } |
|
228 | + if ($lat < 58.84763776) { |
|
229 | + return 31; |
|
230 | + } |
|
231 | + if ($lat < 59.95459277) { |
|
232 | + return 30; |
|
233 | + } |
|
234 | + if ($lat < 61.04917774) { |
|
235 | + return 29; |
|
236 | + } |
|
237 | + if ($lat < 62.13216659) { |
|
238 | + return 28; |
|
239 | + } |
|
240 | + if ($lat < 63.20427479) { |
|
241 | + return 27; |
|
242 | + } |
|
243 | + if ($lat < 64.26616523) { |
|
244 | + return 26; |
|
245 | + } |
|
246 | + if ($lat < 65.31845310) { |
|
247 | + return 25; |
|
248 | + } |
|
249 | + if ($lat < 66.36171008) { |
|
250 | + return 24; |
|
251 | + } |
|
252 | + if ($lat < 67.39646774) { |
|
253 | + return 23; |
|
254 | + } |
|
255 | + if ($lat < 68.42322022) { |
|
256 | + return 22; |
|
257 | + } |
|
258 | + if ($lat < 69.44242631) { |
|
259 | + return 21; |
|
260 | + } |
|
261 | + if ($lat < 70.45451075) { |
|
262 | + return 20; |
|
263 | + } |
|
264 | + if ($lat < 71.45986473) { |
|
265 | + return 19; |
|
266 | + } |
|
267 | + if ($lat < 72.45884545) { |
|
268 | + return 18; |
|
269 | + } |
|
270 | + if ($lat < 73.45177442) { |
|
271 | + return 17; |
|
272 | + } |
|
273 | + if ($lat < 74.43893416) { |
|
274 | + return 16; |
|
275 | + } |
|
276 | + if ($lat < 75.42056257) { |
|
277 | + return 15; |
|
278 | + } |
|
279 | + if ($lat < 76.39684391) { |
|
280 | + return 14; |
|
281 | + } |
|
282 | + if ($lat < 77.36789461) { |
|
283 | + return 13; |
|
284 | + } |
|
285 | + if ($lat < 78.33374083) { |
|
286 | + return 12; |
|
287 | + } |
|
288 | + if ($lat < 79.29428225) { |
|
289 | + return 11; |
|
290 | + } |
|
291 | + if ($lat < 80.24923213) { |
|
292 | + return 10; |
|
293 | + } |
|
294 | + if ($lat < 81.19801349) { |
|
295 | + return 9; |
|
296 | + } |
|
297 | + if ($lat < 82.13956981) { |
|
298 | + return 8; |
|
299 | + } |
|
300 | + if ($lat < 83.07199445) { |
|
301 | + return 7; |
|
302 | + } |
|
303 | + if ($lat < 83.99173563) { |
|
304 | + return 6; |
|
305 | + } |
|
306 | + if ($lat < 84.89166191) { |
|
307 | + return 5; |
|
308 | + } |
|
309 | + if ($lat < 85.75541621) { |
|
310 | + return 4; |
|
311 | + } |
|
312 | + if ($lat < 86.53536998) { |
|
313 | + return 3; |
|
314 | + } |
|
315 | + if ($lat < 87.00000000) { |
|
316 | + return 2; |
|
317 | + } |
|
178 | 318 | return 1; |
179 | 319 | } |
180 | 320 | |
181 | 321 | function cprN($lat,$isodd) { |
182 | 322 | $nl = $this->cprNL($lat) - $isodd; |
183 | - if ($nl > 1) return $nl; |
|
184 | - else return 1; |
|
323 | + if ($nl > 1) { |
|
324 | + return $nl; |
|
325 | + } else { |
|
326 | + return 1; |
|
327 | + } |
|
185 | 328 | } |
186 | 329 | |
187 | 330 | |
@@ -207,10 +350,13 @@ discard block |
||
207 | 350 | $checksum = intval(substr($msg,22,6),16); |
208 | 351 | |
209 | 352 | for ($j = 0; $j < strlen($bin); $j++) { |
210 | - if ($bin[$j]) $crc = $crc^intval($modes_checksum_table[$j],0); |
|
353 | + if ($bin[$j]) { |
|
354 | + $crc = $crc^intval($modes_checksum_table[$j],0); |
|
355 | + } |
|
211 | 356 | } |
212 | - if ($crc == $checksum) return true; |
|
213 | - else { |
|
357 | + if ($crc == $checksum) { |
|
358 | + return true; |
|
359 | + } else { |
|
214 | 360 | //echo "**** CRC ERROR ****\n"; |
215 | 361 | return false; |
216 | 362 | } |
@@ -86,7 +86,9 @@ discard block |
||
86 | 86 | return $result; |
87 | 87 | } |
88 | 88 | $handle = @opendir('./locale'); |
89 | - if ($handle === false) return $result; |
|
89 | + if ($handle === false) { |
|
90 | + return $result; |
|
91 | + } |
|
90 | 92 | while (false !== ($file = readdir($handle))) { |
91 | 93 | $path = './locale'.'/'.$file.'/LC_MESSAGES/fam.mo'; |
92 | 94 | if ($file != "." && $file != ".." && @file_exists($path)) { |
@@ -112,7 +114,9 @@ discard block |
||
112 | 114 | $available = $this->listLocaleDir(); |
113 | 115 | $allAvailableLanguages = array(); |
114 | 116 | foreach ($available as $lang) { |
115 | - if (isset($this->all_languages[$lang])) $allAvailableLanguages[$lang] = $this->all_languages[$lang]; |
|
117 | + if (isset($this->all_languages[$lang])) { |
|
118 | + $allAvailableLanguages[$lang] = $this->all_languages[$lang]; |
|
119 | + } |
|
116 | 120 | } |
117 | 121 | return $allAvailableLanguages; |
118 | 122 | } |
@@ -159,8 +159,9 @@ discard block |
||
159 | 159 | if ($show_attr && count($this->attr)>0) |
160 | 160 | { |
161 | 161 | echo '('; |
162 | - foreach ($this->attr as $k=>$v) |
|
163 | - echo "[$k]=>\"".$this->$k.'", '; |
|
162 | + foreach ($this->attr as $k=>$v) { |
|
163 | + echo "[$k]=>\"".$this->$k.'", '; |
|
164 | + } |
|
164 | 165 | echo ')'; |
165 | 166 | } |
166 | 167 | echo "\n"; |
@@ -218,8 +219,7 @@ discard block |
||
218 | 219 | if (isset($node->_[HDOM_INFO_INNER])) |
219 | 220 | { |
220 | 221 | $string .= $node->_[HDOM_INFO_INNER] . "'"; |
221 | - } |
|
222 | - else |
|
222 | + } else |
|
223 | 223 | { |
224 | 224 | $string .= ' NULL '; |
225 | 225 | } |
@@ -233,8 +233,7 @@ discard block |
||
233 | 233 | { |
234 | 234 | echo $string; |
235 | 235 | return; |
236 | - } |
|
237 | - else |
|
236 | + } else |
|
238 | 237 | { |
239 | 238 | return $string; |
240 | 239 | } |
@@ -320,12 +319,17 @@ discard block |
||
320 | 319 | // returns the previous sibling of node |
321 | 320 | function prev_sibling() |
322 | 321 | { |
323 | - if ($this->parent===null) return null; |
|
322 | + if ($this->parent===null) { |
|
323 | + return null; |
|
324 | + } |
|
324 | 325 | $idx = 0; |
325 | 326 | $count = count($this->parent->children); |
326 | - while ($idx<$count && $this!==$this->parent->children[$idx]) |
|
327 | - ++$idx; |
|
328 | - if (--$idx<0) return null; |
|
327 | + while ($idx<$count && $this!==$this->parent->children[$idx]) { |
|
328 | + ++$idx; |
|
329 | + } |
|
330 | + if (--$idx<0) { |
|
331 | + return null; |
|
332 | + } |
|
329 | 333 | return $this->parent->children[$idx]; |
330 | 334 | } |
331 | 335 | |
@@ -354,12 +358,17 @@ discard block |
||
354 | 358 | // get dom node's inner html |
355 | 359 | function innertext() |
356 | 360 | { |
357 | - if (isset($this->_[HDOM_INFO_INNER])) return $this->_[HDOM_INFO_INNER]; |
|
358 | - if (isset($this->_[HDOM_INFO_TEXT])) return $this->dom->restore_noise($this->_[HDOM_INFO_TEXT]); |
|
361 | + if (isset($this->_[HDOM_INFO_INNER])) { |
|
362 | + return $this->_[HDOM_INFO_INNER]; |
|
363 | + } |
|
364 | + if (isset($this->_[HDOM_INFO_TEXT])) { |
|
365 | + return $this->dom->restore_noise($this->_[HDOM_INFO_TEXT]); |
|
366 | + } |
|
359 | 367 | |
360 | 368 | $ret = ''; |
361 | - foreach ($this->nodes as $n) |
|
362 | - $ret .= $n->outertext(); |
|
369 | + foreach ($this->nodes as $n) { |
|
370 | + $ret .= $n->outertext(); |
|
371 | + } |
|
363 | 372 | return $ret; |
364 | 373 | } |
365 | 374 | |
@@ -380,7 +389,9 @@ discard block |
||
380 | 389 | $debug_object->debug_log(1, 'Innertext of tag: ' . $this->tag . $text); |
381 | 390 | } |
382 | 391 | |
383 | - if ($this->tag==='root') return $this->innertext(); |
|
392 | + if ($this->tag==='root') { |
|
393 | + return $this->innertext(); |
|
394 | + } |
|
384 | 395 | |
385 | 396 | // trigger callback |
386 | 397 | if ($this->dom && $this->dom->callback!==null) |
@@ -388,8 +399,12 @@ discard block |
||
388 | 399 | call_user_func_array($this->dom->callback, array($this)); |
389 | 400 | } |
390 | 401 | |
391 | - if (isset($this->_[HDOM_INFO_OUTER])) return $this->_[HDOM_INFO_OUTER]; |
|
392 | - if (isset($this->_[HDOM_INFO_TEXT])) return $this->dom->restore_noise($this->_[HDOM_INFO_TEXT]); |
|
402 | + if (isset($this->_[HDOM_INFO_OUTER])) { |
|
403 | + return $this->_[HDOM_INFO_OUTER]; |
|
404 | + } |
|
405 | + if (isset($this->_[HDOM_INFO_TEXT])) { |
|
406 | + return $this->dom->restore_noise($this->_[HDOM_INFO_TEXT]); |
|
407 | + } |
|
393 | 408 | |
394 | 409 | // render begin tag |
395 | 410 | if ($this->dom && $this->dom->nodes[$this->_[HDOM_INFO_BEGIN]]) |
@@ -418,23 +433,30 @@ discard block |
||
418 | 433 | } |
419 | 434 | |
420 | 435 | // render end tag |
421 | - if (isset($this->_[HDOM_INFO_END]) && $this->_[HDOM_INFO_END]!=0) |
|
422 | - $ret .= '</'.$this->tag.'>'; |
|
436 | + if (isset($this->_[HDOM_INFO_END]) && $this->_[HDOM_INFO_END]!=0) { |
|
437 | + $ret .= '</'.$this->tag.'>'; |
|
438 | + } |
|
423 | 439 | return $ret; |
424 | 440 | } |
425 | 441 | |
426 | 442 | // get dom node's plain text |
427 | 443 | function text() |
428 | 444 | { |
429 | - if (isset($this->_[HDOM_INFO_INNER])) return $this->_[HDOM_INFO_INNER]; |
|
445 | + if (isset($this->_[HDOM_INFO_INNER])) { |
|
446 | + return $this->_[HDOM_INFO_INNER]; |
|
447 | + } |
|
430 | 448 | switch ($this->nodetype) |
431 | 449 | { |
432 | 450 | case HDOM_TYPE_TEXT: return $this->dom->restore_noise($this->_[HDOM_INFO_TEXT]); |
433 | 451 | case HDOM_TYPE_COMMENT: return ''; |
434 | 452 | case HDOM_TYPE_UNKNOWN: return ''; |
435 | 453 | } |
436 | - if (strcasecmp($this->tag, 'script')===0) return ''; |
|
437 | - if (strcasecmp($this->tag, 'style')===0) return ''; |
|
454 | + if (strcasecmp($this->tag, 'script')===0) { |
|
455 | + return ''; |
|
456 | + } |
|
457 | + if (strcasecmp($this->tag, 'style')===0) { |
|
458 | + return ''; |
|
459 | + } |
|
438 | 460 | |
439 | 461 | $ret = ''; |
440 | 462 | // In rare cases, (always node type 1 or HDOM_TYPE_ELEMENT - observed for some span tags, and some p tags) $this->nodes is set to NULL. |
@@ -470,7 +492,9 @@ discard block |
||
470 | 492 | function makeup() |
471 | 493 | { |
472 | 494 | // text, comment, unknown |
473 | - if (isset($this->_[HDOM_INFO_TEXT])) return $this->dom->restore_noise($this->_[HDOM_INFO_TEXT]); |
|
495 | + if (isset($this->_[HDOM_INFO_TEXT])) { |
|
496 | + return $this->dom->restore_noise($this->_[HDOM_INFO_TEXT]); |
|
497 | + } |
|
474 | 498 | |
475 | 499 | $ret = '<'.$this->tag; |
476 | 500 | $i = -1; |
@@ -480,14 +504,15 @@ discard block |
||
480 | 504 | ++$i; |
481 | 505 | |
482 | 506 | // skip removed attribute |
483 | - if ($val===null || $val===false) |
|
484 | - continue; |
|
507 | + if ($val===null || $val===false) { |
|
508 | + continue; |
|
509 | + } |
|
485 | 510 | |
486 | 511 | $ret .= $this->_[HDOM_INFO_SPACE][$i][0]; |
487 | 512 | //no value attr: nowrap, checked selected... |
488 | - if ($val===true) |
|
489 | - $ret .= $key; |
|
490 | - else { |
|
513 | + if ($val===true) { |
|
514 | + $ret .= $key; |
|
515 | + } else { |
|
491 | 516 | switch ($this->_[HDOM_INFO_QUOTE][$i]) |
492 | 517 | { |
493 | 518 | case HDOM_QUOTE_DOUBLE: $quote = '"'; break; |
@@ -506,7 +531,9 @@ discard block |
||
506 | 531 | function find($selector, $idx=null, $lowercase=false) |
507 | 532 | { |
508 | 533 | $selectors = $this->parse_selector($selector); |
509 | - if (($count=count($selectors))===0) return array(); |
|
534 | + if (($count=count($selectors))===0) { |
|
535 | + return array(); |
|
536 | + } |
|
510 | 537 | $found_keys = array(); |
511 | 538 | |
512 | 539 | // find each selector |
@@ -514,8 +541,12 @@ discard block |
||
514 | 541 | { |
515 | 542 | // The change on the below line was documented on the sourceforge code tracker id 2788009 |
516 | 543 | // used to be: if (($levle=count($selectors[0]))===0) return array(); |
517 | - if (($levle=count($selectors[$c]))===0) return array(); |
|
518 | - if (!isset($this->_[HDOM_INFO_BEGIN])) return array(); |
|
544 | + if (($levle=count($selectors[$c]))===0) { |
|
545 | + return array(); |
|
546 | + } |
|
547 | + if (!isset($this->_[HDOM_INFO_BEGIN])) { |
|
548 | + return array(); |
|
549 | + } |
|
519 | 550 | |
520 | 551 | $head = array($this->_[HDOM_INFO_BEGIN]=>1); |
521 | 552 | |
@@ -545,12 +576,16 @@ discard block |
||
545 | 576 | ksort($found_keys); |
546 | 577 | |
547 | 578 | $found = array(); |
548 | - foreach ($found_keys as $k=>$v) |
|
549 | - $found[] = $this->dom->nodes[$k]; |
|
579 | + foreach ($found_keys as $k=>$v) { |
|
580 | + $found[] = $this->dom->nodes[$k]; |
|
581 | + } |
|
550 | 582 | |
551 | 583 | // return nth-element or array |
552 | - if (is_null($idx)) return $found; |
|
553 | - else if ($idx<0) $idx = count($found) + $idx; |
|
584 | + if (is_null($idx)) { |
|
585 | + return $found; |
|
586 | + } else if ($idx<0) { |
|
587 | + $idx = count($found) + $idx; |
|
588 | + } |
|
554 | 589 | return (isset($found[$idx])) ? $found[$idx] : null; |
555 | 590 | } |
556 | 591 | |
@@ -595,8 +630,9 @@ discard block |
||
595 | 630 | $pass = true; |
596 | 631 | |
597 | 632 | if ($tag==='*' && !$key) { |
598 | - if (in_array($node, $this->children, true)) |
|
599 | - $ret[$i] = 1; |
|
633 | + if (in_array($node, $this->children, true)) { |
|
634 | + $ret[$i] = 1; |
|
635 | + } |
|
600 | 636 | continue; |
601 | 637 | } |
602 | 638 | |
@@ -605,9 +641,13 @@ discard block |
||
605 | 641 | // compare key |
606 | 642 | if ($pass && $key) { |
607 | 643 | if ($no_key) { |
608 | - if (isset($node->attr[$key])) $pass=false; |
|
644 | + if (isset($node->attr[$key])) { |
|
645 | + $pass=false; |
|
646 | + } |
|
609 | 647 | } else { |
610 | - if (($key != "plaintext") && !isset($node->attr[$key])) $pass=false; |
|
648 | + if (($key != "plaintext") && !isset($node->attr[$key])) { |
|
649 | + $pass=false; |
|
650 | + } |
|
611 | 651 | } |
612 | 652 | } |
613 | 653 | // compare value |
@@ -640,13 +680,19 @@ discard block |
||
640 | 680 | } else { |
641 | 681 | $check = $this->match($exp, $val, $k); |
642 | 682 | } |
643 | - if ($check) break; |
|
683 | + if ($check) { |
|
684 | + break; |
|
685 | + } |
|
644 | 686 | } |
645 | 687 | } |
646 | 688 | } |
647 | - if (!$check) $pass = false; |
|
689 | + if (!$check) { |
|
690 | + $pass = false; |
|
691 | + } |
|
692 | + } |
|
693 | + if ($pass) { |
|
694 | + $ret[$i] = 1; |
|
648 | 695 | } |
649 | - if ($pass) $ret[$i] = 1; |
|
650 | 696 | unset($node); |
651 | 697 | } |
652 | 698 | // It's passed by reference so this is actually what this function returns. |
@@ -696,9 +742,13 @@ discard block |
||
696 | 742 | |
697 | 743 | foreach ($matches as $m) { |
698 | 744 | $m[0] = trim($m[0]); |
699 | - if ($m[0]==='' || $m[0]==='/' || $m[0]==='//') continue; |
|
745 | + if ($m[0]==='' || $m[0]==='/' || $m[0]==='//') { |
|
746 | + continue; |
|
747 | + } |
|
700 | 748 | // for browser generated xpath |
701 | - if ($m[1]==='tbody') continue; |
|
749 | + if ($m[1]==='tbody') { |
|
750 | + continue; |
|
751 | + } |
|
702 | 752 | |
703 | 753 | list($tag, $key, $val, $exp, $no_key) = array($m[1], null, null, '=', false); |
704 | 754 | if (!empty($m[2])) {$key='id'; $val=$m[2];} |
@@ -718,8 +768,9 @@ discard block |
||
718 | 768 | $result = array(); |
719 | 769 | } |
720 | 770 | } |
721 | - if (count($result)>0) |
|
722 | - $selectors[] = $result; |
|
771 | + if (count($result)>0) { |
|
772 | + $selectors[] = $result; |
|
773 | + } |
|
723 | 774 | return $selectors; |
724 | 775 | } |
725 | 776 | |
@@ -748,7 +799,9 @@ discard block |
||
748 | 799 | { |
749 | 800 | case 'outertext': return $this->_[HDOM_INFO_OUTER] = $value; |
750 | 801 | case 'innertext': |
751 | - if (isset($this->_[HDOM_INFO_TEXT])) return $this->_[HDOM_INFO_TEXT] = $value; |
|
802 | + if (isset($this->_[HDOM_INFO_TEXT])) { |
|
803 | + return $this->_[HDOM_INFO_TEXT] = $value; |
|
804 | + } |
|
752 | 805 | return $this->_[HDOM_INFO_INNER] = $value; |
753 | 806 | } |
754 | 807 | if (!isset($this->attr[$name])) |
@@ -772,8 +825,9 @@ discard block |
||
772 | 825 | } |
773 | 826 | |
774 | 827 | function __unset($name) { |
775 | - if (isset($this->attr[$name])) |
|
776 | - unset($this->attr[$name]); |
|
828 | + if (isset($this->attr[$name])) { |
|
829 | + unset($this->attr[$name]); |
|
830 | + } |
|
777 | 831 | } |
778 | 832 | |
779 | 833 | // PaperG - Function to convert the text from one character set to another if the two sets are not the same. |
@@ -800,8 +854,7 @@ discard block |
||
800 | 854 | if ((strcasecmp($targetCharset, 'UTF-8') == 0) && ($this->is_utf8($text))) |
801 | 855 | { |
802 | 856 | $converted_text = $text; |
803 | - } |
|
804 | - else |
|
857 | + } else |
|
805 | 858 | { |
806 | 859 | $converted_text = iconv($sourceCharset, $targetCharset, $text); |
807 | 860 | } |
@@ -839,19 +892,31 @@ discard block |
||
839 | 892 | $c=ord($str[$i]); |
840 | 893 | if($c > 128) |
841 | 894 | { |
842 | - if(($c >= 254)) return false; |
|
843 | - elseif($c >= 252) $bits=6; |
|
844 | - elseif($c >= 248) $bits=5; |
|
845 | - elseif($c >= 240) $bits=4; |
|
846 | - elseif($c >= 224) $bits=3; |
|
847 | - elseif($c >= 192) $bits=2; |
|
848 | - else return false; |
|
849 | - if(($i+$bits) > $len) return false; |
|
895 | + if(($c >= 254)) { |
|
896 | + return false; |
|
897 | + } elseif($c >= 252) { |
|
898 | + $bits=6; |
|
899 | + } elseif($c >= 248) { |
|
900 | + $bits=5; |
|
901 | + } elseif($c >= 240) { |
|
902 | + $bits=4; |
|
903 | + } elseif($c >= 224) { |
|
904 | + $bits=3; |
|
905 | + } elseif($c >= 192) { |
|
906 | + $bits=2; |
|
907 | + } else { |
|
908 | + return false; |
|
909 | + } |
|
910 | + if(($i+$bits) > $len) { |
|
911 | + return false; |
|
912 | + } |
|
850 | 913 | while($bits > 1) |
851 | 914 | { |
852 | 915 | $i++; |
853 | 916 | $b=ord($str[$i]); |
854 | - if($b < 128 || $b > 191) return false; |
|
917 | + if($b < 128 || $b > 191) { |
|
918 | + return false; |
|
919 | + } |
|
855 | 920 | $bits--; |
856 | 921 | } |
857 | 922 | } |
@@ -1035,8 +1100,7 @@ discard block |
||
1035 | 1100 | if (preg_match("/^http:\/\//i",$str) || is_file($str)) |
1036 | 1101 | { |
1037 | 1102 | $this->load_file($str); |
1038 | - } |
|
1039 | - else |
|
1103 | + } else |
|
1040 | 1104 | { |
1041 | 1105 | $this->load($str, $lowercase, $stripRN, $defaultBRText, $defaultSpanText); |
1042 | 1106 | } |
@@ -1118,7 +1182,9 @@ discard block |
||
1118 | 1182 | function save($filepath='') |
1119 | 1183 | { |
1120 | 1184 | $ret = $this->root->innertext(); |
1121 | - if ($filepath!=='') file_put_contents($filepath, $ret, LOCK_EX); |
|
1185 | + if ($filepath!=='') { |
|
1186 | + file_put_contents($filepath, $ret, LOCK_EX); |
|
1187 | + } |
|
1122 | 1188 | return $ret; |
1123 | 1189 | } |
1124 | 1190 | |
@@ -1134,7 +1200,10 @@ discard block |
||
1134 | 1200 | { |
1135 | 1201 | foreach ($this->nodes as $n) {$n->clear(); $n = null;} |
1136 | 1202 | // This add next line is documented in the sourceforge repository. 2977248 as a fix for ongoing memory leaks that occur even with the use of clear. |
1137 | - if (isset($this->children)) foreach ($this->children as $n) {$n->clear(); $n = null;} |
|
1203 | + if (isset($this->children)) { |
|
1204 | + foreach ($this->children as $n) {$n->clear(); |
|
1205 | + } |
|
1206 | + $n = null;} |
|
1138 | 1207 | if (isset($this->parent)) {$this->parent->clear(); unset($this->parent);} |
1139 | 1208 | if (isset($this->root)) {$this->root->clear(); unset($this->root);} |
1140 | 1209 | unset($this->doc); |
@@ -1178,7 +1247,9 @@ discard block |
||
1178 | 1247 | $this->root->_[HDOM_INFO_BEGIN] = -1; |
1179 | 1248 | $this->root->nodetype = HDOM_TYPE_ROOT; |
1180 | 1249 | $this->parent = $this->root; |
1181 | - if ($this->size>0) $this->char = $this->doc[0]; |
|
1250 | + if ($this->size>0) { |
|
1251 | + $this->char = $this->doc[0]; |
|
1252 | + } |
|
1182 | 1253 | } |
1183 | 1254 | |
1184 | 1255 | // parse html content |
@@ -1232,8 +1303,7 @@ discard block |
||
1232 | 1303 | if ($success) |
1233 | 1304 | { |
1234 | 1305 | $charset = $matches[1]; |
1235 | - } |
|
1236 | - else |
|
1306 | + } else |
|
1237 | 1307 | { |
1238 | 1308 | // If there is a meta tag, and they don't specify the character set, research says that it's typically ISO-8859-1 |
1239 | 1309 | if (is_object($debug_object)) {$debug_object->debug_log(2, 'meta content-type tag couldn\'t be parsed. using iso-8859 default.');} |
@@ -1296,8 +1366,9 @@ discard block |
||
1296 | 1366 | $tag = $this->copy_until_char('>'); |
1297 | 1367 | |
1298 | 1368 | // skip attributes in end tag |
1299 | - if (($pos = strpos($tag, ' '))!==false) |
|
1300 | - $tag = substr($tag, 0, $pos); |
|
1369 | + if (($pos = strpos($tag, ' '))!==false) { |
|
1370 | + $tag = substr($tag, 0, $pos); |
|
1371 | + } |
|
1301 | 1372 | |
1302 | 1373 | $parent_lower = strtolower($this->parent->tag); |
1303 | 1374 | $tag_lower = strtolower($tag); |
@@ -1309,23 +1380,26 @@ discard block |
||
1309 | 1380 | $this->parent->_[HDOM_INFO_END] = 0; |
1310 | 1381 | $org_parent = $this->parent; |
1311 | 1382 | |
1312 | - while (($this->parent->parent) && strtolower($this->parent->tag)!==$tag_lower) |
|
1313 | - $this->parent = $this->parent->parent; |
|
1383 | + while (($this->parent->parent) && strtolower($this->parent->tag)!==$tag_lower) { |
|
1384 | + $this->parent = $this->parent->parent; |
|
1385 | + } |
|
1314 | 1386 | |
1315 | 1387 | if (strtolower($this->parent->tag)!==$tag_lower) { |
1316 | 1388 | $this->parent = $org_parent; // restore origonal parent |
1317 | - if ($this->parent->parent) $this->parent = $this->parent->parent; |
|
1389 | + if ($this->parent->parent) { |
|
1390 | + $this->parent = $this->parent->parent; |
|
1391 | + } |
|
1318 | 1392 | $this->parent->_[HDOM_INFO_END] = $this->cursor; |
1319 | 1393 | return $this->as_text_node($tag); |
1320 | 1394 | } |
1321 | - } |
|
1322 | - else if (($this->parent->parent) && isset($this->block_tags[$tag_lower])) |
|
1395 | + } else if (($this->parent->parent) && isset($this->block_tags[$tag_lower])) |
|
1323 | 1396 | { |
1324 | 1397 | $this->parent->_[HDOM_INFO_END] = 0; |
1325 | 1398 | $org_parent = $this->parent; |
1326 | 1399 | |
1327 | - while (($this->parent->parent) && strtolower($this->parent->tag)!==$tag_lower) |
|
1328 | - $this->parent = $this->parent->parent; |
|
1400 | + while (($this->parent->parent) && strtolower($this->parent->tag)!==$tag_lower) { |
|
1401 | + $this->parent = $this->parent->parent; |
|
1402 | + } |
|
1329 | 1403 | |
1330 | 1404 | if (strtolower($this->parent->tag)!==$tag_lower) |
1331 | 1405 | { |
@@ -1333,18 +1407,19 @@ discard block |
||
1333 | 1407 | $this->parent->_[HDOM_INFO_END] = $this->cursor; |
1334 | 1408 | return $this->as_text_node($tag); |
1335 | 1409 | } |
1336 | - } |
|
1337 | - else if (($this->parent->parent) && strtolower($this->parent->parent->tag)===$tag_lower) |
|
1410 | + } else if (($this->parent->parent) && strtolower($this->parent->parent->tag)===$tag_lower) |
|
1338 | 1411 | { |
1339 | 1412 | $this->parent->_[HDOM_INFO_END] = 0; |
1340 | 1413 | $this->parent = $this->parent->parent; |
1414 | + } else { |
|
1415 | + return $this->as_text_node($tag); |
|
1341 | 1416 | } |
1342 | - else |
|
1343 | - return $this->as_text_node($tag); |
|
1344 | 1417 | } |
1345 | 1418 | |
1346 | 1419 | $this->parent->_[HDOM_INFO_END] = $this->cursor; |
1347 | - if ($this->parent->parent) $this->parent = $this->parent->parent; |
|
1420 | + if ($this->parent->parent) { |
|
1421 | + $this->parent = $this->parent->parent; |
|
1422 | + } |
|
1348 | 1423 | |
1349 | 1424 | $this->char = (++$this->pos<$this->size) ? $this->doc[$this->pos] : null; // next |
1350 | 1425 | return true; |
@@ -1367,7 +1442,9 @@ discard block |
||
1367 | 1442 | $node->nodetype = HDOM_TYPE_UNKNOWN; |
1368 | 1443 | $node->tag = 'unknown'; |
1369 | 1444 | } |
1370 | - if ($this->char==='>') $node->_[HDOM_INFO_TEXT].='>'; |
|
1445 | + if ($this->char==='>') { |
|
1446 | + $node->_[HDOM_INFO_TEXT].='>'; |
|
1447 | + } |
|
1371 | 1448 | $this->link_nodes($node, true); |
1372 | 1449 | $this->char = (++$this->pos<$this->size) ? $this->doc[$this->pos] : null; // next |
1373 | 1450 | return true; |
@@ -1389,7 +1466,9 @@ discard block |
||
1389 | 1466 | return true; |
1390 | 1467 | } |
1391 | 1468 | |
1392 | - if ($this->char==='>') $node->_[HDOM_INFO_TEXT].='>'; |
|
1469 | + if ($this->char==='>') { |
|
1470 | + $node->_[HDOM_INFO_TEXT].='>'; |
|
1471 | + } |
|
1393 | 1472 | $this->link_nodes($node, false); |
1394 | 1473 | $this->char = (++$this->pos<$this->size) ? $this->doc[$this->pos] : null; // next |
1395 | 1474 | return true; |
@@ -1455,22 +1534,26 @@ discard block |
||
1455 | 1534 | if ($name!=='/' && $name!=='') { |
1456 | 1535 | $space[1] = $this->copy_skip($this->token_blank); |
1457 | 1536 | $name = $this->restore_noise($name); |
1458 | - if ($this->lowercase) $name = strtolower($name); |
|
1537 | + if ($this->lowercase) { |
|
1538 | + $name = strtolower($name); |
|
1539 | + } |
|
1459 | 1540 | if ($this->char==='=') { |
1460 | 1541 | $this->char = (++$this->pos<$this->size) ? $this->doc[$this->pos] : null; // next |
1461 | 1542 | $this->parse_attr($node, $name, $space); |
1462 | - } |
|
1463 | - else { |
|
1543 | + } else { |
|
1464 | 1544 | //no value attr: nowrap, checked selected... |
1465 | 1545 | $node->_[HDOM_INFO_QUOTE][] = HDOM_QUOTE_NO; |
1466 | 1546 | $node->attr[$name] = true; |
1467 | - if ($this->char!='>') $this->char = $this->doc[--$this->pos]; // prev |
|
1547 | + if ($this->char!='>') { |
|
1548 | + $this->char = $this->doc[--$this->pos]; |
|
1549 | + } |
|
1550 | + // prev |
|
1468 | 1551 | } |
1469 | 1552 | $node->_[HDOM_INFO_SPACE][] = $space; |
1470 | 1553 | $space = array($this->copy_skip($this->token_blank), '', ''); |
1554 | + } else { |
|
1555 | + break; |
|
1471 | 1556 | } |
1472 | - else |
|
1473 | - break; |
|
1474 | 1557 | } while ($this->char!=='>' && $this->char!=='/'); |
1475 | 1558 | |
1476 | 1559 | $this->link_nodes($node, true); |
@@ -1481,11 +1564,12 @@ discard block |
||
1481 | 1564 | { |
1482 | 1565 | $node->_[HDOM_INFO_ENDSPACE] .= '/'; |
1483 | 1566 | $node->_[HDOM_INFO_END] = 0; |
1484 | - } |
|
1485 | - else |
|
1567 | + } else |
|
1486 | 1568 | { |
1487 | 1569 | // reset parent |
1488 | - if (!isset($this->self_closing_tags[strtolower($node->tag)])) $this->parent = $node; |
|
1570 | + if (!isset($this->self_closing_tags[strtolower($node->tag)])) { |
|
1571 | + $this->parent = $node; |
|
1572 | + } |
|
1489 | 1573 | } |
1490 | 1574 | $this->char = (++$this->pos<$this->size) ? $this->doc[$this->pos] : null; // next |
1491 | 1575 | |
@@ -1571,7 +1655,9 @@ discard block |
||
1571 | 1655 | $len = strspn($this->doc, $chars, $pos); |
1572 | 1656 | $this->pos += $len; |
1573 | 1657 | $this->char = ($this->pos<$this->size) ? $this->doc[$this->pos] : null; // next |
1574 | - if ($len===0) return ''; |
|
1658 | + if ($len===0) { |
|
1659 | + return ''; |
|
1660 | + } |
|
1575 | 1661 | return substr($this->doc, $pos, $len); |
1576 | 1662 | } |
1577 | 1663 | |
@@ -1586,7 +1672,9 @@ discard block |
||
1586 | 1672 | |
1587 | 1673 | protected function copy_until_char($char) |
1588 | 1674 | { |
1589 | - if ($this->char===null) return ''; |
|
1675 | + if ($this->char===null) { |
|
1676 | + return ''; |
|
1677 | + } |
|
1590 | 1678 | |
1591 | 1679 | if (($pos = strpos($this->doc, $char, $this->pos))===false) { |
1592 | 1680 | $ret = substr($this->doc, $this->pos, $this->size-$this->pos); |
@@ -1595,7 +1683,9 @@ discard block |
||
1595 | 1683 | return $ret; |
1596 | 1684 | } |
1597 | 1685 | |
1598 | - if ($pos===$this->pos) return ''; |
|
1686 | + if ($pos===$this->pos) { |
|
1687 | + return ''; |
|
1688 | + } |
|
1599 | 1689 | $pos_old = $this->pos; |
1600 | 1690 | $this->char = $this->doc[$pos]; |
1601 | 1691 | $this->pos = $pos; |
@@ -1604,7 +1694,9 @@ discard block |
||
1604 | 1694 | |
1605 | 1695 | protected function copy_until_char_escape($char) |
1606 | 1696 | { |
1607 | - if ($this->char===null) return ''; |
|
1697 | + if ($this->char===null) { |
|
1698 | + return ''; |
|
1699 | + } |
|
1608 | 1700 | |
1609 | 1701 | $start = $this->pos; |
1610 | 1702 | while (1) |
@@ -1617,7 +1709,9 @@ discard block |
||
1617 | 1709 | return $ret; |
1618 | 1710 | } |
1619 | 1711 | |
1620 | - if ($pos===$this->pos) return ''; |
|
1712 | + if ($pos===$this->pos) { |
|
1713 | + return ''; |
|
1714 | + } |
|
1621 | 1715 | |
1622 | 1716 | if ($this->doc[$pos-1]==='\\') { |
1623 | 1717 | $start = $pos+1; |
@@ -1674,14 +1768,12 @@ discard block |
||
1674 | 1768 | if (isset($this->noise[$key])) |
1675 | 1769 | { |
1676 | 1770 | $text = substr($text, 0, $pos).$this->noise[$key].substr($text, $pos+16); |
1677 | - } |
|
1678 | - else |
|
1771 | + } else |
|
1679 | 1772 | { |
1680 | 1773 | // do this to prevent an infinite loop. |
1681 | 1774 | $text = substr($text, 0, $pos).'UNDEFINED NOISE FOR KEY: '.$key . substr($text, $pos+16); |
1682 | 1775 | } |
1683 | - } |
|
1684 | - else |
|
1776 | + } else |
|
1685 | 1777 | { |
1686 | 1778 | // There is no valid key being given back to us... We must get rid of the ___noise___ or we will have a problem. |
1687 | 1779 | $text = substr($text, 0, $pos).'NO NUMERIC NOISE KEY' . substr($text, $pos+11); |
@@ -183,8 +183,7 @@ |
||
183 | 183 | if ( mt_rand( 0, 1 ) == 0 ) |
184 | 184 | { |
185 | 185 | $ver = mt_rand( 4, 5 ) . '.' . mt_rand( 0, 1 ); |
186 | - } |
|
187 | - else |
|
186 | + } else |
|
188 | 187 | { |
189 | 188 | $ver = mt_rand( 4, 5 ) . '.0.' . mt_rand( 1, 5 ); |
190 | 189 | } |
@@ -290,7 +290,9 @@ |
||
290 | 290 | |
291 | 291 | function _methods_tester_with_geos($geometry) { |
292 | 292 | // Cannot test methods if GEOS is not intstalled |
293 | - if (!geoPHP::geosInstalled()) return; |
|
293 | + if (!geoPHP::geosInstalled()) { |
|
294 | + return; |
|
295 | + } |
|
294 | 296 | |
295 | 297 | $methods = array( |
296 | 298 | //'boundary', //@@TODO: Uncomment this and fix errors |
@@ -32,7 +32,9 @@ |
||
32 | 32 | |
33 | 33 | // Test to make sure adapter work the same wether GEOS is ON or OFF |
34 | 34 | // Cannot test methods if GEOS is not intstalled |
35 | - if (!geoPHP::geosInstalled()) return; |
|
35 | + if (!geoPHP::geosInstalled()) { |
|
36 | + return; |
|
37 | + } |
|
36 | 38 | |
37 | 39 | foreach (geoPHP::getAdapterMap() as $adapter_key => $adapter_class) { |
38 | 40 | if ($adapter_key != 'google_geocode') { //Don't test google geocoder regularily. Uncomment to test |
@@ -12,8 +12,7 @@ discard block |
||
12 | 12 | |
13 | 13 | if (geoPHP::geosInstalled()) { |
14 | 14 | print "GEOS is installed.\n"; |
15 | - } |
|
16 | - else { |
|
15 | + } else { |
|
17 | 16 | print "GEOS is not installed.\n"; |
18 | 17 | } |
19 | 18 | |
@@ -125,8 +124,7 @@ discard block |
||
125 | 124 | if ($test_geom_1->out('wkt') != $test_geom_2->out('wkt')) { |
126 | 125 | print "Mismatched adapter output in ".$adapter_class."\n"; |
127 | 126 | } |
128 | - } |
|
129 | - else { |
|
127 | + } else { |
|
130 | 128 | print "Empty output on " . $adapter_key . "\n"; |
131 | 129 | } |
132 | 130 | } |
@@ -134,7 +132,9 @@ discard block |
||
134 | 132 | |
135 | 133 | // Test to make sure adapter work the same wether GEOS is ON or OFF |
136 | 134 | // Cannot test methods if GEOS is not intstalled |
137 | - if (!geoPHP::geosInstalled()) return; |
|
135 | + if (!geoPHP::geosInstalled()) { |
|
136 | + return; |
|
137 | + } |
|
138 | 138 | |
139 | 139 | foreach (geoPHP::getAdapterMap() as $adapter_key => $adapter_class) { |
140 | 140 | if ($adapter_key != 'google_geocode') { //Don't test google geocoder regularily. Uncomment to test |
@@ -167,7 +167,9 @@ discard block |
||
167 | 167 | |
168 | 168 | function test_methods($geometry) { |
169 | 169 | // Cannot test methods if GEOS is not intstalled |
170 | - if (!geoPHP::geosInstalled()) return; |
|
170 | + if (!geoPHP::geosInstalled()) { |
|
171 | + return; |
|
172 | + } |
|
171 | 173 | |
172 | 174 | $methods = array( |
173 | 175 | //'boundary', //@@TODO: Uncomment this and fix errors |
@@ -237,8 +239,11 @@ discard block |
||
237 | 239 | function test_detection($value, $format, $file) { |
238 | 240 | $detected = geoPHP::detectFormat($value); |
239 | 241 | if ($detected != $format) { |
240 | - if ($detected) print 'detected as ' . $detected . "\n"; |
|
241 | - else print "not detected\n"; |
|
242 | + if ($detected) { |
|
243 | + print 'detected as ' . $detected . "\n"; |
|
244 | + } else { |
|
245 | + print "not detected\n"; |
|
246 | + } |
|
242 | 247 | } |
243 | 248 | // Make sure it loads using auto-detect |
244 | 249 | geoPHP::load($value); |
@@ -19,8 +19,7 @@ |
||
19 | 19 | $wkt = 'SRID=' . $srid . ';'; |
20 | 20 | $wkt .= $geometry->out('wkt'); |
21 | 21 | return $wkt; |
22 | - } |
|
23 | - else { |
|
22 | + } else { |
|
24 | 23 | return $geometry->out('wkt'); |
25 | 24 | } |
26 | 25 | } |