File manager - Edit - /home/u608250662/domains/rdsolution.org.in/public_html/jevica/application/controllers/Testomonial.php
Back
<?php if (! defined('BASEPATH')) exit('No direct script access allowed'); class Testomonial extends CI_Controller { public function __construct() { parent::__construct(); $this->load->library('session'); } function listing() { $data['TESTIMONIALS'] = $this->crud->get_data('wdi_testimonial_f'); $this->load->view('admin/testimonial_s/list', $data); } function add(){ if (isset($_POST['submit'])) { if ($_FILES['image']['name'] != '') { $bimage = $_FILES['image']['name']; $path = 'media/uploads/testimonials/' . $bimage; move_uploaded_file($_FILES['image']['tmp_name'], $path); } else { $bimage = ""; } $testimonials['name'] = $this->input->post('name'); $testimonials['designation'] = $this->input->post('designation'); $testimonials['image'] = $bimage; $testimonials['content'] = $this->input->post('description'); $this->crud->insert("wdi_testimonial_f", $testimonials); $this->session->set_flashdata('message', '<div class="alert alert-success">Record has been successfully saved.</div>'); redirect('testimonials/listing'); } $this->load->view('admin/testimonial_s/add'); } function edit() { $args = func_get_args(); if (isset($_POST['submit'])) { // Get testimonial ID $testimonialid = $args[0]; // Handle image upload if (!empty($_FILES['image']['name'])) { $allowed_types = array('jpg', 'jpeg', 'png', 'gif', 'webp'); $upload_path = 'media/uploads/testimonials/'; $filename = $_FILES['image']['name']; $ext = pathinfo($filename, PATHINFO_EXTENSION); if (in_array(strtolower($ext), $allowed_types)) { $new_name = time() . '_' . preg_replace('/\s+/', '_', $filename); $path = $upload_path . $new_name; if (move_uploaded_file($_FILES['image']['tmp_name'], $path)) { $bimage = $new_name; // Optionally, delete old image if exists $old_image = $this->input->post('old_image'); if (!empty($old_image) && file_exists($upload_path . $old_image)) { unlink($upload_path . $old_image); } } else { $bimage = $this->input->post('old_image'); } } else { $bimage = $this->input->post('old_image'); } } else { $bimage = $this->input->post('old_image'); } // Prepare data array $testimonials = array( 'image' => $bimage, 'name' => $this->input->post('name'), 'designation' => $this->input->post('designation'), 'content' => $this->input->post('description') ); // Update the table $this->db->where('id', $testimonialid); $this->db->update('wdi_testimonial_f', $testimonials); $this->session->set_flashdata('message', '<div class="alert alert-success">Record has been successfully updated.</div>'); redirect('testimonials/listing'); } $data['EDITDATA'] = $this->testomonials->get_testimonial($args[0]); $this->load->view('admin/testimonial_s/edit', $data); } function delete() { $args = func_get_args(); $data = $this->testomonials->get_testimonial($args[0]); $path = 'media/uploads/testimonials/' . $data[0]->image; @unlink($path); $this->testomonials->delete($args[0]); $this->session->set_flashdata('message', '<div class="alert alert-success">Record has been successfully deleted.</div>'); redirect('testimonials/listing'); } }
| ver. 1.4 |
Github
|
.
| PHP 8.0.30 | Generation time: 0.02 |
proxy
|
phpinfo
|
Settings