Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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.
- Host: GitHub
- URL: https://github.com/muhammetsafak/captcha
- Owner: muhammetsafak
- License: mit
- Created: 2022-04-23T03:36:37.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2022-04-23T03:41:44.000Z (over 2 years ago)
- Last Synced: 2024-04-14T16:39:26.413Z (8 months ago)
- Language: PHP
- Homepage:
- Size: 67.4 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Captcha
It's simply an old-school captcha app.
## 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)