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/smbparts.co.id/public_html/application/controllers/admin/ |
Upload File : |
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); class Home_centerbanners extends Admin_Controller { function __construct() { parent::__construct(); $this->load->model('home_centerbanner_m'); } //this is to list all home_centerbanners public function index() { $this->edit(1); } //to edit brand in admin public function edit($id = NULL) { //check if id exist. If not exist, show 404. $count = $this->home_centerbanner_m->count_exist($id); if ($count == 0) { //page not exist show_404(); } $this->data['home_centerbanners'] = $this->home_centerbanner_m->get($id); //validation check in action $config = array( array( 'field' => 'banner1_link', 'label' => 'Banner 1 Link', '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); $this->form_validation->set_error_delimiters('<div class="error">', '</div>'); if($this->form_validation->run() == TRUE) { if($_POST) { //check & processing image Popup Banner if ($_FILES['userfile0']['size'] !== 0) { $config['upload_path'] = './uploads/page/'; $config['allowed_types'] = 'jpg'; $config['max_size'] = '200'; $config['max_width'] = '800'; $config['max_height'] = '500'; $this->load->library('upload', $config); $this->upload->initialize($config); if ( ! $this->upload->do_upload('userfile0')) { //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>'); redirect('admin/home_centerbanners/edit/' . $id); } else { $image8 = $this->upload->data(); $image_filename8 = $image8['file_name']; } } //check & processing image 1 banner upload files if ($_FILES['userfile1']['size'] !== 0) { //get banner dimensioon $this->db->select('staticbanner1_image_width, staticbanner1_image_height')->from('configuration')->where('id_configuration', 1); $banner1_dimension = $this->db->get()->row(); $config['upload_path'] = './uploads/page/'; $config['allowed_types'] = 'jpg|png'; $config['max_size'] = '500'; $config['max_width'] = $banner1_dimension->staticbanner1_image_width; $config['max_height'] = $banner1_dimension->staticbanner1_image_height; $this->load->library('upload', $config); $this->upload->initialize($config); if ( ! $this->upload->do_upload('userfile1')) { //echo $this->upload->display_errors(); die(); $this->session->set_flashdata('staticerror1', '<br> <p style="background:orange; color:white; padding:5px; font-weight:bold;">Image Upload Error. Wrong format or size.</p>'); redirect('admin/home_centerbanners/edit/' . $id); } else { $image1 = $this->upload->data(); $image_filename1 = $image1['file_name']; } } $data = array( 'banner1_link' => $this->security->xss_clean($this->input->post('banner1_link')), 'banner1_text' => $this->security->xss_clean($this->input->post('banner1_text')), 'banner1_text_en' => $this->security->xss_clean($this->input->post('banner1_text_en')), 'popup_active' => $this->input->post('popup_active'), 'popup_text' => $this->input->post('popup_text'), 'popup_day_expire' => $this->input->post('popup_day_expire') ); //image upload if (isset($image_filename1)) { $data['banner1_image'] = $image_filename1; } //image upload if (isset($image_filename0)) { $data['popup_image'] = $image_filename0; } $this->home_centerbanner_m->edit_home_centerbanners($id, $data); $this->session->set_flashdata('success', '<br><p style="background:green; color:white; padding:5px; font-weight:bold;">Home center Banner Edit Successful</p>'); redirect('admin/home_centerbanners'); } } $this->data['subview'] = 'admin/home_centerbanners/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 brand public function delete($id) { //check if id exist. If not exist, show 404. $count = $this->home_centerbanners_m->count_exist($id); if ($count == 0) { //page not exist show_404(); } //delete brand $this->home_centerbanner_m->delete($id); $this->session->set_flashdata('success', '<br><p style="background:green; color:white; padding:5px; font-weight:bold;">Home center Banner Delete Successful</p>'); redirect('admin/home_centerbanners'); } public function delete_popup_image() { //get image file name for deletion $this->db->select('popup_image')->from('home_centerbanners')->where('id_home_centerbanners', 1); $image = $this->db->get()->row()->popup_image; //Delete the actual image file from server. FCPATH is codeigniter base path unlink(FCPATH .'/uploads/page/'. $image); //Delete image field from database $data = array( 'popup_image' => '', ); $this->db->where('id_home_centerbanners', 1); $this->db->update('home_centerbanners', $data); $this->session->set_flashdata('success', '<br><p style="background:green; color:white; padding:5px; font-weight:bold;">Popup Image Delete Successful</p>'); redirect('admin/home_centerbanners'); } public function delete_static_banner($image_number = NULL) { if($image_number == NULL) { show_404(); } //get image file name for deletion $this->db->select('banner1_image'); $this->db->from('home_centerbanners'); $this->db->where('id_home_centerbanners', 1); switch($image_number) { case '1': $image = $this->db->get()->row()->banner1_image; break; } //Delete the actual image file from server. FCPATH is codeigniter base path unlink(FCPATH .'/uploads/page/'. $image); //Delete image field from database $data = array( 'banner' . $image_number . '_image' => '', ); $this->db->where('id_home_centerbanners', 1); $this->db->update('home_centerbanners', $data); $this->session->set_flashdata('success', '<br><p style="background:green; color:white; padding:5px; font-weight:bold;">Static Image Delete Successful</p>'); redirect('admin/home_centerbanners'); } }