first commit
This commit is contained in:
137
application/controllers/Channel.php
Executable file
137
application/controllers/Channel.php
Executable file
@@ -0,0 +1,137 @@
|
||||
<?php if (!defined('BASEPATH')) {
|
||||
exit('No direct script access allowed');
|
||||
}
|
||||
|
||||
class Channel extends MY_Controller
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
|
||||
public function index()
|
||||
{
|
||||
$totSegments = $this->uri->total_segments();
|
||||
if ($totSegments == 2) {
|
||||
$pageURL = $this->uri->segment($totSegments);
|
||||
$this->load->model('cmap_model');
|
||||
$this->data['viewType'] = 'list';
|
||||
$this->data['channelurl'] = '/channel/' . $pageURL . '/';
|
||||
$this->data['page'] = $this->page_model->getOne($pageURL);
|
||||
$this->data['deliveryCount'] = count($this->page_model->getPageDelivery($this->data['page']->pageID));
|
||||
$this->data['postsCount'] = $this->post_model->getCountPostsByPageId($this->data['page']->pageID);
|
||||
$this->data['posts'] = $this->post_model->getPostsByPageId($this->data['page']->pageID, 15)->get()->result();
|
||||
if ($this->data['page']->pageTemplate != "") {
|
||||
|
||||
$this->load->view('templates/channel/' . $this->data['page']->pageTemplate, $this->data);
|
||||
} else {
|
||||
$this->error();
|
||||
}
|
||||
} elseif (is_numeric($this->uri->segment($totSegments))) {
|
||||
$pageURL = $this->uri->segment($totSegments - 1);
|
||||
$articleURL = $this->uri->segment($totSegments);
|
||||
$this->data['viewType'] = 'article';
|
||||
$this->data['page'] = $this->page_model->getOne($pageURL);
|
||||
$this->data['post'] = $this->post_model->getPost($articleURL);
|
||||
if ($this->data['post']->postID != "") {
|
||||
$this->data['postsCount'] = $this->post_model->getCountPostsByPageId($this->data['page']->pageID);
|
||||
$this->data['video'] = $this->post_model->getPostVideo($this->data['post']->postID);
|
||||
$this->data['tag'] = $this->post_model->getPostTag($this->data['post']->postID);
|
||||
$this->load->view('templates/channel/channel', $this->data);
|
||||
} else {
|
||||
$this->error();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function category()
|
||||
{
|
||||
if (!$this->maintenanceMode) {
|
||||
$catSlug = $this->uri->segment(2);
|
||||
$this->data['page'] = $this->cmap_page_model->getCategory($catSlug);
|
||||
if ($this->data['page']['categoryID'] != "") {
|
||||
$this->data['header'] = $this->load->view('templates/header', $this->data, true);
|
||||
$this->data['footer'] = $this->load->view('templates/footer', '', true);
|
||||
$this->load->view('templates/category', $this->data);
|
||||
} else {
|
||||
$this->error();
|
||||
}
|
||||
} else {
|
||||
$this->maintenance();
|
||||
}
|
||||
}
|
||||
|
||||
public function prayer()
|
||||
{ }
|
||||
|
||||
public function channel()
|
||||
{
|
||||
if (!$this->maintenanceMode) {
|
||||
$totSegments = $this->uri->total_segments();
|
||||
if ($totSegments == 2) {
|
||||
$pageURL = $this->uri->segment($totSegments);
|
||||
$this->load->model('cmap_model');
|
||||
$this->data['viewType'] = 'list';
|
||||
$this->data['channelurl'] = '/channel/' . $pageURL . '/';
|
||||
$this->data['page'] = $this->cmap_page_model->getPage($pageURL);
|
||||
$this->data['deliveryCount'] = count($this->cmap_page_model->getPageDelivery($this->data['page']['pageID']));
|
||||
$this->data['posts'] = $this->cmap_model->getPostByPageId($this->data['page']['pageID']);
|
||||
if ($this->data['page']['pageTemplate'] != "") {
|
||||
$this->data['header'] = $this->load->view('templates/header', $this->data, true);
|
||||
$this->data['footer'] = $this->load->view('templates/footer', '', true);
|
||||
$this->load->view('templates/channel/' . $this->data['page']['pageTemplate'], $this->data);
|
||||
} else {
|
||||
$this->error();
|
||||
}
|
||||
} elseif (is_numeric($this->uri->segment($totSegments))) {
|
||||
$pageURL = $this->uri->segment($totSegments - 1);
|
||||
$articleURL = $this->uri->segment($totSegments);
|
||||
$this->data['viewType'] = 'article';
|
||||
$this->data['page'] = $this->cmap_page_model->getPage($pageURL);
|
||||
$this->data['post'] = $this->cmap_page_model->getArticle($articleURL);
|
||||
if ($this->data['post']['postID'] != "") {
|
||||
$this->data['header'] = $this->load->view('templates/header', $this->data, true);
|
||||
$this->data['footer'] = $this->load->view('templates/footer', '', true);
|
||||
$this->load->view('templates/channel/' . $this->data['page']['pageTemplate'], $this->data);
|
||||
} else {
|
||||
$this->error();
|
||||
}
|
||||
} else {
|
||||
$this->error();
|
||||
}
|
||||
} else {
|
||||
$this->maintenance();
|
||||
}
|
||||
}
|
||||
|
||||
public function article()
|
||||
{
|
||||
if (!$this->maintenanceMode) {
|
||||
$this->load->model('cmap_model');
|
||||
$articleURL = $this->uri->segment(2);
|
||||
$this->data['page'] = $this->cmap_page_model->getArticle($articleURL);
|
||||
if ($this->data['page']['postID'] != "") {
|
||||
$this->data['column'] = $this->cmap_page_model->getColumn();
|
||||
$this->data['focus'] = $this->cmap_model->getPosts(30, 0, 0, 10000, [$this->data['page']['postID']]);
|
||||
$this->data['page']['parentTitle'] = '';
|
||||
if ($this->data['page']['parentID'] != 0 && $this->data['page']['parentID'] % 10000 !== 0) {
|
||||
$parentCategory = $this->cmap_model->getCategory($this->data['page']['parentID']);
|
||||
if (count($parentCategory)) {
|
||||
$this->data['page']['parentTitle'] = $parentCategory[0]['categoryTitle'];
|
||||
}
|
||||
}
|
||||
$this->data['reporter'] = $this->cmap_page_model->getReporterByPostId($this->data['page']['postID']);
|
||||
$this->data['ranking'] = $this->cmap_page_model->getRankingByPostId($this->data['page']['postID']);
|
||||
|
||||
$this->data['header'] = $this->load->view('templates/header', $this->data, true);
|
||||
$this->data['footer'] = $this->load->view('templates/footer', '', true);
|
||||
$this->load->view('templates/article', $this->data);
|
||||
} else {
|
||||
$this->error();
|
||||
}
|
||||
} else {
|
||||
$this->maintenance();
|
||||
}
|
||||
}
|
||||
}
|
||||
37
application/controllers/Cmtv.php
Executable file
37
application/controllers/Cmtv.php
Executable file
@@ -0,0 +1,37 @@
|
||||
<?php if (!defined('BASEPATH')) {
|
||||
exit('No direct script access allowed');
|
||||
}
|
||||
|
||||
class Cmtv extends MY_Controller
|
||||
{
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
echo '<script>history.back()</script>';
|
||||
die('준비중입니다.');
|
||||
parent::__construct();
|
||||
$this->load->model('post_model', 'post');
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
$totSegments = $this->uri->total_segments();
|
||||
if (!is_numeric($this->uri->segment($totSegments))) {
|
||||
$pageURL = $this->uri->segment($totSegments);
|
||||
} elseif (is_numeric($this->uri->segment($totSegments))) {
|
||||
$pageURL = $this->uri->segment($totSegments - 1);
|
||||
}
|
||||
if ($pageURL == "") {
|
||||
$pageURL = "home";
|
||||
}
|
||||
$this->data['page'] = $this->page_model->getOne($pageURL);
|
||||
$this->data['postGroup'] = [];
|
||||
$recentUpdatedPosts = $this->db->where('categoryID', 30022)->get('cm_page_attributes')->result();
|
||||
foreach ($recentUpdatedPosts as $p) {
|
||||
array_push($this->data['postGroup'], $this->post->getPagePostsByPageId($p->pageID, 4));
|
||||
}
|
||||
$this->data['header'] = $this->load->view('templates/others/header', $this->data, true);
|
||||
$this->data['footer'] = $this->load->view('templates/others/footer', '', true);
|
||||
$this->load->view('templates/others/prayer', $this->data);
|
||||
}
|
||||
}
|
||||
121
application/controllers/Comment.php
Executable file
121
application/controllers/Comment.php
Executable file
@@ -0,0 +1,121 @@
|
||||
<?php
|
||||
|
||||
class Comment extends MY_Controller
|
||||
{
|
||||
private $policy;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->policy = [
|
||||
'anyone' => true
|
||||
];
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
if ($this->authorization()) {
|
||||
$this->load->model('comment_model');
|
||||
$this->{$this->uri->segment(2)}();
|
||||
} else {
|
||||
$this->response(array('code' => 405, 'error' => '로그인 하세요'));
|
||||
}
|
||||
}
|
||||
|
||||
private function authorization()
|
||||
{
|
||||
$resource = $this->uri->segment(2);
|
||||
$comment = $this->input->post('comment');
|
||||
if ($resource == 'new' || $resource == 'reply') {
|
||||
return (mb_strlen($comment, 'UTF-8') <= 10 && $this->policy['anyone']) || getSessionUser()->is;
|
||||
} else if ($resource == 'delete') {
|
||||
return getSessionUser()->is;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private function replies()
|
||||
{
|
||||
$commentId = $this->uri->segment(3);
|
||||
$replies = $this->comment_model->getRepliesByCommentId($commentId)
|
||||
->join('cm_user', 'cm_comment.userID=cm_user.userID', 'left')
|
||||
->select('*, 0 like, 0 bad, 0 replies')->get()->result();
|
||||
$this->comment_model->getRepliesAndRankings($replies);
|
||||
$this->response(array('code' => 200, 'replies' => $replies));
|
||||
}
|
||||
|
||||
private function new()
|
||||
{
|
||||
$data = [
|
||||
'postID' => $this->input->post('postId'),
|
||||
'userID' => getSessionUser()->is ? getSessionUser()->userID : 0,
|
||||
'comment' => $this->input->post('comment'),
|
||||
'datePosted' => date('Y-m-d H:i:s')
|
||||
];
|
||||
if ($insertId = $this->comment_model->save($data)) {
|
||||
$this->response(array('code' => 200, 'commentId' => $insertId, 'datePosted' => $data['datePosted'], 'nickname' => getSessionUser()->is ? getSessionUser()->userName : ''));
|
||||
} else {
|
||||
$this->response(array('code' => 500, 'error' => '서버오류가 발생했습니다'));
|
||||
}
|
||||
}
|
||||
|
||||
private function reply()
|
||||
{
|
||||
$data = [
|
||||
'postID' => $this->input->post('postId'),
|
||||
'userID' => getSessionUser()->is ? getSessionUser()->userID : 0,
|
||||
'parentID' => $this->input->post('parentId'),
|
||||
'comment' => $this->input->post('comment'),
|
||||
'datePosted' => date('Y-m-d H:i:s')
|
||||
];
|
||||
if ($insertId = $this->comment_model->save($data)) {
|
||||
$this->response(array('code' => 200, 'commentId' => $insertId, 'datePosted' => $data['datePosted'], 'nickname' => getSessionUser()->is ? getSessionUser()->userName : ''));
|
||||
} else {
|
||||
$this->response(array('code' => 500, 'error' => '서버오류가 발생했습니다'));
|
||||
}
|
||||
}
|
||||
|
||||
private function rating()
|
||||
{
|
||||
$data = [
|
||||
'userID' => getSessionUser()->is ? getSessionUser()->userID : 0,
|
||||
'commentID' => $this->input->post('commentId'),
|
||||
'title' => $this->input->post('title')
|
||||
];
|
||||
if ($this->comment_model->rating($data)) {
|
||||
$this->response(array('code' => 200, 'ranking' => $this->comment_model->getCountRatingByCommentIdAndTitle($data['commentID'], $data['title'])));
|
||||
} else {
|
||||
lq();
|
||||
$this->response(array('code' => 500, 'error' => '서버오류가 발생했습니다'));
|
||||
}
|
||||
}
|
||||
|
||||
private function delete()
|
||||
{
|
||||
if (getSessionUser()->userID == $this->comment_model->getOne($this->input->post('commentId'))->userID) {
|
||||
if ($this->comment_model->delete($this->input->post('commentId'))) {
|
||||
$this->response(array('code' => 200));
|
||||
} else {
|
||||
$this->response(array('code' => 500, 'error' => '서버오류가 발생했습니다'));
|
||||
}
|
||||
} else {
|
||||
$this->response(array('code' => 405, 'error' => '잘못된 요청입니다.'));
|
||||
}
|
||||
}
|
||||
|
||||
private function update()
|
||||
{
|
||||
if (getSessionUser()->userID == $this->comment_model->getOne($this->input->post('commentId'))->userID) {
|
||||
if ($this->comment_model->update([
|
||||
'commentID' => $this->input->post('commentID'),
|
||||
'comment' => $this->input->post('comment')
|
||||
])) {
|
||||
$this->response(array('code' => 200));
|
||||
} else {
|
||||
$this->response(array('code' => 500, 'error' => '서버오류가 발생했습니다'));
|
||||
}
|
||||
} else {
|
||||
$this->response(array('code' => 405, 'error' => '잘못된 요청입니다.'));
|
||||
}
|
||||
}
|
||||
}
|
||||
258
application/controllers/Grace.php
Executable file
258
application/controllers/Grace.php
Executable file
@@ -0,0 +1,258 @@
|
||||
<?php if (!defined('BASEPATH')) {
|
||||
exit('No direct script access allowed');
|
||||
}
|
||||
|
||||
class Grace extends MY_Controller
|
||||
{
|
||||
private $sections;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->load->model('post_model', 'post');
|
||||
$this->load->model('comment_model', 'comment');
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
if ($this->isMobile()) {
|
||||
$this->mobile();
|
||||
} else {
|
||||
$this->desktop();
|
||||
}
|
||||
}
|
||||
|
||||
private function desktop()
|
||||
{
|
||||
$section = $this->uri->segment(2);
|
||||
$article = $this->uri->segment(3);
|
||||
$this->data['sectionCategory'] = NEWS_SECTION_CATEGORY;
|
||||
if (is_numeric($article)) {
|
||||
$this->article($article);
|
||||
$this->load->view('templates/grace/grace-article', $this->data);
|
||||
} elseif ($section) {
|
||||
$this->section();
|
||||
$this->load->view('templates/grace/grace-section', $this->data);
|
||||
} else {
|
||||
$this->main();
|
||||
$this->load->view('templates/grace/grace-home', $this->data);
|
||||
}
|
||||
}
|
||||
|
||||
private function mobile()
|
||||
{
|
||||
$section = $this->uri->segment(2);
|
||||
$article = $this->uri->segment(3);
|
||||
if (is_numeric($article)) {
|
||||
$this->load->view('mobile/grace/grace-article', $this->data);
|
||||
} else if ($article) {
|
||||
$this->load->view('mobile/grace/grace-editor', $this->data);
|
||||
} elseif ($section) {
|
||||
$this->load->view('mobile/grace/grace-section', $this->data);
|
||||
} else {
|
||||
$this->load->view('mobile/grace/grace-home', $this->data);
|
||||
}
|
||||
}
|
||||
|
||||
private function main()
|
||||
{
|
||||
$this->data['featured'] = $this->post->getPagePostsByCategoryId(getChildrenByParentId(30000), 5)
|
||||
->join('cm_user u', 'p.userID=u.userID', 'left')->where('img !=', '')
|
||||
->order_by('p.dateUpdated', 'desc')->group_by('pp.pageID')
|
||||
->get()->result();
|
||||
$this->getLink($this->data['featured']);
|
||||
$this->setSections();
|
||||
foreach ($this->sections as $k => $s) {
|
||||
if($k == 'search') continue;
|
||||
$this->data[$k] = $this->sections[$k][2]()
|
||||
->join('cm_user u', 'p.userID=u.userID', 'left')
|
||||
->join('cm_page_attributes pa', 'pp.pageID=pa.pageID', 'left')
|
||||
->join('cm_page_content pcn', 'pp.pageID=pcn.pageID', 'left')
|
||||
->select('p.*')
|
||||
->select('if(pa.pageIcon is null, if(pcn.img is null, if(u.profile_img is null, p.postImage, u.profile_img), pcn.img), pa.pageIcon) pageIcon')
|
||||
->select('0 likes, 0 views, 0 comments')
|
||||
->select("if(u.nickname = '' or u.nickname is null, u.userName, u.nickName) as author")
|
||||
->group_by('p.postID')
|
||||
->get()->result();
|
||||
$this->getLink($this->data[$k]);
|
||||
}
|
||||
foreach ($this->data as $k => $v) {
|
||||
getPostsImageUrl($this->data[$k]);
|
||||
}
|
||||
}
|
||||
|
||||
private function setSections()
|
||||
{
|
||||
// 은혜충전(구 라이프)의 해당 카테고리의 최신 글 테그
|
||||
// 은혜충전(구 라이프)의 해당 카테고리의 업데이트 순과 좋아요순
|
||||
// 페이징처리
|
||||
|
||||
$this->sections = [
|
||||
'storyqt' => [[30005, 30008], function () {
|
||||
return $this->post->getCountPostsByPageIdAndCategoryId($this->sections['storyqt'][0][0], $this->sections['storyqt'][0][1]);
|
||||
}, function () {
|
||||
return $this->post->getPostsByPageIdAndCategoryId($this->sections['storyqt'][0][0], $this->sections['storyqt'][0][1], 20);
|
||||
}],
|
||||
'wordcard' => [[30003, 30005], function () {
|
||||
return $this->post->getCountPostsByPageId($this->sections['wordcard'][0]);
|
||||
}, function () {
|
||||
return $this->post->getPostsByPageId($this->sections['wordcard'][0], 20);
|
||||
}],
|
||||
'english' => [[30005, 30008], function () {
|
||||
return $this->post->getCountPostsByPageIdAndCategoryId($this->sections['english'][0][0], $this->sections['english'][0][1]);
|
||||
}, function () {
|
||||
return $this->post->getPostsByPageIdAndCategoryId($this->sections['english'][0][0], $this->sections['english'][0][1], 20);
|
||||
}],
|
||||
'videoqt' => [null, function () {
|
||||
return $this->post->getPostQuery()->join('cm_post_video v', 'p.postID=v.postID', 'inner')->count_all_results();
|
||||
}, function () {
|
||||
return $this->post->getPostQuery()->join('cm_post_video v', 'p.postID=v.postID', 'inner')->limit(20);
|
||||
}],
|
||||
'cpost' => [[30006, 30008], function () {
|
||||
return $this->post->getCountPostsByPageId($this->sections['cpost'][0]);
|
||||
}, function () {
|
||||
return $this->post_model->getPostsByPageId($this->sections['cpost'][0], 20);
|
||||
}],
|
||||
'poem' => [[30043], function () {
|
||||
return $this->post->getCountPostsByPageId($this->sections['poem'][0]);
|
||||
}, function () {
|
||||
return $this->post_model->getPostsByPageId($this->sections['poem'][0], 20);
|
||||
}],
|
||||
'popular' => [[30043], function () {
|
||||
return $this->post->getCountPostsByPageId($this->sections['poem'][0]);
|
||||
}, function () {
|
||||
return $this->post_model->getPostsByPageId($this->sections['poem'][0], 20);
|
||||
}],
|
||||
'tagFeatured' => [[30043], function () {
|
||||
return $this->post->getCountPostsByPageId($this->sections['poem'][0]);
|
||||
}, function () {
|
||||
return $this->post_model->getPostQuery()->join('cm_post_tag t', 'p.postID=t.postID', 'left');
|
||||
}],
|
||||
'search' => [[30043], function () {
|
||||
$this->load->library('search');
|
||||
return $this->search->searchByPostTitle($this->input->get('keyword'), 20, [], true)->count_all_results();
|
||||
}, function () {
|
||||
$this->load->library('search');
|
||||
return $this->search->searchByPostTitle($this->input->get('keyword'), 20, [], true)
|
||||
->join('cm_post_page pp', 'p.postID=pp.postID', 'left')->limit(20);
|
||||
}]
|
||||
];
|
||||
}
|
||||
|
||||
private function section()
|
||||
{
|
||||
$this->setSections();
|
||||
$this->load->library('pagination');
|
||||
$this->data['totalRows'] = $this->sections[$this->uri->segment(2)][1]();
|
||||
$this->pagination->initialize([
|
||||
'base_url' => BASE_URL . '/grace/' . $this->uri->segment(2),
|
||||
'total_rows' => $this->data['totalRows'],
|
||||
'per_page' => 20,
|
||||
'full_tag_open' => '',
|
||||
'full_tag_close' => '',
|
||||
'num_tag_open' => '',
|
||||
'num_tag_close' => '',
|
||||
'cur_tag_open' => '<a class="current">',
|
||||
'cur_tag_close' => '</a>',
|
||||
'next_tag_open' => '',
|
||||
'next_tag_close' => '',
|
||||
'prev_tag_open' => '',
|
||||
'prev_tag_close' => '',
|
||||
'next_link' => '',
|
||||
'prev_link' => '',
|
||||
'last_link' => '<img src="' . THEME_FOLDER . '/img/mypage_arrow_right.gif">',
|
||||
'first_link' => '<img src="' . THEME_FOLDER . '/img/mypage_arrow_left.gif">',
|
||||
'prefix' => 'page-',
|
||||
'suffix' => $this->input->get('keyword') ? '?keyword='. $this->input->get('keyword') :''
|
||||
]);
|
||||
$countQuery = $this->db->last_query();
|
||||
$this->data['posts'] = $this->sections[$this->uri->segment(2)][2]()->offset(
|
||||
$this->uri->segment(3) ? str_replace('page-', '', $this->uri->segment(3)) : 0
|
||||
)->join('cm_user u', 'p.userID=u.userID', 'left')
|
||||
->join('cm_page_attributes pa', 'pp.pageID=pa.pageID', 'left')
|
||||
->join('cm_page_content pcn', 'pp.pageID=pcn.pageID', 'left')
|
||||
->select('p.*, if(pa.pageIcon is null, if(pcn.img is null, if(u.profile_img is null, p.postImage, u.profile_img), pcn.img), pa.pageIcon) pageIcon, 0 likes, 0 views, 0 comments, u.userName')->get()->result();
|
||||
|
||||
$sqlSegments = explode('WHERE', explode('FROM', $countQuery)[1]);
|
||||
$tags = $this->db->query('select t.tag from ' . $sqlSegments[0] . ($this->uri->segment(2) == 'search' ? ' ':' inner join cm_post_tag t on p.postID=t.postID ') . (isset($sqlSegments[1]) ? 'where ' . $sqlSegments[1] : '') . ' order by p.dateUpdated desc')->result();
|
||||
// $this->sections[$this->uri->segment(2)][2]()->join('cm_post_tag t', 'p.postID=t.postID', 'inner');
|
||||
$this->data['tags'] = [];
|
||||
foreach ($tags as $t) {
|
||||
$this->data['tags'] = array_merge($this->data['tags'], explode(strpos($t->tag, ',')? ',': ' ', $t->tag));
|
||||
}
|
||||
|
||||
if(count($this->data['posts'])) {
|
||||
array_map(function ($c) {
|
||||
foreach ($this->data['posts'] as $k => $v) {
|
||||
if ($v->postID == $c->postID) {
|
||||
$this->data['posts'][$k]->comments = $c->cnt;
|
||||
}
|
||||
}
|
||||
}, $this->comment->getCountByPostId(array_column($this->data['posts'], 'postID'))->get()->result());
|
||||
array_map(function ($c) {
|
||||
foreach ($this->data['posts'] as $k => $v) {
|
||||
if ($v->postID == $c->postID) {
|
||||
if ($c->title == 'L') {
|
||||
$this->data['posts'][$k]->likes = $c->rating;
|
||||
} else {
|
||||
$this->data['posts'][$k]->views = $c->rating;
|
||||
}
|
||||
}
|
||||
}
|
||||
}, $this->post->getPostsRankingByPostId(array_column($this->data['posts'], 'postID'))->get()->result());
|
||||
}
|
||||
$this->data['tags'] = array_unique($this->data['tags']);
|
||||
$this->getLink($this->data['posts']);
|
||||
}
|
||||
|
||||
private function article($article)
|
||||
{
|
||||
$this->load->model('comment_model');
|
||||
$section = $this->uri->segment(2);
|
||||
|
||||
$this->data['comments'] = $this->comment_model->getByPostId($article)
|
||||
->where('parentID', 0)
|
||||
->join('cm_user', 'cm_comment.userID=cm_user.userID', 'left')
|
||||
->select('*, 0 like, 0 bad, 0 replies')->get()->result();
|
||||
|
||||
$this->comment_model->getRepliesAndRankings($this->data['comments']);
|
||||
|
||||
$this->data['post'] = $this->post->getPostQuery()->join('cm_user u', 'p.userID=u.userID', 'left')
|
||||
->join('cm_page_attributes pa', 'pp.pageID=pa.pageID', 'left')
|
||||
->join('cm_page_content pcn', 'pp.pageID=pcn.pageID', 'left')
|
||||
->where('p.postID', $this->uri->segment(3))->get()->row();
|
||||
$this->data['video'] = $this->post->getPostVideo($this->data['post']->postID);
|
||||
|
||||
|
||||
$this->setSections();
|
||||
foreach ($this->sections as $k => $s) {
|
||||
if($k == 'search') continue;
|
||||
$this->data[$k] = $this->sections[$k][2]()
|
||||
->join('cm_user u', 'p.userID=u.userID', 'left')
|
||||
->join('cm_page_attributes pa', 'pp.pageID=pa.pageID', 'left')
|
||||
->join('cm_page_content pcn', 'pp.pageID=pcn.pageID', 'left')
|
||||
->select('p.*')
|
||||
->select('if(pa.pageIcon is null, if(pcn.img is null, if(u.profile_img is null, p.postImage, u.profile_img), pcn.img), pa.pageIcon) pageIcon')
|
||||
->select('0 likes, 0 views, 0 comments')
|
||||
->select("if(u.nickname = '' or u.nickname is null, u.userName, u.nickName) as author")
|
||||
->group_by('p.postID')
|
||||
->get()->result();
|
||||
$this->getLink($this->data[$k]);
|
||||
}
|
||||
$this->load->library('search');
|
||||
$this->data['related'] = $this->search->searchByPostTitle($this->data['post']->postTitle, 12, [$this->data['post']->postID], true)
|
||||
->join('cm_user u', 'cm_post.userID=u.userID', 'left')
|
||||
->select("*,if(u.nickname = '' or u.nickname is null, u.userName, u.nickName) as author")->get()->result();
|
||||
$this->getLink($this->data['related']);
|
||||
foreach ($this->data as $k => $v) {
|
||||
getPostsImageUrl($this->data[$k]);
|
||||
}
|
||||
}
|
||||
|
||||
private function getLink(&$rows)
|
||||
{
|
||||
array_walk($rows, function (&$r) {
|
||||
$r->articleURL = '/grace/' . ($this->uri->segment(2) ? $this->uri->segment(2) : 'cpost') . '/' . $r->postID;
|
||||
});
|
||||
}
|
||||
}
|
||||
73
application/controllers/Home.php
Executable file
73
application/controllers/Home.php
Executable file
@@ -0,0 +1,73 @@
|
||||
<?php if (!defined('BASEPATH')) {
|
||||
exit('No direct script access allowed');
|
||||
}
|
||||
|
||||
class Home extends MY_Controller
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
|
||||
public function index()
|
||||
{
|
||||
$this->load->model('post_model');
|
||||
$this->load->library('Cacher');
|
||||
$this->main();
|
||||
}
|
||||
|
||||
private function main()
|
||||
{
|
||||
if ($this->isMobile()) {
|
||||
$this->mobile();
|
||||
} else {
|
||||
$this->data['header'] = $this->load->view('templates/others/header', $this->data, true);
|
||||
$this->data['footer'] = $this->load->view('templates/others/footer', '', true);
|
||||
$this->desktop();
|
||||
}
|
||||
}
|
||||
|
||||
private function desktop()
|
||||
{
|
||||
$this->data['webtoons'] = $this->post_model->getPostsByCategoryId(getChildrenByParentId(20000), 6)->get()->result();
|
||||
$this->data['storyqt'] = $this->post_model->getPostsByPageIdAndCategoryId(30005, 30008, 6)->get()->result();
|
||||
$this->data['engMedi'] = $this->post_model->getPostsByPageIdAndCategoryId(30007, 30010, 6)->get()->result();
|
||||
$this->data['mchart'] = array_slice($this->cacher->melon(), 0, 7);
|
||||
$this->data['articles'] = getNewsArticleURL($this->post_model->getPostsByCategoryId(getChildrenByParentId(10000), 20)->get()->result());
|
||||
$this->data['dailyqt'] = $this->post_model->getPostsByPageId(30048, 2)->get()->result();
|
||||
$this->data['dailyword'] = $this->post_model->getPostsByCategoryId(37000, 1)->get()->row();
|
||||
$this->data['talkshow'] = $this->post_model->getPostsByPageId(30045, 7)->get()->result();
|
||||
$this->data['testimony'] = $this->post_model->getPostsByPageId(30044, 7)->get()->result();
|
||||
$this->data['sermon'] = $this->post_model->getPostsByPageId(30042, 7)->get()->result();
|
||||
$this->data['worship'] = $this->post_model->getPostsByPageId(30043, 7)->get()->result();
|
||||
$this->data['letter'] = $this->post_model->getPostsByPageId([30003, 30005], 27)->get()->result(); // 3, 5
|
||||
$this->data['pray'] = $this->post_model->getPostsByPageId(30009, 27)->get()->result(); // 9
|
||||
$this->data['book'] = $this->post_model->getPostsByPageId([30017, 30026], 27)->get()->result(); // 17, 26
|
||||
$this->data['meditate'] = $this->post_model->getPostsByPageId([30006, 30008], 27)->get()->result(); // 8, 6
|
||||
|
||||
|
||||
// ['webtoons','storyqt','engMedi','mchart','articles','dailyqt','dailyword','talkshow','testimony','sermon','worship','letter','pray', 'book', 'meditate']
|
||||
|
||||
foreach($this->data as $k=>$v) {
|
||||
getPostsImageUrl($this->data[$k]);
|
||||
}
|
||||
|
||||
$this->load->view('templates/others/home', $this->data);
|
||||
}
|
||||
|
||||
private function mobile()
|
||||
{
|
||||
$this->data['storyqt'] = $this->post_model->getPostsByPageIdAndCategoryId(30005, 30008, 6)->get()->result();
|
||||
$this->data['featureToons'] = $this->post_model->getPostsRankingByRankTypeAndCategoryId('R', 20008, 4)
|
||||
->join('cm_page_content co', 'pp.pageID=co.pageID', 'left')->get()->result();
|
||||
getResultWithAuthor($this->data['featureToons']);
|
||||
$this->data['talkshow'] = $this->post_model->getPostsByPageId(30045, 5)->get()->result();
|
||||
$this->data['testimony'] = $this->post_model->getPostsByPageId(30044, 5)->get()->result();
|
||||
$this->data['sermon'] = $this->post_model->getPostsByPageId(30042, 5)->get()->result();
|
||||
$this->data['worship'] = $this->post_model->getPostsByPageId(30043, 5)->get()->result();
|
||||
$this->data['articles'] = getNewsArticleURL($this->post_model->getPostsByCategoryId(getChildrenByParentId(10000), 8)->get()->result());
|
||||
$this->data['columns'] = getNewsArticleURL($this->post_model->getPostsByCategoryId(getChildrenByParentId(30011), 4)->get()->result());
|
||||
$this->load->view('mobile/home', $this->data);
|
||||
}
|
||||
}
|
||||
15
application/controllers/Kids.php
Executable file
15
application/controllers/Kids.php
Executable file
@@ -0,0 +1,15 @@
|
||||
<?php if (!defined('BASEPATH')) {
|
||||
exit('No direct script access allowed');
|
||||
}
|
||||
|
||||
class Kids extends MY_Controller
|
||||
{
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
public function index()
|
||||
{ }
|
||||
}
|
||||
28
application/controllers/Mypage.php
Executable file
28
application/controllers/Mypage.php
Executable file
@@ -0,0 +1,28 @@
|
||||
<?php if (!defined('BASEPATH')) {
|
||||
exit('No direct script access allowed');
|
||||
}
|
||||
|
||||
|
||||
class Mypage extends MY_Controller
|
||||
{
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
if(!getSessionUser()->is) {
|
||||
header('location:/');
|
||||
}
|
||||
}
|
||||
|
||||
public function index() {
|
||||
$this->bookmark();
|
||||
}
|
||||
|
||||
public function bookmark() {
|
||||
$this->load->view('templates/mypage/mypage-bookmark');
|
||||
}
|
||||
|
||||
public function qna() {
|
||||
$this->load->view('templates/mypage/mypage-qna');
|
||||
}
|
||||
}
|
||||
233
application/controllers/News.php
Executable file
233
application/controllers/News.php
Executable file
@@ -0,0 +1,233 @@
|
||||
<?php if (!defined('BASEPATH')) {
|
||||
exit('No direct script access allowed');
|
||||
}
|
||||
|
||||
class News extends MY_Controller
|
||||
{
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
if ($this->isMobile()) {
|
||||
$this->mobile();
|
||||
} else {
|
||||
$this->desktop();
|
||||
}
|
||||
}
|
||||
|
||||
private function desktop()
|
||||
{
|
||||
$section = $this->uri->segment(2);
|
||||
$article = $this->uri->segment(3);
|
||||
$this->data['sectionCategory'] = NEWS_SECTION_CATEGORY;
|
||||
if (is_numeric($article)) {
|
||||
$this->article($article);
|
||||
$this->load->view('templates/news/news-article', $this->data);
|
||||
} elseif ($section) {
|
||||
$this->section();
|
||||
$this->load->view('templates/news/news-section', $this->data);
|
||||
} else {
|
||||
$this->main();
|
||||
$this->load->view('templates/news/news-home', $this->data);
|
||||
}
|
||||
}
|
||||
|
||||
private function mobile()
|
||||
{
|
||||
$section = $this->uri->segment(2);
|
||||
$article = $this->uri->segment(3);
|
||||
$this->data['sectionCategory'] = NEWS_SECTION_CATEGORY;
|
||||
if (is_numeric($article)) {
|
||||
$this->article($article);
|
||||
$this->load->view('mobile/news/news-article', $this->data);
|
||||
} elseif ($section) {
|
||||
list($section, $children) = $this->getSectionSegments();
|
||||
$this->data['posts'] = $this->getSectionPosts($children, 26);
|
||||
getNewsArticleURL($this->data['posts'], $section);
|
||||
$this->load->library('search');
|
||||
$this->data['relatedNews'] = $this->search->searchByPostTitle($this->data['posts'][0]->postTitle, 2, [$this->data['posts'][0]->postSeq]);
|
||||
getNewsArticleURL($this->data['relatedNews'], $section);
|
||||
$this->data['hotNews'] = getNewsArticleURL($this->post_model->getPostsRankingByRankTypeAndCategoryId('V', $children, 27)->get()->result());
|
||||
$this->data['photoNews'] = $this->post_model->getPostsRankingByRankTypeAndCategoryId('V', 30024, 3)->get()->result();
|
||||
$this->load->view('mobile/news/news-section', $this->data);
|
||||
} else {
|
||||
$this->main();
|
||||
$this->load->view('mobile/news/news-home', $this->data);
|
||||
}
|
||||
}
|
||||
|
||||
public function main()
|
||||
{
|
||||
$this->data['posts'] = [];
|
||||
$this->data['sortByPosted'] = [];
|
||||
$this->load->model('category_model');
|
||||
$this->load->model('post_model');
|
||||
|
||||
$sectionCategories = $this->category_model->getAll(array_values(NEWS_SECTION_CATEGORY));
|
||||
foreach (NEWS_SECTION_CATEGORY as $sn => $sc) {
|
||||
$children = getChildrenByParentId($sc);
|
||||
$this->data['posts'][$sn] = $this->post_model->getPostsByCategoryId($children, 7)->get()->result();
|
||||
$contentSection = ($sn == 'opinions' ? 'channel' : 'news');
|
||||
$sectionCategory = ['title' => '', 'id' => 0];
|
||||
foreach ($sectionCategories as $s) {
|
||||
if ($s->categoryID == $sc) {
|
||||
$sectionCategory['title'] = $s->categoryTitle;
|
||||
$sectionCategory['id'] = $s->categoryID;
|
||||
}
|
||||
}
|
||||
foreach ($this->data['posts'][$sn] as $post) {
|
||||
$post->sectionCategory = $sectionCategory;
|
||||
$post->articleURL = '/' . $contentSection . '/' . ($sn == 'opinions' ? $post->pageID : $sn) . '/' . $post->postSeq;
|
||||
!count($this->data['sortByPosted']) ? (function () use ($post) {
|
||||
array_push($this->data['sortByPosted'], $post);
|
||||
})() : (function () use ($post) {
|
||||
array_push($this->data['sortByPosted'], $post);
|
||||
if (strtotime($post->datePosted) > strtotime($this->data['sortByPosted'][0]->datePosted)) {
|
||||
$l = array_shift($this->data['sortByPosted']);
|
||||
array_push($this->data['sortByPosted'], $l);
|
||||
}
|
||||
})();
|
||||
}
|
||||
}
|
||||
$this->data['hotNews'] = getNewsArticleURL($this->post_model->getPostsRankingByRankTypeAndCategoryId(
|
||||
'V',
|
||||
getChildrenByParentId(10000),
|
||||
27
|
||||
)->get()->result());
|
||||
$this->data['photoNews'] = $this->post_model->getPostsRankingByRankTypeAndCategoryId('V', 30024, 3)->get()->result();
|
||||
$this->data['prayNews'] = $this->post_model->getPostsByPageId(30009, 4)->get()->result();
|
||||
foreach ($this->data as $k => $v) {
|
||||
getPostsImageUrl($this->data[$k]);
|
||||
}
|
||||
}
|
||||
|
||||
public function section()
|
||||
{
|
||||
list($section, $children) = $this->getSectionSegments();
|
||||
$this->pagination->initialize([
|
||||
'base_url' => BASE_URL . '/news/' . $section,
|
||||
'total_rows' => $this->post_model->getCountPostsByCategoryId($children),
|
||||
'per_page' => 10,
|
||||
'full_tag_open' => '',
|
||||
'full_tag_close' => '',
|
||||
'num_tag_open' => '',
|
||||
'num_tag_close' => '',
|
||||
'cur_tag_open' => '<a class="current">',
|
||||
'cur_tag_close' => '</a>',
|
||||
'next_tag_open' => '',
|
||||
'next_tag_close' => '',
|
||||
'prev_tag_open' => '',
|
||||
'prev_tag_close' => '',
|
||||
'next_link' => '',
|
||||
'prev_link' => '',
|
||||
'last_link' => '<img src="' . THEME_FOLDER . '/img/mypage_arrow_right.gif">',
|
||||
'first_link' => '<img src="' . THEME_FOLDER . '/img/mypage_arrow_left.gif">',
|
||||
'prefix' => 'page-'
|
||||
]);
|
||||
$this->data['posts'] = $this->getSectionPosts($children, 17);
|
||||
getNewsArticleURL($this->data['posts'], $section);
|
||||
$this->data['sortByPosted'] = [];
|
||||
array_push($this->data['sortByPosted'], $this->data['posts'][0]);
|
||||
$this->data['sortByPosted'] = array_merge($this->data['sortByPosted'], array_slice($this->data['posts'], 3, 6));
|
||||
$this->data['posts1'] = array_slice($this->data['posts'], 1, 3);
|
||||
$this->data['posts2'] = array_slice($this->data['posts'], 9);
|
||||
$this->data['posts'] = array_merge($this->data['posts1'], $this->data['posts2']);
|
||||
unset($this->data['posts1'], $this->data['posts2']);
|
||||
$this->data['hotNews'] = getNewsArticleURL($this->post_model->getPostsRankingByRankTypeAndCategoryId('V', $children, 27)->get()->result());
|
||||
$this->data['photoNews'] = $this->post_model->getPostsRankingByRankTypeAndCategoryId('V', 30024, 3)->get()->result();
|
||||
$this->data['prayNews'] = $this->post_model->getPostsByPageId(30009, 4)->get()->result();
|
||||
foreach ($this->data as $k => $v) {
|
||||
getPostsImageUrl($this->data[$k]);
|
||||
}
|
||||
}
|
||||
|
||||
private function getSectionSegments()
|
||||
{
|
||||
$this->load->model('post_model');
|
||||
$section = $this->uri->segment(2);
|
||||
$this->load->library('pagination');
|
||||
$children = getChildrenByParentId(NEWS_SECTION_CATEGORY[$section]);
|
||||
array_push($children, NEWS_SECTION_CATEGORY[$section]);
|
||||
return [$section, $children];
|
||||
}
|
||||
|
||||
private function getSectionPosts($children, $rowCount)
|
||||
{
|
||||
return $this->post_model->getPostsByCategoryId($children, $rowCount, ($this->uri->segment(3) ? substr($this->uri->segment(3), 5) : 0))->get()->result();
|
||||
}
|
||||
|
||||
public function article($article)
|
||||
{
|
||||
$this->load->model('comment_model');
|
||||
$section = $this->uri->segment(2);
|
||||
|
||||
$this->data['comments'] = $this->comment_model->getByPostId($article)
|
||||
->where('parentID', 0)
|
||||
->join('cm_user', 'cm_comment.userID=cm_user.userID', 'left')
|
||||
->select('*, 0 like, 0 bad, 0 replies')->get()->result();
|
||||
|
||||
$this->comment_model->getRepliesAndRankings($this->data['comments']);
|
||||
|
||||
|
||||
$this->data['page'] = $this->post_model->getPost($article);
|
||||
$this->data['column'] = $this->getColumn();
|
||||
// $this->data['focus'] = $this->post_model->getPostsByPageId(30, 0, 0, 10000, [$this->data['page']['postID']]);
|
||||
$this->data['page']->parentTitle = '';
|
||||
if ($this->data['page']->parentID != 0 && $this->data['page']->parentID % 10000 !== 0) {
|
||||
$parentCategory = $this->category_model->getOne($this->data['page']->parentID);
|
||||
if ($parentCategory) {
|
||||
$this->data['page']->parentTitle = $parentCategory->categoryTitle;
|
||||
}
|
||||
}
|
||||
$this->data['reporter'] = $this->getReporterByUserId($this->data['page']->userID);
|
||||
$this->data['ranking'] = $this->getRankingByPostId($this->data['page']->postSeq);
|
||||
|
||||
$this->data['hotNews'] = getNewsArticleURL($this->post_model->getPostsRankingByRankTypeAndCategoryId('V', getChildrenByParentId(NEWS_SECTION_CATEGORY[$section]), 27)->get()->result());
|
||||
|
||||
$this->data['photoNews'] = $this->post_model
|
||||
->getPostsRankingByRankTypeAndCategoryId('V', 30024, 3)->get()->result();
|
||||
$this->data['prayNews'] = $this->post_model->getPostsByPageId(30009, 4)->get()->result();
|
||||
$this->load->library('search');
|
||||
$this->data['relatedNews'] = $this->search->searchByPostTitle($this->data['page']->postTitle, 5, [$this->data['page']->postSeq]);
|
||||
getNewsArticleURL($this->data['relatedNews'], $section);
|
||||
foreach ($this->data as $k => $v) {
|
||||
getPostsImageUrl($this->data[$k]);
|
||||
}
|
||||
}
|
||||
|
||||
private function getColumn($limit = 2, $offset = 0)
|
||||
{
|
||||
return $this->db->limit($limit)->join('cm_user u', 'u.userID = p.userID', 'left')
|
||||
->join('cm_user_group g', 'u.groupID = g.groupID', 'left')->where('g.groupID', 7)
|
||||
->order_by('datePosted', 'desc')->get('cm_post p')->result();
|
||||
}
|
||||
|
||||
private function getReporterByUserId($userID)
|
||||
{
|
||||
return $this->db->from('cm_user u')
|
||||
->join('cm_user_press up', 'u.userID=up.userID', 'left')
|
||||
->join('cm_press p', 'up.pressID=p.pressID', 'left')
|
||||
->where('u.userID', $userID)
|
||||
->select('u.*, p.press_name, p.logo_img, p.homepage')
|
||||
->get()->row();
|
||||
}
|
||||
|
||||
public function getRankingByPostId($postId)
|
||||
{
|
||||
$ranking = ['V' => 0, 'R' => 0, 'L' => 0];
|
||||
$rows = $this->db->where('postID', $postId)
|
||||
->get('cm_post_ranking')->result();
|
||||
foreach ($rows as $row) {
|
||||
foreach ($ranking as $k => $r) {
|
||||
if ($row->title == $k) {
|
||||
$ranking[$k] = $row->rating;
|
||||
}
|
||||
}
|
||||
}
|
||||
return $ranking;
|
||||
}
|
||||
}
|
||||
169
application/controllers/Pray.php
Executable file
169
application/controllers/Pray.php
Executable file
@@ -0,0 +1,169 @@
|
||||
<?php if (!defined('BASEPATH')) {
|
||||
exit('No direct script access allowed');
|
||||
}
|
||||
|
||||
class Pray extends MY_Controller
|
||||
{
|
||||
private $sections;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->load->model('pray_model');
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
if ($this->isMobile()) {
|
||||
$this->mobile();
|
||||
} else {
|
||||
$this->desktop();
|
||||
}
|
||||
}
|
||||
|
||||
private function desktop()
|
||||
{
|
||||
$section = $this->uri->segment(2);
|
||||
$article = $this->uri->segment(3);
|
||||
$this->data['sectionCategory'] = NEWS_SECTION_CATEGORY;
|
||||
if (is_numeric($article)) {
|
||||
$this->article($article);
|
||||
$this->load->view('templates/pray/pray-article', $this->data);
|
||||
} elseif ($section) {
|
||||
if ($this->section()) {
|
||||
$this->load->view('templates/pray/pray-' . $section, $this->data);
|
||||
} else {
|
||||
$this->{$section}();
|
||||
}
|
||||
} else {
|
||||
$this->main();
|
||||
$this->load->view('templates/pray/pray-home', $this->data);
|
||||
}
|
||||
}
|
||||
|
||||
private function mobile()
|
||||
{
|
||||
$section = $this->uri->segment(2);
|
||||
$article = $this->uri->segment(3);
|
||||
if (is_numeric($article)) {
|
||||
$this->load->view('mobile/pray/pray-article', $this->data);
|
||||
} else if ($article) {
|
||||
$this->load->view('mobile/pray/pray-editor', $this->data);
|
||||
} elseif ($section) {
|
||||
$this->load->view('mobile/pray/pray-section', $this->data);
|
||||
} else {
|
||||
$this->load->view('mobile/pray/pray-home', $this->data);
|
||||
}
|
||||
}
|
||||
|
||||
private function main()
|
||||
{
|
||||
$this->setSections();
|
||||
$this->data['prayon'] = $this->pray_model->getPaging(15, 0)
|
||||
->get()->result();
|
||||
$this->data['posts'] = $this->post_model->getPostsByCategoryId(
|
||||
array_column($this->category_model->getCategoriesBySlug([
|
||||
'vclip', 'together', 'story', 'art'
|
||||
])->get()->result(), 'categoryID'),
|
||||
5
|
||||
)->get()->result();
|
||||
$this->data['featured'] = $this->data['posts'][0];
|
||||
foreach ($this->data as $k => $v) {
|
||||
getPostsImageUrl($this->data[$k]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private function getCategoryIdBySlug($slug)
|
||||
{
|
||||
return $this->category_model->getCategoriesBySlug($slug)->get()->row()->categoryID;
|
||||
}
|
||||
|
||||
private function getPostsByCategorySlug($slug)
|
||||
{
|
||||
return $this->post_model->getPostsByCategoryId($this->getCategoryIdBySlug($slug), 20);
|
||||
}
|
||||
|
||||
private function section()
|
||||
{
|
||||
$this->setSections();
|
||||
foreach ($this->data as $k => $v) {
|
||||
getPostsImageUrl($this->data[$k]);
|
||||
}
|
||||
if (isset($this->sections[$this->uri->segment(2)])) {
|
||||
$this->data['posts'] = &$this->data[$this->uri->segment(2)];
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
private function article($article)
|
||||
{
|
||||
$this->load->model('comment_model');
|
||||
$this->data['comments'] = $this->comment_model->getByPostId($article)
|
||||
->where('parentID', 0)
|
||||
->join('cm_user', 'cm_comment.userID=cm_user.userID', 'left')
|
||||
->select('*, 0 like, 0 bad, 0 replies')->get()->result();
|
||||
$this->comment_model->getRepliesAndRankings($this->data['comments']);
|
||||
$this->data['post'] = $this->post_model->getPost($article);
|
||||
foreach ($this->data as $k => $v) {
|
||||
getPostsImageUrl($this->data[$k]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private function setSections()
|
||||
{
|
||||
$this->sections = [
|
||||
'prayon' => ['', function () {
|
||||
$this->data['prayon'] = array_reverse($this->pray_model->getPaging(15, 0)->select('py.*, 0 bookmark, 0 like, 0 bad, 0 bookmarks')
|
||||
->get()->result());
|
||||
$this->pray_model->getBookmarksAndRankings($this->data['prayon']);
|
||||
}],
|
||||
'vclip' => ['vclip', function () {
|
||||
$this->data['vclip'] = $this->getPostsByCategorySlug($this->sections['vclip'][0])
|
||||
->join('cm_post_video v', 'p.postID=v.postID', 'left')
|
||||
->join('cm_user u', 'p.userID=u.userID', 'left')
|
||||
->select("if(u.nickname = '' or u.nickname is null, u.userName, u.nickName) as author")
|
||||
->get()->result();
|
||||
}],
|
||||
'together' => ['together', function () {
|
||||
$this->data['pages'] = [];
|
||||
$this->data['together'] = $this->post_model->getPagePostsByCategoryId($this->getCategoryIdBySlug($this->sections['together'][0]), 29)
|
||||
->join('cm_user u', 'p.userID=u.userID', 'left')
|
||||
->select("*,if(u.nickname = '' or u.nickname is null, u.userName, u.nickName) as author, p.postID postSeq")
|
||||
->get()->result();
|
||||
}],
|
||||
'story' => ['story', function () {
|
||||
$this->data['story'] = $this->getPostsByCategorySlug($this->sections['story'][0])
|
||||
->join('cm_user u', 'p.userID=u.userID', 'left')
|
||||
->select("if(u.nickname = '' or u.nickname is null, u.userName, u.nickName) as author")
|
||||
->get()->result();
|
||||
}],
|
||||
'art' => ['art', function () {
|
||||
$this->data['art'] = $this->getPostsByCategorySlug($this->sections['art'][0])
|
||||
->join('cm_user u', 'p.userID=u.userID', 'left')
|
||||
->select("if(u.nickname = '' or u.nickname is null, u.userName, u.nickName) as author")->get()->result();
|
||||
}]
|
||||
];
|
||||
|
||||
foreach ($this->sections as $k => $s) {
|
||||
$s[0] || $this->uri->segment(2) == $k ? $s[1]() : '';
|
||||
}
|
||||
}
|
||||
|
||||
public function rating()
|
||||
{
|
||||
$data = [
|
||||
'prayID' => $this->input->post('prayId'),
|
||||
'userID' => getSessionUser()->is ? getSessionUser()->userID : 0,
|
||||
'title' => $this->input->post('title'),
|
||||
'dateUpdated' => date('Y-m-d H:i:s')
|
||||
];
|
||||
if ($insertId = $this->pray_model->bookmark($data)) {
|
||||
$this->response(array('code' => 200, 'rating' => 0));
|
||||
// $this->response(array('code' => 200, 'rating' => $this->pray_model->getPrayRankingCountByTitle($data['prayID'], $data['title'])));
|
||||
} else {
|
||||
$this->response(array('code' => 500, 'error' => '서버오류가 발생했습니다'));
|
||||
}
|
||||
}
|
||||
}
|
||||
15
application/controllers/Resource.php
Executable file
15
application/controllers/Resource.php
Executable file
@@ -0,0 +1,15 @@
|
||||
<?php if (!defined('BASEPATH')) {
|
||||
exit('No direct script access allowed');
|
||||
}
|
||||
|
||||
class Resource extends MY_Controller
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
public function index() {
|
||||
|
||||
}
|
||||
}
|
||||
53
application/controllers/Schedule.php
Executable file
53
application/controllers/Schedule.php
Executable file
@@ -0,0 +1,53 @@
|
||||
<?php if (!defined('BASEPATH')) {
|
||||
exit('No direct script access allowed');
|
||||
}
|
||||
|
||||
use GO\Scheduler;
|
||||
use Aws\S3\S3Client;
|
||||
|
||||
class Schedule extends CI_Controller
|
||||
{
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
// if (!$this->input->is_cli_request()) {
|
||||
// echo 'Not allowed';
|
||||
// exit();
|
||||
// }
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
// Create a new scheduler
|
||||
$scheduler = new Scheduler();
|
||||
|
||||
// ... configure the scheduled jobs (see below) ...
|
||||
|
||||
// Let the scheduler execute jobs which are due.
|
||||
$scheduler->run();
|
||||
}
|
||||
|
||||
public function aws() {
|
||||
$this->load->database();
|
||||
$query = $this->db->limit(1)->get('cm_post')->order_by('datePosted', 'desc')->result();
|
||||
|
||||
$s3 = new S3Client([
|
||||
'version' => 'latest',
|
||||
'region' => 'ap-northeast-2',
|
||||
'credentials' => [
|
||||
'key' => "AKIA2WGASVZ56VOBTZJE",
|
||||
'secret' => "o2GpynNMn4ED6Lf8GjXsfupFE9Pua1llIkaElueK",
|
||||
]
|
||||
]);
|
||||
|
||||
$result = $s3->putObject([
|
||||
'Bucket' => 'elasticbeanstalk-ap-northeast-2-734843285115',
|
||||
'Key' => $file_name,
|
||||
'SourceFile' => BASEPATH ,
|
||||
'ACL' => 'public-read'
|
||||
]);
|
||||
|
||||
var_dump($result);
|
||||
}
|
||||
}
|
||||
114
application/controllers/Share.php
Executable file
114
application/controllers/Share.php
Executable file
@@ -0,0 +1,114 @@
|
||||
<?php
|
||||
|
||||
class Share extends MY_Controller
|
||||
{
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
// if (!$this->maintenanceMode) {
|
||||
// $totSegments = $this->uri->total_segments();
|
||||
// if (!is_numeric($this->uri->segment($totSegments))) {
|
||||
// $pageURL = $this->uri->segment($totSegments);
|
||||
// } elseif (is_numeric($this->uri->segment($totSegments))) {
|
||||
// $pageURL = $this->uri->segment($totSegments - 1);
|
||||
// }
|
||||
// if ($pageURL == "") {
|
||||
// $pageURL = "home";
|
||||
// }
|
||||
// $this->data['page'] = $this->cmap_page_model->getPage($pageURL);
|
||||
// $this->data['posts'] = getPagePostsByCategoryId(getChildrenByParentId(30000), 15);
|
||||
// $this->data['reads'] = $this->cmap_page_model->getPagePostByParentCategoryId(30000, 32, 0, 'V');
|
||||
// $this->data['likes'] = $this->cmap_page_model->getPagePostByParentCategoryId(30000, 32, 0, 'L');
|
||||
// if ($this->data['page']['pageTemplate'] != "") {
|
||||
// $this->data['header'] = $this->load->view('templates/header', $this->data, true);
|
||||
// $this->data['footer'] = $this->load->view('templates/footer', '', true);
|
||||
// $this->load->view('templates/' . $this->data['page']['pageTemplate'], $this->data);
|
||||
// } else {
|
||||
// $this->error();
|
||||
// }
|
||||
// } else {
|
||||
// $this->maintenance();
|
||||
// }
|
||||
}
|
||||
|
||||
public function save_comment()
|
||||
{
|
||||
$this->load->model('comment_model');
|
||||
$this->comment_model->save([
|
||||
'postID' => $this->input->post('postId'),
|
||||
'userID' => $this->session->userdata('userID'),
|
||||
'comment' => $this->input->post('comment'),
|
||||
'datePosted' => date('Y-m-d H:i:s')
|
||||
]);
|
||||
}
|
||||
|
||||
public function reply_comment()
|
||||
{
|
||||
$this->load->model('comment_model');
|
||||
$this->comment_model->save([
|
||||
'postID' => $this->input->post('postId'),
|
||||
'userID' => $this->session->userdata('userID'),
|
||||
'parentID' => $this->input->post('parentId'),
|
||||
'comment' => $this->input->post('comment'),
|
||||
'datePosted' => date('Y-m-d H:i:s')
|
||||
]);
|
||||
}
|
||||
|
||||
public function rating_comment()
|
||||
{
|
||||
if (getSessionUser()->is) {
|
||||
$this->load->model('comment_model');
|
||||
$this->comment_model->rating([
|
||||
'userID' => getSessionUser()->userID,
|
||||
'commentID' => $this->input->post('commentID'),
|
||||
'title' => $this->input->post('like') ? 1 : 2
|
||||
]);
|
||||
}else {
|
||||
$this->response(array('code' => 405, 'error' => '로그인 하세요'));
|
||||
}
|
||||
}
|
||||
|
||||
public function delete_comment()
|
||||
{
|
||||
$this->load->model('comment_model');
|
||||
if (getSessionUser()->userID == $this->comment_model->getOne($this->input->post('commentID'))->userID) {
|
||||
$this->comment_model->delete();
|
||||
$this->response(array('code' => 200));
|
||||
} else {
|
||||
$this->response(array('code' => 405, 'error' => '잘못된 요청입니다.'));
|
||||
}
|
||||
}
|
||||
|
||||
public function update_comment()
|
||||
{
|
||||
$this->load->model('comment_model');
|
||||
if (getSessionUser()->userID == $this->comment_model->getOne($this->input->post('commentID'))->userID) {
|
||||
$this->comment_model->update([
|
||||
'commentID' => $this->input->post('commentID'),
|
||||
'comment' => $this->input->post('comment')
|
||||
]);
|
||||
$this->response(array('code' => 200));
|
||||
} else {
|
||||
$this->response(array('code' => 405, 'error' => '잘못된 요청입니다.'));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function pray()
|
||||
{
|
||||
$this->load->model('pray_model');
|
||||
$prayer = $this->input->post('prayer');
|
||||
if($insertId = $this->pray_model->save([
|
||||
'pray' => $prayer,
|
||||
'userID' => getSessionUser()->is ? getSessionUser()->userID : 0,
|
||||
'dateUpdated' => date('Y-m-d H:i:s')
|
||||
])) {
|
||||
$this->response(array('code' => 200, 'commentId' => $insertId));
|
||||
}
|
||||
}
|
||||
}
|
||||
135
application/controllers/User.php
Executable file
135
application/controllers/User.php
Executable file
@@ -0,0 +1,135 @@
|
||||
<?php if (!defined('BASEPATH')) {
|
||||
exit('No direct script access allowed');
|
||||
}
|
||||
|
||||
|
||||
class User extends MY_Controller
|
||||
{
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->load->model('user_model');
|
||||
}
|
||||
|
||||
public function login()
|
||||
{
|
||||
$this->load->view('templates/others/login');
|
||||
}
|
||||
|
||||
public function register($submit = '')
|
||||
{
|
||||
if ($submit) {
|
||||
$this->load->model('user');
|
||||
} else $this->load->view('templates/register/register');
|
||||
}
|
||||
|
||||
public function mobile_auth()
|
||||
{
|
||||
$this->load->view('templates/others/mobile_auth');
|
||||
}
|
||||
|
||||
public function mobile_auth_encode()
|
||||
{
|
||||
$this->load->library('mobileCertification');
|
||||
$this->mobilecertification->mobile_auth_encode();
|
||||
}
|
||||
|
||||
public function find($what)
|
||||
{
|
||||
$this->load->view('templates/others/find-' . $what);
|
||||
}
|
||||
|
||||
public function auth($name = '')
|
||||
{
|
||||
$this->load->library('auth');
|
||||
$this->auth->setIsRequest(true)->auth($name);
|
||||
if ($this->auth->getResponse()) {
|
||||
$this->output
|
||||
->set_status_header(200)
|
||||
->set_content_type('application/json')
|
||||
->set_output(json_encode($this->auth->getResponse()));
|
||||
}
|
||||
}
|
||||
|
||||
public function logout()
|
||||
{
|
||||
$this->load->library('session');
|
||||
$data = array(
|
||||
'userID' => '',
|
||||
'userName' => '',
|
||||
'is' => false,
|
||||
);
|
||||
$this->session->unset_userdata($data);
|
||||
$this->session->sess_destroy();
|
||||
header('location:'. $_SERVER['HTTP_REFERER']);
|
||||
}
|
||||
|
||||
public function check_username($username)
|
||||
{
|
||||
log_message('info', 'checking username ====');
|
||||
log_message('info', $username);
|
||||
if (count($this->user_model->findByUserName($username)) == 0) {
|
||||
$this->output
|
||||
->set_status_header(200)
|
||||
->set_content_type('application/json')
|
||||
->set_output(json_encode(array('code' => 200)));
|
||||
} else {
|
||||
$this->output
|
||||
->set_status_header(200)
|
||||
->set_content_type('application/json')
|
||||
->set_output(json_encode(array('code' => 404)));
|
||||
}
|
||||
}
|
||||
|
||||
public function check_email()
|
||||
{
|
||||
log_message('info', 'checking email ====');
|
||||
log_message('info', $this->input->post('email'));
|
||||
if (count($this->user_model->findByEmail($this->input->post('email'))) == 0) {
|
||||
$this->output
|
||||
->set_status_header(200)
|
||||
->set_content_type('application/json')
|
||||
->set_output(json_encode(array('code' => 200)));
|
||||
} else {
|
||||
$this->output
|
||||
->set_status_header(200)
|
||||
->set_content_type('application/json')
|
||||
->set_output(json_encode(array('code' => 404)));
|
||||
}
|
||||
}
|
||||
|
||||
public function submit()
|
||||
{
|
||||
$params = [];
|
||||
foreach (['userName', 'password', 'gender', 'birthday', 'birth_cal', 'email', 'mobile', 'church'] as $k) {
|
||||
$params[$k] = $this->input->post($k);
|
||||
}
|
||||
$params['password'] = md5($params['password']);
|
||||
if ($this->user_model->save([$params])) {
|
||||
$this->output
|
||||
->set_status_header(200)
|
||||
->set_content_type('application/json')
|
||||
->set_output(json_encode(array('code' => 200)));
|
||||
} else {
|
||||
$this->output
|
||||
->set_status_header(200)
|
||||
->set_content_type('application/json')
|
||||
->set_output(json_encode(array('code' => 404)));
|
||||
}
|
||||
}
|
||||
|
||||
public function oauth($sns = '')
|
||||
{
|
||||
$this->load->library('auth');
|
||||
$sns = $sns ? $sns : $this->uri->segment(2);
|
||||
$this->auth->auth($sns);
|
||||
}
|
||||
|
||||
public function check_session() {
|
||||
$this->output
|
||||
->set_status_header(200)
|
||||
->set_content_type('application/json')
|
||||
->set_output(json_encode(array('code' => (getSessionUser()->is? 200: 400))));
|
||||
}
|
||||
}
|
||||
142
application/controllers/Webtoon.php
Executable file
142
application/controllers/Webtoon.php
Executable file
@@ -0,0 +1,142 @@
|
||||
<?php if (!defined('BASEPATH')) {
|
||||
exit('No direct script access allowed');
|
||||
}
|
||||
|
||||
class Webtoon extends MY_Controller
|
||||
{
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->load->model('post_model');
|
||||
}
|
||||
|
||||
|
||||
public function index()
|
||||
{
|
||||
if ($this->isMobile()) {
|
||||
$this->mobile();
|
||||
} else {
|
||||
$this->desktop();
|
||||
}
|
||||
}
|
||||
|
||||
public function desktop()
|
||||
{
|
||||
$episodeURL = $this->uri->segment(2);
|
||||
$seriesURL = $this->uri->segment(3);
|
||||
if (is_numeric($episodeURL)) {
|
||||
$this->data['page'] = $this->post_model->getPost($episodeURL);
|
||||
if ($this->data['page']->postID != "") {
|
||||
$this->data['page']->postContentHTML = $this->getJsonToPostContent($this->data['page']->postContent);
|
||||
$this->data['hotToons'] = $this->getPostsRankingByRankTypeAndCategoryId('V', getChildrenByParentId(20000), 5);
|
||||
getResultWithAuthor($this->data['hotToons']);
|
||||
$this->data['episodes'] = $this->post_model
|
||||
->getPagePostsByPageId($this->data['page']->pageID, 100)
|
||||
->order_by('p.postID', 'asc')->get()->result();
|
||||
$this->load->view('templates/webtoon/webtoon-article', $this->data);
|
||||
} else {
|
||||
$this->error();
|
||||
}
|
||||
} elseif ($seriesURL) {
|
||||
$this->load->model('page_model');
|
||||
$this->data['seriesURL'] = $seriesURL;
|
||||
$this->data['series'] = $this->post_model->getPostsRatingByPageId($seriesURL, 100)->order_by('dateUpdated', 'desc')->get()->result();
|
||||
$this->data['page'] = $this->page_model->getOne($seriesURL);
|
||||
if (count($this->data['series'])) {
|
||||
$this->list();
|
||||
$this->load->view('templates/webtoon/webtoon-list', $this->data);
|
||||
} else {
|
||||
$this->error();
|
||||
}
|
||||
} elseif ($this->uri->segment(2) == 'series') {
|
||||
$this->series();
|
||||
$this->load->view('templates/webtoon/webtoon-series', $this->data);
|
||||
} else {
|
||||
$this->main();
|
||||
foreach ($this->data as $k => $v) {
|
||||
getPostsImageUrl($this->data[$k]);
|
||||
}
|
||||
$this->load->view('templates/webtoon/webtoon-home', $this->data);
|
||||
}
|
||||
}
|
||||
|
||||
private function getPostsRankingByRankTypeAndCategoryId($rankType, $categoryId, $limit)
|
||||
{
|
||||
return $this->post_model->getPostsRankingByRankTypeAndCategoryId($rankType, $categoryId, $limit)
|
||||
->join('cm_page_content co', 'pp.pageID=co.pageID', 'left')->get()->result();
|
||||
}
|
||||
|
||||
private function getPostsByCategoryId($categories, $limit, $offset = 0)
|
||||
{
|
||||
return $this->post_model->getPostsByCategoryId($categories, $limit, $offset)
|
||||
->join('cm_page_content co', 'pp.pageID=co.pageID', 'left')->get()->result();
|
||||
}
|
||||
|
||||
public function main()
|
||||
{
|
||||
$this->data['featureToons'] = $this->getPostsRankingByRankTypeAndCategoryId('R', 20008, 8);
|
||||
getResultWithAuthor($this->data['featureToons']);
|
||||
|
||||
foreach (['hotToons' => [20009, 8], 'funToons' => [20010, 3], 'touchedToons' => [20011, 3]] as $categoryName => list($categoryID, $rowCount)) {
|
||||
$this->data[$categoryName] = [
|
||||
'updates' => $this->getPostsByCategoryId($categoryID, $rowCount),
|
||||
'reads' => $this->getPostsRankingByRankTypeAndCategoryId('V', $categoryID, $rowCount),
|
||||
'recomm' => $this->getPostsRankingByRankTypeAndCategoryId('R', $categoryID, $rowCount)
|
||||
];
|
||||
foreach($this->data[$categoryName] as $k=>$v) {
|
||||
getPostsImageUrl($this->data[$categoryName][$k]);
|
||||
}
|
||||
getResultWithAuthor($this->data[$categoryName]['updates']);
|
||||
getResultWithAuthor($this->data[$categoryName]['reads']);
|
||||
getResultWithAuthor($this->data[$categoryName]['recomm']);
|
||||
shuffle($this->data[$categoryName]['reads']);
|
||||
shuffle($this->data[$categoryName]['recomm']);
|
||||
}
|
||||
|
||||
$this->data['ratingToons'] = $this->getPostsRankingByRankTypeAndCategoryId('V', getChildrenByParentId(20000), 8);
|
||||
getResultWithAuthor($this->data['ratingToons']);
|
||||
$this->data['recommendChannel'] = $this->post_model->getPagePostsByPageId(getChildrenByParentId(30000), 8)->get()->result();
|
||||
}
|
||||
|
||||
public function series()
|
||||
{
|
||||
$recentToons = $this->post_model->getPagePostsByCategoryId(getChildrenByParentId(20000), 6)->join('cm_page_attributes pa', 'pp.pageID = pa.pageID', 'left')->get()->result();
|
||||
getResultWithAuthor($recentToons);
|
||||
$this->data['daynames'] = ['일요일', '월요일', '화요일', '수요일', '목요일', '금요일', '토요일'];
|
||||
$this->data['todayToons'] = $recentToons;
|
||||
|
||||
foreach (['recomToons' => [20013, 6], 'faithToons' => [20014, 3], 'wordToons' => [20015, 3]] as $title => list($categoryID, $rowCount)) {
|
||||
$this->data[$title] = [
|
||||
'updates' => $this->getPostsByCategoryId($categoryID, $rowCount),
|
||||
'reads' => $this->getPostsRankingByRankTypeAndCategoryId('V', $categoryID, $rowCount),
|
||||
'recomm' => $this->getPostsRankingByRankTypeAndCategoryId('R', $categoryID, $rowCount),
|
||||
];
|
||||
getResultWithAuthor($this->data[$title]['updates']);
|
||||
getResultWithAuthor($this->data[$title]['reads']);
|
||||
getResultWithAuthor($this->data[$title]['recomm']);
|
||||
shuffle($this->data[$title]['recomm']);
|
||||
}
|
||||
|
||||
$this->data['hotToons'] = $this->getPostsRankingByRankTypeAndCategoryId('V', getChildrenByParentId(20000), 9);
|
||||
$this->data['recommLife'] = $this->getPostsRankingByRankTypeAndCategoryId('R', getChildrenByParentId(30000), 3);
|
||||
getResultWithAuthor($this->data['hotToons']);
|
||||
}
|
||||
|
||||
public function list()
|
||||
{
|
||||
$this->data['hotToons'] = $this->getPostsRankingByRankTypeAndCategoryId('V', getChildrenByParentId(20000), 9);
|
||||
$this->data['recommLife'] = $this->getPostsRankingByRankTypeAndCategoryId('R', getChildrenByParentId(30000), 3);
|
||||
getResultWithAuthor($this->data['hotToons']);
|
||||
}
|
||||
|
||||
private function getJsonToPostContent($content)
|
||||
{
|
||||
$html = '';
|
||||
$c = json_decode($content);
|
||||
foreach ($c as $url) {
|
||||
$html .= '<img src="http://crossmap.co.kr' . $url . '">';
|
||||
}
|
||||
return $html;
|
||||
}
|
||||
}
|
||||
15
application/controllers/Worship.php
Executable file
15
application/controllers/Worship.php
Executable file
@@ -0,0 +1,15 @@
|
||||
<?php if (!defined('BASEPATH')) {
|
||||
exit('No direct script access allowed');
|
||||
}
|
||||
|
||||
class Worship extends MY_Controller
|
||||
{
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
public function index()
|
||||
{ }
|
||||
}
|
||||
184
application/controllers/admin/Admin.php
Executable file
184
application/controllers/admin/Admin.php
Executable file
@@ -0,0 +1,184 @@
|
||||
<?php if (!defined('BASEPATH')) {
|
||||
exit('No direct script access allowed');
|
||||
}
|
||||
|
||||
class Admin extends CI_Controller
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
define("HOOSK_ADMIN", 1);
|
||||
$this->load->helper(array('admincontrol', 'url', 'hoosk_admin', 'form'));
|
||||
$this->load->library('session');
|
||||
$this->load->model('Hoosk_model');
|
||||
define('LANG', $this->Hoosk_model->getLang());
|
||||
$this->lang->load('admin', LANG);
|
||||
define('SITE_NAME', $this->Hoosk_model->getSiteName());
|
||||
define('THEME', $this->Hoosk_model->getTheme());
|
||||
define('THEME_FOLDER', BASE_URL . '/theme/' . THEME);
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
Admincontrol_helper::is_logged_in($this->session->userdata('userName'));
|
||||
$this->data['current'] = $this->uri->segment(2);
|
||||
$this->data['recenltyUpdated'] = $this->Hoosk_model->getUpdatedPages();
|
||||
if (RSS_FEED) {
|
||||
$this->load->library('rssparser');
|
||||
$this->rssparser->set_feed_url('http://hoosk.org/feed/rss');
|
||||
$this->rssparser->set_cache_life(30);
|
||||
$this->data['hooskFeed'] = $this->rssparser->getFeed(3);
|
||||
}
|
||||
$this->data['maintenaceActive'] = $this->Hoosk_model->checkMaintenance();
|
||||
$this->data['header'] = $this->load->view('admin/header', $this->data, true);
|
||||
$this->data['footer'] = $this->load->view('admin/footer', '', true);
|
||||
$this->load->view('admin/home', $this->data);
|
||||
}
|
||||
public function upload()
|
||||
{
|
||||
Admincontrol_helper::is_logged_in($this->session->userdata('userName'));
|
||||
$attachment = $this->input->post('attachment');
|
||||
$uploadedFile = $_FILES['attachment']['tmp_name']['file'];
|
||||
|
||||
$path = $_SERVER["DOCUMENT_ROOT"] . '/images';
|
||||
$url = BASE_URL . '/images';
|
||||
|
||||
// create an image name
|
||||
$fileName = $attachment['name'];
|
||||
|
||||
// upload the image
|
||||
move_uploaded_file($uploadedFile, $path . '/' . $fileName);
|
||||
|
||||
$this->output->set_output(
|
||||
json_encode(array('file' => array(
|
||||
'url' => $url . '/' . $fileName,
|
||||
'filename' => $fileName
|
||||
))),
|
||||
200,
|
||||
array('Content-Type' => 'application/json')
|
||||
);
|
||||
}
|
||||
public function login()
|
||||
{
|
||||
$this->data['header'] = $this->load->view('admin/headerlog', '', true);
|
||||
$this->data['footer'] = $this->load->view('admin/footer', '', true);
|
||||
$this->load->view('admin/login', $this->data);
|
||||
}
|
||||
|
||||
public function loginCheck()
|
||||
{
|
||||
$username = $this->input->post('username');
|
||||
$password = md5($this->input->post('password') . SALT);
|
||||
$result = $this->Hoosk_model->login($username, $password);
|
||||
if ($result) {
|
||||
redirect(BASE_URL . '/admin', 'refresh');
|
||||
} else {
|
||||
$this->data['error'] = "1";
|
||||
$this->login();
|
||||
}
|
||||
}
|
||||
public function ajaxLogin()
|
||||
{
|
||||
$username = $this->input->post('username');
|
||||
$password = md5($this->input->post('password') . SALT);
|
||||
$result = $this->Hoosk_model->login($username, $password);
|
||||
if ($result) {
|
||||
echo 1;
|
||||
} else {
|
||||
echo 0;
|
||||
}
|
||||
}
|
||||
public function logout()
|
||||
{
|
||||
$data = array(
|
||||
'userID' => '',
|
||||
'userName' => '',
|
||||
'logged_in' => false,
|
||||
);
|
||||
$this->session->unset_userdata($data);
|
||||
$this->session->sess_destroy();
|
||||
$this->login();
|
||||
}
|
||||
|
||||
|
||||
public function settings()
|
||||
{
|
||||
Admincontrol_helper::is_logged_in($this->session->userdata('userName'));
|
||||
$this->load->helper('directory');
|
||||
$this->data['themesdir'] = directory_map($_SERVER["DOCUMENT_ROOT"] . '/theme/', 1);
|
||||
$this->data['langdir'] = directory_map(APPPATH . '/language/', 1);
|
||||
|
||||
$this->data['settings'] = $this->Hoosk_model->getSettings();
|
||||
$this->data['current'] = $this->uri->segment(2);
|
||||
$this->data['header'] = $this->load->view('admin/header', $this->data, true);
|
||||
$this->data['footer'] = $this->load->view('admin/footer', '', true);
|
||||
$this->load->view('admin/settings', $this->data);
|
||||
}
|
||||
|
||||
public function updateSettings()
|
||||
{
|
||||
Admincontrol_helper::is_logged_in($this->session->userdata('userName'));
|
||||
$path_upload = $_SERVER["DOCUMENT_ROOT"] . '/uploads/';
|
||||
$path_images = $_SERVER["DOCUMENT_ROOT"] . '/images/';
|
||||
if ($this->input->post('siteLogo') != "") {
|
||||
rename($path_upload . $this->input->post('siteLogo'), $path_images . $this->input->post('siteLogo'));
|
||||
}
|
||||
if ($this->input->post('siteFavicon') != "") {
|
||||
rename($path_upload . $this->input->post('siteFavicon'), $path_images . $this->input->post('siteFavicon'));
|
||||
}
|
||||
$this->Hoosk_model->updateSettings();
|
||||
redirect(BASE_URL . '/admin', 'refresh');
|
||||
}
|
||||
|
||||
public function uploadLogo()
|
||||
{
|
||||
Admincontrol_helper::is_logged_in($this->session->userdata('userName'));
|
||||
$config['upload_path'] = './uploads/';
|
||||
$config['allowed_types'] = 'gif|jpg|png';
|
||||
|
||||
$this->load->library('upload', $config);
|
||||
foreach ($_FILES as $key => $value) {
|
||||
if (!$this->upload->do_upload($key)) {
|
||||
$error = array('error' => $this->upload->display_errors());
|
||||
echo 0;
|
||||
} else {
|
||||
echo '"' . $this->upload->data('file_name') . '"';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function social()
|
||||
{
|
||||
Admincontrol_helper::is_logged_in($this->session->userdata('userName'));
|
||||
|
||||
|
||||
$this->data['social'] = $this->Hoosk_model->getSocial();
|
||||
$this->data['current'] = $this->uri->segment(2);
|
||||
$this->data['header'] = $this->load->view('admin/header', $this->data, true);
|
||||
$this->data['footer'] = $this->load->view('admin/footer', '', true);
|
||||
$this->load->view('admin/social', $this->data);
|
||||
}
|
||||
|
||||
public function updateSocial()
|
||||
{
|
||||
Admincontrol_helper::is_logged_in($this->session->userdata('userName'));
|
||||
$this->Hoosk_model->updateSocial();
|
||||
redirect(BASE_URL . '/admin', 'refresh');
|
||||
}
|
||||
|
||||
public function checkSession()
|
||||
{
|
||||
if (!$this->session->userdata('logged_in')) {
|
||||
echo 0;
|
||||
} else {
|
||||
echo 1;
|
||||
}
|
||||
}
|
||||
|
||||
public function complete()
|
||||
{
|
||||
unlink(FCPATH . "install/hoosk.sql");
|
||||
unlink(FCPATH . "install/index.php");
|
||||
redirect(BASE_URL . '/admin', 'refresh');
|
||||
}
|
||||
}
|
||||
118
application/controllers/admin/Categories.php
Executable file
118
application/controllers/admin/Categories.php
Executable file
@@ -0,0 +1,118 @@
|
||||
<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
|
||||
|
||||
class Categories extends CI_Controller
|
||||
{
|
||||
|
||||
function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
define("HOOSK_ADMIN", 1);
|
||||
$this->load->model('Cmap_model');
|
||||
$this->load->helper(array('admincontrol', 'url', 'file', 'form'));
|
||||
$this->load->library('session');
|
||||
define('LANG', $this->Cmap_model->getLang());
|
||||
$this->lang->load('admin', LANG);
|
||||
//Define what page we are on for nav
|
||||
$this->data['current'] = $this->uri->segment(2);
|
||||
define('SITE_NAME', $this->Cmap_model->getSiteName());
|
||||
define('THEME', $this->Cmap_model->getTheme());
|
||||
define('THEME_FOLDER', BASE_URL . '/theme/' . THEME);
|
||||
//check session exists
|
||||
Admincontrol_helper::is_logged_in($this->session->userdata('userName'));
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
$this->load->library('pagination');
|
||||
$result_per_page = 15; // the number of result per page
|
||||
$config['base_url'] = BASE_URL . '/admin/posts/categories/';
|
||||
$config['total_rows'] = $this->Cmap_model->countCategories();
|
||||
$config['uri_segment'] = 4;
|
||||
$config['per_page'] = $result_per_page;
|
||||
$config['last_link'] = false;
|
||||
$config['first_link'] = false;
|
||||
|
||||
$this->pagination->initialize($config);
|
||||
//Get categorys from database
|
||||
$this->data['categories'] = $this->Cmap_model->getCategoriesAll($result_per_page, $this->uri->segment(4));
|
||||
//Load the view
|
||||
$this->data['header'] = $this->load->view('admin/header', $this->data, true);
|
||||
$this->data['footer'] = $this->load->view('admin/footer', '', true);
|
||||
$this->load->view('admin/post_categories', $this->data);
|
||||
}
|
||||
|
||||
public function addCategory()
|
||||
{
|
||||
//Load the view
|
||||
$this->data['header'] = $this->load->view('admin/header', $this->data, true);
|
||||
$this->data['footer'] = $this->load->view('admin/footer', '', true);
|
||||
$this->load->view('admin/post_category_new', $this->data);
|
||||
}
|
||||
|
||||
public function confirm()
|
||||
{
|
||||
//Load the form validation library
|
||||
$this->load->library('form_validation');
|
||||
//Set validation rules
|
||||
$this->form_validation->set_rules('categorySlug', 'category slug', 'trim|alpha_dash|required|is_unique[cm_category.categorySlug]');
|
||||
$this->form_validation->set_rules('categoryTitle', 'category title', 'trim|required');
|
||||
|
||||
if ($this->form_validation->run() == FALSE) {
|
||||
//Validation failed
|
||||
$this->addCategory();
|
||||
} else {
|
||||
//Validation passed
|
||||
//Add the category
|
||||
$this->Cmap_model->createCategory();
|
||||
//Return to category list
|
||||
redirect(BASE_URL . '/admin/posts/categories', 'refresh');
|
||||
}
|
||||
}
|
||||
|
||||
public function editCategory()
|
||||
{
|
||||
//Get category details from database
|
||||
$this->data['category'] = $this->Cmap_model->getCategory($this->uri->segment(5));
|
||||
$this->data['categories'] = $this->Cmap_model->getCategories();
|
||||
//Load the view
|
||||
$this->data['header'] = $this->load->view('admin/header', $this->data, true);
|
||||
$this->data['footer'] = $this->load->view('admin/footer', '', true);
|
||||
$this->load->view('admin/post_category_edit', $this->data);
|
||||
}
|
||||
|
||||
public function edited()
|
||||
{
|
||||
//Load the form validation library
|
||||
$this->load->library('form_validation');
|
||||
//Set validation rules
|
||||
$this->form_validation->set_rules('categorySlug', 'category slug', 'trim|alpha_dash|required|is_unique[cm_category.categorySlug.categoryID.' . $this->uri->segment(5) . ']');
|
||||
$this->form_validation->set_rules('categoryTitle', 'category title', 'trim|required');
|
||||
|
||||
if ($this->form_validation->run() == FALSE) {
|
||||
//Validation failed
|
||||
$this->editCategory();
|
||||
} else {
|
||||
//Validation passed
|
||||
//Update the category
|
||||
$this->Cmap_model->updateCategory($this->uri->segment(5));
|
||||
//Return to category list
|
||||
redirect(BASE_URL . '/admin/posts/categories', 'refresh');
|
||||
}
|
||||
}
|
||||
|
||||
public function categorySearch()
|
||||
{
|
||||
$this->Cmap_model->categorySearch($this->input->post('term'));
|
||||
}
|
||||
|
||||
function delete()
|
||||
{
|
||||
if ($this->input->post('deleteid')) :
|
||||
$this->Cmap_model->removeCategory($this->input->post('deleteid'));
|
||||
redirect(BASE_URL . '/admin/posts/categories');
|
||||
else :
|
||||
$this->data['form'] = $this->Cmap_model->getCategory($this->uri->segment(5));
|
||||
$this->load->view('admin/post_category_delete.php', $this->data);
|
||||
endif;
|
||||
}
|
||||
}
|
||||
54
application/controllers/admin/Comments.php
Executable file
54
application/controllers/admin/Comments.php
Executable file
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
|
||||
|
||||
class Comments extends MY_Controller {
|
||||
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
define("HOOSK_ADMIN", 1);
|
||||
parent::__construct();
|
||||
$this->load->model('comment_model');
|
||||
$this->load->helper(array('admincontrol', 'url', 'hoosk_admin', 'file', 'form'));
|
||||
$this->load->library('session');
|
||||
define('LANG', $this->data['settings']->siteLang);
|
||||
$this->lang->load('admin', LANG);
|
||||
//Define what page we are on for nav
|
||||
$this->data['current'] = $this->uri->segment(2);
|
||||
//check session exists
|
||||
Admincontrol_helper::is_logged_in($this->session->userdata('userName'));
|
||||
$this->load->helper('general');
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
$this->load->library('pagination');
|
||||
$result_per_page = 15; // the number of result per page
|
||||
$config['base_url'] = BASE_URL . '/admin/comments/';
|
||||
$config['total_rows'] = $this->comment_model->getCountPaging();
|
||||
$config['per_page'] = $result_per_page;
|
||||
$config['last_link'] = false;
|
||||
$config['first_link'] = false;
|
||||
$config['suffix'] = '?term=' . getSearchTerm();
|
||||
|
||||
$this->pagination->initialize($config);
|
||||
|
||||
//Get posts from database
|
||||
$this->data['comments'] = $this->comment_model->getPaging($result_per_page, $this->uri->segment(3))
|
||||
->get()->result();
|
||||
$this->data['header'] = $this->load->view('admin/header', $this->data, true);
|
||||
$this->data['footer'] = $this->load->view('admin/footer', '', true);
|
||||
$this->load->view('admin/comments', $this->data);
|
||||
}
|
||||
|
||||
public function delete()
|
||||
{
|
||||
if ($this->input->post('deleteid')) :
|
||||
$this->comment_model->delete($this->input->post('deleteid'));
|
||||
redirect(BASE_URL . '/admin/comments');
|
||||
else :
|
||||
$this->data['form'] = [(array)$this->comment_model->getOne($this->uri->segment(4))];
|
||||
$this->load->view('admin/comment_delete.php', $this->data);
|
||||
endif;
|
||||
}
|
||||
}
|
||||
55
application/controllers/admin/Data.php
Executable file
55
application/controllers/admin/Data.php
Executable file
@@ -0,0 +1,55 @@
|
||||
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
|
||||
|
||||
class Data extends CI_Controller {
|
||||
|
||||
function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
define("HOOSK_ADMIN",1);
|
||||
$this->load->model('Cmap_model');
|
||||
$this->load->helper(array('admincontrol', 'url', 'hoosk_admin', 'file', 'form'));
|
||||
$this->load->library('session');
|
||||
define ('LANG', $this->Cmap_model->getLang());
|
||||
$this->lang->load('admin', LANG);
|
||||
//Define what page we are on for nav
|
||||
$this->data['current'] = $this->uri->segment(2);
|
||||
define ('SITE_NAME', $this->Cmap_model->getSiteName());
|
||||
define('THEME', $this->Cmap_model->getTheme());
|
||||
define ('THEME_FOLDER', BASE_URL.'/theme/'.THEME);
|
||||
//check session exists
|
||||
Admincontrol_helper::is_logged_in($this->session->userdata('userName'));
|
||||
$this->load->library('cacher');
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
$this->data['header'] = $this->load->view('admin/header', $this->data, true);
|
||||
$this->data['footer'] = $this->load->view('admin/footer', '', true);
|
||||
$source = $this->uri->segment(3);
|
||||
$section = $this->uri->segment(4);
|
||||
if($section) {
|
||||
echo json_encode($this->cacher->{$source}($section));
|
||||
}else {
|
||||
$this->data['header'] = $this->load->view('admin/header', $this->data, true);
|
||||
$this->data['footer'] = $this->load->view('admin/footer', '', true);
|
||||
$this->load->view('admin/data_'. $source, $this->data);
|
||||
}
|
||||
}
|
||||
|
||||
public function post()
|
||||
{
|
||||
$source = $this->uri->segment(3);
|
||||
$section = $this->uri->segment(4);
|
||||
$articleID = $this->uri->segment(5);
|
||||
$this->data['header'] = $this->load->view('admin/header', $this->data, true);
|
||||
$this->data['footer'] = $this->load->view('admin/footer', '', true);
|
||||
if($articleID) {
|
||||
$this->data['article'] = $this->cacher->{$source}($section)[$articleID-1];
|
||||
$this->data['article'] = array_merge($this->data['article'], $this->cacher->{$source}($section, $this->data['article']['url'])[0]);
|
||||
$this->load->view('admin/data_post', $this->data);
|
||||
}else {
|
||||
$this->load->view('admin/data_'. $source, $this->data);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
122
application/controllers/admin/Navigation.php
Executable file
122
application/controllers/admin/Navigation.php
Executable file
@@ -0,0 +1,122 @@
|
||||
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
|
||||
|
||||
class Navigation extends CI_Controller {
|
||||
|
||||
function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
define("HOOSK_ADMIN",1);
|
||||
$this->load->model('Hoosk_model');
|
||||
$this->load->helper(array('admincontrol', 'url', 'form'));
|
||||
$this->load->library('session');
|
||||
define ('LANG', $this->Hoosk_model->getLang());
|
||||
$this->lang->load('admin', LANG);
|
||||
//Define what page we are on for nav
|
||||
$this->data['current'] = $this->uri->segment(2);
|
||||
define ('SITE_NAME', $this->Hoosk_model->getSiteName());
|
||||
define('THEME', $this->Hoosk_model->getTheme());
|
||||
define ('THEME_FOLDER', BASE_URL.'/theme/'.THEME);
|
||||
//check session exists
|
||||
Admincontrol_helper::is_logged_in($this->session->userdata('userName'));
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
$this->load->library('pagination');
|
||||
$result_per_page =15; // the number of result per page
|
||||
$config['base_url'] = BASE_URL. '/admin/navigation/';
|
||||
$config['total_rows'] = $this->Hoosk_model->countNavigation();
|
||||
$config['per_page'] = $result_per_page;
|
||||
|
||||
$this->pagination->initialize($config);
|
||||
|
||||
//Get pages from database
|
||||
$this->data['nav'] = $this->Hoosk_model->getAllNav($result_per_page, $this->uri->segment(3));
|
||||
$this->load->helper('form');
|
||||
//Load the view
|
||||
$this->data['header'] = $this->load->view('admin/header', $this->data, true);
|
||||
$this->data['footer'] = $this->load->view('admin/footer', '', true);
|
||||
$this->load->view('admin/navigation', $this->data);
|
||||
}
|
||||
|
||||
public function newNav()
|
||||
{
|
||||
//Get pages from database
|
||||
$this->data['pages'] = $this->Hoosk_model->getPagesAll();
|
||||
//Load the view
|
||||
$this->data['header'] = $this->load->view('admin/header', $this->data, true);
|
||||
$this->data['footer'] = $this->load->view('admin/footer', '', true);
|
||||
$this->load->view('admin/nav_new', $this->data);
|
||||
}
|
||||
|
||||
public function editNav()
|
||||
{
|
||||
//Get pages from database
|
||||
$this->data['pages'] = $this->Hoosk_model->getPagesAll();
|
||||
//Get navigation from database
|
||||
$this->data['nav'] = $this->Hoosk_model->getNav($this->uri->segment(4));
|
||||
//Load the view
|
||||
$this->data['header'] = $this->load->view('admin/header', $this->data, true);
|
||||
$this->data['footer'] = $this->load->view('admin/footer', '', true);
|
||||
$this->load->view('admin/nav_edit', $this->data);
|
||||
}
|
||||
|
||||
public function navAdd()
|
||||
{
|
||||
//Get navigation from database
|
||||
$this->data['page'] = $this->Hoosk_model->getPageNav($this->uri->segment(3));
|
||||
//Load the view
|
||||
$this->load->view('admin/nav_add', $this->data);
|
||||
}
|
||||
|
||||
public function insert()
|
||||
{
|
||||
//Load the form validation library
|
||||
$this->load->library('form_validation');
|
||||
|
||||
$this->form_validation->set_rules('navSlug', 'nav slug', 'trim|alpha_dash|required|max_length[10]|is_unique[cm_navigation.navSlug]');
|
||||
$this->form_validation->set_rules('navTitle', 'navigation title', 'trim|required');
|
||||
|
||||
if($this->form_validation->run() == FALSE) {
|
||||
//Validation failed
|
||||
$this->newNav();
|
||||
} else {
|
||||
//Validation passed
|
||||
$this->Hoosk_model->insertNav();
|
||||
//Return to navigation list
|
||||
redirect(BASE_URL.'/admin/navigation', 'refresh');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
public function update()
|
||||
{
|
||||
//Load the form validation library
|
||||
$this->load->library('form_validation');
|
||||
|
||||
$this->form_validation->set_rules('navTitle', 'navigation title', 'trim|required');
|
||||
|
||||
if($this->form_validation->run() == FALSE) {
|
||||
//Validation failed
|
||||
$this->editNav();
|
||||
} else {
|
||||
//Validation passed
|
||||
$this->Hoosk_model->updateNav($this->uri->segment(4));
|
||||
//Return to navigation list
|
||||
redirect(BASE_URL.'/admin/navigation', 'refresh');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function deleteNav()
|
||||
{
|
||||
if($this->input->post('deleteid')):
|
||||
$this->Hoosk_model->removeNav($this->input->post('deleteid'));
|
||||
redirect(BASE_URL.'/admin/navigation');
|
||||
else:
|
||||
$this->data['form']=$this->Hoosk_model->getNav($this->uri->segment(4));
|
||||
$this->load->view('admin/nav_delete.php', $this->data );
|
||||
endif;
|
||||
}
|
||||
}
|
||||
147
application/controllers/admin/Pages.php
Executable file
147
application/controllers/admin/Pages.php
Executable file
@@ -0,0 +1,147 @@
|
||||
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
|
||||
|
||||
class Pages extends CI_Controller {
|
||||
|
||||
function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
define("HOOSK_ADMIN",1);
|
||||
$this->load->model('Cmap_model');
|
||||
$this->load->helper(array('admincontrol', 'url', 'hoosk_admin', 'file', 'form'));
|
||||
$this->load->library('session');
|
||||
define ('LANG', $this->Cmap_model->getLang());
|
||||
$this->lang->load('admin', LANG);
|
||||
//Define what page we are on for nav
|
||||
$this->data['current'] = $this->uri->segment(2);
|
||||
define ('SITE_NAME', $this->Cmap_model->getSiteName());
|
||||
define('THEME', $this->Cmap_model->getTheme());
|
||||
define ('THEME_FOLDER', BASE_URL.'/theme/'.THEME);
|
||||
//check session exists
|
||||
Admincontrol_helper::is_logged_in($this->session->userdata('userName'));
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
$this->load->library('pagination');
|
||||
$result_per_page =15; // the number of result per page
|
||||
$config['base_url'] = BASE_URL. '/admin/pages/';
|
||||
$config['total_rows'] = $this->Cmap_model->countPages();
|
||||
$config['per_page'] = $result_per_page;
|
||||
$config['last_link'] = false;
|
||||
$config['first_link'] = false;
|
||||
$this->pagination->initialize($config);
|
||||
//Get pages from database
|
||||
$this->data['pages'] = $this->Cmap_model->getPages($result_per_page, $this->uri->segment(3));
|
||||
|
||||
//Load the view
|
||||
$this->data['header'] = $this->load->view('admin/header', $this->data, true);
|
||||
$this->data['footer'] = $this->load->view('admin/footer', '', true);
|
||||
$this->load->view('admin/pages', $this->data);
|
||||
}
|
||||
|
||||
public function addPage()
|
||||
{
|
||||
//Load the view
|
||||
$this->data['templates'] = get_filenames('theme/'.THEME.'/templates');
|
||||
$this->data['header'] = $this->load->view('admin/header', $this->data, true);
|
||||
$this->data['footer'] = $this->load->view('admin/footer', '', true);
|
||||
$this->load->view('admin/page_new', $this->data);
|
||||
}
|
||||
|
||||
public function confirm()
|
||||
{
|
||||
//Load the form validation library
|
||||
$this->load->library('form_validation');
|
||||
//Set validation rules
|
||||
$this->form_validation->set_rules('pageURL', 'page URL', 'trim|alpha_dash|required|is_unique[cm_page_attributes.pageURL]');
|
||||
$this->form_validation->set_rules('pageTitle', 'page title', 'trim|required');
|
||||
$this->form_validation->set_rules('navTitle', 'navigation title', 'trim|required');
|
||||
|
||||
if($this->form_validation->run() == FALSE) {
|
||||
//Validation failed
|
||||
$this->addPage();
|
||||
} else {
|
||||
//Validation passed
|
||||
//Add the page
|
||||
$this->load->library('Sioen');
|
||||
$this->Cmap_model->createPage();
|
||||
//Return to page list
|
||||
redirect(BASE_URL.'/admin/pages', 'refresh');
|
||||
}
|
||||
}
|
||||
|
||||
public function editPage()
|
||||
{
|
||||
//Get page details from database
|
||||
$this->data['pages'] = $this->Cmap_model->getPage($this->uri->segment(4));
|
||||
$this->data['categories'] = $this->Cmap_model->getCategories();
|
||||
//Load the view
|
||||
$this->data['templates'] = get_filenames('theme/'.THEME.'/templates');
|
||||
$this->data['header'] = $this->load->view('admin/header', $this->data, true);
|
||||
$this->data['footer'] = $this->load->view('admin/footer', '', true);
|
||||
$this->load->view('admin/page_edit', $this->data);
|
||||
}
|
||||
|
||||
public function edited()
|
||||
{
|
||||
//Load the form validation library
|
||||
$this->load->library('form_validation');
|
||||
//Set validation rules
|
||||
if ($this->uri->segment(4) != 1){
|
||||
$this->form_validation->set_rules('pageURL', 'page URL', 'trim|alpha_dash|required|is_unique[cm_page_attributes.pageURL.pageID.'.$this->uri->segment(4).']');
|
||||
}
|
||||
$this->form_validation->set_rules('pageTitle', 'page title', 'trim|required');
|
||||
$this->form_validation->set_rules('navTitle', 'navigation title', 'trim|required');
|
||||
|
||||
if($this->form_validation->run() == FALSE) {
|
||||
//Validation failed
|
||||
$this->editPage();
|
||||
} else {
|
||||
//Validation passed
|
||||
//Update the page
|
||||
$this->load->library('Sioen');
|
||||
$this->Cmap_model->updatePage($this->uri->segment(4));
|
||||
//Return to page list
|
||||
redirect(BASE_URL.'/admin/pages', 'refresh');
|
||||
}
|
||||
}
|
||||
|
||||
public function jumbo()
|
||||
{
|
||||
//Get page details from database
|
||||
$this->data['pages'] = $this->Cmap_model->getPage($this->uri->segment(4));
|
||||
$this->data['slides'] = $this->Cmap_model->getPageBanners($this->uri->segment(4));
|
||||
|
||||
//Load the view
|
||||
$this->data['header'] = $this->load->view('admin/header', $this->data, true);
|
||||
$this->data['footer'] = $this->load->view('admin/footer', '', true);
|
||||
$this->load->view('admin/jumbotron_edit', $this->data);
|
||||
}
|
||||
|
||||
public function jumboAdd()
|
||||
{
|
||||
$this->load->library('Sioen');
|
||||
$this->Cmap_model->updateJumbotron($this->uri->segment(4));
|
||||
redirect(BASE_URL.'/admin/pages', 'refresh');
|
||||
}
|
||||
|
||||
|
||||
|
||||
function delete()
|
||||
{
|
||||
if($this->input->post('deleteid')):
|
||||
$this->Cmap_model->removePage($this->input->post('deleteid'));
|
||||
redirect('/admin/pages');
|
||||
else:
|
||||
$this->data['form']=$this->Cmap_model->getPage($this->uri->segment(4));
|
||||
$this->load->view('admin/page_delete.php', $this->data );
|
||||
endif;
|
||||
}
|
||||
|
||||
function pageSearch()
|
||||
{
|
||||
$this->Cmap_model->pageSearch($this->input->post('term'));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
218
application/controllers/admin/Posts.php
Executable file
218
application/controllers/admin/Posts.php
Executable file
@@ -0,0 +1,218 @@
|
||||
<?php if (!defined('BASEPATH')) {
|
||||
exit('No direct script access allowed');
|
||||
}
|
||||
|
||||
class Posts extends MY_Controller
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
define("HOOSK_ADMIN", 1);
|
||||
parent::__construct();
|
||||
$this->load->model('Cmap_model');
|
||||
$this->load->helper(array('admincontrol', 'url', 'hoosk_admin', 'file', 'form'));
|
||||
$this->load->library('session');
|
||||
define('LANG', $this->data['settings']->siteLang);
|
||||
$this->lang->load('admin', LANG);
|
||||
//Define what page we are on for nav
|
||||
$this->data['current'] = $this->uri->segment(2);
|
||||
//check session exists
|
||||
Admincontrol_helper::is_logged_in($this->session->userdata('userName'));
|
||||
$this->load->helper('general');
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
$this->load->library('pagination');
|
||||
$result_per_page = 15; // the number of result per page
|
||||
$config['base_url'] = BASE_URL . '/admin/posts/';
|
||||
$config['total_rows'] = $this->Cmap_model->countPosts();
|
||||
$config['per_page'] = $result_per_page;
|
||||
$config['last_link'] = false;
|
||||
$config['first_link'] = false;
|
||||
$config['suffix'] = '?term=' . getSearchTerm();
|
||||
|
||||
$this->pagination->initialize($config);
|
||||
|
||||
//Get posts from database
|
||||
$this->data['posts'] = $this->post->getPosts($result_per_page, $this->uri->segment(3))
|
||||
->select("p.*, if(u.userName = '', if(u.nickname='', u.userID, u.nickname), u.userName) userName, '' as categoryTitle, c.categorySlug, '' as pageTitle")->get()->result_array();
|
||||
$this->category->getTableCategoryTitle($this->data['posts']);
|
||||
$this->page->getTablePageTitle($this->data['posts']);
|
||||
//Load the view
|
||||
$this->data['header'] = $this->load->view('admin/header', $this->data, true);
|
||||
$this->data['footer'] = $this->load->view('admin/footer', '', true);
|
||||
$this->load->view('admin/posts', $this->data);
|
||||
}
|
||||
|
||||
public function addPost()
|
||||
{
|
||||
$this->data['categories'] = array_merge([['categoryID' => 0, 'categoryTitle' => 'Select category']], $this->Cmap_model->getCategories());
|
||||
$this->data['pages'] = array_merge([['pageID' => 0, 'pageTitle' => 'Select page']], $this->Cmap_model->getPagesAll());
|
||||
//Load the view
|
||||
$this->data['header'] = $this->load->view('admin/header', $this->data, true);
|
||||
$this->data['footer'] = $this->load->view('admin/footer', '', true);
|
||||
$this->load->view('admin/post_new', $this->data);
|
||||
}
|
||||
|
||||
public function confirm()
|
||||
{
|
||||
//Load the form validation library
|
||||
$this->load->library('form_validation');
|
||||
//Set validation rules
|
||||
// $this->form_validation->set_rules('postURL', 'post URL', 'trim|alpha_dash|required|is_unique[cm_post.postURL]');
|
||||
$this->form_validation->set_rules('postTitle', 'post title', 'trim|required');
|
||||
$this->form_validation->set_rules('postExcerpt', 'post excerpt', 'trim|required');
|
||||
|
||||
if ($this->form_validation->run() == false) {
|
||||
|
||||
//Validation failed
|
||||
$this->addPost();
|
||||
} else {
|
||||
//Validation passed
|
||||
if ($this->input->post('postImage')) {
|
||||
//path to save the image
|
||||
$path_upload = $_SERVER["DOCUMENT_ROOT"] . '/uploads/';
|
||||
$path_images = $_SERVER["DOCUMENT_ROOT"] . '/images/' . date('Y/m/d/');
|
||||
|
||||
if (!file_exists($path_images) && !mkdir($path_images, 0775, true)) {
|
||||
die('Failed to create folders...');
|
||||
}
|
||||
//moving temporary file to images folder
|
||||
rename($path_upload . $this->input->post('postImage'), $path_images . $this->input->post('postImage'));
|
||||
}
|
||||
|
||||
if ($this->input->post('postThumb') || $this->input->post('postImageExternal')) {
|
||||
//path to save the image
|
||||
$path_upload = $_SERVER["DOCUMENT_ROOT"] . '/uploads/';
|
||||
$path_images = $_SERVER["DOCUMENT_ROOT"] . '/thumbs/' . date('Y/m/d/');
|
||||
|
||||
if (!file_exists($path_images) && !mkdir($path_images, 0775, true)) {
|
||||
die('Failed to create folders...');
|
||||
}
|
||||
//moving temporary file to images folder
|
||||
if ($this->input->post('postImageExternal')) {
|
||||
$this->load->helper('string');
|
||||
$_POST['postThumb'] = random_string() . '.' . pathinfo(parse_url($this->input->post('postImageExternal'))['path'], PATHINFO_EXTENSION);
|
||||
file_put_contents(
|
||||
$path_images . $this->input->post('postThumb'),
|
||||
file_get_contents($this->input->post('postImageExternal'))
|
||||
);
|
||||
} else {
|
||||
rename($path_upload . $this->input->post('postThumb'), $path_images . $this->input->post('postThumb'));
|
||||
}
|
||||
}
|
||||
|
||||
//Add the post
|
||||
$this->load->library('Sioen');
|
||||
$this->post->save();
|
||||
//Return to post list
|
||||
redirect(BASE_URL . '/admin/posts', 'refresh');
|
||||
}
|
||||
}
|
||||
|
||||
public function editPost()
|
||||
{
|
||||
$this->data['categories'] = array_merge([['categoryID' => 0, 'categoryTitle' => 'Select category']], $this->Cmap_model->getCategories());
|
||||
$this->data['pages'] = array_merge([['pageID' => 0, 'pageTitle' => 'Select page']], $this->Cmap_model->getPagesAll());
|
||||
//Get post details from database
|
||||
$this->data['posts'] = $this->post->getPost($this->uri->segment(4))->get()->result_array();
|
||||
$this->data['posts'][0]['postTag'] = json_encode($this->post->getPostTag($this->uri->segment(4))['tag']);
|
||||
$this->category->getTableCategoryTitle($this->data['posts']);
|
||||
$this->page->getTablePageTitle($this->data['posts']);
|
||||
|
||||
$this->load->model('user_model', 'user');
|
||||
$this->data['users'] = $this->user->getAdminSiteUsers();
|
||||
//Load the view
|
||||
$this->data['header'] = $this->load->view('admin/header', $this->data, true);
|
||||
$this->data['footer'] = $this->load->view('admin/footer', '', true);
|
||||
$this->data['video'] = 0;
|
||||
if ($video = $this->post->getPostVideo($this->uri->segment(4))) {
|
||||
$this->data['video'] = 1;
|
||||
$this->data['posts'][0]['postContentHTML'] .= $this->load->view('admin/youtube-iframe', $video, true);
|
||||
}
|
||||
$this->data['posts'][0]['articleURL'] = getPostLink($this->data['posts'][0], 'church');
|
||||
$this->load->view('admin/post_edit', $this->data);
|
||||
}
|
||||
|
||||
public function edited()
|
||||
{
|
||||
//Load the form validation library
|
||||
$this->load->library('form_validation');
|
||||
//Set validation rules
|
||||
// $this->form_validation->set_rules('postURL', 'post URL', 'trim|alpha_dash|required|is_unique[cm_post.postURL.postID.'.$this->uri->segment(4).']');
|
||||
$this->form_validation->set_rules('postTitle', 'post title', 'trim|required');
|
||||
|
||||
if ($this->form_validation->run() == false) {
|
||||
//Validation failed
|
||||
$this->editPost();
|
||||
} else {
|
||||
//Validation passed
|
||||
if ($this->input->post('postImage')) {
|
||||
//path to save the image
|
||||
$path_upload = $_SERVER["DOCUMENT_ROOT"] . '/uploads/';
|
||||
$path_images = $_SERVER["DOCUMENT_ROOT"] . '/images/' . date('Y/m/d/');
|
||||
//moving temporary file to images folder
|
||||
if (file_exists($path_images) || mkdir($path_images, 0775, true)) {
|
||||
rename($path_upload . $this->input->post('postImage'), $path_images . $this->input->post('postImage'));
|
||||
}
|
||||
}
|
||||
|
||||
if ($this->input->post('postThumb')) {
|
||||
//path to save the image
|
||||
$path_upload = $_SERVER["DOCUMENT_ROOT"] . '/uploads/';
|
||||
$path_images = $_SERVER["DOCUMENT_ROOT"] . '/thumbs/' . date('Y/m/d/');
|
||||
//moving temporary file to images folder
|
||||
if (file_exists($path_images) || mkdir($path_images, 0775, true)) {
|
||||
rename($path_upload . $this->input->post('postThumb'), $path_images . $this->input->post('postThumb'));
|
||||
}
|
||||
}
|
||||
//Update the post
|
||||
$this->load->library('Sioen');
|
||||
if($this->input->post('published') == '0') {
|
||||
$this->schedule([
|
||||
'postID' => $this->uri->segment(4),
|
||||
'run_at' => date('Y-m-d H:i:s', strtotime($this->input->post('dateReserved'))),
|
||||
'userID' => $this->session->userdata('userID')
|
||||
]);
|
||||
}
|
||||
$this->post->update($this->uri->segment(4));
|
||||
//Return to post list
|
||||
redirect(BASE_URL . '/admin/posts', 'refresh');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function delete()
|
||||
{
|
||||
if ($this->input->post('deleteid')) :
|
||||
$this->Cmap_model->removePost($this->input->post('deleteid'));
|
||||
redirect(BASE_URL . '/admin/posts');
|
||||
else :
|
||||
$this->data['form'] = $this->Cmap_model->getPost($this->uri->segment(4));
|
||||
$this->load->view('admin/post_delete.php', $this->data);
|
||||
endif;
|
||||
}
|
||||
|
||||
public function postSearch()
|
||||
{
|
||||
$this->Cmap_model->postSearch($this->input->post('term'));
|
||||
}
|
||||
|
||||
public function schedule($edit = null)
|
||||
{
|
||||
$data = is_null($edit) ? array(
|
||||
'postID' => $this->input->post('postID'),
|
||||
'run_at' => $this->input->post('run_at'),
|
||||
'userID' => $this->session->userdata('userID')
|
||||
) : $edit;
|
||||
|
||||
$this->db->where('postID', $data['postID'])->delete('cm_post_schedule');
|
||||
$this->db->insert('cm_post_schedule', $data);
|
||||
if(!$edit) {
|
||||
$this->output
|
||||
->set_status_header(200)
|
||||
->set_content_type('application/json')
|
||||
->set_output(json_encode(array('code' => 200)));
|
||||
}
|
||||
}
|
||||
}
|
||||
54
application/controllers/admin/Pray.php
Executable file
54
application/controllers/admin/Pray.php
Executable file
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
|
||||
|
||||
class Pray extends MY_Controller {
|
||||
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
define("HOOSK_ADMIN", 1);
|
||||
parent::__construct();
|
||||
$this->load->model('pray_model');
|
||||
$this->load->helper(array('admincontrol', 'url', 'hoosk_admin', 'file', 'form'));
|
||||
$this->load->library('session');
|
||||
define('LANG', $this->data['settings']->siteLang);
|
||||
$this->lang->load('admin', LANG);
|
||||
//Define what page we are on for nav
|
||||
$this->data['current'] = $this->uri->segment(2);
|
||||
//check session exists
|
||||
Admincontrol_helper::is_logged_in($this->session->userdata('userName'));
|
||||
$this->load->helper('general');
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
$this->load->library('pagination');
|
||||
$result_per_page = 15; // the number of result per page
|
||||
$config['base_url'] = BASE_URL . '/admin/pray/';
|
||||
$config['total_rows'] = $this->pray_model->getCountPaging();
|
||||
$config['per_page'] = $result_per_page;
|
||||
$config['last_link'] = false;
|
||||
$config['first_link'] = false;
|
||||
$config['suffix'] = '?term=' . getSearchTerm();
|
||||
|
||||
$this->pagination->initialize($config);
|
||||
|
||||
//Get posts from database
|
||||
$this->data['pray'] = $this->pray_model->getPaging($result_per_page, $this->uri->segment(3))
|
||||
->get()->result();
|
||||
$this->data['header'] = $this->load->view('admin/header', $this->data, true);
|
||||
$this->data['footer'] = $this->load->view('admin/footer', '', true);
|
||||
$this->load->view('admin/pray', $this->data);
|
||||
}
|
||||
|
||||
public function delete()
|
||||
{
|
||||
if ($this->input->post('deleteid')) :
|
||||
$this->pray_model->delete($this->input->post('deleteid'));
|
||||
redirect(BASE_URL . '/admin/pray');
|
||||
else :
|
||||
$this->data['form'] = [(array)$this->pray_model->getOne($this->uri->segment(4))];
|
||||
$this->load->view('admin/pray_delete.php', $this->data);
|
||||
endif;
|
||||
}
|
||||
}
|
||||
211
application/controllers/admin/Settings.php
Executable file
211
application/controllers/admin/Settings.php
Executable file
@@ -0,0 +1,211 @@
|
||||
<?php if (! defined('BASEPATH')) {
|
||||
exit('No direct script access allowed');
|
||||
}
|
||||
|
||||
class Settings extends CI_Controller
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
define("HOOSK_ADMIN", 1);
|
||||
$this->load->helper(array('admincontrol', 'url', 'hoosk_admin', 'form'));
|
||||
$this->load->library('session');
|
||||
$this->load->model('Cmap_model');
|
||||
define('LANG', $this->Cmap_model->getLang());
|
||||
$this->lang->load('admin', LANG);
|
||||
//Define what page we are on for nav
|
||||
$this->data['current'] = $this->uri->segment(2);
|
||||
define('SITE_NAME', $this->Cmap_model->getSiteName());
|
||||
define('THEME', $this->Cmap_model->getTheme());
|
||||
define('THEME_FOLDER', BASE_URL.'/theme/'.THEME);
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
Admincontrol_helper::is_logged_in($this->session->userdata('userName'));
|
||||
$this->load->helper('directory');
|
||||
$this->data['themesdir'] = directory_map($_SERVER["DOCUMENT_ROOT"].'/theme/', 1);
|
||||
$this->data['langdir'] = directory_map(APPPATH.'/language/', 1);
|
||||
|
||||
$this->data['settings'] = $this->Cmap_model->getSettings();
|
||||
$this->data['current'] = $this->uri->segment(2);
|
||||
$this->data['header'] = $this->load->view('admin/header', $this->data, true);
|
||||
$this->data['footer'] = $this->load->view('admin/footer', '', true);
|
||||
$this->load->view('admin/settings', $this->data);
|
||||
}
|
||||
|
||||
public function upload()
|
||||
{
|
||||
Admincontrol_helper::is_logged_in($this->session->userdata('userName'));
|
||||
$attachment = $this->input->post('attachment');
|
||||
$uploadedFile = $_FILES['attachment']['tmp_name']['file'];
|
||||
|
||||
$path = $_SERVER["DOCUMENT_ROOT"].'/images';
|
||||
$url = BASE_URL.'/images';
|
||||
|
||||
// create an image name
|
||||
$fileName = $attachment['name'];
|
||||
|
||||
// upload the image
|
||||
move_uploaded_file($uploadedFile, $path.'/'.$fileName);
|
||||
|
||||
$this->output->set_output(
|
||||
json_encode(array('file' => array(
|
||||
'url' => $url . '/' . $fileName,
|
||||
'filename' => $fileName
|
||||
))),
|
||||
200,
|
||||
array('Content-Type' => 'application/json')
|
||||
);
|
||||
}
|
||||
|
||||
public function updateSettings()
|
||||
{
|
||||
Admincontrol_helper::is_logged_in($this->session->userdata('userName'));
|
||||
$path_upload = $_SERVER["DOCUMENT_ROOT"] . '/uploads/';
|
||||
$path_images = $_SERVER["DOCUMENT_ROOT"] . '/images/';
|
||||
if ($this->input->post('siteLogo') != "") {
|
||||
rename($path_upload . $this->input->post('siteLogo'), $path_images . $this->input->post('siteLogo'));
|
||||
}
|
||||
if ($this->input->post('siteFavicon') != "") {
|
||||
rename($path_upload . $this->input->post('siteFavicon'), $path_images . $this->input->post('siteFavicon'));
|
||||
}
|
||||
$this->Cmap_model->updateSettings();
|
||||
redirect(BASE_URL.'/admin/settings/default', 'refresh');
|
||||
}
|
||||
|
||||
public function uploadLogo()
|
||||
{
|
||||
Admincontrol_helper::is_logged_in($this->session->userdata('userName'));
|
||||
$config['upload_path'] = FCPATH. '/uploads/';
|
||||
$config['allowed_types'] = 'gif|jpg|png';
|
||||
|
||||
$this->load->library('upload', $config);
|
||||
foreach ($_FILES as $key => $value) {
|
||||
if (! $this->upload->do_upload($key)) {
|
||||
$error = array('error' => $this->upload->display_errors());
|
||||
echo 0;
|
||||
} else {
|
||||
echo '"'.$this->upload->data('file_name').'"';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function social()
|
||||
{
|
||||
Admincontrol_helper::is_logged_in($this->session->userdata('userName'));
|
||||
$this->data['social'] = $this->Cmap_model->getSocial();
|
||||
$this->data['current'] = $this->uri->segment(2);
|
||||
$this->data['header'] = $this->load->view('admin/header', $this->data, true);
|
||||
$this->data['footer'] = $this->load->view('admin/footer', '', true);
|
||||
$this->load->view('admin/social', $this->data);
|
||||
}
|
||||
|
||||
public function updateSocial()
|
||||
{
|
||||
Admincontrol_helper::is_logged_in($this->session->userdata('userName'));
|
||||
$this->Cmap_model->updateSocial();
|
||||
redirect(BASE_URL.'/admin/settings/social', 'refresh');
|
||||
}
|
||||
|
||||
|
||||
public function roles()
|
||||
{
|
||||
Admincontrol_helper::is_logged_in($this->session->userdata('userName'));
|
||||
$this->load->library('pagination');
|
||||
$result_per_page =15; // the number of result per page
|
||||
$config['base_url'] = BASE_URL. '/admin/settings/roles/';
|
||||
$config['total_rows'] = $this->Cmap_model->countRoles();
|
||||
$config['per_page'] = $result_per_page;
|
||||
|
||||
$this->pagination->initialize($config);
|
||||
|
||||
//Get users from database
|
||||
$this->data['roles'] = $this->Cmap_model->getRoles($result_per_page, $this->uri->segment(4));
|
||||
|
||||
//Load the view
|
||||
$this->data['header'] = $this->load->view('admin/header', $this->data, true);
|
||||
$this->data['footer'] = $this->load->view('admin/footer', '', true);
|
||||
$this->load->view('admin/roles', $this->data);
|
||||
}
|
||||
|
||||
public function newRole()
|
||||
{
|
||||
Admincontrol_helper::is_logged_in($this->session->userdata('userName'));
|
||||
//Load the view
|
||||
$this->data['header'] = $this->load->view('admin/header', $this->data, true);
|
||||
$this->data['footer'] = $this->load->view('admin/footer', '', true);
|
||||
$this->load->view('admin/role_new', $this->data);
|
||||
}
|
||||
|
||||
public function addRole()
|
||||
{
|
||||
Admincontrol_helper::is_logged_in($this->session->userdata('userName'));
|
||||
//Load the form validation library
|
||||
$this->load->library('form_validation');
|
||||
//Set validation rules
|
||||
$this->form_validation->set_rules('name', 'role name', 'trim|required|is_unique[cm_setting_roles.name]');
|
||||
$this->form_validation->set_rules('slug', 'role slug', 'trim|required|is_unique[cm_setting_roles.slug]');
|
||||
|
||||
if($this->form_validation->run() == FALSE) {
|
||||
//Validation failed
|
||||
$this->newRole();
|
||||
} else {
|
||||
//Validation passed
|
||||
//Add the user
|
||||
$this->Cmap_model->createRole();
|
||||
//Return to user list
|
||||
redirect(BASE_URL.'/admin/settings/roles', 'refresh');
|
||||
}
|
||||
}
|
||||
|
||||
public function editRole()
|
||||
{
|
||||
Admincontrol_helper::is_logged_in($this->session->userdata('userName'));
|
||||
//Get user details from database
|
||||
$this->data['users'] = $this->Cmap_model->getRole($this->uri->segment(5));
|
||||
//Load the view
|
||||
$this->data['header'] = $this->load->view('admin/header', $this->data, true);
|
||||
$this->data['footer'] = $this->load->view('admin/footer', '', true);
|
||||
$this->load->view('admin/role_edit', $this->data);
|
||||
}
|
||||
|
||||
public function editedRole()
|
||||
{
|
||||
Admincontrol_helper::is_logged_in($this->session->userdata('userName'));
|
||||
//Load the form validation library
|
||||
$this->load->library('form_validation');
|
||||
//Set validation rules
|
||||
$this->form_validation->set_rules('name', 'email address', 'trim|required|is_unique[cm_setting_roles.name.roleID.'.$this->uri->segment(5).']');
|
||||
$this->form_validation->set_rules('slug', 'password', 'trim|required');
|
||||
|
||||
|
||||
if($this->form_validation->run() == FALSE) {
|
||||
//Validation failed
|
||||
$this->editRole();
|
||||
} else {
|
||||
//Validation passed
|
||||
//Update the user
|
||||
$this->Cmap_model->updateRole($this->uri->segment(5));
|
||||
//Return to user list
|
||||
redirect(BASE_URL.'/admin/settings/roles', 'refresh');
|
||||
}
|
||||
}
|
||||
|
||||
public function deleteRole()
|
||||
{
|
||||
Admincontrol_helper::is_logged_in($this->session->userdata('userName'));
|
||||
if($this->input->post('deleteid')):
|
||||
$this->Cmap_model->removeRole($this->input->post('deleteid'));
|
||||
redirect(BASE_URL.'/admin/settings/roles');
|
||||
else:
|
||||
$this->data['form']=$this->Cmap_model->getRole($this->uri->segment(5));
|
||||
$this->load->view('admin/role_delete.php', $this->data );
|
||||
endif;
|
||||
}
|
||||
|
||||
function roleSearch()
|
||||
{
|
||||
$this->Cmap_model->roleSearch($this->input->post('term'));
|
||||
}
|
||||
}
|
||||
253
application/controllers/admin/Users.php
Executable file
253
application/controllers/admin/Users.php
Executable file
@@ -0,0 +1,253 @@
|
||||
<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
|
||||
|
||||
class Users extends CI_Controller
|
||||
{
|
||||
|
||||
function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
define("HOOSK_ADMIN", 1);
|
||||
$this->load->model('Cmap_model');
|
||||
$this->load->helper(array('admincontrol', 'url', 'form'));
|
||||
$this->load->library('session');
|
||||
define('LANG', $this->Cmap_model->getLang());
|
||||
$this->lang->load('admin', LANG);
|
||||
//Define what page we are on for nav
|
||||
$this->data['current'] = $this->uri->segment(2);
|
||||
define('SITE_NAME', $this->Cmap_model->getSiteName());
|
||||
define('THEME', $this->Cmap_model->getTheme());
|
||||
define('THEME_FOLDER', BASE_URL . '/theme/' . THEME);
|
||||
$this->load->helper('general');
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
Admincontrol_helper::is_logged_in($this->session->userdata('userName'));
|
||||
$this->load->library('pagination');
|
||||
$result_per_page = 15; // the number of result per page
|
||||
$config['base_url'] = BASE_URL . '/admin/users/';
|
||||
$config['total_rows'] = $this->Cmap_model->countUsers();
|
||||
$config['per_page'] = $result_per_page;
|
||||
$config['suffix'] = '?term='. getSearchTerm();
|
||||
$config['last_link'] = false;
|
||||
$config['first_link'] = false;
|
||||
|
||||
$this->pagination->initialize($config);
|
||||
|
||||
//Get users from database
|
||||
$this->data['users'] = $this->Cmap_model->getUsers($result_per_page, $this->uri->segment(3));
|
||||
|
||||
//Load the view
|
||||
$this->data['header'] = $this->load->view('admin/header', $this->data, true);
|
||||
$this->data['footer'] = $this->load->view('admin/footer', '', true);
|
||||
$this->load->view('admin/users', $this->data);
|
||||
}
|
||||
|
||||
public function addUser()
|
||||
{
|
||||
Admincontrol_helper::is_logged_in($this->session->userdata('userName'));
|
||||
//Load the view
|
||||
$this->data['header'] = $this->load->view('admin/header', $this->data, true);
|
||||
$this->data['footer'] = $this->load->view('admin/footer', '', true);
|
||||
$this->data['roles'] = ['0' => 'Roles'];
|
||||
foreach($this->Cmap_model->getRoles(10000) as $r) {
|
||||
$this->data['roles'][$r['roleID']] = $r['name'];
|
||||
}
|
||||
$this->load->view('admin/user_new', $this->data);
|
||||
}
|
||||
|
||||
public function confirm()
|
||||
{
|
||||
Admincontrol_helper::is_logged_in($this->session->userdata('userName'));
|
||||
//Load the form validation library
|
||||
$this->load->library('form_validation');
|
||||
//Set validation rules
|
||||
$this->form_validation->set_rules('username', 'username', 'trim|alpha_dash|required|is_unique[cm_user.userName]');
|
||||
$this->form_validation->set_rules('email', 'email address', 'trim|required|valid_email|is_unique[cm_user.email]');
|
||||
$this->form_validation->set_rules('password', 'password', 'trim|required|min_length[4]|max_length[32]');
|
||||
$this->form_validation->set_rules('con_password', 'confirm password', 'trim|required|matches[password]');
|
||||
|
||||
|
||||
if ($this->form_validation->run() == FALSE) {
|
||||
//Validation failed
|
||||
$this->addUser();
|
||||
} else {
|
||||
//Validation passed
|
||||
//Add the user
|
||||
$this->Cmap_model->createUser();
|
||||
//Return to user list
|
||||
redirect(BASE_URL . '/admin/users', 'refresh');
|
||||
}
|
||||
}
|
||||
|
||||
public function editUser()
|
||||
{
|
||||
Admincontrol_helper::is_logged_in($this->session->userdata('userName'));
|
||||
//Get user details from database
|
||||
$this->data['users'] = $this->Cmap_model->getUser($this->uri->segment(4));
|
||||
//Load the view
|
||||
$this->data['header'] = $this->load->view('admin/header', $this->data, true);
|
||||
$this->data['footer'] = $this->load->view('admin/footer', '', true);
|
||||
$this->data['roles'] = ['0' => 'Roles'];
|
||||
foreach($this->Cmap_model->getRoles(10000) as $r) {
|
||||
$this->data['roles'][$r['roleID']] = $r['name'];
|
||||
}
|
||||
$this->load->view('admin/user_edit', $this->data);
|
||||
}
|
||||
|
||||
public function edited()
|
||||
{
|
||||
Admincontrol_helper::is_logged_in($this->session->userdata('userName'));
|
||||
//Load the form validation library
|
||||
$this->load->library('form_validation');
|
||||
//Set validation rules
|
||||
$this->form_validation->set_rules('email', 'email address', 'trim|required|valid_email|is_unique[cm_user.email.userID.' . $this->uri->segment(4) . ']');
|
||||
$this->form_validation->set_rules('password', 'password', 'trim|min_length[4]|max_length[32]');
|
||||
$this->form_validation->set_rules('con_password', 'confirm password', 'trim|matches[password]');
|
||||
|
||||
|
||||
if ($this->form_validation->run() == FALSE) {
|
||||
//Validation failed
|
||||
$this->editUser();
|
||||
} else {
|
||||
//Validation passed
|
||||
//Update the user
|
||||
$this->Cmap_model->updateUser($this->uri->segment(4));
|
||||
//Return to user list
|
||||
redirect(BASE_URL . '/admin/users', 'refresh');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function delete()
|
||||
{
|
||||
Admincontrol_helper::is_logged_in($this->session->userdata('userName'));
|
||||
if ($this->input->post('deleteid')) :
|
||||
$this->Cmap_model->removeUser($this->input->post('deleteid'));
|
||||
redirect(BASE_URL . '/admin/users');
|
||||
else :
|
||||
$this->data['form'] = $this->Cmap_model->getUser($this->uri->segment(4));
|
||||
$this->load->view('admin/user_delete.php', $this->data);
|
||||
endif;
|
||||
}
|
||||
|
||||
/************** Forgotten Password Resets **************/
|
||||
|
||||
public function forgot()
|
||||
{
|
||||
$this->load->library('form_validation');
|
||||
$this->form_validation->set_rules('email', 'Email', 'trim|required|valid_email|callback_email_check');
|
||||
if ($this->form_validation->run() == FALSE) {
|
||||
$this->data['header'] = $this->load->view('admin/headerlog', $this->data, true);
|
||||
$this->data['footer'] = $this->load->view('admin/footer', '', true);
|
||||
$this->load->view('admin/email_check', $this->data);
|
||||
} else {
|
||||
$email = $this->input->post('email');
|
||||
$this->load->helper('string');
|
||||
$rs = random_string('alnum', 12);
|
||||
$data = array(
|
||||
'rs' => $rs
|
||||
);
|
||||
$this->db->where('email', $email);
|
||||
$this->db->update('cm_user', $data);
|
||||
|
||||
//now we will send an email
|
||||
$config['protocol'] = 'sendmail';
|
||||
$config['mailpath'] = '/usr/sbin/sendmail';
|
||||
$config['charset'] = 'iso-8859-1';
|
||||
$config['wordwrap'] = TRUE;
|
||||
|
||||
|
||||
$this->load->library('email', $config);
|
||||
|
||||
$this->email->from('password@' . EMAIL_URL, SITE_NAME);
|
||||
$this->email->to($email);
|
||||
|
||||
$this->email->subject($this->lang->line('email_reset_subject'));
|
||||
$this->email->message($this->lang->line('email_reset_message') . "\r\n" . BASE_URL . '/admin/reset/' . $rs);
|
||||
|
||||
$this->email->send();
|
||||
$this->data['header'] = $this->load->view('admin/headerlog', $this->data, true);
|
||||
$this->data['footer'] = $this->load->view('admin/footer', '', true);
|
||||
$this->load->view('admin/check', $this->data);
|
||||
}
|
||||
}
|
||||
|
||||
public function email_check($str)
|
||||
{
|
||||
$query = $this->db->get_where('cm_user', array('email' => $str), 1);
|
||||
if ($query->num_rows() == 1) {
|
||||
return true;
|
||||
} else {
|
||||
$this->form_validation->set_message('email_check', $this->lang->line('email_check'));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function getPassword()
|
||||
{
|
||||
$rs = $this->uri->segment(3);
|
||||
$query = $this->db->get_where('cm_user', array('rs' => $rs), 1);
|
||||
|
||||
if ($query->num_rows() == 0) {
|
||||
$this->data['header'] = $this->load->view('admin/headerlog', $this->data, true);
|
||||
$this->data['footer'] = $this->load->view('admin/footer', '', true);
|
||||
$this->load->view('admin/error', $this->data);
|
||||
} else {
|
||||
$this->load->database();
|
||||
$this->load->helper('url');
|
||||
$this->load->library('form_validation');
|
||||
$this->form_validation->set_rules('password', 'Password', 'trim|required|min_length[4]|max_length[20]|matches[con_password]');
|
||||
$this->form_validation->set_rules('con_password', 'Password Confirmation', 'trim|required');
|
||||
if ($this->form_validation->run() == FALSE) {
|
||||
echo form_open();
|
||||
$this->data['header'] = $this->load->view('admin/headerlog', $this->data, true);
|
||||
$this->data['footer'] = $this->load->view('admin/footer', '', true);
|
||||
$this->load->view('admin/resetform', $this->data);
|
||||
} else {
|
||||
$query = $this->db->get_where('cm_user', array('rs' => $rs), 1);
|
||||
if ($query->num_rows() == 0) {
|
||||
show_error('Sorry!!! Invalid Request!');
|
||||
} else {
|
||||
$data = array(
|
||||
'password' => md5($this->input->post('password') . SALT),
|
||||
'rs' => ''
|
||||
);
|
||||
$where = $this->db->where('rs', $rs);
|
||||
$where->update('cm_user', $data);
|
||||
$this->data['header'] = $this->load->view('admin/headerlog', $this->data, true);
|
||||
$this->data['footer'] = $this->load->view('admin/footer', '', true);
|
||||
$this->load->view('admin/reset', $this->data);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function roles()
|
||||
{
|
||||
Admincontrol_helper::is_logged_in($this->session->userdata('userName'));
|
||||
$this->load->library('pagination');
|
||||
$result_per_page = 15; // the number of result per page
|
||||
$config['base_url'] = BASE_URL . '/admin/users/';
|
||||
$config['total_rows'] = $this->Cmap_model->countUsers();
|
||||
$config['per_page'] = $result_per_page;
|
||||
$config['last_link'] = false;
|
||||
$config['first_link'] = false;
|
||||
|
||||
$this->pagination->initialize($config);
|
||||
|
||||
//Get users from database
|
||||
$this->data['users'] = $this->Cmap_model->getUsers($result_per_page, $this->uri->segment(3));
|
||||
|
||||
//Load the view
|
||||
$this->data['header'] = $this->load->view('admin/header', $this->data, true);
|
||||
$this->data['footer'] = $this->load->view('admin/footer', '', true);
|
||||
$this->load->view('admin/roles', $this->data);
|
||||
}
|
||||
|
||||
public function userSearch()
|
||||
{
|
||||
$this->Cmap_model->userSearch(getSearchTerm());
|
||||
}
|
||||
}
|
||||
715
application/controllers/admin/Webtoons.php
Executable file
715
application/controllers/admin/Webtoons.php
Executable file
@@ -0,0 +1,715 @@
|
||||
<?php
|
||||
defined('BASEPATH') or exit('No direct script access allowed');
|
||||
|
||||
class Webtoons extends CI_Controller
|
||||
{
|
||||
public $tb_name_category = 'wt_categories';
|
||||
public $tb_name_episode = 'mt_episodes';
|
||||
public $tb_name_webtoon_list = 'wt_list';
|
||||
public $tb_name_notice = 'wt_announcement';
|
||||
public $tb_name_cartoonist = 'wt_cartoonists';
|
||||
public $tb_name_post = 'cm_post';
|
||||
public $display_limit = 15; // total # of list
|
||||
public $list_limit = 10; // total # of pages
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
// $this->load->library('util');
|
||||
define("HOOSK_ADMIN", 1);
|
||||
$this->load->language('webtoon');
|
||||
$this->load->model('Hoosk_model');
|
||||
$this->load->model('wtoon_model');
|
||||
$this->load->helper(array('admincontrol', 'url', 'form'));
|
||||
$this->load->library('session');
|
||||
define('LANG', $this->Hoosk_model->getLang());
|
||||
$this->lang->load('admin', LANG);
|
||||
//Define what page we are on for nav
|
||||
$this->data['current'] = $this->uri->segment(2);
|
||||
define('SITE_NAME', $this->Hoosk_model->getSiteName());
|
||||
define('THEME', $this->Hoosk_model->getTheme());
|
||||
define('THEME_FOLDER', BASE_URL.'/theme/'.THEME);
|
||||
//check session exists
|
||||
Admincontrol_helper::is_logged_in($this->session->userdata('userName'));
|
||||
}
|
||||
|
||||
/*
|
||||
@desc : list all maptoons
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$this->load->library('pagination');
|
||||
$result_per_page = $this->display_limit; // the number of result per page
|
||||
$config['base_url'] = BASE_URL. '/admin/webtoons/';
|
||||
$config['total_rows'] = $this->wtoon_model->countWebtoon();
|
||||
$config['per_page'] = $result_per_page;
|
||||
|
||||
$this->pagination->initialize($config);
|
||||
|
||||
//Get webtoons from database
|
||||
$this->data['webtoons'] = $this->wtoon_model->getWebtoons($arr='', $result_per_page, $this->uri->segment(3));
|
||||
$this->data['posts'] = $this->Hoosk_model->getPosts($result_per_page, $this->uri->segment(3));
|
||||
//Load the view
|
||||
$this->data['header'] = $this->load->view('admin/header', $this->data, true);
|
||||
$this->data['footer'] = $this->load->view('admin/footer', '', true);
|
||||
|
||||
// $query_string = ['status'=>1, 'wt_cartoonists_idx'=>1];
|
||||
$query_string = [];
|
||||
$arr_cartoonist = $this->wtoon_model->get_cartoonist_list();
|
||||
$this->data['cartoonists'] = $arr_cartoonist;
|
||||
|
||||
$this->load->view('/admin/webtoon/webtoon', $this->data);
|
||||
}
|
||||
|
||||
/*
|
||||
@desc : register webtoon
|
||||
*/
|
||||
public function webtoon_proc()
|
||||
{
|
||||
$idx = $this->input->post('idx');
|
||||
$mode = $this->input->post('mode');
|
||||
$wt_cartoonists_idx = $this->input->post('wt_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 ($wt_cartoonists_idx=='') {
|
||||
// $this->util->js_alert_back('맵툰작가를 선택해주세요');
|
||||
exit;
|
||||
}
|
||||
|
||||
$this->load->model('m_webtoon');
|
||||
if ($idx!=0) {
|
||||
$maptoon_info = $this->wtoon_model->getWebtoons(['idx' => $idx]);
|
||||
}
|
||||
|
||||
|
||||
//이미지 업로드
|
||||
if ($_FILES['main_img']['name']!='') {
|
||||
$mid_url_path = date("Y")."/".date("m");
|
||||
$upload_path = WEBTOON_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) ? WEBTOON_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"),
|
||||
'wt_cartoonists_idx' => $wt_cartoonists_idx];
|
||||
|
||||
if (is_numeric($idx)==true && $idx>0) { // update data
|
||||
$ret = $this->wtoon_model->updateWebtoon($idx, $data);
|
||||
if ($ret==true) {
|
||||
$result['status'] = 1;
|
||||
$result['message'] ='수정되었습니다.';
|
||||
echo json_encode($result);
|
||||
exit;
|
||||
} else {
|
||||
$result['status'] = 0;
|
||||
$result['message'] = '등록되지 않았습니다. 다시 시도해 주세요';
|
||||
echo json_encode($result);
|
||||
exit;
|
||||
}
|
||||
} else { // insert data
|
||||
$ret = $this->wtoon_model->insertWebtoon($data);
|
||||
if ($ret==true) {
|
||||
$result['status'] = 1;
|
||||
$result['message'] = '등록되었습니다.';
|
||||
echo json_encode($result);
|
||||
exit;
|
||||
} else {
|
||||
$result['status'] = 0;
|
||||
$result['message'] = '등록되지 않았습니다. 다시 시도해 주세요';
|
||||
echo json_encode($result);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
@desc : delete webtoon info
|
||||
*/
|
||||
public function webtoon_delete()
|
||||
{
|
||||
if ($this->input->post('deleteid')):
|
||||
$this->wtoon_model->removeWebtoon($this->input->post('deleteid'));
|
||||
redirect(BASE_URL.'/admin/webtoons'); else:
|
||||
$this->data['form']=$this->wtoon_model->getWebtoon($this->uri->segment(4));
|
||||
$this->load->view('admin/webtoon/webtoon_delete.php', $this->data);
|
||||
endif;
|
||||
}
|
||||
|
||||
/*
|
||||
@desc : list all cartoonists
|
||||
*/
|
||||
public function cartoonist()
|
||||
{
|
||||
//Load the view
|
||||
$this->data['header'] = $this->load->view('admin/header', $this->data, true);
|
||||
$this->data['footer'] = $this->load->view('admin/footer', '', true);
|
||||
|
||||
$idx = $this->input->get('idx');
|
||||
|
||||
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;
|
||||
|
||||
$this->data['cartoonists']= array();
|
||||
foreach ($query->result_array() as $row) {
|
||||
$this->data['cartoonists'][$i] = $row;
|
||||
$i++;
|
||||
}
|
||||
$this->load->view('/admin/webtoon/cartoonist', $this->data);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
@desc : register & modify cartoonist info
|
||||
*/
|
||||
public function 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 (isset($idx) && $idx!='0' && $idx!='') {
|
||||
$data = ['name' => $name,
|
||||
'website' => $website];
|
||||
$this->db->where('idx', $idx);
|
||||
$ret = $this->db->update($this->tb_name_cartoonist, $data);
|
||||
if ($ret==true) {
|
||||
$result['status'] = 1;
|
||||
$result['message'] = "수정성공";
|
||||
} else {
|
||||
$result['status'] = 0;
|
||||
$result['message'] = '수정 실패 관리자에게 문의';
|
||||
}
|
||||
} else {
|
||||
$data = [
|
||||
'name' => $name,
|
||||
'website' => $website
|
||||
];
|
||||
$ret = $this->db->insert($this->tb_name_cartoonist, $data);
|
||||
if ($ret==true) {
|
||||
$result['status'] = 1;
|
||||
$result['message'] = "등록성공";
|
||||
} else {
|
||||
$result['status'] = 0;
|
||||
$result['message'] = "등록 실패";
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$result['status'] = 0;
|
||||
$result['message'] = 'All fields are required';
|
||||
}
|
||||
echo json_encode($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
/*
|
||||
@desc : delete cartoonist info
|
||||
*/
|
||||
public function cartoonist_delete()
|
||||
{
|
||||
if ($this->input->post('deleteid')):
|
||||
$this->wtoon_model->removeCartoonist($this->input->post('deleteid'));
|
||||
redirect(BASE_URL.'/admin/webtoons/cartoonist'); else:
|
||||
$this->data['form']=$this->wtoon_model->getCartoonist($this->uri->segment(5));
|
||||
$this->load->view('admin/webtoon/cartoonist_delete.php', $this->data);
|
||||
endif;
|
||||
}
|
||||
|
||||
/*
|
||||
@desc : show list of maptoon announcement
|
||||
@param: numeric; idx of announcement table
|
||||
*/
|
||||
public function announcement()
|
||||
{
|
||||
|
||||
//Load the view
|
||||
$this->data['header'] = $this->load->view('admin/header', $this->data, true);
|
||||
$this->data['footer'] = $this->load->view('admin/footer', '', true);
|
||||
//Get Webtoons
|
||||
$this->data['webtoons'] = $this->wtoon_model->getWebtoons($arr='', 0, 0);
|
||||
|
||||
$this->data['announcements']=$this->wtoon_model->getAnnouncements();
|
||||
|
||||
$this->load->view('/admin/webtoon/announcement', $this->data);
|
||||
}
|
||||
|
||||
/*
|
||||
@desc : register announcement
|
||||
*/
|
||||
public function announcement_proc()
|
||||
{
|
||||
$idx = $this->input->post('idx');
|
||||
$wt_list_idx = $this->input->post('wt_list_idx');
|
||||
$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 (isset($idx) && $idx!='0' && $idx!='') {
|
||||
$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) {
|
||||
$result['status'] = 1;
|
||||
$result['message'] = '수정되었습니다.';
|
||||
} else {
|
||||
$result['status'] = 0;
|
||||
$result['message'] = '수정 실패 관리자에게 문의';
|
||||
}
|
||||
} else {
|
||||
$data=[
|
||||
'wt_list_idx' => $wt_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) {
|
||||
$result['status'] = 1;
|
||||
$result['message'] = '등록되었습니다.';
|
||||
} else {
|
||||
$result['status'] = 0;
|
||||
$result['message'] = '등록 실패 관리자에게 문의';
|
||||
}
|
||||
}
|
||||
echo json_encode($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
/*
|
||||
@desc : delete maptoon announcement
|
||||
*/
|
||||
public function announcement_delete()
|
||||
{
|
||||
if ($this->input->post('deleteid')):
|
||||
$this->wtoon_model->removeAnnouncement($this->input->post('deleteid'));
|
||||
redirect(BASE_URL.'/admin/webtoons/announcement'); else:
|
||||
$this->data['form']=$this->wtoon_model->getAnnouncements($this->uri->segment(5));
|
||||
$this->load->view('admin/webtoon/announcement_delete.php', $this->data);
|
||||
endif;
|
||||
}
|
||||
|
||||
/*
|
||||
@desc : show list of maptoon episodes
|
||||
*/
|
||||
public function episode()
|
||||
{
|
||||
$this->load->library('pagination');
|
||||
$result_per_page = $this->display_limit; // the number of result per page
|
||||
$config['base_url'] = BASE_URL. '/admin/webtoons/episode/';
|
||||
$config['total_rows'] = $this->wtoon_model->countEpisodes(0);
|
||||
$config['per_page'] = $result_per_page;
|
||||
|
||||
$this->pagination->initialize($config);
|
||||
|
||||
$return_data['list'] = $result = array();
|
||||
|
||||
$arr_cartoonist = $this->wtoon_model->get_cartoonist_list(); //작가 이름
|
||||
|
||||
//Load the view
|
||||
$this->data['header'] = $this->load->view('admin/header', $this->data, true);
|
||||
$this->data['footer'] = $this->load->view('admin/footer', '', true);
|
||||
|
||||
$arr_webtoon = $this->wtoon_model->getWebtoons(); //맵툰 이름 리스트
|
||||
$req_data['limit'] = $result_per_page;
|
||||
$req_data['offset'] = $this->uri->segment(4);
|
||||
$episode = $this->wtoon_model->getEpisode($req_data);
|
||||
|
||||
$this->data['episode'] = $episode;
|
||||
$this->data['arr_cartoonist'] = $arr_cartoonist;
|
||||
$this->data['arr_webtoon'] = $arr_webtoon;
|
||||
|
||||
$this->load->view('/admin/webtoon/episode', $this->data);
|
||||
}
|
||||
|
||||
public function addEpisode()
|
||||
{
|
||||
$return_data['list'] = $result = array();
|
||||
|
||||
//Load the view
|
||||
$this->data['header'] = $this->load->view('admin/header', $this->data, true);
|
||||
$this->data['footer'] = $this->load->view('admin/footer', '', true);
|
||||
|
||||
$arr_webtoon = $this->wtoon_model->getWebtoons(); // 맵툰 이름 리스트
|
||||
|
||||
$this->data['arr_webtoon'] = $arr_webtoon;
|
||||
|
||||
$this->load->view('/admin/webtoon/episode_new', $this->data);
|
||||
}
|
||||
|
||||
public function confirmEpisode()
|
||||
{
|
||||
$postID = ($this->wtoon_model->getInsertPostID()[0]['postID'])+1;
|
||||
$postTitle = $this->input->post('postTitle');
|
||||
$wt_list_idx = $this->input->post('wt_list_idx');
|
||||
$unixStamp = time();
|
||||
$datePosted = $this->input->post('datePosted');
|
||||
$postContentHTML = $this->input->post('contents');
|
||||
strtotime($datePosted)>$unixStamp? $published = 0 : $published = 1;
|
||||
$ep_no = $this->input->post('ep_no');
|
||||
|
||||
//이미지 업로드
|
||||
if ($_FILES['postImage']['name']!='') {
|
||||
$mid_url_path = date("Y")."/".date("m");
|
||||
$upload_path = WEBTOON_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('postImage')) {
|
||||
$error = array('error' => $this->upload->display_errors());
|
||||
echo "이미지 업로드 실패";
|
||||
}
|
||||
$arr_upload_data = $this->upload->data();
|
||||
$postImage = (isset($arr_upload_data['file_name'])==true) ? WEBTOON_DIR_FRONT.$mid_url_path.'/'.$arr_upload_data['file_name'] : '';
|
||||
|
||||
//remove previous image
|
||||
if (isset($webtoon_info[0])==true && $postImage!='') {
|
||||
$postImage = $webtoon_info[0]['postImage'];
|
||||
if ($main_img!='') {
|
||||
unlink($_SERVER['DOCUMENT_ROOT'].$main_img);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$postImage = (isset($webtoon_info[0]['postImage'])==true) ? $webtoon_info[0]['postImage'] : '';
|
||||
}
|
||||
|
||||
|
||||
$data = [
|
||||
'postID' => $postID,
|
||||
'postURL' => $postID,
|
||||
'postTitle' => htmlspecialchars($postTitle),
|
||||
'postExcerpt' => "",
|
||||
'postContentHTML' => htmlspecialchars($postContentHTML),
|
||||
'postContent' => "",
|
||||
'postImage' => $postImage,
|
||||
'categoryID' => 20000,
|
||||
'published' => $published,
|
||||
'datePosted' => $datePosted,
|
||||
'dateUpdated' => date("Y-m-d h:i:s", $unixStamp),
|
||||
'unixStamp' => $unixStamp
|
||||
];
|
||||
|
||||
$this->wtoon_model->insertWebtoonPost($data);
|
||||
|
||||
$data = [
|
||||
'postID' => $postID,
|
||||
'wt_list_idx' => $wt_list_idx,
|
||||
'recommend_count' => 0,
|
||||
'view_count' => 0,
|
||||
'grade' => 0,
|
||||
'grade_total' => 0,
|
||||
'ep_no' => $ep_no
|
||||
];
|
||||
|
||||
$this->wtoon_model->insertEpisode($data);
|
||||
|
||||
//Return to post list
|
||||
redirect(BASE_URL.'/admin/webtoons/episode', 'refresh');
|
||||
}
|
||||
|
||||
public function add_episode_image()
|
||||
{
|
||||
$this->load->view('/admin/webtoon/add_episode_image');
|
||||
}
|
||||
|
||||
public function add_episode_image_upload()
|
||||
{
|
||||
if ($_FILES['uploadInputBox']['name']!='') {
|
||||
$mid_url_path = date("Y")."/".date("m");
|
||||
$upload_path = WEBTOON_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('uploadInputBox')) {
|
||||
$error = array('error' => $this->upload->display_errors());
|
||||
}
|
||||
$arr_upload_data = $this->upload->data();
|
||||
|
||||
/*echo ('<script language=\"javascript\">
|
||||
var tempImg = \'<div class="center-align"><img src="'.WEBTOON_DIR_FRONT.$mid_url_path.'/'.$arr_upload_data['file_name'].'" title="" alt="comic content"></div>\';
|
||||
opener.tinymce.activeEditor.execCommand("mceInsertContent","false",tempImg);
|
||||
</script>
|
||||
');*/
|
||||
echo WEBTOON_DIR_FRONT.$mid_url_path.'/'.$arr_upload_data['file_name'];
|
||||
}
|
||||
}
|
||||
|
||||
public function editEpisode()
|
||||
{
|
||||
//Load the view
|
||||
$this->data['header'] = $this->load->view('admin/header', $this->data, true);
|
||||
$this->data['footer'] = $this->load->view('admin/footer', '', true);
|
||||
|
||||
$arr_webtoon = $this->wtoon_model->getWebtoons(); // 맵툰 이름 리스트
|
||||
$this->data['arr_webtoon'] = $arr_webtoon;
|
||||
|
||||
$postID=$this->uri->segment(5);
|
||||
$req_data['postID']= $postID;
|
||||
$episode = $this->wtoon_model->getEpisode($req_data);
|
||||
$this->data['episode'] = $episode;
|
||||
$this->load->view('/admin/webtoon/episode_edit', $this->data);
|
||||
}
|
||||
|
||||
public function editedEpisode()
|
||||
{
|
||||
$postID = $this->input->post('postID');
|
||||
$postTitle = $this->input->post('postTitle');
|
||||
$wt_list_idx = $this->input->post('wt_list_idx');
|
||||
$unixStamp = time();
|
||||
$datePosted = $this->input->post('datePosted');
|
||||
$postContentHTML = $this->input->post('contents');
|
||||
strtotime($datePosted)>$unixStamp? $published = 0 : $published = 1;
|
||||
$ep_no = $this->input->post('ep_no');
|
||||
|
||||
$req_data['postID']= $postID;
|
||||
$webtoon_info = $this->wtoon_model->getEpisode($req_data);
|
||||
|
||||
//이미지 업로드
|
||||
if ($_FILES['postImage']['name']!='') {
|
||||
$mid_url_path = date("Y")."/".date("m");
|
||||
$upload_path = WEBTOON_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('postImage')) {
|
||||
$error = array('error' => $this->upload->display_errors());
|
||||
echo "이미지 업로드 실패";
|
||||
}
|
||||
$arr_upload_data = $this->upload->data();
|
||||
$postImage = (isset($arr_upload_data['file_name'])==true) ? WEBTOON_DIR_FRONT.$mid_url_path.'/'.$arr_upload_data['file_name'] : '';
|
||||
|
||||
//remove previous image
|
||||
if (isset($webtoon_info[0])==true && $postImage!='') {
|
||||
$postImage = $webtoon_info[0]['postImage'];
|
||||
if ($postImage!='') {
|
||||
unlink($_SERVER['DOCUMENT_ROOT'].$postImage);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$postImage = (isset($webtoon_info[0]['postImage'])==true) ? $webtoon_info[0]['postImage'] : '';
|
||||
}
|
||||
|
||||
$data = [
|
||||
'postID' => $postID,
|
||||
'postURL' => $postID,
|
||||
'postTitle' => htmlspecialchars($postTitle),
|
||||
'postExcerpt' => "",
|
||||
'postContentHTML' => htmlspecialchars($postContentHTML),
|
||||
'postContent' => "",
|
||||
'postImage' => $postImage,
|
||||
'categoryID' => 20000,
|
||||
'published' => $published,
|
||||
'datePosted' => $datePosted,
|
||||
'dateUpdated' => date("Y-m-d h:i:s", $unixStamp),
|
||||
];
|
||||
|
||||
$this->wtoon_model->updateWebtoonPost($data);
|
||||
|
||||
$data = [
|
||||
'postID' => $postID,
|
||||
'wt_list_idx' => $wt_list_idx,
|
||||
'recommend_count' => 0,
|
||||
'view_count' => 0,
|
||||
'grade' => 0,
|
||||
'grade_total' => 0,
|
||||
'ep_no' => $ep_no
|
||||
];
|
||||
|
||||
$this->wtoon_model->updateEpisode($data);
|
||||
|
||||
//Return to post list
|
||||
redirect(BASE_URL.'/admin/webtoons/episode', 'refresh');
|
||||
}
|
||||
|
||||
/*
|
||||
@desc : delete maptoon announcement
|
||||
*/
|
||||
public function episode_delete()
|
||||
{
|
||||
if ($this->input->post('deleteid')):
|
||||
$this->wtoon_model->removeEpisode($this->input->post('deleteid'));
|
||||
redirect(BASE_URL.'/admin/webtoons/episode'); else:
|
||||
$req_data['postID'] = $this->uri->segment(5);
|
||||
$this->data['form']=$this->wtoon_model->getEpisode($req_data);
|
||||
$this->load->view('admin/webtoon/episode_delete.php', $this->data);
|
||||
endif;
|
||||
}
|
||||
|
||||
/*
|
||||
@desc : list all the maptoon categories
|
||||
*/
|
||||
public function category()
|
||||
{
|
||||
|
||||
//Load the view
|
||||
$this->data['header'] = $this->load->view('admin/header', $this->data, true);
|
||||
$this->data['footer'] = $this->load->view('admin/footer', '', true);
|
||||
|
||||
$idx = $this->input->get('idx');
|
||||
|
||||
$categories = $this->wtoon_model->getCategory();
|
||||
$this->data['categories']=$categories;
|
||||
|
||||
$this->load->view('/admin/webtoon/category', $this->data);
|
||||
}
|
||||
|
||||
|
||||
public function editCategory()
|
||||
{
|
||||
//Load the view
|
||||
$this->data['header'] = $this->load->view('admin/header', $this->data, true);
|
||||
$this->data['footer'] = $this->load->view('admin/footer', '', true);
|
||||
|
||||
$categoryID = $this->uri->segment(5);
|
||||
|
||||
$data_category = $this->wtoon_model->getCategory($categoryID);
|
||||
|
||||
$this->data['categoryTitle'] = $data_category['categoryTitle'];
|
||||
|
||||
$data_episodes = $this->wtoon_model->get_episodes_by_category($categoryID);
|
||||
|
||||
|
||||
if ($data_episodes!=false) {
|
||||
$this->data['list'] = $data_episodes;
|
||||
} else {
|
||||
$this->data['list'] = '';
|
||||
}
|
||||
|
||||
$this->data['categoryID'] = $categoryID;
|
||||
$this->load->view('/admin/webtoon/category_edit', $this->data);
|
||||
}
|
||||
|
||||
/*
|
||||
get list of maptoon episodes
|
||||
@return json string
|
||||
*/
|
||||
public function get_episodes_by_search_keyword()
|
||||
{
|
||||
$keyword = $this->input->get('keyword');
|
||||
if ($keyword!='') {
|
||||
$row = $this->wtoon_model->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;
|
||||
}
|
||||
}
|
||||
|
||||
public function register_episode_in_category()
|
||||
{
|
||||
$postID = $this->input->post('postID');
|
||||
$categoryID = $this->input->post('categoryID');
|
||||
// $len = count($postID);
|
||||
$ret = $this->wtoon_model->update_episodes_by_category($categoryID, $postID);
|
||||
|
||||
redirect(BASE_URL.'/admin/webtoons/category');
|
||||
}
|
||||
|
||||
public function get_next_ep_no()
|
||||
{
|
||||
$wt_list_idx = $this->input->post('wt_list_idx');
|
||||
$res_data = $this->wtoon_model->get_next_ep_no($wt_list_idx);
|
||||
echo $res_data->ep_no+1;
|
||||
}
|
||||
}
|
||||
10
application/controllers/admin/index.html
Executable file
10
application/controllers/admin/index.html
Executable file
@@ -0,0 +1,10 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>403 Forbidden</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<p>Directory access is forbidden.</p>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
10
application/controllers/index.html
Executable file
10
application/controllers/index.html
Executable file
@@ -0,0 +1,10 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>403 Forbidden</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<p>Directory access is forbidden.</p>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user