https://t.me/RX1948
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 :  /var/www/kamariallee.com/public_html/application/controllers/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /var/www/kamariallee.com/public_html/application/controllers/Category.php
<?php defined('BASEPATH') || exit('No direct script access allowed');

class Category extends Public_Controller
{
		public function __construct()
		{
				parent::__construct();
				$this->load->model('product_m');
		}

		public function get($alias_level1 = null, $alias_level2 = null)
		{
				$this->session->unset_userdata('filter_product');
				$this->loadCategory(false, $alias_level1, $alias_level2);
		}

		public function filter($alias_level1 = null, $alias_level2 = null)
		{
				$this->loadCategory(true, $alias_level1, $alias_level2);
		}

		private function loadCategory($is_filter, $alias_level1 = null, $alias_level2 = null)
		{
				if ($alias_level1 == null) { show_404(); }

				//get category level 1 detail
				$this->db->select('id_categories, category, image, title, description, meta_description')
				->from('categories')
				->where('alias', $alias_level1)
				->where('parent', null);
				$category = $this->db->get()->row_array();
	
				if(!$category) { show_404(); }

				//get no. of products per page (pagination) from configuration table
				$this->db->select('products_displayed')->from('configuration')->where('id_configuration', 1);
				$per_page = $this->db->get()->row()->products_displayed;

				//check if post sort_product is exist
				if ($this->input->post('sort_product'))
				{
						$this->session->set_userdata('sort_product', $this->input->post('sort_product'));
				}

				$this->data['level1_id'] = $category['id_categories'];
				$this->data['level1_category'] = $category['category'];
				$this->data['level1_alias'] = $alias_level1;
				$this->data['category_name'] = $category['category'];
				$this->data['banner_title'] = $category['title'];
				$this->data['banner_description'] = $category['description'];
				$this->data['banner_image'] = $category['image'];
				$this->data['sort_product_by'] = $this->session->userdata('sort_product');

				//pagination
				$config = array();
				$this->load->library('pagination');
				$this->load->helper('pagination_helper');
				$config = pagination_format();
				$config['per_page'] = $per_page;
			
				if($alias_level1 == 'show-all')
				{
						$config['total_rows'] = $this->product_m->count_products_all();

						if($is_filter)
						{
								$config['base_url'] = base_url() . 'category/filter/' . strtolower($alias_level1);
								$config['uri_segment'] = 4;
						}
						else
						{
								$config['base_url'] = base_url() . 'category/' . strtolower($alias_level1);
								$config['uri_segment'] = 3;
						}

						$this->data['products'] = $this->product_m->get_products_all(
							$config['per_page'], $this->uri->segment($config['uri_segment']));
				}
				elseif($alias_level1 != 'show-all')
				{
						if($alias_level2 && !is_numeric($alias_level2))
						{
								$this->db->select('id_categories, category, title, description,
								image, meta_description')
								->from('categories')
								->where('alias', $alias_level2)
								->where('parent', $category['id_categories']);
								$category = $this->db->get()->row_array();

								if (!$category) { show_404(); }

								$this->data['level2_id'] = $category['id_categories'];
								$this->data['level2_category'] = $category['category'];
								$this->data['level2_alias'] = $alias_level2;
								$this->data['category_name'] = $category['category'];
								$this->data['banner_title'] = $category['title'];
								$this->data['banner_description'] = $category['description'];
								$this->data['banner_image'] = $category['image'];

								$config['total_rows'] = $this->product_m->count_products_by_category($category['id_categories']);

								if($is_filter)
								{
										$config['base_url'] = base_url() . 'category/filter/' .
										strtolower($alias_level1) . '/' . strtolower($alias_level2);
										$config['uri_segment'] = 5;
								}
								else
								{
										$config['base_url'] = base_url() . 'category/' .
										strtolower($alias_level1) . '/' . strtolower($alias_level2);
										$config['uri_segment'] = 4;
								}
								
								$this->data['products'] = $this->product_m->get_products_by_category(
									$category['id_categories'], $config['per_page'], $this->uri->segment($config['uri_segment']));
						}
						else
						{
								$config['total_rows'] = $this->product_m->count_products_by_category($category['id_categories']);

								if($is_filter)
								{
										$config['base_url'] = base_url() . 'category/filter/' . strtolower($alias_level1);
										$config['uri_segment'] = 4;
								}
								else
								{
										$config['base_url'] = base_url() . 'category/' . strtolower($alias_level1);
										$config['uri_segment'] = 3;
								}

								$this->data['products'] = $this->product_m->get_products_by_category(
								$category['id_categories'], $config['per_page'], $this->uri->segment($config['uri_segment']));
						}
				}
				
				$this->pagination->initialize($config);

				$this->data['total_products'] = $config['total_rows'];

				$this->data['alias_level1'] = $alias_level1;
				$this->data['alias_level2'] = $alias_level2;

				$this->load->helper('cms_helper');

				//get available colours
				$this->data['colors'] = $this->db->select('id_product_attributes, product_attributes, color_code')
				->from('product_attributes')
				->where('id_product_size', 4)->get()->result_array();

				//Get SEO
				$this->data_header['browser_title'] = 'Category - ' . ucwords($category['category']);
				$this->data_header['meta_description'] = $category['meta_description'];
				$this->load->view('template/header', $this->data_header);
				$this->load->view('category', $this->data);
				$this->load->view('template/footer', $this->data_footer);

				//set current category to session, so it can be track to product page
				/* $this->session->set_userdata('current_viewed_category', $alias);  */
		}

		public function ajax_categoryfilter()
		{
				//test if ajax call to prevent direct access
				if(!$this->input->is_ajax_request())
				{
						exit('No direct script access allowed');
				}

				$this->session->set_userdata('filter_product', array(
						'chosenProductType' => $this->security->xss_clean($this->input->post('chosenProductType')),
						'chosenProductSize' => $this->security->xss_clean($this->input->post('chosenProductSize')),
						'chosenProductColor' => $this->security->xss_clean($this->input->post('chosenProductColor')),
						'chosenPriceFrom' => $this->security->xss_clean($this->input->post('chosenPriceFrom')),
						'chosenPriceTo' => $this->security->xss_clean($this->input->post('chosenPriceTo')),
				));

				return $this->output
				->set_content_type('application/json')
				->set_status_header(201)
				->set_output(json_encode([
						'filter_success' 	=> true,
				]));
		}
}

https://t.me/RX1948 - 2025