@@ -34,8 +34,7 @@ discard block |
||
| 34 | 34 | * instead of get_file_contents(). This is to account for people who may be on |
| 35 | 35 | * servers where allow_furl_open is disabled. |
| 36 | 36 | */ |
| 37 | -class SocketPost implements RequestMethod |
|
| 38 | -{ |
|
| 37 | +class SocketPost implements RequestMethod { |
|
| 39 | 38 | /** |
| 40 | 39 | * reCAPTCHA service host. |
| 41 | 40 | * @const string |
@@ -68,8 +67,7 @@ discard block |
||
| 68 | 67 | * |
| 69 | 68 | * @param \ReCaptcha\RequestMethod\Socket $socket optional socket, injectable for testing |
| 70 | 69 | */ |
| 71 | - public function __construct(Socket $socket = null) |
|
| 72 | - { |
|
| 70 | + public function __construct(Socket $socket = null) { |
|
| 73 | 71 | if (!is_null($socket)) { |
| 74 | 72 | $this->socket = $socket; |
| 75 | 73 | } else { |
@@ -83,8 +81,7 @@ discard block |
||
| 83 | 81 | * @param RequestParameters $params Request parameters |
| 84 | 82 | * @return string Body of the reCAPTCHA response |
| 85 | 83 | */ |
| 86 | - public function submit(RequestParameters $params) |
|
| 87 | - { |
|
| 84 | + public function submit(RequestParameters $params) { |
|
| 88 | 85 | $errno = 0; |
| 89 | 86 | $errstr = ''; |
| 90 | 87 | |
@@ -29,16 +29,14 @@ discard block |
||
| 29 | 29 | /** |
| 30 | 30 | * Convenience wrapper around the cURL functions to allow mocking. |
| 31 | 31 | */ |
| 32 | -class Curl |
|
| 33 | -{ |
|
| 32 | +class Curl { |
|
| 34 | 33 | |
| 35 | 34 | /** |
| 36 | 35 | * @see http://php.net/curl_init |
| 37 | 36 | * @param string $url |
| 38 | 37 | * @return resource cURL handle |
| 39 | 38 | */ |
| 40 | - public function init($url = null) |
|
| 41 | - { |
|
| 39 | + public function init($url = null) { |
|
| 42 | 40 | return curl_init($url); |
| 43 | 41 | } |
| 44 | 42 | |
@@ -48,8 +46,7 @@ discard block |
||
| 48 | 46 | * @param array $options |
| 49 | 47 | * @return bool |
| 50 | 48 | */ |
| 51 | - public function setoptArray($ch, array $options) |
|
| 52 | - { |
|
| 49 | + public function setoptArray($ch, array $options) { |
|
| 53 | 50 | return curl_setopt_array($ch, $options); |
| 54 | 51 | } |
| 55 | 52 | |
@@ -58,8 +55,7 @@ discard block |
||
| 58 | 55 | * @param resource $ch |
| 59 | 56 | * @return mixed |
| 60 | 57 | */ |
| 61 | - public function exec($ch) |
|
| 62 | - { |
|
| 58 | + public function exec($ch) { |
|
| 63 | 59 | return curl_exec($ch); |
| 64 | 60 | } |
| 65 | 61 | |
@@ -67,8 +63,7 @@ discard block |
||
| 67 | 63 | * @see http://php.net/curl_close |
| 68 | 64 | * @param resource $ch |
| 69 | 65 | */ |
| 70 | - public function close($ch) |
|
| 71 | - { |
|
| 66 | + public function close($ch) { |
|
| 72 | 67 | curl_close($ch); |
| 73 | 68 | } |
| 74 | 69 | } |
@@ -29,8 +29,7 @@ discard block |
||
| 29 | 29 | /** |
| 30 | 30 | * The response returned from the service. |
| 31 | 31 | */ |
| 32 | -class Response |
|
| 33 | -{ |
|
| 32 | +class Response { |
|
| 34 | 33 | /** |
| 35 | 34 | * Succes or failure. |
| 36 | 35 | * @var boolean |
@@ -49,8 +48,7 @@ discard block |
||
| 49 | 48 | * @param string $json |
| 50 | 49 | * @return \ReCaptcha\Response |
| 51 | 50 | */ |
| 52 | - public static function fromJson($json) |
|
| 53 | - { |
|
| 51 | + public static function fromJson($json) { |
|
| 54 | 52 | $responseData = json_decode($json, true); |
| 55 | 53 | |
| 56 | 54 | if (!$responseData) { |
@@ -74,8 +72,7 @@ discard block |
||
| 74 | 72 | * @param boolean $success |
| 75 | 73 | * @param array $errorCodes |
| 76 | 74 | */ |
| 77 | - public function __construct($success, array $errorCodes = array()) |
|
| 78 | - { |
|
| 75 | + public function __construct($success, array $errorCodes = array()) { |
|
| 79 | 76 | $this->success = $success; |
| 80 | 77 | $this->errorCodes = $errorCodes; |
| 81 | 78 | } |
@@ -85,8 +82,7 @@ discard block |
||
| 85 | 82 | * |
| 86 | 83 | * @return boolean |
| 87 | 84 | */ |
| 88 | - public function isSuccess() |
|
| 89 | - { |
|
| 85 | + public function isSuccess() { |
|
| 90 | 86 | return $this->success; |
| 91 | 87 | } |
| 92 | 88 | |
@@ -95,8 +91,7 @@ discard block |
||
| 95 | 91 | * |
| 96 | 92 | * @return array |
| 97 | 93 | */ |
| 98 | - public function getErrorCodes() |
|
| 99 | - { |
|
| 94 | + public function getErrorCodes() { |
|
| 100 | 95 | return $this->errorCodes; |
| 101 | 96 | } |
| 102 | 97 | } |
@@ -29,8 +29,7 @@ discard block |
||
| 29 | 29 | /** |
| 30 | 30 | * Stores and formats the parameters for the request to the reCAPTCHA service. |
| 31 | 31 | */ |
| 32 | -class RequestParameters |
|
| 33 | -{ |
|
| 32 | +class RequestParameters { |
|
| 34 | 33 | /** |
| 35 | 34 | * Site secret. |
| 36 | 35 | * @var string |
@@ -63,8 +62,7 @@ discard block |
||
| 63 | 62 | * @param string $remoteIp User's IP address. |
| 64 | 63 | * @param string $version Version of this client library. |
| 65 | 64 | */ |
| 66 | - public function __construct($secret, $response, $remoteIp = null, $version = null) |
|
| 67 | - { |
|
| 65 | + public function __construct($secret, $response, $remoteIp = null, $version = null) { |
|
| 68 | 66 | $this->secret = $secret; |
| 69 | 67 | $this->response = $response; |
| 70 | 68 | $this->remoteIp = $remoteIp; |
@@ -76,8 +74,7 @@ discard block |
||
| 76 | 74 | * |
| 77 | 75 | * @return array Array formatted parameters. |
| 78 | 76 | */ |
| 79 | - public function toArray() |
|
| 80 | - { |
|
| 77 | + public function toArray() { |
|
| 81 | 78 | $params = array('secret' => $this->secret, 'response' => $this->response); |
| 82 | 79 | |
| 83 | 80 | if (!is_null($this->remoteIp)) { |
@@ -96,8 +93,7 @@ discard block |
||
| 96 | 93 | * |
| 97 | 94 | * @return string Query string formatted parameters. |
| 98 | 95 | */ |
| 99 | - public function toQueryString() |
|
| 100 | - { |
|
| 96 | + public function toQueryString() { |
|
| 101 | 97 | return http_build_query($this->toArray(), '', '&'); |
| 102 | 98 | } |
| 103 | 99 | } |
@@ -22,7 +22,7 @@ discard block |
||
| 22 | 22 | function time_diff_str($t1, $t2) { |
| 23 | 23 | if (!$t1 || !$t2) return "---"; |
| 24 | 24 | $diff = $t2 - $t1; |
| 25 | - if ($diff<0){ |
|
| 25 | + if ($diff<0) { |
|
| 26 | 26 | $pre="In "; |
| 27 | 27 | $post=""; |
| 28 | 28 | $diff=-$diff; |
@@ -63,7 +63,7 @@ discard block |
||
| 63 | 63 | return $pre.$x.$post; |
| 64 | 64 | } elseif($diff > 1 || $diff==0) { |
| 65 | 65 | return $pre."$diff seconds".$post; |
| 66 | - } elseif($diff == 1){ |
|
| 66 | + } elseif($diff == 1) { |
|
| 67 | 67 | return $pre."$diff seconds".$post; |
| 68 | 68 | } |
| 69 | 69 | } |
@@ -215,7 +215,7 @@ |
||
| 215 | 215 | // |
| 216 | 216 | $fl = BoincForumLogging::lookup(0, 0); |
| 217 | 217 | if ($fl) { |
| 218 | - if ($fl->timestamp<time()-MAX_FORUM_LOGGING_TIME){ |
|
| 218 | + if ($fl->timestamp<time()-MAX_FORUM_LOGGING_TIME) { |
|
| 219 | 219 | BoincForumLogging::delete_aux("timestamp<'".(time()-MAX_FORUM_LOGGING_TIME)."' and userid != 0"); |
| 220 | 220 | BoincForumLogging::replace(0, 0, time()); |
| 221 | 221 | } |
@@ -59,7 +59,7 @@ |
||
| 59 | 59 | return 0; |
| 60 | 60 | } |
| 61 | 61 | |
| 62 | -function team_type_select($selected_type, $allow_none=false){ |
|
| 62 | +function team_type_select($selected_type, $allow_none=false) { |
|
| 63 | 63 | global $team_types; |
| 64 | 64 | |
| 65 | 65 | $types = $team_types; |
@@ -556,7 +556,7 @@ |
||
| 556 | 556 | function print_prefs_form( |
| 557 | 557 | $action, $subset, $venue, $user, $prefs, $cols, $error=false, |
| 558 | 558 | $project_error=false |
| 559 | -){ |
|
| 559 | +) { |
|
| 560 | 560 | if ($action == "add") { |
| 561 | 561 | $script = "add_venue.php"; |
| 562 | 562 | $submit_value = tra("Add preferences"); |
@@ -229,7 +229,7 @@ discard block |
||
| 229 | 229 | shmop_close ($shmid); |
| 230 | 230 | } |
| 231 | 231 | |
| 232 | -function _setup_segments($gi){ |
|
| 232 | +function _setup_segments($gi) { |
|
| 233 | 233 | $gi->databaseType = GEOIP_COUNTRY_EDITION; |
| 234 | 234 | $gi->record_length = STANDARD_RECORD_LENGTH; |
| 235 | 235 | if ($gi->flags & GEOIP_SHARED_MEMORY) { |
@@ -241,18 +241,18 @@ discard block |
||
| 241 | 241 | $gi->databaseType = ord(@shmop_read ($gi->shmid, $offset, 1)); |
| 242 | 242 | $offset++; |
| 243 | 243 | |
| 244 | - if ($gi->databaseType == GEOIP_REGION_EDITION_REV0){ |
|
| 244 | + if ($gi->databaseType == GEOIP_REGION_EDITION_REV0) { |
|
| 245 | 245 | $gi->databaseSegments = GEOIP_STATE_BEGIN_REV0; |
| 246 | - } else if ($gi->databaseType == GEOIP_REGION_EDITION_REV1){ |
|
| 246 | + } else if ($gi->databaseType == GEOIP_REGION_EDITION_REV1) { |
|
| 247 | 247 | $gi->databaseSegments = GEOIP_STATE_BEGIN_REV1; |
| 248 | 248 | } else if (($gi->databaseType == GEOIP_CITY_EDITION_REV0)|| |
| 249 | 249 | ($gi->databaseType == GEOIP_CITY_EDITION_REV1) |
| 250 | 250 | || ($gi->databaseType == GEOIP_ORG_EDITION) |
| 251 | 251 | || ($gi->databaseType == GEOIP_ISP_EDITION) |
| 252 | - || ($gi->databaseType == GEOIP_ASNUM_EDITION)){ |
|
| 252 | + || ($gi->databaseType == GEOIP_ASNUM_EDITION)) { |
|
| 253 | 253 | $gi->databaseSegments = 0; |
| 254 | 254 | $buf = @shmop_read ($gi->shmid, $offset, SEGMENT_RECORD_LENGTH); |
| 255 | - for ($j = 0;$j < SEGMENT_RECORD_LENGTH;$j++){ |
|
| 255 | + for ($j = 0;$j < SEGMENT_RECORD_LENGTH;$j++) { |
|
| 256 | 256 | $gi->databaseSegments += (ord($buf[$j]) << ($j * 8)); |
| 257 | 257 | } |
| 258 | 258 | if (($gi->databaseType == GEOIP_ORG_EDITION)|| |
@@ -267,7 +267,7 @@ discard block |
||
| 267 | 267 | } |
| 268 | 268 | if (($gi->databaseType == GEOIP_COUNTRY_EDITION)|| |
| 269 | 269 | ($gi->databaseType == GEOIP_PROXY_EDITION)|| |
| 270 | - ($gi->databaseType == GEOIP_NETSPEED_EDITION)){ |
|
| 270 | + ($gi->databaseType == GEOIP_NETSPEED_EDITION)) { |
|
| 271 | 271 | $gi->databaseSegments = GEOIP_COUNTRY_BEGIN; |
| 272 | 272 | } |
| 273 | 273 | } else { |
@@ -275,21 +275,20 @@ discard block |
||
| 275 | 275 | fseek($gi->filehandle, -3, SEEK_END); |
| 276 | 276 | for ($i = 0; $i < STRUCTURE_INFO_MAX_SIZE; $i++) { |
| 277 | 277 | $delim = fread($gi->filehandle,3); |
| 278 | - if ($delim == (chr(255).chr(255).chr(255))){ |
|
| 278 | + if ($delim == (chr(255).chr(255).chr(255))) { |
|
| 279 | 279 | $gi->databaseType = ord(fread($gi->filehandle,1)); |
| 280 | - if ($gi->databaseType == GEOIP_REGION_EDITION_REV0){ |
|
| 280 | + if ($gi->databaseType == GEOIP_REGION_EDITION_REV0) { |
|
| 281 | 281 | $gi->databaseSegments = GEOIP_STATE_BEGIN_REV0; |
| 282 | - } |
|
| 283 | - else if ($gi->databaseType == GEOIP_REGION_EDITION_REV1){ |
|
| 282 | + } else if ($gi->databaseType == GEOIP_REGION_EDITION_REV1) { |
|
| 284 | 283 | $gi->databaseSegments = GEOIP_STATE_BEGIN_REV1; |
| 285 | - } else if (($gi->databaseType == GEOIP_CITY_EDITION_REV0) || |
|
| 284 | + } else if (($gi->databaseType == GEOIP_CITY_EDITION_REV0) || |
|
| 286 | 285 | ($gi->databaseType == GEOIP_CITY_EDITION_REV1) || |
| 287 | 286 | ($gi->databaseType == GEOIP_ORG_EDITION) || |
| 288 | 287 | ($gi->databaseType == GEOIP_ISP_EDITION) || |
| 289 | - ($gi->databaseType == GEOIP_ASNUM_EDITION)){ |
|
| 288 | + ($gi->databaseType == GEOIP_ASNUM_EDITION)) { |
|
| 290 | 289 | $gi->databaseSegments = 0; |
| 291 | 290 | $buf = fread($gi->filehandle,SEGMENT_RECORD_LENGTH); |
| 292 | - for ($j = 0;$j < SEGMENT_RECORD_LENGTH;$j++){ |
|
| 291 | + for ($j = 0;$j < SEGMENT_RECORD_LENGTH;$j++) { |
|
| 293 | 292 | $gi->databaseSegments += (ord($buf[$j]) << ($j * 8)); |
| 294 | 293 | } |
| 295 | 294 | if ($gi->databaseType == GEOIP_ORG_EDITION) { |
@@ -303,7 +302,7 @@ discard block |
||
| 303 | 302 | } |
| 304 | 303 | if (($gi->databaseType == GEOIP_COUNTRY_EDITION)|| |
| 305 | 304 | ($gi->databaseType == GEOIP_PROXY_EDITION)|| |
| 306 | - ($gi->databaseType == GEOIP_NETSPEED_EDITION)){ |
|
| 305 | + ($gi->databaseType == GEOIP_NETSPEED_EDITION)) { |
|
| 307 | 306 | $gi->databaseSegments = GEOIP_COUNTRY_BEGIN; |
| 308 | 307 | } |
| 309 | 308 | fseek($gi->filehandle,$filepos,SEEK_SET); |
@@ -419,7 +418,7 @@ discard block |
||
| 419 | 418 | return false; |
| 420 | 419 | } |
| 421 | 420 | |
| 422 | -function _get_org($gi,$ipnum){ |
|
| 421 | +function _get_org($gi,$ipnum) { |
|
| 423 | 422 | $seek_org = _geoip_seek_country($gi,$ipnum); |
| 424 | 423 | if ($seek_org == $gi->databaseSegments) { |
| 425 | 424 | return NULL; |
@@ -443,10 +442,10 @@ discard block |
||
| 443 | 442 | return _get_org($gi, $ipnum); |
| 444 | 443 | } |
| 445 | 444 | |
| 446 | -function _get_region($gi,$ipnum){ |
|
| 447 | - if ($gi->databaseType == GEOIP_REGION_EDITION_REV0){ |
|
| 445 | +function _get_region($gi,$ipnum) { |
|
| 446 | + if ($gi->databaseType == GEOIP_REGION_EDITION_REV0) { |
|
| 448 | 447 | $seek_region = _geoip_seek_country($gi,$ipnum) - GEOIP_STATE_BEGIN_REV0; |
| 449 | - if ($seek_region >= 1000){ |
|
| 448 | + if ($seek_region >= 1000) { |
|
| 450 | 449 | $country_code = "US"; |
| 451 | 450 | $region = chr(($seek_region - 1000)/26 + 65) . chr(($seek_region - 1000)%26 + 65); |
| 452 | 451 | } else { |
@@ -454,10 +453,10 @@ discard block |
||
| 454 | 453 | $region = ""; |
| 455 | 454 | } |
| 456 | 455 | return array ($country_code,$region); |
| 457 | - } else if ($gi->databaseType == GEOIP_REGION_EDITION_REV1) { |
|
| 456 | + } else if ($gi->databaseType == GEOIP_REGION_EDITION_REV1) { |
|
| 458 | 457 | $seek_region = _geoip_seek_country($gi,$ipnum) - GEOIP_STATE_BEGIN_REV1; |
| 459 | 458 | //print $seek_region; |
| 460 | - if ($seek_region < US_OFFSET){ |
|
| 459 | + if ($seek_region < US_OFFSET) { |
|
| 461 | 460 | $country_code = ""; |
| 462 | 461 | $region = ""; |
| 463 | 462 | } else if ($seek_region < CANADA_OFFSET) { |
@@ -482,7 +481,7 @@ discard block |
||
| 482 | 481 | return _get_region($gi, $ipnum); |
| 483 | 482 | } |
| 484 | 483 | |
| 485 | -function getdnsattributes ($l,$ip){ |
|
| 484 | +function getdnsattributes ($l,$ip) { |
|
| 486 | 485 | $r = new Net_DNS_Resolver(); |
| 487 | 486 | $r->nameservers = array("ws1.maxmind.com"); |
| 488 | 487 | $p = $r->search($l."." . $ip .".s.maxmind.com","TXT","IN"); |