{"id":37236464,"url":"https://github.com/jacopovalanzano/php-captcha","last_synced_at":"2026-01-15T04:14:42.595Z","repository":{"id":56995624,"uuid":"378760485","full_name":"jacopovalanzano/php-captcha","owner":"jacopovalanzano","description":"Portable Class. One file. Great for simple projects.","archived":true,"fork":false,"pushed_at":"2022-05-06T23:36:00.000Z","size":759,"stargazers_count":7,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-06-09T05:48:06.337Z","etag":null,"topics":["captcha","php","recaptcha"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jacopovalanzano.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-06-20T23:46:14.000Z","updated_at":"2025-04-20T18:33:11.000Z","dependencies_parsed_at":"2022-08-21T11:10:10.291Z","dependency_job_id":null,"html_url":"https://github.com/jacopovalanzano/php-captcha","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/jacopovalanzano/php-captcha","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jacopovalanzano%2Fphp-captcha","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jacopovalanzano%2Fphp-captcha/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jacopovalanzano%2Fphp-captcha/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jacopovalanzano%2Fphp-captcha/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jacopovalanzano","download_url":"https://codeload.github.com/jacopovalanzano/php-captcha/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jacopovalanzano%2Fphp-captcha/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28420814,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-14T10:47:48.104Z","status":"ssl_error","status_checked_at":"2026-01-14T10:46:19.031Z","response_time":107,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["captcha","php","recaptcha"],"created_at":"2026-01-15T04:14:41.942Z","updated_at":"2026-01-15T04:14:42.574Z","avatar_url":"https://github.com/jacopovalanzano.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n\n# PHP Captcha\n\nPortable PHP class for creating simple captchas.\nOne file. Great for simple projects.\n\n![captcha1](https://i.imgur.com/CakXgDj.gif)\n\n![captcha2](https://i.ibb.co/B6tZc0t/ezgif-4-5d353765b4.gif)\n\n**NOTE**: this captcha is not a final solution to combat bots, but will stop avid and raging attackers.\n\nFor comparison, below is an example of a *captcha* used by **tesla.com**:\n\n![tesla-captcha](https://i.imgur.com/tkcogKy.png)\n\nMicrosoft ([live.com](live.com)):\n\n![live.com-captcha](https://i.imgur.com/Yy9qxbk.png)\n\n## Installation\n\nInstall with composer, or use the contents of the **src** folder.\n\n```bash  \ncomposer require jacopovalanzano/php-captcha  \n```  \nRequires PHP ^5.4 and [PHP-GD](https://www.php.net/manual/en/book.image.php).\n\n## Usage\nThe captcha is a binary jpeg image, it can be rendered with the \"image/jpeg\" content-type header.\n```php  \n    // Create a new Captcha  \n    $captcha = new Captcha(\"My super difficult to read string.\");  \n  \n    // Add 3 lines over and 3 behind the text,  \n    // then build the image.  \n    $captcha-\u003elinesFront(3)-\u003elinesBack(3)-\u003ebuild(175,50); // width, height  \n  \n    // Returns a string containing the captcha passphrase  \n    $captcha-\u003egetPassphrase(); // Returns \"My super difficult to read string.\"  \n  \n    // Renders the captcha.  \n    $captcha-\u003eout();  \n  \n```  \n\n## Example\nA simple example to explain the process of dispatching/retrieving the captcha and its passphrase:\n```php  \n    // This file represents the \"www.example.com/get_captcha_image\" url that generates our captcha  \n   \n    // ...      \n  \n    // A list of words  \n    $attributes = [ \"easy\", \"green\", \"digital\" ];  \n  \n    // One more list of words  \n    $nouns = [ \"compare\", \"dungeon\", \"clip\" ];  \n  \n    // Compose a phrase  \n    $words = $attributes[array_rand($attributes)].\" \".$nouns[array_rand($nouns)];  \n  \n    // Create a new captcha with some random words  \n    $captcha = new Captcha($words);  \n  \n    // Add 2 lines over and 5 behind the text,  \n    // then build the image.  \n    $captcha-\u003elinesFront(2)-\u003elinesBack(5)-\u003ebuild(175,50); // width, height  \n  \n    // Save the captcha passphrase to session, so it can be retrieved later...   \n    $_SESSION[\"captcha_passphrase\"] = $captcha-\u003egetPassphrase();  \n  \n    // Render the actual captcha image  \n    $captcha-\u003eout();  \n```  \n\nAn example of a form you need to validate, like a login form:\n\n```html  \n\u003c!-- ...  --\u003e  \n  \n\u003cinput type=\"email\" name=\"email\"\u003e  \n\u003cinput type=\"password\" name=\"password\"\u003e  \n  \n\u003c!-- Render the actual captcha image using the URL of our captcha-generator (see example above): --\u003e  \n\u003cimg id=\"captcha_image\" src=\"www.example.com/get_captcha_image\" alt=\"captcha\"\u003e  \n\u003cinput type=\"text\" name=\"captcha_passphrase\"\u003e  \n\u003cinput type=\"submit\" value=\"send\"\u003e  \n```\nOr \n```\necho '\u003cimg src=\"' . $captcha-\u003einline() . '\"\u003e';\n```\nMatch ```$_SESSION[\"captcha_passphrase\"]```\nagainst the value passed from the input \"captcha_passphrase\" in the example above, eg:\n\n```php  \n    // Compare the captcha passphrase with the one submitted  \n    if($_POST[\"captcha_passphrase\"] !== $_SESSION[\"captcha_passphrase\"]) {  \n        die(\"Wrong captcha!\");  \n    }  \n```  \n\n## Tests\nTested with [GNU ocrad](https://www.gnu.org/software/ocrad/) and [Xevil](http://xevil.net)\n\n![xevil](https://i.imgur.com/xnlZsWV.gif)\n\n## Contributing\nPull requests are welcome.\n\n## License\n[MIT](https://github.com/jacopovalanzano/php-captcha/blob/main/LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjacopovalanzano%2Fphp-captcha","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjacopovalanzano%2Fphp-captcha","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjacopovalanzano%2Fphp-captcha/lists"}