![]() 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/4c77ac01/ |
<?php
// Email configuration for SoundStudioPro
// SMTP Configuration
// Production SMTP settings for soundstudiopro.com
define('SMTP_HOST', 'mail.soundstudiopro.com');
define('SMTP_PORT', 587);
define('SMTP_USERNAME', 'confirmation@soundstudiopro.com');
define('SMTP_PASSWORD', 'C3nGG9e5Dw7NRXuXLxwq');
define('SMTP_FROM_EMAIL', 'confirmation@soundstudiopro.com');
define('SMTP_FROM_NAME', 'SoundStudioPro');
// Email configuration - will fallback to mail() if PHPMailer not available
// Email configuration - will fallback to mail() if PHPMailer not available
// Email sending function using PHPMailer
function sendEmail($to_email, $to_name, $subject, $html_body, $text_body = null, $email_type = 'general', $user_id = null, $order_id = null) {
// Log email attempt to database
$pdo = getDBConnection();
$log_id = null;
if ($pdo) {
try {
$stmt = $pdo->prepare("
INSERT INTO email_logs (recipient_email, recipient_name, subject, email_type, status, user_id, order_id)
VALUES (?, ?, ?, ?, 'pending', ?, ?)
");
$stmt->execute([$to_email, $to_name, $subject, $email_type, $user_id, $order_id]);
$log_id = $pdo->lastInsertId();
} catch (Exception $e) {
error_log("Failed to log email to database: " . $e->getMessage());
}
}
// Check if PHPMailer is available
if (!class_exists('PHPMailer\PHPMailer\PHPMailer')) {
// Fallback to basic mail() function
$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=UTF-8" . "\r\n";
$headers .= "From: " . SMTP_FROM_NAME . " <" . SMTP_FROM_EMAIL . ">" . "\r\n";
$result = mail($to_email, $subject, $html_body, $headers);
// Update log with result
if ($pdo && $log_id) {
try {
$stmt = $pdo->prepare("
UPDATE email_logs SET status = ?, error_message = ? WHERE id = ?
");
$stmt->execute([$result ? 'sent' : 'failed', $result ? null : 'mail() function failed', $log_id]);
} catch (Exception $e) {
error_log("Failed to update email log: " . $e->getMessage());
}
}
return $result;
}
try {
$mail = new PHPMailer\PHPMailer\PHPMailer(true);
// Server settings
$mail->isSMTP();
$mail->Host = SMTP_HOST;
$mail->SMTPAuth = true;
$mail->Username = SMTP_USERNAME;
$mail->Password = SMTP_PASSWORD;
$mail->SMTPSecure = PHPMailer\PHPMailer\PHPMailer::ENCRYPTION_STARTTLS;
$mail->Port = SMTP_PORT;
// Recipients
$mail->setFrom(SMTP_FROM_EMAIL, SMTP_FROM_NAME);
$mail->addAddress($to_email, $to_name);
// Content
$mail->isHTML(true);
$mail->Subject = $subject;
$mail->Body = $html_body;
if ($text_body) {
$mail->AltBody = $text_body;
}
$mail->send();
error_log("Email sent successfully to: $to_email");
// Update log with success
if ($pdo && $log_id) {
try {
$stmt = $pdo->prepare("UPDATE email_logs SET status = 'sent' WHERE id = ?");
$stmt->execute([$log_id]);
} catch (Exception $e) {
error_log("Failed to update email log: " . $e->getMessage());
}
}
return true;
} catch (Exception $e) {
error_log("Email sending failed: " . $mail->ErrorInfo);
// Update log with failure
if ($pdo && $log_id) {
try {
$stmt = $pdo->prepare("
UPDATE email_logs SET status = 'failed', error_message = ? WHERE id = ?
");
$stmt->execute([$mail->ErrorInfo, $log_id]);
} catch (Exception $db_error) {
error_log("Failed to update email log: " . $db_error->getMessage());
}
}
return false;
}
}
// Generate order confirmation email
function generateOrderConfirmationEmail($user_name, $order_details, $billing_address) {
$order_number = 'SSP-' . date('Ymd') . '-' . strtoupper(substr(md5(uniqid()), 0, 8));
$order_date = date('F j, Y \a\t g:i A');
$total_amount = number_format($order_details['total_amount'] / 100, 2);
// Build order items HTML
$items_html = '';
foreach ($order_details['cart_summary'] as $item) {
if ($item['type'] === 'credit') {
$items_html .= '
<tr>
<td style="padding: 12px; border-bottom: 1px solid #e2e8f0;">' . htmlspecialchars($item['name']) . '</td>
<td style="padding: 12px; border-bottom: 1px solid #e2e8f0; text-align: center;">' . $item['quantity'] . '</td>
<td style="padding: 12px; border-bottom: 1px solid #e2e8f0; text-align: right;">$' . number_format($item['amount'] / 100, 2) . '</td>
</tr>';
} else {
$items_html .= '
<tr>
<td style="padding: 12px; border-bottom: 1px solid #e2e8f0;">' . htmlspecialchars($item['title']) . ' by ' . htmlspecialchars($item['artist']) . '</td>
<td style="padding: 12px; border-bottom: 1px solid #e2e8f0; text-align: center;">' . $item['quantity'] . '</td>
<td style="padding: 12px; border-bottom: 1px solid #e2e8f0; text-align: right;">$' . number_format($item['amount'] / 100, 2) . '</td>
</tr>';
}
}
$html = '
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Order Confirmation - SoundStudioPro</title>
<style>
body { font-family: Arial, sans-serif; line-height: 1.6; color: #333; }
.container { max-width: 600px; margin: 0 auto; padding: 20px; }
.header { background: linear-gradient(135deg, #667eea, #764ba2); color: white; padding: 30px; text-align: center; border-radius: 10px 10px 0 0; }
.content { background: #f8f9fa; padding: 30px; border-radius: 0 0 10px 10px; }
.order-number { background: #667eea; color: white; padding: 10px 20px; border-radius: 5px; display: inline-block; margin: 10px 0; }
.order-table { width: 100%; border-collapse: collapse; margin: 20px 0; }
.order-table th { background: #667eea; color: white; padding: 12px; text-align: left; }
.order-table td { padding: 12px; border-bottom: 1px solid #e2e8f0; }
.total-row { font-weight: bold; background: #f1f5f9; }
.billing-info { background: white; padding: 20px; border-radius: 8px; margin: 20px 0; border-left: 4px solid #667eea; }
.footer { text-align: center; margin-top: 30px; color: #666; font-size: 14px; }
.btn { display: inline-block; background: #667eea; color: white; padding: 12px 24px; text-decoration: none; border-radius: 5px; margin: 10px 5px; }
</style>
</head>
<body>
<div class="container">
<div class="header">
<h1>šµ SoundStudioPro</h1>
<h2>Order Confirmation</h2>
<div class="order-number">Order #' . $order_number . '</div>
<p>Thank you for your purchase!</p>
</div>
<div class="content">
<p>Dear ' . htmlspecialchars($user_name) . ',</p>
<p>Thank you for your order! We\'re excited to confirm that your payment has been processed successfully. Here are the details of your purchase:</p>
<h3>š Order Details</h3>
<table class="order-table">
<thead>
<tr>
<th>Item</th>
<th style="text-align: center;">Qty</th>
<th style="text-align: right;">Price</th>
</tr>
</thead>
<tbody>
' . $items_html . '
<tr class="total-row">
<td colspan="2" style="text-align: right; font-weight: bold;">Total:</td>
<td style="text-align: right; font-weight: bold;">$' . $total_amount . '</td>
</tr>
</tbody>
</table>
<div class="billing-info">
<h4>š Billing Information</h4>
<p><strong>Name:</strong> ' . htmlspecialchars($billing_address['billing_first_name'] . ' ' . $billing_address['billing_last_name']) . '</p>
<p><strong>Email:</strong> ' . htmlspecialchars($billing_address['billing_email']) . '</p>
<p><strong>Address:</strong><br>
' . htmlspecialchars($billing_address['billing_address']) . '<br>
' . htmlspecialchars($billing_address['billing_city']) . ', ' . htmlspecialchars($billing_address['billing_state']) . ' ' . htmlspecialchars($billing_address['billing_zip']) . '<br>
' . htmlspecialchars($billing_address['billing_country']) . '</p>
</div>
<h3>š What\'s Next?</h3>';
// Add specific next steps based on what was purchased
$has_credits = false;
$has_tracks = false;
foreach ($order_details['cart_summary'] as $item) {
if ($item['type'] === 'credit') $has_credits = true;
if ($item['type'] === 'track') $has_tracks = true;
}
if ($has_credits) {
$html .= '
<p><strong>šÆ Credits Added:</strong> Your credits have been automatically added to your account and are ready to use for creating music!</p>
<p>You can start creating amazing music right away by visiting your dashboard.</p>';
}
if ($has_tracks) {
$html .= '
<p><strong>šµ Tracks Purchased:</strong> Your purchased tracks are now available in your music library for download.</p>
<p>You can access them anytime from your account dashboard.</p>';
}
$html .= '
<div style="text-align: center; margin: 30px 0;">
<a href="https://soundstudiopro.com/dashboard.php" class="btn">Go to Dashboard</a>
<a href="https://soundstudiopro.com/credits.php" class="btn">View Credits</a>
</div>
<h3>š” Need Help?</h3>
<p>If you have any questions about your order or need assistance, please don\'t hesitate to contact our support team:</p>
<ul>
<li>š§ Email: support@soundstudiopro.com</li>
<li>š Website: <a href="https://soundstudiopro.com/support">soundstudiopro.com/support</a></li>
</ul>
<p><strong>Order Date:</strong> ' . $order_date . '</p>
<p><strong>Payment Method:</strong> Credit Card (Processed by Stripe)</p>
<div class="footer">
<p>Thank you for choosing SoundStudioPro!</p>
<p>Ā© ' . date('Y') . ' SoundStudioPro. All rights reserved.</p>
<p>This email was sent to ' . htmlspecialchars($billing_address['billing_email']) . '</p>
</div>
</div>
</div>
</body>
</html>';
return [
'html' => $html,
'text' => "Order Confirmation - SoundStudioPro\n\nDear $user_name,\n\nThank you for your order! Your payment has been processed successfully.\n\nOrder #$order_number\nOrder Date: $order_date\nTotal: \$$total_amount\n\nYour credits and tracks are now available in your account.\n\nVisit: https://soundstudiopro.com/dashboard.php\n\nThank you for choosing SoundStudioPro!",
'subject' => "Order Confirmation - SoundStudioPro (Order #$order_number)"
];
}
// Generate welcome email for new user registration
function generateWelcomeEmail($user_name, $user_email, $credits = 0, $password = null) {
$html = '
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Welcome to SoundStudioPro - Your Musical Journey Begins!</title>
<style>
body { font-family: Arial, sans-serif; line-height: 1.6; color: #333; margin: 0; padding: 0; }
.container { max-width: 600px; margin: 0 auto; background: #ffffff; }
.header { background: linear-gradient(135deg, #667eea, #764ba2); color: white; padding: 40px 30px; text-align: center; }
.welcome-badge { background: rgba(255, 255, 255, 0.2); padding: 15px 30px; border-radius: 25px; display: inline-block; margin: 20px 0; font-size: 18px; font-weight: bold; }
.content { padding: 40px 30px; background: #ffffff; }
.inspiration-box { background: linear-gradient(135deg, #f093fb, #f5576c); color: white; padding: 30px; border-radius: 15px; margin: 30px 0; text-align: center; }
.credits-box { background: linear-gradient(135deg, #4facfe, #00f2fe); color: white; padding: 25px; border-radius: 12px; margin: 25px 0; text-align: center; }
.feature-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin: 30px 0; }
.feature-item { background: #f8f9fa; padding: 20px; border-radius: 10px; text-align: center; border-left: 4px solid #667eea; }
.feature-item h4 { font-size: 16px !important; margin: 0 0 10px 0; color: #667eea; }
.feature-item p { font-size: 14px !important; margin: 0; line-height: 1.5; }
.btn { display: inline-block; background: linear-gradient(135deg, #667eea, #764ba2); color: white; padding: 15px 30px; text-decoration: none; border-radius: 25px; margin: 15px 10px; font-weight: bold; font-size: 16px; box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3); }
.btn:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4); }
.footer { background: #1a1a1a; color: #ffffff; padding: 30px; text-align: center; }
.social-links { margin: 20px 0; }
.social-links a { color: #667eea; margin: 0 10px; text-decoration: none; }
.quote { font-style: italic; font-size: 18px; margin: 20px 0; }
.highlight { background: linear-gradient(120deg, #a8edea 0%, #fed6e3 100%); padding: 2px 6px; border-radius: 4px; }
</style>
</head>
<body>
<div class="container">
<div class="header">
<h1 style="margin: 0 0 10px 0; font-size: 2.5rem;">šµ SoundStudioPro</h1>
<div class="welcome-badge">Welcome to the Family!</div>
<p style="font-size: 18px; margin: 0;">Your musical journey begins now</p>
</div>
<div class="content">
<h2 style="color: #667eea; text-align: center; margin-bottom: 30px;">Dear ' . htmlspecialchars($user_name) . ',</h2>
<div class="inspiration-box">
<h3 style="margin: 0 0 15px 0; font-size: 24px;">š Welcome to Your Creative Sanctuary</h3>
<p class="quote">"Music is the divine way to tell beautiful, poetic things to the heart."</p>
<p style="margin: 0; font-size: 16px;">You\'ve just joined a community of creators, dreamers, and music lovers. Your unique voice has a place here.</p>
</div>
<p style="font-size: 16px; line-height: 1.8;">We\'re <span class="highlight">thrilled</span> to have you as part of the SoundStudioPro family! You\'ve taken the first step towards turning your musical dreams into reality. Whether you\'re a seasoned producer or just starting your journey, you\'re now part of something extraordinary.</p>
<div class="credits-box">
<h3 style="margin: 0 0 10px 0;">š Your Welcome Gift</h3>
<p style="margin: 0; font-size: 18px;"><strong>' . $credits . ' Credits</strong> are waiting for you!</p>
<p style="margin: 10px 0 0 0; font-size: 14px;">Start creating your first masterpiece today</p>
</div>
' . ($password ? '
<div style="background: #f8f9fa; padding: 25px; border-radius: 12px; margin: 25px 0; border-left: 4px solid #22c55e; border: 2px solid #22c55e;">
<h4 style="color: #22c55e; margin: 0 0 15px 0; font-size: 18px;">š Your Login Credentials</h4>
<p style="margin: 0 0 15px 0; font-size: 16px; color: #333;">Please save these credentials in a secure location:</p>
<div style="background: white; padding: 20px; border-radius: 8px; border: 1px solid #e2e8f0;">
<div style="margin-bottom: 15px;">
<strong style="color: #667eea; font-size: 16px;">š Website:</strong>
<p style="margin: 5px 0 0 0; font-size: 16px; color: #333;">https://soundstudiopro.com</p>
</div>
<div style="margin-bottom: 15px;">
<strong style="color: #667eea; font-size: 16px;">š§ Email:</strong>
<p style="margin: 5px 0 0 0; font-size: 16px; color: #333; font-family: monospace;">' . htmlspecialchars($user_email) . '</p>
</div>
<div style="margin-bottom: 15px;">
<strong style="color: #667eea; font-size: 16px;">š Password:</strong>
<p style="margin: 5px 0 0 0; font-size: 16px; color: #333; font-family: monospace;">' . htmlspecialchars($password) . '</p>
</div>
</div>
<p style="margin: 15px 0 0 0; font-size: 14px; color: #666; font-style: italic;">š” Tip: Consider using a password manager for enhanced security</p>
</div>
' : '') . '
<h3 style="color: #667eea; text-align: center; margin: 30px 0;">š What Awaits You</h3>
<div class="feature-grid">
<div class="feature-item">
<h4 style="color: #667eea; margin: 0 0 10px 0; font-size: 16px;">š¼ AI-Powered Creation</h4>
<p style="margin: 0; font-size: 15px; line-height: 1.5;">Transform your ideas into professional tracks with cutting-edge AI technology</p>
</div>
<div class="feature-item">
<h4 style="color: #667eea; margin: 0 0 10px 0; font-size: 16px;">š§ Premium Library</h4>
<p style="margin: 0; font-size: 15px; line-height: 1.5;">Access thousands of high-quality tracks from talented artists worldwide</p>
</div>
<div class="feature-item">
<h4 style="color: #667eea; margin: 0 0 10px 0; font-size: 16px;">š„ Vibrant Community</h4>
<p style="margin: 0; font-size: 15px; line-height: 1.5;">Connect with fellow musicians, share your work, and get inspired</p>
</div>
<div class="feature-item">
<h4 style="color: #667eea; margin: 0 0 10px 0; font-size: 16px;">ā” Instant Access</h4>
<p style="margin: 0; font-size: 15px; line-height: 1.5;">Start creating immediately with our intuitive, powerful platform</p>
</div>
</div>
<div style="text-align: center; margin: 40px 0;">
<a href="https://soundstudiopro.com/dashboard.php" class="btn">šÆ Start Creating Now</a>
<a href="https://soundstudiopro.com/dashboard.php?tab=credits" class="btn">š° View My Credits</a>
</div>
<div style="background: #f8f9fa; padding: 25px; border-radius: 12px; margin: 30px 0; border-left: 4px solid #667eea;">
<h4 style="color: #667eea; margin: 0 0 15px 0; font-size: 18px;">šµ Your First Steps</h4>
<ol style="margin: 0; padding-left: 20px; font-size: 16px; line-height: 1.6;">
<li style="margin-bottom: 12px;">Explore our <strong>AI Music Generator</strong> to create your first track</li>
<li style="margin-bottom: 12px;">Browse our <strong>Premium Music Library</strong> for inspiration</li>
<li style="margin-bottom: 12px;">Join our <strong>Community</strong> to connect with other artists</li>
<li style="margin-bottom: 12px;">Share your creations and get feedback from the community</li>
</ol>
</div>
<p style="font-size: 16px; text-align: center; color: #667eea; font-weight: bold; margin: 30px 0;">Remember: Every great artist started with a single note. Your masterpiece is waiting to be created! š¼</p>
</div>
<div class="footer">
<h3 style="margin: 0 0 20px 0; color: #667eea;">Stay Connected</h3>
<div class="social-links">
<a href="https://soundstudiopro.com">š Website</a> |
<a href="mailto:support@soundstudiopro.com">š§ Support</a> |
<a href="https://soundstudiopro.com/community">š„ Community</a>
</div>
<p style="margin: 20px 0 0 0; font-size: 14px; color: #a0aec0;">
Thank you for choosing SoundStudioPro<br>
Your creative journey starts here! š
</p>
<p style="margin: 10px 0 0 0; font-size: 12px; color: #718096;">
Ā© 2025 SoundStudioPro.com - Empowering creators worldwide
</p>
</div>
</div>
</body>
</html>';
return [
'html' => $html,
'text' => "Welcome to SoundStudioPro!\n\nDear $user_name,\n\nš Welcome to Your Creative Sanctuary!\n\nWe're thrilled to have you as part of the SoundStudioPro family! You've taken the first step towards turning your musical dreams into reality.\n\nš Your Welcome Gift: $credits Credits are waiting for you!\n\n" . ($password ? "š Your Login Credentials:\nWebsite: https://soundstudiopro.com\nEmail: $user_email\nPassword: $password\n\nPlease save these credentials in a secure location.\n\n" : "") . "š What Awaits You:\n⢠AI-Powered Music Creation\n⢠Premium Music Library\n⢠Vibrant Community\n⢠Instant Access\n\nšµ Your First Steps:\n1. Explore our AI Music Generator\n2. Browse our Premium Music Library\n3. Join our Community\n4. Share your creations\n\nStart creating: https://soundstudiopro.com/dashboard.php\n\nRemember: Every great artist started with a single note. Your masterpiece is waiting to be created! š¼\n\nThank you for choosing SoundStudioPro!\nYour creative journey starts here! š",
'subject' => "š Welcome to SoundStudioPro.com - Your Musical Journey Begins!"
];
}
?>