폼메일에 kcaptcha (자동등록방지)를 적용해 보았는데 문제가 발생합니다 정보
폼메일에 kcaptcha (자동등록방지)를 적용해 보았는데 문제가 발생합니다첨부파일
본문
안녕하세요~
예전에 폼메일을 받아놓은게 있어서 폼메일을 사용하다가
스팸이 많아서 사용중인 폼메일에 그누보드 kcaptcha를 적용해 보았습니다
문제는 폼메일 쓰기에는 문제가 없는데, 자동등록방지 숫자를
잘못 입력해도 실행이 됩니다
contact.php 에 폼메일 쓰기를 하면
mail_update.php 에서 결과값을 거칩니다
mail_post.php 은 폼메일 쓰기값을 이메일로 전송해 주는 역할을 하네요
어떤 파일에 어떤 코드를 넣어야 자동등록방지 숫자가 정확해야만
다음 결과값으로 넘어가는지 고수님들 알려주시길 부탁드립니다
날씨가 쌀쌀하네요 감기조심하세요~
[추가] 첨부파일로 해당파일을 올렸는데 게시판에도 올려봅니다
===================
contact.php
====================
<?
include_once("./_common.php");
// 전화, 휴대폰 배열
$phone_array = array("02","031","032","033","041","042","043","051","052","053","054","055","061","062","063","064");//,"0502","0505","0506");
$mobile_array = array("010","011","016","017","018","019");
$g4[title] = "";
?>
<!-- 한글 필드명으로 인해 사용안함
<SCRIPT LANGUAGE="JavaScript">
<!--
function fo_move(len,fld1,fld2){
if(fld1.value.length == len){
fld2.focus();
}
}
</SCRIPT>
//-->
<script language="JavaScript">
<!--
/* 폼내용중에 라디오박스나 체크박스를 필수선택으로 할 경우 이 주석처리를 변경하여 사용하십시오.
function checkform(){
//var f = document.form;
var getobj = document.getElementsByTagName("input");
var chkfld = false;
for(var i=0; i<getobj.length; i++){
//if((getobj[i].type == "checkbox" || getobj[i].type == "radio") && getobj[i].checked == true){
if(getobj[i].type == "radio" && getobj[i].checked == true){
chkfld = true;
break;
}
}
if(chkfld == false){
alert("라디오박스 필수");
return false;
}
return true;
}
//-->
*/
</script>
<script language="javascript">
function processKey()
{
if((event.ctrlKey == true && (event.keyCode == 78 || event.keyCode == 82)) ||
(event.keyCode >= 112 && event.keyCode <= 123) || event.keyCode == 16)
{
event.keyCode = 0;
event.cancelBubble = true;
event.returnValue = false;
}
}
document.onkeydown = processKey;
</script><body bgcolor="white" text="black" link="blue" vlink="purple" alink="red" leftmargin="0" marginwidth="0" topmargin="0" marginheight="0">
<table cellspacing="0" width="700" bordercolordark="white" bordercolorlight="#CCCCCC" span style="font-size:9pt;" background="" height="469" cellpadding="0">
<form name="fumail" method="post" action="./mail_update.php" onsubmit="return checkform();">
<tr>
<td width="198" height="31">
<p align="right"><span style="font-size:9pt;"><b><font color="#903C39">문의선택</font></b><font color="#903C39"> </font></span></p>
</td>
<td width="502" height="31"> <span style="font-size:9pt;"><select name="문의선택" class="select1" itemname="Select" style="background-color:white;" size="1">
<option NAME="문의선택" value="선택해주세요">선택해주세요<br></option>
<option NAME="문의선택" value="웹디자인">웹디자인<br></option> <option NAME="I want to know about" value="웹사이트 리뉴얼">웹사이트 리뉴얼<br></option>
<option NAME="문의선택" value="관리서비스">관리서비스<br></option>
<option NAME="문의선택" value="도메인 & 호스팅">도메인 & 호스팅<br></option>
<option NAME="문의선택" value="검색엔진 최적화">검색엔진 최적화<br></option>
<option NAME="문의선택" value="온라인 마케팅">온라인 마케팅<br></option>
<option NAME="문의선택" value="사진촬영 & 보정">사진촬영 & 보정<br></option>
<option NAME="문의선택" value="고객님의견접수">고객님 의견접수<br></option>
</select></td>
</tr>
<tr>
<td width="198" height="31">
<p align="right"><span style="font-size:9pt;"><b><font color="#903C39">회사 / 이름</font></b><font color="#903C39"> </font></span></p>
</td>
<td width="502" height="31"> <input type='text' name='이름' style="color:black; background-color:white; border-width:1; border-color:rgb(204,204,204); border-style:solid; width:80%;" required itemname="name"></td>
</tr>
<tr>
<td height="31" width="198">
<p align="right"><span style="font-size:9pt;"><b><font color="#903C39">이메일 </font></b> </span></p>
</td>
<td height="31" width="502"> <input type='text' name='email' style="background-color:white; border-width:1; border-color:rgb(204,204,204); border-style:solid; width:80%;" email required itemname="이메일"></td>
</tr>
</tr>
</tr>
<tr>
<td width="198" height="31">
<p align="right"><span style="font-size:9pt;"><b><font color="#903C39">전화번호 / 핸드폰 </font> </b></span></p>
</td>
<td width="502" height="31"> <input type='text' name='연락번호' style="background-color:white; border-width:1; border-color:rgb(204,204,204); border-style:solid; width:80%;" itemname="telephone"> </td>
</tr>
<tr>
<td width="198" height="191">
<p align="right"><b><font color="#903C39">내용</font></b><font color="#903C39"> </font></p>
</td>
<td width="502" height="191"> <textarea name="내용" style="background-color:white; border-width:1; border-color:rgb(204,204,204); border-style:solid; width:80%; scrollbar-base-color:rgb(224,223,227);" rows='11' itemname='Inquiry'></textarea></td>
</tr>
<tr>
<td class=write_head height="62">
<p align="right"><img id='kcaptcha_image' /> </p>
</td>
<td><input class='ed' type=input size=10 name=wr_key itemname="자동등록방지" required> 왼쪽의 글자를 입력하세요.</td>
</tr>
<tr>
<td width="700" height="88" colspan="2">
<p align="center"><input type='submit' value=" 확 인 "></form>
</td>
</tr>
</table>
===========================
mail_update.php
===========================
<?
include_once("./_common.php");
include_once("$g4[path]/lib/mailer.lib.php");
while(list($key,$val) = each($_POST)){
if($key == "faction" || $key == "x" || $key == "y") continue;
if(empty($val)) continue; // 텍스트박스/입력박스 사용시에 적용
$arrkey[] = $key;
$arrval[] = $val;
}
// 메일발송
// 실제 사용시 제목을 수정하십시오.
//$subject = $_POST["이름"] . " 님이 신청한 내용";
$subject = "온라인 고객문의";
$admin = get_admin('super');
//$admin[mb_email] = $_POST['email'];
ob_start();
include "./mail_post.php";
$content = ob_get_contents();
ob_end_clean();
mailer($_POST["name"], $email, $admin[mb_email], $subject, $content, 1); // 마지막에 숫자 1을 변경하지 마십시오.
// 메일발송 후 돌아가고자 하는 페이지가 index.php 가 아니라면 아래에서 $g4[path] 를 이동하고자 하는 경로로 수정해 주십시오.
alert("감사합니다.","./contact.php");
?>
============================
mail_post.php
============================
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<title>[<?=$subject?>]</title>
</head>
<style>
body, th, td, form, input, select, text, textarea, caption { font-size: 13px; font-family:vernada;}
.line {border: 1px solid #868F98;}
</style>
<body leftmargin=0 topmargin=10 marginwidth=0 marginheight=0>
<table width="95%" cellpadding=5 cellspacing=0 border=1 align="center">
<col width="20%" bgcolor="#eaeaea" style="font:bold;">
<col width="">
<tr>
<td colspan=2 height=40 bgcolor="#ffffff">
<font color='#3300FF'><B><?=$subject?></B></font>
</td>
</tr>
<? for($i=0;$i<count($arrkey);$i++){ ?>
<tr>
<td><?=$arrkey[$i]?></td>
<td><?echo str_replace("\n","<br>",stripslashes($arrval[$i]));?></td>
</tr>
<?}?>
</table>
</body>
</html>
예전에 폼메일을 받아놓은게 있어서 폼메일을 사용하다가
스팸이 많아서 사용중인 폼메일에 그누보드 kcaptcha를 적용해 보았습니다
문제는 폼메일 쓰기에는 문제가 없는데, 자동등록방지 숫자를
잘못 입력해도 실행이 됩니다
contact.php 에 폼메일 쓰기를 하면
mail_update.php 에서 결과값을 거칩니다
mail_post.php 은 폼메일 쓰기값을 이메일로 전송해 주는 역할을 하네요
어떤 파일에 어떤 코드를 넣어야 자동등록방지 숫자가 정확해야만
다음 결과값으로 넘어가는지 고수님들 알려주시길 부탁드립니다
날씨가 쌀쌀하네요 감기조심하세요~
[추가] 첨부파일로 해당파일을 올렸는데 게시판에도 올려봅니다
===================
contact.php
====================
<?
include_once("./_common.php");
// 전화, 휴대폰 배열
$phone_array = array("02","031","032","033","041","042","043","051","052","053","054","055","061","062","063","064");//,"0502","0505","0506");
$mobile_array = array("010","011","016","017","018","019");
$g4[title] = "";
?>
<!-- 한글 필드명으로 인해 사용안함
<SCRIPT LANGUAGE="JavaScript">
<!--
function fo_move(len,fld1,fld2){
if(fld1.value.length == len){
fld2.focus();
}
}
</SCRIPT>
//-->
<script language="JavaScript">
<!--
/* 폼내용중에 라디오박스나 체크박스를 필수선택으로 할 경우 이 주석처리를 변경하여 사용하십시오.
function checkform(){
//var f = document.form;
var getobj = document.getElementsByTagName("input");
var chkfld = false;
for(var i=0; i<getobj.length; i++){
//if((getobj[i].type == "checkbox" || getobj[i].type == "radio") && getobj[i].checked == true){
if(getobj[i].type == "radio" && getobj[i].checked == true){
chkfld = true;
break;
}
}
if(chkfld == false){
alert("라디오박스 필수");
return false;
}
return true;
}
//-->
*/
</script>
<script language="javascript">
function processKey()
{
if((event.ctrlKey == true && (event.keyCode == 78 || event.keyCode == 82)) ||
(event.keyCode >= 112 && event.keyCode <= 123) || event.keyCode == 16)
{
event.keyCode = 0;
event.cancelBubble = true;
event.returnValue = false;
}
}
document.onkeydown = processKey;
</script><body bgcolor="white" text="black" link="blue" vlink="purple" alink="red" leftmargin="0" marginwidth="0" topmargin="0" marginheight="0">
<table cellspacing="0" width="700" bordercolordark="white" bordercolorlight="#CCCCCC" span style="font-size:9pt;" background="" height="469" cellpadding="0">
<form name="fumail" method="post" action="./mail_update.php" onsubmit="return checkform();">
<tr>
<td width="198" height="31">
<p align="right"><span style="font-size:9pt;"><b><font color="#903C39">문의선택</font></b><font color="#903C39"> </font></span></p>
</td>
<td width="502" height="31"> <span style="font-size:9pt;"><select name="문의선택" class="select1" itemname="Select" style="background-color:white;" size="1">
<option NAME="문의선택" value="선택해주세요">선택해주세요<br></option>
<option NAME="문의선택" value="웹디자인">웹디자인<br></option> <option NAME="I want to know about" value="웹사이트 리뉴얼">웹사이트 리뉴얼<br></option>
<option NAME="문의선택" value="관리서비스">관리서비스<br></option>
<option NAME="문의선택" value="도메인 & 호스팅">도메인 & 호스팅<br></option>
<option NAME="문의선택" value="검색엔진 최적화">검색엔진 최적화<br></option>
<option NAME="문의선택" value="온라인 마케팅">온라인 마케팅<br></option>
<option NAME="문의선택" value="사진촬영 & 보정">사진촬영 & 보정<br></option>
<option NAME="문의선택" value="고객님의견접수">고객님 의견접수<br></option>
</select></td>
</tr>
<tr>
<td width="198" height="31">
<p align="right"><span style="font-size:9pt;"><b><font color="#903C39">회사 / 이름</font></b><font color="#903C39"> </font></span></p>
</td>
<td width="502" height="31"> <input type='text' name='이름' style="color:black; background-color:white; border-width:1; border-color:rgb(204,204,204); border-style:solid; width:80%;" required itemname="name"></td>
</tr>
<tr>
<td height="31" width="198">
<p align="right"><span style="font-size:9pt;"><b><font color="#903C39">이메일 </font></b> </span></p>
</td>
<td height="31" width="502"> <input type='text' name='email' style="background-color:white; border-width:1; border-color:rgb(204,204,204); border-style:solid; width:80%;" email required itemname="이메일"></td>
</tr>
</tr>
</tr>
<tr>
<td width="198" height="31">
<p align="right"><span style="font-size:9pt;"><b><font color="#903C39">전화번호 / 핸드폰 </font> </b></span></p>
</td>
<td width="502" height="31"> <input type='text' name='연락번호' style="background-color:white; border-width:1; border-color:rgb(204,204,204); border-style:solid; width:80%;" itemname="telephone"> </td>
</tr>
<tr>
<td width="198" height="191">
<p align="right"><b><font color="#903C39">내용</font></b><font color="#903C39"> </font></p>
</td>
<td width="502" height="191"> <textarea name="내용" style="background-color:white; border-width:1; border-color:rgb(204,204,204); border-style:solid; width:80%; scrollbar-base-color:rgb(224,223,227);" rows='11' itemname='Inquiry'></textarea></td>
</tr>
<tr>
<td class=write_head height="62">
<p align="right"><img id='kcaptcha_image' /> </p>
</td>
<td><input class='ed' type=input size=10 name=wr_key itemname="자동등록방지" required> 왼쪽의 글자를 입력하세요.</td>
</tr>
<tr>
<td width="700" height="88" colspan="2">
<p align="center"><input type='submit' value=" 확 인 "></form>
</td>
</tr>
</table>
===========================
mail_update.php
===========================
<?
include_once("./_common.php");
include_once("$g4[path]/lib/mailer.lib.php");
while(list($key,$val) = each($_POST)){
if($key == "faction" || $key == "x" || $key == "y") continue;
if(empty($val)) continue; // 텍스트박스/입력박스 사용시에 적용
$arrkey[] = $key;
$arrval[] = $val;
}
// 메일발송
// 실제 사용시 제목을 수정하십시오.
//$subject = $_POST["이름"] . " 님이 신청한 내용";
$subject = "온라인 고객문의";
$admin = get_admin('super');
//$admin[mb_email] = $_POST['email'];
ob_start();
include "./mail_post.php";
$content = ob_get_contents();
ob_end_clean();
mailer($_POST["name"], $email, $admin[mb_email], $subject, $content, 1); // 마지막에 숫자 1을 변경하지 마십시오.
// 메일발송 후 돌아가고자 하는 페이지가 index.php 가 아니라면 아래에서 $g4[path] 를 이동하고자 하는 경로로 수정해 주십시오.
alert("감사합니다.","./contact.php");
?>
============================
mail_post.php
============================
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<title>[<?=$subject?>]</title>
</head>
<style>
body, th, td, form, input, select, text, textarea, caption { font-size: 13px; font-family:vernada;}
.line {border: 1px solid #868F98;}
</style>
<body leftmargin=0 topmargin=10 marginwidth=0 marginheight=0>
<table width="95%" cellpadding=5 cellspacing=0 border=1 align="center">
<col width="20%" bgcolor="#eaeaea" style="font:bold;">
<col width="">
<tr>
<td colspan=2 height=40 bgcolor="#ffffff">
<font color='#3300FF'><B><?=$subject?></B></font>
</td>
</tr>
<? for($i=0;$i<count($arrkey);$i++){ ?>
<tr>
<td><?=$arrkey[$i]?></td>
<td><?echo str_replace("\n","<br>",stripslashes($arrval[$i]));?></td>
</tr>
<?}?>
</table>
</body>
</html>
댓글 전체
contact.php
1)
include_once("./head.sub.php");
2)
<form name="fumail" method="post" action="./mail_update.php" onsubmit="return checkform(this);">
3)
<input type='submit' id="btn_submit" value=" 확 인 ">
4)
function checkform(f)
{
// 필드 체크 생략
if (!check_kcaptcha(f.wr_key)) {
return false;
}
document.getElementById('btn_submit').disabled = true;
return true;
}
</script>
5)
<script type="text/javascript" src="<?="$g4[path]/js/jquery-1.4.2.min.js"?>"></script>
<script type="text/javascript" src="<?="$g4[path]/js/jquery.kcaptcha.js"?>"></script>
1)
include_once("./head.sub.php");
2)
<form name="fumail" method="post" action="./mail_update.php" onsubmit="return checkform(this);">
3)
<input type='submit' id="btn_submit" value=" 확 인 ">
4)
function checkform(f)
{
// 필드 체크 생략
if (!check_kcaptcha(f.wr_key)) {
return false;
}
document.getElementById('btn_submit').disabled = true;
return true;
}
</script>
5)
<script type="text/javascript" src="<?="$g4[path]/js/jquery-1.4.2.min.js"?>"></script>
<script type="text/javascript" src="<?="$g4[path]/js/jquery.kcaptcha.js"?>"></script>
감사합니다 슈와이님 덕분에 해결 되었습니다
혹시 다른분들이 폼메일을 사용하시고자 하신다면 슈와이님의 글중에서
4)
<script> <--넣어주셔야 합니다
function checkform(f)
이렇게 사용하시면 됩니다
혹시 다른분들이 폼메일을 사용하시고자 하신다면 슈와이님의 글중에서
4)
<script> <--넣어주셔야 합니다
function checkform(f)
이렇게 사용하시면 됩니다

글쓰기와 비슷한 형태로 하실거면 /bbs/write.php 에서사용하는 kcaptcha와
/skin/board/보드스킨/write.skin.php 에서 사용하는 kcaptcha가 어떤방식으로 돌아가는지 파악하시고 응용하세요
/skin/board/보드스킨/write.skin.php 에서 사용하는 kcaptcha가 어떤방식으로 돌아가는지 파악하시고 응용하세요