회원 가입시 입력하는 자동가입방지 문자열 이미지 만들기
페이지 정보
작성자 서방님 댓글 0건 조회 73회 작성일 12-02-13 13:10본문
<?
// 회원 가입시 입력하는 자동가입방지 문자열 이미지 만들기
function randText($strSize)
{
$str = "";
for ($i=0; $i<$strSize; $i++)
{
$num = rand() % 52;
if ($num < 26) $str .= chr($num + 65); // 대문자
else $str .= chr($num + 97 - 26); //소문자 출력
}
return $str;
}
$fontname = "MALGUN.TTF"; // php 파일과 같은 디렉토리거나, 경로까지 설정해야함
$width = "500";
$height = "500";
function euckr2utf8($text) {
return stripslashes(iconv("EUC-KR","UTF-8",$text));
}
$fontname = "MALGUN.TTF";
$text = randText(5);
$fontsize = 16;
$bound = ImageTTFBBox($fontsize,0,$fontname, $text);
$imgWidth = $bound[2]+20;
$imgHeight = $fontsize*3.0;
$im=ImageCreate($imgWidth,$imgHeight);
$white = ImageColorAllocate ($im, 255, 255, 255);
$black = ImageColorAllocate ($im, 0, 0, 0);
ImageTTFText($im,$fontsize,rand()%20, 10, $imgHeight-10, $black, $fontname, $text);
header ("Content-type: image/png");
ImagePNG($im);
ImageDestroy($im);
?>
댓글목록
등록된 댓글이 없습니다.