Backups Created:
/home/japatmex/public_html/wp-content/edit-wolf.php
Savvy
W
olf -
MANAGER
Edit File: Category.php
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); class Category extends MY_Controller { public function __construct(){ parent::__construct(); $this->load->model('Ecomm_model'); $this->load->helper('ecomm_helper'); } public function index($page = 1) { $this->data['page_title'] = 'Categories'; $this->data['current_page'] = 'Categories'; $cat_dropdown = category_dropdown(); $parent_cat_id = (int)0; $category_name = "Main Categories"; if($this->input->get('id')) { $parent_cat_id = $this->input->get('id'); } $row=$this->Ecomm_model->category_list('id','DESC','','','',$parent_cat_id); if($parent_cat_id) { $category_name = $this->db->select('category_name')->from('tbl_gf_ecomm_category')->where('id', $parent_cat_id)->get()->row()->category_name; } $config = array(); $config["base_url"] = base_url($this->config->item('apanel_name').'/ecomm/category'); $config["total_rows"] = count($row); $config["per_page"] = 12; $config['num_links'] = 4; $config['use_page_numbers'] = TRUE; $config['reuse_query_string'] = TRUE; $config['enable_query_strings'] = TRUE; $config['page_query_string'] = FALSE; $config['full_tag_open'] = '<ul class="pagination">'; $config['full_tag_close'] = '</ul>'; $config['first_link'] = '<i class="fa fa-angle-double-left"></i>'; $config['first_tag_open'] = '<li>'; $config['first_tag_close'] = '</li>'; $config['last_link'] = '<i class="fa fa-angle-double-right"></i>'; $config['last_tag_open'] = '<li>'; $config['last_tag_close'] = '</li>'; $config['next_link'] = ''; $config['next_tag_open'] = '<span class="nextlink">'; $config['next_tag_close'] = '</span>'; $config['prev_link'] = ''; $config['prev_tag_open'] = '<span class="prevlink">'; $config['prev_tag_close'] = '</span>'; $config['cur_tag_open'] = '<li class="active"><a href="#">'; $config['cur_tag_close'] = '<span class="sr-only">(current)</span></a></li>'; $config['num_tag_open'] = '<li style="margin:3px">'; $config['num_tag_close'] = '</li>'; $this->pagination->initialize($config); $page=($page-1) * $config["per_page"]; if($this->input->post('search_value')!=''){ $keyword=addslashes(trim($this->input->post('search_value'))); $this->data['category_list'] = $this->Ecomm_model->category_list('id', 'DESC', '', '', $keyword, $parent_cat_id); } else{ $this->data["links"] = $this->pagination->create_links(); $this->data['category_list'] = $this->Ecomm_model->category_list('OrderBy','ASC' , $config["per_page"], $page,'',$parent_cat_id); } $this->data['category_name'] = $category_name; $this->data['categories_dropdown'] = $cat_dropdown; $this->data['view'] = 'admin/ecomm/category'; $this->load->view('admin/layouts/default1', $this->data); } public function add() { $THEME = $this->data['rsStngs']->Theme; if($this->input->method() == 'post') { $this->load->library('Form_validation'); $this->form_validation->set_rules('title', 'Enter Category Title', 'trim|required'); if($this->form_validation->run() == FALSE) { $messge = array('message' => $this->lang->line('input_required'),'class' => 'alert alert-danger'); $this->session->set_flashdata('response_msg', $messge); redirect(base_url($this->config->item('apanel_name').'/ecomm/category/add').get_query_string()); } else { $config['upload_path'] = FCPATH . 'uplds'.$THEME.'/ecomm/images/category/'; $config['allowed_types'] = 'jpg|png|jpeg|PNG|JPG|JPEG'; $image = date('dmYhis').'_'.rand(0,99999).".".pathinfo($_FILES['file_name']['name'], PATHINFO_EXTENSION); $config['file_name'] = $image; $this->load->library('upload', $config); if (!$this->upload->do_upload('file_name')) { $messge = array('message' => $this->upload->display_errors(),'class' => 'alert alert-danger'); $this->session->set_flashdata('response_msg', $messge); redirect(base_url($this->config->item('apanel_name').'/ecomm/category/add').get_query_string()); } else { $upload_data = $this->upload->data(); } $this->load->helper("date"); $slug = url_title($this->input->post('title'), 'dash', TRUE); $data = array( 'category_name' => $this->input->post('title'), 'category_slug' => $slug, 'category_image' => $image, 'product_features' => ($this->input->post('product_features')!='') ? implode(',', $this->input->post('product_features')) : '', 'created_at' => strtotime(date('d-m-Y h:i:s A',now())), 'parent_id' => $this->input->post('parent_id') ); $data = $this->security->xss_clean($data); if($this->Ecomm_model->insert($data, 'tbl_gf_ecomm_category')){ $messge = array('message' => $this->lang->line('add_msg'),'class' => 'alert alert-success'); $this->session->set_flashdata('response_msg', $messge); } else{ last_query(); die; $messge = array('message' => $this->lang->line('add_error'),'class' => 'alert alert-danger'); $this->session->set_flashdata('response_msg', $messge); } redirect(base_url($this->config->item('apanel_name').'/ecomm/category/add').get_query_string()); } } $this->data['category_list'] = category_dropdown(); $this->data['page_title'] = 'Categories'; $this->data['current_page'] = 'Add Category'; $this->data['view'] = 'admin/ecomm/add_category'; $this->load->view('admin/layouts/default1', $this->data); } public function edit($id, $parent_id = 0) { $THEME = $rowSettings->Theme; if($this->input->method() == 'post') { $data = $this->Ecomm_model->single_category($id); $redirect_url = base_url($this->config->item('apanel_name').'/ecomm/category/edit/'.$id.'/'.$parent_id.get_query_string()); if($_FILES['file_name']['error']!=4){ $config['upload_path'] = FCPATH . 'uplds'.$THEME.'/ecomm/images/category/'; $config['allowed_types'] = 'jpg|png|jpeg|PNG|JPG|JPEG'; if(file_exists(FCPATH . 'uplds'.$THEME.'/ecomm/images/category/'.$data[0]->category_image)){ unlink(FCPATH . 'uplds'.$THEME.'/ecomm/images/category/'.$data[0]->category_image); $mask = $data[0]->category_slug.'*_*'; array_map('unlink', glob(FCPATH . 'uplds'.$THEME.'/ecomm/images/category/thumbs/'.$mask)); } $image = date('dmYhis').'_'.rand(0,99999).".".pathinfo($_FILES['file_name']['name'], PATHINFO_EXTENSION); $config['file_name'] = $image; $this->load->library('upload', $config); if (!$this->upload->do_upload('file_name')) { $messge = array('message' => $this->upload->display_errors(),'class' => 'alert alert-danger'); $this->session->set_flashdata('response_msg', $messge); redirect($redirect_url); } } else{ $image=$data[0]->category_image; } $this->load->helper("date"); $slug = url_title($this->input->post('title'), 'dash', TRUE); $data = array( 'category_name' => $this->input->post('title'), 'category_slug' => $slug, 'category_image' => $image, 'product_features' => ($this->input->post('product_features')!='') ? implode(',', $this->input->post('product_features')) : '', 'parent_id' => $this->input->post('parent_id') ); $data = $this->security->xss_clean($data); if($this->Ecomm_model->update($data, $id,'tbl_gf_ecomm_category')){ $messge = array('message' => $this->lang->line('update_msg'),'class' => 'alert alert-success'); $this->session->set_flashdata('response_msg', $messge); } else{ $messge = array('message' => $this->lang->line('update_error'),'class' => 'alert alert-danger'); $this->session->set_flashdata('response_msg', $messge); } redirect($redirect_url); } $this->data['category_list'] = category_dropdown(); $this->data['parent_id'] = $parent_id; $this->data['page_title'] = 'Categories'; $this->data['category'] = $this->Ecomm_model->single_category($id); $this->data['current_page'] = 'Edit Category'; $this->data['view'] = 'admin/ecomm/edit_category'; $this->load->view('admin/layouts/default1', $this->data); } public function active($id) { $data = array( 'status' => 1 ); $data = $this->security->xss_clean($data); $this->Ecomm_model->update($data, $id,'tbl_gf_ecomm_category'); echo 'Enable successfully...'; } public function deactive($id) { $data = array( 'status' => 0 ); $data = $this->security->xss_clean($data); $this->Ecomm_model->update($data, $id,'tbl_gf_ecomm_category'); echo 'Disable successfully...'; } public function category_on_home() { $data = array( 'set_on_home' => $this->input->post('status') ); $data = $this->security->xss_clean($data); $this->Ecomm_model->update($data, $this->input->post('id'),'tbl_gf_ecomm_category'); if($this->input->post('status')==1){ $messge = array('message' => $this->lang->line('category_show'),'class' => 'success'); $this->session->set_flashdata('response_msg', $messge); } else{ $messge = array('message' => $this->lang->line('category_remove'),'class' => 'success'); $this->session->set_flashdata('response_msg', $messge); } } public function delete($id) { echo $this->Ecomm_model->deleteCategory($id); } }