회원 가입시 입력하는 자동가입방지 문자열 이미지 만들기 > php

본문 바로가기
사이트 내 전체검색

php

회원 가입시 입력하는 자동가입방지 문자열 이미지 만들기

페이지 정보

작성자 서방님 댓글 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);
?>




댓글목록

등록된 댓글이 없습니다.

Total 612건 35 페이지
게시물 검색

회원로그인

접속자집계

오늘
286
어제
225
최대
1,347
전체
155,045
Latest Crypto Fear & Greed Index

그누보드5
Copyright © 서방님.kr All rights reserved.