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/symphony-solusi.co.id/public_html/application/controllers/admin/ |
Upload File : |
<?php if (!defined('BASEPATH')) exit('No direct script access allowed'); class Sap_pages extends Admin_Controller { //this property is used for validating existing page title on call back edit page private $page_current_id = NULL; private $image_filename1 = NULL; private $image_filename2 = NULL; private $image_filename3 = NULL; private $image_filename4 = NULL; private $image_filename5 = NULL; function __construct() { parent::__construct(); $this->load->model('sap_pages_m'); } public function index() { $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; } //pagination in action. 20 results per page $this->load->library('pagination'); $config['base_url'] = base_url() . 'admin/sap/index'; $config['per_page'] = 20; $config["uri_segment"] = 4; //fetch all pages $config['total_rows'] = $this->sap_pages_m->record_count(); $this->pagination->initialize($config); $this->data['pages'] = $this->sap_pages_m->get_all_pages( $config["per_page"], $this->uri->segment(4) ); //get parent pages only $this->data['parent_pages'] = $this->sap_pages_m->get_all_pages($config["per_page"], $this->uri->segment($config['uri_segment'])); //load view $this->data['subview'] = 'admin/sap/index'; $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 add() { $this->data['pages'] = $this->sap_pages_m->get_new(); //get ordering number and display at add form $this->db->select_max('priority')->from('sap_pages'); $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->sap_pages_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 ($_FILES['image1']['size'] !== 0) { $config['upload_path'] = './uploads/page/'; $config['allowed_types'] = 'jpeg|jpg|png'; $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('image1')) { // echo $this->upload->display_errors(); // exit(); $this->session->set_flashdata('image_error1', '<br> <p style="background:red; color:white; padding:5px; font-weight:bold;">Image Upload Error. Wrong format or size.</p>'); redirect('admin/sap_pages/add'); } else { $image1 = $this->upload->data(); $image_filename1 = $image1['file_name']; } } if ($_FILES['image2']['size'] !== 0) { $config['upload_path'] = './uploads/page/'; $config['allowed_types'] = 'jpeg|jpg|png'; $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('image2')) { // echo $this->upload->display_errors(); // exit(); $this->session->set_flashdata('image_error2', '<br> <p style="background:red; color:white; padding:5px; font-weight:bold;">Image Upload Error. Wrong format or size.</p>'); redirect('admin/sap_pages/add'); } else { $image2 = $this->upload->data(); $image_filename2 = $image2['file_name']; } } if ($_FILES['image3']['size'] !== 0) { $config['upload_path'] = './uploads/page/'; $config['allowed_types'] = 'jpeg|jpg|png'; $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('image3')) { // echo $this->upload->display_errors(); // exit(); $this->session->set_flashdata('image_error3', '<br> <p style="background:red; color:white; padding:5px; font-weight:bold;">Image Upload Error. Wrong format or size.</p>'); redirect('admin/sap_pages/add'); } else { $image3 = $this->upload->data(); $image_filename3 = $image3['file_name']; } } if ($_FILES['image4']['size'] !== 0) { $config['upload_path'] = './uploads/page/'; $config['allowed_types'] = 'jpeg|jpg|png'; $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('image4')) { // echo $this->upload->display_errors(); // exit(); $this->session->set_flashdata('image_error4', '<br> <p style="background:red; color:white; padding:5px; font-weight:bold;">Image Upload Error. Wrong format or size.</p>'); redirect('admin/sap_pages/add'); } else { $image4 = $this->upload->data(); $image_filename4 = $image4['file_name']; } } if ($_FILES['image5']['size'] !== 0) { $config['upload_path'] = './uploads/page/'; $config['allowed_types'] = 'jpeg|jpg|png'; $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('image5')) { // echo $this->upload->display_errors(); // exit(); $this->session->set_flashdata('image_error5', '<br> <p style="background:red; color:white; padding:5px; font-weight:bold;">Image Upload Error. Wrong format or size.</p>'); redirect('admin/sap_pages/add'); } else { $image5 = $this->upload->data(); $image_filename5 = $image5['file_name']; } } $data = array( 'sap_page_title' => $this->security->xss_clean($this->input->post('sap_page_title')), 'sap_page_title_en' => $this->security->xss_clean($this->input->post('sap_page_title_en')), 'alias' => url_title($this->security->xss_clean($this->input->post('sap_page_title'))), 'alias_en' => url_title($this->security->xss_clean($this->input->post('sap_page_title_en'))), 'body_text' => $this->security->xss_clean($this->input->post('body_text')), 'body_text2' => $this->security->xss_clean($this->input->post('body_text2')), 'body_text3' => $this->security->xss_clean($this->input->post('body_text3')), 'body_text4' => $this->security->xss_clean($this->input->post('body_text4')), 'body_text5' => $this->security->xss_clean($this->input->post('body_text5')), 'body_text6' => $this->security->xss_clean($this->input->post('body_text6')), 'body_text7' => $this->security->xss_clean($this->input->post('body_text7')), 'body_text8' => $this->security->xss_clean($this->input->post('body_text8')), 'body_text9' => $this->security->xss_clean($this->input->post('body_text9')), 'body_text_en' => $this->security->xss_clean($this->input->post('body_text_en')), 'body_text2_en' => $this->security->xss_clean($this->input->post('body_text2_en')), 'body_text3_en' => $this->security->xss_clean($this->input->post('body_text3_en')), 'body_text4_en' => $this->security->xss_clean($this->input->post('body_text4_en')), 'body_text5_en' => $this->security->xss_clean($this->input->post('body_text5_en')), 'body_text6_en' => $this->security->xss_clean($this->input->post('body_text6_en')), 'body_text7_en' => $this->security->xss_clean($this->input->post('body_text7_en')), 'body_text8_en' => $this->security->xss_clean($this->input->post('body_text8_en')), 'body_text9_en' => $this->security->xss_clean($this->input->post('body_text9_en')), 'priority' => $this->input->post('priority'), 'status' => $this->security->xss_clean($this->input->post('status')), 'meta_description' => $this->security->xss_clean($this->input->post('meta_description')), 'meta_keywords' => $this->security->xss_clean($this->input->post('meta_keywords')), 'template' => $this->input->post('template') ); if (isset($image_filename1)) { $data['image1'] = $image_filename1; } if (isset($image_filename2)) { $data['image2'] = $image_filename2; } if (isset($image_filename3)) { $data['image3'] = $image_filename3; } if (isset($image_filename4)) { $data['image4'] = $image_filename4; } if (isset($image_filename5)) { $data['image5'] = $image_filename5; } $this->sap_pages_m->add_page($data); $this->session->set_flashdata('success', '<br><p style="background:green; color:white; padding:5px; font-weight:bold;">Page Add Successful</p>'); redirect('admin/sap_pages'); } $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/sap/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 edit($id = NULL) { //check if id exist. If not exist, show 404. $count = $this->sap_pages_m->count_exist($id); if ($count == 0) { //page not exist show_404(); } $this->data['pages'] = $this->sap_pages_m->get($id); $this->page_current_id = (int) $id; $config = $this->sap_pages_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 ($_FILES['image1']['size'] !== 0) { $config['upload_path'] = './uploads/page/'; $config['allowed_types'] = 'jpeg|jpg|png'; $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('image1')) { // echo $this->upload->display_errors(); // exit(); $this->session->set_flashdata('image_error1', '<br> <p style="background:red; color:white; padding:5px; font-weight:bold;">Image Upload Error. Wrong format or size.</p>'); redirect('admin/sap_pages/edit/' . $id); } else { $image1 = $this->upload->data(); $image_filename1 = $image1['file_name']; } } if ($_FILES['image2']['size'] !== 0) { $config['upload_path'] = './uploads/page/'; $config['allowed_types'] = 'jpeg|jpg|png'; $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('image2')) { // echo $this->upload->display_errors(); // exit(); $this->session->set_flashdata('image_error2', '<br> <p style="background:red; color:white; padding:5px; font-weight:bold;">Image Upload Error. Wrong format or size.</p>'); redirect('admin/sap_pages/edit/' . $id); } else { $image2 = $this->upload->data(); $image_filename2 = $image2['file_name']; } } if ($_FILES['image3']['size'] !== 0) { $config['upload_path'] = './uploads/page/'; $config['allowed_types'] = 'jpeg|jpg|png'; $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('image3')) { // echo $this->upload->display_errors(); // exit(); $this->session->set_flashdata('image_error3', '<br> <p style="background:red; color:white; padding:5px; font-weight:bold;">Image Upload Error. Wrong format or size.</p>'); redirect('admin/sap_pages/edit/' . $id); } else { $image3 = $this->upload->data(); $image_filename3 = $image3['file_name']; } } if ($_FILES['image4']['size'] !== 0) { $config['upload_path'] = './uploads/page/'; $config['allowed_types'] = 'jpeg|jpg|png'; $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('image4')) { // echo $this->upload->display_errors(); // exit(); $this->session->set_flashdata('image_error4', '<br> <p style="background:red; color:white; padding:5px; font-weight:bold;">Image Upload Error. Wrong format or size.</p>'); redirect('admin/sap_pages/edit/' . $id); } else { $image4 = $this->upload->data(); $image_filename4 = $image4['file_name']; } } if ($_FILES['image5']['size'] !== 0) { $config['upload_path'] = './uploads/page/'; $config['allowed_types'] = 'jpeg|jpg|png'; $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('image5')) { // echo $this->upload->display_errors(); // exit(); $this->session->set_flashdata('image_error5', '<br> <p style="background:red; color:white; padding:5px; font-weight:bold;">Image Upload Error. Wrong format or size.</p>'); redirect('admin/sap_pages/edit/' . $id); } else { $image5 = $this->upload->data(); $image_filename5 = $image5['file_name']; } } $data = array( 'sap_page_title' => $this->security->xss_clean($this->input->post('sap_page_title')), 'sap_page_title_en' => $this->security->xss_clean($this->input->post('sap_page_title_en')), 'alias' => url_title($this->security->xss_clean($this->input->post('sap_page_title'))), 'alias_en' => url_title($this->security->xss_clean($this->input->post('sap_page_title_en'))), 'body_text' => $this->security->xss_clean($this->input->post('body_text')), 'body_text2' => $this->security->xss_clean($this->input->post('body_text2')), 'body_text3' => $this->security->xss_clean($this->input->post('body_text3')), 'body_text4' => $this->security->xss_clean($this->input->post('body_text4')), 'body_text5' => $this->security->xss_clean($this->input->post('body_text5')), 'body_text6' => $this->security->xss_clean($this->input->post('body_text6')), 'body_text7' => $this->security->xss_clean($this->input->post('body_text7')), 'body_text8' => $this->security->xss_clean($this->input->post('body_text8')), 'body_text9' => $this->security->xss_clean($this->input->post('body_text9')), 'body_text_en' => $this->security->xss_clean($this->input->post('body_text_en')), 'body_text2_en' => $this->security->xss_clean($this->input->post('body_text2_en')), 'body_text3_en' => $this->security->xss_clean($this->input->post('body_text3_en')), 'body_text4_en' => $this->security->xss_clean($this->input->post('body_text4_en')), 'body_text5_en' => $this->security->xss_clean($this->input->post('body_text5_en')), 'body_text6_en' => $this->security->xss_clean($this->input->post('body_text6_en')), 'body_text7_en' => $this->security->xss_clean($this->input->post('body_text7_en')), 'body_text8_en' => $this->security->xss_clean($this->input->post('body_text8_en')), 'body_text9_en' => $this->security->xss_clean($this->input->post('body_text9_en')), 'priority' => $this->input->post('priority'), 'status' => $this->security->xss_clean($this->input->post('status')), 'meta_description' => $this->security->xss_clean($this->input->post('meta_description')), 'meta_keywords' => $this->security->xss_clean($this->input->post('meta_keywords')), 'template' => $this->input->post('template') ); if (isset($image_filename1)) { $data['image1'] = $image_filename1; } if (isset($image_filename2)) { $data['image2'] = $image_filename2; } if (isset($image_filename3)) { $data['image3'] = $image_filename3; } if (isset($image_filename4)) { $data['image4'] = $image_filename4; } if (isset($image_filename5)) { $data['image5'] = $image_filename5; } $this->sap_pages_m->edit_page($id, $data); $this->session->set_flashdata('success', '<br><p style="background:green; color:white; padding:5px; font-weight:bold;">Page Edit Successful</p>'); redirect('admin/sap_pages/edit/' . $id); } $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/sap/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->sap_pages_m->count_exist($id); if ($count == 0) { //page not exist show_404(); } //delete page $this->sap_pages_m->delete($id); $this->session->set_flashdata('success', '<br><p style="background:green; color:white; padding:5px; font-weight:bold;">Page Delete Successful</p>'); redirect('admin/sap_pages'); } public function delete_landingpage_image1($id) { //get image file name for deletion $this->db->select('image1')->from('sap_pages')->where('id_sap_pages', $id); $image1 = $this->db->get()->row()->image1; //Delete the actual image file from server. FCPATH is codeigniter base path unlink(FCPATH . '/uploads/page/' . $image1); //Delete image field from database $data = array( 'image1' => '', ); $this->db->where('id_sap_pages', $id); $this->db->update('sap_pages', $data); $this->session->set_flashdata('success', '<br><p style="background:green; color:white; padding:5px; font-weight:bold;">Image Delete Successful</p>'); redirect('admin/sap_pages/edit/' . $id); } public function delete_landingpage_image2($id) { //get image file name for deletion $this->db->select('image2')->from('sap_pages')->where('id_sap_pages', $id); $image2 = $this->db->get()->row()->image2; //Delete the actual image file from server. FCPATH is codeigniter base path unlink(FCPATH . '/uploads/page/' . $image2); //Delete image field from database $data = array( 'image2' => '', ); $this->db->where('id_sap_pages', $id); $this->db->update('sap_pages', $data); $this->session->set_flashdata('success', '<br><p style="background:green; color:white; padding:5px; font-weight:bold;">Image Delete Successful</p>'); redirect('admin/sap_pages/edit/' . $id); } public function delete_landingpage_image3($id) { //get image file name for deletion $this->db->select('image3')->from('sap_pages')->where('id_sap_pages', $id); $image3 = $this->db->get()->row()->image3; //Delete the actual image file from server. FCPATH is codeigniter base path unlink(FCPATH . '/uploads/page/' . $image3); //Delete image field from database $data = array( 'image3' => '', ); $this->db->where('id_sap_pages', $id); $this->db->update('sap_pages', $data); $this->session->set_flashdata('success', '<br><p style="background:green; color:white; padding:5px; font-weight:bold;">Image Delete Successful</p>'); redirect('admin/sap_pages/edit/' . $id); } public function delete_landingpage_image4($id) { //get image file name for deletion $this->db->select('image4')->from('sap_pages')->where('id_sap_pages', $id); $image4 = $this->db->get()->row()->image4; //Delete the actual image file from server. FCPATH is codeigniter base path unlink(FCPATH . '/uploads/page/' . $image4); //Delete image field from database $data = array( 'image4' => '', ); $this->db->where('id_sap_pages', $id); $this->db->update('sap_pages', $data); $this->session->set_flashdata('success', '<br><p style="background:green; color:white; padding:5px; font-weight:bold;">Image Delete Successful</p>'); redirect('admin/sap_pages/edit/' . $id); } public function delete_landingpage_image5($id) { //get image file name for deletion $this->db->select('image5')->from('sap_pages')->where('id_sap_pages', $id); $image5 = $this->db->get()->row()->image5; //Delete the actual image file from server. FCPATH is codeigniter base path unlink(FCPATH . '/uploads/page/' . $image5); //Delete image field from database $data = array( 'image5' => '', ); $this->db->where('id_sap_pages', $id); $this->db->update('sap_pages', $data); $this->session->set_flashdata('success', '<br><p style="background:green; color:white; padding:5px; font-weight:bold;">Image Delete Successful</p>'); redirect('admin/sap_pages/edit/' . $id); } }