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.

76 lines
2.4 KiB

7 years ago
7 years ago
  1. <?php
  2. class Install extends CI_Controller {
  3. private $password = "tjsrmslove0614*";
  4. function index()
  5. {
  6. $this->load->library('form_validation');
  7. $this->form_validation->set_rules('userpass', '비밀번호','required|trim');
  8. if( $this->form_validation->run() )
  9. {
  10. if( $this->input->post('userpass') != $this->password )
  11. {
  12. $this->load->helper('common');
  13. alert('비밀번호가 일치하지 않습니다.');
  14. exit;
  15. }
  16. $this->db_init();
  17. }
  18. else {
  19. $this->load->view('tools/install');
  20. }
  21. }
  22. function db_init()
  23. {
  24. $sql = file_get_contents(BASEPATH . "..". DIRECTORY_SEPARATOR . "config".DIRECTORY_SEPARATOR."wheeparam.sql");
  25. $sqls = explode(';', $sql);
  26. array_pop($sqls);
  27. // DB 기존구조 넣기
  28. $this->load->database();
  29. foreach($sqls as $statement)
  30. {
  31. $this->db->query($statement);
  32. }
  33. $this->load->helper('common');
  34. // 관리자 아이디 생성
  35. $data['mem_status'] = "Y";
  36. $data['mem_userid'] = $this->input->post('admin_id', TRUE, "admin@wheeparam.com");
  37. $data['mem_password'] = get_password_hash($this->input->post('admin_pass', TRUE, $this->password) );
  38. $data['mem_nickname'] = $this->input->post('admin_nick', TRUE, "휘파람");
  39. $data['mem_email'] = $this->input->post('admin_email', TRUE, "admin@wheeparam.com");
  40. $data['mem_gender'] = "U";
  41. $data['mem_recv_email'] = "N";
  42. $data['mem_recv_sms'] = "N";
  43. $data['mem_auth'] = 10;
  44. $data['mem_point'] = 0;
  45. $data['mem_regtime'] = date('Y-m-d H:i:s');
  46. $data['mem_regip'] = ip2long($this->input->ip_address());
  47. $data['mem_logcount'] = 0;
  48. $this->db->insert('member', $data);
  49. unset($data);
  50. // 관리자 아이디를 관리자 목록에 추가
  51. $data['mem_idx'] = $this->db->insert_id();
  52. $data['ath_type'] = "SUPER";
  53. $data['ath_key'] = "";
  54. $this->db->insert('member_auth',$data);
  55. $data['ath_type'] = 'MASTER';
  56. $this->db->insert('member_auth',$data);
  57. unset($data);
  58. // 인스톨 파일 삭제
  59. unlink( APPPATH . '..'.DIRECTORY_SEPARATOR.'config'.DIRECTORY_SEPARATOR.'no_install.php' );
  60. $this->load->helper('url');
  61. redirect( BASE_URL );
  62. }
  63. }