:: **Zploit** v1.0 | Current Path: **/home/kreativepixelz/www/crm/quatation/**
:: Editing File: vcard_testimonial_delete.php
<?php ob_start(); include 'header.php'; /* =============================== PATH CONFIG (MATCH EDIT PAGE) =============================== */ // Filesystem base path define( 'VCARD_UPLOAD_PATH', $_SERVER['DOCUMENT_ROOT'] . '/kreativecrm/uploads/vcard/' ); /* =============================== VALIDATE ID =============================== */ if (!isset($_GET['id']) || !is_numeric($_GET['id'])) { header("Location: vcard_testimonial_list.php?msg=Invalid Testimonial ID"); exit; } $id = intval($_GET['id']); /* =============================== FETCH TESTIMONIAL =============================== */ $q = mysqli_query( $conn, "SELECT id, vcard_id, client_image FROM vcard_testimonials WHERE id = '$id'" ); if (!$q || mysqli_num_rows($q) === 0) { header("Location: vcard_testimonial_list.php?msg=Testimonial Not Found"); exit; } $row = mysqli_fetch_assoc($q); /* =============================== FETCH CARD SLUG =============================== */ $vcard_q = mysqli_query( $conn, "SELECT card_slug FROM vcards WHERE id = '{$row['vcard_id']}'" ); if (!$vcard_q || mysqli_num_rows($vcard_q) === 0) { header("Location: vcard_testimonial_list.php?msg=VCard Not Found"); exit; } $vcard = mysqli_fetch_assoc($vcard_q); $slug = $vcard['card_slug']; /* =============================== TESTIMONIAL DIRECTORY =============================== */ $base_dir = VCARD_UPLOAD_PATH . $slug . '/testimonial/'; /* =============================== DELETE IMAGE (IF EXISTS) =============================== */ if (!empty($row['client_image'])) { $img_path = $base_dir . $row['client_image']; if (file_exists($img_path)) { unlink($img_path); } } /* =============================== DELETE DB RECORD =============================== */ mysqli_query($conn, "DELETE FROM vcard_testimonials WHERE id = '$id'"); /* =============================== OPTIONAL: REMOVE EMPTY FOLDER =============================== */ if (is_dir($base_dir)) { $files = glob($base_dir . '*'); if (!$files) { rmdir($base_dir); } } /* =============================== REDIRECT =============================== */ header("Location: vcard_testimonial_list.php?msg=Testimonial Deleted Successfully"); exit; ?>