| Server IP : 172.67.201.108 / Your IP : 216.73.216.11 Web Server : Apache/2.4.68 (Amazon Linux) OpenSSL/3.5.5 System : Linux ip-172-31-69-123.ec2.internal 6.1.176-223.369.amzn2023.x86_64 #1 SMP PREEMPT_DYNAMIC Fri Jul 24 13:34:27 UTC 2026 x86_64 User : ec2-user ( 1000) PHP Version : 8.4.23 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : ON Directory : /home/banners/domains/stagemag/ |
Upload File : |
<?php
/**
* savethedate-image.php -- Save the Date social media image generator
* Converted from savethedate-image.php
*/
require_once __DIR__ . '/functions.php';
set_time_limit(120);
$size = $_GET['size'] ?? 'square';
$programid = (int)($_GET['programid'] ?? 0);
$label = $_GET['label'] ?? 'save-the-date';
$stmt = db_write()->prepare(
"SELECT * FROM stagemag.productions WHERE id = :id"
);
$stmt->execute([':id' => $programid]);
$geter = $stmt->fetch();
if (!$geter) {
echo '<p>Program not found.</p>';
exit;
}
// Defensive defaults for new STD columns
$std_include_dates = $geter['std_include_dates'] ?? 1;
$std_include_theatre = $geter['std_include_theatre'] ?? 1;
// Label text
$labelMap = [
'7-days' => '7 Days Away',
'3-days' => '3 Days Away',
'today' => "It's Today!",
'now-playing' => 'Now Playing',
'coming-soon' => 'Coming Soon',
];
$labelText = $labelMap[$label] ?? 'Save the Date';
// Dimensions
$sizeMap = [
'instagram-story' => [1080, 1920, 'Instagram Story'],
'square' => [1080, 1080, 'Instagram / Facebook Post'],
'facebook' => [1200, 630, 'Facebook / OG Image'],
'twitter' => [1200, 675, 'Twitter / X Post'],
];
[$imgWidth, $imgHeight, $sizeName] = $sizeMap[$size] ?? [1080, 1080, 'Square'];
// Logo overlay path
$logotype = $geter['logotype'] ?? '';
if (stripos($logotype, 'Regular') !== false) {
$logoFile = 'WhiteBkgd.png';
} elseif (stripos($logotype, 'Black') !== false && stripos($logotype, 'Transparent') !== false) {
$logoFile = 'TransparentBlack.png';
} elseif (stripos($logotype, 'Black') !== false) {
$logoFile = 'BlackBkgd.png';
} elseif (stripos($logotype, 'Transparent - White') !== false) {
$logoFile = 'TransparentWhite.png';
} else {
$logoFile = 'WhiteBkgd.png';
}
$safeTitle = htmlspecialchars($geter['productionname']);
$downloadName = str_replace(' ', '-', $geter['productionname']) . '-' . $label . '-' . $size . '.png';
// Date formatting
$startFormatted = '';
$endFormatted = '';
if (!empty($geter['startdate'])) {
$startFormatted = date('F j, Y', strtotime($geter['startdate']));
}
if (!empty($geter['enddate'])) {
$endFormatted = date('F j, Y', strtotime($geter['enddate']));
}
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title><?= $safeTitle ?> - <?= htmlspecialchars($labelText) ?> - <?= htmlspecialchars($sizeName) ?></title>
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Playfair+Display:wght@400;700;900&family=Raleway:wght@300;400;600;700&display=swap">
<script src="https://cdnjs.cloudflare.com/ajax/libs/html2canvas/1.4.1/html2canvas.min.js"></script>
<style>
* { margin: 0; padding: 0; box-sizing: border-box; }
body { background: #1a1a1a; font-family: Raleway, sans-serif; display: flex; flex-direction: column; align-items: center; padding: 20px; min-height: 100vh; }
.download-bar { background: #2a2a2a; border-radius: 8px; padding: 15px 25px; margin-bottom: 20px; display: flex; align-items: center; gap: 15px; max-width: 100%; }
.download-bar .info { color: #aaa; font-size: 14px; flex: 1; }
.download-bar .info strong { color: #fff; display: block; font-size: 16px; margin-bottom: 2px; }
.download-btn { background: #b20223; color: #fff; border: none; padding: 12px 28px; border-radius: 6px; font-size: 15px; font-weight: 600; cursor: pointer; font-family: Raleway, sans-serif; white-space: nowrap; }
.download-btn:hover { background: #8a011a; }
.download-btn:disabled { background: #666; cursor: wait; }
.canvas-wrapper { width: <?= $imgWidth ?>px; height: <?= $imgHeight ?>px; position: relative; overflow: hidden; flex-shrink: 0; border-radius: 4px; }
.canvas-wrapper .bg-image { position: absolute; top: 0; left: 0; width: 100%; height: 100%; object-fit: cover; }
.canvas-wrapper .logo-overlay { position: absolute; top: 0; left: 0; width: 100%; pointer-events: none; }
.canvas-wrapper .overlay { position: absolute; top: 0; left: 0; width: 100%; height: 100%; background: linear-gradient(180deg, rgba(0,0,0,0.05) 0%, rgba(0,0,0,0.25) 40%, rgba(0,0,0,0.8) 100%); }
.canvas-wrapper .content { position: absolute; bottom: 0; left: 0; right: 0; padding: 8%; color: #fff; text-align: center; }
.canvas-wrapper .show-title { font-family: 'Playfair Display', Georgia, serif; font-weight: 900; line-height: 1.1; margin-bottom: 20px; text-shadow: 0 2px 8px rgba(0,0,0,0.5); }
.canvas-wrapper .show-meta { font-family: Raleway, sans-serif; font-weight: 400; letter-spacing: 2px; text-transform: uppercase; opacity: 0.9; line-height: 1.6; }
.canvas-wrapper .show-meta .dates { font-weight: 600; }
.canvas-wrapper .show-meta .theatre { font-weight: 300; }
.canvas-wrapper .divider { width: 60px; height: 3px; background: #b20223; margin: 20px auto; border-radius: 2px; }
.canvas-wrapper .std-label { font-family: 'Playfair Display', Georgia, serif; font-style: italic; opacity: 0.7; margin-bottom: 15px; }
<?php if ($size === 'instagram-story'): ?>
.canvas-wrapper .show-title { font-size: 64px; }
.canvas-wrapper .show-meta { font-size: 22px; }
.canvas-wrapper .std-label { font-size: 28px; }
<?php elseif ($size === 'square'): ?>
.canvas-wrapper .show-title { font-size: 56px; }
.canvas-wrapper .show-meta { font-size: 20px; }
.canvas-wrapper .std-label { font-size: 24px; }
<?php elseif ($size === 'facebook' || $size === 'twitter'): ?>
.canvas-wrapper .show-title { font-size: 48px; }
.canvas-wrapper .show-meta { font-size: 18px; }
.canvas-wrapper .std-label { font-size: 20px; }
.canvas-wrapper .content { padding: 5% 8%; }
<?php endif; ?>
</style>
</head>
<body>
<div class="download-bar">
<div class="info">
<strong><?= htmlspecialchars($sizeName) ?> (<?= $imgWidth ?> × <?= $imgHeight ?>)</strong>
<?= $safeTitle ?>
</div>
<button class="download-btn" id="downloadBtn" onclick="downloadImage()">Download PNG</button>
</div>
<div class="canvas-wrapper" id="captureArea">
<img class="bg-image" src="https://cloudimages.broadwayworld.com/stagemag/<?= htmlspecialchars($geter['image']) ?>" crossorigin="anonymous" alt="">
<img class="logo-overlay" src="https://cloudimages.broadwayworld.com/stagemag/newlogos/<?= $logoFile ?>" crossorigin="anonymous" alt="">
<div class="overlay"></div>
<div class="content">
<div class="std-label"><?= htmlspecialchars($labelText) ?></div>
<div class="show-title"><?= $safeTitle ?></div>
<div class="divider"></div>
<div class="show-meta">
<?php if ($std_include_dates == 1 && $startFormatted !== ''): ?>
<div class="dates">
<?= $startFormatted ?><?php if ($endFormatted !== '') echo ' – ' . $endFormatted; ?>
</div>
<?php endif; ?>
<?php if ($std_include_theatre == 1 && !empty($geter['theatre'])): ?>
<div class="theatre"><?= htmlspecialchars($geter['theatre']) ?></div>
<?php endif; ?>
</div>
</div>
</div>
<script>
function downloadImage() {
var btn = document.getElementById('downloadBtn');
btn.disabled = true;
btn.textContent = 'Generating...';
var el = document.getElementById('captureArea');
html2canvas(el, {
useCORS: true,
allowTaint: false,
scale: 1,
width: <?= $imgWidth ?>,
height: <?= $imgHeight ?>,
logging: false
}).then(function(canvas) {
var link = document.createElement('a');
link.download = '<?= addslashes($downloadName) ?>';
link.href = canvas.toDataURL('image/png');
link.click();
btn.disabled = false;
btn.textContent = 'Download PNG';
}).catch(function(err) {
console.error('Download error:', err);
btn.disabled = false;
btn.textContent = 'Download PNG';
alert('There was an error generating the image. Try right-clicking the image to save instead.');
});
}
</script>
</body>
</html>