:: **Zploit** v1.0 | Current Path: **/home/kreativepixelz/public_html/crm/**
:: Editing File: vcard_delete.php
<?php ob_start(); include 'header.php'; /* =============================== PATH CONFIG (SAME AS ADD / EDIT) =============================== */ // Filesystem path define('VCARD_UPLOAD_PATH', $_SERVER['DOCUMENT_ROOT'] . '/kreativecrm/uploads/vcard/'); /* =============================== VALIDATE ID =============================== */ if (!isset($_GET['id']) || !is_numeric($_GET['id'])) { header("Location: vcard_list.php?msg=Invalid VCard ID"); exit; } $vcard_id = intval($_GET['id']); /* =============================== FETCH VCARD DATA =============================== */ $result = mysqli_query($conn, " SELECT card_slug, profile_image, banner_image, logo FROM vcards WHERE id = $vcard_id "); if (!$result || mysqli_num_rows($result) === 0) { header("Location: vcard_list.php?msg=VCard Not Found"); exit; } $vcard = mysqli_fetch_assoc($result); /* =============================== BASE DIRECTORY =============================== */ $base_dir = VCARD_UPLOAD_PATH . $vcard['card_slug'] . '/'; /* =============================== DELETE IMAGES =============================== */ $files = [ $vcard['profile_image'], $vcard['banner_image'], $vcard['logo'] ]; foreach ($files as $file) { if (!empty($file)) { $file_path = $base_dir . $file; if (file_exists($file_path)) { unlink($file_path); } } } /* =============================== DELETE DIRECTORY (SAFE) =============================== */ if (is_dir($base_dir)) { $remaining = glob($base_dir . '*'); if ($remaining) { foreach ($remaining as $f) { unlink($f); } } rmdir($base_dir); } /* =============================== DELETE DATABASE RECORD =============================== */ mysqli_query($conn, "DELETE FROM vcards WHERE id = $vcard_id"); /* =============================== REDIRECT =============================== */ header("Location: vcard_list.php?msg=VCard Deleted Successfully"); exit; ?>