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 * FROM teledramas WHERE id = :id LIMIT 1");
$stmt->execute([':id' => $id]);
$teledrama = $stmt->fetch(PDO::FETCH_ASSOC);
if (!$teledrama) {
die("Teledrama not found.");
}
} catch (Exception $e) {
die("Database error: " . htmlspecialchars($e->getMessage()));
}
// ---------------------------
// Handle Update
// ---------------------------
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$title = filter_input(INPUT_POST, 'title', FILTER_SANITIZE_STRING);
$category = filter_input(INPUT_POST, 'category', FILTER_SANITIZE_STRING); // Get Category
$description = filter_input(INPUT_POST, 'description', FILTER_SANITIZE_STRING);
$youtube_playlist = filter_input(INPUT_POST, 'youtube_playlist', FILTER_SANITIZE_STRING);
$cover_image = $teledrama['cover_image']; // Keep old image by default
$target_dir = $_SERVER['DOCUMENT_ROOT'] . '/uploads/teledramas/';
if (isset($_FILES['cover_image']) && $_FILES['cover_image']['error'] === UPLOAD_ERR_OK) {
$new_file = basename($_FILES['cover_image']['name']);
$target_file = $target_dir . $new_file;
$imageFileType = strtolower(pathinfo($target_file, PATHINFO_EXTENSION));
$check = getimagesize($_FILES['cover_image']['tmp_name']);
if ($check === false || !in_array($imageFileType, ['jpg', 'jpeg', 'png', 'gif', 'svg'])) {
$edit_message = "Invalid image file. Please upload JPG, PNG, or GIF.";
} elseif (!move_uploaded_file($_FILES['cover_image']['tmp_name'], $target_file)) {
$edit_message = "Error uploading new image.";
} else {
// Delete old file
if ($cover_image && file_exists($target_dir . $cover_image)) {
unlink($target_dir . $cover_image);
}
$cover_image = $new_file;
}
}
if (!$edit_message) {
try {
$stmt = $conn->prepare("UPDATE teledramas
SET title = :title, category = :category, description = :description, youtube_playlist = :youtube_playlist, cover_image = :cover_image
WHERE id = :id");
$stmt->execute([
':title' => $title,
':category' => $category,
':description' => $description,
':youtube_playlist' => $youtube_playlist,
':cover_image' => $cover_image,
':id' => $id
]);
// --- REDIRECT LOGIC ---
header("Location: dashboard.php");
exit; // Stop script execution immediately after redirect
// ----------------------
} catch (Exception $e) {
$edit_message = "Error updating teledrama: " . htmlspecialchars($e->getMessage());
}
}
}
?>