Skip to content
This repository has been archived by the owner on Jan 29, 2020. It is now read-only.

Commit

Permalink
Merge branch 'develop' of git://github.com/zendframework/zf2 into string
Browse files Browse the repository at this point in the history
  • Loading branch information
Show file tree
Hide file tree
Showing 25 changed files with 190 additions and 440 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"homepage": "https://github.com/zendframework/zend-captcha",
"autoload": {
"psr-4": {
"Zend\\Captcha": "src/"
"Zend\\Captcha\\": "src/"
}
},
"require": {
Expand Down
25 changes: 7 additions & 18 deletions src/AbstractAdapter.php
Original file line number Diff line number Diff line change
@@ -1,22 +1,11 @@
<?php
/**
* Zend Framework
* Zend Framework (http://framework.zend.com/)
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @category Zend
* @package Zend_Captcha
* @subpackage Adapter
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @link http://github.com/zendframework/zf2 for the canonical source repository
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @package Zend_Captcha
*/

namespace Zend\Captcha;
Expand All @@ -32,8 +21,6 @@
* @category Zend
* @package Zend_Captcha
* @subpackage Adapter
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
abstract class AbstractAdapter extends AbstractValidator implements AdapterInterface
{
Expand Down Expand Up @@ -76,6 +63,7 @@ public function getName()
* Set name
*
* @param string $name
* @return AbstractAdapter
*/
public function setName($name)
{
Expand Down Expand Up @@ -113,6 +101,7 @@ public function setOption($key, $value)
* Set object state from options array
*
* @param array|Traversable $options
* @throws Exception\InvalidArgumentException
* @return AbstractAdapter
*/
public function setOptions($options = array())
Expand Down
50 changes: 20 additions & 30 deletions src/AbstractWord.php
Original file line number Diff line number Diff line change
@@ -1,27 +1,17 @@
<?php
/**
* Zend Framework
* Zend Framework (http://framework.zend.com/)
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @category Zend
* @package Zend_Captcha
* @subpackage Adapter
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @link http://github.com/zendframework/zf2 for the canonical source repository
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @package Zend_Captcha
*/

namespace Zend\Captcha;

use Zend\Session\Container;
use Zend\Math\Rand;

/**
* AbstractWord-based captcha adapter
Expand All @@ -31,18 +21,16 @@
* @category Zend
* @package Zend_Captcha
* @subpackage Adapter
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
abstract class AbstractWord extends AbstractAdapter
{
/**#@+
* @var array Character sets
*/
static $V = array("a", "e", "i", "o", "u", "y");
static $VN = array("a", "e", "i", "o", "u", "y","2","3","4","5","6","7","8","9");
static $C = array("b","c","d","f","g","h","j","k","m","n","p","q","r","s","t","u","v","w","x","z");
static $CN = array("b","c","d","f","g","h","j","k","m","n","p","q","r","s","t","u","v","w","x","z","2","3","4","5","6","7","8","9");
public static $V = array("a", "e", "i", "o", "u", "y");
public static $VN = array("a", "e", "i", "o", "u", "y","2","3","4","5","6","7","8","9");
public static $C = array("b","c","d","f","g","h","j","k","m","n","p","q","r","s","t","u","v","w","x","z");
public static $CN = array("b","c","d","f","g","h","j","k","m","n","p","q","r","s","t","u","v","w","x","z","2","3","4","5","6","7","8","9");
/**#@-*/

/**
Expand Down Expand Up @@ -113,7 +101,7 @@ abstract class AbstractWord extends AbstractAdapter
* Error messages
* @var array
*/
protected $_messageTemplates = array(
protected $messageTemplates = array(
self::MISSING_VALUE => 'Empty captcha value',
self::MISSING_ID => 'Captcha ID field is missing',
self::BAD_CAPTCHA => 'Captcha value is wrong',
Expand Down Expand Up @@ -149,7 +137,7 @@ public function setSessionClass($sessionClass)
}

/**
* Retrieve word length to use when genrating captcha
* Retrieve word length to use when generating captcha
*
* @return integer
*/
Expand Down Expand Up @@ -187,7 +175,7 @@ public function getId()
* Set captcha identifier
*
* @param string $id
* return Word
* @return AbstractWord
*/
protected function setId ($id)
{
Expand Down Expand Up @@ -220,7 +208,7 @@ public function getTimeout()
/**
* Sets if session should be preserved on generate()
*
* @param $keepSession Should session be kept on generate()?
* @param bool $keepSession Should session be kept on generate()?
* @return AbstractWord
*/
public function setKeepSession($keepSession)
Expand Down Expand Up @@ -254,6 +242,7 @@ public function setUseNumbers($useNumbers)
/**
* Get session object
*
* @throws Exception\InvalidArgumentException
* @return Container
*/
public function getSession()
Expand Down Expand Up @@ -322,8 +311,8 @@ protected function generateWord()
{
$word = '';
$wordLen = $this->getWordLen();
$vowels = $this->useNumbers ? self::$VN : self::$V;
$consonants = $this->useNumbers ? self::$CN : self::$C;
$vowels = $this->useNumbers ? static::$VN : static::$V;
$consonants = $this->useNumbers ? static::$CN : static::$C;

for ($i=0; $i < $wordLen; $i = $i + 2) {
// generate word with mix of vowels and consonants
Expand Down Expand Up @@ -359,18 +348,19 @@ public function generate()
/**
* Generate a random identifier
*
* @return void
* @return string
*/
protected function generateRandomId()
{
return md5(mt_rand(0, 1000) . microtime(true));
return md5(Rand::getBytes(32));
}

/**
* Validate the word
*
* @see Zend\Validator\ValidatorInterface::isValid()
* @param mixed $value
* @param mixed $context
* @return bool
*/
public function isValid($value, $context = null)
Expand Down
23 changes: 5 additions & 18 deletions src/AdapterInterface.php
Original file line number Diff line number Diff line change
@@ -1,22 +1,11 @@
<?php
/**
* Zend Framework
* Zend Framework (http://framework.zend.com/)
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @category Zend
* @package Zend_Captcha
* @subpackage Adapter
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @link http://github.com/zendframework/zf2 for the canonical source repository
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @package Zend_Captcha
*/

namespace Zend\Captcha;
Expand All @@ -31,8 +20,6 @@
* @category Zend
* @package Zend_Captcha
* @subpackage Adapter
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
interface AdapterInterface extends ValidatorInterface
{
Expand Down
25 changes: 6 additions & 19 deletions src/Dumb.php
Original file line number Diff line number Diff line change
@@ -1,22 +1,11 @@
<?php
/**
* Zend Framework
* Zend Framework (http://framework.zend.com/)
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @category Zend
* @package Zend_Captcha
* @subpackage Adapter
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @link http://github.com/zendframework/zf2 for the canonical source repository
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @package Zend_Captcha
*/

namespace Zend\Captcha;
Expand All @@ -30,8 +19,6 @@
* @category Zend
* @package Zend_Captcha
* @subpackage Adapter
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Dumb extends AbstractWord
{
Expand Down Expand Up @@ -61,7 +48,7 @@ public function getLabel()

/**
* Retrieve optional view helper name to use when rendering this captcha
*
*
* @return string
*/
public function getHelperName()
Expand Down
23 changes: 5 additions & 18 deletions src/Exception/DomainException.php
Original file line number Diff line number Diff line change
@@ -1,22 +1,11 @@
<?php
/**
* Zend Framework
* Zend Framework (http://framework.zend.com/)
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @category Zend
* @package Zend_Captcha
* @subpackage Exception
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @link http://github.com/zendframework/zf2 for the canonical source repository
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @package Zend_Captcha
*/

namespace Zend\Captcha\Exception;
Expand All @@ -25,8 +14,6 @@
* @category Zend
* @package Zend_Captcha
* @subpackage Exception
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class DomainException extends \DomainException implements ExceptionInterface
{
Expand Down
23 changes: 5 additions & 18 deletions src/Exception/ExceptionInterface.php
Original file line number Diff line number Diff line change
@@ -1,22 +1,11 @@
<?php
/**
* Zend Framework
* Zend Framework (http://framework.zend.com/)
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @category Zend
* @package Zend_Captcha
* @subpackage Exception
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @link http://github.com/zendframework/zf2 for the canonical source repository
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @package Zend_Captcha
*/

namespace Zend\Captcha\Exception;
Expand All @@ -27,8 +16,6 @@
* @category Zend
* @package Zend_Captcha
* @subpackage Exception
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
interface ExceptionInterface
{
Expand Down
23 changes: 5 additions & 18 deletions src/Exception/ExtensionNotLoadedException.php
Original file line number Diff line number Diff line change
@@ -1,22 +1,11 @@
<?php
/**
* Zend Framework
* Zend Framework (http://framework.zend.com/)
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @category Zend
* @package Zend_Captcha
* @subpackage Exception
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @link http://github.com/zendframework/zf2 for the canonical source repository
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @package Zend_Captcha
*/

namespace Zend\Captcha\Exception;
Expand All @@ -27,8 +16,6 @@
* @category Zend
* @package Zend_Captcha
* @subpackage Exception
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class ExtensionNotLoadedException extends RuntimeException
{
Expand Down
Loading

0 comments on commit ae88ee0

Please sign in to comment.