SiteโฏBuilder
Editing:
index.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) *************************************************************************/ 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 /* --- load helpers --------------------------------------------------- */ function json_safe($f, $def = []) { return (is_file($f) && ($j = json_decode(file_get_contents($f), true))) ? $j : $def; } /* --- merge global + local ------------------------------------------ */ $global = json_safe(GLOBAL_CFG); // array of {name,active,tier,file,...} $local = json_safe(LOCAL_CFG); $site = [ 'name' => $local['site_name'] ?? 'BestDealOn microsite', 'tier' => ($local['tier']??'free') === 'premium' ? 'premium':'free', 'hero' => $local['hero'] ?? [ 'heading' => 'Welcome!', 'sub' => 'Powered by BestDealOn', 'bg' => '#0066ff', 'fg' => '#ffffff' ] ]; /* --- build final module list --------------------------------------- */ $order = []; if (!empty($local['modules'])) { // honour local ordering first foreach ($local['modules'] as $m) $order[$m['name']] = $m; } foreach ($global as $g) { // add anything not overridden if (!isset($order[$g['name']])) $order[$g['name']] = $g; } /* final filter: tier + active flag */ $modules = []; foreach ($order as $m) { if (($m['active'] ?? false) !== true) continue; if (isset($m['tier']) && $m['tier']==='premium' && $site['tier']!=='premium') continue; $modules[] = $m; } ?> <!doctype html> <html lang="en"> <head> <meta charset="utf-8"> <title><?= htmlspecialchars($site['name']) ?></title> <meta name="viewport" content="width=device-width,initial-scale=1"> <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 /* --- include every module ------------------------------------------ */ foreach ($modules as $m) { $abs = MOD_ROOT . '/' . $m['relative_path']; if (is_file($abs)) { include $abs; // module outputs its own HTML } else { echo '<div class="mod-error">Missing module ' . htmlspecialchars($m['name']) . '</div>'; } } ?> </main> </body></html>
Save changes
Create folder
writable 0777
Create
Cancel