'9999', 'MSG'=>''); try { $cd_userid = $nm_email; if(!$_POST) { throw new Exception("정상적인 접근이 아닙니다.", "9999"); } if(empty($cd_userid)) { throw new Exception("아이디가 없습니다.", "9998"); } if(empty($nm_pass) || empty($nm_pass2)) { throw new Exception("비밀번호가 없습니다.", "9997"); } if($nm_pass != $nm_pass2) { throw new Exception("입력하신 비밀번호가 일치하지 않습니다.", "9996"); } if(empty($nm_name)) { throw new Exception("이름이 없습니다.", "9995"); } if(empty($nm_hp) || $nm_hp == "--") { throw new Exception("휴대번호가 없습니다.", "9993"); } if(empty($ds_area)) { throw new Exception("지역이 없습니다.", "9992"); } // if(empty($nm_birth) || $nm_birth == "--") { // throw new Exception("생년월일이 없습니다.", "9994"); // } // if(empty($ds_sido)) { // throw new Exception("군구가 없습니다.", "9992"); // } // // if($ds_agree1 != "Y") { // throw new Exception("회원 이용약관에 동의해 주세요.", "9992"); // } // if($ds_agree2 != "Y") { // throw new Exception("개인정보수집/이용에대한 안내에 동의해 주세요.", "9992"); // } // if(empty($nm_auth_num)) { // throw new Exception("휴대폰 인증번호가 없습니다.", "9991"); // } //소문자만 사용 $cd_userid = strtolower($cd_userid); // if(!preg_match("/^[a-zA-Z](?=.*[a-zA-Z])(?=.*[0-9]).{3,19}$/i", $cd_userid)) { // // if(!preg_match("/^[a-zA-Z]+[a-zA-Z0-9]{3,19}$/i", $cd_dealerid)) { // throw new Exception("아이디는 영문자로 시작하는 4~20자 영문자/숫자 조합이어야 합니다.", "9991"); // } # 1. 아이디 중복 체크 $_whereis = " cd_userid = '". $cd_userid . "' "; $userid = $dbCon->getOneDAO("cd_userid",$table_name, $_whereis, 1); // echo 'userid:'.$userid; // exit;'//ds_delind='N' And' if(!empty($userid)) { throw new Exception("사용불가능한 아이디입니다.", "9900"); } # 3. DB 저장 $sql="insert into $table_name set cd_userid = '$cd_userid' , nm_name = '".$nm_name."' , nm_pass = password('$nm_pass') , ds_type = '$ds_type' , ds_level = '1' , nm_birth = '".$nm_birth."' , nm_hp = '".$nm_hp."' , nm_email = '$nm_email' , ds_area = '$ds_area' , ds_agree1 = '$ds_agree1' , ds_agree2 = '$ds_agree2' , ds_agree3 = '$ds_agree3' , dt_insert = now() , nm_insert = '$cd_userid' , dt_update = now() , nm_update = '$cd_userid' , ds_delind = 'N' "; //, dt_lastlogin = now() // echo $sql; // exit; $result = mysql_query($sql); $cd_user = mysql_insert_id($connect); if (!$result) { throw new Exception("등록 실패 하였습니다.", "9900"); } $RES['CODE'] = "0000"; $RES['MSG'] = "회원에 가입 되셨습니다"; $RES['DATAS']['URL'] = $url; }catch(Exception $e){ $RES['CODE'] = $e->getCode(); $RES['MSG'] = $e->getMessage(); } echo json_encode($RES); exit; break; case "IdChk": $RES = array('CODE'=>'9999', 'MSG'=>''); try { $cd_userid = trim(avoid_crack($_POST["nm_email"])); if(!$_POST) { throw new Exception("정상적인 접근이 아닙니다.", "9999"); } if(empty($nm_email)) { throw new Exception("아이디를 입력하세요.", "9998"); } $cd_userid = trim($cd_userid); //소문자만 사용 $cd_userid = strtolower($cd_userid); if(!emailCheck($cd_userid)) { throw new Exception("아이디를 이메일 형식으로 입력하세요.", "9998"); } // if(!preg_match("/^[a-zA-Z](?=.*[a-zA-Z])(?=.*[0-9]).{3,19}$/i", $cd_userid)) { // // if(!preg_match("/^[a-zA-Z]+[a-zA-Z0-9]{3,19}$/i", $cd_dealerid)) { // throw new Exception("아이디는 영문자로 시작하는 4~20자 영문자/숫자 조합이어야 합니다.", "9991"); // } $res = mysql_query("select count(cd_userid) from $table_name where cd_userid='$cd_userid' "); //AND ds_delind = 'N' $cnt = mysql_result($res,0,0); if(!empty($cnt)) { throw new Exception("사용할 수 없는 아이디입니다.", "9990"); } $RES['CODE'] = "0000"; $RES['MSG'] = "사용가능한 아이디입니다."; }catch(Exception $e){ $RES['CODE'] = $e->getCode(); $RES['MSG'] = $e->getMessage(); } echo json_encode($RES); exit; break; case "IdSearch": $RES = array('CODE'=>'9999', 'MSG'=>''); try { $nm_name = trim(avoid_crack($_POST["nm_name"])); $nm_hp = trim(avoid_crack($_POST["nm_hp"])); if(empty($nm_name)) { throw new Exception("이름을 입력하세요", "9990"); } if(empty($nm_hp)) { throw new Exception("휴대폰 번호를 입력하세요", "9990"); } $sql = "select * from $table_name where ds_delind='N' And nm_name = '". $nm_name . "' AND nm_hp = '". $nm_hp . "' "; // echo $sql; // exit; $res = mysql_query($sql); $col = mysql_fetch_array($res); if(empty($col['cd_user'])) { throw new Exception("입력하신 정보가 정확하지 않습니다.", "9990"); } # SMS 발송 # 1. 요청자에게 $aligo = new Aligo(); $aligo->getToken(); $ALIGO_DATA = array(); $ALIGO_DATA['id'] = $col['cd_userid']; $ALIGO_DATA['name'] = $col['nm_name']; $ALIGO_DATA['recv_phone'] = $col['nm_hp']; // print_r($ALIGO_DATA); // exit; $response = $aligo->send_common_find_id($ALIGO_DATA); unset($ALIGO_DATA); if($response['code'] != "0") { throw new Exception($response['message'], "4449"); } $RES['CODE'] = "0000"; $RES['MSG'] = "정상."; }catch(Exception $e){ $RES['CODE'] = $e->getCode(); $RES['MSG'] = $e->getMessage(); } @mysql_close($connect); echo json_encode($RES); exit; break; case "PwdSearch": $RES = array('CODE'=>'9999', 'MSG'=>''); try { $cd_userid = trim(avoid_crack($_POST["cd_userid"])); $nm_hp = trim(avoid_crack($_POST["nm_hp"])); //소문자만 사용 $cd_userid = strtolower($cd_userid); if(empty($cd_userid)) { throw new Exception("아이디를 입력하세요", "9990"); } if(empty($nm_hp)) { throw new Exception("휴대폰 번호를 입력하세요", "9990"); } $sql = "select * from $table_name where ds_delind='N' And cd_userid = '". $cd_userid . "' AND nm_hp = '". $nm_hp . "' "; // echo $sql; // exit; $res = mysql_query($sql); $col = mysql_fetch_array($res); if(empty($col['cd_user'])) { throw new Exception("입력하신 정보가 정확하지 않습니다.", "9990"); } $new_passwd = generatePassword(8); $sql="UPDATE $table_name set nm_pass = password('".$new_passwd."') where cd_user = '{$col['cd_user']}'"; // echo $sql; // exit; $result = mysql_query($sql,$connect); if(!$result) { throw new Exception("임시 비밀번호 변경에 실패 하였습니다.잠시후 다시 시도해 주세요.", "9990"); } # SMS 발송 # 1. 요청자에게 $aligo = new Aligo(); $aligo->getToken(); $ALIGO_DATA = array(); $ALIGO_DATA['pwd'] = $new_passwd; $ALIGO_DATA['name'] = $col['nm_name']; $ALIGO_DATA['recv_phone'] = $col['nm_hp']; // print_r($ALIGO_DATA); // exit; $response = $aligo->send_common_find_pwd($ALIGO_DATA); unset($ALIGO_DATA); if($response['code'] != "0") { throw new Exception($response['message'], "4449"); } $RES['CODE'] = "0000"; $RES['MSG'] = "정상."; }catch(Exception $e){ $RES['CODE'] = $e->getCode(); $RES['MSG'] = $e->getMessage(); } @mysql_close($connect); echo json_encode($RES); exit; break; default : AlertBack("지정되지않은 요청입니다"); break; } mysql_close($connect); ?>