Project

General

Profile

« Previous | Next » 

Revision 598

Added by thorn over 16 years ago

ttf-CAPTCHA: check if string is completely inside the image.

View differences:

ttf_image.php
30 30
require_once(WB_PATH.'/search/search_modext.php');
31 31
list($fonts, $dirs) = list_files_dirs(WB_PATH.'/include/captcha/fonts', false);
32 32
list($bgs, $dirs) = list_files_dirs(WB_PATH.'/include/captcha/backgrounds', false);
33
$fonts = clear_filelist($fonts, '\.ttf');
34
$bgs = clear_filelist($bgs, '\.png');
33
$fonts = clear_filelist($fonts, '\.ttf$');
34
$bgs = clear_filelist($bgs, '\.png$');
35 35

  
36 36
// make random string
37 37
if(!function_exists('randomString')) {
......
69 69
	$t_y = rand($height-10,$height-2);
70 70
	$res = imagettftext($image, $ttfsize, $angle, $t_x, $t_y, $color, $ttf, $text);
71 71
	// check if text fits into the image
72
	//if(($res[0]>0 && $res[0]<$width) && ($res[1]>0 && $res[1]<$height) && 
73
	//   ($res[2]>0 && $res[2]<$width) && ($res[3]>0 && $res[3]<$height) && 
74
	//   ($res[4]>0 && $res[4]<$width) && ($res[5]>0 && $res[5]<$height) && 
75
	//   ($res[6]>0 && $res[6]<$width) && ($res[7]>0 && $res[7]<$height)
76
	//) {
72
	if(($res[0]>0 && $res[0]<$width) && ($res[1]>0 && $res[1]<$height) && 
73
	   ($res[2]>0 && $res[2]<$width) && ($res[3]>0 && $res[3]<$height) && 
74
	   ($res[4]>0 && $res[4]<$width) && ($res[5]>0 && $res[5]<$height) && 
75
	   ($res[6]>0 && $res[6]<$width) && ($res[7]>0 && $res[7]<$height)
76
	) {
77 77
		$image_failed = false;
78
	//}
78
	}
79 79
} while($image_failed);
80 80

  
81 81
captcha_header();
......
85 85
ob_end_flush();
86 86
imagedestroy($image);
87 87

  
88
?>
88
?>

Also available in: Unified diff