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 slug = :slug");
$stmt->bindParam(':slug', $slug);
$stmt->execute();
$teledrama = $stmt->fetch(PDO::FETCH_ASSOC);
} elseif ($id > 0) {
// Fetch by ID (Fallback)
$stmt = $conn->prepare("SELECT * FROM teledramas WHERE id = :id");
$stmt->bindParam(':id', $id);
$stmt->execute();
$teledrama = $stmt->fetch(PDO::FETCH_ASSOC);
}
if (!$teledrama) {
die("Teledrama not found.");
}
// IMPORTANT: Ensure $id is set to the real numeric ID for episode queries
$id = $teledrama['id'];
// 3. FETCH EPISODES (FROM DATABASE)
$items_per_page = 21;
$page = isset($_GET['page']) ? (int)$_GET['page'] : 1;
if ($page < 1) {
$page = 1;
}
$offset = ($page - 1) * $items_per_page;
$episodes_stmt = $conn->prepare("SELECT * FROM teledrama_videos WHERE teledrama_id = :id ORDER BY published_at DESC LIMIT :offset, :limit");
$episodes_stmt->bindParam(':id', $id, PDO::PARAM_INT);
$episodes_stmt->bindParam(':offset', $offset, PDO::PARAM_INT);
$episodes_stmt->bindParam(':limit', $items_per_page, PDO::PARAM_INT);
$episodes_stmt->execute();
$episodes = $episodes_stmt->fetchAll(PDO::FETCH_ASSOC);
// Count total episodes for pagination
$count_stmt = $conn->prepare("SELECT COUNT(*) FROM teledrama_videos WHERE teledrama_id = :id");
$count_stmt->bindParam(':id', $id, PDO::PARAM_INT);
$count_stmt->execute();
$total_items = $count_stmt->fetchColumn();
$total_pages = ceil($total_items / $items_per_page);
// 4. PREPARE PAGINATION URL BASE
// If using slug, link format: teledramas/slug?page=X
// If using ID, link format: ?id=X&page=X
$paginationBase = !empty($slug)
? "teledramas/" . htmlspecialchars($slug) . "?"
: "?id=" . $id . "&";
// Set page title
$page_title = $teledrama['title'] . " | Swarnawahini";
require 'components/header.php';
?>