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 Pages extends Admin_Controller { //this property is used for validating existing page title on call back edit page private $page_current_id = NULL; private $image1_filename = NULL; private $image2_filename = NULL; private $image3_filename = NULL; private $image_center1_filename = NULL; private $image_center2_filename = NULL; private $image_center3_filename = NULL; private $image_banner_filename = 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 statis'); //method from Admin_controller $this->load->model('page_m'); } //this is to list all pages public function index() { if (isset($_POST['submit'])) { $this->imageupload_indexpage = 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 banner upload files if ($_FILES['userfile']['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()) { // echo $this->upload->display_errors(); die(); $this->session->set_flashdata('banner_msg', '<br> <p style="background:orange; color:white; padding:5px; font-weight:bold;">Kesalahan Unggah Gambar. Format atau ukuran salah.</p>'); redirect('admin/pages/index/'); } else { $image = $this->upload->data(); $image_filename = $image['file_name']; $this->resize_single_image($image_dimension->image_banner_width, $image_dimension->image_banner_height, 'blog/', $image_filename); } //image upload if (isset($image_filename)) { $data['page_banner'] = $image_filename; } $this->db->where('id_configuration', 1); $this->db->update('configuration', $data); $this->session->set_flashdata('success', '<br><p style="background:green; color:white; padding:5px; font-weight:bold;">Edit Banner Berhasil</p>'); } } $this->data['halaman'] = $this->db->select('page_banner')->from('configuration')->get()->row(); //pagination in action. 20 results per page $this->load->library('pagination'); $config['base_url'] = base_url() . 'admin/pages/index'; $config['per_page'] = 20; $config["uri_segment"] = 4; //fetch all pages $config['total_rows'] = $this->page_m->record_count(); $this->pagination->initialize($config); $this->data['pages'] = $this->page_m->get_all_pages( $config["per_page"], $this->uri->segment(4) ); //get parent pages only $this->data['parent_pages'] = $this->page_m->get_all_parent_pages($config["per_page"], $this->uri->segment($config['uri_segment'])); //load view $this->data['subview'] = 'admin/pages/index'; $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 blog landingpage banner image file from server, and from database public function delete_page_banner() { //get image file name for deletion $this->db->select('page_banner')->from('configuration')->where('id_configuration', 1); $image = $this->db->get()->row()->page_banner; //Delete the actual image file from server. FCPATH is codeigniter base path unlink(FCPATH . '/uploads/blog/' . $image); //Delete image field from database $data = array( 'page_banner' => '', ); $this->db->where('id_configuration', 1); $this->db->update('configuration', $data); $this->session->set_flashdata('success', '<br><p style="background:green; color:white; padding:5px; font-weight:bold;">Hapus Banner Berhasil</p>'); redirect('admin/pages/index'); } 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('pages', $data, array('id_pages' => $this_id)); if ($upd) { echo json_encode(array( "res" => "sukses", )); } } //to add a new page public function add() { $this->data['pages'] = $this->page_m->get_new(); $this->data['parent_pages'] = $this->page_m->get_parent_pages(); //get ordering number and display at add form $this->db->select_max('priority')->from('pages')->where('parent', NULL); $current_priority = $this->db->get()->row()->priority; if ($current_priority == NULL) { $this->data['pages']->priority = 1; } else { $this->data['pages']->priority = $current_priority + 1; } //validation in action //validation check in action $config = $this->page_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) { if ($_POST) { $data = array(); //check & processing image banner upload files if ($_FILES['image1']['size'] !== 0) { $config['upload_path'] = './uploads/banners/'; $config['allowed_types'] = 'jpg|png'; $config['max_size'] = '600'; $config['max_width'] = '1670'; $config['max_height'] = '800'; if ($id == '23') { $config['max_size'] = '400'; $config['max_width'] = '570'; $config['max_height'] = '425'; } $this->load->library('upload', $config); $this->upload->initialize($config); if (!$this->upload->do_upload('image1')) { echo 'image1' . $this->upload->display_errors(); exit(); $this->session->set_flashdata('error1', '<br> <p style="background:orange; color:white; padding:5px; font-weight:bold;">Kesalahan Unggah Gambar. Format atau ukuran salah.</p>'); redirect('admin/pages/add'); } else { $image1 = $this->upload->data(); $image1_filename = $image1['file_name']; // $this->resize_single_image('580','500','home_about/',$image1_filename); } } if ($_FILES['image2']['size'] !== 0) { $config['upload_path'] = './uploads/banners/'; $config['allowed_types'] = 'jpg|png'; $config['max_size'] = '600'; $config['max_width'] = '1670'; $config['max_height'] = '800'; if ($id == '23') { $config['max_size'] = '400'; $config['max_width'] = '570'; $config['max_height'] = '425'; } $this->load->library('upload', $config); $this->upload->initialize($config); if (!$this->upload->do_upload('image2')) { echo 'image2' . $this->upload->display_errors(); exit(); $this->session->set_flashdata('error2', '<br> <p style="background:orange; color:white; padding:5px; font-weight:bold;">Kesalahan Unggah Gambar. Format atau ukuran salah.</p>'); redirect('admin/pages/add'); } else { $image2 = $this->upload->data(); $image2_filename = $image2['file_name']; // $this->resize_single_image('580','500','home_about/',$image2_filename); } } if ($_FILES['image3']['size'] !== 0) { $config['upload_path'] = './uploads/banners/'; $config['allowed_types'] = 'jpg|png'; $config['max_size'] = '600'; $config['max_width'] = '1670'; $config['max_height'] = '800'; if ($id == '23') { $config['max_size'] = '400'; $config['max_width'] = '570'; $config['max_height'] = '425'; } $this->load->library('upload', $config); $this->upload->initialize($config); if (!$this->upload->do_upload('image3')) { echo 'image3' . $this->upload->display_errors(); exit(); $this->session->set_flashdata('error3', '<br> <p style="background:orange; color:white; padding:5px; font-weight:bold;">Kesalahan Unggah Gambar. Format atau ukuran salah.</p>'); redirect('admin/pages/add'); } else { $image3 = $this->upload->data(); $image3_filename = $image3['file_name']; // $this->resize_single_image('580','500','home_about/',$image3_filename); } } $data = $this->table_data_processing( $this->input->post('page_title'), $this->input->post('page_title_en'), $this->input->post('status'), $this->input->post('body_text'), $this->input->post('body_text_en'), $this->input->post('meta_description'), $this->input->post('meta_keywords') ); //image upload if (isset($image1_filename)) { $data['img_name'] = $image1_filename; } else { $data['img_name'] = @explode(' | ', $this->data['pages']->img_name)[0]; } //image upload if (isset($image2_filename)) { $data['img_name'] .= ' | ' . $image2_filename; } else { $data['img_name'] .= ' | ' . @explode(' | ', $this->data['pages']->img_name)[1]; } //image upload if (isset($image3_filename)) { $data['img_name'] .= ' | ' . $image3_filename; } else { $data['img_name'] .= ' | ' . @explode(' | ', $this->data['pages']->img_name)[2]; } if (isset($id) && ($id != '23' && $id != '28' && $id != '30')) { if ($_FILES['image_center1']['size'] !== 0) { $config['upload_path'] = './uploads/image_center/'; $config['allowed_types'] = 'jpg|png'; $config['max_size'] = '300'; $config['max_width'] = '1670'; $config['max_height'] = '800'; $this->load->library('upload', $config); $this->upload->initialize($config); if (!$this->upload->do_upload('image_center1')) { echo 'image_center1' . $this->upload->display_errors(); exit(); $this->session->set_flashdata('image_center1', '<br> <p style="background:orange; color:white; padding:5px; font-weight:bold;">Kesalahan Unggah Gambar. Format atau ukuran salah.</p>'); redirect('admin/pages/add'); } else { $image_center1 = $this->upload->data(); $image_center1_filename = $image_center1['file_name']; } } if (isset($image_center1_filename)) { $data['img_center1'] = $image_center1_filename; } if ($_FILES['image_center2']['size'] !== 0) { echo 'image_center2' . $this->upload->display_errors(); exit(); $config['upload_path'] = './uploads/image_center/'; $config['allowed_types'] = 'jpg|png'; $config['max_size'] = '300'; $config['max_width'] = '1670'; $config['max_height'] = '800'; $this->load->library('upload', $config); $this->upload->initialize($config); if (!$this->upload->do_upload('image_center2')) { $this->session->set_flashdata('image_center2', '<br> <p style="background:orange; color:white; padding:5px; font-weight:bold;">Kesalahan Unggah Gambar. Format atau ukuran salah.</p>'); redirect('admin/pages/add'); } else { $image_center2 = $this->upload->data(); $image_center2_filename = $image_center2['file_name']; } } if (isset($image_center2_filename)) { $data['img_center2'] = $image_center2_filename; } if ($_FILES['image_center3']['size'] !== 0) { $config['upload_path'] = './uploads/image_center/'; $config['allowed_types'] = 'jpg|png'; $config['max_size'] = '300'; $config['max_width'] = '1670'; $config['max_height'] = '800'; $this->load->library('upload', $config); $this->upload->initialize($config); if (!$this->upload->do_upload('image_center3')) { echo 'image_center3' . $this->upload->display_errors(); exit(); $this->session->set_flashdata('image_center3', '<br> <p style="background:orange; color:white; padding:5px; font-weight:bold;">Kesalahan Unggah Gambar. Format atau ukuran salah.</p>'); redirect('admin/pages/add'); } else { $image_center3 = $this->upload->data(); $image_center3_filename = $image_center3['file_name']; } } if (isset($image_center3_filename)) { $data['img_center3'] = $image_center3_filename; } if ($_FILES['image_banner']['size'] !== 0) { $config['upload_path'] = './uploads/banners/'; $config['allowed_types'] = 'jpg|png'; $config['max_size'] = '600'; $config['max_width'] = '1670'; $config['max_height'] = '800'; $this->load->library('upload', $config); $this->upload->initialize($config); if (!$this->upload->do_upload('image_banner')) { echo 'image_banner' . $this->upload->display_errors(); exit(); $this->session->set_flashdata('image_banner', '<br> <p style="background:orange; color:white; padding:5px; font-weight:bold;">Kesalahan Unggah Gambar. Format atau ukuran salah.</p>'); redirect('admin/pages/add'); } else { $image_banner = $this->upload->data(); $image_banner_filename = $image_banner['file_name']; } } if (isset($image_banner_filename)) { $data['img_banner'] = $image_banner_filename; } } $data['header_text'] = $this->input->post('header_text'); $data['header_text_en'] = $this->input->post('header_text_en'); $data['active_banner_slider'] = $this->input->post('active_banner_slider'); $data['active_content'] = $this->input->post('active_content'); $data['active_gallery'] = $this->input->post('active_gallery'); $data['active_all_product'] = $this->input->post('active_all_product'); $data['active_map'] = $this->input->post('active_map'); $data['active_contact'] = $this->input->post('active_contact'); $data['active_center_img'] = $this->input->post('active_center_img'); $data['text_judul'] = $this->input->post('text_judul'); $data['text_content'] = $this->input->post('text_content'); $data['text_judul_2'] = $this->input->post('text_judul_2'); $data['text_content_2'] = $this->input->post('text_content_2'); $data['text_judul_3'] = $this->input->post('text_judul_3'); $data['text_content_3'] = $this->input->post('text_content_3'); $data['active_section_hotel'] = $this->input->post('active_section_hotel'); $data['active_section_lounge'] = $this->input->post('active_section_lounge'); $data['active_section_cafe'] = $this->input->post('active_section_cafe'); $data['active_section_residence'] = $this->input->post('active_section_residence'); // echo '<pre>'; // var_dump($data); // exit(); // echo '</pre>'; $this->page_m->add_page($data); } $this->session->set_flashdata('success', '<br><p style="background:green; color:white; padding:5px; font-weight:bold;">Tambah Halaman Berhasil</p>'); redirect('admin/pages'); } $this->data['subview'] = 'admin/pages/edit'; $this->load->view('admin/templates/header', $this->data_header); $this->load->view('admin/_layout_main', $this->data); $this->load->view('admin/templates/footer'); } function ajax_addnew_pages_static() { $page_title = $this->input->post('inp_page_title'); $page_title_en = $this->input->post('inp_page_title_en'); $body_text = $this->input->post('body_text'); $body_text_en = $this->input->post('body_text_en'); $current_priority = $this->db->select_max('priority')->from('pages') ->where('parent', NULL)->get()->row()->priority; $priority = null; if ($current_priority == NULL) { $priority = 1; } else { $priority = $current_priority + 1; } $data = array( 'page_title' => $this->security->xss_clean($page_title), 'page_title_en' => $this->security->xss_clean($page_title_en), 'alias' => url_title($this->security->xss_clean($page_title)), 'alias_en' => url_title($this->security->xss_clean($page_title_en)), 'body_text' => $body_text, 'body_text_en' => $body_text_en, 'priority' => $this->security->xss_clean($priority), ); $this->page_m->add_page($data); $this_option_out = '<option value="" data-title_idn="" data-title_eng=""> -- Pilih -- </option>'; $query_pages = $this->db->get("pages")->result(); foreach ($query_pages as $key) { $this_option_out .= "<option value='" . $key->id_pages . "' data-title_idn='" . $key->page_title . "' data-title_eng='" . $key->page_title_en . "'>" . ucwords($key->page_title . ' / ' . $key->page_title_en) . "</option>"; } echo json_encode(array( "result" => "sukses", "option_output" => $this_option_out, )); } public function edit_gallery_image($pages_id = NULL, $id = NULL) { $quer_pages_gallery = $this->db->get_where("pages_gallery", array( "id" => $id, "id_pages" => $pages_id, )); if ( $quer_pages_gallery->num_rows() == 0 // && $pages_id != '24' ) { show_404(); } $quer_pages_gallery = $quer_pages_gallery->row(); $this->data['pages_gallery'] = $quer_pages_gallery; $this->data['id_pages'] = $pages_id; $this->data['id_gallery'] = $id; $config = array( array( 'field' => 'priority', 'label' => 'Urutan Tampilan', 'rules' => 'trim|required' ), array( 'field' => 'header_text', 'label' => 'Judul Gambar', 'rules' => 'trim|required' ), array( 'field' => 'status', 'label' => 'Status', 'rules' => 'trim|required' ), ); $this->load->library('form_validation'); $this->form_validation->set_error_delimiters('<div class="error">', '</div>'); $this->form_validation->set_rules($config); $this->form_validation->set_error_delimiters('<div class="error">', '</div>'); if ($this->form_validation->run($this) == TRUE) { if ($_POST) { if ($_FILES['image1']['size'] !== 0) { $config['upload_path'] = './uploads/gallery/'; $config['allowed_types'] = 'jpg|png'; $config['max_size'] = '300'; $config['max_width'] = '1000'; $config['max_height'] = '700'; $this->load->library('upload', $config); $this->upload->initialize($config); if (!$this->upload->do_upload('image1')) { $this->session->set_flashdata('image_error', '<br> <p style="background:orange; color:white; padding:5px; font-weight:bold;">Kesalahan Unggah Gambar. Format atau ukuran salah.</p>'); redirect('admin/pages/edit_gallery_image/' . $pages_id . '/' . $id); } else { $image1 = $this->upload->data(); $image1_filename = $image1['file_name']; $this->load->library('image_lib'); //image resizing (SMALL IMAGE) $config2['image_library'] = 'gd2'; $config2['source_image'] = './uploads/gallery/' . $image1_filename; $config2['new_image'] = './uploads/gallery/small/'; $config2['create_thumb'] = FALSE; $config2['maintain_ratio'] = TRUE; $config2['width'] = '270'; $config2['height'] = '189'; $this->image_lib->initialize($config2); //firstly autoload image_lib, then initialize it. Dont repeatly load it. $this->image_lib->resize(); } } $data = array( "priority" => $this->security->xss_clean($this->input->post('priority')), "is_active" => $this->security->xss_clean($this->input->post('status')), ); //image upload if (isset($image1_filename)) { $data['img_name'] = $image1_filename; } else { $data['img_name'] = $this->data['pages_gallery']->img_name; } $data['header_text'] = $this->security->xss_clean($this->input->post('header_text')); $data['header_text_en'] = $this->security->xss_clean($this->input->post('header_text_en')); $data['body_text'] = $this->input->post('body_text'); $data['body_text_en'] = $this->input->post('body_text_en'); $this->db->where("id_pages", $pages_id) ->where('id', $id)->update('pages_gallery', $data); } $this->session->set_flashdata('success', '<br><p style="background:green; color:white; padding:5px; font-weight:bold;">Edit Gallery Berhasil</p>'); redirect('admin/pages/edit_gallery_image/' . $pages_id . '/' . $id); } $this->data['subview'] = 'admin/pages/edit_gallery_image'; $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_all_gallery() { $checkbox_for_del = $this->input->post('checkbox_del'); $id_pages = $this->input->post('id_pages'); if (empty($checkbox_for_del)) { redirect('admin/pages/pages_gallery/' . $id_pages); } for ($i = 0; $i < count($checkbox_for_del); $i++) { $id = $checkbox_for_del[$i]; $this->db->where('id', $id); $this->db->delete('pages_gallery'); } $this->session->set_flashdata('success', '<br><p style="background:green; color:white; padding:5px; font-weight:bold;">Foto Gallery berhasil dihapus</p>'); echo json_encode(array( 'result' => 'sukses', )); } function changeStatusActImages() { $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('pages_gallery', $data, array('id' => $this_id)); if ($upd) { echo json_encode(array( "res" => "sukses", )); } } function refreshDisplayPriority_Gallery() { $this_data = $this->input->post('this_data'); foreach ($this_data as $key) { $u_data = array( 'priority' => $key['val'], ); $this->db->update('pages_gallery', $u_data, array('id' => $key['id'])); } $this->session->set_flashdata('success', '<br><p style="background:green; color:white; padding:5px; font-weight:bold;">Gallery Priority berhasil diubah</p>'); echo json_encode(array( "res" => "sukses", // "data"=>$this_data, )); } public function delete_gallery_image($id_pages = NULL, $id = NULL) { if (empty($id_pages) || empty($id)) { redirect('admin/pages/pages_gallery/' . $id_pages . '/' . $id); } $this->db->where('id', $id); $this->db->delete('pages_gallery'); $this->session->set_flashdata('success', '<br><p style="background:green; color:white; padding:5px; font-weight:bold;">Foto Gallery berhasil dihapus</p>'); redirect('admin/pages/pages_gallery/' . $id_pages . '/' . $id); } public function add_gallery_image($pages_id = NULL) { $quer_pages_gallery = $this->db->get_where("pages_gallery", array( "id_pages" => $pages_id, )); // if ($quer_pages_gallery->num_rows() == 0 // // && $pages_id != '24' // ) { // show_404(); // } $quer_pages_gallery = new stdClass(); $quer_pages_gallery->img_name = ''; $quer_pages_gallery->status = 1; $quer_pages_gallery->priority = ''; $quer_pages_gallery->header_text = ''; $quer_pages_gallery->header_text_en = ''; $quer_pages_gallery->body_text = ''; $quer_pages_gallery->body_text_en = ''; $this->data['pages_gallery'] = $quer_pages_gallery; $this->data['id_pages'] = $pages_id; $config = array( // array( // 'field' => 'priority', // 'label' => 'Urutan Tampilan', // 'rules' => 'trim|required' // ), array( 'field' => 'status', 'label' => 'Status', 'rules' => 'trim|required' ), array( 'field' => 'header_text', 'label' => 'Judul Gambar', 'rules' => 'trim|required' ), ); $this->load->library('form_validation'); $this->form_validation->set_error_delimiters('<div class="error">', '</div>'); $this->form_validation->set_rules($config); $this->form_validation->set_error_delimiters('<div class="error">', '</div>'); if ($this->form_validation->run($this) == TRUE) { if ($_POST) { if ($_FILES['image1']['size'] !== 0) { $config['upload_path'] = './uploads/gallery/'; $config['allowed_types'] = 'jpg|png'; $config['max_size'] = '300'; $config['max_width'] = '270'; $config['max_height'] = '191'; $this->load->library('upload', $config); $this->upload->initialize($config); if (!$this->upload->do_upload('image1')) { $this->session->set_flashdata('image_error', '<br> <p style="background:orange; color:white; padding:5px; font-weight:bold;">Kesalahan Unggah Gambar. Format atau ukuran salah.</p>'); redirect('admin/pages/add_gallery_image/' . $pages_id); } else { $image1 = $this->upload->data(); $image1_filename = $image1['file_name']; $this->load->library('image_lib'); //image resizing (LARGE IMAGE) $config2['image_library'] = 'gd2'; $config2['source_image'] = './uploads/gallery/' . $image1_filename; $config2['new_image'] = './uploads/gallery/large/'; $config2['create_thumb'] = FALSE; $config2['maintain_ratio'] = TRUE; $config2['width'] = '1170'; $config2['height'] = '600'; $this->image_lib->initialize($config2); //firstly autoload image_lib, then initialize it. Dont repeatly load it. $this->image_lib->resize(); // $this->resize_single_image('1170','600','gallery/large/',$image1_filename); // $this->resize_single_image('580','500','home_about/',$image1_filename); } } $data = array( "priority" => $this->security->xss_clean($this->input->post('priority')), "is_active" => $this->security->xss_clean($this->input->post('status')), "id_pages" => '24', ); //image upload if (isset($image1_filename)) { $data['img_name'] = $image1_filename; } else { $data['img_name'] = $this->data['pages_gallery']->img_name; } $data['header_text'] = $this->security->xss_clean($this->input->post('header_text')); $data['header_text_en'] = $this->security->xss_clean($this->input->post('header_text_en')); $data['body_text'] = $this->input->post('body_text'); $data['body_text_en'] = $this->input->post('body_text_en'); $this->db->insert('pages_gallery', $data); } $this->session->set_flashdata('success', '<br><p style="background:green; color:white; padding:5px; font-weight:bold;">Edit Gallery Berhasil</p>'); redirect('admin/pages/pages_gallery/' . $pages_id); } $this->data['subview'] = 'admin/pages/edit_gallery_image'; $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 pages_gallery($id = NULL) { //check if id exist. If not exist, show 404. $count = $this->page_m->count_exist($id); if ( $count == 0 // && $id != '24' ) { //page not exist show_404(); } $this->data['pages'] = $this->page_m->get($id); //pagination in action. 100 results per page $this->load->library('pagination'); $config['base_url'] = base_url() . 'admin/pages/edit_gallery'; $config['per_page'] = 100; $config['uri_segment'] = 3; $this->db->select('id')->from('pages_gallery')->where('id_pages', $id); $config['total_rows'] = $this->db->get()->num_rows(); $this->pagination->initialize($config); $this->db->select('*'); $this->db->from('pages_gallery'); $this->db->where('id_pages', $id); $this->db->order_by('id', 'ASC'); $this->db->order_by('priority', 'ASC'); $this->db->limit($config['per_page'], $this->uri->segment($config['uri_segment'])); $this->data['pages_gallery'] = $this->db->get()->result(); $this->data['id_pages'] = $id; //load view $this->data['subview'] = 'admin/pages/pages_gallery'; $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 page in admin public function edit($id = NULL) { //check if id exist. If not exist, show 404. $count = $this->page_m->count_exist($id); if ($count == 0) { //page not exist show_404(); } $this->data['pages'] = $this->page_m->get($id); $this->data['parent_pages'] = $this->page_m->get_parent_pages(); $this->page_current_id = (int) $id; //validation check in action $config = $this->page_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) { $data = $this->table_data_processing($this->input->post('page_title'), $this->input->post('page_title_en'), $this->input->post('status'), $this->input->post('body_text'), $this->input->post('body_text_en'), $this->input->post('meta_description'), $this->input->post('meta_keywords')); $this->page_m->edit_page($id, $data); if ($_POST) { //check & processing image banner upload files if ($_FILES['image1']['size'] !== 0) { $config['upload_path'] = './uploads/banners/'; $config['allowed_types'] = 'jpg|png'; $config['max_size'] = '600'; $config['max_width'] = '1670'; $config['max_height'] = '800'; if ($id == '23') { $config['max_size'] = '400'; $config['max_width'] = '570'; $config['max_height'] = '425'; } $this->load->library('upload', $config); $this->upload->initialize($config); if (!$this->upload->do_upload('image1')) { $this->session->set_flashdata('error1', '<br> <p style="background:orange; color:white; padding:5px; font-weight:bold;">Kesalahan Unggah Gambar. Format atau ukuran salah.</p>'); redirect('admin/pages/edit/' . $id); } else { $image1 = $this->upload->data(); $image1_filename = $image1['file_name']; // $this->resize_single_image('580','500','home_about/',$image1_filename); } } if ($_FILES['image2']['size'] !== 0) { $config['upload_path'] = './uploads/banners/'; $config['allowed_types'] = 'jpg|png'; $config['max_size'] = '600'; $config['max_width'] = '1670'; $config['max_height'] = '800'; if ($id == '23') { $config['max_size'] = '400'; $config['max_width'] = '570'; $config['max_height'] = '425'; } $this->load->library('upload', $config); $this->upload->initialize($config); if (!$this->upload->do_upload('image2')) { $this->session->set_flashdata('error2', '<br> <p style="background:orange; color:white; padding:5px; font-weight:bold;">Kesalahan Unggah Gambar. Format atau ukuran salah.</p>'); redirect('admin/pages/edit/' . $id); } else { $image2 = $this->upload->data(); $image2_filename = $image2['file_name']; // $this->resize_single_image('580','500','home_about/',$image2_filename); } } if ($_FILES['image3']['size'] !== 0) { $config['upload_path'] = './uploads/banners/'; $config['allowed_types'] = 'jpg|png'; $config['max_size'] = '600'; $config['max_width'] = '1670'; $config['max_height'] = '800'; if ($id == '23') { $config['max_size'] = '400'; $config['max_width'] = '570'; $config['max_height'] = '425'; } $this->load->library('upload', $config); $this->upload->initialize($config); if (!$this->upload->do_upload('image3')) { $this->session->set_flashdata('error3', '<br> <p style="background:orange; color:white; padding:5px; font-weight:bold;">Kesalahan Unggah Gambar. Format atau ukuran salah.</p>'); redirect('admin/pages/edit/' . $id); } else { $image3 = $this->upload->data(); $image3_filename = $image3['file_name']; // $this->resize_single_image('580','500','home_about/',$image3_filename); } } $data = array(); //image upload if (isset($image1_filename)) { $data['img_name'] = $image1_filename; } else { $data['img_name'] = @explode(' | ', $this->data['pages']->img_name)[0]; } //image upload if (isset($image2_filename)) { $data['img_name'] .= ' | ' . $image2_filename; } else { $data['img_name'] .= ' | ' . @explode(' | ', $this->data['pages']->img_name)[1]; } //image upload if (isset($image3_filename)) { $data['img_name'] .= ' | ' . $image3_filename; } else { $data['img_name'] .= ' | ' . @explode(' | ', $this->data['pages']->img_name)[2]; } if (isset($_FILES['image_center1'])) { if ($_FILES['image_center1']['size'] !== 0) { $config['upload_path'] = './uploads/image_center/'; $config['allowed_types'] = 'jpg|png'; $config['max_size'] = '300'; $config['max_width'] = '570'; $config['max_height'] = '290'; $this->load->library('upload', $config); $this->upload->initialize($config); if (!$this->upload->do_upload('image_center1')) { $this->session->set_flashdata('image_center1', '<br> <p style="background:orange; color:white; padding:5px; font-weight:bold;">Kesalahan Unggah Gambar. Format atau ukuran salah.</p>'); redirect('admin/pages/edit/' . $id); } else { $image_center1 = $this->upload->data(); $image_center1_filename = $image_center1['file_name']; } } if (isset($image_center1)) { $data['img_center1'] = $image_center1_filename; } if ($_FILES['image_center2']['size'] !== 0) { $config['upload_path'] = './uploads/image_center/'; $config['allowed_types'] = 'jpg|png'; $config['max_size'] = '300'; $config['max_width'] = '570'; $config['max_height'] = '290'; $this->load->library('upload', $config); $this->upload->initialize($config); if (!$this->upload->do_upload('image_center2')) { $this->session->set_flashdata('image_center2', '<br> <p style="background:orange; color:white; padding:5px; font-weight:bold;">Kesalahan Unggah Gambar. Format atau ukuran salah.</p>'); redirect('admin/pages/edit/' . $id); } else { $image_center2 = $this->upload->data(); $image_center2_filename = $image_center2['file_name']; } } if (isset($image_center2)) { $data['img_center2'] = $image_center2_filename; } if ($_FILES['image_center3']['size'] !== 0) { $config['upload_path'] = './uploads/image_center/'; $config['allowed_types'] = 'jpg|png'; $config['max_size'] = '300'; $config['max_width'] = '570'; $config['max_height'] = '290'; $this->load->library('upload', $config); $this->upload->initialize($config); if (!$this->upload->do_upload('image_center3')) { $this->session->set_flashdata('image_center3', '<br> <p style="background:orange; color:white; padding:5px; font-weight:bold;">Kesalahan Unggah Gambar. Format atau ukuran salah.</p>'); redirect('admin/pages/edit/' . $id); } else { $image_center3 = $this->upload->data(); $image_center3_filename = $image_center3['file_name']; } } if (isset($image_center3)) { $data['img_center3'] = $image_center3_filename; } } if (isset($_FILES['image_banner'])) { if ($_FILES['image_banner']['size'] !== 0) { $config['upload_path'] = './uploads/banners/'; $config['allowed_types'] = 'jpg|png'; $config['max_size'] = '600'; $config['max_width'] = '1670'; $config['max_height'] = '800'; $this->load->library('upload', $config); $this->upload->initialize($config); if (!$this->upload->do_upload('image_banner')) { $this->session->set_flashdata('image_banner', '<br> <p style="background:orange; color:white; padding:5px; font-weight:bold;">Kesalahan Unggah Gambar. Format atau ukuran salah.</p>'); redirect('admin/pages/edit/' . $id); } else { $image_banner = $this->upload->data(); $image_banner_filename = $image_banner['file_name']; } } if (isset($image_banner)) { $data['img_banner'] = $image_banner_filename; } } if ($id == '23') { $data['img_descr'] = $this->input->post('img_descr'); $data['img_descr_en'] = $this->input->post('img_descr_en'); } if ($id == '36') { if (isset($_FILES['image_promo_1'])) { if ($_FILES['image_promo_1']['size'] !== 0) { $config['upload_path'] = './uploads/banners/'; $config['allowed_types'] = 'jpg|png'; $config['max_size'] = '600'; $config['max_width'] = '1670'; $config['max_height'] = '800'; $this->load->library('upload', $config); $this->upload->initialize($config); if (!$this->upload->do_upload('image_promo_1')) { $this->session->set_flashdata('image_promo_1', '<br> <p style="background:orange; color:white; padding:5px; font-weight:bold;">Kesalahan Unggah Gambar. Format atau ukuran salah.</p>'); redirect('admin/pages/edit/' . $id); } else { $image_promo_1 = $this->upload->data(); $image_promo_1_filename = $image_promo_1['file_name']; } } if (isset($image_promo_1)) { $data['image_promo_1'] = $image_promo_1_filename; } } if (isset($_FILES['image_promo_2'])) { if ($_FILES['image_promo_2']['size'] !== 0) { $config['upload_path'] = './uploads/banners/'; $config['allowed_types'] = 'jpg|png'; $config['max_size'] = '600'; $config['max_width'] = '1670'; $config['max_height'] = '800'; $this->load->library('upload', $config); $this->upload->initialize($config); if (!$this->upload->do_upload('image_promo_2')) { $this->session->set_flashdata('image_promo_2', '<br> <p style="background:orange; color:white; padding:5px; font-weight:bold;">Kesalahan Unggah Gambar. Format atau ukuran salah.</p>'); redirect('admin/pages/edit/' . $id); } else { $image_promo_2 = $this->upload->data(); $image_promo_2_filename = $image_promo_2['file_name']; } } if (isset($image_promo_2)) { $data['image_promo_2'] = $image_promo_2_filename; } } $data['text_body_promo'] = $this->input->post('text_body_promo'); $data['text_body_promo_en'] = $this->input->post('text_body_promo_en'); $data['text_image_promo_1'] = $this->input->post('text_image_promo_1'); $data['text_image_promo_1_en'] = $this->input->post('text_image_promo_1_en'); $data['text_image_promo_2'] = $this->input->post('text_image_promo_2_en'); $data['text_image_promo_2_en'] = $this->input->post('text_image_promo_2_en'); $data['active_section_hotel'] = $this->input->post('active_section_hotel'); $data['active_section_lounge'] = $this->input->post('active_section_lounge'); $data['active_section_cafe'] = $this->input->post('active_section_cafe'); $data['active_section_residence'] = $this->input->post('active_section_residence'); } // echo "<pre>"; // var_dump($data); // exit(); $data['header_text'] = $this->input->post('header_text'); $data['header_text_en'] = $this->input->post('header_text_en'); if ($this->input->post('active_banner_slider')) { $data['active_banner_slider'] = $this->input->post('active_banner_slider'); } if ($this->input->post('active_content')) { $data['active_content'] = $this->input->post('active_content'); } if ($this->input->post('active_gallery')) { $data['active_gallery'] = $this->input->post('active_gallery'); } if ($this->input->post('active_all_product')) { $data['active_all_product'] = $this->input->post('active_all_product'); } if ($this->input->post('active_map')) { $data['active_map'] = $this->input->post('active_map'); } if ($this->input->post('active_contact')) { $data['active_contact'] = $this->input->post('active_contact'); } if ($this->input->post('active_center_img')) { $data['active_center_img'] = $this->input->post('active_center_img'); } if ($this->input->post('text_judul')) { $data['text_judul'] = $this->input->post('text_judul'); } if ($this->input->post('text_content')) { $data['text_content'] = $this->input->post('text_content'); } if ($this->input->post('text_judul_2')) { $data['text_judul_2'] = $this->input->post('text_judul_2'); } if ($this->input->post('text_content_2')) { $data['text_content_2'] = $this->input->post('text_content_2'); } if ($this->input->post('text_judul_3')) { $data['text_judul_3'] = $this->input->post('text_judul_3'); } if ($this->input->post('text_content_3')) { $data['text_content_3'] = $this->input->post('text_content_3'); } // else { // $data['active_banner_slider'] = 'yes'; // $data['active_content'] = 'yes'; // $data['active_gallery'] = 'yes'; // $data['active_all_product'] = 'yes'; // $data['active_map'] = 'yes'; // $data['active_contact'] = 'yes'; // $data['active_center_img'] = 'yes'; // } $this->db->where('id_pages', $id)->update('pages', $data); // $this->db->insert('home_slideshow', $data); // return $this->db->insert_id(); } $this->session->set_flashdata('success', '<br><p style="background:green; color:white; padding:5px; font-weight:bold;">Edit Halaman Berhasil</p>'); redirect('admin/pages/edit/' . $id); } $this->data['subview'] = 'admin/pages/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 page public function delete($id) { //check if id exist. If not exist, show 404. $count = $this->page_m->count_exist($id); if ($count == 0) { //page not exist show_404(); } //delete page $this->page_m->delete($id); $this->session->set_flashdata('success', '<br><p style="background:green; color:white; padding:5px; font-weight:bold;">Hapus Halaman Berhasil</p>'); redirect('admin/pages'); } //callback function validation add new pages public function _cek_existing_page_title($str) { $num_rows = $this->page_m->cek_existing_page_title($str, $this->page_current_id); if ($num_rows != 0) { $this->form_validation->set_message('_cek_existing_page_title', 'Judul halaman indonesia sudah ada !'); return FALSE; } else { return TRUE; } } //callback function validation add new pages public function _cek_existing_page_en_title($str) { $num_rows = $this->page_m->cek_existing_page_en_title($str, $this->page_current_id); if ($num_rows != 0) { $this->form_validation->set_message('_cek_existing_page_en_title', 'Judul halaman bahasa Inggris sudah ada !'); return FALSE; } else { return TRUE; } } private function table_data_processing( $page_title, $page_title_en, $status, $body_text, $body_text_en, $meta_description, $meta_keywords ) { $data = array( 'page_title' => $this->security->xss_clean($page_title), 'page_title_en' => $this->security->xss_clean($page_title_en), 'alias' => url_title($this->security->xss_clean($page_title)), 'alias_en' => url_title($this->security->xss_clean($page_title_en)), 'status' => $status, 'body_text' => $body_text, 'body_text_en' => $body_text_en, 'meta_description' => $this->security->xss_clean($meta_description), 'meta_keywords' => $this->security->xss_clean($meta_keywords), 'priority' => $this->security->xss_clean($this->input->post('priority')), ); if($this->page_current_id == 29) { $data['loyalty_gold_text'] = $this->security->xss_clean($this->input->post('loyalty_gold_text')); $data['loyalty_priorityblue_text'] = $this->security->xss_clean($this->input->post('loyalty_priorityblue_text')); } if ($this->input->post('parent_id') == 'no-parent') { $data['parent'] = NULL; } else { $data['parent'] = (int) $this->input->post('parent_id'); } return $data; } }