카테고리 없음2013. 6. 16. 08:57

로봇에 의한 광고글을 못올리게하는 방법입니다..요즘 워낙에,,봇들이 설치고 다녀서리,, 함 올려봅니다..-_-- 원리는 글쓰기에서 랜덤숫자로된 코드 이미지를 보여주고 값을 입력하게한후..키값이 맞으면 등록, 틀리면,, 등록을 못하게하는... 직접 설치해보시면 아실겁니다..^^;이미지 코드 샘플은 위 이미지와 같습니다.그럼.. 소스 나갑니다..1. 아래소스를 code_img.php로 저장후 제로보드(bbs)폴더안에 넣습니다..

<?// 향상된 난수발생,생성.mt_srand(hexdec(substr(md5(microtime()), -8)) & 0x7fffffff);$rand_code .= mt_rand(1000,9999); //anti_code폴더에 권한과 쓰기$fp = fopen("anti_code/".$_GET['anti_robotCode'].".hnx","w") or die("쓰기에 실패"); fwrite($fp, md5($rand_code), 1024); chmod("anti_code/".$_GET['anti_robotCode'].".hnx", 0666) or die("권한 실패"); fclose($fp);header ("Content-type: image/png"); //그림의 가로크기 $width = "80"; //그림의 세로크기 $height = "22"; $im = @imagecreate ($width, $height) or die ("이미지 에러!!"); //그림안의 색(rgb) ImageColorAllocate($im, 255,255,255); //그림의 테두리색(rgb색 코드) $black = ImageColorAllocate($im, 219,219,219); ImageRectangle($im,0,0,$width-1,$height-1,$black); for ($i=0;$i<=128;$i++) { $point_color = imagecolorallocate ($im, mt_rand(0,255), mt_rand(0,255), mt_rand(0,255)); imagesetpixel($im,mt_rand(2,128),mt_rand(2,38),$point_color); } for ($i=0;$i<=5;$i++) { $text_color = imagecolorallocate ($im, mt_rand(0,255), mt_rand(0,128), mt_rand(0,255)); $x = 5 + $i * 20; $y = mt_rand(1,5); imagechar ($im, 5, $x, $y,$rand_code{$i}, $text_color); } imagepng ($im); imagedestroy ($im); die(); ?>
2. 제로보드(bbs)폴더/script/script_write.php 파일을 php전용 에디터로 열어..
if(!document.write.name.value){ alert('이름을 입력하여 주세요.'); document.write.name.focus(); return false;}
요부분 아래에 다음 소스를 넣어줍니다.
if(!document.write.anti_robotCodeimg.value){ alert('코드를 입력해주세요.'); document.write.anti_robotCodeimg.focus(); return false;}
3. 제로보드(bbs)폴더안 write_ok.php를 php전용 에디터로 열어..24번째줄...
// 각종 변수 검사;;if(!$member[no]) {
요거 다음줄에 아래소스를 넣습니다.
$codeFile = file("anti_code/".$_GET['anti_robotCode'].".hnx");if($codeFile[0] != md5($_POST['anti_robotCodeimg'])) Error("코드입력이 올바른지 확인하세요.");
그다음.. 소스 끝부분쯤에..// MySQL 닫기 이거 바로위에 아래소스를 추가합니다.
// 파일 자동삭제.$anti_codedir = './anti_code/';$dir = opendir($anti_codedir);while((false!==($file=readdir($dir))))if($file!="." and $file !="..") @unlink($anti_codedir.'/'.$file);closedir($dir);
4. 사용중인 스킨폴더안 write.php를 php전용 에디터로 열어..소스 맨위에..
<?// 향상된 난수발생,생성.mt_srand(hexdec(substr(md5(microtime()), -8)) & 0x7fffffff);$rand_codei = md5(mt_rand(1000000, 9999999));?>
추가합니다..그다음..
action=write_ok.php
이부분을..
action=write_ok.php<? echo "?anti_robotCode=".$rand_codei; ?>
이렇게 변경.그다음..이미지 코드가 보일 자리에..
<?if(!$member[no]){?>코드입력: <input name="anti_robotCodeimg" type="text" ><?}?>
넣어주세요...5. 이제 마지막으로..제로보드폴더(bbs)안에 anti_code폴더를 만들어 줍니다..권한설정(퍼미션)은 707로 해 주어야 합니다.
Posted by 아이맥스