You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

87 lines
3.6 KiB

7 years ago
  1. <?php
  2. defined('BASEPATH') OR exit('No direct script access allowed');
  3. class Contact extends WB_Controller {
  4. public function index()
  5. {
  6. $this->load->library('form_validation');
  7. $this->form_validation->set_rules('con_name',"이름","required|trim");
  8. $this->form_validation->set_rules('con_email',"이메일","required|trim|valid_email");
  9. $this->form_validation->set_rules('con_phone',"연락처","required|trim");
  10. $this->form_validation->set_rules('con_content', "문의 내용","required|trim");
  11. if( $this->form_validation->run() != FALSE )
  12. {
  13. $reurl = $this->input->post('reurl', TRUE, base_url());
  14. $complete_msg = $this->input->post('complete_msg', TRUE, '문의 작성이 완료되었습니다.');
  15. $con_name = $this->input->post('con_name', TRUE);
  16. $con_phone = $this->input->post('con_phone', TRUE);
  17. $con_email = $this->input->post('con_email', TRUE);
  18. $con_content = $this->input->post('con_content', TRUE);
  19. $extra = $this->input->post('extra', TRUE);
  20. $extra_name = $this->input->post('extra_name', TRUE);
  21. $extra_content = "";
  22. $extra_content .= "이름 : {$con_name}".PHP_EOL;
  23. $extra_content .= "연락처 : {$con_phone}".PHP_EOL;
  24. $extra_content .= "이메일 : {$con_email}".PHP_EOL;
  25. foreach($extra as $key=>$value)
  26. {
  27. $name = isset($extra_name[$key]) && $extra_name[$key] ? $extra_name[$key] : $key;
  28. $extra_content .= $name . " : " . $value . PHP_EOL;
  29. }
  30. $con_content = $extra_content . "문의 내용 : ".PHP_EOL.$con_content;
  31. $this->load->library('email');
  32. $email_config = array();
  33. if( SEND_EMAIL_SMTP_USE )
  34. {
  35. $email_config['protocol'] = "smtp";
  36. $email_config['smtp_host'] = SEND_EMAIL_SMTP_HOST;
  37. $email_config['smtp_user'] = SEND_EMAIL_SMTP_USER;
  38. $email_config['smtp_pass'] = SEND_EMAIL_SMTP_PASS;
  39. $email_config['smtp_port'] = SEND_EMAIL_SMTP_PORT;
  40. $email_config['smtp_crypto'] = SEND_EMAIL_SMTP_CRYP;
  41. }
  42. else
  43. {
  44. $email_config['protocol'] = "mail";
  45. }
  46. $this->email->initialize($email_config);
  47. $this->email->from(SEND_EMAIL, '홈페이지 문의');
  48. $this->email->to( $this->site->config('email_send_address') );
  49. $this->email->reply_to( $con_email );
  50. $this->email->subject('홈페이지 문의 메일 ['.$con_name.']');
  51. $this->email->message($con_content);
  52. if( $this->email->send() ) {
  53. alert($complete_msg, $reurl);
  54. exit;
  55. }
  56. else {
  57. alert('메일 발송 도중 오류가 발생하였습니다.');
  58. exit;
  59. }
  60. }
  61. else
  62. {
  63. // 메타태그 설정
  64. $this->site->meta_title = "문의하기"; // 이 페이지의 타이틀
  65. // $this->site->meta_description = ""; // 이 페이지의 요약 설명
  66. // $this->site->meta_keywords = ""; // 이 페이지에서 추가할 키워드 메타 태그
  67. // $this->site->meta_image = ""; // 이 페이지에서 표시할 대표이미지
  68. // 레이아웃 & 뷰파일 설정
  69. $this->theme = $this->site->get_layout();
  70. $this->view = "contact/index";
  71. $this->active = "/contact";
  72. }
  73. }
  74. }