[ Index ] |
PHP Cross Reference of phpBB-3.3.14-deutsch |
[Summary view] [Print] [Text view]
1 <?php 2 /** 3 * This is a PHP library that handles calling reCAPTCHA. 4 * 5 * BSD 3-Clause License 6 * @copyright (c) 2019, Google Inc. 7 * @link https://www.google.com/recaptcha 8 * All rights reserved. 9 * 10 * Redistribution and use in source and binary forms, with or without 11 * modification, are permitted provided that the following conditions are met: 12 * 1. Redistributions of source code must retain the above copyright notice, this 13 * list of conditions and the following disclaimer. 14 * 15 * 2. Redistributions in binary form must reproduce the above copyright notice, 16 * this list of conditions and the following disclaimer in the documentation 17 * and/or other materials provided with the distribution. 18 * 19 * 3. Neither the name of the copyright holder nor the names of its 20 * contributors may be used to endorse or promote products derived from 21 * this software without specific prior written permission. 22 * 23 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 24 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 25 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 26 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 27 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 28 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 29 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 30 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 31 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 32 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 33 */ 34 35 namespace ReCaptcha; 36 37 /** 38 * Stores and formats the parameters for the request to the reCAPTCHA service. 39 */ 40 class RequestParameters 41 { 42 /** 43 * The shared key between your site and reCAPTCHA. 44 * @var string 45 */ 46 private $secret; 47 48 /** 49 * The user response token provided by reCAPTCHA, verifying the user on your site. 50 * @var string 51 */ 52 private $response; 53 54 /** 55 * Remote user's IP address. 56 * @var string 57 */ 58 private $remoteIp; 59 60 /** 61 * Client version. 62 * @var string 63 */ 64 private $version; 65 66 /** 67 * Initialise parameters. 68 * 69 * @param string $secret Site secret. 70 * @param string $response Value from g-captcha-response form field. 71 * @param string $remoteIp User's IP address. 72 * @param string $version Version of this client library. 73 */ 74 public function __construct($secret, $response, $remoteIp = null, $version = null) 75 { 76 $this->secret = $secret; 77 $this->response = $response; 78 $this->remoteIp = $remoteIp; 79 $this->version = $version; 80 } 81 82 /** 83 * Array representation. 84 * 85 * @return array Array formatted parameters. 86 */ 87 public function toArray() 88 { 89 $params = array('secret' => $this->secret, 'response' => $this->response); 90 91 if (!is_null($this->remoteIp)) { 92 $params['remoteip'] = $this->remoteIp; 93 } 94 95 if (!is_null($this->version)) { 96 $params['version'] = $this->version; 97 } 98 99 return $params; 100 } 101 102 /** 103 * Query string representation for HTTP request. 104 * 105 * @return string Query string formatted parameters. 106 */ 107 public function toQueryString() 108 { 109 return http_build_query($this->toArray(), '', '&'); 110 } 111 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Mon Nov 25 19:05:08 2024 | Cross-referenced by PHPXref 0.7.1 |