@@ -29,8 +29,7 @@ discard block |
||
29 | 29 | /** |
30 | 30 | * reCAPTCHA client. |
31 | 31 | */ |
32 | -class ReCaptcha |
|
33 | -{ |
|
32 | +class ReCaptcha { |
|
34 | 33 | /** |
35 | 34 | * Version of this client library. |
36 | 35 | * @const string |
@@ -55,8 +54,7 @@ discard block |
||
55 | 54 | * @param string $secret shared secret between site and reCAPTCHA server. |
56 | 55 | * @param RequestMethod $requestMethod method used to send the request. Defaults to POST. |
57 | 56 | */ |
58 | - public function __construct($secret, RequestMethod $requestMethod = null) |
|
59 | - { |
|
57 | + public function __construct($secret, RequestMethod $requestMethod = null) { |
|
60 | 58 | if (empty($secret)) { |
61 | 59 | throw new \RuntimeException('No secret provided'); |
62 | 60 | } |
@@ -82,8 +80,7 @@ discard block |
||
82 | 80 | * @param string $remoteIp The end user's IP address. |
83 | 81 | * @return Response Response from the service. |
84 | 82 | */ |
85 | - public function verify($response, $remoteIp = null) |
|
86 | - { |
|
83 | + public function verify($response, $remoteIp = null) { |
|
87 | 84 | // Discard empty solution submissions |
88 | 85 | if (empty($response)) { |
89 | 86 | $recaptchaResponse = new Response(false, array('missing-input-response')); |
@@ -29,8 +29,7 @@ |
||
29 | 29 | /** |
30 | 30 | * Method used to send the request to the service. |
31 | 31 | */ |
32 | -interface RequestMethod |
|
33 | -{ |
|
32 | +interface RequestMethod { |
|
34 | 33 | |
35 | 34 | /** |
36 | 35 | * Submit the request with the specified parameters. |
@@ -34,8 +34,7 @@ discard block |
||
34 | 34 | * Note: this requires the cURL extension to be enabled in PHP |
35 | 35 | * @see http://php.net/manual/en/book.curl.php |
36 | 36 | */ |
37 | -class CurlPost implements RequestMethod |
|
38 | -{ |
|
37 | +class CurlPost implements RequestMethod { |
|
39 | 38 | /** |
40 | 39 | * URL to which requests are sent via cURL. |
41 | 40 | * @const string |
@@ -48,8 +47,7 @@ discard block |
||
48 | 47 | */ |
49 | 48 | private $curl; |
50 | 49 | |
51 | - public function __construct(Curl $curl = null) |
|
52 | - { |
|
50 | + public function __construct(Curl $curl = null) { |
|
53 | 51 | if (!is_null($curl)) { |
54 | 52 | $this->curl = $curl; |
55 | 53 | } else { |
@@ -63,8 +61,7 @@ discard block |
||
63 | 61 | * @param RequestParameters $params Request parameters |
64 | 62 | * @return string Body of the reCAPTCHA response |
65 | 63 | */ |
66 | - public function submit(RequestParameters $params) |
|
67 | - { |
|
64 | + public function submit(RequestParameters $params) { |
|
68 | 65 | $handle = $this->curl->init(self::SITE_VERIFY_URL); |
69 | 66 | |
70 | 67 | $options = array( |
@@ -32,8 +32,7 @@ discard block |
||
32 | 32 | /** |
33 | 33 | * Sends POST requests to the reCAPTCHA service. |
34 | 34 | */ |
35 | -class Post implements RequestMethod |
|
36 | -{ |
|
35 | +class Post implements RequestMethod { |
|
37 | 36 | /** |
38 | 37 | * URL to which requests are POSTed. |
39 | 38 | * @const string |
@@ -46,8 +45,7 @@ discard block |
||
46 | 45 | * @param RequestParameters $params Request parameters |
47 | 46 | * @return string Body of the reCAPTCHA response |
48 | 47 | */ |
49 | - public function submit(RequestParameters $params) |
|
50 | - { |
|
48 | + public function submit(RequestParameters $params) { |
|
51 | 49 | /** |
52 | 50 | * PHP 5.6.0 changed the way you specify the peer name for SSL context options. |
53 | 51 | * Using "CN_name" will still work, but it will raise deprecated errors. |
@@ -30,8 +30,7 @@ discard block |
||
30 | 30 | * Convenience wrapper around native socket and file functions to allow for |
31 | 31 | * mocking. |
32 | 32 | */ |
33 | -class Socket |
|
34 | -{ |
|
33 | +class Socket { |
|
35 | 34 | private $handle = null; |
36 | 35 | |
37 | 36 | /** |
@@ -45,8 +44,7 @@ discard block |
||
45 | 44 | * @param float $timeout |
46 | 45 | * @return resource |
47 | 46 | */ |
48 | - public function fsockopen($hostname, $port = -1, &$errno = 0, &$errstr = '', $timeout = null) |
|
49 | - { |
|
47 | + public function fsockopen($hostname, $port = -1, &$errno = 0, &$errstr = '', $timeout = null) { |
|
50 | 48 | $this->handle = fsockopen($hostname, $port, $errno, $errstr, (is_null($timeout) ? ini_get("default_socket_timeout") : $timeout)); |
51 | 49 | |
52 | 50 | if ($this->handle != false && $errno === 0 && $errstr === '') { |
@@ -63,8 +61,7 @@ discard block |
||
63 | 61 | * @param int $length |
64 | 62 | * @return int | bool |
65 | 63 | */ |
66 | - public function fwrite($string, $length = null) |
|
67 | - { |
|
64 | + public function fwrite($string, $length = null) { |
|
68 | 65 | return fwrite($this->handle, $string, (is_null($length) ? strlen($string) : $length)); |
69 | 66 | } |
70 | 67 | |
@@ -75,8 +72,7 @@ discard block |
||
75 | 72 | * @param int $length |
76 | 73 | * @return string |
77 | 74 | */ |
78 | - public function fgets($length = null) |
|
79 | - { |
|
75 | + public function fgets($length = null) { |
|
80 | 76 | return fgets($this->handle, $length); |
81 | 77 | } |
82 | 78 | |
@@ -86,8 +82,7 @@ discard block |
||
86 | 82 | * @see http://php.net/feof |
87 | 83 | * @return bool |
88 | 84 | */ |
89 | - public function feof() |
|
90 | - { |
|
85 | + public function feof() { |
|
91 | 86 | return feof($this->handle); |
92 | 87 | } |
93 | 88 | |
@@ -97,8 +92,7 @@ discard block |
||
97 | 92 | * @see http://php.net/fclose |
98 | 93 | * @return bool |
99 | 94 | */ |
100 | - public function fclose() |
|
101 | - { |
|
95 | + public function fclose() { |
|
102 | 96 | return fclose($this->handle); |
103 | 97 | } |
104 | 98 | } |
@@ -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 | } |
@@ -56,17 +56,17 @@ discard block |
||
56 | 56 | $dl_md5_path = "$dl_path.md5"; |
57 | 57 | $have_md5_file = false; |
58 | 58 | $md5 = md5_file($path); |
59 | - if ($md5 === FALSE) { |
|
59 | + if ($md5 === false) { |
|
60 | 60 | return -2; |
61 | 61 | } |
62 | 62 | $size = filesize($path); |
63 | - if ($size === FALSE) { |
|
63 | + if ($size === false) { |
|
64 | 64 | return -2; |
65 | 65 | } |
66 | 66 | |
67 | 67 | if (file_exists($dl_md5_path)) { |
68 | 68 | $x = file_get_contents($dl_md5_path); |
69 | - if ($x === FALSE) { |
|
69 | + if ($x === false) { |
|
70 | 70 | return -2; |
71 | 71 | } |
72 | 72 | $x = explode(" ", $x); |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | if (file_exists($dl_path)) { |
79 | 79 | if ($have_md5_file) { |
80 | 80 | $s = filesize($dl_path); |
81 | - if ($s === FALSE) { |
|
81 | + if ($s === false) { |
|
82 | 82 | return -2; |
83 | 83 | } |
84 | 84 | if ($s == $dl_size && $dl_md5 == $md5) { |
@@ -91,11 +91,11 @@ discard block |
||
91 | 91 | // missing the .md5 file; need to look at the file |
92 | 92 | // |
93 | 93 | $m = md5_file($dl_path); |
94 | - if ($m === FALSE) { |
|
94 | + if ($m === false) { |
|
95 | 95 | return -2; |
96 | 96 | } |
97 | 97 | if ($m == $md5) { |
98 | - if (file_put_contents($dl_md5_path, "$md5 $size\n") === FALSE) { |
|
98 | + if (file_put_contents($dl_md5_path, "$md5 $size\n") === false) { |
|
99 | 99 | return -2; |
100 | 100 | } |
101 | 101 | return 0; |
@@ -103,7 +103,7 @@ discard block |
||
103 | 103 | return -1; |
104 | 104 | } |
105 | 105 | } else { |
106 | - if (file_put_contents($dl_md5_path, "$md5 $size\n") === FALSE) { |
|
106 | + if (file_put_contents($dl_md5_path, "$md5 $size\n") === false) { |
|
107 | 107 | return -2; |
108 | 108 | } |
109 | 109 | return 1; |
@@ -37,7 +37,7 @@ |
||
37 | 37 | } |
38 | 38 | |
39 | 39 | function upload_path($filename) { |
40 | - static $upload_dir=null; |
|
40 | + static $upload_dir = null; |
|
41 | 41 | if (!$upload_dir) { |
42 | 42 | $config = get_config(); |
43 | 43 | $upload_dir = parse_config($config, '<upload_dir>'); |