ClassicASP Security Image Generator (CAPTCHA) 적용하기
페이지 정보
첨부파일
-
첨부있을때.zip (44.7K)
124회 다운로드 | DATE : 2013-04-25 11:41:38 -
no-upload_20140627.zip (44.5K)
118회 다운로드 | DATE : 2014-06-27 01:38:48
본문
첨부파일설명
첨부없을때.zip : 첨부파일을 사용하지 않을때
자동가입방지2.zip : 첨부파일 업로드 할때
1. test.asp 생성
<%@ Language=VBScript %>
관련자료
http://www.tipstricks.org/
첨부없을때.zip : 첨부파일을 사용하지 않을때
자동가입방지2.zip : 첨부파일 업로드 할때
1. test.asp 생성
<%@ Language=VBScript %>
<% Option Explicit %>
<%
Dim up_form, upload_component
'upload_component = "SiteGalaxy" ' 업로드컴포넌트 선언
upload_component = "Dext_upload" ' 업로드컴포넌트 선언
'======================== DEXT ========================
if upload_component = "Dext_upload" then
Set up_form = Server.CreateObject("DEXT.FileUpload")
up_form.UploadTimeout = 3600
up_form.DefaultPath = Server.MapPath(".\upload\") & "\"
'up_form.AutoMakeFolder = True
'up_form.Codepage = 65001
'======================== SiteGalaxy ==================
elseif upload_component = "SiteGalaxy" then
Set up_form = Server.CreateObject("SiteGalaxyUpload.Form")
end if
'======================== end =========================
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=euc-kr" />
<title></title>
<script type="text/javascript">
<!--
function input_check() {
var f = document.formwrite; // 본문 form에서의 name 값으로 수정
if(f.writer.value == "") {
alert("writer를 입력해주세요");
f.writer.focus();
return false;
}
if(f.captchacode.value == "") {
alert("스팸방지 글자를 입력하셔야 합니다.");
f.captchacode.focus();
return false;
}
}
//-->
</script>
</head>
<body>
<form name="formwrite" method="post" id="formwrite" enctype="multipart/form-data" onSubmit="return input_check(this)" action="ok.asp">
<table border="0" cellpadding="0" cellspacing="0">
<table border="0" cellpadding="0" cellspacing="0">
<tr><td colspan="2"><input name="writer" id="writer" value="<%'=up_form("writer")%>" /></td></tr>
<tr><td colspan="2"><input type="file" name="bf_file1" id="bf_file1" /></td></tr>
<tr><td><a href="javascript:void(0)" onClick="RefreshImage('imgCaptcha')"><img id="imgCaptcha" src="captcha.asp" border="0" alt="글자가 잘 안보이시면 클릭하세요" align="absmiddle" /></a></td>
<td><input name="captchacode" type="text" id="captchacode" value="<%'=up_form("captchacode")%>" size="20" /> 옆의 글자를 입력해주세요.</td>
</tr>
<tr><td colspan="2"><input type="submit" id="btn_submit" value="글쓰기" /></td></tr>
</table>
</form>
<script type="text/javascript">
<!-- // captcha
function RefreshImage(valImageId) {
var objImage = document.images[valImageId];
if (objImage == undefined) {
return;
}
var now = new Date();
objImage.src = objImage.src.split('?')[0] + '?x=' + now.toUTCString();
}
//-->
</script>
</body>
</html>
2. captch.asp 파일을 캡챠 적용시킬 파일이 있는 폴더에 업로드
3. ok.asp
<%@ Language=VBScript %>
2. captch.asp 파일을 캡챠 적용시킬 파일이 있는 폴더에 업로드
3. ok.asp
<%@ Language=VBScript %>
<% Option Explicit %>
<%
Dim up_form, upload_component,writer,bf_file1,userfilepath,fs
upload_component = "SiteGalaxy" ' 업로드컴포넌트 선언
'======================== DEXT ========================
if upload_component = "Dext_upload" then
Set up_form = Server.CreateObject("DEXT.FileUpload")
up_form.UploadTimeout = 3600
up_form.DefaultPath = Server.MapPath(".\upload\") & "\"
'======================== SiteGalaxy ==================
elseif upload_component = "SiteGalaxy" then
Set up_form = Server.CreateObject("SiteGalaxyUpload.Form")
end if
'======================== end =========================
' chapcha 필요함수
function TestCaptcha(byval valSession, byval valCaptcha)
dim tmpSession
valSession = Trim(valSession)
valCaptcha = Trim(valCaptcha)
if (valSession = vbNullString) or (valCaptcha = vbNullString) then
TestCaptcha = false
else
tmpSession = valSession
valSession = Trim(Session(valSession))
Session(tmpSession) = vbNullString
if valSession = vbNullString then
TestCaptcha = false
else
valCaptcha = Replace(valCaptcha,"i","I")
if StrComp(valSession,valCaptcha,1) = 0 then
TestCaptcha = true
else
TestCaptcha = false
end if
end if
end if
end function
Dim captchacode,SpamCheck
if InStr(Request.ServerVariables("CONTENT_TYPE"), "multipart/form-data") = 1 AND Request.ServerVariables("REQUEST_METHOD") = "POST" then
'response.write "captchacode1 = "& up_form("captchacode")
captchacode = up_form("captchacode")
'response.write "captchacode2 = "& captchacode
captchacode = up_form("captchacode")
'response.write "captchacode2 = "& captchacode
if not IsEmpty(captchacode) then
if TestCaptcha("ASPCAPTCHA", captchacode) then
SpamCheck = "no_Spam"
else
response.write "<script>alert('스팸방지코드 입력이 올바르지 않습니다. 다시 입력해주세요.');history.back();</script>"
Response.End():
end If
end if
else
response.write "<script>alert('스팸방지코드 입력이 올바르지 않습니다. 다시 입력해주세요.');history.back();</script>"
Response.End():
end if
writer = up_form("writer")
captchacode = up_form("captchacode")
bf_file1 = up_form("bf_file1")
if bf_file1 <> "" then
set fs = server.createobject("scripting.filesystemobject")
userfilepath = bf_file1.filepath
set fs = nothing
else
userfilepath = up_form("userfilename")
end if
response.write captchacode&"<br>"
response.write writer&"<br>"
response.write userfilepath
response.end()
%>
관련자료
http://www.tipstricks.org/
댓글목록
등록된 댓글이 없습니다.