searchbarFunctional

This commit is contained in:
Flatlogic Bot 2026-01-08 20:14:31 +00:00
parent 9d87d07945
commit c1e9d05209
8 changed files with 395 additions and 149 deletions

172
assets/css/custom.css Normal file
View File

@ -0,0 +1,172 @@
/*
* Verified Local Directory - Custom Stylesheet
* Palette:
* - Primary Accent: #2E7D32
* - Secondary Accent: #4CAF50
* - Background: #1B262C
* - Surface: #223038
* - Text: #F0F0F0
*/
body {
background-color: #1B262C;
color: #F0F0F0;
font-family: 'Open Sans', 'Helvetica Neue', Arial, sans-serif;
}
h1, h2, h3, h4, h5, h6 {
font-family: 'Roboto', 'Helvetica Neue', Arial, sans-serif;
}
a {
color: #4CAF50;
}
a:hover {
color: #66bb6a;
}
.navbar {
background-color: #223038;
}
.hero-section {
padding: 100px 0;
text-align: center;
background: linear-gradient(rgba(46, 125, 50, 0.1), transparent);
}
.hero-section h1 {
font-size: 3.5rem;
font-weight: 700;
margin-bottom: 30px;
}
.search-bar {
max-width: 600px;
margin: auto;
}
.search-bar .form-control {
height: 58px;
border-radius: 30px;
padding-left: 25px;
border: none;
}
.search-bar .btn {
height: 58px;
border-radius: 30px;
padding: 0 30px;
background-color: #2E7D32;
color: #fff;
border: none;
}
.search-bar .btn:hover {
background-color: #388e3c;
}
.categories-section {
padding: 60px 0;
}
.category-card {
background-color: #223038;
border-radius: 8px;
text-align: center;
padding: 30px 20px;
transition: transform 0.3s ease, box-shadow 0.3s ease;
border: 1px solid transparent;
}
.category-card:hover {
transform: translateY(-5px);
box-shadow: 0 10px 20px rgba(0,0,0,0.2);
border-color: #2E7D32;
}
.category-card .icon {
font-size: 3rem;
color: #4CAF50;
margin-bottom: 15px;
}
.category-card h5 {
font-size: 1.25rem;
margin: 0;
color: #F0F0F0;
}
.footer {
padding: 20px 0;
background-color: #223038;
text-align: center;
margin-top: 40px;
}
/* Search Results Page */
.search-results-section {
padding: 60px 0;
background-color: #1B262C;
color: #F0F0F0;
min-height: 80vh;
}
.listing-card {
background-color: #223038;
border: 1px solid #3c4d58;
border-radius: 8px;
transition: transform 0.3s, box-shadow 0.3s;
height: 100%;
display: flex;
flex-direction: column;
}
.listing-card:hover {
transform: translateY(-5px);
box-shadow: 0 10px 20px rgba(0, 0, 0, 0.2);
}
.listing-card .card-body {
padding: 1.5rem;
flex-grow: 1;
}
.listing-card .card-title {
color: #F0F0F0;
font-weight: 700;
}
.listing-card .card-subtitle {
color: #a0b3c1;
}
.listing-card ul {
padding-left: 0;
list-style: none;
margin-top: 1rem;
}
.listing-card ul li {
margin-bottom: 0.5rem;
color: #a0b3c1;
display: flex;
align-items: center;
}
.listing-card ul i {
color: #4CAF50;
margin-right: 0.75rem;
font-size: 1.2rem;
}
.listing-card a {
color: #66bb6a;
text-decoration: none;
transition: color 0.3s;
}
.listing-card a:hover {
color: #ffffff;
}

View File

@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" width="100" height="100" viewBox="0 0 24 24" fill="none" stroke="#4CAF50" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="11" cy="11" r="8"></circle><line x1="21" y1="21" x2="16.65" y2="16.65"></line><line x1="11" y1="8" x2="11" y2="14"></line><line x1="8" y1="11" x2="14" y2="11"></line></svg>

After

Width:  |  Height:  |  Size: 362 B

0
assets/js/main.js Normal file
View File

View File

@ -0,0 +1,21 @@
CREATE TABLE IF NOT EXISTS listings (
id INT AUTO_INCREMENT PRIMARY KEY,
name VARCHAR(255) NOT NULL,
description TEXT,
category VARCHAR(100),
address VARCHAR(255),
phone VARCHAR(20),
website VARCHAR(255),
is_verified BOOLEAN DEFAULT FALSE,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);
-- Insert sample data
INSERT INTO listings (name, description, category, address, phone, website, is_verified) VALUES
('Green Leaf Cafe', 'A cozy cafe with organic coffee and homemade pastries.', 'Restaurants', '123 Main St, Anytown, USA', '555-1234', 'http://greenleafcafe.com', TRUE),
('QuickFix Plumbers', '24/7 emergency plumbing services.', 'Plumbers', '456 Oak Ave, Anytown, USA', '555-5678', 'http://quickfixplumbers.com', TRUE),
('The Cutting Edge', 'Modern hair salon for men and women.', 'Salons', '789 Pine Ln, Anytown, USA', '555-9012', 'http://thecuttingedge.com', FALSE),
('AutoCare Experts', 'Complete auto repair and maintenance services.', 'Auto Repair', '101 Maple Dr, Anytown, USA', '555-3456', 'http://autocareexperts.com', TRUE),
('Paws & Claws', 'Veterinary clinic and pet supply store.', 'Veterinarians', '212 Birch Rd, Anytown, USA', '555-7890', 'http://pawsandclaws.com', TRUE),
('Builder Bros.', 'Residential and commercial construction services.', 'Construction', '333 Elm St, Anytown, USA', '555-2345', 'http://builderbros.com', FALSE);

14
includes/footer.php Normal file
View File

@ -0,0 +1,14 @@
<!-- Footer -->
<footer class="footer">
<div class="container">
<p class="mb-0">&copy; <?php echo date("Y"); ?> <?php echo $projectName; ?>. All Rights Reserved.</p>
</div>
</footer>
<!-- Bootstrap JS -->
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js"></script>
<!-- Custom JS with cache-busting -->
<script src="assets/js/main.js?v=<?php echo time(); ?>"></script>
</body>
</html>

50
includes/header.php Normal file
View File

@ -0,0 +1,50 @@
<?php
// Default project details if not set in environment
$projectName = htmlspecialchars(getenv('PROJECT_NAME') ?: 'Verified Local Directory');
$projectDescription = htmlspecialchars(getenv('PROJECT_DESCRIPTION') ?: 'A searchable, vetted directory of local businesses and professionals.');
$projectImageUrl = htmlspecialchars(getenv('PROJECT_IMAGE_URL') ?: 'assets/images/og_image.jpg'); // A default image
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title><?php echo $projectName; ?> - Find Trusted Local Businesses</title>
<!-- SEO and Meta Tags -->
<meta name="description" content="<?php echo $projectDescription; ?>">
<meta name="robots" content="index, follow">
<!-- Open Graph / Facebook -->
<meta property="og:type" content="website">
<meta property="og:title" content="<?php echo $projectName; ?>">
<meta property="og:description" content="<?php echo $projectDescription; ?>">
<meta property="og:image" content="<?php echo $projectImageUrl; ?>">
<!-- Twitter -->
<meta property="twitter:card" content="summary_large_image">
<meta property="twitter:title" content="<?php echo $projectName; ?>">
<meta property="twitter:description" content="<?php echo $projectDescription; ?>">
<meta property="twitter:image" content="<?php echo $projectImageUrl; ?>">
<!-- Bootstrap CSS -->
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet">
<!-- Bootstrap Icons -->
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.3/font/bootstrap-icons.min.css">
<!-- Google Fonts -->
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Open+Sans:wght@400;700&family=Roboto:wght@700&display=swap" rel="stylesheet">
<!-- Custom CSS with cache-busting -->
<link rel="stylesheet" href="assets/css/custom.css?v=<?php echo time(); ?>">
</head>
<body>
<!-- Header -->
<nav class="navbar navbar-expand-lg navbar-dark">
<div class="container">
<a class="navbar-brand fw-bold" href="index.php"><?php echo $projectName; ?></a>
</div>
</nav>

192
index.php
View File

@ -1,150 +1,52 @@
<?php <?php require_once 'includes/header.php'; ?>
declare(strict_types=1);
@ini_set('display_errors', '1');
@error_reporting(E_ALL);
@date_default_timezone_set('UTC');
$phpVersion = PHP_VERSION; <!-- Hero Section -->
$now = date('Y-m-d H:i:s'); <section class="hero-section">
?> <div class="container">
<!doctype html> <div class="row">
<html lang="en"> <div class="col-lg-8 mx-auto">
<head> <h1>Find Trusted Local Services</h1>
<meta charset="utf-8" /> <p class="lead mb-5">Your one-stop directory for vetted and verified local businesses.</p>
<meta name="viewport" content="width=device-width, initial-scale=1" /> <div class="search-bar">
<title>New Style</title> <form action="search.php" method="get">
<div class="input-group">
<input type="text" name="q" class="form-control" placeholder="Search for plumbers, restaurants, salons..." aria-label="Search">
<button class="btn" type="submit"><i class="bi bi-search"></i></button>
</div>
</form>
</div>
</div>
</div>
</div>
</section>
<!-- Categories Section -->
<section class="categories-section">
<div class="container">
<h2 class="text-center mb-5">Browse Categories</h2>
<div class="row g-4">
<?php <?php
// Read project preview data from environment $categories = [
$projectDescription = $_SERVER['PROJECT_DESCRIPTION'] ?? ''; ['name' => 'Restaurants', 'icon' => 'bi-cup-hot-fill'],
$projectImageUrl = $_SERVER['PROJECT_IMAGE_URL'] ?? ''; ['name' => 'Plumbers', 'icon' => 'bi-wrench-adjustable-circle-fill'],
['name' => 'Salons', 'icon' => 'bi-scissors'],
['name' => 'Auto Repair', 'icon' => 'bi-car-front-fill'],
['name' => 'Home Services', 'icon' => 'bi-house-heart-fill'],
['name' => 'Pet Grooming', 'icon' => 'bi-heart-pulse-fill'], // Using a different icon as a placeholder
];
foreach ($categories as $category):
?> ?>
<?php if ($projectDescription): ?> <div class="col-6 col-md-4 col-lg-2">
<!-- Meta description --> <a href="#" class="text-decoration-none">
<meta name="description" content='<?= htmlspecialchars($projectDescription) ?>' /> <div class="category-card">
<!-- Open Graph meta tags --> <div class="icon"><i class="bi <?php echo $category['icon']; ?>"></i></div>
<meta property="og:description" content="<?= htmlspecialchars($projectDescription) ?>" /> <h5><?php echo $category['name']; ?></h5>
<!-- Twitter meta tags -->
<meta property="twitter:description" content="<?= htmlspecialchars($projectDescription) ?>" />
<?php endif; ?>
<?php if ($projectImageUrl): ?>
<!-- Open Graph image -->
<meta property="og:image" content="<?= htmlspecialchars($projectImageUrl) ?>" />
<!-- Twitter image -->
<meta property="twitter:image" content="<?= htmlspecialchars($projectImageUrl) ?>" />
<?php endif; ?>
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;700&display=swap" rel="stylesheet">
<style>
:root {
--bg-color-start: #6a11cb;
--bg-color-end: #2575fc;
--text-color: #ffffff;
--card-bg-color: rgba(255, 255, 255, 0.01);
--card-border-color: rgba(255, 255, 255, 0.1);
}
body {
margin: 0;
font-family: 'Inter', sans-serif;
background: linear-gradient(45deg, var(--bg-color-start), var(--bg-color-end));
color: var(--text-color);
display: flex;
justify-content: center;
align-items: center;
min-height: 100vh;
text-align: center;
overflow: hidden;
position: relative;
}
body::before {
content: '';
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-image: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="100" height="100" viewBox="0 0 100 100"><path d="M-10 10L110 10M10 -10L10 110" stroke-width="1" stroke="rgba(255,255,255,0.05)"/></svg>');
animation: bg-pan 20s linear infinite;
z-index: -1;
}
@keyframes bg-pan {
0% { background-position: 0% 0%; }
100% { background-position: 100% 100%; }
}
main {
padding: 2rem;
}
.card {
background: var(--card-bg-color);
border: 1px solid var(--card-border-color);
border-radius: 16px;
padding: 2rem;
backdrop-filter: blur(20px);
-webkit-backdrop-filter: blur(20px);
box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.1);
}
.loader {
margin: 1.25rem auto 1.25rem;
width: 48px;
height: 48px;
border: 3px solid rgba(255, 255, 255, 0.25);
border-top-color: #fff;
border-radius: 50%;
animation: spin 1s linear infinite;
}
@keyframes spin {
from { transform: rotate(0deg); }
to { transform: rotate(360deg); }
}
.hint {
opacity: 0.9;
}
.sr-only {
position: absolute;
width: 1px; height: 1px;
padding: 0; margin: -1px;
overflow: hidden;
clip: rect(0, 0, 0, 0);
white-space: nowrap; border: 0;
}
h1 {
font-size: 3rem;
font-weight: 700;
margin: 0 0 1rem;
letter-spacing: -1px;
}
p {
margin: 0.5rem 0;
font-size: 1.1rem;
}
code {
background: rgba(0,0,0,0.2);
padding: 2px 6px;
border-radius: 4px;
font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
footer {
position: absolute;
bottom: 1rem;
font-size: 0.8rem;
opacity: 0.7;
}
</style>
</head>
<body>
<main>
<div class="card">
<h1>Analyzing your requirements and generating your website…</h1>
<div class="loader" role="status" aria-live="polite" aria-label="Applying initial changes">
<span class="sr-only">Loading…</span>
</div> </div>
<p class="hint"><?= ($_SERVER['HTTP_HOST'] ?? '') === 'appwizzy.com' ? 'AppWizzy' : 'Flatlogic' ?> AI is collecting your requirements and applying the first changes.</p> </a>
<p class="hint">This page will update automatically as the plan is implemented.</p>
<p>Runtime: PHP <code><?= htmlspecialchars($phpVersion) ?></code> — UTC <code><?= htmlspecialchars($now) ?></code></p>
</div> </div>
</main> <?php endforeach; ?>
<footer> </div>
Page updated: <?= htmlspecialchars($now) ?> (UTC) </div>
</footer> </section>
</body>
</html> <?php require_once 'includes/footer.php'; ?>

86
search.php Normal file
View File

@ -0,0 +1,86 @@
<?php
require_once 'includes/header.php';
require_once 'db/config.php';
$query = $_GET['q'] ?? '';
$results = [];
if (!empty($query)) {
try {
$db = db();
$stmt = $db->prepare(
'SELECT * FROM listings WHERE (name LIKE :query OR description LIKE :query OR category LIKE :query) AND is_verified = 1'
);
$stmt->bindValue(':query', '%' . $query . '%');
$stmt->execute();
$results = $stmt->fetchAll();
} catch (PDOException $e) {
// In a real application, log this error instead of displaying it.
error_log('Search query failed: ' . $e->getMessage());
// Optionally, set a user-friendly error message.
$error_message = "Sorry, we couldn't perform the search at this time. Please try again later.";
}
}
?>
<section class="search-results-section">
<div class="container">
<h1 class="mb-4">Search Results</h1>
<div class="row">
<div class="col-lg-8 mx-auto">
<div class="search-bar mb-5">
<form action="search.php" method="get">
<div class="input-group">
<input type="text" name="q" class="form-control" placeholder="Search again..." value="<?php echo htmlspecialchars($query); ?>" aria-label="Search">
<button class="btn" type="submit"><i class="bi bi-search"></i></button>
</div>
</form>
</div>
</div>
</div>
<?php if (isset($error_message)): ?>
<div class="alert alert-danger text-center">
<?php echo $error_message; ?>
</div>
<?php elseif (!empty($query)): ?>
<?php if (count($results) > 0): ?>
<p class="text-center mb-4">Found <?php echo count($results); ?> verified listing(s) matching your search.</p>
<div class="row g-4">
<?php foreach ($results as $listing): ?>
<div class="col-md-6 col-lg-4">
<div class="listing-card">
<div class="card-body">
<h5 class="card-title"><?php echo htmlspecialchars($listing['name']); ?></h5>
<h6 class="card-subtitle mb-2 text-muted"><?php echo htmlspecialchars($listing['category']); ?></h6>
<p class="card-text"><?php echo htmlspecialchars($listing['description']); ?></p>
<ul class="list-unstyled">
<?php if ($listing['address']): ?>
<li><i class="bi bi-geo-alt-fill"></i> <?php echo htmlspecialchars($listing['address']); ?></li>
<?php endif; ?>
<?php if ($listing['phone']): ?>
<li><i class="bi bi-telephone-fill"></i> <?php echo htmlspecialchars($listing['phone']); ?></li>
<?php endif; ?>
<?php if ($listing['website']): ?>
<li><i class="bi bi-globe"></i> <a href="<?php echo htmlspecialchars($listing['website']); ?>" target="_blank" rel="noopener noreferrer">Visit Website</a></li>
<?php endif; ?>
</ul>
</div>
</div>
</div>
<?php endforeach; ?>
</div>
<?php else: ?>
<div class="text-center">
<img src="assets/images/no_results.svg" alt="No Results Found" style="max-width: 200px;" class="mb-3">
<h4>No Verified Listings Found</h4>
<p>We couldn't find any verified businesses matching "<?php echo htmlspecialchars($query); ?>".</p>
<p>Try searching for something else or browse our categories.</p>
</div>
<?php endif; ?>
<?php endif; ?>
</div>
</section>
<?php require_once 'includes/footer.php'; ?>