![]() Server : Apache/2 System : Linux server-15-235-50-60 5.15.0-164-generic #174-Ubuntu SMP Fri Nov 14 20:25:16 UTC 2025 x86_64 User : gositeme ( 1004) PHP Version : 8.2.29 Disable Function : exec,system,passthru,shell_exec,proc_close,proc_open,dl,popen,show_source,posix_kill,posix_mkfifo,posix_getpwuid,posix_setpgid,posix_setsid,posix_setuid,posix_setgid,posix_seteuid,posix_setegid,posix_uname Directory : /home/gositeme/domains/soundstudiopro.com/public_html/radio/dashboard/ |
<?php
// Enable error reporting for debugging
error_reporting(E_ALL);
ini_set('display_errors', 1);
session_start();
require_once __DIR__ . '/../../config/database.php';
require_once __DIR__ . '/../includes/functions.php';
// Check if station is logged in
if (!isset($_SESSION['radio_station_id'])) {
header('Location: /radio/login.php');
exit;
}
$station_id = $_SESSION['radio_station_id'];
try {
$station = getRadioStation($station_id);
if (!$station) {
session_destroy();
header('Location: /radio/login.php');
exit;
}
$pdo = getDBConnection();
// Get statistics (handle errors gracefully)
$stats = getStationStats($station_id, 30);
if (!$stats) {
$stats = ['total_plays' => 0, 'unique_tracks' => 0, 'active_days' => 0];
}
$top_tracks = getStationTopTracks($station_id, 10, 30);
if (!$top_tracks) {
$top_tracks = [];
}
// Get recent plays (handle if table doesn't exist)
$recent_plays = [];
try {
$stmt = $pdo->prepare("
SELECT
pl.*,
t.title,
t.artist_name
FROM radio_play_logs pl
JOIN music_tracks t ON pl.track_id = t.id
WHERE pl.station_id = ?
ORDER BY pl.played_at DESC
LIMIT 10
");
$stmt->execute([$station_id]);
$recent_plays = $stmt->fetchAll(PDO::FETCH_ASSOC);
} catch (PDOException $e) {
// Table might not exist yet, that's okay
error_log("Error fetching recent plays: " . $e->getMessage());
$recent_plays = [];
}
} catch (Exception $e) {
error_log("Dashboard error: " . $e->getMessage());
$error = "Error loading dashboard: " . $e->getMessage();
$station = null;
$stats = ['total_plays' => 0, 'unique_tracks' => 0, 'active_days' => 0];
$top_tracks = [];
$recent_plays = [];
}
$page_title = 'Radio Station Dashboard - ' . htmlspecialchars($station['station_name']);
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title><?= $page_title ?></title>
<link rel="stylesheet" href="/assets/css/main.css">
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap" rel="stylesheet">
<style>
* {
box-sizing: border-box;
}
body {
font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
min-height: 100vh;
padding: 2rem 1rem;
}
.radio-dashboard {
max-width: 1400px;
margin: 0 auto;
}
.dashboard-header {
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
padding: 2.5rem;
border-radius: 20px;
margin-bottom: 2rem;
color: white;
box-shadow: 0 10px 40px rgba(102, 126, 234, 0.3);
display: flex;
justify-content: space-between;
align-items: center;
}
.dashboard-header h1 {
margin: 0;
font-size: 2.5rem;
font-weight: 800;
}
.dashboard-header p {
margin: 0.5rem 0 0 0;
opacity: 0.9;
font-size: 1.1rem;
}
.dashboard-header a {
color: white;
text-decoration: none;
padding: 0.75rem 1.5rem;
background: rgba(255, 255, 255, 0.2);
border-radius: 10px;
font-weight: 600;
transition: all 0.3s ease;
backdrop-filter: blur(10px);
}
.dashboard-header a:hover {
background: rgba(255, 255, 255, 0.3);
transform: translateY(-2px);
}
.subscription-status {
display: inline-block;
padding: 0.5rem 1rem;
border-radius: 20px;
font-size: 0.85rem;
font-weight: 600;
margin-left: 1rem;
text-transform: uppercase;
letter-spacing: 0.5px;
}
.subscription-status.active {
background: rgba(212, 237, 218, 0.3);
color: #fff;
border: 2px solid rgba(255, 255, 255, 0.3);
}
.subscription-status.trial {
background: rgba(255, 243, 205, 0.3);
color: #fff;
border: 2px solid rgba(255, 255, 255, 0.3);
}
.nav-links {
display: flex;
gap: 1rem;
margin-bottom: 2rem;
flex-wrap: wrap;
}
.nav-links a {
padding: 0.75rem 1.5rem;
background: white;
color: #667eea;
text-decoration: none;
border-radius: 12px;
font-weight: 600;
transition: all 0.3s ease;
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}
.nav-links a:hover {
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
color: white;
transform: translateY(-2px);
box-shadow: 0 8px 24px rgba(102, 126, 234, 0.3);
}
.stats-grid {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
gap: 1.5rem;
margin-bottom: 2rem;
}
.stat-card {
background: white;
padding: 2rem;
border-radius: 16px;
box-shadow: 0 8px 24px rgba(0, 0, 0, 0.1);
transition: all 0.3s ease;
border: 1px solid rgba(255, 255, 255, 0.5);
}
.stat-card:hover {
transform: translateY(-4px);
box-shadow: 0 12px 32px rgba(102, 126, 234, 0.2);
}
.stat-card h3 {
margin: 0 0 1rem 0;
font-size: 0.9rem;
color: #666;
text-transform: uppercase;
letter-spacing: 0.5px;
font-weight: 600;
}
.stat-number {
font-size: 2.5rem;
font-weight: 800;
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
background-clip: text;
}
.section {
background: white;
padding: 2rem;
border-radius: 16px;
box-shadow: 0 8px 24px rgba(0, 0, 0, 0.1);
margin-bottom: 2rem;
border: 1px solid rgba(255, 255, 255, 0.5);
}
.section h2 {
margin-top: 0;
color: #333;
font-size: 1.75rem;
font-weight: 700;
margin-bottom: 1.5rem;
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
background-clip: text;
}
table {
width: 100%;
border-collapse: collapse;
}
table th,
table td {
padding: 1rem;
text-align: left;
border-bottom: 1px solid #f0f0f0;
}
table th {
background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
font-weight: 600;
color: #333;
text-transform: uppercase;
font-size: 0.85rem;
letter-spacing: 0.5px;
}
table tr:hover {
background: #f8f9fa;
}
table td {
color: #555;
}
.error-message {
background: linear-gradient(135deg, #fee 0%, #fcc 100%);
color: #c33;
padding: 1.5rem;
border-radius: 12px;
margin-bottom: 2rem;
border: 2px solid rgba(204, 51, 51, 0.3);
font-weight: 500;
}
@media (max-width: 768px) {
.dashboard-header {
flex-direction: column;
text-align: center;
gap: 1rem;
}
.dashboard-header h1 {
font-size: 2rem;
}
.stats-grid {
grid-template-columns: 1fr;
}
}
</style>
</head>
<body>
<?php
// Try to include header, but don't fail if it doesn't exist
$header_path = __DIR__ . '/../../includes/header.php';
if (file_exists($header_path)) {
try {
include $header_path;
} catch (Exception $e) {
error_log("Header include error: " . $e->getMessage());
// Fallback minimal header
echo '<header style="padding: 1rem; background: rgba(102, 126, 234, 0.1);"><a href="/" style="color: #667eea; text-decoration: none; font-weight: 600;">SoundStudioPro</a> | <a href="/radio/logout.php" style="color: #667eea; text-decoration: none;">Logout</a></header>';
}
} else {
// Fallback minimal header
echo '<header style="padding: 1rem; background: rgba(102, 126, 234, 0.1);"><a href="/" style="color: #667eea; text-decoration: none; font-weight: 600;">SoundStudioPro</a> | <a href="/radio/logout.php" style="color: #667eea; text-decoration: none;">Logout</a></header>';
}
?>
<div class="radio-dashboard">
<?php if (isset($error)): ?>
<div class="error-message">
<strong>⚠️ Error:</strong> <?= htmlspecialchars($error) ?>
</div>
<?php endif; ?>
<?php if ($station): ?>
<div class="dashboard-header">
<div>
<h1>📻 <?= htmlspecialchars($station['station_name']) ?></h1>
<p>
<?php if ($station['call_sign']): ?>
<?= htmlspecialchars($station['call_sign']) ?> •
<?php endif; ?>
<span class="subscription-status <?= $station['subscription_status'] ?>">
<?= ucfirst($station['subscription_status']) ?>
</span>
</p>
</div>
<div>
<a href="/radio/logout.php">🚪 Logout</a>
</div>
</div>
<div class="nav-links">
<a href="/radio/dashboard/">Dashboard</a>
<a href="/radio/catalog/">Music Catalog</a>
<a href="/radio/playlists/">Playlists</a>
<a href="/radio/dashboard/live_stream.php">Live Stream</a>
<a href="/radio/analytics/">Analytics</a>
<a href="/radio/api/">API Settings</a>
</div>
<div class="stats-grid">
<div class="stat-card">
<h3>Monthly Plays</h3>
<div class="stat-number">
<?= number_format($station['current_month_plays']) ?> / <?= number_format($station['monthly_play_limit']) ?>
</div>
</div>
<div class="stat-card">
<h3>Total Plays (30 days)</h3>
<div class="stat-number"><?= number_format($stats['total_plays'] ?? 0) ?></div>
</div>
<div class="stat-card">
<h3>Unique Tracks</h3>
<div class="stat-number"><?= number_format($stats['unique_tracks'] ?? 0) ?></div>
</div>
<div class="stat-card">
<h3>Active Days</h3>
<div class="stat-number"><?= number_format($stats['active_days'] ?? 0) ?></div>
</div>
</div>
<div class="section">
<h2>Top Tracks This Month</h2>
<?php if (empty($top_tracks)): ?>
<p>No plays recorded yet. Start playing music to see your top tracks!</p>
<?php else: ?>
<table>
<thead>
<tr>
<th>Track</th>
<th>Artist</th>
<th>Plays</th>
<th>Last Played</th>
</tr>
</thead>
<tbody>
<?php foreach ($top_tracks as $track): ?>
<tr>
<td><?= htmlspecialchars($track['title']) ?></td>
<td><?= htmlspecialchars($track['artist_name'] ?? 'Unknown') ?></td>
<td><?= number_format($track['play_count']) ?></td>
<td><?= date('M j, Y g:i A', strtotime($track['last_played'])) ?></td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
<?php endif; ?>
</div>
<div class="section">
<h2>Recent Plays</h2>
<?php if (empty($recent_plays)): ?>
<p>No recent plays. Log your first play to get started!</p>
<?php else: ?>
<table>
<thead>
<tr>
<th>Track</th>
<th>Artist</th>
<th>Played At</th>
<th>Duration</th>
</tr>
</thead>
<tbody>
<?php foreach ($recent_plays as $play): ?>
<tr>
<td><?= htmlspecialchars($play['title']) ?></td>
<td><?= htmlspecialchars($play['artist_name'] ?? 'Unknown') ?></td>
<td><?= date('M j, Y g:i A', strtotime($play['played_at'])) ?></td>
<td><?= $play['duration_played'] ? gmdate('i:s', $play['duration_played']) : 'Full' ?></td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
<?php endif; ?>
</div>
<?php else: ?>
<div style="text-align: center; padding: 4rem;">
<h2>Unable to load dashboard</h2>
<p>Please try logging in again.</p>
<a href="/radio/login.php" class="btn-primary">Go to Login</a>
</div>
<?php endif; ?>
</div>
<?php
// Try to include footer, but don't fail if it doesn't exist
$footer_path = __DIR__ . '/../../includes/footer.php';
if (file_exists($footer_path)) {
try {
include $footer_path;
} catch (Exception $e) {
error_log("Footer include error: " . $e->getMessage());
}
}
?>
</body>
</html>