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.

491 lines
18 KiB

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