:: **Zploit** v1.0 | Current Path: **/home/kreativepixelz/public_html/kreative_crm/**
:: Editing File: vcard_portfolio_delete.php
<?php ob_start(); include 'header.php'; /* =============================== PATH CONFIG (IMPORTANT) =============================== */ // 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_portfolio_list.php?msg=Invalid Portfolio ID"); exit; } $id = intval($_GET['id']); /* =============================== FETCH PORTFOLIO RECORD =============================== */ $q = mysqli_query( $conn, "SELECT id, vcard_id, image FROM vcard_portfolio WHERE id = '$id'" ); if (!$q || mysqli_num_rows($q) === 0) { header("Location: vcard_portfolio_list.php?msg=Portfolio Not Found"); exit; } $row = mysqli_fetch_assoc($q); /* =============================== FETCH VCARD 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_portfolio_list.php?msg=VCard Not Found"); exit; } $vcard = mysqli_fetch_assoc($vcard_q); $slug = $vcard['card_slug']; /* =============================== PORTFOLIO DIRECTORY =============================== */ $base_dir = VCARD_UPLOAD_PATH . $slug . '/portfolio/'; /* =============================== DELETE IMAGE FILE =============================== */ if (!empty($row['image'])) { $img_path = $base_dir . $row['image']; if (file_exists($img_path)) { unlink($img_path); } } /* =============================== DELETE DB RECORD =============================== */ mysqli_query($conn, "DELETE FROM vcard_portfolio WHERE id = '$id'"); /* =============================== REMOVE EMPTY PORTFOLIO FOLDER =============================== */ if (is_dir($base_dir)) { $files = glob($base_dir . '*'); if (!$files) { rmdir($base_dir); } } /* =============================== REDIRECT =============================== */ header("Location: vcard_portfolio_list.php?msg=Portfolio deleted successfully"); exit; ?>