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/kokohpondasi.co.id/public_html/application/controllers/admin/ |
Upload File : |
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); class Service extends Admin_Controller { function __construct() { parent::__construct(); $this->load->model('service_m'); } public function index() { $this->edit(1); } public function edit($id = NULL) { //check if id exist. If not exist, show 404. $count = $this->service_m->count_exist($id); if ($count == 0) { //page not exist show_404(); } $this->data['service'] = $this->service_m->get($id); $config = array( array( 'field' => 'text1', 'label' => 'text 1', 'rules' => 'trim' ) ); $this->load->library('form_validation'); $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 1 banner upload files if ($_FILES['userfile1']['size'] !== 0) { $config['upload_path'] = './uploads/service/'; $config['allowed_types'] = 'jpg|png|jpeg'; $config['max_size'] = '1024'; $config['max_width'] = '2000'; $config['max_height'] = '2000'; $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('error1', '<br> <p style="background:orange; color:white; padding:5px; font-weight:bold;">Image Upload Error. Wrong format or size.</p>'); redirect('admin/service/edit/' . $id); } else { $image1 = $this->upload->data(); $image_filename1 = $image1['file_name']; } } //check & processing image 1 banner upload files if ($_FILES['userfile2']['size'] !== 0) { $config['upload_path'] = './uploads/service/'; $config['allowed_types'] = 'jpg|png|jpeg'; $config['max_size'] = '1024'; $config['max_width'] = '2000'; $config['max_height'] = '2000'; $this->load->library('upload', $config); $this->upload->initialize($config); if ( ! $this->upload->do_upload('userfile2')) { //echo $this->upload->display_errors(); die(); $this->session->set_flashdata('error2', '<br> <p style="background:orange; color:white; padding:5px; font-weight:bold;">Image Upload Error. Wrong format or size.</p>'); redirect('admin/service/edit/' . $id); } else { $image2 = $this->upload->data(); $image_filename2 = $image2['file_name']; } } //check & processing image 1 banner upload files if ($_FILES['userfile3']['size'] !== 0) { $config['upload_path'] = './uploads/service/'; $config['allowed_types'] = 'jpg|png|jpeg'; $config['max_size'] = '1024'; $config['max_width'] = '2000'; $config['max_height'] = '2000'; $this->load->library('upload', $config); $this->upload->initialize($config); if ( ! $this->upload->do_upload('userfile3')) { //echo $this->upload->display_errors(); die(); $this->session->set_flashdata('error3', '<br> <p style="background:orange; color:white; padding:5px; font-weight:bold;">Image Upload Error. Wrong format or size.</p>'); redirect('admin/service/edit/' . $id); } else { $image3 = $this->upload->data(); $image_filename3 = $image3['file_name']; } } //check & processing image 1 banner upload files if ($_FILES['userfile4']['size'] !== 0) { $config['upload_path'] = './uploads/service/'; $config['allowed_types'] = 'jpg|png|jpeg'; $config['max_size'] = '1024'; $config['max_width'] = '2000'; $config['max_height'] = '2000'; $this->load->library('upload', $config); $this->upload->initialize($config); if ( ! $this->upload->do_upload('userfile4')) { //echo $this->upload->display_errors(); die(); $this->session->set_flashdata('error4', '<br> <p style="background:orange; color:white; padding:5px; font-weight:bold;">Image Upload Error. Wrong format or size.</p>'); redirect('admin/service/edit/' . $id); } else { $image4 = $this->upload->data(); $image_filename4 = $image4['file_name']; } } if ($_FILES['userfile5']['size'] !== 0) { $config['upload_path'] = './uploads/service/'; $config['allowed_types'] = 'jpg|png|jpeg'; $config['max_size'] = '1024'; $config['max_width'] = '2000'; $config['max_height'] = '2000'; $this->load->library('upload', $config); $this->upload->initialize($config); if ( ! $this->upload->do_upload('userfile5')) { //echo $this->upload->display_errors(); die(); $this->session->set_flashdata('error5', '<br> <p style="background:orange; color:white; padding:5px; font-weight:bold;">Image Upload Error. Wrong format or size.</p>'); redirect('admin/service/edit/' . $id); } else { $image5 = $this->upload->data(); $image_filename5 = $image5['file_name']; } } if ($_FILES['userfile6']['size'] !== 0) { $config['upload_path'] = './uploads/service/'; $config['allowed_types'] = 'jpg|png|jpeg'; $config['max_size'] = '1024'; $config['max_width'] = '2000'; $config['max_height'] = '2000'; $this->load->library('upload', $config); $this->upload->initialize($config); if ( ! $this->upload->do_upload('userfile6')) { //echo $this->upload->display_errors(); die(); $this->session->set_flashdata('error6', '<br> <p style="background:orange; color:white; padding:5px; font-weight:bold;">Image Upload Error. Wrong format or size.</p>'); redirect('admin/service/edit/' . $id); } else { $image6 = $this->upload->data(); $image_filename6 = $image6['file_name']; } } if ($_FILES['userfile7']['size'] !== 0) { $config['upload_path'] = './uploads/service/'; $config['allowed_types'] = 'jpg|png|jpeg'; $config['max_size'] = '1024'; $config['max_width'] = '2000'; $config['max_height'] = '2000'; $this->load->library('upload', $config); $this->upload->initialize($config); if ( ! $this->upload->do_upload('userfile7')) { //echo $this->upload->display_errors(); die(); $this->session->set_flashdata('error7', '<br> <p style="background:orange; color:white; padding:5px; font-weight:bold;">Image Upload Error. Wrong format or size.</p>'); redirect('admin/service/edit/' . $id); } else { $image7 = $this->upload->data(); $image_filename7 = $image7['file_name']; } } if ($_FILES['userfile8']['size'] !== 0) { $config['upload_path'] = './uploads/service/'; $config['allowed_types'] = 'jpg|png|jpeg'; $config['max_size'] = '1024'; $config['max_width'] = '2000'; $config['max_height'] = '2000'; $this->load->library('upload', $config); $this->upload->initialize($config); if ( ! $this->upload->do_upload('userfile8')) { //echo $this->upload->display_errors(); die(); $this->session->set_flashdata('error8', '<br> <p style="background:orange; color:white; padding:5px; font-weight:bold;">Image Upload Error. Wrong format or size.</p>'); redirect('admin/service/edit/' . $id); } else { $image8 = $this->upload->data(); $image_filename8 = $image8['file_name']; } } if ($_FILES['userfile9']['size'] !== 0) { $config['upload_path'] = './uploads/service/'; $config['allowed_types'] = 'jpg|png|jpeg'; $config['max_size'] = '1024'; $config['max_width'] = '2000'; $config['max_height'] = '2000'; $this->load->library('upload', $config); $this->upload->initialize($config); if ( ! $this->upload->do_upload('userfile9')) { //echo $this->upload->display_errors(); die(); $this->session->set_flashdata('error9', '<br> <p style="background:orange; color:white; padding:5px; font-weight:bold;">Image Upload Error. Wrong format or size.</p>'); redirect('admin/service/edit/' . $id); } else { $image9 = $this->upload->data(); $image_filename9 = $image9['file_name']; } } if ($_FILES['userfile10']['size'] !== 0) { $config['upload_path'] = './uploads/service/'; $config['allowed_types'] = 'jpg|png|jpeg'; $config['max_size'] = '1024'; $config['max_width'] = '2000'; $config['max_height'] = '2000'; $this->load->library('upload', $config); $this->upload->initialize($config); if ( ! $this->upload->do_upload('userfile10')) { //echo $this->upload->display_errors(); die(); $this->session->set_flashdata('error10', '<br> <p style="background:orange; color:white; padding:5px; font-weight:bold;">Image Upload Error. Wrong format or size.</p>'); redirect('admin/service/edit/' . $id); } else { $image10 = $this->upload->data(); $image_filename10 = $image10['file_name']; } } } $data = array( 'text1' => $this->security->xss_clean($this->input->post('text1')), 'text2' => $this->security->xss_clean($this->input->post('text2')), 'text3' => $this->security->xss_clean($this->input->post('text3')), 'text4' => $this->security->xss_clean($this->input->post('text4')), 'text5' => $this->security->xss_clean($this->input->post('text5')), 'text6' => $this->security->xss_clean($this->input->post('text6')), 'text7' => $this->security->xss_clean($this->input->post('text7')), 'text8' => $this->security->xss_clean($this->input->post('text8')), 'text9' => $this->security->xss_clean($this->input->post('text9')), 'text10' => $this->security->xss_clean($this->input->post('text10')), 'text11' => $this->security->xss_clean($this->input->post('text11')), 'text12' => $this->security->xss_clean($this->input->post('text12')), 'text13' => $this->security->xss_clean($this->input->post('text13')) ); //image upload if (isset($image_filename1)) { $data['image1'] = $image_filename1; } //image upload if (isset($image_filename2)) { $data['image2'] = $image_filename2; } //image upload if (isset($image_filename3)) { $data['image3'] = $image_filename3; } //image upload if (isset($image_filename4)) { $data['image4'] = $image_filename4; } //image upload if (isset($image_filename5)) { $data['image5'] = $image_filename5; } //image upload if (isset($image_filename6)) { $data['image6'] = $image_filename6; } //image upload if (isset($image_filename7)) { $data['image7'] = $image_filename7; } //image upload if (isset($image_filename8)) { $data['image8'] = $image_filename8; } //image upload if (isset($image_filename9)) { $data['image9'] = $image_filename9; } //image upload if (isset($image_filename10)) { $data['image10'] = $image_filename10; } $this->service_m->edit_service($id, $data); $this->session->set_flashdata('success', '<br><p style="background:green; color:white; padding:5px; font-weight:bold;">Service Edit Successful</p>'); redirect('admin/service'); } $this->db->select('*'); $this->db->from('configuration'); $data['config'] = $this->db->get()->result(); foreach ($data['config'] as $item) { $this->data_header['image'] = $item->logo; $this->data_header['icon'] = $item->website_icon; } $this->data['subview'] = 'admin/service/edit'; $this->load->view('admin/templates/header', $this->data_header); $this->load->view('admin/_layout_main', $this->data); $this->load->view('admin/templates/footer'); } public function delete_image($image_number = NULL) { if($image_number == NULL) { show_404(); } //get image file name for deletion $this->db->select('image1,image2,image3,image4,image5,image6,image7,image8,image9,image10'); $this->db->from('service'); $this->db->where('id_service', 1); switch($image_number) { case '1': $image = $this->db->get()->row()->image; break; case '2': $image = $this->db->get()->row()->image2; break; case '3': $image = $this->db->get()->row()->image3; break; case '4': $image = $this->db->get()->row()->image4; break; case '5': $image = $this->db->get()->row()->image5; break; case '6': $image = $this->db->get()->row()->image6; break; case '7': $image = $this->db->get()->row()->image7; break; case '8': $image = $this->db->get()->row()->image8; break; case '9': $image = $this->db->get()->row()->image9; break; case '10': $image = $this->db->get()->row()->image10; break; } //Delete the actual image file from server. FCPATH is codeigniter base path unlink(FCPATH .'uploads/service/'. $image); //Delete image field from database $data = array( 'image' . $image_number => '', ); $this->db->where('id_service', 1); $this->db->update('service', $data); $this->session->set_flashdata('success', '<br><p style="background:green; color:white; padding:5px; font-weight:bold;">Service Image Delete Successful</p>'); redirect('admin/service'); } } ?>