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/serbaantik.com/public_html/application/controllers/admin/ |
Upload File : |
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); class Configuration extends Admin_Controller { function __construct() { parent::__construct(); if (!in_array('configuration', $this->allowed_sections)) redirect('admin/dashboard'); $this->load->model('configuration_m'); } function index() { redirect('admin/configuration/edit'); } //to EDIT workshop in admin public function edit($id = 1) { $this->data['configuration'] = $this->configuration_m->get($id); //validation check in action $config = array( array( 'field' => 'website_name', 'label' => 'Website Name', 'rules' => 'trim|required' ), array( 'field' => 'browser_title', 'label' => 'Browser Title', 'rules' => 'trim|required' ), array( 'field' => 'meta_description', 'label' => 'Meta Description', 'rules' => 'trim|required' ), array( 'field' => 'from_email', 'label' => 'From Email', 'rules' => 'trim|required|valid_email' ), array( 'field' => 'phone', 'label' => 'Phone', 'rules' => 'trim|required' ), array( 'field' => 'category_image_width', 'label' => 'category_image_width', 'rules' => 'trim|numeric|required' ), array( 'field' => 'category_image_height', 'label' => 'category_image_height', 'rules' => 'trim|numeric|required' ), array( 'field' => 'category_thumbnail_width', 'label' => 'category_thumbnail_width', 'rules' => 'trim|numeric|required' ), array( 'field' => 'category_thumbnail_height', 'label' => 'category_thumbnail_height', 'rules' => 'trim|numeric|required' ), array( 'field' => 'brand_logo_width', 'label' => 'brand_logo_width', 'rules' => 'trim|numeric|required' ), array( 'field' => 'brand_logo_height', 'label' => 'brand_logo_height', 'rules' => 'trim|numeric|required' ), array( 'field' => 'brand_image_width', 'label' => 'brand_image_width', 'rules' => 'trim|numeric|required' ), array( 'field' => 'brand_image_height', 'label' => 'brand_image_height', 'rules' => 'trim|numeric|required' ), array( 'field' => 'product_image_width', 'label' => 'product_image_width', 'rules' => 'trim|numeric|required' ), array( 'field' => 'product_image_height', 'label' => 'product_image_height', 'rules' => 'trim|numeric|required' ), array( 'field' => 'product_image_large_width', 'label' => 'product_image_large_width', 'rules' => 'trim|numeric|required' ), array( 'field' => 'product_image_large_height', 'label' => 'product_image_large_height', 'rules' => 'trim|numeric|required' ), array( 'field' => 'product_image_small_width', 'label' => 'product_image_small_width', 'rules' => 'trim|numeric|required' ), array( 'field' => 'product_image_small_height', 'label' => 'product_image_small_height', 'rules' => 'trim|numeric|required' ), array( 'field' => 'product_image_thumbnail_height', 'label' => 'product_image_thumbnail_height', 'rules' => 'trim|numeric|required' ), array( 'field' => 'logo_image_width', 'label' => 'logo_image_width', 'rules' => 'trim|numeric|required' ), array( 'field' => 'logo_image_height', 'label' => 'logo_image_height', 'rules' => 'trim|numeric|required' ), array( 'field' => 'home_slideshow_width', 'label' => 'home_slideshow_width', 'rules' => 'trim|numeric|required' ), array( 'field' => 'home_slideshow_height', 'label' => 'home_slideshow_height', 'rules' => 'trim|numeric|required' ), array( 'field' => 'blog_image_width', 'label' => 'blog_image_width', 'rules' => 'trim|numeric|required' ), array( 'field' => 'blog_image_height', 'label' => 'blog_image_height', 'rules' => 'trim|numeric|required' ), array( 'field' => 'blog_thumbnail_width', 'label' => 'blog_thumbnail_width', 'rules' => 'trim|numeric|required' ), array( 'field' => 'blog_thumbnail_height', 'label' => 'blog_thumbnail_height', 'rules' => 'trim|numeric|required' ), array( 'field' => 'facebook', 'label' => 'facebook', 'rules' => 'trim' ), array( 'field' => 'twitter', 'label' => 'twitter', 'rules' => 'trim' ), array( 'field' => 'google', 'label' => 'google', 'rules' => 'trim' ), array( 'field' => 'instagram', 'label' => 'instagram', 'rules' => 'trim' ), array( 'field' => 'youtube', 'label' => 'youtube', 'rules' => 'trim' ), array( 'field' => 'email_smtp_host', 'label' => 'email_smtp_host', 'rules' => 'trim|required' ), array( 'field' => 'email_smtp_port', 'label' => 'email_smtp_port', 'rules' => 'trim|required' ), array( 'field' => 'email_smtp_password', 'label' => 'email_smtp_password', 'rules' => 'trim|required' ), array( 'field' => 'email_smtp', 'label' => 'email_smtp', 'rules' => 'trim|required' ), array( 'field' => 'staticbanner1_image_height', 'label' => 'staticbanner1_image_height', 'rules' => 'trim|numeric|required' ), array( 'field' => 'staticbanner2_image_height', 'label' => 'staticbanner2_image_height', 'rules' => 'trim|numeric|required' ), array( 'field' => 'staticbanner3_image_height', 'label' => 'staticbanner3_image_height', 'rules' => 'trim|numeric|required' ), array( 'field' => 'staticbanner4_image_height', 'label' => 'staticbanner4_image_height', 'rules' => 'trim|numeric|required' ), array( 'field' => 'staticbanner5_image_height', 'label' => 'staticbanner5_image_height', 'rules' => 'trim|numeric|required' ), array( 'field' => 'staticbanner6_image_height', 'label' => 'staticbanner6_image_height', 'rules' => 'trim|numeric|required' ), array( 'field' => 'staticbanner1_image_width', 'label' => 'staticbanner1_image_width', 'rules' => 'trim|numeric|required' ), array( 'field' => 'staticbanner2_image_width', 'label' => 'staticbanner2_image_width', 'rules' => 'trim|numeric|required' ), array( 'field' => 'staticbanner3_image_width', 'label' => 'staticbanner3_image_width', 'rules' => 'trim|numeric|required' ), array( 'field' => 'staticbanner4_image_width', 'label' => 'staticbanner4_image_width', 'rules' => 'trim|numeric|required' ), array( 'field' => 'staticbanner5_image_width', 'label' => 'staticbanner5_image_width', 'rules' => 'trim|numeric|required' ), array( 'field' => 'staticbanner6_image_width', 'label' => 'staticbanner6_image_width', 'rules' => 'trim|numeric|required' ), array( 'field' => 'featuredproduct_image_width', 'label' => 'featuredproduct_image_width', 'rules' => 'trim|numeric|required' ), array( 'field' => 'featuredproduct_image_height', 'label' => 'featuredproduct_image_height', 'rules' => 'trim|numeric|required' ), array( 'field' => 'website_ip', 'label' => 'website IP', 'rules' => 'trim' ) ); $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); if($this->form_validation->run($this) == TRUE) { //get max image width and height from configuration table $this->db->select('logo_image_width, logo_image_height')->from('configuration')->where('id_configuration', 1); $image_dimension = $this->db->get()->row(); //check & processing logo upload files if ($_FILES['logo']['size'] !== 0) { $config = array(); $config['upload_path'] = './uploads/'; $config['allowed_types'] = '*'; // $config['allowed_types'] = 'jpg|png|jpeg|webp'; $config['max_size'] = '300'; $config['max_width'] = $image_dimension->logo_image_width; $config['max_height'] = $image_dimension->logo_image_height; $this->load->library('upload', $config); $this->upload->initialize($config); if ( ! $this->upload->do_upload('logo')) { //echo $this->upload->display_errors(); die(); $this->session->set_flashdata('error', '<br> <p style="background:orange; color:white; padding:5px; font-weight:bold;">Image Upload Error. Wrong format or size.</p>'); redirect('admin/configuration/edit/'); } else { $logo = $this->upload->data(); $logo_filename = $logo['file_name']; } } //check & processing logo upload files if ($_FILES['dna_logo']['size'] !== 0) { $config = array(); $config['upload_path'] = './uploads/'; $config['allowed_types'] = '*'; // $config['allowed_types'] = 'jpg|png|jpeg|webp'; $config['max_size'] = '800'; $this->load->library('upload', $config); $this->upload->initialize($config); if ( ! $this->upload->do_upload('dna_logo')) { //echo $this->upload->display_errors(); die(); $this->session->set_flashdata('error', '<br> <p style="background:orange; color:white; padding:5px; font-weight:bold;">Image Upload Error. Wrong format or size.</p>'); redirect('admin/configuration/edit/'); } else { $dna_logo = $this->upload->data(); $dna_logo_filename = $dna_logo['file_name']; } } //check & processing website icon upload files if ($_FILES['website_icon']['size'] !== 0) { $config = array(); $config['upload_path'] = './uploads/'; $config['allowed_types'] = '*'; // $config['allowed_types'] = 'jpg|png|jpeg|webp'; $config['max_size'] = '50'; $config['max_width'] = '200'; $config['max_height'] = '200'; $this->load->library('upload', $config); $this->upload->initialize($config); if ( ! $this->upload->do_upload('website_icon')) { //echo $this->upload->display_errors(); die(); $this->session->set_flashdata('error2', '<br> <p style="background:orange; color:white; padding:5px; font-weight:bold;">Website Icon Upload Error. Wrong format or size.</p>'); redirect('admin/configuration/edit/'); } else { $website_icon = $this->upload->data(); $website_icon_filename = $website_icon['file_name']; } } //check & processing website icon upload files if ($_FILES['contact_us_image']['size'] !== 0) { $config = array(); $config['upload_path'] = './uploads/'; $config['allowed_types'] = '*'; // $config['allowed_types'] = 'jpg|png|jpeg|webp'; $config['max_size'] = '500'; $this->load->library('upload', $config); $this->upload->initialize($config); if ( ! $this->upload->do_upload('contact_us_image')) { //echo $this->upload->display_errors(); die(); $this->session->set_flashdata('error2', '<br> <p style="background:orange; color:white; padding:5px; font-weight:bold;">Website Icon Upload Error. Wrong format or size.</p>'); redirect('admin/configuration/edit/'); } else { $contact_us_image = $this->upload->data(); $contact_us_image_filename = $contact_us_image['file_name']; } } $data = array( 'website_name' => $this->input->post('website_name'), 'from_email' => $this->input->post('from_email'), 'phone' => $this->input->post('phone'), 'address' => $this->input->post('address'), 'map' => $this->input->post('map'), 'browser_title' => $this->input->post('browser_title'), 'meta_description' => $this->input->post('meta_description'), 'category_image_width' => $this->input->post('category_image_width'), 'category_image_height' => $this->input->post('category_image_height'), 'category_thumbnail_width' => $this->input->post('category_thumbnail_width'), 'category_thumbnail_height' => $this->input->post('category_thumbnail_height'), 'brand_image_width' => $this->input->post('brand_image_width'), 'brand_image_height' => $this->input->post('brand_image_height'), 'brand_logo_width' => $this->input->post('brand_logo_width'), 'brand_logo_height' => $this->input->post('brand_logo_height'), 'product_image_width' => $this->input->post('product_image_width'), 'product_image_height' => $this->input->post('product_image_height'), 'product_image_large_width' => $this->input->post('product_image_large_width'), 'product_image_large_height' => $this->input->post('product_image_large_height'), 'product_image_small_width' => $this->input->post('product_image_small_width'), 'product_image_small_height' => $this->input->post('product_image_small_height'), 'product_image_thumbnail_width' => $this->input->post('product_image_thumbnail_width'), 'product_image_thumbnail_height' => $this->input->post('product_image_thumbnail_height'), 'logo_image_width' => $this->input->post('logo_image_width'), 'logo_image_height' => $this->input->post('logo_image_height'), 'home_slideshow_width' => $this->input->post('home_slideshow_width'), 'home_slideshow_height' => $this->input->post('home_slideshow_height'), 'blog_image_width' => $this->input->post('blog_image_width'), 'blog_image_height' => $this->input->post('blog_image_height'), 'blog_thumbnail_width' => $this->input->post('blog_thumbnail_width'), 'blog_thumbnail_height' => $this->input->post('blog_thumbnail_height'), 'facebook' => $this->input->post('facebook'), 'tiktok' => $this->input->post('tiktok'), 'instagram' => $this->input->post('instagram'), 'youtube' => $this->input->post('youtube'), 'linkedin' => $this->input->post('linkedin'), 'tokopedia' => $this->input->post('tokopedia'), 'email_smtp_host' => $this->input->post('email_smtp_host'), 'email_smtp_port' => $this->input->post('email_smtp_port'), 'email_smtp' => $this->input->post('email_smtp'), 'email_smtp_password' => $this->input->post('email_smtp_password'), 'staticbanner1_image_width' => $this->input->post('staticbanner1_image_width'), 'staticbanner1_image_height' => $this->input->post('staticbanner1_image_height'), 'staticbanner2_image_width' => $this->input->post('staticbanner2_image_width'), 'staticbanner2_image_height' => $this->input->post('staticbanner2_image_height'), 'staticbanner3_image_width' => $this->input->post('staticbanner3_image_width'), 'staticbanner3_image_height' => $this->input->post('staticbanner3_image_height'), 'staticbanner4_image_width' => $this->input->post('staticbanner4_image_width'), 'staticbanner4_image_height' => $this->input->post('staticbanner4_image_height'), 'staticbanner5_image_width' => $this->input->post('staticbanner5_image_width'), 'staticbanner5_image_height' => $this->input->post('staticbanner5_image_height'), 'staticbanner6_image_width' => $this->input->post('staticbanner6_image_width'), 'staticbanner6_image_height' => $this->input->post('staticbanner6_image_height'), 'featuredproduct_image_width' => $this->input->post('featuredproduct_image_width'), 'featuredproduct_image_height' => $this->input->post('featuredproduct_image_height'), 'website_active' => $this->input->post('website_active'), 'website_ip' => str_replace(' ', '', $this->security->xss_clean($this->input->post('website_ip'))), 'website_default_language' => $this->input->post('website_default_language'), 'contact_us_text' => $this->input->post('contact_us_text'), ); //image upload if (isset($logo_filename)) { $data['logo'] = $logo_filename; } //image upload if (isset($dna_logo_filename)) { $data['dna_logo'] = $dna_logo_filename; } //image upload if (isset($website_icon_filename)) { $data['website_icon'] = $website_icon_filename; } //image upload if (isset($contact_us_image_filename)) { $data['contact_us_image'] = $contact_us_image_filename; } $this->configuration_m->edit_configuration($id, $data); $this->session->set_flashdata('success', '<br><p style="background:green; color:white; padding:5px; font-weight:bold;">Configuration Edit Successful. Click "Dashboard" to go back</p>'); redirect('admin/configuration/edit'); } $this->data['error'] = ''; $this->data['subview'] = 'admin/configuration/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 logo file from server, and from database public function delete_logo() { //get image file name for deletion $this->db->select('logo')->from('configuration')->where('id_configuration', 1); $image = $this->db->get()->row(); //Delete the actual image file from server. FCPATH is codeigniter base path unlink(FCPATH .'/uploads/'. $image->logo); //Delete logo field from configuration database $data = array( 'logo' => '', ); $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;">Logo Delete Successful</p>'); redirect('admin/configuration/edit'); } public function delete_dna_logo() { //get image file name for deletion $this->db->select('dna_logo')->from('configuration')->where('id_configuration', 1); $image = $this->db->get()->row(); //Delete the actual image file from server. FCPATH is codeigniter base path unlink(FCPATH .'/uploads/'. $image->dna_logo); //Delete logo field from configuration database $data = array( 'dna_logo' => '', ); $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;">Logo Delete Successful</p>'); redirect('admin/configuration/edit'); } //To delete website icon from server, and from database public function delete_website_icon() { //get image file name for deletion $this->db->select('website_icon')->from('configuration')->where('id_configuration', 1); $website_icon = $this->db->get()->row()->website_icon; //Delete the actual image file from server. FCPATH is codeigniter base path unlink(FCPATH .'/uploads/'. $website_icon); //Delete website_icon field from configuration database $data = array( 'website_icon' => '', ); $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;">Website Icon Delete Successful</p>'); redirect('admin/configuration/edit'); } }