![]() 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/private_html/ |
<?php
session_start();
require_once 'config/database.php';
// Only allow admin to run this
if (!isset($_SESSION['user_id']) || !isset($_SESSION['is_admin']) || !$_SESSION['is_admin']) {
die('Access denied. Admin only.');
}
$pdo = getDBConnection();
echo "<h1>🎵 Generating Sample Chart Data</h1>";
try {
// Get existing tracks
$stmt = $pdo->prepare("
SELECT
mt.id,
mt.title,
mt.audio_url,
mt.duration,
mt.created_at,
mt.metadata,
u.name as artist_name,
u.profile_image
FROM music_tracks mt
JOIN users u ON mt.user_id = u.id
WHERE mt.status = 'complete'
AND mt.audio_url IS NOT NULL
AND mt.audio_url != ''
ORDER BY mt.created_at DESC
LIMIT 50
");
$stmt->execute();
$tracks = $stmt->fetchAll();
echo "<p>Found " . count($tracks) . " tracks to generate data for.</p>";
// Generate sample data for each track
foreach ($tracks as $index => $track) {
// Generate realistic engagement data based on track age and position
$days_old = max(1, (time() - strtotime($track['created_at'])) / 86400);
$base_multiplier = max(1, 50 - $index); // Newer tracks get more engagement
// Generate likes (0-500 range)
$likes = rand(0, 50) * $base_multiplier;
// Generate plays (likes * 3-10 range)
$plays = $likes * rand(3, 10);
// Generate comments (likes * 0.1-0.3 range)
$comments = max(0, floor($likes * (rand(10, 30) / 100)));
// Generate shares (likes * 0.05-0.15 range)
$shares = max(0, floor($likes * (rand(5, 15) / 100)));
// Generate views (plays * 2-5 range)
$views = $plays * rand(2, 5);
// Insert sample likes
for ($i = 0; $i < $likes; $i++) {
$user_id = rand(1, 10); // Random user IDs
$created_at = date('Y-m-d H:i:s', time() - rand(0, $days_old * 86400));
$stmt = $pdo->prepare("
INSERT IGNORE INTO track_likes (user_id, track_id, created_at)
VALUES (?, ?, ?)
");
$stmt->execute([$user_id, $track['id'], $created_at]);
}
// Insert sample plays
for ($i = 0; $i < $plays; $i++) {
$user_id = rand(1, 20); // Some plays are anonymous
$created_at = date('Y-m-d H:i:s', time() - rand(0, $days_old * 86400));
$stmt = $pdo->prepare("
INSERT IGNORE INTO track_plays (track_id, user_id, created_at)
VALUES (?, ?, ?)
");
$stmt->execute([$track['id'], $user_id, $created_at]);
}
// Insert sample comments
$sample_comments = [
"Amazing track! 🔥",
"Love this vibe!",
"Great production!",
"This is fire!",
"Awesome work!",
"Incredible!",
"Love it!",
"Fantastic!",
"Brilliant!",
"Outstanding!"
];
for ($i = 0; $i < $comments; $i++) {
$user_id = rand(1, 10);
$comment = $sample_comments[array_rand($sample_comments)];
$created_at = date('Y-m-d H:i:s', time() - rand(0, $days_old * 86400));
$stmt = $pdo->prepare("
INSERT IGNORE INTO track_comments (user_id, track_id, comment, created_at)
VALUES (?, ?, ?, ?)
");
$stmt->execute([$user_id, $track['id'], $comment, $created_at]);
}
// Insert sample shares
for ($i = 0; $i < $shares; $i++) {
$user_id = rand(1, 10);
$created_at = date('Y-m-d H:i:s', time() - rand(0, $days_old * 86400));
$stmt = $pdo->prepare("
INSERT IGNORE INTO track_shares (track_id, user_id, created_at)
VALUES (?, ?, ?)
");
$stmt->execute([$track['id'], $user_id, $created_at]);
}
// Insert sample views
for ($i = 0; $i < $views; $i++) {
$user_id = rand(1, 15);
$created_at = date('Y-m-d H:i:s', time() - rand(0, $days_old * 86400));
$stmt = $pdo->prepare("
INSERT IGNORE INTO track_views (track_id, user_id, created_at)
VALUES (?, ?, ?)
");
$stmt->execute([$track['id'], $user_id, $created_at]);
}
echo "<p>✅ Generated data for track #{$track['id']}: {$likes} likes, {$plays} plays, {$comments} comments, {$shares} shares, {$views} views</p>";
}
echo "<h2>🎉 Chart data generation complete!</h2>";
echo "<p>Your charts page should now display realistic engagement data.</p>";
echo "<p><a href='/charts.php' style='color: #667eea; text-decoration: none;'>View Charts →</a></p>";
} catch (Exception $e) {
echo "<p style='color: red;'>Error: " . $e->getMessage() . "</p>";
}
?>
<style>
body {
font-family: 'Inter', sans-serif;
background: #0a0a0a;
color: white;
padding: 2rem;
line-height: 1.6;
}
h1 {
color: #667eea;
margin-bottom: 2rem;
}
h2 {
color: #764ba2;
margin-top: 2rem;
}
p {
margin: 0.5rem 0;
}
a {
color: #667eea;
text-decoration: none;
}
a:hover {
text-decoration: underline;
}
</style>