Verzeichnisstruktur phpBB-3.2.0


Veröffentlicht
06.01.2017

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.
Auf den Verzeichnisnamen klicken, dies zeigt nur das Verzeichnis mit Inhalt an

(Beispiel Datei-Icons)

Auf das Icon klicken um den Quellcode anzuzeigen

Response.php

Zuletzt modifiziert: 09.10.2024, 12:57 - Dateigröße: 2.73 KiB


001  <?php
002  /**
003   * This is a PHP library that handles calling reCAPTCHA.
004   *
005   * @copyright Copyright (c) 2015, Google Inc.
006   * @link      http://www.google.com/recaptcha
007   *
008   * Permission is hereby granted, free of charge, to any person obtaining a copy
009   * of this software and associated documentation files (the "Software"), to deal
010   * in the Software without restriction, including without limitation the rights
011   * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
012   * copies of the Software, and to permit persons to whom the Software is
013   * furnished to do so, subject to the following conditions:
014   *
015   * The above copyright notice and this permission notice shall be included in
016   * all copies or substantial portions of the Software.
017   *
018   * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
019   * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
020   * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
021   * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
022   * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
023   * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
024   * THE SOFTWARE.
025   */
026   
027  namespace ReCaptcha;
028   
029  /**
030   * The response returned from the service.
031   */
032  class Response
033  {
034      /**
035       * Succes or failure.
036       * @var boolean
037       */
038      private $success = false;
039   
040      /**
041       * Error code strings.
042       * @var array
043       */
044      private $errorCodes = array();
045   
046      /**
047       * Build the response from the expected JSON returned by the service.
048       *
049       * @param string $json
050       * @return \ReCaptcha\Response
051       */
052      public static function fromJson($json)
053      {
054          $responseData = json_decode($json, true);
055   
056          if (!$responseData) {
057              return new Response(false, array('invalid-json'));
058          }
059   
060          if (isset($responseData['success']) && $responseData['success'] == true) {
061              return new Response(true);
062          }
063   
064          if (isset($responseData['error-codes']) && is_array($responseData['error-codes'])) {
065              return new Response(false, $responseData['error-codes']);
066          }
067   
068          return new Response(false);
069      }
070   
071      /**
072       * Constructor.
073       *
074       * @param boolean $success
075       * @param array $errorCodes
076       */
077      public function __construct($success, array $errorCodes = array())
078      {
079          $this->success = $success;
080          $this->errorCodes = $errorCodes;
081      }
082   
083      /**
084       * Is success?
085       *
086       * @return boolean
087       */
088      public function isSuccess()
089      {
090          return $this->success;
091      }
092   
093      /**
094       * Get error codes.
095       *
096       * @return array
097       */
098      public function getErrorCodes()
099      {
100          return $this->errorCodes;
101      }
102  }
103