2017 © Pedro Peláez
 

library app

Coercive App

image

coercive/app

Coercive App

  • Friday, June 1, 2018
  • by Coercive
  • Repository
  • 1 Watchers
  • 1 Stars
  • 223 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 11 Versions
  • 81 % Grown

The README.md

Coercive App

!!! IN WORKS !!!, (*1)

Get

composer require coercive/app

Usage


# in works ...

ReCaptcha handler

Load class and set your keys, (*2)

$recaptcha = new ReCaptcha;

$recaptcha
   ->setPublicKey("RECAPTCHA_PUBLIC_KEY")
   ->setPrivateKey("RECAPTCHA_SECRET_KEY")

Check if your token is valid, (*3)

if (!$recaptcha->validateAndPersist($_POST['inputTokenToCheck'])) {
    die('invalid');
}

Optional: by default is V2 ; set threshold if you wan't to use reCaptcha V3, (*4)

$recaptcha->threshold(0.5)

Optional: use storage data to optimize your quota, (*5)

$recaptcha->setStoreCallback(function($result) {
    /* your storage logic here */
})

$recaptcha->setRetrieveCallback(function() {
    /* your retrieve logic here */
})

/* use `validateAndPersist()` to trigger your callbacks */
$recaptcha->validateAndPersist($_POST['inputTokenToCheck'])

Full example with session storage logic, (*6)

$recaptcha
   ->setPublicKey("RECAPTCHA_PUBLIC_KEY")
   ->setPrivateKey("RECAPTCHA_SECRET_KEY")
   ->threshold(0.5)
   ->setStoreCallback(function($result) {
         $_SESSION['recaptcha']['result'] = $result;
         $_SESSION['recaptcha']['timestamp'] = time();
   })
   ->setRetrieveCallback(function () {
         if(!isset($_SESSION['recaptcha'])) {
            return null;
         }
         if(($_SESSION['recaptcha']['timestamp'] ?? 0) + (24 * 60 * 60) < time()) {
            return null; # example 1 day in second before recheck
         }
         return $_SESSION['recaptcha']['result'] ?? false;
   });

The Versions

01/06 2018

dev-master

9999999-dev http://coercive.fr

Coercive App

  Sources   Download

MIT GNU

The Requires

 

01/06 2018

0.0.9

0.0.9.0 http://coercive.fr

Coercive App

  Sources   Download

MIT

The Requires

 

22/05 2018

0.0.8

0.0.8.0 http://coercive.fr

Coercive App

  Sources   Download

MIT

The Requires

 

22/05 2018

0.0.7

0.0.7.0 http://coercive.fr

Coercive App

  Sources   Download

MIT

The Requires

 

11/04 2018

0.0.6

0.0.6.0 http://coercive.fr

Coercive App

  Sources   Download

MIT

The Requires

 

10/04 2018

0.0.5

0.0.5.0 http://coercive.fr

Coercive App

  Sources   Download

MIT

The Requires

 

05/03 2018

0.0.4

0.0.4.0 http://coercive.fr

Coercive App

  Sources   Download

MIT

The Requires

 

07/02 2018

0.0.3

0.0.3.0 http://coercive.fr

Coercive App

  Sources   Download

MIT

The Requires

 

20/11 2017

0.0.2

0.0.2.0 http://coercive.fr

Coercive App

  Sources   Download

GNU

The Requires

 

19/11 2017

0.0.1

0.0.1.0 http://coercive.fr

Coercive App

  Sources   Download

GNU

The Requires

  • php >=7.0

 

12/11 2017

0.0.0

0.0.0.0 http://coercive.fr

Coercive App

  Sources   Download

GNU

The Requires

  • php >=7.0