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

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

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

class Testimonies extends Admin_Controller {

	//this property is used for validating existing testimony title on call back edit testimony
	private $testimony_current_id = NULL;
	private $image_filename = NULL;

	function __construct() { 
		parent::__construct();	
		$this->load->model('testimony_m');
		$this->load->helper('form');
	}
		
	//this is to list all testimony
	public function index() {
		//pagination in action. 100 results per page 
		$this->load->library('pagination');
		$config['base_url'] = base_url() . 'admin/testimonies/index';
        $config['total_rows'] = $this->testimony_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['testimonies'] = $this->testimony_m->get_all_testimonies($config["per_page"], $this->uri->segment(4));   

		//load view
		$this->data['subview'] = 'admin/testimonies/index';
		$this->load->view('admin/templates/header', $this->data); 
		$this->load->view('admin/_layout_main', $this->data);
		$this->load->view('admin/templates/footer', $this->data);	
    }
	
	//to add a new testimony 
	public function add() {
		$this->data['testimony'] = $this->testimony_m->get_new();	
		//validation in action
		//validation check in action 
		$config = $this->testimony_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 image
			if ($_FILES['image']['size'] !== 0) { 	

				$config['upload_path'] = './uploads/'; 
				$config['allowed_types'] = 'jpg|png|jpeg'; 
				$config['max_size']	= '300'; 
				$config['max_width'] = '600';
				$config['max_height'] = '600';

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

				if (!$this->upload->do_upload('image')) {

          // return the error message and kill the script
          $this->session->set_flashdata('image-error', "<br>
              <p style='background:red; color:white; padding:5px; font-weight:bold;'>{$this->upload->display_errors()}</p>");
          redirect('admin/testimonies/add');
				
				} else {
					$image = $this->upload->data();
					$image_filename = $image['file_name']; 
				} 
			}

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

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

			redirect('admin/testimonies');
        } 
		
		$this->data['subview'] = 'admin/testimonies/edit';
		$this->load->view('admin/templates/header', $this->data); 
		$this->load->view('admin/_layout_main', $this->data);
		$this->load->view('admin/templates/footer', $this->data);	
	}
	
	//to edit testimony in admin
	public function edit($id = NULL) {

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

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

		$this->data['testimony'] = $this->testimony_m->get($id);	

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

		//validation check in action
		$config = $this->testimony_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['image']['size'] !== 0) { 	

				$config['upload_path'] = './uploads/'; 
				$config['allowed_types'] = 'jpg|png|jpeg'; 
				$config['max_size']	= '300'; 
				$config['max_width'] = '600';
				$config['max_height'] = '600';

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

				if ( ! $this->upload->do_upload('image')) {

				  // return the error message and kill the script
     			echo $this->upload->display_errors(); 

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

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

			$this->testimony_m->edit_testimony($id, $data); 

			$this->session->set_flashdata('success', '<br><p style="background:green; color:white; padding:5px; font-weight:bold;">Testimony Edit Successful</p>');
			
			redirect('admin/testimonies/edit/' .  $id);
		} 
		
		$this->data['subview'] = 'admin/testimonies/edit';
		$this->load->view('admin/templates/header', $this->data); 
		$this->load->view('admin/_layout_main', $this->data);
		$this->load->view('admin/templates/footer');	
	}
	

	//to delete a testimony
	public function delete($id) {

		//check if id exist. If not exist, show 404.
		$count = $this->testimony_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('testimonies')->where('id', (int) $id);
		$image = $this->db->get()->row();
		
		if ($image->image != '') {
			//Delete the actual image file from server. FCPATH is codeigniter base path
			unlink(FCPATH .'/uploads/'. $image->image);
		} 

		//delete testimony
		$this->testimony_m->delete($id); 

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

	private function table_data_processing($image) {

		$data = array(
			'testimony' => $this->security->xss_clean($this->input->post('testimony')),
			'name' 		=> $this->security->xss_clean($this->input->post('name')),
      'status' 		=> $this->input->post('status'),
      'ordering' 		=> $this->input->post('ordering'),
		);

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

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

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

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

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

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

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

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

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

https://t.me/RX1948 - 2025