| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324 |
- <?php
- include $_SERVER["DOCUMENT_ROOT"].'/common/lib/comm.php';
- include $_SERVER['DOCUMENT_ROOT'].'/common/lib/aligo.php';
- $table_name = "sa_master";
- $PageNo = trim(avoid_crack($_REQUEST["PageNo"]));
- $mode = trim(avoid_crack($_POST["mode"]));
- $cd_user = trim(avoid_crack($_POST["cd_user"]));
- $cd_userid = trim(avoid_crack($_POST["cd_userid"]));
- $nm_name = trim(avoid_crack($_POST["nm_name"]));
- $nm_pass = trim(avoid_crack($_POST["nm_pass"]));
- $ds_type = trim(avoid_crack($_POST["ds_type"]));
- $ds_level = trim(avoid_crack($_POST["ds_level"]));
- $nm_company = trim(avoid_crack($_POST["nm_company"]));
- // $nm_birth = trim(avoid_crack($_POST["nm_birth"]));
- // $nm_tel = trim(avoid_crack($_POST["nm_tel"]));
- // $nm_tel_01 = trim(avoid_crack($_POST["nm_tel_01"]));
- // $nm_tel_02 = trim(avoid_crack($_POST["nm_tel_02"]));
- // $nm_tel_03 = trim(avoid_crack($_POST["nm_tel_03"]));
- $nm_hp = trim(avoid_crack($_POST["nm_hp"]));
- $nm_hp_01 = trim(avoid_crack($_POST["nm_hp_01"]));
- $nm_hp_02 = trim(avoid_crack($_POST["nm_hp_02"]));
- $nm_hp_03 = trim(avoid_crack($_POST["nm_hp_03"]));
- $nm_email = trim(avoid_crack($_POST["nm_email"]));
- $ds_company_bp = trim(avoid_crack($_POST["ds_company_bp"]));
- $ds_branch = trim(avoid_crack($_POST["ds_branch"]));
- $ds_area = trim(avoid_crack($_POST["ds_area"]));
- $ds_area_sub = trim(avoid_crack($_POST["ds_area_sub"]));
- $ds_agree1 = trim(avoid_crack($_POST["ds_agree1"]));
- $ds_agree2 = trim(avoid_crack($_POST["ds_agree2"]));
- $ds_agree3 = trim(avoid_crack($_POST["ds_agree3"]));
- $ds_agree4 = trim(avoid_crack($_POST["ds_agree4"]));
- /*
- $nm_zip = trim(avoid_crack($_POST["nm_zip"]));
- $nm_addr = trim(avoid_crack($_POST["nm_addr"]));
- $nm_addr_sub = trim(avoid_crack($_POST["nm_addr_sub"]));
- $ds_job = trim(avoid_crack($_POST["ds_job"]));
- $nm_etc_01 =trim(avoid_crack($_POST["nm_etc_01"]));
- $nm_etc_02 = trim(avoid_crack($_POST["nm_etc_02"]));
- $nm_etc_03 = trim(avoid_crack($_POST["nm_etc_03"]));
- */
- $ds_status = trim(avoid_crack($_POST["ds_status"]));
- $ds_delind = trim(avoid_crack($_POST["ds_delind"]));
- // $cd_procid = $_SESSION[admin_cd_userid];
- // $PageNo = trim(avoid_crack($_POST["PageNo"]));
- switch($mode) {
- //저장하기
- case "Add" :
- $RES = array('CODE'=>'9999', 'MSG'=>'');
- try {
- 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($nm_email) || $nm_email == "@") {
- throw new Exception("이메일이 없습니다.", "9993");
- }
- if(strlen($cd_userid)<3 || strlen($cd_userid)>20) {
- throw new Exception("아이디(3~20)의 자리수가 맞지 않습니다.", "9990");
- }
- if($cd_userid=="userid" || $cd_userid=="member" || $cd_userid=="admin"){
- throw new Exception("중복된 아이디입니다. 관리자에게 문의하십시요.", "9990");
- }
- 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");
- }
- $check_id=@mysql_result(mysql_query("select count(*) from $table_name where cd_userid='$cd_userid'"),0,0);
- if($check_id>0) {
- throw new Exception("이미 사용중인 아이디입니다.다시 한번 확인하세요.", "9990");
- }
- //소문자만 사용
- $cd_userid = strtolower($cd_userid);
- $sql = "INSERT INTO $table_name SET
- cd_userid = '$cd_userid'
- , nm_name = '$nm_name'
- , ds_type = 'A0'
- , ds_level = '1'
- , nm_hp = '$nm_hp'
- , nm_email = '$nm_email'
- , ds_company_bp = '$ds_company_bp'
- , ds_branch = '$ds_branch'
- , ds_area = '$ds_area'
- , ds_area_sub = '$ds_area_sub'
- , ds_agree1 = '$ds_agree1'
- , ds_agree2 = '$ds_agree2'
- , ds_agree3 = '$ds_agree3'
- , ds_agree4 = '$ds_agree4'
- , nm_pass = password('".$nm_pass."')
- , dt_insert = now()
- , nm_insert = '$cd_userid'
- , dt_update = now()
- , nm_update = '$cd_userid'
- , ds_delind = 'N'
- ";
- // echo $sql;
- // exit;
- $result = mysql_query($sql,$connect);
- if(!$result) {
- throw new Exception("회원 등록처리에 실패 하였습니다.잠시후 다시 시도해 주세요.", "9990");
- }
- $RES['CODE'] = "0000";
- $RES['MSG'] = "회원 등록이 완료되었습니다.";
- }catch(Exception $e){
- $RES['CODE'] = $e->getCode();
- $RES['MSG'] = $e->getMessage();
- }
- @mysql_close($connect);
- echo json_encode($RES);
- exit;
- // "nm_zip"=>$nm_zip,
- // "nm_addr"=>$nm_addr,
- // "nm_addr_sub"=>$nm_addr_sub,
- // "ds_status"=>$ds_status,
- // "nm_hp_01"=>$nm_hp_01,
- // "nm_hp_02"=>$nm_hp_02,
- // "nm_hp_03"=>$nm_hp_03,
- // "nm_company"=>$nm_company,
- // "nm_birth"=>$nm_birth,
- break;
- case "IdChk":
- $RES = array('CODE'=>'9999', 'MSG'=>'');
- try {
- //소문자만 사용
- $cd_userid = strtolower($cd_userid);
- if(strlen($cd_userid)<4 || strlen($cd_userid)>20) {
- throw new Exception("아이디(4~20)의 자리수가 맞지 않습니다.", "9990");
- }
- if($cd_userid=="userid" || $cd_userid=="member" || $cd_userid=="admin"){
- throw new Exception("중복된 아이디입니다. 관리자에게 문의하십시요.", "9990");
- }
- 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");
- }
- $check_id=@mysql_result(mysql_query("select count(*) from $table_name where cd_userid='$cd_userid'"),0,0);
- if($check_id>0) {
- throw new Exception("이미 사용중인 아이디입니다.다시 한번 확인하세요.", "9990");
- }
- $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 "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'];
- $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'];
- $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);
- ?>
|