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 : |
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); class Home_centerbanners extends Admin_Controller { function __construct() { parent::__construct(); if (!in_array('home & about contents', $this->allowed_sections)) redirect('admin/dashboard'); $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); if($this->form_validation->run() == TRUE) { //check & processing image Popup Banner if ($_FILES['about_image1']['size'] !== 0) { $config = array(); $config['upload_path'] = './uploads/page/'; $config['allowed_types'] = 'mp4'; // $config['max_size'] = '800'; $this->load->library('upload', $config); $this->upload->initialize($config); if ( ! $this->upload->do_upload('about_image1')) { //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 { $about_image1 = $this->upload->data(); $image_about_image1 = $about_image1['file_name']; } } //check & processing image Popup Banner if ($_FILES['about_image2']['size'] !== 0) { $config = array(); $config['upload_path'] = './uploads/page/'; $config['allowed_types'] = '*'; // $config['allowed_types'] = 'jpg|png|jpeg|webp'; $config['max_size'] = '800'; $this->load->library('upload', $config); $this->upload->initialize($config); if ( ! $this->upload->do_upload('about_image2')) { //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 { $about_image2 = $this->upload->data(); $image_about_image2 = $about_image2['file_name']; } } //check & processing image Popup Banner if ($_FILES['about_image3']['size'] !== 0) { $config = array(); $config['upload_path'] = './uploads/page/'; $config['allowed_types'] = '*'; // $config['allowed_types'] = 'jpg|png|jpeg|webp'; $config['max_size'] = '800'; $this->load->library('upload', $config); $this->upload->initialize($config); if ( ! $this->upload->do_upload('about_image3')) { //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 { $about_image3 = $this->upload->data(); $image_about_image3 = $about_image3['file_name']; } } //check & processing image Popup Banner if ($_FILES['about_image4']['size'] !== 0) { $config = array(); $config['upload_path'] = './uploads/page/'; $config['allowed_types'] = '*'; // $config['allowed_types'] = 'jpg|png|jpeg|webp'; $config['max_size'] = '800'; $this->load->library('upload', $config); $this->upload->initialize($config); if ( ! $this->upload->do_upload('about_image4')) { //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 { $about_image4 = $this->upload->data(); $image_about_image4 = $about_image4['file_name']; } } //check & processing image Popup Banner if ($_FILES['about_image5']['size'] !== 0) { $config = array(); $config['upload_path'] = './uploads/page/'; $config['allowed_types'] = '*'; // $config['allowed_types'] = 'jpg|png|jpeg|webp'; $config['max_size'] = '800'; $this->load->library('upload', $config); $this->upload->initialize($config); if ( ! $this->upload->do_upload('about_image5')) { //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 { $about_image5 = $this->upload->data(); $image_about_image5 = $about_image5['file_name']; } } //check & processing image Popup Banner if ($_FILES['about_image6']['size'] !== 0) { $config = array(); $config['upload_path'] = './uploads/page/'; $config['allowed_types'] = '*'; // $config['allowed_types'] = 'jpg|png|jpeg|webp'; $config['max_size'] = '800'; $this->load->library('upload', $config); $this->upload->initialize($config); if ( ! $this->upload->do_upload('about_image6')) { //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 { $about_image6 = $this->upload->data(); $image_about_image6 = $about_image6['file_name']; } } //check & processing image Popup Banner if ($_FILES['about_image7']['size'] !== 0) { $config = array(); $config['upload_path'] = './uploads/page/'; $config['allowed_types'] = '*'; // $config['allowed_types'] = 'jpg|png|jpeg|webp'; $config['max_size'] = '800'; $this->load->library('upload', $config); $this->upload->initialize($config); if ( ! $this->upload->do_upload('about_image7')) { //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 { $about_image7 = $this->upload->data(); $image_about_image7 = $about_image7['file_name']; } } //check & processing image Popup Banner if ($_FILES['about_image8']['size'] !== 0) { $config = array(); $config['upload_path'] = './uploads/page/'; $config['allowed_types'] = '*'; // $config['allowed_types'] = 'jpg|png|jpeg|webp'; $config['max_size'] = '800'; $this->load->library('upload', $config); $this->upload->initialize($config); if ( ! $this->upload->do_upload('about_image8')) { //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 { $about_image8 = $this->upload->data(); $image_about_image8 = $about_image8['file_name']; } } //check & processing image Popup Banner if ($_FILES['about_image9']['size'] !== 0) { $config = array(); $config['upload_path'] = './uploads/page/'; $config['allowed_types'] = '*'; // $config['allowed_types'] = 'jpg|png|jpeg|webp'; $config['max_size'] = '800'; $this->load->library('upload', $config); $this->upload->initialize($config); if ( ! $this->upload->do_upload('about_image9')) { //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 { $about_image9 = $this->upload->data(); $image_about_image9 = $about_image9['file_name']; } } //check & processing image Popup Banner if ($_FILES['about_image10']['size'] !== 0) { $config = array(); $config['upload_path'] = './uploads/page/'; $config['allowed_types'] = '*'; // $config['allowed_types'] = 'jpg|png|jpeg|webp'; $config['max_size'] = '800'; $this->load->library('upload', $config); $this->upload->initialize($config); if ( ! $this->upload->do_upload('about_image10')) { //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 { $about_image10 = $this->upload->data(); $image_about_image10 = $about_image10['file_name']; } } $data = array( 'about_title' => $this->security->xss_clean($this->input->post('about_title')), 'about_text' => $this->security->xss_clean($this->input->post('about_text')), 'why_text' => $this->security->xss_clean($this->input->post('why_text')), 'statistic1_title' => $this->security->xss_clean($this->input->post('statistic1_title')), 'statistic2_title' => $this->security->xss_clean($this->input->post('statistic2_title')), 'statistic3_title' => $this->security->xss_clean($this->input->post('statistic3_title')), 'statistic4_title' => $this->security->xss_clean($this->input->post('statistic4_title')), 'statistic5_title' => $this->security->xss_clean($this->input->post('statistic5_title')), 'statistic1_text' => $this->security->xss_clean($this->input->post('statistic1_text')), 'statistic2_text' => $this->security->xss_clean($this->input->post('statistic2_text')), 'statistic3_text' => $this->security->xss_clean($this->input->post('statistic3_text')), 'statistic4_text' => $this->security->xss_clean($this->input->post('statistic4_text')), 'statistic5_text' => $this->security->xss_clean($this->input->post('statistic5_text')), 'aboutpage_title' => $this->security->xss_clean($this->input->post('aboutpage_title')), 'aboutpage_text' => $this->security->xss_clean($this->input->post('aboutpage_text')), 'aboutpage_subtitle' => $this->security->xss_clean($this->input->post('aboutpage_subtitle')), 'aboutpage_subtext' => $this->security->xss_clean($this->input->post('aboutpage_subtext')), 'aboutpage_subtext2' => $this->security->xss_clean($this->input->post('aboutpage_subtext2')), 'aboutpagesec1_title' => $this->security->xss_clean($this->input->post('aboutpagesec1_title')), 'aboutpagesec2_title' => $this->security->xss_clean($this->input->post('aboutpagesec2_title')), 'aboutpagesec3_title' => $this->security->xss_clean($this->input->post('aboutpagesec3_title')), 'aboutpagesec1_text' => $this->security->xss_clean($this->input->post('aboutpagesec1_text')), 'aboutpagesec2_text' => $this->security->xss_clean($this->input->post('aboutpagesec2_text')), 'aboutpagesec3_text' => $this->security->xss_clean($this->input->post('aboutpagesec3_text')), ); //image upload if (isset($image_about_image1)) { $data['about_image1'] = $image_about_image1; } //image upload if (isset($image_about_image2)) { $data['about_image2'] = $image_about_image2; } //image upload if (isset($image_about_image3)) { $data['about_image3'] = $image_about_image3; } //image upload if (isset($image_about_image4)) { $data['about_image4'] = $image_about_image4; } //image upload if (isset($image_about_image5)) { $data['about_image5'] = $image_about_image5; } //image upload if (isset($image_about_image6)) { $data['about_image6'] = $image_about_image6; } //image upload if (isset($image_about_image7)) { $data['about_image7'] = $image_about_image7; } //image upload if (isset($image_about_image8)) { $data['about_image8'] = $image_about_image8; } //image upload if (isset($image_about_image9)) { $data['about_image9'] = $image_about_image9; } //image upload if (isset($image_about_image10)) { $data['about_image10'] = $image_about_image10; } $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('about_image1, about_image1'); $this->db->from('home_centerbanners'); $this->db->where('id_home_centerbanners', 1); switch($image_number) { case '1': $image = $this->db->get()->row()->about_image1; break; case '2': $image = $this->db->get()->row()->about_image2; 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( 'about_image' . $image_number => '', ); $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;">Delete Successful</p>'); redirect('admin/home_centerbanners'); } }