join_proc.php 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324
  1. <?php
  2. include $_SERVER["DOCUMENT_ROOT"].'/common/lib/comm.php';
  3. include $_SERVER['DOCUMENT_ROOT'].'/common/lib/aligo.php';
  4. $table_name = "sa_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. if(!$_POST) {
  51. throw new Exception("정상적인 접근이 아닙니다.", "9999");
  52. }
  53. if(empty($cd_userid)) {
  54. throw new Exception("아이디가 없습니다.", "9998");
  55. }
  56. if(empty($nm_pass) || empty($nm_pass2)) {
  57. throw new Exception("비밀번호가 없습니다.", "9997");
  58. }
  59. if($nm_pass != $nm_pass2) {
  60. throw new Exception("입력하신 비밀번호가 일치하지 않습니다.", "9996");
  61. }
  62. if(empty($nm_name)) {
  63. throw new Exception("이름이 없습니다.", "9995");
  64. }
  65. if(empty($nm_hp) || $nm_hp == "--") {
  66. throw new Exception("휴대번호가 없습니다.", "9993");
  67. }
  68. if(empty($nm_email) || $nm_email == "@") {
  69. throw new Exception("이메일이 없습니다.", "9993");
  70. }
  71. if(strlen($cd_userid)<3 || strlen($cd_userid)>20) {
  72. throw new Exception("아이디(3~20)의 자리수가 맞지 않습니다.", "9990");
  73. }
  74. if($cd_userid=="userid" || $cd_userid=="member" || $cd_userid=="admin"){
  75. throw new Exception("중복된 아이디입니다. 관리자에게 문의하십시요.", "9990");
  76. }
  77. if(!preg_match("/^[a-zA-Z](?=.*[a-zA-Z])(?=.*[0-9]).{3,19}$/i", $cd_userid)) {
  78. // if(!preg_match("/^[a-zA-Z]+[a-zA-Z0-9]{3,19}$/i", $cd_dealerid)) {
  79. throw new Exception("아이디는 영문자로 시작하는 4~20자 영문자/숫자 조합이어야 합니다.", "9991");
  80. }
  81. $check_id=@mysql_result(mysql_query("select count(*) from $table_name where cd_userid='$cd_userid'"),0,0);
  82. if($check_id>0) {
  83. throw new Exception("이미 사용중인 아이디입니다.다시 한번 확인하세요.", "9990");
  84. }
  85. //소문자만 사용
  86. $cd_userid = strtolower($cd_userid);
  87. $sql = "INSERT INTO $table_name SET
  88. cd_userid = '$cd_userid'
  89. , nm_name = '$nm_name'
  90. , ds_type = 'A0'
  91. , ds_level = '1'
  92. , nm_hp = '$nm_hp'
  93. , nm_email = '$nm_email'
  94. , ds_company_bp = '$ds_company_bp'
  95. , ds_branch = '$ds_branch'
  96. , ds_area = '$ds_area'
  97. , ds_area_sub = '$ds_area_sub'
  98. , ds_agree1 = '$ds_agree1'
  99. , ds_agree2 = '$ds_agree2'
  100. , ds_agree3 = '$ds_agree3'
  101. , ds_agree4 = '$ds_agree4'
  102. , nm_pass = password('".$nm_pass."')
  103. , dt_insert = now()
  104. , nm_insert = '$cd_userid'
  105. , dt_update = now()
  106. , nm_update = '$cd_userid'
  107. , ds_delind = 'N'
  108. ";
  109. // echo $sql;
  110. // exit;
  111. $result = mysql_query($sql,$connect);
  112. if(!$result) {
  113. throw new Exception("회원 등록처리에 실패 하였습니다.잠시후 다시 시도해 주세요.", "9990");
  114. }
  115. $RES['CODE'] = "0000";
  116. $RES['MSG'] = "회원 등록이 완료되었습니다.";
  117. }catch(Exception $e){
  118. $RES['CODE'] = $e->getCode();
  119. $RES['MSG'] = $e->getMessage();
  120. }
  121. @mysql_close($connect);
  122. echo json_encode($RES);
  123. exit;
  124. // "nm_zip"=>$nm_zip,
  125. // "nm_addr"=>$nm_addr,
  126. // "nm_addr_sub"=>$nm_addr_sub,
  127. // "ds_status"=>$ds_status,
  128. // "nm_hp_01"=>$nm_hp_01,
  129. // "nm_hp_02"=>$nm_hp_02,
  130. // "nm_hp_03"=>$nm_hp_03,
  131. // "nm_company"=>$nm_company,
  132. // "nm_birth"=>$nm_birth,
  133. break;
  134. case "IdChk":
  135. $RES = array('CODE'=>'9999', 'MSG'=>'');
  136. try {
  137. //소문자만 사용
  138. $cd_userid = strtolower($cd_userid);
  139. if(strlen($cd_userid)<4 || strlen($cd_userid)>20) {
  140. throw new Exception("아이디(4~20)의 자리수가 맞지 않습니다.", "9990");
  141. }
  142. if($cd_userid=="userid" || $cd_userid=="member" || $cd_userid=="admin"){
  143. throw new Exception("중복된 아이디입니다. 관리자에게 문의하십시요.", "9990");
  144. }
  145. if(!preg_match("/^[a-zA-Z](?=.*[a-zA-Z])(?=.*[0-9]).{3,19}$/i", $cd_userid)) {
  146. // if(!preg_match("/^[a-zA-Z]+[a-zA-Z0-9]{3,19}$/i", $cd_dealerid)) {
  147. throw new Exception("아이디는 영문자로 시작하는 4~20자 영문자/숫자 조합이어야 합니다.", "9991");
  148. }
  149. $check_id=@mysql_result(mysql_query("select count(*) from $table_name where cd_userid='$cd_userid'"),0,0);
  150. if($check_id>0) {
  151. throw new Exception("이미 사용중인 아이디입니다.다시 한번 확인하세요.", "9990");
  152. }
  153. $RES['CODE'] = "0000";
  154. $RES['MSG'] = "정상.";
  155. }catch(Exception $e){
  156. $RES['CODE'] = $e->getCode();
  157. $RES['MSG'] = $e->getMessage();
  158. }
  159. @mysql_close($connect);
  160. echo json_encode($RES);
  161. exit;
  162. break;
  163. case "IdSearch":
  164. $RES = array('CODE'=>'9999', 'MSG'=>'');
  165. try {
  166. $nm_name = trim(avoid_crack($_POST["nm_name"]));
  167. $nm_hp = trim(avoid_crack($_POST["nm_hp"]));
  168. if(empty($nm_name)) {
  169. throw new Exception("이름을 입력하세요", "9990");
  170. }
  171. if(empty($nm_hp)) {
  172. throw new Exception("휴대폰 번호를 입력하세요", "9990");
  173. }
  174. $sql = "select * from $table_name where ds_delind='N' And nm_name = '". $nm_name . "' AND nm_hp = '". $nm_hp . "' ";
  175. // echo $sql;
  176. // exit;
  177. $res = mysql_query($sql);
  178. $col = mysql_fetch_array($res);
  179. if(empty($col['cd_user'])) {
  180. throw new Exception("입력하신 정보가 정확하지 않습니다.", "9990");
  181. }
  182. # SMS 발송
  183. # 1. 요청자에게
  184. $aligo = new Aligo();
  185. $aligo->getToken();
  186. $ALIGO_DATA = array();
  187. $ALIGO_DATA['id'] = $col['cd_userid'];
  188. $ALIGO_DATA['name'] = $col['nm_name'];
  189. $ALIGO_DATA['recv_phone'] = $col['nm_hp'];
  190. $response = $aligo->send_common_find_id($ALIGO_DATA);
  191. unset($ALIGO_DATA);
  192. if($response['code'] != "0") {
  193. throw new Exception($response['message'], "4449");
  194. }
  195. $RES['CODE'] = "0000";
  196. $RES['MSG'] = "정상.";
  197. }catch(Exception $e){
  198. $RES['CODE'] = $e->getCode();
  199. $RES['MSG'] = $e->getMessage();
  200. }
  201. @mysql_close($connect);
  202. echo json_encode($RES);
  203. exit;
  204. break;
  205. case "PwdSearch":
  206. $RES = array('CODE'=>'9999', 'MSG'=>'');
  207. try {
  208. $cd_userid = trim(avoid_crack($_POST["cd_userid"]));
  209. $nm_hp = trim(avoid_crack($_POST["nm_hp"]));
  210. //소문자만 사용
  211. $cd_userid = strtolower($cd_userid);
  212. if(empty($cd_userid)) {
  213. throw new Exception("아이디를 입력하세요", "9990");
  214. }
  215. if(empty($nm_hp)) {
  216. throw new Exception("휴대폰 번호를 입력하세요", "9990");
  217. }
  218. $sql = "select * from $table_name where ds_delind='N' And cd_userid = '". $cd_userid . "' AND nm_hp = '". $nm_hp . "' ";
  219. // echo $sql;
  220. // exit;
  221. $res = mysql_query($sql);
  222. $col = mysql_fetch_array($res);
  223. if(empty($col['cd_user'])) {
  224. throw new Exception("입력하신 정보가 정확하지 않습니다.", "9990");
  225. }
  226. $new_passwd = generatePassword(8);
  227. $sql="UPDATE $table_name set nm_pass = password('".$new_passwd."') where cd_user = '{$col['cd_user']}'";
  228. // echo $sql;
  229. // exit;
  230. $result = mysql_query($sql,$connect);
  231. if(!$result) {
  232. throw new Exception("임시 비밀번호 변경에 실패 하였습니다.잠시후 다시 시도해 주세요.", "9990");
  233. }
  234. # SMS 발송
  235. # 1. 요청자에게
  236. $aligo = new Aligo();
  237. $aligo->getToken();
  238. $ALIGO_DATA = array();
  239. $ALIGO_DATA['pwd'] = $new_passwd;
  240. $ALIGO_DATA['name'] = $col['nm_name'];
  241. $ALIGO_DATA['recv_phone'] = $col['nm_hp'];
  242. $response = $aligo->send_common_find_pwd($ALIGO_DATA);
  243. unset($ALIGO_DATA);
  244. if($response['code'] != "0") {
  245. throw new Exception($response['message'], "4449");
  246. }
  247. $RES['CODE'] = "0000";
  248. $RES['MSG'] = "정상.";
  249. }catch(Exception $e){
  250. $RES['CODE'] = $e->getCode();
  251. $RES['MSG'] = $e->getMessage();
  252. }
  253. @mysql_close($connect);
  254. echo json_encode($RES);
  255. exit;
  256. break;
  257. default :
  258. AlertBack("지정되지않은 요청입니다");
  259. break;
  260. }
  261. mysql_close($connect);
  262. ?>