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/kanvakanva.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(); $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_title', 'label' => 'Banner 1 Title', 'rules' => 'trim' ), array( 'field' => 'banner1_link', 'label' => 'Banner 1 Link', 'rules' => 'trim' ), array( 'field' => 'banner2_link', 'label' => 'Banner 2 link', 'rules' => 'trim' ), array( 'field' => 'banner3_link', 'label' => 'Banner 3 link', 'rules' => 'trim' ), array( 'field' => 'banner4_title', 'label' => 'Banner 4 title', 'rules' => 'trim' ), array( 'field' => 'banner4_link', 'label' => 'Banner 4 Link', 'rules' => 'trim' ), array( 'field' => 'banner5_link', 'label' => 'Banner 5 Link', 'rules' => 'trim' ), array( 'field' => 'banner6_link', 'label' => 'Banner 6 Link', 'rules' => 'trim' ), ); $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['userfile8']['size'] !== 0) { $config['upload_path'] = './uploads/page/'; $config['allowed_types'] = 'jpg'; $config['max_size'] = '200'; $config['max_width'] = '1000'; $config['max_height'] = '600'; $this->load->library('upload', $config); if ( ! $this->upload->do_upload('userfile8')) { //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) { $config['upload_path'] = './uploads/page/'; $config['allowed_types'] = 'jpg'; $config['max_size'] = '300'; $config['max_width'] = '360'; $config['max_height'] = '400'; $this->load->library('upload', $config); if ( ! $this->upload->do_upload('userfile1')) { 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 { $image1 = $this->upload->data(); $image_filename1 = $image1['file_name']; } } //check & processing image 2 banner upload files if ($_FILES['userfile2']['size'] !== 0) { $config['upload_path'] = './uploads/page/'; $config['allowed_types'] = 'jpg'; $config['max_size'] = '300'; $config['max_width'] = '360'; $config['max_height'] = '400'; $this->load->library('upload', $config); if ( ! $this->upload->do_upload('userfile2')) { //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 { $image2 = $this->upload->data(); $image_filename2 = $image2['file_name']; } } //check & processing image 3 banner upload files if ($_FILES['userfile3']['size'] !== 0) { $config['upload_path'] = './uploads/page/'; $config['allowed_types'] = 'jpg'; $config['max_size'] = '300'; $config['max_width'] = '360'; $config['max_height'] = '400'; $this->load->library('upload', $config); if ( ! $this->upload->do_upload('userfile3')) { //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 { $image3 = $this->upload->data(); $image_filename3 = $image3['file_name']; } } //check & processing image 4 banner upload files if ($_FILES['userfile4']['size'] !== 0) { $config['upload_path'] = './uploads/page/'; $config['allowed_types'] = 'jpg'; $config['max_size'] = '300'; $config['max_width'] = '360'; $config['max_height'] = '400'; $this->load->library('upload', $config); if ( ! $this->upload->do_upload('userfile4')) { //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/add'); } else { $image4 = $this->upload->data(); $image_filename4 = $image4['file_name']; } } //check & processing image 5 banner upload files if ($_FILES['userfile5']['size'] !== 0) { $config['upload_path'] = './uploads/page/'; $config['allowed_types'] = 'jpg'; $config['max_size'] = '300'; $config['max_width'] = '360'; $config['max_height'] = '400'; $this->load->library('upload', $config); if ( ! $this->upload->do_upload('userfile5')) { //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/add'); } else { $image5 = $this->upload->data(); $image_filename5 = $image5['file_name']; } } //check & processing image 6 banner upload files if ($_FILES['userfile6']['size'] !== 0) { $config['upload_path'] = './uploads/page/'; $config['allowed_types'] = 'jpg'; $config['max_size'] = '300'; $config['max_width'] = '360'; $config['max_height'] = '400'; $this->load->library('upload', $config); if ( ! $this->upload->do_upload('userfile6')) { //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/add'); } else { $image6 = $this->upload->data(); $image_filename6 = $image6['file_name']; } } $data = array( 'banner1_title' => $this->input->post('banner1_title'), 'banner1_link' => $this->input->post('banner1_link'), 'banner2_link' => $this->input->post('banner2_link'), 'banner3_link' => $this->input->post('banner3_link'), 'banner4_title' => $this->input->post('banner4_title'), 'banner4_link' => $this->input->post('banner4_link'), 'banner5_link' => $this->input->post('banner5_link'), 'banner6_link' => $this->input->post('banner6_link'), 'popup_active' => $this->input->post('popup_active'), 'popup_text' => $this->input->post('popup_text') ); //image upload if (isset($image_filename1)) { $data['banner1_image'] = $image_filename1; } //image upload if (isset($image_filename2)) { $data['banner2_image'] = $image_filename2; } //image upload if (isset($image_filename3)) { $data['banner3_image'] = $image_filename3; } //image upload if (isset($image_filename4)) { $data['banner4_image'] = $image_filename4; } //image upload if (isset($image_filename5)) { $data['banner5_image'] = $image_filename5; } //image upload if (isset($image_filename6)) { $data['banner6_image'] = $image_filename6; } //image upload if (isset($image_filename8)) { $data['popup_image'] = $image_filename8; } $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); $this->load->view('admin/_layout_main', $this->data); $this->load->view('admin/templates/footer', $this->data); } //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:orange; color:white; padding:5px; font-weight:bold;">Home center Banner Delete Successful</p>'); redirect('admin/home_centerbanners'); } }