First version, support for sending mail not yet implemented.
This commit is contained in:
commit
0222265abc
76 changed files with 4858 additions and 0 deletions
11
vendor/gregwar/captcha/demo/demo.php
vendored
Normal file
11
vendor/gregwar/captcha/demo/demo.php
vendored
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
<?php
|
||||
|
||||
require_once __DIR__.'/../vendor/autoload.php';
|
||||
|
||||
use Gregwar\Captcha\CaptchaBuilder;
|
||||
|
||||
$captcha = new CaptchaBuilder;
|
||||
$captcha
|
||||
->build()
|
||||
->save('out.jpg')
|
||||
;
|
||||
12
vendor/gregwar/captcha/demo/fingerprint.php
vendored
Normal file
12
vendor/gregwar/captcha/demo/fingerprint.php
vendored
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
<?php
|
||||
|
||||
require_once __DIR__.'/../vendor/autoload.php';
|
||||
|
||||
use Gregwar\Captcha\CaptchaBuilder;
|
||||
|
||||
echo count(CaptchaBuilder::create()
|
||||
->build()
|
||||
->getFingerprint()
|
||||
);
|
||||
|
||||
echo "\n";
|
||||
32
vendor/gregwar/captcha/demo/form.php
vendored
Normal file
32
vendor/gregwar/captcha/demo/form.php
vendored
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
<?php
|
||||
require_once __DIR__.'/../vendor/autoload.php';
|
||||
use Gregwar\Captcha\PhraseBuilder;
|
||||
|
||||
// We need the session to check the phrase after submitting
|
||||
session_start();
|
||||
?>
|
||||
|
||||
<html>
|
||||
<?php
|
||||
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
|
||||
// Checking that the posted phrase match the phrase stored in the session
|
||||
if (isset($_SESSION['phrase']) && PhraseBuilder::comparePhrases($_SESSION['phrase'], $_POST['phrase'])) {
|
||||
echo "<h1>Captcha is valid !</h1>";
|
||||
} else {
|
||||
echo "<h1>Captcha is not valid!</h1>";
|
||||
}
|
||||
// The phrase can't be used twice
|
||||
unset($_SESSION['phrase']);
|
||||
}
|
||||
?>
|
||||
<form method="post">
|
||||
Copy the CAPTCHA:
|
||||
<?php
|
||||
// See session.php, where the captcha is actually rendered and the session phrase
|
||||
// is set accordingly to the image displayed
|
||||
?>
|
||||
<img src="session.php" />
|
||||
<input type="text" name="phrase" />
|
||||
<input type="submit" />
|
||||
</form>
|
||||
</html>
|
||||
15
vendor/gregwar/captcha/demo/index.php
vendored
Normal file
15
vendor/gregwar/captcha/demo/index.php
vendored
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
<!DOCTYPE html>
|
||||
<body>
|
||||
<html>
|
||||
<meta charset="utf-8" />
|
||||
</html>
|
||||
<body>
|
||||
<h1>Captchas gallery</h1>
|
||||
<?php for ($x=0; $x<8; $x++) { ?>
|
||||
<?php for ($y=0; $y<5; $y++) { ?>
|
||||
<img src="output.php?n=<?php echo 5*$x+$y; ?>" />
|
||||
<?php } ?>
|
||||
<br />
|
||||
<?php } ?>
|
||||
</body>
|
||||
</body>
|
||||
22
vendor/gregwar/captcha/demo/inline.php
vendored
Normal file
22
vendor/gregwar/captcha/demo/inline.php
vendored
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
<?php
|
||||
require_once __DIR__.'/../vendor/autoload.php';
|
||||
|
||||
use Gregwar\Captcha\CaptchaBuilder;
|
||||
|
||||
$captcha = new CaptchaBuilder();
|
||||
$captcha->build();
|
||||
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<body>
|
||||
<html>
|
||||
<meta charset="utf-8" />
|
||||
</html>
|
||||
<body>
|
||||
<h1>Inline Captcha</h1>
|
||||
|
||||
<img src="<?php echo $captcha->inline(); ?>"/><br/>
|
||||
Phrase: <?php echo $captcha->getPhrase(); ?>
|
||||
|
||||
</body>
|
||||
</body>
|
||||
39
vendor/gregwar/captcha/demo/ocr.php
vendored
Normal file
39
vendor/gregwar/captcha/demo/ocr.php
vendored
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
<?php
|
||||
|
||||
require_once __DIR__.'/../vendor/autoload.php';
|
||||
|
||||
use Gregwar\Captcha\CaptchaBuilder;
|
||||
|
||||
/**
|
||||
* Generates 1000 captchas and try to read their code with the
|
||||
* ocrad OCR
|
||||
*/
|
||||
|
||||
$tests = 10000;
|
||||
$passed = 0;
|
||||
|
||||
shell_exec('rm passed*.jpg');
|
||||
|
||||
for ($i=0; $i<$tests; $i++) {
|
||||
echo "Captcha $i/$tests... ";
|
||||
|
||||
$captcha = new CaptchaBuilder;
|
||||
|
||||
$captcha
|
||||
->setDistortion(false)
|
||||
->build()
|
||||
;
|
||||
|
||||
if ($captcha->isOCRReadable()) {
|
||||
$passed++;
|
||||
$captcha->save("passed$passed.jpg");
|
||||
echo "passed at ocr... ";
|
||||
} else {
|
||||
echo "failed... ";
|
||||
}
|
||||
|
||||
echo "pass rate: ".round(100*$passed/($i+1),2)."%\n";
|
||||
}
|
||||
|
||||
echo "\n";
|
||||
echo "Over, $passed/$tests readed with OCR\n";
|
||||
12
vendor/gregwar/captcha/demo/output.php
vendored
Normal file
12
vendor/gregwar/captcha/demo/output.php
vendored
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
<?php
|
||||
|
||||
require_once __DIR__.'/../vendor/autoload.php';
|
||||
|
||||
use Gregwar\Captcha\CaptchaBuilder;
|
||||
|
||||
header('Content-type: image/jpeg');
|
||||
|
||||
CaptchaBuilder::create()
|
||||
->build()
|
||||
->output()
|
||||
;
|
||||
22
vendor/gregwar/captcha/demo/session.php
vendored
Normal file
22
vendor/gregwar/captcha/demo/session.php
vendored
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
<?php
|
||||
// We need the session to store the correct phrase for later check
|
||||
session_start();
|
||||
|
||||
// Including the autoload (you need to composer install in the main directory)
|
||||
require_once __DIR__.'/../vendor/autoload.php';
|
||||
|
||||
use Gregwar\Captcha\CaptchaBuilder;
|
||||
|
||||
// Creating the captcha instance and setting the phrase in the session to store
|
||||
// it for check when the form is submitted
|
||||
$captcha = new CaptchaBuilder;
|
||||
$_SESSION['phrase'] = $captcha->getPhrase();
|
||||
|
||||
// Setting the header to image jpeg because we here render an image
|
||||
header('Content-Type: image/jpeg');
|
||||
|
||||
// Running the actual rendering of the captcha image
|
||||
$captcha
|
||||
->build()
|
||||
->output()
|
||||
;
|
||||
Loading…
Add table
Add a link
Reference in a new issue