join_proc.php 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433
  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. //소문자만 사용
  111. $cd_dealerid = strtolower($cd_dealerid);
  112. $sql = "INSERT INTO $table_name SET
  113. cd_dealerid = '$cd_dealerid'
  114. , cd_dealer_p = 0
  115. , nm_name = '$nm_name'
  116. , ds_type = 'D0'
  117. , ds_level = '1'
  118. , nm_hp = '$nm_hp'
  119. , nm_hp_01 = '$nm_hp1'
  120. , nm_hp_02 = '$nm_hp2'
  121. , nm_hp_03 = '$nm_hp3'
  122. , ds_status = 'A0'
  123. , ds_company_bp = '$ds_company_bp'
  124. , ds_branch = '$ds_branch'
  125. , nm_pass = password('".$nm_pass."')
  126. , ds_usertype = ''
  127. , nm_company = ''
  128. , nm_birth = ''
  129. , nm_tel_01 = ''
  130. , nm_tel_02 = ''
  131. , nm_tel_03 = ''
  132. , nm_fax_01 = ''
  133. , nm_fax_02 = ''
  134. , nm_fax_03 = ''
  135. , nm_email = ''
  136. , nm_zip = ''
  137. , nm_addr = ''
  138. , nm_addr_sub = ''
  139. , nm_etc_01 = ''
  140. , nm_etc_02 = ''
  141. , nm_etc_03 = ''
  142. , nm_company_biz = ''
  143. , nm_name_biz = ''
  144. , nm_no_biz = ''
  145. , nm_date_biz = ''
  146. , nm_type_biz = ''
  147. , nm_condition_biz = ''
  148. , nm_tel_biz_01 = ''
  149. , nm_tel_biz_02 = ''
  150. , nm_tel_biz_03 = ''
  151. , nm_hp_biz_01 = ''
  152. , nm_hp_biz_02 = ''
  153. , nm_hp_biz_03 = ''
  154. , nm_fax_biz_01 = ''
  155. , nm_fax_biz_02 = ''
  156. , nm_fax_biz_03 = ''
  157. , nm_email_biz = ''
  158. , nm_zip_biz = ''
  159. , nm_addr_biz = ''
  160. , nm_addr_sub_biz = ''
  161. , ds_company_bp1 = ''
  162. , ds_company_bp2 = ''
  163. , ds_company_bp3 = ''
  164. , ds_branch1 = ''
  165. , ds_branch2 = ''
  166. , ds_branch3 = ''
  167. , dt_insert = now()
  168. , nm_insert = '$cd_dealerid'
  169. , dt_update = now()
  170. , nm_update = '$cd_dealerid'
  171. , ds_delind = 'N'
  172. ";
  173. // echo $sql;
  174. // exit;
  175. if($_SERVER['REMOTE_ADDR'] == '220.86.24.199') {
  176. // exit;
  177. }
  178. $result = mysql_query($sql,$connect);
  179. $cd_dealer = mysql_insert_id();
  180. if(!$result) {
  181. throw new Exception("회원 등록처리에 실패 하였습니다.잠시후 다시 시도해 주세요.", "9990");
  182. }
  183. $sql = "UPDATE $table_name SET
  184. cd_dealer_p = '$cd_dealer'
  185. WHERE cd_dealer = '$cd_dealer'
  186. ";
  187. mysql_query($sql,$connect);
  188. $RES['CODE'] = "0000";
  189. $RES['MSG'] = "AAP 등록이 완료되었습니다.";
  190. }catch(Exception $e){
  191. $RES['CODE'] = $e->getCode();
  192. $RES['MSG'] = $e->getMessage();
  193. }
  194. @mysql_close($connect);
  195. echo json_encode($RES);
  196. exit;
  197. break;
  198. case "IdChk":
  199. $RES = array('CODE'=>'9999', 'MSG'=>'');
  200. try {
  201. //소문자만 사용
  202. $cd_dealerid = strtolower($cd_dealerid);
  203. if(strlen($cd_dealerid)<4 || strlen($cd_dealerid)>20) {
  204. throw new Exception("아이디(4~20)의 자리수가 맞지 않습니다.", "9990");
  205. }
  206. if($cd_dealerid=="userid" || $cd_dealerid=="member" || $cd_dealerid=="admin"){
  207. throw new Exception("중복된 아이디입니다. 관리자에게 문의하십시요.", "9990");
  208. }
  209. if(!preg_match("/^[a-zA-Z](?=.*[a-zA-Z])(?=.*[0-9]).{3,19}$/i", $cd_dealerid)) {
  210. // if(!preg_match("/^[a-zA-Z]+[a-zA-Z0-9]{3,19}$/i", $cd_dealerid)) {
  211. throw new Exception("아이디는 영문자로 시작하는 4~20자 영문자/숫자 조합이어야 합니다.", "9991");
  212. }
  213. $check_id=mysql_result(mysql_query("select count(*) from $table_name where cd_dealerid='$cd_dealerid'"),0,0);
  214. if($check_id > 0) {
  215. throw new Exception("이미 사용중인 아이디입니다.다시 한번 확인하세요.", "9990");
  216. }
  217. $RES['CODE'] = "0000";
  218. $RES['MSG'] = "정상.";
  219. }catch(Exception $e){
  220. $RES['CODE'] = $e->getCode();
  221. $RES['MSG'] = $e->getMessage();
  222. }
  223. @mysql_close($connect);
  224. echo json_encode($RES);
  225. exit;
  226. break;
  227. case "IdChkTest":
  228. $RES = array('CODE'=>'9999', 'MSG'=>'');
  229. try {
  230. //소문자만 사용
  231. $cd_dealerid = strtolower($cd_dealerid);
  232. if(strlen($cd_dealerid)<4 || strlen($cd_dealerid)>20) {
  233. throw new Exception("아이디(4~20)의 자리수가 맞지 않습니다.", "9990");
  234. }
  235. if($cd_dealerid=="userid" || $cd_dealerid=="member" || $cd_dealerid=="admin"){
  236. throw new Exception("중복된 아이디입니다. 관리자에게 문의하십시요.", "9990");
  237. }
  238. if(!preg_match("/^[a-zA-Z](?=.*[a-zA-Z])(?=.*[0-9]).{3,19}$/i", $cd_dealerid)) {
  239. // if(!preg_match("/^[a-zA-Z]+[a-zA-Z0-9]{3,19}$/i", $cd_dealerid)) {
  240. throw new Exception("아이디는 영문자로 시작하는 4~20자 영문자/숫자 조합이어야 합니다.", "9991");
  241. }
  242. $check_id=mysql_result(mysql_query("select count(*) from $table_name where cd_dealerid='$cd_dealerid'"),0,0);
  243. if($check_id > 0) {
  244. throw new Exception("이미 사용중인 아이디입니다.다시 한번 확인하세요.", "9990");
  245. }
  246. $RES['CODE'] = "0000";
  247. $RES['MSG'] = "정상.";
  248. }catch(Exception $e){
  249. $RES['CODE'] = $e->getCode();
  250. $RES['MSG'] = $e->getMessage();
  251. }
  252. @mysql_close($connect);
  253. echo json_encode($RES);
  254. exit;
  255. break;
  256. case "IdSearch":
  257. $RES = array('CODE'=>'9999', 'MSG'=>'');
  258. try {
  259. $nm_name = trim(avoid_crack($_POST["nm_name"]));
  260. $nm_hp = trim(avoid_crack($_POST["nm_hp"]));
  261. if(empty($nm_name)) {
  262. throw new Exception("이름을 입력하세요", "9990");
  263. }
  264. if(empty($nm_hp)) {
  265. throw new Exception("휴대폰 번호를 입력하세요", "9990");
  266. }
  267. $sql = "select * from $table_name where ds_delind='N' And nm_name = '". $nm_name . "' AND nm_hp = '". $nm_hp . "' ";
  268. // echo $sql;
  269. // exit;
  270. $res = mysql_query($sql);
  271. $col = mysql_fetch_array($res);
  272. if(empty($col['cd_dealer'])) {
  273. throw new Exception("입력하신 정보가 정확하지 않습니다.", "9990");
  274. }
  275. # SMS 발송
  276. # 1. 요청자에게
  277. $aligo = new Aligo();
  278. $aligo->getToken();
  279. $ALIGO_DATA = array();
  280. $ALIGO_DATA['id'] = $col['cd_dealerid'];
  281. $ALIGO_DATA['name'] = $col['nm_name'];
  282. $ALIGO_DATA['recv_phone'] = $col['nm_hp'];
  283. // print_r($ALIGO_DATA);
  284. // exit;
  285. $response = $aligo->send_common_find_id($ALIGO_DATA);
  286. unset($ALIGO_DATA);
  287. if($response['code'] != "0") {
  288. throw new Exception($response['message'], "4449");
  289. }
  290. $RES['CODE'] = "0000";
  291. $RES['MSG'] = "정상.";
  292. }catch(Exception $e){
  293. $RES['CODE'] = $e->getCode();
  294. $RES['MSG'] = $e->getMessage();
  295. }
  296. @mysql_close($connect);
  297. echo json_encode($RES);
  298. exit;
  299. break;
  300. case "PwdSearch":
  301. $RES = array('CODE'=>'9999', 'MSG'=>'');
  302. try {
  303. $cd_dealerid = trim(avoid_crack($_POST["cd_dealerid"]));
  304. $nm_hp = trim(avoid_crack($_POST["nm_hp"]));
  305. //소문자만 사용
  306. $cd_dealerid = strtolower($cd_dealerid);
  307. if(empty($cd_dealerid)) {
  308. throw new Exception("아이디를 입력하세요", "9990");
  309. }
  310. if(empty($nm_hp)) {
  311. throw new Exception("휴대폰 번호를 입력하세요", "9990");
  312. }
  313. $sql = "select * from $table_name where ds_delind='N' And cd_dealerid = '". $cd_dealerid . "' AND nm_hp = '". $nm_hp . "' ";
  314. // echo $sql;
  315. // exit;
  316. $res = mysql_query($sql);
  317. $col = mysql_fetch_array($res);
  318. if(empty($col['cd_dealer'])) {
  319. throw new Exception("입력하신 정보가 정확하지 않습니다.", "9990");
  320. }
  321. $new_passwd = generatePassword(8);
  322. $sql="UPDATE $table_name set nm_pass = password('".$new_passwd."') where cd_dealer = '{$col['cd_dealer']}'";
  323. // echo $sql;
  324. // exit;
  325. $result = mysql_query($sql,$connect);
  326. if(!$result) {
  327. throw new Exception("임시 비밀번호 변경에 실패 하였습니다.잠시후 다시 시도해 주세요.", "9990");
  328. }
  329. # SMS 발송
  330. # 1. 요청자에게
  331. $aligo = new Aligo();
  332. $aligo->getToken();
  333. $ALIGO_DATA = array();
  334. $ALIGO_DATA['pwd'] = $new_passwd;
  335. $ALIGO_DATA['name'] = $col['nm_name'];
  336. $ALIGO_DATA['recv_phone'] = $col['nm_hp'];
  337. // print_r($ALIGO_DATA);
  338. // exit;
  339. $response = $aligo->send_common_find_pwd($ALIGO_DATA);
  340. unset($ALIGO_DATA);
  341. if($response['code'] != "0") {
  342. throw new Exception($response['message'], "4449");
  343. }
  344. $RES['CODE'] = "0000";
  345. $RES['MSG'] = "정상.";
  346. }catch(Exception $e){
  347. $RES['CODE'] = $e->getCode();
  348. $RES['MSG'] = $e->getMessage();
  349. }
  350. @mysql_close($connect);
  351. echo json_encode($RES);
  352. exit;
  353. break;
  354. default :
  355. AlertBack("지정되지않은 요청입니다");
  356. break;
  357. }
  358. mysql_close($connect);
  359. ?>