join_proc.php 10.0 KB

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