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/blue-sky.co.id/public_html/application/controllers/admin/ |
Upload File : |
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); class Custom_info extends Admin_Controller { function __construct() { parent::__construct(); //admin role module check $this->check_admin_role('custom info'); //method from Admin_controller $this->load->model('custom_info_m'); } public function edit($id = 1) { //check if id exist. If not exist, show 404. $count = $this->custom_info_m->count_exist($id); if ($count == 0) { //page not exist show_404(); } $this->data['custom_info'] = $this->custom_info_m->get($id); //validation check in action $config = array( array( 'field' => 'custom_info', 'label' => 'Custom Info Content', 'rules' => 'trim' ), array( 'field' => 'custom_info2', 'label' => 'Custom Info2 Content', 'rules' => 'trim' ), array( 'field' => 'custom_info3', 'label' => 'Custom Info3 Content', 'rules' => 'trim' ), ); $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) { if($_POST) { //check & processing image banner upload files if ($_FILES['image1']['size'] !== 0) { //get slideshow size from configuration table $config['upload_path'] = './uploads/banners/'; $config['allowed_types'] = 'jpg|png'; $config['max_size'] = '600'; $config['max_width'] = '1600'; $config['max_height'] = '974'; $this->load->library('upload', $config); if (!$this->upload->do_upload('image1')) { //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/custom_info/edit/1'); } else { $image1 = $this->upload->data(); $image1_filename = $image1['file_name']; } } $data = array( 'custom_info' => $this->security->xss_clean($this->input->post('custom_info')), 'custom_info_en' => $this->security->xss_clean($this->input->post('custom_info_en')), 'link' => $this->security->xss_clean($this->input->post('link')), 'button_text' => $this->security->xss_clean($this->input->post('button_text')), 'button_text_en' => $this->security->xss_clean($this->input->post('button_text_en')), 'status' => $this->security->xss_clean($this->input->post('status')) ); if (isset($image1_filename)) { $data['image'] = $image1_filename; } $this->custom_info_m->edit_custom_info($id, $data); $this->session->set_flashdata('success', '<br><p style="background:green; color:white; padding:5px; font-weight:bold;">Custom Info Edit Sukses</p>'); redirect('admin/custom_info/edit'); } } $this->data['subview'] = 'admin/custom_info/edit'; $this->load->view('admin/templates/header', $this->data_header); $this->load->view('admin/_layout_main', $this->data); $this->load->view('admin/templates/footer'); } }