Quote:
Originally Posted by firefly
PHP Code:
<?php
class tscaptcha {
public function tscaptcha( $width, $height, $characters ) { $font = dirname( __FILE__ )."/captcha_fonts/monofont.ttf"; $code = generateCode( $characters ); $font_size = $height * 0.75; if ( !( $image = @imagecreate( @$width, @$height ) ) ) { exit( "Cannot initialize new GD image stream" ); } $background_color = imagecolorallocate( $image, 255, 255, 255 ); $text_color = imagecolorallocate( $image, 20, 40, 100 ); $noise_color = imagecolorallocate( $image, 100, 120, 180 ); $i = 0; while ( $i < $width * $height / 3 ) { imagefilledellipse( $image, mt_rand( 0, $width ), mt_rand( 0, $height ), 1, 1, $noise_color ); ++$i; } $i = 0; while ( $i < $width * $height / 150 ) { imageline( $image, mt_rand( 0, $width ), mt_rand( 0, $height ), mt_rand( 0, $width ), mt_rand( 0, $height ), $noise_color ); ++$i; } if ( !( $textbox = imagettfbbox( $font_size, 0, $font, $code ) ) ) { exit( "Error in imagettfbbox function" ); } $x = ( $width - $textbox[4] ) / 2; $y = ( $height - $textbox[5] ) / 2; if ( !imagettftext( $image, $font_size, 0, $x, $y, $text_color, $font, $code ) ) { exit( "Error in imagettftext function" ); } header( "Expires: Mon, 01 Jan 1990 00:00:00 GMT" ); header( "Last-Modified: ".gmdate( "D, d M Y H:i:s" )." GMT" ); header( "Cache-Control: no-store, no-cache, must-revalidate" ); header( "Cache-Control: post-check=0, pre-check=0", false ); header( "Pragma: no-cache" ); header( "Content-Type: image/jpeg" ); imagejpeg( $image ); imagedestroy( $image ); $_SESSION['security_code'] = $code; }
public function generatecode( $characters ) { unset( $_SESSION['security_code'] ); $possible = "abcdfghjkmnpqrstvwxyzABCDFGHJKMNPQRSTVWXYZ"; $code = ""; $i = 0; while ( $i < $characters ) { $code .= substr( $possible, mt_rand( 0, strlen( $possible ) - 1 ), 1 ); ++$i; } return $code; }
}
class tscaptcha2 extends tscaptcha {
public function tscaptcha2( $width, $height, $characters ) { $code = generateCode( $characters ); if ( !( $im = @imagecreate( @$width, @$height ) ) ) { exit( "Cannot Initialize new GD image stream" ); } $background_color = imagecolorallocate( $im, 0, 0, 0 ); $text_color = imagecolorallocate( $im, 233, 14, 91 ); $font_size = $height * 0.75; $bottom = $height / 2 / 2; $center = $width / 2 / 2; imagestring( $im, $font_size, $center, $bottom, $code, $text_color ); header( "Expires: Mon, 01 Jan 1990 00:00:00 GMT" ); header( "Last-Modified: ".gmdate( "D, d M Y H:i:s" )." GMT" ); header( "Cache-Control: no-store, no-cache, must-revalidate" ); header( "Cache-Control: post-check=0, pre-check=0", false ); header( "Pragma: no-cache" ); header( "Content-Type: image/png" ); imagepng( $im ); imagedestroy( $im ); }
}
function gd_version( ) { static $gd_version; if ( $gd_version ) { return $gd_version; } if ( !extension_loaded( "gd" ) ) { exit( ); } ob_start( ); phpinfo( 8 ); $info = ob_get_contents( ); ob_end_clean( ); $info = stristr( $info, "gd version" ); preg_match( "/\\d/", $info, $gd ); $gd_version = $gd[0]; return $gd_version; }
@error_reporting( @E_ALL & @~E_NOTICE ); @ini_set( "error_reporting", @E_ALL & @~E_NOTICE ); @ini_set( "display_errors", "0" ); @ini_set( "session.gc_maxlifetime", "18000" ); @session_cache_expire( 1440 ); @set_time_limit( 0 ); @set_magic_quotes_runtime( 0 ); @ini_set( "magic_quotes_sybase", 0 ); @session_name( "TSSE_Session" ); @session_start( ); define( "CTSC_VERSION", "0.1 by xam" ); $width = isset( $_GET['width'] ) ? intval( $_GET['width'] ) : "200"; $height = isset( $_GET['height'] ) ? intval( $_GET['height'] ) : "60"; $characters = isset( $_GET['characters'] ) && 1 < $_GET['characters'] ? intval( $_GET['characters'] ) : "6"; $gd_version = gd_version( ); if ( function_exists( "imagettftext" ) && function_exists( "imagettfbbox" ) && 2 <= gd_version( ) && !isset( $_GET['type'] ) ) { $Var_1728->TsCaptcha( $width, $height, $characters ); $captcha = $Var_1728; } else { $Var_1896->TsCaptcha2( $width, $height, $characters ); $captcha = $Var_1896; } ?>
|
thank you very much!!!
Bump:
Quote:
Originally Posted by firefly
PHP Code:
<?php
class tscaptcha {
public function tscaptcha( $width, $height, $characters ) { $font = dirname( __FILE__ )."/captcha_fonts/monofont.ttf"; $code = generateCode( $characters ); $font_size = $height * 0.75; if ( !( $image = @imagecreate( @$width, @$height ) ) ) { exit( "Cannot initialize new GD image stream" ); } $background_color = imagecolorallocate( $image, 255, 255, 255 ); $text_color = imagecolorallocate( $image, 20, 40, 100 ); $noise_color = imagecolorallocate( $image, 100, 120, 180 ); $i = 0; while ( $i < $width * $height / 3 ) { imagefilledellipse( $image, mt_rand( 0, $width ), mt_rand( 0, $height ), 1, 1, $noise_color ); ++$i; } $i = 0; while ( $i < $width * $height / 150 ) { imageline( $image, mt_rand( 0, $width ), mt_rand( 0, $height ), mt_rand( 0, $width ), mt_rand( 0, $height ), $noise_color ); ++$i; } if ( !( $textbox = imagettfbbox( $font_size, 0, $font, $code ) ) ) { exit( "Error in imagettfbbox function" ); } $x = ( $width - $textbox[4] ) / 2; $y = ( $height - $textbox[5] ) / 2; if ( !imagettftext( $image, $font_size, 0, $x, $y, $text_color, $font, $code ) ) { exit( "Error in imagettftext function" ); } header( "Expires: Mon, 01 Jan 1990 00:00:00 GMT" ); header( "Last-Modified: ".gmdate( "D, d M Y H:i:s" )." GMT" ); header( "Cache-Control: no-store, no-cache, must-revalidate" ); header( "Cache-Control: post-check=0, pre-check=0", false ); header( "Pragma: no-cache" ); header( "Content-Type: image/jpeg" ); imagejpeg( $image ); imagedestroy( $image ); $_SESSION['security_code'] = $code; }
public function generatecode( $characters ) { unset( $_SESSION['security_code'] ); $possible = "abcdfghjkmnpqrstvwxyzABCDFGHJKMNPQRSTVWXYZ"; $code = ""; $i = 0; while ( $i < $characters ) { $code .= substr( $possible, mt_rand( 0, strlen( $possible ) - 1 ), 1 ); ++$i; } return $code; }
}
class tscaptcha2 extends tscaptcha {
public function tscaptcha2( $width, $height, $characters ) { $code = generateCode( $characters ); if ( !( $im = @imagecreate( @$width, @$height ) ) ) { exit( "Cannot Initialize new GD image stream" ); } $background_color = imagecolorallocate( $im, 0, 0, 0 ); $text_color = imagecolorallocate( $im, 233, 14, 91 ); $font_size = $height * 0.75; $bottom = $height / 2 / 2; $center = $width / 2 / 2; imagestring( $im, $font_size, $center, $bottom, $code, $text_color ); header( "Expires: Mon, 01 Jan 1990 00:00:00 GMT" ); header( "Last-Modified: ".gmdate( "D, d M Y H:i:s" )." GMT" ); header( "Cache-Control: no-store, no-cache, must-revalidate" ); header( "Cache-Control: post-check=0, pre-check=0", false ); header( "Pragma: no-cache" ); header( "Content-Type: image/png" ); imagepng( $im ); imagedestroy( $im ); }
}
function gd_version( ) { static $gd_version; if ( $gd_version ) { return $gd_version; } if ( !extension_loaded( "gd" ) ) { exit( ); } ob_start( ); phpinfo( 8 ); $info = ob_get_contents( ); ob_end_clean( ); $info = stristr( $info, "gd version" ); preg_match( "/\\d/", $info, $gd ); $gd_version = $gd[0]; return $gd_version; }
@error_reporting( @E_ALL & @~E_NOTICE ); @ini_set( "error_reporting", @E_ALL & @~E_NOTICE ); @ini_set( "display_errors", "0" ); @ini_set( "session.gc_maxlifetime", "18000" ); @session_cache_expire( 1440 ); @set_time_limit( 0 ); @set_magic_quotes_runtime( 0 ); @ini_set( "magic_quotes_sybase", 0 ); @session_name( "TSSE_Session" ); @session_start( ); define( "CTSC_VERSION", "0.1 by xam" ); $width = isset( $_GET['width'] ) ? intval( $_GET['width'] ) : "200"; $height = isset( $_GET['height'] ) ? intval( $_GET['height'] ) : "60"; $characters = isset( $_GET['characters'] ) && 1 < $_GET['characters'] ? intval( $_GET['characters'] ) : "6"; $gd_version = gd_version( ); if ( function_exists( "imagettftext" ) && function_exists( "imagettfbbox" ) && 2 <= gd_version( ) && !isset( $_GET['type'] ) ) { $Var_1728->TsCaptcha( $width, $height, $characters ); $captcha = $Var_1728; } else { $Var_1896->TsCaptcha2( $width, $height, $characters ); $captcha = $Var_1896; } ?>
|
What software to encode it, may I ask?
|