![]() 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/-a0427ec/ |
<?php
session_start();
require_once 'config/database.php';
echo "<h1>๐งช Populating Test Data</h1>";
try {
$pdo = getDBConnection();
echo "<p>โ
Database connection successful</p>";
// Check if we have tracks and users
$stmt = $pdo->query("SELECT COUNT(*) as count FROM music_tracks WHERE is_public = 1");
$track_count = $stmt->fetch()['count'];
$stmt = $pdo->query("SELECT COUNT(*) as count FROM users");
$user_count = $stmt->fetch()['count'];
echo "<p>๐ต Public tracks: $track_count</p>";
echo "<p>๐ฅ Users: $user_count</p>";
if ($track_count == 0) {
echo "<p>โ No public tracks found. Creating test track...</p>";
// Create a test user if none exists
if ($user_count == 0) {
$stmt = $pdo->prepare("INSERT INTO users (name, email, password_hash, created_at) VALUES (?, ?, ?, NOW())");
$stmt->execute(['Test User', 'test@example.com', password_hash('password123', PASSWORD_DEFAULT)]);
echo "<p>โ
Test user created</p>";
}
// Get first user
$stmt = $pdo->query("SELECT id FROM users LIMIT 1");
$user = $stmt->fetch();
if ($user) {
// Create test track
$stmt = $pdo->prepare("INSERT INTO music_tracks (title, prompt, audio_url, duration, user_id, is_public, created_at) VALUES (?, ?, ?, ?, ?, 1, NOW())");
$stmt->execute([
'Test Track - Amazing AI Music',
'A beautiful AI-generated track for testing',
'/assets/audio/sample-track.mp3',
180,
$user['id']
]);
echo "<p>โ
Test track created</p>";
}
}
// Get track and user IDs for creating comments
$stmt = $pdo->query("SELECT id FROM music_tracks WHERE is_public = 1 LIMIT 1");
$track = $stmt->fetch();
$stmt = $pdo->query("SELECT id FROM users LIMIT 1");
$user = $stmt->fetch();
if ($track && $user) {
echo "<p>๐ง Creating test comments...</p>";
// Check if comments already exist
$stmt = $pdo->prepare("SELECT COUNT(*) as count FROM track_comments WHERE track_id = ?");
$stmt->execute([$track['id']]);
$existing_comments = $stmt->fetch()['count'];
if ($existing_comments == 0) {
// Create sample comments
$sample_comments = [
"This track is absolutely amazing! ๐ต",
"Love the AI-generated melody, so creative!",
"The production quality is incredible",
"Can't stop listening to this one!",
"Perfect for my playlist, thanks for sharing!",
"The beat is so catchy, great work!",
"This is exactly what I was looking for",
"AI music has come so far, this is proof!",
"Would love to hear more from this artist",
"The arrangement is spot on, great job!"
];
foreach ($sample_comments as $comment_text) {
$stmt = $pdo->prepare("INSERT INTO track_comments (track_id, user_id, comment, created_at) VALUES (?, ?, ?, NOW())");
$stmt->execute([$track['id'], $user['id'], $comment_text]);
}
echo "<p>โ
Created " . count($sample_comments) . " test comments</p>";
} else {
echo "<p>โน๏ธ Comments already exist ($existing_comments found)</p>";
}
// Create some likes
$stmt = $pdo->prepare("SELECT COUNT(*) as count FROM track_likes WHERE track_id = ?");
$stmt->execute([$track['id']]);
$existing_likes = $stmt->fetch()['count'];
if ($existing_likes == 0) {
// Create some likes
$stmt = $pdo->prepare("INSERT INTO track_likes (track_id, user_id, created_at) VALUES (?, ?, NOW())");
$stmt->execute([$track['id'], $user['id']]);
echo "<p>โ
Created test like</p>";
} else {
echo "<p>โน๏ธ Likes already exist ($existing_likes found)</p>";
}
// Create some plays
$stmt = $pdo->prepare("SELECT COUNT(*) as count FROM track_plays WHERE track_id = ?");
$stmt->execute([$track['id']]);
$existing_plays = $stmt->fetch()['count'];
if ($existing_plays == 0) {
// Create some plays
$stmt = $pdo->prepare("INSERT INTO track_plays (track_id, user_id, created_at) VALUES (?, ?, NOW())");
$stmt->execute([$track['id'], $user['id']]);
echo "<p>โ
Created test play record</p>";
} else {
echo "<p>โน๏ธ Plays already exist ($existing_plays found)</p>";
}
// Create some views
$stmt = $pdo->prepare("SELECT COUNT(*) as count FROM track_views WHERE track_id = ?");
$stmt->execute([$track['id']]);
$existing_views = $stmt->fetch()['count'];
if ($existing_views == 0) {
// Create some views
$stmt = $pdo->prepare("INSERT INTO track_views (track_id, user_id, created_at) VALUES (?, ?, NOW())");
$stmt->execute([$track['id'], $user['id']]);
echo "<p>โ
Created test view record</p>";
} else {
echo "<p>โน๏ธ Views already exist ($existing_views found)</p>";
}
} else {
echo "<p>โ Could not find track or user for creating test data</p>";
}
// Show final counts
echo "<h3>๐ Final Database Status:</h3>";
$stmt = $pdo->query("SELECT COUNT(*) as count FROM music_tracks WHERE is_public = 1");
$track_count = $stmt->fetch()['count'];
$stmt = $pdo->query("SELECT COUNT(*) as count FROM users");
$user_count = $stmt->fetch()['count'];
$stmt = $pdo->query("SELECT COUNT(*) as count FROM track_comments");
$comment_count = $stmt->fetch()['count'];
$stmt = $pdo->query("SELECT COUNT(*) as count FROM track_likes");
$like_count = $stmt->fetch()['count'];
$stmt = $pdo->query("SELECT COUNT(*) as count FROM track_plays");
$play_count = $stmt->fetch()['count'];
$stmt = $pdo->query("SELECT COUNT(*) as count FROM track_views");
$view_count = $stmt->fetch()['count'];
echo "<ul>";
echo "<li>๐ต Public Tracks: $track_count</li>";
echo "<li>๐ฅ Users: $user_count</li>";
echo "<li>๐ฌ Comments: $comment_count</li>";
echo "<li>โค๏ธ Likes: $like_count</li>";
echo "<li>โถ๏ธ Plays: $play_count</li>";
echo "<li>๐๏ธ Views: $view_count</li>";
echo "</ul>";
echo "<p>โ
Test data population complete!</p>";
} catch (Exception $e) {
echo "<p>โ Error: " . $e->getMessage() . "</p>";
echo "<p>Stack trace:</p>";
echo "<pre>" . $e->getTraceAsString() . "</pre>";
}
echo "<hr>";
echo "<h3>๐ Next Steps:</h3>";
echo "<ul>";
echo "<li><a href='debug_comments.php'>Debug Comments</a></li>";
echo "<li><a href='test_community_functions.php'>Test Community Functions</a></li>";
echo "<li><a href='community_clean.php'>Go to Community Page</a></li>";
echo "<li><a href='populate_test_data.php'>Refresh Test Data</a></li>";
echo "</ul>";
?>