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,58 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
/**
* Appinfo
*/
class Appinfo extends CI_Controller
{
private $CI;
function __construct()
{
$this->CI = & get_instance();
}
function main()
{
if ( ! $this->CI->input->post_get('token')) {
$this->CI->apilib->make_error("토큰 값이 넘어오지 않았습니다");
}
$token = $this->CI->input->post_get('token');
$app_id = (int) trim($this->CI->input->post_get('app_id'));
if (empty($app_id)) {
$this->CI->apilib->make_error("어플 아이디가 넘어오지 않았습니다");
}
$this->CI->load->model(array('Apps_model'));
$where = array(
'app_id' => $app_id,
);
$result = $this->CI->Apps_model->get_one('', '', $where);
if ( ! element('app_id', $result)) {
$this->CI->apilib->make_error("존재하지 않는 어플입니다");
}
$arr = array(
'result' => 'ok',
'token' => $token,
'app_id' => $app_id,
'app_package' => html_escape(element('app_package', $result)),
'app_name' => html_escape(element('app_name', $result)),
'app_sort' => html_escape(element('app_sort', $result)),
'app_policy' => nl2br(html_escape(element('app_policy', $result))),
);
return $arr;
}
}

View File

@@ -0,0 +1,70 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
/**
* Apprank
*/
class Apprank extends CI_Controller
{
private $CI;
function __construct()
{
$this->CI = & get_instance();
}
function main()
{
if ( ! $this->CI->input->post_get('token')) {
$this->CI->apilib->make_error("토큰 값이 넘어오지 않았습니다");
}
$token = $this->CI->input->post_get('token');
$app_id = (int) trim($this->CI->input->post_get('app_id'));
if (empty($app_id)) {
$this->CI->apilib->make_error("어플 아이디가 넘어오지 않았습니다");
}
$this->CI->load->model(array('Apps_model'));
$where = array(
'app_id' => $app_id,
);
$result = $this->CI->Apps_model->get_one('', '', $where);
if ( ! element('app_id', $result)) {
$this->CI->apilib->make_error("존재하지 않는 어플입니다");
}
$apprank = json_decode($result['app_rank'], true);
$arr = array(
'result' => 'ok',
'token' => $token,
'app_id' => $app_id,
'app_rank_1_title' => html_escape(element('app_rank_1_title', $apprank)),
'app_rank_1_desc' => html_escape(element('app_rank_1_desc', $apprank)),
'app_rank_1_link' => html_escape(element('app_rank_1_link', $apprank)),
'app_rank_1_image_url' => thumb_url('apprank', element('app_rank_1_image_url', $apprank), '50', '50'),
'app_rank_2_title' => html_escape(element('app_rank_2_title', $apprank)),
'app_rank_2_desc' => html_escape(element('app_rank_2_desc', $apprank)),
'app_rank_2_link' => html_escape(element('app_rank_2_link', $apprank)),
'app_rank_2_image_url' => thumb_url('apprank', element('app_rank_2_image_url', $apprank), '50', '50'),
'app_rank_3_title' => html_escape(element('app_rank_3_title', $apprank)),
'app_rank_3_desc' => html_escape(element('app_rank_3_desc', $apprank)),
'app_rank_3_link' => html_escape(element('app_rank_3_link', $apprank)),
'app_rank_3_image_url' => thumb_url('apprank', element('app_rank_3_image_url', $apprank), '50', '50'),
);
return $arr;
}
}

View File

@@ -0,0 +1,88 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
/**
* Category
*/
class Category extends CI_Controller
{
private $CI;
function __construct()
{
$this->CI = & get_instance();
}
function main()
{
if ( ! $this->CI->input->post_get('token')) {
$this->CI->apilib->make_error("토큰 값이 넘어오지 않았습니다");
}
$token = $this->CI->input->post_get('token');
$app_id = (int) trim($this->CI->input->post_get('app_id'));
if (empty($app_id)) {
$this->CI->apilib->make_error("어플 아이디가 넘어오지 않았습니다");
}
$allowed_depth = array('1', '2', '3', '4');
$q = $this->CI->input->get('q');
$depth = $this->CI->input->get('depth');
if ($depth) {
if ( ! is_numeric($depth)) {
$this->CI->apilib->make_error('Depth 값이 잘못 넘어왔습니다. 값이 비어있든지, 1,2,3,4 중 하나의 값만 허용됩니다.');
}
if ( ! in_array($depth, $allowed_depth)) {
$this->CI->apilib->make_error('Depth 값이 잘못 넘어왔습니다. 값이 비어있든지, 1,2,3,4 중 하나의 값만 허용됩니다.');
}
}
$this->CI->load->model(array('Contents_category_model'));
if ($q) {
$this->CI->db->like('cat_name', $q);
}
if ($depth) {
$this->CI->db->where('cat_depth', $depth);
}
$this->CI->db->where('app_id', $app_id);
$this->CI->db->order_by('cat_sort', 'desc');
$qry = $this->CI->db->get('contents_category');
$data = $qry->result_array();
$count = 0;
$result = array();
if ($data) {
foreach ($data as $key => $val) {
$cinfo = $this->CI->Contents_category_model->get_hierarchical_name($app_id, element('cat_id', $val));
$result[$key]['cat1id'] = element('1', element('id', $cinfo));
$result[$key]['cat2id'] = element('2', element('id', $cinfo));
$result[$key]['cat1code'] = element('1', element('code', $cinfo));
$result[$key]['cat2code'] = element('2', element('code', $cinfo));
$result[$key]['cat1name'] = element('1', element('name', $cinfo));
$result[$key]['cat2name'] = element('2', element('name', $cinfo));
$count++;
}
}
$arr = array(
'result' => 'ok',
'token' => $token,
'app_id' => $app_id,
'count' => $count,
'list' => $result,
);
return $arr;
}
}

View File

@@ -0,0 +1,80 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
/**
* Comment_delete
*/
class Comment_delete extends CI_Controller
{
private $CI;
function __construct()
{
$this->CI = & get_instance();
}
function main()
{
if ( ! $this->CI->input->post_get('token')) {
$this->CI->apilib->make_error("토큰 값이 넘어오지 않았습니다");
}
$token = $this->CI->input->post_get('token');
$app_id = (int) trim($this->CI->input->post_get('app_id'));
if (empty($app_id)) {
$this->CI->apilib->make_error("어플 아이디가 넘어오지 않았습니다");
}
$con_id = (int) trim($this->CI->input->post('con_id'));
if (empty($con_id)) {
$this->CI->apilib->make_error("데이터 고유 아이디가 넘어오지 않았습니다");
}
$com_id = (int) trim($this->CI->input->post('com_id'));
if (empty($com_id)) {
$this->CI->apilib->make_error("댓글 고유 아이디가 넘어오지 않았습니다");
}
$this->CI->load->model(array('Contents_model', 'Contents_comment_model'));
$sessionuser = $this->CI->User_model->get_by_token($app_id, $token);
if ( ! element('user_id', $sessionuser)) {
$this->CI->apilib->make_error("로그인 한 회원만 댓글을 삭제할 수 있습니다");
}
$contents = $this->CI->Contents_model->get_one($con_id);
if ( ! element('con_id', $contents)) {
$this->CI->apilib->make_error("존재하지 않는 컨텐츠입니다.");
}
$comment = $this->CI->Contents_comment_model->get_one($com_id);
if ( ! element('com_id', $comment)) {
$this->CI->apilib->make_error("존재하지 않는 댓글입니다.");
}
if (element('user_id', $comment) != element('user_id', $sessionuser)) {
$this->CI->apilib->make_error("본인의 댓글만 삭제가 가능합니다.");
}
$this->CI->Contents_comment_model->delete($com_id);
$arr = array(
'result' => 'ok',
'token' => $token,
'app_id' => $app_id,
'con_id' => $con_id,
'com_id' => $com_id,
'datetime' => cdate('Y-m-d H:i:s'),
);
return $arr;
}
}

View File

@@ -0,0 +1,88 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
/**
* Comment_list
*/
class Comment_list extends CI_Controller
{
private $CI;
function __construct()
{
$this->CI = & get_instance();
}
function main()
{
if ( ! $this->CI->input->post_get('token')) {
$this->CI->apilib->make_error("토큰 값이 넘어오지 않았습니다");
}
$token = $this->CI->input->post_get('token');
$app_id = (int) trim($this->CI->input->post_get('app_id'));
if (empty($app_id)) {
$this->CI->apilib->make_error("어플 아이디가 넘어오지 않았습니다");
}
$con_id = (int) trim($this->CI->input->get('con_id'));
if (empty($con_id)) {
$this->CI->apilib->make_error("데이터 고유 아이디가 넘어오지 않았습니다");
}
$this->CI->load->model(array('Contents_model', 'Contents_comment_model'));
$sessionuser = $this->CI->User_model->get_by_token($app_id, $token);
if ( ! element('user_id', $sessionuser)) {
//$this->CI->apilib->make_error("로그인 한 회원만 댓글을 보실 수 있습니다");
}
$contents = $this->CI->Contents_model->get_one($con_id);
if ( ! element('con_id', $contents)) {
$this->CI->apilib->make_error("존재하지 않는 컨텐츠입니다.");
}
$data = $this->CI->Contents_comment_model->get_api_list($app_id, $con_id);
$result = array();
$count = 0;
if ($data) {
foreach ($data as $key => $value) {
$result[$key]['com_id'] = html_escape(element('com_id', $value));
$result[$key]['con_id'] = html_escape(element('con_id', $value));
$result[$key]['user_id'] = html_escape(element('user_id', $value));
$result[$key]['user_name'] = html_escape(element('user_username', $value));
$result[$key]['user_photo'] = user_photo_url(element('user_photo', $value));
$result[$key]['com_content'] = html_escape(element('com_content', $value));
$result[$key]['com_created_at'] = html_escape(element('com_created_at', $value));
$result[$key]['com_updated_at'] = html_escape(element('com_updated_at', $value));
$result[$key]['com_reply_user_userid'] = '';
if (element('com_reply_user_id', $value)) {
$reply_user = $this->CI->User_model->get_one(element('com_reply_user_id', $value), 'user_userid');
$result[$key]['com_reply_user_userid'] = element('user_userid', $reply_user);
}
$count++;
}
}
$arr = array(
'result' => 'ok',
'token' => $token,
'app_id' => $app_id,
'count' => $count,
'list' => $result,
);
return $arr;
}
}

View File

@@ -0,0 +1,174 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
/**
* Comment_write
*/
class Comment_write extends CI_Controller
{
private $CI;
function __construct()
{
$this->CI = & get_instance();
}
function main()
{
if ( ! $this->CI->input->post_get('token')) {
$this->CI->apilib->make_error("토큰 값이 넘어오지 않았습니다");
}
$token = $this->CI->input->post_get('token');
$app_id = (int) trim($this->CI->input->post_get('app_id'));
if (empty($app_id)) {
$this->CI->apilib->make_error("어플 아이디가 넘어오지 않았습니다");
}
$con_id = (int) trim($this->CI->input->post('con_id'));
if (empty($con_id)) {
$this->CI->apilib->make_error("데이터 고유 아이디가 넘어오지 않았습니다");
}
$com_id = (int) trim($this->CI->input->post('com_id'));
$this->CI->load->model(array('Contents_model', 'Contents_comment_model'));
$sessionuser = $this->CI->User_model->get_by_token($app_id, $token);
if ( ! element('user_id', $sessionuser)) {
$this->CI->apilib->make_error("로그인 한 회원만 댓글을 입력할 수 있습니다");
}
$contents = $this->CI->Contents_model->get_one($con_id);
if ( ! element('con_id', $contents)) {
$this->CI->apilib->make_error("존재하지 않는 컨텐츠입니다.");
}
$reply_com_id = (int) trim($this->CI->input->post('reply_com_id'));
$com_content = trim($this->CI->input->post('com_content'));
if (empty($com_content)) {
$this->CI->apilib->make_error("댓글 내용이 입력되지 않았습니다");
}
// mode : new, modify, reply
$mode = 'new';
if ($com_id) {
$mode = 'modify';
}
else if ($reply_com_id) {
$mode = 'reply';
}
$comment = '';
if ($mode == 'modify') {
$comment = $this->CI->Contents_comment_model->get_one($com_id);
if ( ! element('com_id', $comment)) {
$this->CI->apilib->make_error("존재하지 않는 댓글입니다.");
}
if (element('user_id', $comment) != element('user_id', $sessionuser)) {
$this->CI->apilib->make_error("본인의 댓글만 수정이 가능합니다.");
}
}
$com_reply = '';
if ($mode == 'reply') {
$origin = $this->CI->Contents_comment_model->get_one($reply_com_id);
if ( ! element('com_id', $origin)) {
$this->CI->apilib->make_error("존재하지 않는 댓글에 답변을 달려고 시도하고 있습니다");
}
//if (element('com_reply', $origin)) {
// $this->CI->apilib->make_error("답변댓글에는 더 이상 답변댓글을 입력하실 수가 없습니다");
//}
$reply_len = strlen(element('com_reply', $origin)) + 1;
$begin_reply_char = 'A';
$end_reply_char = 'Z';
$reply_number = +1;
$this->CI->db->select('MAX(SUBSTRING(com_reply, ' . $reply_len . ', 1)) as reply', false);
$this->CI->db->where('com_num', element('com_num', $origin));
$this->CI->db->where('SUBSTRING(com_reply, ' . $reply_len . ', 1) <>', '');
if (element('com_id', $origin)) {
$this->CI->db->like('com_reply', element('com_reply', $origin), 'after');
}
$result = $this->CI->db->get('contents_comment');
$row = $result->row_array();
if ( ! element('reply', $row)) {
$reply_char = $begin_reply_char;
} elseif (element('reply', $row) === $end_reply_char) { // A~Z은 26 입니다.
$this->CI->apilib->make_error("더 이상 답변하실 수 없습니다.\\n답변은 26개 까지만 가능합니다");
} else {
$reply_char = chr(ord(element('reply', $row)) + $reply_number);
}
$com_reply = element('com_reply', $origin) . $reply_char;
$com_reply_user_id = element('user_id', $origin);
}
if ($mode == 'new') {
$com_num = $this->CI->Contents_comment_model->next_comment_num();
$insertdata = array(
'con_id' => $con_id,
'app_id' => $app_id,
'con_user_id' => element('user_id', $contents),
'user_id' => element('user_id', $sessionuser),
'com_num' => $com_num,
'com_reply' => '',
'com_content' => $com_content,
'com_created_at' => cdate('Y-m-d H:i:s'),
'com_updated_at' => cdate('Y-m-d H:i:s'),
);
$com_id = $this->CI->Contents_comment_model->insert($insertdata);
}
else if ($mode == 'reply') {
$com_num = element('com_num', $origin);
$insertdata = array(
'con_id' => $con_id,
'app_id' => $app_id,
'con_user_id' => element('user_id', $contents),
'user_id' => element('user_id', $sessionuser),
'com_num' => $com_num,
'com_reply' => $com_reply,
'com_reply_user_id' => $com_reply_user_id,
'com_content' => $com_content,
'com_created_at' => cdate('Y-m-d H:i:s'),
'com_updated_at' => cdate('Y-m-d H:i:s'),
);
$com_id = $this->CI->Contents_comment_model->insert($insertdata);
}
else if ($mode == 'modify') {
$updatedata = array(
'com_content' => $com_content,
'com_updated_at' => cdate('Y-m-d H:i:s'),
);
$this->CI->Contents_comment_model->update($com_id, $updatedata);
}
$arr = array(
'result' => 'ok',
'token' => $token,
'app_id' => $app_id,
'con_id' => $con_id,
'com_id' => $com_id,
);
return $arr;
}
}

View File

@@ -0,0 +1,108 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
/**
* Contents
*/
class Contents extends CI_Controller
{
private $CI;
function __construct()
{
$this->CI = & get_instance();
}
function main()
{
if ( ! $this->CI->input->post_get('token')) {
$this->CI->apilib->make_error("토큰 값이 넘어오지 않았습니다");
}
$token = $this->CI->input->post_get('token');
$app_id = (int) trim($this->CI->input->post_get('app_id'));
if (empty($app_id)) {
$this->CI->apilib->make_error("어플 아이디가 넘어오지 않았습니다");
}
$sessionuser = $this->CI->User_model->get_by_token($app_id, $token);
$this->CI->load->model(array('Contents_model', 'Contents_category_model', 'Contents_comment_model', 'Contents_like_model', 'Upload_file_model'));
$category = $this->CI->Contents_category_model->cat_list($app_id);
$cat1_id = $this->CI->input->get('cat1_id');
$cat2_id = $this->CI->input->get('cat2_id');
$cat3_id = $this->CI->input->get('cat3_id');
$cat4_id = $this->CI->input->get('cat4_id');
$tag = $this->CI->input->get('tag');
$sort = $this->CI->input->get('sort');
$is_bookmark = $this->CI->input->get('is_bookmark') == 'Y' ? '1' : '';
if ($sort == 'H') {
$data = $this->CI->Contents_model->get_api_popular_list($app_id, $is_bookmark, element('user_id', $sessionuser), $tag, $cat1_id, $cat2_id);
} else {
$data = $this->CI->Contents_model->get_api_list($app_id, $is_bookmark, element('user_id', $sessionuser), $tag, $cat1_id, $cat2_id);
}
$result = array();
$count = 0;
if ($data) {
foreach ($data as $key => $value) {
$result[$key]['con_id'] = html_escape(element('con_id', $value));
$result[$key]['con_sort'] = html_escape(element('con_sort', $value));
$result[$key]['cat1_id'] = html_escape(element('cat1_id', $value));
$result[$key]['cat2_id'] = html_escape(element('cat2_id', $value));
$result[$key]['cat3_id'] = html_escape(element('cat3_id', $value));
$result[$key]['cat4_id'] = html_escape(element('cat4_id', $value));
$result[$key]['cat1_code'] = element('cat1_id', $value) ? html_escape(element('cat_code', element(element('cat1_id', $value), $category))) : null;
$result[$key]['cat2_code'] = element('cat2_id', $value) ? html_escape(element('cat_code', element(element('cat2_id', $value), $category))) : null;
$result[$key]['cat3_code'] = element('cat3_id', $value) ? html_escape(element('cat_code', element(element('cat3_id', $value), $category))) : null;
$result[$key]['cat4_code'] = element('cat4_id', $value) ? html_escape(element('cat_code', element(element('cat4_id', $value), $category))) : null;
$result[$key]['cat1_name'] = element('cat1_id', $value) ? html_escape(element('cat_name', element(element('cat1_id', $value), $category))) : null;
$result[$key]['cat2_name'] = element('cat2_id', $value) ? html_escape(element('cat_name', element(element('cat2_id', $value), $category))) : null;
$result[$key]['cat3_name'] = element('cat3_id', $value) ? html_escape(element('cat_name', element(element('cat3_id', $value), $category))) : null;
$result[$key]['cat4_name'] = element('cat4_id', $value) ? html_escape(element('cat_name', element(element('cat4_id', $value), $category))) : null;
$result[$key]['user_id'] = html_escape(element('user_id', $value));
$result[$key]['user_name'] = html_escape(element('user_name', $value));
$result[$key]['con_title'] = html_escape(element('con_title', $value));
$result[$key]['con_content'] = html_escape('<meta name="viewport" content="width=320"><style>img, table {max-width:100% !important;}</style>'. element('con_content', $value));
$result[$key]['con_published_at'] = html_escape(element('con_published_at', $value));
$cwhere = array(
'app_id' => $app_id,
'con_id' => element('con_id', $value),
);
$result[$key]['comment_count'] = $this->CI->Contents_comment_model->count_by($cwhere);
$result[$key]['like_count'] = element('con_like', $value);
$result[$key]['share_count'] = element('con_share_count', $value);
$result[$key]['share_url'] = site_url('contents/view/'.element('con_id', $value));
$result[$key]['cnt'] = element('cnt', $value);
$filedata = array();
$files = $this->CI->Upload_file_model->get_files('contents', element('con_id', $value));
if ($files) {
foreach ($files as $fkey => $fval) {
$filedata[$fkey]['url'] = base_url('uploads/files/' . element('ufi_filename', $fval));
}
}
$result[$key]['files'] = $filedata;
$count++;
}
}
$arr = array(
'result' => 'ok',
'token' => $token,
'app_id' => $app_id,
'count' => $count,
'list' => $result,
);
return $arr;
}
}

View File

@@ -0,0 +1,67 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
/**
* Contents_add_share_count
*/
class Contents_add_share_count extends CI_Controller
{
private $CI;
function __construct()
{
$this->CI = & get_instance();
}
function main()
{
if ( ! $this->CI->input->post_get('token')) {
$this->CI->apilib->make_error("토큰 값이 넘어오지 않았습니다");
}
$token = $this->CI->input->post_get('token');
$app_id = (int) trim($this->CI->input->post_get('app_id'));
if (empty($app_id)) {
$this->CI->apilib->make_error("어플 아이디가 넘어오지 않았습니다");
}
$con_id = (int) trim($this->CI->input->post_get('con_id'));
if (empty($con_id)) {
$this->CI->apilib->make_error("데이터 고유 아이디가 넘어오지 않았습니다");
}
$this->CI->load->model(array('Contents_model', 'User_model'));
$sessionuser = $this->CI->User_model->get_by_token($app_id, $token);
//if ( ! element('user_id', $sessionuser)) {
// $this->CI->apilib->make_error("로그인 한 회원만 Like 할 수 있습니다");
//}
$contents = $this->CI->Contents_model->get_one($con_id);
if ( ! element('con_id', $contents)) {
$this->CI->apilib->make_error("존재하지 않는 컨텐츠입니다.");
}
$this->CI->Contents_model->update_share_count(element('con_id', $contents));
$share_count = element('con_share_count', $contents) + 1;
$arr = array(
'result' => 'ok',
'token' => $token,
'app_id' => $app_id,
'con_id' => $con_id,
'share_count' => $share_count,
);
return $arr;
}
}

View File

@@ -0,0 +1,90 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
/**
* Contents_bookmark
*/
class Contents_bookmark extends CI_Controller
{
private $CI;
function __construct()
{
$this->CI = & get_instance();
}
function main()
{
if ( ! $this->CI->input->post_get('token')) {
$this->CI->apilib->make_error("토큰 값이 넘어오지 않았습니다");
}
$token = $this->CI->input->post_get('token');
$app_id = (int) trim($this->CI->input->post_get('app_id'));
if (empty($app_id)) {
$this->CI->apilib->make_error("어플 아이디가 넘어오지 않았습니다");
}
$con_id = (int) trim($this->CI->input->post('con_id'));
if (empty($con_id)) {
$this->CI->apilib->make_error("데이터 고유 아이디가 넘어오지 않았습니다");
}
$this->CI->load->model(array('Contents_model', 'User_model', 'Contents_bookmark_model'));
$sessionuser = $this->CI->User_model->get_by_token($app_id, $token);
if ( ! element('user_id', $sessionuser)) {
$this->CI->apilib->make_error("로그인 한 회원만 북마크 할 수 있습니다");
}
$contents = $this->CI->Contents_model->get_one($con_id);
if ( ! element('con_id', $contents)) {
$this->CI->apilib->make_error("존재하지 않는 컨텐츠입니다.");
}
$bookmarkwhere = array(
'con_id' => $con_id,
'user_id' => element('user_id', $sessionuser),
);
$bookmark = $this->CI->Contents_bookmark_model->get_one('', '', $bookmarkwhere);
if (element('bookmark_id', $bookmark)) {
$this->CI->Contents_bookmark_model->delete(element('bookmark_id', $bookmark));
$type = 'N';
}
if ( ! element('bookmark_id', $bookmark)) {
$insertdata = array(
'con_id' => element('con_id', $contents),
'app_id' => $app_id,
'user_id' => element('user_id', $sessionuser),
'target_user_id' => element('user_id', $contents),
'bookmark_at' => cdate('Y-m-d H:i:s'),
);
$bookmark_id = $this->CI->Contents_bookmark_model->insert($insertdata);
$type = 'Y';
}
$cwhere = array(
'con_id' => element('con_id', $contents),
);
$bookmark_count = $this->CI->Contents_bookmark_model->count_by($cwhere);
$arr = array(
'result' => 'ok',
'token' => $token,
'app_id' => $app_id,
'con_id' => $con_id,
'type' => $type,
'bookmark_count' => $bookmark_count,
);
return $arr;
}
}

View File

@@ -0,0 +1,97 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
/**
* Contents_get_count
*/
class Contents_get_count extends CI_Controller
{
private $CI;
function __construct()
{
$this->CI = & get_instance();
}
function main()
{
if ( ! $this->CI->input->post_get('token')) {
$this->CI->apilib->make_error("토큰 값이 넘어오지 않았습니다");
}
$token = $this->CI->input->post_get('token');
$app_id = (int) trim($this->CI->input->post_get('app_id'));
if (empty($app_id)) {
$this->CI->apilib->make_error("어플 아이디가 넘어오지 않았습니다");
}
$sessionuser = $this->CI->User_model->get_by_token($app_id, $token);
$this->CI->load->model(array('Contents_model', 'Contents_category_model', 'Contents_comment_model', 'Contents_like_model', 'Upload_file_model'));
$category = $this->CI->Contents_category_model->cat_list($app_id);
$data = $this->CI->Contents_model->get_api_list($app_id, '', '', '', '', '', '1');
$result = array();
$count = 0;
if ($data) {
foreach ($data as $key => $value) {
$result[$key]['con_id'] = html_escape(element('con_id', $value));
$result[$key]['con_sort'] = html_escape(element('con_sort', $value));
$result[$key]['cat1_id'] = html_escape(element('cat1_id', $value));
$result[$key]['cat2_id'] = html_escape(element('cat2_id', $value));
$result[$key]['cat3_id'] = html_escape(element('cat3_id', $value));
$result[$key]['cat4_id'] = html_escape(element('cat4_id', $value));
$result[$key]['cat1_code'] = element('cat1_id', $value) ? html_escape(element('cat_code', element(element('cat1_id', $value), $category))) : null;
$result[$key]['cat2_code'] = element('cat2_id', $value) ? html_escape(element('cat_code', element(element('cat2_id', $value), $category))) : null;
$result[$key]['cat3_code'] = element('cat3_id', $value) ? html_escape(element('cat_code', element(element('cat3_id', $value), $category))) : null;
$result[$key]['cat4_code'] = element('cat4_id', $value) ? html_escape(element('cat_code', element(element('cat4_id', $value), $category))) : null;
$result[$key]['cat1_name'] = element('cat1_id', $value) ? html_escape(element('cat_name', element(element('cat1_id', $value), $category))) : null;
$result[$key]['cat2_name'] = element('cat2_id', $value) ? html_escape(element('cat_name', element(element('cat2_id', $value), $category))) : null;
$result[$key]['cat3_name'] = element('cat3_id', $value) ? html_escape(element('cat_name', element(element('cat3_id', $value), $category))) : null;
$result[$key]['cat4_name'] = element('cat4_id', $value) ? html_escape(element('cat_name', element(element('cat4_id', $value), $category))) : null;
$result[$key]['user_id'] = html_escape(element('user_id', $value));
$result[$key]['user_name'] = html_escape(element('user_name', $value));
$result[$key]['con_title'] = html_escape(element('con_title', $value));
$result[$key]['con_content'] = html_escape(element('con_content', $value));
$result[$key]['con_published_at'] = html_escape(element('con_published_at', $value));
$cwhere = array(
'app_id' => $app_id,
'con_id' => element('con_id', $value),
);
$result[$key]['comment_count'] = $this->CI->Contents_comment_model->count_by($cwhere);
$result[$key]['like_count'] = $this->CI->Contents_like_model->count_by($cwhere);
$result[$key]['share_count'] = element('con_share_count', $value);
$result[$key]['share_url'] = site_url('contents/view/'.element('con_id', $value));
$result[$key]['cnt'] = element('cnt', $value);
$filedata = array();
$files = $this->CI->Upload_file_model->get_files('contents', element('con_id', $value));
if ($files) {
foreach ($files as $fkey => $fval) {
$filedata[$fkey]['url'] = base_url('uploads/files/' . element('ufi_filename', $fval));
}
}
$result[$key]['files'] = $filedata;
$count++;
}
}
$arr = array(
'result' => 'ok',
'token' => $token,
'app_id' => $app_id,
'count' => $count,
'list' => $result,
);
return $arr;
}
}

View File

@@ -0,0 +1,92 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
/**
* Contents_like
*/
class Contents_like extends CI_Controller
{
private $CI;
function __construct()
{
$this->CI = & get_instance();
}
function main()
{
if ( ! $this->CI->input->post_get('token')) {
$this->CI->apilib->make_error("토큰 값이 넘어오지 않았습니다");
}
$token = $this->CI->input->post_get('token');
$app_id = (int) trim($this->CI->input->post_get('app_id'));
if (empty($app_id)) {
$this->CI->apilib->make_error("어플 아이디가 넘어오지 않았습니다");
}
$con_id = (int) trim($this->CI->input->post('con_id'));
if (empty($con_id)) {
$this->CI->apilib->make_error("데이터 고유 아이디가 넘어오지 않았습니다");
}
$this->CI->load->model(array('Contents_model', 'User_model', 'Contents_like_model'));
$sessionuser = $this->CI->User_model->get_by_token($app_id, $token);
//if ( ! element('user_id', $sessionuser)) {
// $this->CI->apilib->make_error("로그인 한 회원만 Like 할 수 있습니다");
//}
$contents = $this->CI->Contents_model->get_one($con_id);
if ( ! element('con_id', $contents)) {
$this->CI->apilib->make_error("존재하지 않는 컨텐츠입니다.");
}
$likewhere = array(
'con_id' => $con_id,
'user_token' => $token,
);
$like = $this->CI->Contents_like_model->get_one('', '', $likewhere);
if (element('like_id', $like)) {
$this->CI->Contents_like_model->delete(element('like_id', $like));
$type = 'N';
$this->CI->Contents_model->minus_like_count($con_id);
$like_count = element('con_like', $contents) - 1;
}
if ( ! element('like_id', $like)) {
$user_id = element('user_id', $sessionuser) ? element('user_id', $sessionuser) : 0;
$insertdata = array(
'con_id' => element('con_id', $contents),
'app_id' => $app_id,
'user_id' => $user_id,
'user_token' => $token,
'target_user_id' => element('user_id', $contents),
'like_at' => cdate('Y-m-d H:i:s'),
);
$like_id = $this->CI->Contents_like_model->insert($insertdata);
$type = 'Y';
$this->CI->Contents_model->plus_like_count($con_id);
$like_count = element('con_like', $contents) + 1;
}
$arr = array(
'result' => 'ok',
'token' => $token,
'app_id' => $app_id,
'con_id' => $con_id,
'type' => $type,
'like_count' => $like_count,
);
return $arr;
}
}

View File

@@ -0,0 +1,137 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
/**
* Contents_view
*/
class Contents_view extends CI_Controller
{
private $CI;
function __construct()
{
$this->CI = & get_instance();
}
function main()
{
if ( ! $this->CI->input->post_get('token')) {
$this->CI->apilib->make_error("토큰 값이 넘어오지 않았습니다");
}
$token = $this->CI->input->post_get('token');
$app_id = (int) trim($this->CI->input->post_get('app_id'));
if (empty($app_id)) {
$this->CI->apilib->make_error("어플 아이디가 넘어오지 않았습니다");
}
$con_id = (int) trim($this->CI->input->get('con_id'));
if (empty($con_id)) {
$this->CI->apilib->make_error("데이터 고유 아이디가 넘어오지 않았습니다");
}
$this->CI->load->model(array('Contents_model', 'Contents_category_model', 'Contents_comment_model', 'Contents_like_model', 'Upload_file_model', 'Contents_bookmark_model'));
$sessionuser = $this->CI->User_model->get_by_token($app_id, $token);
$where = array(
'app_id' => $app_id,
'con_id' => $con_id,
'is_open' => '1',
'is_del' => '0',
'con_published_at <=' => cdate('Y-m-d H:i:s'),
);
$result = $this->CI->Contents_model->get_one('', '', $where);
if ( ! element('con_id', $result)) {
$this->CI->apilib->make_error("존재하지 않는 데이터입니다");
}
if ( ! element('con_published_at', $result)) {
$this->CI->apilib->make_error("존재하지 않는 데이터입니다");
}
if ( ! $this->CI->session->userdata('con_hit_' . element('con_id', $result))) {
$this->CI->session->set_userdata('con_hit_' . element('con_id', $result), '1');
$this->CI->Contents_model->update_plus(element('con_id', $result), 'con_hit', '1');
}
$category = $this->CI->Contents_category_model->cat_list($app_id);
$arr = array(
'result' => 'ok',
'token' => $token,
'app_id' => $app_id,
'con_id' => html_escape(element('con_id', $result)),
'con_sort' => html_escape(element('con_sort', $result)),
'cat1_id' => html_escape(element('cat1_id', $result)),
'cat2_id' => html_escape(element('cat2_id', $result)),
'cat3_id' => html_escape(element('cat3_id', $result)),
'cat4_id' => html_escape(element('cat4_id', $result)),
'user_id' => html_escape(element('user_id', $result)),
'user_name' => html_escape(element('user_name', $result)),
'con_title' => html_escape(element('con_title', $result)),
'con_content' => nl2br(html_escape('<meta name="viewport" content="width=320"><style>img, table {max-width:100% !important;}</style>'. element('con_content', $result))),
'con_published_at' => html_escape(element('con_published_at', $result)),
);
$arr['cat1_code'] = element('cat1_id', $result) ? html_escape(element('cat_code', element(element('cat1_id', $result), $category))) : null;
$arr['cat2_code'] = element('cat2_id', $result) ? html_escape(element('cat_code', element(element('cat2_id', $result), $category))) : null;
$arr['cat3_code'] = element('cat3_id', $result) ? html_escape(element('cat_code', element(element('cat3_id', $result), $category))) : null;
$arr['cat4_code'] = element('cat4_id', $result) ? html_escape(element('cat_code', element(element('cat4_id', $result), $category))) : null;
$arr['cat1_name'] = element('cat1_id', $result) ? html_escape(element('cat_name', element(element('cat1_id', $result), $category))) : null;
$arr['cat2_name'] = element('cat2_id', $result) ? html_escape(element('cat_name', element(element('cat2_id', $result), $category))) : null;
$arr['cat3_name'] = element('cat3_id', $result) ? html_escape(element('cat_name', element(element('cat3_id', $result), $category))) : null;
$arr['cat4_name'] = element('cat4_id', $result) ? html_escape(element('cat_name', element(element('cat4_id', $result), $category))) : null;
$cwhere = array(
'app_id' => $app_id,
'con_id' => element('con_id', $result),
);
$arr['comment_count'] = $this->CI->Contents_comment_model->count_by($cwhere);
//$arr['like_count'] = $this->CI->Contents_like_model->count_by($cwhere);
$arr['like_count'] = element('con_like', $result);
$arr['share_count'] = element('con_share_count', $result);
$arr['share_url'] = site_url('contents/view/'.element('con_id', $result));
$filedata = array();
$files = $this->CI->Upload_file_model->get_files('contents', element('con_id', $result));
if ($files) {
foreach ($files as $fkey => $fval) {
$filedata[$fkey]['url'] = base_url('uploads/files/' . element('ufi_filename', $fval));
}
}
$arr['files'] = $filedata;
$where = array(
'app_id' => $app_id,
'con_id' => $con_id,
'user_token' => $token
);
$like = $this->CI->Contents_like_model->get_one('', '', $where);
$arr['i_like'] = (element('like_id', $like)) ? 1 : 0;
if (element('user_id', $sessionuser)) {
$where = array(
'app_id' => $app_id,
'con_id' => $con_id,
'user_id' => element('user_id', $sessionuser)
);
$bookmark = $this->CI->Contents_bookmark_model->get_one('', '', $where);
$arr['i_bookmark'] = (element('bookmark_id', $bookmark)) ? 1 : 0;
} else {
$arr['i_bookmark'] = 0;
}
return $arr;
}
}

View File

@@ -0,0 +1,109 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
/**
* Find_my_password
*/
class Find_my_password extends CI_Controller
{
private $CI;
function __construct()
{
$this->CI = & get_instance();
$this->CI->load->library(array('email'));
}
function main()
{
$this->CI->load->model('Apps_model');
if ( ! $this->CI->input->post_get('token')) {
$this->CI->apilib->make_error("토큰 값이 넘어오지 않았습니다");
}
$token = $this->CI->input->post_get('token');
$app_id = (int) trim($this->CI->input->post_get('app_id'));
if (empty($app_id)) {
$this->CI->apilib->make_error("어플 아이디가 넘어오지 않았습니다");
}
$email = trim($this->CI->input->post('email'));
if ( ! $email) {
$this->CI->apilib->make_error("이메일이 입력되지 않았습니다");
}
$this->CI->load->helper('string');
if ( ! function_exists('password_hash')) {
$this->CI->load->helper('password');
}
$userinfo = $this->CI->User_model->get_by_api_email($app_id, $email, 'user_id, user_email, user_denied, user_username, user_password');
if (element('user_denied', $userinfo)) {
$this->CI->apilib->make_error("회원님의 아이디는 접근이 금지된 아이디입니다");
}
if ( ! element('user_id', $userinfo)) {
$this->CI->apilib->make_error("일치하는 회원정보가 없습니다");
}
$user_id = element('user_id', $userinfo);
$new_password = rand(100000,999999);
$hash = password_hash($new_password, PASSWORD_BCRYPT);
$updatedata = array(
'user_password' => $hash,
);
$upwhere = array(
'app_id' => $app_id,
'user_id' => $user_id,
);
$this->CI->User_model->update('', $updatedata, $upwhere);
$appinfo = $this->CI->Apps_model->get_one($app_id);
$email_title = '[' . element('app_name', $appinfo) . '] 회원님의 패스워드가 변경되었습니다.';
$email_content = '<table width="100%" cellpadding="0" cellspacing="0" style="border-left: 1px solid rgb(226,226,225);border-right: 1px solid rgb(226,226,225);background-color: rgb(255,255,255);border-top:10px solid #348fe2; border-bottom:5px solid #348fe2;border-collapse: collapse;"><tbody><tr><td width="200" style="padding:20px 30px;font-family: Arial,sans-serif;color: rgb(0,0,0);font-size: 14px;line-height: 20px;">' . element('app_name', $appinfo) . '</td><td style="font-size:12px;padding:20px 30px;font-family: Arial,sans-serif;color: rgb(0,0,0);font-size: 14px;line-height: 20px;"><span style="font-size:14px;font-weight:bold;color:rgb(0,0,0)">안녕하세요 ' . html_escape(element('user_username', $userinfo)) . '님,</span><br>회원님의 패스워드 변경</td></tr><tr style="border-top:1px solid #e2e2e2; border-bottom:1px solid #e2e2e2;"><td colspan="2" style="padding:20px 30px;font-family: Arial,sans-serif;color: rgb(0,0,0);font-size: 14px;line-height: 20px;"><p>' . html_escape(element('user_username', $userinfo)) . '님, 안녕하세요!</p><p>&nbsp;</p><p>회원님의 패스워드가 변경되었습니다.</p><p>변경된 패스워드는 다음과 같습니다</p><p style="color:red;font-weight:bold;">' . $new_password . '</p><p>&nbsp;</p><p>감사합니다.</p></td></tr></tbody></table>';
include_once(FCPATH . 'plugin/PHPMailer/PHPMailerAutoload.php');
$mail = new PHPMailer;
$mail->SMTPDebug = 0; // Enable verbose debug output
$mail->CharSet = "euc-kr";
$mail->isSMTP(); // Set mailer to use SMTP
$mail->Host = config_item('email_smtp_host'); // Specify main and backup SMTP servers
$mail->SMTPAuth = true; // Enable SMTP authentication
$mail->Username = config_item('email_smtp_user'); // SMTP username
$mail->Password = config_item('email_smtp_pass'); // SMTP password
$mail->SMTPSecure = 'ssl'; // Enable TLS encryption, `ssl` also accepted
$mail->Port = 465; // TCP port to connect to
$mail->setFrom(config_item('email_smtp_user'), iconv("UTF-8", "EUC-KR", element('app_name', $appinfo)));
$mail->addAddress($email, element('user_username', $userinfo)); // Add a recipient
$mail->isHTML(true); // Set email format to HTML
$mail->Subject = iconv("UTF-8", "EUC-KR", $email_title);
$mail->Body = iconv("UTF-8", "EUC-KR", $email_content);
if(!$mail->send()) {
$this->CI->apilib->make_error("메일을 발송할 수가 없습니다");
//echo 'Mailer Error: ' . $mail->ErrorInfo;
}
$arr = array(
'result' => 'ok',
'token' => $token,
'app_id' => $app_id,
'user_id' => element('user_id', $userinfo),
'user_email' => element('user_email', $userinfo),
);
return $arr;
}
}

View File

@@ -0,0 +1,95 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
/**
* Login
*/
class Login extends CI_Controller
{
private $CI;
function __construct()
{
$this->CI = & get_instance();
}
function main()
{
if ( ! $this->CI->input->post_get('token')) {
$this->CI->apilib->make_error("토큰 값이 넘어오지 않았습니다");
}
$token = $this->CI->input->post_get('token');
$app_id = (int) trim($this->CI->input->post_get('app_id'));
if (empty($app_id)) {
$this->CI->apilib->make_error("어플 아이디가 넘어오지 않았습니다");
}
$sessionuser = $this->CI->User_model->get_by_token($app_id, $token);
$this->CI->load->helper('email');
if ( ! $this->CI->input->post('user_email')) {
$this->CI->apilib->make_error("회원 이메일이 입력되지 않았습니다");
}
if ( ! valid_email($this->CI->input->post('user_email')) ) {
$this->CI->apilib->make_error("이메일이 형식에 맞지 않습니다.");
}
if ( ! $this->CI->input->post('user_password')) {
$this->CI->apilib->make_error("비밀번호를 입력해주십시오.");
}
if ( ! $this->CI->input->post('fcm_token')) {
//$this->CI->apilib->make_error("fcm_token 값이 입력되지 않았습니다");
}
$user_email = trim($this->CI->input->post('user_email'));
$user_password = trim($this->CI->input->post('user_password'));
$userinfo = $this->CI->User_model->get_by_api_email($app_id, $user_email, 'user_id, user_email, user_denied, user_password');
$hash = password_hash($user_password, PASSWORD_BCRYPT);
if ( ! element('user_id', $userinfo) OR ! element('user_password', $userinfo)) {
$this->CI->apilib->make_error("회원 아이디와 비밀번호가 일치하지 않습니다.");
} elseif ( ! password_verify($user_password, element('user_password', $userinfo))) {
$this->CI->apilib->make_error("회원 아이디와 비밀번호가 일치하지 않습니다.");
} elseif (element('user_denied', $userinfo)) {
$this->CI->apilib->make_error("회원님의 아이디는 접근이 금지된 아이디입니다");
}
$updatedata = array(
'user_token' => '',
);
$upwhere = array(
'user_token' => $token,
);
$this->CI->User_model->update('', $updatedata, $upwhere);
$updatedata = array(
'user_token' => $token,
'user_lastlogin_datetime' => cdate('Y-m-d H:i:s'),
);
$this->CI->User_model->update(element('user_id', $userinfo), $updatedata);
//fcm token 등록하기
if ($this->CI->input->post('fcm_token')) {
$this->CI->load->library('Fcm_library');
$this->CI->fcm_library->update_token(element('user_id', $userinfo), $this->CI->input->post('fcm_token'));
}
$arr = array(
'result' => 'ok',
'token' => $token,
'app_id' => $app_id,
'user_id' => element('user_id', $userinfo),
);
return $arr;
}
}

View File

@@ -0,0 +1,57 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
/**
* Logout
*/
class Logout extends CI_Controller
{
private $CI;
function __construct()
{
$this->CI = & get_instance();
}
function main()
{
if ( ! $this->CI->input->post_get('token')) {
$this->CI->apilib->make_error("토큰 값이 넘어오지 않았습니다");
}
$token = $this->CI->input->post_get('token');
$app_id = (int) trim($this->CI->input->post_get('app_id'));
if (empty($app_id)) {
$this->CI->apilib->make_error("어플 아이디가 넘어오지 않았습니다");
}
$sessionuser = $this->CI->User_model->get_by_token($app_id, $token);
$updatedata = array(
'user_token' => '',
);
$upwhere = array(
'app_id' => $app_id,
'user_token' => $token,
);
$this->CI->User_model->update('', $updatedata, $upwhere);
$arr = array(
'result' => 'ok',
'token' => $token,
'app_id' => $app_id,
);
return $arr;
}
}

View File

@@ -0,0 +1,82 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
/**
* Notice
*/
class Notice extends CI_Controller
{
private $CI;
function __construct()
{
$this->CI = & get_instance();
}
function main()
{
if ( ! $this->CI->input->post_get('token')) {
$this->CI->apilib->make_error("토큰 값이 넘어오지 않았습니다");
}
$token = $this->CI->input->post_get('token');
$app_id = (int) trim($this->CI->input->post_get('app_id'));
if (empty($app_id)) {
$this->CI->apilib->make_error("어플 아이디가 넘어오지 않았습니다");
}
$this->CI->load->model(array('Notice_model', 'Upload_file_model'));
$where = array(
'app_id' => $app_id,
);
$data = $this->CI->Notice_model->get('', '', $where, '', '', 'notice_id', 'desc');
$result = array();
$count = 0;
if ($data) {
foreach ($data as $key => $value) {
$uploadwhere = array(
'origin_table' => 'notice',
'origin_id' => element('notice_id', $value),
);
$file = $this->CI->Upload_file_model->get('', '', $uploadwhere, '', '', 'ufi_id', 'ASC');
$files = array();
if ($file && is_array($file)) {
foreach ($file as $key2 => $val2) {
$files[] = site_url('uploads/files/' . element('ufi_filename', $val2));
}
}
$result[$key]['notice_id'] = html_escape(element('notice_id', $value));
$result[$key]['user_id'] = html_escape(element('user_id', $value));
$result[$key]['user_name'] = html_escape(element('user_name', $value));
$result[$key]['notice_title'] = html_escape(element('notice_title', $value));
$result[$key]['notice_content'] = html_escape(element('notice_content', $value));
$result[$key]['files'] = $files;
$result[$key]['created_at'] = html_escape(element('created_at', $value));
$result[$key]['updated_at'] = html_escape(element('updated_at', $value));
$count++;
}
}
$arr = array(
'result' => 'ok',
'token' => $token,
'app_id' => $app_id,
'count' => $count,
'list' => $result,
);
return $arr;
}
}

View File

@@ -0,0 +1,79 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
/**
* Notice_view
*/
class Notice_view extends CI_Controller
{
private $CI;
function __construct()
{
$this->CI = & get_instance();
}
function main()
{
if ( ! $this->CI->input->post_get('token')) {
$this->CI->apilib->make_error("토큰 값이 넘어오지 않았습니다");
}
$token = $this->CI->input->post_get('token');
$app_id = (int) trim($this->CI->input->post_get('app_id'));
if (empty($app_id)) {
$this->CI->apilib->make_error("어플 아이디가 넘어오지 않았습니다");
}
$notice_id = (int) trim($this->CI->input->get('notice_id'));
if (empty($notice_id)) {
$this->CI->apilib->make_error("공지사항 고유 아이디가 넘어오지 않았습니다");
}
$this->CI->load->model(array('Notice_model', 'Upload_file_model'));
$where = array(
'app_id' => $app_id,
'notice_id' => $notice_id,
);
$result = $this->CI->Notice_model->get_one('', '', $where);
if ( ! element('notice_id', $result)) {
$this->CI->apilib->make_error("존재하지 않는 공지사항입니다");
}
$uploadwhere = array(
'origin_table' => 'notice',
'origin_id' => element('notice_id', $result),
);
$file = $this->CI->Upload_file_model->get('', '', $uploadwhere, '', '', 'ufi_id', 'ASC');
$files = array();
if ($file && is_array($file)) {
foreach ($file as $key => $value) {
$files[] = site_url('uploads/files/' . element('ufi_filename', $value));
}
}
$arr = array(
'result' => 'ok',
'token' => $token,
'app_id' => $app_id,
'notice_id' => html_escape(element('notice_id', $result)),
'user_id' => html_escape(element('user_id', $result)),
'user_name' => html_escape(element('user_name', $result)),
'notice_title' => html_escape(element('notice_title', $result)),
'notice_content' => nl2br(html_escape(element('notice_content', $result))),
'files' => $files,
'created_at' => html_escape(element('created_at', $result)),
'updated_at' => html_escape(element('updated_at', $result)),
);
return $arr;
}
}

View File

@@ -0,0 +1,95 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
/**
* Profile_change_info
*/
class Profile_change_info extends CI_Controller
{
private $CI;
function __construct()
{
$this->CI = & get_instance();
}
function main()
{
if ( ! $this->CI->input->post_get('token')) {
$this->CI->apilib->make_error("토큰 값이 넘어오지 않았습니다");
}
$token = $this->CI->input->post_get('token');
$app_id = (int) trim($this->CI->input->post_get('app_id'));
if (empty($app_id)) {
$this->CI->apilib->make_error("어플 아이디가 넘어오지 않았습니다");
}
$sessionuser = $this->CI->User_model->get_by_token($app_id, $token);
if ( ! element('user_id', $sessionuser)) {
$this->CI->apilib->make_error("로그인 한 회원만 접근이 가능합니다");
}
$user_id = element('user_id', $sessionuser);
$this->CI->load->model(array('User_model'));
$user_username = $this->CI->input->post('user_username');
$user_old_pw = $this->CI->input->post('user_old_pw');
$user_pw1 = $this->CI->input->post('user_pw1');
$user_pw2 = $this->CI->input->post('user_pw2');
if ( ! $user_old_pw) {
$this->CI->apilib->make_error("이전 비밀번호가 입력되지 않았습니다");
}
if ( ! password_verify($user_old_pw, element('user_password', $sessionuser))) {
$this->CI->apilib->make_error("이전 비밀번호가 일치하지 않습니다");
}
if ( ! $user_username) {
$this->CI->apilib->make_error("닉네임이 입력되지 않았습니다");
}
if ($user_pw1 && $user_pw1 != $user_pw2) {
$this->CI->apilib->make_error("2개의 비밀번호가 일치하지 않아 업데이트할 수 없습니다");
}
if (mb_strlen($user_username) > 25) {
$this->CI->apilib->make_error("25자 이내로 입력해주세요");
}
if ($user_username != element('user_username', $sessionuser)) {
$userwhere = array(
'app_id' => $app_id,
'user_username' => $user_username,
);
$row = $this->CI->User_model->get_one('', 'user_id', $userwhere);
if (element('user_id', $row)) {
$this->CI->apilib->make_error("이미 사용중인 닉네임입니다. 다른 닉네임을 입력해주세요.");
}
}
$updatedata = array(
'user_username' => $user_username,
);
if ($user_pw1 && $user_pw1 == $user_pw2) {
$updatedata['user_password'] = password_hash($user_pw1, PASSWORD_BCRYPT);
}
$user = $this->CI->User_model->update(element('user_id', $sessionuser), $updatedata);
$arr = array(
'result' => 'ok',
'token' => $token,
'app_id' => $app_id,
'user_username' => $user_username,
'datetime' => cdate('Y-m-d H:i:s'),
);
return $arr;
}
}

View File

@@ -0,0 +1,58 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
/**
* Profile_delete_photo
*/
class Profile_delete_photo extends CI_Controller
{
private $CI;
function __construct()
{
$this->CI = & get_instance();
}
function main()
{
if ( ! $this->CI->input->post_get('token')) {
$this->CI->apilib->make_error("토큰 값이 넘어오지 않았습니다");
}
$token = $this->CI->input->post_get('token');
$app_id = (int) trim($this->CI->input->post_get('app_id'));
if (empty($app_id)) {
$this->CI->apilib->make_error("어플 아이디가 넘어오지 않았습니다");
}
$sessionuser = $this->CI->User_model->get_by_token($app_id, $token);
if ( ! element('user_id', $sessionuser)) {
$this->CI->apilib->make_error("로그인 한 회원만 접근이 가능합니다");
}
$user_id = element('user_id', $sessionuser);
if (element('user_photo', $sessionuser)) {
@unlink(config_item('uploads_dir') . '/user_photo/' . element('user_photo', $sessionuser));
}
$updatedata = array(
'user_photo' => '',
);
$this->CI->User_model->update($user_id, $updatedata);
$arr = array(
'result' => 'ok',
'token' => $token,
'app_id' => $app_id,
);
return $arr;
}
}

View File

@@ -0,0 +1,114 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
/**
* Profile_upload_photo
*/
class Profile_upload_photo extends CI_Controller
{
private $CI;
function __construct()
{
$this->CI = & get_instance();
}
function main()
{
if ( ! $this->CI->input->post_get('token')) {
$this->CI->apilib->make_error("토큰 값이 넘어오지 않았습니다");
}
$token = $this->CI->input->post_get('token');
$app_id = (int) trim($this->CI->input->post_get('app_id'));
if (empty($app_id)) {
$this->CI->apilib->make_error("어플 아이디가 넘어오지 않았습니다");
}
$sessionuser = $this->CI->User_model->get_by_token($app_id, $token);
if ( ! element('user_id', $sessionuser)) {
$this->CI->apilib->make_error("로그인 한 회원만 접근이 가능합니다");
}
$user_id = element('user_id', $sessionuser);
$this->CI->load->library('upload');
$uploadfiledata = '';
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'] = 1024 * 20;
$uploadconfig['encrypt_name'] = true;
$this->CI->upload->initialize($uploadconfig);
$_FILES['userfile']['name'] = $_FILES['user_photo']['name'];
$_FILES['userfile']['type'] = $_FILES['user_photo']['type'];
$_FILES['userfile']['tmp_name'] = $_FILES['user_photo']['tmp_name'];
$_FILES['userfile']['error'] = $_FILES['user_photo']['error'];
$_FILES['userfile']['size'] = $_FILES['user_photo']['size'];
if ($this->CI->upload->do_upload('user_photo')) {
$filedata = $this->CI->upload->data();
$image_name = cdate('Y') . '/' . cdate('m') . '/' . element('file_name', $filedata);
} else {
$file_error = $this->CI->upload->display_errors();
$this->CI->apilib->make_error($file_error);
}
} else {
$this->CI->apilib->make_error("파일이 업로드되지 않았습니다");
}
$updatedata = array(
'user_photo' => $image_name,
);
$this->CI->User_model->update($user_id, $updatedata);
$arr = array(
'result' => 'ok',
'token' => $token,
'app_id' => $app_id,
'photo_url' => user_photo_url($image_name),
);
return $arr;
}
}

View File

@@ -0,0 +1,91 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
/**
* Qna
*/
class Qna extends CI_Controller
{
private $CI;
function __construct()
{
$this->CI = & get_instance();
}
function main()
{
if ( ! $this->CI->input->post_get('token')) {
$this->CI->apilib->make_error("토큰 값이 넘어오지 않았습니다");
}
$token = $this->CI->input->post_get('token');
$app_id = (int) trim($this->CI->input->post_get('app_id'));
if (empty($app_id)) {
$this->CI->apilib->make_error("어플 아이디가 넘어오지 않았습니다");
}
$sessionuser = $this->CI->User_model->get_by_token($app_id, $token);
if ( ! element('user_id', $sessionuser)) {
$this->CI->apilib->make_error("로그인 한 회원만 접근이 가능합니다");
}
$user_id = element('user_id', $sessionuser);
$this->CI->load->model(array('Qna_model', 'Upload_file_model'));
$where = array(
'app_id' => $app_id,
'user_id' => $user_id,
);
$data = $this->CI->Qna_model->get('', '', $where, '', '', 'qna_id', 'desc');
$result = array();
$count = 0;
if ($data) {
foreach ($data as $key => $value) {
$uploadwhere = array(
'origin_table' => 'qna',
'origin_id' => element('qna_id', $value),
);
$file = $this->CI->Upload_file_model->get('', '', $uploadwhere, '', '', 'ufi_id', 'ASC');
$files = array();
if ($file && is_array($file)) {
foreach ($file as $key2 => $val2) {
$files[] = site_url('uploads/files/' . element('ufi_filename', $val2));
}
}
$result[$key]['qna_id'] = html_escape(element('qna_id', $value));
$result[$key]['user_id'] = html_escape(element('user_id', $value));
$result[$key]['user_name'] = html_escape(element('user_name', $value));
$result[$key]['qna_title'] = html_escape(element('qna_title', $value));
$result[$key]['qna_content'] = html_escape(element('qna_content', $value));
$result[$key]['qna_answer'] = html_escape(element('qna_answer', $value));
$result[$key]['files'] = $files;
$result[$key]['created_at'] = html_escape(element('created_at', $value));
$result[$key]['answer_at'] = html_escape(element('answer_at', $value));
$result[$key]['has_answer'] = element('has_answer', $value);
$count++;
}
}
$arr = array(
'result' => 'ok',
'token' => $token,
'app_id' => $app_id,
'count' => $count,
'list' => $result,
);
return $arr;
}
}

View File

@@ -0,0 +1,89 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
/**
* Qna_view
*/
class Qna_view extends CI_Controller
{
private $CI;
function __construct()
{
$this->CI = & get_instance();
}
function main()
{
if ( ! $this->CI->input->post_get('token')) {
$this->CI->apilib->make_error("토큰 값이 넘어오지 않았습니다");
}
$token = $this->CI->input->post_get('token');
$app_id = (int) trim($this->CI->input->post_get('app_id'));
if (empty($app_id)) {
$this->CI->apilib->make_error("어플 아이디가 넘어오지 않았습니다");
}
$qna_id = (int) trim($this->CI->input->get('qna_id'));
if (empty($qna_id)) {
$this->CI->apilib->make_error("문의사항 고유 아이디가 넘어오지 않았습니다");
}
$sessionuser = $this->CI->User_model->get_by_token($app_id, $token);
if ( ! element('user_id', $sessionuser)) {
$this->CI->apilib->make_error("로그인 한 회원만 접근이 가능합니다");
}
$user_id = element('user_id', $sessionuser);
$this->CI->load->model(array('Qna_model', 'Upload_file_model'));
$where = array(
'app_id' => $app_id,
'qna_id' => $qna_id,
);
$result = $this->CI->Qna_model->get_one('', '', $where);
if ( ! element('qna_id', $result)) {
$this->CI->apilib->make_error("존재하지 않는 문의사항입니다");
}
$uploadwhere = array(
'origin_table' => 'qna',
'origin_id' => element('v_id', $result),
);
$file = $this->CI->Upload_file_model->get('', '', $uploadwhere, '', '', 'ufi_id', 'ASC');
$files = array();
if ($file && is_array($file)) {
foreach ($file as $key => $value) {
$files[] = site_url('uploads/files/' . element('ufi_filename', $value));
}
}
$arr = array(
'result' => 'ok',
'token' => $token,
'app_id' => $app_id,
'qna_id' => html_escape(element('qna_id', $result)),
'user_id' => html_escape(element('user_id', $result)),
'user_name' => html_escape(element('user_name', $result)),
'qna_title' => html_escape(element('qna_title', $result)),
'qna_content' => nl2br(html_escape(element('qna_content', $result))),
'qna_answer' => nl2br(html_escape(element('qna_answer', $result))),
'files' => $files,
'created_at' => html_escape(element('created_at', $result)),
'answer_at' => html_escape(element('answer_at', $result)),
'has_answer' => element('has_answer', $result),
);
return $arr;
}
}

View File

@@ -0,0 +1,259 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
/**
* Qna_write
*/
class Qna_write extends CI_Controller
{
private $CI;
function __construct()
{
$this->CI = & get_instance();
}
function main()
{
if ( ! $this->CI->input->post_get('token')) {
$this->CI->apilib->make_error("토큰 값이 넘어오지 않았습니다");
}
$token = $this->CI->input->post_get('token');
$app_id = (int) trim($this->CI->input->post_get('app_id'));
if (empty($app_id)) {
$this->CI->apilib->make_error("어플 아이디가 넘어오지 않았습니다");
}
$this->CI->load->model(array('Qna_model', 'Upload_file_model'));
$sessionuser = $this->CI->User_model->get_by_token($app_id, $token);
if ( ! element('user_id', $sessionuser)) {
$this->CI->apilib->make_error("로그인 한 회원만 문의를 작성할 수 있습니다");
}
if ( ! $this->CI->input->post('qna_title')) {
$this->CI->apilib->make_error("문의 제목을 입력하여 주십시오.");
}
if ( ! $this->CI->input->post('qna_content')) {
$this->CI->apilib->make_error("문의 내용을 입력하여 주십시오.");
}
$uploadfiledata = '';
$uploadfiledata2 = '';
$this->CI->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->CI->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->CI->upload->do_upload()) {
$filedata = $this->CI->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->CI->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->CI->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->CI->upload->do_upload()) {
$filedata = $this->CI->upload->data();
$olduploadfile = $this->CI->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->CI->upload->display_errors();
break;
}
}
}
}
$insertdata = array(
'app_id' => $app_id,
'user_id' => element('user_id', $sessionuser),
'user_name' => element('user_username', $sessionuser),
'qna_title' => $this->CI->input->post('qna_title'),
'qna_content' => $this->CI->input->post('qna_content'),
'created_at' => cdate('Y-m-d H:i:s'),
);
$qna_id = $this->CI->Qna_model->insert($insertdata);
$file_updated = false;
$file_changed = false;
if (is_array($uploadfiledata) && count($uploadfiledata) > 0) {
foreach ($uploadfiledata as $pkey => $pval) {
if ($pval) {
$fileupdate = array(
'origin_id' => $qna_id,
'origin_table' => 'qna',
'user_id' => $this->CI->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->CI->input->ip_address(),
);
$file_id = $this->CI->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->CI->input->ip_address(),
);
$this->CI->Upload_file_model->update($pkey, $fileupdate);
$file_changed = true;
}
}
}
$arr = array(
'result' => 'ok',
'token' => $token,
'app_id' => $app_id,
'datetime' => cdate('Y-m-d H:i:s'),
);
return $arr;
}
}

View File

@@ -0,0 +1,121 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
/**
* Signup
*/
class Signup extends CI_Controller
{
private $CI;
function __construct()
{
$this->CI = & get_instance();
}
function main()
{
if ( ! $this->CI->input->post_get('token')) {
$this->CI->apilib->make_error("토큰 값이 넘어오지 않았습니다");
}
$token = $this->CI->input->post_get('token');
$app_id = (int) trim($this->CI->input->post_get('app_id'));
if (empty($app_id)) {
$this->CI->apilib->make_error("어플 아이디가 넘어오지 않았습니다");
}
$sessionuser = $this->CI->User_model->get_by_token($app_id, $token);
if ( ! function_exists('password_hash')) {
$this->load->helper('password');
}
$this->CI->load->helper('email');
if ( ! $this->CI->input->post('user_email')) {
$this->CI->apilib->make_error("회원 이메일이 입력되지 않았습니다");
}
if ( ! valid_email($this->CI->input->post('user_email')) ) {
$this->CI->apilib->make_error("이메일이 형식에 맞지 않습니다.");
}
if ( ! $this->CI->input->post('user_username')) {
$this->CI->apilib->make_error("회원 닉네임이 입력되지 않았습니다");
}
if ( ! $this->CI->input->post('user_password')) {
$this->CI->apilib->make_error("비밀번호를 입력해주십시오.");
}
if ($this->CI->input->post('user_password') != $this->CI->input->post('user_password2')) {
$this->CI->apilib->make_error("비밀번호가 일치하지 않습니다. 다시 입력해주세요.");
}
$user_email = trim($this->CI->input->post('user_email'));
$user_username = trim($this->CI->input->post('user_username'));
$user_password = trim($this->CI->input->post('user_password'));
$userwhere = array(
'app_id' => $app_id,
'user_email' => $user_email,
);
$row = $this->CI->User_model->get_one('', 'user_id', $userwhere);
if (element('user_id', $row)) {
$this->CI->apilib->make_error("이미 사용중인 이메일입니다. 다른 이메일을 입력해주세요.");
}
$userwhere = array(
'app_id' => $app_id,
'user_username' => $user_username,
);
$row = $this->CI->User_model->get_one('', 'user_id', $userwhere);
if (element('user_id', $row)) {
$this->CI->apilib->make_error("이미 사용중인 닉네임입니다. 다른 닉네임을 입력해주세요.");
}
$insertdata = array(
'app_id' => $app_id,
'user_email' => $user_email,
'user_password' => password_hash($user_password, PASSWORD_BCRYPT),
'user_username' => $user_username,
'user_register_datetime' => cdate('Y-m-d H:i:s'),
'user_token' => $token,
);
$user_id = $this->CI->User_model->insert($insertdata);
$dwhere = array(
'app_id' => $app_id,
'user_id <>' => $user_id,
'user_token' => $token,
);
$this->CI->User_model->delete('', $dwhere);
//fcm token 등록하기
if ($this->CI->input->post('fcm_token')) {
$this->CI->load->library('Fcm_library');
$this->CI->fcm_library->update_token($user_id, $this->CI->input->post('fcm_token'));
}
//$this->CI->session->set_userdata('user_id', $user_id);
$arr = array(
'result' => 'ok',
'token' => $token,
'user_id' => $user_id,
'user_email' => $user_email,
'user_username' => $user_username,
'datetime' => cdate('Y-m-d H:i:s'),
);
return $arr;
}
}

View File

@@ -0,0 +1,66 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
/**
* Signup_check_email
*/
class Signup_check_email extends CI_Controller
{
private $CI;
function __construct()
{
$this->CI = & get_instance();
}
function main()
{
if ( ! $this->CI->input->post_get('token')) {
$this->CI->apilib->make_error("토큰 값이 넘어오지 않았습니다");
}
$token = $this->CI->input->post_get('token');
$app_id = (int) trim($this->CI->input->post_get('app_id'));
if (empty($app_id)) {
$this->CI->apilib->make_error("어플 아이디가 넘어오지 않았습니다");
}
$sessionuser = $this->CI->User_model->get_by_token($app_id, $token);
$this->CI->load->helper('email');
$user_email = $this->CI->input->post('user_email');
if ( ! $user_email) {
$this->CI->apilib->make_error("회원 이메일이 입력되지 않았습니다");
}
if ( ! valid_email($user_email) ) {
$this->CI->apilib->make_error("이메일 형식에 맞지 않습니다.");
}
$userwhere = array(
'app_id' => $app_id,
'user_email' => $user_email,
);
$row = $this->CI->User_model->get_one('', 'user_id', $userwhere);
if (element('user_id', $row)) {
$this->CI->apilib->make_error("이미 사용중인 이메일입니다. 다른 이메일을 입력해주세요.");
}
$arr = array(
'result' => 'ok',
'token' => $token,
'app_id' => $app_id,
'user_email' => $user_email,
);
return $arr;
}
}

View File

@@ -0,0 +1,55 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
/**
* User_myinfo
*/
class User_myinfo extends CI_Controller
{
private $CI;
function __construct()
{
$this->CI = & get_instance();
}
function main()
{
if ( ! $this->CI->input->post_get('token')) {
$this->CI->apilib->make_error("토큰 값이 넘어오지 않았습니다");
}
$token = $this->CI->input->post_get('token');
$app_id = (int) trim($this->CI->input->post_get('app_id'));
if (empty($app_id)) {
$this->CI->apilib->make_error("어플 아이디가 넘어오지 않았습니다");
}
$sessionuser = $this->CI->User_model->get_by_token($app_id, $token);
if ( ! element('user_id', $sessionuser)) {
$this->CI->apilib->make_error("로그인 한 회원만 회원정보를 열람할 수 있습니다");
}
$user_id = element('user_id', $sessionuser);
$this->CI->load->model(array('User_model'));
$user = $this->CI->User_model->get_one(element('user_id', $sessionuser));
$arr = array(
'result' => 'ok',
'token' => $token,
'user_id' => element('user_id', $user),
'user_email' => element('user_email', $user),
'user_username' => element('user_username', $user),
'user_photo' => user_photo_url(element('user_photo', $user)),
);
return $arr;
}
}