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 : /proc/self/root/var/www/blue-sky.co.id/public_html/application/controllers/admin/ |
Upload File : |
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); class Halaman_info extends Admin_Controller { //this property is used for validating existing blog title on call back edit blog private $blog_current_id = NULL; private $small_image = NULL; private $small_image2 = NULL; private $small_image3 = NULL; private $image1 = NULL; private $image2 = NULL; private $image3 = NULL; private $image4 = NULL; private $half_image = NULL; private $half_image2 = NULL; private $half_image3 = NULL; //this property is to mark whether we are uploading image in the index page private $imageupload_indexpage = FALSE; function __construct() { parent::__construct(); //admin role module check $this->check_admin_role('halaman info'); //method from Admin_controller $this->load->model('halaman_info_m'); $this->load->helper('form'); } //this is to list all blog public function index() { //pagination in action. 100 results per page $this->load->library('pagination'); $config['base_url'] = base_url() . 'admin/halaman_info/index'; $config['total_rows'] = $this->halaman_info_m->record_count(); $config['per_page'] = 100; $config["uri_segment"] = 4; $config['num_tag_open'] = '<span style="padding-left:10px; padding-right:10px">'; $config['num_tag_close'] = '</span>'; $this->pagination->initialize($config); $this->data['blog'] = $this->halaman_info_m->get_all_blog($config["per_page"], $this->uri->segment(4)); //load view $this->data['subview'] = 'admin/halaman_info/index'; $this->load->view('admin/templates/header', $this->data_header); $this->load->view('admin/_layout_main', $this->data); $this->load->view('admin/templates/footer'); } function changeStatusAct(){ $this_id = $this->input->post('this_id'); $toStat = $this->input->post('toStat'); $codeStat = null; if ($toStat == "Ya") { $codeStat = '1'; }else{ $codeStat = '0'; } $data = array( "status"=>$codeStat, ); $upd = $this->db->update('halaman_info', $data, array('id_halaman_info' => $this_id)); if ($upd) { echo json_encode(array( "res"=>"sukses", )); } } // //to add a new blog // public function add() { // $this->data['blog'] = $this->halaman_info_m->get_new(); // //get ordering number and display at add form // $this->db->select_max('priority')->from('halaman_info'); // $current_priority = $this->db->get()->row()->priority; // if($current_priority == NULL) { // $this->data['blog']->priority = 1; // } else { // $this->data['blog']->priority = $current_priority + 1; // } // //validation in action // //validation check in action // $config = $this->halaman_info_m->rules; // $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($this) == TRUE) { // //get max image width and height from configuration table // $this->db->select('blog_image_width, blog_image_height, blog_thumbnail_width, blog_thumbnail_height')->from('configuration')->where('id_configuration', 1); // $image_dimension = $this->db->get()->row(); // //check & processing IMAGE INTRO // if ($_FILES['image1']['size'] !== 0) { // $config['upload_path'] = './uploads/blog/'; // $config['allowed_types'] = 'jpg|png'; // $config['max_size'] = '300'; // $config['max_width'] = $image_dimension->blog_image_width; // $config['max_height'] = $image_dimension->blog_image_height; // $this->load->library('upload', $config); // if ( ! $this->upload->do_upload('image1')) { // // return the error message and kill the script // //echo $this->upload->display_errors(); // $this->session->set_flashdata('image1-error', '<br> // <p style="background:red; color:white; padding:5px; font-weight:bold;">Kesalahan Unggah Gambar. Format atau ukuran salah.</p>'); // redirect('admin/halaman_info/add'); // } else { // $image1 = $this->upload->data(); // $this->image1_filename = $image1['file_name']; // $this->resize_single_image($image_dimension->blog_image_width,$image_dimension->blog_image_height,'blog/',$this->image1_filename); // } // } // //check & processing IMAGE TOP BANNER // if ($_FILES['image2']['size'] !== 0) { // $config['upload_path'] = './uploads/blog/'; // $config['allowed_types'] = 'jpg|png'; // $config['max_size'] = '500'; // $config['max_width'] = $image_dimension->blog_image_width; // $config['max_height'] = $image_dimension->blog_image_height; // $this->load->library('upload', $config); // if ( ! $this->upload->do_upload('image2')) { // // return the error message and kill the script // //echo $this->upload->display_errors(); // $this->session->set_flashdata('image2-error', '<br> // <p style="background:red; color:white; padding:5px; font-weight:bold;">Kesalahan Unggah Gambar. Format atau ukuran salah.</p>'); // redirect('admin/halaman_info/add'); // } else { // $image2 = $this->upload->data(); // $this->image2_filename = $image2['file_name']; // $this->resize_single_image($image_dimension->blog_image_width,$image_dimension->blog_image_height,'blog/',$this->image2_filename); // } // } // //check & processing IMAGE TOP BANNER // if ($_FILES['image_konten2']['size'] !== 0) { // $config['upload_path'] = './uploads/blog/'; // $config['allowed_types'] = 'jpg|png'; // $config['max_size'] = '500'; // // $config['max_width'] = '1000'; // // $config['max_height'] = '565'; // $this->load->library('upload', $config); // if ( ! $this->upload->do_upload('image_konten2')) { // // return the error message and kill the script // //echo $this->upload->display_errors(); // $this->session->set_flashdata('image_konten2', '<br> // <p style="background:red; color:white; padding:5px; font-weight:bold;">Kesalahan Unggah Gambar. Format atau ukuran salah.</p>'); // redirect('admin/halaman_info/add'); // } else { // $image_konten2 = $this->upload->data(); // $this->image_konten2_filename = $image_konten2['file_name']; // $this->resize_single_image('1000','565','blog/',$this->image_konten2_filename); // } // } // //check & processing IMAGE TOP BANNER // if ($_FILES['image_konten3']['size'] !== 0) { // $config['upload_path'] = './uploads/blog/'; // $config['allowed_types'] = 'jpg|png'; // $config['max_size'] = '500'; // // $config['max_width'] = '1000'; // // $config['max_height'] = '565'; // $this->load->library('upload', $config); // if ( ! $this->upload->do_upload('image_konten3')) { // // return the error message and kill the script // //echo $this->upload->display_errors(); // $this->session->set_flashdata('image_konten3', '<br> // <p style="background:red; color:white; padding:5px; font-weight:bold;">Kesalahan Unggah Gambar. Format atau ukuran salah.</p>'); // redirect('admin/halaman_info/add'); // } else { // $image_konten3 = $this->upload->data(); // $this->image_konten3_filename = $image_konten3['file_name']; // $this->resize_single_image('1000','565','blog/',$this->image_konten3_filename); // } // } // $data = $this->table_data_processing($this->input->post('blog_name'), $this->input->post('author'), $this->input->post('status'), $this->input->post('description'), $this->image1_filename, $this->image2_filename, $this->input->post('meta_description'), $this->input->post('meta_keywords'), $this->input->post('publish_date')); // $this->halaman_info_m->add_blog($data); // $this->session->set_flashdata('success', '<br><p style="background:green; color:white; padding:5px; font-weight:bold;">Tambah Blog Berhasil</p>'); // redirect('admin/halaman_info'); // } // $this->data['subview'] = 'admin/halaman_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'); // } //to edit blog in admin public function edit($id = NULL) { if ($id == NULL) { show_404(); } //check if id exist. If not exist, show 404. $count = $this->halaman_info_m->count_exist($id); if ($count == 0) { //page not exist show_404(); } $this->data['blog'] = $this->halaman_info_m->get($id); $this->blog_current_id = (int) $id; //validation check in action $config = $this->halaman_info_m->rules; $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($this) == TRUE) { //get max image width and height from configuration table $this->db->select('*')->from('configuration')->where('id_configuration', 1); $image_dimension = $this->db->get()->row(); //check & processing IMAGE INTRO if ($_FILES['image_banner']['size'] !== 0) { $config['upload_path'] = './uploads/blog/'; $config['allowed_types'] = 'jpg|png'; $config['max_size'] = '1024'; $config['max_width'] = $image_dimension->image_banner_width; $config['max_height'] = $image_dimension->image_banner_height; $this->load->library('upload', $config); if ( ! $this->upload->do_upload('image_banner')) { // return the error message and kill the script // echo $this->upload->display_errors(); // exit(); $this->session->set_flashdata('image_banner', '<br> <p style="background:red; color:white; padding:5px; font-weight:bold;">Kesalahan Unggah Gambar. Format atau ukuran salah.</p>'); redirect('admin/halaman_info/edit/' . $id); } else { $image_banner = $this->upload->data(); $this->image_banner_filename = $image_banner['file_name']; // $this->resize_single_image($image_dimension->blog_image_width,$image_dimension->blog_image_height,'blog/',$this->image_banner_filename); } } if($id==1) : //check & processing IMAGE INTRO if ($_FILES['small_image']['size'] !== 0) { $config['upload_path'] = './uploads/blog/'; $config['allowed_types'] = 'jpg|png'; $config['max_size'] = '1024'; $config['max_width'] = $image_dimension->small_image_width; $config['max_height'] = $image_dimension->small_image_height; $this->load->library('upload', $config); if ( ! $this->upload->do_upload('small_image')) { // return the error message and kill the script // echo $this->upload->display_errors(); // exit(); $this->session->set_flashdata('small_image', '<br> <p style="background:red; color:white; padding:5px; font-weight:bold;">Kesalahan Unggah Gambar. Format atau ukuran salah.</p>'); redirect('admin/halaman_info/edit/' . $id); } else { $small_image = $this->upload->data(); $this->small_image_filename = $small_image['file_name']; // $this->resize_single_image($image_dimension->blog_image_width,$image_dimension->blog_image_height,'blog/',$this->small_image_filename); } } //check & processing IMAGE TOP BANNER if ($_FILES['small_image2']['size'] !== 0) { $config['upload_path'] = './uploads/blog/'; $config['allowed_types'] = 'jpg|png'; $config['max_size'] = '1024'; $config['max_width'] = $image_dimension->small_image_width; $config['max_height'] = $image_dimension->small_image_height; $this->load->library('upload', $config); if ( ! $this->upload->do_upload('small_image2')) { // return the error message and kill the script // echo $this->upload->display_errors(); // exit(); $this->session->set_flashdata('small_image2-error', '<br> <p style="background:red; color:white; padding:5px; font-weight:bold;">Kesalahan Unggah Gambar. Format atau ukuran salah.</p>'); redirect('admin/halaman_info/edit/' . $id); } else { $small_image2 = $this->upload->data(); $this->small_image2_filename = $small_image2['file_name']; // $this->resize_single_image($image_dimension->blog_image_width,$image_dimension->blog_image_height,'blog/',$this->small_image2_filename); } } //check & processing IMAGE TOP BANNER if ($_FILES['small_image3']['size'] !== 0) { $config['upload_path'] = './uploads/blog/'; $config['allowed_types'] = 'jpg|png'; $config['max_size'] = '1024'; $config['max_width'] = $image_dimension->small_image_width; $config['max_height'] = $image_dimension->small_image_height; $this->load->library('upload', $config); if ( ! $this->upload->do_upload('small_image3')) { // return the error message and kill the script // echo $this->upload->display_errors(); // exit(); $this->session->set_flashdata('small_image3', '<br> <p style="background:red; color:white; padding:5px; font-weight:bold;">Kesalahan Unggah Gambar. Format atau ukuran salah.</p>'); redirect('admin/halaman_info/edit/' . $id); } else { $small_image3 = $this->upload->data(); $this->small_image3_filename = $small_image3['file_name']; // $this->resize_single_image('1000','565','blog/',$this->small_image3_filename); } } //check & processing IMAGE TOP BANNER if ($_FILES['image1']['size'] !== 0) { $config['upload_path'] = './uploads/blog/'; $config['allowed_types'] = 'jpg|png'; $config['max_size'] = '1024'; $config['max_width'] = $image_dimension->rectangle_image_width; $config['max_height'] = $image_dimension->rectangle_image_height; $this->load->library('upload', $config); if ( ! $this->upload->do_upload('image1')) { // return the error message and kill the script // echo $this->upload->display_errors(); // exit(); $this->session->set_flashdata('image1', '<br> <p style="background:red; color:white; padding:5px; font-weight:bold;">Kesalahan Unggah Gambar. Format atau ukuran salah.</p>'); redirect('admin/halaman_info/edit/' . $id); } else { $image1 = $this->upload->data(); $this->image1_filename = $image1['file_name']; // $this->resize_single_image('1000','565','blog/',$this->image1_filename); } } endif; if($id==6) : //check & processing IMAGE INTRO if ($_FILES['half_image3']['size'] !== 0) { $config['upload_path'] = './uploads/blog/'; $config['allowed_types'] = 'jpg|png'; $config['max_size'] = '1024'; $config['max_width'] = $image_dimension->half_image_width; $config['max_height'] = $image_dimension->half_image_height; $this->load->library('upload', $config); if ( ! $this->upload->do_upload('half_image3')) { // return the error message and kill the script // echo $this->upload->display_errors(); // exit(); $this->session->set_flashdata('half_image3', '<br> <p style="background:red; color:white; padding:5px; font-weight:bold;">Kesalahan Unggah Gambar. Format atau ukuran salah.</p>'); redirect('admin/halaman_info/edit/' . $id); } else { $half_image3 = $this->upload->data(); $this->half_image3_filename = $half_image3['file_name']; // $this->resize_single_image($image_dimension->blog_image_width,$image_dimension->blog_image_height,'blog/',$this->small_image_filename); } } endif; if($id==2) : //check & processing IMAGE INTRO if ($_FILES['video']['size'] !== 0) { $config['upload_path'] = './uploads/video/'; $config['allowed_types'] = 'mp4'; $config['max_size'] = '60000'; // $config['max_width'] = $image_dimension->video_width; // $config['max_height'] = $image_dimension->video_height; $this->load->library('upload', $config); if ( ! $this->upload->do_upload('video')) { // return the error message and kill the script echo $this->upload->display_errors(); exit(); $this->session->set_flashdata('video', '<br> <p style="background:red; color:white; padding:5px; font-weight:bold;">Kesalahan Unggah Gambar. Format atau ukuran salah.</p>'); redirect('admin/halaman_info/edit/' . $id); } else { $video = $this->upload->data(); $this->video_filename = $video['file_name']; // $this->resize_single_image($image_dimension->blog_image_width,$image_dimension->blog_image_height,'blog/',$this->small_image_filename); } } endif; if($id==2 || $id==6) : //check & processing IMAGE TOP BANNER if ($_FILES['half_image']['size'] !== 0) { $config['upload_path'] = './uploads/blog/'; $config['allowed_types'] = 'jpg|png'; $config['max_size'] = '1024'; $config['max_width'] = $image_dimension->half_image_width; $config['max_height'] = $image_dimension->half_image_height; $this->load->library('upload', $config); if ( ! $this->upload->do_upload('half_image')) { // return the error message and kill the script // echo $this->upload->display_errors(); // exit(); $this->session->set_flashdata('half_image', '<br> <p style="background:red; color:white; padding:5px; font-weight:bold;">Kesalahan Unggah Gambar. Format atau ukuran salah.</p>'); redirect('admin/halaman_info/edit/' . $id); } else { $half_image = $this->upload->data(); $this->half_image_filename = $half_image['file_name']; // $this->resize_single_image('1000','565','blog/',$this->image2_filename); } } //check & processing IMAGE TOP BANNER if ($_FILES['half_image2']['size'] !== 0) { $config['upload_path'] = './uploads/blog/'; $config['allowed_types'] = 'jpg|png'; $config['max_size'] = '1024'; $config['max_width'] = $image_dimension->half_image_width; $config['max_height'] = $image_dimension->half_image_height; $this->load->library('upload', $config); if ( ! $this->upload->do_upload('half_image2')) { // return the error message and kill the script // echo $this->upload->display_errors(); // exit(); $this->session->set_flashdata('half_image2', '<br> <p style="background:red; color:white; padding:5px; font-weight:bold;">Kesalahan Unggah Gambar. Format atau ukuran salah.</p>'); redirect('admin/halaman_info/edit/' . $id); } else { $half_image2 = $this->upload->data(); $this->half_image2_filename = $half_image2['file_name']; // $this->resize_single_image('1000','565','blog/',$this->image2_filename); } } endif; if($id==1 || $id==2) : //check & processing IMAGE TOP BANNER if ($_FILES['image2']['size'] !== 0) { $config['upload_path'] = './uploads/blog/'; $config['allowed_types'] = 'jpg|png'; $config['max_size'] = '1024'; $config['max_width'] = $image_dimension->rectangle_image_width; $config['max_height'] = $image_dimension->rectangle_image_height; $this->load->library('upload', $config); if ( ! $this->upload->do_upload('image2')) { // return the error message and kill the script // echo $this->upload->display_errors(); // exit(); $this->session->set_flashdata('image2', '<br> <p style="background:red; color:white; padding:5px; font-weight:bold;">Kesalahan Unggah Gambar. Format atau ukuran salah.</p>'); redirect('admin/halaman_info/edit/' . $id); } else { $image2 = $this->upload->data(); $this->image2_filename = $image2['file_name']; // $this->resize_single_image('1000','565','blog/',$this->image2_filename); } } endif; if($id==1 || $id==2 || $id==6) : //check & processing IMAGE TOP BANNER if ($_FILES['image3']['size'] !== 0) { $config['upload_path'] = './uploads/blog/'; $config['allowed_types'] = 'jpg|png'; $config['max_size'] = '1024'; $config['max_width'] = $image_dimension->rectangle_image_width; $config['max_height'] = $image_dimension->rectangle_image_height; $this->load->library('upload', $config); if ( ! $this->upload->do_upload('image3')) { // return the error message and kill the script // echo $this->upload->display_errors(); // exit(); $this->session->set_flashdata('image3', '<br> <p style="background:red; color:white; padding:5px; font-weight:bold;">Kesalahan Unggah Gambar. Format atau ukuran salah.</p>'); redirect('admin/halaman_info/edit/' . $id); } else { $image3 = $this->upload->data(); $this->image3_filename = $image3['file_name']; // $this->resize_single_image('1000','565','blog/',$this->image3_filename); } } endif; if($id==1 || $id==3) : //check & processing IMAGE TOP BANNER if ($_FILES['image4']['size'] !== 0) { $config['upload_path'] = './uploads/blog/'; $config['allowed_types'] = 'jpg|png'; $config['max_size'] = '1024'; $config['max_width'] = $image_dimension->rectangle_image_width; $config['max_height'] = $image_dimension->rectangle_image_height; $this->load->library('upload', $config); if ( ! $this->upload->do_upload('image4')) { // return the error message and kill the script // echo $this->upload->display_errors(); // exit(); $this->session->set_flashdata('image4', '<br> <p style="background:red; color:white; padding:5px; font-weight:bold;">Kesalahan Unggah Gambar. Format atau ukuran salah.</p>'); redirect('admin/halaman_info/edit/' . $id); } else { $image4 = $this->upload->data(); $this->image4_filename = $image4['file_name']; // $this->resize_single_image('1000','565','blog/',$this->image4_filename); } } endif; // $data = $this->table_data_processing($this->input->post('halaman'), $this->input->post('halaman_en'),'','',$this->input->post('text_content'),$this->input->post('text_content_en'),$this->input->post('title2'),$this->input->post('title2_en'),'',$this->small_image_filename,$this->small_image2_filename,$this->small_image3_filename,'','',$this->input->post('text_content2'),$this->input->post('text_content2_en'),'','','',$this->input->post('text_content3'),$this->input->post('text_content3_en'),'',$this->image1_filename,'','','','',$this->input->post('text_content4'),$this->input->post('text_content4_en'),'',$this->image2_filename,$this->input->post('title6'),$this->input->post('title6_en'),$this->input->post('text_content5'),$this->input->post('text_content5_en'),'',$this->image3_filename,$this->input->post('title7'),$this->input->post('title7_en'),$this->input->post('text_content6'),$this->input->post('text_content6_en'),'','',$this->input->post('status'),$this->input->post('priority'),'','','','','','','','','','','','','','','','','',''); $data = $this->table_data_processing($this->input->post('halaman'), $this->input->post('halaman_en'),'','',$this->input->post('text_content'),$this->input->post('text_content_en'),$this->input->post('title2'),$this->input->post('title2_en'),'','','','','','',$this->input->post('text_content2'),$this->input->post('text_content2_en'),'','','',$this->input->post('text_content3'),$this->input->post('text_content3_en'),'','','','','','',$this->input->post('text_content4'),$this->input->post('text_content4_en'),'','',$this->input->post('title6'),$this->input->post('title6_en'),$this->input->post('text_content5'),$this->input->post('text_content5_en'),'','',$this->input->post('title7'),$this->input->post('title7_en'),$this->input->post('text_content6'),$this->input->post('text_content6_en'),'','',$this->input->post('status'),$this->input->post('priority'),$this->input->post('title8'),$this->input->post('title8_en'),$this->input->post('title9'),$this->input->post('title9_en'),$this->input->post('text_content7'),$this->input->post('text_content7_en'),$this->input->post('text_content8'),$this->input->post('text_content8_en'),$this->input->post('text_content9'),$this->input->post('text_content9_en'),'','','','','','','','',$this->input->post('optradio2'),$this->input->post('optradio3'),$this->input->post('optradio4'),$this->input->post('optradio5'),$this->input->post('optradio6'),$this->input->post('optradio7'),$this->input->post('optradio8'),$this->input->post('optradio9')); $this->halaman_info_m->edit_blog($id, $data); $this->session->set_flashdata('success', '<br><p style="background:green; color:white; padding:5px; font-weight:bold;">Edit Halaman Berhasil</p>'); switch ($id) { case 1: if ($this->input->post('btn_link1')) { $this->db->where('id_halaman_info', (int) $id); $this->db->update('halaman_info', array( "link"=>$this->input->post('btn_link1'), "link2"=>$this->input->post('btn_link2'), "link3"=>$this->input->post('btn_link3'), "link4"=>$this->input->post('btn_link4'), )); } break; case 2: if ($this->input->post('btn_link1')) { $this->db->where('id_halaman_info', (int) $id); $this->db->update('halaman_info', array( "link"=>$this->input->post('btn_link1'), "link2"=>$this->input->post('btn_link2'), "link3"=>$this->input->post('btn_link3'), "link4"=>$this->input->post('btn_link4'), )); } break; case 3: if ($this->input->post('btn_link1')) { $this->db->where('id_halaman_info', (int) $id); $this->db->update('halaman_info', array( "link"=>$this->input->post('btn_link1'), )); } break; default: # code... break; } redirect('admin/halaman_info/edit/' . $id); } $this->data['subview'] = 'admin/halaman_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'); } // //to delete a blog // public function delete($id) { // //check if id exist. If not exist, show 404. // $count = $this->halaman_info_m->count_exist($id); // if ($count == 0) { //page not exist // show_404(); // } // //delete image from server // //check if there is an existing image // $this->db->select('image1, image2')->from('halaman_info')->where('id_halaman_info', (int) $id); // $image = $this->db->get()->row(); // if ($image->image1 != '') { // //Delete the actual image file from server. FCPATH is codeigniter base path // unlink(FCPATH .'/uploads/blog/'. $image->image1); // } // if ($image->image2 != '') { // //Delete the actual image file from server. FCPATH is codeigniter base path // unlink(FCPATH .'/uploads/blog/'. $image->image2); // } // //delete blog // $this->halaman_info_m->delete($id); // $this->session->set_flashdata('success', '<br><p style="background:green; color:white; padding:5px; font-weight:bold;">Hapus Blog Berhasil</p>'); // redirect('admin/halaman_info'); // } // private function table_data_processing($halaman,$halaman_en,$title,$title_en,$text_content,$text_content_en,$title2,$title2_en,$video,$small_image,$small_image2,$small_image3,$title3,$title3_en,$text_content2,$text_content2_en,$link,$title4,$title4_en,$text_content3,$text_content3_en,$link2,$image,$half_image,$half_image2,$title5,$title5_en,$text_content4,$text_content4_en,$link3,$image2,$title6,$title6_en,$text_content5,$text_content5_en,$link4,$image3,$title7,$title7_en,$text_content6,$text_content6_en,$link5,$image4,$status,$priority,$title8,$title8_en,$title9,$title9_en,$text_content7,$text_content7_en,$text_content8,$text_content8_en,$text_content9,$text_content9_en,$icon,$icon2,$icon3,$icon4,$icon5,$icon6,$icon7,$icon8) { private function table_data_processing($halaman,$halaman_en,$title,$title_en,$text_content,$text_content_en,$title2,$title2_en,$video,$small_image,$small_image2,$small_image3,$title3,$title3_en,$text_content2,$text_content2_en,$link,$title4,$title4_en,$text_content3,$text_content3_en,$link2,$image,$half_image,$half_image2,$title5,$title5_en,$text_content4,$text_content4_en,$link3,$image2,$title6,$title6_en,$text_content5,$text_content5_en,$link4,$image3,$title7,$title7_en,$text_content6,$text_content6_en,$link5,$image4,$status,$priority,$title8,$title8_en,$title9,$title9_en,$text_content7,$text_content7_en,$text_content8,$text_content8_en,$text_content9,$text_content9_en,$icon,$icon2,$icon3,$icon4,$icon5,$icon6,$icon7,$icon8,$status2,$status3,$status4,$status5,$status6,$status7,$status8,$status9) { $data = array( 'halaman' => $halaman, 'halaman_en' => $halaman_en, 'alias' => url_title($halaman), 'alias_en' => url_title($halaman_en), 'title' => '', 'title_en' => '', 'text_content' => $text_content, 'text_content_en' => $text_content_en, 'title2' => $title2, 'title2_en' => $title2_en, // 'video' => '', // 'small_image' => $small_image, // 'small_image2' => $small_image2, // 'small_image3' => $small_image3, 'title3' => '', 'title3_en' => '', 'text_content2' => $text_content2, 'text_content2_en' => $text_content2_en, 'link' => '', 'title4' => '', 'title4_en' => '', 'text_content3' => $text_content3, 'text_content3_en' => $text_content3_en, 'link2' => '', // 'image' => $image, // 'half_image' => '', // 'half_image2' => '', 'title5' => '', 'title5_en' => '', 'text_content4' => $text_content4, 'text_content4_en' => $text_content4_en, 'link3' => '', // 'image2' => $image2, 'title6' => $title6, 'title6_en' => $title6_en, 'text_content5' => $text_content5, 'text_content5_en' => $text_content5_en, 'link4' => '', // 'image3' => $image3, 'title7' => $title7, 'title7_en' => $title7_en, 'text_content6' => $text_content6, 'text_content6_en' => $text_content6_en, 'link5' => '', // 'image4' => $image4, 'status' => $status, 'priority' => $priority, 'title8' => $title8, 'title8_en' => $title8_en, 'title9' => $title9, 'title9_en' => $title9_en, 'text_content7' => $text_content7, 'text_content7_en' => $text_content7_en, 'text_content8' => $text_content8, 'text_content8_en' => $text_content8_en, 'text_content9' => $text_content9, 'text_content9_en' => $text_content9_en, 'icon' => '', 'icon2' => '', 'icon3' => '', 'icon4' => '', 'icon5' => '', 'icon6' => '', 'icon7' => '', 'icon8' => '', 'status2' => $status2, 'status3' => $status3, 'status4' => $status4, 'status5' => $status5, 'status6' => $status6, 'status7' => $status7, 'status8' => $status8, 'status9' => $status9, ); //image upload if (isset($this->small_image_filename)) { $data['small_image'] = $this->small_image_filename; } //image upload if (isset($this->small_image2_filename)) { $data['small_image2'] = $this->small_image2_filename; } //image upload if (isset($this->small_image3_filename)) { $data['small_image3'] = $this->small_image3_filename; } //image upload if (isset($this->image1_filename)) { $data['image'] = $this->image1_filename; } //image upload if (isset($this->image2_filename)) { $data['image2'] = $this->image2_filename; } //image upload if (isset($this->image3_filename)) { $data['image3'] = $this->image3_filename; } //image upload if (isset($this->image4_filename)) { $data['image4'] = $this->image4_filename; } //image upload if (isset($this->half_image_filename)) { $data['half_image'] = $this->half_image_filename; } //image upload if (isset($this->half_image2_filename)) { $data['half_image2'] = $this->half_image2_filename; } //image upload if (isset($this->half_image3_filename)) { $data['half_image3'] = $this->half_image3_filename; } //image upload if (isset($this->video_filename)) { $data['video'] = $this->video_filename; } //image upload if (isset($this->image_banner_filename)) { $data['image_banner'] = $this->image_banner_filename; } return $data; } //callback function validation add new blog //make it private by adding _ public function _cek_existing_blog_title($str) { $num_rows = $this->halaman_info_m->cek_existing_blog_title($str, $this->blog_current_id); if ($num_rows != 0 ) { $this->form_validation->set_message('_cek_existing_blog_title', 'nama blog sudah ada !'); return FALSE; } else { return TRUE; } } public function _cek_existing_blog_title_en($str) { $num_rows = $this->halaman_info_m->cek_existing_blog_title_en($str, $this->blog_current_id); if ($num_rows != 0 ) { $this->form_validation->set_message('_cek_existing_blog_title_en', 'nama blog bahasa inggris sudah ada !'); return FALSE; } else { return TRUE; } } //To delete blog image file from server, and from database public function delete_image($id = NULL, $image_type = NULL) { $count = $this->halaman_info_m->count_exist($id); if ($id == NULL || $count == 0) { redirect('admin/halaman_info'); } if ($image_type == NULL) {redirect('admin/halaman_info'); } //get image file name for deletion $this->db->select('*')->from('halaman_info')->where('id_halaman_info', (int) $id); $image = $this->db->get()->row(); if($image_type == 'small_image') { //Delete the actual image file from server. FCPATH is codeigniter base path unlink(FCPATH .'/uploads/blog/'. $image->small_image); //Delete image field from database $data = array( 'small_image' => '', ); } elseif($image_type == 'small_image2') { //Delete the actual image file from server. FCPATH is codeigniter base path unlink(FCPATH .'/uploads/blog/'. $image->small_image2); //Delete image field from database $data = array( 'small_image2' => '', ); } elseif($image_type == 'small_image3') { //Delete the actual image file from server. FCPATH is codeigniter base path unlink(FCPATH .'/uploads/blog/'. $image->small_image3); //Delete image field from database $data = array( 'small_image3' => '', ); } elseif($image_type == 'image1') { //Delete the actual image file from server. FCPATH is codeigniter base path unlink(FCPATH .'/uploads/blog/'. $image->image); //Delete image field from database $data = array( 'image' => '', ); } elseif($image_type == 'image2') { //Delete the actual image file from server. FCPATH is codeigniter base path unlink(FCPATH .'/uploads/blog/'. $image->image2); //Delete image field from database $data = array( 'image2' => '', ); } elseif($image_type == 'image3') { //Delete the actual image file from server. FCPATH is codeigniter base path unlink(FCPATH .'/uploads/blog/'. $image->image3); //Delete image field from database $data = array( 'image3' => '', ); } elseif($image_type == 'image4') { //Delete the actual image file from server. FCPATH is codeigniter base path unlink(FCPATH .'/uploads/blog/'. $image->image4); //Delete image field from database $data = array( 'image4' => '', ); } elseif($image_type == 'half_image') { //Delete the actual image file from server. FCPATH is codeigniter base path unlink(FCPATH .'/uploads/blog/'. $image->half_image); //Delete image field from database $data = array( 'half_image' => '', ); } elseif($image_type == 'half_image2') { //Delete the actual image file from server. FCPATH is codeigniter base path unlink(FCPATH .'/uploads/blog/'. $image->half_image2); //Delete image field from database $data = array( 'half_image2' => '', ); } elseif($image_type == 'half_image3') { //Delete the actual image file from server. FCPATH is codeigniter base path unlink(FCPATH .'/uploads/blog/'. $image->half_image3); //Delete image field from database $data = array( 'half_image3' => '', ); } elseif($image_type == 'video') { //Delete the actual image file from server. FCPATH is codeigniter base path unlink(FCPATH .'/uploads/video/'. $image->video); //Delete image field from database $data = array( 'video' => '', ); } elseif($image_type == 'image_banner') { //Delete the actual image file from server. FCPATH is codeigniter base path unlink(FCPATH .'/uploads/blog/'. $image->image_banner); //Delete image field from database $data = array( 'image_banner' => '', ); } $this->db->where('id_halaman_info', (int) $id); $this->db->update('halaman_info', $data); $this->session->set_flashdata('success', '<br><p style="background:green; color:white; padding:5px; font-weight:bold;">Hapus Gambar Berhasil</p>'); redirect('admin/halaman_info/edit/' . $id); } function refreshDisplayPriority(){ $this_data = $this->input->post('this_data'); foreach ($this_data as $key) { $u_data = array( 'priority'=>$key['val'], ); $this->db->update('halaman_info', $u_data, array('id_halaman_info' => $key['id'])); } $this->session->set_flashdata('success', '<br><p style="background:green; color:white; padding:5px; font-weight:bold;">Urutan halaman berhasil diubah</p>'); echo json_encode(array( "res"=>"sukses", // "data"=>$this_data, )); } }