added chaptcha module
This commit is contained in:
parent
57e32beb74
commit
540d6cd83f
10 changed files with 70 additions and 0 deletions
6
captcha/captcha.html
Normal file
6
captcha/captcha.html
Normal file
|
@ -0,0 +1,6 @@
|
|||
<?php
|
||||
<img id="captcha" alt="captcha" src="captcha.php" />
|
||||
<a href="#" onclick="document.getElementById(\'captcha\').src = \'img/loading_small.gif\'; window.setTimeout(function() {document.getElementById(\'captcha\').src = \'captcha.php\'}, 500); return false;">
|
||||
<img src="img/reload.png" alt="reload" />
|
||||
</a>
|
||||
?>
|
64
captcha/captcha.php
Normal file
64
captcha/captcha.php
Normal file
|
@ -0,0 +1,64 @@
|
|||
<?php
|
||||
|
||||
header('Content-Type: image/gif', true);
|
||||
header('Cache-Control: no-store', true);
|
||||
|
||||
/* Configuration */
|
||||
$conf['width'] = 145;
|
||||
$conf['height'] = 50;
|
||||
$conf['font_size'] = 18;
|
||||
$conf['length'] = 5;
|
||||
|
||||
$conf['fonts'] = array(
|
||||
'technine',
|
||||
'texasled',
|
||||
'xband',
|
||||
'3000',
|
||||
'42',
|
||||
'39smooth'
|
||||
);
|
||||
|
||||
$conf['alphabet'] = array(
|
||||
'A', 'B', 'C', 'D', 'E', 'F', 'G',
|
||||
'H', 'Q', 'J', 'K', 'L', 'M', 'N',
|
||||
'P', 'R', 'S', 'T', 'U', 'V', 'Y',
|
||||
'W', '2', '3', '4', '5', '6', '7'
|
||||
);
|
||||
|
||||
$img = imagecreatetruecolor($conf['width'], $conf['height']);
|
||||
//$col = imagecolorallocate($img, rand(200, 255), rand(200, 255), rand(200, 255));
|
||||
$col = imagecolorallocate($img, 255, 255, 255);
|
||||
|
||||
imagefill($img, 0, 0, $col);
|
||||
|
||||
$captcha = '';
|
||||
$x = 10;
|
||||
|
||||
for ($p = 0; $p < 15; $p++) {
|
||||
$col = imagecolorallocate($img, rand(150, 255), rand(150, 255), rand(150, 255));
|
||||
imageline($img, rand(0, $conf['width']), rand(0, $conf['height']), rand(0, $conf['width']), rand(0, $conf['height']), $col);
|
||||
}
|
||||
|
||||
for($i = 0; $i < $conf['length']; $i++) {
|
||||
|
||||
$chr = $conf['alphabet'][rand(0, count($conf['alphabet']) - 1)];
|
||||
$captcha .= $chr;
|
||||
|
||||
$col = imagecolorallocate($img, rand(0, 199), rand(0, 199), rand(0, 199));
|
||||
$font = 'fonts/' . $conf['fonts'][rand(0, count($conf['fonts']) - 1)] . '.ttf';
|
||||
|
||||
$y = 25 + rand(0, 20);
|
||||
$angle = rand(0, 45);
|
||||
|
||||
imagettftext($img, $conf['font_size'], $angle, $x, $y, $col, $font, $chr);
|
||||
|
||||
$dim = imagettfbbox($conf['font_size'], $angle, $font, $chr);
|
||||
$x += $dim[4] + abs($dim[6]) + 10;
|
||||
}
|
||||
|
||||
imagegif($img);
|
||||
imagedestroy($img);
|
||||
|
||||
$_SESSION['captcha'] = $captcha;
|
||||
|
||||
?>
|
BIN
captcha/fonts/3000.ttf
Normal file
BIN
captcha/fonts/3000.ttf
Normal file
Binary file not shown.
BIN
captcha/fonts/39smooth.ttf
Normal file
BIN
captcha/fonts/39smooth.ttf
Normal file
Binary file not shown.
BIN
captcha/fonts/42.ttf
Normal file
BIN
captcha/fonts/42.ttf
Normal file
Binary file not shown.
BIN
captcha/fonts/technine.ttf
Normal file
BIN
captcha/fonts/technine.ttf
Normal file
Binary file not shown.
BIN
captcha/fonts/texasled.ttf
Normal file
BIN
captcha/fonts/texasled.ttf
Normal file
Binary file not shown.
BIN
captcha/fonts/xband.ttf
Normal file
BIN
captcha/fonts/xband.ttf
Normal file
Binary file not shown.
BIN
captcha/img/loading_small.gif
Normal file
BIN
captcha/img/loading_small.gif
Normal file
Binary file not shown.
After Width: | Height: | Size: 673 B |
BIN
captcha/img/reload.png
Normal file
BIN
captcha/img/reload.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 602 B |
Loading…
Add table
Reference in a new issue