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/kanvakanva.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(); $this->load->model('configuration_m'); $this->load->helper('rajaongkir'); } function index() { redirect('admin/configuration/edit'); } //to EDIT workshop in admin public function edit($id = 1) { $this->data['configuration'] = $this->configuration_m->get($id); //get all province data from RajaOngkir.com API $this->data['provinces'] = get_rajaongkir_data('province'); //get from helper file //get all initial districts based on stored province $this->db->select('shop_province_id')->from('configuration')->where('id_configuration', 1); $current_province_id = $this->db->get()->row()->shop_province_id; $this->data['districts'] = get_rajaongkir_data('city?province=' . (int) $current_province_id); //get from helper file //validation check in action $config = array( array( 'field' => 'veritrans_server_key', 'label' => 'Veritrans Server Key', 'rules' => 'trim|required' ), array( 'field' => 'website_name', 'label' => 'Website Name', 'rules' => 'trim|required' ), array( 'field' => 'province', 'label' => 'province', 'rules' => 'trim|required' ), array( 'field' => 'district', 'label' => 'district', 'rules' => 'trim|required' ), array( 'field' => 'browser_title', 'label' => 'Browser Title', 'rules' => 'trim' ), array( 'field' => 'meta_description', 'label' => 'Meta Description', 'rules' => 'trim' ), array( 'field' => 'meta_keywords', 'label' => 'Meta Keywords', 'rules' => 'trim' ), array( 'field' => 'bank', 'label' => 'Bank', 'rules' => 'trim|required' ), array( 'field' => 'from_email', 'label' => 'From Email', 'rules' => 'trim|required|valid_email' ), array( 'field' => 'free_shipping', 'label' => 'Email Subject', 'rules' => 'trim|numeric' ), 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' => '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' => 'products_displayed', 'label' => 'products_displayed', 'rules' => 'trim|numeric|required' ), array( 'field' => 'google_analytic_id', 'label' => 'google_analytic_id', 'rules' => 'trim' ), array( 'field' => 'facebook', 'label' => 'facebook', 'rules' => 'trim' ), array( 'field' => 'twitter', 'label' => 'twitter', 'rules' => 'trim' ), array( 'field' => 'instagram', 'label' => 'instagram', 'rules' => 'trim' ), array( 'field' => 'top_menu_position', 'label' => 'top_menu_position', 'rules' => 'trim|required|numeric' ), ); $this->form_validation->set_rules($config); $this->form_validation->set_error_delimiters('<div class="error">', '</div>'); if($this->form_validation->run() == 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 image banner upload files if ($_FILES['userfile']['size'] !== 0) { $config['upload_path'] = './uploads/'; $config['allowed_types'] = 'jpg|png'; $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); if ( ! $this->upload->do_upload()) { //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 { $image = $this->upload->data(); $image_filename = $image['file_name']; } } if($_POST) { $data = array( 'veritrans_server_key' => $this->input->post('veritrans_server_key'), 'veritrans_production_mode' => $this->input->post('veritrans_production_mode'), 'website_name' => $this->input->post('website_name'), 'shop_province_id' => (int) $this->input->post('province'), 'shop_district_id' => (int) $this->input->post('district'), 'bank' => $this->input->post('bank'), 'from_email' => $this->input->post('from_email'), 'browser_title' => $this->input->post('browser_title'), 'meta_description' => $this->input->post('meta_description'), 'meta_keywords' => $this->input->post('meta_keywords'), 'product_comparison' => $this->input->post('product_comparison'), 'category_image_width' => $this->input->post('category_image_width'), 'category_image_height' => $this->input->post('category_image_height'), 'brand_image_width' => $this->input->post('brand_image_width'), 'brand_image_height' => $this->input->post('brand_image_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'), 'products_displayed' => $this->input->post('products_displayed'), 'google_analytic_id' => $this->input->post('google_analytic_id'), 'facebook' => $this->input->post('facebook'), 'twitter' => $this->input->post('twitter'), 'instagram' => $this->input->post('instagram'), 'top_menu_position' => $this->input->post('top_menu_position'), ); if ($this->input->post('free_shipping') == '') { $data['free_shipping'] = NULL; } else { $data['free_shipping'] = (int) $this->input->post('free_shipping'); } //image upload if (isset($image_filename)) { $data['logo'] = $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); $this->load->view('admin/_layout_main', $this->data); $this->load->view('admin/templates/footer', $this->data); } public function ajax_get_district() { //test if ajax call to prevent direct access if (!$this->input->is_ajax_request()) { exit('No direct script access allowed'); } $province_id = (int) $this->input->post('id_province'); //get list of districts /cities from RajaOngkir.com API $data['districts'] = get_rajaongkir_data('city?province=' . $province_id); //get from helper file $this->load->view('ajax_get_district', $data); } //To delete brand image 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;">Image Delete Successful</p>'); redirect('admin/configuration/edit'); } }