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 |
CurlPost.php
001 <?php
002 /**
003 * This is a PHP library that handles calling reCAPTCHA.
004 *
005 * BSD 3-Clause License
006 * @copyright (c) 2019, Google Inc.
007 * @link https://www.google.com/recaptcha
008 * All rights reserved.
009 *
010 * Redistribution and use in source and binary forms, with or without
011 * modification, are permitted provided that the following conditions are met:
012 * 1. Redistributions of source code must retain the above copyright notice, this
013 * list of conditions and the following disclaimer.
014 *
015 * 2. Redistributions in binary form must reproduce the above copyright notice,
016 * this list of conditions and the following disclaimer in the documentation
017 * and/or other materials provided with the distribution.
018 *
019 * 3. Neither the name of the copyright holder nor the names of its
020 * contributors may be used to endorse or promote products derived from
021 * this software without specific prior written permission.
022 *
023 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
024 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
025 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
026 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
027 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
028 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
029 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
030 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
031 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
032 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
033 */
034
035 namespace ReCaptcha\RequestMethod;
036
037 use ReCaptcha\ReCaptcha;
038 use ReCaptcha\RequestMethod;
039 use ReCaptcha\RequestParameters;
040
041 /**
042 * Sends cURL request to the reCAPTCHA service.
043 * Note: this requires the cURL extension to be enabled in PHP
044 * @see http://php.net/manual/en/book.curl.php
045 */
046 class CurlPost implements RequestMethod
047 {
048 /**
049 * Curl connection to the reCAPTCHA service
050 * @var Curl
051 */
052 private $curl;
053
054 /**
055 * URL for reCAPTCHA siteverify API
056 * @var string
057 */
058 private $siteVerifyUrl;
059
060 /**
061 * Only needed if you want to override the defaults
062 *
063 * @param Curl $curl Curl resource
064 * @param string $siteVerifyUrl URL for reCAPTCHA siteverify API
065 */
066 public function __construct(Curl $curl = null, $siteVerifyUrl = null)
067 {
068 $this->curl = (is_null($curl)) ? new Curl() : $curl;
069 $this->siteVerifyUrl = (is_null($siteVerifyUrl)) ? ReCaptcha::SITE_VERIFY_URL : $siteVerifyUrl;
070 }
071
072 /**
073 * Submit the cURL request with the specified parameters.
074 *
075 * @param RequestParameters $params Request parameters
076 * @return string Body of the reCAPTCHA response
077 */
078 public function submit(RequestParameters $params)
079 {
080 $handle = $this->curl->init($this->siteVerifyUrl);
081
082 $options = array(
083 CURLOPT_POST => true,
084 CURLOPT_POSTFIELDS => $params->toQueryString(),
085 CURLOPT_HTTPHEADER => array(
086 'Content-Type: application/x-www-form-urlencoded'
087 ),
088 CURLINFO_HEADER_OUT => false,
089 CURLOPT_HEADER => false,
090 CURLOPT_RETURNTRANSFER => true,
091 CURLOPT_SSL_VERIFYPEER => true
092 );
093 $this->curl->setoptArray($handle, $options);
094
095 $response = $this->curl->exec($handle);
096 $this->curl->close($handle);
097
098 if ($response !== false) {
099 return $response;
100 }
101
102 return '{"success": false, "error-codes": ["'.ReCaptcha::E_CONNECTION_FAILED.'"]}';
103 }
104 }
105