join_proc.php 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337
  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. # 3. DB 저장
  103. $sql="insert into $table_name set
  104. cd_userid = '$cd_userid'
  105. , nm_name = '".$nm_name."'
  106. , nm_pass = password('$nm_pass')
  107. , ds_type = '$ds_type'
  108. , ds_level = '1'
  109. , nm_birth = '".$nm_birth."'
  110. , nm_hp = '".$nm_hp."'
  111. , nm_email = '$nm_email'
  112. , ds_area = '$ds_area'
  113. , ds_agree1 = '$ds_agree1'
  114. , ds_agree2 = '$ds_agree2'
  115. , ds_agree3 = '$ds_agree3'
  116. , dt_insert = now()
  117. , nm_insert = '$cd_userid'
  118. , dt_update = now()
  119. , nm_update = '$cd_userid'
  120. , ds_delind = 'N'
  121. ";
  122. //, dt_lastlogin = now()
  123. // echo $sql;
  124. // exit;
  125. $result = mysql_query($sql);
  126. $cd_user = mysql_insert_id($connect);
  127. if (!$result) {
  128. throw new Exception("등록 실패 하였습니다.", "9900");
  129. }
  130. $RES['CODE'] = "0000";
  131. $RES['MSG'] = "회원에 가입 되셨습니다";
  132. $RES['DATAS']['URL'] = $url;
  133. }catch(Exception $e){
  134. $RES['CODE'] = $e->getCode();
  135. $RES['MSG'] = $e->getMessage();
  136. }
  137. echo json_encode($RES);
  138. exit;
  139. break;
  140. case "IdChk":
  141. $RES = array('CODE'=>'9999', 'MSG'=>'');
  142. try {
  143. $cd_userid = trim(avoid_crack($_POST["nm_email"]));
  144. if(!$_POST) {
  145. throw new Exception("정상적인 접근이 아닙니다.", "9999");
  146. }
  147. if(empty($nm_email)) {
  148. throw new Exception("아이디를 입력하세요.", "9998");
  149. }
  150. $cd_userid = trim($cd_userid);
  151. //소문자만 사용
  152. $cd_userid = strtolower($cd_userid);
  153. if(!emailCheck($cd_userid)) {
  154. throw new Exception("아이디를 이메일 형식으로 입력하세요.", "9998");
  155. }
  156. // if(!preg_match("/^[a-zA-Z](?=.*[a-zA-Z])(?=.*[0-9]).{3,19}$/i", $cd_userid)) {
  157. // // if(!preg_match("/^[a-zA-Z]+[a-zA-Z0-9]{3,19}$/i", $cd_dealerid)) {
  158. // throw new Exception("아이디는 영문자로 시작하는 4~20자 영문자/숫자 조합이어야 합니다.", "9991");
  159. // }
  160. $res = mysql_query("select count(cd_userid) from $table_name where cd_userid='$cd_userid' ");
  161. //AND ds_delind = 'N'
  162. $cnt = mysql_result($res,0,0);
  163. if(!empty($cnt)) {
  164. throw new Exception("사용할 수 없는 아이디입니다.", "9990");
  165. }
  166. $RES['CODE'] = "0000";
  167. $RES['MSG'] = "사용가능한 아이디입니다.";
  168. }catch(Exception $e){
  169. $RES['CODE'] = $e->getCode();
  170. $RES['MSG'] = $e->getMessage();
  171. }
  172. echo json_encode($RES);
  173. exit;
  174. break;
  175. case "IdSearch":
  176. $RES = array('CODE'=>'9999', 'MSG'=>'');
  177. try {
  178. $nm_name = trim(avoid_crack($_POST["nm_name"]));
  179. $nm_hp = trim(avoid_crack($_POST["nm_hp"]));
  180. if(empty($nm_name)) {
  181. throw new Exception("이름을 입력하세요", "9990");
  182. }
  183. if(empty($nm_hp)) {
  184. throw new Exception("휴대폰 번호를 입력하세요", "9990");
  185. }
  186. $sql = "select * from $table_name where ds_delind='N' And nm_name = '". $nm_name . "' AND nm_hp = '". $nm_hp . "' ";
  187. // echo $sql;
  188. // exit;
  189. $res = mysql_query($sql);
  190. $col = mysql_fetch_array($res);
  191. if(empty($col['cd_user'])) {
  192. throw new Exception("입력하신 정보가 정확하지 않습니다.", "9990");
  193. }
  194. # SMS 발송
  195. # 1. 요청자에게
  196. $aligo = new Aligo();
  197. $aligo->getToken();
  198. $ALIGO_DATA = array();
  199. $ALIGO_DATA['id'] = $col['cd_userid'];
  200. $ALIGO_DATA['name'] = $col['nm_name'];
  201. $ALIGO_DATA['recv_phone'] = $col['nm_hp'];
  202. // print_r($ALIGO_DATA);
  203. // exit;
  204. $response = $aligo->send_common_find_id($ALIGO_DATA);
  205. unset($ALIGO_DATA);
  206. if($response['code'] != "0") {
  207. throw new Exception($response['message'], "4449");
  208. }
  209. $RES['CODE'] = "0000";
  210. $RES['MSG'] = "정상.";
  211. }catch(Exception $e){
  212. $RES['CODE'] = $e->getCode();
  213. $RES['MSG'] = $e->getMessage();
  214. }
  215. @mysql_close($connect);
  216. echo json_encode($RES);
  217. exit;
  218. break;
  219. case "PwdSearch":
  220. $RES = array('CODE'=>'9999', 'MSG'=>'');
  221. try {
  222. $cd_userid = trim(avoid_crack($_POST["cd_userid"]));
  223. $nm_hp = trim(avoid_crack($_POST["nm_hp"]));
  224. //소문자만 사용
  225. $cd_userid = strtolower($cd_userid);
  226. if(empty($cd_userid)) {
  227. throw new Exception("아이디를 입력하세요", "9990");
  228. }
  229. if(empty($nm_hp)) {
  230. throw new Exception("휴대폰 번호를 입력하세요", "9990");
  231. }
  232. $sql = "select * from $table_name where ds_delind='N' And cd_userid = '". $cd_userid . "' AND nm_hp = '". $nm_hp . "' ";
  233. // echo $sql;
  234. // exit;
  235. $res = mysql_query($sql);
  236. $col = mysql_fetch_array($res);
  237. if(empty($col['cd_user'])) {
  238. throw new Exception("입력하신 정보가 정확하지 않습니다.", "9990");
  239. }
  240. $new_passwd = generatePassword(8);
  241. $sql="UPDATE $table_name set nm_pass = password('".$new_passwd."') where cd_user = '{$col['cd_user']}'";
  242. // echo $sql;
  243. // exit;
  244. $result = mysql_query($sql,$connect);
  245. if(!$result) {
  246. throw new Exception("임시 비밀번호 변경에 실패 하였습니다.잠시후 다시 시도해 주세요.", "9990");
  247. }
  248. # SMS 발송
  249. # 1. 요청자에게
  250. $aligo = new Aligo();
  251. $aligo->getToken();
  252. $ALIGO_DATA = array();
  253. $ALIGO_DATA['pwd'] = $new_passwd;
  254. $ALIGO_DATA['name'] = $col['nm_name'];
  255. $ALIGO_DATA['recv_phone'] = $col['nm_hp'];
  256. // print_r($ALIGO_DATA);
  257. // exit;
  258. $response = $aligo->send_common_find_pwd($ALIGO_DATA);
  259. unset($ALIGO_DATA);
  260. if($response['code'] != "0") {
  261. throw new Exception($response['message'], "4449");
  262. }
  263. $RES['CODE'] = "0000";
  264. $RES['MSG'] = "정상.";
  265. }catch(Exception $e){
  266. $RES['CODE'] = $e->getCode();
  267. $RES['MSG'] = $e->getMessage();
  268. }
  269. @mysql_close($connect);
  270. echo json_encode($RES);
  271. exit;
  272. break;
  273. default :
  274. AlertBack("지정되지않은 요청입니다");
  275. break;
  276. }
  277. mysql_close($connect);
  278. ?>