| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 1 | 2 | 3 | 4 | 5 | 6 | 7 |
| 8 | 9 | 10 | 11 | 12 | 13 | 14 |
| 15 | 16 | 17 | 18 | 19 | 20 | 21 |
| 22 | 23 | 24 | 25 | 26 | 27 | 28 |
- 안드로이드 gcm
- xe
- Mail Server
- not working
- 자동 생성
- roundcube
- android 효과음
- javascript
- 설치
- C# IO
- 폼메일
- dovecot
- PHP
- chart.js
- 자바스크립트
- 안드로이드
- C#
- Android
- 안드로이드 푸쉬
- curl
- php 시큐어코딩
- 우분투
- FCM
- UML
- soundpool
- html5
- mysql
- php 취약점
- 안드로이드 푸시
- WebView
- Today
- Total
그러냐
스팸글 자동등록 방지 오픈소스 - Securimage,captcha 본문
출처 : http://happyman73.tistory.com/74
게시판이나 온라인 상담등에서 로그인을 하지 않은 사용자에게 글쓰기를 허용할 경우
시간이 흘러서 사이트가 알려지면 스팸성 글들이 많이 올라오게 되는 경우가 많습니다.
$HTTP_REFERER를 확인하여 처리하기도 했었는데요.
요즘은 $HTTP_REFERER를 확인하여도 스팸성 글들이 올라오기도 합니다.
그래서 스팸글 자동등록을 방지하는 오픈소스를 소개해 드립니다.
Securimage라는 오픈소스인데요 PHP를 사용하여 captcha images 와 audio를 만들어주는 소스입니다.
소스와 설명등은 해당 홈페이지 https://www.phpcaptcha.org/에서 확인하실 수 있습니다.
현재 3.5.2 버젼까지 배포되고 있습니다.
여기서 Demo를 보실 수도 있고 다운받으실 수도 있습니다.
다음은 다운로드 페이지 입니다.
다운로드 페이지를 보시면 기부금에 대한 얘기가 나옵니다.
기부금으로 3(미국)달러를 요구하였습니다.
그러나 꼭 기부를 해야 하는 것은 아니며 유용하였다면 기부를 해주면 쌩큐~ 라는것 같네요
해당소스를 다운받아 서버에 올렸습니다.
그리고 아래의 두가지 방법으로 각각 테스트하였습니다.
1. 코드를 직접 삽입하는 방법
(코드는 Syntax Highlighter가 적용되어 모바일에서는 안보일 수 있습니다.)
|
1
2
3
4
5
6
7
8 |
<p><img align="left" id="siimage" style="border: 1px solid rgb(0, 0, 0); margin-right: 15px;" alt="CAPTCHA Image" src="http://happyman73.tistory.com/admin/entry/post/securimage/securimage_show.php?sid=<?php echo md5(uniqid()) ?>"><script type="text/javascript">//<![CDATA[writeCode2("<OBJECT data=\"./securimage/securimage_play.swf?bgcol=#ffffff&icon_file=./securimage/images/audio_icon.png&audio_file=./securimage/securimage_play.php\" width=32 height=32 type=application/x-shockwave-flash></OBJECT>")//]]></script><object width="32" height="32" data="./securimage/securimage_play.swf?bgcol=#ffffff&icon_file=./securimage/images/audio_icon.png&audio_file=./securimage/securimage_play.php" type="application/x-shockwave-flash"></object> <a tabindex="-1" title="Refresh Image" style="" onclick="document.getElementById('siimage').src = './securimage_show.php?sid=' + Math.random(); this.blur(); return false" href="http://happyman73.tistory.com/admin/entry/post/?id=74&returnURL=CLOSEME#"><img align="bottom" onclick="this.blur()" alt="Reload Image" src="http://happyman73.tistory.com/admin/entry/post/securimage/images/refresh.png" border="0"></a><br><span id="callbacknesthappyman73tistorycom744921" style="width: 1px; height: 1px; float: right;"><embed width="1" height="1" id="bootstrapperhappyman73tistorycom744921" src="http://happyman73.tistory.com/plugin/CallBack_bootstrapperSrc?nil_profile=tistory&nil_type=copied_post" type="application/x-shockwave-flash" swliveconnect="true" flashvars="&callbackId=happyman73tistorycom744921&host=http://happyman73.tistory.com&embedCodeSrc=http%3A%2F%2Fhappyman73.tistory.com%2Fplugin%2FCallBack_bootstrapper%3F%26src%3Dhttp%3A%2F%2Fs1.daumcdn.net%2Fcfs.tistory%2Fresource%2F1943%2Fblog%2Fplugins%2FCallBack%2Fcallback%26id%3D74%26callbackId%3Dhappyman73tistorycom744921%26destDocId%3Dcallbacknesthappyman73tistorycom744921%26host%3Dhttp%3A%2F%2Fhappyman73.tistory.com%26float%3Dleft" enablecontextmenu="false" wmode="transparent" allowscriptaccess="always"></span><strong>Enter Code*:</strong><br><input name="ct_captcha" size="12" maxlength="16"></p> |
2. 클래스를 이용하는 방법
(코드는 Syntax Highlighter가 적용되어 모바일에서는 안보일 수 있습니다.)
|
1
2
3
4
5
6
7
8
9
10
11 |
// show captcha HTML using Securimage::getCaptchaHtml()require_once './securimage/securimage.php';$options = array();$options['input_name'] = 'ct_captcha'; // change name of input element for form postif (!empty($_SESSION['ctform']['captcha_error'])) { // error html to show in captcha output $options['error_html'] = $_SESSION['ctform']['captcha_error'];}echo Securimage::getCaptchaHtml($options); |
위 두 경우 모두 파일이나 이미지등의 경로는 상황에 맞게 변경해 주셔야합니다.
아래는 위 코드중 2번째 방법을 써서 적용해본 이미지입니다.
실제 음성이 들리는 것까지 확인하였으며 익스11과 크롬에서 동작 테스트를 완료하였습니다.
* 추가 (클래스 이용시)
1. "Type the text: " 문자 변경 : 이미지를 불러오는 부분에서 옵션을 추가
예 ) $options['input_text'] = '원하는 문구';
2. DB입력부분에서 값 확인
|
1
2
3
4
5
6
7
8
9
10 |
$captcha = $_POST['ct_captcha']; require_once './securimage/securimage.php';$securimage = new Securimage();if ($securimage->check($captcha) == false) { echo"error"; }else{ echo "OK";} |
'php' 카테고리의 다른 글
| [알고리즘] 암호화/복호화 함수(실전 응용 가능) (0) | 2016.02.22 |
|---|---|
| md5(), crypt(), password() 등의 문제점 및 로그인 암호화 보안 (0) | 2016.02.22 |
| php.ini 설정하기 (0) | 2016.01.25 |
| [PHP] 두 날짜 차이 "0년 0개월 0일" 구하기 (2) | 2016.01.25 |
| [xe]모바일에서의 통합검색기능 (0) | 2016.01.25 |