Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/muhammetsafak/captcha

It's simply an old-school captcha app.
https://github.com/muhammetsafak/captcha

Last synced: 26 days ago
JSON representation

It's simply an old-school captcha app.

Awesome Lists containing this project

README

        

# Captcha

It's simply an old-school captcha app.

php-basic-captcha

## Requirements

- PHP 5.6 or higher
- PHP GD Extension

## Installation

```
composer require muhammetsafak/captcha:dev-main
```

or download and include the file `src/Captcha.php`.

## Usage

The file `src/image-captcha.php` simply generates and presents a captcha for you. You can edit this file for a custom configuration or create your own.

### Configuration
```
$configs = array(
'width' => 200, // Width of captcha image to be created
'height' => 70, // Height of captcha image to be created
'length' => 7, // The number of characters to be found in the captcha image.
'font' => __DIR__ . '/src/AHGBold.ttf', // Defines the font of the captcha characters.
'size' => 18 // Defines the size of captcha characters.
);
```

To create a captcha image; `image-captcha.php`

```php
require_once __DIR__ . '/src/Captcha.php';
$config = array(
'width' => 180,
'height' => 50,
'length' => 6
);
$captcha = new \MuhammetSafak\Captcha\Captcha($config);
$captcha->create();
```

```html






Refresh



function captcha_refresh()
{
img = document.getElementById("captcha");
img.src = '../src/image-captcha.php';
}

```

A simple validation example is as follows.

```php
require_once __DIR__ . '/src/Captcha.php';
$captcha = new \MuhammetSafak\Captcha\Captcha();
if(isset($_POST)){
if($captcha->verify($_POST['areYouBot'])){
// Success
// ...process
}else{
// Error
echo 'Enter the characters in the picture correctly.';
}
}
```

## Licence

Copyright © 2022 [MIT License](./LICENSE)