사이트 내 전체검색
PHP
[PHP] 자동등록방지 코드 (2009-10-21 수정)
로빈아빠
https://cmd.kr/php/675 URL이 복사되었습니다.

본문

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);  // 메모리에서 이미지 제거

///// 비교하기 /////
/*
// ( ltm_time을 히든값으로.. mktime(); )
$c_time = md5($ltm_time);
$string = substr($c_time,14,5);
if ($string != "$ltm_code"){ error_msg("입력하신 코드번호가 올바르지 않습니다."); }
*/
?>
※ <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

댓글목록

등록된 댓글이 없습니다.

PHP
871 (6/18P)

Search

Copyright © Cmd 명령어 18.118.121.55