join_proc.php 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397
  1. <?php
  2. include $_SERVER["DOCUMENT_ROOT"].'/common/lib/comm.php';
  3. include $_SERVER['DOCUMENT_ROOT'].'/common/lib/aligo.php';
  4. $table_name = "aap_master";
  5. $PageNo = trim(avoid_crack($_REQUEST["PageNo"]));
  6. $mode = trim(avoid_crack($_POST["mode"]));
  7. $cd_dealer = trim(avoid_crack($_POST["cd_dealer"]));
  8. $cd_dealerid = trim(avoid_crack($_POST["cd_dealerid"]));
  9. $cd_dealer_p = trim(avoid_crack($_POST["cd_dealer_p"]));
  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_name = trim(avoid_crack($_POST["nm_name"]));
  15. $nm_birth = trim(avoid_crack($_POST["nm_birth"]));
  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_01 = trim(avoid_crack($_POST["nm_hp_01"]));
  20. $nm_hp_02 = trim(avoid_crack($_POST["nm_hp_02"]));
  21. $nm_hp_03 = trim(avoid_crack($_POST["nm_hp_03"]));
  22. $nm_fax_01 = trim(avoid_crack($_POST["nm_fax_01"]));
  23. $nm_fax_02 = trim(avoid_crack($_POST["nm_fax_02"]));
  24. $nm_fax_03 = trim(avoid_crack($_POST["nm_fax_03"]));
  25. $nm_email = trim(avoid_crack($_POST["nm_email"]));
  26. $nm_zip = trim(avoid_crack($_POST["nm_zip"]));
  27. $nm_addr = trim(avoid_crack($_POST["nm_addr"]));
  28. $nm_addr_sub = trim(avoid_crack($_POST["nm_addr_sub"]));
  29. $nm_etc_01 = trim(avoid_crack($_POST["nm_etc_01"]));
  30. $nm_etc_02 = trim(avoid_crack($_POST["nm_etc_02"]));
  31. $nm_etc_03 = trim(avoid_crack($_POST["nm_etc_03"]));
  32. $ds_status = trim(avoid_crack($_POST["ds_status"]));
  33. $nm_company_biz = trim(avoid_crack($_POST["nm_company_biz"]));
  34. $nm_name_biz = trim(avoid_crack($_POST["nm_name_biz"]));
  35. $nm_no_biz = trim(avoid_crack($_POST["nm_no_biz"]));
  36. $nm_date_biz = trim(avoid_crack($_POST["nm_date_biz"]));
  37. $nm_type_biz = trim(avoid_crack($_POST["nm_type_biz"]));
  38. $nm_condition_biz = trim(avoid_crack($_POST["nm_condition_biz"]));
  39. $nm_tel_biz_01 = trim(avoid_crack($_POST["nm_tel_biz_01"]));
  40. $nm_tel_biz_02 = trim(avoid_crack($_POST["nm_tel_biz_02"]));
  41. $nm_tel_biz_03 = trim(avoid_crack($_POST["nm_tel_biz_03"]));
  42. $nm_hp_biz_01 = trim(avoid_crack($_POST["nm_hp_biz_01"]));
  43. $nm_hp_biz_02 = trim(avoid_crack($_POST["nm_hp_biz_02"]));
  44. $nm_hp_biz_03 = trim(avoid_crack($_POST["nm_hp_biz_03"]));
  45. $nm_fax_biz_01 = trim(avoid_crack($_POST["nm_fax_biz_01"]));
  46. $nm_fax_biz_02 = trim(avoid_crack($_POST["nm_fax_biz_02"]));
  47. $nm_fax_biz_03 = trim(avoid_crack($_POST["nm_fax_biz_03"]));
  48. $nm_email_biz = trim(avoid_crack($_POST["nm_email_biz"]));
  49. $nm_zip_biz = trim(avoid_crack($_POST["nm_zip_biz"]));
  50. $nm_addr_biz = trim(avoid_crack($_POST["nm_addr_biz"]));
  51. $nm_addr_sub_biz = trim(avoid_crack($_POST["nm_addr_sub_biz"]));
  52. $ds_company_bp1 = trim(avoid_crack($_POST["ds_company_bp1"]));
  53. $ds_branch1 = trim(avoid_crack($_POST["ds_branch1"]));
  54. $ds_company_bp2 = trim(avoid_crack($_POST["ds_company_bp2"]));
  55. $ds_branch2 = trim(avoid_crack($_POST["ds_branch2"]));
  56. $ds_company_bp3 = trim(avoid_crack($_POST["ds_company_bp3"]));
  57. $ds_branch3 = trim(avoid_crack($_POST["ds_branch3"]));
  58. $ds_company_bp = trim(avoid_crack($_POST["ds_company_bp"]));
  59. $ds_branch = trim(avoid_crack($_POST["ds_branch"]));
  60. $nm_area = trim(avoid_crack($_POST["nm_area"]));
  61. // $nm_area = trim(avoid_crack(implode(",",$_POST["nm_area"])));
  62. $nm_title = trim(avoid_crack($_POST["nm_title"]));
  63. $nm_file = trim(avoid_crack($_POST["nm_file"]));
  64. $nm_etc = trim(avoid_crack($_POST["nm_etc"]));
  65. $nm_deposit = trim(avoid_crack($_POST["nm_deposit"]));
  66. $dt_insert = trim(avoid_crack($_POST["dt_insert"]));
  67. $nm_insert = trim(avoid_crack($_POST["nm_insert"]));
  68. $dt_update = trim(avoid_crack($_POST["dt_update"]));
  69. $nm_update = trim(avoid_crack($_POST["nm_update"]));
  70. $ds_delind = trim(avoid_crack($_POST["ds_delind"]));
  71. // $cd_procid = $_SESSION[admin_cd_dealerid];
  72. // $PageNo = trim(avoid_crack($_POST["PageNo"]));
  73. switch($mode) {
  74. //저장하기
  75. case "Add" :
  76. $RES = array('CODE'=>'9999', 'MSG'=>'');
  77. try {
  78. if(!$_POST) {
  79. throw new Exception("정상적인 접근이 아닙니다.", "9999");
  80. }
  81. if(empty($cd_dealerid)) {
  82. throw new Exception("아이디가 없습니다.", "9998");
  83. }
  84. if(empty($nm_pass) || empty($nm_pass2)) {
  85. throw new Exception("비밀번호가 없습니다.", "9997");
  86. }
  87. if($nm_pass != $nm_pass2) {
  88. throw new Exception("입력하신 비밀번호가 일치하지 않습니다.", "9996");
  89. }
  90. if(empty($nm_name)) {
  91. throw new Exception("이름이 없습니다.", "9995");
  92. }
  93. if(empty($nm_hp) || $nm_hp == "--") {
  94. throw new Exception("휴대번호가 없습니다.", "9993");
  95. }
  96. if(strlen($cd_dealerid)<3 || strlen($cd_dealerid)>20) {
  97. throw new Exception("아이디(3~20)의 자리수가 맞지 않습니다.", "9990");
  98. }
  99. if($cd_dealerid=="userid" || $cd_dealerid=="member" || $cd_dealerid=="admin"){
  100. throw new Exception("중복된 아이디입니다. 관리자에게 문의하십시요.", "9990");
  101. }
  102. if(!preg_match("/^[a-zA-Z](?=.*[a-zA-Z])(?=.*[0-9]).{3,19}$/i", $cd_dealerid)) {
  103. // if(!preg_match("/^[a-zA-Z]+[a-zA-Z0-9]{3,19}$/i", $cd_dealerid)) {
  104. throw new Exception("아이디는 영문자로 시작하는 4~20자 영문자/숫자 조합이어야 합니다.", "9991");
  105. }
  106. $check_id=@mysql_result(mysql_query("select count(*) from $table_name where cd_dealerid='$cd_dealerid'"),0,0);
  107. if($check_id>0) {
  108. throw new Exception("이미 사용중인 아이디입니다.다시 한번 확인하세요.", "9990");
  109. }
  110. $nm_hp = preg_replace("/[^0-9]*/s", "", $nm_hp);
  111. $nm_hp = add_hyphen($nm_hp);
  112. //소문자만 사용
  113. $cd_dealerid = strtolower($cd_dealerid);
  114. $sql = "INSERT INTO $table_name SET
  115. cd_dealerid = '$cd_dealerid'
  116. , cd_dealer_p = 0
  117. , nm_name = '$nm_name'
  118. , ds_type = 'D0'
  119. , ds_level = '1'
  120. , nm_hp = '$nm_hp'
  121. , nm_hp_01 = '$nm_hp1'
  122. , nm_hp_02 = '$nm_hp2'
  123. , nm_hp_03 = '$nm_hp3'
  124. , ds_status = 'A0'
  125. , ds_company_bp = '$ds_company_bp'
  126. , ds_branch = '$ds_branch'
  127. , nm_pass = password('".$nm_pass."')
  128. , ds_usertype = ''
  129. , nm_company = ''
  130. , nm_birth = ''
  131. , nm_tel_01 = ''
  132. , nm_tel_02 = ''
  133. , nm_tel_03 = ''
  134. , nm_fax_01 = ''
  135. , nm_fax_02 = ''
  136. , nm_fax_03 = ''
  137. , nm_email = ''
  138. , nm_zip = ''
  139. , nm_addr = ''
  140. , nm_addr_sub = ''
  141. , nm_etc_01 = ''
  142. , nm_etc_02 = ''
  143. , nm_etc_03 = ''
  144. , nm_company_biz = ''
  145. , nm_name_biz = ''
  146. , nm_no_biz = ''
  147. , nm_date_biz = ''
  148. , nm_type_biz = ''
  149. , nm_condition_biz = ''
  150. , nm_tel_biz_01 = ''
  151. , nm_tel_biz_02 = ''
  152. , nm_tel_biz_03 = ''
  153. , nm_hp_biz_01 = ''
  154. , nm_hp_biz_02 = ''
  155. , nm_hp_biz_03 = ''
  156. , nm_fax_biz_01 = ''
  157. , nm_fax_biz_02 = ''
  158. , nm_fax_biz_03 = ''
  159. , nm_email_biz = ''
  160. , nm_zip_biz = ''
  161. , nm_addr_biz = ''
  162. , nm_addr_sub_biz = ''
  163. , ds_company_bp1 = ''
  164. , ds_company_bp2 = ''
  165. , ds_company_bp3 = ''
  166. , ds_branch1 = ''
  167. , ds_branch2 = ''
  168. , ds_branch3 = ''
  169. , dt_insert = now()
  170. , nm_insert = '$cd_dealerid'
  171. , dt_update = now()
  172. , nm_update = '$cd_dealerid'
  173. , ds_delind = 'N'
  174. ";
  175. // echo $sql;
  176. // exit;
  177. $result = mysql_query($sql,$connect);
  178. $cd_dealer = mysql_insert_id();
  179. if(!$result) {
  180. throw new Exception("회원 등록처리에 실패 하였습니다.잠시후 다시 시도해 주세요.", "9990");
  181. }
  182. $sql = "UPDATE $table_name SET
  183. cd_dealer_p = '$cd_dealer'
  184. WHERE cd_dealer = '$cd_dealer'
  185. ";
  186. mysql_query($sql,$connect);
  187. $RES['CODE'] = "0000";
  188. $RES['MSG'] = "AAP 등록이 완료되었습니다.";
  189. }catch(Exception $e){
  190. $RES['CODE'] = $e->getCode();
  191. $RES['MSG'] = $e->getMessage();
  192. }
  193. @mysql_close($connect);
  194. echo json_encode($RES);
  195. exit;
  196. break;
  197. case "IdChk":
  198. $RES = array('CODE'=>'9999', 'MSG'=>'');
  199. try {
  200. //소문자만 사용
  201. $cd_dealerid = strtolower($cd_dealerid);
  202. if(strlen($cd_dealerid)<4 || strlen($cd_dealerid)>20) {
  203. throw new Exception("아이디(4~20)의 자리수가 맞지 않습니다.", "9990");
  204. }
  205. if($cd_dealerid=="userid" || $cd_dealerid=="member" || $cd_dealerid=="admin"){
  206. throw new Exception("중복된 아이디입니다. 관리자에게 문의하십시요.", "9990");
  207. }
  208. if(!preg_match("/^[a-zA-Z](?=.*[a-zA-Z])(?=.*[0-9]).{3,19}$/i", $cd_dealerid)) {
  209. // if(!preg_match("/^[a-zA-Z]+[a-zA-Z0-9]{3,19}$/i", $cd_dealerid)) {
  210. throw new Exception("아이디는 영문자로 시작하는 4~20자 영문자/숫자 조합이어야 합니다.", "9991");
  211. }
  212. $check_id=mysql_result(mysql_query("select count(*) from $table_name where cd_dealerid='$cd_dealerid'"),0,0);
  213. if($check_id > 0) {
  214. throw new Exception("이미 사용중인 아이디입니다.다시 한번 확인하세요.", "9990");
  215. }
  216. $RES['CODE'] = "0000";
  217. $RES['MSG'] = "정상.";
  218. }catch(Exception $e){
  219. $RES['CODE'] = $e->getCode();
  220. $RES['MSG'] = $e->getMessage();
  221. }
  222. @mysql_close($connect);
  223. echo json_encode($RES);
  224. exit;
  225. break;
  226. case "IdSearch":
  227. $RES = array('CODE'=>'9999', 'MSG'=>'');
  228. try {
  229. $nm_name = trim(avoid_crack($_POST["nm_name"]));
  230. $nm_hp = trim(avoid_crack($_POST["nm_hp"]));
  231. if(empty($nm_name)) {
  232. throw new Exception("이름을 입력하세요", "9990");
  233. }
  234. if(empty($nm_hp)) {
  235. throw new Exception("휴대폰 번호를 입력하세요", "9990");
  236. }
  237. $nm_hp = preg_replace("/[^0-9]*/s", "", $nm_hp);
  238. $nm_hp = add_hyphen($nm_hp);
  239. $sql = "select * from $table_name where ds_delind='N' And nm_name = '". $nm_name . "' AND nm_hp = '". $nm_hp . "' ";
  240. // echo $sql;
  241. // exit;
  242. $res = mysql_query($sql);
  243. $col = mysql_fetch_array($res);
  244. if(empty($col['cd_dealer'])) {
  245. throw new Exception("입력하신 정보가 정확하지 않습니다.", "9990");
  246. }
  247. # SMS 발송
  248. # 1. 요청자에게
  249. $aligo = new Aligo();
  250. $aligo->getToken();
  251. $ALIGO_DATA = array();
  252. $ALIGO_DATA['id'] = $col['cd_dealerid'];
  253. $ALIGO_DATA['name'] = $col['nm_name'];
  254. $ALIGO_DATA['recv_phone'] = $col['nm_hp'];
  255. // print_r($ALIGO_DATA);
  256. // exit;
  257. $response = $aligo->send_common_find_id($ALIGO_DATA);
  258. unset($ALIGO_DATA);
  259. if($response['code'] != "0") {
  260. throw new Exception($response['message'], "4449");
  261. }
  262. $RES['CODE'] = "0000";
  263. $RES['MSG'] = "정상.";
  264. }catch(Exception $e){
  265. $RES['CODE'] = $e->getCode();
  266. $RES['MSG'] = $e->getMessage();
  267. }
  268. @mysql_close($connect);
  269. echo json_encode($RES);
  270. exit;
  271. break;
  272. case "PwdSearch":
  273. $RES = array('CODE'=>'9999', 'MSG'=>'');
  274. try {
  275. $cd_dealerid = trim(avoid_crack($_POST["cd_dealerid"]));
  276. $nm_hp = trim(avoid_crack($_POST["nm_hp"]));
  277. //소문자만 사용
  278. $cd_dealerid = strtolower($cd_dealerid);
  279. if(empty($cd_dealerid)) {
  280. throw new Exception("아이디를 입력하세요", "9990");
  281. }
  282. if(empty($nm_hp)) {
  283. throw new Exception("휴대폰 번호를 입력하세요", "9990");
  284. }
  285. $nm_hp = preg_replace("/[^0-9]*/s", "", $nm_hp);
  286. $nm_hp = add_hyphen($nm_hp);
  287. $sql = "select * from $table_name where ds_delind='N' And cd_dealerid = '". $cd_dealerid . "' AND nm_hp = '". $nm_hp . "' ";
  288. // echo $sql;
  289. // exit;
  290. $res = mysql_query($sql);
  291. $col = mysql_fetch_array($res);
  292. if(empty($col['cd_dealer'])) {
  293. throw new Exception("입력하신 정보가 정확하지 않습니다.", "9990");
  294. }
  295. $new_passwd = generatePassword(8);
  296. $sql="UPDATE $table_name set nm_pass = password('".$new_passwd."') where cd_dealer = '{$col['cd_dealer']}'";
  297. // echo $sql;
  298. // exit;
  299. $result = mysql_query($sql,$connect);
  300. if(!$result) {
  301. throw new Exception("임시 비밀번호 변경에 실패 하였습니다.잠시후 다시 시도해 주세요.", "9990");
  302. }
  303. # SMS 발송
  304. # 1. 요청자에게
  305. $aligo = new Aligo();
  306. $aligo->getToken();
  307. $ALIGO_DATA = array();
  308. $ALIGO_DATA['pwd'] = $new_passwd;
  309. $ALIGO_DATA['name'] = $col['nm_name'];
  310. $ALIGO_DATA['recv_phone'] = $col['nm_hp'];
  311. // print_r($ALIGO_DATA);
  312. // exit;
  313. $response = $aligo->send_common_find_pwd($ALIGO_DATA);
  314. unset($ALIGO_DATA);
  315. if($response['code'] != "0") {
  316. throw new Exception($response['message'], "4449");
  317. }
  318. $RES['CODE'] = "0000";
  319. $RES['MSG'] = "정상.";
  320. }catch(Exception $e){
  321. $RES['CODE'] = $e->getCode();
  322. $RES['MSG'] = $e->getMessage();
  323. }
  324. @mysql_close($connect);
  325. echo json_encode($RES);
  326. exit;
  327. break;
  328. default :
  329. AlertBack("지정되지않은 요청입니다");
  330. break;
  331. }
  332. mysql_close($connect);
  333. ?>