Site Builder
Editing:
indexhhhh.php
writable 0666
<?php /************************************************************************* * Generic microsite / landing‑page template * ---------------------------------------- * • Drop next to profile.json / prompts.json / coupon.json … inside any * business or social folder. * • Requires /pages/modules/ with per‑module sub‑folders * and /pages/modules/modules.json (global registry) *************************************************************************/ /* ---------- helper bundle (caches JSON reads) ---------- */ require_once $_SERVER['DOCUMENT_ROOT'].'/pages/lib/helpers.php'; /* ---------- fall‑back JSON helper (unchanged) ---------- */ function json_safe($f, $def = []) { return (is_file($f) && ($j = json_decode(file_get_contents($f), true))) ? $j : $def; } /* ---------- constants ---------- */ define('MOD_ROOT', $_SERVER['DOCUMENT_ROOT'].'/pages/modules'); define('GLOBAL_CFG', MOD_ROOT.'/modules.json'); define('LOCAL_CFG', __DIR__.'/config.json'); define('SITE_DIR', __DIR__); // full absolute path, no trailing slash /* ---------- profile + local site config ---------- */ $profile = get_profile(); // cached by helpers.php $local = json_safe(LOCAL_CFG); $site = [ 'name' => $local['site_name'] ?? ($profile['display_name'] ?? 'BestDealOn microsite'), 'tier' => ($local['tier'] ?? 'free') === 'premium' ? 'premium' : 'free', 'hero' => $local['hero'] ?? [ 'heading' => $profile['display_name'] ?? 'Welcome!', 'sub' => $profile['slogan'] ?? 'Powered by BestDealOn', 'bg' => '#0066ff', 'fg' => '#ffffff' ] ]; /* ---------- meta tags (all text, no images) ---------- */ $metaTitle = trim(($profile['display_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 ) ); $lat = $profile['lat'] ?? ''; $lon = $profile['lon'] ?? ''; $geo = ($lat && $lon) ? "$lat;$lon" : ''; /* ---------- build final module list ---------- */ $global = json_safe(GLOBAL_CFG); // [{name,active,tier,…}] $localMods = $local['modules'] ?? []; $order = []; foreach ($localMods as $m) $order[$m['name']] = $m; // local priority foreach ($global as $g) if(!isset($order[$g['name']])) $order[$g['name']] = $g; $modules = []; foreach ($order as $m){ if (($m['active'] ?? false) !== true) continue; if (($m['tier'] ?? 'free') === 'premium' && $site['tier']!=='premium') continue; $modules[] = $m; } ?> <!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"> <?php if ($metaDesc): ?> <meta name="description" content="<?= htmlspecialchars($metaDesc) ?>"> <?php endif; ?> <?php if ($metaKeywords): ?> <meta name="keywords" content="<?= htmlspecialchars($metaKeywords) ?>"> <?php endif; ?> <?php if ($geo): ?> <meta name="geo.position" content="<?= $geo ?>"> <meta name="ICBM" content="<?= $geo ?>"> <?php endif; ?> <?php if (!empty($profile['city']) || !empty($profile['state'])): ?> <meta name="geo.placename" content="<?= htmlspecialchars(trim(($profile['city']??'').', '.($profile['state']??''), ' ,')) ?>"> <?php endif; ?> <!-- minimal OG / Twitter (text only) --> <meta property="og:type" content="website"> <meta property="og:title" content="<?= htmlspecialchars($metaTitle) ?>"> <meta property="og:description" content="<?= htmlspecialchars($metaDesc) ?>"> <meta property="og:url" content="<?= htmlspecialchars($_SERVER['REQUEST_URI'] ?? '') ?>"> <meta name="twitter:card" content="summary"> <meta name="twitter:title" content="<?= htmlspecialchars($metaTitle) ?>"> <meta name="twitter:description" content="<?= htmlspecialchars($metaDesc) ?>"> <link rel="modulepreload" href="/socialPromptinator.js"> <style> :root{ --hero-bg: <?= htmlspecialchars($site['hero']['bg']) ?>; --hero-fg: <?= htmlspecialchars($site['hero']['fg']) ?>; font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica,Arial,sans-serif; } body{margin:0;background:#f9fbff;color:#111} .hero{background:var(--hero-bg);color:var(--hero-fg);padding:2.8rem 1rem;text-align:center} .hero h1{margin:0;font-size:2.3rem} .hero p {margin:.8rem auto 0;font-size:1.1rem;max-width:560px} main{max-width:960px;margin:2rem auto;padding:0 1rem;display:grid;gap:2rem} .mod-error{padding:1rem;border:2px dashed #c00;color:#c00;background:#fff5f5} </style> </head> <body> <header class="hero"> <h1><?= htmlspecialchars($site['hero']['heading']) ?></h1> <p><?= htmlspecialchars($site['hero']['sub']) ?></p> </header> <main> <?php foreach ($modules as $m){ $abs = MOD_ROOT.'/'.$m['relative_path']; if (is_file($abs)) { try { include $abs; } catch (Throwable $e) { error_log($e); // keep trace in php‑error.log echo '<div class="mod-error">Module “'.htmlspecialchars($m['name']) .'” failed.</div>'; } } else { echo '<div class="mod-error">Missing module ' . htmlspecialchars($m['name']).'</div>'; } } ?> </main> </body> </html>
Save changes
Create folder
writable 0777
Create
Cancel