Siteβ―Builder
Editing:
a-z.php
writable 0666
<?php // Load category JSON $jsonFile = __DIR__ . '/allcategories.json'; $categories = file_exists($jsonFile) ? json_decode(file_get_contents($jsonFile), true) : []; // Parse geo from GET, or default $country = isset($_GET['country']) ? preg_replace('/[^A-Za-z]/','',$_GET['country']) : 'USA'; $state = isset($_GET['state']) ? preg_replace('/[^A-Za-z]/','',$_GET['state']) : 'FL'; $city = isset($_GET['city']) ? preg_replace('/[^A-Za-z0-9\- ]/','',$_GET['city']) : 'Seminole'; // Category letter selection $letters = array_keys($categories); $letter = isset($_GET['letter']) && in_array($_GET['letter'], $letters) ? $_GET['letter'] : 'A'; // Helper: slugify (for business.php) function slugify($cat) { return strtolower(trim(preg_replace('/[^a-z0-9]+/i', '-', $cat), '-')); } // Helper: for city folder function city_folder($city) { return ucfirst(strtolower(str_replace(' ', '-', $city))); } $pageTitle = "Categories Starting with $letter - " . ucwords(str_replace('-', ' ', $city)) . ", $state"; $pageDesc = "Browse all business categories starting with $letter in " . ucwords(str_replace('-', ' ', $city)) . ", $state. Click any category to find local businesses or get listed!"; ?> <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title><?= htmlspecialchars($pageTitle) ?> | BestDealOn</title> <meta name="viewport" content="width=device-width, initial-scale=1"> <meta name="description" content="<?= htmlspecialchars($pageDesc) ?>"> <style> body { background: #f5f8fb; font-family: system-ui,Arial,sans-serif; margin:0; color:#095a76;} .main { max-width:1200px; margin:2.5em auto 1em; padding:0 1em;} h1 { text-align:center; font-size:2.3rem; color:#016285; margin-bottom:.5em; margin-top:0;} .aznav { text-align:center; margin-bottom:2em; font-size:1.22em; } .aznav a, .aznav strong { color:#014b85; text-decoration:none; font-weight:700; margin:0 .09em; display:inline-block;} .aznav a:hover { color:#e11e9c; text-decoration:underline;} .geoinfo { text-align:center; margin-bottom:.7em; } .geoinfo span { color:#045065; font-weight:500; } .catcols { display:flex; flex-wrap:wrap; gap:2em; justify-content:center; margin-top:1.6em; } .catcol { flex:1 1 240px; min-width:220px; max-width:350px;} .catcol ul { list-style:none; margin:0; padding:0; } .catcol li { margin-bottom:.38em; } .catcol a { color:#015c92; text-decoration:underline; font-size:1.05em;} .catcol a:hover { color:#ee2266; } @media(max-width:1000px){ .catcols{flex-direction:column; gap:.2em;} .catcol{max-width:none;} } @media(max-width:600px){ h1{font-size:1.26em;} .main{padding:0 .15em;} } .geo-bar { display:inline-block; background:#d7ebfd; border-radius:12px; padding:.5em 1.1em; font-size:.97em; font-weight:500; color:#015c92; margin:0 auto 1.5em auto;} .geobutton { background:#5b36ff; color:#fff; border:none; border-radius:6px; font-size:.98em; font-weight:600; padding:.36em 1em; margin-left:1.1em; cursor:pointer;} .geobutton:hover{background:#3b289b;} </style> <script> // Geolocate to set city/state/country via Nominatim function geolocateMe() { if (!navigator.geolocation) { alert("Geolocation not supported."); return; } document.getElementById('geo-status').textContent = 'Detecting...'; navigator.geolocation.getCurrentPosition(function(pos) { var lat = pos.coords.latitude, lon = pos.coords.longitude; fetch('https://nominatim.openstreetmap.org/reverse?format=json&lat='+lat+'&lon='+lon+'&zoom=10&addressdetails=1') .then(r=>r.json()) .then(j=>{ if(!j.address) return alert('Could not geolocate city/state.'); var city = j.address.city || j.address.town || j.address.village || j.address.hamlet || ''; var state = j.address.state || ''; var country = j.address.country_code ? j.address.country_code.toUpperCase() : 'USA'; if(city && state) { var url = window.location.pathname + '?country='+encodeURIComponent(country)+'&state='+encodeURIComponent(state)+'&city='+encodeURIComponent(city)+'&letter=A'; window.location = url; } else { alert('Could not detect both city and state.'); } }); }, function(){ alert("Geolocation failed."); }); } </script> </head> <body> <div class="main"> <h1>Categories Starting with <?= htmlspecialchars($letter) ?> - <?= ucwords(str_replace('-', ' ', $city)) ?>, <?= $state ?></h1> <div class="aznav"> <?php foreach(range('A','Z') as $az): ?> <?= ($az === $letter) ? "<strong>$az</strong>" : '<a href="?country='.urlencode($country).'&state='.urlencode($state).'&city='.urlencode($city).'&letter='.$az.'">'.$az.'</a>' ?> <?php endforeach; ?> </div> <div class="geoinfo"> <span class="geo-bar"> Current Location: <?= htmlspecialchars(ucwords(str_replace('-', ' ', $city))) ?>, <?= htmlspecialchars($state) ?>, <?= htmlspecialchars($country) ?> <button class="geobutton" onclick="geolocateMe()">Geolocate Me</button> </span> <span id="geo-status" style="color:#333;margin-left:.8em;"></span> </div> <?php // Three columns (auto) $colCount = 3; $cats = isset($categories[$letter]) ? $categories[$letter] : []; $num = count($cats); $perCol = ceil($num/$colCount); $chunks = array_chunk($cats, $perCol); // Build business.php link base $cityFolder = city_folder($city); $base = "/geo/$country/$state/$cityFolder/business.php?type="; ?> <div class="catcols"> <?php foreach($chunks as $col): ?> <div class="catcol"> <ul> <?php foreach($col as $cat): $slug = slugify($cat['name']); $href = $base . urlencode($slug); ?> <li><a href="<?= htmlspecialchars($href) ?>"><?= htmlspecialchars($cat['name']) ?></a></li> <?php endforeach; ?> </ul> </div> <?php endforeach; ?> </div> </div> </body> </html>
Save changes
Create folder
writable 0777
Create
Cancel