@@ -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 | } |
@@ -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 | } |
@@ -25,7 +25,7 @@ discard block |
||
25 | 25 | // Return path of sandbox directory for the given user. |
26 | 26 | // Create dir if not present. |
27 | 27 | // |
28 | -if (!function_exists("sandbox_dir")){ |
|
28 | +if (!function_exists("sandbox_dir")) { |
|
29 | 29 | function sandbox_dir($user) { |
30 | 30 | $dir = parse_config(get_config(), "<sandbox_dir>"); |
31 | 31 | if (!$dir) { $dir = "../../sandbox/"; } |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | foreach ($files as $file) { |
55 | 55 | $path = $dir."/".$file; |
56 | 56 | list($err, $file_size, $file_md5) = sandbox_parse_link_file($path); |
57 | - if (!$err){ |
|
57 | + if (!$err) { |
|
58 | 58 | if (strcmp($md5, $file_md5) == 0) { |
59 | 59 | //echo "this file with $md5 already exisits with another name $file"; |
60 | 60 | $exist = 1; |
@@ -125,7 +125,7 @@ discard block |
||
125 | 125 | } |
126 | 126 | $files = sandbox_file_names($user); |
127 | 127 | foreach ($files as $f) { |
128 | - if(preg_match("/$regexp/",$f)){ |
|
128 | + if(preg_match("/$regexp/",$f)) { |
|
129 | 129 | $x .= "<option value=\"$f\">$f</option>\n"; |
130 | 130 | } |
131 | 131 | } |
@@ -136,7 +136,7 @@ discard block |
||
136 | 136 | |
137 | 137 | //check if a file is still being used by a unfinished batch |
138 | 138 | // |
139 | -function sandbox_file_in_use($user, $file){ |
|
139 | +function sandbox_file_in_use($user, $file) { |
|
140 | 140 | $ufiles = array(); |
141 | 141 | |
142 | 142 | // batch status: 2(completed), 3(aborted) |
@@ -144,17 +144,17 @@ discard block |
||
144 | 144 | $pbatches = BoincBatch::enum("user_id = $user->id and state != 2 and state != 3"); |
145 | 145 | if (!$pbatches) return false; |
146 | 146 | |
147 | - foreach ($pbatches as $batch){ |
|
147 | + foreach ($pbatches as $batch) { |
|
148 | 148 | $wus = BoincWorkUnit::enum("batch = $batch->id limit 1" ); |
149 | - if ($wus == null){ |
|
149 | + if ($wus == null) { |
|
150 | 150 | //echo " no workunit for this batch<br/>"; |
151 | 151 | continue; |
152 | 152 | } |
153 | - foreach($wus as $wu){ |
|
153 | + foreach($wus as $wu) { |
|
154 | 154 | $x = "<in>".$wu->xml_doc."</in>"; |
155 | 155 | $x = simplexml_load_string($x); |
156 | 156 | global $fanout; |
157 | - foreach($x->workunit->file_ref as $fr){ |
|
157 | + foreach($x->workunit->file_ref as $fr) { |
|
158 | 158 | $pname = (string)$fr->file_name; |
159 | 159 | $ufiles[] = $pname; |
160 | 160 | } |
@@ -165,10 +165,10 @@ discard block |
||
165 | 165 | $dir = sandbox_dir($user); |
166 | 166 | $path = $dir."/".$file; |
167 | 167 | list($err, $size, $md5) = sandbox_parse_link_file($path); |
168 | - if (!$err){ |
|
168 | + if (!$err) { |
|
169 | 169 | $f = sandbox_file_name($user, $md5); |
170 | 170 | foreach($ufiles as $uf) { |
171 | - if (strcmp($f,$uf) == 0){ |
|
171 | + if (strcmp($f,$uf) == 0) { |
|
172 | 172 | return true; |
173 | 173 | } |
174 | 174 |
@@ -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; |