diff options
author | cash <cash@36083f99-b078-4883-b0ff-0f9b5a30f544> | 2010-08-25 12:02:07 +0000 |
---|---|---|
committer | cash <cash@36083f99-b078-4883-b0ff-0f9b5a30f544> | 2010-08-25 12:02:07 +0000 |
commit | 4bf0d12ffd08f5af82b037a42ba00cce4d5abfdb (patch) | |
tree | 89ebe972958b5b6ada5ac019d728cccc07608447 /mod/captcha/captcha.php | |
parent | 38105e2bbbfd821214d877bdcc5e19b13d13f968 (diff) | |
download | elgg-4bf0d12ffd08f5af82b037a42ba00cce4d5abfdb.tar.gz elgg-4bf0d12ffd08f5af82b037a42ba00cce4d5abfdb.tar.bz2 |
standardized captcha plugin
git-svn-id: http://code.elgg.org/elgg/trunk@6864 36083f99-b078-4883-b0ff-0f9b5a30f544
Diffstat (limited to 'mod/captcha/captcha.php')
-rw-r--r-- | mod/captcha/captcha.php | 77 |
1 files changed, 38 insertions, 39 deletions
diff --git a/mod/captcha/captcha.php b/mod/captcha/captcha.php index 1a2580f15..94716d973 100644 --- a/mod/captcha/captcha.php +++ b/mod/captcha/captcha.php @@ -1,40 +1,39 @@ <?php - /** - * Elgg captcha plugin graphics file generator - * - * @package ElggCaptcha - * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2 - * @author Curverider Ltd - * @copyright Curverider Ltd 2008-2010 - * @link http://elgg.com/ - */ - - global $CONFIG; - $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, $CONFIG->captcha_num_bg); - $image = imagecreatefromjpeg($CONFIG->pluginspath . "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, $CONFIG->pluginspath . "captcha/fonts/1.ttf", $captcha); - - // Output image - imagejpeg($image); - - // Free memory - imagedestroy($image); - } -?>
\ No newline at end of file +/** + * Elgg captcha plugin graphics file generator + * + * @package ElggCaptcha + * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2 + * @author Curverider Ltd + * @copyright Curverider Ltd 2008-2010 + * @link http://elgg.com/ + */ + +global $CONFIG; +$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, $CONFIG->captcha_num_bg); + $image = imagecreatefromjpeg($CONFIG->pluginspath . "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, $CONFIG->pluginspath . "captcha/fonts/1.ttf", $captcha); + + // Output image + imagejpeg($image); + + // Free memory + imagedestroy($image); +} |