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/vajra.id/public_html/application/controllers/admin/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

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

class Activity extends Admin_Controller {

	private $activity_current_id = NULL;
	private $image1_filename = NULL;
	private $image2_filename = NULL;
		
	function __construct() { 
		parent::__construct();	
		$this->load->model('activity_m');
		$this->load->helper('form');
		$this->load->library('upload');
	}
		
	//this is to list all blog
	public function index() {

		if (isset($_POST['submit'])) {

			//check & processing image banner upload files	
			if ($_FILES['userfile']['size'] !== 0) {  
			
				$config['upload_path'] = './uploads/activity/'; 
				$config['allowed_types'] = 'jpg|png'; 
				$config['max_size'] = '300';
				$config['max_width'] = '1200';
				$config['max_height'] = '300';
				
				$this->load->library('upload', $config); 

				if ( ! $this->upload->do_upload()) {
					 $error = array('error' => $this->upload->display_errors());
					 var_dump($error);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/activity');				
				} else {
					$image 			= $this->upload->data();
					$image_filename = $image['file_name']; 	 

					$data = array(
						'activity_landingpage_image' => $image['file_name'],
					);
					$this->db->where('id_configuration', 1);
					$this->db->update('configuration', $data); 
				}	
			}
			
			$data = array(
				'activity_landingpage_title' => $this->security->xss_clean($this->input->post('activity_landingpage_title'))
			);
			$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;">Activity Landing Page Edit Successful</p>');
		}

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

		//get all activity
		$this->data['activities'] = $this->db->select('*')->from('activity')->order_by('id','DESC')->get()->result();

		//load view
		$this->data['subview'] = 'admin/activity/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 delete blog landingpage banner image file from server, and from database
	public function delete_landingpage_image() { 

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

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

		//Delete image field from database
		$data = array( 
			'activity_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/activity'); 
	}
	
	//to add a new blog 
	public function add() {
	
		$this->data['activity'] = $this->activity_m->get_new();	
		
		//validation in action
		//validation check in action 
		$config = $this->activity_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); 
		$this->form_validation->set_error_delimiters('<div class="error">', '</div>');

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

			//get max image width and height from configuration table
			$this->db->select('blog_image_width, blog_image_height, blog_thumbnail_width, blog_thumbnail_height')->from('configuration')->where('id_configuration', 1);
			$image_dimension = $this->db->get()->row();

			//check & processing IMAGE INTRO
			if ($_FILES['image1']['size'] !== 0) { 	
				$config1['upload_path'] 	= './uploads/activity/'; 
				$config1['allowed_types'] 	= 'jpg|png'; 
				$config1['max_size']		= '300'; 
				$config1['max_width'] 		= $image_dimension->blog_thumbnail_width;
				$config1['max_height'] 		= $image_dimension->blog_thumbnail_height;
				$this->upload->initialize($config1);
				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/activity/add');
				} else {
					$image1 = $this->upload->data();
					$this->image1_filename = $image1['file_name']; 					
				} 
			}
			//check & processing IMAGE TOP BANNER
			if ($_FILES['image2']['size'] !== 0) { 	
				$config2['upload_path'] 	= './uploads/activity/'; 
				$config2['allowed_types']	= 'jpg|png'; 
				$config2['max_size']		= '300'; 
				$config2['max_width'] 		= $image_dimension->blog_image_width;
				$config2['max_height'] 		= $image_dimension->blog_image_height;
				$this->upload->initialize($config2);
				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/activity/add');
				} else {
					$image2 = $this->upload->data();
					$this->image2_filename = $image2['file_name']; 
				} 
			}
			$data = $this->table_data_processing(
				$this->input->post('activity'), 
				$this->input->post('author'), 
				$this->input->post('status'), 
				$this->input->post('description'), 
				$this->image1_filename, 
				$this->image2_filename, 
				$this->input->post('meta_description'), 
				$this->input->post('meta_keywords'), 
				$this->input->post('publish_date')
			);
		
			$this->activity_m->add_activity($data);
			$this->session->set_flashdata('success', '<br><p style="background:green; color:white; padding:5px; font-weight:bold;">Activity Add Successful</p>');
			redirect('admin/activity');			
		} 
		$this->data['subview'] = 'admin/activity/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 blog in admin
	public function edit($id = NULL) {
		if ($id == NULL) { show_404(); }
		//check if id exist. If not exist, show 404.
		$count = $this->activity_m->count_exist($id);
		if ($count == 0) { 
			//page not exist
			show_404();
		}		
		$this->data['activity'] = $this->activity_m->get($id);	
		$this->activity_current_id = (int) $id;
		//validation check in action
		$config = $this->activity_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); 
		$this->form_validation->set_error_delimiters('<div class="error">', '</div>');
		if($this->form_validation->run($this) == TRUE) {
			//get max image width and height from configuration table
			$this->db->select('blog_image_width, blog_image_height, blog_thumbnail_width, blog_thumbnail_height')->from('configuration')->where('id_configuration', 1);
			$image_dimension = $this->db->get()->row();
			//check & processing IMAGE INTRO
			if ($_FILES['image1']['size'] !== 0) { 	
				$config1['upload_path'] 	= './uploads/activity/'; 
				$config1['allowed_types']	= 'jpg|png'; 
				$config1['max_size']		= '300'; 
				$config1['max_width'] 		= $image_dimension->blog_thumbnail_width;
				$config1['max_height'] 		= $image_dimension->blog_thumbnail_height;
				$this->upload->initialize($config1);
				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/activity/edit'.$id);
				} else {
					$image1 = $this->upload->data();
					$this->image1_filename = $image1['file_name']; 
				} 
			}
			//check & processing IMAGE TOP BANNER
			if ($_FILES['image2']['size'] !== 0) { 	
				$config2['upload_path'] 	= './uploads/activity/'; 
				$config2['allowed_types'] 	= 'jpg|png'; 
				$config2['max_size']		= '300'; 
				$config2['max_width'] 		= $image_dimension->blog_image_width;
				$config2['max_height'] 		= $image_dimension->blog_image_height;
				$this->upload->initialize($config2);
				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/activity/edit'.$id);
				} else {
					$image2 = $this->upload->data();
					$this->image2_filename = $image2['file_name']; 
				} 
			}
			$data = $this->table_data_processing(
				$this->input->post('activity'), 
				$this->input->post('author'), 
				$this->input->post('status'), 
				$this->input->post('description'), 
				$this->image1_filename, 
				$this->image2_filename, 
				$this->input->post('meta_description'), 
				$this->input->post('meta_keywords'), 
				$this->input->post('publish_date')
			);
			$this->activity_m->edit_activity($id, $data); 
			$this->session->set_flashdata('success', '<br><p style="background:green; color:white; padding:5px; font-weight:bold;">Activity Edit Successful</p>');			
			redirect('admin/activity/edit/'. $id);
		} 
		
		$this->data['subview'] = 'admin/activity/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 blog
	public function delete($id) {

		//check if id exist. If not exist, show 404.
		$count = $this->activity_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, image2')->from('activity')->where('id', (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/activity/'. $image->image1);
		} 

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

		//delete blog
		$this->activity_m->delete($id); 

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

	private function table_data_processing($activity, $author, $status, $description, $image1_filename, $image2_filename, $meta_description, $meta_keywords, $publish_date) {

		$publish_date = explode('-',$publish_date);	
		$publish_date = $publish_date[2] . '-' . $publish_date[1] . '-' . $publish_date[0];

		$data = array(
			'activity' 		=> $this->security->xss_clean($activity),
			'author'		=> $author,	
			'alias' 		=> url_title($activity),
			'status' 		=> $status,
			'description' 	=> $description,
			'publish_date' 	=> $publish_date,	
		);
		//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 blog
	//make it private by adding _
	public function _cek_existing_activity_title($str) {

		$num_rows = $this->activity_m->cek_existing_activity_title($str,$this->activity_current_id);   
		if ($num_rows != 0 ) {  
			$this->form_validation->set_message('_cek_existing_activity_title', 'activity name already exist !');
			return FALSE;
		} else {
			return TRUE;   
		}
	}

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

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

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

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

		//get image file name for deletion
		$this->db->select('image1, image2')->from('activity')->where('id', (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/activity/'. $image->image1);

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

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

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

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

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

https://t.me/RX1948 - 2025