first commit

This commit is contained in:
pakerpale
2020-06-10 06:21:34 +09:00
commit 20c9739ba9
1913 changed files with 266257 additions and 0 deletions

View 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');
}
}

View 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;
}
}

View 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;
}
}

View 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);
}
}
}

View 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;
}
}

View 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'));
}
}

View 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)));
}
}
}

View 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;
}
}

View 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'));
}
}

View 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());
}
}

View 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;
}
}

View File

@@ -0,0 +1,10 @@
<html>
<head>
<title>403 Forbidden</title>
</head>
<body>
<p>Directory access is forbidden.</p>
</body>
</html>