| Server IP : 127.0.0.1 / Your IP : 216.73.216.48 Web Server : Apache/2.4.58 (Win64) OpenSSL/3.1.3 PHP/8.2.12 System : Windows NT DESKTOP-3H4FHQJ 10.0 build 19045 (Windows 10) AMD64 User : win 10 ( 0) PHP Version : 8.2.12 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : D:/xampp/htdocs-coblaa/Cinevaa/ |
Upload File : |
<?php
include("db.php");
include("con_db.php");
session_start();
if (!isset($_SESSION['my_id'])) {
header("Location: login.php");
exit();
}
// --- TRENDING TOGGLE LOGIC ---
if (isset($_GET['toggle_trending'])) {
$id = mysqli_real_escape_string($con, $_GET['id']);
$current_status = mysqli_real_escape_string($con, $_GET['toggle_trending']);
$new_status = ($current_status == 1) ? 0 : 1;
$update_query = "UPDATE sn_moviestb SET is_trending = '$new_status' WHERE id = '$id'";
if (mysqli_query($con, $update_query)) {
header("Location: admin_movie_dash.php?msg=updated");
exit();
}
}
// --- DELETE LOGIC ---
if (isset($_GET['delete'])) {
$id = mysqli_real_escape_string($con, $_GET['delete']);
$fileQuery = mysqli_query($con, "SELECT thumbnail, video_path FROM sn_moviestb WHERE id = '$id'");
$files = mysqli_fetch_assoc($fileQuery);
if ($files) {
@unlink("thumbnail/" . $files['thumbnail']);
@unlink("movies/" . $files['video_path']);
}
mysqli_query($con, "DELETE FROM sn_moviestb WHERE id = '$id'");
header("Location: admin_movie_dash.php?msg=deleted");
}
// --- SEARCH & FILTER LOGIC ---
$search = isset($_GET['search']) ? mysqli_real_escape_string($con, $_GET['search']) : '';
$filter_trend = isset($_GET['filter_trend']) ? $_GET['filter_trend'] : '';
$where_clauses = [];
if ($search != '') {
$where_clauses[] = "(title LIKE '%$search%' OR movieCategory LIKE '%$search%')";
}
if ($filter_trend === '1') {
$where_clauses[] = "is_trending = 1";
} elseif ($filter_trend === '0') {
$where_clauses[] = "is_trending = 0";
}
$query_string = "SELECT * FROM sn_moviestb";
if (count($where_clauses) > 0) {
$query_string .= " WHERE " . implode(" AND ", $where_clauses);
}
$query_string .= " ORDER BY id DESC";
$movies = mysqli_query($con, $query_string);
// --- STATS ---
$totalMovies = mysqli_num_rows(mysqli_query($con, "SELECT id FROM sn_moviestb"));
$userCount = mysqli_fetch_assoc(mysqli_query($conn, "SELECT COUNT(*) as total FROM cb_userstb"))['total'];
$activeSubs = mysqli_fetch_assoc(mysqli_query($con, "SELECT COUNT(*) as total FROM cine_subscriptiontb WHERE subscription_status='active'"))['total'];
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Admin Dashboard | CINEVAA</title>
<style>
:root {
--primary: #e50914;
--gold: #d4af37;
--bg: #0a0a0a;
--card-bg: #141414;
--text: #fff;
--border: #262626;
}
body { font-family: 'Inter', sans-serif; background: var(--bg); color: var(--text); margin: 0; display: flex; }
.sidebar { width: 240px; background: #000; height: 100vh; position: fixed; border-right: 1px solid var(--border); padding: 20px; }
.logo { color: var(--primary); font-size: 22px; font-weight: 800; text-decoration: none; display: block; margin-bottom: 40px; }
.nav-link { display: block; color: #888; text-decoration: none; padding: 12px 15px; border-radius: 8px; margin-bottom: 5px; transition: 0.3s; }
.nav-link:hover, .nav-link.active { background: var(--card-bg); color: var(--primary); }
.main-content { margin-left: 240px; padding: 40px; width: calc(100% - 240px); }
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 20px; margin-bottom: 40px; }
.stat-card { background: var(--card-bg); padding: 25px; border-radius: 12px; border: 1px solid var(--border); }
.stat-card h3 { margin: 0; font-size: 13px; color: #888; text-transform: uppercase; }
.stat-card p { margin: 10px 0 0; font-size: 28px; font-weight: bold; color: var(--gold); }
/* Search Section */
.search-container { margin-bottom: 25px; display: flex; gap: 15px; background: var(--card-bg); padding: 20px; border-radius: 12px; border: 1px solid var(--border); }
.search-container input, .search-container select {
background: #000; border: 1px solid var(--border); color: #fff; padding: 10px; border-radius: 6px; outline: none;
}
.search-container input:focus { border-color: var(--gold); }
.btn-search { background: var(--gold); color: #000; border: none; padding: 10px 20px; border-radius: 6px; font-weight: bold; cursor: pointer; }
.content-card { background: var(--card-bg); border-radius: 12px; border: 1px solid var(--border); overflow: hidden; }
.table-header { padding: 20px; display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid var(--border); }
.btn-add { background: var(--primary); color: #fff; text-decoration: none; padding: 10px 20px; border-radius: 6px; font-weight: bold; font-size: 14px; }
table { width: 100%; border-collapse: collapse; text-align: left; }
th { background: #1a1a1a; padding: 15px; font-size: 13px; color: #888; }
td { padding: 15px; border-bottom: 1px solid var(--border); font-size: 14px; }
.thumb-img { width: 80px; height: 45px; object-fit: cover; border-radius: 4px; border: 1px solid var(--border); }
.trend-badge { font-size: 10px; padding: 2px 6px; border-radius: 4px; margin-left: 8px; font-weight: bold; text-transform: uppercase; }
.is-trend { background: var(--gold); color: #000; }
.btn-trend { font-size: 11px; padding: 5px 10px; border-radius: 4px; text-decoration: none; color: #fff; border: 1px solid #444; }
.btn-trend:hover { border-color: var(--gold); color: var(--gold); }
.action-btns a { margin-right: 10px; text-decoration: none; font-size: 12px; font-weight: bold; }
.edit-link { color: #3b82f6; }
.delete-link { color: var(--primary); }
.alert { background: #166534; color: #fff; padding: 15px; border-radius: 8px; margin-bottom: 20px; }
</style>
</head>
<body>
<div class="sidebar">
<a href="#" class="logo">CINEVAA ADMIN</a>
<a href="admin_movie_dash.php" class="nav-link active">Movies List</a>
<a href="users_list.php" class="nav-link">Manage Users</a>
<a href="upload_movie.php" class="nav-link">Upload New</a>
<a href="admin_analytics.php" class="nav-link">Analytics</a>
<hr style="border: 0; border-top: 1px solid var(--border); margin: 20px 0;">
<a href="logout.php" class="nav-link">Sign Out</a>
</div>
<div class="main-content">
<?php if(isset($_GET['msg'])) echo '<div class="alert">Operation Successful!</div>'; ?>
<div class="stats-grid">
<div class="stat-card"><h3>Total Movies</h3><p><?php echo $totalMovies; ?></p></div>
<div class="stat-card"><h3>Total Users</h3><p><?php echo $userCount; ?></p></div>
<div class="stat-card"><h3>Active Subs</h3><p><?php echo $activeSubs; ?></p></div>
</div>
<form class="search-container" method="GET">
<input type="text" name="search" placeholder="Search by Title or Category..." value="<?php echo htmlspecialchars($search); ?>" style="flex: 2;">
<select name="filter_trend">
<option value="">All Movies</option>
<option value="1" <?php if($filter_trend === '1') echo 'selected'; ?>>Trending Only</option>
<option value="0" <?php if($filter_trend === '0') echo 'selected'; ?>>Non-Trending</option>
</select>
<button type="submit" class="btn-search">Apply Filter</button>
<a href="admin_movie_dash.php" style="color: #888; text-decoration: none; padding-top: 10px; font-size: 12px;">Clear</a>
</form>
<div class="content-card">
<div class="table-header">
<h2 style="margin:0; font-size: 18px;">
<?php echo ($search != '') ? 'Search Results for "'.htmlspecialchars($search).'"' : 'Movie Library'; ?>
</h2>
<a href="upload_movie.php" class="btn-add">+ Upload Movie</a>
</div>
<table>
<thead>
<tr>
<th>Thumbnail</th>
<th>Title & Status</th>
<th>Category</th>
<th>Trending Control</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
<?php if(mysqli_num_rows($movies) > 0): ?>
<?php while($row = mysqli_fetch_assoc($movies)): ?>
<tr>
<td><img src="thumbnail/<?php echo $row['thumbnail']; ?>" class="thumb-img"></td>
<td>
<strong><?php echo $row['title']; ?></strong>
<?php if($row['is_trending'] == 1): ?>
<span class="trend-badge is-trend">Trending</span>
<?php endif; ?>
</td>
<td><?php echo $row['movieCategory']; ?></td>
<td>
<a href="admin_movie_dash.php?id=<?php echo $row['id']; ?>&toggle_trending=<?php echo $row['is_trending']; ?>" class="btn-trend">
<?php echo ($row['is_trending'] == 1) ? "Remove from Trending" : "Set as Trending"; ?>
</a>
</td>
<td class="action-btns">
<a href="edit_movie.php?id=<?php echo $row['id']; ?>" class="edit-link">EDIT</a>
<a href="admin_movie_dash.php?delete=<?php echo $row['id']; ?>" class="delete-link" onclick="return confirm('Delete this movie permanently?')">DELETE</a>
</td>
</tr>
<?php endwhile; ?>
<?php else: ?>
<tr><td colspan="5" style="text-align:center; padding: 40px; color: #666;">No movies found matching your criteria.</td></tr>
<?php endif; ?>
</tbody>
</table>
</div>
</div>
</body>
</html>