Siteβ―Builder
Editing:
index.php
writable 0666
<?php /************************************************************************* * Generic microsite / landingβpage template (staticβcache edition) * © 2025Β BestDealOn β free to modify. *************************************************************************/ /* βββ 0. ultraβlight static cache βββββββββββββββββββββββββββββββββββ */ $cacheFile = __DIR__.'/index.cached.html'; if (!isset($_GET['rebuild']) && is_readable($cacheFile)) { readfile($cacheFile); return; } ob_start(); /* βββ 1. helpers & constants βββββββββββββββββββββββββββββββββββββββ */ require_once $_SERVER['DOCUMENT_ROOT'].'/pages/lib/helpers.php'; define('MOD_ROOT', $_SERVER['DOCUMENT_ROOT'].'/pages/modules'); define('GLOBAL_CFG', MOD_ROOT.'/modules.json'); define('LOCAL_CFG', __DIR__.'/config.json'); $profile = get_profile(); // socialΒ orΒ ph profile $local = json_safe(LOCAL_CFG); // may not exist /* βββ 2. core site settings & hero colours (unchanged) βββββββββββββ */ $site = [ 'name' => $local['site_name'] ?? ($profile['display_name'] ?? $profile['name'] ?? 'BestDealOn microsite'), 'tier' => ($local['tier'] ?? 'free') === 'premium' ? 'premium' : 'free', 'hero' => [ 'heading' => $profile['display_name'] ?? $profile['name'] ?? 'Welcome!', 'sub' => $profile['slogan'] ?? 'Powered by BestDealOn', 'bg' => $local['hero']['bg'] ?? '#5c3bff', 'fg' => $local['hero']['fg'] ?? '#ffffff' ] ]; /* βββ 3. SEO meta (unchanged) βββββββββββββββββββββββββββββββββββββββ */ $metaTitle = trim( ($profile['display_name'] ?? $profile['name'] ?? 'Profile') . (isset($profile['slogan']) ? ' | '.$profile['slogan'] : '') ); $metaDesc = substr(strip_tags($profile['description'] ?? ''), 0, 160); $metaKeywords = implode(', ', array_slice( array_merge($profile['tags'] ?? [], $profile['location_tags'] ?? []), 0, 20 )); /* βββ 4. MODULE LIST Β βΒ order + locks + tierΒ ββββββββββββββββββββββββ */ $gMods = is_readable(GLOBAL_CFG) ? json_safe(GLOBAL_CFG) : []; $globalByName = []; $adminActive = []; foreach ($gMods as $g) { $globalByName[$g['name']] = $g; $adminActive[$g['name']] = !empty($g['active']); // true = allowed } /* read user config rows (could be legacy or {"modules":[β¦]}) */ $localRows = []; if (is_array($local)) { $rows = $local['modules'] ?? $local; foreach ($rows as $row) { if (is_array($row) && isset($row['name'])) { $localRows[$row['name']] = $row; // keyed by name } } } /* determine display order */ $orderNames = array_keys($localRows); // user order first if (!$orderNames) $orderNames = array_keys($globalByName); foreach ($globalByName as $n => $_) // append any missing if (!in_array($n, $orderNames, true)) $orderNames[] = $n; /* merge + final filtering */ $modules = []; foreach ($orderNames as $name) { if (!isset($globalByName[$name])) continue; // skip rogue names $g = $globalByName[$name]; $u = $localRows[$name] ?? []; /* final active flag */ $userWants = isset($u['active']) ? !empty($u['active']) : !empty($g['active']); $isAllowed = $adminActive[$name] ?? true; $active = $isAllowed && $userWants; /* hide premium modules on free tier */ if (($g['tier'] ?? 'free') === 'premium' && $site['tier'] !== 'premium') $active = false; if ($active) { $modules[] = array_merge($g, $u); // keep metadata + user flags } } /* βββ 5. HTML Β (unchanged below) βββββββββββββββββββββββββββββββββββ */ ?> <!doctype html> <html lang="en"> <head> <meta charset="utf-8"> <title><?= htmlspecialchars($metaTitle ?: $site['name']) ?></title> <meta name="viewport" content="width=device-width,initial-scale=1"> <!-- Canonical & crawl --> <link rel="canonical" href="<?= 'https://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'] ?>"> <meta name="robots" content="index,follow,max-snippet:-1,max-image-preview:large"> <meta name="referrer" content="strict-origin-when-cross-origin"> <?php if ($metaDesc): ?> <meta name="description" content="<?= htmlspecialchars($metaDesc) ?>"> <?php endif; ?> <?php if ($metaKeywords): ?> <meta name="keywords" content="<?= htmlspecialchars($metaKeywords) ?>"> <?php endif; ?> <?php if (!empty($profile['lat']) && !empty($profile['lon'])): ?> <meta name="geo.position" content="<?= $profile['lat'] ?>;<?= $profile['lon'] ?>"> <meta name="ICBM" content="<?= $profile['lat'] ?>, <?= $profile['lon'] ?>"> <?php endif; ?> <?php if (!empty($profile['city']) || !empty($profile['state'])): ?> <meta name="geo.placename" content="<?= htmlspecialchars(trim(($profile['city']??'').', '.($profile['state']??''), ' ,')) ?>"> <?php endif; ?> <meta property="og:type" content="website"> <meta property="og:url" content="<?= 'https://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'] ?>"> <meta property="og:title" content="<?= htmlspecialchars($metaTitle) ?>"> <meta property="og:description" content="<?= htmlspecialchars($metaDesc) ?>"> <meta property="og:locale" content="en_US"> <meta name="twitter:card" content="summary"> <meta name="twitter:title" content="<?= htmlspecialchars($metaTitle) ?>"> <meta name="twitter:description" content="<?= htmlspecialchars($metaDesc) ?>"> <?php if (!empty($profile['email'])): ?> <meta name="reply-to" content="<?= htmlspecialchars($profile['email']) ?>"><?php endif; ?> <?php if (!empty($profile['phone'])): ?> <meta name="telephone" content="<?= htmlspecialchars($profile['phone']) ?>"><?php endif; ?> <?php if (!empty($profile['website'])): ?> <meta name="url" content="<?= htmlspecialchars($profile['website']) ?>"><?php endif; ?> <meta name="theme-color" content="#5c3bff"> <link rel="modulepreload" href="/socialPromptinator.js"> <style> /* ββ existing CSS left intact ββ */ :root{--violet1:#5c3bff;--violet2:#3b1ecf;--gold:#ffb63b;--fg-ribbon:#fff; font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica,Arial,sans-serif} body{margin:0;background:#f9fbff;color:#111;line-height:1.4;} main{max-width:960px;margin:2rem auto;padding:0 1rem;display:grid;gap:1.25rem} .mod-error{padding:1rem;border:2px dashed #c00;color:#c00;background:#fff5f5} /* hero, logo, badge β¦ unchanged */ .hero{position:relative;text-align:center;color:var(--fg-ribbon);padding:3rem 1rem 2.2rem; background:url("data:image/svg+xml,%3Csvg viewBox='0 0 120 6' xmlns='http://www.w3.org/2000/svg'%3E%3Ccircle cx='6' cy='3' r='1.2' fill='%23ffffff22'/%3E%3C/svg%3E") center/6px repeat, linear-gradient(120deg,var(--violet1) 0%,var(--violet2) 100%);background-blend-mode:screen} .hero h1{margin:.05em 0 .25em;font-size:2.4rem;font-weight:900; background:linear-gradient(90deg,#ffffff 0%,#e9e6ff 90%); -webkit-background-clip:text;-webkit-text-fill-color:transparent} .hero p{margin:.4em auto 0;font-size:1.15rem;font-weight:600;max-width:620px} .hero p::after{content:'';display:block;margin:.55rem auto 0;width:50%;height:.12rem;background:#ffe480;border-radius:2px;opacity:.8} .hero::after{content:'';position:absolute;inset:0;background:linear-gradient(to bottom,transparent 72%,rgba(0,0,0,.06));pointer-events:none} .logo{position:absolute;top:18px;left:22px;font-weight:900;letter-spacing:-.5px;text-decoration:none;font-size:1.35rem;line-height:1;z-index:3} .logo .b{color:#fff}.logo .d{color:#28d764}.logo .o{color:#ff3737} .badge{position:absolute;top:18px;right:22px;padding:.48em 1.2em;border-radius:999px;font-size:.83rem;font-weight:800; display:flex;align-items:center;gap:.45em;text-transform:uppercase} .badge-prem{background:linear-gradient(90deg,#ffd54d 0%,#ffea96 100%);color:#473400} .badge-free{background:#ffe0e0;color:#7d0000} @media(max-width:480px){.logo{left:14px;font-size:1.2rem}.badge{right:14px;font-size:.74rem;padding:.42em 1em}.hero{padding-top:90px}} </style> </head> <body> <header class="hero"> <a class="logo" href="/" aria-label="Best Deal On"> <span class="b">BEST </span><span class="d">DEAL </span><span class="o">ON</span> </a> <?php if ($profile['premium'] === 'on'): ?> <div class="badge badge-prem">β Β Premium Influencer</div> <?php else: ?> <div class="badge badge-free">Influencer</div> <?php endif; ?> <h1><?= htmlspecialchars($site['hero']['heading']) ?></h1> <p><?= htmlspecialchars($site['hero']['sub']) ?></p> </header> <main> <?php foreach ($modules as $m): ?> <?php $abs = MOD_ROOT.'/'.$m['relative_path']; if (is_file($abs)) { try { include $abs; } catch (Throwable $e) { error_log($e); echo '<div class="mod-error">Module β'.htmlspecialchars($m['name']).'β failed.</div>'; } } else { echo '<div class="mod-error">Missing module '.htmlspecialchars($m['name']).'</div>'; } ?> <?php endforeach; ?> </main> <div style="text-align:center;font-size:.9rem;margin:1.5rem 0 2.5rem;"> <a href="/members/dashboard.php">Dashboard</a>Β Β·Β <a href="?rebuild=1">β³Β Rebuild static cache</a>Β Β·Β <a href="index.cached.html" target="_blank">View cached HTML</a> </div> </body> </html> <?php /* βββ 6. save rendered output to static cache βββββββββββββββββββββββ */ $html = ob_get_contents(); ob_end_flush(); file_put_contents($cacheFile, $html, LOCK_EX); ?>
Save changes
Create folder
writable 0777
Create
Cancel