![]() 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
// First, check if a custom OG image exists - use it directly if found
// Use the most reliable path method first
$base_path = __DIR__;
$image_path = $base_path . '/assets/images/og-image.png';
// Try realpath first (resolves symlinks and gives absolute path)
$resolved_path = realpath($image_path);
if ($resolved_path && is_file($resolved_path) && is_readable($resolved_path)) {
$custom_og_image = $resolved_path;
} elseif (file_exists($image_path) && is_readable($image_path)) {
// Fallback to direct path if realpath fails
$custom_og_image = $image_path;
} else {
// Last resort: try document root
if (isset($_SERVER['DOCUMENT_ROOT']) && $_SERVER['DOCUMENT_ROOT']) {
$doc_root_path = rtrim($_SERVER['DOCUMENT_ROOT'], '/\\') . '/assets/images/og-image.png';
if (file_exists($doc_root_path) && is_readable($doc_root_path)) {
$custom_og_image = $doc_root_path;
}
}
}
if ($custom_og_image) {
// Use the custom image directly - optimized for Facebook scraper
$file_size = filesize($custom_og_image);
// Clear any output buffers completely
while (ob_get_level()) {
ob_end_clean();
}
// Get image dimensions for proper headers
$image_info = @getimagesize($custom_og_image);
if ($image_info) {
$image_width = $image_info[0];
$image_height = $image_info[1];
} else {
$image_width = 1536;
$image_height = 1024;
}
// Facebook requires these specific headers - send them before any output
header('HTTP/1.1 200 OK');
header('Content-Type: image/png');
header('Content-Length: ' . $file_size);
header('Accept-Ranges: bytes');
header('Cache-Control: public, max-age=86400, immutable');
header('Last-Modified: ' . gmdate('D, d M Y H:i:s', filemtime($custom_og_image)) . ' GMT');
header('Expires: ' . gmdate('D, d M Y H:i:s', time() + 86400) . ' GMT');
header('ETag: "' . md5_file($custom_og_image) . '"');
header('X-Content-Type-Options: nosniff');
// Handle If-None-Match for caching
if (isset($_SERVER['HTTP_IF_NONE_MATCH'])) {
$etag = '"' . md5_file($custom_og_image) . '"';
if (trim($_SERVER['HTTP_IF_NONE_MATCH']) === $etag) {
header('HTTP/1.1 304 Not Modified');
exit;
}
}
// Handle If-Modified-Since
if (isset($_SERVER['HTTP_IF_MODIFIED_SINCE'])) {
$if_modified_since = strtotime($_SERVER['HTTP_IF_MODIFIED_SINCE']);
$file_mtime = filemtime($custom_og_image);
if ($if_modified_since >= $file_mtime) {
header('HTTP/1.1 304 Not Modified');
exit;
}
}
// Output the file directly
@readfile($custom_og_image);
exit;
}
// Fallback: Generate image dynamically if custom image doesn't exist
// Check if GD extension is available
if (!extension_loaded('gd')) {
header('Location: /create_simple_image.php');
exit;
}
// Set content type to PNG
header('Content-Type: image/png');
// Create image with optimal OG dimensions
$width = 1200;
$height = 630;
$image = imagecreatetruecolor($width, $height);
// Enable alpha blending
imagealphablending($image, true);
imagesavealpha($image, true);
// Brand colors from main.css
$primary_blue = [102, 126, 234]; // #667eea
$secondary_purple = [118, 75, 162]; // #764ba2
$accent_blue = [79, 172, 254]; // #4facfe
$bg_dark = [10, 10, 10]; // #0a0a0a
// Create gradient background (smooth horizontal gradient from left to right)
for ($y = 0; $y < $height; $y++) {
for ($x = 0; $x < $width; $x++) {
// Calculate gradient position (0 to 1) from left to right
$ratio = $x / $width;
// Blend from deep indigo/dark blue to purplish-blue
// Deep indigo: approximately RGB(20, 25, 60)
// Purplish-blue: approximately RGB(40, 50, 120)
$r = round(20 + (40 - 20) * $ratio);
$g = round(25 + (50 - 25) * $ratio);
$b = round(60 + (120 - 60) * $ratio);
$color = imagecolorallocate($image, $r, $g, $b);
imagesetpixel($image, $x, $y, $color);
}
}
// Add subtle light blue dots scattered across background (like stars)
$dot_color = imagecolorallocatealpha($image, 79, 172, 254, 80); // Light blue with transparency
$num_dots = 50; // Number of dots to scatter
for ($i = 0; $i < $num_dots; $i++) {
$dot_x = rand(0, $width);
$dot_y = rand(0, $height);
$dot_size = rand(2, 5); // Random size between 2-5 pixels
imagefilledellipse($image, $dot_x, $dot_y, $dot_size, $dot_size, $dot_color);
}
// Define colors for text
$text_white = imagecolorallocate($image, 255, 255, 255);
$text_accent = imagecolorallocate($image, $accent_blue[0], $accent_blue[1], $accent_blue[2]);
$text_secondary = imagecolorallocate($image, 160, 174, 192); // #a0aec0
// Load and place the actual logo (which includes icon + text + tagline)
$logo_path = 'assets/images/logo.png';
$logo = null;
$logo_width = 0;
$logo_height = 0;
$logo_loaded = false; // Track if logo was successfully loaded
if (file_exists($logo_path)) {
// Try to load as PNG first
$logo = @imagecreatefrompng($logo_path);
if (!$logo) {
// Try JPEG if PNG fails
$logo = @imagecreatefromjpeg($logo_path);
}
if (!$logo) {
// Try GIF if GIF fails
$logo = @imagecreatefromgif($logo_path);
}
if ($logo) {
$logo_width = imagesx($logo);
$logo_height = imagesy($logo);
// Calculate logo size to fit nicely (max 400px width or 300px height, maintain aspect ratio)
$max_logo_width = 600;
$max_logo_height = 400;
$width_scale = $max_logo_width / $logo_width;
$height_scale = $max_logo_height / $logo_height;
$logo_scale = min($width_scale, $height_scale, 1.0); // Don't upscale
$scaled_logo_width = (int)($logo_width * $logo_scale);
$scaled_logo_height = (int)($logo_height * $logo_scale);
// Position logo centered horizontally, vertically centered
$logo_x = (int)(($width - $scaled_logo_width) / 2);
$logo_y = (int)(($height - $scaled_logo_height) / 2);
// Resize and copy logo to main image with transparency support
$resized_logo = imagecreatetruecolor($scaled_logo_width, $scaled_logo_height);
imagealphablending($resized_logo, false);
imagesavealpha($resized_logo, true);
// Fill with transparent background
$transparent = imagecolorallocatealpha($resized_logo, 0, 0, 0, 127);
imagefill($resized_logo, 0, 0, $transparent);
imagealphablending($resized_logo, true);
imagecopyresampled($resized_logo, $logo, 0, 0, 0, 0, $scaled_logo_width, $scaled_logo_height, $logo_width, $logo_height);
// Copy resized logo onto main image with alpha blending
imagealphablending($image, true);
imagecopy($image, $resized_logo, $logo_x, $logo_y, 0, 0, $scaled_logo_width, $scaled_logo_height);
imagedestroy($resized_logo);
imagedestroy($logo);
$logo_loaded = true; // Mark logo as successfully loaded
} else {
// Fallback: logo file exists but couldn't be loaded
$title_x = 80;
$title_y = 180;
}
} else {
// Fallback: logo file doesn't exist
$title_x = 80;
$title_y = 180;
}
// Only add text if logo wasn't loaded
if (!$logo_loaded) {
// Add main title
$title = "SoundStudioPro";
// Check if we can use TTF fonts
$font_path = 'assets/fonts/Poppins-Bold.ttf';
if (function_exists('imagettftext') && file_exists($font_path)) {
// Use TTF font for beautiful typography
$font_size = 72;
// Add text shadow for better readability
$shadow_color = imagecolorallocatealpha($image, 0, 0, 0, 120);
imagettftext($image, $font_size, 0, $title_x + 3, $title_y + 3, $shadow_color, $font_path, $title);
// Main title
imagettftext($image, $font_size, 0, $title_x, $title_y, $text_white, $font_path, $title);
// Subtitle
$subtitle = "AI Music Creation Platform";
$subtitle_font_size = 42;
$subtitle_y = $title_y + 90;
imagettftext($image, $subtitle_font_size, 0, $title_x, $subtitle_y, $text_accent, $font_path, $subtitle);
// Tagline
$tagline = "Create Professional Music with AI";
$tagline_font_size = 32;
$tagline_y = $subtitle_y + 70;
imagettftext($image, $tagline_font_size, 0, $title_x, $tagline_y, $text_secondary, $font_path, $tagline);
// Key features (more concise)
$features = [
"🎵 Studio-Quality Audio Generation",
"🎧 Lyrics, Videos & Variations",
"🚀 Join Thousands of Creators"
];
$feature_y = $tagline_y + 90;
$feature_font_size = 26;
foreach ($features as $feature) {
imagettftext($image, $feature_font_size, 0, $title_x, $feature_y, $text_white, $font_path, $feature);
$feature_y += 55;
}
// Add website URL at bottom
$url = "soundstudiopro.com";
$url_x = $title_x;
$url_y = $height - 60;
$url_font_size = 20;
imagettftext($image, $url_font_size, 0, $url_x, $url_y, $text_accent, $font_path, $url);
} else {
// Fallback to basic fonts
$font_size = 5;
// Main title
imagestring($image, $font_size, $title_x, $title_y, $title, $text_white);
// Subtitle
$subtitle = "AI Music Creation Platform";
$subtitle_y = $title_y + 40;
imagestring($image, $font_size - 1, $title_x, $subtitle_y, $subtitle, $text_accent);
// Tagline
$tagline = "Create Professional Music with AI";
$tagline_y = $subtitle_y + 35;
imagestring($image, $font_size - 1, $title_x, $tagline_y, $tagline, $text_secondary);
// Features
$features = [
"Generate Original Tracks",
"Professional Quality Audio",
"50,000+ Creators Worldwide"
];
$feature_y = $tagline_y + 50;
foreach ($features as $feature) {
imagestring($image, 3, $title_x, $feature_y, $feature, $text_white);
$feature_y += 30;
}
// Add website URL
$url = "soundstudiopro.com";
$url_x = $title_x;
$url_y = $height - 40;
imagestring($image, 3, $url_x, $url_y, $url, $text_accent);
}
}
// Output the image
imagepng($image);
imagedestroy($image);
?>