Coder Social home page Coder Social logo

visualcaptcha-php's Introduction

Build Status Codacy Code Climate

visualCaptcha-PHP

PHP sample for visualCaptcha.

This is a demo/sample PHP app that uses the visualCaptcha PHP composer/packagist package and the visualCaptcha jQuery plugin bower package, as a proof-of-concept for how to integrate it with your PHP project.

NOTES FOR BEGINNERS

If you're used to the simpler, older version of visualCaptcha, you can still get version 4.2.0, but note it's harder to update and it has a potential flaw that could make bots override it, though it isn't a big concern if you understand how it's done.

If you're not familiar with building APIs, custom routes, composer, or bower, you should also consider using that simpler version.

This won't look like the current demo, because all demos use version 5.0+.

Installation

You need PHP 5.3+ installed with composer. Use the following command if you've got composer locally installed:

php composer.phar install

If you've got composer installed globally, use the following command

composer install

This will install the visualCaptcha package, PHPUnit, and Slim (for the API demo).

Run server

If you don't have a server running, you can use PHP's new built-in server to run it, for example on port 8282, by typing the following command:

php -S localhost:8282 -t public

If you already have apache or nginx running with PHP, you just need to point the root to public/index.php

Run tests

If you need to run Unit tests, just use the following command:

vendor/bin/phpunit

Issues installing composer and/or dependencies

You can get a ZIP with all dependencies already installed (just run a webserver and go inside the public folder). Download it here.

API

visualCaptcha, since 5.0, uses an API for increased security and to become back-end-agnostic (that's why you can easily plug-in a Vanilla JS, AngularJS, or jQuery front-end without changing anything).

It expects the following routes to exist, which we've put in this sample, using Slim (just to make it easier).

You are expected to have these routes in your implementation, but you can change them in visualCaptcha's front-end config.

GET /start/:howmany

This route will be the first route called by the front-end, which will generate and store session data.

Parameters:

  • howmany is required, the number of images to generate.

GET /image/:index

This route will be called for each image, to get it and show it, by index.

Parameters:

  • index is required, the index of the image you want to get.

GET /audio(/:type)

This route will be called for the audio file, to get it and play it, either the mp3 or ogg file.

Parameters:

  • type is optional, the audio file format defaults to mp3, but can also be ogg.

POST /try

This is just a sample route, where we post the form to, and where the visualCaptcha validation takes place.

License

MIT. Check the LICENSE file.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.