web/lib/Zend/Service/ReCaptcha/Response.php
changeset 807 877f952ae2bd
parent 207 621fa6caec0c
child 1230 68c69c656a2c
equal deleted inserted replaced
805:5e7a0fedabdf 807:877f952ae2bd
    13  * to license@zend.com so we can send you a copy immediately.
    13  * to license@zend.com so we can send you a copy immediately.
    14  *
    14  *
    15  * @category   Zend
    15  * @category   Zend
    16  * @package    Zend_Service
    16  * @package    Zend_Service
    17  * @subpackage ReCaptcha
    17  * @subpackage ReCaptcha
    18  * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
    18  * @copyright  Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
    19  * @license    http://framework.zend.com/license/new-bsd     New BSD License
    19  * @license    http://framework.zend.com/license/new-bsd     New BSD License
    20  */
    20  */
    21 
    21 
    22 /**
    22 /**
    23  * Zend_Service_ReCaptcha_Response
    23  * Zend_Service_ReCaptcha_Response
    24  *
    24  *
    25  * @category   Zend
    25  * @category   Zend
    26  * @package    Zend_Service
    26  * @package    Zend_Service
    27  * @subpackage ReCaptcha
    27  * @subpackage ReCaptcha
    28  * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
    28  * @copyright  Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
    29  * @license    http://framework.zend.com/license/new-bsd     New BSD License
    29  * @license    http://framework.zend.com/license/new-bsd     New BSD License
    30  * @version    $Id: Response.php 20096 2010-01-06 02:05:09Z bkarwin $
    30  * @version    $Id: Response.php 25152 2012-11-28 11:55:44Z cogo $
    31  */
    31  */
    32 class Zend_Service_ReCaptcha_Response
    32 class Zend_Service_ReCaptcha_Response
    33 {
    33 {
    34     /**
    34     /**
    35      * Status
    35      * Status
   140      */
   140      */
   141     public function setFromHttpResponse(Zend_Http_Response $response)
   141     public function setFromHttpResponse(Zend_Http_Response $response)
   142     {
   142     {
   143         $body = $response->getBody();
   143         $body = $response->getBody();
   144 
   144 
   145         $parts = explode("\n", $body, 2);
   145         // Default status and error code
       
   146         $status = 'false';
       
   147         $errorCode = '';
   146 
   148 
   147         if (count($parts) !== 2) {
   149         $parts = explode("\n", $body);
   148             $status = 'false';
   150 
   149             $errorCode = '';
   151         if ($parts[0] === 'true') {
   150         } else {
   152             $status = 'true';
   151             list($status, $errorCode) = $parts;
   153         }
       
   154 
       
   155         if (!empty($parts[1])) {
       
   156             $errorCode = $parts[1];
   152         }
   157         }
   153 
   158 
   154         $this->setStatus($status);
   159         $this->setStatus($status);
   155         $this->setErrorCode($errorCode);
   160         $this->setErrorCode($errorCode);
   156 
   161