825 lines
28 KiB
PHP
Executable File
825 lines
28 KiB
PHP
Executable File
<?php
|
|
defined('BASEPATH') OR exit('No direct script access allowed');
|
|
|
|
include_once (APPPATH.'core/admin/cm_controller.php');
|
|
|
|
class maptoon extends cm_controller {
|
|
|
|
var $tb_name_category = 'mt_categories';
|
|
var $tb_name_episode = 'mt_episodes';
|
|
var $tb_name_maptoon_list = 'mt_list';
|
|
var $tb_name_notice = 'mt_notices';
|
|
var $tb_name_cartoonist = 'mt_cartoonists';
|
|
var $total_count = 20; // total # of list
|
|
var $list_limit = 10; // total # of pages
|
|
|
|
function __construct() {
|
|
parent::__construct();
|
|
$this->load->library('util');
|
|
}
|
|
|
|
/*
|
|
@desc : list all the maptoon categories
|
|
*/
|
|
public function fn_category() {
|
|
$idx = $this->input->get('idx');
|
|
|
|
$this->load->database();
|
|
if(is_numeric($idx)==TRUE && $idx>0) {
|
|
$query = $this->db->get_where($this->tb_name_category,['idx'=>$idx]);
|
|
$row = $query->row_array();
|
|
if($row!=FALSE) {
|
|
$row['result'] = 'success';
|
|
}
|
|
echo json_encode($row);
|
|
exit;
|
|
} else {
|
|
$query = $this->db->get($this->tb_name_category);
|
|
$i = 0;
|
|
$return_data = array();
|
|
foreach($query->result_array() as $row) {
|
|
$return_data['list'][$i] = $row;
|
|
$i++;
|
|
}
|
|
return $this->load->view('/admin/maptoon/category_list', $return_data, true);
|
|
}
|
|
}
|
|
|
|
/*
|
|
@desc : register category
|
|
*/
|
|
public function fn_category_proc() {
|
|
$c_name = $this->input->post('c_name');
|
|
$mode = $this->input->post('mode');
|
|
$idx = $this->input->post('idx');
|
|
$c_name = trim($c_name);
|
|
|
|
if($c_name=='') {
|
|
$this->util->js_alert('카테고리 이름을 입력해 주십시오'); exit;
|
|
}
|
|
if($mode=='upt') {
|
|
if(is_numeric($idx)==TRUE && $idx>0) {
|
|
$data = ['c_name'=>$c_name];
|
|
$this->db->where('idx',$idx);
|
|
$ret = $this->db->update($this->tb_name_category, $data);
|
|
if($ret==TRUE) {
|
|
$this->util->js_alert_parent_reload('수정되었습니다.');
|
|
} else {
|
|
$this->util->js_alert('DB error');
|
|
}
|
|
} else {
|
|
$this->util->js_alert('키값이 입력되지 않았습니다.');
|
|
}
|
|
} else {
|
|
$data = ['c_name' => $c_name];
|
|
$ret = $this->db->insert($this->tb_name_category,$data);
|
|
if($ret==TRUE) {
|
|
$this->util->js_alert_parent_reload('등록되었습니다.');
|
|
} else {
|
|
$this->util->js_alert('DB error');
|
|
}
|
|
}
|
|
exit;
|
|
}
|
|
|
|
public function fn_register_episode_in_category() {
|
|
$episodes_idx = $this->input->post('episodes_idx');
|
|
$idx = $this->input->post('idx');
|
|
|
|
$len = count($episodes_idx);
|
|
|
|
if(is_array($episodes_idx)==TRUE && is_numeric($idx)==TRUE
|
|
&& $idx>0 && $len>0) {
|
|
$str = implode(',',$episodes_idx);
|
|
$this->load->model('maptoon/m_maptoon');
|
|
$ret = $this->m_maptoon->update_episodes_by_category($idx,$str);
|
|
|
|
$this->config->load('filecache',TRUE);
|
|
$file_cache_path = $this->config->item('file_cache_path','filecache');
|
|
$params = array('file_cache_path'=>$file_cache_path);
|
|
$this->load->library('maptoon_lib',$params);
|
|
|
|
// get episode data to write cache
|
|
$json_data = $this->m_maptoon->get_widget_info_by_episode_idx($episodes_idx,'json');
|
|
|
|
if($json_data!=FALSE) {
|
|
$this->maptoon_lib->write_category_cache($idx,$json_data);
|
|
}
|
|
}
|
|
$this->util->js_alert_go('카테고리내 에피소드 등록이 완료되었습니다.','/admin/maptoon/category/10');
|
|
}
|
|
|
|
public function fn_category_detail() {
|
|
$idx = $this->input->get('idx');
|
|
$search_keyword = $this->input->get('search_keyword');
|
|
|
|
if(is_numeric($idx)==FALSE || $idx<=0) {
|
|
$this->util->js_alert_back('잘못된 접근입니다.'); exit;
|
|
}
|
|
|
|
// get maptoon list in chosen category
|
|
$this->load->model('maptoon/m_maptoon');
|
|
|
|
$return_data = ['c_name' => ''];
|
|
$data_category = $this->m_maptoon->get_category($idx);
|
|
if($data_category!=FALSE && isset($data_category['c_name'])==TRUE) {
|
|
$return_data['c_name'] = $data_category['c_name'];
|
|
}
|
|
|
|
if($data_category['mt_episodes_idx']=='') {// get episodes from episode category
|
|
$data_episodes = $this->m_maptoon->get_episodes_by_category($idx);
|
|
} else { // get episodes in chosen category
|
|
$data_episodes = $this->m_maptoon->get_episodes_by_category($data_category['mt_episodes_idx']);
|
|
}
|
|
if($data_episodes!=FALSE) {
|
|
$return_data['list'] = $data_episodes;
|
|
} else {
|
|
$return_data['list'] = '';
|
|
}
|
|
$return_data['idx'] = $idx;
|
|
return $this->load->view('/admin/maptoon/category_detail', $return_data, true);
|
|
}
|
|
|
|
/*
|
|
@desc : delete category
|
|
*/
|
|
public function fn_category_del_proc() {
|
|
$idx = $this->input->post('idx');
|
|
|
|
if(is_numeric($idx)==TRUE && $idx>0) {
|
|
$this->db->where('idx',$idx);
|
|
$ret = $this->db->delete($this->tb_name_category);
|
|
if($ret==TRUE) {
|
|
$this->db->where('mt_categories_idx',$idx);
|
|
$data = ['mt_categories_idx' => 0];
|
|
$ret = $this->db->update($this->tb_name_episode,$data);
|
|
//echo $this->db->last_query();
|
|
$this->util->js_alert_parent_reload('삭제되었습니다.');
|
|
}
|
|
} else {
|
|
$this->util->js_alert('키값이 전달되지 않았습니다.');
|
|
}
|
|
exit;
|
|
}
|
|
|
|
/*
|
|
get list of maptoon episodes
|
|
@return json string
|
|
*/
|
|
public function fn_get_episodes_by_search_keyword() {
|
|
$keyword = $this->input->get('keyword');
|
|
if($keyword!='') {
|
|
$this->load->model('maptoon/m_maptoon');
|
|
$row = $this->m_maptoon->get_episodes_by_search_keyword($keyword);
|
|
// $row = array(['idx'=>2, 'main_img'=>'/files/maptoon/2019/03/efe2b7b7f5d738ffc4ff288ef3a5b055.png','title'=>htmlspecialchars('김"집사')],
|
|
// ['idx'=>3, 'main_img'=>'/files/maptoon/2019/03/efe2b7b7f5d738ffc4ff288ef3a5b055.png','title'=>'김집사']);
|
|
echo json_encode($row);exit;
|
|
}
|
|
}
|
|
|
|
/*
|
|
@desc : list all maptoons
|
|
*/
|
|
public function fn_maptoon_list() {
|
|
$page = $this->input->get('page',TRUE);
|
|
|
|
$this->load->model('maptoon/m_maptoon');
|
|
//$query_string = ['status'=>1, 'mt_cartoonists_idx'=>1];
|
|
$query_string = [];
|
|
$data = $this->m_maptoon->get_maptoon_list($query_string);
|
|
$arr_cartoonist = $this->m_maptoon->get_cartoonist_list();
|
|
|
|
# paging 설정
|
|
if($page == '') $page = 1;
|
|
$limit = PAGE_SIZE;
|
|
$offset = ($page-1) * $limit;
|
|
|
|
# pagination
|
|
$req_data = array();
|
|
$req_data['total_count'] = $this->total_count;
|
|
$req_data['limit'] = $this->list_limit;
|
|
$req_data['base_url'] = '/admin/maptoon/maptoon_list/10/' ;
|
|
$req_data['suffix'] = '?'.$_SERVER['QUERY_STRING'];
|
|
|
|
$this->load->library('comm_admin');
|
|
$pagination = $this->comm_admin->fn_pagination($req_data);
|
|
$return_data = $req_data;
|
|
for($i=0; $i<count($data); $i++) {
|
|
$data[$i]['num_of_episodes'] = $this->m_maptoon->get_num_of_episodes($data[$i]['idx']);
|
|
}
|
|
|
|
$return_data['list'] = $data;
|
|
$return_data['page'] = $page;
|
|
$return_data['cartoonist'] = $arr_cartoonist;
|
|
return $this->load->view('/admin/maptoon/list', $return_data, true);
|
|
}
|
|
|
|
public function fn_maptoon_list_del() {
|
|
$idx = $this->input->post('idx');
|
|
if(is_numeric($idx)==TRUE && $idx>0) {
|
|
//1.check num of episode in maptoon
|
|
$this->load->model('maptoon/m_maptoon');
|
|
$num = $this->m_maptoon->get_num_of_episodes($idx);
|
|
|
|
$num_of_announcement = $this->m_maptoon->get_num_of_announcement_by_maptoon($idx);
|
|
if($num>0) {
|
|
$ret = ['result'=>"이미 등록되어 있는 에피소드가 있어서 삭제가 불가능합니다.\n해당 에피소드 삭제후 웹툰 삭제가 가능합니다."];
|
|
echo json_encode($ret); exit;
|
|
}
|
|
if($num_of_announcement>0) {
|
|
$ret = ['result'=>"이미 웹툰에 등록되어 있는 공지사항이 있어서 삭제가 불가능합니다.\n해당 공지사항 삭제후 웹툰 삭제가 가능합니다."];
|
|
echo json_encode($ret); exit;
|
|
}
|
|
|
|
$result = $this->m_maptoon->delete_maptoon($idx);
|
|
$ret = ['result'=>$result];
|
|
if($result==TRUE) {
|
|
$ret = ['result'=>'success'];
|
|
} else {
|
|
$ret = ['result'=>'DB error, 개발자에게 문의 바랍니다.'];
|
|
}
|
|
} else {
|
|
$ret = ['result'=>'wrong parameter'];
|
|
}
|
|
exit;
|
|
}
|
|
|
|
public function fn_maptoon_detail() {
|
|
$idx = $this->input->get('idx');
|
|
|
|
$this->load->model('maptoon/m_maptoon');
|
|
$arr_cartoonist = $this->m_maptoon->get_cartoonist_list();
|
|
$return_data['cartoonist'] = $arr_cartoonist;
|
|
|
|
if(is_numeric($idx)==TRUE && $idx>0) {
|
|
$num_of_episodes = $this->m_maptoon->get_num_of_episodes($idx);
|
|
$return_data['num_of_episodes'] = $num_of_episodes;
|
|
$row = $this->m_maptoon->get_maptoon_list(['idx' => $idx]);
|
|
if(isset($row[0])==TRUE) {
|
|
$return_data['data'] = $row[0];
|
|
}
|
|
$return_data['maptoon_idx'] = $idx;
|
|
} else {
|
|
$return_data['data'] = [];
|
|
}
|
|
return $this->load->view('/admin/maptoon/maptoon_detail', $return_data, true);
|
|
}
|
|
|
|
/*
|
|
@desc : register maptoon
|
|
*/
|
|
public function fn_maptoon_proc() {
|
|
$idx = $this->input->post('idx');
|
|
$mode = $this->input->post('mode');
|
|
$mt_cartoonists_idx = $this->input->post('mt_cartoonists_idx'); //
|
|
$name = $this->input->post('name'); //
|
|
$status = $this->input->post('status');
|
|
$date_sun = ($this->input->post('date_sun')=='') ? 0 : $this->input->post('date_sun');
|
|
$date_mon = ($this->input->post('date_mon')=='') ? 0 : $this->input->post('date_mon');
|
|
$date_tue = ($this->input->post('date_tue')=='') ? 0 : $this->input->post('date_tue');
|
|
$date_wed = ($this->input->post('date_wed')=='') ? 0 : $this->input->post('date_wed');
|
|
$date_thu = ($this->input->post('date_thu')=='') ? 0 : $this->input->post('date_thu');
|
|
$date_fri = ($this->input->post('date_fri')=='') ? 0 : $this->input->post('date_fri');
|
|
$date_sat = ($this->input->post('date_sat')=='') ? 0 : $this->input->post('date_sat');
|
|
$description = $this->input->post('description');
|
|
|
|
if($name=='') {
|
|
$this->util->js_alert_back('맵툰명을 입력해주십시오'); exit;
|
|
}
|
|
if($mt_cartoonists_idx=='') {
|
|
$this->util->js_alert_back('맵툰작가를 입력해주십시오'); exit;
|
|
}
|
|
|
|
$this->load->model('maptoon/m_maptoon');
|
|
$maptoon_info = $this->m_maptoon->get_maptoon_list(['idx' => $idx]);
|
|
|
|
//이미지 업로드
|
|
if($_FILES['main_img']['name']!='') {
|
|
$mid_url_path = date("Y")."/".date("m");
|
|
$upload_path = MAPTOON_DIR_BACK.$mid_url_path;
|
|
if (!is_dir($upload_path)) {
|
|
umask(0);
|
|
mkdir($upload_path, 0777, TRUE);
|
|
}
|
|
$config['max_size'] = 20*1024;
|
|
$config['upload_path'] = $upload_path;
|
|
$config['allowed_types'] = 'gif|jpg|png|jpeg';
|
|
$config['encrypt_name'] = TRUE;
|
|
|
|
$this->load->library('upload');
|
|
$this->upload->initialize($config);
|
|
|
|
$file_name= date("H").date("i").date("s");
|
|
|
|
if ( ! $this->upload->do_upload('main_img')) {
|
|
$error = array('error' => $this->upload->display_errors());
|
|
gf_alert("이미지 업로드에 실패했습니다.", 'back');
|
|
}
|
|
$arr_upload_data = $this->upload->data();
|
|
$img_data = (isset($arr_upload_data['file_name'])==TRUE) ? MAPTOON_DIR_FRONT.$mid_url_path.'/'.$arr_upload_data['file_name'] : '';
|
|
|
|
//remove previous image
|
|
if(isset($maptoon_info[0])==TRUE && $img_data!='') {
|
|
$main_img = $maptoon_info[0]['main_img'];
|
|
if($main_img!='') {
|
|
unlink($_SERVER['DOCUMENT_ROOT'].$main_img);
|
|
}
|
|
}
|
|
} else {
|
|
$img_data = (isset($maptoon_info[0]['main_img'])==TRUE) ? $maptoon_info[0]['main_img'] : '';
|
|
}
|
|
|
|
$data = ['main_img' => $img_data,
|
|
'name' => $name,
|
|
'status' => $status,
|
|
'date_sun' => $date_sun,
|
|
'date_mon' => $date_mon,
|
|
'date_tue' => $date_tue,
|
|
'date_wed' => $date_wed,
|
|
'date_thu' => $date_thu,
|
|
'date_fri' => $date_fri,
|
|
'date_sat' => $date_sat,
|
|
'description' => $description,
|
|
'reg_date' => date("Y-m-d H:i:s"),
|
|
'mt_cartoonists_idx' => $mt_cartoonists_idx];
|
|
|
|
if(is_numeric($idx)==TRUE && $idx>0) { // update data
|
|
$ret = $this->m_maptoon->update_maptoon($idx, $data);
|
|
if($ret==TRUE) {
|
|
$this->util->js_alert_go('수정되었습니다','/admin/maptoon/maptoon_list/10');exit;
|
|
} else {
|
|
$this->util->js_alert_back('수정되지 않았습니다. 다시 시도해 주세요');exit;
|
|
}
|
|
} else { // insert data
|
|
$ret = $this->m_maptoon->insert_maptoon($data);
|
|
if($ret==TRUE) {
|
|
$this->util->js_alert_go('등록되었습니다','/admin/maptoon/maptoon_list/10');exit;
|
|
} else {
|
|
$this->util->js_alert_back('등록되지 않았습니다. 다시 시도해 주세요');exit;
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
/*
|
|
@desc : delete maptoon
|
|
*/
|
|
public function fn_maptoon_del_proc() {
|
|
|
|
}
|
|
|
|
/*
|
|
@desc : show list of maptoon episodes
|
|
*/
|
|
public function fn_episode() {
|
|
$return_data['list'] = $result = array();
|
|
|
|
$this->load->model('maptoon/m_maptoon');
|
|
$arr_cartoonist = $this->m_maptoon->get_cartoonist_list(); //작가 이름
|
|
$arr_mt_title = $this->m_maptoon->get_mt_title(); //맵툰 이름 리스트
|
|
$cartoonist_list=array();
|
|
foreach($arr_cartoonist as $val){
|
|
$cartoonist_list[$val['idx']]=$val['name'];
|
|
}
|
|
|
|
$query = $this->db->get($this->tb_name_category);
|
|
$arr_category = $query->result_array(); //카테고리 리스트
|
|
$category_list=array();
|
|
foreach($arr_category as $val){
|
|
$category_list[$val['idx']]=$val['c_name'];
|
|
}
|
|
|
|
|
|
$page = $this->input->get('page',TRUE);
|
|
|
|
|
|
$query_string = $_SERVER['QUERY_STRING'];
|
|
parse_str($query_string);
|
|
|
|
|
|
if(isset($author)) $arr_cartoonist_idx = $this->m_maptoon->get_cartoonist_idx_by_name(urldecode($author));
|
|
|
|
# 검색
|
|
$req_data = array();
|
|
isset($sort_list)? $req_data['sort_list']=$sort_list :$req_data['sort_list']=""; // 최신 조회
|
|
isset($date_reg)? $req_data['date_reg']=$date_reg :$req_data['date_reg']=""; // 등록 날짜별
|
|
isset($ca)? $req_data['category']=$ca :$req_data['category']=""; // 카테고리
|
|
isset($sdate)? $req_data['sdate']=$sdate :$req_data['sdate']=""; // 시작일
|
|
isset($edate)? $req_data['edate']=$edate :$req_data['edate']=""; // 종료일
|
|
isset($mt_name)? $req_data['mt_name']= urldecode($mt_name) :$req_data['mt_name']=""; // 맵툰 이름
|
|
isset($ep_title)? $req_data['ep_title']= urldecode($ep_title) :$req_data['ep_title']=""; // 맵툰 제목
|
|
isset($arr_cartoonist_idx)? $req_data['author']= $arr_cartoonist_idx :$req_data['author']=""; // 작가 번호
|
|
|
|
|
|
# paging 설정
|
|
if($page == '') $page = 1;
|
|
$limit = PAGE_SIZE;
|
|
$offset = ($page-1) * $limit;
|
|
|
|
$req_data['offset'] = $offset;
|
|
$req_data['limit'] = $limit;
|
|
|
|
//list 가져오기
|
|
|
|
$data = $this->m_maptoon->get_episode_list($req_data);
|
|
|
|
# pagination
|
|
$req_data = array();
|
|
$req_data['total_count'] = $this->total_count;
|
|
$req_data['limit'] = $this->list_limit;
|
|
$req_data['base_url'] = '/admin/maptoon/episode/10/' ;
|
|
$req_data['suffix'] = '?'.$query_string;
|
|
|
|
$this->load->library('comm_admin');
|
|
$pagination = $this->comm_admin->fn_pagination($req_data);
|
|
$return_data = $req_data;
|
|
$return_data['list'] = $data;
|
|
$return_data['page'] = $page;
|
|
$return_data['pagination' ] = $pagination;
|
|
$return_data['cartoonist'] = $arr_cartoonist; // 작가 이름
|
|
$return_data['cartoonist_list'] = $cartoonist_list; // 작가 이름2
|
|
$return_data['mt_title' ] = $arr_mt_title; // 맵툰 이름
|
|
$return_data['category'] = $arr_category; // 카테고리 리스트
|
|
$return_data['category_list'] = $category_list; // 카테고리 리스트2
|
|
|
|
return $this->load->view('/admin/maptoon/episode_list', $return_data, true);
|
|
}
|
|
|
|
/*
|
|
@desc : register form for maptoon episode
|
|
*/
|
|
public function fn_episode_reg() {
|
|
$this->load->model('maptoon/m_maptoon');
|
|
|
|
$return_data['cartoonist'] = $this->m_maptoon->get_cartoonist_list();
|
|
$return_data['mt_title' ] = $this->m_maptoon->get_mt_title();
|
|
|
|
|
|
if(empty($this->input->post('idx')==FALSE)){
|
|
$idx= $this->input->post('idx');
|
|
$query = $this->db->get_where($this->tb_name_episode,['idx'=>$idx]);
|
|
$row = $query->row_array();
|
|
|
|
$return_data['modify_data'] = $row;
|
|
}
|
|
|
|
$query = $this->db->get($this->tb_name_category);
|
|
$arr_category = $query->result_array();
|
|
|
|
$return_data['category']=$arr_category;
|
|
|
|
return $this->load->view('/admin/maptoon/episode_reg', $return_data, true);
|
|
}
|
|
|
|
/*
|
|
@desc : register maptoon episode
|
|
*/
|
|
public function fn_episode_reg_proc() {
|
|
echo $this->input->get_post("idx");
|
|
var_dump($_FILES);
|
|
exit;
|
|
$mode = $this->input->get_post("mode");// edit 이면 수정
|
|
$idx = $this->input->get_post("idx"); // 수정시 사용
|
|
$this->input->get_post("mt_categories_idx")!="n"?$mt_categories_idx = $this->input->get_post("mt_categories_idx"):$mt_categories_idx=null;
|
|
$mt_list_idx = $this->input->get_post("mt_list_idx");
|
|
$title = $this->input->get_post("title");
|
|
$display_date = $this->input->get_post("display_date");
|
|
$is_display = $this->input->get_post("is_display"); //0: NO 1:YES
|
|
$ep_no = $this->input->get_post("ep_no");
|
|
|
|
//메인이미지 업로드
|
|
$main_img = '';
|
|
if(isset($_FILES['main_img']['name'])) {
|
|
$mid_url_path = date("Y")."/".date("m");
|
|
$upload_path = MAPTOON_DIR_BACK.$mid_url_path;
|
|
if (!is_dir($upload_path)) {
|
|
umask(0);
|
|
mkdir($upload_path, 0777, TRUE);
|
|
}
|
|
$config['max_size'] = 20*1024;
|
|
$config['upload_path'] = $upload_path;
|
|
$config['allowed_types'] = 'gif|jpg|png|jpeg';
|
|
$config['encrypt_name'] = TRUE;
|
|
|
|
$this->load->library('upload');
|
|
$this->upload->initialize($config);
|
|
|
|
$file_name= date("H").date("i").date("s");
|
|
|
|
if ( ! $this->upload->do_upload('main_img')) {
|
|
$error = array('error' => $this->upload->display_errors());
|
|
gf_alert("메인 이미지 업로드에 실패했습니다.", 'back');
|
|
}
|
|
$arr_upload_data = $this->upload->data();
|
|
$main_img = (isset($arr_upload_data['file_name'])==TRUE) ? MAPTOON_DIR_FRONT.$mid_url_path.'/'.$arr_upload_data['file_name'] : '';
|
|
}
|
|
|
|
//맵툰이미지 업로드
|
|
$data = array();
|
|
$filesCount = count($_FILES['webtoon_images']['name']);
|
|
$webtoon_images = '';
|
|
if($filesCount>0 && $_FILES['webtoon_images']['name']!=''){
|
|
for($i =0; $i<$filesCount;$i++){
|
|
$_FILES['webtoon_images'.$i]['name'] = $_FILES['webtoon_images']['name'][$i];
|
|
$_FILES['webtoon_images'.$i]['type'] = $_FILES['webtoon_images']['type'][$i];
|
|
$_FILES['webtoon_images'.$i]['tmp_name'] = $_FILES['webtoon_images']['tmp_name'][$i];
|
|
$_FILES['webtoon_images'.$i]['error'] = $_FILES['webtoon_images']['error'][$i];
|
|
$_FILES['webtoon_images'.$i]['size'] = $_FILES['webtoon_images']['size'][$i];
|
|
//이미지 업로드
|
|
if($_FILES['webtoon_images'.$i]['name']!='') {
|
|
$mid_url_path = date("Y")."/".date("m");
|
|
$upload_path = MAPTOON_DIR_BACK.$mid_url_path;
|
|
if (!is_dir($upload_path)) {
|
|
umask(0);
|
|
mkdir($upload_path, 0777, TRUE);
|
|
}
|
|
$config['max_size'] = 20*1024;
|
|
$config['upload_path'] = $upload_path;
|
|
$config['allowed_types'] = 'gif|jpg|png|jpeg';
|
|
$config['encrypt_name'] = TRUE;
|
|
|
|
$this->load->library('upload');
|
|
$this->upload->initialize($config);
|
|
|
|
$file_name= 'webtoon_images'.$i.date("H").date("i").date("s");
|
|
|
|
if ( ! $this->upload->do_upload('webtoon_images'.$i)) {
|
|
$error = array('error' => $this->upload->display_errors());
|
|
gf_alert("이미지 업로드에 실패했습니다1.", 'back');
|
|
}
|
|
$arr_upload_data = $this->upload->data();
|
|
$webtoon_images[$i] = (isset($arr_upload_data['file_name'])==TRUE) ? MAPTOON_DIR_FRONT.$mid_url_path.'/'.$arr_upload_data['file_name'] : '';
|
|
}
|
|
}
|
|
}
|
|
|
|
if($mode!="edit"){
|
|
$data=[
|
|
'mt_categories_idx' => $mt_categories_idx,
|
|
'mt_list_idx' => $mt_list_idx,
|
|
'title' => $title,
|
|
'main_img' => $main_img,
|
|
'display_date' => $display_date,
|
|
'is_display' => $is_display,
|
|
'ep_no' => $ep_no,
|
|
'webtoon_images' => json_encode($webtoon_images),
|
|
'reg_date' => date("Y-m-d H:i:s")
|
|
];
|
|
$ret = $this->db->insert($this->tb_name_episode,$data);
|
|
if($ret==TRUE) {
|
|
$this->util->js_alert_go('등록되었습니다','/admin/maptoon/episode/10');exit;
|
|
} else {
|
|
$this->util->js_alert('DB error');
|
|
}
|
|
}else if($mode=="edit"){
|
|
$data=[
|
|
'mt_categories_idx' => $mt_categories_idx,
|
|
'mt_list_idx' => $mt_list_idx,
|
|
'title' => $title,
|
|
'display_date' => $display_date,
|
|
'ep_no' => $ep_no,
|
|
'is_display' => $is_display,
|
|
'reg_date' => date("Y-m-d H:i:s")
|
|
];
|
|
|
|
if($main_img!='')$data['main_img']= $main_img;
|
|
if($webtoon_images!='') $data['webtoon_images'] = json_encode($webtoon_images);
|
|
|
|
$this->db->where('idx',$idx);
|
|
|
|
$ret = $this->db->update($this->tb_name_episode,$data);
|
|
if($ret==TRUE) {
|
|
$this->util->js_alert_go('수정되었습니다','/admin/maptoon/episode/10');exit;
|
|
} else {
|
|
$this->util->js_alert('DB error');
|
|
}
|
|
}
|
|
}
|
|
|
|
/*
|
|
@desc : update maptoon episode
|
|
*/
|
|
public function fn_episode_upd_proc() {
|
|
|
|
}
|
|
|
|
/*
|
|
@desc : delete maptoon episode
|
|
*/
|
|
public function fn_episode_del_proc() {
|
|
$idx = $this->input->post('idx');
|
|
if(is_numeric($idx)==TRUE && $idx>=0) {
|
|
$this->load->database();
|
|
$this->db->query("SET FOREIGN_KEY_CHECKS=0;");
|
|
$this->db->where('idx',$idx);
|
|
$ret = $this->db->delete($this->tb_name_episode);
|
|
if($ret==TRUE) {
|
|
$message = '삭제되었습니다.';
|
|
} else {
|
|
$message = '삭제되지 않았습니다.(디비 에러) 서버 관리자에게 문의해 주십시오.';
|
|
}
|
|
}else{
|
|
$message = '인덱스 값이 잘못 입력되었습니다';
|
|
exit;
|
|
}
|
|
// $this->util->js_alert_back($message);exit;
|
|
echo "<script>alert('".$message."');</script>";
|
|
Header("Location:/admin/maptoon/episode/10");
|
|
}
|
|
|
|
/*
|
|
@desc : show list of maptoon announcement
|
|
@param: numeric; idx of announcement table
|
|
*/
|
|
public function fn_announcement() {
|
|
$this->load->model('maptoon/m_maptoon');
|
|
$mt_idx=0; //all data
|
|
$return_data['list']=$this->m_maptoon->get_announcement_list($mt_idx);
|
|
$return_data['mt_title' ]=$this->m_maptoon->get_mt_title();
|
|
return $this->load->view('/admin/maptoon/notice_list',$return_data,true);
|
|
}
|
|
|
|
/*
|
|
@desc : register announcement
|
|
*/
|
|
public function fn_announcement_reg_proc() {
|
|
$mt_list_idx = $this->input->post('mt_title');
|
|
$mode = $this->input->post('mode');
|
|
$idx = $this->input->post('idx');
|
|
$contents = $this->input->post('contents');
|
|
$s_date = $this->input->post('s_date');
|
|
$e_date = $this->input->post('e_date');
|
|
|
|
if($mode=='modify') {
|
|
if(is_numeric($idx)==TRUE && $idx>0) {
|
|
$data = [
|
|
'contents' => $contents,
|
|
's_date' => $s_date,
|
|
'e_date' => $e_date
|
|
];
|
|
$this->db->where('idx',$idx);
|
|
$ret = $this->db->update($this->tb_name_notice, $data);
|
|
if($ret==TRUE) {
|
|
$this->util->js_alert_parent_reload('수정되었습니다.');
|
|
} else {
|
|
$this->util->js_alert('DB error');
|
|
}
|
|
} else {
|
|
$this->util->js_alert('키값이 입력되지 않았습니다.');
|
|
}
|
|
} else {
|
|
$data=[ 'mt_list_idx' => $mt_list_idx,
|
|
'contents' => $contents,
|
|
's_date' => $s_date,
|
|
'e_date' => $e_date,
|
|
'reg_date' => date("Y-m-d H:i:s")
|
|
];
|
|
$ret = $this->db->insert($this->tb_name_notice,$data);
|
|
if($ret==TRUE) {
|
|
$this->util->js_alert_parent_reload('등록되었습니다.');
|
|
} else {
|
|
$this->util->js_alert('DB error');
|
|
}
|
|
// $this->util->js_alert('존재하지 않는 웹툰 제목입니다.');
|
|
}
|
|
exit;
|
|
}
|
|
|
|
/*
|
|
@desc : update maptoon announcement NOT USE
|
|
|
|
public function fn_announcement_upd_proc() {
|
|
$idx= $this->input->post('idx');
|
|
$contents= $this->input->post('contentes');
|
|
$idx= $this->input->post('s_date');
|
|
$idx= $this->input->post('e_date');
|
|
$mode= $this->input->post('mode');
|
|
if($mode==""){
|
|
exit;
|
|
}else{
|
|
$data = [
|
|
'contentes' => $contents,
|
|
's_date' => $s_date,
|
|
'e_date' => $e_date];
|
|
$this->db->where('idx',$idx);
|
|
$ret = $this->db->update($this->tb_name_notice, $data);
|
|
if($ret==TRUE) {
|
|
$this->util->js_alert_parent_reload('수정되었습니다.');
|
|
} else {
|
|
$this->util->js_alert('DB error');
|
|
}
|
|
}
|
|
|
|
}
|
|
*/
|
|
/*
|
|
@desc : delete maptoon announcement
|
|
*/
|
|
public function fn_announcement_del_proc() {
|
|
$idx = $this->input->get_post('idx');
|
|
if(is_numeric($idx)==TRUE && $idx>0) {
|
|
$this->load->database();
|
|
$this->db->where('idx',$idx);
|
|
$ret = $this->db->delete($this->tb_name_notice);
|
|
echo $ret;
|
|
if($ret==TRUE) {
|
|
$message = '삭제되었습니다.';
|
|
} else {
|
|
$message = '삭제되지 않았습니다.(디비 에러) 서버 관리자에게 문의해 주십시오.';
|
|
}
|
|
}else{
|
|
$message = '인덱스 값이 잘못 입력되었습니다';
|
|
exit;
|
|
}
|
|
echo "<script>alert('".$message."'); parent.location.reload();</script>";
|
|
}
|
|
/*
|
|
@desc : list all cartoonists
|
|
*/
|
|
public function fn_cartoonist() {
|
|
$idx = $this->input->get('idx');
|
|
$this->load->database();
|
|
if(is_numeric($idx)==TRUE && $idx>0) {
|
|
$query = $this->db->get_where($this->tb_name_cartoonist,['idx'=>$idx]);
|
|
$row = $query->row_array();
|
|
if($row!=FALSE) {
|
|
$row['result'] = 'success';
|
|
}
|
|
echo json_encode($row);
|
|
exit;
|
|
} else {
|
|
$query = $this->db->get($this->tb_name_cartoonist);
|
|
$i = 0;
|
|
$return_data = array();
|
|
foreach($query->result_array() as $row) {
|
|
$return_data['list'][$i] = $row;
|
|
$i++;
|
|
}
|
|
return $this->load->view('/admin/maptoon/cartoonist', $return_data, true);
|
|
}
|
|
}
|
|
|
|
/*
|
|
@desc : register & modify cartoonist info
|
|
*/
|
|
public function fn_cartoonist_proc() {
|
|
$name = $this->input->post('name');
|
|
$website = $this->input->post('website');
|
|
$mode = $this->input->post('mode');
|
|
$idx = $this->input->post('idx');
|
|
$name = trim($name);
|
|
$website = trim($website);
|
|
|
|
if($name!='' && $website!='') {
|
|
if($mode=='upt') {
|
|
if(is_numeric($idx)==TRUE && $idx>0) {
|
|
$data = ['name' => $name,
|
|
'website' => $website];
|
|
$this->db->where('idx',$idx);
|
|
$ret = $this->db->update($this->tb_name_cartoonist, $data);
|
|
if($ret==TRUE) {
|
|
$this->util->js_alert_parent_reload('수정되었습니다.');
|
|
} else {
|
|
$this->util->js_alert('DB error');
|
|
}
|
|
} else {
|
|
$this->util->js_alert('키값이 입력되지 않았습니다.');
|
|
}
|
|
} else {
|
|
$data = ['name' => $name,
|
|
'website' => $website];
|
|
$ret = $this->db->insert($this->tb_name_cartoonist,$data);
|
|
if($ret==TRUE) {
|
|
$this->util->js_alert_parent_reload('등록되었습니다.');
|
|
} else {
|
|
$this->util->js_alert('DB error');
|
|
}
|
|
}
|
|
} else {
|
|
$this->util->js_alert('카테고리 이름을 입력해 주십시오');
|
|
}
|
|
exit;
|
|
}
|
|
|
|
/*
|
|
@desc : delete cartoonist info
|
|
*/
|
|
public function fn_cartoonist_del_proc() {
|
|
$idx = $this->input->post('idx');
|
|
|
|
if(is_numeric($idx)==TRUE && $idx>0) {
|
|
$this->db->where('idx',$idx);
|
|
$ret = $this->db->delete($this->tb_name_cartoonist);
|
|
if($ret==TRUE) {
|
|
$this->db->where('mt_cartoonists_idx',$idx);
|
|
$data = ['mt_cartoonists_idx' => 0];
|
|
$ret = $this->db->update($this->tb_name_maptoon_list,$data);
|
|
//echo $this->db->last_query();
|
|
$this->util->js_alert_parent_reload('삭제되었습니다.');
|
|
}
|
|
} else {
|
|
$this->util->js_alert('키값이 전달되지 않았습니다.');
|
|
}
|
|
exit;
|
|
}
|
|
} |