@@ -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 | |
@@ -86,11 +90,15 @@ discard block |
||
| 86 | 90 | curl_setopt($ch, CURLOPT_URL, $url); |
| 87 | 91 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); |
| 88 | 92 | curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); |
| 89 | - if ($referer != '') curl_setopt($ch, CURLOPT_REFERER, $referer); |
|
| 93 | + if ($referer != '') { |
|
| 94 | + curl_setopt($ch, CURLOPT_REFERER, $referer); |
|
| 95 | + } |
|
| 90 | 96 | 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'); |
| 91 | 97 | curl_setopt($ch, CURLOPT_FILE, $fp); |
| 92 | 98 | curl_exec($ch); |
| 93 | - if (curl_errno($ch) && $globalDebug) echo 'Download error: '.curl_error($ch); |
|
| 99 | + if (curl_errno($ch) && $globalDebug) { |
|
| 100 | + echo 'Download error: '.curl_error($ch); |
|
| 101 | + } |
|
| 94 | 102 | curl_close($ch); |
| 95 | 103 | fclose($fp); |
| 96 | 104 | } |
@@ -101,10 +109,16 @@ discard block |
||
| 101 | 109 | * @return Array array of the tables in HTML page |
| 102 | 110 | */ |
| 103 | 111 | public function table2array($data) { |
| 104 | - if (!is_string($data)) return array(); |
|
| 105 | - if ($data == '') return array(); |
|
| 112 | + if (!is_string($data)) { |
|
| 113 | + return array(); |
|
| 114 | + } |
|
| 115 | + if ($data == '') { |
|
| 116 | + return array(); |
|
| 117 | + } |
|
| 106 | 118 | $html = str_get_html($data); |
| 107 | - if ($html === false) return array(); |
|
| 119 | + if ($html === false) { |
|
| 120 | + return array(); |
|
| 121 | + } |
|
| 108 | 122 | $tabledata=array(); |
| 109 | 123 | foreach($html->find('tr') as $element) |
| 110 | 124 | { |
@@ -139,7 +153,9 @@ discard block |
||
| 139 | 153 | */ |
| 140 | 154 | public function text2array($data) { |
| 141 | 155 | $html = str_get_html($data); |
| 142 | - if ($html === false) return array(); |
|
| 156 | + if ($html === false) { |
|
| 157 | + return array(); |
|
| 158 | + } |
|
| 143 | 159 | $tabledata=array(); |
| 144 | 160 | foreach($html->find('p') as $element) |
| 145 | 161 | { |
@@ -160,7 +176,9 @@ discard block |
||
| 160 | 176 | * @return Float Distance in $unit |
| 161 | 177 | */ |
| 162 | 178 | public function distance($lat, $lon, $latc, $lonc, $unit = 'km') { |
| 163 | - if ($lat == $latc && $lon == $lonc) return 0; |
|
| 179 | + if ($lat == $latc && $lon == $lonc) { |
|
| 180 | + return 0; |
|
| 181 | + } |
|
| 164 | 182 | $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; |
| 165 | 183 | if ($unit == "km") { |
| 166 | 184 | return round($dist * 1.609344); |
@@ -184,10 +202,16 @@ discard block |
||
| 184 | 202 | public function withinThreshold ($timeDifference, $distance) { |
| 185 | 203 | $x = abs($timeDifference); |
| 186 | 204 | $d = abs($distance); |
| 187 | - if ($x == 0 || $d == 0) return true; |
|
| 205 | + if ($x == 0 || $d == 0) { |
|
| 206 | + return true; |
|
| 207 | + } |
|
| 188 | 208 | // may be due to Internet jitter; distance is realistic |
| 189 | - if ($x < 0.7 && $d < 2000) return true; |
|
| 190 | - else return $d/$x < 1500*0.27778; // 1500 km/h max |
|
| 209 | + if ($x < 0.7 && $d < 2000) { |
|
| 210 | + return true; |
|
| 211 | + } else { |
|
| 212 | + return $d/$x < 1500*0.27778; |
|
| 213 | + } |
|
| 214 | + // 1500 km/h max |
|
| 191 | 215 | } |
| 192 | 216 | |
| 193 | 217 | |
@@ -247,7 +271,9 @@ discard block |
||
| 247 | 271 | public function hex2str($hex) { |
| 248 | 272 | $str = ''; |
| 249 | 273 | $hexln = strlen($hex); |
| 250 | - for($i=0;$i<$hexln;$i+=2) $str .= chr(hexdec(substr($hex,$i,2))); |
|
| 274 | + for($i=0;$i<$hexln;$i+=2) { |
|
| 275 | + $str .= chr(hexdec(substr($hex,$i,2))); |
|
| 276 | + } |
|
| 251 | 277 | return $str; |
| 252 | 278 | } |
| 253 | 279 | |
@@ -275,8 +301,11 @@ discard block |
||
| 275 | 301 | $b = $lat2 - $lat1; |
| 276 | 302 | $c = -($a*$lat1+$b*$lon1); |
| 277 | 303 | $d = $a*$lat3+$b*$lon3+$c; |
| 278 | - if ($d > -$approx && $d < $approx) return true; |
|
| 279 | - else return false; |
|
| 304 | + if ($d > -$approx && $d < $approx) { |
|
| 305 | + return true; |
|
| 306 | + } else { |
|
| 307 | + return false; |
|
| 308 | + } |
|
| 280 | 309 | } |
| 281 | 310 | |
| 282 | 311 | public function array_merge_noappend() { |
@@ -312,7 +341,9 @@ discard block |
||
| 312 | 341 | return $result; |
| 313 | 342 | } |
| 314 | 343 | $handle = @opendir('./locale'); |
| 315 | - if ($handle === false) return $result; |
|
| 344 | + if ($handle === false) { |
|
| 345 | + return $result; |
|
| 346 | + } |
|
| 316 | 347 | while (false !== ($file = readdir($handle))) { |
| 317 | 348 | $path = './locale'.'/'.$file.'/LC_MESSAGES/fam.mo'; |
| 318 | 349 | if ($file != "." && $file != ".." && @file_exists($path)) { |