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.

482 lines
18 KiB

7 years ago
  1. <?php
  2. defined('BASEPATH') OR exit('No direct script access allowed');
  3. class Members extends WB_Controller {
  4. public function login(){
  5. if( $this->member->is_login() ) {
  6. alert(langs('회원/login/already'), base_url("members/info"));
  7. exit;
  8. }
  9. $form_attributes['id'] = "form-login";
  10. $form_attributes['autocomplete'] = "off";
  11. $form_attributes['name'] = "form_login";
  12. $form_attributes['data-role'] = "form-login";
  13. $form_hidden_inputs['reurl'] = set_value('reurl', $this->input->get("reurl", TRUE, base_url()));
  14. $action_url = base_url( 'admin/members/login', SSL_VERFIY ? 'https' : 'http' );
  15. $this->data['form_open'] = form_open($action_url, $form_attributes, $form_hidden_inputs);
  16. $this->data['form_close'] = form_close();
  17. $this->site->meta_title = "관리자 로그인";
  18. $this->theme = "admin";
  19. $this->theme_file = "iframe";
  20. $this->view = "members/login";
  21. }
  22. /*****************************************************************
  23. * 회원 목록
  24. *****************************************************************/
  25. public function lists()
  26. {
  27. $this->load->model('member_model');
  28. // 정보 넣기
  29. $param['page'] = $this->input->get('page', TRUE, 1);
  30. $param['page_rows'] = 20;
  31. // 회원목록 가져오기
  32. $this->data['member_list'] = $this->member_model->member_list($param);
  33. // 페이지네이션 세팅
  34. $this->load->library('paging');
  35. $this->paging->initialize(array(
  36. "page" => $param['page'],
  37. "page_rows" => $param['page_rows'],
  38. "total_rows" => $this->data['member_list']['total_count'],
  39. "fixe_nums" => 10,
  40. 'full_tag_open' => '<ul class="pagination pagination-sm">'
  41. ));
  42. $this->data['pagination'] = $this->paging->create();
  43. // 메타태그 설정
  44. $this->site->meta_title = "회원 목록"; // 이 페이지의 타이틀
  45. // 레이아웃 & 뷰파일 설정
  46. $this->theme = "admin";
  47. $this->view = "members/lists";
  48. $this->active = "members/lists";
  49. }
  50. /**
  51. * @param $mem_idx
  52. */
  53. public function info($mem_idx)
  54. {
  55. if(empty($mem_idx))
  56. {
  57. alert_modal_close('잘못된 접근입니다.');
  58. exit;
  59. }
  60. $this->data['mem'] = $this->member->get_member($mem_idx,'mem_idx');
  61. $this->theme = "admin";
  62. $this->theme_file = "iframe";
  63. $this->view = "members/info";
  64. }
  65. /**
  66. * 회원 포인트 관리
  67. * @param $mem_idx
  68. */
  69. public function point($mem_idx)
  70. {
  71. if(empty($mem_idx))
  72. {
  73. alert_modal_close('잘못된 접근입니다.');
  74. exit;
  75. }
  76. $this->load->model('member_model');
  77. $this->data['startdate'] = $param['startdate'] = $this->input->get('startdate', TRUE);
  78. $this->data['enddate'] = $param['enddate'] = $this->input->get('enddate', TRUE);
  79. $this->data['target_type'] = $this->input->get('target_type', TRUE);
  80. if( $this->data['target_type'] )
  81. {
  82. $param['where']['target_type'] = $this->data['target_type'];
  83. }
  84. // 정보 넣기
  85. $param['page'] = $this->input->get('page', TRUE, 1);
  86. $param['page_rows'] = 10;
  87. // 회원목록 가져오기
  88. $this->data['point_list'] = $this->member_model->point_list($mem_idx, $param);
  89. // 페이지네이션 세팅
  90. $this->load->library('paging');
  91. $this->paging->initialize(array(
  92. "page" => $param['page'],
  93. "page_rows" => $param['page_rows'],
  94. "total_rows" => $this->data['point_list']['total_count'],
  95. "fixe_nums" => 10,
  96. 'full_tag_open' => '<ul class="pagination pagination-sm">'
  97. ));
  98. $this->data['pagination'] = $this->paging->create();
  99. // 회원 정보
  100. $this->data['mem'] = $this->member->get_member($mem_idx,'mem_idx');
  101. // 포인트 유형
  102. $this->data['point_type'] = point_type(TRUE);
  103. $this->theme = "admin";
  104. $this->theme_file = "iframe";
  105. $this->view = "members/point";
  106. }
  107. /**
  108. * 회원 포인트 추가
  109. * @param $mem_idx
  110. */
  111. public function point_form($mem_idx)
  112. {
  113. if(empty($mem_idx))
  114. {
  115. alert_modal_close('잘못된 접근입니다.');
  116. exit;
  117. }
  118. $this->data['mem'] = $this->member->get_member($mem_idx,'mem_idx');
  119. $this->load->library('form_validation');
  120. $this->form_validation->set_rules('mem_idx', '회원번호', 'required|trim');
  121. $this->form_validation->set_rules('mpo_value', $this->site->config('point_name'), 'required|trim|numeric');
  122. $this->form_validation->set_rules('mpo_description', $this->site->config('point_name').' 내용', 'required|trim');
  123. if( $this->form_validation->run() != FALSE )
  124. {
  125. $data['mem_idx'] = $this->input->post('mem_idx', TRUE);
  126. $data['mpo_value'] = $this->input->post('mpo_value', TRUE);
  127. $data['mpo_description'] = $this->input->post('mpo_description', TRUE);
  128. $data['target_type'] = $this->input->post('target_type', TRUE);
  129. $data['mpo_regtime'] = date('Y-m-d H:i:s');
  130. if( $this->member->add_point($data['mem_idx'], $data['mpo_value'], FALSE, $data['target_type'], $data['mpo_description'],0))
  131. {
  132. alert_modal2_close('등록완료');
  133. exit;
  134. }
  135. else {
  136. alert('DB 입력도중 오류가 발생하였습니다.');
  137. exit;
  138. }
  139. }
  140. else
  141. {
  142. $this->data['mem_idx'] = $mem_idx;
  143. $this->theme = "admin";
  144. $this->theme_file = "iframe";
  145. $this->view = "members/point_form";
  146. }
  147. }
  148. /**
  149. * 포인트 관리
  150. */
  151. function points()
  152. {
  153. $this->load->model('basic_model');
  154. $param['page'] = $this->input->get('page', TRUE, 1);
  155. $param['page_rows'] = 15;
  156. $param['limit'] = TRUE;
  157. $param['join'][] = array('member', 'member.mem_idx=member_point.mem_idx','inner');
  158. $param['from'] = 'member_point';
  159. $param['order_by'] = 'mpo_idx DESC';
  160. $this->data['list'] = $this->basic_model->get_list($param);
  161. // 페이지네이션 세팅
  162. $this->load->library('paging');
  163. $this->paging->initialize(array(
  164. "page" => $param['page'],
  165. "page_rows" => $param['page_rows'],
  166. "total_rows" => $this->data['list']['total_count'],
  167. "fixe_nums" => 10,
  168. 'full_tag_open' => '<ul class="pagination pagination-sm">'
  169. ));
  170. $this->data['pagination'] = $this->paging->create();
  171. // 메타태그 설정
  172. $this->site->meta_title = $this->site->config('point_name'). " 관리";
  173. // 레이아웃 & 뷰파일 설정
  174. $this->theme = "admin";
  175. $this->view = "members/points";
  176. $this->active = "members/points";
  177. }
  178. /*****************************************************************
  179. * 회원 추가
  180. ****************************************************************/
  181. public function add()
  182. {
  183. $this->load->model('member_model');
  184. $this->load->library('form_validation');
  185. $this->form_validation->set_rules('mem_userid', "아이디", "required|trim|min_length[6]" . (USE_EMAIL_ID ? '|valid_email' :'') . '|callback_userid_check' );
  186. $this->form_validation->set_rules('mem_password', '비밀번호', 'required|trim|min_length[6]');
  187. $this->form_validation->set_rules('mem_password2', "비밀번호 확인", "required|trim|matches[mem_password]");
  188. $this->form_validation->set_rules('mem_nickname', "닉네임", "required|trim|callback_nickname_check");
  189. $this->form_validation->set_rules('mem_email', '이메일', 'required|trim|valid_email');
  190. if( $this->form_validation->run() != FALSE)
  191. {
  192. $data['mode'] = "INSERT";
  193. $data['mem_userid'] = $this->input->post('mem_userid', TRUE);
  194. $data['mem_password'] = $this->input->post('mem_password', TRUE);
  195. $data['mem_nickname'] = $this->input->post('mem_nickname', TRUE);
  196. $data['mem_email'] = $this->input->post('mem_email', TRUE);
  197. $data['mem_verfy_email'] = ( USE_EMAIL_VERFY ) ? ( $this->input->post('mem_verfy_email', TRUE) == 'Y' ? 'Y' : 'N' ) : 'Y';
  198. $data['mem_phone'] = $this->input->post('mem_phone', TRUE);
  199. $data['mem_auth'] = $this->input->post('mem_auth', TRUE);
  200. $data['mem_gender'] = $this->input->post('mem_gender', TRUE);
  201. $data['mem_recv_email'] = $this->input->post('mem_recv_email', TRUE) == 'Y' ? 'Y' : 'N';
  202. $data['mem_recv_sms'] = $this->input->post('mem_recv_sms', TRUE) == 'Y' ? 'Y' : 'N';
  203. $data['mem_password'] = get_password_hash($data['mem_password']);
  204. if( $this->member->info_process($data) )
  205. {
  206. alert('사용자 등록이 완료되었습니다.', base_url('admin/members/lists'));
  207. exit;
  208. }
  209. else {
  210. alert('등록도중 오류가 발생하였습니다.');
  211. exit;
  212. }
  213. }
  214. else
  215. {
  216. // 메타태그 설정
  217. $this->site->meta_title = "신규 회원 등록"; // 이 페이지의 타이틀
  218. // 레이아웃 & 뷰파일 설정
  219. $this->theme = "admin";
  220. $this->view = "members/add";
  221. $this->active = "members/add";
  222. }
  223. }
  224. /*****************************************************************
  225. * 폼검증 : 회원 아이디 체크
  226. ****************************************************************/
  227. public function userid_check($str)
  228. {
  229. $deny_id = explode(',', $this->site->config('deny_id'));
  230. if( in_array($str, $deny_id) )
  231. {
  232. $this->form_validation->set_message('userid_check', "{field}에 사용할 수 없는 단어입니다 : {$str}");
  233. return FALSE;
  234. }
  235. if( $member = $this->member->get_member($str, 'mem_userid') )
  236. {
  237. $this->form_validation->set_message('userid_check', "이미 사용중인 {field}입니다 : {$str}");
  238. return FALSE;
  239. }
  240. return true;
  241. }
  242. /*****************************************************************
  243. * 폼검증 : 회원 닉네임 체크
  244. ****************************************************************/
  245. public function nickname_check_pre($str)
  246. {
  247. $deny_nickname = explode(',',$this->site->config('deny_nickname'));
  248. $deny_word = explode(',', $this->site->config('deny_word'));
  249. $deny = array();
  250. foreach($deny_nickname as $d) $deny[] = trim($d);
  251. foreach($deny_word as $d) $deny[] = trim($d);
  252. if ( in_array($str, $deny) )
  253. {
  254. $this->form_validation->set_message('nickname_check_pre', "{field}에 사용할 수 없는 단어입니다 : {$str}");
  255. return FALSE;
  256. }
  257. return TRUE;
  258. }
  259. /*****************************************************************
  260. * 폼검증 : 회원 닉네임 체크 + 사용여부 체크
  261. ****************************************************************/
  262. public function nickname_check($str)
  263. {
  264. if(! $this->nickname_check_pre($str) )
  265. {
  266. return FALSE;
  267. }
  268. if( $member = $this->member->get_member($str, 'mem_nickname') )
  269. {
  270. $this->form_validation->set_message('nickname_check', "이미 사용중인 {field} 입니다 : {$str}");
  271. return FALSE;
  272. }
  273. return TRUE;
  274. }
  275. /**
  276. * 사용자 로그인 로그
  277. */
  278. public function log()
  279. {
  280. // 모델 가져오기
  281. $this->load->model('member_model');
  282. // 넘어온 검색값 정리
  283. $this->data['startdate'] = $this->input->get('startdate', TRUE, date('Y-m-d', strtotime("-1 month", time())));
  284. $this->data['enddate'] = $this->input->get('enddate', TRUE, date('Y-m-d'));
  285. $this->data['st'] = $this->input->get('st', TRUE);
  286. $this->data['sc'] = $this->input->get('sc', TRUE);
  287. if ( $this->data['st'] && $this->data['sc'] )
  288. {
  289. if( $this->data['sc'] == 'nickname' OR $this->data['sc'] == 'userid')
  290. {
  291. $param['sc'] = "member_log.mem_" . $this->data['sc'];
  292. $param['st'] = $this->data['st'];
  293. }
  294. else if ( $this->data['sc'] == 'idx' )
  295. {
  296. $param['where']['member_log.mem_idx'] = $this->data['st'];
  297. }
  298. }
  299. $param['where']['mlg_regtime >='] = $this->data['startdate'] . " 00:00:00";
  300. $param['where']['mlg_regtime <='] = $this->data['enddate'] . " 23:59:59";
  301. // 값 가져오기
  302. $param['page'] = $this->input->get('page', TRUE, 1);
  303. $param['page_rows'] = 20;
  304. $this->data['log_list'] = $this->member_model->log_list($param);
  305. // 페이지네이션 세팅
  306. $this->load->library('paging');
  307. $this->paging->initialize(array(
  308. "page" => $param['page'],
  309. "page_rows" => $param['page_rows'],
  310. "total_rows" => $this->data['log_list']['total_count'],
  311. "fixe_nums" => 10,
  312. 'full_tag_open' => '<ul class="pagination pagination-sm">'
  313. ));
  314. $this->data['pagination'] = $this->paging->create();
  315. // 메타태그 설정
  316. $this->site->meta_title = "회원 로그인 기록"; // 이 페이지의 타이틀
  317. // 레이아웃 & 뷰파일 설정
  318. $this->theme = "admin";
  319. $this->view = "members/log";
  320. $this->active = "members/log";
  321. }
  322. /**
  323. * 사용자 비밀번호 변경
  324. */
  325. public function password($mem_idx)
  326. {
  327. if(empty($mem_idx))
  328. {
  329. alert_modal_close('잘못된 접근입니다.');
  330. exit;
  331. }
  332. $this->data['mem'] = $this->member->get_member($mem_idx,'mem_idx');
  333. $this->load->library('form_validation');
  334. $this->form_validation->set_rules('mem_password', '새 비밀번호', 'required|trim|min_length[6]');
  335. $this->form_validation->set_rules('mem_password2', "새 비밀번호 확인", "required|trim|matches[mem_password]");
  336. if( $this->form_validation->run() != FALSE)
  337. {
  338. $data['mem_password'] = $this->input->post('mem_password', TRUE);
  339. $data['mem_password'] = get_password_hash($data['mem_password']);
  340. if( $this->db->where('mem_idx', $mem_idx)->set('mem_password', $data['mem_password'])->update('member') )
  341. {
  342. alert_modal_close('사용자의 비밀번호가 변경되었습니다.');
  343. exit;
  344. }
  345. else {
  346. alert('비밀번호 변경도중 오류가 발생하였습니다.');
  347. exit;
  348. }
  349. }
  350. else
  351. {
  352. // 레이아웃 & 뷰파일 설정
  353. $this->theme = "admin";
  354. $this->view = "members/password";
  355. $this->theme_file = "iframe";
  356. }
  357. }
  358. /**
  359. * 사용자 정보수정
  360. */
  361. public function modify($mem_idx)
  362. {
  363. if(empty($mem_idx))
  364. {
  365. alert_modal_close('잘못된 접근입니다.');
  366. exit;
  367. }
  368. if(! $this->data['mem'] = $this->member->get_member($mem_idx,'mem_idx'))
  369. {
  370. alert_modal_close('존재하지 않는 회원입니다.');
  371. exit;
  372. }
  373. $this->load->model('member_model');
  374. $this->load->library('form_validation');
  375. $this->form_validation->set_rules('mem_nickname', "닉네임", "required|trim|callback_nickname_check_pre");
  376. $this->form_validation->set_rules('mem_email', '이메일', 'required|trim|valid_email');
  377. if( $this->form_validation->run() != FALSE)
  378. {
  379. $data['mode'] = "MODIFY";
  380. $data['mem_idx'] = $mem_idx;
  381. $data['mem_nickname'] = $this->input->post('mem_nickname', TRUE);
  382. $data['mem_email'] = $this->input->post('mem_email', TRUE);
  383. $data['mem_verfy_email'] = ( USE_EMAIL_VERFY ) ? ( $this->input->post('mem_verfy_email', TRUE) == 'Y' ? 'Y' : 'N' ) : 'Y';
  384. $data['mem_phone'] = $this->input->post('mem_phone', TRUE);
  385. $data['mem_auth'] = $this->input->post('mem_auth', TRUE);
  386. $data['mem_gender'] = $this->input->post('mem_gender', TRUE);
  387. $data['mem_recv_email'] = $this->input->post('mem_recv_email', TRUE) == 'Y' ? 'Y' : 'N';
  388. $data['mem_recv_sms'] = $this->input->post('mem_recv_sms', TRUE) == 'Y' ? 'Y' : 'N';
  389. if( $this->member->info_process($data) )
  390. {
  391. alert_modal_close('사용자 정보수정이 완료되었습니다.');
  392. exit;
  393. }
  394. else {
  395. alert('등록도중 오류가 발생하였습니다.');
  396. exit;
  397. }
  398. }
  399. else
  400. {
  401. // 메타태그 설정
  402. $this->site->meta_title = "신규 회원 등록"; // 이 페이지의 타이틀
  403. // 레이아웃 & 뷰파일 설정
  404. $this->theme = "admin";
  405. $this->view = "members/modify";
  406. $this->theme_file = "iframe";
  407. }
  408. }
  409. }