d

Siren24 페이지 이동없이 Socket 으로 실명인증( UTF-8)

phpschool.com에서 퍼옴.
정말 대단합니다...^^

ssn.html//
##########################################
<html>
<body>

<script type="text/javascript">
var xmlhttp = XMLHTTP();

function XMLHTTP() {
try {
xmlhttp = new ActiveXObject("MSXML2.XMLHTTP");
}
catch(e) {
xmlhttp = new XMLHttpRequest();
}
return xmlhttp;
}
function remove_space( str ) {
str = str.replace(/\s+/g,"");
return str;
}
function is_numeric( str ) {
if ( str == str.match(/[0-9]+$/) )
{
return true;
}
else { return false; }
}
function is_ssn( ssn1 , ssn2 ) {
if ( !is_numeric(ssn1) || !is_numeric(ssn2) || ssn1.length != 6 || ssn2.length !=7 ) { return false; }
else { return true; }
}

function chk_ssn() {

var name = remove_space( document.getElementById("name").value );
var ssn1 = remove_space( document.getElementById("ssn1").value );
var ssn2 = remove_space( document.getElementById("ssn2").value );
if ( name == "" )
{
alert('이름을 입력해 주세요');
document.getElementById("name").focus();
return false;
}
else if( !is_ssn( ssn1 , ssn2 ))
{
alert('주민등록번호를 정확히 입력해 주시기 바랍니다.');
document.getElementById("ssn1").focus();
return false;
}
else {

document.getElementById("chk_ssn_msg").innerHTML="실명 확인중입니다.";
try
{
with( xmlhttp ) {
open("POST", "chk_ssn.php", true);
setRequestHeader("Content-Type", "application/x-www-form-urlencoded");

onreadystatechange = function() {

if (xmlhttp.readyState == 4) {
if ( xmlhttp.status==200)
{
var res = remove_space(xmlhttp.responseText) ;
var res_ = res.split("|");
res_no = res_[0];

if ( res_no == 99)
{
document.getElementById("chk_ssn_msg").innerHTML="<a onclick=\"chk_ssn();\">실명인증</a>";
alert('기존에 가입하신 아이디가 있습니다.');
}
else if ( res_no=="1" ) {
document.getElementById("chk_ssn_msg").innerHTML="<a onclick=\"chk_ssn();\">실명인증</a>";
alert('실명확인 성공.');
}
else if (res_no==2 || res_no == 4 )
{
document.getElementById("chk_ssn_msg").innerHTML="<a onclick=\"chk_ssn();\">실명인증</a>";
alert('주민등록번호 오류 입니다. 다시 입력해 주세요.');

}
else {

document.getElementById("chk_ssn_msg").innerHTML="<a onclick=\"chk_ssn();\">실명인증</a>";
if ( confirm('실명이 인증되지 않았습니다. 일반 회원으로 가입하시겠습니까?') )
{
document.getElementById("ssn_form").realSSN.value = "0";
document.getElementById("ssn_form").submit();
}
}
}
}
}

send( "name="+ name +"&ssn1="+ ssn1 + "&ssn2=" + ssn2 );
}
}
catch ( e)
{

}

}
}
</script>
<form>
이름:<input type="text" name="name" id="name" /><br />
주민번호앞: <input type="text" name="ssn1" id="ssn1" maxlength="6" /><br />
주민번호뒤:<input type="password" name="ssn2" id="ssn2" maxlength="7" /><br />
메세지:<span id="chk_ssn_msg"><a onclick="chk_ssn();" style="cursor:pointer;cursor:hand">실명확인</a></span>
</form>
</body>
</html>


#######################################

chk_ssn.php

#######################################

<?
include "../inc/funct/common.inc.php";
include "../inc/funct/db_class.inc.php";


//가입 유저인지 확인 (중복가입 금지)
/*
$que = "SELECT user_id FROM _member_login WHERE ssn='".$_POST['ssn1'].$_POST['ssn2']."'";
$rs = $db->ExecQuery($que);

$chk_num = $db->GetNumrows($rs);
*/
if ( $chk_num > 0 ) {
/*
$id = $db->GetResult($rs,0,0);
echo "99|".$id;
*/
}
else {
$host = "210.207.91.246"; //신용평가원 아이피
$uri = "/servlet/name_check"; //POST 데이타 전송할 URI
$name = iconv( "UTF-8","EUC-KR",$_POST['name']);

/** 수정 **/
$ok_url = "http://okurl";//중요하지 않음
$referer_page = "http://신평에 등록된 실명인증확인 페이지";
$siren_id = "siren 아이디";
/** 수정 **/



$jumin1 = $_POST['ssn1'];
$jumin2 = $_POST['ssn2'];

$reqbody =
"id=$siren_id&name=".urlencode( $name ).
"&jumin1=$jumin1".
"&jumin2=$jumin2".
"&ok_url=".urlencode($ok_url); // 리턴주소 별로 중요하지 않음

$contentlength = strlen($reqbody);

$reqheader = "POST $uri HTTP/1.0\r\n".
"Host: name.siren24.com\r\n".
"Content-Type: application/x-www-form-urlencoded\r\n".
"Referer: $referer_page\r\n".
"Content-Length: $contentlength\r\n\r\n".
"$reqbody\r\n";

$fp = fsockopen( $host , 80 , $err , $err2);
fputs($fp, $reqheader);

$tmp="x";

while ($tmp!="") {
$tmp = $buffer = fgets($fp, 4096);

if (preg_match('/name=result/',$buffer,$aMatch)) {
preg_match('/value=\\"([^\\"]*)\\"/',$buffer,$aMatch);
$result = $aMatch[1];
}

if (preg_match('/<font>/',$buffer,$aMatch)) {
preg_match('/<font>([^\\"]*)\<\/font>/',$buffer,$aMatch2);
$result = $aMatch2[1];
}
//echo $buffer;
}

fclose($fp);
?>
<?

if (!is_numeric( $result ) ) {
$result="0";
}

echo (int)$result;
}
?>


#####################<div class='small'>[이 게시물은 관리자님에 의해 2011-10-31 17:12:10 PHP & HTML에서 이동 됨]</div>
|

댓글 1개

ajax 코드로 처리하면 쉬운것을 이전에 왜 그리 페이지 이동을 해서 한글이름 깨지고 ㅜ.ㅜ
동생넘이 asp로 짜면서 ajax코드로 금방 처리해버리더군요.. 헉~! 하는 말밖에.. 덕분에 한가지 배웠지만요..
댓글을 작성하시려면 로그인이 필요합니다.

프로그램

+
제목 글쓴이 날짜 조회
19년 전 조회 2,750
19년 전 조회 3,076
19년 전 조회 4,654
19년 전 조회 2,560
19년 전 조회 2,582
19년 전 조회 3,628
19년 전 조회 3,292
19년 전 조회 2,948
19년 전 조회 2,182
19년 전 조회 1,926
19년 전 조회 3,016
19년 전 조회 1,867
19년 전 조회 2,447
19년 전 조회 4,087
19년 전 조회 3,869
19년 전 조회 3,593
19년 전 조회 3,545
19년 전 조회 1,702
19년 전 조회 2,072
19년 전 조회 1,988
19년 전 조회 2,670
19년 전 조회 4,755
19년 전 조회 2,897
19년 전 조회 2,058
19년 전 조회 2,063
19년 전 조회 1,952
19년 전 조회 2,695
19년 전 조회 8,314
19년 전 조회 2,873
19년 전 조회 2,927
19년 전 조회 3,194
19년 전 조회 2,335
19년 전 조회 2,349
19년 전 조회 2,310
19년 전 조회 2,202
19년 전 조회 2,389
19년 전 조회 2,644
19년 전 조회 3,216
19년 전 조회 2,465
19년 전 조회 2,039
19년 전 조회 2,971
19년 전 조회 5,142
19년 전 조회 3,625
19년 전 조회 3,585
19년 전 조회 3,112
19년 전 조회 2,533
19년 전 조회 1,624
19년 전 조회 3,265
19년 전 조회 2,143
19년 전 조회 5,502
19년 전 조회 2,572
19년 전 조회 3,575
19년 전 조회 2,989
19년 전 조회 1,897
19년 전 조회 4,006
19년 전 조회 2,543
19년 전 조회 2,431
19년 전 조회 3,139
19년 전 조회 3,428
19년 전 조회 2,634
19년 전 조회 2,398
19년 전 조회 2,459
19년 전 조회 2,134
19년 전 조회 3,216
19년 전 조회 2,137
19년 전 조회 2,166
19년 전 조회 1,831
19년 전 조회 2,349
19년 전 조회 2,310
19년 전 조회 2,609
19년 전 조회 3,010
19년 전 조회 2,514
19년 전 조회 2,590
19년 전 조회 3,625
19년 전 조회 3,340
19년 전 조회 3,336
19년 전 조회 3,151
19년 전 조회 2,157
19년 전 조회 2,471
19년 전 조회 2,367
19년 전 조회 2,175
19년 전 조회 2,628
19년 전 조회 2,560
19년 전 조회 2,934
19년 전 조회 2,310
19년 전 조회 3,629
19년 전 조회 2,104
19년 전 조회 2,712
19년 전 조회 1,723
19년 전 조회 2,971
19년 전 조회 3,196
19년 전 조회 2,291
19년 전 조회 2,129
19년 전 조회 2,611
19년 전 조회 2,526
19년 전 조회 3,218
19년 전 조회 6,897
19년 전 조회 2,850
19년 전 조회 3,320
19년 전 조회 3,221