diff options
author | Silvio Rhatto <rhatto@riseup.net> | 2014-03-15 14:53:35 -0300 |
---|---|---|
committer | Silvio Rhatto <rhatto@riseup.net> | 2014-03-15 14:53:35 -0300 |
commit | e10b0bd1f9403d38568173d76a93f93a484d9646 (patch) | |
tree | 9f0e5fb09d4a6281810a1d54928f6308bdce0672 /mod/captcha/captcha.php | |
parent | 75d2225cd98feafd5e5e75df5505914295f569ff (diff) | |
parent | cb346ff43a63f93ff5275502638c51a4653fac7d (diff) | |
download | elgg-e10b0bd1f9403d38568173d76a93f93a484d9646.tar.gz elgg-e10b0bd1f9403d38568173d76a93f93a484d9646.tar.bz2 |
Merge commit 'cb346ff43a63f93ff5275502638c51a4653fac7d' as 'mod/captcha'
Diffstat (limited to 'mod/captcha/captcha.php')
-rw-r--r-- | mod/captcha/captcha.php | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/mod/captcha/captcha.php b/mod/captcha/captcha.php new file mode 100644 index 000000000..085641c79 --- /dev/null +++ b/mod/captcha/captcha.php @@ -0,0 +1,34 @@ +<?php +/** + * Elgg captcha plugin graphics file generator + * + * @package ElggCaptcha + */ + +$token = get_input('captcha_token'); + +// Output captcha +if ($token) { + // Set correct header + header("Content-type: image/jpeg"); + + // Generate captcha + $captcha = captcha_generate_captcha($token); + + // Pick a random background image + $n = rand(1, elgg_get_config('captcha_num_bg')); + $image = imagecreatefromjpeg(elgg_get_plugins_path() . "captcha/backgrounds/bg$n.jpg"); + + // Create a colour (black so its not a simple matter of masking out one colour and ocring the rest) + $colour = imagecolorallocate($image, 0,0,0); + + // Write captcha to image + //imagestring($image, 5, 30, 4, $captcha, $black); + imagettftext($image, 30, 0, 10, 30, $colour, elgg_get_plugins_path() . "captcha/fonts/1.ttf", $captcha); + + // Output image + imagejpeg($image); + + // Free memory + imagedestroy($image); +} |