Skip to content

Releases: WackoWiki/freecap

Release list

1.5.1

Choose a tag to compare

@vendeeglobe vendeeglobe released this 10 Jul 12:58

correct namespace in composer.json

1.5.0

Choose a tag to compare

@vendeeglobe vendeeglobe released this 10 Jul 12:36

Release v1.5.0 - Modern OOP Refactor & Composer Support

Welcome to the first release of the modernized freeCap!

This release completely refactors Howard Yeend's original procedural CAPTCHA script into a robust, object-oriented, PSR-4 compliant PHP library. It is designed for seamless integration into modern PHP applications and frameworks like WackoWiki, while carefully preserving all the original educational comments and OCR circumvention logic.

Highlights

  • Object-Oriented Architecture: The entire procedural script has been encapsulated within the FreeCap\FreeCap class. State and configuration are now strictly managed via class properties.
  • Composer & PSR-4: Full Composer support. Install via composer require wackowiki/freecap and let the autoloader handle the rest.
  • Decoupled Session Adapters: Introduced AdapterInterface and SessionAdapter. CAPTCHA state (hashes, attempts, shown flags) is no longer hardcoded to $_SESSION. You can easily integrate with framework-specific session objects, caches, or custom arrays.
  • Graceful Asset Fallbacks: Moved assets to a dedicated resources/ folder. If custom GD fonts or dictionary files are missing, freeCap now gracefully falls back to bundled GD fonts and pseudo-random string generation instead of crashing.
  • PHPUnit 11 Tests: Added a comprehensive test suite covering image generation, validation success/failure, and brute-force protection mechanisms.

Code Quality & Style

  • Added native PHP 8.2+ type hints, return types, and readonly properties.
  • Preserved the original freeCap educational inline comments regarding brute force protection, OCR circumvention, and morph logic, mapped accurately to their new OOP counterparts.

Directory Structure

If you are upgrading from the legacy package, note that assets must now be placed in a resources/ directory at the root of your library installation:

freecap/
├── resources/           # <-- Move fonts, dictionary, and bg images here
├── src/
│   ├── AdapterInterface.php
│   ├── FreeCap.php
│   └── SessionAdapter.php
├── tests/
└── composer.json

Quick Start

use FreeCap\FreeCap;
use FreeCap\SessionAdapter;

// 1. Initialize adapter
$adapter = new SessionAdapter($_SESSION);

// 2. Configure (optional)
$config = [
    'use_dict' => 1,
    'bg_type'  => 1,
    'output'   => 'webp',
];

// 3. Render image
$captcha = new FreeCap($adapter, $config);
$captcha->render(); 

Full documentation available in the README.md.

Credits

  • Howard Yeend (puremango.co.uk) - Original author of freeCap.
  • WackoWiki Team - OOP refactor, test coverage, and modern maintenance.