join_proc.php 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346
  1. <?php
  2. include $_SERVER["DOCUMENT_ROOT"].'/common/lib/comm.php';
  3. include $_SERVER['DOCUMENT_ROOT'].'/common/lib/aligo.php';
  4. $table_name = "member_master";
  5. $PageNo = trim(avoid_crack($_REQUEST["PageNo"]));
  6. $mode = trim(avoid_crack($_POST["mode"]));
  7. $cd_user = trim(avoid_crack($_POST["cd_user"]));
  8. $cd_userid = trim(avoid_crack($_POST["cd_userid"]));
  9. $nm_name = trim(avoid_crack($_POST["nm_name"]));
  10. $nm_pass = trim(avoid_crack($_POST["nm_pass"]));
  11. $ds_type = trim(avoid_crack($_POST["ds_type"]));
  12. $ds_level = trim(avoid_crack($_POST["ds_level"]));
  13. $nm_company = trim(avoid_crack($_POST["nm_company"]));
  14. // $nm_birth = trim(avoid_crack($_POST["nm_birth"]));
  15. // $nm_tel = trim(avoid_crack($_POST["nm_tel"]));
  16. // $nm_tel_01 = trim(avoid_crack($_POST["nm_tel_01"]));
  17. // $nm_tel_02 = trim(avoid_crack($_POST["nm_tel_02"]));
  18. // $nm_tel_03 = trim(avoid_crack($_POST["nm_tel_03"]));
  19. $nm_hp = trim(avoid_crack($_POST["nm_hp"]));
  20. $nm_hp_01 = trim(avoid_crack($_POST["nm_hp_01"]));
  21. $nm_hp_02 = trim(avoid_crack($_POST["nm_hp_02"]));
  22. $nm_hp_03 = trim(avoid_crack($_POST["nm_hp_03"]));
  23. $nm_email = trim(avoid_crack($_POST["nm_email"]));
  24. $ds_company_bp = trim(avoid_crack($_POST["ds_company_bp"]));
  25. $ds_branch = trim(avoid_crack($_POST["ds_branch"]));
  26. $ds_area = trim(avoid_crack($_POST["ds_area"]));
  27. $ds_area_sub = trim(avoid_crack($_POST["ds_area_sub"]));
  28. $ds_agree1 = trim(avoid_crack($_POST["ds_agree1"]));
  29. $ds_agree2 = trim(avoid_crack($_POST["ds_agree2"]));
  30. $ds_agree3 = trim(avoid_crack($_POST["ds_agree3"]));
  31. $ds_agree4 = trim(avoid_crack($_POST["ds_agree4"]));
  32. /*
  33. $nm_zip = trim(avoid_crack($_POST["nm_zip"]));
  34. $nm_addr = trim(avoid_crack($_POST["nm_addr"]));
  35. $nm_addr_sub = trim(avoid_crack($_POST["nm_addr_sub"]));
  36. $ds_job = trim(avoid_crack($_POST["ds_job"]));
  37. $nm_etc_01 =trim(avoid_crack($_POST["nm_etc_01"]));
  38. $nm_etc_02 = trim(avoid_crack($_POST["nm_etc_02"]));
  39. $nm_etc_03 = trim(avoid_crack($_POST["nm_etc_03"]));
  40. */
  41. $ds_status = trim(avoid_crack($_POST["ds_status"]));
  42. $ds_delind = trim(avoid_crack($_POST["ds_delind"]));
  43. // $cd_procid = $_SESSION[admin_cd_userid];
  44. // $PageNo = trim(avoid_crack($_POST["PageNo"]));
  45. switch($mode) {
  46. //저장하기
  47. case "Add" :
  48. $RES = array('CODE'=>'9999', 'MSG'=>'');
  49. try {
  50. $cd_userid = $nm_email;
  51. if(!$_POST) {
  52. throw new Exception("정상적인 접근이 아닙니다.", "9999");
  53. }
  54. if(empty($cd_userid)) {
  55. throw new Exception("아이디가 없습니다.", "9998");
  56. }
  57. if(empty($nm_pass) || empty($nm_pass2)) {
  58. throw new Exception("비밀번호가 없습니다.", "9997");
  59. }
  60. if($nm_pass != $nm_pass2) {
  61. throw new Exception("입력하신 비밀번호가 일치하지 않습니다.", "9996");
  62. }
  63. if(empty($nm_name)) {
  64. throw new Exception("이름이 없습니다.", "9995");
  65. }
  66. if(empty($nm_hp) || $nm_hp == "--") {
  67. throw new Exception("휴대번호가 없습니다.", "9993");
  68. }
  69. if(empty($ds_area)) {
  70. throw new Exception("지역이 없습니다.", "9992");
  71. }
  72. // if(empty($nm_birth) || $nm_birth == "--") {
  73. // throw new Exception("생년월일이 없습니다.", "9994");
  74. // }
  75. // if(empty($ds_sido)) {
  76. // throw new Exception("군구가 없습니다.", "9992");
  77. // }
  78. //
  79. // if($ds_agree1 != "Y") {
  80. // throw new Exception("회원 이용약관에 동의해 주세요.", "9992");
  81. // }
  82. // if($ds_agree2 != "Y") {
  83. // throw new Exception("개인정보수집/이용에대한 안내에 동의해 주세요.", "9992");
  84. // }
  85. // if(empty($nm_auth_num)) {
  86. // throw new Exception("휴대폰 인증번호가 없습니다.", "9991");
  87. // }
  88. //소문자만 사용
  89. $cd_userid = strtolower($cd_userid);
  90. // if(!preg_match("/^[a-zA-Z](?=.*[a-zA-Z])(?=.*[0-9]).{3,19}$/i", $cd_userid)) {
  91. // // if(!preg_match("/^[a-zA-Z]+[a-zA-Z0-9]{3,19}$/i", $cd_dealerid)) {
  92. // throw new Exception("아이디는 영문자로 시작하는 4~20자 영문자/숫자 조합이어야 합니다.", "9991");
  93. // }
  94. # 1. 아이디 중복 체크
  95. $_whereis = " cd_userid = '". $cd_userid . "' ";
  96. $userid = $dbCon->getOneDAO("cd_userid",$table_name, $_whereis, 1);
  97. // echo 'userid:'.$userid;
  98. // exit;'//ds_delind='N' And'
  99. if(!empty($userid)) {
  100. throw new Exception("사용불가능한 아이디입니다.", "9900");
  101. }
  102. $nm_hp = preg_replace("/[^0-9]*/s", "", $nm_hp);
  103. $nm_hp = add_hyphen($nm_hp);
  104. # 3. DB 저장
  105. $sql="insert into $table_name set
  106. cd_userid = '$cd_userid'
  107. , nm_name = '".$nm_name."'
  108. , nm_pass = password('$nm_pass')
  109. , ds_type = '$ds_type'
  110. , ds_level = '1'
  111. , nm_birth = '".$nm_birth."'
  112. , nm_hp = '".$nm_hp."'
  113. , nm_email = '$nm_email'
  114. , ds_area = '$ds_area'
  115. , ds_agree1 = '$ds_agree1'
  116. , ds_agree2 = '$ds_agree2'
  117. , ds_agree3 = '$ds_agree3'
  118. , dt_insert = now()
  119. , nm_insert = '$cd_userid'
  120. , dt_update = now()
  121. , nm_update = '$cd_userid'
  122. , ds_delind = 'N'
  123. ";
  124. //, dt_lastlogin = now()
  125. // echo $sql;
  126. // exit;
  127. $result = mysql_query($sql);
  128. $cd_user = mysql_insert_id($connect);
  129. if (!$result) {
  130. throw new Exception("등록 실패 하였습니다.", "9900");
  131. }
  132. $RES['CODE'] = "0000";
  133. $RES['MSG'] = "회원에 가입 되셨습니다";
  134. $RES['DATAS']['URL'] = $url;
  135. }catch(Exception $e){
  136. $RES['CODE'] = $e->getCode();
  137. $RES['MSG'] = $e->getMessage();
  138. }
  139. echo json_encode($RES);
  140. exit;
  141. break;
  142. case "IdChk":
  143. $RES = array('CODE'=>'9999', 'MSG'=>'');
  144. try {
  145. $cd_userid = trim(avoid_crack($_POST["nm_email"]));
  146. if(!$_POST) {
  147. throw new Exception("정상적인 접근이 아닙니다.", "9999");
  148. }
  149. if(empty($nm_email)) {
  150. throw new Exception("아이디를 입력하세요.", "9998");
  151. }
  152. $cd_userid = trim($cd_userid);
  153. //소문자만 사용
  154. $cd_userid = strtolower($cd_userid);
  155. if(!emailCheck($cd_userid)) {
  156. throw new Exception("아이디를 이메일 형식으로 입력하세요.", "9998");
  157. }
  158. // if(!preg_match("/^[a-zA-Z](?=.*[a-zA-Z])(?=.*[0-9]).{3,19}$/i", $cd_userid)) {
  159. // // if(!preg_match("/^[a-zA-Z]+[a-zA-Z0-9]{3,19}$/i", $cd_dealerid)) {
  160. // throw new Exception("아이디는 영문자로 시작하는 4~20자 영문자/숫자 조합이어야 합니다.", "9991");
  161. // }
  162. $res = mysql_query("select count(cd_userid) from $table_name where cd_userid='$cd_userid' ");
  163. //AND ds_delind = 'N'
  164. $cnt = mysql_result($res,0,0);
  165. if(!empty($cnt)) {
  166. throw new Exception("사용할 수 없는 아이디입니다.", "9990");
  167. }
  168. $RES['CODE'] = "0000";
  169. $RES['MSG'] = "사용가능한 아이디입니다.";
  170. }catch(Exception $e){
  171. $RES['CODE'] = $e->getCode();
  172. $RES['MSG'] = $e->getMessage();
  173. }
  174. echo json_encode($RES);
  175. exit;
  176. break;
  177. case "IdSearch":
  178. $RES = array('CODE'=>'9999', 'MSG'=>'');
  179. try {
  180. $nm_name = trim(avoid_crack($_POST["nm_name"]));
  181. $nm_hp = trim(avoid_crack($_POST["nm_hp"]));
  182. if(empty($nm_name)) {
  183. throw new Exception("이름을 입력하세요", "9990");
  184. }
  185. if(empty($nm_hp)) {
  186. throw new Exception("휴대폰 번호를 입력하세요", "9990");
  187. }
  188. $nm_hp = preg_replace("/[^0-9]*/s", "", $nm_hp);
  189. $nm_hp = add_hyphen($nm_hp);
  190. $sql = "select * from $table_name where ds_delind='N' And nm_name = '". $nm_name . "' AND nm_hp = '". $nm_hp . "' ";
  191. // echo $sql;
  192. // exit;
  193. $res = mysql_query($sql);
  194. $col = mysql_fetch_array($res);
  195. if(empty($col['cd_user'])) {
  196. throw new Exception("입력하신 정보가 정확하지 않습니다.", "9990");
  197. }
  198. # SMS 발송
  199. # 1. 요청자에게
  200. $aligo = new Aligo();
  201. $aligo->getToken();
  202. $ALIGO_DATA = array();
  203. $ALIGO_DATA['id'] = $col['cd_userid'];
  204. $ALIGO_DATA['name'] = $col['nm_name'];
  205. $ALIGO_DATA['recv_phone'] = $col['nm_hp'];
  206. // print_r($ALIGO_DATA);
  207. // exit;
  208. $response = $aligo->send_common_find_id($ALIGO_DATA);
  209. unset($ALIGO_DATA);
  210. if($response['code'] != "0") {
  211. throw new Exception($response['message'], "4449");
  212. }
  213. $RES['CODE'] = "0000";
  214. $RES['MSG'] = "정상.";
  215. }catch(Exception $e){
  216. $RES['CODE'] = $e->getCode();
  217. $RES['MSG'] = $e->getMessage();
  218. }
  219. @mysql_close($connect);
  220. echo json_encode($RES);
  221. exit;
  222. break;
  223. case "PwdSearch":
  224. $RES = array('CODE'=>'9999', 'MSG'=>'');
  225. try {
  226. $cd_userid = trim(avoid_crack($_POST["cd_userid"]));
  227. $nm_hp = trim(avoid_crack($_POST["nm_hp"]));
  228. //소문자만 사용
  229. $cd_userid = strtolower($cd_userid);
  230. if(empty($cd_userid)) {
  231. throw new Exception("아이디를 입력하세요", "9990");
  232. }
  233. if(empty($nm_hp)) {
  234. throw new Exception("휴대폰 번호를 입력하세요", "9990");
  235. }
  236. $nm_hp = preg_replace("/[^0-9]*/s", "", $nm_hp);
  237. $nm_hp = add_hyphen($nm_hp);
  238. $sql = "select * from $table_name where ds_delind='N' And cd_userid = '". $cd_userid . "' AND nm_hp = '". $nm_hp . "' ";
  239. // echo $sql;
  240. // exit;
  241. $res = mysql_query($sql);
  242. $col = mysql_fetch_array($res);
  243. if(empty($col['cd_user'])) {
  244. throw new Exception("입력하신 정보가 정확하지 않습니다.", "9990");
  245. }
  246. $new_passwd = generatePassword(8);
  247. $sql="UPDATE $table_name set nm_pass = password('".$new_passwd."') where cd_user = '{$col['cd_user']}'";
  248. // echo $sql;
  249. // exit;
  250. $result = mysql_query($sql,$connect);
  251. if(!$result) {
  252. throw new Exception("임시 비밀번호 변경에 실패 하였습니다.잠시후 다시 시도해 주세요.", "9990");
  253. }
  254. # SMS 발송
  255. # 1. 요청자에게
  256. $aligo = new Aligo();
  257. $aligo->getToken();
  258. $ALIGO_DATA = array();
  259. $ALIGO_DATA['pwd'] = $new_passwd;
  260. $ALIGO_DATA['name'] = $col['nm_name'];
  261. $ALIGO_DATA['recv_phone'] = $col['nm_hp'];
  262. // print_r($ALIGO_DATA);
  263. // exit;
  264. $response = $aligo->send_common_find_pwd($ALIGO_DATA);
  265. unset($ALIGO_DATA);
  266. if($response['code'] != "0") {
  267. throw new Exception($response['message'], "4449");
  268. }
  269. $RES['CODE'] = "0000";
  270. $RES['MSG'] = "정상.";
  271. }catch(Exception $e){
  272. $RES['CODE'] = $e->getCode();
  273. $RES['MSG'] = $e->getMessage();
  274. }
  275. @mysql_close($connect);
  276. echo json_encode($RES);
  277. exit;
  278. break;
  279. default :
  280. AlertBack("지정되지않은 요청입니다");
  281. break;
  282. }
  283. mysql_close($connect);
  284. ?>