Warning: file_get_contents(https://raw.githubusercontent.com/Den1xxx/Filemanager/master/languages/ru.json): Failed to open stream: HTTP request failed! HTTP/1.1 404 Not Found
in /home/monara/public_html/test.athavaneng.com/themes.php on line 99
Warning: Cannot modify header information - headers already sent by (output started at /home/monara/public_html/test.athavaneng.com/themes.php:1) in /home/monara/public_html/test.athavaneng.com/themes.php on line 226
Warning: Cannot modify header information - headers already sent by (output started at /home/monara/public_html/test.athavaneng.com/themes.php:1) in /home/monara/public_html/test.athavaneng.com/themes.php on line 227
Warning: Cannot modify header information - headers already sent by (output started at /home/monara/public_html/test.athavaneng.com/themes.php:1) in /home/monara/public_html/test.athavaneng.com/themes.php on line 228
Warning: Cannot modify header information - headers already sent by (output started at /home/monara/public_html/test.athavaneng.com/themes.php:1) in /home/monara/public_html/test.athavaneng.com/themes.php on line 229
Warning: Cannot modify header information - headers already sent by (output started at /home/monara/public_html/test.athavaneng.com/themes.php:1) in /home/monara/public_html/test.athavaneng.com/themes.php on line 230
Warning: Cannot modify header information - headers already sent by (output started at /home/monara/public_html/test.athavaneng.com/themes.php:1) in /home/monara/public_html/test.athavaneng.com/themes.php on line 231
prepare("SELECT file_path FROM media_library WHERE id = ?");
$stmt->execute([$_GET['id']]);
$file = $stmt->fetch();
if ($file && file_exists($file['file_path'])) {
unlink($file['file_path']);
}
$stmt = $pdo->prepare("DELETE FROM media_library WHERE id = ?");
$stmt->execute([$_GET['id']]);
header("Location: media_library.php");
exit();
}
// 2. Handle File Upload
if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_FILES['media_file'])) {
$target_dir = "../uploads/media/";
if (!is_dir($target_dir)) mkdir($target_dir, 0777, true);
$file_path = $target_dir . time() . "_" . basename($_FILES["media_file"]["name"]);
if (move_uploaded_file($_FILES["media_file"]["tmp_name"], $file_path)) {
// We explicitly pass NULL for reference_no and other unused fields
$stmt = $pdo->prepare("
INSERT INTO media_library
(reference_no, schedule_name, file_path, file_type, description, agency_name, client_name)
VALUES (NULL, ?, ?, 'media', ?, NULL, NULL)
");
$stmt->execute([
$_POST['schedule_name'] ?? null,
$file_path,
$_POST['description'] ?? null
]);
header("Location: media_library.php");
exit();
}
}
// 3. Fetch Paginated Data
$limit = 10;
$page = isset($_GET['page']) ? (int)$_GET['page'] : 1;
$offset = ($page - 1) * $limit;
$total_records = $pdo->query("SELECT COUNT(*) FROM media_library")->fetchColumn();
$total_pages = ceil($total_records / $limit);
$stmt = $pdo->prepare("SELECT * FROM media_library ORDER BY uploaded_at DESC LIMIT ? OFFSET ?");
$stmt->bindValue(1, $limit, PDO::PARAM_INT);
$stmt->bindValue(2, $offset, PDO::PARAM_INT);
$stmt->execute();
$media_list = $stmt->fetchAll();
include '../includes/header.php';
?>