Site Builder
Editing:
profile-index.php
writable 0666
<?php /*-------------------------------------------------------------------- VIEW A SOCIAL PROFILE ------------------------------------------------------------------*/ declare(strict_types=1); define('SOCIAL_DIR', __DIR__ . '/social'); /* ---------- helpers ------------------------------------------------------- */ function load(string $slug): array { $file = SOCIAL_DIR . '/' . $slug . '/social.json'; if (!is_file($file)) { throw new RuntimeException("Profile @$slug not found."); } return json_decode(file_get_contents($file), true, flags: JSON_THROW_ON_ERROR); } /* ---------- bootstrap ----------------------------------------------------- */ $slug = preg_replace('/[^a-z0-9_]/i', '', ($_GET['user'] ?? '')); $error = ''; try { $p = load($slug); } catch (Throwable $e) { $error = $e->getMessage(); } ?> <!doctype html> <html lang="en"><head> <meta charset="utf-8"> <title><?= $error ? 'Profile not found' : $p['display_name'].' – Deals' ?></title> <style> body{font-family:sans-serif;max-width:35em;margin:2em auto} .card{border:1px solid #ddd;padding:1.5em;border-radius:6px} .premium{background:#fff8d9;border-color:#f0d264} </style> </head><body> <?php if ($error): ?> <h1><?= htmlspecialchars($error) ?></h1> <?php else: ?> <div class="card <?= $p['premium'] ? 'premium' : '' ?>"> <h1><?= htmlspecialchars($p['display_name'] ?: $p['handle']) ?></h1> <p><strong>Handle:</strong> <?= htmlspecialchars($p['handle']) ?></p> <?php if ($p['affiliate_url']): ?> <p><a href="<?= htmlspecialchars($p['affiliate_url']) ?>" target="_blank" rel="noopener"> Best deal link </a></p> <?php endif; ?> <?php if ($p['coupon_code']): ?> <p><strong>Coupon code:</strong> <code><?= htmlspecialchars($p['coupon_code']) ?></code></p> <?php endif; ?> <?php if (!empty($p['updated_at'])): ?> <p style="font-size:.85em;color:#666"> Updated <?= (new DateTime($p['updated_at']))->format('M j, Y H:i') ?> </p> <?php endif; ?> </div> <p style="margin-top:2em"> <a href="edit.php?user=<?= urlencode($slug) ?>">Edit this profile</a> </p> <?php endif; ?> </body></html>
Save changes
Create folder
writable 0777
Create
Cancel