Server : Apache/2.4.18 (Ubuntu) System : Linux canvaswebdesign 3.13.0-71-generic #114-Ubuntu SMP Tue Dec 1 02:34:22 UTC 2015 x86_64 User : oppastar ( 1041) PHP Version : 7.0.33-0ubuntu0.16.04.15 Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority, Directory : /proc/self/root/var/www/serbaantik.com/public_html/application/controllers/ |
Upload File : |
<?php defined('BASEPATH') or exit('No direct script access allowed'); class Blog extends Public_Controller { public function __construct() { parent::__construct(); $this->load->library('pagination'); $this->load->model('blog_m'); } public function index() { //pagination $this->load->helper('pagination_helper'); $config = pagination_format_fe(); $config['base_url'] = base_url() . 'blog/index'; $config['per_page'] = 12; $config['uri_segment'] = 3; $config['total_rows'] = $this->db->select('id_blog')->from('blog')->where('status', '1')->get()->num_rows(); $this->pagination->initialize($config); //get blogs $this->db->select('blog.*, blogs_category.name, blogs_category.alias as cat_alias') ->from('blog') ->join('blogs_category', 'blogs_category.id = blog.id_blogs_category') ->where('blog.status', '1') ->order_by('publish_date', 'DESC') ->limit($config['per_page'], $this->uri->segment($config['uri_segment'])); $data['blogs'] = $this->db->get()->result_array(); $this->data_header['browser_title'] ='Blogs from Serba Antik'; $this->data_header['meta_description'] ='Blogs from Serba Antik'; $data['landing_image'] = $this->db->select('blog_landingpage_image')->from('configuration')->where('id_configuration', 1)->get()->row()->blog_landingpage_image; $data['landing_title'] = 'Blog'; $this->load->view('template/header', $this->data_header); $this->load->view('blogs', $data); $this->load->view('template/footer', $this->data_footer); } public function category($alias) { $this->data['blog_category'] = $this->db->select('id, name, image')->from('blogs_category')->where('status', '1')->where('alias', $alias)->get()->row_array(); if(!$this->data['blog_category']) { redirect(base_url('blog')); } $this->load->helper('pagination_helper'); $config = pagination_format_fe(); $config['base_url'] = base_url() . 'blog/category/' . $alias; $config['per_page'] = 12; $config['uri_segment'] = 4; $config['total_rows'] = $this->db->select('id_blog')->from('blog')->where('id_blogs_category', $this->data['blog_category']['id'])->where('status', '1')->get()->num_rows(); $this->pagination->initialize($config); //get blogs $this->db->select('blog.*, blogs_category.name, blogs_category.alias as cat_alias') ->from('blog') ->join('blogs_category', 'blogs_category.id = blog.id_blogs_category') ->where('blog.status', '1') ->where('id_blogs_category', $this->data['blog_category']['id']) ->order_by('publish_date', 'DESC') ->limit($config['per_page'], $this->uri->segment($config['uri_segment'])); $data['blogs'] = $this->db->get()->result_array(); $this->data_header['browser_title'] = 'Blog Category: ' . $this->data['blog_category']['name']; $this->data_header['meta_description'] = 'Blog Category ' . $this->data['blog_category']['name']; $data['landing_image'] = $this->data['blog_category']['image']; $data['landing_title'] = ucwords($this->data['blog_category']['name']); $this->load->view('template/header', $this->data_header); $this->load->view('blogs', $data); $this->load->view('template/footer', $this->data_footer); } public function detail($alias) { $data['blog'] = $this->db->select('blog.*, blogs_category.name, blogs_category.alias as cat_alias') ->from('blog') ->join('blogs_category', 'blogs_category.id = blog.id_blogs_category') ->where('blog.alias', $alias) ->where('blog.status', 1) ->get() ->row_array(); if (!$data['blog']) { redirect(base_url('blog')); } //get 2 related blogs $this->db->select('blog.*, blogs_category.name, blogs_category.alias as cat_alias') ->from('blog') ->join('blogs_category', 'blogs_category.id = blog.id_blogs_category') ->where('blog.status', '1') ->where('blog.id_blog !=', $data['blog']['id_blog']) ->where('id_blogs_category', $data['blog']['id_blogs_category']) ->order_by('publish_date', 'DESC') ->limit(2); $data['related_blogs'] = $this->db->get()->result_array(); //get 3 recent blogs $this->db->select('*') ->from('blog') ->where('blog.id_blog !=', $data['blog']['id_blog']) ->order_by('publish_date', 'DESC') ->limit(5); $data['recent_blogs'] = $this->db->get()->result_array(); //get all blog categories $data['categories'] = $this->db->select('name, alias')->from(' blogs_category')->where('status', '1')->order_by('priority', 'ASC')->get()->result_array(); $this->data_header['browser_title'] = 'Blog - ' . ucwords($data['blog']['blog']); $this->data_header['meta_description'] = 'Blog - ' . ucwords($data['blog']['blog']); $this->load->view('template/header', $this->data_header); $this->load->view('blog-detail', $data); $this->load->view('template/footer', $this->data_footer); } private function migration_skript() { //delete previous blog content $this->db->where('status', '1'); $this->db->delete('blog'); $sql ="SELECT p.id AS post_id, p.post_title, p.post_name AS alias, p.post_date, p.post_content, pm2.meta_value AS image FROM `wp_posts` AS p INNER JOIN `wp_postmeta` AS pm1 ON p.id = pm1.post_id INNER JOIN `wp_postmeta` AS pm2 ON pm1.meta_value = pm2.post_id AND pm2.meta_key = '_wp_attached_file' AND pm1.meta_key = '_thumbnail_id' ORDER BY p.id DESC"; $old_blogs = $this->db->query($sql)->result_array(); $insert_data = array(); foreach($old_blogs as $old) { $insert_data[] = array( 'id_blogs_category' => 5, 'blog' => $old['post_title'], 'alias' => $old['alias'], 'created_at' => $old['post_date'], 'publish_date' => $old['post_date'], 'status' => '1', 'description' => $old['post_content'], 'meta_description' => $old['post_title'], 'image2' => $old['image'], ); } $this->db->insert_batch('blog', $insert_data); echo 'done'; } }