![]() 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/ |
<?php
require_once 'config/database.php';
// Get track ID from URL
$track_id = $_GET['track'] ?? null;
if (!$track_id) {
// Return default image
header('Location: /assets/images/og-default.png');
exit;
}
// Get track information
$pdo = getDBConnection();
$stmt = $pdo->prepare("
SELECT mt.title, mt.prompt, u.name as artist_name
FROM music_tracks mt
JOIN users u ON mt.user_id = u.id
WHERE mt.id = ? AND mt.status = 'complete'
");
$stmt->execute([$track_id]);
$track = $stmt->fetch();
if (!$track) {
header('Location: /assets/images/og-default.png');
exit;
}
// Set content type
header('Content-Type: image/png');
// Create image (1200x630 for Open Graph)
$width = 1200;
$height = 630;
$image = imagecreatetruecolor($width, $height);
// Define colors
$bg_color = imagecolorallocate($image, 26, 35, 126); // Deep purple gradient start
$bg_color2 = imagecolorallocate($image, 118, 75, 162); // Deep purple gradient end
$white = imagecolorallocate($image, 255, 255, 255);
$light_blue = imagecolorallocate($image, 102, 126, 234);
$semi_transparent = imagecolorallocatealpha($image, 255, 255, 255, 100);
// Create gradient background
for ($y = 0; $y < $height; $y++) {
$ratio = $y / $height;
$r = round(26 + (118 - 26) * $ratio);
$g = round(35 + (75 - 35) * $ratio);
$b = round(126 + (162 - 126) * $ratio);
$color = imagecolorallocate($image, $r, $g, $b);
imageline($image, 0, $y, $width, $y, $color);
}
// Add SoundStudioPro logo/text at top
$font_path = __DIR__ . '/assets/fonts/Inter-Bold.ttf';
if (!file_exists($font_path)) {
// Fallback to built-in font if custom font not available
imagestring($image, 5, 50, 30, 'SoundStudioPro', $white);
} else {
imagettftext($image, 24, 0, 50, 60, $white, $font_path, 'SoundStudioPro');
}
// Generate waveform visualization
$waveform_y = 250;
$waveform_height = 180;
$bar_width = 8;
$bar_spacing = 4;
$num_bars = floor($width / ($bar_width + $bar_spacing));
for ($i = 0; $i < $num_bars; $i++) {
$x = $i * ($bar_width + $bar_spacing) + 50;
// Generate pseudo-random height based on track title for consistency
$seed = abs(crc32($track['title'] . $i)) % 100;
$bar_height = ($seed / 100) * $waveform_height;
// Add some variation
$bar_height = max(10, $bar_height + sin($i * 0.1) * 20);
$y1 = $waveform_y + ($waveform_height - $bar_height) / 2;
$y2 = $y1 + $bar_height;
// Create gradient effect on bars
if ($i < $num_bars * 0.3) {
$bar_color = $light_blue;
} else {
$bar_color = $semi_transparent;
}
imagefilledrectangle($image, $x, $y1, $x + $bar_width, $y2, $bar_color);
}
// Add track title
$title = $track['title'];
if (strlen($title) > 40) {
$title = substr($title, 0, 37) . '...';
}
if (file_exists($font_path)) {
imagettftext($image, 32, 0, 50, 480, $white, $font_path, $title);
} else {
imagestring($image, 5, 50, 460, $title, $white);
}
// Add artist name
$artist = "by " . $track['artist_name'];
if (file_exists($font_path)) {
imagettftext($image, 20, 0, 50, 520, $semi_transparent, $font_path, $artist);
} else {
imagestring($image, 4, 50, 500, $artist, $semi_transparent);
}
// Add prompt/description
$prompt = $track['prompt'];
if (strlen($prompt) > 80) {
$prompt = substr($prompt, 0, 77) . '...';
}
if (file_exists($font_path)) {
imagettftext($image, 16, 0, 50, 560, $semi_transparent, $font_path, $prompt);
} else {
imagestring($image, 3, 50, 540, $prompt, $semi_transparent);
}
// Add play icon
$play_size = 60;
$play_x = $width - 150;
$play_y = $height - 120;
// Create play triangle
$triangle = array(
$play_x, $play_y,
$play_x, $play_y + $play_size,
$play_x + $play_size * 0.8, $play_y + $play_size / 2
);
imagefilledpolygon($image, $triangle, 3, $white);
// Add circular background for play button
imagefilledellipse($image, $play_x + 20, $play_y + 30, $play_size + 20, $play_size + 20, $light_blue);
imagefilledpolygon($image, $triangle, 3, $white);
// Output the image
imagepng($image);
imagedestroy($image);
?>