Siteβ―Builder
Editing:
index-2row.php
writable 0666
<?php /************************************************************************** * BUSINESS PROFILE INDEX β masonry edition β’ v7.0 (userβorder) * © 2025Β BestDealOn β free to modify. **************************************************************************/ declare(strict_types=1); require_once $_SERVER['DOCUMENT_ROOT'].'/pages/lib/helpers.php'; /* βββ profile & helpers (unchanged) βββ */ $profile = get_profile(); function h(string $s):string{return htmlspecialchars($s,ENT_QUOTES,'UTF-8');} function ss(string $st):string{return strtoupper(trim($st));} function cs(string $c):string {return strtolower(str_replace(' ','-',$c));} function fp(string $n):string{$d=preg_replace('/\D/','',$n); return strlen($d)===10?sprintf('(%s) %sβ%s',substr($d,0,3),substr($d,3,3),substr($d,6)):$n;} /* basic fields */ $name=$profile['display_name']??'Business'; $slogan=$profile['slogan']??''; $desc=$profile['description']??''; $addr=$profile['address']??''; $city=$profile['city']??''; $state=$profile['state']??''; $zip=$profile['zip']??''; $phone=$profile['phone']??''; $site=$profile['website']??''; $country='USA'; $stateslug=ss($state); $cityslug=cs($city); $metaTitle="$name in $city, $state | BestDealOn"; $metaDesc=$desc?:($slogan?:$name); $canonical="https://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']; /* βββββββββββββββββββββββββββββββββββββββββββββββ * MODULES REGISTRY β honours perβuser order + admin locks * βββββββββββββββββββββββββββββββββββββββββββββββ */ $root = $_SERVER['DOCUMENT_ROOT']; $modDir = "$root/pages/modules"; $gCfg = "$modDir/modules.json"; // global master $lCfg = __DIR__.'/config.json'; // perβprofile config $gMods = is_readable($gCfg) ? json_decode(file_get_contents($gCfg), true) : []; $globalByName = []; $adminActive = []; foreach ($gMods as $row) { $name = $row['name']; $globalByName[$name] = $row; $adminActive[$name] = !empty($row['active']); // true = allowed } /* STEPΒ 1Β βΒ read local config (could be newβstyle {"modules":[β¦]} or legacy) */ $localRaw = is_readable($lCfg) ? json_decode(file_get_contents($lCfg), true) : []; $localRows = []; if (is_array($localRaw)) { $rows = $localRaw['modules'] ?? $localRaw; foreach ($rows as $row) { if (is_array($row) && isset($row['name'])) { $localRows[$row['name']] = $row; // keyed by name } } } /* STEPΒ 2Β βΒ determine display order */ $orderNames = array_keys($localRows); // userβs order first if (!$orderNames) $orderNames = array_keys($globalByName); // fallback to global foreach ($globalByName as $n => $_) // append any missing if (!in_array($n, $orderNames, true)) $orderNames[] = $n; /* STEPΒ 3Β βΒ merge rows respecting admin lock */ $modules = []; foreach ($orderNames as $name) { if (!isset($globalByName[$name])) continue; // skip rogue names $g = $globalByName[$name]; $u = $localRows[$name] ?? []; $merged = array_merge($g, $u); // keep metadata /* final active flag: admin must allow + user must want */ $userWants = !empty($u['active']) || (!isset($u['active']) && !empty($g['active'])); $merged['active'] = ($adminActive[$name] ?? true) && $userWants; if ($merged['active']) $modules[] = $merged; // keep only actives } /* βββββββββββββββββββββββββββββββββββββββββββββββ */ ?> <!doctype html><html lang="en"><head> <meta charset="utf-8"> <title><?=h($metaTitle)?></title> <meta name="viewport" content="width=device-width,initial-scale=1"> <meta name="description" content="<?=h($metaDesc)?>"> <link rel="canonical" href="<?=h($canonical)?>"> <style> /* ββ existing CSS left intact ββ */ :root{--fg:#1b334a;--link:#2357d7; font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica,Arial,sans-serif;} body{margin:0;background:#f5f8fb;color:var(--fg);} .top-bar{display:flex;justify-content:space-between;align-items:center;flex-wrap:wrap; gap:.45rem;padding:.55rem 1rem;background:#eee;text-align:center} .logo{font-weight:900;letter-spacing:-.5px;color:var(--link);text-decoration:none} .breadcrumb a{color:var(--link);text-decoration:none}.breadcrumb span{margin:0 .25rem} .biz-card{max-width:680px;margin:2rem auto;background:#fff;border-radius:20px; box-shadow:0 2px 16px #dde3fa26;padding:2rem 1.4rem; display:grid;gap:1rem;grid-template-columns:1fr 1fr} .biz-card h1{grid-column:1/-1;font-size:1.7rem;color:#2c61d7;margin:.1em 0} .biz-card .slogan{grid-column:1/-1;color:#2e6eb0;font-style:italic;font-size:1.1rem} .field{display:flex;gap:.6rem}.label{font-weight:600;min-width:95px;color:#23487b} .value{color:#364868} @media(max-width:600px){.biz-card{grid-template-columns:1fr}.field{flex-direction:column}} .modules{column-width:340px;column-gap:.8rem;max-width:960px;margin:0 auto 1.2rem;padding:0 1rem} @media(min-width:1100px){.modules{column-width:440px}} .mod-card{display:inline-block;width:100%;margin:0 0 .8rem;padding:0;background:transparent; box-shadow:none;break-inside:avoid;} </style> </head><body> <!-- header --> <div class="top-bar"> <a class="logo" href="/">BESTΒ DEALΒ ON</a> <nav class="breadcrumb" aria-label="Breadcrumb"> <a href="/">Index</a><span>/</span> <a href="/geo/<?=h($country)?>/<?=h($stateslug)?>/"><?=h($stateslug)?></a><span>/</span> <?php if($city):?> <a href="/geo/<?=h($country)?>/<?=h($stateslug)?>/<?=h($cityslug)?>/"><?=h($city)?></a><span>/</span> <?php endif;?> <span><?=h($name)?></span> </nav> </div> <!-- business info --> <section class="biz-card"> <h1><?=h($name)?></h1> <?php if($slogan):?><div class="slogan"><?=h($slogan)?></div><?php endif;?> <?php if($addr||$city||$state||$zip):?> <div class="field"><span class="label">Address:</span><span class="value"> <?php if($addr) echo h($addr).'<br>'; ?> <?=h(trim(($city?$city.', ':'').$state.' '.$zip))?> </span></div> <?php endif;?> <?php if($phone):?> <div class="field"><span class="label">Phone:</span> <span class="value"><b><?=h(fp($phone))?></b></span></div> <?php endif;?> <?php if($site):?> <div class="field"><span class="label">Website:</span> <span class="value"><a href="<?=h($site)?>" target="_blank"><?=h($site)?></a></span></div> <?php endif;?> <?php if($desc):?> <div class="field" style="grid-column:1/-1"> <span class="value" style="line-height:1.4"><?=h($desc)?></span></div> <?php endif;?> </section> <!-- modules --> <main class="modules"> <?php foreach ($modules as $mod) { if (empty($mod['relative_path'])) continue; $abs = $modDir.'/'.$mod['relative_path']; if (!is_file($abs)) continue; echo "<section class='mod-card'>"; try { include $abs; } catch (Throwable $e) { echo '<p style="color:#c00">Module β'.h($mod['name']).'β failed.</p>'; } echo "</section>"; } ?> </main> </body></html>
Save changes
Create folder
writable 0777
Create
Cancel