Verzeichnisstruktur phpBB-3.3.15
- Veröffentlicht
- 28.08.2024
So funktioniert es
|
Auf das letzte Element klicken. Dies geht jeweils ein Schritt zurück |
Auf das Icon klicken, dies öffnet das Verzeichnis. Nochmal klicken schließt das Verzeichnis. |
|
(Beispiel Datei-Icons)
|
Auf das Icon klicken um den Quellcode anzuzeigen |
Post.php
01 <?php
02 /**
03 * This is a PHP library that handles calling reCAPTCHA.
04 *
05 * BSD 3-Clause License
06 * @copyright (c) 2019, Google Inc.
07 * @link https://www.google.com/recaptcha
08 * All rights reserved.
09 *
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\RequestMethod;
36
37 use ReCaptcha\ReCaptcha;
38 use ReCaptcha\RequestMethod;
39 use ReCaptcha\RequestParameters;
40
41 /**
42 * Sends POST requests to the reCAPTCHA service.
43 */
44 class Post implements RequestMethod
45 {
46 /**
47 * URL for reCAPTCHA siteverify API
48 * @var string
49 */
50 private $siteVerifyUrl;
51
52 /**
53 * Only needed if you want to override the defaults
54 *
55 * @param string $siteVerifyUrl URL for reCAPTCHA siteverify API
56 */
57 public function __construct($siteVerifyUrl = null)
58 {
59 $this->siteVerifyUrl = (is_null($siteVerifyUrl)) ? ReCaptcha::SITE_VERIFY_URL : $siteVerifyUrl;
60 }
61
62 /**
63 * Submit the POST request with the specified parameters.
64 *
65 * @param RequestParameters $params Request parameters
66 * @return string Body of the reCAPTCHA response
67 */
68 public function submit(RequestParameters $params)
69 {
70 $options = array(
71 'http' => array(
72 'header' => "Content-type: application/x-www-form-urlencoded\r\n",
73 'method' => 'POST',
74 'content' => $params->toQueryString(),
75 // Force the peer to validate (not needed in 5.6.0+, but still works)
76 'verify_peer' => true,
77 ),
78 );
79 $context = stream_context_create($options);
80 $response = file_get_contents($this->siteVerifyUrl, false, $context);
81
82 if ($response !== false) {
83 return $response;
84 }
85
86 return '{"success": false, "error-codes": ["'.ReCaptcha::E_CONNECTION_FAILED.'"]}';
87 }
88 }
89