Initial import from local backup (Documents-Playground/pakerpale)

This commit is contained in:
jeonghwa
2026-07-03 05:27:47 +09:00
commit d8dab43237
1460 changed files with 134466 additions and 0 deletions

View File

@@ -0,0 +1,62 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
/**
* Api class
*/
/**
* Api 관련 controller 입니다.
*/
class Api extends MY_Controller
{
function __construct()
{
parent::__construct();
/**
* 모델을 로딩합니다
*/
$this->load->model(array('Api_error_log_model', 'Api_input_model', 'Api_list_model', 'Api_output_model'));
/**
* 라이브러리를 로딩합니다
*/
$this->load->helper(array('array'));
/**
* 라이브러리를 로딩합니다
*/
$this->load->library(array('apilib'));
}
/**
* API 실행하는 함수입니다.
*/
function run($libraryname = '')
{
if ( ! $libraryname) show_404();
$getdata = $this->Api_list_model->get_one('', '', array('api_name' => $libraryname));
if ( ! element('api_idx', $getdata)) show_404();
if ( ! element('api_use', $getdata)) show_404();
$this->load->library('apis/' . $libraryname);
if ( ! class_exists($libraryname))
{
show_404();
}
if ($this->input->method() == 'post') {
$return_type = $this->input->post('return_type');
} else {
$return_type = $this->input->get('return_type');
}
if ( $return_type != 'json' && $return_type != 'json2') $return_type = 'xml';
echo $this->apilib->callapi($getdata, $return_type);
}
}

View File

@@ -0,0 +1,87 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
/**
* Captcha class
*/
/**
* 비회원이 접근시 보여주는 captcha 에 관한 controller 입니다.
*/
class Captcha extends MY_Controller
{
function __construct()
{
parent::__construct();
/**
* 라이브러리를 로딩합니다
*/
$this->load->helper(array('captcha', 'string'));
}
/**
* 캡차 세션 생성후 보여주는 함수입니다.
*/
function show($width = '', $height = '')
{
$this->output->set_content_type('application/json');
if ( ! $width) {
$width = 150;
}
if ( ! $height) {
$height = 40;
}
$img_path = config_item('uploads_dir') . '/captcha/';
if ( ! is_dir($img_path)) {
@mkdir($img_path, 0755);
@chmod($img_path, 0755);
$file = $img_path . 'index.php';
$f = @fopen($file, 'w');
@fwrite($f, '');
@fclose($f);
@chmod($file, 0644);
}
$data = array(
'img_path' => $img_path,
'img_url' => site_url(config_item('uploads_dir') . '/captcha') . '/',
'img_width' => $width,
'img_height' => $height,
'font_size' => 15,
'font_path' => './assets/fonts/BreeSerif-Regular.ttf',
'pool' => '23456789abcdefghjkmnpqrstuvwxyzABCDEFGHJKMNPQRSTUVWXYZ',
'word_length' => '8',
'img_id' => 'captcha',
);
$cap = create_captcha($data);
$save = array(
'captcha_time' => $cap['time'],
'ip_address' => $this->input->ip_address(),
'word' => $cap['word'],
);
$this->session->set_userdata('captcha', $save);
exit(json_encode($cap));
}
/**
* 구글 캡차 생성후 보여주는 함수입니다.
*/
function recaptcha()
{
$html = '<div id="google-recaptcha">';
$html .= '<script src="https://www.google.com/recaptcha/api.js"></script>';
$html .= '<div class="g-recaptcha" data-sitekey="' . $this->configlib->item('recaptcha_sitekey') . '"></div>';
$html .= '</div">';
echo $html;
}
}

View File

@@ -0,0 +1,68 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
/**
* Download class
*/
class Download extends MY_Controller
{
/**
* 모델을 로딩합니다
*/
protected $models = array();
/**
* 헬퍼를 로딩합니다
*/
protected $helpers = array('form', 'array');
function __construct()
{
parent::__construct();
/**
* 라이브러리를 로딩합니다
*/
$this->load->library(array('querystring'));
}
/**
* 첨부파일 다운로드 하기
*/
public function downfiles($file_id = 0)
{
$file_id = (int) $file_id;
if (empty($file_id) OR $file_id < 1) {
show_404();
}
$this->load->model(array('Upload_file_model'));
$file = $this->Upload_file_model->get_one($file_id);
if ( ! element('ufi_id', $file)) {
show_404();
}
$user_id = (int) $this->userlib->item('user_id');
if ( ! $this->session->userdata('upload_file_download_' . element('ufi_id', $file))) {
$this->session->set_userdata('upload_file_download_' . element('ufi_id', $file), '1');
$this->Upload_file_model->update_plus(element('ufi_id', $file), 'ufi_download', 1);
}
$this->load->helper('download');
// Read the file's contents
$data = file_get_contents(config_item('uploads_dir') . '/files/' . element('ufi_filename', $file));
$name = element('ufi_originname', $file);
force_download($name, $data);
}
}

View File

@@ -0,0 +1,201 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
/**
* Editorfileupload class
*/
/**
* 에디터를 통해 파일을 업로드하는 controller 입니다.
*/
class Editorfileupload extends MY_Controller
{
/**
* 모델을 로딩합니다
*/
protected $models = array('Editor_image');
/**
* 헬퍼를 로딩합니다
*/
protected $helpers = array('array');
function __construct()
{
parent::__construct();
$this->load->library('upload');
}
/**
* 스마트 에디터를 통해 이미지를 업로드하는 컨트롤러입니다.
*/
public function smarteditor()
{
$this->_init();
$user_id = (int) $this->userlib->item('user_id');
$upload_path = config_item('uploads_dir') . '/editor/' . cdate('Y') . '/' . cdate('m') . '/';
if (isset($_FILES)
&& isset($_FILES['files'])
&& isset($_FILES['files']['name'])
&& isset($_FILES['files']['name'][0])) {
$uploadconfig = array(
'upload_path' => $upload_path,
'allowed_types' => 'jpg|jpeg|png|gif',
'max_size' => 10 * 1024,
'encrypt_name' => true,
);
$this->upload->initialize($uploadconfig);
$_FILES['userfile']['name'] = $_FILES['files']['name'][0];
$_FILES['userfile']['type'] = $_FILES['files']['type'][0];
$_FILES['userfile']['tmp_name'] = $_FILES['files']['tmp_name'][0];
$_FILES['userfile']['error'] = $_FILES['files']['error'][0];
$_FILES['userfile']['size'] = $_FILES['files']['size'][0];
if ($this->upload->do_upload()) {
$filedata = $this->upload->data();
$fileupdate = array(
'user_id' => $user_id,
'eim_originname' => element('orig_name', $filedata),
'eim_filename' => cdate('Y') . '/' . cdate('m') . '/' . element('file_name', $filedata),
'eim_filesize' => intval(element('file_size', $filedata) * 1024),
'eim_width' => element('image_width', $filedata) ? element('image_width', $filedata) : 0,
'eim_height' => element('image_height', $filedata) ? element('image_height', $filedata) : 0,
'eim_type' => str_replace('.', '', element('file_ext', $filedata)),
'eim_datetime' => cdate('Y-m-d H:i:s'),
'eim_ip' => $this->input->ip_address(),
);
$image_id = $this->Editor_image_model->insert($fileupdate);
$image_url = site_url(config_item('uploads_dir') . '/editor/' . cdate('Y') . '/' . cdate('m') . '/' . element('file_name', $filedata));
$info = new stdClass();
$info->oriname = element('orig_name', $filedata);
$info->name = element('file_name', $filedata);
$info->size = intval(element('file_size', $filedata) * 1024);
$info->type = 'image/' . str_replace('.', '', element('file_ext', $filedata));
$info->url = $image_url;
$info->width = element('image_width', $filedata)
? element('image_width', $filedata) : 0;
$info->height = element('image_height', $filedata)
? element('image_height', $filedata) : 0;
$return['files'][0] = $info;
exit(json_encode($return));
} else {
exit($this->upload->display_errors());
}
} elseif ($this->input->get('file') && $user_id) {
$where = array(
'user_id' => $user_id,
'eim_filename' => cdate('Y') . '/' . cdate('m') . '/' . $this->input->get('file'),
'eim_ip' => $this->input->ip_address(),
);
$image = $this->Editor_image_model->get_one('', '', $where);
if (element('eim_filename', $image)) {
unlink($upload_path . $this->input->get('file'));
$this->Editor_image_model->delete_where($where);
}
}
}
/**
* CK 에디터를 통해 이미지를 업로드하는 컨트롤러입니다.
*/
public function ckeditor()
{
$this->_init();
$user_id = (int) $this->userlib->item('user_id');
$upload_path = config_item('uploads_dir') . '/editor/' . cdate('Y') . '/' . cdate('m') . '/';
$uploadconfig = array(
'upload_path' => $upload_path,
'allowed_types' => 'jpg|jpeg|png|gif',
'max_size' => 10 * 1024,
'encrypt_name' => true,
);
if (isset($_FILES)
&& isset($_FILES['upload'])
&& isset($_FILES['upload']['name'])) {
$this->upload->initialize($uploadconfig);
$_FILES['userfile']['name'] = $_FILES['upload']['name'];
$_FILES['userfile']['type'] = $_FILES['upload']['type'];
$_FILES['userfile']['tmp_name'] = $_FILES['upload']['tmp_name'];
$_FILES['userfile']['error'] = $_FILES['upload']['error'];
$_FILES['userfile']['size'] = $_FILES['upload']['size'];
if ($this->upload->do_upload()) {
$filedata = $this->upload->data();
$fileupdate = array(
'user_id' => $user_id,
'eim_originname' => element('orig_name', $filedata),
'eim_filename' => cdate('Y') . '/' . cdate('m') . '/' . element('file_name', $filedata),
'eim_filesize' => intval(element('file_size', $filedata) * 1024),
'eim_width' => element('image_width', $filedata) ? element('image_width', $filedata) : 0,
'eim_height' => element('image_height', $filedata) ? element('image_height', $filedata) : 0,
'eim_type' => str_replace('.', '', element('file_ext', $filedata)),
'eim_datetime' => cdate('Y-m-d H:i:s'),
'eim_ip' => $this->input->ip_address(),
);
$this->Editor_image_model->insert($fileupdate);
$image_url = site_url(config_item('uploads_dir') . '/editor/' . cdate('Y') . '/' . cdate('m') . '/' . element('file_name', $filedata));
echo "<script>window.parent.CKEDITOR.tools.callFunction("
. $this->input->get('CKEditorFuncNum', null, '') . ", '"
. $image_url . "', '업로드완료');</script>";
} else {
echo $this->upload->display_errors();
}
}
}
public function _init()
{
$upload_path = config_item('uploads_dir') . '/editor/';
if (is_dir($upload_path) === false) {
mkdir($upload_path, 0707);
$file = $upload_path . 'index.php';
$f = @fopen($file, 'w');
@fwrite($f, '');
@fclose($f);
@chmod($file, 0644);
}
$upload_path .= cdate('Y') . '/';
if (is_dir($upload_path) === false) {
mkdir($upload_path, 0707);
$file = $upload_path . 'index.php';
$f = @fopen($file, 'w');
@fwrite($f, '');
@fclose($f);
@chmod($file, 0644);
}
$upload_path .= cdate('m') . '/';
if (is_dir($upload_path) === false) {
mkdir($upload_path, 0707);
$file = $upload_path . 'index.php';
$f = @fopen($file, 'w');
@fwrite($f, '');
@fclose($f);
@chmod($file, 0644);
}
}
}

View File

@@ -0,0 +1,371 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
/**
* Findaccount class
*/
/**
* 회원정보 찾기에 관련도니 controller 입니다.
*/
class Findaccount extends MY_Controller
{
/**
* 모델을 로딩합니다
*/
protected $models = array( 'User_auth_email');
/**
* 헬퍼를 로딩합니다
*/
protected $helpers = array('form', 'array', 'string');
function __construct()
{
parent::__construct();
/**
* 라이브러리를 로딩합니다
*/
$this->load->library(array('querystring', 'email'));
}
/**
* 아이디/패스워드찾기 페이지입니다
*/
public function index()
{
if ($this->userlib->is_user() !== false
&& ! (
$this->userlib->is_admin() === 'super' && $this->uri->segment(1) === config_item('uri_segment_admin')
)) {
redirect();
}
$view = array();
$view['view'] = array();
$this->load->library(array('form_validation'));
if ( ! function_exists('password_hash')) {
$this->load->helper('password');
}
/**
* 전송된 데이터의 유효성을 체크합니다
*/
$config = array();
if ($this->input->post('findtype') === 'findidpw') {
$config[] = array(
'field' => 'idpw_email',
'label' => '이메일',
'rules' => 'trim|required|valid_email|callback__existemail',
);
} elseif ($this->input->post('findtype') === 'verifyemail') {
$config[] = array(
'field' => 'verify_email',
'label' => '이메일',
'rules' => 'trim|required|valid_email|callback__verifyemail',
);
}
$this->form_validation->set_rules($config);
/**
* 유효성 검사를 하지 않는 경우, 또는 유효성 검사에 실패한 경우입니다.
* 즉 글쓰기나 수정 페이지를 보고 있는 경우입니다
*/
if ($this->form_validation->run() === false) {
} else {
if ($this->input->post('findtype') === 'findidpw') {
$mb = $this->User_model->get_by_email($this->input->post('idpw_email'));
$user_id = (int) element('user_id', $mb);
$uae_type = 3;
$vericode = array('$', '/', '.');
$verificationcode = str_replace(
$vericode,
'',
password_hash($user_id . '-' . $this->input->post('idpw_email') . '-' . random_string('alnum', 10), PASSWORD_BCRYPT)
);
$beforeauthdata = array(
'user_id' => $user_id,
'uae_type' => $uae_type,
);
$this->User_auth_email_model->delete_where($beforeauthdata);
$authdata = array(
'user_id' => $user_id,
'uae_key' => $verificationcode,
'uae_type' => $uae_type,
'uae_generate_datetime' => cdate('Y-m-d H:i:s'),
);
$this->User_auth_email_model->insert($authdata);
$verify_url = site_url('verify/resetpassword?user=' . element('user_id', $mb) . '&code=' . $verificationcode);
$searchconfig = array(
'{홈페이지명}',
'{홈페이지주소}',
'{회원명}',
'{회원이메일}',
'{메일수신여부}',
'{회원아이피}',
'{패스워드변경주소}',
);
$receive_email = element('user_receive_email', $mb) ? '동의' : '거부';
$replaceconfig = array(
$this->configlib->item('site_title'),
site_url(),
element('user_username', $mb),
element('user_email', $mb),
$receive_email,
$this->input->ip_address(),
$verify_url,
);
$replaceconfig_escape = array(
html_escape($this->configlib->item('site_title')),
site_url(),
html_escape(element('user_username', $mb)),
html_escape(element('user_email', $mb)),
$receive_email,
$this->input->ip_address(),
$verify_url,
);
$title = str_replace(
$searchconfig,
$replaceconfig,
$this->configlib->item('send_email_findaccount_user_title')
);
$content = str_replace(
$searchconfig,
$replaceconfig_escape,
$this->configlib->item('send_email_findaccount_user_content')
);
$this->email->clear(true);
$this->email->from($this->configlib->item('webmaster_email'), $this->configlib->item('webmaster_name'));
$this->email->to($this->input->post('idpw_email'));
$this->email->subject($title);
$this->email->message($content);
$this->email->send();
$view['view']['message'] = $this->input->post('idpw_email') . '로 인증메일이 발송되었습니다. <br />발송된 인증메일을 확인하신 후에 회원님의 정보 확인이 가능합니다';
} elseif ($this->input->post('findtype') === 'verifyemail') {
$mb = $this->User_model->get_by_email($this->input->post('verify_email'));
$user_id = (int) element('user_id', $mb);
$uae_type = 2;
$vericode = array('$', '/', '.');
$verificationcode = str_replace(
$vericode,
'',
password_hash($user_id . '-' . $this->input->post('verify_email') . '-' . random_string('alnum', 10), PASSWORD_BCRYPT)
);
$beforeauthdata = array(
'user_id' => $user_id,
'uae_type' => $uae_type,
);
$this->User_auth_email_model->delete_where($beforeauthdata);
$authdata = array(
'user_id' => $user_id,
'uae_key' => $verificationcode,
'uae_type' => $uae_type,
'uae_generate_datetime' => cdate('Y-m-d H:i:s'),
);
$this->User_auth_email_model->insert($authdata);
$verify_url = site_url('verify/confirmemail?user=' . element('user_id', $mb) . '&code=' . $verificationcode);
$searchconfig = array(
'{홈페이지명}',
'{홈페이지주소}',
'{회원명}',
'{회원이메일}',
'{메일수신여부}',
'{회원아이피}',
'{메일인증주소}',
);
$receive_email = element('user_receive_email', $mb) ? '동의' : '거부';
$replaceconfig = array(
$this->configlib->item('site_title'),
site_url(),
element('user_username', $mb),
element('user_email', $mb),
$receive_email,
$this->input->ip_address(),
$verify_url,
);
$replaceconfig_escape = array(
html_escape($this->configlib->item('site_title')),
site_url(),
html_escape(element('user_username', $mb)),
html_escape(element('user_email', $mb)),
$receive_email,
$this->input->ip_address(),
$verify_url,
);
$title = str_replace(
$searchconfig,
$replaceconfig,
$this->configlib->item('send_email_resendverify_user_title')
);
$content = str_replace(
$searchconfig,
$replaceconfig_escape,
$this->configlib->item('send_email_resendverify_user_content')
);
$this->email->clear(true);
$this->email->from($this->configlib->item('webmaster_email'), $this->configlib->item('webmaster_name'));
$this->email->to($this->input->post('verify_email'));
$this->email->subject($title);
$this->email->message($content);
$this->email->send();
$view['view']['message'] = $this->input->post('verify_email') . '로 인증메일이 발송되었습니다. <br />발송된 인증메일을 확인하신 후에 사이트 이용이 가능합니다';
}
}
/**
* 레이아웃을 정의합니다
*/
$layoutconfig = array(
'path' => 'findaccount',
'layout' => 'layout',
'skin' => 'findaccount',
);
$view['layout'] = $this->layoutlib->front($layoutconfig, $this->configlib->get_device_view_type());
$this->data = $view;
$this->layout = element('layout_skin_file', element('layout', $view));
$this->view = element('view_skin_file', element('layout', $view));
}
/**
* 존재하는 이메일인지 체크합니다
*/
public function _existemail($str)
{
$userinfo = $this->User_model
->get_by_email($str, 'user_id, user_email, user_denied, user_email_cert');
if ( ! element('user_id', $userinfo)) {
$this->form_validation->set_message(
'_existemail',
'존재하지 않는 이메일주소입니다'
);
return false;
}
if (element('user_denied', $userinfo)) {
$this->form_validation->set_message(
'_existemail',
'회원님의 계정은 접근이 금지되어 있습니다'
);
return false;
} elseif ($this->configlib->item('use_register_email_auth') && ! element('user_email_cert', $userinfo)) {
$this->form_validation->set_message(
'_existemail',
'회원님은 아직 이메일 인증을 받지 않으셨습니다<br> 아래 인증메일 재발송 란에서 이메일을 받아 인증해주시기 바랍니다'
);
return false;
}
return true;
}
/**
* 이메일이 실제 디비에 존재하는지 체크합니다
*/
public function _verifyemail($str)
{
if ( ! $this->configlib->item('use_register_email_auth')) {
$this->form_validation->set_message(
'_verifyemail',
'이 웹사이트는 이메일 인증 기능을 사용하고 있지 않습니다'
);
return false;
}
$userinfo = $this->User_model
->get_by_email($str, 'user_id, user_email, user_denied, user_email_cert');
if ( ! element('user_id', $userinfo)) {
$this->form_validation->set_message(
'_verifyemail',
'존재하지 않는 이메일주소입니다'
);
return false;
}
if (element('user_denied', $userinfo)) {
$this->form_validation->set_message(
'_verifyemail',
'회원님의 계정은 접근이 금지되어 있습니다'
);
return false;
}
if (element('user_email_cert', $userinfo)) {
$this->form_validation->set_message(
'_verifyemail',
'회원님의 계정은 이미 인증이 완료되어 있습니다'
);
return false;
}
return true;
}
/**
* 이메일 변경시 기존에 다른 회원에 의해 사용되고 있는 이메일인지 체크합니다
*/
public function _change_email($str)
{
if ( ! $this->configlib->item('use_register_email_auth')) {
$this->form_validation->set_message(
'_change_email',
'이 웹사이트는 이메일 인증 기능을 사용하고 있지 않습니다'
);
return false;
}
$userinfo = $this->User_model
->get_by_email($str, 'user_id, user_email, user_denied, user_email_cert');
if (element('user_id', $userinfo)) {
$this->form_validation->set_message(
'_change_email',
'이 이메일은 이미 다른 회원에 의해 사용되어지고 있는 이메일입니다'
);
return false;
}
if (element('user_denied', $userinfo)) {
$this->form_validation->set_message(
'_change_email',
'회원님의 계정은 접근이 금지되어 있습니다'
);
return false;
}
if (element('user_email_cert', $userinfo)) {
$this->form_validation->set_message(
'_change_email',
'회원님의 계정은 이미 인증이 완료되어 있습니다'
);
return false;
}
}
}

View File

@@ -0,0 +1,33 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
/**
* Gotourl class
*/
/**
* 다른 페이지로 이동시 중간에 거쳐가는 controller 입니다.
* admin 페이지에서 외부 페이이지로 이동시 이 페이지를 거쳐가면 referer 가 이 주소로 남기 때문에 admin 주소를 referer 에서 감출 수 있습니다
*/
class Gotourl extends MY_Controller
{
function __construct()
{
parent::__construct();
}
/**
* url 이동 관련 함수입니다
*/
public function index()
{
$url = $this->input->get('url');
if (empty($url)) {
$url = '/';
}
redirect($url, 'refresh');
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,229 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
/**
* Login class
*/
/**
* 로그인 페이지와 관련된 controller 입니다.
*/
class Login extends MY_Controller
{
/**
* 모델을 로딩합니다
*/
protected $models = array();
/**
* 헬퍼를 로딩합니다
*/
protected $helpers = array('form', 'array', 'string');
function __construct()
{
parent::__construct();
}
/**
* 로그인 페이지입니다
*/
public function index()
{
if ($this->userlib->is_user() !== false && ! ($this->userlib->is_admin() === 'super' && $this->uri->segment(1) === config_item('uri_segment_admin'))) {
redirect();
}
$view = array();
$view['view'] = array();
$this->load->library(array('form_validation'));
if ( ! function_exists('password_hash')) {
$this->load->helper('password');
}
$use_login_account = $this->configlib->item('use_login_account');
/**
* 전송된 데이터의 유효성을 체크합니다
*/
$config[] = array(
'field' => 'user_email',
'label' => '이메일',
'rules' => 'trim|required|valid_email',
);
$view['view']['useremail_label_text'] = '이메일';
$config[] = array(
'field' => 'user_password',
'label' => '패스워드',
'rules' => 'trim|required|min_length[4]|callback__check_id_pw[' . $this->input->post('user_email') . ']',
);
$this->form_validation->set_rules($config);
/**
* 유효성 검사를 하지 않는 경우, 또는 유효성 검사에 실패한 경우입니다.
* 즉 글쓰기나 수정 페이지를 보고 있는 경우입니다
*/
if ($this->form_validation->run() === false) {
if ($this->input->post('returnurl')) {
if (validation_errors('<div class="alert alert-warning" role="alert">', '</div>')) {
$this->session->set_flashdata(
'loginvalidationmessage',
validation_errors('<div class="alert alert-warning" role="alert">', '</div>')
);
}
$this->session->set_flashdata(
'loginuseremail',
$this->input->post('user_email')
);
redirect(urldecode($this->input->post('returnurl')));
}
/**
* 레이아웃을 정의합니다
*/
$layoutconfig = array(
'path' => 'login',
'layout' => 'layout',
'skin' => 'login',
);
$view['layout'] = $this->layoutlib->front($layoutconfig, $this->configlib->get_device_view_type());
$this->data = $view;
$this->layout = element('layout_skin_file', element('layout', $view));
$this->view = element('view_skin_file', element('layout', $view));
} else {
/**
* 유효성 검사를 통과한 경우입니다.
* 즉 데이터의 insert 나 update 의 process 처리가 필요한 상황입니다
*/
$userinfo = $this->User_model->get_by_email($this->input->post('user_email'), 'user_id, user_email');
$this->session->set_userdata(
'user_id',
element('user_id', $userinfo)
);
$site_title = $this->configlib->item('site_title');
$url_after_login = $this->configlib->item('url_after_login');
if ($url_after_login) {
$url_after_login = site_url($url_after_login);
}
if (empty($url_after_login)) {
$url_after_login = $this->input->get_post('url') ? urldecode($this->input->get_post('url')) : site_url();
}
redirect($url_after_login);
}
}
/**
* 로그인 페이지입니다
*/
public function nopage()
{
$view = array();
$view['view'] = array();
$layoutconfig = array(
'path' => 'login',
'layout' => 'layout',
'skin' => 'login_nopage',
'layout_dir' => $this->configlib->item('layout_login'),
'mobile_layout_dir' => $this->configlib->item('mobile_layout_login'),
'use_sidebar' => $this->configlib->item('sidebar_login'),
'use_mobile_sidebar' => $this->configlib->item('mobile_sidebar_login'),
'skin_dir' => $this->configlib->item('skin_login'),
'mobile_skin_dir' => $this->configlib->item('mobile_skin_login'),
);
$view['layout'] = $this->layoutlib->front($layoutconfig, $this->configlib->get_device_view_type());
$this->data = $view;
$this->layout = element('layout_skin_file', element('layout', $view));
$this->view = element('view_skin_file', element('layout', $view));
}
/**
* 로그인시 아이디와 패스워드가 일치하는지 체크합니다
*/
public function _check_id_pw($password, $useremail)
{
if ( ! function_exists('password_hash')) {
$this->load->helper('password');
}
$max_login_try_count = (int) $this->configlib->item('max_login_try_count');
$max_login_try_limit_second = (int) $this->configlib->item('max_login_try_limit_second');
$use_login_account = $this->configlib->item('use_login_account');
$userselect = 'user_id, user_password, user_denied, user_email_cert, user_is_admin';
$userinfo = $this->User_model->get_by_email($useremail, $userselect);
$hash = password_hash($password, PASSWORD_BCRYPT);
if ( ! element('user_id', $userinfo) OR ! element('user_password', $userinfo)) {
$this->form_validation->set_message(
'_check_id_pw',
'회원 아이디와 패스워드가 서로 맞지 않습니다'
);
return false;
} elseif ( ! password_verify($password, element('user_password', $userinfo))) {
$this->form_validation->set_message(
'_check_id_pw',
'회원 아이디와 패스워드가 서로 맞지 않습니다'
);
return false;
} elseif (element('user_denied', $userinfo)) {
$this->form_validation->set_message(
'_check_id_pw',
'회원님의 아이디는 접근이 금지된 아이디입니다'
);
return false;
} elseif ($this->configlib->item('use_register_email_auth') && ! element('user_email_cert', $userinfo)) {
$this->form_validation->set_message(
'_check_id_pw',
'회원님은 아직 이메일 인증을 받지 않으셨습니다'
);
return false;
}
return true;
}
/**
* 로그아웃합니다
*/
public function logout()
{
if ($this->userlib->is_user() === false) {
redirect();
}
$this->session->sess_destroy();
$url_after_logout = $this->configlib->item('url_after_logout');
if ($url_after_logout) {
$url_after_logout = site_url($url_after_logout);
}
if (empty($url_after_logout)) {
$url_after_logout = $this->input->get_post('url') ? $this->input->get_post('url') : site_url();
}
redirect($url_after_logout, 'refresh');
}
}

View File

@@ -0,0 +1,48 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
/**
* Main class
*/
/**
* 메인 페이지를 담당하는 controller 입니다.
*/
class Main extends MY_Controller
{
/**
* 모델을 로딩합니다
*/
protected $models = array();
/**
* 헬퍼를 로딩합니다
*/
protected $helpers = array('form', 'array');
function __construct()
{
parent::__construct();
/**
* 라이브러리를 로딩합니다
*/
$this->load->library(array('querystring'));
}
/**
* 전체 메인 페이지입니다
*/
public function index()
{
if ($this->userlib->is_admin()) {
redirect(admin_url());
} else if ( ! $this->userlib->item('user_id')) {
redirect(site_url('login'));
} else {
redirect(site_url('login/nopage'));
}
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,890 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
/**
* Social class
*/
/**
* 소셜로그인 관련 controller 입니다.
*/
class Social extends MY_Controller
{
/**
* 모델을 로딩합니다
*/
protected $models = array('Social', 'Social_meta');
/**
* 헬퍼를 로딩합니다
*/
protected $helpers = array('form', 'array');
public $socialtype = array(
'facebook' => '페이스북',
'twitter' => '트위터',
'google' => '구글',
'naver' => '네이버',
'kakao' => '카카오',
);
function __construct()
{
parent::__construct();
/**
* 라이브러리를 로딩합니다
*/
$this->load->library(array('querystring', 'email'));
if ( ! $this->configlib->item('use_sociallogin')) {
alert_close('이 웹사이트는 소셜 로그인 기능을 지원하고 있지 않습니다.');
}
}
/**
* 페이스북 연동 함수입니다
*/
public function facebook_login()
{
if ( ! $this->configlib->item('use_sociallogin_facebook')) {
alert_close('이 웹사이트는 페이스북 로그인 기능을 지원하고 있지 않습니다.');
}
require_once FCPATH . 'plugin/social/libraries/Facebook/autoload.php';
$fb = new Facebook\Facebook([
'app_id' => $this->configlib->item('facebook_app_id'),
'app_secret' => $this->configlib->item('facebook_secret'),
'default_graph_version' => 'v2.2',
]);
$helper = $fb->getRedirectLoginHelper();
try {
$accessToken = $helper->getAccessToken();
if (empty($accessToken)) {
$permissions = ['email', 'public_profile']; // Optional permissions
$loginUrl = $helper->getLoginUrl(site_url('social/facebook_login'), $permissions);
redirect($loginUrl);
}
} catch(Facebook\Exceptions\FacebookResponseException $e) {
// When Graph returns an error
echo 'Graph returned an error: ' . $e->getMessage();
exit;
} catch(Facebook\Exceptions\FacebookSDKException $e) {
// When validation fails or other local issues
echo 'Facebook SDK returned an error: ' . $e->getMessage();
exit;
}
try {
// Returns a `Facebook\FacebookResponse` object
$response = $fb->get('/me?fields=id,name,first_name,last_name,link,gender,locale,timezone,updated_time,verified,email', $accessToken->getValue());
} catch(Facebook\Exceptions\FacebookResponseException $e) {
echo 'Graph returned an error: ' . $e->getMessage();
exit;
} catch(Facebook\Exceptions\FacebookSDKException $e) {
echo 'Facebook SDK returned an error: ' . $e->getMessage();
exit;
}
$userinfo = $response->getGraphUser();
$facebook_id = $userinfo->getProperty('id');
if ( ! $userinfo->getProperty('name')) {
alert_close('이름 정보를 확인할 수 없어 로그인할 수 없습니다');
}
$socialdata = array(
'name' => $userinfo->getProperty('name'),
'first_name' => $userinfo->getProperty('first_name'),
'last_name' => $userinfo->getProperty('last_name'),
'email' => $userinfo->getProperty('email'),
'link' => $userinfo->getProperty('link'),
'gender' => $userinfo->getProperty('gender'),
'locale' => $userinfo->getProperty('locale'),
'timezone' => $userinfo->getProperty('timezone'),
'update_datetime' => cdate('Y-m-d H:i:s'),
'ip_address' => $this->input->ip_address(),
);
$this->Social_model->save('facebook', $facebook_id, $socialdata);
$this->_common_login('facebook', $facebook_id);
}
/**
* 트위터 연동 함수입니다
*/
public function twitter_login()
{
if ( ! $this->configlib->item('use_sociallogin_twitter')) {
alert_close('이 웹사이트는 트위터 로그인 기능을 지원하고 있지 않습니다.');
}
require_once FCPATH . 'plugin/social/libraries/twitter/twitteroauth.php';
if ( ! $this->input->get_post('oauth_token')
OR $this->session->userdata('twitter_oauth_token') !== $this->input->get_post('oauth_token')) {
$this->session->unset_userdata('twitter_oauth_token');
$this->session->unset_userdata('twitter_oauth_token_secret');
}
if ( ! $this->session->userdata('twitter_oauth_token')) {
$connection = new TwitterOAuth(
$this->configlib->item('twitter_consumer_key'),
$this->configlib->item('twitter_consumer_secret')
);
$request_token = $connection->getRequestToken(site_url('social/twitter_login'));
$token = element('oauth_token', $request_token);
$this->session->set_userdata(
'twitter_oauth_token',
$token
);
$this->session->set_userdata(
'twitter_oauth_token_secret',
element('oauth_token_secret', $request_token)
);
if ((string) $connection->http_code === '200') {
$url = $connection->getAuthorizeURL($token);
redirect($url);
} else {
alert_close('트위터에 접속할 수 없습니다');
}
} else {
$connection = new TwitterOAuth(
$this->configlib->item('twitter_consumer_key'),
$this->configlib->item('twitter_consumer_secret'),
$this->session->userdata('twitter_oauth_token'),
$this->session->userdata('twitter_oauth_token_secret')
);
$this->session->unset_userdata('twitter_oauth_token');
$this->session->unset_userdata('twitter_oauth_token_secret');
$twitter_access_token = $connection->getAccessToken($this->input->get_post('oauth_verifier', null, ''));
$this->session->userdata('twitter_access_token', $twitter_access_token);
if ((string) $connection->http_code === '200') {
$userinfo = $connection->get('account/verify_credentials');
$twitter_id = $userinfo->id;
if ( ! $userinfo->name OR ! $userinfo->screen_name) {
$this->session->unset_userdata('twitter_access_token');
alert_close('이름 정보를 확인할 수 없어 로그인할 수 없습니다');
}
$socialdata = array(
'name' => $userinfo->name,
'screen_name' => $userinfo->screen_name,
'url' => $userinfo->url,
'lang' => $userinfo->lang,
'description' => $userinfo->description,
'location' => $userinfo->location,
'url' => $userinfo->url,
'followers_count' => $userinfo->followers_count,
'friends_count' => $userinfo->friends_count,
'listed_count' => $userinfo->listed_count,
'created_at' => $userinfo->created_at,
'lang' => $userinfo->lang,
'following' => $userinfo->following,
'update_datetime' => cdate('Y-m-d H:i:s'),
'ip_address' => $this->input->ip_address(),
);
$this->Social_model->save('twitter', $twitter_id, $socialdata);
$this->_common_login('twitter', $twitter_id);
} else {
alert_close('잘못된 접근입니다');
}
}
}
/**
* 구글 연동 함수입니다
*/
public function google_login()
{
if ( ! $this->configlib->item('use_sociallogin_google')) {
alert_close('이 웹사이트는 구글 로그인 기능을 지원하고 있지 않습니다.');
}
require_once FCPATH . 'plugin/social/libraries/google/autoload.php';
$client_id = $this->configlib->item('google_client_id');
$client_secret = $this->configlib->item('google_client_secret');
$redirect_uri = site_url('social/google_login');
$client = new Google_Client();
$client->setClientId($client_id);
$client->setClientSecret($client_secret);
$client->setRedirectUri($redirect_uri);
$client->setScopes('email');
$client->addScope('profile');
$plus = new Google_Service_Oauth2($client);
/************************************************
If we have a code back from the OAuth 2.0 flow,
we need to exchange that with the authenticate()
function. We store the resultant access token
bundle in the session, and redirect to ourself.
************************************************/
if ($this->input->get('code')) {
$client->authenticate($this->input->get('code'));
$this->session->set_userdata(
'google_access_token',
$client->getAccessToken()
);
redirect(current_url());
}
/************************************************
If we have an access token, we can make
requests, else we generate an authentication URL.
************************************************/
if ($this->session->userdata('google_access_token')) {
$client->setAccessToken($this->session->userdata('google_access_token'));
} else {
$authUrl = $client->createAuthUrl();
redirect($authUrl);
}
/************************************************
If we're signed in we can go ahead and retrieve
the ID token, which is part of the bundle of
data that is exchange in the authenticate step
- we only need to do a network call if we have
to retrieve the Google certificate to verify it,
and that can be cached.
************************************************/
if ($client->getAccessToken()) {
$this->session->set_userdata(
'google_access_token',
$client->getAccessToken()
);
$token_data = $client->verifyIdToken()->getAttributes();
}
if (strpos($client_id, 'googleusercontent') === false) {
alert_close('구글 API 정보가 제대로 입력되지 않았습니다');
}
if (isset($token_data)) {
$google_id = element('sub', element('payload', $token_data));
$userinfo = $plus->userinfo->get();
if ( ! $userinfo->name) {
$this->session->unset_userdata('google_access_token');
alert_close('이름 정보를 확인할 수 없어 로그인할 수 없습니다');
}
$socialdata = array(
'email' => $userinfo->email,
'familyName' => $userinfo->familyName,
'givenName' => $userinfo->givenName,
'name' => $userinfo->name,
'gender' => $userinfo->gender,
'link' => $userinfo->link,
'locale' => $userinfo->locale,
'picture' => $userinfo->picture,
'update_datetime' => cdate('Y-m-d H:i:s'),
'ip_address' => $this->input->ip_address(),
);
$this->Social_model->save('google', $google_id, $socialdata);
$this->_common_login('google', $google_id);
} else {
alert_close('잘못된 접근입니다');
}
}
/**
* 네이버 연동 함수입니다
*/
public function naver_login()
{
if ( ! $this->configlib->item('use_sociallogin_naver')) {
alert_close('이 웹사이트는 네이버 로그인 기능을 지원하고 있지 않습니다.');
}
if ($this->session->userdata('naver_access_token')) {
$url = 'https://apis.naver.com/nidlogin/nid/getUserProfile.xml';
$ch = curl_init();
curl_setopt ($ch, CURLOPT_URL, $url);
curl_setopt ($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt ($ch, CURLOPT_SSLVERSION, 1);
curl_setopt ($ch, CURLOPT_HEADER, 0);
curl_setopt ($ch, CURLOPT_HTTPHEADER, array('Authorization: Bearer ' . $this->session->userdata('naver_access_token')));
curl_setopt ($ch, CURLOPT_POST, 0);
curl_setopt ($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt ($ch, CURLOPT_TIMEOUT, 30);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
$result = curl_exec($ch);
curl_close($ch);
$xml = simplexml_load_string($result);
$naver_id = (string) $xml->response->enc_id;
$email = (string) $xml->response->email;
$username = (string) $xml->response->nickname;
$profile_image = (string) $xml->response->profile_image;
$age = (string) $xml->response->age;
$gender = (string) $xml->response->gender;
$id = (string) $xml->response->id;
$name = (string) $xml->response->name;
$birthday = (string) $xml->response->birthday;
if (empty($username)) {
$this->session->unset_userdata('naver_access_token');
alert_close('이름 정보를 확인할 수 없어 로그인할 수 없습니다');
}
$socialdata = array(
'email' => $email,
'username' => $username,
'profile_image' => $profile_image,
'age' => $age,
'gender' => $gender,
'id' => $id,
'name' => $name,
'birthday' => $birthday,
'update_datetime' => cdate('Y-m-d H:i:s'),
'ip_address' => $this->input->ip_address(),
);
$this->Social_model->save('naver', $naver_id, $socialdata);
$this->_common_login('naver', $naver_id);
}
if ($this->input->get('code')) {
$url = 'https://nid.naver.com/oauth2.0/token';
$url.= sprintf("?client_id=%s&client_secret=%s&grant_type=authorization_code&state=%s&code=%s",
$this->configlib->item('naver_client_id'), $this->configlib->item('naver_client_secret'), $this->input->get('state', null, ''), $this->input->get('code'));
$ch = curl_init();
curl_setopt ($ch, CURLOPT_URL, $url);
curl_setopt ($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt ($ch, CURLOPT_SSLVERSION,1);
curl_setopt ($ch, CURLOPT_HEADER, 0);
curl_setopt ($ch, CURLOPT_POST, 0);
curl_setopt ($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt ($ch, CURLOPT_TIMEOUT, 30);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
$result = curl_exec($ch);
curl_close($ch);
$json = json_decode($result, true);
if (element('access_token', $json)) {
$this->session->set_userdata(
'naver_access_token',
element('access_token', $json)
);
echo '<script type="text/javascript">location.reload()</script>';
exit;
} else {
alert_close('로그인에 실패하였습니다');
}
}
if ($this->input->get('state')) {
if ($this->input->get('state') === $this->session->userdata('naver_state')) {
return RESPONSE_SUCCESS;
} else {
return RESPONSE_UNAUTHORIZED;
}
exit;
}
if ( ! $this->session->userdata('naver_access_token')) {
$this->load->helper('string');
$state = random_string('alnum', 50);
$this->session->set_userdata('naver_state', $state);
$url = 'https://nid.naver.com/oauth2.0/authorize';
$url.= sprintf("?client_id=%s&response_type=code&redirect_uri=%s&state=%s",
$this->configlib->item('naver_client_id'), urlencode(site_url('social/naver_login')), $state);
redirect($url);
}
}
/**
* 카카오 연동 함수입니다
*/
public function kakao_login()
{
if ( ! $this->configlib->item('use_sociallogin_kakao')) {
alert_close('이 웹사이트는 카카오 로그인 기능을 지원하고 있지 않습니다.');
}
if ($this->session->userdata('kakao_access_token')) {
$url = 'https://kapi.kakao.com/v1/user/me';
$ch = curl_init();
curl_setopt ($ch, CURLOPT_URL, $url);
curl_setopt ($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt ($ch, CURLOPT_SSLVERSION, 1);
curl_setopt ($ch, CURLOPT_HEADER, 0);
curl_setopt ($ch, CURLOPT_HTTPHEADER, array('Authorization: Bearer ' . $this->session->userdata('kakao_access_token')));
curl_setopt ($ch, CURLOPT_POST, 0);
curl_setopt ($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt ($ch, CURLOPT_TIMEOUT, 30);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
$result = curl_exec($ch);
curl_close($ch);
$json = json_decode($result, true);
$kakao_id = element('id', $json);
$username = element('nickname', element('properties', $json));
$profile_image = element('profile_image', element('properties', $json));
$thumbnail_image = element('thumbnail_image', element('properties', $json));
if (empty($username)) {
$this->session->unset_userdata('kakao_access_token');
alert_close('이름 정보를 확인할 수 없어 로그인할 수 없습니다');
}
$socialdata = array(
'username' => $username,
'profile_image' => $profile_image,
'thumbnail_image' => $thumbnail_image,
'update_datetime' => cdate('Y-m-d H:i:s'),
'ip_address' => $this->input->ip_address(),
);
$this->Social_model->save('kakao', $kakao_id, $socialdata);
$this->_common_login('kakao', $kakao_id);
}
if ($this->input->get('code')) {
$url = 'https://kauth.kakao.com/oauth/token';
$url.= sprintf("?client_id=%s&grant_type=authorization_code&redirect_uri=%s&code=%s",
$this->configlib->item('kakao_client_id'), urlencode(site_url('social/kakao_login')), $this->input->get('code'));
$ch = curl_init();
curl_setopt ($ch, CURLOPT_URL, $url);
curl_setopt ($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt ($ch, CURLOPT_SSLVERSION,1);
curl_setopt ($ch, CURLOPT_HEADER, 0);
curl_setopt ($ch, CURLOPT_POST, 0);
curl_setopt ($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt ($ch, CURLOPT_TIMEOUT, 30);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
$result = curl_exec($ch);
curl_close($ch);
$json = json_decode($result, true);
if (element('access_token', $json)) {
$this->session->set_userdata(
'kakao_access_token',
element('access_token', $json)
);
echo '<script type="text/javascript">location.reload()</script>';
exit;
} else {
alert_close('로그인에 실패하였습니다');
}
}
if ( ! $this->session->userdata('kakao_access_token')) {
$url = 'https://kauth.kakao.com/oauth/authorize';
$url.= sprintf("?client_id=%s&response_type=code&redirect_uri=%s",
$this->configlib->item('kakao_client_id'), urlencode(site_url('social/kakao_login')));
redirect($url);
}
}
/**
* 소셜 연동 해제 함수입니다
*/
public function social_connect_off($stype)
{
if ($this->userlib->is_user() === false) {
$result = array('error' => '로그인 후 이용해주세요.');
exit(json_encode($result));
}
if (empty($stype)) {
$result = array('error' => '잘못된 접근입니다');
exit(json_encode($result));
}
if ($stype !== 'facebook' && $stype !== 'twitter' && $stype !== 'google' && $stype !== 'naver' && $stype !== 'kakao') {
$result = array('error' => '잘못된 접근입니다');
exit(json_encode($result));
}
$user_id = (int) $this->userlib->item('user_id');
/**
* Validation 라이브러리를 가져옵니다
*/
$this->load->library('form_validation');
/**
* 전송된 데이터의 유효성을 체크합니다
*/
$config = array(
array(
'field' => 'is_submit',
'label' => '전송',
'rules' => 'trim|required',
),
);
$this->form_validation->set_rules($config);
/**
* 유효성 검사를 하지 않는 경우, 또는 유효성 검사에 실패한 경우입니다.
*/
if ($this->form_validation->run() === false) {
$result = array('error' => '올바른 방법으로 접근하여주세요');
exit(json_encode($result));
} else {
$metadata = '';
switch ($stype) {
case 'facebook':
$metadata = array('facebook_id' => '');
break;
case 'twitter':
$metadata = array('twitter_id' => '');
break;
case 'google':
$metadata = array('google_id' => '');
break;
case 'naver':
$metadata = array('naver_id' => '');
break;
case 'kakao':
$metadata = array('kakao_id' => '');
break;
}
if ($metadata) {
$this->Social_meta_model->save($user_id, $metadata);
}
$result = array('success' => '연동이 해제되었습니다.');
exit(json_encode($result));
}
}
public function _common_login($social_type = '', $social_id = '')
{
if (empty($social_type)) {
return;
}
if (empty($social_id)) {
return;
}
if ( ! element($social_type, $this->socialtype)) {
return;
}
if ($this->userlib->is_user()) {
// 이미 로그인 한 상태에서 소셜로그인을 추가로 진행한 상황
$user_id = $this->Social_meta_model
->get_user_id_by_social($social_type, $social_id);
if ($user_id) {
if ((int) $user_id === (int) $this->userlib->item('user_id')) {
// 나의 계정과 같으므로, 고의로 접근한 경우임
// 별다른 액션을 취할 것 없음
} else {
// 다른 회원 아이디에 연결된 계정으로 로그인 시도함
alert_close('연동하고자 하는 ' . element($social_type, $this->socialtype) . ' 계정은 이미 다른 아이디에 연결되어있습니다. 연동을 원하시면 연결되어 있는 다른 아이디에서 ' . element($social_type, $this->socialtype) . ' 연동을 제거하신 후에 이곳에서 다시 연동하여주세요');
}
} else {
// 연결된 계정 없었음, 처음 연동하는 경우임
$metadata = array(
$social_type . '_id' => $social_id,
);
$this->Social_meta_model
->save($this->userlib->item('user_id'), $metadata);
}
$this->_connected_close($social_type);
} else {
$user_id = $this->Social_meta_model
->get_user_id_by_social($social_type, $social_id);
$userselect = 'user_id, user_password, user_denied, user_email_cert, user_is_admin';
$userinfo = $this->User_model->get_by_id($user_id, $userselect);
if ( ! element('user_id', $userinfo)) {
$this->Social_meta_model->delete_where(array('user_id' => $user_id));
$user_id = '';
}
if (element('user_denied', $userinfo)) {
alert_close('회원님의 아이디는 접근이 금지되어 있습니다.');
}
if ($user_id) {
// 이미 회원정보를 가지고 있는 상황에서 소셜로그인을 진행한 상황
$this->session->set_userdata('user_id', $user_id);
$url_after_login = $this->configlib->item('url_after_login');
if ($url_after_login) {
$url_after_login = site_url($url_after_login);
}
echo '<meta http-equiv="content-type" content="text/html; charset=' . config_item('charset') . '">';
echo '<script type="text/javascript"> window.close();';
if ($url_after_login) {
echo 'window.opener.document.location.href = "' . $url_after_login . '";';
} else {
echo 'window.opener.location.reload();';
}
echo '</script>';
exit;
} else {
// 비회원이 소셜로그인을 처음 진행하는 상황
if ($this->configlib->item('use_register_block')) {
alert_close('현재 이 사이트는 회원가입이 금지되어 있습니다.');
}
$socialwhere = array(
'soc_type' => $social_type,
'soc_account_id' => $social_id,
);
$socialinfo = '';
$socialdata = $this->Social_model->get('', '', $socialwhere);
if ($socialdata) {
foreach ($socialdata as $skey => $sval) {
$socialinfo[$sval['soc_key']] = $sval['soc_value'];
}
}
$username = '';
$user_id = '';
if ($social_type === 'facebook') {
$username = element('name', $socialinfo);
$username = preg_replace('/\s+/', '', $username);
if (element('email', $socialinfo)) {
$user_id = '-social_' . strtolower(substr(element('email', $socialinfo), 0, strpos(element('email', $socialinfo), '@')));
} else {
$user_id = '-social_' . $social_id;
}
} elseif ($social_type === 'twitter') {
$username = element('name', $socialinfo);
$username = preg_replace('/\s+/', '', $username);
if (element('screen_name', $socialinfo)) {
$user_id = '-social_' . strtolower(element('screen_name', $socialinfo));
} else {
$user_id = '-social_' . $social_id;
}
} elseif ($social_type === 'google') {
$username = element('name', $socialinfo);
$username = preg_replace('/\s+/', '', $username);
if (element('email', $socialinfo)) {
$user_id = '-social_' . strtolower(substr(element('email', $socialinfo), 0, strpos(element('email', $socialinfo), '@')));
} else {
$user_id = '-social_' . $social_id;
}
} elseif ($social_type === 'naver') {
$username = element('username', $socialinfo) ? element('username', $socialinfo) : element('name', $socialinfo);
$username = preg_replace('/\s+/', '', $username);
if (element('email', $socialinfo)) {
$user_id = '-social_' . strtolower(substr(element('email', $socialinfo), 0, strpos(element('email', $socialinfo), '@')));
} else {
$user_id = '-social_' . $social_id;
}
} elseif ($social_type === 'kakao') {
$username = element('username', $socialinfo);
$username = preg_replace('/\s+/', '', $username);
$user_id = '-social_' . $social_id;
}
if (empty($username)) {
$username = '사용자';
}
$username_origin = $username;
$k = 1;
while (true) {
$good = true;
if (preg_match("/[\,]?{$username}/i", $this->configlib->item('denied_username_list'))) {
$good = false;
}
if ($good) {
$countwhere = array(
'user_username' => $username,
);
$row = $this->User_model->count_by($countwhere);
if ($row > 0) {
$good = false;
}
}
if ($good) {
$countwhere = array(
'user_username' => $username,
);
$row = $this->User_model->count_by($countwhere);
if ($row > 0) {
$good = false;
}
}
if ($good) {
break;
}
$username = $username_origin . $k;
$k++;
}
$insertdata = array();
$insertdata['user_username'] = $username;
$insertdata['user_register_datetime'] = cdate('Y-m-d H:i:s');
$insertdata['user_register_ip'] = $this->input->ip_address();
$insertdata['user_lastlogin_datetime'] = cdate('Y-m-d H:i:s');
$insertdata['user_lastlogin_ip'] = $this->input->ip_address();
$user_id = $this->User_model->insert($insertdata);
$searchconfig = array(
'{홈페이지명}',
'{홈페이지주소}',
'{회원명}',
'{회원이메일}',
'{메일수신여부}',
'{쪽지수신여부}',
'{문자수신여부}',
'{회원아이피}',
);
$user_username = $username;
$replaceconfig = array(
$this->configlib->item('site_title'),
site_url(),
$user_username,
$this->input->ip_address(),
);
$replaceconfig_escape = array(
html_escape($this->configlib->item('site_title')),
site_url(),
html_escape($user_username),
$this->input->ip_address(),
);
$emailsendlistadmin = array();
$superadminlist = '';
if ($this->configlib->item('send_email_register_admin')) {
$mselect = 'user_id, user_email, user_username, user_phone';
$superadminlist = $this->User_model->get_superadmin_list($mselect);
}
if ($this->configlib->item('send_email_register_admin') && $superadminlist) {
foreach ($superadminlist as $key => $value) {
$emailsendlistadmin[$value['user_id']] = $value;
}
}
if ($emailsendlistadmin) {
$title = str_replace(
$searchconfig,
$replaceconfig,
$this->configlib->item('send_email_register_admin_title')
);
$content = str_replace(
$searchconfig,
$replaceconfig_escape,
$this->configlib->item('send_email_register_admin_content')
);
foreach ($emailsendlistadmin as $akey => $aval) {
$this->email->clear(true);
$this->email->from($this->configlib->item('webmaster_email'), $this->configlib->item('webmaster_name'));
$this->email->to(element('user_email', $aval));
$this->email->subject($title);
$this->email->message($content);
$this->email->send();
}
}
$metadata = array(
$social_type . '_id' => $social_id,
);
$this->Social_meta_model->save($user_id, $metadata);
$this->session->set_userdata('user_id', $user_id);
$url_after_login = $this->configlib->item('url_after_login');
if ($url_after_login) {
$url_after_login = site_url($url_after_login);
}
echo '<meta http-equiv="content-type" content="text/html; charset=' . config_item('charset') . '">';
echo '<script type="text/javascript"> window.close();';
if ($url_after_login) {
echo 'window.opener.document.location.href = "' . $url_after_login . '";';
} else {
echo 'window.opener.location.reload();';
}
echo '</script>';
exit;
}
}
}
public function _connected_close($stype)
{
echo '<meta http-equiv="content-type" content="text/html; charset=' . config_item('charset') . '">';
echo '<script type="text/javascript"> window.close();window.opener.social_connect_on_done("' . $stype . '");</script>';
exit;
}
}

View File

@@ -0,0 +1,94 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
/**
* Userappi class
*/
/**
* 회원정보를 저장하는 클래스입니다.
*/
class Userapi extends MY_Controller
{
protected $available_keys;
public function __construct()
{
parent::__construct();
$this->available_keys = [
'admin-skin',
'admin-layout-fixed',
'admin-layout-layout-boxed',
'admin-layout-sidebar-collapse',
'admin-layout-control-sidebar-open',
'admin-layout-sidebarskin',
];
}
/**
* get user info
*/
public function getuserinfo($key = '')
{
/**
* only login user can access
*/
if (!$this->userlib->is_user()) {
return;
}
if ($this->input->method() != 'post') {
return;
}
if (!in_array($key, $this->available_keys)) {
return;
}
if ($value = $this->userlib->item($key)) {
echo $value;
}
}
/**
* set user info
*/
public function setuserinfo($key = '', $value = '')
{
/**
* only login user can access
*/
if (!$this->userlib->is_user()) {
return;
}
if ($this->input->method() != 'post') {
return;
}
if (!$key) {
return;
}
if (!in_array($key, $this->available_keys)) {
return;
}
$savedata = [$key => $value];
$this->User_meta_model->save($this->userlib->item('user_id'), $savedata);
if ($value = $this->userlib->item($key)) {
return $value;
}
return;
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,304 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
/**
* Verify class
*/
/**
* 이메일 인증 시 필요한 controller 입니다.
*/
class Verify extends MY_Controller
{
/**
* 모델을 로딩합니다
*/
protected $models = array('User_auth_email');
/**
* 헬퍼를 로딩합니다
*/
protected $helpers = array('form', 'array');
function __construct()
{
parent::__construct();
/**
* 라이브러리를 로딩합니다
*/
$this->load->library(array('querystring'));
if ( ! function_exists('password_hash')) {
$this->load->helper('password');
}
}
/**
* 이메일 인증 함수입니다.
*/
public function confirmemail()
{
$view = array();
$view['view'] = array();
if ( ! $this->input->get('code')) {
show_404();
}
if ( ! $this->input->get('user')) {
show_404();
}
if ($this->userlib->is_user()) {
redirect();
}
if ( ! $this->configlib->item('use_register_email_auth')) {
alert('이 웹사이트는 이메일 인증 기능을 사용하고 있지 않습니다');
}
$where = array(
'uae_key' => $this->input->get('code'),
);
$result = $this->User_auth_email_model->get_one('', '', $where);
if ( ! element('uae_id', $result)) {
$view['view']['message'] = '잘못된 접근입니다';
} elseif ( ! (element('uae_type', $result) === '1' OR element('uae_type', $result) === '2')) {
$view['view']['message'] = '잘못된 접근입니다';
} elseif ( ! empty($result['uae_use_datetime']) && element('uae_use_datetime', $result) !== '0000-00-00 00:00:00') {
$view['view']['message'] = '회원님은 이미 인증을 받으셨습니다';
} elseif (strtotime(element('uae_generate_datetime', $result)) < ctimestamp()- 86400) {
$view['view']['message'] = '24 시간 이내에 인증을 받으셔야 합니다';
} elseif (element('uae_expired', $result)) {
$view['view']['message'] = '잘못된 접근입니다';
} else {
$select = 'user_id, user_email, user_denied, user_email_cert';
$dbuser = $this->User_model->get_by_id(element('user_id', $result), $select);
if ( ! element('user_id', $dbuser)) {
$view['view']['message'] = '잘못된 접근입니다';
} elseif (element('user_id', $dbuser) !== $this->input->get('user')) {
$view['view']['message'] = '잘못된 접근입니다';
} elseif (element('user_denied', $dbuser)) {
$view['view']['message'] = '접근이 금지된 아이디입니다';
} elseif (element('user_email_cert', $dbuser)) {
$view['view']['message'] = '회원님은 이미 인증을 받으셨습니다';
} else {
$updatedata = array(
'user_email_cert' => 1,
);
$this->User_model->update(element('user_id', $result), $updatedata);
$metadata = array(
'meta_email_cert_datetime' => cdate('Y-m-d H:i:s'),
);
$this->load->model('User_meta_model');
$this->User_meta_model->save(element('user_id', $result), $metadata);
$updateemail = array(
'uae_use_datetime' => cdate('Y-m-d H:i:s'),
'uae_expired' => 1
);
$view['view']['message'] = '이메일 인증이 완료되었습니다.<br />감사합니다';
$this->User_auth_email_model->update(element('uae_id', $result), $updateemail);
$this->session->set_userdata('user_id', element('user_id', $dbuser));
}
}
/**
* 레이아웃을 정의합니다
*/
$layoutconfig = array(
'path' => 'findaccount',
'layout' => 'layout',
'skin' => 'verifyemail',
);
$view['layout'] = $this->layoutlib->front($layoutconfig, $this->configlib->get_device_view_type());
$this->data = $view;
$this->layout = element('layout_skin_file', element('layout', $view));
$this->view = element('view_skin_file', element('layout', $view));
}
/**
* 패스워드 리셋위한 함수입니다.
*/
public function resetpassword()
{
$view = array();
$view['view'] = array();
if ( ! $this->input->get('code')) {
show_404();
}
if ( ! $this->input->get('user')) {
show_404();
}
if ($this->userlib->is_user()) {
redirect();
}
$this->load->library(array('form_validation'));
$password_length = $this->configlib->item('password_length');
$view['view']['password_length'] = $password_length;
$where = array(
'uae_key' => $this->input->get('code'),
);
$result = $this->User_auth_email_model->get_one('', '', $where);
$view['view']['error_message'] = '';
$view['view']['successs_message'] = '';
if ( ! element('uae_id', $result)) {
$view['view']['error_message'] = '잘못된 접근입니다';
} elseif ( ! empty($result['uae_use_datetime']) && element('uae_use_datetime', $result) !== '0000-00-00 00:00:00') {
$view['view']['error_message'] = '회원님은 이미 패스워드 변경을 하셨습니다';
} elseif (strtotime(element('uae_generate_datetime', $result)) < ctimestamp()- 86400) {
$view['view']['message'] = '24 시간 이내에 인증을 받으셔야 합니다';
} elseif (element('uae_type', $result) !== '3') {
$view['view']['error_message'] = '잘못된 접근입니다';
} else {
$select = 'user_id, user_email, user_denied, user_email_cert';
$dbuser = $this->User_model->get_by_id(element('user_id', $result), $select);
if ( ! element('user_id', $dbuser)) {
$view['view']['error_message'] = '잘못된 접근입니다';
} elseif (element('user_id', $dbuser) !== $this->input->get('user')) {
$view['view']['error_message'] = '잘못된 접근입니다';
} elseif (element('user_denied', $dbuser)) {
$view['view']['error_message'] = '회원님의 계정은 접근이 금지되어 있습니다';
} elseif ($this->configlib->item('use_register_email_auth') && ! element('user_email_cert', $dbuser)) {
$view['view']['error_message'] = '회원님은 회원가입 후, 또는 이메일 정보 변경후 아직 이메일 인증을 받지 않으셨습니다';
}
$view['view']['user_email'] = element('user_email', $dbuser);
}
$config = array(
array(
'field' => 'new_password',
'label' => '패스워드',
'rules' => 'trim|required|min_length[' . $password_length . ']|callback__user_password_check',
),
array(
'field' => 'new_password_re',
'label' => '패스워드',
'rules' => 'trim|required|min_length[' . $password_length . ']',
),
);
$this->form_validation->set_rules($config);
/**
* 유효성 검사를 하지 않는 경우, 또는 유효성 검사에 실패한 경우입니다.
* 즉 글쓰기나 수정 페이지를 보고 있는 경우입니다
*/
if ($this->form_validation->run() === false) {
} else {
if (empty($view['view']['error_message'])) {
$hash = password_hash($this->input->post('new_password'), PASSWORD_BCRYPT);
$updatedata = array(
'user_password' => $hash,
);
$this->User_model->update(element('user_id', $result), $updatedata);
$metadata = array(
'meta_change_pw_datetime' => cdate('Y-m-d H:i:s'),
);
$this->load->model('User_meta_model');
$this->User_meta_model->save(element('user_id', $result), $metadata);
$updateemail = array(
'uae_use_datetime' => cdate('Y-m-d H:i:s'),
'uae_expired' => 1
);
$this->User_auth_email_model->update(element('uae_id', $result), $updateemail);
$view['view']['success_message'] = '회원님의 패스워드가 변경되었습니다.<br />감사합니다';
$this->session->set_userdata('user_id', element('user_id', $result));
}
}
$password_description = '비밀번호는 ' . $password_length . '자리 이상이어야 ';
if ($this->configlib->item('password_uppercase_length') OR $this->configlib->item('password_numbers_length') OR $this->configlib->item('password_specialchars_length')) {
$password_description .= '하며 ';
if ($this->configlib->item('password_uppercase_length')) {
$password_description .= ', ' . $this->configlib->item('password_uppercase_length') . '개의 대문자';
}
if ($this->configlib->item('password_numbers_length')) {
$password_description .= ', ' . $this->configlib->item('password_numbers_length') . '개의 숫자';
}
if ($this->configlib->item('password_specialchars_length')) {
$password_description .= ', ' . $this->configlib->item('password_specialchars_length') . '개의 특수문자';
}
$password_description .= '를 포함해야 ';
}
$password_description .= '합니다';
$view['view']['info'] = $password_description;
/**
* 레이아웃을 정의합니다
*/
$layoutconfig = array(
'path' => 'findaccount',
'layout' => 'layout',
'skin' => 'findaccount_change_pw',
);
$view['layout'] = $this->layoutlib->front($layoutconfig, $this->configlib->get_device_view_type());
$this->data = $view;
$this->layout = element('layout_skin_file', element('layout', $view));
$this->view = element('view_skin_file', element('layout', $view));
}
/**
* 새로 입력한 패스워드가 규약에 맞는지 체크합니다.
*/
public function _user_password_check($str)
{
$uppercase = $this->configlib->item('password_uppercase_length');
$number = $this->configlib->item('password_numbers_length');
$specialchar = $this->configlib->item('password_specialchars_length');
$this->load->helper('chkstring');
$str_uc = count_uppercase($str);
$str_num = count_numbers($str);
$str_spc = count_specialchars($str);
if ($str_uc < $uppercase OR $str_num < $number OR $str_spc < $specialchar) {
$description = '비밀번호는 ';
if ($str_uc < $uppercase) {
$description .= ' ' . $uppercase . '개 이상의 대문자';
}
if ($str_num < $number) {
$description .= ' ' . $number . '개 이상의 숫자';
}
if ($str_spc < $specialchar) {
$description .= ' ' . $specialchar . '개 이상의 특수문자';
}
$description .= '를 포함해야 합니다';
$this->form_validation->set_message(
'_user_password_check',
$description
);
return false;
}
return true;
}
}

View File

@@ -0,0 +1,73 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
/**
* Main class
*/
/**
* 관리자 메인 controller 입니다.
*/
class Main extends MY_Controller
{
/**
* 관리자 페이지 상의 현재 디렉토리입니다
* 페이지 이동시 필요한 정보입니다
*/
public $pagedir = '';
/**
* 모델을 로딩합니다
*/
protected $models = array();
/**
* 이 컨트롤러의 메인 모델 이름입니다
*/
protected $modelname = '';
/**
* 헬퍼를 로딩합니다
*/
protected $helpers = array('form', 'array');
function __construct()
{
parent::__construct();
/**
* 라이브러리를 로딩합니다
*/
$this->load->library(array('querystring'));
}
/**
* 관리자 메인 페이지입니다
*/
public function index()
{
$view = array();
$view['view'] = array();
$view['view']['latest_user'] = $this->User_model->get_admin_list(7, '', '', '', 'user_id', 'desc', '', '');
if (isset($view['view']['latest_user']['list']) && is_array($view['view']['latest_user']['list'])) {
foreach ($view['view']['latest_user']['list'] as $key => $val) {
$view['view']['latest_user']['list'][$key]['display_name'] = display_username(
element('user_username', $val)
);
}
}
/**
* 어드민 레이아웃을 정의합니다
*/
$layoutconfig = array('layout' => 'layout', 'skin' => 'main');
$view['layout'] = $this->layoutlib->admin($layoutconfig, $this->configlib->get_device_view_type());
$this->data = $view;
$this->layout = element('layout_skin_file', element('layout', $view));
$this->view = element('view_skin_file', element('layout', $view));
}
}

View File

@@ -0,0 +1,168 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
/**
* Apidocument class
*/
/**
* 관리자>Api 관리>Api 문서보기 controller 입니다.
*/
class Apidocument extends MY_Controller
{
/**
* 관리자 페이지 상의 현재 디렉토리입니다
* 페이지 이동시 필요한 정보입니다
*/
public $pagedir = 'apis/apidocument';
/**
* 모델을 로딩합니다
*/
protected $models = array('Api_error_log', 'Api_input', 'Api_list', 'Api_output');
/**
* 이 컨트롤러의 메인 모델 이름입니다
*/
protected $modelname = 'Api_list_model';
/**
* 헬퍼를 로딩합니다
*/
protected $helpers = array('form', 'array');
function __construct()
{
parent::__construct();
/**
* 라이브러리를 로딩합니다
*/
$this->load->library(array('pagination', 'querystring', 'apilib'));
}
/**
* 메인페이지입니다 메소드입니다
*/
public function index()
{
$this->accesslevel->check_admin('read');
$view = array();
$view['view'] = array();
$menu = $this->_menu();
$view['view']['data'] = $menu;
/**
* 어드민 레이아웃을 정의합니다
*/
$layoutconfig = array('layout' => 'layout_api', 'skin' => 'index');
$view['layout'] = $this->layoutlib->admin($layoutconfig, $this->configlib->get_device_view_type());
$view['layout']['menu'] = $menu;
$this->data = $view;
$this->layout = element('layout_skin_file', element('layout', $view));
$this->view = element('view_skin_file', element('layout', $view));
}
/**
* 뷰페이지입니다 메소드입니다
*/
public function view($pid = 0)
{
$this->accesslevel->check_admin('read');
$view = array();
$view['view'] = array();
/**
* 프라이머리키에 숫자형이 입력되지 않으면 에러처리합니다
*/
if ($pid) {
$pid = (int) $pid;
if (empty($pid) OR $pid < 1) {
show_404();
}
}
$primary_key = $this->Api_list_model->primary_key;
/**
* 수정 페이지일 경우 기존 데이터를 가져옵니다
*/
$getdata = array();
if ($pid) {
$getdata = $this->Api_list_model->get_one($pid);
// input data
$input = $this->Api_input_model->get('', '', $where = array('api_idx' => $pid), '', 0, 'ai_sort', 'asc');
// output data
$output = $this->Api_output_model->get('', '', $where = array('api_idx' => $pid), '', 0, 'ai_sort', 'asc');
} else {
show_404();
}
$menu = $this->_menu();
$view['view']['data'] = $getdata;
$view['view']['input'] = $input;
$view['view']['output'] = $output;
/**
* 어드민 레이아웃을 정의합니다
*/
$layoutconfig = array('layout' => 'layout_api', 'skin' => 'view');
$view['layout'] = $this->layoutlib->admin($layoutconfig, $this->configlib->get_device_view_type());
$view['layout']['menu'] = $menu;
$this->data = $view;
$this->layout = element('layout_skin_file', element('layout', $view));
$this->view = element('view_skin_file', element('layout', $view));
}
public function emptypage()
{
echo '실행하여주세요';
}
public function xml($api_idx)
{
if (! $api_idx) show_404();
$getdata = $this->Api_list_model->get_one($api_idx);
if (! element('api_idx', $getdata)) show_404();
echo $this->apilib->callapi($getdata, 'xml');
}
public function json($api_idx)
{
if (! $api_idx) show_404();
$getdata = $this->Api_list_model->get_one($api_idx);
if (! element('api_idx', $getdata)) show_404();
echo $this->apilib->callapi($getdata, 'json');
}
public function json2($api_idx)
{
if (! $api_idx) show_404();
$getdata = $this->Api_list_model->get_one($api_idx);
if (! element('api_idx', $getdata)) show_404();
echo $this->apilib->callapi($getdata, 'json2');
}
public function _menu()
{
$menu = $this->Api_list_model->get('', '', $where = array('api_use' => '1'), '', 0, 'api_name', 'asc');
return $menu;
}
}

View File

@@ -0,0 +1,614 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
/**
* Apimanage class
*/
/**
* 관리자>Api 관리>Api 관리 controller 입니다.
*/
class Apimanage extends MY_Controller
{
/**
* 관리자 페이지 상의 현재 디렉토리입니다
* 페이지 이동시 필요한 정보입니다
*/
public $pagedir = 'apis/apimanage';
/**
* 모델을 로딩합니다
*/
protected $models = array('Api_error_log', 'Api_input', 'Api_list', 'Api_output');
/**
* 이 컨트롤러의 메인 모델 이름입니다
*/
protected $modelname = 'Api_list_model';
/**
* 헬퍼를 로딩합니다
*/
protected $helpers = array('form', 'array');
function __construct()
{
parent::__construct();
/**
* 라이브러리를 로딩합니다
*/
$this->load->library(array('pagination', 'querystring'));
}
/**
* 목록을 가져오는 메소드입니다
*/
public function index()
{
$this->accesslevel->check_admin('read');
$view = array();
$view['view'] = array();
/**
* 페이지에 숫자가 아닌 문자가 입력되거나 1보다 작은 숫자가 입력되면 에러 페이지를 보여줍니다.
*/
$param =& $this->querystring;
$page = (((int) $this->input->get('page')) > 0) ? ((int) $this->input->get('page')) : 1;
$findex = $this->input->get('findex') ? $this->input->get('findex') : 'api_name';
$forder = $this->input->get('forder', null, 'asc');
$sfield = $this->input->get('sfield', null, '');
$skeyword = $this->input->get('skeyword', null, '');
$per_page = 50;
$offset = ($page - 1) * $per_page;
/**
* 게시판 목록에 필요한 정보를 가져옵니다.
*/
$this->{$this->modelname}->allow_search_field = array('api_idx', 'api_name', 'api_exp', 'api_url', 'api_bigo'); // 검색이 가능한 필드
$this->{$this->modelname}->search_field_equal = array('api_idx'); // 검색중 like 가 아닌 = 검색을 하는 필드
$this->{$this->modelname}->allow_order_field = array('api_idx', 'api_name'); // 정렬이 가능한 필드
$result = $this->{$this->modelname}
->get_admin_list($per_page, $offset, '', '', $findex, $forder, $sfield, $skeyword);
$list_num = $result['total_rows'] - ($page - 1) * $per_page;
if (element('list', $result)) {
foreach (element('list', $result) as $key => $val) {
$result['list'][$key]['num'] = $list_num--;
}
}
$view['view']['data'] = $result;
/**
* primary key 정보를 저장합니다
*/
$view['view']['primary_key'] = $this->{$this->modelname}->primary_key;
/**
* 페이지네이션을 생성합니다
*/
$config['base_url'] = admin_url($this->pagedir) . '?' . $param->replace('page');
$config['total_rows'] = $result['total_rows'];
$config['per_page'] = $per_page;
$this->pagination->initialize($config);
$view['view']['paging'] = $this->pagination->create_links();
$view['view']['page'] = $page;
/**
* 쓰기 주소, 삭제 주소등 필요한 주소를 구합니다
*/
$search_option = array('api_name' => '이름', 'api_method' => '호출방식', 'api_exp' => '설명', 'api_bigo' => '비고');
$view['view']['skeyword'] = ($sfield && array_key_exists($sfield, $search_option)) ? $skeyword : '';
$view['view']['search_option'] = search_option($search_option, $sfield);
$view['view']['listall_url'] = admin_url($this->pagedir);
$view['view']['write_url'] = admin_url($this->pagedir . '/write');
$view['view']['list_delete_url'] = admin_url($this->pagedir . '/listdelete/?' . $param->output());
/**
* 어드민 레이아웃을 정의합니다
*/
$layoutconfig = array('layout' => 'layout', 'skin' => 'index');
$view['layout'] = $this->layoutlib->admin($layoutconfig, $this->configlib->get_device_view_type());
$this->data = $view;
$this->layout = element('layout_skin_file', element('layout', $view));
$this->view = element('view_skin_file', element('layout', $view));
}
/**
* 게시판 글쓰기 또는 수정 페이지를 가져오는 메소드입니다
*/
public function write($pid = 0)
{
$this->accesslevel->check_admin('read');
$view = array();
$view['view'] = array();
/**
* 프라이머리키에 숫자형이 입력되지 않으면 에러처리합니다
*/
if ($pid) {
$pid = (int) $pid;
if (empty($pid) OR $pid < 1) {
show_404();
}
}
$primary_key = $this->{$this->modelname}->primary_key;
/**
* 수정 페이지일 경우 기존 데이터를 가져옵니다
*/
$getdata = array();
if ($pid) {
$getdata = $this->{$this->modelname}->get_one($pid);
}
/**
* Validation 라이브러리를 가져옵니다
*/
$this->load->library('form_validation');
/**
* 전송된 데이터의 유효성을 체크합니다
*/
$config = array(
array(
'field' => 'api_name',
'label' => 'API 이름',
'rules' => 'trim|required',
),
array(
'field' => 'api_exp',
'label' => '내용',
'rules' => 'trim',
),
array(
'field' => 'api_method',
'label' => '호출방식',
'rules' => 'trim|required',
),
array(
'field' => 'api_use',
'label' => '사용여부',
'rules' => 'trim|numeric',
),
array(
'field' => 'api_bigo',
'label' => '비고',
'rules' => 'trim',
),
);
$this->form_validation->set_rules($config);
/**
* 유효성 검사를 하지 않는 경우, 또는 유효성 검사에 실패한 경우입니다.
* 즉 글쓰기나 수정 페이지를 보고 있는 경우입니다
*/
if ($this->form_validation->run() === false) {
$view['view']['data'] = $getdata;
/**
* primary key 정보를 저장합니다
*/
$view['view']['primary_key'] = $primary_key;
/**
* 어드민 레이아웃을 정의합니다
*/
$layoutconfig = array('layout' => 'layout', 'skin' => 'write');
$view['layout'] = $this->layoutlib->admin($layoutconfig, $this->configlib->get_device_view_type());
$this->data = $view;
$this->layout = element('layout_skin_file', element('layout', $view));
$this->view = element('view_skin_file', element('layout', $view));
} else {
/**
* 유효성 검사를 통과한 경우입니다.
* 즉 데이터의 insert 나 update 의 process 처리가 필요한 상황입니다
*/
$updatedata = array(
'api_name' => $this->input->post('api_name', null, ''),
'api_exp' => $this->input->post('api_exp', null, ''),
'api_method' => $this->input->post('api_method', null, ''),
'api_use' => $this->input->post('api_use', null, ''),
'api_bigo' => $this->input->post('api_bigo', null, ''),
);
/**
* 게시물을 수정하는 경우입니다
*/
if ($this->input->post($primary_key)) {
$this->accesslevel->check_admin('edit');
$this->{$this->modelname}->update($this->input->post($primary_key), $updatedata);
$this->session->set_flashdata(
'message',
'정상적으로 수정되었습니다'
);
} else {
$this->accesslevel->check_admin('write');
/**
* 게시물을 새로 입력하는 경우입니다
*/
$this->{$this->modelname}->insert($updatedata);
$this->session->set_flashdata(
'message',
'정상적으로 입력되었습니다'
);
}
/**
* 게시물의 신규입력 또는 수정작업이 끝난 후 목록 페이지로 이동합니다
*/
$param =& $this->querystring;
$redirecturl = admin_url($this->pagedir . '?' . $param->output());
redirect($redirecturl);
}
}
/**
* 목록 페이지에서 선택삭제를 하는 경우 실행되는 메소드입니다
*/
public function listdelete()
{
$this->accesslevel->check_admin('delete');
/**
* 체크한 게시물의 삭제를 실행합니다
*/
if ($this->input->post('chk') && is_array($this->input->post('chk'))) {
foreach ($this->input->post('chk') as $val) {
if ($val) {
$outdata = $this->Api_output_model->get_one('', '', array('api_idx', $val));
if (element('ai_idx', $outdata)) {
alert('Input 및 Output 변수를 먼저 삭제하신 후에 삭제가 가능합니다.');
}
$indata = $this->Api_input_model->get_one('', '', array('api_idx', $val));
if (element('ai_idx', $indata)) {
alert('Input 및 Output 변수를 먼저 삭제하신 후에 삭제가 가능합니다.');
}
$this->{$this->modelname}->delete($val);
}
}
}
/**
* 삭제가 끝난 후 목록페이지로 이동합니다
*/
$this->session->set_flashdata(
'message',
'정상적으로 삭제되었습니다'
);
$param =& $this->querystring;
$redirecturl = admin_url($this->pagedir . '?' . $param->output());
redirect($redirecturl);
}
/**
* 목록을 가져오는 메소드입니다
*/
public function argumentlist($type = '', $api_idx = '')
{
$this->accesslevel->check_admin('read');
$view = array();
$view['view'] = array();
if ($type != 'output') $type = 'input';
$view['view']['type'] = $type;
if (! $api_idx) show_404();
if ( ! is_numeric($api_idx)) show_404();
$view['view']['apidata'] = $apidata = $this->Api_list_model->get_one($api_idx);
if ( ! element('api_idx', $apidata)) show_404();
$modelname = $type == 'output' ? 'Api_output_model' : 'Api_input_model';
/**
* 페이지에 숫자가 아닌 문자가 입력되거나 1보다 작은 숫자가 입력되면 에러 페이지를 보여줍니다.
*/
$param =& $this->querystring;
$page = (((int) $this->input->get('page')) > 0) ? ((int) $this->input->get('page')) : 1;
$findex = $this->input->get('findex') ? $this->input->get('findex') : 'ai_sort';
$forder = $this->input->get('forder', null, 'asc');
$sfield = $this->input->get('sfield', null, '');
$skeyword = $this->input->get('skeyword', null, '');
$per_page = 100;
$offset = ($page - 1) * $per_page;
/**
* 게시판 목록에 필요한 정보를 가져옵니다.
*/
$this->{$modelname}->allow_search_field = array('ai_idx', 'ai_name', 'ai_type', 'ai_ness', 'ai_exp', 'ai_sort', 'api_bigo'); // 검색이 가능한 필드
$this->{$modelname}->search_field_equal = array('ai_idx'); // 검색중 like 가 아닌 = 검색을 하는 필드
$this->{$modelname}->allow_order_field = array('ai_idx', 'ai_name', 'ai_sort'); // 정렬이 가능한 필드
$where = array(
'api_idx' => $api_idx,
);
$result = $this->{$modelname}
->get_admin_list($per_page, $offset, $where, '', $findex, $forder, $sfield, $skeyword);
$list_num = $result['total_rows'] - ($page - 1) * $per_page;
if (element('list', $result)) {
foreach (element('list', $result) as $key => $val) {
$result['list'][$key]['num'] = $list_num--;
}
}
$view['view']['data'] = $result;
/**
* primary key 정보를 저장합니다
*/
$view['view']['primary_key'] = $this->{$modelname}->primary_key;
/**
* 페이지네이션을 생성합니다
*/
$config['base_url'] = admin_url($this->pagedir) . '?' . $param->replace('page');
$config['total_rows'] = $result['total_rows'];
$config['per_page'] = $per_page;
$this->pagination->initialize($config);
$view['view']['paging'] = $this->pagination->create_links();
$view['view']['page'] = $page;
/**
* 쓰기 주소, 삭제 주소등 필요한 주소를 구합니다
*/
$search_option = array('ai_name' => '변수명', 'ai_type' => '타입', 'ai_ness' => '종류', 'ai_exp' => '설명', 'ai_sort' => '순서');
$view['view']['skeyword'] = ($sfield && array_key_exists($sfield, $search_option)) ? $skeyword : '';
$view['view']['search_option'] = search_option($search_option, $sfield);
$view['view']['listall_url'] = admin_url($this->pagedir);
$view['view']['input_list_url'] = admin_url($this->pagedir . '/argumentlist/input/' . $api_idx);
$view['view']['output_list_url'] = admin_url($this->pagedir . '/argumentlist/output/' . $api_idx);
$view['view']['write_url'] = admin_url($this->pagedir . '/argumentwrite/' . $type . '/' . $api_idx);
$view['view']['list_delete_url'] = admin_url($this->pagedir . '/argumentlistdelete/' . $type . '/' . $api_idx . '?' . $param->output());
/**
* 어드민 레이아웃을 정의합니다
*/
$layoutconfig = array('layout' => 'layout', 'skin' => 'argumentlist');
$view['layout'] = $this->layoutlib->admin($layoutconfig, $this->configlib->get_device_view_type());
$this->data = $view;
$this->layout = element('layout_skin_file', element('layout', $view));
$this->view = element('view_skin_file', element('layout', $view));
}
/**
* 게시판 글쓰기 또는 수정 페이지를 가져오는 메소드입니다
*/
public function argumentwrite($type = '', $api_idx = '', $pid = 0)
{
$this->accesslevel->check_admin('read');
$view = array();
$view['view'] = array();
if ($type != 'output') $type = 'input';
$view['view']['type'] = $type;
if (! $api_idx) show_404();
if ( ! is_numeric($api_idx)) show_404();
$modelname = $type == 'output' ? 'Api_output_model' : 'Api_input_model';
$view['view']['apidata'] = $apidata = $this->Api_list_model->get_one($api_idx);
if ( ! element('api_idx', $apidata)) show_404();
/**
* 프라이머리키에 숫자형이 입력되지 않으면 에러처리합니다
*/
if ($pid) {
$pid = (int) $pid;
if (empty($pid) OR $pid < 1) {
show_404();
}
}
$primary_key = $this->{$modelname}->primary_key;
/**
* 수정 페이지일 경우 기존 데이터를 가져옵니다
*/
$getdata = array();
if ($pid) {
$getdata = $this->{$modelname}->get_one($pid);
} else {
$max_sort = $this->{$modelname}->select_max_sort($api_idx);
$getdata['ai_sort'] = $max_sort + 1;
}
/**
* Validation 라이브러리를 가져옵니다
*/
$this->load->library('form_validation');
/**
* 전송된 데이터의 유효성을 체크합니다
*/
$config = array(
array(
'field' => 'api_idx',
'label' => 'API IDX',
'rules' => 'trim|required',
),
array(
'field' => 'ai_name',
'label' => '내용',
'rules' => 'trim|required',
),
array(
'field' => 'ai_type',
'label' => '타입',
'rules' => 'trim|required',
),
array(
'field' => 'ai_ness',
'label' => '종류',
'rules' => 'trim',
),
array(
'field' => 'ai_exp',
'label' => '설명',
'rules' => 'trim',
),
array(
'field' => 'ai_sort',
'label' => '순서',
'rules' => 'trim|numeric',
),
);
$this->form_validation->set_rules($config);
/**
* 유효성 검사를 하지 않는 경우, 또는 유효성 검사에 실패한 경우입니다.
* 즉 글쓰기나 수정 페이지를 보고 있는 경우입니다
*/
if ($this->form_validation->run() === false) {
$view['view']['data'] = $getdata;
/**
* primary key 정보를 저장합니다
*/
$view['view']['primary_key'] = $primary_key;
$view['view']['input_list_url'] = admin_url($this->pagedir . '/argumentlist/input/' . $api_idx);
$view['view']['output_list_url'] = admin_url($this->pagedir . '/argumentlist/output/' . $api_idx);
/**
* 어드민 레이아웃을 정의합니다
*/
$layoutconfig = array('layout' => 'layout', 'skin' => 'argumentwrite');
$view['layout'] = $this->layoutlib->admin($layoutconfig, $this->configlib->get_device_view_type());
$this->data = $view;
$this->layout = element('layout_skin_file', element('layout', $view));
$this->view = element('view_skin_file', element('layout', $view));
} else {
/**
* 유효성 검사를 통과한 경우입니다.
* 즉 데이터의 insert 나 update 의 process 처리가 필요한 상황입니다
*/
$updatedata = array(
'api_idx' => $this->input->post('api_idx', null, ''),
'ai_name' => $this->input->post('ai_name', null, ''),
'ai_type' => $this->input->post('ai_type', null, ''),
'ai_ness' => $this->input->post('ai_ness', null, ''),
'ai_exp' => $this->input->post('ai_exp', null, ''),
'ai_sort' => $this->input->post('ai_sort', null, ''),
);
/**
* 게시물을 수정하는 경우입니다
*/
if ($this->input->post($primary_key)) {
$this->accesslevel->check_admin('edit');
$this->{$modelname}->update($this->input->post($primary_key), $updatedata);
$this->session->set_flashdata(
'message',
'정상적으로 수정되었습니다'
);
} else {
$this->accesslevel->check_admin('write');
/**
* 게시물을 새로 입력하는 경우입니다
*/
$this->{$modelname}->update_sort($this->input->post('api_idx', null, ''), $this->input->post('ai_sort', null, ''));
$this->{$modelname}->insert($updatedata);
$this->session->set_flashdata(
'message',
$this->input->post('ai_name', null, '') . '변수명이 등록되었습니다'
);
}
/**
* 게시물의 신규입력 또는 수정작업이 끝난 후 목록 페이지로 이동합니다
*/
$param =& $this->querystring;
if ($this->input->post('reinput')) {
$redirecturl = admin_url($this->pagedir . '/argumentwrite/' . $type . '/' . $api_idx . '?' . $param->output());
} else {
$redirecturl = admin_url($this->pagedir . '/argumentlist/' . $type . '/' . $api_idx . '?' . $param->output());
}
redirect($redirecturl);
}
}
/**
* 목록 페이지에서 선택삭제를 하는 경우 실행되는 메소드입니다
*/
public function argumentlistdelete($type = '', $api_idx = '')
{
$this->accesslevel->check_admin('delete');
if ($type != 'output') $type = 'input';
if (! $api_idx) show_404();
if ( ! is_numeric($api_idx)) show_404();
$modelname = $type == 'output' ? 'Api_output_model' : 'Api_input_model';
/**
* 체크한 게시물의 삭제를 실행합니다
*/
if ($this->input->post('chk') && is_array($this->input->post('chk'))) {
foreach ($this->input->post('chk') as $val) {
if ($val) {
$this->{$modelname}->delete($val);
}
}
}
/**
* 삭제가 끝난 후 목록페이지로 이동합니다
*/
$this->session->set_flashdata(
'message',
'정상적으로 삭제되었습니다'
);
$param =& $this->querystring;
$redirecturl = admin_url($this->pagedir . '/argumentlist/' . $type . '/' . $api_idx . '?' . $param->output());
redirect($redirecturl);
}
}

View File

@@ -0,0 +1,358 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
/**
* Appcats class
*/
class Appcats extends MY_Controller
{
/**
* 관리자 페이지 상의 현재 디렉토리입니다
* 페이지 이동시 필요한 정보입니다
*/
public $pagedir = 'appmanage/appcats';
/**
* 모델을 로딩합니다
*/
protected $models = array('Contents_category', 'Upload_file', 'Apps');
/**
* 이 컨트롤러의 메인 모델 이름입니다
*/
protected $modelname = 'Contents_category_model';
/**
* 헬퍼를 로딩합니다
*/
protected $helpers = array('form', 'array', 'dhtml_editor');
function __construct()
{
parent::__construct();
/**
* 라이브러리를 로딩합니다
*/
$this->load->library(array('pagination', 'querystring'));
}
/**
* 목록을 가져오는 메소드입니다
*/
public function index()
{
$view = array();
$view['view'] = array();
/**
* 페이지에 숫자가 아닌 문자가 입력되거나 1보다 작은 숫자가 입력되면 에러 페이지를 보여줍니다.
*/
$param =& $this->querystring;
$app_id = $this->input->get('app_id');
if ($app_id) {
$where = array(
'cat_parent' => '0',
'app_id' => $app_id,
);
$result = $this->{$this->modelname}->get('', '', $where, '', '', 'cat_sort', 'desc');
$view['view']['data'] = $result;
}
$view['view']['applist'] = $this->Apps_model->app_list();
/**
* primary key 정보를 저장합니다
*/
$view['view']['primary_key'] = $this->{$this->modelname}->primary_key;
/**
* 어드민 레이아웃을 정의합니다
*/
$layoutconfig = array('layout' => 'layout', 'skin' => 'index');
$view['layout'] = $this->layoutlib->admin($layoutconfig, $this->configlib->get_device_view_type());
$this->data = $view;
$this->layout = element('layout_skin_file', element('layout', $view));
$this->view = element('view_skin_file', element('layout', $view));
}
/**
* 게시판 글쓰기 또는 수정 페이지를 가져오는 메소드입니다
*/
public function write($app_id = 0, $pid = 0)
{
$view = array();
$view['view'] = array();
/**
* 프라이머리키에 숫자형이 입력되지 않으면 에러처리합니다
*/
if ($pid) {
$pid = (int) $pid;
if (empty($pid) OR $pid < 1) {
show_404();
}
}
$primary_key = $this->{$this->modelname}->primary_key;
/**
* 수정 페이지일 경우 기존 데이터를 가져옵니다
*/
$getdata = array();
if ($pid) {
$getdata = $this->{$this->modelname}->get_one($pid);
}
/**
* Validation 라이브러리를 가져옵니다
*/
$this->load->library('form_validation');
/**
* 전송된 데이터의 유효성을 체크합니다
*/
$config = array(
array(
'field' => 'cat_code',
'label' => '분류코드',
'rules' => 'trim|required|alpha_numeric',
),
array(
'field' => 'cat_name',
'label' => '카테고리명',
'rules' => 'trim|required',
),
array(
'field' => 'cat_parent',
'label' => 'Parent',
'rules' => 'trim|numeric',
),
array(
'field' => 'cat_sort',
'label' => '정렬순서',
'rules' => 'trim|numeric',
),
);
$this->form_validation->set_rules($config);
/**
* 유효성 검사를 하지 않는 경우, 또는 유효성 검사에 실패한 경우입니다.
* 즉 글쓰기나 수정 페이지를 보고 있는 경우입니다
*/
if ($this->form_validation->run() === false) {
$parent = '';
if ($cat_parent = (int) $this->input->get('cat_parent') OR $cat_parent = element('cat_parent', $getdata)) {
$pwhere = array(
'app_id' => $app_id,
'cat_id' => $cat_parent,
);
$parent = $this->{$this->modelname}->get_one('', '', $pwhere);
if ( ! element('cat_id', $parent)) {
alert_close('잘못된 접근입니다.');
}
}
$view['view']['data'] = $getdata;
$view['view']['parent'] = $parent;
/**
* primary key 정보를 저장합니다
*/
$view['view']['primary_key'] = $primary_key;
/**
* 어드민 레이아웃을 정의합니다
*/
$layoutconfig = array('layout' => 'layout_popup', 'skin' => 'write');
$view['layout'] = $this->layoutlib->admin($layoutconfig, $this->configlib->get_device_view_type());
$this->data = $view;
$this->layout = element('layout_skin_file', element('layout', $view));
$this->view = element('view_skin_file', element('layout', $view));
} else {
/**
* 유효성 검사를 통과한 경우입니다.
* 즉 데이터의 insert 나 update 의 process 처리가 필요한 상황입니다
*/
/**
* 게시물을 수정하는 경우입니다
*/
if ($this->input->post($primary_key)) {
$uniqwhere = array(
'app_id' => $app_id,
'cat_code' => $this->input->post('cat_code'),
'cat_id <>' => $this->input->post($primary_key),
);
$uniqcheck = $this->{$this->modelname}->get_one('', '', $uniqwhere);
if (element('cat_id', $uniqcheck)) {
alert('중복된 코드가 존재합니다.');
}
$updatedata = array(
'cat_code' => $this->input->post('cat_code'),
'cat_name' => $this->input->post('cat_name'),
'cat_sort' => $this->input->post('cat_sort'),
'cat_publish_time' => $this->input->post('cat_publish_time'),
);
$this->{$this->modelname}->update($this->input->post($primary_key), $updatedata);
$cat_parent = (int) $this->input->post('cat_parent');
alert_refresh_close('정상적으로 수정되었습니다', admin_url('appmanage/appcats?app_id=' . $app_id . '&cat1_id=' . $cat_parent));
} else {
$uniqwhere = array(
'app_id' => $app_id,
'cat_code' => $this->input->post('cat_code'),
);
$uniqcheck = $this->{$this->modelname}->get_one('', '', $uniqwhere);
if (element('cat_id', $uniqcheck)) {
alert('중복된 코드가 존재합니다.');
}
$cat_parent = (int) $this->input->post('cat_parent');
if ($cat_parent) {
$pwhere = array(
'app_id' => $app_id,
'cat_id' => $cat_parent,
);
$parent = $this->{$this->modelname}->get_one('', '', $pwhere);
if ( ! element('cat_id', $parent)) {
alert_close('잘못된 접근입니다.');
}
$cat_depth = element('cat_depth', $parent) + 1;
} else {
$cat_depth = 1;
}
$updatedata = array(
'app_id' => $app_id,
'cat_parent' => $cat_parent,
'cat_depth' => $cat_depth,
'cat_code' => $this->input->post('cat_code'),
'cat_name' => $this->input->post('cat_name'),
'cat_sort' => $this->input->post('cat_sort'),
'cat_publish_time' => $this->input->post('cat_publish_time'),
);
/**
* 게시물을 새로 입력하는 경우입니다
*/
$insert_id = $this->{$this->modelname}->insert($updatedata);
alert_refresh_close('정상적으로 입력되었습니다', admin_url('appmanage/appcats?app_id=' . $app_id . '&cat1_id=' . $cat_parent));
}
}
}
public function getcategory($app_id= '', $parent_id = '', $depth = '')
{
if ( ! $app_id) show_404();
if ( ! $parent_id) show_404();
if ( ! $depth) show_404();
if ($depth != '2' && $depth != '3' && $depth != '4') show_404();
$view = array();
$view['view'] = array();
$where = array(
'app_id' => $app_id,
'cat_parent' => $parent_id,
'cat_depth' => $depth,
);
$result = $this->{$this->modelname}->get('', '', $where, '', '', 'cat_sort', 'desc');
$nextdepth = $depth + 1;
/**
* primary key 정보를 저장합니다
*/
$view['view']['primary_key'] = $this->{$this->modelname}->primary_key;
$html = '<div class="list-group"><li class="list-group-item active">';
$cattitle = '';
if ($depth == '2') {
$cattitle = '2차분류';
}
else if ($depth == '3') {
$cattitle = '소분류';
}
else if ($depth == '4') {
$cattitle = '세분류';
}
$html .= $cattitle . '<button type="button" class="btn btn-xs pull-right btn-default" onClick="add_category(\'' . $app_id . '\', \'' . $parent_id . '\');">추가</button></li>';
if ($result) {
foreach ($result as $key => $value) {
$html .= '<li class="list-group-item">';
if ($nextdepth < 5) {
$html .= '<a href="javascript:;" onclick="show_sub_category(\'' . $app_id . '\', \'' . element('cat_id', $value) . '\', \'' . $nextdepth . '\');">';
}
$html .= html_escape(element('cat_name', $value));
if ($nextdepth < 5) {
$html .= '</a>';
}
$html .= ' ('. html_escape(element('cat_code', $value)) . ')';
$html .= '<span class="label label-default">' . element('cat_sort', $value) . '</span>';
$html .= '<button type="button" class="btn btn-xs pull-right bg-olive" onClick="modify_category(\'' . $app_id . '\', \'' . $parent_id . '\', \'' . element('cat_id', $value) . '\');">수정</button></li>';
}
}
$html .= '</div>';
echo $html;
}
/**
* 삭제를 하는 경우 실행되는 메소드입니다
*/
public function delete($id='')
{
if ( ! $id) show_404();
$data = $this->{$this->modelname}->get_one($id);
if ( ! element('app_id', $data)) {
alert_close('잘못된 접근입니다.');
}
/**
* 체크한 게시물의 삭제를 실행합니다
*/
$this->_recursiveDelete(element('app_id', $data), $id);
alert_refresh_close('정상적으로 삭제되었습니다');
}
public function _recursiveDelete($app_id, $id) {
$result=$this->{$this->modelname}->get('', '', array('app_id' => $app_id, 'cat_parent' => $id));
if (count($result)) {
foreach($result as $current) {
$this->_recursiveDelete($app_id, element('cat_id', $current));
}
}
$this->{$this->modelname}->delete($id);
return true;
}
}

View File

@@ -0,0 +1,772 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
/**
* Apps class
*/
class Apps extends MY_Controller
{
/**
* 관리자 페이지 상의 현재 디렉토리입니다
* 페이지 이동시 필요한 정보입니다
*/
public $pagedir = 'appmanage/apps';
/**
* 모델을 로딩합니다
*/
protected $models = array('Apps', 'Upload_file');
/**
* 이 컨트롤러의 메인 모델 이름입니다
*/
protected $modelname = 'Apps_model';
/**
* 헬퍼를 로딩합니다
*/
protected $helpers = array('form', 'array', 'dhtml_editor');
function __construct()
{
parent::__construct();
/**
* 라이브러리를 로딩합니다
*/
$this->load->library(array('pagination', 'querystring'));
}
/**
* 목록을 가져오는 메소드입니다
*/
public function index()
{
$this->accesslevel->check_admin('read');
$view = array();
$view['view'] = array();
/**
* 페이지에 숫자가 아닌 문자가 입력되거나 1보다 작은 숫자가 입력되면 에러 페이지를 보여줍니다.
*/
$param =& $this->querystring;
$page = (((int) $this->input->get('page')) > 0) ? ((int) $this->input->get('page')) : 1;
$findex = $this->input->get('findex') ? $this->input->get('findex') : 'app_sort';
$forder = $this->input->get('forder', null, 'desc');
$sfield = $this->input->get('sfield', null, '');
$skeyword = $this->input->get('skeyword', null, '');
$per_page = admin_listnum();
$offset = ($page - 1) * $per_page;
/**
* 게시판 목록에 필요한 정보를 가져옵니다.
*/
$this->{$this->modelname}->allow_search_field = array('app_id','app_package','app_name'); // 검색이 가능한 필드
$this->{$this->modelname}->search_field_equal = array('app_id'); // 검색중 like 가 아닌 = 검색을 하는 필드
$this->{$this->modelname}->allow_order_field = array('app_id', 'app_sort'); // 정렬이 가능한 필드
$result = $this->{$this->modelname}
->get_admin_list($per_page, $offset, '', '', $findex, $forder, $sfield, $skeyword);
$list_num = $result['total_rows'] - ($page - 1) * $per_page;
if (element('list', $result)) {
foreach (element('list', $result) as $key => $val) {
$result['list'][$key]['num'] = $list_num--;
}
}
$view['view']['data'] = $result;
/**
* primary key 정보를 저장합니다
*/
$view['view']['primary_key'] = $this->{$this->modelname}->primary_key;
/**
* 페이지네이션을 생성합니다
*/
$config['base_url'] = admin_url($this->pagedir) . '?' . $param->replace('page');
$config['total_rows'] = $result['total_rows'];
$config['per_page'] = $per_page;
$this->pagination->initialize($config);
$view['view']['paging'] = $this->pagination->create_links();
$view['view']['page'] = $page;
/**
* 쓰기 주소, 삭제 주소등 필요한 주소를 구합니다
*/
$search_option = array('app_id' => '고유번호','app_package' => '패키지명','app_name' => '어플 이름');
$view['view']['skeyword'] = ($sfield && array_key_exists($sfield, $search_option)) ? $skeyword : '';
$view['view']['search_option'] = search_option($search_option, $sfield);
$view['view']['listall_url'] = admin_url($this->pagedir);
$view['view']['write_url'] = admin_url($this->pagedir . '/write');
$view['view']['list_delete_url'] = admin_url($this->pagedir . '/listdelete/?' . $param->output());
/**
* 어드민 레이아웃을 정의합니다
*/
$layoutconfig = array('layout' => 'layout', 'skin' => 'index');
$view['layout'] = $this->layoutlib->admin($layoutconfig, $this->configlib->get_device_view_type());
$this->data = $view;
$this->layout = element('layout_skin_file', element('layout', $view));
$this->view = element('view_skin_file', element('layout', $view));
}
/**
* 게시판 글쓰기 또는 수정 페이지를 가져오는 메소드입니다
*/
public function write($pid = 0)
{
$this->accesslevel->check_admin('read');
$view = array();
$view['view'] = array();
/**
* 프라이머리키에 숫자형이 입력되지 않으면 에러처리합니다
*/
if ($pid) {
$pid = (int) $pid;
if (empty($pid) OR $pid < 1) {
show_404();
}
}
$primary_key = $this->{$this->modelname}->primary_key;
/**
* 수정 페이지일 경우 기존 데이터를 가져옵니다
*/
$getdata = array();
if ($pid) {
$getdata = $this->{$this->modelname}->get_one($pid);
}
/**
* Validation 라이브러리를 가져옵니다
*/
$this->load->library('form_validation');
$view['view']['upload_file_count'] = $upload_file_count = 0;
/**
* 전송된 데이터의 유효성을 체크합니다
*/
$config = array(
array('field' => 'app_package', 'label' => '패키지명', 'rules' => 'trim|required'),
array('field' => 'app_name', 'label' => '어플 이름', 'rules' => 'trim|required'),
array('field' => 'app_sort', 'label' => '정렬순서', 'rules' => 'trim|required'),
array('field' => 'app_policy', 'label' => '개인정보취급방침', 'rules' => 'trim'),
);
$this->form_validation->set_rules($config);
$form_validation = $this->form_validation->run();
$file_error = '';
$uploadfiledata = '';
$uploadfiledata2 = '';
if ($upload_file_count > 0 && $form_validation) {
$this->load->library('upload');
if (isset($_FILES) && isset($_FILES['upload_file']) && isset($_FILES['upload_file']['name']) && is_array($_FILES['upload_file']['name'])) {
$filecount = count($_FILES['upload_file']['name']);
$upload_path = config_item('uploads_dir') . '/files/';
if (is_dir($upload_path) === false) {
mkdir($upload_path, 0707);
$file = $upload_path . 'index.php';
$f = @fopen($file, 'w');
@fwrite($f, '');
@fclose($f);
@chmod($file, 0644);
}
$upload_path .= cdate('Y') . '/';
if (is_dir($upload_path) === false) {
mkdir($upload_path, 0707);
$file = $upload_path . 'index.php';
$f = @fopen($file, 'w');
@fwrite($f, '');
@fclose($f);
@chmod($file, 0644);
}
$upload_path .= cdate('m') . '/';
if (is_dir($upload_path) === false) {
mkdir($upload_path, 0707);
$file = $upload_path . 'index.php';
$f = @fopen($file, 'w');
@fwrite($f, '');
@fclose($f);
@chmod($file, 0644);
}
foreach ($_FILES['upload_file']['name'] as $i => $value) {
if ($value) {
$uploadconfig = '';
$uploadconfig['upload_path'] = $upload_path;
$uploadconfig['allowed_types'] = '*';
$uploadconfig['max_size'] = 10240;
$uploadconfig['encrypt_name'] = true;
$this->upload->initialize($uploadconfig);
$_FILES['userfile']['name'] = $_FILES['upload_file']['name'][$i];
$_FILES['userfile']['type'] = $_FILES['upload_file']['type'][$i];
$_FILES['userfile']['tmp_name'] = $_FILES['upload_file']['tmp_name'][$i];
$_FILES['userfile']['error'] = $_FILES['upload_file']['error'][$i];
$_FILES['userfile']['size'] = $_FILES['upload_file']['size'][$i];
if ($this->upload->do_upload()) {
$filedata = $this->upload->data();
$uploadfiledata[$i]['ufi_filename'] = cdate('Y') . '/' . cdate('m') . '/' . element('file_name', $filedata);
$uploadfiledata[$i]['ufi_originname'] = element('orig_name', $filedata);
$uploadfiledata[$i]['ufi_filesize'] = intval(element('file_size', $filedata) * 1024);
$uploadfiledata[$i]['ufi_width'] = element('image_width', $filedata) ? element('image_width', $filedata) : 0;
$uploadfiledata[$i]['ufi_height'] = element('image_height', $filedata) ? element('image_height', $filedata) : 0;
$uploadfiledata[$i]['ufi_type'] = str_replace('.', '', element('file_ext', $filedata));
$uploadfiledata[$i]['is_image'] = element('is_image', $filedata) ? element('is_image', $filedata) : 0;
} else {
$file_error = $this->upload->display_errors();
break;
}
}
}
}
if (isset($_FILES) && isset($_FILES['upload_file_update'])
&& isset($_FILES['upload_file_update']['name'])
&& is_array($_FILES['upload_file_update']['name'])
&& $file_error === '') {
$filecount = count($_FILES['upload_file_update']['name']);
$upload_path = config_item('uploads_dir') . '/files/';
if (is_dir($upload_path) === false) {
mkdir($upload_path, 0707);
$file = $upload_path . 'index.php';
$f = @fopen($file, 'w');
@fwrite($f, '');
@fclose($f);
@chmod($file, 0644);
}
$upload_path .= cdate('Y') . '/';
if (is_dir($upload_path) === false) {
mkdir($upload_path, 0707);
$file = $upload_path . 'index.php';
$f = @fopen($file, 'w');
@fwrite($f, '');
@fclose($f);
@chmod($file, 0644);
}
$upload_path .= cdate('m') . '/';
if (is_dir($upload_path) === false) {
mkdir($upload_path, 0707);
$file = $upload_path . 'index.php';
$f = @fopen($file, 'w');
@fwrite($f, '');
@fclose($f);
@chmod($file, 0644);
}
foreach ($_FILES['upload_file_update']['name'] as $i => $value) {
if ($value) {
$uploadconfig = '';
$uploadconfig['upload_path'] = $upload_path;
$uploadconfig['allowed_types'] = '*';
$uploadconfig['max_size'] = 10240;
$uploadconfig['encrypt_name'] = true;
$this->upload->initialize($uploadconfig);
$_FILES['userfile']['name'] = $_FILES['upload_file_update']['name'][$i];
$_FILES['userfile']['type'] = $_FILES['upload_file_update']['type'][$i];
$_FILES['userfile']['tmp_name'] = $_FILES['upload_file_update']['tmp_name'][$i];
$_FILES['userfile']['error'] = $_FILES['upload_file_update']['error'][$i];
$_FILES['userfile']['size'] = $_FILES['upload_file_update']['size'][$i];
if ($this->upload->do_upload()) {
$filedata = $this->upload->data();
$olduploadfile = $this->Upload_file_model->get_one($i);
if ((int) element('origin_id', $olduploadfile) !== (int) element('app_id', $getdata)) {
alert('잘못된 접근입니다');
}
@unlink(config_item('uploads_dir') . '/files/' . element('ufi_filename', $oldpostfile));
$uploadfiledata2[$i]['ufi_id'] = $i;
$uploadfiledata2[$i]['ufi_filename'] = cdate('Y') . '/' . cdate('m') . '/' . element('file_name', $filedata);
$uploadfiledata2[$i]['ufi_originname'] = element('orig_name', $filedata);
$uploadfiledata2[$i]['ufi_filesize'] = intval(element('file_size', $filedata) * 1024);
$uploadfiledata2[$i]['ufi_width'] = element('image_width', $filedata)
? element('image_width', $filedata) : 0;
$uploadfiledata2[$i]['ufi_height'] = element('image_height', $filedata)
? element('image_height', $filedata) : 0;
$uploadfiledata2[$i]['ufi_type'] = str_replace('.', '', element('file_ext', $filedata));
$uploadfiledata2[$i]['is_image'] = element('is_image', $filedata)
? element('is_image', $filedata) : 0;
} else {
$file_error = $this->upload->display_errors();
break;
}
}
}
}
}
/**
* 유효성 검사를 하지 않는 경우, 또는 유효성 검사에 실패한 경우입니다.
* 즉 글쓰기나 수정 페이지를 보고 있는 경우입니다
*/
if ($form_validation === false OR $file_error !== '') {
if ( ! $pid) {
$max_sort = $this->{$this->modelname}->select_max_sort();
$getdata['app_sort'] = $max_sort + 1;
}
$view['view']['data'] = $getdata;
/**
* primary key 정보를 저장합니다
*/
$view['view']['primary_key'] = $primary_key;
if (element('app_id', $getdata)) {
$uploadwhere = array(
'origin_table' => 'apps',
'origin_id' => element('app_id', $getdata),
);
$view['view']['file'] = $file = $this->Upload_file_model->get('', '', $uploadwhere, '', '', 'ufi_id', 'ASC');
if ($file && is_array($file)) {
foreach ($file as $key => $value) {
$view['view']['file'][$key]['download_link']
= site_url('download/downfiles/' . element('ufi_id', $value));
}
}
}
/**
* 어드민 레이아웃을 정의합니다
*/
$layoutconfig = array('layout' => 'layout', 'skin' => 'write');
$view['layout'] = $this->layoutlib->admin($layoutconfig, $this->configlib->get_device_view_type());
$this->data = $view;
$this->layout = element('layout_skin_file', element('layout', $view));
$this->view = element('view_skin_file', element('layout', $view));
} else {
/**
* 유효성 검사를 통과한 경우입니다.
* 즉 데이터의 insert 나 update 의 process 처리가 필요한 상황입니다
*/
$updatedata = array(
'app_package' => $this->input->post('app_package', null, ''),
'app_name' => $this->input->post('app_name', null, ''),
'app_sort' => $this->input->post('app_sort', null, ''),
'app_policy' => $this->input->post('app_policy', null, ''),
);
/**
* 게시물을 수정하는 경우입니다
*/
if ($this->input->post($primary_key)) {
$this->accesslevel->check_admin('edit');
$updatedata['app_updated_at'] = cdate('Y-m-d H:i:s');
$this->{$this->modelname}->update($this->input->post($primary_key), $updatedata);
$origin_id = $this->input->post($primary_key);
$this->session->set_flashdata('message','정상적으로 수정되었습니다');
} else {
$this->accesslevel->check_admin('write');
/**
* 게시물을 새로 입력하는 경우입니다
*/
$updatedata['app_created_at'] = cdate('Y-m-d H:i:s');
$updatedata['app_updated_at'] = cdate('Y-m-d H:i:s');
$origin_id = $this->{$this->modelname}->insert($updatedata);
$this->session->set_flashdata('message','정상적으로 입력되었습니다');
}
$file_updated = false;
$file_changed = false;
if (is_array($uploadfiledata) && count($uploadfiledata) > 0) {
foreach ($uploadfiledata as $pkey => $pval) {
if ($pval) {
$fileupdate = array(
'origin_id' => $origin_id,
'origin_table' => 'apps',
'user_id' => $this->userlib->item('user_id'),
'ufi_originname' => element('ufi_originname', $pval),
'ufi_filename' => element('ufi_filename', $pval),
'ufi_filesize' => element('ufi_filesize', $pval),
'ufi_width' => element('ufi_width', $pval),
'ufi_height' => element('ufi_height', $pval),
'ufi_type' => element('ufi_type', $pval),
'ufi_is_image' => element('is_image', $pval),
'ufi_datetime' => cdate('Y-m-d H:i:s'),
'ufi_ip' => $this->input->ip_address(),
);
$file_id = $this->Upload_file_model->insert($fileupdate);
$file_updated = true;
}
}
$file_changed = true;
}
if (is_array($uploadfiledata2) && count($uploadfiledata2) > 0) {
foreach ($uploadfiledata2 as $pkey => $pval) {
if ($pval) {
$fileupdate = array(
'user_id' => $this->userlib->item('user_id'),
'ufi_originname' => element('ufi_originname', $pval),
'ufi_filename' => element('ufi_filename', $pval),
'ufi_filesize' => element('ufi_filesize', $pval),
'ufi_width' => element('ufi_width', $pval),
'ufi_height' => element('ufi_height', $pval),
'ufi_type' => element('ufi_type', $pval),
'ufi_is_image' => element('is_image', $pval),
'ufi_datetime' => cdate('Y-m-d H:i:s'),
'ufi_ip' => $this->input->ip_address(),
);
$this->Upload_file_model->update($pkey, $fileupdate);
$file_changed = true;
}
}
}
if ($this->input->post('upload_file_del')) {
foreach ($this->input->post('upload_file_del') as $key => $val) {
if ($val === '1' && ! isset($uploadfiledata2[$key])) {
$olduploadfile = $this->Upload_file_model->get_one($key);
if ( ! element('origin_id', $olduploadfile) OR (int) element('origin_id', $olduploadfile) !== (int) $origin_id) {
alert('잘못된 접근입니다.');
}
@unlink(config_item('uploads_dir') . '/files/' . element('ufi_filename', $olduploadfile));
$this->Upload_file_model->delete($key);
$file_changed = true;
}
}
}
/**
* 게시물의 신규입력 또는 수정작업이 끝난 후 목록 페이지로 이동합니다
*/
$redirecturl = admin_url($this->pagedir . '/write/' . $pid);
redirect($redirecturl);
}
}
/**
* 게시판 글쓰기 또는 수정 페이지를 가져오는 메소드입니다
*/
public function write_rank($pid = 0)
{
$this->accesslevel->check_admin('read');
$view = array();
$view['view'] = array();
/**
* 프라이머리키에 숫자형이 입력되지 않으면 에러처리합니다
*/
if ($pid) {
$pid = (int) $pid;
if (empty($pid) OR $pid < 1) {
show_404();
}
}
$primary_key = $this->{$this->modelname}->primary_key;
/**
* 수정 페이지일 경우 기존 데이터를 가져옵니다
*/
$getdata = array();
if ($pid) {
$getdata = $this->{$this->modelname}->get_one($pid);
$getdata['app_rank'] = json_decode($getdata['app_rank'], true);
}
/**
* Validation 라이브러리를 가져옵니다
*/
$this->load->library('form_validation');
/**
* 전송된 데이터의 유효성을 체크합니다
*/
$config = array(
array(
'field' => 'is_submit',
'label' => '전송',
'rules' => 'trim|required',
),
array(
'field' => 'app_rank_1_title',
'label' => '1위 제목',
'rules' => 'trim|required',
),
array(
'field' => 'app_rank_1_desc',
'label' => '1위 소개내용',
'rules' => 'trim|required',
),
array(
'field' => 'app_rank_1_link',
'label' => '1위 링크',
'rules' => 'trim',
),
array(
'field' => 'app_rank_1_image_url',
'label' => '1위 이미지 URL',
'rules' => 'trim',
),
array(
'field' => 'app_rank_2_title',
'label' => '2위 제목',
'rules' => 'trim|required',
),
array(
'field' => 'app_rank_2_desc',
'label' => '2위 소개내용',
'rules' => 'trim|required',
),
array(
'field' => 'app_rank_2_link',
'label' => '2위 링크',
'rules' => 'trim',
),
array(
'field' => 'app_rank_2_image_url',
'label' => '2위 이미지 URL',
'rules' => 'trim',
),
array(
'field' => 'app_rank_3_title',
'label' => '3위 제목',
'rules' => 'trim|required',
),
array(
'field' => 'app_rank_3_desc',
'label' => '3위 소개내용',
'rules' => 'trim|required',
),
array(
'field' => 'app_rank_3_link',
'label' => '3위 링크',
'rules' => 'trim',
),
array(
'field' => 'app_rank_3_image_url',
'label' => '3위 이미지 URL',
'rules' => 'trim',
),
);
$this->form_validation->set_rules($config);
/**
* 유효성 검사를 하지 않는 경우, 또는 유효성 검사에 실패한 경우입니다.
* 즉 글쓰기나 수정 페이지를 보고 있는 경우입니다
*/
if ($this->form_validation->run() === false) {
$view['view']['data'] = $getdata['app_rank'];
$view['view']['data']['app_id'] = $getdata['app_id'];
/**
* 어드민 레이아웃을 정의합니다
*/
$layoutconfig = array('layout' => 'layout', 'skin' => 'write_rank');
$view['layout'] = $this->layoutlib->admin($layoutconfig, $this->configlib->get_device_view_type());
$this->data = $view;
$this->layout = element('layout_skin_file', element('layout', $view));
$this->view = element('view_skin_file', element('layout', $view));
} else {
/**
* 유효성 검사를 통과한 경우입니다.
* 즉 데이터의 insert 나 update 의 process 처리가 필요한 상황입니다
*/
$updatedata = array(
'app_rank_1_title' => $this->input->post('app_rank_1_title', null, ''),
'app_rank_1_desc' => $this->input->post('app_rank_1_desc', null, ''),
'app_rank_1_link' => $this->input->post('app_rank_1_link', null, ''),
'app_rank_2_title' => $this->input->post('app_rank_2_title', null, ''),
'app_rank_2_desc' => $this->input->post('app_rank_2_desc', null, ''),
'app_rank_2_link' => $this->input->post('app_rank_2_link', null, ''),
'app_rank_3_title' => $this->input->post('app_rank_3_title', null, ''),
'app_rank_3_desc' => $this->input->post('app_rank_3_desc', null, ''),
'app_rank_3_link' => $this->input->post('app_rank_3_link', null, ''),
'app_rank_1_image_url' => element('app_rank_1_image_url', element('app_rank', $getdata)),
'app_rank_2_image_url' => element('app_rank_2_image_url', element('app_rank', $getdata)),
'app_rank_3_image_url' => element('app_rank_3_image_url', element('app_rank', $getdata)),
);
$this->accesslevel->check_admin('edit');
$this->load->library('upload');
$app_rank_1_image_url = '';
if (isset($_FILES) && isset($_FILES['app_rank_1_image_url']) && isset($_FILES['app_rank_1_image_url']['name']) && $_FILES['app_rank_1_image_url']['name']) {
$upload_path = config_item('uploads_dir') . '/apprank/';
if (is_dir($upload_path) === false) {
mkdir($upload_path, 0707);
$file = $upload_path . 'index.php';
$f = @fopen($file, 'w');
@fwrite($f, '');
@fclose($f);
@chmod($file, 0644);
}
$uploadconfig = '';
$uploadconfig['upload_path'] = $upload_path;
$uploadconfig['allowed_types'] = 'jpg|jpeg|png|gif';
$uploadconfig['max_size'] = '2000';
$uploadconfig['max_width'] = '1000';
$uploadconfig['max_height'] = '1000';
$uploadconfig['encrypt_name'] = true;
$this->upload->initialize($uploadconfig);
if ($this->upload->do_upload('app_rank_1_image_url')) {
$img = $this->upload->data();
$app_rank_1_image_url = element('file_name', $img);
} else {
$file_error = $this->upload->display_errors();
}
}
$app_rank_2_image_url = '';
if (isset($_FILES) && isset($_FILES['app_rank_2_image_url']) && isset($_FILES['app_rank_2_image_url']['name']) && $_FILES['app_rank_2_image_url']['name']) {
$upload_path = config_item('uploads_dir') . '/apprank/';
if (is_dir($upload_path) === false) {
mkdir($upload_path, 0707);
$file = $upload_path . 'index.php';
$f = @fopen($file, 'w');
@fwrite($f, '');
@fclose($f);
@chmod($file, 0644);
}
$uploadconfig = '';
$uploadconfig['upload_path'] = $upload_path;
$uploadconfig['allowed_types'] = 'jpg|jpeg|png|gif';
$uploadconfig['max_size'] = '2000';
$uploadconfig['max_width'] = '1000';
$uploadconfig['max_height'] = '1000';
$uploadconfig['encrypt_name'] = true;
$this->upload->initialize($uploadconfig);
if ($this->upload->do_upload('app_rank_2_image_url')) {
$img = $this->upload->data();
$app_rank_2_image_url = element('file_name', $img);
} else {
$file_error = $this->upload->display_errors();
}
}
$app_rank_3_image_url = '';
if (isset($_FILES) && isset($_FILES['app_rank_3_image_url']) && isset($_FILES['app_rank_3_image_url']['name']) && $_FILES['app_rank_3_image_url']['name']) {
$upload_path = config_item('uploads_dir') . '/apprank/';
if (is_dir($upload_path) === false) {
mkdir($upload_path, 0707);
$file = $upload_path . 'index.php';
$f = @fopen($file, 'w');
@fwrite($f, '');
@fclose($f);
@chmod($file, 0644);
}
$uploadconfig = '';
$uploadconfig['upload_path'] = $upload_path;
$uploadconfig['allowed_types'] = 'jpg|jpeg|png|gif';
$uploadconfig['max_size'] = '2000';
$uploadconfig['max_width'] = '1000';
$uploadconfig['max_height'] = '1000';
$uploadconfig['encrypt_name'] = true;
$this->upload->initialize($uploadconfig);
if ($this->upload->do_upload('app_rank_3_image_url')) {
$img = $this->upload->data();
$app_rank_3_image_url = element('file_name', $img);
} else {
$file_error = $this->upload->display_errors();
}
}
if ($app_rank_1_image_url) {
$updatedata['app_rank_1_image_url'] = $app_rank_1_image_url;
}
if ($app_rank_2_image_url) {
$updatedata['app_rank_2_image_url'] = $app_rank_2_image_url;
}
if ($app_rank_3_image_url) {
$updatedata['app_rank_3_image_url'] = $app_rank_3_image_url;
}
$updata = json_encode($updatedata,JSON_UNESCAPED_UNICODE);
$this->{$this->modelname}->update($pid, array('app_rank' => $updata));
$this->session->set_flashdata('message','정상적으로 수정되었습니다');
/**
* 게시물의 신규입력 또는 수정작업이 끝난 후 목록 페이지로 이동합니다
*/
$redirecturl = admin_url($this->pagedir . '/write_rank/' . $pid);
redirect($redirecturl);
}
}
/**
* 목록 페이지에서 선택삭제를 하는 경우 실행되는 메소드입니다
*/
public function listdelete()
{
$this->accesslevel->check_admin('delete');
/**
* 체크한 게시물의 삭제를 실행합니다
*/
if ($this->input->post('chk') && is_array($this->input->post('chk'))) {
foreach ($this->input->post('chk') as $val) {
if ($val) {
$this->{$this->modelname}->delete($val);
}
}
}
/**
* 삭제가 끝난 후 목록페이지로 이동합니다
*/
$this->session->set_flashdata('message','정상적으로 삭제되었습니다');
$param =& $this->querystring;
$redirecturl = admin_url($this->pagedir . '?' . $param->output());
redirect($redirecturl);
}
}

View File

@@ -0,0 +1,260 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
/**
* Configlibs class
*/
/**
* 관리자>환경설정>기본환경설정 controller 입니다.
*/
class Configlibs extends MY_Controller
{
/**
* 관리자 페이지 상의 현재 디렉토리입니다
* 페이지 이동시 필요한 정보입니다
*/
public $pagedir = 'config/configlibs';
/**
* 모델을 로딩합니다
*/
protected $models = array('Config');
/**
* 이 컨트롤러의 메인 모델 이름입니다
*/
protected $modelname = 'Config_model';
/**
* 헬퍼를 로딩합니다
*/
protected $helpers = array('form', 'array', 'dhtml_editor');
function __construct()
{
parent::__construct();
}
/**
* 기본환경설정>기본정보 페이지입니다
*/
public function index()
{
$this->accesslevel->check_admin('read');
$view = array();
$view['view'] = array();
/**
* Validation 라이브러리를 가져옵니다
*/
$this->load->library('form_validation');
/**
* 전송된 데이터의 유효성을 체크합니다
*/
$config = array(
array(
'field' => 'is_submit',
'label' => '전송',
'rules' => 'trim|required',
),
array(
'field' => 'site_title',
'label' => '홈페이지 제목',
'rules' => 'trim|required',
),
array(
'field' => 'admin_logo',
'label' => '관리자페이지 로고',
'rules' => 'trim|required',
),
array(
'field' => 'footer_script',
'label' => '하단스크립트',
'rules' => 'trim',
),
array(
'field' => 'webmaster_name',
'label' => '웹마스터 이름',
'rules' => 'trim|required',
),
array(
'field' => 'webmaster_email',
'label' => '웹마스터 이메일주소',
'rules' => 'trim|required|valid_email',
),
array(
'field' => 'spam_word',
'label' => '단어 필터링',
'rules' => 'trim',
),
array(
'field' => 'white_iframe',
'label' => '허용하는 Iframe 주소',
'rules' => 'trim',
),
array(
'field' => 'use_recaptcha',
'label' => '구글 캡챠 사용 여부',
'rules' => 'trim|numeric|is_natural',
),
array(
'field' => 'recaptcha_sitekey',
'label' => '구글 reCaptcha Sitekey',
'rules' => 'trim',
),
array(
'field' => 'recaptcha_secret',
'label' => '구글 reCaptcha Secret',
'rules' => 'trim',
),
);
$this->form_validation->set_rules($config);
/**
* 유효성 검사를 하지 않는 경우, 또는 유효성 검사에 실패한 경우입니다.
* 즉 글쓰기나 수정 페이지를 보고 있는 경우입니다
*/
if ($this->form_validation->run() === false) {
} else {
$this->accesslevel->check_admin('edit');
/**
* 유효성 검사를 통과한 경우입니다.
* 즉 데이터의 insert 나 update 의 process 처리가 필요한 상황입니다
*/
$array = array(
'site_title', 'admin_logo', 'footer_script', 'webmaster_name', 'webmaster_email',
'spam_word', 'white_iframe',
'use_recaptcha', 'recaptcha_sitekey', 'recaptcha_secret'
);
foreach ($array as $value) {
$savedata[$value] = $this->input->post($value, null, '');
}
$this->Config_model->save($savedata);
$view['view']['alert_message'] = '기본정보 설정이 저장되었습니다';
}
$getdata = $this->Config_model->get_all_meta();
$view['view']['data'] = $getdata;
/**
* 어드민 레이아웃을 정의합니다
*/
$layoutconfig = array('layout' => 'layout', 'skin' => 'index');
$view['layout'] = $this->layoutlib->admin($layoutconfig, $this->configlib->get_device_view_type());
$this->data = $view;
$this->layout = element('layout_skin_file', element('layout', $view));
$this->view = element('view_skin_file', element('layout', $view));
}
/**
* 기본환경설정>접근기능 페이지입니다
*/
public function access()
{
$this->accesslevel->check_admin('read');
$view = array();
$view['view'] = array();
/**
* Validation 라이브러리를 가져옵니다
*/
$this->load->library('form_validation');
/**
* 전송된 데이터의 유효성을 체크합니다
*/
$config = array(
array(
'field' => 'is_submit',
'label' => '전송',
'rules' => 'trim|required',
),
array(
'field' => 'admin_ip_whitelist',
'label' => '관리자페이지 접근가능 IP',
'rules' => 'trim',
),
array(
'field' => 'site_ip_blacklist',
'label' => '사이트 접근 불가 IP',
'rules' => 'trim',
),
array(
'field' => 'site_ip_whitelist',
'label' => '사이트 접근 가능 IP',
'rules' => 'trim',
),
array(
'field' => 'site_blacklist_title',
'label' => '사이트 차단시 안내문 제목',
'rules' => 'trim',
),
array(
'field' => 'site_blacklist_content',
'label' => '사이트 차단시 안내문 내용',
'rules' => 'trim',
),
);
$this->form_validation->set_rules($config);
/**
* 유효성 검사를 하지 않는 경우, 또는 유효성 검사에 실패한 경우입니다.
* 즉 글쓰기나 수정 페이지를 보고 있는 경우입니다
*/
if ($this->form_validation->run() === false) {
} else {
$this->accesslevel->check_admin('edit');
/**
* 유효성 검사를 통과한 경우입니다.
* 즉 데이터의 insert 나 update 의 process 처리가 필요한 상황입니다
*/
$array = array(
'admin_ip_whitelist', 'site_ip_blacklist', 'site_ip_whitelist',
'site_blacklist_title', 'site_blacklist_content',
);
foreach ($array as $value) {
$savedata[$value] = $this->input->post($value, null, '');
}
$this->Config_model->save($savedata);
$view['view']['alert_message'] = '접근기능 설정이 저장되었습니다';
}
$getdata = $this->Config_model->get_all_meta();
$view['view']['data'] = $getdata;
/**
* 어드민 레이아웃을 정의합니다
*/
$layoutconfig = array('layout' => 'layout', 'skin' => 'access');
$view['layout'] = $this->layoutlib->admin($layoutconfig, $this->configlib->get_device_view_type());
$this->data = $view;
$this->layout = element('layout_skin_file', element('layout', $view));
$this->view = element('view_skin_file', element('layout', $view));
}
}

View File

@@ -0,0 +1,120 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
/**
* Dbupgrade class
*/
/**
* 관리자>환경설정>DB 업그레이드 controller 입니다.
*/
class Dbupgrade extends MY_Controller
{
/**
* 관리자 페이지 상의 현재 디렉토리입니다
* 페이지 이동시 필요한 정보입니다
*/
public $pagedir = 'config/dbupgrade';
/**
* 모델을 로딩합니다
*/
protected $models = array();
/**
* 이 컨트롤러의 메인 모델 이름입니다
*/
protected $modelname = '';
/**
* 헬퍼를 로딩합니다
*/
protected $helpers = array('form', 'array');
function __construct()
{
parent::__construct();
/**
* 라이브러리를 로딩합니다
*/
$this->load->library(array('querystring'));
}
/**
* 디비 업그레이드 페이지입니다
*/
public function index()
{
$this->accesslevel->check_admin('read');
$view = array();
$view['view'] = array();
/**
* 마이그레이션 라이브러리를 가져옵니다
*/
$this->load->library('migration');
$this->config->load('migration');
$row = $this->db->get('migrations')->row();
$view['view']['current_version'] = $row ? $row->version : 0;
$view['view']['latest_version'] = $latest_version = config_item('migration_version');
/**
* Validation 라이브러리를 가져옵니다
*/
$this->load->library('form_validation');
/**
* 전송된 데이터의 유효성을 체크합니다
*/
$config = array(
array(
'field' => 'execute',
'label' => '실행',
'rules' => 'trim',
),
);
$this->form_validation->set_rules($config);
/**
* 유효성 검사를 하지 않는 경우, 또는 유효성 검사에 실패한 경우입니다.
* 즉 글쓰기나 수정 페이지를 보고 있는 경우입니다
*/
if ($this->form_validation->run() === false) {
} else {
$this->accesslevel->check_admin('edit');
/**
* 유효성 검사를 통과한 경우입니다.
* 즉 데이터의 insert 나 update 의 process 처리가 필요한 상황입니다
*/
if ($this->migration->version($latest_version) === false) {
$view['view']['alert_message'] = $this->migration->error_string();
} else {
$row = $this->db->get('migrations')->row();
$view['view']['current_version'] = $row ? $row->version : 0;
$view['view']['latest_version'] = config_item('migration_version');
$view['view']['alert_message'] = '최신버전으로 업그레이드가 완료되었습니다';
}
}
/**
* 어드민 레이아웃을 정의합니다
*/
$layoutconfig = array('layout' => 'layout', 'skin' => 'index');
$view['layout'] = $this->layoutlib->admin($layoutconfig, $this->configlib->get_device_view_type());
$this->data = $view;
$this->layout = element('layout_skin_file', element('layout', $view));
$this->view = element('view_skin_file', element('layout', $view));
}
}

View File

@@ -0,0 +1,764 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
/**
* Userconfig class
*/
/**
* 관리자>환경설정>회원가입설정 controller 입니다.
*/
class Userconfig extends MY_Controller
{
/**
* 관리자 페이지 상의 현재 디렉토리입니다
* 페이지 이동시 필요한 정보입니다
*/
public $pagedir = 'config/userconfig';
/**
* 모델을 로딩합니다
*/
protected $models = array('Config');
/**
* 이 컨트롤러의 메인 모델 이름입니다
*/
protected $modelname = 'Config_model';
/**
* 헬퍼를 로딩합니다
*/
protected $helpers = array('form', 'array');
function __construct()
{
parent::__construct();
}
/**
* 회원가입설정>기본정보 페이지입니다
*/
public function index()
{
$this->accesslevel->check_admin('read');
$view = array();
$view['view'] = array();
/**
* Validation 라이브러리를 가져옵니다
*/
$this->load->library('form_validation');
/**
* 전송된 데이터의 유효성을 체크합니다
*/
$config = array(
array(
'field' => 'is_submit',
'label' => '전송',
'rules' => 'trim|numeric',
),
array(
'field' => 'use_login_account',
'label' => '로그인시 사용할 계정',
'rules' => 'trim|required',
),
array(
'field' => 'use_register_block',
'label' => '회원가입차단',
'rules' => 'trim|numeric',
),
array(
'field' => 'use_register_email_auth',
'label' => '회원가입시 메일인증사용',
'rules' => 'trim|numeric',
),
array(
'field' => 'password_length',
'label' => '비밀번호 길이',
'rules' => 'trim|required|numeric|is_natural_no_zero',
),
array(
'field' => 'password_uppercase_length',
'label' => '비밀번호 대문자 포함 개수',
'rules' => 'trim|required|numeric',
),
array(
'field' => 'password_numbers_length',
'label' => '비밀번호 수자 포함 개수',
'rules' => 'trim|required|numeric',
),
array(
'field' => 'password_specialchars_length',
'label' => '비밀번호 특수문자 포함 개수',
'rules' => 'trim|required|numeric',
),
array(
'field' => 'use_user_photo',
'label' => '회원프로필사진',
'rules' => 'trim|numeric',
),
array(
'field' => 'user_photo_width',
'label' => '회원프로필사진가로길이',
'rules' => 'trim|numeric',
),
array(
'field' => 'user_photo_height',
'label' => '회원프로필사진세로길이',
'rules' => 'trim|numeric',
),
array(
'field' => 'use_user_icon',
'label' => '회원아이콘',
'rules' => 'trim|numeric',
),
array(
'field' => 'user_icon_width',
'label' => '회원아이콘가로길이',
'rules' => 'trim|numeric',
),
array(
'field' => 'user_icon_height',
'label' => '회원아이콘세로길이',
'rules' => 'trim|numeric',
),
array(
'field' => 'denied_username_list',
'label' => '금지 회원명',
'rules' => 'trim',
),
array(
'field' => 'denied_email_list',
'label' => '금지 이메일',
'rules' => 'trim',
),
);
$this->form_validation->set_rules($config);
/**
* 유효성 검사를 하지 않는 경우, 또는 유효성 검사에 실패한 경우입니다.
* 즉 글쓰기나 수정 페이지를 보고 있는 경우입니다
*/
if ($this->form_validation->run() === false) {
} else {
$this->accesslevel->check_admin('edit');
/**
* 유효성 검사를 통과한 경우입니다.
* 즉 데이터의 insert 나 update 의 process 처리가 필요한 상황입니다
*/
$array = array('use_login_account', 'use_register_block', 'use_register_email_auth',
'password_length', 'password_uppercase_length', 'password_numbers_length',
'password_specialchars_length', 'use_user_photo', 'user_photo_width',
'user_photo_height', 'use_user_icon', 'user_icon_width', 'user_icon_height',
'denied_username_list', 'denied_email_list');
foreach ($array as $value) {
$savedata[$value] = $this->input->post($value, null, '');
}
$this->Config_model->save($savedata);
$view['view']['alert_message'] = '회원가입 기본정보설정이 저장되었습니다';
}
$getdata = $this->Config_model->get_all_meta();
$view['view']['data'] = $getdata;
/**
* 어드민 레이아웃을 정의합니다
*/
$layoutconfig = array('layout' => 'layout', 'skin' => 'index');
$view['layout'] = $this->layoutlib->admin($layoutconfig, $this->configlib->get_device_view_type());
$this->data = $view;
$this->layout = element('layout_skin_file', element('layout', $view));
$this->view = element('view_skin_file', element('layout', $view));
}
/**
* 회원가입설정>가입폼관리 페이지입니다
*/
public function registerform()
{
$this->accesslevel->check_admin('read');
$view = array();
$view['view'] = array();
/**
* Validation 라이브러리를 가져옵니다
*/
$this->load->library('form_validation');
/**
* 전송된 데이터의 유효성을 체크합니다
*/
$config = array(
array(
'field' => 's',
'label' => '회원가입폼',
'rules' => 'trim',
),
);
$this->form_validation->set_rules($config);
$default_form = array(
'user_email' => array(
'name' => '이메일주소', 'field_type' => 'email', 'use' => true, 'disable_use' => true, 'open' => false, 'disable_open' => true, 'required' => true, 'disable_required' => true
),
'user_password' => array(
'name' => '비밀번호', 'field_type' => 'password', 'use' => true, 'disable_use' => true, 'open' => false, 'disable_open' => true, 'required' => true, 'disable_required' => true
),
'user_username' => array(
'name' => '이름', 'field_type' => 'text', 'use' => true, 'disable_use' => false, 'open' => false, 'disable_open' => false, 'required' => false, 'disable_required' => false
),
'user_homepage' => array(
'name' => '홈페이지', 'field_type' => 'url', 'use' => true, 'disable_use' => false, 'open' => false, 'disable_open' => false, 'required' => false, 'disable_required' => false
),
'user_phone' => array(
'name' => '전화번호', 'field_type' => 'phone', 'use' => true, 'disable_use' => false, 'open' => false, 'disable_open' => false, 'required' => false, 'disable_required' => false
),
'user_birthday' => array(
'name' => '생년월일', 'field_type' => 'date', 'use' => true, 'disable_use' => false, 'open' => false, 'disable_open' => false, 'required' => false, 'disable_required' => false
),
'user_sex' => array(
'name' => '성별', 'field_type' => 'radio', 'use' => true, 'disable_use' => false, 'open' => false, 'disable_open' => false, 'required' => false, 'disable_required' => false
),
'user_address' => array(
'name' => '주소', 'field_type' => 'address', 'use' => true, 'disable_use' => false, 'open' => false, 'disable_open' => false, 'required' => false, 'disable_required' => false
),
);
/**
* 유효성 검사를 하지 않는 경우, 또는 유효성 검사에 실패한 경우입니다.
* 즉 글쓰기나 수정 페이지를 보고 있는 경우입니다
*/
if ($this->form_validation->run() === false) {
} else {
$this->accesslevel->check_admin('edit');
/**
* 유효성 검사를 통과한 경우입니다.
* 즉 데이터의 insert 나 update 의 process 처리가 필요한 상황입니다
*/
$updatedata = $this->input->post();
$array_count_values = array_count_values($updatedata['field_name']);
$fail = false;
if ($fail === false) {
foreach ($array_count_values as $akey => $aval) {
if ($aval > 1) {
$view['view']['warning_message'] = $akey . ' 값이 ' . $aval . ' 회 중복 입력되었습니다. ID 값이 중복되지 않게 입력해주세요';
$fail = true;
break;
}
}
}
if ($fail === false) {
foreach (element('field_name', $updatedata) as $fkey => $fval) {
if (empty($fval)) {
$view['view']['warning_message'] = '비어있는 ID 값이 있습니다. ID 값을 빠뜨리지 말고 입력해주세요';
$fail = true;
break;
}
}
}
if ($fail === false) {
foreach (element('display_name', $updatedata) as $fkey => $fval) {
if (empty($fval)) {
$view['view']['warning_message'] = '비어있는 입력항목제목이 있습니다. 입력항목제목 값을 빠뜨리지 말고 입력해주세요';
$fail = true;
break;
}
}
}
if ($fail === false) {
$order = 0;
$update = array();
$extra_vars_field = array();
foreach (element('key', $updatedata) as $key => $value) {
if ($value) {
if (isset($updatedata['basic'][$value]) && $updatedata['basic'][$value]) {
$update[$value]['field_name'] = $value;
$update[$value]['func'] = 'basic';
$update[$value]['display_name'] = element('name', element($value, $default_form));
$update[$value]['field_type'] = element('field_type', element($value, $default_form));
$update[$value]['use'] = element('disable_use', element($value, $default_form))
? (element('use', element($value, $default_form)) ? '1' : '')
: element($value, element('use', $updatedata));
$update[$value]['open'] = element('disable_open', element($value, $default_form))
? (element('open', element($value, $default_form)) ? '1' : '')
: element($value, element('open', $updatedata));
$update[$value]['required'] = element('disable_required', element($value, $default_form))
? (element('required', element($value, $default_form)) ? '1' : '')
: element($value, element('required', $updatedata));
} else {
$update[$value] = array(
'field_name' => element($order, element('field_name', $updatedata)),
'func' => 'added',
'display_name' => element($order, element('display_name', $updatedata)),
'field_type' => element($value, element('field_type', $updatedata)),
'use' => element($value, element('use', $updatedata)),
'open' => element($value, element('open', $updatedata)),
'required' => element($value, element('required', $updatedata)),
'options' => element($value, element('options', $updatedata)),
);
$extra_vars_field[] = element($order, element('field_name', $updatedata));
}
} else {
$update[$updatedata['field_name'][$order]] = array(
'field_name' => element($order, element('field_name', $updatedata)),
'func' => 'added',
'display_name' => element($order, element('display_name', $updatedata)),
'use' => element($key, element('use', $updatedata)),
'field_type' => element($key, element('field_type', $updatedata)),
'open' => element($key, element('open', $updatedata)),
'required' => element($key, element('required', $updatedata)),
'options' => element($key, element('options', $updatedata)),
);
$extra_vars_field[] = element($order, element('field_name', $updatedata));
}
$order++;
}
if ($default_form && is_array($default_form)) {
foreach ($default_form as $key => $value) {
if (isset($update[$key]) && $update[$key]) {
continue;
}
$update[$key]['field_name'] = $key;
$update[$key]['func'] = 'basic';
$update[$key]['display_name'] = element('name', element($key, $default_form));
$update[$key]['field_type'] = element('field_type', element($key, $default_form));
$update[$key]['use'] = element('disable_use', element($key, $default_form))
? (element('use', element($key, $default_form)) ? '1' : '')
: element($key, element('use', $updatedata));
$update[$key]['open'] = element('disable_open', element($key, $default_form))
? (element('open', element($key, $default_form)) ? '1' : '')
: element($key, element('open', $updatedata));
$update[$key]['required'] = element('disable_required', element($key, $default_form))
? (element('required', element($key, $default_form)) ? '1' : '')
: element($key, element('required', $updatedata));
}
}
$savedata = array(
'registerform' => json_encode($update),
);
$this->Config_model->save($savedata);
$view['view']['alert_message'] = '정상적으로 저장되었습니다';
}
}
$getdata = $this->Config_model->get_all_meta();
if ( ! element('registerform', $getdata)) {
foreach ($default_form as $key => $value) {
$initdata[$key]['field_name'] = $key;
$initdata[$key]['func'] = 'basic';
$initdata[$key]['display_name'] = element('name', element($key, $default_form));
$initdata[$key]['field_type'] = element('field_type', element($key, $default_form));
$initdata[$key]['use'] = element('disable_use', element($key, $default_form))
? (element('use', element($key, $default_form)) ? '1' : '') : '';
$initdata[$key]['open'] = element('disable_open', element($key, $default_form))
? (element('open', element($key, $default_form)) ? '1' : '') : '';
$initdata[$key]['required'] = element('disable_required', element($key, $default_form))
? (element('required', element($key, $default_form)) ? '1' : '') : '';
}
$getdata['registerform'] = json_encode($initdata);
}
$getdata['result'] = json_decode($getdata['registerform'], true);
$getdata['default_form'] = $default_form;
$view['view']['data'] = $getdata;
/**
* 어드민 레이아웃을 정의합니다
*/
$layoutconfig = array('layout' => 'layout', 'skin' => 'registerform');
$view['layout'] = $this->layoutlib->admin($layoutconfig, $this->configlib->get_device_view_type());
$this->data = $view;
$this->layout = element('layout_skin_file', element('layout', $view));
$this->view = element('view_skin_file', element('layout', $view));
}
/**
* 회원가입설정>로그인 페이지입니다
*/
public function login()
{
$this->accesslevel->check_admin('read');
$view = array();
$view['view'] = array();
/**
* Validation 라이브러리를 가져옵니다
*/
$this->load->library('form_validation');
/**
* 전송된 데이터의 유효성을 체크합니다
*/
$config = array(
array(
'field' => 'is_submit',
'label' => '전송',
'rules' => 'trim|numeric',
),
array(
'field' => 'change_password_date',
'label' => '비밀번호 갱신주기',
'rules' => 'trim|numeric|is_natural',
),
array(
'field' => 'max_login_try_count',
'label' => '로그인시도 회수제한',
'rules' => 'trim|numeric|is_natural',
),
array(
'field' => 'max_login_try_limit_second',
'label' => '로그인시도제한시간',
'rules' => 'trim|numeric|is_natural',
),
array(
'field' => 'url_after_login',
'label' => '로그인후이동할주소',
'rules' => 'trim',
),
array(
'field' => 'url_after_logout',
'label' => '로그아웃후이동할주소',
'rules' => 'trim',
),
);
$this->form_validation->set_rules($config);
/**
* 유효성 검사를 하지 않는 경우, 또는 유효성 검사에 실패한 경우입니다.
* 즉 글쓰기나 수정 페이지를 보고 있는 경우입니다
*/
if ($this->form_validation->run() === false) {
} else {
$this->accesslevel->check_admin('edit');
/**
* 유효성 검사를 통과한 경우입니다.
* 즉 데이터의 insert 나 update 의 process 처리가 필요한 상황입니다
*/
$array = array('change_password_date', 'max_login_try_count',
'max_login_try_limit_second', 'url_after_login', 'url_after_logout');
foreach ($array as $value) {
$savedata[$value] = $this->input->post($value, null, '');
}
$this->Config_model->save($savedata);
$view['view']['alert_message'] = '로그인 설정이 저장되었습니다';
}
$getdata = $this->Config_model->get_all_meta();
$view['view']['data'] = $getdata;
/**
* 어드민 레이아웃을 정의합니다
*/
$layoutconfig = array('layout' => 'layout', 'skin' => 'login');
$view['layout'] = $this->layoutlib->admin($layoutconfig, $this->configlib->get_device_view_type());
$this->data = $view;
$this->layout = element('layout_skin_file', element('layout', $view));
$this->view = element('view_skin_file', element('layout', $view));
}
/**
* 회원가입설정>알림 페이지입니다
*/
public function alarm()
{
$this->accesslevel->check_admin('read');
$view = array();
$view['view'] = array();
/**
* Validation 라이브러리를 가져옵니다
*/
$this->load->library('form_validation');
/**
* 전송된 데이터의 유효성을 체크합니다
*/
$config = array(
array(
'field' => 'is_submit',
'label' => '전송',
'rules' => 'trim|numeric',
),
array(
'field' => 'send_email_register_admin',
'label' => '회원가입시최고관리자에게메일발송',
'rules' => 'trim|numeric',
),
array(
'field' => 'send_email_register_user',
'label' => '회원가입시가입한회원에게메일발송',
'rules' => 'trim|numeric',
),
array(
'field' => 'send_email_register_alluser',
'label' => '회원가입시가입한회원에게메일발송',
'rules' => 'trim|numeric',
),
array(
'field' => 'send_email_changepw_admin',
'label' => '패스워드변경시최고관리자에게메일발송',
'rules' => 'trim|numeric',
),
array(
'field' => 'send_email_changepw_user',
'label' => '패스워드변경시가입한회원에게메일발송',
'rules' => 'trim|numeric',
),
array(
'field' => 'send_email_changepw_alluser',
'label' => '패스워드변경시가입한회원에게메일발송',
'rules' => 'trim|numeric',
),
array(
'field' => 'send_email_userleave_admin',
'label' => '패스워드변경시최고관리자에게메일발송',
'rules' => 'trim|numeric',
),
array(
'field' => 'send_email_userleave_user',
'label' => '패스워드변경시가입한회원에게메일발송',
'rules' => 'trim|numeric',
),
array(
'field' => 'send_email_userleave_alluser',
'label' => '패스워드변경시가입한회원에게메일발송',
'rules' => 'trim|numeric',
),
);
$this->form_validation->set_rules($config);
/**
* 유효성 검사를 하지 않는 경우, 또는 유효성 검사에 실패한 경우입니다.
* 즉 글쓰기나 수정 페이지를 보고 있는 경우입니다
*/
if ($this->form_validation->run() === false) {
} else {
$this->accesslevel->check_admin('edit');
/**
* 유효성 검사를 통과한 경우입니다.
* 즉 데이터의 insert 나 update 의 process 처리가 필요한 상황입니다
*/
$array = array(
'send_email_register_admin', 'send_email_register_user', 'send_email_register_alluser',
'send_email_changepw_admin', 'send_email_changepw_user', 'send_email_changepw_alluser',
'send_email_userleave_admin', 'send_email_userleave_user', 'send_email_userleave_alluser',
);
foreach ($array as $value) {
$savedata[$value] = $this->input->post($value, null, '');
}
$this->Config_model->save($savedata);
$view['view']['alert_message'] = '알림 설정이 저장되었습니다';
}
$getdata = $this->Config_model->get_all_meta();
$view['view']['data'] = $getdata;
/**
* 어드민 레이아웃을 정의합니다
*/
$layoutconfig = array('layout' => 'layout', 'skin' => 'alarm');
$view['layout'] = $this->layoutlib->admin($layoutconfig, $this->configlib->get_device_view_type());
$this->data = $view;
$this->layout = element('layout_skin_file', element('layout', $view));
$this->view = element('view_skin_file', element('layout', $view));
}
/**
* 회원가입설정>소셜로그인 페이지입니다
*/
public function sociallogin()
{
$this->accesslevel->check_admin('read');
$view = array();
$view['view'] = array();
/**
* Validation 라이브러리를 가져옵니다
*/
$this->load->library('form_validation');
/**
* 전송된 데이터의 유효성을 체크합니다
*/
$config = array(
array(
'field' => 'is_submit',
'label' => '전송',
'rules' => 'trim|numeric',
),
array(
'field' => 'use_sociallogin',
'label' => '소셜로그인 사용',
'rules' => 'trim|numeric|is_natural',
),
array(
'field' => 'use_sociallogin_facebook',
'label' => '페이스북 사용',
'rules' => 'trim|numeric|is_natural',
),
array(
'field' => 'facebook_app_id',
'label' => '페이스북 APP ID',
'rules' => 'trim',
),
array(
'field' => 'facebook_secret',
'label' => '페이스북 Secret',
'rules' => 'trim',
),
array(
'field' => 'use_sociallogin_twitter',
'label' => '트위터 사용',
'rules' => 'trim|numeric|is_natural',
),
array(
'field' => 'twitter_consumer_key',
'label' => '트위터 Consumer Key',
'rules' => 'trim',
),
array(
'field' => 'twitter_consumer_secret',
'label' => '트위터 Consumer Secret',
'rules' => 'trim',
),
array(
'field' => 'use_sociallogin_google',
'label' => '구글 사용',
'rules' => 'trim|numeric|is_natural',
),
array(
'field' => 'google_client_id',
'label' => '구글 Client ID',
'rules' => 'trim',
),
array(
'field' => 'google_client_secret',
'label' => '구글 Client Secret',
'rules' => 'trim',
),
array(
'field' => 'use_sociallogin_naver',
'label' => '네이버 사용',
'rules' => 'trim|numeric|is_natural',
),
array(
'field' => 'naver_client_id',
'label' => '네이버 Client ID',
'rules' => 'trim',
),
array(
'field' => 'naver_client_secret',
'label' => '네이버 Client Secret',
'rules' => 'trim',
),
array(
'field' => 'use_sociallogin_kakao',
'label' => '카카오 사용',
'rules' => 'trim|numeric|is_natural',
),
array(
'field' => 'kakao_client_id',
'label' => '카카오 Client ID',
'rules' => 'trim',
),
);
$this->form_validation->set_rules($config);
/**
* 유효성 검사를 하지 않는 경우, 또는 유효성 검사에 실패한 경우입니다.
* 즉 글쓰기나 수정 페이지를 보고 있는 경우입니다
*/
if ($this->form_validation->run() === false) {
} else {
$this->accesslevel->check_admin('edit');
/**
* 유효성 검사를 통과한 경우입니다.
* 즉 데이터의 insert 나 update 의 process 처리가 필요한 상황입니다
*/
$array = array(
'use_sociallogin', 'use_sociallogin_facebook', 'facebook_app_id',
'facebook_secret', 'use_sociallogin_twitter', 'twitter_consumer_key', 'twitter_consumer_secret',
'use_sociallogin_google', 'google_client_id', 'google_client_secret', 'use_sociallogin_naver',
'naver_client_id', 'naver_client_secret', 'use_sociallogin_kakao', 'kakao_client_id'
);
foreach ($array as $value) {
$savedata[$value] = $this->input->post($value, null, '');
}
$this->Config_model->save($savedata);
$view['view']['alert_message'] = '소셜로그인 설정이 저장되었습니다';
}
$getdata = $this->Config_model->get_all_meta();
$view['view']['data'] = $getdata;
/**
* 어드민 레이아웃을 정의합니다
*/
$layoutconfig = array('layout' => 'layout', 'skin' => 'sociallogin');
$view['layout'] = $this->layoutlib->admin($layoutconfig, $this->configlib->get_device_view_type());
$this->data = $view;
$this->layout = element('layout_skin_file', element('layout', $view));
$this->view = element('view_skin_file', element('layout', $view));
}
}

View File

@@ -0,0 +1,170 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
/**
* Bookmark class
*/
class Bookmark extends MY_Controller
{
/**
* 관리자 페이지 상의 현재 디렉토리입니다
* 페이지 이동시 필요한 정보입니다
*/
public $pagedir = 'contents/bookmark';
/**
* 모델을 로딩합니다
*/
protected $models = array('Contents_bookmark', 'Apps', 'Contents_category');
/**
* 이 컨트롤러의 메인 모델 이름입니다
*/
protected $modelname = 'Contents_bookmark_model';
/**
* 헬퍼를 로딩합니다
*/
protected $helpers = array('form', 'array');
function __construct()
{
parent::__construct();
/**
* 라이브러리를 로딩합니다
*/
$this->load->library(array('pagination', 'querystring'));
}
/**
* 목록을 가져오는 메소드입니다
*/
public function index()
{
$this->accesslevel->check_admin('read');
$view = array();
$view['view'] = array();
/**
* 페이지에 숫자가 아닌 문자가 입력되거나 1보다 작은 숫자가 입력되면 에러 페이지를 보여줍니다.
*/
$param =& $this->querystring;
$page = (((int) $this->input->get('page')) > 0) ? ((int) $this->input->get('page')) : 1;
$findex = $this->input->get('findex') ? $this->input->get('findex') : $this->{$this->modelname}->primary_key;
$forder = $this->input->get('forder', null, 'desc');
$sfield = $this->input->get('sfield', null, '');
$skeyword = $this->input->get('skeyword', null, '');
$per_page = admin_listnum();
$offset = ($page - 1) * $per_page;
/**
* 게시판 목록에 필요한 정보를 가져옵니다.
*/
$this->{$this->modelname}->allow_search_field = array('bookmark_id', 'target_user_id', 'contents_bookmark.user_id', 'contents', 'contents_bookmark.con_id'); // 검색이 가능한 필드
$this->{$this->modelname}->search_field_equal = array('bookmark_id', 'contents_bookmark.con_id'); // 검색중 like 가 아닌 = 검색을 하는 필드
$this->{$this->modelname}->allow_order_field = array('bookmark_id'); // 정렬이 가능한 필드
$where = array();
if ($this->input->get('app_id')) {
$where['contents_bookmark.app_id'] = $this->input->get('app_id');
}
$result = $this->{$this->modelname}
->get_admin_list($per_page, $offset, $where, '', $findex, $forder, $sfield, $skeyword);
$list_num = $result['total_rows'] - ($page - 1) * $per_page;
if (element('list', $result)) {
foreach (element('list', $result) as $key => $val) {
$result['list'][$key]['num'] = $list_num--;
if (element('cat1_id', $val)) {
$result['list'][$key]['category1'] = $this->Contents_category_model->get_one(element('cat1_id', $val));
}
if (element('cat2_id', $val)) {
$result['list'][$key]['category2'] = $this->Contents_category_model->get_one(element('cat2_id', $val));
}
/*
if (element('cat3_id', $val)) {
$result['list'][$key]['category3'] = $this->Contents_category_model->get_one(element('cat3_id', $val));
}
if (element('cat4_id', $val)) {
$result['list'][$key]['category4'] = $this->Contents_category_model->get_one(element('cat4_id', $val));
}
*/
$result['list'][$key]['display_name'] = display_username(
element('user_username', $val)
);
}
}
$view['view']['data'] = $result;
$view['view']['applist'] = $this->Apps_model->app_list();
/**
* primary key 정보를 저장합니다
*/
$view['view']['primary_key'] = $this->{$this->modelname}->primary_key;
/**
* 페이지네이션을 생성합니다
*/
$config['base_url'] = admin_url($this->pagedir) . '?' . $param->replace('page');
$config['total_rows'] = $result['total_rows'];
$config['per_page'] = $per_page;
$this->pagination->initialize($config);
$view['view']['paging'] = $this->pagination->create_links();
$view['view']['page'] = $page;
/**
* 쓰기 주소, 삭제 주소등 필요한 주소를 구합니다
*/
$search_option = array('bookmark_id' => '고유번호');
$view['view']['skeyword'] = ($sfield && array_key_exists($sfield, $search_option)) ? $skeyword : '';
$view['view']['search_option'] = search_option($search_option, $sfield);
$view['view']['listall_url'] = admin_url($this->pagedir);
/**
* 어드민 레이아웃을 정의합니다
*/
$layoutconfig = array('layout' => 'layout', 'skin' => 'index');
$view['layout'] = $this->layoutlib->admin($layoutconfig, $this->configlib->get_device_view_type());
$this->data = $view;
$this->layout = element('layout_skin_file', element('layout', $view));
$this->view = element('view_skin_file', element('layout', $view));
}
/**
* 목록 페이지에서 선택삭제를 하는 경우 실행되는 메소드입니다
*/
public function listdelete()
{
/**
* 체크한 게시물의 삭제를 실행합니다
*/
if ($this->input->post('chk') && is_array($this->input->post('chk'))) {
foreach ($this->input->post('chk') as $val) {
if ($val) {
$getdata = $this->{$this->modelname}->get_one($val);
$this->{$this->modelname}->delete($val);
}
}
}
/**
* 삭제가 끝난 후 목록페이지로 이동합니다
*/
$this->session->set_flashdata(
'message',
'정상적으로 삭제되었습니다'
);
$param =& $this->querystring;
$redirecturl = admin_url($this->pagedir . '?' . $param->output());
redirect($redirecturl);
}
}

View File

@@ -0,0 +1,172 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
/**
* Comment class
*/
class Comment extends MY_Controller
{
/**
* 관리자 페이지 상의 현재 디렉토리입니다
* 페이지 이동시 필요한 정보입니다
*/
public $pagedir = 'contents/comment';
/**
* 모델을 로딩합니다
*/
protected $models = array('Contents', 'Contents_comment', 'Upload_file', 'Apps', 'Contents_category');
/**
* 이 컨트롤러의 메인 모델 이름입니다
*/
protected $modelname = 'Contents_comment_model';
/**
* 헬퍼를 로딩합니다
*/
protected $helpers = array('form', 'array', 'dhtml_editor');
function __construct()
{
parent::__construct();
/**
* 라이브러리를 로딩합니다
*/
$this->load->library(array('pagination', 'querystring'));
}
/**
* 목록을 가져오는 메소드입니다
*/
public function index()
{
$this->accesslevel->check_admin('read');
$view = array();
$view['view'] = array();
/**
* 페이지에 숫자가 아닌 문자가 입력되거나 1보다 작은 숫자가 입력되면 에러 페이지를 보여줍니다.
*/
$param =& $this->querystring;
$page = (((int) $this->input->get('page')) > 0) ? ((int) $this->input->get('page')) : 1;
$findex = $this->input->get('findex') ? $this->input->get('findex') : 'con_sort';
$forder = $this->input->get('forder', null, 'desc');
$sfield = $this->input->get('sfield', null, '');
$skeyword = $this->input->get('skeyword', null, '');
$per_page = admin_listnum();
$offset = ($page - 1) * $per_page;
/**
* 게시판 목록에 필요한 정보를 가져옵니다.
*/
$this->{$this->modelname}->allow_search_field = array('app_id','com_id', 'contents_comment.con_id', 'com_content', 'contents_comment.user_id', 'contents.user_id', 'com_created_at'); // 검색이 가능한 필드
$this->{$this->modelname}->search_field_equal = array('app_id','com_id'); // 검색중 like 가 아닌 = 검색을 하는 필드
$this->{$this->modelname}->allow_order_field = array('con_id', 'com_id'); // 정렬이 가능한 필드
$where = array('contents.is_del' => '0');
if ($this->input->get('app_id')) {
$where['contents.app_id'] = $this->input->get('app_id');
}
if ($this->input->get('cat_id')) {
$where['contents.cat_id'] = $this->input->get('cat_id');
}
$result = $this->{$this->modelname}
->get_admin_list($per_page, $offset, $where, '', $findex, $forder, $sfield, $skeyword);
$list_num = $result['total_rows'] - ($page - 1) * $per_page;
if (element('list', $result)) {
foreach (element('list', $result) as $key => $val) {
$result['list'][$key]['num'] = $list_num--;
if (element('cat1_id', $val)) {
$result['list'][$key]['category1'] = $this->Contents_category_model->get_one(element('cat1_id', $val));
}
if (element('cat2_id', $val)) {
$result['list'][$key]['category2'] = $this->Contents_category_model->get_one(element('cat2_id', $val));
}
/*
if (element('cat3_id', $val)) {
$result['list'][$key]['category3'] = $this->Contents_category_model->get_one(element('cat3_id', $val));
}
if (element('cat4_id', $val)) {
$result['list'][$key]['category4'] = $this->Contents_category_model->get_one(element('cat4_id', $val));
}
*/
$result['list'][$key]['display_name'] = display_username(
element('user_username', $val)
);
}
}
$view['view']['data'] = $result;
$view['view']['applist'] = $this->Apps_model->app_list();
/**
* primary key 정보를 저장합니다
*/
$view['view']['primary_key'] = $this->{$this->modelname}->primary_key;
/**
* 페이지네이션을 생성합니다
*/
$config['base_url'] = admin_url($this->pagedir) . '?' . $param->replace('page');
$config['total_rows'] = $result['total_rows'];
$config['per_page'] = $per_page;
$this->pagination->initialize($config);
$view['view']['paging'] = $this->pagination->create_links();
$view['view']['page'] = $page;
/**
* 쓰기 주소, 삭제 주소등 필요한 주소를 구합니다
*/
$search_option = array('com_content' => '댓글내용');
$view['view']['skeyword'] = ($sfield && array_key_exists($sfield, $search_option)) ? $skeyword : '';
$view['view']['search_option'] = search_option($search_option, $sfield);
$view['view']['listall_url'] = admin_url($this->pagedir);
$view['view']['write_url'] = admin_url($this->pagedir . '/write');
$view['view']['list_delete_url'] = admin_url($this->pagedir . '/listdelete/?' . $param->output());
/**
* 어드민 레이아웃을 정의합니다
*/
$layoutconfig = array('layout' => 'layout', 'skin' => 'index');
$view['layout'] = $this->layoutlib->admin($layoutconfig, $this->configlib->get_device_view_type());
$this->data = $view;
$this->layout = element('layout_skin_file', element('layout', $view));
$this->view = element('view_skin_file', element('layout', $view));
}
/**
* 목록 페이지에서 선택삭제를 하는 경우 실행되는 메소드입니다
*/
public function listdelete()
{
$this->accesslevel->check_admin('delete');
/**
* 체크한 게시물의 삭제를 실행합니다
*/
if ($this->input->post('chk') && is_array($this->input->post('chk'))) {
foreach ($this->input->post('chk') as $val) {
if ($val) {
$this->{$this->modelname}->delete($val);
}
}
}
/**
* 삭제가 끝난 후 목록페이지로 이동합니다
*/
$this->session->set_flashdata('message','정상적으로 삭제되었습니다');
$param =& $this->querystring;
$redirecturl = admin_url($this->pagedir . '?' . $param->output());
redirect($redirecturl);
}
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,167 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
/**
* Crawlhistory class
*/
class Crawlhistory extends MY_Controller
{
/**
* 관리자 페이지 상의 현재 디렉토리입니다
* 페이지 이동시 필요한 정보입니다
*/
public $pagedir = 'contents/crawlhistory';
/**
* 모델을 로딩합니다
*/
protected $models = array('Crawl_list', 'Upload_file', 'Apps', 'Contents_category', 'Contents', 'Contents_tag', 'Crawl_history');
/**
* 이 컨트롤러의 메인 모델 이름입니다
*/
protected $modelname = 'Crawl_history_model';
/**
* 헬퍼를 로딩합니다
*/
protected $helpers = array('form', 'array');
function __construct()
{
parent::__construct();
/**
* 라이브러리를 로딩합니다
*/
$this->load->library(array('pagination', 'querystring'));
}
/**
* 목록을 가져오는 메소드입니다
*/
public function index()
{
$this->accesslevel->check_admin('read');
$view = array();
$view['view'] = array();
/**
* 페이지에 숫자가 아닌 문자가 입력되거나 1보다 작은 숫자가 입력되면 에러 페이지를 보여줍니다.
*/
$param =& $this->querystring;
$page = (((int) $this->input->get('page')) > 0) ? ((int) $this->input->get('page')) : 1;
$findex = $this->input->get('findex') ? $this->input->get('findex') : $this->{$this->modelname}->primary_key;
$forder = $this->input->get('forder', null, 'desc');
$sfield = $this->input->get('sfield', null, '');
$skeyword = $this->input->get('skeyword', null, '');
$per_page = admin_listnum();
$offset = ($page - 1) * $per_page;
/**
* 게시판 목록에 필요한 정보를 가져옵니다.
*/
$this->{$this->modelname}->allow_search_field = array('app_id', 'crawl_title'); // 검색이 가능한 필드
$this->{$this->modelname}->search_field_equal = array('app_id'); // 검색중 like 가 아닌 = 검색을 하는 필드
$this->{$this->modelname}->allow_order_field = array('crawl_id'); // 정렬이 가능한 필드
$where = array();
if ($this->input->get('app_id')) {
$where['crawl_history.app_id'] = $this->input->get('app_id');
}
if ($this->input->get('cat_id')) {
$where['crawl_history.cat_id'] = $this->input->get('cat_id');
}
if ($this->input->get('site_key')) {
$where['crawl_history.site_key'] = $this->input->get('site_key');
}
if ($this->input->get('crawl_category_name')) {
$where['crawl_list.crawl_category_name'] = $this->input->get('crawl_category_name');
}
if ($this->input->get('start_date')) {
$where['crawl_history.history_at >='] = $this->input->get('start_date');
}
if ($this->input->get('end_date')) {
$where['crawl_history.history_at <='] = $this->input->get('end_date');
}
$result = $this->Crawl_history_model->get_admin_list($per_page, $offset, $where, '', $findex, $forder, $sfield, $skeyword);
$list_num = $result['total_rows'] - ($page - 1) * $per_page;
if (element('list', $result)) {
foreach (element('list', $result) as $key => $val) {
$result['list'][$key]['num'] = $list_num--;
if (element('cat_id', $val)) {
$result['list'][$key]['category'] = $this->Contents_category_model->get_one(element('cat_id', $val));
$result['list'][$key]['origin_link'] = '';
if (element('site_type', $val) == '1') {
if (element('crawl_category', $val)) {
$result['list'][$key]['origin_link'] = 'http://m.blog.naver.com/PostList.nhn?blogId=' . element('site_key', $val) . '&categoryNo=' . element('crawl_category', $val);
} else {
$result['list'][$key]['origin_link'] = 'http://m.blog.naver.com/' . element('site_key', $val);
}
}
if (element('site_type', $val) == '2') {
$result['list'][$key]['origin_link'] = 'ttp://m.post.naver.com/my.nhn?memberNo=' . element('site_key', $val);
}
if (element('site_type', $val) == '3') {
if (element('crawl_category', $val)) {
$result['list'][$key]['origin_link'] = 'https://www.vingle.net/collections/' . element('crawl_category', $val);
} else {
$result['list'][$key]['origin_link'] = 'https://www.vingle.net/' . element('site_key', $val);
}
}
if (element('site_type', $val) == '4') {
$result['list'][$key]['origin_link'] = 'https://story.kakao.com/ch/' . element('site_key', $val);
}
}
}
}
$view['view']['data'] = $result;
$view['view']['applist'] = $this->Apps_model->app_list();
$view['view']['crawl_site'] = $this->Crawl_list_model->get_by_site();
$view['view']['crawl_category'] = $this->Crawl_list_model->get_by_category();
if ($this->input->get('app_id')) {
$view['view']['app_category'] = $this->Contents_category_model->cat_list($this->input->get('app_id'));
}
/**
* primary key 정보를 저장합니다
*/
$view['view']['primary_key'] = $this->{$this->modelname}->primary_key;
/**
* 페이지네이션을 생성합니다
*/
$config['base_url'] = admin_url($this->pagedir) . '?' . $param->replace('page');
$config['total_rows'] = $result['total_rows'];
$config['per_page'] = $per_page;
$this->pagination->initialize($config);
$view['view']['paging'] = $this->pagination->create_links();
$view['view']['page'] = $page;
/**
* 쓰기 주소, 삭제 주소등 필요한 주소를 구합니다
*/
$search_option = array('crawl_title' => '제목');
$view['view']['skeyword'] = ($sfield && array_key_exists($sfield, $search_option)) ? $skeyword : '';
$view['view']['search_option'] = search_option($search_option, $sfield);
$view['view']['listall_url'] = admin_url($this->pagedir);
$view['view']['write_url'] = admin_url($this->pagedir . '/write');
$view['view']['list_delete_url'] = admin_url($this->pagedir . '/listdelete/?' . $param->output());
/**
* 어드민 레이아웃을 정의합니다
*/
$layoutconfig = array('layout' => 'layout', 'skin' => 'index');
$view['layout'] = $this->layoutlib->admin($layoutconfig, $this->configlib->get_device_view_type());
$this->data = $view;
$this->layout = element('layout_skin_file', element('layout', $view));
$this->view = element('view_skin_file', element('layout', $view));
}
}

View File

@@ -0,0 +1,170 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
/**
* Like class
*/
class Like extends MY_Controller
{
/**
* 관리자 페이지 상의 현재 디렉토리입니다
* 페이지 이동시 필요한 정보입니다
*/
public $pagedir = 'contents/like';
/**
* 모델을 로딩합니다
*/
protected $models = array('Contents_like', 'Apps', 'Contents_category');
/**
* 이 컨트롤러의 메인 모델 이름입니다
*/
protected $modelname = 'Contents_like_model';
/**
* 헬퍼를 로딩합니다
*/
protected $helpers = array('form', 'array');
function __construct()
{
parent::__construct();
/**
* 라이브러리를 로딩합니다
*/
$this->load->library(array('pagination', 'querystring'));
}
/**
* 목록을 가져오는 메소드입니다
*/
public function index()
{
$this->accesslevel->check_admin('read');
$view = array();
$view['view'] = array();
/**
* 페이지에 숫자가 아닌 문자가 입력되거나 1보다 작은 숫자가 입력되면 에러 페이지를 보여줍니다.
*/
$param =& $this->querystring;
$page = (((int) $this->input->get('page')) > 0) ? ((int) $this->input->get('page')) : 1;
$findex = $this->input->get('findex') ? $this->input->get('findex') : $this->{$this->modelname}->primary_key;
$forder = $this->input->get('forder', null, 'desc');
$sfield = $this->input->get('sfield', null, '');
$skeyword = $this->input->get('skeyword', null, '');
$per_page = admin_listnum();
$offset = ($page - 1) * $per_page;
/**
* 게시판 목록에 필요한 정보를 가져옵니다.
*/
$this->{$this->modelname}->allow_search_field = array('like_id', 'target_user_id', 'contents_like.user_id', 'contents', 'contents_like.con_id'); // 검색이 가능한 필드
$this->{$this->modelname}->search_field_equal = array('like_id', 'contents_like.con_id'); // 검색중 like 가 아닌 = 검색을 하는 필드
$this->{$this->modelname}->allow_order_field = array('like_id'); // 정렬이 가능한 필드
$where = array();
if ($this->input->get('app_id')) {
$where['contents_like.app_id'] = $this->input->get('app_id');
}
$result = $this->{$this->modelname}
->get_admin_list($per_page, $offset, $where, '', $findex, $forder, $sfield, $skeyword);
$list_num = $result['total_rows'] - ($page - 1) * $per_page;
if (element('list', $result)) {
foreach (element('list', $result) as $key => $val) {
$result['list'][$key]['num'] = $list_num--;
if (element('cat1_id', $val)) {
$result['list'][$key]['category1'] = $this->Contents_category_model->get_one(element('cat1_id', $val));
}
if (element('cat2_id', $val)) {
$result['list'][$key]['category2'] = $this->Contents_category_model->get_one(element('cat2_id', $val));
}
/*
if (element('cat3_id', $val)) {
$result['list'][$key]['category3'] = $this->Contents_category_model->get_one(element('cat3_id', $val));
}
if (element('cat4_id', $val)) {
$result['list'][$key]['category4'] = $this->Contents_category_model->get_one(element('cat4_id', $val));
}
*/
$result['list'][$key]['display_name'] = display_username(
element('user_username', $val)
);
}
}
$view['view']['data'] = $result;
$view['view']['applist'] = $this->Apps_model->app_list();
/**
* primary key 정보를 저장합니다
*/
$view['view']['primary_key'] = $this->{$this->modelname}->primary_key;
/**
* 페이지네이션을 생성합니다
*/
$config['base_url'] = admin_url($this->pagedir) . '?' . $param->replace('page');
$config['total_rows'] = $result['total_rows'];
$config['per_page'] = $per_page;
$this->pagination->initialize($config);
$view['view']['paging'] = $this->pagination->create_links();
$view['view']['page'] = $page;
/**
* 쓰기 주소, 삭제 주소등 필요한 주소를 구합니다
*/
$search_option = array('like_id' => '고유번호');
$view['view']['skeyword'] = ($sfield && array_key_exists($sfield, $search_option)) ? $skeyword : '';
$view['view']['search_option'] = search_option($search_option, $sfield);
$view['view']['listall_url'] = admin_url($this->pagedir);
/**
* 어드민 레이아웃을 정의합니다
*/
$layoutconfig = array('layout' => 'layout', 'skin' => 'index');
$view['layout'] = $this->layoutlib->admin($layoutconfig, $this->configlib->get_device_view_type());
$this->data = $view;
$this->layout = element('layout_skin_file', element('layout', $view));
$this->view = element('view_skin_file', element('layout', $view));
}
/**
* 목록 페이지에서 선택삭제를 하는 경우 실행되는 메소드입니다
*/
public function listdelete()
{
/**
* 체크한 게시물의 삭제를 실행합니다
*/
if ($this->input->post('chk') && is_array($this->input->post('chk'))) {
foreach ($this->input->post('chk') as $val) {
if ($val) {
$getdata = $this->{$this->modelname}->get_one($val);
$this->{$this->modelname}->delete($val);
}
}
}
/**
* 삭제가 끝난 후 목록페이지로 이동합니다
*/
$this->session->set_flashdata(
'message',
'정상적으로 삭제되었습니다'
);
$param =& $this->querystring;
$redirecturl = admin_url($this->pagedir . '?' . $param->output());
redirect($redirecturl);
}
}

View File

@@ -0,0 +1,498 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
/**
* Notice class
*/
class Notice extends MY_Controller
{
/**
* 관리자 페이지 상의 현재 디렉토리입니다
* 페이지 이동시 필요한 정보입니다
*/
public $pagedir = 'contents/notice';
/**
* 모델을 로딩합니다
*/
protected $models = array('Notice', 'Upload_file', 'Apps');
/**
* 이 컨트롤러의 메인 모델 이름입니다
*/
protected $modelname = 'Notice_model';
/**
* 헬퍼를 로딩합니다
*/
protected $helpers = array('form', 'array', 'dhtml_editor');
function __construct()
{
parent::__construct();
/**
* 라이브러리를 로딩합니다
*/
$this->load->library(array('pagination', 'querystring'));
}
/**
* 목록을 가져오는 메소드입니다
*/
public function index()
{
$this->accesslevel->check_admin('read');
$view = array();
$view['view'] = array();
/**
* 페이지에 숫자가 아닌 문자가 입력되거나 1보다 작은 숫자가 입력되면 에러 페이지를 보여줍니다.
*/
$param =& $this->querystring;
$page = (((int) $this->input->get('page')) > 0) ? ((int) $this->input->get('page')) : 1;
$findex = $this->input->get('findex') ? $this->input->get('findex') : $this->{$this->modelname}->primary_key;
$forder = $this->input->get('forder', null, 'desc');
$sfield = $this->input->get('sfield', null, '');
$skeyword = $this->input->get('skeyword', null, '');
$per_page = admin_listnum();
$offset = ($page - 1) * $per_page;
/**
* 게시판 목록에 필요한 정보를 가져옵니다.
*/
$this->{$this->modelname}->allow_search_field = array('app_id','notice_title','notice_content'); // 검색이 가능한 필드
$this->{$this->modelname}->search_field_equal = array('app_id'); // 검색중 like 가 아닌 = 검색을 하는 필드
$this->{$this->modelname}->allow_order_field = array('notice_id'); // 정렬이 가능한 필드
$where = array();
if ($this->input->get('app_id')) {
$where['notice.app_id'] = $this->input->get('app_id');
}
$result = $this->{$this->modelname}
->get_admin_list($per_page, $offset, $where, '', $findex, $forder, $sfield, $skeyword);
$list_num = $result['total_rows'] - ($page - 1) * $per_page;
if (element('list', $result)) {
foreach (element('list', $result) as $key => $val) {
$result['list'][$key]['num'] = $list_num--;
}
}
$view['view']['data'] = $result;
$view['view']['applist'] = $this->Apps_model->app_list();
/**
* primary key 정보를 저장합니다
*/
$view['view']['primary_key'] = $this->{$this->modelname}->primary_key;
/**
* 페이지네이션을 생성합니다
*/
$config['base_url'] = admin_url($this->pagedir) . '?' . $param->replace('page');
$config['total_rows'] = $result['total_rows'];
$config['per_page'] = $per_page;
$this->pagination->initialize($config);
$view['view']['paging'] = $this->pagination->create_links();
$view['view']['page'] = $page;
/**
* 쓰기 주소, 삭제 주소등 필요한 주소를 구합니다
*/
$search_option = array('notice_title' => '제목','notice_content' => '내용');
$view['view']['skeyword'] = ($sfield && array_key_exists($sfield, $search_option)) ? $skeyword : '';
$view['view']['search_option'] = search_option($search_option, $sfield);
$view['view']['listall_url'] = admin_url($this->pagedir);
$view['view']['write_url'] = admin_url($this->pagedir . '/write');
$view['view']['list_delete_url'] = admin_url($this->pagedir . '/listdelete/?' . $param->output());
/**
* 어드민 레이아웃을 정의합니다
*/
$layoutconfig = array('layout' => 'layout', 'skin' => 'index');
$view['layout'] = $this->layoutlib->admin($layoutconfig, $this->configlib->get_device_view_type());
$this->data = $view;
$this->layout = element('layout_skin_file', element('layout', $view));
$this->view = element('view_skin_file', element('layout', $view));
}
/**
* 게시판 글쓰기 또는 수정 페이지를 가져오는 메소드입니다
*/
public function write($pid = 0)
{
$this->accesslevel->check_admin('read');
$view = array();
$view['view'] = array();
/**
* 프라이머리키에 숫자형이 입력되지 않으면 에러처리합니다
*/
if ($pid) {
$pid = (int) $pid;
if (empty($pid) OR $pid < 1) {
show_404();
}
}
$primary_key = $this->{$this->modelname}->primary_key;
/**
* 수정 페이지일 경우 기존 데이터를 가져옵니다
*/
$getdata = array();
if ($pid) {
$getdata = $this->{$this->modelname}->get_one($pid);
} else if ($this->input->get('app_id')) {
$getdata['app_id'] = $this->input->get('app_id');
}
/**
* Validation 라이브러리를 가져옵니다
*/
$this->load->library('form_validation');
$view['view']['upload_file_count'] = $upload_file_count = 2;
/**
* 전송된 데이터의 유효성을 체크합니다
*/
$config = array(
array('field' => 'app_id', 'label' => '어플이름', 'rules' => 'trim|required'),
array('field' => 'notice_title', 'label' => '제목', 'rules' => 'trim|required'),
array('field' => 'notice_content', 'label' => '내용', 'rules' => 'trim|required'),
);
$this->form_validation->set_rules($config);
$form_validation = $this->form_validation->run();
$file_error = '';
$uploadfiledata = '';
$uploadfiledata2 = '';
if ($upload_file_count > 0 && $form_validation) {
$this->load->library('upload');
if (isset($_FILES) && isset($_FILES['upload_file']) && isset($_FILES['upload_file']['name']) && is_array($_FILES['upload_file']['name'])) {
$filecount = count($_FILES['upload_file']['name']);
$upload_path = config_item('uploads_dir') . '/files/';
if (is_dir($upload_path) === false) {
mkdir($upload_path, 0707);
$file = $upload_path . 'index.php';
$f = @fopen($file, 'w');
@fwrite($f, '');
@fclose($f);
@chmod($file, 0644);
}
$upload_path .= cdate('Y') . '/';
if (is_dir($upload_path) === false) {
mkdir($upload_path, 0707);
$file = $upload_path . 'index.php';
$f = @fopen($file, 'w');
@fwrite($f, '');
@fclose($f);
@chmod($file, 0644);
}
$upload_path .= cdate('m') . '/';
if (is_dir($upload_path) === false) {
mkdir($upload_path, 0707);
$file = $upload_path . 'index.php';
$f = @fopen($file, 'w');
@fwrite($f, '');
@fclose($f);
@chmod($file, 0644);
}
foreach ($_FILES['upload_file']['name'] as $i => $value) {
if ($value) {
$uploadconfig = '';
$uploadconfig['upload_path'] = $upload_path;
$uploadconfig['allowed_types'] = '*';
$uploadconfig['max_size'] = 10240;
$uploadconfig['encrypt_name'] = true;
$this->upload->initialize($uploadconfig);
$_FILES['userfile']['name'] = $_FILES['upload_file']['name'][$i];
$_FILES['userfile']['type'] = $_FILES['upload_file']['type'][$i];
$_FILES['userfile']['tmp_name'] = $_FILES['upload_file']['tmp_name'][$i];
$_FILES['userfile']['error'] = $_FILES['upload_file']['error'][$i];
$_FILES['userfile']['size'] = $_FILES['upload_file']['size'][$i];
if ($this->upload->do_upload()) {
$filedata = $this->upload->data();
$uploadfiledata[$i]['ufi_filename'] = cdate('Y') . '/' . cdate('m') . '/' . element('file_name', $filedata);
$uploadfiledata[$i]['ufi_originname'] = element('orig_name', $filedata);
$uploadfiledata[$i]['ufi_filesize'] = intval(element('file_size', $filedata) * 1024);
$uploadfiledata[$i]['ufi_width'] = element('image_width', $filedata) ? element('image_width', $filedata) : 0;
$uploadfiledata[$i]['ufi_height'] = element('image_height', $filedata) ? element('image_height', $filedata) : 0;
$uploadfiledata[$i]['ufi_type'] = str_replace('.', '', element('file_ext', $filedata));
$uploadfiledata[$i]['is_image'] = element('is_image', $filedata) ? element('is_image', $filedata) : 0;
} else {
$file_error = $this->upload->display_errors();
break;
}
}
}
}
if (isset($_FILES) && isset($_FILES['upload_file_update'])
&& isset($_FILES['upload_file_update']['name'])
&& is_array($_FILES['upload_file_update']['name'])
&& $file_error === '') {
$filecount = count($_FILES['upload_file_update']['name']);
$upload_path = config_item('uploads_dir') . '/files/';
if (is_dir($upload_path) === false) {
mkdir($upload_path, 0707);
$file = $upload_path . 'index.php';
$f = @fopen($file, 'w');
@fwrite($f, '');
@fclose($f);
@chmod($file, 0644);
}
$upload_path .= cdate('Y') . '/';
if (is_dir($upload_path) === false) {
mkdir($upload_path, 0707);
$file = $upload_path . 'index.php';
$f = @fopen($file, 'w');
@fwrite($f, '');
@fclose($f);
@chmod($file, 0644);
}
$upload_path .= cdate('m') . '/';
if (is_dir($upload_path) === false) {
mkdir($upload_path, 0707);
$file = $upload_path . 'index.php';
$f = @fopen($file, 'w');
@fwrite($f, '');
@fclose($f);
@chmod($file, 0644);
}
foreach ($_FILES['upload_file_update']['name'] as $i => $value) {
if ($value) {
$uploadconfig = '';
$uploadconfig['upload_path'] = $upload_path;
$uploadconfig['allowed_types'] = '*';
$uploadconfig['max_size'] = 10240;
$uploadconfig['encrypt_name'] = true;
$this->upload->initialize($uploadconfig);
$_FILES['userfile']['name'] = $_FILES['upload_file_update']['name'][$i];
$_FILES['userfile']['type'] = $_FILES['upload_file_update']['type'][$i];
$_FILES['userfile']['tmp_name'] = $_FILES['upload_file_update']['tmp_name'][$i];
$_FILES['userfile']['error'] = $_FILES['upload_file_update']['error'][$i];
$_FILES['userfile']['size'] = $_FILES['upload_file_update']['size'][$i];
if ($this->upload->do_upload()) {
$filedata = $this->upload->data();
$olduploadfile = $this->Upload_file_model->get_one($i);
if ((int) element('origin_id', $olduploadfile) !== (int) element('notice_id', $getdata)) {
alert('잘못된 접근입니다');
}
@unlink(config_item('uploads_dir') . '/files/' . element('ufi_filename', $oldpostfile));
$uploadfiledata2[$i]['ufi_id'] = $i;
$uploadfiledata2[$i]['ufi_filename'] = cdate('Y') . '/' . cdate('m') . '/' . element('file_name', $filedata);
$uploadfiledata2[$i]['ufi_originname'] = element('orig_name', $filedata);
$uploadfiledata2[$i]['ufi_filesize'] = intval(element('file_size', $filedata) * 1024);
$uploadfiledata2[$i]['ufi_width'] = element('image_width', $filedata)
? element('image_width', $filedata) : 0;
$uploadfiledata2[$i]['ufi_height'] = element('image_height', $filedata)
? element('image_height', $filedata) : 0;
$uploadfiledata2[$i]['ufi_type'] = str_replace('.', '', element('file_ext', $filedata));
$uploadfiledata2[$i]['is_image'] = element('is_image', $filedata)
? element('is_image', $filedata) : 0;
} else {
$file_error = $this->upload->display_errors();
break;
}
}
}
}
}
/**
* 유효성 검사를 하지 않는 경우, 또는 유효성 검사에 실패한 경우입니다.
* 즉 글쓰기나 수정 페이지를 보고 있는 경우입니다
*/
if ($form_validation === false OR $file_error !== '') {
$view['view']['data'] = $getdata;
$view['view']['applist'] = $this->Apps_model->app_list();
/**
* primary key 정보를 저장합니다
*/
$view['view']['primary_key'] = $primary_key;
if (element('notice_id', $getdata)) {
$uploadwhere = array(
'origin_table' => 'notice',
'origin_id' => element('notice_id', $getdata),
);
$view['view']['file'] = $file = $this->Upload_file_model->get('', '', $uploadwhere, '', '', 'ufi_id', 'ASC');
if ($file && is_array($file)) {
foreach ($file as $key => $value) {
$view['view']['file'][$key]['download_link']
= site_url('download/downfiles/' . element('ufi_id', $value));
}
}
}
/**
* 어드민 레이아웃을 정의합니다
*/
$layoutconfig = array('layout' => 'layout', 'skin' => 'write');
$view['layout'] = $this->layoutlib->admin($layoutconfig, $this->configlib->get_device_view_type());
$this->data = $view;
$this->layout = element('layout_skin_file', element('layout', $view));
$this->view = element('view_skin_file', element('layout', $view));
} else {
/**
* 유효성 검사를 통과한 경우입니다.
* 즉 데이터의 insert 나 update 의 process 처리가 필요한 상황입니다
*/
$updatedata = array(
'app_id' => $this->input->post('app_id', null, ''),
'notice_title' => $this->input->post('notice_title', null, ''),
'notice_content' => $this->input->post('notice_content', null, ''),
);
/**
* 게시물을 수정하는 경우입니다
*/
if ($this->input->post($primary_key)) {
$this->accesslevel->check_admin('edit');
$updatedata['updated_at'] = cdate('Y-m-d H:i:s');
$this->{$this->modelname}->update($this->input->post($primary_key), $updatedata);
$origin_id = $this->input->post($primary_key);
$this->session->set_flashdata('message','정상적으로 수정되었습니다');
} else {
$this->accesslevel->check_admin('write');
/**
* 게시물을 새로 입력하는 경우입니다
*/
$updatedata['created_at'] = cdate('Y-m-d H:i:s');
$updatedata['updated_at'] = cdate('Y-m-d H:i:s');
$updatedata['user_id'] = $this->userlib->item('user_id');
$updatedata['user_name'] = $this->userlib->item('user_username');
$origin_id = $this->{$this->modelname}->insert($updatedata);
$this->session->set_flashdata('message','정상적으로 입력되었습니다');
}
$file_updated = false;
$file_changed = false;
if (is_array($uploadfiledata) && count($uploadfiledata) > 0) {
foreach ($uploadfiledata as $pkey => $pval) {
if ($pval) {
$fileupdate = array(
'origin_id' => $origin_id,
'origin_table' => 'notice',
'user_id' => $this->userlib->item('user_id'),
'ufi_originname' => element('ufi_originname', $pval),
'ufi_filename' => element('ufi_filename', $pval),
'ufi_filesize' => element('ufi_filesize', $pval),
'ufi_width' => element('ufi_width', $pval),
'ufi_height' => element('ufi_height', $pval),
'ufi_type' => element('ufi_type', $pval),
'ufi_is_image' => element('is_image', $pval),
'ufi_datetime' => cdate('Y-m-d H:i:s'),
'ufi_ip' => $this->input->ip_address(),
);
$file_id = $this->Upload_file_model->insert($fileupdate);
$file_updated = true;
}
}
$file_changed = true;
}
if (is_array($uploadfiledata2) && count($uploadfiledata2) > 0) {
foreach ($uploadfiledata2 as $pkey => $pval) {
if ($pval) {
$fileupdate = array(
'user_id' => $this->userlib->item('user_id'),
'ufi_originname' => element('ufi_originname', $pval),
'ufi_filename' => element('ufi_filename', $pval),
'ufi_filesize' => element('ufi_filesize', $pval),
'ufi_width' => element('ufi_width', $pval),
'ufi_height' => element('ufi_height', $pval),
'ufi_type' => element('ufi_type', $pval),
'ufi_is_image' => element('is_image', $pval),
'ufi_datetime' => cdate('Y-m-d H:i:s'),
'ufi_ip' => $this->input->ip_address(),
);
$this->Upload_file_model->update($pkey, $fileupdate);
$file_changed = true;
}
}
}
if ($this->input->post('upload_file_del')) {
foreach ($this->input->post('upload_file_del') as $key => $val) {
if ($val === '1' && ! isset($uploadfiledata2[$key])) {
$olduploadfile = $this->Upload_file_model->get_one($key);
if ( ! element('origin_id', $olduploadfile) OR (int) element('origin_id', $olduploadfile) !== (int) $origin_id) {
alert('잘못된 접근입니다.');
}
@unlink(config_item('uploads_dir') . '/files/' . element('ufi_filename', $olduploadfile));
$this->Upload_file_model->delete($key);
$file_changed = true;
}
}
}
/**
* 게시물의 신규입력 또는 수정작업이 끝난 후 목록 페이지로 이동합니다
*/
$param =& $this->querystring;
$redirecturl = admin_url($this->pagedir . '?' . $param->output());
redirect($redirecturl);
}
}
/**
* 목록 페이지에서 선택삭제를 하는 경우 실행되는 메소드입니다
*/
public function listdelete()
{
$this->accesslevel->check_admin('delete');
/**
* 체크한 게시물의 삭제를 실행합니다
*/
if ($this->input->post('chk') && is_array($this->input->post('chk'))) {
foreach ($this->input->post('chk') as $val) {
if ($val) {
$this->{$this->modelname}->delete($val);
}
}
}
/**
* 삭제가 끝난 후 목록페이지로 이동합니다
*/
$this->session->set_flashdata('message','정상적으로 삭제되었습니다');
$param =& $this->querystring;
$redirecturl = admin_url($this->pagedir . '?' . $param->output());
redirect($redirecturl);
}
}

View File

@@ -0,0 +1,504 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
/**
* Qna class
*/
class Qna extends MY_Controller
{
/**
* 관리자 페이지 상의 현재 디렉토리입니다
* 페이지 이동시 필요한 정보입니다
*/
public $pagedir = 'contents/qna';
/**
* 모델을 로딩합니다
*/
protected $models = array('Qna', 'Upload_file', 'Apps');
/**
* 이 컨트롤러의 메인 모델 이름입니다
*/
protected $modelname = 'Qna_model';
/**
* 헬퍼를 로딩합니다
*/
protected $helpers = array('form', 'array', 'dhtml_editor');
function __construct()
{
parent::__construct();
/**
* 라이브러리를 로딩합니다
*/
$this->load->library(array('pagination', 'querystring'));
}
/**
* 목록을 가져오는 메소드입니다
*/
public function index()
{
$this->accesslevel->check_admin('read');
$view = array();
$view['view'] = array();
/**
* 페이지에 숫자가 아닌 문자가 입력되거나 1보다 작은 숫자가 입력되면 에러 페이지를 보여줍니다.
*/
$param =& $this->querystring;
$page = (((int) $this->input->get('page')) > 0) ? ((int) $this->input->get('page')) : 1;
$findex = $this->input->get('findex') ? $this->input->get('findex') : $this->{$this->modelname}->primary_key;
$forder = $this->input->get('forder', null, 'desc');
$sfield = $this->input->get('sfield', null, '');
$skeyword = $this->input->get('skeyword', null, '');
$per_page = admin_listnum();
$offset = ($page - 1) * $per_page;
/**
* 게시판 목록에 필요한 정보를 가져옵니다.
*/
$this->{$this->modelname}->allow_search_field = array('app_id','qna_title','qna_content'); // 검색이 가능한 필드
$this->{$this->modelname}->search_field_equal = array('app_id'); // 검색중 like 가 아닌 = 검색을 하는 필드
$this->{$this->modelname}->allow_order_field = array('qna_id'); // 정렬이 가능한 필드
$where = array();
if ($this->input->get('app_id')) {
$where['qna.app_id'] = $this->input->get('app_id');
}
$result = $this->{$this->modelname}
->get_admin_list($per_page, $offset, $where, '', $findex, $forder, $sfield, $skeyword);
$list_num = $result['total_rows'] - ($page - 1) * $per_page;
if (element('list', $result)) {
foreach (element('list', $result) as $key => $val) {
$result['list'][$key]['num'] = $list_num--;
}
}
$view['view']['data'] = $result;
$view['view']['applist'] = $this->Apps_model->app_list();
/**
* primary key 정보를 저장합니다
*/
$view['view']['primary_key'] = $this->{$this->modelname}->primary_key;
/**
* 페이지네이션을 생성합니다
*/
$config['base_url'] = admin_url($this->pagedir) . '?' . $param->replace('page');
$config['total_rows'] = $result['total_rows'];
$config['per_page'] = $per_page;
$this->pagination->initialize($config);
$view['view']['paging'] = $this->pagination->create_links();
$view['view']['page'] = $page;
/**
* 쓰기 주소, 삭제 주소등 필요한 주소를 구합니다
*/
$search_option = array('qna_title' => '제목','qna_content' => '내용');
$view['view']['skeyword'] = ($sfield && array_key_exists($sfield, $search_option)) ? $skeyword : '';
$view['view']['search_option'] = search_option($search_option, $sfield);
$view['view']['listall_url'] = admin_url($this->pagedir);
$view['view']['write_url'] = admin_url($this->pagedir . '/write');
$view['view']['list_delete_url'] = admin_url($this->pagedir . '/listdelete/?' . $param->output());
/**
* 어드민 레이아웃을 정의합니다
*/
$layoutconfig = array('layout' => 'layout', 'skin' => 'index');
$view['layout'] = $this->layoutlib->admin($layoutconfig, $this->configlib->get_device_view_type());
$this->data = $view;
$this->layout = element('layout_skin_file', element('layout', $view));
$this->view = element('view_skin_file', element('layout', $view));
}
/**
* 게시판 글쓰기 또는 수정 페이지를 가져오는 메소드입니다
*/
public function write($pid = 0)
{
$this->accesslevel->check_admin('read');
$view = array();
$view['view'] = array();
/**
* 프라이머리키에 숫자형이 입력되지 않으면 에러처리합니다
*/
if ($pid) {
$pid = (int) $pid;
if (empty($pid) OR $pid < 1) {
show_404();
}
}
$primary_key = $this->{$this->modelname}->primary_key;
/**
* 수정 페이지일 경우 기존 데이터를 가져옵니다
*/
$getdata = array();
if ($pid) {
$getdata = $this->{$this->modelname}->get_one($pid);
} else if ($this->input->get('app_id')) {
$getdata['app_id'] = $this->input->get('app_id');
}
/**
* Validation 라이브러리를 가져옵니다
*/
$this->load->library('form_validation');
$view['view']['upload_file_count'] = $upload_file_count = 2;
/**
* 전송된 데이터의 유효성을 체크합니다
*/
$config = array(
array('field' => 'app_id', 'label' => '어플이름', 'rules' => 'trim|required'),
array('field' => 'qna_title', 'label' => '제목', 'rules' => 'trim|required'),
array('field' => 'qna_content', 'label' => '문의내용', 'rules' => 'trim|required'),
array('field' => 'qna_answer', 'label' => ' 답변내용', 'rules' => 'trim|required'),
);
$this->form_validation->set_rules($config);
$form_validation = $this->form_validation->run();
$file_error = '';
$uploadfiledata = '';
$uploadfiledata2 = '';
if ($upload_file_count > 0 && $form_validation) {
$this->load->library('upload');
if (isset($_FILES) && isset($_FILES['upload_file']) && isset($_FILES['upload_file']['name']) && is_array($_FILES['upload_file']['name'])) {
$filecount = count($_FILES['upload_file']['name']);
$upload_path = config_item('uploads_dir') . '/files/';
if (is_dir($upload_path) === false) {
mkdir($upload_path, 0707);
$file = $upload_path . 'index.php';
$f = @fopen($file, 'w');
@fwrite($f, '');
@fclose($f);
@chmod($file, 0644);
}
$upload_path .= cdate('Y') . '/';
if (is_dir($upload_path) === false) {
mkdir($upload_path, 0707);
$file = $upload_path . 'index.php';
$f = @fopen($file, 'w');
@fwrite($f, '');
@fclose($f);
@chmod($file, 0644);
}
$upload_path .= cdate('m') . '/';
if (is_dir($upload_path) === false) {
mkdir($upload_path, 0707);
$file = $upload_path . 'index.php';
$f = @fopen($file, 'w');
@fwrite($f, '');
@fclose($f);
@chmod($file, 0644);
}
foreach ($_FILES['upload_file']['name'] as $i => $value) {
if ($value) {
$uploadconfig = '';
$uploadconfig['upload_path'] = $upload_path;
$uploadconfig['allowed_types'] = '*';
$uploadconfig['max_size'] = 10240;
$uploadconfig['encrypt_name'] = true;
$this->upload->initialize($uploadconfig);
$_FILES['userfile']['name'] = $_FILES['upload_file']['name'][$i];
$_FILES['userfile']['type'] = $_FILES['upload_file']['type'][$i];
$_FILES['userfile']['tmp_name'] = $_FILES['upload_file']['tmp_name'][$i];
$_FILES['userfile']['error'] = $_FILES['upload_file']['error'][$i];
$_FILES['userfile']['size'] = $_FILES['upload_file']['size'][$i];
if ($this->upload->do_upload()) {
$filedata = $this->upload->data();
$uploadfiledata[$i]['ufi_filename'] = cdate('Y') . '/' . cdate('m') . '/' . element('file_name', $filedata);
$uploadfiledata[$i]['ufi_originname'] = element('orig_name', $filedata);
$uploadfiledata[$i]['ufi_filesize'] = intval(element('file_size', $filedata) * 1024);
$uploadfiledata[$i]['ufi_width'] = element('image_width', $filedata) ? element('image_width', $filedata) : 0;
$uploadfiledata[$i]['ufi_height'] = element('image_height', $filedata) ? element('image_height', $filedata) : 0;
$uploadfiledata[$i]['ufi_type'] = str_replace('.', '', element('file_ext', $filedata));
$uploadfiledata[$i]['is_image'] = element('is_image', $filedata) ? element('is_image', $filedata) : 0;
} else {
$file_error = $this->upload->display_errors();
break;
}
}
}
}
if (isset($_FILES) && isset($_FILES['upload_file_update'])
&& isset($_FILES['upload_file_update']['name'])
&& is_array($_FILES['upload_file_update']['name'])
&& $file_error === '') {
$filecount = count($_FILES['upload_file_update']['name']);
$upload_path = config_item('uploads_dir') . '/files/';
if (is_dir($upload_path) === false) {
mkdir($upload_path, 0707);
$file = $upload_path . 'index.php';
$f = @fopen($file, 'w');
@fwrite($f, '');
@fclose($f);
@chmod($file, 0644);
}
$upload_path .= cdate('Y') . '/';
if (is_dir($upload_path) === false) {
mkdir($upload_path, 0707);
$file = $upload_path . 'index.php';
$f = @fopen($file, 'w');
@fwrite($f, '');
@fclose($f);
@chmod($file, 0644);
}
$upload_path .= cdate('m') . '/';
if (is_dir($upload_path) === false) {
mkdir($upload_path, 0707);
$file = $upload_path . 'index.php';
$f = @fopen($file, 'w');
@fwrite($f, '');
@fclose($f);
@chmod($file, 0644);
}
foreach ($_FILES['upload_file_update']['name'] as $i => $value) {
if ($value) {
$uploadconfig = '';
$uploadconfig['upload_path'] = $upload_path;
$uploadconfig['allowed_types'] = '*';
$uploadconfig['max_size'] = 10240;
$uploadconfig['encrypt_name'] = true;
$this->upload->initialize($uploadconfig);
$_FILES['userfile']['name'] = $_FILES['upload_file_update']['name'][$i];
$_FILES['userfile']['type'] = $_FILES['upload_file_update']['type'][$i];
$_FILES['userfile']['tmp_name'] = $_FILES['upload_file_update']['tmp_name'][$i];
$_FILES['userfile']['error'] = $_FILES['upload_file_update']['error'][$i];
$_FILES['userfile']['size'] = $_FILES['upload_file_update']['size'][$i];
if ($this->upload->do_upload()) {
$filedata = $this->upload->data();
$olduploadfile = $this->Upload_file_model->get_one($i);
if ((int) element('origin_id', $olduploadfile) !== (int) element('qna_id', $getdata)) {
alert('잘못된 접근입니다');
}
@unlink(config_item('uploads_dir') . '/files/' . element('ufi_filename', $oldpostfile));
$uploadfiledata2[$i]['ufi_id'] = $i;
$uploadfiledata2[$i]['ufi_filename'] = cdate('Y') . '/' . cdate('m') . '/' . element('file_name', $filedata);
$uploadfiledata2[$i]['ufi_originname'] = element('orig_name', $filedata);
$uploadfiledata2[$i]['ufi_filesize'] = intval(element('file_size', $filedata) * 1024);
$uploadfiledata2[$i]['ufi_width'] = element('image_width', $filedata)
? element('image_width', $filedata) : 0;
$uploadfiledata2[$i]['ufi_height'] = element('image_height', $filedata)
? element('image_height', $filedata) : 0;
$uploadfiledata2[$i]['ufi_type'] = str_replace('.', '', element('file_ext', $filedata));
$uploadfiledata2[$i]['is_image'] = element('is_image', $filedata)
? element('is_image', $filedata) : 0;
} else {
$file_error = $this->upload->display_errors();
break;
}
}
}
}
}
/**
* 유효성 검사를 하지 않는 경우, 또는 유효성 검사에 실패한 경우입니다.
* 즉 글쓰기나 수정 페이지를 보고 있는 경우입니다
*/
if ($form_validation === false OR $file_error !== '') {
$view['view']['data'] = $getdata;
$view['view']['applist'] = $this->Apps_model->app_list();
/**
* primary key 정보를 저장합니다
*/
$view['view']['primary_key'] = $primary_key;
if (element('qna_id', $getdata)) {
$uploadwhere = array(
'origin_table' => 'qna',
'origin_id' => element('qna_id', $getdata),
);
$view['view']['file'] = $file = $this->Upload_file_model->get('', '', $uploadwhere, '', '', 'ufi_id', 'ASC');
if ($file && is_array($file)) {
foreach ($file as $key => $value) {
$view['view']['file'][$key]['download_link']
= site_url('download/downfiles/' . element('ufi_id', $value));
}
}
}
/**
* 어드민 레이아웃을 정의합니다
*/
$layoutconfig = array('layout' => 'layout', 'skin' => 'write');
$view['layout'] = $this->layoutlib->admin($layoutconfig, $this->configlib->get_device_view_type());
$this->data = $view;
$this->layout = element('layout_skin_file', element('layout', $view));
$this->view = element('view_skin_file', element('layout', $view));
} else {
/**
* 유효성 검사를 통과한 경우입니다.
* 즉 데이터의 insert 나 update 의 process 처리가 필요한 상황입니다
*/
$updatedata = array(
'app_id' => $this->input->post('app_id', null, ''),
'qna_title' => $this->input->post('qna_title', null, ''),
'qna_content' => $this->input->post('qna_content', null, ''),
'qna_answer' => $this->input->post('qna_answer', null, ''),
);
if ($this->input->post('qna_answer')) {
$updatedata['answer_at'] = cdate('Y-m-d H:i:s');
$updatedata['has_answer'] = '1';
} else {
$updatedata['answer_at'] = null;
$updatedata['has_answer'] = '0';
}
/**
* 게시물을 수정하는 경우입니다
*/
if ($this->input->post($primary_key)) {
$this->accesslevel->check_admin('edit');
$this->{$this->modelname}->update($this->input->post($primary_key), $updatedata);
$origin_id = $this->input->post($primary_key);
$this->session->set_flashdata('message','정상적으로 수정되었습니다');
} else {
$this->accesslevel->check_admin('write');
/**
* 게시물을 새로 입력하는 경우입니다
*/
$updatedata['user_id'] = $this->userlib->item('user_id');
$updatedata['user_name'] = $this->userlib->item('user_username');
$origin_id = $this->{$this->modelname}->insert($updatedata);
$this->session->set_flashdata('message','정상적으로 입력되었습니다');
}
$file_updated = false;
$file_changed = false;
if (is_array($uploadfiledata) && count($uploadfiledata) > 0) {
foreach ($uploadfiledata as $pkey => $pval) {
if ($pval) {
$fileupdate = array(
'origin_id' => $origin_id,
'origin_table' => 'qna',
'user_id' => $this->userlib->item('user_id'),
'ufi_originname' => element('ufi_originname', $pval),
'ufi_filename' => element('ufi_filename', $pval),
'ufi_filesize' => element('ufi_filesize', $pval),
'ufi_width' => element('ufi_width', $pval),
'ufi_height' => element('ufi_height', $pval),
'ufi_type' => element('ufi_type', $pval),
'ufi_is_image' => element('is_image', $pval),
'ufi_datetime' => cdate('Y-m-d H:i:s'),
'ufi_ip' => $this->input->ip_address(),
);
$file_id = $this->Upload_file_model->insert($fileupdate);
$file_updated = true;
}
}
$file_changed = true;
}
if (is_array($uploadfiledata2) && count($uploadfiledata2) > 0) {
foreach ($uploadfiledata2 as $pkey => $pval) {
if ($pval) {
$fileupdate = array(
'user_id' => $this->userlib->item('user_id'),
'ufi_originname' => element('ufi_originname', $pval),
'ufi_filename' => element('ufi_filename', $pval),
'ufi_filesize' => element('ufi_filesize', $pval),
'ufi_width' => element('ufi_width', $pval),
'ufi_height' => element('ufi_height', $pval),
'ufi_type' => element('ufi_type', $pval),
'ufi_is_image' => element('is_image', $pval),
'ufi_datetime' => cdate('Y-m-d H:i:s'),
'ufi_ip' => $this->input->ip_address(),
);
$this->Upload_file_model->update($pkey, $fileupdate);
$file_changed = true;
}
}
}
if ($this->input->post('upload_file_del')) {
foreach ($this->input->post('upload_file_del') as $key => $val) {
if ($val === '1' && ! isset($uploadfiledata2[$key])) {
$olduploadfile = $this->Upload_file_model->get_one($key);
if ( ! element('origin_id', $olduploadfile) OR (int) element('origin_id', $olduploadfile) !== (int) $origin_id) {
alert('잘못된 접근입니다.');
}
@unlink(config_item('uploads_dir') . '/files/' . element('ufi_filename', $olduploadfile));
$this->Upload_file_model->delete($key);
$file_changed = true;
}
}
}
/**
* 게시물의 신규입력 또는 수정작업이 끝난 후 목록 페이지로 이동합니다
*/
$param =& $this->querystring;
$redirecturl = admin_url($this->pagedir . '?' . $param->output());
redirect($redirecturl);
}
}
/**
* 목록 페이지에서 선택삭제를 하는 경우 실행되는 메소드입니다
*/
public function listdelete()
{
$this->accesslevel->check_admin('delete');
/**
* 체크한 게시물의 삭제를 실행합니다
*/
if ($this->input->post('chk') && is_array($this->input->post('chk'))) {
foreach ($this->input->post('chk') as $val) {
if ($val) {
$this->{$this->modelname}->delete($val);
}
}
}
/**
* 삭제가 끝난 후 목록페이지로 이동합니다
*/
$this->session->set_flashdata('message','정상적으로 삭제되었습니다');
$param =& $this->querystring;
$redirecturl = admin_url($this->pagedir . '?' . $param->output());
redirect($redirecturl);
}
}

View File

@@ -0,0 +1,163 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
/**
* Tag class
*/
class Tag extends MY_Controller
{
/**
* 관리자 페이지 상의 현재 디렉토리입니다
* 페이지 이동시 필요한 정보입니다
*/
public $pagedir = 'contents/tag';
/**
* 모델을 로딩합니다
*/
protected $models = array('Contents_tag', 'Apps', 'Contents_category');
/**
* 이 컨트롤러의 메인 모델 이름입니다
*/
protected $modelname = 'Contents_tag_model';
/**
* 헬퍼를 로딩합니다
*/
protected $helpers = array('form', 'array');
function __construct()
{
parent::__construct();
/**
* 라이브러리를 로딩합니다
*/
$this->load->library(array('pagination', 'querystring'));
}
/**
* 목록을 가져오는 메소드입니다
*/
public function index()
{
$this->accesslevel->check_admin('read');
$view = array();
$view['view'] = array();
/**
* 페이지에 숫자가 아닌 문자가 입력되거나 1보다 작은 숫자가 입력되면 에러 페이지를 보여줍니다.
*/
$param =& $this->querystring;
$view['view']['sort'] = array(
'tag_id' => $param->sort('tag_id', 'desc'),
'tag_name' => $param->sort('tag_name', 'asc'),
'cnt' => $param->sort('cnt', 'desc'),
);
$page = (((int) $this->input->get('page')) > 0) ? ((int) $this->input->get('page')) : 1;
$findex = $this->input->get('findex') ? $this->input->get('findex') : $this->{$this->modelname}->primary_key;
$forder = $this->input->get('forder', null, 'desc');
$sfield = $this->input->get('sfield', null, '');
$skeyword = $this->input->get('skeyword', null, '');
$per_page = admin_listnum();
$offset = ($page - 1) * $per_page;
/**
* 게시판 목록에 필요한 정보를 가져옵니다.
*/
$this->{$this->modelname}->allow_search_field = array('tag_name'); // 검색이 가능한 필드
$this->{$this->modelname}->search_field_equal = array(); // 검색중 like 가 아닌 = 검색을 하는 필드
$this->{$this->modelname}->allow_order_field = array('tag_id', 'tag_name', 'cnt'); // 정렬이 가능한 필드
$where = array();
if ($this->input->get('app_id')) {
$where['app_id'] = $this->input->get('app_id');
}
$result = $this->{$this->modelname}
->get_admin_list($per_page, $offset, $where, '', $findex, $forder, $sfield, $skeyword);
$list_num = $result['total_rows'] - ($page - 1) * $per_page;
if (element('list', $result)) {
foreach (element('list', $result) as $key => $val) {
$result['list'][$key]['num'] = $list_num--;
}
}
$view['view']['data'] = $result;
$view['view']['applist'] = $this->Apps_model->app_list();
/**
* primary key 정보를 저장합니다
*/
$view['view']['primary_key'] = $this->{$this->modelname}->primary_key;
/**
* 페이지네이션을 생성합니다
*/
$config['base_url'] = admin_url($this->pagedir) . '?' . $param->replace('page');
$config['total_rows'] = $result['total_rows'];
$config['per_page'] = $per_page;
$this->pagination->initialize($config);
$view['view']['paging'] = $this->pagination->create_links();
$view['view']['page'] = $page;
/**
* 쓰기 주소, 삭제 주소등 필요한 주소를 구합니다
*/
$search_option = array('tag_name' => '태그명');
$view['view']['skeyword'] = ($sfield && array_key_exists($sfield, $search_option)) ? $skeyword : '';
$view['view']['search_option'] = search_option($search_option, $sfield);
$view['view']['listall_url'] = admin_url($this->pagedir);
/**
* 어드민 레이아웃을 정의합니다
*/
$layoutconfig = array('layout' => 'layout', 'skin' => 'index');
$view['layout'] = $this->layoutlib->admin($layoutconfig, $this->configlib->get_device_view_type());
$this->data = $view;
$this->layout = element('layout_skin_file', element('layout', $view));
$this->view = element('view_skin_file', element('layout', $view));
}
/**
* 목록 페이지에서 선택삭제를 하는 경우 실행되는 메소드입니다
*/
public function listdelete()
{
/**
* 체크한 게시물의 삭제를 실행합니다
*/
if ($this->input->post('chk') && is_array($this->input->post('chk'))) {
foreach ($this->input->post('chk') as $val) {
if ($val) {
$getdata = $this->{$this->modelname}->get_one($val);
$where = array(
'tag_name' => element('tag_name', $getdata),
);
$this->{$this->modelname}->delete('', $where);
}
}
}
/**
* 삭제가 끝난 후 목록페이지로 이동합니다
*/
$this->session->set_flashdata(
'message',
'정상적으로 삭제되었습니다'
);
$param =& $this->querystring;
$redirecturl = admin_url($this->pagedir . '?' . $param->output());
redirect($redirecturl);
}
}

View File

@@ -0,0 +1,142 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
/**
* Reserve class
*/
class Reserve extends MY_Controller
{
/**
* 관리자 페이지 상의 현재 디렉토리입니다
* 페이지 이동시 필요한 정보입니다
*/
public $pagedir = 'reserve/reserve';
/**
* 모델을 로딩합니다
*/
protected $models = array('Contents_category', 'Apps');
/**
* 이 컨트롤러의 메인 모델 이름입니다
*/
protected $modelname = 'Contents_category_model';
/**
* 헬퍼를 로딩합니다
*/
protected $helpers = array('form', 'array');
function __construct()
{
parent::__construct();
/**
* 라이브러리를 로딩합니다
*/
$this->load->library(array('pagination', 'querystring'));
}
/**
* 목록을 가져오는 메소드입니다
*/
public function index()
{
$view = array();
$view['view'] = array();
/**
* 페이지에 숫자가 아닌 문자가 입력되거나 1보다 작은 숫자가 입력되면 에러 페이지를 보여줍니다.
*/
$param =& $this->querystring;
$app_id = $this->input->get('app_id');
if ($app_id) {
$where = array(
'cat_parent' => '0',
'app_id' => $app_id,
);
$result = $this->{$this->modelname}->get('', '', $where, '', '', 'cat_sort', 'desc');
$view['view']['data'] = $result;
}
$view['view']['applist'] = $this->Apps_model->app_list();
/**
* primary key 정보를 저장합니다
*/
$view['view']['primary_key'] = $this->{$this->modelname}->primary_key;
/**
* 어드민 레이아웃을 정의합니다
*/
$layoutconfig = array('layout' => 'layout', 'skin' => 'index');
$view['layout'] = $this->layoutlib->admin($layoutconfig, $this->configlib->get_device_view_type());
$this->data = $view;
$this->layout = element('layout_skin_file', element('layout', $view));
$this->view = element('view_skin_file', element('layout', $view));
}
/**
* 게시판 글쓰기 또는 수정 페이지를 가져오는 메소드입니다
*/
public function write($app_id = 0)
{
$this->accesslevel->check_admin('read');
$view = array();
$view['view'] = array();
/**
* 프라이머리키에 숫자형이 입력되지 않으면 에러처리합니다
*/
$primary_key = $this->{$this->modelname}->primary_key;
if (! $this->input->post('is_submit')) {
alert('잘못된 접근입니다');
}
$cat_time = $this->input->post('cat_publish_time');
if ($cat_time) {
foreach ($cat_time as $key => $value) {
if ($value) {
$updatedata = array(
'cat_publish_time' => $value,
);
} else {
$updatedata = array(
'cat_publish_time' => null,
);
}
$upwhere = array(
'cat_id' => $key,
);
$this->{$this->modelname}->update('', $updatedata, $upwhere);
}
}
$this->session->set_flashdata('message','정상적으로 수정되었습니다');
/**
* 게시물의 신규입력 또는 수정작업이 끝난 후 목록 페이지로 이동합니다
*/
$param =& $this->querystring;
$redirecturl = admin_url($this->pagedir . '?app_id=' . $this->input->post('app_id'));
redirect($redirecturl);
}
}

View File

@@ -0,0 +1,327 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
/**
* Pushsend class
*/
/**
* Pushsend controller 입니다.
*/
class Pushsend extends MY_Controller
{
/**
* 마이샵 페이지 상의 현재 디렉토리입니다
* 페이지 이동시 필요한 정보입니다
*/
public $pagedir = 'user/pushsend';
/**
* 모델을 로딩합니다
*/
protected $models = array('Fcm_result');
/**
* 이 컨트롤러의 메인 모델 이름입니다
*/
protected $modelname = 'Fcm_result_model';
/**
* 헬퍼를 로딩합니다
*/
protected $helpers = array('form', 'array', 'chkstring');
function __construct()
{
parent::__construct();
/**
* 라이브러리를 로딩합니다
*/
$this->load->library(array('pagination', 'querystring'));
}
/**
* 목록을 가져오는 메소드입니다
*/
public function index()
{
$view = array();
$view['view'] = array();
/**
* 페이지에 숫자가 아닌 문자가 입력되거나 1보다 작은 숫자가 입력되면 에러 페이지를 보여줍니다.
*/
$param =& $this->querystring;
$page = (((int) $this->input->get('page')) > 0) ? ((int) $this->input->get('page')) : 1;
$findex = $this->input->get('findex') ? $this->input->get('findex') : $this->{$this->modelname}->primary_key;
$forder = $this->input->get('forder', null, 'desc');
$sfield = $this->input->get('sfield', null, '');
$skeyword = $this->input->get('skeyword', null, '');
$per_page = admin_listnum();
$offset = ($page - 1) * $per_page;
/**
* 게시판 목록에 필요한 정보를 가져옵니다.
*/
$this->{$this->modelname}->allow_search_field = array('id', 'user_id'); // 검색이 가능한 필드
$this->{$this->modelname}->search_field_equal = array('id'); // 검색중 like 가 아닌 = 검색을 하는 필드
$this->{$this->modelname}->allow_order_field = array('id'); // 정렬이 가능한 필드
$where = array();
$result = $this->{$this->modelname}
->get_admin_list($per_page, $offset, $where, '', $findex, $forder, $sfield, $skeyword);
$list_num = $result['total_rows'] - ($page - 1) * $per_page;
if (element('list', $result)) {
foreach (element('list', $result) as $key => $val) {
$result['list'][$key]['num'] = $list_num--;
}
}
$view['view']['data'] = $result;
/**
* primary key 정보를 저장합니다
*/
$view['view']['primary_key'] = $this->{$this->modelname}->primary_key;
/**
* 페이지네이션을 생성합니다
*/
$config['base_url'] = admin_url($this->pagedir) . '?' . $param->replace('page');
$config['total_rows'] = $result['total_rows'];
$config['per_page'] = $per_page;
$this->pagination->initialize($config);
$view['view']['paging'] = $this->pagination->create_links();
$view['view']['page'] = $page;
/**
* 쓰기 주소, 삭제 주소등 필요한 주소를 구합니다
*/
$search_option = array('id' => '고유번호');
$view['view']['skeyword'] = ($sfield && array_key_exists($sfield, $search_option)) ? $skeyword : '';
$view['view']['search_option'] = search_option($search_option, $sfield);
$view['view']['listall_url'] = admin_url($this->pagedir);
$view['view']['write_url'] = admin_url($this->pagedir . '/write');
$view['view']['list_delete_url'] = admin_url($this->pagedir . '/listdelete/?' . $param->output());
/**
* 어드민 레이아웃을 정의합니다
*/
$layoutconfig = array('layout' => 'layout', 'skin' => 'index');
$view['layout'] = $this->layoutlib->admin($layoutconfig, $this->configlib->get_device_view_type());
$this->data = $view;
$this->layout = element('layout_skin_file', element('layout', $view));
$this->view = element('view_skin_file', element('layout', $view));
}
/**
* 게시판 글쓰기 또는 수정 페이지를 가져오는 메소드입니다
*/
public function write($pid = 0)
{
$view = array();
$view['view'] = array();
/**
* 프라이머리키에 숫자형이 입력되지 않으면 에러처리합니다
*/
if ($pid) {
$pid = (int) $pid;
if (empty($pid) OR $pid < 1) {
show_404();
}
}
$primary_key = $this->{$this->modelname}->primary_key;
/**
* 수정 페이지일 경우 기존 데이터를 가져옵니다
*/
$getdata = array();
if ($pid) {
$getdata = $this->{$this->modelname}->get_one($pid);
}
/**
* Validation 라이브러리를 가져옵니다
*/
$this->load->library('form_validation');
if ( ! function_exists('password_hash')) {
$this->load->helper('password');
}
/**
* 전송된 데이터의 유효성을 체크합니다
*/
$config = array(
array(
'field' => 'sendto',
'label' => '발송방법',
'rules' => 'trim|required',
),
array(
'field' => 'user_token',
'label' => '토큰',
'rules' => 'trim',
),
array(
'field' => 'title',
'label' => '제목',
'rules' => 'trim|required',
),
array(
'field' => 'message',
'label' => '내용',
'rules' => 'trim',
)
);
$this->form_validation->set_rules($config);
//현재 설정 key 가져오기
$this->load->config('fcm');
$view['view']['fcm_api_key'] = $this->config->item('fcm_api_key');
/**
* 유효성 검사를 하지 않는 경우, 또는 유효성 검사에 실패한 경우입니다.
* 즉 글쓰기나 수정 페이지를 보고 있는 경우입니다
*/
if ($this->form_validation->run() === false) {
//기본값
if(!element('message', $getdata)) {
$getdata['message'] = '';
}
$view['view']['data'] = $getdata;
//primary key 정보를 저장합니다
$view['view']['primary_key'] = $primary_key;
//어드민 레이아웃을 정의합니다
$layoutconfig = array('layout' => 'layout', 'skin' => 'write');
$view['layout'] = $this->layoutlib->admin($layoutconfig, $this->configlib->get_device_view_type());
$this->data = $view;
$this->layout = element('layout_skin_file', element('layout', $view));
$this->view = element('view_skin_file', element('layout', $view));
} else {
/**
* 유효성 검사를 통과한 경우입니다.
* 즉 데이터의 insert 나 update 의 process 처리가 필요한 상황입니다
*/
$updatedata = array(
'sendto' => $this->input->post('sendto', null, ''),
'topic' => $this->input->post('topic', null, ''),
'user_id' => $this->input->post('user_id', null, ''),
'user_token' => $this->input->post('user_token', null, ''),
'title' => $this->input->post('title', null, ''),
'message' => $this->input->post('message', null, ''),
);
//게시물 수정
if ($this->input->post($primary_key)) {
$as_id = $this->input->post($primary_key);
$this->{$this->modelname}->update($as_id, $updatedata);
$this->session->set_flashdata(
'message',
'정상적으로 수정되었습니다'
);
} else {
//$this->accesslevel->check_admin('write');//20170602 에러 발생하여 주석처리 함
//푸시발송
$this->load->library('Fcm_library');
//변수 정리
$sendto = $this->input->post('sendto');
$topic = $this->input->post('topic');
$user_id = $this->input->post('user_id');
$user_token = $this->input->post('user_token');
$title = $this->input->post('title');
$message = $this->input->post('message');
//전체발송일 경우 처리
//앱에서 FCM 처리가 되지 않아 전체 FOR문을 돌리는 것으로 대체함
//20170420
if($sendto == 'topic') {
$all_user_token = $this->db->select('user_userid, user_fcm_token')->where("user_fcm_token != ", "")->where("user_use_push", "1")->get("user")->result_array();
if($all_user_token) {
foreach($all_user_token as $k => $v) {
$sendto = 'token';
$topic = '';
$user_id = $v['user_userid'];
$user_token = $v['user_fcm_token'];
if(strlen($user_token) < 100) continue;
$this->fcm_library->send($sendto, $topic, $user_id, $user_token, $title, $message);
}
}
} else {
$this->fcm_library->send($sendto, $topic, $user_id, $user_token, $title, $message);
}
$this->session->set_flashdata(
'message',
'정상적으로 입력되었습니다'
);
}
/**
* 게시물의 신규입력 또는 수정작업이 끝난 후 목록 페이지로 이동합니다
*/
$param =& $this->querystring;
$redirecturl = admin_url($this->pagedir . '?' . $param->output());
redirect($redirecturl);
}
}
/**
* 목록 페이지에서 선택삭제를 하는 경우 실행되는 메소드입니다
*/
public function listdelete()
{
/**
* 체크한 게시물의 삭제를 실행합니다
*/
if ($this->input->post('chk') && is_array($this->input->post('chk'))) {
foreach ($this->input->post('chk') as $val) {
if ($val) {
$this->Fcm_result_model->delete($val);
}
}
}
/**
* 삭제가 끝난 후 목록페이지로 이동합니다
*/
$this->session->set_flashdata(
'message',
'정상적으로 삭제되었습니다'
);
$param =& $this->querystring;
$redirecturl = admin_url($this->pagedir . '?' . $param->output());
redirect($redirecturl);
}
}

View File

@@ -0,0 +1,952 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
/**
* Users class
*/
/**
* 관리자>회원설정>회원관리 controller 입니다.
*/
class Users extends MY_Controller
{
/**
* 관리자 페이지 상의 현재 디렉토리입니다
* 페이지 이동시 필요한 정보입니다
*/
public $pagedir = 'user/users';
/**
* 모델을 로딩합니다
*/
protected $models = array('User_meta', 'Social_meta', 'Apps');
/**
* 이 컨트롤러의 메인 모델 이름입니다
*/
protected $modelname = 'User_model';
/**
* 헬퍼를 로딩합니다
*/
protected $helpers = array('form', 'array', 'chkstring');
function __construct()
{
parent::__construct();
/**
* 라이브러리를 로딩합니다
*/
$this->load->library(array('pagination', 'querystring'));
}
/**
* 목록을 가져오는 메소드입니다
*/
public function index()
{
$this->accesslevel->check_admin('read');
$view = array();
$view['view'] = array();
/**
* 페이지에 숫자가 아닌 문자가 입력되거나 1보다 작은 숫자가 입력되면 에러 페이지를 보여줍니다.
*/
$param =& $this->querystring;
$page = (((int) $this->input->get('page')) > 0) ? ((int) $this->input->get('page')) : 1;
$view['view']['sort'] = array(
'user_id' => $param->sort('user_id', 'asc'),
'user_username' => $param->sort('user_username', 'asc'),
'user_email' => $param->sort('user_email', 'asc'),
'user_register_datetime' => $param->sort('user_register_datetime', 'asc'),
'user_lastlogin_datetime' => $param->sort('user_lastlogin_datetime', 'asc'),
);
$findex = $this->input->get('findex', null, 'user.user_id');
$forder = $this->input->get('forder', null, 'desc');
$sfield = $this->input->get('sfield', null, '');
$skeyword = $this->input->get('skeyword', null, '');
$per_page = admin_listnum();
$offset = ($page - 1) * $per_page;
/**
* 게시판 목록에 필요한 정보를 가져옵니다.
*/
$this->{$this->modelname}->allow_search_field = array('user_id', 'user_email', 'user_username', 'user_homepage', 'user_register_datetime', 'user_register_ip', 'user_lastlogin_datetime', 'user_lastlogin_ip', 'user_is_admin'); // 검색이 가능한 필드
$this->{$this->modelname}->search_field_equal = array('user_id', 'user_is_admin'); // 검색중 like 가 아닌 = 검색을 하는 필드
$this->{$this->modelname}->allow_order_field = array('user.user_id', 'user_username', 'user_email', 'user_register_datetime', 'user_lastlogin_datetime'); // 정렬이 가능한 필드
$where = array();
if ($this->input->get('user_is_admin')) {
$where['user_is_admin'] = 1;
}
if ($this->input->get('user_denied')) {
$where['user_denied'] = 1;
}
$result = $this->{$this->modelname}
->get_admin_list($per_page, $offset, $where, '', $findex, $forder, $sfield, $skeyword);
$list_num = $result['total_rows'] - ($page - 1) * $per_page;
if (element('list', $result)) {
foreach (element('list', $result) as $key => $val) {
$result['list'][$key]['display_name'] = display_username(
element('user_username', $val)
);
$result['list'][$key]['meta'] = $this->User_meta_model->get_all_meta(element('user_id', $val));
$result['list'][$key]['social'] = $this->Social_meta_model->get_all_meta(element('user_id', $val));
if (element('app_id', $val)) {
$result['list'][$key]['apps'] = $this->Apps_model->get_one(element('app_id', $val));
}
$result['list'][$key]['num'] = $list_num--;
}
}
$view['view']['data'] = $result;
/**
* primary key 정보를 저장합니다
*/
$view['view']['primary_key'] = $this->{$this->modelname}->primary_key;
/**
* 페이지네이션을 생성합니다
*/
$config['base_url'] = admin_url($this->pagedir) . '?' . $param->replace('page');
$config['total_rows'] = $result['total_rows'];
$config['per_page'] = $per_page;
$this->pagination->initialize($config);
$view['view']['paging'] = $this->pagination->create_links();
$view['view']['page'] = $page;
/**
* 쓰기 주소, 삭제 주소등 필요한 주소를 구합니다
*/
$search_option = array('user_email' => '이메일', 'user_username' => '회원명', 'user_homepage' => '홈페이지', 'user_register_datetime' => '회원가입날짜', 'user_register_ip' => '회원가입IP', 'user_lastlogin_datetime' => '최종로그인날짜', 'user_lastlogin_ip' => '최종로그인IP', 'user_adminmemo' => '관리자메모');
$view['view']['skeyword'] = ($sfield && array_key_exists($sfield, $search_option)) ? $skeyword : '';
$view['view']['search_option'] = search_option($search_option, $sfield);
$view['view']['listall_url'] = admin_url($this->pagedir);
$view['view']['write_url'] = admin_url($this->pagedir . '/write');
$view['view']['list_delete_url'] = admin_url($this->pagedir . '/listdelete/?' . $param->output());
/**
* 어드민 레이아웃을 정의합니다
*/
$layoutconfig = array('layout' => 'layout', 'skin' => 'index');
$view['layout'] = $this->layoutlib->admin($layoutconfig, $this->configlib->get_device_view_type());
$this->data = $view;
$this->layout = element('layout_skin_file', element('layout', $view));
$this->view = element('view_skin_file', element('layout', $view));
}
/**
* 게시판 글쓰기 또는 수정 페이지를 가져오는 메소드입니다
*/
public function write($pid = 0)
{
$this->accesslevel->check_admin('read');
$view = array();
$view['view'] = array();
/**
* 프라이머리키에 숫자형이 입력되지 않으면 에러처리합니다
*/
if ($pid) {
$pid = (int) $pid;
if (empty($pid) OR $pid < 1) {
show_404();
}
}
$primary_key = $this->{$this->modelname}->primary_key;
/**
* 수정 페이지일 경우 기존 데이터를 가져옵니다
*/
$getdata = array();
if ($pid) {
$getdata = $this->{$this->modelname}->get_one($pid);
$getdata['meta'] = $this->User_meta_model->get_all_meta($pid);
}
$registerform = $this->configlib->item('registerform');
$form = json_decode($registerform, true);
/**
* Validation 라이브러리를 가져옵니다
*/
$this->load->library('form_validation');
if ( ! function_exists('password_hash')) {
$this->load->helper('password');
}
/**
* 전송된 데이터의 유효성을 체크합니다
*/
$config = array(
array(
'field' => 'user_username',
'label' => '이름',
'rules' => 'trim|min_length[2]|max_length[20]|callback__user_username_check',
),
array(
'field' => 'user_homepage',
'label' => '홈페이지',
'rules' => 'valid_url',
),
array(
'field' => 'user_birthday',
'label' => '생일',
'rules' => 'trim|exact_length[10]',
),
array(
'field' => 'user_sex',
'label' => '성별',
'rules' => 'trim|exact_length[1]',
),
array(
'field' => 'user_phone',
'label' => '전화번호',
'rules' => 'trim|valid_phone',
),
array(
'field' => 'user_zipcode',
'label' => '우편번호',
'rules' => 'trim|min_length[5]|max_length[7]',
),
array(
'field' => 'user_address1',
'label' => '기본주소',
'rules' => 'trim',
),
array(
'field' => 'user_address2',
'label' => '상세주소',
'rules' => 'trim',
),
array(
'field' => 'user_address3',
'label' => '참고항목',
'rules' => 'trim',
),
array(
'field' => 'user_address4',
'label' => '지번',
'rules' => 'trim',
),
array(
'field' => 'user_receive_email',
'label' => '이메일수신여부',
'rules' => 'trim|exact_length[1]',
),
);
if ($this->input->post($primary_key)) {
$config[] = array(
'field' => 'user_password',
'label' => '패스워드',
'rules' => 'trim|min_length[4]',
);
$config[] = array(
'field' => 'user_email',
'label' => '회원이메일',
'rules' => 'trim|required|valid_email|is_unique[user.user_email.user_id.' . element('user_id', $getdata) . ']',
);
} else {
$config[] = array(
'field' => 'user_password',
'label' => '패스워드',
'rules' => 'trim|required|min_length[4]',
);
$config[] = array(
'field' => 'user_email',
'label' => '회원이메일',
'rules' => 'trim|required|valid_email|is_unique[user.user_email]',
);
}
$this->form_validation->set_rules($config);
$form_validation = $this->form_validation->run();
$file_error = '';
$updatephoto = '';
$file_error2 = '';
$updateicon = '';
if ($form_validation) {
$this->load->library('upload');
if (isset($_FILES) && isset($_FILES['user_photo']) && isset($_FILES['user_photo']['name']) && $_FILES['user_photo']['name']) {
$upload_path = config_item('uploads_dir') . '/user_photo/';
if (is_dir($upload_path) === false) {
mkdir($upload_path, 0707);
$file = $upload_path . 'index.php';
$f = @fopen($file, 'w');
@fwrite($f, '');
@fclose($f);
@chmod($file, 0644);
}
$upload_path .= cdate('Y') . '/';
if (is_dir($upload_path) === false) {
mkdir($upload_path, 0707);
$file = $upload_path . 'index.php';
$f = @fopen($file, 'w');
@fwrite($f, '');
@fclose($f);
@chmod($file, 0644);
}
$upload_path .= cdate('m') . '/';
if (is_dir($upload_path) === false) {
mkdir($upload_path, 0707);
$file = $upload_path . 'index.php';
$f = @fopen($file, 'w');
@fwrite($f, '');
@fclose($f);
@chmod($file, 0644);
}
$uploadconfig = '';
$uploadconfig['upload_path'] = $upload_path;
$uploadconfig['allowed_types'] = 'jpg|jpeg|png|gif';
$uploadconfig['max_size'] = '2000';
$uploadconfig['max_width'] = '1000';
$uploadconfig['max_height'] = '1000';
$uploadconfig['encrypt_name'] = true;
$this->upload->initialize($uploadconfig);
if ($this->upload->do_upload('user_photo')) {
$img = $this->upload->data();
$updatephoto = cdate('Y') . '/' . cdate('m') . '/' . element('file_name', $img);
} else {
$file_error = $this->upload->display_errors();
}
}
if (isset($_FILES)
&& isset($_FILES['user_icon'])
&& isset($_FILES['user_icon']['name'])
&& $_FILES['user_icon']['name']) {
$upload_path = config_item('uploads_dir') . '/user_icon/';
if (is_dir($upload_path) === false) {
mkdir($upload_path, 0707);
$file = $upload_path . 'index.php';
$f = @fopen($file, 'w');
@fwrite($f, '');
@fclose($f);
@chmod($file, 0644);
}
$upload_path .= cdate('Y') . '/';
if (is_dir($upload_path) === false) {
mkdir($upload_path, 0707);
$file = $upload_path . 'index.php';
$f = @fopen($file, 'w');
@fwrite($f, '');
@fclose($f);
@chmod($file, 0644);
}
$upload_path .= cdate('m') . '/';
if (is_dir($upload_path) === false) {
mkdir($upload_path, 0707);
$file = $upload_path . 'index.php';
$f = @fopen($file, 'w');
@fwrite($f, '');
@fclose($f);
@chmod($file, 0644);
}
$uploadconfig = '';
$uploadconfig['upload_path'] = $upload_path;
$uploadconfig['allowed_types'] = 'jpg|jpeg|png|gif';
$uploadconfig['max_size'] = '2000';
$uploadconfig['max_width'] = '1000';
$uploadconfig['max_height'] = '1000';
$uploadconfig['encrypt_name'] = true;
$this->upload->initialize($uploadconfig);
if ($this->upload->do_upload('user_icon')) {
$img = $this->upload->data();
$updateicon = cdate('Y') . '/' . cdate('m') . '/' . element('file_name', $img);
} else {
$file_error2 = $this->upload->display_errors();
}
}
}
/**
* 유효성 검사를 하지 않는 경우, 또는 유효성 검사에 실패한 경우입니다.
* 즉 글쓰기나 수정 페이지를 보고 있는 경우입니다
*/
if ($form_validation === false OR $file_error !== '' OR $file_error2 !== '') {
$view['view']['message'] = $file_error . $file_error2;
$view['view']['data'] = $getdata;
if (empty($pid)) {
$view['view']['data']['user_receive_email'] = 1;
}
/**
* primary key 정보를 저장합니다
*/
$view['view']['primary_key'] = $primary_key;
$html_content = '';
$k = 0;
if ($form && is_array($form)) {
foreach ($form as $key => $value) {
if ( ! element('use', $value)) {
continue;
}
if (element('func', $value) === 'basic') {
continue;
}
$required = element('required', $value) ? 'required' : '';
$item = element(element('field_name', $value), element('extras', $getdata));
$html_content[$k]['field_name'] = element('field_name', $value);
$html_content[$k]['display_name'] = element('display_name', $value);
$html_content[$k]['input'] = '';
//field_type : text, url, email, phone, textarea, radio, select, checkbox, date
if (element('field_type', $value) === 'text'
OR element('field_type', $value) === 'url'
OR element('field_type', $value) === 'email'
OR element('field_type', $value) === 'phone'
OR element('field_type', $value) === 'date') {
if (element('field_type', $value) === 'date') {
$html_content[$k]['input'] .= '<input type="text" id="' . element('field_name', $value) . '" name="' . element('field_name', $value) . '" class="form-control datepicker" value="' . set_value(element('field_name', $value), $item) . '" readonly="readonly" ' . $required . ' />';
} elseif (element('field_type', $value) === 'phone') {
$html_content[$k]['input'] .= '<input type="text" id="' . element('field_name', $value) . '" name="' . element('field_name', $value) . '" class="form-control validphone" value="' . set_value(element('field_name', $value), $item) . '" ' . $required . ' />';
} else {
$html_content[$k]['input'] .= '<input type="' . element('field_type', $value) . '" id="' . element('field_name', $value) . '" name="' . element('field_name', $value) . '" class="form-control" value="' . set_value(element('field_name', $value), $item) . '" ' . $required . ' />';
}
} elseif (element('field_type', $value) === 'textarea') {
$html_content[$k]['input'] .= '<textarea id="' . element('field_name', $value) . '" name="' . element('field_name', $value) . '" class="form-control" ' . $required . ' >' . set_value(element('field_name', $value), $item) . '</textarea>';
} elseif (element('field_type', $value) === 'radio') {
$html_content[$k]['input'] .= '<div class="checkbox">';
$options = explode("\n", element('options', $value));
$i =1;
if ($options) {
foreach ($options as $okey => $oval) {
$oval = trim($oval);
$radiovalue = (element('field_name', $value) === 'user_sex') ? $okey : $oval;
$html_content[$k]['input'] .= '<label for="' . element('field_name', $value) . '_' . $i . '"><input type="radio" name="' . element('field_name', $value) . '" id="' . element('field_name', $value) . '_' . $i . '" value="' . $radiovalue . '" ' . set_radio(element('field_name', $value), $radiovalue, ($item === $radiovalue ? true : false)) . ' /> ' . $oval . ' </label> ';
$i++;
}
}
$html_content[$k]['input'] .= '</div>';
} elseif (element('field_type', $value) === 'checkbox') {
$html_content[$k]['input'] .= '<div class="checkbox">';
$options = explode("\n", element('options', $value));
$item = json_decode($item, true);
$i =1;
if ($options) {
foreach ($options as $okey => $oval) {
$oval = trim($oval);
$chkvalue = is_array($item) && in_array($oval, $item) ? $oval : '';
$html_content[$k]['input'] .= '<label for="' . element('field_name', $value) . '_' . $i . '"><input type="checkbox" name="' . element('field_name', $value) . '[]" id="' . element('field_name', $value) . '_' . $i . '" value="' . $oval . '" ' . set_checkbox(element('field_name', $value), $oval, ($chkvalue ? true : false)) . ' /> ' . $oval . ' </label> ';
$i++;
}
}
$html_content[$k]['input'] .= '</div>';
} elseif (element('field_type', $value) === 'select') {
$html_content[$k]['input'] .= '<div class="input-group">';
$html_content[$k]['input'] .= '<select name="' . element('field_name', $value) . '" class="form-control" ' . $required . '>';
$html_content[$k]['input'] .= '<option value="" >선택하세요</option> ';
$options = explode("\n", element('options', $value));
if ($options) {
foreach ($options as $okey => $oval) {
$oval = trim($oval);
$html_content[$k]['input'] .= '<option value="' . $oval . '" ' . set_select(element('field_name', $value), $oval, ($item === $oval ? true : false)) . ' >' . $oval . '</option> ';
}
}
$html_content[$k]['input'] .= '</select>';
$html_content[$k]['input'] .= '</div>';
}
$k++;
}
}
$view['view']['html_content'] = $html_content;
/**
* 어드민 레이아웃을 정의합니다
*/
$layoutconfig = array('layout' => 'layout', 'skin' => 'write');
$view['layout'] = $this->layoutlib->admin($layoutconfig, $this->configlib->get_device_view_type());
$this->data = $view;
$this->layout = element('layout_skin_file', element('layout', $view));
$this->view = element('view_skin_file', element('layout', $view));
} else {
/**
* 유효성 검사를 통과한 경우입니다.
* 즉 데이터의 insert 나 update 의 process 처리가 필요한 상황입니다
*/
$user_sex = $this->input->post('user_sex') ? $this->input->post('user_sex') : 0;
$user_receive_email = $this->input->post('user_receive_email') ? 1 : 0;
$user_email_cert = $this->input->post('user_email_cert') ? 1 : 0;
$user_is_admin = $this->input->post('user_is_admin') ? $this->input->post('user_is_admin') : 0;
$updatedata = array(
'user_email' => $this->input->post('user_email', null, ''),
'user_username' => $this->input->post('user_username', null, ''),
'user_homepage' => $this->input->post('user_homepage', null, ''),
'user_birthday' => $this->input->post('user_birthday', null, ''),
'user_phone' => $this->input->post('user_phone', null, ''),
'user_sex' => $user_sex,
'user_zipcode' => $this->input->post('user_zipcode', null, ''),
'user_address1' => $this->input->post('user_address1', null, ''),
'user_address2' => $this->input->post('user_address2', null, ''),
'user_address3' => $this->input->post('user_address3', null, ''),
'user_address4' => $this->input->post('user_address4', null, ''),
'user_receive_email' => $user_receive_email,
'user_denied' => $this->input->post('user_denied', null, ''),
'user_email_cert' => $user_email_cert,
'user_is_admin' => $user_is_admin,
'user_adminmemo' => $this->input->post('user_adminmemo', null, ''),
);
$metadata = array();
if (empty($getdata['user_denied']) && $this->input->post('user_denied')) {
$metadata['meta_denied_datetime'] = cdate('Y-m-d H:i:s');
$metadata['meta_denied_by_user_id'] = $this->userlib->item('user_id');
}
if ( ! empty($getdata['user_denied']) && ! $this->input->post('user_denied')) {
$metadata['meta_denied_datetime'] = '';
$metadata['meta_denied_by_user_id'] = '';
}
if (empty($getdata['user_email_cert']) && $this->input->post('user_email_cert')) {
$metadata['meta_email_cert_datetime'] = cdate('Y-m-d H:i:s');
}
if ( ! empty($getdata['user_email_cert']) && ! $this->input->post('user_email_cert')) {
$metadata['meta_email_cert_datetime'] = '';
}
if (element('user_username', $getdata) !== $this->input->post('user_username')) {
$updatedata['user_username'] = $this->input->post('user_username', null, '');
$metadata['meta_username_datetime'] = cdate('Y-m-d H:i:s');
}
if ($this->input->post('user_password')) {
$updatedata['user_password'] = password_hash($this->input->post('user_password'), PASSWORD_BCRYPT);
}
if ($this->input->post('user_photo_del')) {
$updatedata['user_photo'] = '';
} elseif ($updatephoto) {
$updatedata['user_photo'] = $updatephoto;
}
if (element('user_photo', $getdata) && ($this->input->post('user_photo_del') OR $updatephoto)) {
// 기존 파일 삭제
@unlink(config_item('uploads_dir') . '/user_photo/' . element('user_photo', $getdata));
}
if ($this->input->post('user_icon_del')) {
$updatedata['user_icon'] = '';
} elseif ($updateicon) {
$updatedata['user_icon'] = $updateicon;
}
if (element('user_icon', $getdata) && ($this->input->post('user_icon_del') OR $updateicon)) {
// 기존 파일 삭제
@unlink(config_item('uploads_dir') . '/user_icon/' . element('user_icon', $getdata));
}
/**
* 게시물을 수정하는 경우입니다
*/
if ($this->input->post($primary_key)) {
$this->accesslevel->check_admin('edit');
$user_id = $this->input->post($primary_key);
$this->{$this->modelname}->update($user_id, $updatedata);
$this->User_meta_model->save($user_id, $metadata);
$this->session->set_flashdata(
'message',
'정상적으로 수정되었습니다'
);
} else {
$this->accesslevel->check_admin('write');
/**
* 게시물을 새로 입력하는 경우입니다
*/
$updatedata['user_register_datetime'] = cdate('Y-m-d H:i:s');
$updatedata['user_register_ip'] = $this->input->ip_address();
$user_id = $this->{$this->modelname}->insert($updatedata);
$this->User_meta_model->save($user_id, $metadata);
$this->session->set_flashdata(
'message',
'정상적으로 입력되었습니다'
);
}
/**
* 게시물의 신규입력 또는 수정작업이 끝난 후 목록 페이지로 이동합니다
*/
$param =& $this->querystring;
$redirecturl = admin_url($this->pagedir . '?' . $param->output());
redirect($redirecturl);
}
}
/**
* 소셜 정보 자세히 보는 팝업페이지입니다
*/
public function socialinfo($socialtype = '', $user_id = 0)
{
$this->accesslevel->check_admin('read');
$view = array();
$view['view'] = array();
$this->load->model(array('Social_model', 'Social_meta_model'));
$social = array('facebook' => '페이스북', 'twitter' => '트위터', 'google' => '구글', 'naver' => '네이버', 'kakao' => '카카오');
$user_id = (int) $user_id;
if (empty($user_id) OR $user_id < 1) {
alert('잘못된 접근입니다');
}
if (empty($socialtype)) {
alert('잘못된 접근입니다');
}
if ( ! element($socialtype, $social)) {
alert('잘못된 접근입니다');
}
$social_id = $this->Social_meta_model->get_social_id_by_user_id($socialtype, $user_id);
$swhere = array(
'soc_type' => $socialtype,
'soc_account_id' => $social_id,
);
$socialinfo = $this->Social_model->get('', '', $swhere, '', '', 'soc_id', 'ASC');
$data = array();
if ($socialinfo) {
foreach ($socialinfo as $key => $value) {
if ($value['soc_value']) {
$data[$value['soc_key']] = $value['soc_value'];
}
}
}
$info = '';
if ($socialtype === 'facebook') {
$info = array(
array(
'key' => 'name',
'text' => '성명',
'value' => element('name', $data),
),
array(
'key' => 'last_name',
'text' => '성',
'value' => element('last_name', $data),
),
array(
'key' => 'first_name',
'text' => '이름',
'value' => element('first_name', $data),
),
array(
'key' => 'email',
'text' => '이메일',
'value' => element('email', $data),
),
array(
'key' => 'link',
'text' => '주소',
'value' => '<a href="' . goto_url(element('link', $data)) . '" target="_blank">' . element('link', $data) . '</a>',
),
array(
'key' => 'gender',
'text' => '성별',
'value' => (element('gender', $data) === 'male' ? '남성' : '여성'),
),
array(
'key' => 'locale',
'text' => '언어',
'value' => element('locale', $data),
),
array(
'key' => 'timezone',
'text' => '타임존',
'value' => element('timezone', $data),
),
array(
'key' => 'update_datetime',
'text' => '최종정보갱신일',
'value' => element('update_datetime', $data),
),
array(
'key' => 'ip_address',
'text' => '최종접속IP',
'value' => element('ip_address', $data),
),
);
}
if ($socialtype === 'twitter') {
$info = array(
array(
'key' => 'name',
'text' => '이름',
'value' => element('name', $data),
),
array(
'key' => 'screen_name',
'text' => '주소',
'value' => element('screen_name', $data),
),
array(
'key' => 'url',
'text' => 'URL',
'value' => element('url', $data),
),
array(
'key' => 'lang',
'text' => '언어',
'value' => element('lang', $data),
),
array(
'key' => 'description',
'text' => '설명',
'value' => element('description', $data),
),
array(
'key' => 'location',
'text' => '지역',
'value' => element('location', $data),
),
array(
'key' => 'created_at',
'text' => '트위터 생성일',
'value' => element('created_at', $data),
),
array(
'key' => 'update_datetime',
'text' => '최종정보갱신일',
'value' => element('update_datetime', $data),
),
array(
'key' => 'ip_address',
'text' => '최종접속IP',
'value' => element('ip_address', $data),
),
);
}
if ($socialtype === 'google') {
$info = array(
array(
'key' => 'name',
'text' => '성명',
'value' => element('name', $data),
),
array(
'key' => 'familyName',
'text' => '성',
'value' => element('familyName', $data),
),
array(
'key' => 'givenName',
'text' => '이름',
'value' => element('givenName', $data),
),
array(
'key' => 'email',
'text' => '이메일',
'value' => element('email', $data),
),
array(
'key' => 'gender',
'text' => '성별',
'value' => (element('gender', $data) === 'male' ? '남성' : '여성'),
),
array(
'key' => 'locale',
'text' => '언어',
'value' => element('locale', $data),
),
array(
'key' => 'link',
'text' => '주소',
'value' => '<a href="' . goto_url(element('link', $data)) . '" target="_blank">' . element('link', $data) . '</a>',
),
array(
'key' => 'picture',
'text' => '사진',
'value' => '<img src="' . element('picture', $data) . '" width="200" />',
),
array(
'key' => 'update_datetime',
'text' => '최종정보갱신일',
'value' => element('update_datetime', $data),
),
array(
'key' => 'ip_address',
'text' => '최종접속IP',
'value' => element('ip_address', $data),
),
);
}
if ($socialtype === 'naver') {
$info = array(
array(
'key' => 'name',
'text' => '이름',
'value' => element('name', $data),
),
array(
'key' => 'username',
'text' => '회원명',
'value' => element('username', $data),
),
array(
'key' => 'email',
'text' => '이메일',
'value' => element('email', $data),
),
array(
'key' => 'age',
'text' => '연령',
'value' => element('age', $data),
),
array(
'key' => 'gender',
'text' => '성별',
'value' => (element('gender', $data) === 'F' ? '여성' : '남성'),
),
array(
'key' => 'birthday',
'text' => '생일',
'value' => element('birthday', $data),
),
array(
'key' => 'update_datetime',
'text' => '최종정보갱신일',
'value' => element('update_datetime', $data),
),
array(
'key' => 'ip_address',
'text' => '최종접속IP',
'value' => element('ip_address', $data),
),
);
}
if ($socialtype === 'kakao') {
$info = array(
array(
'key' => 'username',
'text' => '회원명',
'value' => element('username', $data),
),
array(
'key' => 'profile_image',
'text' => '프로필이미지',
'value' => '<img src="' . element('profile_image', $data) . '" width="200" />'
),
array(
'key' => 'thumbnail_image',
'text' => '썸네일이미지',
'value' => '<img src="' . element('thumbnail_image', $data) . '" width="200" />'
),
array(
'key' => 'update_datetime',
'text' => '최종정보갱신일',
'value' => element('update_datetime', $data),
),
array(
'key' => 'ip_address',
'text' => '최종접속IP',
'value' => element('ip_address', $data),
),
);
}
$view['view']['data'] = $info;
$view['view']['socialtype'] = $socialtype;
$view['view']['socialname'] = $social[$socialtype];
/**
* 어드민 레이아웃을 정의합니다
*/
$layoutconfig = array('layout' => 'layout_popup', 'skin' => 'socialinfo');
$view['layout'] = $this->layoutlib->admin($layoutconfig, $this->configlib->get_device_view_type());
$this->data = $view;
$this->layout = element('layout_skin_file', element('layout', $view));
$this->view = element('view_skin_file', element('layout', $view));
}
/**
* 목록 페이지에서 선택삭제를 하는 경우 실행되는 메소드입니다
*/
public function listdelete()
{
$this->accesslevel->check_admin('delete');
/**
* 체크한 게시물의 삭제를 실행합니다
*/
if ($this->input->post('chk') && is_array($this->input->post('chk'))) {
foreach ($this->input->post('chk') as $val) {
if ($val) {
$this->userlib->delete_user($val);
}
}
}
/**
* 삭제가 끝난 후 목록페이지로 이동합니다
*/
$this->session->set_flashdata(
'message',
'정상적으로 삭제되었습니다'
);
$param =& $this->querystring;
$redirecturl = admin_url($this->pagedir . '?' . $param->output());
redirect($redirecturl);
}
/**
* 회원명 체크함수입니다
*/
public function _user_username_check($str)
{
if (chkstring($str, _HANGUL_ + _ALPHABETIC_ + _NUMERIC_) === false) {
$this->form_validation->set_message(
'_user_username_check',
'회원명은 공백없이 한글, 영문, 숫자만 입력 가능합니다'
);
return false;
}
return true;
}
}