Download the PHP package aminarjmand/pure-captcha without Composer

On this page you can find all versions of the php package aminarjmand/pure-captcha. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package pure-captcha

# 🔒 Pure Captcha **A secure, customizable and lightweight PHP CAPTCHA package** **یک پکیج کپچای امن، قابل تنظیم و سبک برای PHP** [![PHP Version](https://img.shields.io/badge/PHP-%3E%3D7.4-8892BF.svg)](https://php.net) [![License: MIT](https://img.shields.io/badge/License-MIT-green.svg)](LICENSE) [![Packagist](https://img.shields.io/packagist/v/aminarjmand/pure-captcha.svg)](https://packagist.org/packages/aminarjmand/pure-captcha) [English](#english) | [فارسی](#فارسی)

🇬🇧 English

📖 About

Pure Captcha is a lightweight, dependency-free PHP CAPTCHA package that generates secure CAPTCHA images using only PHP's built-in GD extension. No external services, no JavaScript dependencies, no API keys required.

✨ Features

📋 Requirements

📥 Installation

🚀 Quick Start

Step 1: Create the image endpoint

Create a file called captcha_image.php:

Step 2: Add CAPTCHA to your form

Step 3: Validate the CAPTCHA

Create submit.php:

⚙️ Configuration

Method 1: Configuration File

Create captcha_config.php in your project root:

Method 2: Runtime Configuration

⚠️ Note: When using configure(), you must call it in both your form file and captcha_image.php, because each HTTP request is independent.

Configuration Options

Option Type Default Description
lang string 'fa' Language: 'fa' or 'en'
font string '' Font filename (place in fonts/ directory) or full path
expiry int 300 CAPTCHA expiry time in seconds
length int 5 Number of characters
width int 170 Image width in pixels
height int 55 Image height in pixels
font_size int 22 Font size in points
char_type string 'mixed' Character set: 'mixed', 'letters', 'numbers', 'characters'
case_sensitive bool false Enable case-sensitive validation
noise_level string 'medium' Difficulty level (see below)

Character Sets

Type Characters
mixed ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789~!@#$%^&*()-+
lettersB ABCDEFGHJKLMNPRSTUVWXYZ
lettersS abcdefghijklmnopqrstuvwxyz
numbers 0123456789
characters ~!@#$%^&*()-+

🎯 Difficulty Levels

Level Dots Arcs Lines Rotation Grid Ghosts Wave Difficulty
low 1000 10 1 ±15° ✅ (2)
medium 2000 20 2 ±20° ✅ (4) ⭐⭐
high 3000 30 4 ±25° ✅ (6) ⭐⭐⭐
extreme 4000 40 6 ±35° ✅ (8) ⭐⭐⭐⭐
nightmare 5000 50 8 ±40° ✅ (10) ⭐⭐⭐⭐⭐

What each feature does:

📚 API Reference

Captcha::configure(array $options): void

Set configuration options at runtime.

Captcha::get(string $key, mixed $default = null): mixed

Read a configuration value.

Captcha::generate(): string

Generate a new CAPTCHA code and store it in the session. Returns the generated code.

Captcha::validate(string $input): bool

Validate user input against the stored CAPTCHA code. Returns true if valid. The stored code is destroyed after validation (one-time use).

Captcha::renderImage(): void

Generate and output a CAPTCHA PNG image. Sends headers and exits.

Captcha::html(string $imageUrl, string $inputName, ?string $lang): string

Generate the HTML markup for the CAPTCHA widget.

Parameter Default Description
$imageUrl 'captcha_image.php' URL of the image endpoint
$inputName 'captcha' Name attribute of the input field
$lang null (uses config) Override language

Captcha::styles(): string

Generate the CSS styles for the CAPTCHA widget.

🎨 Custom Fonts

  1. Place your .ttf font file in the fonts/ directory inside the package, or provide a full path.
  2. Set the font in config:

If no font is configured or found, the package falls back to system fonts, and then to PHP's built-in bitmap font as a last resort.

🔧 Usage Examples

Simple number-only CAPTCHA

High-security CAPTCHA

English CAPTCHA


# 🇮🇷 فارسی ## 📖 درباره پروژه **Pure Captcha** یک پکیج سبک و بدون وابستگی برای تولید تصاویر کپچای امن در PHP است. فقط از اکستنشن GD خود PHP استفاده می‌کند. نیازی به سرویس خارجی، جاوااسکریپت اضافه یا کلید API ندارد.

✨ امکانات

📋 پیش‌نیازها

📥 نصب

🚀 شروع سریع

مرحله ۱: ساخت فایل تصویر کپچا

فایلی به نام captcha_image.php بسازید:

مرحله ۲: اضافه کردن کپچا به فرم

مرحله ۳: اعتبارسنجی کپچا

فایل submit.php بسازید:

⚙️ پیکربندی

روش ۱: فایل کانفیگ

فایل captcha_config.php را در روت پروژه بسازید:

روش ۲: پیکربندی در زمان اجرا

⚠️ توجه: اگر از configure() استفاده می‌کنید، باید آن را هم در فایل فرم و هم در captcha_image.php فراخوانی کنید، زیرا هر درخواست HTTP مستقل است.

جدول تنظیمات

تنظیم نوع پیش‌فرض توضیح
lang string 'fa' زبان: 'fa' یا 'en'
font string '' نام فایل فونت (در پوشه fonts/) یا مسیر کامل
expiry int 300 زمان انقضای کپچا (ثانیه)
length int 5 تعداد کاراکترها
width int 170 عرض تصویر (پیکسل)
height int 55 ارتفاع تصویر (پیکسل)
font_size int 22 اندازه فونت
char_type string 'mixed' مجموعه کاراکتر
case_sensitive bool false حساسیت به بزرگ/کوچکی حروف
noise_level string 'medium' سطح سختی

مجموعه کاراکترها

نوع کاراکترها
mixed ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789~!@#$%^&*()-+
lettersB ABCDEFGHJKLMNPRSTUVWXYZ
lettersS abcdefghijklmnopqrstuvwxyz
numbers 0123456789
characters ~!@#$%^&*()-+

🎯 سطوح سختی

سطح نقاط کمان خطوط چرخش شبکه شبح موج سختی
low ۱۰۰۰ ۱۰ ۱ ±۱۵° ✅ (۲)
medium ۲۰۰۰ ۲۰ ۲ ±۲۰° ✅ (۴) ⭐⭐
high ۳۰۰۰ ۳۰ ۴ ±۲۵° ✅ (۶) ⭐⭐⭐
extreme ۴۰۰۰ ۴۰ ۶ ±۳۵° ✅ (۸) ⭐⭐⭐⭐
nightmare ۵۰۰۰ ۵۰ ۸ ±۴۰° ✅ (۱۰) ⭐⭐⭐⭐⭐

هر ویژگی چه کاری انجام می‌دهد:

📚 مرجع API

Captcha::configure(array $options): void

تنظیمات را در زمان اجرا تغییر می‌دهد.

Captcha::get(string $key, mixed $default = null): mixed

مقدار یک تنظیم را برمی‌گرداند.

Captcha::generate(): string

یک کد کپچای جدید تولید و در سشن ذخیره می‌کند. کد تولیدشده را برمی‌گرداند.

Captcha::validate(string $input): bool

ورودی کاربر را با کد ذخیره‌شده مقایسه می‌کند. در صورت صحت true برمی‌گرداند. کد ذخیره‌شده بعد از اعتبارسنجی حذف می‌شود (یکبار مصرف).

Captcha::renderImage(): void

تصویر PNG کپچا را تولید و به خروجی ارسال می‌کند.

Captcha::html(string $imageUrl, string $inputName, ?string $lang): string

کد HTML ویجت کپچا را تولید می‌کند.

پارامتر پیش‌فرض توضیح
$imageUrl 'captcha_image.php' آدرس فایل تصویر
$inputName 'captcha' نام فیلد ورودی
$lang null (از کانفیگ) زبان

Captcha::styles(): string

استایل‌های CSS ویجت کپچا را تولید می‌کند.

🎨 فونت سفارشی

  1. فایل فونت .ttf خود را در پوشه fonts/ داخل پکیج قرار دهید یا مسیر کامل را وارد کنید.
  2. فونت را در کانفیگ تنظیم کنید:

اگر فونتی تنظیم نشده باشد، پکیج ابتدا فونت‌های سیستمی و سپس فونت داخلی PHP را استفاده می‌کند.

🔧 مثال‌های کاربردی

کپچای فقط عددی

کپچای امنیت بالا

کپچای انگلیسی


📁 Project Structure / ساختار پروژه

🤝 Contributing / مشارکت

Contributions, issues and feature requests are welcome!

از مشارکت، گزارش مشکلات و پیشنهاد ویژگی‌های جدید استقبال می‌شود!

📄 License / مجوز

This project is licensed under the MIT License.

این پروژه تحت مجوز MIT منتشر شده است.

👤 Author / توسعه‌دهنده

Amin Arjmand


Made with ❤️ by [Amin Arjmand](https://aminarjmand.com)

All versions of pure-captcha with dependencies

PHP Build Version
Package Version
Requires php Version >=7.4
ext-gd Version *
ext-session Version *
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package aminarjmand/pure-captcha contains the following files

Loading the files please wait ...