summaryrefslogtreecommitdiff
path: root/captcha_image.php
diff options
context:
space:
mode:
authorChristian Fowler <spider@viovio.com>2006-09-15 20:39:14 +0000
committerChristian Fowler <spider@viovio.com>2006-09-15 20:39:14 +0000
commit529422f24732f650c1cdfd4f04102a0a41fd5130 (patch)
tree80e36d191311e7a85d9be56e05a3ea4c38a8e978 /captcha_image.php
parentd4609201f6a104c59667ae79f7e32f4458400da2 (diff)
downloadusers-529422f24732f650c1cdfd4f04102a0a41fd5130.tar.gz
users-529422f24732f650c1cdfd4f04102a0a41fd5130.tar.bz2
users-529422f24732f650c1cdfd4f04102a0a41fd5130.zip
move file to a more general captcha solution
Diffstat (limited to 'captcha_image.php')
-rw-r--r--captcha_image.php58
1 files changed, 58 insertions, 0 deletions
diff --git a/captcha_image.php b/captcha_image.php
new file mode 100644
index 0000000..272874e
--- /dev/null
+++ b/captcha_image.php
@@ -0,0 +1,58 @@
+<?php
+/**
+ * $Header: /cvsroot/bitweaver/_bit_users/captcha_image.php,v 1.1 2006/09/15 20:39:14 spiderr Exp $
+ *
+ * Copyright (c) 2004 bitweaver.org
+ * Copyright (c) 2003 tikwiki.org
+ * Copyright (c) 2002-2003, Luis Argerich, Garland Foster, Eduardo Polidor, et. al.
+ * All Rights Reserved. See copyright.txt for details and a complete list of authors.
+ * Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details
+ *
+ * $Id: captcha_image.php,v 1.1 2006/09/15 20:39:14 spiderr Exp $
+ * @package users
+ * @subpackage functions
+ */
+
+/**
+ * required setup
+ */
+// hmm. too many session tweaks in setup_smarty ... we need to call this
+require_once( '../bit_setup_inc.php' );
+
+// dimensions
+$width = 140;
+$height = 35;
+
+$img = @imagecreate( $width, $height ) or die( "The GD image library doesn't seem to be available or doesn't have JPG support." );
+
+// colours
+$text[] = imagecolorallocate( $img, 0 , 0 , 128 );
+$text[] = imagecolorallocate( $img, 0 , 128, 0 );
+$text[] = imagecolorallocate( $img, 128, 0 , 0 );
+$text[] = imagecolorallocate( $img, 0 , 128, 128 );
+$text[] = imagecolorallocate( $img, 128, 128, 0 );
+$text[] = imagecolorallocate( $img, 128, 0 , 128 );
+$border = imagecolorallocate( $img, 0 , 0 , 0 );
+$bg = imagecolorallocate( $img, 230, 240, 250 );
+
+imagefill( $img, 0, 0, $bg );
+imagerectangle( $img, 1, 1, $width - 1, $height - 1, $border );
+srand( time() );
+$number = rand( 10000, 99999 );
+$_SESSION['random_number'] = $number;
+for( $i = 0; $i < 5; $i++ ) {
+ imagestring( $img, 10, ( $width / 6 ) - 5 + ( $width / 6 ) * $i + rand( 0, 2 ), 2 + rand( 0, $height - 22 ), substr( $number, $i, 1 ), $text[rand( 0, count( $text ) - 1 )] );
+}
+
+$gd = gd_info();
+if( $gd["PNG Support"] ) {
+ header( "Content-type: image/png" );
+ imagepng( $img );
+} elseif( $gd["GIF Create Support"] ) {
+ header( "Content-type: image/gif" );
+ imagegif( $img );
+} else {
+ header( "Content-type: image/jpeg" );
+ imagejpeg( $img );
+}
+?>