@@ -27,8 +27,11 @@ discard block |
||
27 | 27 | } else { |
28 | 28 | curl_setopt($ch, CURLOPT_USERAGENT, $useragent); |
29 | 29 | } |
30 | - if ($timeout == '') curl_setopt($ch, CURLOPT_TIMEOUT, 10); |
|
31 | - else curl_setopt($ch, CURLOPT_TIMEOUT, $timeout); |
|
30 | + if ($timeout == '') { |
|
31 | + curl_setopt($ch, CURLOPT_TIMEOUT, 10); |
|
32 | + } else { |
|
33 | + curl_setopt($ch, CURLOPT_TIMEOUT, $timeout); |
|
34 | + } |
|
32 | 35 | curl_setopt($ch, CURLOPT_HEADERFUNCTION, array('Common',"curlResponseHeaderCallback")); |
33 | 36 | if ($type == 'post') { |
34 | 37 | curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST"); |
@@ -74,8 +77,9 @@ discard block |
||
74 | 77 | private function curlResponseHeaderCallback($ch, $headerLine) { |
75 | 78 | //global $cookies; |
76 | 79 | $cookies = array(); |
77 | - if (preg_match('/^Set-Cookie:\s*([^;]*)/mi', $headerLine, $cookie) == 1) |
|
78 | - $cookies[] = $cookie; |
|
80 | + if (preg_match('/^Set-Cookie:\s*([^;]*)/mi', $headerLine, $cookie) == 1) { |
|
81 | + $cookies[] = $cookie; |
|
82 | + } |
|
79 | 83 | return strlen($headerLine); // Needed by curl |
80 | 84 | } |
81 | 85 | |
@@ -85,7 +89,9 @@ discard block |
||
85 | 89 | curl_setopt($ch, CURLOPT_URL, $url); |
86 | 90 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); |
87 | 91 | curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); |
88 | - if ($referer != '') curl_setopt($ch, CURLOPT_REFERER, $referer); |
|
92 | + if ($referer != '') { |
|
93 | + curl_setopt($ch, CURLOPT_REFERER, $referer); |
|
94 | + } |
|
89 | 95 | curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.1.2) Gecko/20090729 Firefox/3.5.2 GTB5'); |
90 | 96 | curl_setopt($ch, CURLOPT_FILE, $fp); |
91 | 97 | curl_exec($ch); |
@@ -99,10 +105,16 @@ discard block |
||
99 | 105 | * @return Array array of the tables in HTML page |
100 | 106 | */ |
101 | 107 | public function table2array($data) { |
102 | - if (!is_string($data)) return array(); |
|
103 | - if ($data == '') return array(); |
|
108 | + if (!is_string($data)) { |
|
109 | + return array(); |
|
110 | + } |
|
111 | + if ($data == '') { |
|
112 | + return array(); |
|
113 | + } |
|
104 | 114 | $html = str_get_html($data); |
105 | - if ($html === false) return array(); |
|
115 | + if ($html === false) { |
|
116 | + return array(); |
|
117 | + } |
|
106 | 118 | $tabledata=array(); |
107 | 119 | foreach($html->find('tr') as $element) |
108 | 120 | { |
@@ -137,7 +149,9 @@ discard block |
||
137 | 149 | */ |
138 | 150 | public function text2array($data) { |
139 | 151 | $html = str_get_html($data); |
140 | - if ($html === false) return array(); |
|
152 | + if ($html === false) { |
|
153 | + return array(); |
|
154 | + } |
|
141 | 155 | $tabledata=array(); |
142 | 156 | foreach($html->find('p') as $element) |
143 | 157 | { |
@@ -158,7 +172,9 @@ discard block |
||
158 | 172 | * @return Float Distance in $unit |
159 | 173 | */ |
160 | 174 | public function distance($lat, $lon, $latc, $lonc, $unit = 'km') { |
161 | - if ($lat == $latc && $lon == $lonc) return 0; |
|
175 | + if ($lat == $latc && $lon == $lonc) { |
|
176 | + return 0; |
|
177 | + } |
|
162 | 178 | $dist = rad2deg(acos(sin(deg2rad(floatval($lat)))*sin(deg2rad(floatval($latc)))+ cos(deg2rad(floatval($lat)))*cos(deg2rad(floatval($latc)))*cos(deg2rad(floatval($lon)-floatval($lonc)))))*60*1.1515; |
163 | 179 | if ($unit == "km") { |
164 | 180 | return round($dist * 1.609344); |
@@ -182,10 +198,16 @@ discard block |
||
182 | 198 | public function withinThreshold ($timeDifference, $distance) { |
183 | 199 | $x = abs($timeDifference); |
184 | 200 | $d = abs($distance); |
185 | - if ($x == 0 || $d == 0) return true; |
|
201 | + if ($x == 0 || $d == 0) { |
|
202 | + return true; |
|
203 | + } |
|
186 | 204 | // may be due to Internet jitter; distance is realistic |
187 | - if ($x < 0.7 && $d < 2000) return true; |
|
188 | - else return $d/$x < 1500*0.27778; // 1500 km/h max |
|
205 | + if ($x < 0.7 && $d < 2000) { |
|
206 | + return true; |
|
207 | + } else { |
|
208 | + return $d/$x < 1500*0.27778; |
|
209 | + } |
|
210 | + // 1500 km/h max |
|
189 | 211 | } |
190 | 212 | |
191 | 213 | |
@@ -245,7 +267,9 @@ discard block |
||
245 | 267 | public function hex2str($hex) { |
246 | 268 | $str = ''; |
247 | 269 | $hexln = strlen($hex); |
248 | - for($i=0;$i<$hexln;$i+=2) $str .= chr(hexdec(substr($hex,$i,2))); |
|
270 | + for($i=0;$i<$hexln;$i+=2) { |
|
271 | + $str .= chr(hexdec(substr($hex,$i,2))); |
|
272 | + } |
|
249 | 273 | return $str; |
250 | 274 | } |
251 | 275 | |
@@ -273,8 +297,11 @@ discard block |
||
273 | 297 | $b = $lat2 - $lat1; |
274 | 298 | $c = -($a*$lat1+$b*$lon1); |
275 | 299 | $d = $a*$lat3+$b*$lon3+$c; |
276 | - if ($d > -$approx && $d < $approx) return true; |
|
277 | - else return false; |
|
300 | + if ($d > -$approx && $d < $approx) { |
|
301 | + return true; |
|
302 | + } else { |
|
303 | + return false; |
|
304 | + } |
|
278 | 305 | } |
279 | 306 | |
280 | 307 | public function array_merge_noappend() { |
@@ -310,7 +337,9 @@ discard block |
||
310 | 337 | return $result; |
311 | 338 | } |
312 | 339 | $handle = @opendir('./locale'); |
313 | - if ($handle === false) return $result; |
|
340 | + if ($handle === false) { |
|
341 | + return $result; |
|
342 | + } |
|
314 | 343 | while (false !== ($file = readdir($handle))) { |
315 | 344 | $path = './locale'.'/'.$file.'/LC_MESSAGES/fam.mo'; |
316 | 345 | if ($file != "." && $file != ".." && @file_exists($path)) { |