![]() 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/.cursor-server/data/User/History/-1caf4efe/ |
<?php
session_start();
require_once 'config/database.php';
// Handle AJAX requests
$is_ajax = isset($_GET['ajax']) && $_GET['ajax'] == '1';
// Include header only for full page loads
if (!$is_ajax) {
include 'includes/header.php';
}
// Global player is included via footer.php
$pdo = getDBConnection();
// Get user name from database if logged in
$user_name = 'Guest';
$user_id = null;
if (isset($_SESSION['user_id'])) {
$stmt = $pdo->prepare("SELECT name FROM users WHERE id = ?");
$stmt->execute([$_SESSION['user_id']]);
$user = $stmt->fetch();
$user_name = $user['name'] ?? 'User';
$user_id = $_SESSION['user_id'];
}
// Get recent community tracks with social data
try {
$stmt = $pdo->prepare("
SELECT
mt.id,
mt.title,
mt.prompt,
mt.audio_url,
mt.duration,
mt.created_at,
mt.user_id,
u.name as artist_name,
u.id as artist_id,
(SELECT COUNT(*) FROM track_likes WHERE track_id = mt.id) as like_count,
(SELECT COUNT(*) FROM track_comments WHERE track_id = mt.id) as comment_count,
(SELECT COUNT(*) FROM user_follows WHERE follower_id = ? AND following_id = mt.user_id) as is_following,
(SELECT COUNT(*) FROM track_likes WHERE track_id = mt.id AND user_id = ?) as user_liked
FROM music_tracks mt
JOIN users u ON mt.user_id = u.id
WHERE mt.status = 'complete'
ORDER BY mt.created_at DESC
LIMIT 20
");
$stmt->execute([$user_id ?? 0, $user_id ?? 0]);
$recent_tracks = $stmt->fetchAll();
} catch (Exception $e) {
// Fallback to basic query if social query fails
$stmt = $pdo->prepare("
SELECT
mt.id,
mt.title,
mt.prompt,
mt.audio_url,
mt.duration,
mt.created_at,
mt.user_id,
u.name as artist_name,
u.id as artist_id,
0 as like_count,
0 as comment_count,
0 as is_following,
0 as user_liked
FROM music_tracks mt
JOIN users u ON mt.user_id = u.id
WHERE mt.status = 'complete'
ORDER BY mt.created_at DESC
LIMIT 20
");
$stmt->execute();
$recent_tracks = $stmt->fetchAll();
}
// Get community stats
try {
$stmt = $pdo->prepare("
SELECT
COUNT(DISTINCT mt.id) as total_tracks,
COUNT(DISTINCT mt.user_id) as total_artists,
COALESCE(SUM(mt.duration), 0) as total_duration,
(SELECT COUNT(*) FROM track_likes) as total_likes,
(SELECT COUNT(*) FROM track_comments) as total_comments,
(SELECT COUNT(*) FROM user_follows) as total_follows
FROM music_tracks mt
WHERE mt.status = 'complete'
");
$stmt->execute();
$community_stats = $stmt->fetch();
} catch (Exception $e) {
// Fallback stats if query fails
$community_stats = [
'total_tracks' => count($recent_tracks),
'total_artists' => count(array_unique(array_column($recent_tracks, 'artist_name'))),
'total_duration' => 0,
'total_likes' => 0,
'total_comments' => 0,
'total_follows' => 0
];
}
// Set page variables for header
$page_title = 'Community - SoundStudioPro';
$page_description = 'Explore the latest AI-generated music from our community. Discover amazing tracks from talented creators.';
$current_page = 'community';
?>
<div class="container" id="pageContainer">
<div class="main-content">
<style>
/* Main Content */
.main-content {
margin-top: 0;
padding: 4rem 0;
min-height: calc(100vh - 100px);
}
/* Hero Section */
.hero {
padding: 8rem 0 6rem;
text-align: center;
color: white;
background: linear-gradient(135deg, #0a0a0a 0%, #1a1a1a 50%, #0a0a0a 100%);
position: relative;
overflow: hidden;
margin-bottom: 4rem;
}
.hero::before {
content: '';
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
background: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><defs><pattern id="grid" width="10" height="10" patternUnits="userSpaceOnUse"><path d="M 10 0 L 0 0 0 10" fill="none" stroke="rgba(102,126,234,0.1)" stroke-width="0.5"/></pattern></defs><rect width="100" height="100" fill="url(%23grid)"/></svg>');
opacity: 0.3;
}
.hero-content {
max-width: 90rem;
margin: 0 auto;
position: relative;
z-index: 2;
}
.hero-badge {
display: inline-block;
background: linear-gradient(135deg, rgba(102, 126, 234, 0.2), rgba(118, 75, 162, 0.2));
color: #667eea;
padding: 1.2rem 2.4rem;
border-radius: 50px;
font-size: 1.4rem;
font-weight: 600;
margin-bottom: 3rem;
backdrop-filter: blur(10px);
border: 1px solid rgba(102, 126, 234, 0.3);
}
.hero-title {
font-size: 5.6rem;
font-weight: 900;
line-height: 1.1;
margin-bottom: 2.4rem;
background: linear-gradient(135deg, #ffffff, #667eea, #764ba2);
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
background-clip: text;
}
.hero-subtitle {
font-size: 2rem;
font-weight: 400;
margin-bottom: 4rem;
opacity: 0.9;
max-width: 70rem;
margin-left: auto;
margin-right: auto;
color: #a0aec0;
}
/* Community Content */
.community-content {
background: linear-gradient(135deg, #1a1a1a 0%, #2d2d2d 100%);
padding: 6rem 0;
border-radius: 40px 40px 0 0;
margin-top: -2rem;
position: relative;
z-index: 10;
}
.community-container {
max-width: 120rem;
margin: 0 auto;
}
/* Community Stats */
.community-stats {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
gap: 3rem;
margin-bottom: 6rem;
}
.stat-card {
background: rgba(255, 255, 255, 0.05);
padding: 3rem;
border-radius: 20px;
backdrop-filter: blur(20px);
border: 1px solid rgba(255, 255, 255, 0.1);
text-align: center;
transition: all 0.3s ease;
}
.stat-card:hover {
transform: translateY(-5px);
border-color: rgba(102, 126, 234, 0.3);
box-shadow: 0 20px 60px rgba(102, 126, 234, 0.1);
}
.stat-number {
font-size: 4.8rem;
font-weight: 900;
color: #667eea;
margin-bottom: 1rem;
}
.stat-label {
color: #a0aec0;
font-size: 1.8rem;
font-weight: 500;
}
/* Tracks Section */
.tracks-section {
margin-bottom: 6rem;
}
.section-header {
text-align: center;
margin-bottom: 4rem;
}
.section-title {
font-size: 4.8rem;
font-weight: 700;
color: white;
margin-bottom: 1.5rem;
}
.section-subtitle {
font-size: 2rem;
color: #a0aec0;
}
.tracks-grid {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(400px, 1fr));
gap: 3rem;
}
.track-card {
background: rgba(255, 255, 255, 0.05);
padding: 3rem;
border-radius: 20px;
backdrop-filter: blur(20px);
border: 1px solid rgba(255, 255, 255, 0.1);
transition: all 0.3s ease;
}
.track-card:hover {
transform: translateY(-5px);
border-color: rgba(102, 126, 234, 0.3);
box-shadow: 0 20px 60px rgba(102, 126, 234, 0.1);
}
.track-header {
display: flex;
justify-content: space-between;
align-items: flex-start;
margin-bottom: 2rem;
}
.track-title {
font-size: 2rem;
font-weight: 700;
color: white;
margin-bottom: 0.5rem;
}
.track-artist {
font-size: 1.4rem;
color: #667eea;
font-weight: 500;
}
.track-prompt {
font-size: 1.4rem;
color: #a0aec0;
line-height: 1.6;
margin-bottom: 2rem;
background: rgba(255, 255, 255, 0.05);
padding: 1.5rem;
border-radius: 12px;
}
.track-details {
display: flex;
gap: 2rem;
margin-bottom: 2rem;
font-size: 1.2rem;
color: #a0aec0;
}
.track-details span {
display: flex;
align-items: center;
gap: 0.5rem;
}
.track-actions {
display: flex;
gap: 1rem;
flex-wrap: wrap;
}
.btn {
padding: 1rem 2rem;
border: none;
border-radius: 12px;
font-size: 1.4rem;
font-weight: 600;
cursor: pointer;
transition: all 0.3s ease;
text-decoration: none;
display: inline-flex;
align-items: center;
gap: 0.8rem;
}
.btn-primary {
background: linear-gradient(135deg, #667eea, #764ba2);
color: white;
}
.btn-secondary {
background: rgba(255, 255, 255, 0.1);
color: white;
border: 1px solid rgba(255, 255, 255, 0.2);
}
.btn:hover {
transform: translateY(-2px);
box-shadow: 0 10px 30px rgba(102, 126, 234, 0.3);
}
/* Social Actions */
.social-actions {
display: flex;
gap: 1rem;
margin-top: 2rem;
padding-top: 2rem;
border-top: 1px solid rgba(255, 255, 255, 0.1);
}
.social-btn {
background: rgba(255, 255, 255, 0.05);
border: 1px solid rgba(255, 255, 255, 0.1);
color: #a0aec0;
padding: 0.8rem 1.5rem;
border-radius: 8px;
font-size: 1.2rem;
cursor: pointer;
transition: all 0.3s ease;
display: flex;
align-items: center;
gap: 0.5rem;
}
.social-btn:hover {
background: rgba(255, 255, 255, 0.1);
color: white;
}
.social-btn.liked {
background: rgba(239, 68, 68, 0.2);
border-color: rgba(239, 68, 68, 0.3);
color: #ef4444;
}
.social-btn.following {
background: rgba(34, 197, 94, 0.2);
border-color: rgba(34, 197, 94, 0.3);
color: #22c55e;
}
.social-count {
font-size: 1.2rem;
font-weight: 600;
}
/* Empty State */
.empty-state {
text-align: center;
padding: 4rem;
grid-column: 1 / -1;
}
.empty-icon {
font-size: 6rem;
margin-bottom: 2rem;
}
.empty-title {
font-size: 2.4rem;
color: white;
margin-bottom: 1rem;
}
.empty-description {
font-size: 1.6rem;
color: #a0aec0;
margin-bottom: 3rem;
}
/* Responsive */
@media (max-width: 768px) {
.hero-title {
font-size: 4rem;
}
.hero-subtitle {
font-size: 1.6rem;
}
.section-title {
font-size: 3.2rem;
}
.section-subtitle {
font-size: 1.4rem;
}
.community-stats {
grid-template-columns: repeat(2, 1fr);
gap: 2rem;
}
.stat-card {
padding: 2rem 1.5rem;
}
.stat-number {
font-size: 2.8rem;
}
.stat-label {
font-size: 1.2rem;
}
.tracks-grid {
grid-template-columns: 1fr;
gap: 2rem;
}
.track-card {
padding: 2rem;
}
.track-title {
font-size: 2rem;
}
.track-artist {
font-size: 1.4rem;
}
.track-prompt {
font-size: 1.4rem;
line-height: 1.5;
}
.track-details {
flex-wrap: wrap;
gap: 1rem;
}
.track-details span {
font-size: 1.2rem;
}
.track-actions {
flex-direction: column;
gap: 1rem;
}
.track-actions .btn {
width: 100%;
justify-content: center;
padding: 1.2rem 2rem;
font-size: 1.4rem;
}
.social-actions {
flex-wrap: wrap;
gap: 1rem;
justify-content: center;
}
.social-btn {
padding: 1rem 1.5rem;
font-size: 1.2rem;
}
.social-count {
font-size: 1.2rem;
}
.container {
padding: 0 1.5rem;
}
.community-content {
padding: 4rem 0;
}
}
@media (max-width: 480px) {
.hero-title {
font-size: 3.2rem;
}
.hero-subtitle {
font-size: 1.4rem;
}
.section-title {
font-size: 2.8rem;
}
.community-stats {
grid-template-columns: 1fr;
gap: 1.5rem;
}
.stat-card {
padding: 1.5rem;
}
.stat-number {
font-size: 2.4rem;
}
.track-card {
padding: 1.5rem;
}
.track-title {
font-size: 1.8rem;
}
.track-artist {
font-size: 1.2rem;
}
.track-prompt {
font-size: 1.3rem;
}
.track-actions .btn {
padding: 1rem 1.5rem;
font-size: 1.3rem;
}
.social-btn {
padding: 0.8rem 1.2rem;
font-size: 1.1rem;
}
.container {
padding: 0 1rem;
}
.community-content {
padding: 3rem 0;
}
}
</style>
<!-- Hero Section -->
<section class="hero">
<div class="container">
<div class="hero-content">
<div class="hero-badge">🌍 Community</div>
<h1 class="hero-title">Discover Amazing AI Music</h1>
<p class="hero-subtitle">Explore the latest tracks from our creative community. Get inspired by AI-generated music from talented artists around the world.</p>
</div>
</div>
</section>
<!-- Community Content -->
<section class="community-content">
<div class="container">
<div class="community-container">
<!-- Community Stats -->
<div class="community-stats">
<div class="stat-card">
<div class="stat-number"><?= $community_stats['total_tracks'] ?? count($recent_tracks) ?></div>
<div class="stat-label">Total Tracks</div>
</div>
<div class="stat-card">
<div class="stat-number"><?= $community_stats['total_artists'] ?? count(array_unique(array_column($recent_tracks, 'artist_name'))) ?></div>
<div class="stat-label">Active Artists</div>
</div>
<div class="stat-card">
<div class="stat-number"><?= $community_stats['total_likes'] ?? 0 ?></div>
<div class="stat-label">Total Likes</div>
</div>
<div class="stat-card">
<div class="stat-number"><?= $community_stats['total_follows'] ?? 0 ?></div>
<div class="stat-label">Total Follows</div>
</div>
</div>
<!-- Recent Tracks -->
<div class="tracks-section">
<div class="section-header">
<h2 class="section-title">Latest Community Tracks</h2>
<p class="section-subtitle">Fresh AI-generated music from our talented community</p>
</div>
<div class="tracks-grid">
<?php if (empty($recent_tracks)): ?>
<div class="empty-state">
<div class="empty-icon">🎵</div>
<h3 class="empty-title">No tracks yet</h3>
<p class="empty-description">Be the first to create amazing AI music for the community!</p>
<a href="/#create" class="btn btn-primary">
<i class="fas fa-plus"></i> Create Your First Track
</a>
</div>
<?php else: ?>
<?php foreach ($recent_tracks as $track): ?>
<div class="track-card">
<div class="track-header">
<div>
<div class="track-title"><?= htmlspecialchars($track['title']) ?></div>
<div class="track-artist">by <?= htmlspecialchars($track['artist_name']) ?></div>
</div>
</div>
<div class="track-prompt"><?= htmlspecialchars(substr($track['prompt'], 0, 100)) ?>...</div>
<div class="track-details">
<span><i class="fas fa-clock"></i> <?= $track['duration'] ?>s</span>
<span><i class="fas fa-calendar"></i> <?= date('M j, Y', strtotime($track['created_at'])) ?></span>
</div>
<div class="track-actions">
<button class="btn btn-primary" onclick="playTrack('<?= htmlspecialchars($track['audio_url']) ?>', '<?= htmlspecialchars($track['title']) ?>', '<?= htmlspecialchars($track['artist_name']) ?>')">
<i class="fas fa-play"></i> Play
</button>
<a href="/artist_profile.php?id=<?= $track['user_id'] ?>" class="btn btn-secondary">
<i class="fas fa-user"></i> View Artist
</a>
</div>
<!-- Social Actions -->
<div class="social-actions">
<button class="social-btn <?= $track['user_liked'] ? 'liked' : '' ?>" onclick="toggleLike(<?= $track['id'] ?>, this)">
<i class="fas fa-heart"></i>
<span class="social-count"><?= $track['like_count'] ?></span>
</button>
<button class="social-btn" onclick="showComments(<?= $track['id'] ?>)">
<i class="fas fa-comment"></i>
<span class="social-count"><?= $track['comment_count'] ?></span>
</button>
<?php if ($user_id && $user_id != $track['user_id']): ?>
<button class="social-btn <?= $track['is_following'] ? 'following' : '' ?>" onclick="toggleFollow(<?= $track['user_id'] ?>, this)">
<i class="fas fa-user-plus"></i>
<span><?= $track['is_following'] ? 'Following' : 'Follow' ?></span>
</button>
<?php endif; ?>
</div>
</div>
<?php endforeach; ?>
<?php endif; ?>
</div>
</div>
</div>
</div>
</section>
<script>
// Community page functionality using global player
// Check if global player is loaded
window.addEventListener('load', function() {
console.log('🎵 Community page loaded');
console.log('🎵 Global player status:', typeof window.globalPlayer !== 'undefined');
console.log('🎵 Global player element exists:', !!document.getElementById('globalMusicPlayer'));
if (typeof window.globalPlayer === 'undefined') {
console.error('🎵 Global player not loaded!');
// Try to manually initialize if not loaded
setTimeout(() => {
if (typeof window.globalPlayer !== 'undefined') {
console.log('🎵 Global player loaded after delay');
} else {
console.error('🎵 Global player still not available after delay');
}
}, 1000);
} else {
console.log('🎵 Global player loaded successfully');
// Force show the player
window.globalPlayer.showPlayer();
// Test the global player with a simple track
setTimeout(() => {
console.log('🎵 Testing global player with sample track...');
if (typeof window.globalPlayer.playTrack === 'function') {
console.log('🎵 Global player playTrack function exists');
} else {
console.error('🎵 Global player playTrack function missing!');
}
}, 2000);
}
});
// Social Functions
function toggleLike(trackId, button) {
if (!<?= $user_id ? 'true' : 'false' ?>) {
alert('Please log in to like tracks');
return;
}
fetch('/api_social.php', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ action: 'like', track_id: trackId })
})
.then(response => response.json())
.then(data => {
if (data.success) {
button.classList.toggle('liked');
const countSpan = button.querySelector('.social-count');
const currentCount = parseInt(countSpan.textContent);
countSpan.textContent = button.classList.contains('liked') ? currentCount + 1 : currentCount - 1;
}
});
}
function toggleFollow(userId, button) {
if (!<?= $user_id ? 'true' : 'false' ?>) {
alert('Please log in to follow users');
return;
}
fetch('/api_social.php', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ action: 'follow', user_id: userId })
})
.then(response => response.json())
.then(data => {
if (data.success) {
button.classList.toggle('following');
const span = button.querySelector('span');
span.textContent = button.classList.contains('following') ? 'Following' : 'Follow';
}
});
}
function showComments(trackId) {
// TODO: Implement comments modal
alert('Comments feature coming soon!');
}
// Use global player for track playback
async function playTrack(audioUrl, title, artist) {
console.log('🎵 Community playTrack called:', { audioUrl, title, artist });
// Use the global player function
const success = await window.playTrackWithGlobalPlayer(audioUrl, title, artist);
if (!success) {
console.error('🎵 Global player failed, showing error message');
alert(`Failed to play: ${title} by ${artist}. Please try again.`);
}
}
</script>
</div>
</div>
<?php
// Include footer only for full page loads
if (!$is_ajax) {
include 'includes/footer.php';
}
?>