프리랜서 웹디자이너 웹퍼블리셔RELATION

RELATION 로고

PHP 웹프로그래밍

[소스] 자동입력방지 소스

2013.05.24
북마크 [출처 이동]    작성자 정보
write.html 코드중에서

<?
$time = mktime(); // 시간 유닉스형식
$c_time = md5($time); //암호화
$string = substr($c_time,14,5); //글자크기를 5글자로 자름
$gd_image = "img/code_graph.gif"; // 출력할 이미지
$image = ImageCreate (150, 50); // 사이즈가 150x50인 이미지 생성
$color_black = ImageColorAllocate ($image, 0xFF, 0xFF, 0xFF); // 검정색을 설정
$color_white = ImageColorAllocate ($image, 0x00, 0x00, 0x00); // 흰색을 설정
ImageTTFtext ($image, 20, 10, 20, 40, $color_white, "./img/gulim.ttf", "$string"); // (100,150)에 navyism을 입력
//이미지가출력되는위치 이미지,위 아래 좌 우 , 바탕화면 , 폰트, 글자)
//ImageGif ($image); // 이미지 출력
imageJpeg($image, $gd_image, 100); // ($base 이미지를, 파일이름.jpg, 100% 품질로 저장)
echo "<img src=$gd_image>";
ImageDestroy ($image); // 메모리에서 이미지 제거

///// 비교하기 /////

?>
※ <span class=8pt>자동글 방지를 위하여 <b>왼쪽에 보이시는 문구를 입력</b>하세요.</span><br>
<input type="text" name="ltm_code" class=input style="ime-mode:disabled">
<input type="hidden" name="ltm_time" value="<?=$time?>">


write_ok.php 에서
<?
$c_time = md5($ltm_time);
$string = substr($c_time,14,5);

if ($string !== "$ltm_code"){
echo " <script>alert('입력하신 코드번호가 올바르지 않습니다.'); document.location.href='form.htm'; </script>";
exit;
}
?>



[ 오류 1 ]
Warning: imagegif() [function.imagegif]: Unable to open 'img/code_graph.gif' for writing: Permission denied in /home/happyjung/www/write.html on line 50

또는

Warning: imagejpeg() [function.imagejpeg]: Unable to open 'img/code_graph.gif' for writing in /home/happyjung/www/write.html on line 50

원인 : code_graph.gif 파일의 퍼미션오류
해결 : chmod 766 code_graph.gif


[ 오류 2 ]
Warning: imagettftext() [function.imagettftext]: Could not find/open font in /home/happyjung/www/write.html on line 54

원인 : gullim.ttf 파일 경로 오류이거나, 파일을 찾을수 없을때
방법 : gullim.ttf 을 서버에 업로드

gullim.ttf 다운로드 : http://offree.net/2808


참고사이트
http://offree.net/2808

이 포스트 공유하기

전체목록