DEPRECATED
Detects human/robots easily!
0.2.1
- Lifetime
- Saves the captcha in session
- Generates the captcha in png format
- XSS clean
- Extensible using adapters
- Apdaters: random text, math equation
This content is released under the MIT License
- PHP 5.3.*
cd /var/www
git clone https://github.com/rocket-code/owncaptcha.git
cd owncaptcha
composer install
"require": {
"php": ">=5.3.0",
"rocketcode/owncaptcha": "*",
}
0.2.2 (development)
- Add unit testing
0.2.1
- Change repository url
- Update composer.json
- Update docblock
- Travis-CI integration
0.2.0
- Math image adapter
- New examples
- Unit testing
- Change function name: setSessionVar to sessionVar
- Change function name in \owncaptcha\Captcha class: draw to build
0.1.0
- Text image adapter
- Session storage
- Captcha validation
El tiempo de vida del captcha se configura mediante el método ttl. Default: 60 seg
$captcha = new \owncaptcha\Catpcha();
$captcha->ttl(3600); //1 hora
Habilitar/deshabilitar sessiones
Para habilitar/deshabilitar que el script guarde el valor del captcha en sessiones: Default: true
$captcha->sessionSave(true); //o false
Variable donde se almacena el valor del capcha en session
Con el método setSessionVar se puede cambiar la variable donde se almacena el captcha en session Default: owncaptcha
$captcha->sessionVar('myvar');
La validación se realiza con el método validate
$code = (isset($_POST['code']))?$_POST['code']:'';
$result = $captcha->validate($code); // true or false
Los adapters son distintas clases que implementan la lógica de como renderizar el captcha.
Crea imagen con un texto aleatorio.
$adapter = new \owncaptcha\adapters\TextImage();
$adapter->config(
array(....)
);
- width: (int) ancho de la imagen
- height: (int) alto de la imagen
- bg: (array) color de fondo (rgb)
- forecolor: (array) color del testo (rgb)
- linecolor: (array) color de las lineas del fondo (rgb)
- lines: (int) cantidad de lineas en el fondo
- enablettf: (bool) indica si se usa una tipografia ttf o del sistema (true: usa ttf, false: usa del sistema)
- ttf: (string) ubicación de la fuente ttf
- fontsize: (int) tamaño de la fuente ttf
- padding: (int) padding de la imagen
- lineweight: (int) grosor de las lineas de fondo
Crea imagen con una ecuación matemática.
$adapter = new \owncaptcha\adapters\MathImage();