@@ -161,7 +161,7 @@ discard block |
||
| 161 | 161 | // To override this with your own policy, create a similar function in |
| 162 | 162 | // your own project.inc called uotd_candidates_query() |
| 163 | 163 | // |
| 164 | -function default_uotd_candidates_query(){ |
|
| 164 | +function default_uotd_candidates_query() { |
|
| 165 | 165 | $query = "SELECT * FROM profile,user WHERE profile.userid=user.id "; |
| 166 | 166 | $query .= " AND verification=1 "; |
| 167 | 167 | $query .= " AND expavg_credit>1 "; |
@@ -173,7 +173,7 @@ discard block |
||
| 173 | 173 | // get a list of profiles that have been 'approved' for UOTD, |
| 174 | 174 | // using a project-specific query if supplied in project.inc |
| 175 | 175 | // |
| 176 | -function count_uotd_candidates(){ |
|
| 176 | +function count_uotd_candidates() { |
|
| 177 | 177 | $n = -1; // negative value returned on error |
| 178 | 178 | if (function_exists('uotd_candidates_query')) { |
| 179 | 179 | $query = uotd_candidates_query(); |
@@ -196,16 +196,16 @@ discard block |
||
| 196 | 196 | function generate_uotd_gadget($profile, $user) { |
| 197 | 197 | $x = "<font size='2'>\n"; |
| 198 | 198 | $gadget = PROFILE_PATH."uotd_gadget.html"; |
| 199 | - if( $h = fopen($gadget, "w") ){ |
|
| 199 | + if( $h = fopen($gadget, "w") ) { |
|
| 200 | 200 | $age = time()-$profile->uotd_time; |
| 201 | 201 | echo "age: $age"; |
| 202 | - if($age <= 86400+3600) { // allow for slop |
|
| 202 | + if($age <= 86400+3600) { |
|
| 203 | +// allow for slop |
|
| 203 | 204 | $x .= uotd_thumbnail($profile, $user); |
| 204 | 205 | $x .= user_links($user, BADGE_HEIGHT_MEDIUM); |
| 205 | 206 | $resp = sanitize_tags(output_transform($profile->response1)); |
| 206 | 207 | $x .= " ". sub_sentence($resp, ' ', 250, true); |
| 207 | - } |
|
| 208 | - else { |
|
| 208 | + } else { |
|
| 209 | 209 | $x .= "<font color='fuscia'> |
| 210 | 210 | There is no User of the Day today. |
| 211 | 211 | Only volunteers who have created a Profile |
@@ -46,7 +46,7 @@ discard block |
||
| 46 | 46 | $temph = $fh; |
| 47 | 47 | } |
| 48 | 48 | |
| 49 | - if ($newGD){ |
|
| 49 | + if ($newGD) { |
|
| 50 | 50 | $tempImage = imageCreateTrueColor($tempw, $temph); |
| 51 | 51 | // Seems not to work: |
| 52 | 52 | // imageAntiAlias($tempImage, true); |
@@ -66,7 +66,7 @@ discard block |
||
| 66 | 66 | $offsetx = number_format(($tempw/2)-($fw/2), 0); |
| 67 | 67 | } |
| 68 | 68 | |
| 69 | - if ($newGD){ |
|
| 69 | + if ($newGD) { |
|
| 70 | 70 | $destImage = imageCreateTrueColor($fw, $fh); |
| 71 | 71 | // Seems not to work: |
| 72 | 72 | // imageAntiAlias($tempImage, true); |
@@ -42,7 +42,8 @@ discard block |
||
| 42 | 42 | |
| 43 | 43 | $response = akismet_request($request, "$key.rest.akismet.com", "/1.1/comment-check"); |
| 44 | 44 | |
| 45 | - if ("true" == $response[1]) { // Akismet says it's spam |
|
| 45 | + if ("true" == $response[1]) { |
|
| 46 | +// Akismet says it's spam |
|
| 46 | 47 | return false; |
| 47 | 48 | } else { |
| 48 | 49 | return true; |
@@ -64,8 +65,10 @@ discard block |
||
| 64 | 65 | $response = ''; |
| 65 | 66 | if( false !== ( $fs = @fsockopen($host, $port, $errno, $errstr, 3) ) ) { |
| 66 | 67 | fwrite($fs, $http_request); |
| 67 | - while ( !feof($fs) ) |
|
| 68 | - $response .= fgets($fs, 1160); // One TCP-IP packet |
|
| 68 | + while ( !feof($fs) ) { |
|
| 69 | + $response .= fgets($fs, 1160); |
|
| 70 | + } |
|
| 71 | + // One TCP-IP packet |
|
| 69 | 72 | fclose($fs); |
| 70 | 73 | $response = explode("\r\n\r\n", $response, 2); |
| 71 | 74 | } |
@@ -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 | } |
@@ -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 | |